Class: Duby::AST::Loop

Inherits:
Node show all
Defined in:
lib/duby/ast/flow.rb,
lib/duby/jvm/source_generator/precompile.rb

Direct Known Subclasses

ForLoop, WhileLoop

Instance Attribute Summary collapse

Attributes inherited from Node

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

Instance Method Summary collapse

Methods inherited from Node

#[], #each, #initialize, #inspect, #line_number, #log, #resolve_if, #resolved!, #resolved?, #simple_name, #temp, #to_s

Constructor Details

This class inherits a constructor from Duby::AST::Node

Instance Attribute Details

#redoObject

Returns the value of attribute redo.



96
97
98
# File 'lib/duby/ast/flow.rb', line 96

def redo
  @redo
end

Instance Method Details

#expr?(compiler) ⇒ Boolean

Returns:



59
60
61
# File 'lib/duby/jvm/source_generator/precompile.rb', line 59

def expr?(compiler)
  false
end

#infer(typer) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/duby/ast/flow.rb', line 98

def infer(typer)
  unless resolved?
    child_types = children.map {|c| typer.infer(c)}
    if child_types.any? {|t| t.nil?}
      typer.defer(self)
    else
      resolved!
      @inferred_type = typer.null_type
    end
  end

  @inferred_type
end

#precompile(compiler) ⇒ Object



63
64
65
66
# File 'lib/duby/jvm/source_generator/precompile.rb', line 63

def precompile(compiler)
  compile(compiler, false)
  temp(compiler, 'null')
end