[svn:parrot] r41225 - trunk/compilers/imcc

chromatic at svn.parrot.org chromatic at svn.parrot.org
Sat Sep 12 10:54:53 UTC 2009


Author: chromatic
Date: Sat Sep 12 10:54:53 2009
New Revision: 41225
URL: https://trac.parrot.org/parrot/changeset/41225

Log:
[IMCC] Improved IMCC line number tracking.  This is an ugly fix, as it papers
around the unfortunate fact that IMCC only increases the line number as it
detects the end of a line.  This would be fine, except that IMCC emits
instructions *before* it reaches the end of a line in certain circumstances,
thus incrementing the line counter eventually, but not at the right time to get
the right number for certain ops.

A better fix is welcome.  pirc is very welcome.

Modified:
   trunk/compilers/imcc/imcc.y
   trunk/compilers/imcc/imcparser.c

Modified: trunk/compilers/imcc/imcc.y
==============================================================================
--- trunk/compilers/imcc/imcc.y	Sat Sep 12 10:54:48 2009	(r41224)
+++ trunk/compilers/imcc/imcc.y	Sat Sep 12 10:54:53 2009	(r41225)
@@ -2003,7 +2003,7 @@
    | target '=' un_op var
             { $$ = MK_I(interp, IMCC_INFO(interp)->cur_unit, $3, 2, $1, $4);  }
    | target '=' var bin_op var
-            { $$ = MK_I(interp, IMCC_INFO(interp)->cur_unit, $4, 3, $1, $3, $5);  }
+            { IMCC_INFO(interp)->line++; $$ = MK_I(interp, IMCC_INFO(interp)->cur_unit, $4, 3, $1, $3, $5); IMCC_INFO(interp)->line--; }
    | target '=' var '[' keylist ']'
             { $$ = iINDEXFETCH(interp, IMCC_INFO(interp)->cur_unit, $1, $3, $5); }
    | target '[' keylist ']' '=' var
@@ -2087,7 +2087,7 @@
 op_assign:
      target assign_op var
          {
-           $$ = MK_I(interp, IMCC_INFO(interp)->cur_unit, $2, 2, $1, $3);
+           IMCC_INFO(interp)->line++; $$ = MK_I(interp, IMCC_INFO(interp)->cur_unit, $2, 2, $1, $3); IMCC_INFO(interp)->line--;
          }
    ;
 

Modified: trunk/compilers/imcc/imcparser.c
==============================================================================
--- trunk/compilers/imcc/imcparser.c	Sat Sep 12 10:54:48 2009	(r41224)
+++ trunk/compilers/imcc/imcparser.c	Sat Sep 12 10:54:53 2009	(r41225)
@@ -4433,7 +4433,7 @@
 
   case 203:
 #line 2006 "compilers/imcc/imcc.y"
-    { (yyval.i) = MK_I(interp, IMCC_INFO(interp)->cur_unit, (yyvsp[(4) - (5)].s), 3, (yyvsp[(1) - (5)].sr), (yyvsp[(3) - (5)].sr), (yyvsp[(5) - (5)].sr));  }
+    { IMCC_INFO(interp)->line++; (yyval.i) = MK_I(interp, IMCC_INFO(interp)->cur_unit, (yyvsp[(4) - (5)].s), 3, (yyvsp[(1) - (5)].sr), (yyvsp[(3) - (5)].sr), (yyvsp[(5) - (5)].sr)); IMCC_INFO(interp)->line--; }
     break;
 
   case 204:
@@ -4629,7 +4629,7 @@
   case 242:
 #line 2089 "compilers/imcc/imcc.y"
     {
-           (yyval.i) = MK_I(interp, IMCC_INFO(interp)->cur_unit, (yyvsp[(2) - (3)].s), 2, (yyvsp[(1) - (3)].sr), (yyvsp[(3) - (3)].sr));
+           IMCC_INFO(interp)->line++; (yyval.i) = MK_I(interp, IMCC_INFO(interp)->cur_unit, (yyvsp[(2) - (3)].s), 2, (yyvsp[(1) - (3)].sr), (yyvsp[(3) - (3)].sr)); IMCC_INFO(interp)->line--;
          }
     break;
 


More information about the parrot-commits mailing list