net.sf.transjvm
Class Variable

java.lang.Object
  extended by net.sf.transjvm.Expression
      extended by net.sf.transjvm.Variable

public abstract class Variable
extends Expression

Variables represents storage locations in the JVM: locals, fields and array members. They can be read, so extend Expression, but can be written to as well, using the store and assign methods.

Author:
Mark Shannon
See Also:
FieldID.variable(Expression owner), FieldID.staticVariable(), Frame.variable(TypeID type), Frame.parameter(int index), Frame._this(), Expression.index(Expression index)

Field Summary
 
Fields inherited from class net.sf.transjvm.Expression
FALSE, NULL, ONE, TRUE, ZERO
 
Method Summary
 Expression assign(Expression value)
          Returns the assignment expression this = value.
abstract  void assign(Expression value, InstructionStream stream, int depth)
          Store value to this Variable and leave value on top of stack, returning stack height
 Statement increment(int incr)
          Returns a statement which increments this by incr.
 Expression postIncrement()
          Returns an expression which increments the variable by one as a side effect, and evaluates to the value of the variable after it has incremented.
 Expression preIncrement()
          Returns an expression which evaluates to the same as this Variable, while incrementing the variable by one as a side effect.
 Statement store(Expression value)
          Returns the assignment statement this = value.
abstract  void store(Expression value, InstructionStream stream)
          Store value to this Variable
 
Methods inherited from class net.sf.transjvm.Expression
accept, bitwise, bitwiseNot, branch, branch, branch, cast, compare, conditional, constant, constant, constant, constant, constant, convert, emptyArray, eval, filledArray, getType, index, isInstanceOf, length, logicalNot, math, negate, not, shortCut, toStm
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

store

public abstract void store(Expression value,
                           InstructionStream stream)
Store value to this Variable


assign

public abstract void assign(Expression value,
                            InstructionStream stream,
                            int depth)
Store value to this Variable and leave value on top of stack, returning stack height


preIncrement

public final Expression preIncrement()
Returns an expression which evaluates to the same as this Variable, while incrementing the variable by one as a side effect. This variable must have a numeric type.


postIncrement

public final Expression postIncrement()
Returns an expression which increments the variable by one as a side effect, and evaluates to the value of the variable after it has incremented. This variable must have a numeric type.


store

public Statement store(Expression value)
Returns the assignment statement this = value.

Parameters:
value - The value to be assigned.
Returns:
A statement which assigns value to this.

increment

public Statement increment(int incr)
Returns a statement which increments this by incr. Type must be INT32

Parameters:
incr - The amount to increment var by.

assign

public Expression assign(Expression value)
Returns the assignment expression this = value. Note that var.assign(value).toStm() is equivalent to var.store(value).

Parameters:
value - The value to be assigned.
Returns:
Expression which has the same value as value, but assigns value to this as a side effect.


Copyright 2004-5, Mark Shannon