00001 00002 #include <assert.h> 00003 #include <string.h> 00004 #include <stdio.h> 00005 #include "stdtypes.h" 00006 #include "blockpool.h" 00007 #include "pools.h" 00008 #include "str.h" 00009 #include "list.h" 00010 #include "fifo_list.h" 00011 #include "hash_serv.h" 00012 #include "sparse.h" 00013 #include "strtable.h" 00014 #include "sym.h" 00015 #include "type.h" 00016 #include "typetable.h" 00017 00018 00019 00020 type *typetable::find_time(const uint time_scale ) 00021 { 00022 type_time *pT; 00023 type_time *time_elem; 00024 LIST<type_time *>::handle h; 00025 00026 pT = NULL; 00027 00028 if (time_scale != time_bad_time) { 00029 for (h = time_list.first(); h != NULL; h = time_list.next( h )) { 00030 time_elem = time_list.get_item( h ); 00031 if (time_elem->get_unit() == time_scale) { 00032 pT = time_elem; 00033 break; 00034 } 00035 } 00036 00037 // If pT is NULL then a type with that time scale is not in the 00038 // type list. Allocate the type from the global memory pool. 00039 if (pT == NULL) { 00040 pT = new( &global_mem ) type_time( time_scale ); 00041 time_list.add( pT ); 00042 } 00043 } 00044 00045 return pT; 00046 } // find_time 00047 00048 00066 type *typetable::new_type( uint kind, uint time_scale /* = time_bad_time */ ) 00067 { 00068 pType pT; 00069 00070 assert( alloc_pool != NULL ); 00071 00072 pT = NULL; 00073 00074 switch (kind) { 00075 case ty_time: 00076 pT = find_time( time_scale ); 00077 break; 00078 case ty_range: 00079 pT = new( alloc_pool ) type_range( ); 00080 break; 00081 case ty_real: 00082 pT = &REAL; // there is only one real type 00083 break; 00084 case ty_array: 00085 pT = new( alloc_pool ) type_array( ); 00086 break; 00087 case ty_record: 00088 pT = new( alloc_pool ) type_record( ); 00089 break; 00090 case ty_file: 00091 pT = new( alloc_pool ) type_file( ); 00092 break; 00093 default: 00094 assert( FALSE ); 00095 break; 00096 } // switch 00097 00098 return pT; 00099 } // new_type 00100 00101 00106 void typetable::pr(void) 00107 { 00108 // To Be Done 00109 } // pr 00110