edu.vub.at.objects.natives
Class NATNamespace
java.lang.Object
edu.vub.at.objects.natives.NATNil
edu.vub.at.objects.natives.NATByRef
edu.vub.at.objects.natives.NATCallframe
edu.vub.at.objects.natives.NATObject
edu.vub.at.objects.natives.NATNamespace
- All Implemented Interfaces:
- ATAbstractGrammar, ATConversions, ATExpression, ATNil, ATObject, ATStatement, java.io.Serializable
- public final class NATNamespace
- extends NATObject
Instances of the class NATNamespace represent namespace objects.
Namespace objects act as regular AmbientTalk objects with the following differences and conventions:
- Behaviourally, a namespace object is mirrored by a mirror whose doesNotUnderstand
method reacts differently from the standard semantics of raising a 'selector not found' exception.
- Structurally, a namespace has the lexical root as its lexical parent and the dynamic root as its dynamic parent.
Furthermore, a namespace object encapsulates an absolute file system path and a relative 'path name'.
The name should correspond to a portion of the tail of the absolute path.
These variables are not visible to AmbientTalk code.
When a slot is looked up in a namespace NS for a path P (via meta_select) and not found, the namespace object
queries the local file system to see whether the selector corresponds to a directory or file in the
directory P. Either the selector:
- corresponds to a directory, in which case the missing slot is bound to a new namespace object corresponding to the path P/selector
- corresponds to a file named selector.at, in which case:
1) the slot is temporarily bound to nil
(this is to prevent loops when the code to be evaluated would refer to itself;
it also means there can be no circular dependencies, because referring to a slot still under construction yields nil)
2) a new object FS (the 'file scope') is created.
This object acts as the local scope for the file and has access to its 'enclosing' namespace via the '~' slot.
Hence, it can refer to other files in the 'current directory' using ~.filename
3) the code in the file is loaded and evaluated in the context (current=FS, self=FS, super=FS.parent=dynroot)
4) the result of the evaluated code is bound to the missing slot.
The next time the slot is queried for in the namespace, the value is immediately returned. This prevents
files from being loaded twice.
- does not correspond to any file or directory, resulting in a selector not found exception as usual.
- Author:
- tvcutsem, smostinc
- See Also:
- Serialized Form
Field Summary |
private static java.lang.String |
_AT_EXT_
|
private java.lang.String |
name_
|
private java.io.File |
path_
|
Constructor Summary |
private |
NATNamespace(FieldMap map,
java.util.Vector state,
java.util.LinkedList customFields,
MethodDictionary methodDict,
ATObject dynamicParent,
ATObject lexicalParent,
byte flags,
ATStripe[] stripes,
java.io.File path,
java.lang.String name)
Private constructor used only for cloning |
|
NATNamespace(java.lang.String name,
java.io.File path)
A namespace object encapsulates a given absolute path and represents the given relative path. |
Methods inherited from class edu.vub.at.objects.natives.NATObject |
asAmbientTalkObject, base_asActorMirror, base_asAsyncMessage, base_asBegin, base_asBoolean, base_asClosure, base_asDefinition, base_asExpression, 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_isBoolean, base_isCallFrame, base_isClosure, base_isMethod, base_isMirror, base_isSplice, base_isStripe, base_isSymbol, base_isTable, base_isUnquoteSplice, createChild, createIsolate, isAmbientTalkObject, isPrimitive, listTransitiveFields, listTransitiveMethods, meta_addMethod, meta_assignField, meta_clone, meta_defineField, meta_extend, meta_getStripes, meta_grabMethod, meta_invoke, meta_isCloneOf, meta_isRelatedTo, meta_isStripedWith, meta_listMethods, meta_lookup, meta_newInstance, meta_pass, meta_resolve, meta_respondsTo, meta_select, meta_share |
Methods inherited from class edu.vub.at.objects.natives.NATCallframe |
getLocalCustomField, getLocalField, hasLocalCustomField, hasLocalField, hasLocalNativeField, meta_addField, meta_assignVariable, meta_getDynamicParent, meta_getLexicalParent, meta_grabField, meta_listFields, setLocalField |
Methods inherited from class edu.vub.at.objects.natives.NATNil |
asJavaClassUnderSymbiosis, asJavaObjectUnderSymbiosis, asNativeBoolean, asNativeException, asNativeFarReference, asNativeFraction, asNativeNumber, asNativeNumeric, asNativeTable, asNativeText, base__opeql__opeql_, base_asFarReference, base_asVariableAssignment, base_init, base_isFarReference, base_isMessageCreation, base_isVariableAssignment, base_new, equals, isJavaObjectUnderSymbiosis, isNativeBoolean, isNativeField, isNativeText, meta_eval, meta_quote, meta_receive, meta_send, 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_assignVariable, 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 |
_AT_EXT_
private static final java.lang.String _AT_EXT_
- See Also:
- Constant Field Values
path_
private final java.io.File path_
name_
private final java.lang.String name_
NATNamespace
public NATNamespace(java.lang.String name,
java.io.File path)
- A namespace object encapsulates a given absolute path and represents the given relative path.
- Parameters:
name
- the name of this namespace (corresponding to a certain depth to the tail of the absolute path)path
- an absolute path referring to a local file system directory.
NATNamespace
private NATNamespace(FieldMap map,
java.util.Vector state,
java.util.LinkedList customFields,
MethodDictionary methodDict,
ATObject dynamicParent,
ATObject lexicalParent,
byte flags,
ATStripe[] stripes,
java.io.File path,
java.lang.String name)
throws InterpreterException
- Private constructor used only for cloning
meta_doesNotUnderstand
public ATObject meta_doesNotUnderstand(ATSymbol selector)
throws InterpreterException
- For a namespace object, doesNotUnderstand triggers the querying of the local file system
to load files corresponding to the missing selector.
- Specified by:
meta_doesNotUnderstand
in interface ATObject
- Overrides:
meta_doesNotUnderstand
in class NATCallframe
- 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 NATObject
- Throws:
InterpreterException
createFileScopeFor
public static NATObject createFileScopeFor(NATNamespace ns)
createClone
protected NATObject createClone(FieldMap map,
java.util.Vector state,
java.util.LinkedList customFields,
MethodDictionary methodDict,
ATObject dynamicParent,
ATObject lexicalParent,
byte flags,
ATStripe[] stripes)
throws InterpreterException
- Overrides:
createClone
in class NATObject
- Throws:
InterpreterException