Class: Duby::AST::Super
- Includes:
- Named
- Defined in:
- lib/duby/jvm/source_generator/precompile.rb,
lib/duby/ast/call.rb,
lib/duby/compiler.rb,
lib/duby/jvm/compiler.rb
Overview
TODO merge with FunctionalCall logic (almost identical)
Instance Attribute Summary collapse
-
#cast ⇒ Object
(also: #cast?)
Returns the value of attribute cast.
-
#method(compiler) ⇒ Object
Returns the value of attribute method.
-
#target ⇒ Object
Returns the value of attribute target.
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) ⇒ Super
constructor
A new instance of Super.
- #name ⇒ 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) ⇒ Super
Returns a new instance of Super.
173 174 175 176 177 178 |
# File 'lib/duby/ast/call.rb', line 173 def initialize(parent, line_number) super(parent, line_number) @call_parent = parent @call_parent = (@call_parent = @call_parent.parent) until MethodDefinition === @call_parent @cast = false end |
Instance Attribute Details
#cast ⇒ Object Also known as: cast?
Returns the value of attribute cast.
168 169 170 |
# File 'lib/duby/ast/call.rb', line 168 def cast @cast end |
#method(compiler) ⇒ Object
Returns the value of attribute method.
168 169 170 |
# File 'lib/duby/ast/call.rb', line 168 def method @method end |
#target ⇒ Object
Returns the value of attribute target.
16 17 18 |
# File 'lib/duby/jvm/compiler.rb', line 16 def target @target end |
Instance Method Details
#compile(compiler, expression) ⇒ Object
205 206 207 208 |
# File 'lib/duby/compiler.rb', line 205 def compile(compiler, expression) compiler.line(line_number) compiler.super_call(self, expression) end |
#expr?(compiler) ⇒ Boolean
108 109 110 111 |
# File 'lib/duby/jvm/source_generator/precompile.rb', line 108 def expr?(compiler) parameters.all? {|p| p.expr?(compiler)} && !method(compiler).actual_return_type.void? end |
#infer(typer) ⇒ Object
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/duby/ast/call.rb', line 184 def infer(typer) @self_type ||= typer.self_type.superclass unless @inferred_type receiver_type = @call_parent.defining_class.superclass should_defer = receiver_type.nil? 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 |
#name ⇒ Object
180 181 182 |
# File 'lib/duby/ast/call.rb', line 180 def name @call_parent.name end |