class Ikra::AST::TreeNode

Constants

TYPE_INFO_VARS

Public Instance Methods

==(other) click to toggle source
# File lib/ast/nodes.rb, line 238
def ==(other)
    if self.class != other.class
        return false
    end

    # Ignore types
    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)
            # Avoid cycles via :parent... There could still be other cycles though
            if instance_variable_get(var_name) != other.instance_variable_get(var_name)
                return false
            end
        end
    end

    return true
end
enclosing_class() click to toggle source
# File lib/ast/nodes.rb, line 228
def enclosing_class
    @parent.enclosing_class
end
find_behavior_node() click to toggle source
# File lib/ast/nodes.rb, line 232
def find_behavior_node
    return parent.find_behavior_node
end
get_type() click to toggle source
# File lib/types/inference/ast_inference.rb, line 12
def get_type
    @type ||= Types::UnionType.new
    return @type.dup
end
is_begin_node?() click to toggle source
# File lib/ast/nodes.rb, line 209
def is_begin_node?
    false
end
merge_union_type(union_type) click to toggle source
# 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() click to toggle source
# File lib/types/inference/ast_inference.rb, line 31
def register_type_change
    if parent != nil
        parent.register_type_change
    else
        # This node is not part of a full AST, i.e., it does not have a [BehaviorNode]
        # as a parent. Do nothing.
    end
end
replace(another_node) click to toggle source
# File lib/ast/nodes.rb, line 213
def replace(another_node)
    # Sometimes, this method does not work as expected, if the `parent` of the `self`
    # is already modified before calling this method.
    parent.replace_child(self, another_node)
end
replace_child(node, another_node) click to toggle source
# 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() click to toggle source
# File lib/types/inference/ast_inference.rb, line 27
def symbol_table
    return parent.symbol_table
end