Class: Duby::AST::Call
- Includes:
- Named
- Defined in:
- lib/duby/ast/call.rb,
lib/duby/compiler.rb,
lib/duby/jvm/source_generator/precompile.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#target ⇒ Object
Returns the value of attribute target.
Attributes included from Named
Attributes inherited from Node
#children, #inferred_type, #newline, #parent, #position
Instance Method Summary collapse
- #compile(compiler, expression) ⇒ Object
- #expr?(compiler) ⇒ Boolean
- #infer(typer) ⇒ Object
-
#initialize(parent, line_number, name, &kids) ⇒ Call
constructor
A new instance of Call.
- #method(compiler = nil) ⇒ Object
Methods included from Named
Methods inherited from Node
#[], #each, #inspect, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #temp, #to_s
Constructor Details
#initialize(parent, line_number, name, &kids) ⇒ Call
Returns a new instance of Call.
48 49 50 51 52 |
# File 'lib/duby/ast/call.rb', line 48 def initialize(parent, line_number, name, &kids) super(parent, line_number, children, &kids) @target, @parameters, @block = children @name = name end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
46 47 48 |
# File 'lib/duby/ast/call.rb', line 46 def block @block end |
#parameters ⇒ Object
Returns the value of attribute parameters.
46 47 48 |
# File 'lib/duby/ast/call.rb', line 46 def parameters @parameters end |
#target ⇒ Object
Returns the value of attribute target.
46 47 48 |
# File 'lib/duby/ast/call.rb', line 46 def target @target end |
Instance Method Details
#compile(compiler, expression) ⇒ Object
146 147 148 149 |
# File 'lib/duby/compiler.rb', line 146 def compile(compiler, expression) compiler.line(line_number) compiler.call(self, expression) end |
#expr?(compiler) ⇒ Boolean
77 78 79 80 81 |
# File 'lib/duby/jvm/source_generator/precompile.rb', line 77 def expr?(compiler) target.expr?(compiler) && parameters.all? {|p| p.expr?(compiler)} && !method.actual_return_type.void? end |
#infer(typer) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/duby/ast/call.rb', line 54 def infer(typer) unless @inferred_type receiver_type = typer.infer(target) should_defer = false parameter_types = parameters.map do |param| typer.infer(param) || should_defer = true end unless should_defer @inferred_type = typer.method_type(receiver_type, name, parameter_types) end @inferred_type ? resolved! : typer.defer(self) end @inferred_type end |
#method(compiler = nil) ⇒ Object
70 71 72 73 74 75 |
# File 'lib/duby/jvm/source_generator/precompile.rb', line 70 def method(compiler=nil) @method ||= begin arg_types = parameters.map {|p| p.inferred_type} target.inferred_type.get_method(name, arg_types) end end |