50 class CSymtabEntry :
public map<CSymbol*,T1*>
53 CSymtabEntry* previous;
59 CSymtabEntry( CSymtabEntry* parent )
68 CSymtabEntry* GetPrevious() {
77 T1* Lookup(
CSymbol* key,
int skip=0 )
80 typename map<CSymbol*,T1*>::iterator ptr;
83 ptr = this->find( key );
84 if( skip==0 && ptr != this->end() ) {
88 result = previous->Lookup( key, skip>0 ? skip-1 : 0 );
101 typename map<CSymbol*,T1*>::iterator ptr;
104 ptr = this->find( key );
105 if( ptr != this->end() ) {
106 result = ptr->second;
111 void Dump( FILE *f,
int recurse,
int level = 0 )
113 typename map<CSymbol*,T1*>::iterator ptr;
115 for( ptr = this->begin(); ptr != this->end(); ++ptr) {
116 printf(
"\t%d::%s => ", level, ptr->first->GetName() );
117 ptr->second->DumpDeclInfo( f );
119 if( recurse && previous != NULL ) {
120 previous->Dump( f, recurse, level+1 );
139 CSymtabEntry<T1>* table;
140 list<CSymtab<T1> > importPath;
153 table =
new CSymtabEntry<T1>( NULL );
160 MASSERT( table != NULL );
162 table = table->GetPrevious();
169 table =
new CSymtabEntry<T1>( table );
192 return table->LookupTop( sym );
204 T1* result = table->Lookup( sym, skip );
206 typename list<CSymtab<T1> >::iterator ptr;
207 for( ptr = importPath.begin(); ptr != importPath.end(); ++ptr ) {
208 result = ptr->Lookup( sym );
233 importPath.push_back( table );
241 void Dump( FILE *f,
int recurse )
243 table->Dump( f, recurse );
248 #endif // CSYMTAB_HPP
CSymtab()
Create a symbol table.
Definition: csymtab.h:151
void ImportSearchTable(CSymtab< T1 > &table)
Import all symbols given package.
Definition: csymtab.h:231
T1 * LookupTop(CSymbol *sym)
Lookup symbol only in current scope.
Definition: csymtab.h:189
static T1 * Resolve(CSymbol *sym)
hook for namespaces
void PopScope()
Jump back to parent scope.
Definition: csymtab.h:158
Aux class used to create symbol table scoping.
Definition: csymtab.h:136
void Add(CSymbol *sym, T1 *obj)
Add a symbol and it's assocated object at the current level.
Definition: csymtab.h:178
Holder for character strings.
Definition: csymbol.h:44
void Dump(FILE *f, int recurse)
Dump all symbols in table to file descriptor.
Definition: csymtab.h:241
T1 * Lookup(CSymbol *sym, int skip=0)
Lookup symbol in all scopes starting at the current scope.
Definition: csymtab.h:202
void PushScope()
Create a new scope for table.
Definition: csymtab.h:167