From: ceriel Date: Mon, 23 Jan 1989 15:37:57 +0000 (+0000) Subject: evaluate switch-expression on a different spot, X-Git-Tag: release-5-5~2675 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=cc55ab947d7ff493e4177f7e13bb32f91dfcc644;p=ack.git evaluate switch-expression on a different spot, allow for *STRING expressions --- diff --git a/lang/cem/cemcom/ch7mon.c b/lang/cem/cemcom/ch7mon.c index a5a3ad17b..cff0b8053 100644 --- a/lang/cem/cemcom/ch7mon.c +++ b/lang/cem/cemcom/ch7mon.c @@ -40,7 +40,7 @@ ch7mon(oper, expp) } else { expr = *expp; - if (expr->ex_lvalue == 0) + if (expr->ex_lvalue == 0 && expr->ex_class != String) /* dereference in administration only */ expr->ex_type = expr->ex_type->tp_up; else /* runtime code */ diff --git a/lang/cem/cemcom/eval.c b/lang/cem/cemcom/eval.c index 04264e1a0..aa32e8464 100644 --- a/lang/cem/cemcom/eval.c +++ b/lang/cem/cemcom/eval.c @@ -198,8 +198,12 @@ EVAL(expr, val, code, true_label, false_label) } break; case '*': - if (left == 0) /* unary */ + if (left == 0) { /* unary */ EVAL(right, RVAL, gencode, NO_LABEL, NO_LABEL); + if (gencode && right->ex_class == String) { + C_loi((arith)1); + } + } else { /* binary */ EVAL(left, RVAL, gencode, NO_LABEL, NO_LABEL); EVAL(right, RVAL, gencode, NO_LABEL, NO_LABEL); diff --git a/lang/cem/cemcom/switch.c b/lang/cem/cemcom/switch.c index bfc40ce49..859766ce0 100644 --- a/lang/cem/cemcom/switch.c +++ b/lang/cem/cemcom/switch.c @@ -79,10 +79,9 @@ code_startswitch(expp) sh->sh_type = (*expp)->ex_type; /* the expression switched */ sh->sh_lowerbd = sh->sh_upperbd = (arith)0; /* immaterial ??? */ sh->sh_entries = (struct case_entry *) 0; /* case-entry list */ + sh->sh_expr = *expp; sh->next = switch_stack; /* push onto switch-stack */ switch_stack = sh; - /* evaluate the switch expr. */ - code_expr(*expp, RVAL, TRUE, NO_LABEL, NO_LABEL); C_bra(l_table); /* goto start of switch_table */ } @@ -96,6 +95,8 @@ code_endswitch() sh->sh_default = sh->sh_break; C_bra(sh->sh_break); /* skip the switch table now */ C_df_ilb(sh->sh_table); /* switch table entry */ + /* evaluate the switch expr. */ + code_expr(sh->sh_expr, RVAL, TRUE, NO_LABEL, NO_LABEL); tablabel = data_label(); /* the rom must have a label */ C_df_dlb(tablabel); C_rom_ilb(sh->sh_default); diff --git a/lang/cem/cemcom/switch.str b/lang/cem/cemcom/switch.str index 6442a3916..a8c118f2c 100644 --- a/lang/cem/cemcom/switch.str +++ b/lang/cem/cemcom/switch.str @@ -12,6 +12,7 @@ struct switch_hdr { label sh_table; int sh_nrofentries; struct type *sh_type; + struct expr *sh_expr; arith sh_lowerbd; arith sh_upperbd; struct case_entry *sh_entries;