summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2012-08-29 12:27:56 -0400
committerAdrian Thurston <thurston@complang.org>2012-08-29 12:27:56 -0400
commitab40d1b49d9a1631145ff604ad2a65eaa6345dfd (patch)
treeb3a9cf5fce0cc57d8f6d84a9ee91ce4de31edc96
parent10978e1598a33811085cf3e51684948087d3c4db (diff)
downloadcolm-ab40d1b49d9a1631145ff604ad2a65eaa6345dfd.tar.gz
guard against nested contiguous stack blocks, they don't work
-rw-r--r--colm/compiler.cc3
-rw-r--r--colm/parsedata.h2
-rw-r--r--colm/synthesis.cc35
3 files changed, 35 insertions, 5 deletions
diff --git a/colm/compiler.cc b/colm/compiler.cc
index 27114d8f..54e42a09 100644
--- a/colm/compiler.cc
+++ b/colm/compiler.cc
@@ -441,7 +441,8 @@ Compiler::Compiler( const String &fileName, const String &sectionName,
predValue(0),
nextMatchEndNum(0),
argvTypeRef(0),
- context(0)
+ context(0),
+ inContiguous(false)
{
}
diff --git a/colm/parsedata.h b/colm/parsedata.h
index c4a034a8..ac39e0b2 100644
--- a/colm/parsedata.h
+++ b/colm/parsedata.h
@@ -1040,6 +1040,8 @@ struct Compiler
TypeRef *argvTypeRef;
Context *context;
+
+ bool inContiguous;
};
void afterOpMinimize( FsmGraph *fsm, bool lastInSeq = true );
diff --git a/colm/synthesis.cc b/colm/synthesis.cc
index 8f5c0975..88bdbee1 100644
--- a/colm/synthesis.cc
+++ b/colm/synthesis.cc
@@ -1130,8 +1130,13 @@ void LangVarRef::popRefQuals( Compiler *pd, CodeVect &code,
UniqueType *LangVarRef::evaluateCall( Compiler *pd, CodeVect &code, ExprVect *args )
{
- code.append( IN_CONTIGUOUS );
- code.appendHalf( 512 );
+ bool resetContiguous = false;
+ if ( !pd->inContiguous ) {
+ code.append( IN_CONTIGUOUS );
+ code.appendHalf( 512 );
+ pd->inContiguous = true;
+ resetContiguous = true;
+ }
/* Evaluate the object. */
VarRefLookup lookup = lookupMethod( pd );
@@ -1147,6 +1152,9 @@ UniqueType *LangVarRef::evaluateCall( Compiler *pd, CodeVect &code, ExprVect *ar
resetActiveRefs( pd, lookup, paramRefs);
delete[] paramRefs;
+ if ( resetContiguous )
+ pd->inContiguous = false;
+
/* Return the type to the expression. */
return lookup.uniqueType;
}
@@ -1979,6 +1987,14 @@ UniqueType *LangTerm::evaluateMakeToken( Compiler *pd, CodeVect &code ) const
UniqueType *LangTerm::evaluateMakeTree( Compiler *pd, CodeVect &code ) const
{
+ bool resetContiguous = false;
+ if ( !pd->inContiguous ) {
+ code.append( IN_CONTIGUOUS );
+ code.appendHalf( 512 );
+ pd->inContiguous = true;
+ resetContiguous = true;
+ }
+
if ( pd->compileContext != Compiler::CompileTranslation )
error(loc) << "make_tree can be used only in a translation block" << endp;
@@ -1999,6 +2015,9 @@ UniqueType *LangTerm::evaluateMakeTree( Compiler *pd, CodeVect &code ) const
code.append( IN_MAKE_TREE );
code.append( args->length() );
+ if ( resetContiguous )
+ pd->inContiguous = false;
+
return pd->uniqueTypeAny;
}
@@ -2100,8 +2119,13 @@ LangTerm *LangStmt::chooseDefaultIter( Compiler *pd, LangTerm *fromVarRef ) cons
void LangStmt::compileForIter( Compiler *pd, CodeVect &code ) const
{
- code.append( IN_CONTIGUOUS );
- code.appendHalf( 512 );
+ bool resetContiguous = false;
+ if ( !pd->inContiguous ) {
+ code.append( IN_CONTIGUOUS );
+ code.appendHalf( 512 );
+ pd->inContiguous = true;
+ resetContiguous = true;
+ }
pd->curLocalFrame->iterPushScope();
@@ -2163,6 +2187,9 @@ void LangStmt::compileForIter( Compiler *pd, CodeVect &code ) const
delete[] paramRefs;
pd->curLocalFrame->iterPopScope();
+
+ if ( resetContiguous )
+ pd->inContiguous = false;
}
void LangStmt::compileWhile( Compiler *pd, CodeVect &code ) const