Class: Duby::AST::Arguments
- Defined in:
- lib/duby/compiler.rb,
lib/duby/ast/method.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#block_arg ⇒ Object
Returns the value of attribute block_arg.
-
#opt_args ⇒ Object
Returns the value of attribute opt_args.
-
#rest_arg ⇒ Object
Returns the value of attribute rest_arg.
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
#[], #each, #expr?, #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.
5 6 7 8 |
# File 'lib/duby/ast/method.rb', line 5 def initialize(parent, line_number, &block) super(parent, line_number, &block) @args, @opt_args, @rest_arg, @block_arg = children end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
3 4 5 |
# File 'lib/duby/ast/method.rb', line 3 def args @args end |
#block_arg ⇒ Object
Returns the value of attribute block_arg.
3 4 5 |
# File 'lib/duby/ast/method.rb', line 3 def block_arg @block_arg end |
#opt_args ⇒ Object
Returns the value of attribute opt_args.
3 4 5 |
# File 'lib/duby/ast/method.rb', line 3 def opt_args @opt_args end |
#rest_arg ⇒ Object
Returns the value of attribute rest_arg.
3 4 5 |
# File 'lib/duby/ast/method.rb', line 3 def rest_arg @rest_arg end |
Instance Method Details
#compile(compiler, expression) ⇒ Object
110 111 112 113 |
# File 'lib/duby/compiler.rb', line 110 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
10 11 12 13 14 |
# File 'lib/duby/ast/method.rb', line 10 def infer(typer) unless @inferred_type @inferred_type = args ? args.map {|arg| typer.infer(arg)} : [] end end |