added EX_SIDEEFFECTS, options['p'] --> ! options['L'], fixed some bugs
This commit is contained in:
parent
0ffdfb4f76
commit
493efb1bf7
10 changed files with 51 additions and 26 deletions
|
@ -14,7 +14,7 @@ LINT = /usr/new/lint
|
|||
SYSLIB = $(EMHOME)/modules/lib/libsystem.a
|
||||
EMKLIB = $(EMHOME)/modules/lib/libemk.a
|
||||
EMELIB = $(EMHOME)/modules/lib/libeme.a
|
||||
STRLIB = $(EMHOME)/modules/lib/libstr.a
|
||||
STRLIB = $(EMHOME)/modules/lib/libstring.a
|
||||
PRTLIB = $(EMHOME)/modules/lib/libprint.a
|
||||
EMMESLIB = $(EMHOME)/modules/lib/libem_mes.a
|
||||
INPLIB = $(EMHOME)/modules/lib/libinput.a
|
||||
|
|
|
@ -42,8 +42,9 @@ set maximum identifier length to \fIn\fP.
|
|||
do not generate EM register messages.
|
||||
The user-declared variables are not stored into registers on the target
|
||||
machine.
|
||||
.IP \fB\-p\fR
|
||||
generate the EM \fBfil\fR and \fBlin\fR instructions in order to enable
|
||||
.IP \fB\-L\fR
|
||||
don't generate the EM \fBfil\fR and \fBlin\fR instructions
|
||||
that usually are generated to enable
|
||||
an interpreter to keep track of the current location in the source code.
|
||||
.IP \fB\-P\fR
|
||||
like \fB\-E\fR but without #\fBline\fR control lines.
|
||||
|
|
|
@ -333,6 +333,7 @@ ch7asgn(expp, oper, expr)
|
|||
*expp = new_oper((*expp)->ex_type, *expp, oper, expr);
|
||||
#endif NOBITFIELD
|
||||
(*expp)->OP_TYPE = tp; /* for EVAL() */
|
||||
(*expp)->ex_flags |= EX_SIDEEFFECTS;
|
||||
}
|
||||
|
||||
/* Some interesting (?) questions answered.
|
||||
|
|
|
@ -77,6 +77,7 @@ ch7bin(expp, oper, expr)
|
|||
else
|
||||
*expp = new_oper((*expp)->ex_type->tp_up,
|
||||
*expp, '(', expr);
|
||||
(*expp)->ex_flags |= EX_SIDEEFFECTS;
|
||||
break;
|
||||
case PARCOMMA: /* RM 7.1 */
|
||||
if ((*expp)->ex_type->tp_fund == FUNCTION)
|
||||
|
@ -149,8 +150,8 @@ ch7bin(expp, oper, expr)
|
|||
}
|
||||
break;
|
||||
case LEFT:
|
||||
case LEFTAB:
|
||||
case RIGHT:
|
||||
case LEFTAB:
|
||||
case RIGHTAB:
|
||||
opnd2integral(expp, oper);
|
||||
opnd2integral(&expr, oper);
|
||||
|
|
|
@ -201,7 +201,7 @@ begin_proc(name, def) /* to be called when entering a procedure */
|
|||
lab_count = (label) 1;
|
||||
return_label = text_label();
|
||||
return_expr_occurred = 0;
|
||||
if (options['p']) { /* profiling */
|
||||
if (! options['L']) { /* profiling */
|
||||
if (strcmp(last_fn_given, FileName) != 0) {
|
||||
/* previous function came from other file */
|
||||
C_df_dlb(file_name_label = data_label());
|
||||
|
@ -479,7 +479,7 @@ code_expr(expr, val, code, tlbl, flbl)
|
|||
generator. If line number trace is wanted, it generates a
|
||||
lin instruction. EVAL() is called directly.
|
||||
*/
|
||||
if (options['p']) /* profiling */
|
||||
if (! options['L']) /* profiling */
|
||||
C_lin((arith)LineNumber);
|
||||
EVAL(expr, val, code, tlbl, flbl);
|
||||
}
|
||||
|
|
|
@ -337,8 +337,10 @@ PRIVATE
|
|||
do_endif()
|
||||
{
|
||||
SkipRestOfLine();
|
||||
if (nestlevel-- < 0)
|
||||
if (nestlevel < 0) {
|
||||
lexerror("#endif without corresponding #if");
|
||||
}
|
||||
else nestlevel--;
|
||||
}
|
||||
|
||||
PRIVATE
|
||||
|
|
|
@ -94,8 +94,10 @@ EVAL(expr, val, code, true_label, false_label)
|
|||
register struct expr *right = expr->OP_RIGHT;
|
||||
register struct type *tp = expr->OP_TYPE;
|
||||
|
||||
if (tp->tp_fund == ERRONEOUS) /* stop immediately */
|
||||
if (tp->tp_fund == ERRONEOUS || (expr->ex_flags & EX_ERROR)) {
|
||||
/* stop immediately */
|
||||
break;
|
||||
}
|
||||
if (tp->tp_fund == VOID)
|
||||
gencode = 0;
|
||||
switch (oper) {
|
||||
|
@ -298,15 +300,7 @@ EVAL(expr, val, code, true_label, false_label)
|
|||
C_bra(false_label);
|
||||
}
|
||||
else {
|
||||
label l_true = text_label();
|
||||
label l_end = text_label();
|
||||
|
||||
compare(oper, l_true);
|
||||
C_loc((arith)0);
|
||||
C_bra(l_end);
|
||||
C_df_ilb(l_true);
|
||||
C_loc((arith)1);
|
||||
C_df_ilb(l_end);
|
||||
truthvalue(oper);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -384,9 +378,9 @@ EVAL(expr, val, code, true_label, false_label)
|
|||
load_val(left, RVAL);
|
||||
}
|
||||
else
|
||||
if (left->ex_depth == 1 && left->OP_OPER == ARROW) {
|
||||
compl = 1; /* Value->sel */
|
||||
ASSERT(left->OP_LEFT->ex_class == Value);
|
||||
if (left->ex_depth == 1 &&
|
||||
!(left->ex_flags & EX_SIDEEFFECTS)) {
|
||||
compl = 1;
|
||||
EVAL(left, RVAL, newcode, NO_LABEL, NO_LABEL);
|
||||
}
|
||||
else {
|
||||
|
@ -662,6 +656,35 @@ compare(relop, lbl)
|
|||
}
|
||||
}
|
||||
|
||||
/* truthvalue() serves as an auxiliary function of EVAL */
|
||||
truthvalue(relop)
|
||||
int relop;
|
||||
{
|
||||
switch (relop) {
|
||||
case '<':
|
||||
C_tlt();
|
||||
break;
|
||||
case LESSEQ:
|
||||
C_tle();
|
||||
break;
|
||||
case '>':
|
||||
C_tgt();
|
||||
break;
|
||||
case GREATEREQ:
|
||||
C_tge();
|
||||
break;
|
||||
case EQUAL:
|
||||
C_teq();
|
||||
break;
|
||||
case NOTEQUAL:
|
||||
C_tne();
|
||||
break;
|
||||
default:
|
||||
CRASH();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* assop() generates the opcode of an assignment operators op= */
|
||||
assop(type, oper)
|
||||
register struct type *type;
|
||||
|
|
|
@ -94,6 +94,7 @@ struct expr {
|
|||
#define EX_LOGICAL 0004 /* contains logical operator */
|
||||
#define EX_COMMA 0010 /* contains expression comma */
|
||||
#define EX_PARENS 0020 /* the top level is parenthesized */
|
||||
#define EX_SIDEEFFECTS 0040 /* expression has side effects */
|
||||
#define EX_ERROR 0200 /* the expression is wrong */
|
||||
|
||||
#define NILEXPR ((struct expr *)0)
|
||||
|
|
|
@ -115,7 +115,7 @@ do_option(text)
|
|||
break;
|
||||
|
||||
case 'L' :
|
||||
warning("-L: default no EM profiling; use -p for EM profiling");
|
||||
options['L'] = 1; /* no fil/lin */
|
||||
break;
|
||||
|
||||
case 'M': /* maximum identifier length */
|
||||
|
@ -126,10 +126,6 @@ do_option(text)
|
|||
fatal("maximum identifier length is %d", IDFSIZE);
|
||||
break;
|
||||
|
||||
case 'p' : /* generate profiling code (fil/lin) */
|
||||
options['p'] = 1;
|
||||
break;
|
||||
|
||||
case 'P' : /* run preprocessor stand-alone, without #'s */
|
||||
#ifndef NOPP
|
||||
options['E'] = 1;
|
||||
|
|
|
@ -155,7 +155,7 @@ macro2buffer(idef, actpars, siztext)
|
|||
/* copy the text of the actual parameter
|
||||
into the replacement text
|
||||
*/
|
||||
for (p = actpars[n - 1]; p && *p; p++) {
|
||||
for (p = actpars[n - 1]; *p; p++) {
|
||||
text[pos++] = *p;
|
||||
if (pos == size)
|
||||
text = Srealloc(text, size += RSTRSIZE);
|
||||
|
|
Loading…
Reference in a new issue