diff options
author | Adrian Thurston <thurston@complang.org> | 2011-07-04 06:16:58 +0000 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2011-07-04 06:16:58 +0000 |
commit | 0c5ac9491222c887082d919c7cd109af1ef9d60e (patch) | |
tree | c50ebffd4ccdda35ec228e7cf4f9e0871992e941 | |
parent | 7d7fd45c3b41587d2d024bb236ed66bfdccb20f8 (diff) | |
download | colm-0c5ac9491222c887082d919c7cd109af1ef9d60e.tar.gz |
Removed the final two lookupType calls from the resolve class.
refs #298
-rw-r--r-- | colm/compile.cc | 42 | ||||
-rw-r--r-- | colm/parsetree.h | 22 |
2 files changed, 31 insertions, 33 deletions
diff --git a/colm/compile.cc b/colm/compile.cc index 9d0d2592..f9b70b52 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->uniqueType;//lookupType( pd ); + UniqueType *fieldUT = field->typeRef->uniqueType; 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->uniqueType;//lookupType( pd ); + UniqueType *elUT = el->typeRef->uniqueType; /* 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->uniqueType;//lookupType( pd ); + elUT = el->typeRef->searchUniqueType; return elUT; } @@ -446,9 +446,9 @@ long LangVarRef::loadQualificationRefs( ParseData *pd, CodeVect &code ) const code.appendHalf( el->offset ); } - UniqueType *elUT = el->typeRef->uniqueType;//lookupType( pd ); + UniqueType *elUT = el->typeRef->uniqueType; if ( elUT->typeId == TYPE_ITER ) - elUT = el->typeRef->searchTypeRef->uniqueType;//lookupType( pd ); + elUT = el->typeRef->searchUniqueType; 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->uniqueType;//lookupType( pd ); + UniqueType *qualUT = el->typeRef->uniqueType; /* If we are dealing with an iterator then dereference it. */ if ( qualUT->typeId == TYPE_ITER ) - qualUT = el->typeRef->searchTypeRef->uniqueType;//lookupType( pd ); + qualUT = el->typeRef->searchUniqueType; /* 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->uniqueType;//lookupType( pd ); + qualUT = el->typeRef->searchUniqueType; 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->uniqueType;//lookupType( pd ); + lookup.uniqueType = field->typeRef->uniqueType; - if ( field->typeRef->searchTypeRef != 0 ) - lookup.iterSearchUT = field->typeRef->searchTypeRef->uniqueType;//lookupType( pd ); + if ( field->typeRef->searchUniqueType != 0 ) + lookup.iterSearchUT = field->typeRef->searchUniqueType; 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->uniqueType;//lookupType( pd ); + UniqueType *fieldUT = field->typeRef->uniqueType; if ( !castAssignment( pd, code, fieldUT, 0, fieldInit->exprUT ) ) error(fieldInit->loc) << "type mismatch in initialization" << endp; @@ -1463,7 +1463,7 @@ UniqueType *LangTerm::evaluate( ParseData *pd, CodeVect &code ) const return evaluateNew( pd, code ); case TypeIdType: { /* Evaluate the expression. */ - UniqueType *ut = typeRef->uniqueType;//lookupType( pd ); + UniqueType *ut = typeRef->uniqueType; if ( ut->typeId != TYPE_TREE ) error() << "typeid can only be applied to tree types" << 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->uniqueType;//lookupType( pd ); - assert( lookup.uniqueType == lookup.objField->typeRef->uniqueType );//lookupType( pd ) ); + UniqueType *objUT = lookup.objField->typeRef->uniqueType; + assert( lookup.uniqueType == lookup.objField->typeRef->uniqueType ); if ( !castAssignment( pd, code, objUT, lookup.iterSearchUT, exprUT ) ) error(loc) << "type mismatch in assignment" << endp; @@ -1893,12 +1893,8 @@ 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. */ - 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 ); + UniqueType *iterUniqueType = pd->findUniqueType( TYPE_ITER, lookup.objMethod->iterDef ); + objField->typeRef = new TypeRef( loc, lookup.objMethod->iterDef, iterUniqueType, searchUT ); /* Also force the field to be initialized. */ pd->curLocalFrame->initField( pd, objField ); @@ -1907,7 +1903,7 @@ void LangStmt::compileForIter( ParseData *pd, CodeVect &code ) const * Create the iterator from the local var. */ - UniqueType *iterUT = objField->typeRef->uniqueType;//lookupType( pd ); + UniqueType *iterUT = objField->typeRef->uniqueType; /* Evaluate and push the arguments. */ ObjField **paramRefs = iterCallTerm->varRef->evaluateArgs( @@ -2442,7 +2438,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->uniqueType;//lookupType( this ); + UniqueType *ut = el->typeRef->uniqueType; if ( ut->typeId == TYPE_TREE || ut->typeId == TYPE_PTR ) trees.insert( el->offset ); } diff --git a/colm/parsetree.h b/colm/parsetree.h index 84c08002..6b591995 100644 --- a/colm/parsetree.h +++ b/colm/parsetree.h @@ -1337,29 +1337,31 @@ struct TypeRef /* Qualification and a type name. These require lookup. */ TypeRef( const InputLoc &loc, NamespaceQual *nspaceQual, String typeName ) : loc(loc), nspaceQual(nspaceQual), typeName(typeName), iterDef(0), - searchTypeRef(0), factor(0), + factor(0), isPtr(false), isRef(false), repeatType(RepeatNone), - uniqueType(0) {} + uniqueType(0), searchUniqueType(0) {} /* Iterator definition. */ - TypeRef( const InputLoc &loc, IterDef *iterDef, TypeRef *searchTypeRef ) : - loc(loc), iterDef(iterDef), searchTypeRef(searchTypeRef), factor(0), + TypeRef( const InputLoc &loc, IterDef *iterDef, UniqueType *uniqueType, + UniqueType *searchUniqueType ) + : + loc(loc), iterDef(iterDef), factor(0), isPtr(false), isRef(false), repeatType(RepeatNone), - uniqueType(0) {} + uniqueType(uniqueType), searchUniqueType(searchUniqueType) {} /* Unique type is given directly. */ TypeRef( const InputLoc &loc, UniqueType *uniqueType ) : - loc(loc), nspaceQual(0), iterDef(0), searchTypeRef(0), factor(0), + loc(loc), nspaceQual(0), iterDef(0), factor(0), isPtr(false), isRef(false), repeatType(RepeatNone), - uniqueType(uniqueType) {} + uniqueType(uniqueType), searchUniqueType(0) {} /* A factor in a pattern. In the case of matches we need a type ref at * parse time, but factors have not been resolved yet, so this allows us * to do it on demand. */ TypeRef( const InputLoc &loc, PdaFactor *factor ) : - loc(loc), nspaceQual(0), iterDef(0), searchTypeRef(0), factor(factor), + loc(loc), nspaceQual(0), iterDef(0), factor(factor), isPtr(false), isRef(false), repeatType(RepeatNone), - uniqueType(0) {} + uniqueType(0), searchUniqueType(0) {} void resolve( ParseData *pd ) const; UniqueType *lookupTypePart( ParseData *pd, NamespaceQual *nspaceQual, @@ -1370,7 +1372,6 @@ struct TypeRef NamespaceQual *nspaceQual; String typeName; IterDef *iterDef; - TypeRef *searchTypeRef; PdaFactor *factor; bool isPtr; bool isRef; @@ -1378,6 +1379,7 @@ struct TypeRef /* Resolved. */ UniqueType *uniqueType; + UniqueType *searchUniqueType; }; typedef DList<ObjField> ParameterList; |