edu.vub.at.objects.mirrors
Class Reflection

java.lang.Object
  extended byedu.vub.at.objects.mirrors.Reflection

public final class Reflection
extends java.lang.Object

Reflection is an auxiliary class meant to serve as a repository for methods related to 'up' and 'down' Java values properly into and out of the AmbientTalk base level. Keep the following mental picture in mind: ^ Java = implementation-level | to deify | Java AT objects = meta-level | to reify (= to up) | ------------------------------------------ | (= to down) (= to absorb) | AmbientTalk = base-level v (= to reflect) Although deification and reification are more accurate terms, we will use 'up' and 'down' because they are the clearest terminology, and clarity matters. In this class, the following conventions hold: - methods start with either 'up' or 'down', denoting whether they deify or reify something - arguments start with either 'j' or 'at', denoting whether they represent Java or AmbientTalk values With 'java values' is meant 'java objects representing mirrors'

Author:
tvc

Field Summary
static java.lang.String _BASE_PREFIX_
           
static java.lang.String _BGET_PREFIX_
           
static java.lang.String _BSET_PREFIX_
           
static java.lang.String _MAGET_PREFIX_
           
static java.lang.String _MAGIC_PREFIX_
           
static java.lang.String _MASET_PREFIX_
           
static java.lang.String _META_PREFIX_
           
static java.lang.String _MGET_PREFIX_
           
static java.lang.String _MSET_PREFIX_
           
private static java.util.regex.Pattern oprCode
           
private static java.util.regex.Pattern symbol
           
 
Constructor Summary
Reflection()
           
 
Method Summary
static ATSymbol downBaseFieldAccessSelector(java.lang.String jSelector)
          Transforms a Java selector prefixed with base_get into an equivalent AmbientTalk selector.
static ATSymbol downBaseFieldMutationSelector(java.lang.String jSelector)
          Transforms a Java selector prefixed with base_set into an equivalent AmbientTalk selector.
static ATField downBaseLevelField(ATObject natObject, ATSymbol atSelector)
           
static ATField[] downBaseLevelFields(ATObject atObj)
          Returns, for a given AmbientTalk object atObj, an array of NativeField objects corresponding to all non-static methods of that object's Java class, where each method's name is prefixed with 'base_get'
static ATMethod downBaseLevelMethod(ATObject natObject, ATSymbol atSelector)
           
static ATMethod[] downBaseLevelMethods(ATObject atObj)
          Returns, for a given AmbientTalk object atObj, an array of NativeMethod objects corresponding to all non-static methods of that object's class, where each method's name: - is prefixed with 'base_' - is not prefixed with 'base_get' - is not prefixed with 'base_set'
static ATSymbol downBaseLevelSelector(java.lang.String jSelector)
          Transforms a Java selector prefixed with base_ into an AmbientTalk selector without the prefix.
static ATField downField(ATObject natObject, ATSymbol atSelector, java.lang.String getPrefix, java.lang.String setPrefix)
          Constructs an AmbientTalk ATField from a pair of accessor/mutator methods of a Java object.
static ATSymbol downFieldName(java.lang.String jName)
          A field name "Field" passed from the Java to the AmbientTalk level undergoes the following transformations: - the same transformations applicable to downSelector
static ATObject downInvocation(ATObject atRcvr, java.lang.reflect.Method jMethod, ATObject[] jArgs)
          downInvocation takes an implicit Java invocation and turns it into an explicit AmbientTalk invocation process.
static ATSymbol downMetaFieldAccessSelector(java.lang.String jSelector)
          Transforms a Java selector prefixed with meta_get into an equivalent AmbientTalk selector Example: downMetaFieldAccessSelector("meta_getReceiver") => ATSymbol("receiver")
static ATSymbol downMetaFieldMutationSelector(java.lang.String jSelector)
          Transforms a Java selector prefixed with meta_set into an equivalent AmbientTalk selector.
static ATField downMetaLevelField(ATObject natObject, ATSymbol atSelector)
           
static ATField[] downMetaLevelFields(ATObject atObj)
          Returns, for a given AmbientTalk object atObj, an array of NativeField objects corresponding to all non-static methods of that object's Java class, where each method's name is prefixed with 'meta_get'
