improved filename and linenumber generation

This commit is contained in:
ceriel 1988-01-28 16:15:16 +00:00
parent 72e13f3a5a
commit 16e381031b
3 changed files with 54 additions and 35 deletions

View file

@ -201,7 +201,7 @@ CaseCode(nd, exitlabel)
} }
} }
C_df_ilb(sh->sh_break); def_ilb(sh->sh_break);
FreeSh(sh); FreeSh(sh);
} }

View file

@ -94,6 +94,7 @@ CodeExpr(nd, ds, true_label, false_label)
{ {
register t_type *tp = nd->nd_type; register t_type *tp = nd->nd_type;
DoLineno(nd);
if (tp->tp_fund == T_REAL) fp_used = 1; if (tp->tp_fund == T_REAL) fp_used = 1;
switch(nd->nd_class) { switch(nd->nd_class) {
case Def: case Def:
@ -300,7 +301,7 @@ CodeCoercion(t1, t2)
C_zge(lb); C_zge(lb);
c_loc(ECONV); c_loc(ECONV);
C_trp(); C_trp();
C_df_ilb(lb); def_ilb(lb);
} }
c_loc((int)(t1->tp_size)); c_loc((int)(t1->tp_size));
c_loc((int)(t2->tp_size)); c_loc((int)(t2->tp_size));
@ -368,6 +369,7 @@ CodeCall(nd)
} }
else C_lfr(sz); else C_lfr(sz);
} }
DoFilename();
} }
CodeParameters(param, arg) CodeParameters(param, arg)
@ -660,16 +662,17 @@ RangeCheck(tpl, tpr)
C_zge(lb); C_zge(lb);
c_loc(ECONV); c_loc(ECONV);
C_trp(); C_trp();
C_df_ilb(lb); def_ilb(lb);
} }
} }
Operands(leftop, rightop) Operands(nd)
register t_node *leftop, *rightop; register t_node *nd;
{ {
CodePExpr(leftop); CodePExpr(nd->nd_left);
CodePExpr(rightop); CodePExpr(nd->nd_right);
DoLineno(nd);
} }
CodeOper(expr, true_label, false_label) CodeOper(expr, true_label, false_label)
@ -683,7 +686,7 @@ CodeOper(expr, true_label, false_label)
switch (expr->nd_symb) { switch (expr->nd_symb) {
case '+': case '+':
Operands(leftop, rightop); Operands(expr);
switch (tp->tp_fund) { switch (tp->tp_fund) {
case T_INTEGER: case T_INTEGER:
C_adi(tp->tp_size); C_adi(tp->tp_size);
@ -705,7 +708,7 @@ CodeOper(expr, true_label, false_label)
} }
break; break;
case '-': case '-':
Operands(leftop, rightop); Operands(expr);
switch (tp->tp_fund) { switch (tp->tp_fund) {
case T_INTEGER: case T_INTEGER:
C_sbi(tp->tp_size); C_sbi(tp->tp_size);
@ -728,7 +731,7 @@ CodeOper(expr, true_label, false_label)
} }
break; break;
case '*': case '*':
Operands(leftop, rightop); Operands(expr);
switch (tp->tp_fund) { switch (tp->tp_fund) {
case T_INTEGER: case T_INTEGER:
C_mli(tp->tp_size); C_mli(tp->tp_size);
@ -758,7 +761,7 @@ CodeOper(expr, true_label, false_label)
} }
break; break;
case '/': case '/':
Operands(leftop, rightop); Operands(expr);
switch (tp->tp_fund) { switch (tp->tp_fund) {
case T_REAL: case T_REAL:
C_dvf(tp->tp_size); C_dvf(tp->tp_size);
@ -771,7 +774,7 @@ CodeOper(expr, true_label, false_label)
} }
break; break;
case DIV: case DIV:
Operands(leftop, rightop); Operands(expr);
switch(tp->tp_fund) { switch(tp->tp_fund) {
case T_INTEGER: case T_INTEGER:
C_dvi(tp->tp_size); C_dvi(tp->tp_size);
@ -787,7 +790,7 @@ CodeOper(expr, true_label, false_label)
} }
break; break;
case MOD: case MOD:
Operands(leftop, rightop); Operands(expr);
switch(tp->tp_fund) { switch(tp->tp_fund) {
case T_INTEGER: case T_INTEGER:
C_rmi(tp->tp_size); C_rmi(tp->tp_size);
@ -808,7 +811,7 @@ CodeOper(expr, true_label, false_label)
case GREATEREQUAL: case GREATEREQUAL:
case '=': case '=':
case '#': case '#':
Operands(leftop, rightop); Operands(expr);
tp = BaseType(leftop->nd_type); tp = BaseType(leftop->nd_type);
if (tp == intorcard_type) tp = BaseType(rightop->nd_type); if (tp == intorcard_type) tp = BaseType(rightop->nd_type);
switch (tp->tp_fund) { switch (tp->tp_fund) {
@ -891,17 +894,17 @@ CodeOper(expr, true_label, false_label)
CodeExpr(leftop, Des, true_label, l_maybe); CodeExpr(leftop, Des, true_label, l_maybe);
} }
else CodeExpr(leftop, Des, l_maybe, false_label); else CodeExpr(leftop, Des, l_maybe, false_label);
C_df_ilb(l_maybe); def_ilb(l_maybe);
free_desig(Des); free_desig(Des);
Des = new_desig(); Des = new_desig();
CodeExpr(rightop, Des, true_label, false_label); CodeExpr(rightop, Des, true_label, false_label);
if (genlabels) { if (genlabels) {
C_df_ilb(true_label); def_ilb(true_label);
c_loc(1); c_loc(1);
C_bra(l_end); C_bra(l_end);
C_df_ilb(false_label); def_ilb(false_label);
c_loc(0); c_loc(0);
C_df_ilb(l_end); def_ilb(l_end);
} }
free_desig(Des); free_desig(Des);
break; break;
@ -1027,7 +1030,7 @@ CodeEl(nd, tp)
C_loc(eltype->sub_ub); C_loc(eltype->sub_ub);
} }
else C_loc((arith) (eltype->enm_ncst - 1)); else C_loc((arith) (eltype->enm_ncst - 1));
Operands(nd->nd_left, nd->nd_right); Operands(nd);
C_cal("_LtoUset"); /* library routine to fill set */ C_cal("_LtoUset"); /* library routine to fill set */
C_asp(5 * word_size); C_asp(5 * word_size);
} }

