00001 // $Id: vtbl_utils.h,v 1.1.1.1 2000/06/08 00:10:03 afikes Exp $ 00002 00003 #ifndef VTBLNODES__VTBL_UTILS_H 00004 #define VTBLNODES__VTBL_UTILS_H 00005 00006 #include "basicnodes/basic.h" 00007 #include "basicnodes/basic_factory.h" 00008 #include "suifnodes/suif.h" 00009 #include "suifnodes/suif_factory.h" 00010 #include "osuifnodes/osuif.h" 00011 #include "osuifnodes/osuif_factory.h" 00012 #include "osuifextensionnodes/osuifextension.h" 00013 #include "osuifextensionnodes/osuifextension_factory.h" 00014 #include "vtblnodes/vtbl.h" 00015 #include "vtblnodes/vtbl_factory.h" 00016 #include "common/suif_list.h" 00017 #include "common/suif_map.h" 00018 00019 00020 extern LString k_vtbl_annote; 00021 extern LString k_vtbl_slot_annote; 00022 extern LString k_vtbl_slot_count_annote; 00023 extern LString k_vtbl_slot_number_annote; 00024 extern LString k_no_vtbl_annote; 00025 00026 00027 void attach_vtbl_annote( SuifEnv* env, 00028 VariableSymbol* vtbl_sym, 00029 ClassType* owning_class ); 00030 00031 VariableSymbol* build_vtbl_variable_symbol( SuifEnv* env, 00032 ClassType* owning_class, 00033 const LString & name= emptyLString ); 00034 00035 00036 void attach_vtbl_slot_annote( SuifEnv* env, 00037 IntConstant* icnst, 00038 InstanceMethodSymbol* msym ); 00039 00040 IntConstant* build_vtbl_slot_int_constant( SuifEnv* env, 00041 InstanceMethodSymbol* msym ); 00042 00043 00044 extern void attach_vtbl_slot_count_annote( SuifEnv* env, 00045 IntConstant* icnst, 00046 ClassType* owning_class ); 00047 00048 IntConstant* build_vtbl_slot_count_int_constant( SuifEnv* env, 00049 ClassType* owning_class ); 00050 00051 00052 void attach_vtbl_slot_number_annote( SuifEnv* env, 00053 InstanceMethodSymbol* msym, 00054 IInteger slot_number ); 00055 00056 00057 extern void attach_no_vtbl_annote( SuifEnv* env, 00058 ClassType* ctype ); 00059 00060 extern bool has_no_vtbl_annote( ClassType* ctype ); 00061 00062 00063 00064 IInteger biggest_local_vtbl_slot( ClassType* ctype ); 00065 IInteger biggest_vtbl_slot( SingleInheritanceClassType* ctype ); 00066 00067 00068 00070 typedef list<InstanceMethodSymbol* > vtbl_t; 00071 00072 class SingleInheritanceVtbls { 00073 protected: 00074 SuifEnv* _env; 00075 TypeBuilder* _tb; 00076 00077 suif_map<SingleInheritanceClassType*, vtbl_t* > _vtbls; 00078 00079 virtual vtbl_t* derive_vtbl( vtbl_t* parent_vtbl, 00080 SingleInheritanceClassType* current_class ); 00081 virtual void insert_method( InstanceMethodSymbol* current_msym, vtbl_t* vtbl ); 00082 00083 virtual void handle_incomplete_class( SingleInheritanceClassType* ctype ); 00084 virtual vtbl_t* build_vtbls( SingleInheritanceClassType* ctype ); 00085 public: 00086 SingleInheritanceVtbls( SuifEnv* env ); 00087 virtual ~SingleInheritanceVtbls() { } 00088 00089 virtual bool x_overrides_y( InstanceMethodSymbol* msym1, 00090 InstanceMethodSymbol* msym2 ); 00091 00093 virtual DataType* vtbl_slot_type( SingleInheritanceClassType* ctype ); 00094 00096 virtual DataType* get_vtbl_type( SingleInheritanceClassType* ctype, 00097 IInteger vtbl_size = IInteger() ); 00098 00099 00100 virtual String vtbl_name( SingleInheritanceClassType* ctype ); 00101 00102 virtual void attach_vtbl_slot_number_annotes( SingleInheritanceClassType* ctype ); 00103 virtual void 00104 attach_precessors_vtbl_slot_number_annotes( SingleInheritanceClassType* ctype ); 00105 00106 virtual VariableDefinition* get_vtbl( SingleInheritanceClassType* ctype ); 00107 virtual void attach_vtbl( SingleInheritanceClassType* ctype, 00108 VariableSymbol* vsym ); 00109 virtual void attach_vtbl( SingleInheritanceClassType* ctype ); 00110 00112 virtual void print_vtbl( SingleInheritanceClassType* ctype ); 00113 }; 00114 00115 00116 #endif