org.inxar.jenesis
Class VirtualMachine

java.lang.Object
  |
  +--org.inxar.jenesis.VirtualMachine
Direct Known Subclasses:
MVM

public abstract class VirtualMachine
extends java.lang.Object

The VirtualMachine acts as a factory method for CompilationUnit, Type, Literal, and Expression objects. Most Statement factory methods are located on Block; most Declaration factory methods are located on the objects that contain them.


Field Summary
protected static VirtualMachine virtualMachine
          The default VirtualMachine implementation.
 
Constructor Summary
VirtualMachine()
           
 
Method Summary
abstract  void encode()
          Writes out the source code to all enclosed CompilationUnit instances.
abstract  VirtualCompiler getCompiler()
          Returns the active compiler.
static VirtualMachine getVirtualMachine()
          Returns the default VirtualMachine implementation previously set using the static setVirtualMachine(VirtualMachine) method OR returns the reference implementation (com.inxar.jenesis.MVM.
abstract  FieldAccess newAccess(java.lang.String qualifier, java.lang.String name)
          Expression factory method which returns a new field access with the given qualifier and name.
abstract  NewAnonymousClass newAnon(Type type)
          Expression factory method which returns a new anonymous class instance creation expression for the given type.
abstract  ArrayType newArray(int type, int dims)
          Type factory method which returns an array of primitive type with the given constant and dimensions.
abstract  ArrayType newArray(java.lang.String type, int dims)
          Type factory method which returns an array of class type with the given name and dimensions.
abstract  NewArray newArray(Type type)
          Expression factory method which returns a new array instance creation expression for the given type.
abstract  ArrayAccess newArrayAccess(java.lang.String qual, java.lang.String name)
          Expression factory method which returns a new array access expression with the given qualifier and name.
abstract  ArrayInitializer newArrayInit(java.lang.Object o)
          Expression factory method which returns a new array initializer with the given arguments.
abstract  Assign newAssign(int type, Variable left, Expression right)
          Expression factory method which returns a new assignment of the given type.
abstract  Assign newAssign(Variable left, Expression right)
          Expression factory method which returns a new assignment of the SIMPLE type.
abstract  Binary newBinary(int type, Expression left, Expression right)
          Expression factory method which returns a new unary function of the given type.
abstract  Blank newBlank()
          Expression factory method which returns the blank expression.
abstract  ByteLiteral newByte(byte val)
          Literal factory method which returns a new byte literal.
abstract  Cast newCast(Type type, Expression value)
          Expression factory method which returns a new cast function having the given type and value.
abstract  CharLiteral newChar(char val)
          Literal factory method which returns a new char literal.
abstract  ClassLiteral newClass(java.lang.String className)
          Literal factory method which returns a new Class literal.
abstract  NewClass newClass(Type type)
          Expression factory method which returns a new class instance creation expression for the given type.
abstract  CompilationUnit newCompilationUnit(java.lang.String sourcepath)
          Creates a new CompilationUnit in this Machine and returns it.
abstract  DoubleLiteral newDouble(double val)
          Literal factory method which returns a new double literal.
abstract  False newFalse()
          Literal factory method which returns the boolean false literal.
abstract  FloatLiteral newFloat(float val)
          Literal factory method which returns a new float literal.
abstract  Freeform newFree(java.lang.String code)
          Expression factory method which returns a new freeform expression with the given code.
abstract  IntLiteral newInt(int val)
          Literal factory method which returns a new int literal.
abstract  Invoke newInvoke(java.lang.String qualifier, java.lang.String name)
          Expression factory method which returns a new method invocation with the given qualifier and name.
abstract  LongLiteral newLong(long val)
          Literal factory method which returns a new long literal.
abstract  Null newNull()
          Literal factory method which returns the null literal.
abstract  OctalLiteral newOctal(char val)
          Literal factory method which returns a new octal char literal.
abstract  ScientificLiteral newScientific(int precision, int scale, int exponent)
          Literal factory method which returns a new scientific floating point char literal.
abstract  ShortLiteral newShort(short val)
          Literal factory method which returns a new short literal.
abstract  StringLiteral newString(java.lang.String val)
          Literal factory method which returns a new String literal.
abstract  Ternary newTernary(int type, Expression one, Expression two, Expression three)
          Expression factory method which returns a new unary function of the given type.
abstract  True newTrue()
          Literal factory method which returns the boolean true literal.
abstract  PrimitiveType newType(int type)
          Type factory method which returns a primitive type named by the given int as allowed by the constants listed in the Type interface.
abstract  ClassType newType(java.lang.String name)
          Type factory method which returns a class type named with the given String.
abstract  Unary newUnary(int type, Expression value)
          Expression factory method which returns a new unary function of the given type.
abstract  UnicodeLiteral newUnicode(char val)
          Literal factory method which returns a new unicode char literal.
abstract  Variable newVar(java.lang.String name)
          Expression factory method which returns a new variable with the given name.
abstract  void setCompiler(VirtualCompiler compiler)
          Sets the active compiler.
static void setVirtualMachine(VirtualMachine vm)
          Sets the default VirtualMachine implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

virtualMachine

protected static VirtualMachine virtualMachine
The default VirtualMachine implementation.
Constructor Detail

VirtualMachine

public VirtualMachine()
Method Detail

encode

public abstract void encode()
                     throws java.io.IOException
Writes out the source code to all enclosed CompilationUnit instances.

newCompilationUnit

public abstract CompilationUnit newCompilationUnit(java.lang.String sourcepath)
Creates a new CompilationUnit in this Machine and returns it.

newType

public abstract ClassType newType(java.lang.String name)
Type factory method which returns a class type named with the given String.

newType

public abstract PrimitiveType newType(int type)
Type factory method which returns a primitive type named by the given int as allowed by the constants listed in the Type interface.

newArray

public abstract ArrayType newArray(java.lang.String type,
                                   int dims)
Type factory method which returns an array of class type with the given name and dimensions.

newArray

public abstract ArrayType newArray(int type,
                                   int dims)
Type factory method which returns an array of primitive type with the given constant and dimensions.

newNull

public abstract Null newNull()
Literal factory method which returns the null literal.

newTrue

public abstract True newTrue()
Literal factory method which returns the boolean true literal.

newFalse

public abstract False newFalse()
Literal factory method which returns the boolean false literal.

newByte

public abstract ByteLiteral newByte(byte val)
Literal factory method which returns a new byte literal.

newShort

public abstract ShortLiteral newShort(short val)
Literal factory method which returns a new short literal.

newInt

public abstract IntLiteral newInt(int val)
Literal factory method which returns a new int literal.

newLong

public abstract LongLiteral newLong(long val)
Literal factory method which returns a new long literal.

newFloat

public abstract FloatLiteral newFloat(float val)
Literal factory method which returns a new float literal.

newDouble

public abstract DoubleLiteral newDouble(double val)
Literal factory method which returns a new double literal.

newScientific

public abstract ScientificLiteral newScientific(int precision,
                                                int scale,
                                                int exponent)
Literal factory method which returns a new scientific floating point char literal.

newChar

public abstract CharLiteral newChar(char val)
Literal factory method which returns a new char literal.

newOctal

public abstract OctalLiteral newOctal(char val)
Literal factory method which returns a new octal char literal.

newUnicode

public abstract UnicodeLiteral newUnicode(char val)
Literal factory method which returns a new unicode char literal.

newString

public abstract StringLiteral newString(java.lang.String val)
Literal factory method which returns a new String literal.

newClass

public abstract ClassLiteral newClass(java.lang.String className)
Literal factory method which returns a new Class literal.

newCast

public abstract Cast newCast(Type type,
                             Expression value)
Expression factory method which returns a new cast function having the given type and value.

newUnary

public abstract Unary newUnary(int type,
                               Expression value)
Expression factory method which returns a new unary function of the given type.

newBinary

public abstract Binary newBinary(int type,
                                 Expression left,
                                 Expression right)
Expression factory method which returns a new unary function of the given type.

newTernary

public abstract Ternary newTernary(int type,
                                   Expression one,
                                   Expression two,
                                   Expression three)
Expression factory method which returns a new unary function of the given type.

newAssign

public abstract Assign newAssign(int type,
                                 Variable left,
                                 Expression right)
Expression factory method which returns a new assignment of the given type.

newAssign

public abstract Assign newAssign(Variable left,
                                 Expression right)
Expression factory method which returns a new assignment of the SIMPLE type. This is a convenience * method.

newArrayInit

public abstract ArrayInitializer newArrayInit(java.lang.Object o)
Expression factory method which returns a new array initializer with the given arguments.

newFree

public abstract Freeform newFree(java.lang.String code)
Expression factory method which returns a new freeform expression with the given code.

newVar

public abstract Variable newVar(java.lang.String name)
Expression factory method which returns a new variable with the given name.

newBlank

public abstract Blank newBlank()
Expression factory method which returns the blank expression.

newAccess

public abstract FieldAccess newAccess(java.lang.String qualifier,
                                      java.lang.String name)
Expression factory method which returns a new field access with the given qualifier and name.

newInvoke

public abstract Invoke newInvoke(java.lang.String qualifier,
                                 java.lang.String name)
Expression factory method which returns a new method invocation with the given qualifier and name.

newArrayAccess

public abstract ArrayAccess newArrayAccess(java.lang.String qual,
                                           java.lang.String name)
Expression factory method which returns a new array access expression with the given qualifier and name.

newArray

public abstract NewArray newArray(Type type)
Expression factory method which returns a new array instance creation expression for the given type.

newClass

public abstract NewClass newClass(Type type)
Expression factory method which returns a new class instance creation expression for the given type.

newAnon

public abstract NewAnonymousClass newAnon(Type type)
Expression factory method which returns a new anonymous class instance creation expression for the given type.

getCompiler

public abstract VirtualCompiler getCompiler()
Returns the active compiler.

setCompiler

public abstract void setCompiler(VirtualCompiler compiler)
Sets the active compiler.

getVirtualMachine

public static VirtualMachine getVirtualMachine()
Returns the default VirtualMachine implementation previously set using the static setVirtualMachine(VirtualMachine) method OR returns the reference implementation (com.inxar.jenesis.MVM.

setVirtualMachine

public static void setVirtualMachine(VirtualMachine vm)
Sets the default VirtualMachine implementation.