View file

@ -51,6 +51,7 @@ t_node *Modules;
static t_type *func_type; static t_type *func_type;
static arith priority; static arith priority;
static int oldlineno;
static int RegisterMessage(); static int RegisterMessage();
static int WalkDef(); static int WalkDef();
@ -69,7 +70,7 @@ LblWalkNode(lbl, nd, exit)
enclosing LOOP. enclosing LOOP.
*/ */
C_df_ilb(lbl); def_ilb(lbl);
WalkNode(nd, exit); WalkNode(nd, exit);
} }
@ -95,8 +96,23 @@ EndPriority()
} }
} }
STATIC def_ilb(l)
DoProfil() label l;
{
C_df_ilb(l);
oldlineno = 0;
}
DoLineno(nd)
register t_node *nd;
{
if (! options['L'] && nd->nd_lineno && nd->nd_lineno != oldlineno) {
oldlineno = nd->nd_lineno;
C_lin((arith) nd->nd_lineno);
}
}
DoFilename()
{ {
static label filename_label = 0; static label filename_label = 0;
@ -139,7 +155,7 @@ WalkModule(module)
TmpOpen(sc); /* Initialize for temporaries */ TmpOpen(sc); /* Initialize for temporaries */
C_pro_narg(sc->sc_name); C_pro_narg(sc->sc_name);
DoPriority(); DoPriority();
DoProfil(); DoFilename();
if (module == Defined) { if (module == Defined) {
/* Body of implementation or program module. /* Body of implementation or program module.
Call initialization routines of imported modules. Call initialization routines of imported modules.
@ -169,7 +185,7 @@ WalkModule(module)
proclevel++; proclevel++;
WalkNode(module->mod_body, NO_EXIT_LABEL); WalkNode(module->mod_body, NO_EXIT_LABEL);
DO_DEBUG(options['X'], PrNode(module->mod_body, 0)); DO_DEBUG(options['X'], PrNode(module->mod_body, 0));
C_df_ilb(RETURN_LABEL); def_ilb(RETURN_LABEL);
EndPriority(); EndPriority();
C_ret((arith) 0); C_ret((arith) 0);
C_end(-sc->sc_off); C_end(-sc->sc_off);
@ -206,7 +222,7 @@ WalkProcedure(procedure)
*/ */
C_pro_narg(sc->sc_name); C_pro_narg(sc->sc_name);
DoPriority(); DoPriority();
DoProfil(); DoFilename();
TmpOpen(sc); TmpOpen(sc);
func_type = tp = RemoveEqual(ResultType(procedure->df_type)); func_type = tp = RemoveEqual(ResultType(procedure->df_type));
@ -302,7 +318,7 @@ WalkProcedure(procedure)
C_trp(); C_trp();
C_asp(-func_res_size); C_asp(-func_res_size);
} }
C_df_ilb(RETURN_LABEL); /* label at end */ def_ilb(RETURN_LABEL); /* label at end */
if (func_res_label) { if (func_res_label) {
/* Fill the data area reserved for the function result /* Fill the data area reserved for the function result
with the result with the result
@ -426,7 +442,7 @@ WalkStat(nd, exit_label)
assert(nd->nd_class == Stat); assert(nd->nd_class == Stat);
if (! options['L'] && nd->nd_lineno) C_lin((arith) nd->nd_lineno); DoLineno(nd);
switch(nd->nd_symb) { switch(nd->nd_symb) {
case '(': case '(':
if (ChkCall(nd)) { if (ChkCall(nd)) {
@ -459,7 +475,7 @@ WalkStat(nd, exit_label)
LblWalkNode(l1, right->nd_right, exit_label); LblWalkNode(l1, right->nd_right, exit_label);
l1 = l2; l1 = l2;
} }
C_df_ilb(l1); def_ilb(l1);
break; break;
} }
@ -472,11 +488,11 @@ WalkStat(nd, exit_label)
exit = ++text_label, exit = ++text_label,
dummy = ++text_label; dummy = ++text_label;
C_df_ilb(loop); def_ilb(loop);
ExpectBool(left, dummy, exit); ExpectBool(left, dummy, exit);
LblWalkNode(dummy, right, exit_label); LblWalkNode(dummy, right, exit_label);
C_bra(loop); C_bra(loop);
C_df_ilb(exit); def_ilb(exit);
break; break;
} }
@ -485,7 +501,7 @@ WalkStat(nd, exit_label)
LblWalkNode(loop, left, exit_label); LblWalkNode(loop, left, exit_label);
ExpectBool(right, exit, loop); ExpectBool(right, exit, loop);
C_df_ilb(exit); def_ilb(exit);
break; break;
} }
@ -494,7 +510,7 @@ WalkStat(nd, exit_label)
LblWalkNode(loop, right, exit); LblWalkNode(loop, right, exit);
C_bra(loop); C_bra(loop);
C_df_ilb(exit); def_ilb(exit);
break; break;
} }
@ -545,7 +561,7 @@ WalkStat(nd, exit_label)
} }
C_stl(tmp); C_stl(tmp);
nd->nd_def->df_flags |= D_FORLOOP; nd->nd_def->df_flags |= D_FORLOOP;
C_df_ilb(l1); def_ilb(l1);
if (! options['R']) { if (! options['R']) {
tmp2 = NewInt(); tmp2 = NewInt();
ForLoopVarExpr(nd); ForLoopVarExpr(nd);
@ -562,7 +578,7 @@ WalkStat(nd, exit_label)
C_beq(x); C_beq(x);
c_loc(M2_FORCH); c_loc(M2_FORCH);
C_trp(); C_trp();
C_df_ilb(x); def_ilb(x);
FreeInt(tmp2); FreeInt(tmp2);
} }
if (stepsize) { if (stepsize) {
@ -580,7 +596,7 @@ WalkStat(nd, exit_label)
} }
} }
C_bra(l1); C_bra(l1);
C_df_ilb(l2); def_ilb(l2);
FreeInt(tmp); FreeInt(tmp);
#ifdef DEBUG #ifdef DEBUG
nd->nd_left = left; nd->nd_left = left;