static ATMethod downMetaLevelMethod(ATObject natObject, ATSymbol atSelector)
           
static ATMethod[] downMetaLevelMethods(ATObject natObj)
          Returns, for a given AmbientTalk object natObj, an array of NativeMethod objects corresponding to all non-static methods of that object's class, where each method's name: - is prefixed with 'meta_' - is not prefixed with 'meta_get' - is not prefixed with 'meta_set'
static ATSymbol downMetaLevelSelector(java.lang.String jSelector)
          Transforms a Java selector prefixed with meta_ into an AmbientTalk selector without the prefix.
static ATMethod downMethod(ATObject natObject, java.lang.String jSelector, ATSymbol origName)
          Constructs an AmbientTalk ATMethod from a Java method.
static ATObject downObject(ATObject metaObject)
          Pass an AmbientTalk meta-level object into the base-level
static ATSymbol downSelector(java.lang.String jSelector)
          A selector passed from the Java to the AmbientTalk level undergoes the following transformations: - any pattern of the form _op{code}_ is transformed to a symbol corresponding to the operator code Operator codes are: pls -> + mns -> - tms -> * div -> / bsl -> \ and -> & not -> !
private static java.lang.String javaToAmbientTalkSelector(java.lang.String jSelector)
           
private static java.lang.String oprCode2Symbol(java.lang.String code)
           
private static java.lang.String stripPrefix(java.lang.String input, java.lang.String prefix)
           
private static java.lang.String symbol2oprCode(java.lang.String symbol)
           
static java.lang.String upBaseFieldAccessSelector(ATSymbol atName)
          Transforms an AmbientTalk selector into an equivalent Java selector uppercased and prefixed with "base_get".
static java.lang.String upBaseFieldMutationSelector(ATSymbol atName)
          Transforms an AmbientTalk selector into an equivalent Java selector uppercased and prefixed with "base_set".
static java.lang.String upBaseLevelSelector(ATSymbol atSelector)
          Transforms an AmbientTalk selector into a Java-level selector prefixed with base_.
static ATObject upExceptionCreation(InterpreterException jRcvr, ATTable atInitargs)
           
static ATObject upFieldAssignment(ATObject atOrigRcvr, java.lang.String jSelector, ATObject value)
          upFieldAssignment takes an explicit AmbientTalk field assignment and turns it into an implicitly performed Java field assignment by invoking a mutator method, if such a method exists.
static java.lang.String upFieldName(ATSymbol atName)
          A field name "field" passed from the AmbientTalk to the Java level undergoes the following transformations: - the same transformations applicable to upSelector
static ATObject upFieldSelection(ATObject atOrigRcvr, java.lang.String jSelector)
          upFieldSelection takes an explicit AmbientTalk field selection and turns it into an implicitly performed Java selection by invoking a getter method, if such a getter method exists.
static ATObject upInstanceCreation(ATObject jRcvr, ATTable atInitargs)
          upInstanceCreation takes an explicit AmbientTalk 'new' invocation and turns it into an implicit Java instance creation by calling a constructor.
static ATObject upInvocation(ATObject atOrigRcvr, java.lang.String jSelector, ATTable atArgs)
          upInvocation takes an explicit AmbientTalk method invocation and turns it into an implicitly performed Java invocation.
static java.lang.String upMagicFieldAccessSelector(ATSymbol atName)
          Transforms an AmbientTalk selector into an equivalent Java selector uppercased and prefixed with "meta_get".
static java.lang.String upMagicFieldMutationSelector(ATSymbol atName)
          Transforms an AmbientTalk selector into an equivalent Java selector uppercased and prefixed with "meta_set".
static java.lang.String upMagicLevelSelector(ATSymbol atSelector)
          Transforms an AmbientTalk selector into a Java-level selector prefixed with magic_.
static java.lang.String upMetaFieldAccessSelector(ATSymbol atName)
          Transforms an AmbientTalk selector into an equivalent Java selector uppercased and prefixed with "meta_get".
