org.erights.e.elang.evm
Class EExpr

java.lang.Object
  |
  +--org.erights.e.elang.evm.ParseNode
        |
        +--org.erights.e.elang.evm.ENode
              |
              +--org.erights.e.elang.evm.EExpr
All Implemented Interfaces:
Cloneable, EPrintable, MatchMaker
Direct Known Subclasses:
AssignExpr, AtomicExpr, CallExpr, CatchExpr, DefineExpr, EscapeExpr, FinallyExpr, HideExpr, IfExpr, LiteralExpr, MatchBindExpr, ObjectExpr, ScopeExpr, SendExpr, SeqExpr, SlotExpr, SmallcapsExpr

public abstract class EExpr
extends ENode

Untamed: Those ParseNodes that--after expansion--define the kernel expressions evaluated by the E Virtual Machine.

Author:
Mark S. Miller, E. Dean Tribble

Field Summary
 
Fields inherited from class org.erights.e.elang.evm.ENode
 
Fields inherited from class org.erights.e.elang.evm.ParseNode
NUM_PR, PR_ASSIGN, PR_CALL, PR_COMP, PR_EEXPR, PR_LISTPATT, PR_ORDER, PR_PATTERN, PR_PRIM, PR_START
 
Constructor Summary
protected EExpr(SourceSpan optSpan)
           
 
Method Summary
 void __printOn(TextWriter out)
          Enabled: @see #subPrintOn
(package private) static void appendAllTo(FlexList accum, EExpr[] all)
          Recursively append all the supplied nodes to accum.
(package private)  void appendTo(FlexList accum)
          Append the sequence of operations representated by this node to the argument.
static Object eval(EExpr self, Scope scope, int maxLocals)
          Enabled: To be invoked only on a Transformed-E expression to do the actual evaluation.
 Object eval(Scope scope)
          Enabled: Used to evaluate this expression to a value in scope.
(package private)  boolean evalBool(EvalContext ctx)
          Like subEval, but returns the result coerced to a boolean.
 void printAsBlockOn(TextWriter out)
          Enabled:
protected abstract  Object subEval(EvalContext ctx, boolean forValue)
          The recursive part that does the work
 EExpr substitute(ConstList args)
          Enabled:
static Object[] transform(EExpr self, Scope scope)
          Enabled: Transforms from Expanded-E or Kernel-E to the internal Transformed-E.
 
Methods inherited from class org.erights.e.elang.evm.ENode
cleanCopy, computeStaticScope, copy, getOptPatternMap, getOptScopeMap, getPatternMap, getScopeMap, qbuild, setPatternMap, setScopeMap, staticScope, synEnv, welcome
 
Methods inherited from class org.erights.e.elang.evm.ParseNode
asText, getOptSpan, lnPrintOn, lnPrintOn, matchBind, matchBind, matchBind, matchBind, printListOn, subPrintOn, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EExpr

protected EExpr(SourceSpan optSpan)
Method Detail

__printOn

public void __printOn(TextWriter out)
               throws IOException
Enabled: @see #subPrintOn

Specified by:
__printOn in interface EPrintable
Overrides:
__printOn in class ParseNode
IOException
See Also:
ParseNode.subPrintOn(org.erights.e.elib.oldeio.TextWriter, int)

substitute

public EExpr substitute(ConstList args)
Enabled:


transform

public static Object[] transform(EExpr self,
                                 Scope scope)
Enabled: Transforms from Expanded-E or Kernel-E to the internal Transformed-E.

The transform method is factored out from eval so that the interpreter loop can print the transformed expression for debugging purposes.

XXX This should be changed to only take a scopeMap as argument instead, so that the [Expanded-E, ScopeMap] => Transformed-E mapping can be memoized. Once we compile Transformed-E to JVM bytecodes, this will allow us to cache the class files and classes as well.

Returns:
A pair of a Transformed-E expression and the number of locals it needs to evaluate.

eval

public static Object eval(EExpr self,
                          Scope scope,
                          int maxLocals)
Enabled: To be invoked only on a Transformed-E expression to do the actual evaluation.

This is the rest of eval/1 after factoring out transform/2, and is likewise public only for debugging purposes.

XXX We need to enforce that this is only invoked on a Transformed-E expression. The Transformed-E EExpr should probably remember the number of locals it needs, so we don't have to worry about a bad value being passed in.


eval

public Object eval(Scope scope)
Enabled: Used to evaluate this expression to a value in scope.


subEval

protected abstract Object subEval(EvalContext ctx,
                                  boolean forValue)
The recursive part that does the work


evalBool

boolean evalBool(EvalContext ctx)
Like subEval, but returns the result coerced to a boolean.


printAsBlockOn

public void printAsBlockOn(TextWriter out)
                    throws IOException
Enabled:

IOException

appendTo

void appendTo(FlexList accum)
Append the sequence of operations representated by this node to the argument.

Parameters:
accum -

appendAllTo

static void appendAllTo(FlexList accum,
                        EExpr[] all)
Recursively append all the supplied nodes to accum.

Parameters:
accum - the List to accumulate the results into.
all - the EExprs to accumulate.


comments?