@@ -102,14 +102,19 @@ YYSTYPE yylval;
102102
103103 extern int print_objects_while_running;
104104
105- int tag_count; /* use this to count tagged GENERIC types in the formal */
106- /* argument lists. Gross, but much easier to do it this */
107- /* way then with the 'help' of yacc. */
108- /* Set it to -1 to indicate that tags cannot be defined, */
109- /* only used (outside of formal parameter list, i.e. for */
110- /* return types). Hey, as long as */
111- /* there's a gross hack sitting around, we might as well */
112- /* milk it for all it's worth! -snc */
105+ int tag_count; /* *< use this to count tagged GENERIC types in the formal
106+ * argument lists. Gross, but much easier to do it this
107+ * way then with the 'help' of yacc. Set it to -1 to
108+ * indicate that tags cannot be defined, only used
109+ * (outside of formal parameter list, i.e. for return
110+ * types). Hey, as long as there's a gross hack sitting
111+ * around, we might as well milk it for all it's worth!
112+ * - snc
113+ */
114+
115+ int local_var_count; /* *< used to keep LOCAL variables in order
116+ * used in combination with Variable.offset
117+ */
113118
114119 Express yyexpresult; /* hook to everything built by parser */
115120
@@ -376,7 +381,7 @@ action_body_item(A) ::= local_decl(B).
376381}
377382
378383/* this corresponds to 'algorithm_head' in N14-ese but it should be rewritten
379- * to force declarationsfollowed by constants followed by local_decls
384+ * to force declarations followed by constants followed by local_decls
380385 */
381386action_body_item_rep ::= /* NULL item */ .
382387action_body_item_rep (A) ::= action_body_item(B) action_body_item_rep.
@@ -1669,20 +1674,21 @@ local_variable ::= id_list(A) TOK_COLON parameter_type(B) semicolon.
16691674 e = EXPcreate (Type_Attribute);
16701675 e->symbol = *sym; SYMBOL_destroy (sym);
16711676 v = VARcreate (e, B);
1672- DICTdefine (CURRENT_SCOPE-> symbol_table , e-> symbol . name , (Generic)v,
1673- &e->symbol , OBJ_VARIABLE);
1677+ v-> offset = local_var_count++;
1678+ DICTdefine (CURRENT_SCOPE-> symbol_table , e-> symbol . name , (Generic)v, &e->symbol , OBJ_VARIABLE);
16741679 LISTod;
16751680 LISTfree (A);
16761681}
1677- local_variable ::= id_list(A) TOK_COLON parameter_type (B) local_initializer(C)
1678- semicolon.
1682+
1683+ local_variable ::= id_list(A) TOK_COLON parameter_type (B) local_initializer(C) semicolon.
16791684{
16801685 Expression e;
16811686 Variable v;
16821687 LISTdo (A, sym, Symbol *)
16831688 e = EXPcreate (Type_Attribute);
16841689 e->symbol = *sym; SYMBOL_destroy (sym);
16851690 v = VARcreate (e, B);
1691+ v->offset = local_var_count++;
16861692 v->initializer = C;
16871693 DICTdefine (CURRENT_SCOPE->symbol_table , e->symbol .name , (Generic)v,
16881694 &e->symbol , OBJ_VARIABLE);
@@ -1696,14 +1702,15 @@ local_body(A) ::= local_variable(B) local_body.
16961702 A = B;
16971703}
16981704
1699- local_decl ::= TOK_LOCAL allow_generic_types local_body TOK_END_LOCAL semicolon disallow_generic_types .
1705+ local_decl ::= TOK_LOCAL local_decl_rules_on local_body TOK_END_LOCAL semicolon local_decl_rules_off .
17001706
1701- allow_generic_types ::= /* subroutine */ .
1707+ local_decl_rules_on ::= /* subroutine */ .
17021708{
17031709 tag_count = 0 ; /* don't signal an error if we find a generic_type */
1710+ local_var_count = 0 ; /* used to keep local var decl's in the same order */
17041711}
17051712
1706- disallow_generic_types ::= /* subroutine */ .
1713+ local_decl_rules_off ::= /* subroutine */ .
17071714{
17081715 tag_count = -1 ; /* signal an error if we find a generic_type */
17091716}
0 commit comments