Class: Duby::AST::OptionalArgument
- Defined in:
- lib/duby/ast/method.rb
Instance Attribute Summary collapse
-
#child ⇒ Object
Returns the value of attribute child.
Attributes included from Named
Attributes included from Typed
Attributes inherited from Node
#children, #inferred_type, #newline, #parent, #position
Instance Method Summary collapse
- #infer(typer) ⇒ Object
-
#initialize(parent, line_number, name, &block) ⇒ OptionalArgument
constructor
A new instance of OptionalArgument.
Methods included from Scoped
Methods included from Named
Methods inherited from Node
#[], #each, #expr?, #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.
58 59 60 61 62 |
# File 'lib/duby/ast/method.rb', line 58 def initialize(parent, line_number, name, &block) super(parent, line_number, &block) @child = children[0] @name = name end |
Instance Attribute Details
#child ⇒ Object
Returns the value of attribute child.
56 57 58 |
# File 'lib/duby/ast/method.rb', line 56 def child @child end |
Instance Method Details
#infer(typer) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/duby/ast/method.rb', line 64 def infer(typer) unless @inferred_type # if not already typed, check parent of parent (MethodDefinition) for signature info method_def = parent.parent signature = method_def.signature # if signature, search for this argument @inferred_type = child.infer(typer) if @inferred_type typer.learn_local_type(scope, name, @inferred_type) signature[name.intern] = @inferred_type else typer.defer(self) end end @inferred_type end |