Class: Duby::AST::Arguments

Inherits:
Node show all
Defined in:
lib/duby/compiler.rb,
lib/duby/ast/method.rb

Instance Attribute Summary collapse

Attributes inherited from Node

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

Instance Method Summary collapse

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

#argsObject

Returns the value of attribute args.



3
4
5
# File 'lib/duby/ast/method.rb', line 3

def args
  @args
end

#block_argObject

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_argsObject

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_argObject

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