org.erights.e.elang.evm
Class Matcher

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

public class Matcher
extends ENode
implements Script, EStackItem

Safe:


Field Summary
private  EExpr myBody
           
private  CallCounter myCallCounter
           
private  int myLocalCount
           
private  String myOptTypeName
           
private  Pattern myPattern
           
 
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
Matcher(SourceSpan optSpan, Pattern pattern, EExpr body)
          Enabled:
Matcher(SourceSpan optSpan, Pattern pattern, EExpr body, int localCount)
          Enabled:
 
Method Summary
 EExpr body()
          Enabled:
protected  StaticScope computeStaticScope()
          When staticScope() is first requested on a given node, it calls computeStaticScope() to do the actual computation, which is then remembered.
 Object execute(Object self, String verb, Object[] args)
          Enabled:
 boolean matchBind(ConstList args, Object specimen, FlexList bindings)
          Enabled:
 Pattern pattern()
          Enabled:
 void protocol(Object optSelf, FlexList mTypes)
          Enabled:
 boolean respondsTo(Object optSelf, String verb, int arity)
          Enabled:
(package private)  void setTypeName(String typeName)
           
 Script shorten(Object optSelf, String aVerb, Object[] args)
          Enabled: Just returns this.
 void subPrintOn(TextWriter out, int priority)
          Enabled:
 String toString()
          Suppressed:
 void traceOn(TextWriter out)
          Enabled:
 Object welcome(ETreeVisitor visitor)
          Enabled:
 
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
__printOn, asText, getOptSpan, lnPrintOn, lnPrintOn, matchBind, matchBind, matchBind, printListOn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myPattern

private final Pattern myPattern

myBody

private final EExpr myBody

myLocalCount

private final int myLocalCount

myOptTypeName

private String myOptTypeName

myCallCounter

private CallCounter myCallCounter
Constructor Detail

Matcher

public Matcher(SourceSpan optSpan,
               Pattern pattern,
               EExpr body)
Enabled:


Matcher

public Matcher(SourceSpan optSpan,
               Pattern pattern,
               EExpr body,
               int localCount)
Enabled:

Method Detail

welcome

public Object welcome(ETreeVisitor visitor)
Enabled:

Specified by:
welcome in class ENode

pattern

public Pattern pattern()
Enabled:


body

public EExpr body()
Enabled:


computeStaticScope

protected StaticScope computeStaticScope()
When staticScope() is first requested on a given node, it calls computeStaticScope() to do the actual computation, which is then remembered.

Specified by:
computeStaticScope in class ENode

shorten

public Script shorten(Object optSelf,
                      String aVerb,
                      Object[] args)
Enabled: Just returns this.

Specified by:
shorten in interface Script
Parameters:
optSelf - If present, then a script could shorten using instance-specific data.
aVerb - Must be interned
args - Typically, only its arity is used. But OverloaderNode uses the types of the arguments to select among Java overloads.
Returns:
The Script to use in lieu of this one. Note that it's always correct a Script to just return itself.

execute

public Object execute(Object self,
                      String verb,
                      Object[] args)
Enabled:

Specified by:
execute in interface Script

matchBind

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

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

protocol

public void protocol(Object optSelf,
                     FlexList mTypes)
Enabled:

Specified by:
protocol in interface Script
Parameters:
optSelf - If non-null, and if this script has a match clause, then delegate an __allegedType query to optSelf via the match clause so it can add further elements to mTypes.

Since 'null' is normally a valid value for a 'self', this use of 'null' depends on our knowledge that 'null''s script does not have its own match clause.

mTypes - message descriptions.

respondsTo

public boolean respondsTo(Object optSelf,
                          String verb,
                          int arity)
Enabled:

Specified by:
respondsTo in interface Script
Parameters:
optSelf - If non-null, and if this script has a match clause, and if this script doesn't have a directly matching method, then delegate the respondsTo question to optSelf via the match clause to see if it responds.

Since 'null' is normally a valid value for a 'self', this use of 'null' depends on our knowledge that 'null''s script does not have its own match clause.

verb -
arity -
Returns:

setTypeName

void setTypeName(String typeName)

toString

public String toString()
Suppressed:

Overrides:
toString in class ParseNode
Returns:
a string representation of the object.

traceOn

public void traceOn(TextWriter out)
             throws IOException
Enabled:

Specified by:
traceOn in interface EStackItem
IOException

subPrintOn

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

Specified by:
subPrintOn in class ParseNode
IOException


comments?