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
-
#inlined ⇒ Object
Returns the value of attribute inlined.
-
#proxy ⇒ Object
Returns the value of attribute proxy.
Attributes included from Named
Attributes inherited from Node
#children, #inferred_type, #newline, #parent, #position
Class Method Summary collapse
Instance Method Summary collapse
- #arguments ⇒ Object
- #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
#<<, ===, #[], #_set_parent, child, child_name, #each, #empty?, #initialize_copy, #insert, #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.
116 117 118 119 |
# File 'lib/duby/ast/call.rb', line 116 def initialize(parent, line_number, name, &kids) super(parent, line_number, &kids) @name = name end |
Instance Attribute Details
#inlined ⇒ Object
Returns the value of attribute inlined.
105 106 107 |
# File 'lib/duby/ast/call.rb', line 105 def inlined @inlined end |
#proxy ⇒ Object
Returns the value of attribute proxy.
105 106 107 |
# File 'lib/duby/ast/call.rb', line 105 def proxy @proxy end |
Class Method Details
Instance Method Details
#arguments ⇒ Object
121 122 123 124 125 126 127 128 129 |
# File 'lib/duby/ast/call.rb', line 121 def arguments @arguments ||= begin args = java.util.ArrayList.new(parameters.size) parameters.each do |param| args.add(param) end args end end |
#compile(compiler, expression) ⇒ Object
198 199 200 201 |
# File 'lib/duby/compiler.rb', line 198 def compile(compiler, expression) compiler.line(line_number) compiler.call(self, expression) end |
#expr?(compiler) ⇒ Boolean
77 78 79 80 81 82 |
# File 'lib/duby/jvm/source_generator/precompile.rb', line 77 def expr?(compiler) target.expr?(compiler) && parameters.all? {|p| p.expr?(compiler)} && !method.return_type.kind_of?(Duby::AST::InlineCode) && !method.actual_return_type.void? end |
#infer(typer) ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/duby/ast/call.rb', line 131 def infer(typer) unless @inferred_type receiver_type = typer.infer(target) should_defer = receiver_type.nil? parameter_types = parameters.map do |param| typer.infer(param) || should_defer = true end parameter_types << Duby::AST.block_type if block unless should_defer @inferred_type = typer.method_type(receiver_type, name, parameter_types) if @inferred_type.kind_of? InlineCode @inlined = @inferred_type.inline(typer.transformer, self) proxy.__inline__(@inlined) return proxy.infer(typer) end end if @inferred_type if block && !receiver_type.error? method = receiver_type.get_method(name, parameter_types) block.prepare(typer, method) end resolved! else typer.defer(proxy) end 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 |