Pick some low-hanging const fruit

Makes more of the code const-correct; there are still plenty of difficult-to-fix const problems left.
No behavior change expected.
This commit is contained in:
Larry Doolittle 2014-05-28 09:25:50 -07:00 committed by Cary R
parent 35a8485a44
commit 855bf9cfe8
9 changed files with 12 additions and 11 deletions

View File

@ -231,7 +231,7 @@ static void show_property_expression(ivl_expr_t net, unsigned ind)
{ {
ivl_signal_t sig = ivl_expr_signal(net); ivl_signal_t sig = ivl_expr_signal(net);
const char* pnam = ivl_expr_name(net); const char* pnam = ivl_expr_name(net);
char*signed_flag = ivl_expr_signed(net)? "signed" : "unsigned"; const char*signed_flag = ivl_expr_signed(net)? "signed" : "unsigned";
if (ivl_expr_value(net) == IVL_VT_REAL) { if (ivl_expr_value(net) == IVL_VT_REAL) {
fprintf(out, "%*s<property base=%s, prop=%s, real>\n", ind, "", fprintf(out, "%*s<property base=%s, prop=%s, real>\n", ind, "",

View File

@ -401,7 +401,7 @@ static unsigned calc_can_skip_unsigned(ivl_expr_t oper1, ivl_expr_t oper2)
static void emit_expr_binary(ivl_scope_t scope, ivl_expr_t expr, unsigned wid, static void emit_expr_binary(ivl_scope_t scope, ivl_expr_t expr, unsigned wid,
unsigned is_full_prec) unsigned is_full_prec)
{ {
char *oper = "<invalid>"; const char *oper = "<invalid>";
ivl_expr_t oper1 = ivl_expr_oper1(expr); ivl_expr_t oper1 = ivl_expr_oper1(expr);
ivl_expr_t oper2 = ivl_expr_oper2(expr); ivl_expr_t oper2 = ivl_expr_oper2(expr);
unsigned can_skip_unsigned = calc_can_skip_unsigned(oper1, oper2); unsigned can_skip_unsigned = calc_can_skip_unsigned(oper1, oper2);
@ -976,7 +976,7 @@ static void emit_expr_ternary(ivl_scope_t scope, ivl_expr_t expr, unsigned wid,
static void emit_expr_unary(ivl_scope_t scope, ivl_expr_t expr, unsigned wid, static void emit_expr_unary(ivl_scope_t scope, ivl_expr_t expr, unsigned wid,
unsigned is_full_prec) unsigned is_full_prec)
{ {
char *oper = "invalid"; const char *oper = "invalid";
ivl_expr_t oper1 = ivl_expr_oper1(expr); ivl_expr_t oper1 = ivl_expr_oper1(expr);
switch (ivl_expr_opcode(expr)) { switch (ivl_expr_opcode(expr)) {
case '-': oper = "-"; break; case '-': oper = "-"; break;

View File

@ -24,7 +24,7 @@
const char *func_rtn_name = 0; const char *func_rtn_name = 0;
static char*get_time_const(int time_value) static const char*get_time_const(int time_value)
{ {
switch (time_value) { switch (time_value) {
case 2: return "100s"; case 2: return "100s";

View File

@ -408,7 +408,8 @@ static void emit_assign_and_opt_opcode(ivl_scope_t scope, ivl_statement_t stmt,
unsigned allow_opcode) unsigned allow_opcode)
{ {
unsigned wid; unsigned wid;
char opcode, *opcode_str; char opcode;
const char *opcode_str;
assert (ivl_statement_type(stmt) == IVL_ST_ASSIGN); assert (ivl_statement_type(stmt) == IVL_ST_ASSIGN);
// HERE: Do we need to calculate the width? The compiler should have already // HERE: Do we need to calculate the width? The compiler should have already
@ -941,7 +942,7 @@ static void emit_stmt_block_named(ivl_scope_t scope, ivl_statement_t stmt)
static void emit_stmt_case(ivl_scope_t scope, ivl_statement_t stmt) static void emit_stmt_case(ivl_scope_t scope, ivl_statement_t stmt)
{ {
char *case_type; const char *case_type;
unsigned idx, default_case, count = ivl_stmt_case_count(stmt); unsigned idx, default_case, count = ivl_stmt_case_count(stmt);
switch (ivl_statement_type(stmt)) { switch (ivl_statement_type(stmt)) {
case IVL_ST_CASE: case IVL_ST_CASE:

View File

@ -30,7 +30,7 @@ static void show_prop_type_vector(ivl_type_t ptype)
unsigned packed_dimensions = ivl_type_packed_dimensions(ptype); unsigned packed_dimensions = ivl_type_packed_dimensions(ptype);
assert(packed_dimensions < 2); assert(packed_dimensions < 2);
char*signed_flag = ivl_type_signed(ptype)? "s" : ""; const char*signed_flag = ivl_type_signed(ptype)? "s" : "";
char code = data_type==IVL_VT_BOOL? 'b' : 'L'; char code = data_type==IVL_VT_BOOL? 'b' : 'L';
if (packed_dimensions == 0) { if (packed_dimensions == 0) {

View File

@ -230,7 +230,7 @@ static void str_repeat(char*buf, const char*str, unsigned rpt)
* If the drive strength is strong we can draw a C4<> constant as the * If the drive strength is strong we can draw a C4<> constant as the
* pull value, otherwise we need to draw a C8<> constant. * pull value, otherwise we need to draw a C8<> constant.
*/ */
static char* draw_net_pull(ivl_net_logic_t lptr, ivl_drive_t drive, char*level) static char* draw_net_pull(ivl_net_logic_t lptr, ivl_drive_t drive, const char*level)
{ {
char*result; char*result;
char tmp[32]; char tmp[32];

View File

@ -1804,7 +1804,7 @@ static int sfunc_has_modpath_output(ivl_lpm_t lptr)
static void draw_sfunc_output_def(ivl_lpm_t net, char type) static void draw_sfunc_output_def(ivl_lpm_t net, char type)
{ {
ivl_nexus_t nex = ivl_lpm_q(net); ivl_nexus_t nex = ivl_lpm_q(net);
char *suf = (type == 'd') ? "/d" : ""; const char *suf = (type == 'd') ? "/d" : "";
switch (data_type_of_nexus(nex)) { switch (data_type_of_nexus(nex)) {
case IVL_VT_REAL: case IVL_VT_REAL:

View File

@ -102,7 +102,7 @@ static PLI_INT32 sys_countdrivers_compiletf(ICARUS_VPI_CONST PLI_BYTE8 *name)
/* The optional arguments must be variables. */ /* The optional arguments must be variables. */
for (arg_num = 2; arg_num < 7; arg_num += 1) { for (arg_num = 2; arg_num < 7; arg_num += 1) {
char *arg_name = NULL; const char *arg_name = NULL;
switch (arg_num) { switch (arg_num) {
case 2: arg_name = "second"; break; case 2: arg_name = "second"; break;
case 3: arg_name = "third"; break; case 3: arg_name = "third"; break;

View File

@ -587,7 +587,7 @@ static unsigned check_numeric_args(vpiHandle argv, unsigned count,
/* Check that the first count arguments are numeric. Currently /* Check that the first count arguments are numeric. Currently
* only three are needed/supported. */ * only three are needed/supported. */
for (idx = 0; idx < count; idx += 1) { for (idx = 0; idx < count; idx += 1) {
char *loc = NULL; const char *loc = NULL;
vpiHandle arg = vpi_scan(argv); vpiHandle arg = vpi_scan(argv);
/* Get the name for this argument. */ /* Get the name for this argument. */