org.erights.e.elang.evm
Class ObjectExpr

java.lang.Object
  |
  +--org.erights.e.elang.evm.ParseNode
        |
        +--org.erights.e.elang.evm.ENode
              |
              +--org.erights.e.elang.evm.EExpr
                    |
                    +--org.erights.e.elang.evm.ObjectExpr
All Implemented Interfaces:
Cloneable, EPrintable, MatchMaker

public class ObjectExpr
extends EExpr

Safe: BNF: "def" litString [ "implements" eExpr* ] "{" method* [ matcher ] "}"

Yields an object that closes over the current scope, and responds to requests by dispatching to one of its matching methods, or to a matcher if provided and no methods match.

Author:
Mark S. Miller
See Also:
org.erights.e.elang.evm.DefineExpr

Field Summary
private static ValueGuard AuditorGuard
           
private  FlexSet myAuditorCache
           
private  EExpr[] myAuditorExprs
           
private  String myDocComment
           
private  EScript myEScript
           
private  EMethodTable myOptEMTableCache
           
private  NounExpr[] myOptFieldInits
           
private  String myOptFQN
           
 
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
ObjectExpr(SourceSpan optSpan, String docComment, String optFQN, EExpr[] auditorExprs, EScript eScript)
          Enabled:
ObjectExpr(SourceSpan optSpan, String docComment, String optFQN, EExpr[] auditorExprs, EScript eScript, NounExpr[] fieldNouns)
          Enabled:
 
Method Summary
 ConstList auditors()
          Enabled:
protected  StaticScope computeStaticScope()
          The left-to-right sum of the auditors + the eScript.
private  EMethodTable eMethodTable()
           
 EScript eScript()
          Enabled:
 String getFQName()
          Enabled: Call only after a fully qualified name has been assigned
 String getOptFQN()
          Enabled:
 boolean matchBind(ConstList args, Object specimen, FlexList bindings)
          Enabled:
(package private)  NounExpr[] optFieldNouns()
          Return the nouns used to initialize instance fields from the outer scope.
protected  Object subEval(EvalContext ctx, boolean forValue)
          The recursive part that does the work
 void subPrintOn(TextWriter out, int priority)
          Enabled:
 Object welcome(ETreeVisitor visitor)
          Enabled:
 
Methods inherited from class org.erights.e.elang.evm.EExpr
__printOn, appendAllTo, appendTo, eval, eval, evalBool, printAsBlockOn, substitute, transform
 
Methods inherited from class org.erights.e.elang.evm.ENode
cleanCopy, copy, getOptPatternMap, getOptScopeMap, getPatternMap, getScopeMap, qbuild, setPatternMap, setScopeMap, staticScope, synEnv
 
Methods inherited from class org.erights.e.elang.evm.ParseNode
asText, getOptSpan, lnPrintOn, lnPrintOn, matchBind, matchBind, matchBind, printListOn, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myDocComment

private final String myDocComment

myOptFQN

private final String myOptFQN

myAuditorExprs

private final EExpr[] myAuditorExprs

myAuditorCache

private final FlexSet myAuditorCache

myEScript

private final EScript myEScript

myOptFieldInits

private final NounExpr[] myOptFieldInits

myOptEMTableCache

private transient EMethodTable myOptEMTableCache

AuditorGuard

private static final ValueGuard AuditorGuard
Constructor Detail

ObjectExpr

public ObjectExpr(SourceSpan optSpan,
                  String docComment,
                  String optFQN,
                  EExpr[] auditorExprs,
                  EScript eScript)
Enabled:


ObjectExpr

public ObjectExpr(SourceSpan optSpan,
                  String docComment,
                  String optFQN,
                  EExpr[] auditorExprs,
                  EScript eScript,
                  NounExpr[] fieldNouns)
Enabled:

Method Detail

welcome

public Object welcome(ETreeVisitor visitor)
Enabled:

Specified by:
welcome in class ENode

optFieldNouns

NounExpr[] optFieldNouns()
Return the nouns used to initialize instance fields from the outer scope.

Will be non-null after the appropriate compilation transformation.


getOptFQN

public String getOptFQN()
Enabled:


computeStaticScope

protected StaticScope computeStaticScope()
The left-to-right sum of the auditors + the eScript.

Note that the instance variable are only the variables used by the eScript, not the variables used by the objectExpr as a whole, since the auditor expressions are evaluated in the instantiating environment.

Specified by:
computeStaticScope in class ENode

subEval

protected Object subEval(EvalContext ctx,
                         boolean forValue)
Description copied from class: EExpr
The recursive part that does the work

Specified by:
subEval in class EExpr

matchBind

public boolean matchBind(ConstList args,
                         Object specimen,
                         FlexList bindings)
Enabled:

Specified by:
matchBind in interface MatchMaker
Specified by:
matchBind in class ParseNode

subPrintOn

public void subPrintOn(TextWriter out,
                       int priority)
                throws IOException
Enabled:

Specified by:
subPrintOn in class ParseNode
IOException

getFQName

public String getFQName()
Enabled: Call only after a fully qualified name has been assigned


auditors

public ConstList auditors()
Enabled:


eScript

public EScript eScript()
Enabled:


eMethodTable

private EMethodTable eMethodTable()


comments?