class Ikra::AST::MethDefNode

Attributes

body[R]
name[R]
receiver_type[RW]
ruby_method[R]

Public Class Methods

new(name:, body:, ruby_method:, method_binding: nil) click to toggle source
# File lib/ast/nodes.rb, line 148
def initialize(name:, body:, ruby_method:, method_binding: nil)
    @name = name
    @body = body
    @ruby_method = ruby_method
    @binding = method_binding

    body.parent = self
end
new_with_types( name:, body:, parameters_names_and_types:, ruby_method:, receiver_type:, return_type: Types::UnionType.new, method_binding: nil) click to toggle source
# File lib/types/inference/ast_inference.rb, line 59
def self.new_with_types(
        name:,
        body:,
        parameters_names_and_types:,
        ruby_method:,
        receiver_type:,
        return_type: Types::UnionType.new,
        method_binding: nil)

    instance = new(name: name, body: body, ruby_method: ruby_method, method_binding: method_binding)
    instance.initialize_types(receiver_type: receiver_type, return_type: return_type)
    instance.parameters_names_and_types = parameters_names_and_types
    return instance
end

Public Instance Methods

==(other) click to toggle source
Calls superclass method Ikra::AST::Node#==
# File lib/ast/nodes.rb, line 174
def ==(other)
    return super(other) && name == other.name && body == other.body
end
accept(visitor) click to toggle source
# File lib/ast/visitor.rb, line 32
def accept(visitor)
    return visitor.visit_meth_def_node(self)
end
binding() click to toggle source
# File lib/ast/nodes.rb, line 164
def binding
    if @binding != nil
        return @binding
    elsif ruby_method == nil 
        return nil
    else 
        return ruby_method.send(:binding)
    end
end
callers() click to toggle source
# File lib/types/inference/ast_inference.rb, line 74
def callers
    @callers ||= []
end
clone() click to toggle source
# File lib/ast/nodes.rb, line 157
def clone
    return MethodDefNode.new(
        name: @name,
        body: @body.clone,
        ruby_method: @ruby_method)
end
initialize_types(receiver_type:, return_type: Types::UnionType.new) click to toggle source
# File lib/types/inference/ast_inference.rb, line 54
def initialize_types(receiver_type:, return_type: Types::UnionType.new)
    @receiver_type = receiver_type
    @type = return_type
end
to_s() click to toggle source
# File lib/ast/printer.rb, line 28
def to_s
    return "[MethDefNode: #{name} #{body.to_s}]"
end