summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2013-12-31 16:54:59 -0500
committerAdrian Thurston <thurston@complang.org>2013-12-31 16:54:59 -0500
commitff77b00aa629ab9df563faee970d62100358baa8 (patch)
tree426ff837915a3e4a15a044f39bfb9ed79d7e86ea
parent60e81bf16b38de449a207cb0383c3319a0e7a866 (diff)
downloadcolm-ff77b00aa629ab9df563faee970d62100358baa8.tar.gz
store the current scope in LangStmt::ForLoop, use if creating triter var ref
-rw-r--r--src/loadcolm.cc3
-rw-r--r--src/parser.cc4
-rw-r--r--src/parser.h2
-rw-r--r--src/parsetree.h5
-rw-r--r--src/synthesis.cc4
5 files changed, 11 insertions, 7 deletions
diff --git a/src/loadcolm.cc b/src/loadcolm.cc
index d7746686..acfe10fa 100644
--- a/src/loadcolm.cc
+++ b/src/loadcolm.cc
@@ -227,7 +227,8 @@ struct LoadColm
LangIterCall *iterCall = walkIterCall( Statement.iter_call() );
- stmt = forScope( Statement.id().loc(), forDecl, typeRef, iterCall, stmtList );
+ stmt = forScope( Statement.id().loc(), forDecl,
+ pd->curLocalFrame->scope, typeRef, iterCall, stmtList );
popScope();
break;
diff --git a/src/parser.cc b/src/parser.cc
index 8741773d..f4c24f65 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -663,7 +663,7 @@ ConsItemList *BaseParser::consListConcat( ConsItemList *list1,
}
LangStmt *BaseParser::forScope( const InputLoc &loc, const String &data,
- TypeRef *typeRef, LangIterCall *iterCall, StmtList *stmtList )
+ ObjNameScope *scope, TypeRef *typeRef, LangIterCall *iterCall, StmtList *stmtList )
{
/* Check for redeclaration. */
if ( pd->curLocalFrame->checkRedecl( data ) != 0 )
@@ -676,7 +676,7 @@ LangStmt *BaseParser::forScope( const InputLoc &loc, const String &data,
pd->curLocalFrame->insertField( data, iterField );
LangStmt *stmt = LangStmt::cons( loc, LangStmt::ForIterType,
- iterField, typeRef, iterCall, stmtList );
+ iterField, typeRef, iterCall, stmtList, scope );
return stmt;
}
diff --git a/src/parser.h b/src/parser.h
index d54ad62e..428c55bd 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -97,7 +97,7 @@ struct BaseParser
PatternItemList *patListConcat( PatternItemList *list1, PatternItemList *list2 );
ConsItemList *consListConcat( ConsItemList *list1, ConsItemList *list2 );
LangStmt *forScope( const InputLoc &loc, const String &data,
- TypeRef *typeRef, LangIterCall *iterCall, StmtList *stmtList );
+ ObjNameScope *scope, TypeRef *typeRef, LangIterCall *iterCall, StmtList *stmtList );
void preEof( const InputLoc &loc, StmtList *stmtList, ObjectDef *localFrame );
ProdEl *prodElName( const InputLoc &loc, const String &data,
diff --git a/src/parsetree.h b/src/parsetree.h
index 198bd3eb..2fd2a5d5 100644
--- a/src/parsetree.h
+++ b/src/parsetree.h
@@ -2927,6 +2927,7 @@ struct LangStmt
stmtList(0),
elsePart(0),
iterCall(0),
+ scope(0),
/* Normally you don't need to initialize double list pointers, however,
* we make use of the next pointer for returning a pair of statements
@@ -3047,7 +3048,7 @@ struct LangStmt
}
static LangStmt *cons( const InputLoc &loc, Type type, ObjectField *objField,
- TypeRef *typeRef, LangIterCall *iterCall, StmtList *stmtList )
+ TypeRef *typeRef, LangIterCall *iterCall, StmtList *stmtList, ObjNameScope *scope )
{
LangStmt *s = new LangStmt;
s->loc = loc;
@@ -3056,6 +3057,7 @@ struct LangStmt
s->typeRef = typeRef;
s->iterCall = iterCall;
s->stmtList = stmtList;
+ s->scope = scope;
return s;
}
@@ -3092,6 +3094,7 @@ struct LangStmt
LangStmt *elsePart;
String name;
LangIterCall *iterCall;
+ ObjNameScope *scope;
/* Normally you don't need to initialize double list pointers, however, we
* make use of the next pointer for returning a pair of statements using
diff --git a/src/synthesis.cc b/src/synthesis.cc
index 6f88da9f..f6084bae 100644
--- a/src/synthesis.cc
+++ b/src/synthesis.cc
@@ -2089,7 +2089,7 @@ void LangStmt::compileForIterBody( Compiler *pd,
void LangStmt::chooseDefaultIter( Compiler *pd, LangIterCall *iterCall ) const
{
/* The iterator name. */
- LangVarRef *callVarRef = LangVarRef::cons( loc, pd->curLocalFrame->scope, "triter" );
+ LangVarRef *callVarRef = LangVarRef::cons( loc, scope, "triter" );
/* The parameters. */
CallArgVect *callExprVect = new CallArgVect;
@@ -2628,7 +2628,7 @@ void Compiler::findLocalTrees( CharSet &trees )
void Compiler::findLocalIters( Iters &iters )
{
- /* We exlcude "lhs" from being downrefed because we need to use if after
+ /* We exclude "lhs" from being downrefed because we need to use if after
* the frame is is cleaned and so it must survive. */
for ( ObjFieldList::Iter ol = *curLocalFrame->objFieldList; ol.lte(); ol++ ) {
ObjectField *el = ol->value;