diff options
-rw-r--r-- | colm/compiler.cc | 3 | ||||
-rw-r--r-- | colm/parsedata.h | 2 | ||||
-rw-r--r-- | colm/synthesis.cc | 35 |
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 §ionName, 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 |