edu.vub.at.objects.symbiosis
Class JavaClosure

java.lang.Object
  extended byedu.vub.at.objects.natives.NATNil
      extended byedu.vub.at.objects.natives.NATByRef
          extended byedu.vub.at.objects.natives.NATClosure
              extended byedu.vub.at.objects.symbiosis.JavaClosure
All Implemented Interfaces:
ATAbstractGrammar, ATClosure, ATConversions, ATExpression, ATJavaClosure, ATNil, ATObject, ATStatement, java.io.Serializable

public final class JavaClosure
extends NATClosure
implements ATJavaClosure

A JavaClosure pairs a JavaMethod (a bundle of native overloaded java.lang.reflect.Method objects) together with a Java object receiver. It also provides the possibility of casting the JavaMethod instances to fit a narrower static type signature.

Author:
tvcutsem
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class edu.vub.at.objects.natives.NATClosure
 
Field Summary
private  ATObject scope_
           
 
Fields inherited from class edu.vub.at.objects.natives.NATClosure
context_, method_
 
Fields inherited from class edu.vub.at.objects.natives.NATNil
_INSTANCE_
 
Constructor Summary
JavaClosure(ATObject scope, JavaMethod meth)
           
 
Method Summary
 ATClosure base_cast(ATObject[] types)
          For each Method in the wrapped JavaMethod's choices_, check whether it is compatible with the given types.
 ATContext base_getContext()
          Overridden to allow for lazy instantiation of the context.
private static boolean matches(java.lang.Class[] formals, java.lang.Class[] actuals)
          Compares two Class arrays and returns true iff both arrays have equal size and all members are the same.
 NATText meta_print()
          Prints out the object in a human-readable way.
 
Methods inherited from class edu.vub.at.objects.natives.NATClosure
base_apply, base_applyInScope, base_asClosure, base_escape, base_getMethod, base_isClosure, base_whileTrue_, meta_getStripes
 
Methods inherited from class edu.vub.at.objects.natives.NATByRef
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_asDefinition, base_asExpression, base_asFarReference, base_asField, base_asHandler, base_asMessage, base_asMessageCreation, base_asMethod, 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_isFarReference, base_isMessageCreation, base_isMethod, 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.ATClosure
base_apply, base_applyInScope, base_escape, base_getMethod, base_whileTrue_
 
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_getStripes, 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_asMethod, 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_isMethod, base_isMirror, base_isSplice, base_isStripe, base_isSymbol, base_isTable, base_isUnquoteSplice, base_isVariableAssignment, isAmbientTalkObject, isJavaObjectUnderSymbiosis, isNativeBoolean, isNativeField, isNativeText
 

Field Detail

scope_

private final ATObject scope_
Constructor Detail

JavaClosure

public JavaClosure(ATObject scope,
                   JavaMethod meth)
Method Detail

base_getContext

public ATContext base_getContext()
                          throws InterpreterException
Overridden to allow for lazy instantiation of the context. A 'default' context is lazily constructed and returned.

Specified by:
base_getContext in interface ATClosure
Overrides:
base_getContext in class NATClosure
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 NATClosure
Throws:
InterpreterException

base_cast

public ATClosure base_cast(ATObject[] types)
                    throws InterpreterException
For each Method in the wrapped JavaMethod's choices_, check whether it is compatible with the given types. If so, add it to the choices_ array of the new JavaMethod.

Specified by:
base_cast in interface ATJavaClosure
Parameters:
types - an array of JavaClass objects
Returns:
a new JavaClosure where the wrapped overloaded methods correspond to the given types
Throws:
InterpreterException

matches

private static final boolean matches(java.lang.Class[] formals,
                                     java.lang.Class[] actuals)
Compares two Class arrays and returns true iff both arrays have equal size and all members are the same.