summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--colm/compile.cc38
-rw-r--r--colm/parsedata.cc4
-rw-r--r--colm/resolve.cc20
3 files changed, 42 insertions, 20 deletions
diff --git a/colm/compile.cc b/colm/compile.cc
index 43b64354..b7c115e7 100644
--- a/colm/compile.cc
+++ b/colm/compile.cc
@@ -344,7 +344,7 @@ void ObjectDef::initField( ParseData *pd, ObjField *field )
{
if ( !field->beenInitialized ) {
field->beenInitialized = true;
- UniqueType *fieldUT = field->typeRef->lookupType( pd );
+ UniqueType *fieldUT = field->typeRef->uniqueType;//lookupType( pd );
if ( type == FrameType ) {
nextOffset += sizeOfField( fieldUT );
@@ -368,7 +368,7 @@ UniqueType *LangVarRef::loadFieldInstr( ParseData *pd, CodeVect &code,
/* Ensure that the field is referenced. */
inObject->referenceField( pd, el );
- UniqueType *elUT = el->typeRef->lookupType( pd );
+ UniqueType *elUT = el->typeRef->uniqueType;//lookupType( pd );
/* If it's a reference then we load it read always. */
if ( forWriting ) {
@@ -396,7 +396,7 @@ UniqueType *LangVarRef::loadFieldInstr( ParseData *pd, CodeVect &code,
/* If we are dealing with an iterator then dereference it. */
if ( elUT->typeId == TYPE_ITER )
- elUT = el->typeRef->searchTypeRef->lookupType( pd );
+ elUT = el->typeRef->searchTypeRef->uniqueType;//lookupType( pd );
return elUT;
}
@@ -446,9 +446,9 @@ long LangVarRef::loadQualificationRefs( ParseData *pd, CodeVect &code ) const
code.appendHalf( el->offset );
}
- UniqueType *elUT = el->typeRef->lookupType( pd );
+ UniqueType *elUT = el->typeRef->uniqueType;//lookupType( pd );
if ( elUT->typeId == TYPE_ITER )
- elUT = el->typeRef->searchTypeRef->lookupType( pd );
+ elUT = el->typeRef->searchTypeRef->uniqueType;//lookupType( pd );
assert( qi->type == QualItem::Dot );
@@ -667,11 +667,11 @@ VarRefLookup LangVarRef::lookupQualification( ParseData *pd, ObjectDef *rootDef
error(qi->loc) << "cannot resolve qualification " << qi->data << endp;
/* Lookup the type of the field. */
- UniqueType *qualUT = el->typeRef->lookupType( pd );
+ UniqueType *qualUT = el->typeRef->uniqueType;//lookupType( pd );
/* If we are dealing with an iterator then dereference it. */
if ( qualUT->typeId == TYPE_ITER )
- qualUT = el->typeRef->searchTypeRef->lookupType( pd );
+ qualUT = el->typeRef->searchTypeRef->uniqueType;//lookupType( pd );
/* Is it const? */
if ( firstConstPart < 0 && el->isConst )
@@ -690,7 +690,7 @@ VarRefLookup LangVarRef::lookupQualification( ParseData *pd, ObjectDef *rootDef
}
else if ( qi->type == QualItem::Arrow ) {
if ( qualUT->typeId == TYPE_ITER )
- qualUT = el->typeRef->searchTypeRef->lookupType( pd );
+ qualUT = el->typeRef->searchTypeRef->uniqueType;//lookupType( pd );
else if ( qualUT->typeId == TYPE_PTR )
qualUT = pd->findUniqueType( TYPE_TREE, qualUT->langEl );
}
@@ -725,10 +725,10 @@ VarRefLookup LangVarRef::lookupField( ParseData *pd ) const
error(loc) << "cannot find name " << name << " in object" << endp;
lookup.objField = field;
- lookup.uniqueType = field->typeRef->lookupType( pd );
+ lookup.uniqueType = field->typeRef->uniqueType;//lookupType( pd );
if ( field->typeRef->searchTypeRef != 0 )
- lookup.iterSearchUT = field->typeRef->searchTypeRef->lookupType( pd );
+ lookup.iterSearchUT = field->typeRef->searchTypeRef->uniqueType;//lookupType( pd );
return lookup;
}
@@ -1146,7 +1146,7 @@ void LangTerm::assignFieldArgs( ParseData *pd, CodeVect &code, UniqueType *replU
/* Lookup the type of the field and compare it to the type of the
* expression. */
- UniqueType *fieldUT = field->typeRef->lookupType( pd );
+ UniqueType *fieldUT = field->typeRef->uniqueType;//lookupType( pd );
if ( !castAssignment( pd, code, fieldUT, 0, fieldInit->exprUT ) )
error(fieldInit->loc) << "type mismatch in initialization" << endp;
@@ -1705,8 +1705,8 @@ void LangVarRef::assignValue( ParseData *pd, CodeVect &code,
lookup.objField->dirtyTree = true;
/* Check the types of the assignment and possibly cast. */
- UniqueType *objUT = lookup.objField->typeRef->lookupType( pd );
- assert( lookup.uniqueType == lookup.objField->typeRef->lookupType( pd ) );
+ UniqueType *objUT = lookup.objField->typeRef->uniqueType;//lookupType( pd );
+ assert( lookup.uniqueType == lookup.objField->typeRef->uniqueType );//lookupType( pd ) );
if ( !castAssignment( pd, code, objUT, lookup.iterSearchUT, exprUT ) )
error(loc) << "type mismatch in assignment" << endp;
@@ -1893,8 +1893,12 @@ void LangStmt::compileForIter( ParseData *pd, CodeVect &code ) const
/* Now that we have done the iterator call lookup we can make the type
* reference for the object field. */
- TypeRef *iterTypeRef = new TypeRef( loc, lookup.objMethod->iterDef, typeRef );
- objField->typeRef = iterTypeRef;
+ objField->typeRef = new TypeRef( loc, lookup.objMethod->iterDef, typeRef );
+
+ /* FIXME: this should go to the resolve stage, but the new typref needs to
+ * be moved too. */
+ objField->typeRef->lookupType( pd );
+ objField->typeRef->searchTypeRef->lookupType( pd );
/* Also force the field to be initialized. */
pd->curLocalFrame->initField( pd, objField );
@@ -1903,7 +1907,7 @@ void LangStmt::compileForIter( ParseData *pd, CodeVect &code ) const
* Create the iterator from the local var.
*/
- UniqueType *iterUT = iterTypeRef->lookupType( pd );
+ UniqueType *iterUT = objField->typeRef->uniqueType;//lookupType( pd );
/* Evaluate and push the arguments. */
ObjField **paramRefs = iterCallTerm->varRef->evaluateArgs(
@@ -2481,7 +2485,7 @@ void ParseData::findLocalTrees( CharSet &trees )
/* FIXME: This test needs to be improved. Match_text was getting
* through before useOffset was tested. What will? */
if ( el->useOffset && !el->isLhsEl && ( el->beenReferenced || el->isParam ) ) {
- UniqueType *ut = el->typeRef->lookupType( this );
+ UniqueType *ut = el->typeRef->uniqueType;//lookupType( this );
if ( ut->typeId == TYPE_TREE || ut->typeId == TYPE_PTR )
trees.insert( el->offset );
}
diff --git a/colm/parsedata.cc b/colm/parsedata.cc
index e5454e94..7631202a 100644
--- a/colm/parsedata.cc
+++ b/colm/parsedata.cc
@@ -1438,11 +1438,11 @@ void ParseData::semanticAnalysis()
resolveReplacementEls();
resolveAccumEls();
- resolveParseTree();
-
/* This needs to happen before the scanner is built. */
resolveProductionEls();
+ resolveParseTree();
+
makeTerminalWrappers();
makeEofElements();
resolveGenericTypes();
diff --git a/colm/resolve.cc b/colm/resolve.cc
index 00f7533d..841f5d46 100644
--- a/colm/resolve.cc
+++ b/colm/resolve.cc
@@ -302,7 +302,6 @@ void ObjectDef::resolve( ParseData *pd )
ObjField *field = fli->value;
if ( field->typeRef != 0 ) {
- cout << "lookup type" << endl;
field->typeRef->lookupType( pd );
}
}
@@ -337,6 +336,8 @@ void ParseData::resolvePreEof( TokenRegion *region )
void ParseData::resolveRootBlock()
{
+ rootLocalFrame->resolve( this );
+
CodeBlock *block = rootCodeBlock;
block->resolve( this );
}
@@ -389,6 +390,23 @@ void ParseData::resolveParseTree()
/* Compile the init code */
resolveRootBlock( );
+
+ /* Init all user object fields (need consistent size). */
+ for ( LelList::Iter lel = langEls; lel.lte(); lel++ ) {
+ ObjectDef *objDef = lel->objectDef;
+ if ( objDef != 0 ) {
+ /* Init all fields of the object. */
+ for ( ObjFieldList::Iter f = *objDef->objFieldList; f.lte(); f++ ) {
+ f->value->typeRef->lookupType( this );
+ }
+ }
+ }
+
+ /* Init all fields of the global object. */
+ for ( ObjFieldList::Iter f = *globalObjectDef->objFieldList; f.lte(); f++ ) {
+ f->value->typeRef->lookupType( this );
+ }
+
}