|
|||||||||||
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.NATCallframe
edu.vub.at.objects.natives.NATObject
Native implementation of a default ambienttalk object. Although a native AmbientTalk object is implemented as a subtype of callframes, the reality is that call frames are a special kind of object. This is a pure form of implementation subclassing: we subclass NATCallframe only for reusing the field definition/assignment protocol and for inheriting the variable map, the state vector and the lexical parent. NATObjects are one of the five native classes that fully implement the ATObject interface (next to NATCallFrame, NATNil, NATMirage and NATSuperObject). The implementation is such that a NATObject instance represents *both* a base-level AmbientTalk object, as well as a meta-level AmbientTalk mirror on that object. An AmbientTalk base-level object has the following structure: - properties: a set of boolean flags denoting: - whether the dynamic parent is an IS_A or a SHARES_A parent - whether the object shares its variable map with clones - whether the object shares its method dictionary with clones - whether the object is an isolate (i.e. pass-by-copy) - a variable map, mapping variable names to indices into the state vector - a state vector, containing the field values of the object - a linked list containing custom field objects - a method dictionary, mapping selectors to methods - a dynamic object parent, to delegate select and invoke operations ( this parent slot is represented by a true AmbientTalk field, rather than by an instance variable ) - a lexical object parent, to support lexical scoping - a table of stripes that were attached to this object (for classification purposes)
Field Summary | |
static AGSymbol |
_EQL_NAME_
|
static AGSymbol |
_INI_NAME_
|
static boolean |
_IS_A_
|
private static byte |
_IS_ISOLATE_FLAG_
This flag determines whether or not the object is an isolate and hence pass-by-copy: - 1: the object is an isolate, pass-by-copy and no lexical parent except for the root - 0: the object is pass-by-reference and can have any lexical parent |
private static byte |
_ISAPARENT_FLAG_
This flag determines the type of parent pointer of this object. |
static AGSymbol |
_NEW_NAME_
|
static ATStripe[] |
_NO_STRIPES_
An empty stripe array shared by those objects that do not have any stripes. |
private static PrimitiveMethod |
_PRIM_EQL_
def ==(comparand) { nil } |
private static PrimitiveMethod |
_PRIM_INI_
def init(@initargs) { nil } |
private static PrimitiveMethod |
_PRIM_NEW_
def new(@initargs) { nil } |
private static byte |
_SHARE_DCT_FLAG_
Similar to _SHARE_MAP_FLAG__ but for determining the shared status of the method dictionary. |
private static byte |
_SHARE_MAP_FLAG_
This flag determines whether or not the field map of this object is shared by other objects: - 1: the map is shared, so modifications must be performed on a copy - 0: the map is not shared, modifications may be directly performed on it This flag is important for maintaining the semantics that clones are self-sufficient objects: they share field names and methods only at the implementation-level. |
static boolean |
_SHARES_A_
|
static AGSymbol |
_SUPER_NAME_
|
private byte |
flags_
The flags of an AmbientTalk object encode the following boolean information: Format: 0b0000idmp where p = parent flag: if set, dynamic parent is 'is-a' parent, otherwise 'shares-a' parent m = shares map flag: if set, the map of this object is shared between clones d = shares dictionary flag: if set, the method dictionary of this object is shared between clones i = is isolate flag: if set, the object is passed by copy in inter-actor communication |
private MethodDictionary |
methodDictionary_
The method dictionary of this object. |
protected ATStripe[] |
stripes_
The stripes under which this object has been classified |
Fields inherited from class edu.vub.at.objects.natives.NATCallframe |
customFields_, lexicalParent_, stateVector_, variableMap_ |
Fields inherited from class edu.vub.at.objects.natives.NATNil |
_INSTANCE_ |
Constructor Summary | |
|
NATObject()
Constructs a new AmbientTalk object whose lexical parent is the global scope and whose dynamic parent is the dynamic root. |
|
NATObject(ATObject lexicalParent)
Constructs a new ambienttalk object parametrised by a lexical scope. |
|
NATObject(ATObject dynamicParent,
ATObject lexicalParent,
boolean parentType)
Constructs a new ambienttalk object based on a set of parent pointers. |
|
NATObject(ATObject dynamicParent,
ATObject lexicalParent,
boolean parentType,
ATStripe[] stripes)
Constructs a new ambienttalk object based on a set of parent pointers. |
|
NATObject(ATObject lexicalParent,
ATStripe[] stripes)
Constructs a new ambienttalk object parametrised by a lexical scope. |
|
NATObject(ATObject dynamicParent,
boolean parentType)
Constructs a new ambienttalk object with the given dynamic parent. |
|
NATObject(ATStripe[] stripes)
|
protected |
NATObject(FieldMap map,
java.util.Vector state,
java.util.LinkedList originalCustomFields,
MethodDictionary methodDict,
ATObject dynamicParent,
ATObject lexicalParent,
byte flags,
ATStripe[] stripes)
Constructs a new ambienttalk object as a clone of an existing object. |
Method Summary | |
NATObject |
asAmbientTalkObject()
|
ATActorMirror |
base_asActorMirror()
|
ATAsyncMessage |
base_asAsyncMessage()
|
ATBegin |
base_asBegin()
|
ATBoolean |
base_asBoolean()
|
ATClosure |
base_asClosure()
|
ATDefinition |
base_asDefinition()
|
ATExpression |
base_asExpression()
|
ATField |
base_asField()
|
ATHandler |
base_asHandler()
|
ATMessage |
base_asMessage()
|
ATMessageCreation |
base_asMessageCreation()
|
ATMethod |
base_asMethod()
|
ATMirror |
base_asMirror()
|
ATNumber |
base_asNumber()
|
ATSplice |
base_asSplice()
|
ATStatement |
base_asStatement()
|
ATStripe |
base_asStripe()
|
ATSymbol |
base_asSymbol()
|
ATTable |
base_asTable()
|
ATUnquoteSplice |
base_asUnquoteSplice()
|
boolean |
base_isBoolean()
|
boolean |
base_isCallFrame()
|
boolean |
base_isClosure()
|
boolean |
base_isMethod()
|
boolean |
base_isMirror()
|
boolean |
base_isSplice()
|
boolean |
base_isStripe()
|
boolean |
base_isSymbol()
|
boolean |
base_isTable()
|
boolean |
base_isUnquoteSplice()
|
private java.lang.Object |
coerce(ATStripe requiredStripe,
java.lang.Class providedInterface)
ALL asXXX methods return a coercer object which returns a proxy of the correct interface that will 'down' subsequent Java base-level invocations to the AmbientTalk level. |
protected ATObject |
createChild(ATClosure code,
boolean parentPointerType)
When creating children of objects, care must be taken that an extension of an isolate itself remains an isolate. |
protected NATObject |
createClone(FieldMap map,
java.util.Vector state,
java.util.LinkedList originalCustomFields,
MethodDictionary methodDict,
ATObject dynamicParent,
ATObject lexicalParent,
byte flags,
ATStripe[] stripes)
|
static NATObject |
createIsolate()
Creates an object striped with the at.stripes.Isolate stripe. |
private ATMethod |
getLocalMethod(ATSymbol selector)
|
private boolean |
hasLocalMethod(ATSymbol selector)
|
boolean |
isAmbientTalkObject()
|
private boolean |
isFlagSet(byte flag)
|
private boolean |
isLocallyStripedWith(ATStripe stripe)
Performs a stripe test for this object locally. |
static boolean |
isPrimitive(ATSymbol name)
Does the selector signify a 'primitive' method, present in each AmbientTalk object? |
static ATField[] |
listTransitiveFields(ATObject obj)
Auxiliary method to access the fields of an object and all of its super-objects up to (but excluding) nil. |
static ATMethod[] |
listTransitiveMethods(ATObject obj)
Auxiliary method to access the methods of an object and all of its super-objects up to (but excluding) nil. |
ATNil |
meta_addMethod(ATMethod method)
When a method is added to an object, it is first checked whether the method does not already exist. |
ATNil |
meta_assignField(ATObject receiver,
ATSymbol selector,
ATObject value)
meta_assignField is used to evaluate code of the form o.m := v. |
ATObject |
meta_clone()
When cloning an object, it is first determined whether the parent has to be shared by the clone, or whether the parent must also be cloned. |
ATNil |
meta_defineField(ATSymbol name,
ATObject value)
When a new field is defined in an object, it is important to check whether or not the field map is shared between clones or not. |
ATObject |
meta_extend(ATClosure code)
Create an is-a extension of the receiver object. |
ATTable |
meta_getStripes()
Return the stripes that were directly attached to this object. |
ATMethod |
meta_grabMethod(ATSymbol selector)
Queries an object for one of its method slots. |
ATObject |
meta_invoke(ATObject receiver,
ATSymbol selector,
ATTable arguments)
Invocations on an object ( o.m( args ) ) are handled by looking up the requested selector in the dynamic parent chain of the receiver. |
ATBoolean |
meta_isCloneOf(ATObject original)
Detects whether this object an the passed parameter are the result of cloning from a common ancestor (possibly either one of the objects itself). |
ATBoolean |
meta_isRelatedTo(ATObject object)
Detects whether both objects have a common origin, in other words whether they are related through a combination of the cloning and extension operators. |
ATBoolean |
meta_isStripedWith(ATStripe stripe)
Check whether one of the stripes of this object is a substripe of the given stripe. |
ATTable |
meta_listMethods()
Queries an object for a list of all of its method slots. |
ATObject |
meta_lookup(ATSymbol selector)
This method is used to evaluate code of the form selector within the scope of this object. |
ATObject |
meta_newInstance(ATTable initargs)
When new is invoked on an object's mirror, the object is first cloned by the mirror, after which the method named 'init' is invoked on it. |
ATObject |
meta_pass()
An isolate object does not return a proxy representation of itself during serialization, hence it is serialized itself. |
NATText |
meta_print()
Prints out the object in a human-readable way. |
ATObject |
meta_resolve()
An isolate object represents itself upon deserialization. |
ATBoolean |
meta_respondsTo(ATSymbol selector)
An ambienttalk object can respond to a message if a corresponding field or method exists either in the receiver object locally, or in one of its dynamic parents. |
ATObject |
meta_select(ATObject receiver,
ATSymbol selector)
meta_select is used to evaluate code of the form o.m. |
ATObject |
meta_share(ATClosure code)
Create a shares-a extension of the receiver object. |
private void |
setFlag(byte flag)
|
private void |
unsetFlag(byte flag)
|
Methods inherited from class edu.vub.at.objects.natives.NATCallframe |
getLocalCustomField, getLocalField, hasLocalCustomField, hasLocalField, hasLocalNativeField, meta_addField, meta_assignVariable, meta_doesNotUnderstand, meta_getDynamicParent, meta_getLexicalParent, meta_grabField, meta_listFields, setLocalField |
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_assignVariable, meta_doesNotUnderstand, meta_eval, meta_getDynamicParent, meta_getLexicalParent, meta_grabField, meta_listFields, meta_quote, meta_receive, meta_send |
Methods inherited from interface edu.vub.at.objects.coercion.ATConversions |
asJavaClassUnderSymbiosis, asJavaObjectUnderSymbiosis, asNativeBoolean, asNativeException, asNativeFarReference, asNativeFraction, asNativeNumber, asNativeNumeric, asNativeTable, asNativeText, base_asFarReference, base_asVariableAssignment, base_isFarReference, base_isMessageCreation, base_isVariableAssignment, isJavaObjectUnderSymbiosis, isNativeBoolean, isNativeField, isNativeText |
Field Detail |
public static final AGSymbol _SUPER_NAME_
public static final AGSymbol _EQL_NAME_
public static final AGSymbol _NEW_NAME_
public static final AGSymbol _INI_NAME_
private static final PrimitiveMethod _PRIM_EQL_
private static final PrimitiveMethod _PRIM_NEW_
private static final PrimitiveMethod _PRIM_INI_
public static final boolean _IS_A_
public static final boolean _SHARES_A_
private static final byte _ISAPARENT_FLAG_
private static final byte _SHARE_MAP_FLAG_
private static final byte _SHARE_DCT_FLAG_
private static final byte _IS_ISOLATE_FLAG_
public static final ATStripe[] _NO_STRIPES_
private byte flags_
private MethodDictionary methodDictionary_
protected ATStripe[] stripes_
Constructor Detail |
public NATObject()
public NATObject(ATStripe[] stripes)
public NATObject(ATObject lexicalParent)
lexicalParent
- - the lexical scope in which the object's definition was nestedpublic NATObject(ATObject lexicalParent, ATStripe[] stripes)
public NATObject(ATObject dynamicParent, boolean parentType)
dynamicParent
- - the dynamic parent of the new objectparentType
- - the type of parent linkpublic NATObject(ATObject dynamicParent, ATObject lexicalParent, boolean parentType)
dynamicParent
- - the parent object of the newly created objectlexicalParent
- - the lexical scope in which the object's definition was nestedparentType
- - how this object extends its dynamic parent (is-a or shares-a)public NATObject(ATObject dynamicParent, ATObject lexicalParent, boolean parentType, ATStripe[] stripes)
dynamicParent
- - the parent object of the newly created objectlexicalParent
- - the lexical scope in which the object's definition was nestedparentType
- - how this object extends its dynamic parent (is-a or shares-a)stripes
- - the stripes attached to this objectprotected NATObject(FieldMap map, java.util.Vector state, java.util.LinkedList originalCustomFields, MethodDictionary methodDict, ATObject dynamicParent, ATObject lexicalParent, byte flags, ATStripe[] stripes) throws InterpreterException
Method Detail |
public static boolean isPrimitive(ATSymbol name)
public static NATObject createIsolate()
public ATObject meta_invoke(ATObject receiver, ATSymbol selector, ATTable arguments) throws InterpreterException
return this.meta_select(receiver, selector).asClosure().meta_apply(arguments);
but has a specialized implementation for performance reasons (no unnecessary closure is created)
meta_invoke
in interface ATObject
meta_invoke
in class NATCallframe
InterpreterException
public ATBoolean meta_respondsTo(ATSymbol selector) throws InterpreterException
meta_respondsTo
in interface ATObject
meta_respondsTo
in class NATCallframe
InterpreterException
public ATObject meta_select(ATObject receiver, ATSymbol selector) throws InterpreterException
meta_select
in interface ATObject
meta_select
in class NATCallframe
receiver
- the original receiver of the selectionselector
- the selector to look up
InterpreterException
public ATObject meta_lookup(ATSymbol selector) throws InterpreterException
meta_lookup
in interface ATObject
meta_lookup
in class NATCallframe
InterpreterException
public ATNil meta_defineField(ATSymbol name, ATObject value) throws InterpreterException
meta_defineField
in interface ATObject
meta_defineField
in class NATCallframe
InterpreterException
public ATNil meta_assignField(ATObject receiver, ATSymbol selector, ATObject value) throws InterpreterException
meta_assignField
in interface ATObject
meta_assignField
in class NATCallframe
value
- the value to assign to the fieldselector
- the field to assign
InterpreterException
public ATObject meta_clone() throws InterpreterException
meta_clone
in interface ATObject
meta_clone
in class NATCallframe
InterpreterException
public ATObject meta_newInstance(ATTable initargs) throws InterpreterException
meta_newInstance
in interface ATObject
meta_newInstance
in class NATCallframe
InterpreterException
public ATObject meta_extend(ATClosure code) throws InterpreterException
ATObject
meta_extend
in interface ATObject
meta_extend
in class NATCallframe
InterpreterException
public ATObject meta_share(ATClosure code) throws InterpreterException
ATObject
obj.share { code }
is represented at the meta-level by
mirror(obj).meta_share(code)
Triggers the objectShared event on this object's beholders (mirror observers).
meta_share
in interface ATObject
meta_share
in class NATCallframe
InterpreterException
public ATNil meta_addMethod(ATMethod method) throws InterpreterException
meta_addMethod
in interface ATObject
meta_addMethod
in class NATCallframe
InterpreterException
public ATMethod meta_grabMethod(ATSymbol selector) throws InterpreterException
ATObject
meta_grabMethod
in interface ATObject
meta_grabMethod
in class NATCallframe
InterpreterException
public ATTable meta_listMethods() throws InterpreterException
ATObject
meta_listMethods
in interface ATObject
meta_listMethods
in class NATCallframe
InterpreterException
public NATText meta_print() throws InterpreterException
ATObject
meta_print
in interface ATObject
meta_print
in class NATCallframe
InterpreterException
public boolean base_isCallFrame()
base_isCallFrame
in interface ATConversions
base_isCallFrame
in class NATCallframe
protected NATObject createClone(FieldMap map, java.util.Vector state, java.util.LinkedList originalCustomFields, MethodDictionary methodDict, ATObject dynamicParent, ATObject lexicalParent, byte flags, ATStripe[] stripes) throws InterpreterException
InterpreterException
protected ATObject createChild(ATClosure code, boolean parentPointerType) throws InterpreterException
createChild
in class NATNil
InterpreterException
public ATBoolean meta_isCloneOf(ATObject original) throws InterpreterException
ATObject
meta_isCloneOf
in interface ATObject
meta_isCloneOf
in class NATCallframe
InterpreterException
public ATBoolean meta_isRelatedTo(ATObject object) throws InterpreterException
ATObject
meta_isRelatedTo
in interface ATObject
meta_isRelatedTo
in class NATCallframe
InterpreterException
public ATBoolean meta_isStripedWith(ATStripe stripe) throws InterpreterException
meta_isStripedWith
in interface ATObject
meta_isStripedWith
in class NATNil
InterpreterException
public ATTable meta_getStripes() throws InterpreterException
meta_getStripes
in interface ATObject
meta_getStripes
in class NATNil
InterpreterException
public ATObject meta_pass() throws InterpreterException
meta_pass
in interface ATObject
meta_pass
in class NATByRef
InterpreterException
public ATObject meta_resolve() throws InterpreterException
meta_resolve
in interface ATObject
meta_resolve
in class NATByRef
InterpreterException
public NATObject asAmbientTalkObject()
asAmbientTalkObject
in interface ATConversions
asAmbientTalkObject
in class NATNil
private java.lang.Object coerce(ATStripe requiredStripe, java.lang.Class providedInterface) throws InterpreterException
InterpreterException
public ATBoolean base_asBoolean() throws InterpreterException
base_asBoolean
in interface ATConversions
base_asBoolean
in class NATNil
InterpreterException
public ATClosure base_asClosure() throws InterpreterException
base_asClosure
in interface ATConversions
base_asClosure
in class NATNil
InterpreterException
public ATExpression base_asExpression() throws InterpreterException
base_asExpression
in interface ATConversions
base_asExpression
in class NATNil
InterpreterException
public ATField base_asField() throws InterpreterException
base_asField
in interface ATConversions
base_asField
in class NATNil
InterpreterException
public ATMessage base_asMessage() throws InterpreterException
base_asMessage
in interface ATConversions
base_asMessage
in class NATNil
InterpreterException
public ATMethod base_asMethod() throws InterpreterException
base_asMethod
in interface ATConversions
base_asMethod
in class NATNil
InterpreterException
public ATMirror base_asMirror() throws InterpreterException
base_asMirror
in interface ATConversions
base_asMirror
in class NATNil
InterpreterException
public ATHandler base_asHandler() throws InterpreterException
base_asHandler
in interface ATConversions
base_asHandler
in class NATNil
InterpreterException
public ATNumber base_asNumber() throws InterpreterException
base_asNumber
in interface ATConversions
base_asNumber
in class NATNil
InterpreterException
public ATTable base_asTable() throws InterpreterException
base_asTable
in interface ATConversions
base_asTable
in class NATNil
InterpreterException
public ATAsyncMessage base_asAsyncMessage() throws InterpreterException
base_asAsyncMessage
in interface ATConversions
base_asAsyncMessage
in class NATNil
InterpreterException
public ATActorMirror base_asActorMirror() throws InterpreterException
base_asActorMirror
in interface ATConversions
base_asActorMirror
in class NATNil
InterpreterException
public ATStripe base_asStripe() throws InterpreterException
base_asStripe
in interface ATConversions
base_asStripe
in class NATNil
InterpreterException
public ATBegin base_asBegin() throws InterpreterException
base_asBegin
in interface ATConversions
base_asBegin
in class NATNil
InterpreterException
public ATStatement base_asStatement() throws InterpreterException
base_asStatement
in interface ATConversions
base_asStatement
in class NATNil
InterpreterException
public ATUnquoteSplice base_asUnquoteSplice() throws InterpreterException
base_asUnquoteSplice
in interface ATConversions
base_asUnquoteSplice
in class NATNil
InterpreterException
public ATSymbol base_asSymbol() throws InterpreterException
base_asSymbol
in interface ATConversions
base_asSymbol
in class NATNil
InterpreterException
public ATSplice base_asSplice() throws InterpreterException
base_asSplice
in interface ATConversions
base_asSplice
in class NATNil
InterpreterException
public ATDefinition base_asDefinition() throws InterpreterException
base_asDefinition
in interface ATConversions
base_asDefinition
in class NATNil
InterpreterException
public ATMessageCreation base_asMessageCreation() throws InterpreterException
base_asMessageCreation
in interface ATConversions
base_asMessageCreation
in class NATNil
InterpreterException
public boolean isAmbientTalkObject()
isAmbientTalkObject
in interface ATConversions
isAmbientTalkObject
in class NATNil
public boolean base_isMirror() throws InterpreterException
base_isMirror
in interface ATConversions
base_isMirror
in class NATNil
InterpreterException
public boolean base_isBoolean() throws InterpreterException
base_isBoolean
in interface ATConversions
base_isBoolean
in class NATNil
InterpreterException
public boolean base_isClosure() throws InterpreterException
base_isClosure
in interface ATConversions
base_isClosure
in class NATNil
InterpreterException
public boolean base_isMethod() throws InterpreterException
base_isMethod
in interface ATConversions
base_isMethod
in class NATNil
InterpreterException
public boolean base_isSplice() throws InterpreterException
base_isSplice
in interface ATConversions
base_isSplice
in class NATNil
InterpreterException
public boolean base_isSymbol() throws InterpreterException
base_isSymbol
in interface ATConversions
base_isSymbol
in class NATNil
InterpreterException
public boolean base_isTable() throws InterpreterException
base_isTable
in interface ATConversions
base_isTable
in class NATNil
InterpreterException
public boolean base_isUnquoteSplice() throws InterpreterException
base_isUnquoteSplice
in interface ATConversions
base_isUnquoteSplice
in class NATNil
InterpreterException
public boolean base_isStripe() throws InterpreterException
base_isStripe
in interface ATConversions
base_isStripe
in class NATNil
InterpreterException
private boolean isFlagSet(byte flag)
private void setFlag(byte flag)
private void unsetFlag(byte flag)
private boolean hasLocalMethod(ATSymbol selector)
private ATMethod getLocalMethod(ATSymbol selector) throws InterpreterException
InterpreterException
private boolean isLocallyStripedWith(ATStripe stripe) throws InterpreterException
InterpreterException
public static ATField[] listTransitiveFields(ATObject obj) throws InterpreterException
InterpreterException
public static ATMethod[] listTransitiveMethods(ATObject obj) throws InterpreterException
InterpreterException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |