Class: Duby::AST::OptionalArgument

Inherits:
Argument show all
Includes:
Named, Scoped
Defined in:
lib/duby/ast/method.rb

Instance Attribute Summary

Attributes included from Named

#name

Attributes included from Typed

#type

Attributes inherited from Node

#children, #inferred_type, #newline, #parent, #position

Instance Method Summary collapse

Methods included from Scoped

#containing_scope, #scope

Methods included from Named

#to_s

Methods inherited from Argument

#resolved!

Methods inherited from Node

#<<, ===, #[], #_set_parent, child, child_name, #each, #empty?, #expr?, #initialize_copy, #insert, #inspect, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #temp, #to_s

Constructor Details

#initialize(parent, line_number, name, &block) ⇒ OptionalArgument

Returns a new instance of OptionalArgument.



63
64
65
66
# File 'lib/duby/ast/method.rb', line 63

def initialize(parent, line_number, name, &block)
  super(parent, line_number, &block)
  @name = name
end

Instance Method Details

#infer(typer) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/duby/ast/method.rb', line 68

def infer(typer)
  resolve_if(typer) do
    scope.static_scope << name
    # if not already typed, check parent of parent (MethodDefinition)
    # for signature info
    method_def = parent.parent
    signature = method_def.signature

    signature[name.intern] = child.infer(typer)
  end
end