static java.lang.String upMetaFieldMutationSelector(ATSymbol atName)
          Transforms an AmbientTalk selector into an equivalent Java selector uppercased and prefixed with "meta_set".
static java.lang.String upMetaLevelSelector(ATSymbol atSelector)
          Transforms an AmbientTalk selector into a Java-level selector prefixed with meta_.
static NativeClosure upMethodSelection(ATObject atOrigRcvr, java.lang.String jSelector, ATSymbol origSelector)
          upMethodSelection takes an explicit AmbientTalk field selection and checks whether a Java method exists that matches the selector.
static ATObject upObject(ATObject baseObject)
          Pass an AmbientTalk base-level object to the meta-level
static boolean upRespondsTo(ATObject jRcvr, java.lang.String jSelector)
          upRespondsTo transforms an explicit AmbientTalk respondsTo meta-level request into an implicit check whether the given jRcvr java object has a method corresponding to the given selector, prefixed with base_
static java.lang.String upSelector(ATSymbol atSelector)
          A selector passed from the AmbientTalk to the Java level undergoes the following transformations: - any colons (:) are replaced by underscores (_) - any operator symbol is replaced by _op{code}_ where code is generated as follows: Operator codes are: + -> pls - -> mns * -> tms / -> div \ -> bsl & -> and !
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_BASE_PREFIX_

public static final java.lang.String _BASE_PREFIX_
See Also:
Constant Field Values

_BGET_PREFIX_

public static final java.lang.String _BGET_PREFIX_
See Also:
Constant Field Values

_BSET_PREFIX_

public static final java.lang.String _BSET_PREFIX_
See Also:
Constant Field Values

_META_PREFIX_

public static final java.lang.String _META_PREFIX_
See Also:
Constant Field Values

_MGET_PREFIX_

public static final java.lang.String _MGET_PREFIX_
See Also:
Constant Field Values

_MSET_PREFIX_

public static final java.lang.String _MSET_PREFIX_
See Also:
Constant Field Values

_MAGIC_PREFIX_

public static final java.lang.String _MAGIC_PREFIX_
See Also:
Constant Field Values

_MAGET_PREFIX_

public static final java.lang.String _MAGET_PREFIX_
See Also:
Constant Field Values

_MASET_PREFIX_

public static final java.lang.String _MASET_PREFIX_
See Also:
Constant Field Values

oprCode

private static final java.util.regex.Pattern oprCode

symbol

private static final java.util.regex.Pattern symbol
Constructor Detail

Reflection

public Reflection()
Method Detail

downSelector

public static final ATSymbol downSelector(java.lang.String jSelector)
A selector passed from the Java to the AmbientTalk level undergoes the following transformations: - any pattern of the form _op{code}_ is transformed to a symbol corresponding to the operator code Operator codes are: pls -> + mns -> - tms -> * div -> / bsl -> \ and -> & not -> ! gtx -> > ltx -> < eql -> = til -> ~ que -> ? rem -> % - any underscores (_) are replaced by colons (:)


downBaseLevelSelector

public static final ATSymbol downBaseLevelSelector(java.lang.String jSelector)
                                            throws InterpreterException
Transforms a Java selector prefixed with base_ into an AmbientTalk selector without the prefix.

Throws:
InterpreterException

downMetaLevelSelector

public static final ATSymbol downMetaLevelSelector(java.lang.String jSelector)
                                            throws InterpreterException
Transforms a Java selector prefixed with meta_ into an AmbientTalk selector without the prefix.

Throws:
InterpreterException

downBaseFieldAccessSelector

public static final ATSymbol downBaseFieldAccessSelector(java.lang.String jSelector)
                                                  throws InterpreterException
Transforms a Java selector prefixed with base_get into an equivalent AmbientTalk selector. Example: downBaseFieldAccessSelector("base_getReceiver") => ATSymbol("receiver")

Throws:
InterpreterException

downBaseFieldMutationSelector

public static final ATSymbol downBaseFieldMutationSelector(java.lang.String jSelector)
                                                    throws InterpreterException
Transforms a Java selector prefixed with base_set into an equivalent AmbientTalk selector. Example: downBaseFieldMutationSelector("base_setReceiver") => ATSymbol("receiver")

