|
|||||||||||
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.NATClosure
A NATClosure instance represents a first-class AmbientTalk closure. A closure is modelled as a pair (method, context), where the method contains the pure function (function name, arguments and body). The single most important operation to be performed on a closure is applying it. This will give rise to the application of its underlying method within the context wrapped by the closure.
Nested Class Summary | |
private static class |
NATClosure.QuitClosureFrame
|
Field Summary | |
protected ATContext |
context_
|
protected ATMethod |
method_
|
Fields inherited from class edu.vub.at.objects.natives.NATNil |
_INSTANCE_ |
Constructor Summary | |
NATClosure(ATMethod method,
ATContext context)
|
|
NATClosure(ATMethod method,
ATObject implementor,
ATObject receiver)
This constructor creates a closure with a bound dynamic receiver, and it is called after the succesful lookup of a receiverful message. |
Method Summary | |
ATObject |
base_apply(ATTable arguments)
To apply a closure, apply its underlying method with the context of the closure, rather than the runtime context of the invoker. |
ATObject |
base_applyInScope(ATTable args,
ATObject scope)
To apply a closure in a given scope, apply its underlying method with a new context constructed from the scope object. |
ATClosure |
base_asClosure()
|
ATObject |
base_escape()
The following is a pseudo-code implementation of escape. |
ATContext |
base_getContext()
Structural access to the scope of the closure. |
ATMethod |
base_getMethod()
Structural access to the encapsulated method. |
boolean |
base_isClosure()
|
ATObject |
base_whileTrue_(ATClosure body)
receiver is a zero-argument block closure returning a boolean |
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 |
protected ATMethod method_
protected ATContext context_
Constructor Detail |
public NATClosure(ATMethod method, ATObject implementor, ATObject receiver) throws InterpreterException
method
- the method being wrapped into a closure.implementor
- the object in which the definition is nested.receiver
- the object where the lookup was initiated.public NATClosure(ATMethod method, ATContext context)
Method Detail |
public ATObject base_apply(ATTable arguments) throws InterpreterException
base_apply
in interface ATClosure
arguments
- the already evaluated arguments, wrapped in a table
InterpreterException
public ATObject base_applyInScope(ATTable args, ATObject scope) throws InterpreterException
base_applyInScope
in interface ATClosure
args
- the already evaluated arguments, wrapped in a tablescope
- the object that will act as self and as lexically enclosing scope.
InterpreterException
public ATObject base_whileTrue_(ATClosure body) throws InterpreterException
base_whileTrue_
in interface ATClosure
body
- a zero-argument block closure
def whileTrue: body {
self.apply().ifTrue: {
body();
self.whileTrue: body
}
}
InterpreterException
public ATObject base_escape() throws InterpreterException
base_escape
in interface ATClosure
InterpreterException
public ATContext base_getContext() throws InterpreterException
ATClosure
base_getContext
in interface ATClosure
InterpreterException
public ATMethod base_getMethod()
ATClosure
base_getMethod
in interface ATClosure
public boolean base_isClosure()
base_isClosure
in interface ATConversions
base_isClosure
in class NATNil
public ATClosure base_asClosure()
base_asClosure
in interface ATConversions
base_asClosure
in class NATNil
public NATText meta_print() throws InterpreterException
ATObject
meta_print
in interface ATObject
meta_print
in class NATNil
InterpreterException
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 |