Class: Ikra::AST::TreeNode
- Inherits:
-
Node
show all
- Defined in:
- lib/ast/nodes.rb,
lib/types/inference/ast_inference.rb
Direct Known Subclasses
ArrayNode, BeginNode, BoolLiteralNode, BreakNode, ConstNode, FloatLiteralNode, ForNode, HashNode, IVarReadNode, IfNode, IntLiteralNode, LVarReadNode, LVarWriteNode, NilLiteralNode, ReturnNode, RootNode, SendNode, SourceCodeExprNode, StringLiteralNode, SymbolLiteralNode, TernaryNode, UntilNode, UntilPostNode, WhileNode, WhilePostNode
Constant Summary
collapse
- TYPE_INFO_VARS =
[:@return_type_by_recv_type, :@type]
Instance Attribute Summary
Attributes inherited from Node
#parent
Instance Method Summary
collapse
Methods inherited from Node
#accept, #eql?, #hash, #to_s
Instance Method Details
#==(other) ⇒ Object
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
|
# File 'lib/ast/nodes.rb', line 238
def ==(other)
if self.class != other.class
return false
end
if (instance_variables - TYPE_INFO_VARS) != (other.instance_variables - TYPE_INFO_VARS)
return false
end
for var_name in instance_variables
if var_name != :@parent && !TYPE_INFO_VARS.include?(var_name)
if instance_variable_get(var_name) != other.instance_variable_get(var_name)
return false
end
end
end
return true
end
|
#enclosing_class ⇒ Object
228
229
230
|
# File 'lib/ast/nodes.rb', line 228
def enclosing_class
@parent.enclosing_class
end
|
#find_behavior_node ⇒ Object
232
233
234
|
# File 'lib/ast/nodes.rb', line 232
def find_behavior_node
return parent.find_behavior_node
end
|
12
13
14
15
|
# File 'lib/types/inference/ast_inference.rb', line 12
def get_type
@type ||= Types::UnionType.new
return @type.dup
end
|
#is_begin_node? ⇒ Boolean
209
210
211
|
# File 'lib/ast/nodes.rb', line 209
def is_begin_node?
false
end
|
#merge_union_type(union_type) ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'lib/types/inference/ast_inference.rb', line 17
def merge_union_type(union_type)
@type ||= Types::UnionType.new
if not @type.include_all?(union_type)
register_type_change
end
return @type.expand_return_type(union_type).dup
end
|
#register_type_change ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'lib/types/inference/ast_inference.rb', line 31
def register_type_change
if parent != nil
parent.register_type_change
else
end
end
|
#replace(another_node) ⇒ Object
213
214
215
216
217
|
# File 'lib/ast/nodes.rb', line 213
def replace(another_node)
parent.replace_child(self, another_node)
end
|
#replace_child(node, another_node) ⇒ Object
219
220
221
222
223
224
225
226
|
# File 'lib/ast/nodes.rb', line 219
def replace_child(node, another_node)
instance_variables.each do |inst_var|
if instance_variable_get(inst_var).equal?(node)
instance_variable_set(inst_var, another_node)
another_node.parent = self
end
end
end
|
#symbol_table ⇒ Object
27
28
29
|
# File 'lib/types/inference/ast_inference.rb', line 27
def symbol_table
return parent.symbol_table
end
|