Throws:
InterpreterException

downMetaFieldAccessSelector

public static final ATSymbol downMetaFieldAccessSelector(java.lang.String jSelector)
                                                  throws InterpreterException
Transforms a Java selector prefixed with meta_get into an equivalent AmbientTalk selector Example: downMetaFieldAccessSelector("meta_getReceiver") => ATSymbol("receiver")

Throws:
InterpreterException

downMetaFieldMutationSelector

public static final ATSymbol downMetaFieldMutationSelector(java.lang.String jSelector)
                                                    throws InterpreterException
Transforms a Java selector prefixed with meta_set into an equivalent AmbientTalk selector. Example: downMetaFieldMutationSelector("meta_setReceiver") => ATSymbol("receiver")

Throws:
InterpreterException

downFieldName

public static final ATSymbol downFieldName(java.lang.String jName)
                                    throws InterpreterException
A field name "Field" passed from the Java to the AmbientTalk level undergoes the following transformations: - the same transformations applicable to downSelector

Throws:
InterpreterException
See Also:
- the first letter is transformed into lower case (as it was uppercased for Java conventions)

upSelector

public static final java.lang.String upSelector(ATSymbol atSelector)
                                         throws InterpreterException
A selector passed from the AmbientTalk to the Java level undergoes the following transformations: - any colons (:) are replaced by underscores (_) - any operator symbol is replaced by _op{code}_ where code is generated as follows: Operator codes are: + -> pls - -> mns * -> tms / -> div \ -> bsl & -> and ! -> not > -> gtx < -> ltx = -> eql ~ -> til ? -> que % -> rem

Throws:
InterpreterException

upBaseLevelSelector

public static final java.lang.String upBaseLevelSelector(ATSymbol atSelector)
                                                  throws InterpreterException
Transforms an AmbientTalk selector into a Java-level selector prefixed with base_.

Throws:
InterpreterException

upMetaLevelSelector

public static final java.lang.String upMetaLevelSelector(ATSymbol atSelector)
                                                  throws InterpreterException
Transforms an AmbientTalk selector into a Java-level selector prefixed with meta_.

Throws:
InterpreterException

upMagicLevelSelector

public static final java.lang.String upMagicLevelSelector(ATSymbol atSelector)
                                                   throws InterpreterException
Transforms an AmbientTalk selector into a Java-level selector prefixed with magic_.

Throws:
InterpreterException

upFieldName

public static final java.lang.String upFieldName(ATSymbol atName)
                                          throws InterpreterException
A field name "field" passed from the AmbientTalk to the Java level undergoes the following transformations: - the same transformations applicable to upSelector

Throws:
InterpreterException
See Also:
- the first letter is transformed into upper case such that it can be accessed using respectively "getField" | "setField" methods at the Java level.

upBaseFieldAccessSelector

public static final java.lang.String upBaseFieldAccessSelector(ATSymbol atName)
                                                        throws InterpreterException
Transforms an AmbientTalk selector into an equivalent Java selector uppercased and prefixed with "base_get". Example: upBaseFieldAccessSelector(ATSymbol('receiver')) => "base_getReceiver"

Throws:
InterpreterException

upBaseFieldMutationSelector

public static final java.lang.String upBaseFieldMutationSelector(ATSymbol atName)
                                                          throws InterpreterException
Transforms an AmbientTalk selector into an equivalent Java selector uppercased and prefixed with "base_set". Example: upBaseFieldMutationSelector(ATSymbol('receiver')) => "base_setReceiver"

Throws:
InterpreterException

upMetaFieldAccessSelector

public static final java.lang.String upMetaFieldAccessSelector(ATSymbol atName)
                                                        throws InterpreterException
Transforms an AmbientTalk selector into an equivalent Java selector uppercased and prefixed with "meta_get". Example: upMetaFieldAccessSelector(ATSymbol('receiver')) => "meta_getReceiver"

Throws:
InterpreterException

upMetaFieldMutationSelector

public static final java.lang.String upMetaFieldMutationSelector(ATSymbol atName)
                                                          throws InterpreterException
