|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.vub.at.objects.natives.NATNil
edu.vub.at.objects.natives.NATByRef
edu.vub.at.objects.natives.NATClosureMethod
A 'closure method' is literally a function that sits in between of a full closure and a method. It is a method that captures only its lexical scope of definition, but not the value of 'self' and 'super' which are active at that time. When invoked, the method is evaluated in its lexical scope, but with the values of 'self' and 'super' equal to those given to it at method invocation time. Closure methods are used to implement 'externally added' methods to objects. In such cases, the external methods can only access their own surrounding lexical scope (and not that of the actual object to which they are added), but their values for 'self' and 'super' will act as if the method was actually defined within the object itself. See the description of the ATDefExternalMethod interface for more information.
Field Summary | |
private ATObject |
lexicalScope_
|
private ATMethod |
method_
|
Fields inherited from class edu.vub.at.objects.natives.NATNil |
_INSTANCE_ |
Constructor Summary | |
NATClosureMethod(ATObject scope,
ATMethod method)
|
Method Summary | |
ATObject |
base_apply(ATTable arguments,
ATContext ctx)
A closure method application acts exactly like a regular direct method application, except that the given lexical scope is disregarded and replaced by the lexical scope encapsulated by the closure method. |
ATObject |
base_applyInScope(ATTable arguments,
ATContext ctx)
Applies the method to the given arguments in the given context. |
ATMethod |
base_asMethod()
|
ATBegin |
base_getBodyExpression()
Structural access to the body of the method. |
ATSymbol |
base_getName()
Structural access to the name of the method. |
ATTable |
base_getParameters()
Structural access to the parameter list of the method, which is normally a table of symbols. |
boolean |
base_isMethod()
|
ATTable |
meta_getStripes()
Returns the stripes of this object. |
NATText |
meta_print()
Prints out the object in a human-readable way. |
Methods inherited from class edu.vub.at.objects.natives.NATByRef |
meta_pass, meta_resolve |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface edu.vub.at.objects.ATObject |
base__opeql__opeql_, base_init, base_new, meta_addField, meta_addMethod, meta_assignField, meta_assignVariable, meta_clone, meta_defineField, meta_doesNotUnderstand, meta_eval, meta_extend, meta_getDynamicParent, meta_getLexicalParent, meta_grabField, meta_grabMethod, meta_invoke, meta_isCloneOf, meta_isRelatedTo, meta_isStripedWith, meta_listFields, meta_listMethods, meta_lookup, meta_newInstance, meta_pass, meta_quote, meta_receive, meta_resolve, meta_respondsTo, meta_select, meta_send, meta_share |
Field Detail |
private final ATObject lexicalScope_
private final ATMethod method_
Constructor Detail |
public NATClosureMethod(ATObject scope, ATMethod method) throws InterpreterException
Method Detail |
public ATObject base_apply(ATTable arguments, ATContext ctx) throws InterpreterException
base_apply
in interface ATMethod
arguments
- the evaluated actual argumentsctx
- the context whose 'self' binding will be used during the execution of the method.
The lexical scope, however, will be replaced by the closure method's own lexical scope. A call frame will
be inserted into this lexical scope before executing the method body.
To ensure that 'super' points to the parent of the actual 'self' and not the parent of the object
performing the external method definition, a 'super' field is added to the call frame shadowing
the defining object's 'super' field.
InterpreterException
public ATObject base_applyInScope(ATTable arguments, ATContext ctx) throws InterpreterException
ATMethod
base_applyInScope
in interface ATMethod
arguments
- the actual arguments, already eagerly evaluatedctx
- the context in which to evaluate the method body, to be used without inserting a call frame
InterpreterException
public ATBegin base_getBodyExpression() throws InterpreterException
ATMethod
base_getBodyExpression
in interface ATMethod
InterpreterException
public ATSymbol base_getName() throws InterpreterException
ATMethod
base_getName
in interface ATMethod
InterpreterException
public ATTable base_getParameters() throws InterpreterException
ATMethod
base_getParameters
in interface ATMethod
InterpreterException
public NATText meta_print() throws InterpreterException
ATObject
meta_print
in interface ATObject
meta_print
in class NATNil
InterpreterException
public ATMethod base_asMethod() throws XTypeMismatch
base_asMethod
in interface ATConversions
base_asMethod
in class NATNil
XTypeMismatch
public boolean base_isMethod()
base_isMethod
in interface ATConversions
base_isMethod
in class NATNil
public ATTable meta_getStripes() throws InterpreterException
ATObject
meta_getStripes
in interface ATObject
meta_getStripes
in class NATNil
InterpreterException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |