autohit.vm.i
Class VMInstruction

java.lang.Object
  extended byautohit.vm.i.VMInstruction
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
VMIAssert, VMICall, VMIClear, VMIEval, VMIExec, VMIFault, VMIFetch, VMIGoto, VMIIf, VMIJump, VMILoad, VMIMask, VMIMath, VMIMerge, VMIMethod, VMINew, VMINop, VMIReduce, VMIRight, VMIRScope, VMIScope, VMIStore, VMISubr

public class VMInstruction
extends java.lang.Object
implements java.io.Serializable

A Virtual Machine instruction base class. All vm instructions extend this class. This class also defines the static/final tokens and related constants used by both the vm and the compiler.

We will implement Serializable with this base class, so all final instruction classes will inherit it,

I thought about making this an interface, but since this IS a vm, it seem like a needless slowdown of a class that is going to get banged around enough as it is.

This class defines the numeric token for all instructions. So, if you create a new instruction, be sure to add a token for it in this class... and recompile ALL of the packages.

All derived-class constructors must set the numeric token.

Version:
1.1 Version History EPG - Rewrite - 9Apr03
EPG - Add goto - 16Jul03
Author:
Erich P. Gatejen
See Also:
Serialized Form

Field Summary
static int ASSERT
           
static int CALL
           
static int CLEAR
           
static int EVAL
           
static int EXEC
           
static int FAULT
           
static int FETCH
           
static int GOTO
           
static int IF
           
 int instruction
          instruction
static int JUMP
           
static int LOAD
           
static int MASK
           
static int MATH
           
static int MERGE
           
static int METHOD
           
static int NEW
           
static int NOP
          Numeric token values.
static int REDUCE
           
static int RIGHT
           
static int RSCOPE
           
static int SCOPE
           
 int sourceline
          source code line - good for debugging TODO sourceline doesn't actually work
static int STORE
           
static int SUBR
           
 
Constructor Summary
VMInstruction()
          Default constructor Normally you would use the other constructor.
VMInstruction(int I)
          Typical constructor.
 
Method Summary
 java.lang.String dump()
          Dump this Instruction.
 java.lang.String toString()
          Dump this Instruction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NOP

public static final int NOP
Numeric token values. This is used as an optimization so we can do an OpCode switch(nToken) in the VM...

See Also:
Constant Field Values

EVAL

public static final int EVAL
See Also:
Constant Field Values

STORE

public static final int STORE
See Also:
Constant Field Values

NEW

public static final int NEW
See Also:
Constant Field Values

SCOPE

public static final int SCOPE
See Also:
Constant Field Values

RSCOPE

public static final int RSCOPE
See Also:
Constant Field Values

REDUCE

public static final int REDUCE
See Also:
Constant Field Values

MASK

public static final int MASK
See Also:
Constant Field Values

MERGE

public static final int MERGE
See Also:
Constant Field Values

RIGHT

public static final int RIGHT
See Also:
Constant Field Values

MATH

public static final int MATH
See Also:
Constant Field Values

LOAD

public static final int LOAD
See Also:
Constant Field Values

CLEAR

public static final int CLEAR
See Also:
Constant Field Values

FAULT

public static final int FAULT
See Also:
Constant Field Values

FETCH

public static final int FETCH
See Also:
Constant Field Values

IF

public static final int IF
See Also:
Constant Field Values

CALL

public static final int CALL
See Also:
Constant Field Values

EXEC

public static final int EXEC
See Also:
Constant Field Values

SUBR

public static final int SUBR
See Also:
Constant Field Values

JUMP

public static final int JUMP
See Also:
Constant Field Values

GOTO

public static final int GOTO
See Also:
Constant Field Values

ASSERT

public static final int ASSERT
See Also:
Constant Field Values

METHOD

public static final int METHOD
See Also:
Constant Field Values

instruction

public int instruction
instruction


sourceline

public int sourceline
source code line - good for debugging TODO sourceline doesn't actually work

Constructor Detail

VMInstruction

public VMInstruction()
Default constructor Normally you would use the other constructor.


VMInstruction

public VMInstruction(int I)
Typical constructor. Sets the instruction type. Use this one!

Method Detail

toString

public java.lang.String toString()
Dump this Instruction. Mostly for debugging.

Returns:
a String containing the dump.

dump

public java.lang.String dump()
Dump this Instruction. Mostly for debugging. Subclasses should override this.

Returns:
a String containing the dump.


Test.