#include <typetable.h>
Collaboration diagram for typetable:
Public Member Functions | |
typetable (pool *p=NULL) | |
void | set_pool (pool *p) |
type * | new_type (uint kind, uint time_scale=time_bad_time) |
The new_type class function returns a type based on its "kind" argument. | |
void | pr () |
Debug print for the type table. | |
Private Member Functions | |
typetable (const typetable &ty) | |
type * | find_time (const uint time_scale) |
Private Attributes | |
LIST< type_range * > | range_list |
LIST< type_real * > | real_list |
LIST< type_array * > | array_list |
LIST< type_record * > | rec_list |
LIST< type_file * > | file_list |
pool * | alloc_pool |
Static Private Attributes | |
LIST< type_time * > | time_list |
A sym_type object has a pointer to a type, which is an unnamed object described by the classes in type.h. The type table class provides a way to encapsulate these allocated types.
Two allocation scopes are used for types: the global allocation scope, where types defined in packages will be entered and the component allocation scope. Types in the global scope will be allocated from the global pool. Types in the component scope will be allocated from the component pool.
The types in the type table are ordered as lists of a given type class (e.g., type_range, type_real, type_array, type_record, type_file). Types in the type table are not currently unique. There are two reasons for this: its a pain to make show that two types are the same in all cases and I can't think of a reason to do this extra work.
Definition at line 39 of file typetable.h.
|
Definition at line 52 of file typetable.h. References FALSE.
00052 { assert( FALSE ); } |
|
Definition at line 57 of file typetable.h. References alloc_pool.
00058 { 00059 alloc_pool = p; 00060 } |
|
Definition at line 20 of file typetable.C. References LIST< type_time * >::add(), LIST< type_time * >::first(), LIST< type_time * >::get_item(), type_time::get_unit(), global_mem, LIST< type_time * >::next(), NULL, time_bad_time, and time_list. Referenced by new_type().
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 |
|
The new_type class function returns a type based on its "kind" argument. The time_scale argument is only needed in the case that kind == ty_time. There are a very large number of possible range types and an infinite number of possible array, record and file types. However, this is only one REAL type. The time type is also special. There are a limited number of time types reflecting the various resolutions. These types are stored in a list that is shared by all instances of the typetable class. When the component is processed it can he quickly determined what the smallest time resolution is by searching this list. Of course the time resolution must be done across components as well. Definition at line 66 of file typetable.C. References alloc_pool, FALSE, find_time(), NULL, REAL, ty_array, ty_file, ty_range, ty_real, ty_record, and ty_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 |
|
Debug print for the type table.
Definition at line 106 of file typetable.C.
00107 { 00108 // To Be Done 00109 } // pr |
|
Definition at line 62 of file typetable.h. References alloc_pool. Referenced by sym_component::init(), and symtable::new_sym().
00063 { 00064 alloc_pool = p; 00065 } |
|
Definition at line 48 of file typetable.h. Referenced by new_type(), set_pool(), and typetable(). |
|
Definition at line 44 of file typetable.h. |
|
Definition at line 46 of file typetable.h. |
|
Definition at line 42 of file typetable.h. |
|
Definition at line 43 of file typetable.h. |
|
Definition at line 45 of file typetable.h. |
|
Definition at line 36 of file globals.C. Referenced by find_time(). |