|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.erights.e.elib.prim.VTable
Untamed: E's mechanism for method dispatch
Field Summary | |
private String |
myFQName
The fully qualified behavior name, sort of. |
private FlexMap |
myMethods
Maps from intered verb strings to either |
private Script |
myOptOtherwise
The script to execute if none of the methods match |
Constructor Summary | |
VTable(String fqName)
Enabled: @param fqName The fully qualified behavior name. |
|
VTable(String fqName,
Script optOtherwise)
Enabled: @param fqName The fully qualified behavior name. |
Method Summary | |
boolean |
addMethod(MethodNode newMeth,
SafeJ safeJ)
Enabled: Throw the method into the pile, if appropriate, and in an order independent way. |
boolean |
addMethod(String verb,
MethodNode newMeth,
SafeJ safeJ)
Enabled: Throw the method into the pile, if appropriate, and in an order independent way. |
void |
addMethods(ConstMap methods,
SafeJ safeJ)
Enabled: 'methods' must be a map from mverbs (mangled verbs) to MethodNodes, as would be returned by 'methods()'. |
Object |
execute(Object self,
String aVerb,
Object[] args)
Enabled: |
String |
getFQName()
Enabled: Fully qualified behavior name. |
Script |
getOptOtherwise()
Enabled: |
ConstMap |
methods()
Enabled: Returns a table mapping mverbs (mangled verbs) to MethodNodes. |
MethodNode |
optMethod(String mverb)
Enabled: Like optMethods/2, but uses an mverb (mangled verb) rather than a separate verb and arity. |
MethodNode |
optMethod(String verb,
int arity)
Enabled: If there's a method in the vTable for this verb and arity, return it. |
void |
protocol(Object optSelf,
FlexList mTypes)
Enabled: |
private MethodNode |
resolveConflict(MethodNode a,
MethodNode b)
XXX cheesy indeed, as it doesn't distinguish inheritance vs override vs overload |
boolean |
respondsTo(Object optSelf,
String verb,
int arity)
Enabled: |
void |
setOptOtherwise(Script optOtherwise)
Enabled: Overwrites the property. |
Script |
shorten(Object optSelf,
String aVerb,
Object[] args)
Enabled: Returns a matching method or matcher, or throws an exception. |
String |
toString()
Suppressed: |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private final String myFQName
private final FlexMap myMethods
a MethodNode, for verbs that are only defined for one arity, or
An array of MethodNodes, with a MethodNode for every occupied arity and a null for the rest.
private Script myOptOtherwise
Constructor Detail |
public VTable(String fqName)
public VTable(String fqName, Script optOtherwise)
optOtherwise
- the script to call if no matching method is found.Method Detail |
public void addMethods(ConstMap methods, SafeJ safeJ)
'safeJ' indicates which typedVerbs to include.
public boolean addMethod(String verb, MethodNode newMeth, SafeJ safeJ) throws AlreadyDefinedException
resolveConflict(org.erights.e.elib.base.MethodNode, org.erights.e.elib.base.MethodNode)
.
AlreadyDefinedException
public boolean addMethod(MethodNode newMeth, SafeJ safeJ) throws AlreadyDefinedException
AlreadyDefinedException
public Script shorten(Object optSelf, String aVerb, Object[] args)
shorten
in interface Script
optSelf
- If present, then a script could shorten using
instance-specific data.aVerb
- Must be internedargs
- Typically, only its arity is used. But OverloaderNode uses
the types of the arguments to select among Java overloads.
public Object execute(Object self, String aVerb, Object[] args)
execute
in interface Script
public ConstMap methods()
A mangled verb is 'verb + "/" + arity'
public MethodNode optMethod(String mverb)
public MethodNode optMethod(String verb, int arity)
public String getFQName()
public Script getOptOtherwise()
public void setOptOtherwise(Script optOtherwise)
As with the addMethod methods, this should only be used when initializing a vTable.
optOtherwise
- private MethodNode resolveConflict(MethodNode a, MethodNode b)
public void protocol(Object optSelf, FlexList mTypes)
protocol
in interface Script
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.public boolean respondsTo(Object optSelf, String verb, int arity)
respondsTo
in interface Script
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
-
public String toString()
toString
in class Object
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |