Class: Duby::AST::Arguments
- Defined in:
- lib/duby/compiler.rb,
lib/duby/ast/method.rb
Instance Attribute Summary
Attributes inherited from Node
#children, #inferred_type, #newline, #parent, #position
Instance Method Summary collapse
- #compile(compiler, expression) ⇒ Object
- #infer(typer) ⇒ Object
-
#initialize(parent, line_number, &block) ⇒ Arguments
constructor
A new instance of Arguments.
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, &block) ⇒ Arguments
Returns a new instance of Arguments.
8 9 10 |
# File 'lib/duby/ast/method.rb', line 8 def initialize(parent, line_number, &block) super(parent, line_number, &block) end |
Instance Method Details
#compile(compiler, expression) ⇒ Object
162 163 164 165 |
# File 'lib/duby/compiler.rb', line 162 def compile(compiler, expression) # TODO: what does it mean for a method to be an expression? args.each {|arg| compiler.declare_argument(arg.name, arg.inferred_type)} if args end |
#infer(typer) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/duby/ast/method.rb', line 12 def infer(typer) unless resolved? @inferred_type = args ? args.map {|arg| typer.infer(arg)} : [] if @inferred_type.all? resolved! else typer.defer(self) end end @inferred_type end |