Transforms an AmbientTalk selector into an equivalent Java selector uppercased and prefixed with "meta_set". Example: upMetaFieldMutationSelector(ATSymbol('receiver')) => "meta_setReceiver"

Throws:
InterpreterException

upMagicFieldAccessSelector

public static final java.lang.String upMagicFieldAccessSelector(ATSymbol atName)
                                                         throws InterpreterException
Transforms an AmbientTalk selector into an equivalent Java selector uppercased and prefixed with "meta_get". Example: upMetaFieldAccessSelector(ATSymbol('receiver')) => "meta_getReceiver"

Throws:
InterpreterException

upMagicFieldMutationSelector

public static final java.lang.String upMagicFieldMutationSelector(ATSymbol atName)
                                                           throws InterpreterException
Transforms an AmbientTalk selector into an equivalent Java selector uppercased and prefixed with "meta_set". Example: upMetaFieldMutationSelector(ATSymbol('receiver')) => "meta_setReceiver"

Throws:
InterpreterException

downField

public static final ATField downField(ATObject natObject,
                                      ATSymbol atSelector,
                                      java.lang.String getPrefix,
                                      java.lang.String setPrefix)
                               throws InterpreterException
Constructs an AmbientTalk ATField from a pair of accessor/mutator methods of a Java object. Given an object obj and a String sel, it is checked whether a) obj has a method named getPrefix + Sel, if so, a field can be created b) obj has a method named setPrefix + Sel, if so, the field is mutable, otherwise it is read-only The accessor method cannot take any arguments, the mutator method must have a unary arity.

Parameters:
natObject - the native AT object in whose class the accessor/mutator methods should be found
atSelector - the AmbientTalk name of the field
Returns:
a reified field, which may either be read-only or mutable depending on available methods Example: eval "(reflect: msg).getField('selector')" where msg is a NATMessage => downField(aNATMessage, "selector", "base_get", "base_set") => NATMessage must have a zero-arg method base_getSelector and optionally base_setSelector
Throws:
InterpreterException

downBaseLevelField

public static final ATField downBaseLevelField(ATObject natObject,
                                               ATSymbol atSelector)
                                        throws InterpreterException
Throws:
InterpreterException

downMetaLevelField

public static final ATField downMetaLevelField(ATObject natObject,
                                               ATSymbol atSelector)
                                        throws InterpreterException
Throws:
InterpreterException

downMethod

public static final ATMethod downMethod(ATObject natObject,
                                        java.lang.String jSelector,
                                        ATSymbol origName)
                                 throws InterpreterException
Constructs an AmbientTalk ATMethod from a Java method. Given an object obj and a String sel, it is checked whether obj has a method named sel. If so, the corresponding Java method is wrapped in a NativeMethod. If not, the downing fails.

Parameters:
natObject - the native AmbientTalk object in whose class the method should be found
jSelector - a selector which should yield a method in natObject
origName - the original AmbientTalk name of the method
Returns:
a reified method wrapping the Java method Example: eval "(reflect: tbl).getMethod('at')" where tbl is a NATTable => downMethod(aNATTable, "base_at") => NATTable must have a method named base_at Callers should use the more specialised 'downBaseLevelMethod' and 'downMetaLevelMethod' methods to specify the prefix of the method to be found
Throws:
InterpreterException

downBaseLevelMethod

public static final ATMethod downBaseLevelMethod(ATObject natObject,
                                                 ATSymbol atSelector)
                                          throws InterpreterException
Throws:
InterpreterException

downMetaLevelMethod

public static final ATMethod downMetaLevelMethod(ATObject natObject,
                                                 ATSymbol atSelector)
                                          throws InterpreterException
Throws:
InterpreterException

downInvocation

public static final ATObject downInvocation(ATObject atRcvr,
                                            java.lang.reflect.Method jMethod,
                                            ATObject[] jArgs)
                                     throws InterpreterException
downInvocation takes an implicit Java invocation and turns it into an explicit AmbientTalk invocation process. This happens when Java code sends normal Java messages to AmbientTalk objects (wrapped by a mirage).

