irt
Class Interpreter

java.lang.Object
  |
  +--irt.Interpreter

public class Interpreter
extends java.lang.Object

A class to interpret Intermediate Representation (IR) trees of PT programs. To use, create a new instance of Interpreter with an output stream, list of fragments to interpret, and flags fTrace and fDump (see constructor documentation).

The interpreter makes a number of undocumented assumptions about the nature of IR trees, so it may be fragile in some respects. Some specific assumptions are documented here.

Predefined, built-in registers. The interpreter assumes that IR code referring to Temp.FP is the Frame Pointer register and Temp.SP is the Stack Pointer register. There is no need for an IR program to set the FP or SP registers; all manipulation is done automatically.

Procedure calling convention. The (procedure call) stack grows "downward" in memory, towards numerically smaller addresses. Arguments to a procedure are pushed onto the (system) stack in reverse order (argument 1 nearest the top of the stack). The FP register is set to point to the first argument. Thus, FP+wordsize is argument 2 and FP-wordsize is the first allocated local variable. The size argument to CALL is the size of the frame *excluding* the parameters (which are a part of the extended frame of the caller, and so need not be counted).

Evaluation stack. The interpreter includes a built-in "evaluation stack" for evaluating nested arithmetic expressions. There is no need to generate and use temporaries (although they are supported). The evaluation stack is automatically saved and restored across procedure calls.


Constructor Summary
Interpreter(java.io.PrintStream out, FragList fragList, boolean fTrace, boolean fDump)
          Create interpreter and compile program fragments.
 
Method Summary
 void run()
          Start execution of PT program.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Interpreter

public Interpreter(java.io.PrintStream out,
                   FragList fragList,
                   boolean fTrace,
                   boolean fDump)
Create interpreter and compile program fragments.
Parameters:
out - all output is written to this stream.
fragList - head of fragment list to be loaded and run.
fTrace - set true to see trace output during run.
fDump - set true to get a memory dump before run.
Method Detail

run

public void run()
Start execution of PT program.