00001
00002 #ifndef SYM_H
00003 #define SYM_H
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "typedefs.h"
00017 #include "list.h"
00018 #include "const.h"
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00044 class src_ref {
00045 ushort file_num;
00046 ushort offset;
00047 uint line_num;
00048 };
00049
00050
00051 enum { bad_symbol,
00052 sy_ident,
00053 sy_type,
00054 sy_const,
00055 sy_subprog,
00056 sy_component,
00057 sy_package,
00058 sy_process,
00059 sy_block_label
00060 };
00061
00062 class symtable;
00063 class typetable;
00064
00073 class sym {
00074 private:
00075 STRING name;
00076 src_ref m_sr;
00077 uint m_referenced : 1,
00078 m_unused : 31;
00079
00080 public:
00081 sym(STRING n )
00082 {
00083 name = n;
00084 m_referenced = FALSE;
00085 }
00086
00087 sym( )
00088 {
00089 name.SetText( NULL );
00090 m_referenced = FALSE;
00091 }
00092
00093
00094 void *operator new( unsigned int num_bytes )
00095 {
00096 assert( FALSE );
00097 return NULL;
00098 }
00099
00100
00101
00102
00103 void *operator new( unsigned int num_bytes, pool *mem_pool )
00104 {
00105 return mem_pool->GetMem( num_bytes );
00106 }
00107
00108
00109
00110 void operator delete( void *addr ) {}
00111
00112 STRING get_name(void) { return name; }
00113 void set_name( const STRING str ) { name = str; }
00114
00115 void set_referenced(void) { m_referenced = TRUE; }
00116 void unset_referenced(void) { m_referenced = FALSE; }
00117 const Boolean is_referenced(void) { return m_referenced; }
00118
00119
00120
00121
00122 virtual const uint get_sy_kind(void) { return bad_symbol; }
00123
00124
00125
00126
00127
00128
00129 virtual void set_scope( pSym scope )
00130 {
00131 assert( FALSE );
00132 }
00133
00134
00135
00136
00137
00138
00139 virtual const pSym get_parent_scope(void)
00140 {
00141 return NULL;
00142 }
00143
00144
00145
00146 virtual void set_const( pConst c )
00147 {
00148 assert( FALSE );
00149 }
00150 virtual const pConst get_const(void)
00151 {
00152 assert( NULL );
00153 return NULL;
00154 }
00155
00156
00157
00158 virtual void set_ty_type( pType t )
00159 {
00160 assert( NULL );
00161 }
00162 virtual const pType get_ty_type(void)
00163 {
00164 assert( FALSE );
00165 return NULL;
00166 }
00167
00168
00169
00170 virtual void set_alloc( uint alloc )
00171 {
00172 assert( FALSE );
00173 }
00174 virtual const uint get_alloc(void)
00175 {
00176 assert( FALSE );
00177 return 0;
00178 }
00179 virtual void set_id_kind( uint kind )
00180 {
00181 assert( FALSE );
00182 }
00183 virtual const uint get_id_kind(void)
00184 {
00185 assert( FALSE );
00186 return 0;
00187 }
00188 virtual void set_id_type( pType t )
00189 {
00190 assert( FALSE );
00191 }
00192 virtual const pType get_id_type(void)
00193 {
00194 assert( FALSE );
00195 return NULL;
00196 }
00197
00198
00199
00200 virtual sym *LookupFromScope(STRING s)
00201 {
00202 assert( FALSE );
00203 return NULL;
00204 }
00205 virtual sym *LookupFromScope(const char *pChar )
00206 {
00207 assert( FALSE );
00208 return NULL;
00209 }
00210 virtual symtable *get_symtab(void)
00211 {
00212 assert( FALSE );
00213 return NULL;
00214 }
00215
00216 virtual typetable *get_typtab(void)
00217 {
00218 assert( FALSE );
00219 return NULL;
00220 }
00221 virtual Boolean has_scope()
00222 {
00223
00224
00225 return FALSE;
00226 }
00227
00228
00229
00230 virtual void set_statement( NODE *s )
00231 {
00232 assert( FALSE );
00233 }
00234 virtual const NODE *get_statement(void)
00235 {
00236 assert( FALSE );
00237 return NULL;
00238 }
00239
00240 virtual void set_func_type( pType t )
00241 {
00242 assert( FALSE );
00243 }
00244 virtual const pType get_func_type(void)
00245 {
00246 assert( FALSE );
00247 return NULL;
00248 }
00249
00250
00251
00252 virtual void init(void)
00253 {
00254
00255 }
00256 virtual void dealloc(void)
00257 {
00258
00259 }
00260
00261
00262 virtual void *GetMem( uint num_bytes )
00263 {
00264 assert( FALSE );
00265 return NULL;
00266 }
00267
00268 virtual LIST<sym *> *get_proc_list(void)
00269 {
00270 assert( FALSE );
00271 return NULL;
00272 }
00273 virtual LIST<NODE *> *get_sigass_list(void)
00274 {
00275 assert( FALSE );
00276 return NULL;
00277 }
00278 };
00279
00280
00281
00332 class sym_scoped : public sym {
00333 private:
00334 pSym parent_scope;
00335
00336 public:
00337 sym_scoped(STRING n) : sym( n )
00338 {
00339 parent_scope = NULL;
00340 }
00341
00342 sym_scoped()
00343 {
00344 parent_scope = NULL;
00345 }
00346
00347 void set_scope( pSym scope )
00348 {
00349 parent_scope = scope;
00350 }
00351 const pSym get_parent_scope(void)
00352 {
00353 return parent_scope;
00354 }
00355 };
00356
00357
00358 #endif