Class: Ikra::AST::BehaviorNode

Inherits:
Node show all
Defined in:
lib/ast/nodes.rb,
lib/types/inference/ast_inference.rb

Direct Known Subclasses

BlockDefNode, MethDefNode

Instance Attribute Summary

Attributes inherited from Node

#parent

Instance Method Summary collapse

Methods inherited from Node

#==, #accept, #eql?, #hash, #to_s

Instance Method Details

#find_behavior_nodeObject



138
139
140
# File 'lib/ast/nodes.rb', line 138

def find_behavior_node
    return self
end

#get_typeObject



80
81
82
# File 'lib/types/inference/ast_inference.rb', line 80

def get_type
    @type ||= Types::UnionType.new
end

#lexical_variables_names_and_typesObject

Mapping: lexical variable name -> UnionType



104
105
106
# File 'lib/types/inference/ast_inference.rb', line 104

def lexical_variables_names_and_types
    @lexical_variables_names_and_types ||= {}
end

#local_variables_names_and_typesObject

Mapping: local variable name -> UnionType



109
110
111
# File 'lib/types/inference/ast_inference.rb', line 109

def local_variables_names_and_types
    @local_variables_names_and_types ||= {}
end

#local_variables_names_and_types=(value) ⇒ Object



113
114
115
# File 'lib/types/inference/ast_inference.rb', line 113

def local_variables_names_and_types=(value)
    @local_variables_names_and_types = value
end

#merge_union_type(union_type) ⇒ Object



84
85
86
87
88
89
90
91
92
# File 'lib/types/inference/ast_inference.rb', line 84

def merge_union_type(union_type)
    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

#parameters_names_and_typesObject

Mapping: parameter name -> UnionType



95
96
97
# File 'lib/types/inference/ast_inference.rb', line 95

def parameters_names_and_types
    @parameters_names_and_types ||= {}
end

#parameters_names_and_types=(value) ⇒ Object



99
100
101
# File 'lib/types/inference/ast_inference.rb', line 99

def parameters_names_and_types=(value)
    @parameters_names_and_types = value
end

#register_type_changeObject



129
130
131
# File 'lib/types/inference/ast_inference.rb', line 129

def register_type_change
    @types_changed = true
end

#reset_types_changedObject



125
126
127
# File 'lib/types/inference/ast_inference.rb', line 125

def reset_types_changed
    @types_changed = false
end

#symbol_tableObject



117
118
119
# File 'lib/types/inference/ast_inference.rb', line 117

def symbol_table
    @symbol_table ||= TypeInference::SymbolTable.new
end

#types_changed?Boolean

Returns:

  • (Boolean)


121
122
123
# File 'lib/types/inference/ast_inference.rb', line 121

def types_changed?
    return @types_changed ||= false
end