Class: Duby::AST::Body
- Defined in:
- lib/duby/compiler.rb,
lib/duby/ast/structure.rb,
lib/duby/jvm/source_generator/precompile.rb
Instance Attribute Summary
Attributes inherited from Node
#children, #inferred_type, #newline, #parent, #position
Instance Method Summary collapse
- #compile(compiler, expression) ⇒ Object
- #expr?(compiler) ⇒ Boolean
-
#infer(typer) ⇒ Object
Type of a block is the type of its final element.
-
#initialize(parent, line_number, &block) ⇒ Body
constructor
A new instance of Body.
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, &block) ⇒ Body
Returns a new instance of Body.
3 4 5 |
# File 'lib/duby/ast/structure.rb', line 3 def initialize(parent, line_number, &block) super(parent, line_number, &block) end |
Instance Method Details
#compile(compiler, expression) ⇒ Object
42 43 44 45 |
# File 'lib/duby/compiler.rb', line 42 def compile(compiler, expression) compiler.line(line_number) compiler.body(self, expression) end |
#expr?(compiler) ⇒ Boolean
44 45 46 |
# File 'lib/duby/jvm/source_generator/precompile.rb', line 44 def expr?(compiler) false end |
#infer(typer) ⇒ Object
Type of a block is the type of its final element
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/duby/ast/structure.rb', line 8 def infer(typer) unless @inferred_type if children.size == 0 @inferred_type = typer.default_type else children.each {|child| @inferred_type = typer.infer(child)} end unless @inferred_type typer.defer(self) end end @inferred_type end |