Parameters:
atRcvr - the AmbientTalk object having received the Java method invocation
jArgs - the arguments to the Java method invocation (normally all args are ATObjects) jArgs may be null, indicating that there are no arguments
Returns:
the return value of the AmbientTalk method invoked via the java invocation. Example: in Java: "tbl.base_at(1)" where tbl is an ATTable coercer wrapping aNATObject => downInvocation(aNATObject, "base_at", ATObject[] { ATNumber(1) }) => aNATObject must implement a method named "at" Depending on the prefix of the invoked Java method selector, the following translation should occur: - obj.base_selector(args) => obj.meta_invoke(obj, selector, args) - obj.base_getSelector() => obj.meta_select(obj, selector) - obj.base_setSelector(x) => obj.meta_assignField(selector, x) - obj.meta_selector(args) => obj.meta_selector(args) - obj.meta_set|getSelector(args) => obj.meta_set|getSelector(args) - obj.selector(args) => either obj.selector(args) if selector is understood natively or obj.meta_invoke(obj, selector, args) otherwise
Throws:
InterpreterException

upInvocation

public static final ATObject upInvocation(ATObject atOrigRcvr,
                                          java.lang.String jSelector,
                                          ATTable atArgs)
                                   throws InterpreterException
upInvocation takes an explicit AmbientTalk method invocation and turns it into an implicitly performed Java invocation. Depending on whether the AmbientTalk invocation happens at the base-level or the meta-level (i.e. the receiver denotes a base-level object or a mirror), the jSelector parameter will have a different prefix.

Parameters:
atOrigRcvr - the original AmbientTalk object that received the invocation
jSelector - the selector of the message to be invoked, converted to a Java selector
atArgs - the arguments to the AmbientTalk method invocation
Returns:
the return value of the Java method invoked via the java invocation. Example: eval "tbl.at(1)" where tbl is a NATTable => upInvocation(aNATTable, "base_at", ATObject[] { ATNumber(1) }) => NATTable must have a method named base_at Example: eval "(reflect: tbl).invoke(tbl, "at", [1])" where tbl is a NATTable => upInvocation(aNATTable, "meta_invoke", ATObject[] { aNATTable, ATSymbol('at'), ATTable([ATNumber(1)]) }) => NATTable must have a method named meta_invoke
Throws:
InterpreterException

upRespondsTo

public static final boolean upRespondsTo(ATObject jRcvr,
                                         java.lang.String jSelector)
                                  throws InterpreterException
upRespondsTo transforms an explicit AmbientTalk respondsTo meta-level request into an implicit check whether the given jRcvr java object has a method corresponding to the given selector, prefixed with base_

Parameters:
jRcvr - the Java object being queried for a certain selector
jSelector - the selector of the message to be invoked, converted to a Java selector
Returns:
a boolean indicating whether the jRcvr implements a method corresponding to base_ + atSelector Example: eval "(reflect: [1,2,3]).respondsTo("at")" where the receiver of repondsTo is a NATTable => upRespondsTo(aNATTable, "at") => NATTable must have a method named base_at
Throws:
InterpreterException

upFieldSelection

public static final ATObject upFieldSelection(ATObject atOrigRcvr,
                                              java.lang.String jSelector)
                                       throws InterpreterException
upFieldSelection takes an explicit AmbientTalk field selection and turns it into an implicitly performed Java selection by invoking a getter method, if such a getter method exists.

Parameters:
atOrigRcvr - the original AmbientTalk object that received the selection
jSelector - the selector of the message to be invoked, already converted to a Java selector
Returns:
the return value of the Java getter method invoked via the AmbientTalk selection. Example: eval "msg.selector" where msg is a NATMessage => upSelection(aNATMessage, "selector") => NATMessage must have a zero-argument method named getSelector
Throws:
InterpreterException

upFieldAssignment

public static final ATObject upFieldAssignment(ATObject atOrigRcvr,
                                               java.lang.String jSelector,
                                               ATObject value)
                                        throws InterpreterException
upFieldAssignment takes an explicit AmbientTalk field assignment and turns it into an implicitly performed Java field assignment by invoking a mutator method, if such a method exists.

