edu.vub.at.objects.natives
Class NATMethod

java.lang.Object
  extended byedu.vub.at.objects.natives.NATNil
      extended byedu.vub.at.objects.natives.NATByCopy
          extended byedu.vub.at.objects.natives.NATMethod
All Implemented Interfaces:
ATAbstractGrammar, ATConversions, ATExpression, ATMethod, ATNil, ATObject, ATStatement, java.io.Serializable

public class NATMethod
extends NATByCopy
implements ATMethod

NATMethod implements methods as named functions which are in fact simply containers for a name, a table of arguments and a body.

Author:
smostinc, tvcutsem
See Also:
Serialized Form

Field Summary
private  ATBegin body_
           
private  ATSymbol name_
           
private  PartialBinder parameterBindingFunction_
           
private  ATTable parameters_
           
 
Fields inherited from class edu.vub.at.objects.natives.NATNil
_INSTANCE_
 
Constructor Summary
NATMethod(ATSymbol name, ATTable parameters, ATBegin body)
           
 
Method Summary
 ATObject base_apply(ATTable arguments, ATContext ctx)
          To apply a function, first bind its parameters to the evaluated arguments within a new call frame.
 ATObject base_applyInScope(ATTable arguments, ATContext ctx)
          Applies the method in the context given, without first inserting a call frame to bind parameters.
 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.NATByCopy
meta_pass, meta_resolve
 
Methods inherited from class edu.vub.at.objects.natives.NATNil
asAmbientTalkObject, asJavaClassUnderSymbiosis, asJavaObjectUnderSymbiosis, asNativeBoolean, asNativeException, asNativeFarReference, asNativeFraction, asNativeNumber, asNativeNumeric, asNativeTable, asNativeText, base__opeql__opeql_, base_asActorMirror, base_asAsyncMessage, base_asBegin, base_asBoolean, base_asClosure, base_asDefinition, base_asExpression, base_asFarReference, base_asField, base_asHandler, base_asMessage, base_asMessageCreation, base_asMirror, base_asNumber, base_asSplice, base_asStatement, base_asStripe, base_asSymbol, base_asTable, base_asUnquoteSplice, base_asVariableAssignment, base_init, base_isBoolean, base_isCallFrame, base_isClosure, base_isFarReference, base_isMessageCreation, base_isMirror, base_isSplice, base_isStripe, base_isSymbol, base_isTable, base_isUnquoteSplice, base_isVariableAssignment, base_new, createChild, equals, isAmbientTalkObject, isJavaObjectUnderSymbiosis, isNativeBoolean, isNativeField, isNativeText, 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_quote, meta_receive, meta_respondsTo, meta_select, meta_send, meta_share, readResolve, toString, writeReplace
 
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
 
Methods inherited from interface edu.vub.at.objects.coercion.ATConversions
asAmbientTalkObject, asJavaClassUnderSymbiosis, asJavaObjectUnderSymbiosis, asNativeBoolean, asNativeException, asNativeFarReference, asNativeFraction, asNativeNumber, asNativeNumeric, asNativeTable, asNativeText, base_asActorMirror, base_asAsyncMessage, base_asBegin, base_asBoolean, base_asClosure, base_asDefinition, base_asExpression, base_asFarReference, base_asField, base_asHandler, base_asMessage, base_asMessageCreation, base_asMirror, base_asNumber, base_asSplice, base_asStatement, base_asStripe, base_asSymbol, base_asTable, base_asUnquoteSplice, base_asVariableAssignment, base_isBoolean, base_isCallFrame, base_isClosure, base_isFarReference, base_isMessageCreation, base_isMirror, base_isSplice, base_isStripe, base_isSymbol, base_isTable, base_isUnquoteSplice, base_isVariableAssignment, isAmbientTalkObject, isJavaObjectUnderSymbiosis, isNativeBoolean, isNativeField, isNativeText
 

Field Detail

name_

private final ATSymbol name_

parameters_

private final ATTable parameters_

body_

private final ATBegin body_

parameterBindingFunction_

private final PartialBinder parameterBindingFunction_
Constructor Detail

NATMethod

public NATMethod(ATSymbol name,
                 ATTable parameters,
                 ATBegin body)
          throws InterpreterException
Method Detail

base_getName

public ATSymbol base_getName()
Description copied from interface: ATMethod
Structural access to the name of the method. Note that all methods (defined using def name( ...args... ) { ... } of def foo: arg bar: arg { ... }) retain the name with which they were first bound. Literal blocks which may be created outside of a definition are implicitly named 'lambda'.

Specified by:
base_getName in interface ATMethod

base_getParameters

public ATTable base_getParameters()
Description copied from interface: ATMethod
Structural access to the parameter list of the method, which is normally a table of symbols.

Specified by:
base_getParameters in interface ATMethod

base_getBodyExpression

public ATBegin base_getBodyExpression()
Description copied from interface: ATMethod
Structural access to the body of the method.

Specified by:
base_getBodyExpression in interface ATMethod

base_apply

public ATObject base_apply(ATTable arguments,
                           ATContext ctx)
                    throws InterpreterException
To apply a function, first bind its parameters to the evaluated arguments within a new call frame. This call frame is lexically nested within the current lexical scope. This method is invoked via the following paths: - either by directly 'calling a function', in which case this method is applied via NATClosure.base_apply. The closure ensures that the context used is the lexical scope, not the dynamic scope of invocation. - or by 'invoking a method' through an object, in which case this method is applied via NATObject.meta_invoke. The enclosing object ensures that the context is properly initialized with the implementor, the dynamic receiver and the implementor's parent.

Specified by:
base_apply in interface ATMethod
Parameters:
arguments - the evaluated actual arguments
ctx - the context in which to evaluate the method body, where a call frame will be inserted first
Returns:
the value of evaluating the function body
Throws:
InterpreterException

base_applyInScope

public ATObject base_applyInScope(ATTable arguments,
                                  ATContext ctx)
                           throws InterpreterException
Applies the method in the context given, without first inserting a call frame to bind parameters. Arguments are bound directly in the given lexical scope. This method is often invoked via its enclosing closure when used to implement various language constructs such as object:, mirror:, extend:with: etc.

Specified by:
base_applyInScope in interface ATMethod
Parameters:
arguments - the evaluated actual arguments
ctx - the context in which to evaluate the method body, to be used as-is
Returns:
the value of evaluating the function body
Throws:
InterpreterException

meta_print

public NATText meta_print()
                   throws InterpreterException
Description copied from interface: ATObject
Prints out the object in a human-readable way.

Specified by:
meta_print in interface ATObject
Overrides:
meta_print in class NATNil
Throws:
InterpreterException

base_asMethod

public ATMethod base_asMethod()
                       throws XTypeMismatch
Specified by:
base_asMethod in interface ATConversions
Overrides:
base_asMethod in class NATNil
Throws:
XTypeMismatch

base_isMethod

public boolean base_isMethod()
Specified by:
base_isMethod in interface ATConversions
Overrides:
base_isMethod in class NATNil

meta_getStripes

public ATTable meta_getStripes()
                        throws InterpreterException
Description copied from interface: ATObject
Returns the stripes of this object. Note that only the stripes that were attached directly to this object are returned, not all of the parent's stripes as well.

Specified by:
meta_getStripes in interface ATObject
Overrides:
meta_getStripes in class NATNil
Throws:
InterpreterException