summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2014-01-04 10:00:43 -0500
committerAdrian Thurston <thurston@complang.org>2014-01-04 10:00:43 -0500
commit39a0d2775b9106462b1e41d18e8fbdbc25116f88 (patch)
tree87e227747d1232134fb9966bd804a22ea34a86c7
parent0681e8d12912b147a98f9328db6e1e55762f690c (diff)
downloadcolm-39a0d2775b9106462b1e41d18e8fbdbc25116f88.tar.gz
moved the creation of match, input, ctx vars to declare pass
-rw-r--r--src/declare.cc78
-rw-r--r--src/synthesis.cc72
2 files changed, 78 insertions, 72 deletions
diff --git a/src/declare.cc b/src/declare.cc
index ec55e812..1d4ab04e 100644
--- a/src/declare.cc
+++ b/src/declare.cc
@@ -561,12 +561,23 @@ void Compiler::declareReductionCode( Production *prod )
void Compiler::declareTranslateBlock( LangEl *langEl )
{
CodeBlock *block = langEl->transBlock;
+
+ /* References to the reduce item. */
+ addMatchLength( block->localFrame, langEl );
+ addMatchText( block->localFrame, langEl );
+ addInput( block->localFrame );
+ addCtx( block->localFrame );
+
block->declare( this );
}
void Compiler::declarePreEof( TokenRegion *region )
{
CodeBlock *block = region->preEofBlock;
+
+ addInput( block->localFrame );
+ addCtx( block->localFrame );
+
block->declare( this );
}
@@ -652,6 +663,73 @@ void Compiler::makeDefaultIterators()
}
}
+void Compiler::addMatchLength( ObjectDef *frame, LangEl *lel )
+{
+ /* Make the type ref. */
+ TypeRef *typeRef = TypeRef::cons( internal, uniqueTypeInt );
+
+ /* Create the field and insert it into the map. */
+ ObjectField *el = ObjectField::cons( InputLoc(), typeRef, "match_length" );
+ el->beenReferenced = true;
+ el->beenInitialized = true;
+ el->isConst = true;
+ el->useOffset = false;
+ el->inGetR = IN_GET_MATCH_LENGTH_R;
+ frame->insertField( el->name, el );
+}
+
+void Compiler::addMatchText( ObjectDef *frame, LangEl *lel )
+{
+ /* Make the type ref. */
+ TypeRef *typeRef = TypeRef::cons( internal, uniqueTypeStr );
+
+ /* Create the field and insert it into the map. */
+ ObjectField *el = ObjectField::cons( internal, typeRef, "match_text" );
+ el->beenReferenced = true;
+ el->beenInitialized = true;
+ el->isConst = true;
+ el->useOffset = false;
+ el->inGetR = IN_GET_MATCH_TEXT_R;
+ frame->insertField( el->name, el );
+}
+
+void Compiler::addInput( ObjectDef *frame )
+{
+ /* Make the type ref. */
+ TypeRef *typeRef = TypeRef::cons( internal, uniqueTypeStream );
+
+ /* Create the field and insert it into the map. */
+ ObjectField *el = ObjectField::cons( internal, typeRef, "input" );
+ el->beenReferenced = true;
+ el->beenInitialized = true;
+ el->isConst = false;
+ el->useOffset = false;
+ el->isCustom = true;
+ el->inGetR = IN_LOAD_INPUT_R;
+ el->inGetWV = IN_LOAD_INPUT_WV;
+ el->inGetWC = IN_LOAD_INPUT_WC;
+ frame->insertField( el->name, el );
+}
+
+void Compiler::addCtx( ObjectDef *frame )
+{
+ /* Make the type ref. */
+ TypeRef *typeRef = TypeRef::cons( internal, uniqueTypeStream );
+
+ /* Create the field and insert it into the map. */
+ ObjectField *el = ObjectField::cons( internal, typeRef, "ctx" );
+ el->beenReferenced = true;
+ el->beenInitialized = true;
+ el->isConst = false;
+ el->useOffset = false;
+ el->isCustom = true;
+ el->inGetR = IN_LOAD_CTX_R;
+ el->inGetWV = IN_LOAD_CTX_WV;
+ el->inGetWC = IN_LOAD_CTX_WC;
+ frame->insertField( el->name, el );
+}
+
+
/*
* Type Declaration Root.
diff --git a/src/synthesis.cc b/src/synthesis.cc
index e98e1f6c..33853bd4 100644
--- a/src/synthesis.cc
+++ b/src/synthesis.cc
@@ -2232,72 +2232,6 @@ void CodeBlock::compile( Compiler *pd, CodeVect &code ) const
stmt->compile( pd, code );
}
-void Compiler::addMatchLength( ObjectDef *frame, LangEl *lel )
-{
- /* Make the type ref. */
- TypeRef *typeRef = TypeRef::cons( internal, uniqueTypeInt );
-
- /* Create the field and insert it into the map. */
- ObjectField *el = ObjectField::cons( InputLoc(), typeRef, "match_length" );
- el->beenReferenced = true;
- el->beenInitialized = true;
- el->isConst = true;
- el->useOffset = false;
- el->inGetR = IN_GET_MATCH_LENGTH_R;
- frame->insertField( el->name, el );
-}
-
-void Compiler::addMatchText( ObjectDef *frame, LangEl *lel )
-{
- /* Make the type ref. */
- TypeRef *typeRef = TypeRef::cons( internal, uniqueTypeStr );
-
- /* Create the field and insert it into the map. */
- ObjectField *el = ObjectField::cons( internal, typeRef, "match_text" );
- el->beenReferenced = true;
- el->beenInitialized = true;
- el->isConst = true;
- el->useOffset = false;
- el->inGetR = IN_GET_MATCH_TEXT_R;
- frame->insertField( el->name, el );
-}
-
-void Compiler::addInput( ObjectDef *frame )
-{
- /* Make the type ref. */
- TypeRef *typeRef = TypeRef::cons( internal, uniqueTypeStream );
-
- /* Create the field and insert it into the map. */
- ObjectField *el = ObjectField::cons( internal, typeRef, "input" );
- el->beenReferenced = true;
- el->beenInitialized = true;
- el->isConst = false;
- el->useOffset = false;
- el->isCustom = true;
- el->inGetR = IN_LOAD_INPUT_R;
- el->inGetWV = IN_LOAD_INPUT_WV;
- el->inGetWC = IN_LOAD_INPUT_WC;
- frame->insertField( el->name, el );
-}
-
-void Compiler::addCtx( ObjectDef *frame )
-{
- /* Make the type ref. */
- TypeRef *typeRef = TypeRef::cons( internal, uniqueTypeStream );
-
- /* Create the field and insert it into the map. */
- ObjectField *el = ObjectField::cons( internal, typeRef, "ctx" );
- el->beenReferenced = true;
- el->beenInitialized = true;
- el->isConst = false;
- el->useOffset = false;
- el->isCustom = true;
- el->inGetR = IN_LOAD_CTX_R;
- el->inGetWV = IN_LOAD_CTX_WV;
- el->inGetWC = IN_LOAD_CTX_WC;
- frame->insertField( el->name, el );
-}
-
void Compiler::initFieldInstructions( ObjectField *el )
{
el->inGetR = IN_GET_FIELD_R;
@@ -2602,12 +2536,6 @@ void Compiler::compileTranslateBlock( LangEl *langEl )
revertOn = true;
block->frameId = nextFrameId++;
- /* References to the reduce item. */
- addMatchLength( curLocalFrame, langEl );
- addMatchText( curLocalFrame, langEl );
- addInput( curLocalFrame );
- addCtx( curLocalFrame );
-
CodeVect &code = block->codeWV;
/* Add the alloc frame opcode. We don't have the right