From 353f6656f153c49c59060edce6585ee8bae48220 Mon Sep 17 00:00:00 2001 From: Adrian Thurston Date: Mon, 11 Feb 2013 21:56:17 -0500 Subject: cleanup in parser: pass localFrame to CodeBlock --- colm/lmparse.kl | 17 ++++++----------- colm/parsetree.h | 4 ++-- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/colm/lmparse.kl b/colm/lmparse.kl index bbfd9b6f..2acc897f 100644 --- a/colm/lmparse.kl +++ b/colm/lmparse.kl @@ -41,7 +41,7 @@ include "lmparse.kh"; start: root_item_list final { - pd->rootCodeBlock = new CodeBlock( $1->stmtList ); + pd->rootCodeBlock = new CodeBlock( $1->stmtList, 0 ); }; nonterm root_item_list uses lang_stmt_list; @@ -115,8 +115,7 @@ block_close: '}' iter_def: KW_Iter TK_Word '(' opt_param_list ')' block_open lang_stmt_list block_close final { - CodeBlock *codeBlock = new CodeBlock( $7->stmtList ); - codeBlock->localFrame = $6->localFrame; + CodeBlock *codeBlock = new CodeBlock( $7->stmtList, $6->localFrame ); Function *newFunction = new Function( 0, $2->data, $4->paramList, codeBlock, pd->nextFuncId++, true ); pd->functionList.append( newFunction ); @@ -125,8 +124,7 @@ iter_def: function_def: type_ref TK_Word '(' opt_param_list ')' block_open lang_stmt_list block_close final { - CodeBlock *codeBlock = new CodeBlock( $7->stmtList ); - codeBlock->localFrame = $6->localFrame; + CodeBlock *codeBlock = new CodeBlock( $7->stmtList, $6->localFrame ); Function *newFunction = new Function( $1->typeRef, $2->data, $4->paramList, codeBlock, pd->nextFuncId++, false ); pd->functionList.append( newFunction ); @@ -1323,8 +1321,7 @@ nonterm opt_translate opt_translate: block_open lang_stmt_list block_close final { - $$->transBlock = new CodeBlock( $2->stmtList ); - $$->transBlock->localFrame = $1->localFrame; + $$->transBlock = new CodeBlock( $2->stmtList, $1->localFrame ); $$->transBlock->context = contextStack.length() == 0 ? 0 : contextStack.top(); }; @@ -1340,8 +1337,7 @@ pre_eof: if ( !insideRegion ) error($1->loc) << "preeof must be used inside an existing region" << endl; - CodeBlock *codeBlock = new CodeBlock( $3->stmtList ); - codeBlock->localFrame = $2->localFrame; + CodeBlock *codeBlock = new CodeBlock( $3->stmtList, $2->localFrame ); codeBlock->context = contextStack.length() == 0 ? 0 : contextStack.top(); TokenRegion *region = regionStack.top(); @@ -1399,8 +1395,7 @@ opt_reduce_code: opt_reduce_code: start_reduce lang_stmt_list block_close final { - $$->codeBlock = new CodeBlock( $2->stmtList ); - $$->codeBlock->localFrame = $1->localFrame; + $$->codeBlock = new CodeBlock( $2->stmtList, $1->localFrame ); $$->codeBlock->context = contextStack.length() == 0 ? 0 : contextStack.top(); }; diff --git a/colm/parsetree.h b/colm/parsetree.h index 9e65bf6d..76b35702 100644 --- a/colm/parsetree.h +++ b/colm/parsetree.h @@ -2800,11 +2800,11 @@ struct LangStmt struct CodeBlock { - CodeBlock( StmtList *stmtList ) + CodeBlock( StmtList *stmtList, ObjectDef *localFrame ) : frameId(-1), stmtList(stmtList), - localFrame(0), + localFrame(localFrame), context(0) {} void compile( Compiler *pd, CodeVect &code ) const; -- cgit v1.2.1