50 class CSymtabEntry :
public map<CSymbol*,T1*>
53 CSymtabEntry* previous;
59 CSymtabEntry( CSymtabEntry* parent )
68 CSymtabEntry* GetPrevious() {
80 typename map<CSymbol*,T1*>::iterator ptr;
83 ptr = this->find( key );
84 if( ptr != this->end() ) {
88 result = previous->Lookup( key );
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 )
113 typename map<CSymbol*,T1*>::iterator ptr;
115 for( ptr = this->begin(); ptr != this->end(); ++ptr) {
116 printf(
"\t%s => ", ptr->first->GetName() );
117 ptr->second->DumpDeclInfo( f );
119 if( recurse && previous != NULL ) {
120 previous->Dump( f, recurse );
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 );
203 T1* result = table->Lookup( sym );
205 typename list<CSymtab<T1> >::iterator ptr;
206 for( ptr = importPath.begin(); ptr != importPath.end(); ++ptr ) {
207 result = ptr->Lookup( sym );
232 importPath.push_back( table );
240 void Dump( FILE *f,
int recurse )
242 table->Dump( f, recurse );
247 #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:230
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
T1 * Lookup(CSymbol *sym)
Lookup symbol in all scopes starting at the current scope.
Definition: csymtab.h:201
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:240
void PushScope()
Create a new scope for table.
Definition: csymtab.h:167