improved filename and linenumber generation
authorceriel <none@none>
Thu, 28 Jan 1988 16:15:16 +0000 (16:15 +0000)
committerceriel <none@none>
Thu, 28 Jan 1988 16:15:16 +0000 (16:15 +0000)
lang/m2/comp/casestat.C
lang/m2/comp/code.c
lang/m2/comp/walk.c

index 55a2205..3e93b6f 100644 (file)
@@ -201,7 +201,7 @@ CaseCode(nd, exitlabel)
                }
        }
 
-       C_df_ilb(sh->sh_break);
+       def_ilb(sh->sh_break);
        FreeSh(sh);
 }
 
index 161011d..29ff781 100644 (file)
@@ -94,6 +94,7 @@ CodeExpr(nd, ds, true_label, false_label)
 {
        register t_type *tp = nd->nd_type;
 
+       DoLineno(nd);
        if (tp->tp_fund == T_REAL) fp_used = 1;
        switch(nd->nd_class) {
        case Def:
@@ -300,7 +301,7 @@ CodeCoercion(t1, t2)
                                C_zge(lb);
                                c_loc(ECONV);
                                C_trp();
-                               C_df_ilb(lb);
+                               def_ilb(lb);
                        }
                        c_loc((int)(t1->tp_size));
                        c_loc((int)(t2->tp_size));
@@ -368,6 +369,7 @@ CodeCall(nd)
                }
                else    C_lfr(sz);
        }
+       DoFilename();
 }
 
 CodeParameters(param, arg)
@@ -660,16 +662,17 @@ RangeCheck(tpl, tpr)
                C_zge(lb);
                c_loc(ECONV);
                C_trp();
-               C_df_ilb(lb);
+               def_ilb(lb);
        }
 }
 
-Operands(leftop, rightop)
-       register t_node *leftop, *rightop;
+Operands(nd)
+       register t_node *nd;
 {
 
-       CodePExpr(leftop);
-       CodePExpr(rightop);
+       CodePExpr(nd->nd_left);
+       CodePExpr(nd->nd_right);
+       DoLineno(nd);
 }
 
 CodeOper(expr, true_label, false_label)
@@ -683,7 +686,7 @@ CodeOper(expr, true_label, false_label)
 
        switch (expr->nd_symb)  {
        case '+':
-               Operands(leftop, rightop);
+               Operands(expr);
                switch (tp->tp_fund)    {
                case T_INTEGER:
                        C_adi(tp->tp_size);
@@ -705,7 +708,7 @@ CodeOper(expr, true_label, false_label)
                }
                break;
        case '-':
-               Operands(leftop, rightop);
+               Operands(expr);
                switch (tp->tp_fund)    {
                case T_INTEGER:
                        C_sbi(tp->tp_size);
@@ -728,7 +731,7 @@ CodeOper(expr, true_label, false_label)
                }
                break;
        case '*':
-               Operands(leftop, rightop);
+               Operands(expr);
                switch (tp->tp_fund)    {
                case T_INTEGER:
                        C_mli(tp->tp_size);
@@ -758,7 +761,7 @@ CodeOper(expr, true_label, false_label)
                }
                break;
        case '/':
-               Operands(leftop, rightop);
+               Operands(expr);
                switch (tp->tp_fund)    {
                case T_REAL:
                        C_dvf(tp->tp_size);
@@ -771,7 +774,7 @@ CodeOper(expr, true_label, false_label)
                }
                break;
        case DIV:
-               Operands(leftop, rightop);
+               Operands(expr);
                switch(tp->tp_fund)     {
                case T_INTEGER:
                        C_dvi(tp->tp_size);
@@ -787,7 +790,7 @@ CodeOper(expr, true_label, false_label)
                }
                break;
        case MOD:
-               Operands(leftop, rightop);
+               Operands(expr);
                switch(tp->tp_fund)     {
                case T_INTEGER:
                        C_rmi(tp->tp_size);
@@ -808,7 +811,7 @@ CodeOper(expr, true_label, false_label)
        case GREATEREQUAL:
        case '=':
        case '#':
-               Operands(leftop, rightop);
+               Operands(expr);
                tp = BaseType(leftop->nd_type);
                if (tp == intorcard_type) tp = BaseType(rightop->nd_type);
                switch (tp->tp_fund)    {
@@ -891,17 +894,17 @@ CodeOper(expr, true_label, false_label)
                        CodeExpr(leftop, Des, true_label, l_maybe);
                }
                else    CodeExpr(leftop, Des, l_maybe, false_label);
-               C_df_ilb(l_maybe);
+               def_ilb(l_maybe);
                free_desig(Des);
                Des = new_desig();
                CodeExpr(rightop, Des, true_label, false_label);
                if (genlabels) {
-                       C_df_ilb(true_label);
+                       def_ilb(true_label);
                        c_loc(1);
                        C_bra(l_end);
-                       C_df_ilb(false_label);
+                       def_ilb(false_label);
                        c_loc(0);
-                       C_df_ilb(l_end);
+                       def_ilb(l_end);
                }
                free_desig(Des);
                break;
@@ -1027,7 +1030,7 @@ CodeEl(nd, tp)
                        C_loc(eltype->sub_ub);
                }
                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_asp(5 * word_size);
        }
