Class: Mirah::AST::TempValue

Inherits:
Object
  • Object
show all
Defined in:
lib/mirah/jvm/source_generator/precompile.rb

Instance Method Summary collapse

Constructor Details

#initialize(node, compiler = nil, value = nil) ⇒ TempValue

Returns a new instance of TempValue.



20
21
22
23
24
25
26
27
# File 'lib/mirah/jvm/source_generator/precompile.rb', line 20

def initialize(node, compiler=nil, value=nil)
  if compiler.nil?
    @tempname = node
  else
    @tempname = compiler.temp(node, value)
    @tempvalue = value || node
  end
end

Instance Method Details

#compile(compiler, expression) ⇒ Object



29
30
31
32
33
# File 'lib/mirah/jvm/source_generator/precompile.rb', line 29

def compile(compiler, expression)
  if expression
    compiler.method.print @tempname
  end
end

#reload(compiler) ⇒ Object



35
36
37
# File 'lib/mirah/jvm/source_generator/precompile.rb', line 35

def reload(compiler)
  compiler.assign(@tempname, @tempvalue)
end