summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2011-07-06 06:59:32 +0000
committerAdrian Thurston <thurston@complang.org>2011-07-06 06:59:32 +0000
commit99462cb6687354fd12ae0859848c482ae5358f8a (patch)
treee722bbf13f9b4265553d912ee7b85cd38d31380b
parent0c5ac9491222c887082d919c7cd109af1ef9d60e (diff)
downloadcolm-99462cb6687354fd12ae0859848c482ae5358f8a.tar.gz
Unsugar type references (repeat, list, opt) on every lookupType. Bit more
towards general.
-rw-r--r--colm/lmparse.kl7
-rw-r--r--colm/parsetree.h8
-rw-r--r--colm/resolve.cc6
3 files changed, 11 insertions, 10 deletions
diff --git a/colm/lmparse.kl b/colm/lmparse.kl
index 01a8387d..972e0bb2 100644
--- a/colm/lmparse.kl
+++ b/colm/lmparse.kl
@@ -383,13 +383,13 @@ nonterm define_prod
define_prod: '[' prod_el_list ']' opt_commit opt_reduce_code opt_prec
final {
const InputLoc &loc = $1->loc;
- const String &name = curDefineId;
+ //const String &name = curDefineId;
ProdElList *prodElList = curProdElList;
bool commit = $4->commit;
CodeBlock *redBlock = $5->codeBlock;
KlangEl *predOf = $6->predOf;
- Namespace *nspace = namespaceStack.top();
+ //Namespace *nspace = namespaceStack.top();
Definition *newDef = new Definition( loc, 0/*prodName*/,
prodElList, commit, redBlock,
@@ -615,7 +615,8 @@ pattern_el: opt_label pattern_el_type_or_lit
" redeclared" << endp;
}
- TypeRef *typeRef = new TypeRef( InputLoc(), $2->patternItem->factor );
+ NamespaceQual *qual = new NamespaceQual( namespaceStack.top(), regionStack.top() );
+ TypeRef *typeRef = new TypeRef( InputLoc(), qual, $2->patternItem->factor );
ObjField *objField = new ObjField( InputLoc(), typeRef, $1->varRef->name );
/* Insert it into the field map. */
diff --git a/colm/parsetree.h b/colm/parsetree.h
index 6b591995..9ebafc5b 100644
--- a/colm/parsetree.h
+++ b/colm/parsetree.h
@@ -1345,7 +1345,7 @@ struct TypeRef
TypeRef( const InputLoc &loc, IterDef *iterDef, UniqueType *uniqueType,
UniqueType *searchUniqueType )
:
- loc(loc), iterDef(iterDef), factor(0),
+ loc(loc), nspaceQual(0), iterDef(iterDef), factor(0),
isPtr(false), isRef(false), repeatType(RepeatNone),
uniqueType(uniqueType), searchUniqueType(searchUniqueType) {}
@@ -1358,12 +1358,12 @@ struct TypeRef
/* 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), factor(factor),
+ TypeRef( const InputLoc &loc, NamespaceQual *nspaceQual, PdaFactor *factor ) :
+ loc(loc), nspaceQual(nspaceQual), iterDef(0), factor(factor),
isPtr(false), isRef(false), repeatType(RepeatNone),
uniqueType(0), searchUniqueType(0) {}
- void resolve( ParseData *pd ) const;
+ void sugaredDecls( ParseData *pd ) const;
UniqueType *lookupTypePart( ParseData *pd, NamespaceQual *nspaceQual,
const String &name );
UniqueType *lookupType( ParseData *pd );
diff --git a/colm/resolve.cc b/colm/resolve.cc
index 841f5d46..4d327f46 100644
--- a/colm/resolve.cc
+++ b/colm/resolve.cc
@@ -57,6 +57,8 @@ UniqueType *TypeRef::lookupType( ParseData *pd )
{
if ( uniqueType != 0 )
return uniqueType;
+
+ sugaredDecls( pd );
// cout << __PRETTY_FUNCTION__ << " " << typeName.data << " " << this << endl;
@@ -81,7 +83,7 @@ UniqueType *TypeRef::lookupType( ParseData *pd )
}
-void TypeRef::resolve( ParseData *pd ) const
+void TypeRef::sugaredDecls( ParseData *pd ) const
{
/* Look for the production's associated region. */
Namespace *nspace = nspaceQual->getQual( pd );
@@ -122,7 +124,6 @@ void LangTerm::resolve( ParseData *pd ) const
{
switch ( type ) {
case ConstructType:
- typeRef->resolve( pd );
typeRef->lookupType( pd );
/* Evaluate the initialization expressions. */
@@ -163,7 +164,6 @@ void LangTerm::resolve( ParseData *pd ) const
case ParseType:
case ParseStopType:
- typeRef->resolve( pd );
typeRef->lookupType( pd );
break;