From b54441bfc1d2c91c8db71215b7d4587124f0b8db Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sun, 5 Feb 2006 06:10:43 +0000 Subject: [PATCH] *** empty log message *** --- ase/awk/parse.c | 13 ++++++++----- ase/awk/tree.c | 13 ++++++++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/ase/awk/parse.c b/ase/awk/parse.c index 1f867120..876d9802 100644 --- a/ase/awk/parse.c +++ b/ase/awk/parse.c @@ -1,5 +1,5 @@ /* - * $Id: parse.c,v 1.44 2006-02-04 19:37:40 bacon Exp $ + * $Id: parse.c,v 1.45 2006-02-05 06:10:43 bacon Exp $ */ #include @@ -504,9 +504,10 @@ static xp_awk_node_t* __parse_block (xp_awk_t* awk, xp_bool_t is_top) { xp_awk_node_t* head, * curr, * node; xp_awk_node_block_t* block; - xp_size_t nlocals, tmp; + xp_size_t nlocals, nlocals_max, tmp; nlocals = xp_awk_tab_getsize(&awk->parse.locals); + nlocals_max = awk->parse.nlocals_max; /* local variable declarations */ if (awk->opt.parse & XP_AWK_EXPLICIT) { @@ -581,6 +582,8 @@ static xp_awk_node_t* __parse_block (xp_awk_t* awk, xp_bool_t is_top) } tmp = xp_awk_tab_getsize(&awk->parse.locals); + if (tmp > awk->parse.nlocals_max) awk->parse.nlocals_max = tmp; + xp_awk_tab_remrange ( &awk->parse.locals, nlocals - 1, tmp - nlocals); @@ -591,14 +594,14 @@ static xp_awk_node_t* __parse_block (xp_awk_t* awk, xp_bool_t is_top) block->next = XP_NULL; block->body = head; - /* migrate all local variables to a top-level block */ + /* migrate all block-local variables to a top-level block */ if (is_top) { block->nlocals = awk->parse.nlocals_max - nlocals; - awk->parse.nlocals_max = nlocals; + awk->parse.nlocals_max = nlocals_max; } else { + /*block->nlocals = tmp - nlocals;*/ block->nlocals = 0; - if (tmp > awk->parse.nlocals_max) awk->parse.nlocals_max = tmp; } return (xp_awk_node_t*)block; diff --git a/ase/awk/tree.c b/ase/awk/tree.c index 2a10b6ec..16eff061 100644 --- a/ase/awk/tree.c +++ b/ase/awk/tree.c @@ -1,5 +1,5 @@ /* - * $Id: tree.c,v 1.16 2006-02-04 19:31:51 bacon Exp $ + * $Id: tree.c,v 1.17 2006-02-05 06:10:43 bacon Exp $ */ #include @@ -121,6 +121,7 @@ static int __print_expr_node_list (xp_awk_node_t* tree) static void __print_statements (xp_awk_node_t* tree, int depth) { xp_awk_node_t* p = tree; + xp_size_t i; while (p != XP_NULL) { @@ -133,11 +134,17 @@ static void __print_statements (xp_awk_node_t* tree, int depth) case XP_AWK_NODE_BLOCK: __print_tabs (depth); xp_printf (XP_TEXT("{\n")); + if (((xp_awk_node_block_t*)p)->nlocals > 0) { __print_tabs (depth + 1); - xp_printf (XP_TEXT("NLOCALS=>%u;\n"), - (unsigned int)((xp_awk_node_block_t*)p)->nlocals); + xp_printf (XP_TEXT("local ")); + + for (i = 0; i < ((xp_awk_node_block_t*)p)->nlocals - 1; i++) { + xp_printf (XP_TEXT("__local%u, "), (unsigned int)i); + } + xp_printf (XP_TEXT("__local%u;\n"), (unsigned int)i); } + __print_statements (((xp_awk_node_block_t*)p)->body, depth + 1); __print_tabs (depth); xp_printf (XP_TEXT("}\n"));