cvsuser 04/08/03 05:51:06
Modified: ast ast.y ast_main.c astparser.c astparser.h node.c
imcc imc.h
Log:
ast 8 - get rid of global top_node
Revision Changes Path
1.6 +1 -3 parrot/ast/ast.y
Index: ast.y
===================================================================
RCS file: /cvs/public/parrot/ast/ast.y,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -r1.5 -r1.6
--- ast.y 3 Aug 2004 11:21:30 -0000 1.5
+++ ast.y 3 Aug 2004 12:51:02 -0000 1.6
@@ -36,8 +36,6 @@
#define YYPARSE_PARAM interp
#define YYLEX_PARAM interp
-extern struct nodeType_t *top_node;
-
%}
%union {
@@ -58,7 +56,7 @@
%%
-program: nodes { top_node = $$; }
+program: nodes { IMCC_INFO(interp)->top_node = $$; }
| error { pr_error(@1, "Bug"); YYABORT; }
;
1.4 +9 -3 parrot/ast/ast_main.c
Index: ast_main.c
===================================================================
RCS file: /cvs/public/parrot/ast/ast_main.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -r1.3 -r1.4
--- ast_main.c 2 Aug 2004 13:33:02 -0000 1.3
+++ ast_main.c 3 Aug 2004 12:51:02 -0000 1.4
@@ -1,6 +1,6 @@
/*
Copyright: 2001-2004 The Perl Foundation. All Rights Reserved.
-$Id: ast_main.c,v 1.3 2004/08/02 13:33:02 leo Exp $
+$Id: ast_main.c,v 1.4 2004/08/03 12:51:02 leo Exp $
=head1 NAME
@@ -43,17 +43,23 @@
*/
-struct nodeType_t *top_node; /* XXX */
void
IMCC_ast_compile(Interp *interpreter, FILE *fp)
{
+ nodeType *top_node;
+
ASTin = fp;
ASTparse(interpreter);
+
+ top_node = interpreter->imc_info->top_node;
top_node = IMCC_expand_nodes(interpreter, top_node);
if (top_node) {
- /* IMCC_dump_nodes(top_node); TODO commandline switches */
+ if (interpreter->imc_info->debug & 0x100) {
+ IMCC_dump_nodes(top_node); /* TODO commandline switches */
+ }
IMCC_free_nodes(interpreter, top_node);
}
+ interpreter->imc_info->top_node = NULL;
}
static void
1.8 +24 -26 parrot/ast/astparser.c
Index: astparser.c
===================================================================
RCS file: /cvs/public/parrot/ast/astparser.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -w -r1.7 -r1.8
--- astparser.c 3 Aug 2004 11:21:30 -0000 1.7
+++ astparser.c 3 Aug 2004 12:51:02 -0000 1.8
@@ -121,8 +121,6 @@
#define YYPARSE_PARAM interp
#define YYLEX_PARAM interp
-extern struct nodeType_t *top_node;
-
/* Enabling traces. */
@@ -139,14 +137,14 @@
#endif
#ifndef YYSTYPE
-#line 43 "ast/ast.y"
+#line 41 "ast/ast.y"
typedef union {
int t;
char *s;
struct nodeType_t *n;
} yystype;
/* Line 193 of /usr/share/bison/yacc.c. */
-#line 150 "ast/astparser.c"
+#line 148 "ast/astparser.c"
# define YYSTYPE yystype
# define YYSTYPE_IS_TRIVIAL 1
#endif
@@ -167,7 +165,7 @@
/* Line 213 of /usr/share/bison/yacc.c. */
-#line 171 "ast/astparser.c"
+#line 169 "ast/astparser.c"
#if ! defined (yyoverflow) || YYERROR_VERBOSE
@@ -340,9 +338,9 @@
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const unsigned char yyrline[] =
{
- 0, 61, 61, 62, 65, 66, 69, 70, 71, 72,
- 75, 76, 76, 80, 80, 84, 86, 87, 88, 91,
- 94
+ 0, 59, 59, 60, 63, 64, 67, 68, 69, 70,
+ 73, 74, 74, 78, 78, 82, 84, 85, 86, 89,
+ 92
};
#endif
@@ -1013,79 +1011,79 @@
switch (yyn)
{
case 2:
-#line 61 "ast/ast.y"
- { top_node = yyval.n; }
+#line 59 "ast/ast.y"
+ { IMCC_INFO(interp)->top_node = yyval.n; }
break;
case 3:
-#line 62 "ast/ast.y"
+#line 60 "ast/ast.y"
{ pr_error(yylsp[0], "Bug"); YYABORT; }
break;
case 5:
-#line 66 "ast/ast.y"
+#line 64 "ast/ast.y"
{ yyval.n = 0; }
break;
case 7:
-#line 70 "ast/ast.y"
+#line 68 "ast/ast.y"
{ yyval.n = IMCC_append_node(interp, yyvsp[-1].n, yyvsp[0].n, &yylsp[-1]); }
break;
case 10:
-#line 75 "ast/ast.y"
+#line 73 "ast/ast.y"
{ yyval.n = IMCC_new_node(interp, yyvsp[-3].t, yyvsp[-1].n, &yylsp[-3]); }
break;
case 11:
-#line 76 "ast/ast.y"
+#line 74 "ast/ast.y"
{ cur_unit = imc_open_unit(interp, IMC_PCCSUB); }
break;
case 12:
-#line 77 "ast/ast.y"
+#line 75 "ast/ast.y"
{ yyval.n = IMCC_new_node(interp, yyvsp[-4].t, yyvsp[-1].n, &yylsp[-4]);
yyval.n->unit = cur_unit;
cur_unit = cur_unit->prev; }
break;
case 13:
-#line 80 "ast/ast.y"
+#line 78 "ast/ast.y"
{ cur_unit = imc_open_unit(interp, IMC_PCCSUB); }
break;
case 14:
-#line 81 "ast/ast.y"
+#line 79 "ast/ast.y"
{ yyval.n = IMCC_new_node(interp, yyvsp[-4].t, yyvsp[-1].n, &yylsp[-4]); }
break;
case 15:
-#line 85 "ast/ast.y"
+#line 83 "ast/ast.y"
{ yyval.n = IMCC_new_const_node(interp, yyvsp[0].s, 'S', &yylsp[0]); }
break;
case 16:
-#line 86 "ast/ast.y"
+#line 84 "ast/ast.y"
{ yyval.n = IMCC_new_const_node(interp, yyvsp[0].s, 'I', &yylsp[0]); }
break;
case 17:
-#line 87 "ast/ast.y"
+#line 85 "ast/ast.y"
{ yyval.n = IMCC_new_const_node(interp, yyvsp[0].s, 'N', &yylsp[0]); }
break;
case 18:
-#line 88 "ast/ast.y"
+#line 86 "ast/ast.y"
{ yyval.n = IMCC_new_const_node(interp, yyvsp[0].s, 'U', &yylsp[0]); }
break;
case 19:
-#line 91 "ast/ast.y"
+#line 89 "ast/ast.y"
{ yyval.n = IMCC_new_var_node(interp, yyvsp[0].s, yyvsp[-1].t, &yylsp[0]); }
break;
case 20:
-#line 94 "ast/ast.y"
+#line 92 "ast/ast.y"
{ yyval.t = 'P'; }
break;
@@ -1093,7 +1091,7 @@
}
/* Line 1016 of /usr/share/bison/yacc.c. */
-#line 1097 "ast/astparser.c"
+#line 1095 "ast/astparser.c"
yyvsp -= yylen;
yyssp -= yylen;
@@ -1312,7 +1310,7 @@
}
-#line 97 "ast/ast.y"
+#line 95 "ast/ast.y"
static void
1.6 +1 -1 parrot/ast/astparser.h
Index: astparser.h
===================================================================
RCS file: /cvs/public/parrot/ast/astparser.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -r1.5 -r1.6
--- astparser.h 3 Aug 2004 08:03:01 -0000 1.5
+++ astparser.h 3 Aug 2004 12:51:02 -0000 1.6
@@ -55,7 +55,7 @@
#ifndef YYSTYPE
-#line 43 "ast/ast.y"
+#line 41 "ast/ast.y"
typedef union {
int t;
char *s;
1.10 +2 -1 parrot/ast/node.c
Index: node.c
===================================================================
RCS file: /cvs/public/parrot/ast/node.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -r1.9 -r1.10
--- node.c 3 Aug 2004 11:21:30 -0000 1.9
+++ node.c 3 Aug 2004 12:51:02 -0000 1.10
@@ -1,6 +1,6 @@
/*
Copyright: 2001-2004 The Perl Foundation. All Rights Reserved.
-$Id: node.c,v 1.9 2004/08/03 11:21:30 leo Exp $
+$Id: node.c,v 1.10 2004/08/03 12:51:02 leo Exp $
=head1 NAME
@@ -574,6 +574,7 @@
if (!r->type)
r->type = VTIDENTIFIER;
p->expand = exp_Var;
+ p->d = "Var";
p->dump = dump_Var;
return p;
}
1.68 +3 -0 parrot/imcc/imc.h
Index: imc.h
===================================================================
RCS file: /cvs/public/parrot/imcc/imc.h,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -w -r1.67 -r1.68
--- imc.h 3 Aug 2004 11:21:33 -0000 1.67
+++ imc.h 3 Aug 2004 12:51:06 -0000 1.68
@@ -177,6 +177,8 @@
EXTERN struct imcc_ostat ostat;
+struct nodeType_t;
+
typedef struct _imc_info_t {
IMC_Unit * imc_units;
@@ -186,6 +188,7 @@
int debug;
int n_comp_units;
SymReg * cur_namespace;
+ struct nodeType_t *top_node;
} imc_info_t;