Parameters:
atOrigRcvr - the original AmbientTalk object that received the assignField request
jSelector - the selector of the message to be invoked, already converted to a Java selector
Returns:
the return value of the Java mutator method invoked via the AmbientTalk assignField request. Example: eval "msg.selector := v" where msg is a NATMessage => upFieldAssignment(aNATMessage, "selector", v) => NATMessage must have a one-argument method named base_setSelector
Throws:
InterpreterException

upMethodSelection

public static final NativeClosure upMethodSelection(ATObject atOrigRcvr,
                                                    java.lang.String jSelector,
                                                    ATSymbol origSelector)
                                             throws InterpreterException
upMethodSelection takes an explicit AmbientTalk field selection and checks whether a Java method exists that matches the selector. If so, this method is wrapped in a NativeClosure and returned.

Parameters:
atOrigRcvr - the original AmbientTalk object that received the selection
jSelector - the selector of the message to be invoked, converted to a Java selector
Returns:
a closure wrapping the method selected via the AmbientTalk selection. Example: eval "[1,2,3].at" => upSelection(aNATTable, "at") => either NATTable must have a method base_at, which is then wrapped
Throws:
InterpreterException

upInstanceCreation

public static final ATObject upInstanceCreation(ATObject jRcvr,
                                                ATTable atInitargs)
                                         throws InterpreterException
upInstanceCreation takes an explicit AmbientTalk 'new' invocation and turns it into an implicit Java instance creation by calling a constructor. The initargs are upped as well and are passed as arguments to the constructor.

Parameters:
jRcvr - the Java object having received the call to new
atInitargs - the arguments to the constructor
Returns:
a new instance of a Java class
Throws:
InterpreterException

upExceptionCreation

public static final ATObject upExceptionCreation(InterpreterException jRcvr,
                                                 ATTable atInitargs)
                                          throws InterpreterException
Throws:
InterpreterException

downObject

public static final ATObject downObject(ATObject metaObject)
                                 throws InterpreterException
Pass an AmbientTalk meta-level object into the base-level

Throws:
InterpreterException

upObject

public static final ATObject upObject(ATObject baseObject)
Pass an AmbientTalk base-level object to the meta-level


downBaseLevelFields

public static final ATField[] downBaseLevelFields(ATObject atObj)
                                           throws InterpreterException
Returns, for a given AmbientTalk object atObj, an array of NativeField objects corresponding to all non-static methods of that object's Java class, where each method's name is prefixed with 'base_get'

Throws:
InterpreterException

downMetaLevelFields

public static final ATField[] downMetaLevelFields(ATObject atObj)
                                           throws InterpreterException
Returns, for a given AmbientTalk object atObj, an array of NativeField objects corresponding to all non-static methods of that object's Java class, where each method's name is prefixed with 'meta_get'

Throws:
InterpreterException

downBaseLevelMethods

public static final ATMethod[] downBaseLevelMethods(ATObject atObj)
                                             throws InterpreterException
Returns, for a given AmbientTalk object atObj, an array of NativeMethod objects corresponding to all non-static methods of that object's class, where each method's name: - is prefixed with 'base_' - is not prefixed with 'base_get' - is not prefixed with 'base_set'

Throws:
InterpreterException

downMetaLevelMethods

public static final ATMethod[] downMetaLevelMethods(ATObject natObj)
                                             throws InterpreterException
Returns, for a given AmbientTalk object natObj, an array of NativeMethod objects corresponding to all non-static methods of that object's class, where each method's name: - is prefixed with 'meta_' - is not prefixed with 'meta_get' - is not prefixed with 'meta_set'

Throws:
InterpreterException

stripPrefix

private static java.lang.String stripPrefix(java.lang.String input,
                                            java.lang.String prefix)

oprCode2Symbol

private static final java.lang.String oprCode2Symbol(java.lang.String code)

symbol2oprCode

private static final java.lang.String symbol2oprCode(java.lang.String symbol)

javaToAmbientTalkSelector

private static final java.lang.String javaToAmbientTalkSelector(java.lang.String jSelector)