diff options
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/lookup.cc | 46 | ||||
-rw-r--r-- | src/parsetree.h | 3 | ||||
-rw-r--r-- | src/resolve.cc | 13 | ||||
-rw-r--r-- | src/synthesis.cc | 2 |
5 files changed, 51 insertions, 15 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 4e50caf6..c39371bc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -53,7 +53,7 @@ libprog_a_SOURCES = \ parsetree.h pcheck.h pdacodegen.h pdagraph.h pdarun.h pool.h redbuild.h \ redfsm.h rtvector.h tree.h version.h global.h colm.h parser.h cstring.h \ \ - resolve.cc synthesis.cc parsetree.cc \ + resolve.cc lookup.cc synthesis.cc parsetree.cc \ fsmstate.cc fsmbase.cc fsmattach.cc fsmmin.cc \ fsmgraph.cc pdagraph.cc pdabuild.cc pdacodegen.cc fsmcodegen.cc \ redfsm.cc fsmexec.cc redbuild.cc closure.cc fsmap.cc \ diff --git a/src/lookup.cc b/src/lookup.cc new file mode 100644 index 00000000..a2815acb --- /dev/null +++ b/src/lookup.cc @@ -0,0 +1,46 @@ +/* + * Copyright 2007-2014 Adrian Thurston <thurston@complang.org> + */ + +/* This file is part of Colm. + * + * Colm is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Colm is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Colm; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "bytecode.h" +#include "parsedata.h" + +#include <iostream> +#include <assert.h> + +using std::cout; +using std::cerr; +using std::endl; + +UniqueType *LangVarRef::lookup( Compiler *pd ) const +{ + /* Lookup the loadObj. */ + VarRefLookup lookup = lookupField( pd ); + + ObjectField *el = lookup.objField; + UniqueType *elUT = el->typeRef->uniqueType; + + /* Deref iterators. */ + if ( elUT->typeId == TYPE_ITER ) + elUT = el->typeRef->searchUniqueType; + + return elUT; +} + diff --git a/src/parsetree.h b/src/parsetree.h index b2892983..c73fca1c 100644 --- a/src/parsetree.h +++ b/src/parsetree.h @@ -2465,7 +2465,8 @@ struct LangVarRef return l; } - UniqueType *resolve( Compiler *pd ) const; + void resolve( Compiler *pd ) const; + UniqueType *lookup( Compiler *pd ) const; UniqueType *loadFieldInstr( Compiler *pd, CodeVect &code, ObjectDef *inObject, ObjectField *el, bool forWriting, bool revert ) const; diff --git a/src/resolve.cc b/src/resolve.cc index d14d5c86..6b3c70d5 100644 --- a/src/resolve.cc +++ b/src/resolve.cc @@ -379,19 +379,8 @@ void LangTerm::resolve( Compiler *pd ) } } -UniqueType *LangVarRef::resolve( Compiler *pd ) const +void LangVarRef::resolve( Compiler *pd ) const { - /* Lookup the loadObj. */ - VarRefLookup lookup = lookupField( pd ); - - ObjectField *el = lookup.objField; - UniqueType *elUT = el->typeRef->uniqueType; - - /* Deref iterators. */ - if ( elUT->typeId == TYPE_ITER ) - elUT = el->typeRef->searchUniqueType; - - return elUT; } void LangExpr::resolve( Compiler *pd ) const diff --git a/src/synthesis.cc b/src/synthesis.cc index d9dad476..34130d5c 100644 --- a/src/synthesis.cc +++ b/src/synthesis.cc @@ -1711,7 +1711,7 @@ void LangTerm::evaluateSendParser( Compiler *pd, CodeVect &code ) const UniqueType *LangTerm::evaluateSend( Compiler *pd, CodeVect &code ) const { - UniqueType *varUt = varRef->resolve( pd ); + UniqueType *varUt = varRef->lookup( pd ); if ( varUt == pd->uniqueTypeStream ) { evaluateSendStream( pd, code ); |