Class: Duby::AST::TempValue

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of TempValue.



5
6
7
8
9
10
11
12
# File 'lib/duby/jvm/source_generator/precompile.rb', line 5

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



14
15
16
17
18
# File 'lib/duby/jvm/source_generator/precompile.rb', line 14

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

#reload(compiler) ⇒ Object



20
21
22
# File 'lib/duby/jvm/source_generator/precompile.rb', line 20

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