00001 /* 00002 FALCON - The Falcon Programming Language. 00003 FILE: flc_symtab.h 00004 00005 Symbol table definition 00006 ------------------------------------------------------------------- 00007 Author: Giancarlo Niccolai 00008 Begin: mar ago 3 2004 00009 00010 ------------------------------------------------------------------- 00011 (C) Copyright 2004: the FALCON developers (see list in AUTHORS file) 00012 00013 See LICENSE file for licensing details. 00014 */ 00015 00016 #ifndef FLC_SYMBOLTABLE_H 00017 #define FLC_SYMBOLTABLE_H 00018 00019 #include <falcon/setup.h> 00020 #include <falcon/common.h> 00021 #include <falcon/string.h> 00022 #include <falcon/genericvector.h> 00023 #include <falcon/genericmap.h> 00024 #include <falcon/basealloc.h> 00025 00026 namespace Falcon { 00027 00028 class Symbol; 00029 class Stream; 00030 class Module; 00031 00032 class FALCON_DYN_CLASS SymbolTable: public BaseAlloc 00033 { 00037 Map m_map; 00038 00039 public: 00043 SymbolTable(); 00044 00050 bool add( Symbol *sym ); 00051 00065 bool add( const String *name, Symbol *sym ); 00066 00075 Symbol *findByName( const String &name ) const 00076 { 00077 Symbol **ptrsym = (Symbol **) m_map.find( &name ); 00078 if ( ptrsym == 0 ) 00079 return 0; 00080 return *ptrsym; 00081 } 00082 00086 void exportUndefined(); 00087 00095 bool remove( const String &name ); 00096 00097 00101 int size() const { 00102 return m_map.size(); 00103 } 00104 00105 00113 bool save( Stream *out ) const; 00114 00125 bool load( Module *owner, Stream *in ); 00126 00127 const Map &map() const { return m_map; } 00128 }; 00129 00130 class FALCON_DYN_CLASS SymbolVector: public GenericVector 00131 { 00132 00133 public: 00134 SymbolVector(); 00135 00136 ~SymbolVector(); 00137 00138 Symbol *symbolAt( uint32 pos ) const { return *(Symbol **) at( pos ); } 00139 00140 bool save( Stream *out ) const; 00141 bool load( Module *owner, Stream *in ); 00142 }; 00143 00144 } 00145 #endif 00146 /* end of flc_symtab.h */