Class: YTLJit::VM::Node::ClassTopNode
- Includes:
- MethodTopCodeGen, SendNodeCodeGen
- Defined in:
- lib/ytljit/vm.rb
Direct Known Subclasses
Constant Summary collapse
- @@class_top_tab =
{}
Constants included from AbsArch
AbsArch::AL, AbsArch::BL, AbsArch::CL, AbsArch::DL, AbsArch::FUNC_ARG, AbsArch::FUNC_ARG_YTL, AbsArch::FUNC_FLOAT_ARG, AbsArch::FUNC_FLOAT_ARG_YTL, AbsArch::INDIRECT_BPR, AbsArch::INDIRECT_RETR, AbsArch::INDIRECT_SPR, AbsArch::INDIRECT_TMPR, AbsArch::INDIRECT_TMPR2, AbsArch::INDIRECT_TMPR3
Constants included from SSE
SSE::XMM0, SSE::XMM1, SSE::XMM2, SSE::XMM3, SSE::XMM4, SSE::XMM5, SSE::XMM6, SSE::XMM7
Instance Attribute Summary collapse
-
#constant_tab ⇒ Object
readonly
Returns the value of attribute constant_tab.
-
#klass_object ⇒ Object
readonly
Returns the value of attribute klass_object.
-
#klassclass ⇒ Object
readonly
Returns the value of attribute klassclass.
-
#klassclass_node ⇒ Object
readonly
Returns the value of attribute klassclass_node.
-
#method_tab ⇒ Object
readonly
Returns the value of attribute method_tab.
Attributes inherited from TopNode
#end_nodes, #name, #orig_modified_local_var, #signature_cache, #yield_node
Attributes included from HaveChildlenMixin
Attributes inherited from BaseNode
#code_space, #debug_info, #element_node_list, #id, #is_escape, #parent, #ti_observee, #ti_observer, #type
Class Method Summary collapse
Instance Method Summary collapse
- #collect_candidate_type(context, signode, sig) ⇒ Object
- #collect_info(context) ⇒ Object
- #compile(context) ⇒ Object
- #construct_frame_info(locals, argnum, args) ⇒ Object
- #get_constant_tab(klassobj = @klass_object) ⇒ Object
- #get_constant_value ⇒ Object
- #get_method_tab(klassobj = @klass_object) ⇒ Object
-
#initialize(parent, klassobj, name = nil) ⇒ ClassTopNode
constructor
A new instance of ClassTopNode.
- #make_klassclass_node ⇒ Object
- #search_constant_with_super(name, klassobj = @klass_object) ⇒ Object
- #search_method_with_super(name, klassobj = @klass_object) ⇒ Object
Methods included from MethodTopCodeGen
Methods included from SendNodeCodeGen
Methods included from CommonCodeGen
#dump_context, #gen_alloca, #gen_call
Methods inherited from TopNode
#add_arg_to_args, #add_cs_for_signature, #compile_init, #disp_signature, #find_cs_by_signature, #modified_instance_var, #traverse_childlen
Methods included from NodeUtil
#search_class_top, #search_end, #search_frame_info, #search_top
Methods included from HaveChildlenMixin
Methods inherited from BaseNode
#add_element_node, #decide_type, #decide_type_core, #decide_type_once, #gen_type_inference_proc, #inference_type, #merge_type, #same_type, #ti_add_observer, #ti_changed, #ti_del_link, #ti_reset, #ti_update
Methods included from TypeListWithSignature
#add_type, #set_type_list, #type_list, #type_list_initvar
Methods included from Inspect
Constructor Details
#initialize(parent, klassobj, name = nil) ⇒ ClassTopNode
Returns a new instance of ClassTopNode.
1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 |
# File 'lib/ytljit/vm.rb', line 1034 def initialize(parent, klassobj, name = nil) super(parent, name) @constant_tab = {} @method_tab = {} @klass_object = klassobj @klassclass = ClassClassWrapper.instance(@klass_object) @klassclass_node = nil # Lazy RubyType::define_wraped_class(@klassclass, RubyType::RubyTypeBoxed) unless @@class_top_tab[klassobj] @@class_top_tab[klassobj] = self end end |
Instance Attribute Details
#constant_tab ⇒ Object (readonly)
Returns the value of attribute constant_tab.
1049 1050 1051 |
# File 'lib/ytljit/vm.rb', line 1049 def constant_tab @constant_tab end |
#klass_object ⇒ Object (readonly)
Returns the value of attribute klass_object.
1048 1049 1050 |
# File 'lib/ytljit/vm.rb', line 1048 def klass_object @klass_object end |
#klassclass ⇒ Object (readonly)
Returns the value of attribute klassclass.
1051 1052 1053 |
# File 'lib/ytljit/vm.rb', line 1051 def klassclass @klassclass end |
#klassclass_node ⇒ Object (readonly)
Returns the value of attribute klassclass_node.
1052 1053 1054 |
# File 'lib/ytljit/vm.rb', line 1052 def klassclass_node @klassclass_node end |
#method_tab ⇒ Object (readonly)
Returns the value of attribute method_tab.
1050 1051 1052 |
# File 'lib/ytljit/vm.rb', line 1050 def method_tab @method_tab end |
Class Method Details
.get_class_top_node(klass) ⇒ Object
1030 1031 1032 |
# File 'lib/ytljit/vm.rb', line 1030 def self.get_class_top_node(klass) @@class_top_tab[klass] end |
Instance Method Details
#collect_candidate_type(context, signode, sig) ⇒ Object
1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 |
# File 'lib/ytljit/vm.rb', line 1132 def collect_candidate_type(context, signode, sig) @type = RubyType::BaseType.from_ruby_class(@klassclass) add_type(sig, @type) if add_cs_for_signature(sig) == nil and context.visited_top_node[self] then return context end context.visited_top_node[self] = true context.push_signature(signode, self) context = @body.collect_candidate_type(context) context.pop_signature if @klassclass_node then @klassclass_node.collect_candidate_type(context, signode, sig) else context end end |
#collect_info(context) ⇒ Object
1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 |
# File 'lib/ytljit/vm.rb', line 1054 def collect_info(context) context.modified_local_var.push [{}] context.modified_instance_var = Hash.new context = super context.modified_local_var.pop if @klassclass_node then @klassclass_node.collect_info(context) else context end end |
#compile(context) ⇒ Object
1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 |
# File 'lib/ytljit/vm.rb', line 1154 def compile(context) context = super(context) sig = context.to_signature.dup sig[2] = @type =begin pp sig pp @name pp @code_spaces.map{|a| a[0]} =end cs = self.find_cs_by_signature(sig) if cs then asm = context.assembler add = lambda { @klass_object.address } var_klassclass = OpVarImmidiateAddress.new(add) context.start_arg_reg asm.with_retry do asm.mov(FUNC_ARG_YTL[0], BPR) asm.mov(FUNC_ARG_YTL[1], 4) asm.mov(FUNC_ARG_YTL[2], var_klassclass) end context.set_reg_content(FUNC_ARG_YTL[0].dst_opecode, BPR) context.set_reg_content(FUNC_ARG_YTL[1].dst_opecode, nil) context.set_reg_content(FUNC_ARG_YTL[2].dst_opecode, self) add = cs.var_base_address context = gen_call(context, add, 3) context.end_arg_reg end context end |
#construct_frame_info(locals, argnum, args) ⇒ Object
1123 1124 1125 1126 1127 1128 1129 1130 |
# File 'lib/ytljit/vm.rb', line 1123 def construct_frame_info(locals, argnum, args) locals.unshift :_self locals.unshift :_block locals.unshift :_prev_env argnum += 3 args = add_arg_to_args(args, 3) super(locals, argnum, args) end |
#get_constant_tab(klassobj = @klass_object) ⇒ Object
1085 1086 1087 1088 1089 1090 1091 1092 1093 |
# File 'lib/ytljit/vm.rb', line 1085 def get_constant_tab(klassobj = @klass_object) ktop = @@class_top_tab[klassobj] if ktop then ktop.constant_tab else ktop.constant_tab = {} ktop.constant_tab end end |
#get_constant_value ⇒ Object
1187 1188 1189 |
# File 'lib/ytljit/vm.rb', line 1187 def get_constant_value [@klass_object] end |
#get_method_tab(klassobj = @klass_object) ⇒ Object
1076 1077 1078 1079 1080 1081 1082 1083 |
# File 'lib/ytljit/vm.rb', line 1076 def get_method_tab(klassobj = @klass_object) ktop = @@class_top_tab[klassobj] if ktop then ktop.method_tab else {} end end |
#make_klassclass_node ⇒ Object
1066 1067 1068 1069 1070 1071 1072 1073 1074 |
# File 'lib/ytljit/vm.rb', line 1066 def make_klassclass_node if @klassclass_node == nil then clsclsnode = ClassTopNode.new(self, @klassclass, @klassclass.name) clsclsnode.body = DummyNode.new @klassclass_node = clsclsnode end end |
#search_constant_with_super(name, klassobj = @klass_object) ⇒ Object
1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 |
# File 'lib/ytljit/vm.rb', line 1109 def search_constant_with_super(name, klassobj = @klass_object) clsnode = @@class_top_tab[klassobj] if clsnode then ctab = clsnode.get_constant_tab if val = ctab[name] then return [val, clsnode] end return search_constant_with_super(name, klassobj.superclass) end [nil, nil] end |
#search_method_with_super(name, klassobj = @klass_object) ⇒ Object
1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 |
# File 'lib/ytljit/vm.rb', line 1095 def search_method_with_super(name, klassobj = @klass_object) clsnode = @@class_top_tab[klassobj] if clsnode then mtab = clsnode.get_method_tab if val = mtab[name] then return [val, clsnode] end return search_method_with_super(name, klassobj.superclass) end [nil, nil] end |