org.erights.e.elang.smallcaps
Class SmallcapsActivation

java.lang.Object
  |
  +--org.erights.e.elang.smallcaps.SmallcapsActivation
All Implemented Interfaces:
SmallcapsOps

public class SmallcapsActivation
extends Object
implements SmallcapsOps

Untamed: The state of one activation frame in a Smallcaps call stack.

XXX This is an incomplete, broken reference implementation -- fix me!

Author:
Mark S. Miller, Darius Bacon

Field Summary
private static ClassDesc BooleanGuard
          Needed from branching
private static ClassDesc EListGuard
          Needed for list-pattern matching.
private  byte[] myCode
           
private  EvalContext myCtx
           
private  SmallcapsHandler[] myHandlerStack
           
private  int myHandlerTOS
           
private  Object[] myOperandStack
           
private  int myPC
           
private  int myTOS
          The top of the operand stack.
 
Fields inherited from interface org.erights.e.elang.smallcaps.SmallcapsOps
ADDR_FRAME, ADDR_FRAME_SLOT, ADDR_LITERAL, ADDR_LOCAL, ADDR_LOCAL_SLOT, ADDR_OUTER_SLOT, OP_ASSIGN, OP_BIND, OP_BIND_SLOT, OP_BRANCH, OP_CALL, OP_CALL_ONLY, OP_CDR_PATT, OP_CHAR, OP_DUP, OP_EJECTOR, OP_EJECTOR_ONLY, OP_END_HANDLER, OP_FALSE, OP_FLOAT64, OP_JUMP, OP_LIST_PATT, OP_NEG_INT, OP_NOUN, OP_NULL, OP_OBJECT, OP_POP, OP_RETURN, OP_ROT, OP_SCOPE, OP_SEND, OP_SEND_ONLY, OP_SLOT, OP_STRING, OP_SWAP, OP_TRUE, OP_TRY, OP_TWINE, OP_UNWIND, OP_WHOLE_NUM
 
Constructor Summary
SmallcapsActivation(byte[] code, int pc, EvalContext ctx)
          Enabled:
 
Method Summary
 Object eval()
          Enabled:
private  void handle(Object problem)
          Handle the problem using the top handler on the handler stack.
private  void handle(OneArgFunc optEjector, Object problem)
          Handle the problem using optEjector, if it's not null, or the top handler on the handler stack if optEjector is null.
private  OneArgFunc makeEjector(int label)
           
private  OneArgFunc makeEjectorOnly(int label)
           
private  Object pop()
           
private  void popHandler()
           
private  Object[] popN(int n)
           
private  void push(Object operand)
           
private  void pushHandler()
           
private  void pushHandler(OneArgFunc ejector)
           
private  void pushTryHandler(int label)
           
private  char readChar()
           
private  double readFloat64()
           
private  int readLabel()
           
private  String readUTF()
           
private  int readWholeInt()
           
private  BigInteger readWholeNum()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EListGuard

private static final ClassDesc EListGuard
Needed for list-pattern matching.


BooleanGuard

private static final ClassDesc BooleanGuard
Needed from branching


myCode

private final byte[] myCode

myPC

private int myPC

myOperandStack

private final Object[] myOperandStack

myTOS

private int myTOS
The top of the operand stack.


myHandlerStack

private final SmallcapsHandler[] myHandlerStack

myHandlerTOS

private int myHandlerTOS

myCtx

private final EvalContext myCtx
Constructor Detail

SmallcapsActivation

public SmallcapsActivation(byte[] code,
                           int pc,
                           EvalContext ctx)
Enabled:

Method Detail

push

private void push(Object operand)

pop

private Object pop()

popN

private Object[] popN(int n)
Parameters:
n - How many to pop
Returns:
An n-element array of the popped elements, from bottom-most to top-most.

handle

private void handle(Object problem)
Handle the problem using the top handler on the handler stack.

Parameters:
problem -

handle

private void handle(OneArgFunc optEjector,
                    Object problem)
Handle the problem using optEjector, if it's not null, or the top handler on the handler stack if optEjector is null.

optEjector may include user-defined behavior. If optEjector returns normally, then invoke the top handler on the handler stack to handle this inappropriate return.

Parameters:
optEjector -
problem -

popHandler

private void popHandler()

pushHandler

private void pushHandler()

pushHandler

private void pushHandler(OneArgFunc ejector)
Parameters:
ejector -

pushTryHandler

private void pushTryHandler(int label)
Parameters:
label -

makeEjectorOnly

private OneArgFunc makeEjectorOnly(int label)
Returns:

makeEjector

private OneArgFunc makeEjector(int label)
Returns:

readWholeNum

private BigInteger readWholeNum()
See Also:
SmallcapsEncoderVisitor#writeWholeNum(BigInteger)

readWholeInt

private int readWholeInt()
See Also:
SmallcapsEncoderVisitor#writeWholeNum(int)

readLabel

private int readLabel()
Returns:

readUTF

private String readUTF()
Returns:

readChar

private char readChar()
Returns:

readFloat64

private double readFloat64()
Returns:

eval

public Object eval()
Enabled:



comments?