index 180494d..3d8ec57 100644 (file)
@@ -51,6 +51,7 @@ t_node                        *Modules;
 
 static t_type          *func_type;
 static arith           priority;
+static int             oldlineno;
 
 static int             RegisterMessage();
 static int             WalkDef();
@@ -69,7 +70,7 @@ LblWalkNode(lbl, nd, exit)
                enclosing LOOP.
        */
 
-       C_df_ilb(lbl);
+       def_ilb(lbl);
        WalkNode(nd, exit);
 }
 
@@ -95,8 +96,23 @@ EndPriority()
        }
 }
 
-STATIC
-DoProfil()
+def_ilb(l)
+       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;
 
@@ -139,7 +155,7 @@ WalkModule(module)
        TmpOpen(sc);            /* Initialize for temporaries */
        C_pro_narg(sc->sc_name);
        DoPriority();
-       DoProfil();
+       DoFilename();
        if (module == Defined) {
                /* Body of implementation or program module.
                   Call initialization routines of imported modules.
@@ -169,7 +185,7 @@ WalkModule(module)
        proclevel++;
        WalkNode(module->mod_body, NO_EXIT_LABEL);
        DO_DEBUG(options['X'], PrNode(module->mod_body, 0));
-       C_df_ilb(RETURN_LABEL);
+       def_ilb(RETURN_LABEL);
        EndPriority();
        C_ret((arith) 0);
        C_end(-sc->sc_off);
@@ -206,7 +222,7 @@ WalkProcedure(procedure)
        */
        C_pro_narg(sc->sc_name);
        DoPriority();
-       DoProfil();
+       DoFilename();
        TmpOpen(sc);
 
        func_type = tp = RemoveEqual(ResultType(procedure->df_type));
@@ -302,7 +318,7 @@ WalkProcedure(procedure)
                C_trp();
                C_asp(-func_res_size);
        }
-       C_df_ilb(RETURN_LABEL); /* label at end */
+       def_ilb(RETURN_LABEL);  /* label at end */
        if (func_res_label) {
                /* Fill the data area reserved for the function result
                   with the result
@@ -426,7 +442,7 @@ WalkStat(nd, exit_label)
 
        assert(nd->nd_class == Stat);
 
-       if (! options['L'] && nd->nd_lineno) C_lin((arith) nd->nd_lineno);
+       DoLineno(nd);
        switch(nd->nd_symb) {
        case '(':
                if (ChkCall(nd)) {
@@ -459,7 +475,7 @@ WalkStat(nd, exit_label)
                                LblWalkNode(l1, right->nd_right, exit_label);
                                l1 = l2;
                        }
-                       C_df_ilb(l1);
+                       def_ilb(l1);
                        break;
                }
 
@@ -472,11 +488,11 @@ WalkStat(nd, exit_label)
                                exit = ++text_label,
                                dummy = ++text_label;
 
-                       C_df_ilb(loop);
+                       def_ilb(loop);
                        ExpectBool(left, dummy, exit);
                        LblWalkNode(dummy, right, exit_label);
                        C_bra(loop);
-                       C_df_ilb(exit);
+                       def_ilb(exit);
                        break;
                }
 
@@ -485,7 +501,7 @@ WalkStat(nd, exit_label)
 
                        LblWalkNode(loop, left, exit_label);
                        ExpectBool(right, exit, loop);
-                       C_df_ilb(exit);
+                       def_ilb(exit);
                        break;
                }
 
@@ -494,7 +510,7 @@ WalkStat(nd, exit_label)
 
                        LblWalkNode(loop, right, exit);
                        C_bra(loop);
-                       C_df_ilb(exit);
+                       def_ilb(exit);
                        break;
                }
 
@@ -545,7 +561,7 @@ WalkStat(nd, exit_label)
                                }
                                C_stl(tmp);
                                nd->nd_def->df_flags |= D_FORLOOP;
-                               C_df_ilb(l1);
+                               def_ilb(l1);
                                if (! options['R']) {
                                        tmp2 = NewInt();
                                        ForLoopVarExpr(nd);
@@ -562,7 +578,7 @@ WalkStat(nd, exit_label)
                                        C_beq(x);
                                        c_loc(M2_FORCH);
                                        C_trp();
-                                       C_df_ilb(x);
+                                       def_ilb(x);
                                        FreeInt(tmp2);
                                }
                                if (stepsize) {
@@ -580,7 +596,7 @@ WalkStat(nd, exit_label)
                                }
                        }
                        C_bra(l1);
-                       C_df_ilb(l2);
+                       def_ilb(l2);
                        FreeInt(tmp);
 #ifdef DEBUG
                        nd->nd_left = left;