Class: Mirah::AST::OptionalArgument
- Defined in:
- lib/mirah/ast/method.rb
Instance Attribute Summary
Attributes included from Named
Attributes included from Typed
Attributes inherited from Node
#children, #inferred_type, #newline, #parent, #position
Instance Method Summary collapse
- #infer(typer, expression) ⇒ Object
-
#initialize(parent, line_number, name, &block) ⇒ OptionalArgument
constructor
A new instance of OptionalArgument.
Methods included from Scoped
Methods included from Named
#string_value, #to_s, #validate_name
Methods inherited from Argument
Methods inherited from Node
#<<, ===, #[], #[]=, #_dump, _load, #_set_parent, child, child_name, #child_nodes, #each, #empty?, #expr?, #inferred_type!, #initialize_copy, #insert, #inspect, #inspect_children, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #string_value, #temp, #to_s, #top_level?, #validate_child, #validate_children
Constructor Details
#initialize(parent, line_number, name, &block) ⇒ OptionalArgument
Returns a new instance of OptionalArgument.
155 156 157 158 |
# File 'lib/mirah/ast/method.rb', line 155 def initialize(parent, line_number, name, &block) super(parent, line_number, &block) self.name = name end |
Instance Method Details
#infer(typer, expression) ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/mirah/ast/method.rb', line 160 def infer(typer, expression) 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 value_type = value.infer(typer, true) declared_type = type_node.type_reference(typer) if type_node signature[name.intern] = declared_type || value_type end end |