edu.vub.at.objects.mirrors
Class OBJMirrorRoot

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

public class OBJMirrorRoot
extends NATByCopy

OBJMirrorRoot is a singleton which is shared by as a parent by all NATIntercessiveMirrors, It encodes the default behaviour to deal with invocation, selection and field assignment along the dynamic parent chain. This behaviour can be extracted, since these operations are always parameterised by a receiver object, namely the intercessive mirror in question.

Author:
smostinc
See Also:
Serialized Form

Field Summary
static OBJMirrorRoot _INSTANCE_
           
static ATSymbol _MIRROR_
           
 
Constructor Summary
private OBJMirrorRoot()
           
 
Method Summary
protected  ATObject createChild(ATClosure code, boolean parentPointerType)
           
 ATNil meta_assignField(ATObject receiver, ATSymbol name, ATObject value)
          The effect of assigning a field on a mirror can be twofold.
 ATObject meta_clone()
          OBJMirrorRoot is a singleton object.
 ATTable meta_getStripes()
          By default, a native object (and also nil) has no stripes.
 ATObject meta_invoke(ATObject receiver, ATSymbol atSelector, ATTable arguments)
          The effect of invoking methods on a mirror (through meta_invoke) consists of checking whether the requested functionality is provided as a meta-operation by the principal that is wrapped by this mirror.
 ATObject meta_resolve()
          After deserialization, ensure that the mirror root remains unique.
 ATObject meta_select(ATObject receiver, ATSymbol atSelector)
          The effect of selecting fields or methods on a mirror (through meta_select) consists of checking whether the requested selector matches a field of the principal wrapped by this mirror.
 
Methods inherited from class edu.vub.at.objects.natives.NATByCopy
meta_pass
 
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_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_isClosure, base_isFarReference, base_isMessageCreation, base_isMethod, base_isMirror, base_isSplice, base_isStripe, base_isSymbol, base_isTable, base_isUnquoteSplice, base_isVariableAssignment, base_new, equals, isAmbientTalkObject, isJavaObjectUnderSymbiosis, isNativeBoolean, isNativeField, isNativeText, meta_addField, meta_addMethod, meta_assignVariable, meta_defineField, meta_doesNotUnderstand, meta_eval, meta_extend, meta_getDynamicParent, meta_getLexicalParent, meta_grabField, meta_grabMethod, meta_isCloneOf, meta_isRelatedTo, meta_isStripedWith, meta_listFields, meta_listMethods, meta_lookup, meta_newInstance, meta_print, meta_quote, meta_receive, meta_respondsTo, meta_send, meta_share, readResolve, toString, writeReplace
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_MIRROR_

public static final ATSymbol _MIRROR_

_INSTANCE_

public static final OBJMirrorRoot _INSTANCE_
Constructor Detail

OBJMirrorRoot

private OBJMirrorRoot()
Method Detail

meta_invoke

public ATObject meta_invoke(ATObject receiver,
                            ATSymbol atSelector,
                            ATTable arguments)
                     throws InterpreterException

The effect of invoking methods on a mirror (through meta_invoke) consists of checking whether the requested functionality is provided as a meta-operation by the principal that is wrapped by this mirror. Since such meta-operations are intercepted and forwarded to allow for interception, the mirage is expected to have a method for the given selector albeit prefixed with 'magic_'.

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

meta_clone

public ATObject meta_clone()
                    throws InterpreterException
OBJMirrorRoot is a singleton object.

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

createChild

protected ATObject createChild(ATClosure code,
                               boolean parentPointerType)
                        throws InterpreterException
Overrides:
createChild in class NATNil
Throws:
InterpreterException

meta_select

public ATObject meta_select(ATObject receiver,
                            ATSymbol atSelector)
                     throws InterpreterException

The effect of selecting fields or methods on a mirror (through meta_select) consists of checking whether the requested selector matches a field of the principal wrapped by this mirror. If this is the case, the principal's ('meta_get' + selector) method will be invoked. Else the selector might identify one of the principal's meta-operations. If this is the case, then an AmbientTalk representation of the Java method ('meta_' + selector) will be returned.

Because an explicit AmbientTalk method invocation must be converted into an implicit Java method invocation, the invocation must be deified ('upped'). To uphold stratification of the mirror architecture, the result of this operation should be a mirror on the result of the Java method invocation.

Note that only when the principal does not have a matching meta_level field or method the mirror itself will be tested for a corresponding base_level behaviour (e.g. for its base field or for operators such as ==). In the latter case, stratification is not enforced. This is due to the fact that the said fields and methods are not meta-level behaviour, rather they are base-level operations which happen to be applicable on a mirror. An added advantage of this technique is that it permits a mirror to have a field referring to its principal.

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

meta_assignField

public ATNil meta_assignField(ATObject receiver,
                              ATSymbol name,
                              ATObject value)
                       throws InterpreterException
The effect of assigning a field on a mirror can be twofold. Either a meta_field of the reflectee is altered (in this case, the passed value must be a mirror to uphold stratification). Otherwise it is possible that a base field of the mirror itself is changed.

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

meta_resolve

public ATObject meta_resolve()
                      throws InterpreterException
After deserialization, ensure that the mirror root remains unique.

Specified by:
meta_resolve in interface ATObject
Overrides:
meta_resolve in class NATByCopy
Throws:
InterpreterException

meta_getStripes

public ATTable meta_getStripes()
                        throws InterpreterException
Description copied from class: NATNil
By default, a native object (and also nil) has no stripes.

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