piglet.translate
Class SpigletResult

java.lang.Object
  extended by piglet.translate.SpigletResult

public final class SpigletResult
extends java.lang.Object

The result of visiting a Piglet expression subtree in translating to Spiglet.

Author:
Santoso Wijaya

Constructor Summary
SpigletResult(SimpleExp exp)
          Wraps a simple expression as a result.
 
Method Summary
 SimpleExp getExp()
          Returns the wrapped expression result.
 SpigletTemp processAsTemp(SpigletContext context)
          Returns a Temp object that is equivalent to the evaluation of the wrapped expression result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpigletResult

public SpigletResult(SimpleExp exp)
Wraps a simple expression as a result.

Parameters:
exp - the expression result
Method Detail

getExp

public SimpleExp getExp()
Returns the wrapped expression result.

Returns:
the wrapped expression result

processAsTemp

public SpigletTemp processAsTemp(SpigletContext context)
Returns a Temp object that is equivalent to the evaluation of the wrapped expression result. If it is already a Temp, return said Temp. If it is not, move it first to a new Temp, then return said Temp.

Parameters:
context - the context to where a possible MOVE statement might be attached
Returns:
the Temp object that corresponds to the evaluated expression