autohit.vm
Class SimVM

java.lang.Object
  extended byautohit.vm.VM
      extended byautohit.vm.SimVM

public class SimVM
extends VM

A VM for a Sim.

A VMNOp marks the bottom of the scope stack. If we ever pop a nop, there is nothing left to do.

Subroutine stack frames consist of the IP pointer (to calling instruction) in Integer form and the calling VMExecutable. When a the IP goes past the last instruction, the SimVM wil check the stack for a VMExecutable. If it sees one, it will assume it is the return from a subroutine. The LEFT is left alone, since this is how the subroutine passes a return value. If the subroutine specified a return, but it isn't set, the VM will log an error and use a blank return value. The subroutine depth (subDepth) will be incremented and decremented as we enter and leave routines. This helps up keep an exception from unravelling the entire VM.

Currently only the following MATH operations are implemented

 +	= plus
 - 	= minus
 /    = division
 *    = multiply
 

ERRORS ----------

This VM expects the following environment variables to be set before the execute() method is called. If they aren't set, the defaults will be used.

Version:
1.0 Version History EPG - Rewrite - 8May03
EPG - Add goto - 16Jul03
EPG - Add assert - 5Aug03
EPG - Add module shortcut - 9Aug03
Author:
Erich P. Gatejen
See Also:
autohit.vm

Field Summary
 
Fields inherited from class autohit.vm.VM
buf, core, errors, faults, ip, left, loader, myLog, process, right, rinjector, rootProgram, sname, state, STATE_ACTIVE_THRESHOLD, STATE_BUILDING, STATE_DONE, STATE_INVALID, STATE_NEW, STATE_NO_VM, STATE_PAUSED, STATE_RUNNING, TIME_GRAN
 
Constructor Summary
SimVM()
          Default Constructor.
 
Method Summary
 void construct()
          Complete construction.
 void destruct()
          Destroy.
 void execute()
          Implements the inherited abstract method execute().
 void prepare()
          Prepare for execution of the first instruction.
 
Methods inherited from class autohit.vm.VM
attach, die, finalize, getState, init, pause, resume, setParentCore, start, ticks
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimVM

public SimVM()
Default Constructor. Don't do anything!

Method Detail

construct

public void construct()
Complete construction. This will be (should be) called right after a VM object is constructed. This is where you set the target program name.

Specified by:
construct in class VM

destruct

public void destruct()
              throws VMException
Destroy. This will be called when the VM is finalizing.

Specified by:
destruct in class VM
Throws:
VMException

prepare

public void prepare()
             throws java.lang.Exception
Prepare for execution of the first instruction. We need to add environment variables. DO NOT call this method directly.

Overrides:
prepare in class VM
Throws:
Any - exceptions it encounters.
java.lang.Exception

execute

public void execute()
             throws VMException
Implements the inherited abstract method execute(). Call this to execute a single instruction, The first call will be automatic after the inherited start() method is called. From there, the owning Object/Thread should call this method for each successive instruction to execute.

This method will throw a VMException(VMException.DONE) if there are no more instructions that can be executed. (The ip is past the end of the exec Vector).

Specified by:
execute in class VM
Throws:
VMException
See Also:
VMException


Test.