net.sf.transjvm
Class Statement

java.lang.Object
  extended by net.sf.transjvm.Statement
Direct Known Subclasses:
Label

public abstract class Statement
extends java.lang.Object

Statements are the basic building blocks of JVM code


Field Summary
static Statement RETURN_VOID
          Return statement for methods of type VOID.
static Statement SKIP
          The "No operation" statement.
 
Constructor Summary
Statement()
           
 
Method Summary
static Statement _goto(Label target)
          Returns a statement that jumps to the Label target.
static Statement _if(Expression cond, Statement stmt)
          Returns a Statement conditionally executing stmt.
static Statement _if(Expression cond, Statement _true, Statement _false)
          Returns a Statement conditionally executing either _true or _false.
static Statement _return(Expression ret)
          Returns a Statement which returns Expression ret from the current method.
static Statement _switch(Expression value, Case[] cases, Label _default)
          Returns a Statement branches to whichever Case matches value, _default otherwise.
static Statement _switch(Expression value, Case[] cases, Label _default, float density)
          Returns a Statement branches to whichever Case matches value, _default otherwise.
static Statement _throw(Expression throwable)
          Returns a Statement throwing Expression throwable.
static Statement always(Statement body, Statement epilogue, Variable errorStore)
          Returns a Statement which executes body, followed by epilogue.
static Statement callSuper(ConstructorID initID, Expression... arguments)
          Returns a statement which calls the super-class constructor with arguments.
 Statement concat(Statement other)
          Returns a new Statement which executes this followed by other.
static Statement defaultCallSuper(TypeID superClass)
          Returns a statement which calls the super-class constructor with no arguments.
static Statement delegate(TypeID[] params, TypeID retType, boolean isStatic, MethodID proxyID)
           
static Statement guarded(Statement body, Variable errorValue, Handler... handlers)
          Returns a Statement which executes body, handling exceptions which may occur.
 Statement line(int line)
          Returns the same statement, but with the line number attached for debugging.
static Statement list(java.util.List<Statement> list)
          Returns a Statement representing a list of statements, to be executed sequentially.
static Statement list(Statement... list)
          Returns a Statement representing a list of statements, to be executed sequentially.
abstract  void write(InstructionStream stream)
          Writes this Statement to the stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SKIP

public static final Statement SKIP
The "No operation" statement. Does nothing.


RETURN_VOID

public static final Statement RETURN_VOID
Return statement for methods of type VOID.

Constructor Detail

Statement

public Statement()
Method Detail

_switch

public static Statement _switch(Expression value,
                                Case[] cases,
                                Label _default)
Returns a Statement branches to whichever Case matches value, _default otherwise. Calls _switch(value, cases, _default, 0.5).

Parameters:
value - The expression which determines which way to branch. Must be of type INT32.
cases - Possible branch targets.
_default - The default target.

_switch

public static Statement _switch(Expression value,
                                Case[] cases,
                                Label _default,
                                float density)
Returns a Statement branches to whichever Case matches value, _default otherwise.

Parameters:
value - The expression which determines which way to branch. Must be of type INT32.
cases - Possible branch targets.
_default - The default target.
density - The minimum density for array access, otherwise hash access.

guarded

public static Statement guarded(Statement body,
                                Variable errorValue,
                                Handler... handlers)
Returns a Statement which executes body, handling exceptions which may occur.

Parameters:
body - The body of code to be executed.
handlers - The handlers guarding body.
errorValue - The variable into which the throwable is to be stored.

always

public static Statement always(Statement body,
                               Statement epilogue,
                               Variable errorStore)
Returns a Statement which executes body, followed by epilogue. epilogue is executed after body whether, or not, an exception is thrown. However if code in body branches elsewhere, epilogue will not be executed.

Parameters:
body - The body of code to be executed.
epilogue - Code guaranteed to be executed whether or not an exeception occurs.
errorStore - The variable into which to store any throwable thrown during body, whilst always is executing.

_if

public static Statement _if(Expression cond,
                            Statement _true,
                            Statement _false)
Returns a Statement conditionally executing either _true or _false.

Parameters:
cond - The condition, must be of type BOOLEAN.
_true - The statement executed if cond is true.
_false - The statement executed if cond is false.

_throw

public static Statement _throw(Expression throwable)
Returns a Statement throwing Expression throwable.

Parameters:
throwable - Expression throwable must be a Throwable.

defaultCallSuper

public static Statement defaultCallSuper(TypeID superClass)
Returns a statement which calls the super-class constructor with no arguments.

Parameters:
superClass - The super-class.

callSuper

public static Statement callSuper(ConstructorID initID,
                                  Expression... arguments)
Returns a statement which calls the super-class constructor with arguments.

Parameters:
initID - The super-class constructor.
arguments - The arguments to pass to the super-class constructor.

_goto

public static Statement _goto(Label target)
Returns a statement that jumps to the Label target.

Parameters:
target - The target of the goto statement.

_if

public static Statement _if(Expression cond,
                            Statement stmt)
Returns a Statement conditionally executing stmt.

Parameters:
cond - The condition, must be of type BOOLEAN.
stmt - The statement executed if cond is true.

_return

public static Statement _return(Expression ret)
Returns a Statement which returns Expression ret from the current method.

Parameters:
ret - The expression to be returned. Type must match the return type of the enclosing method.

concat

public final Statement concat(Statement other)
Returns a new Statement which executes this followed by other.

Parameters:
other - The statement to be executed after this.
Returns:
Compound statement of this followed by other.

line

public final Statement line(int line)
Returns the same statement, but with the line number attached for debugging.


list

public static final Statement list(java.util.List<Statement> list)
Returns a Statement representing a list of statements, to be executed sequentially.


list

public static final Statement list(Statement... list)
Returns a Statement representing a list of statements, to be executed sequentially.

Throws:
java.lang.IllegalArgumentException - if any member of list is not a Statement.

write

public abstract void write(InstructionStream stream)
Writes this Statement to the stream

Parameters:
stream - The InstructionStream to write to.

delegate

public static Statement delegate(TypeID[] params,
                                 TypeID retType,
                                 boolean isStatic,
                                 MethodID proxyID)


Copyright 2004-5, Mark Shannon