edu.vub.at.objects.natives
Class OBJLexicalRoot

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

public final class OBJLexicalRoot
extends NATByCopy

An instance of the class OBJLexicalRoot represents the lexical root of an actor. Since a lexical root is sealed (it cannot be modified) and contains no mutable fields, it should be possible to share a singleton instance of this class among all actors. The lexical root is an object containing globally visible AmbientTalk native methods. Such methods include control structures such as if:then:else: and while:do: but also object creation methods like object: and extend:with: Furthermore, the lexical root is also responsible for ending recursive meta-level methods such as lookup and assignField. OBJLexicalRoot extends NATNil such that it inherits that class's ATObject protocol to convert AmbientTalk invocations of a method m into Java base_m invocations. Note that OBJLexicalRoot is a 'sentinel' class. The actual object bound to the lexical root of an actor will be a normal NATObject which is assumed to be 'nested' in this instance. This empty object is local to each actor and is mutable.

Author:
smostinc, tvcutsem
See Also:
Serialized Form

Field Summary
private static AGSymbol _ALIAS_PARAM_
           
private static java.util.HashSet _DEFAULT_EXCLUDED_SLOTS_
           
private static AGSymbol _EXCLUDE_PARAM_
           
private static AGSymbol _IMPORT_ALIAS_EXCLUDE_NAME_
           
private static AGSymbol _IMPORT_ALIAS_NAME_
           
private static AGSymbol _IMPORT_EXCLUDE_NAME_
           
private static AGSymbol _IMPORT_NAME_
           
static OBJLexicalRoot _INSTANCE_
          The singleton instance of the sentinel lexical root
protected static PrimitiveMethod _PRIM_IMPORT_
          Imports fields and methods from a given source object.
protected static PrimitiveMethod _PRIM_IMPORT_ALIAS_
          def import: sourceObject alias: [ `oldname -> `newname , ... ]
protected static PrimitiveMethod _PRIM_IMPORT_ALIAS_EXCLUDE_
          def import: sourceObject alias: [ `oldname -> `newname, ... ] excludes: [ `name1, `name2, ... ]
protected static PrimitiveMethod _PRIM_IMPORT_EXCLUDE_
          def import: sourceObject excludes: [ `name1, `name2, ... ]
private static AGSymbol _SRC_PARAM_
           
 
Constructor Summary
private OBJLexicalRoot()
          Constructor made private for singleton design pattern
 
Method Summary
 ATBoolean base__opeql__opeql_(ATObject comparand)
          The pointer equality == operator.
 ATNumber base__opmns_(ATNumber n)
          The unary - primitive: -NBR(n) == NBR(-n)
 ATBoolean base__opnot_(ATBoolean b)
          The unary !
 ATNumber base__oppls_(ATNumber n)
          The unary + primitive: +NBR(n) == NBR(n)
 ATObject base_actor_(ATClosure code)
          actor: { code } == actor: { code } mirroredBy: The semantics of actor creation is as follows: - Mandatory parameters to the block of initialization code are treated as lexically visible variables that have to remain available in the new actor behaviour.
 ATObject base_clone_(ATObject original)
          The clone: primitive, which returns a clone of an object.
 ATObject base_do_if_(ATClosure body, ATBoolean condition)
          The do:if: primitive, which in Ruby terminology is a 'statement modifier' usage: do: { body } if: condition pseudo-implementation: condition.ifTrue: { body }
 ATObject base_do_unless_(ATClosure body, ATBoolean condition)
          The do:unless: primitive, which in Ruby terminology is a 'statement modifier' usage: do: { body } unless: condition pseudo-implementation: condition.ifFalse: { body }
 ATObject base_eval_in_(ATAbstractGrammar ast, ATObject obj)
          eval: ast in: obj => evaluates the given AST in the context of the given object, returning its value
 ATObject base_export_as_(ATObject object, ATStripe topic)
          export: object as: topic => object becomes discoverable by objects in other actors via topic returns a publication object that can be used to cancel the export
 ATObject base_extend_with_(ATObject parent, ATClosure code)
          The extend:with: primitive, which delegates to the extend meta operation on the parent object.
 ATObject base_extend_with_mirroredBy_(ATObject parent, ATClosure code, NATIntercessiveMirror mirror)
           
 ATObject base_foreach_in_(ATClosure body, ATTable tab)
          The foreach:in: primitive, which calls back on the table using each: usage: foreach: { |v| body } in: [ table ] pseudo-implementation: [ table ].each: { |v| body }
 ATObject base_get_opdiv_()
          '/' (the global namespace) '/' is an alias for 'lobby'
 ATActorMirror base_getActor()
          actor => a reference to a mirror on the current actor
 ATBoolean base_getFalse()
          false
 ATObject base_getJlobby()
          jlobby (the Java class package root, initialized using the Java classpath)
 ATObject base_getLobby()
          lobby (the global namespace initialized using the objectpath)
 ATObject base_getNetwork()
          network (the network control object, to go online and offline)
 ATNil base_getNil()
          nil
 ATObject base_getRoot()
          root (the global scope)
 ATBoolean base_getTrue()
          true
 ATObject base_handle_with_(ATStripe filter, ATClosure replacementCode)
          handle: stripe with: { |e| replacementCode } Creates a first-class handler from a filter prototype and some handler code.
 ATObject base_if_then_(ATBoolean cond, ATClosure consequent)
          The if:then: primitive, which calls back on the boolean using ifTrue: usage: if: booleanCondition then: { consequent }
 ATObject base_if_then_else_(ATBoolean cond, ATClosure consequent, ATClosure alternative)
          The if:then:else primitive, which calls back on the boolean using ifTrue:ifFalse: usage: if: booleanCondition then: { consequent } else: { alternative } pseudo-implementation: booleanCondition.ifTrue: { consequent } ifFalse: { alternative }
 ATBoolean base_is_stripedWith_(ATObject object, ATStripe stripe)
          is: object stripedWith: stripe => returns true if the given object is striped with the given stripe
 ATObject base_isolate_(ATClosure code)
          isolate: { code } => create an isolate object Equivalent to: object: { code } stripedWith: [ at.stripes.Isolate ]
 ATObject base_let_(ATClosure body)
          The let: primitive, which allows for the easy creation of temporary local variables.
 ATObject base_mirror_(ATClosure code)
          The mirror: primitive, which allows creating custom mirrors which can be used to allow intercessive reflection on objects created from this mirror.
 ATObject base_new(ATObject[] initargs)
          Invoking root.new(args) results in an exception for reasons of safety.
 ATObject base_object_(ATClosure code)
          The object: primitive, implemented as base-level code.
 ATObject base_object_mirroredBy_(ATClosure code, NATIntercessiveMirror mirror)
          object: { code } mirroredBy: mirror => return an object mirage initialized with code
 ATObject base_object_stripedWith_(ATClosure code, ATTable stripes)
          object: { code } stripedWith: [ s1, s2, ... ] => creates a new object tagged with the given stripes
 ATText base_print_(ATObject obj)
          print: expression => string representing the expression
 ATNil base_raise_(ATObject anExceptionObject)
          raise: exception Raises an exception which can be caught by dynamically installed try-catch-using blocks.
 ATAbstractGrammar base_read_(ATText source)
          read: "text" => parses the given string into an AST
 ATObject base_reflect_(ATObject reflectee)
          The reflect: primitive, which returns a mirror on an object.
 ATTable base_retract_(ATFarReference farReference)
          retract: farReference => retract all currently unsent messages from the far reference's outbox This has the side effect that the returned messages will *not* be sent automatically anymore, the programmer is responsible to resend all messages that still need to be sent by hand.
 ATObject base_share_with_(ATObject parent, ATClosure code)
          The share:with: primitive, which delegates to the share meta operation on the parent object.
 ATObject base_share_with_mirroredBy_(ATObject parent, ATClosure code, NATIntercessiveMirror mirror)
           
 ATTable base_stripesOf_(ATObject object)
          stripesOf: object => returns all of the stripes of an object
 ATObject base_try_catch_using_(ATClosure tryBlock, ATStripe filter, ATClosure replacementCode)
          try: { tryBlock} catch: stripe using: { |e| replacementCode } 'Syntactic sugar' for one in-line handler
 ATObject base_try_catch_using_catch_using_(ATClosure tryBlock, ATStripe filter1, ATClosure hdl1, ATStripe filter2, ATClosure hdl2)
          try: { tryBlock } catch: stripe using: { |e| replacementCode } catch: stripe2 using: { |e| replacementCode2 } 'Syntactic sugar' for two in-line handlers
 ATObject base_try_catch_using_catch_using_catch_using_(ATClosure tryBlock, ATStripe filter1, ATClosure hdl1, ATStripe filter2, ATClosure hdl2, ATStripe filter3, ATClosure hdl3)
          try: { tryBlock } catch: stripe using: { |e| replacementCode } catch: stripe2 using: { |e| replacementCode2 } catch: stripe3 using: { |e| replacementCode3 } 'Syntactic sugar' for three in-line handlers
 ATObject base_try_using_(ATClosure tryBlock, ATHandler handler)
          try: { tryBlock} using: handler Ad-hoc code for one exception handler
 ATObject base_try_using_using_(ATClosure tryBlock, ATHandler hdl1, ATHandler hdl2)
          try: { tryBlock} using: handler1 using: handler2 Ad-hoc code for two exception handlers
 ATObject base_try_using_using_using_(ATClosure tryBlock, ATHandler hdl1, ATHandler hdl2, ATHandler hdl3)
          try: { tryBlock} using: hdl1 using: hdl2 using: hdl3 Ad-hoc code for three exception handlers
 ATObject base_try_usingHandlers_(ATClosure tryBlock, ATTable exceptionHandlers)
          try: { tryBlock } usingHandlers: [ handler1, handler2, ... ] Applies the given closure (to []) and handles exceptions using the given exception handlers.
 ATObject base_when_disconnected_(ATFarReference farReference, ATClosure listener)
          when: farReference disconnected: { code } => when the remote reference is broken due to network disconnections, trigger the code returns a subscription object that can be used to cancel the listener
 ATObject base_when_discovered_(ATStripe topic, ATClosure handler)
          when: topic discovered: { code } => when an object is exported by another actor under topic, trigger the code returns a subscription object that can be used to cancel the handler Once the code block has run once, it will not be triggered again.
 ATObject base_when_reconnected_(ATFarReference farReference, ATClosure listener)
          when: farReference reconnected: { code } => when the remote reference is reinstated after a network disconnection, trigger the code returns a subscription object that can be used to cancel the listener
 ATObject base_whenever_discovered_(ATStripe topic, ATClosure handler)
          whenever: topic discovered: { code } => when an object is exported by another actor under topic, trigger the code returns a subscription object that can be used to cancel the handler The code block can be fired multiple times.
 ATObject base_while_do_(ATClosure condition, ATClosure body)
          The while:do: primitive, which calls back on the closure using whileTrue: usage: while: { condition } do: { body } pseudo-implementation: { condition }.whileTrue: { body }
private static java.util.HashSet getDefaultExcludedSlots()
           
static void initializeRoot(NATObject root)
          Invoked whenever a new true AmbientTalk object is created that should represent the root.
 ATObject meta_resolve()
          After deserialization, ensure that the lexical root remains unique.
private static ATObject performImport(ATObject sourceObject, ATContext ctx, java.util.Hashtable aliases, java.util.HashSet exclude)
          Performs the actual copying of the slots from the source object to the importing object.
private static java.util.Hashtable preprocessAliases(ATTable aliases)
          Given a table of tables, of the form [ [oldname, newname], ... ], returns a hashtable mapping the old names to the new names.
private static java.util.HashSet preprocessExcludes(ATTable exclusions)
          Given a table of symbols, returns a hashset containing all the names.
 
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_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, 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_getStripes, meta_grabField, meta_grabMethod, meta_invoke, meta_isCloneOf, meta_isRelatedTo, meta_isStripedWith, meta_listFields, meta_listMethods, meta_lookup, meta_newInstance, meta_print, 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
 

Field Detail

_INSTANCE_

public static final OBJLexicalRoot _INSTANCE_
The singleton instance of the sentinel lexical root


_IMPORT_NAME_

private static final AGSymbol _IMPORT_NAME_

_IMPORT_ALIAS_NAME_

private static final AGSymbol _IMPORT_ALIAS_NAME_

_IMPORT_EXCLUDE_NAME_

private static final AGSymbol _IMPORT_EXCLUDE_NAME_

_IMPORT_ALIAS_EXCLUDE_NAME_

private static final AGSymbol _IMPORT_ALIAS_EXCLUDE_NAME_

_SRC_PARAM_

private static final AGSymbol _SRC_PARAM_

_ALIAS_PARAM_

private static final AGSymbol _ALIAS_PARAM_

_EXCLUDE_PARAM_

private static final AGSymbol _EXCLUDE_PARAM_

_PRIM_IMPORT_

protected static final PrimitiveMethod _PRIM_IMPORT_
Imports fields and methods from a given source object. This operation is very akin to a class using a trait. For each field in the trait, a new field is created in the importing 'host' object. For each method in the trait, a method is added to the host object whose body consists of delegating the message to the trait object. The purpose of import: is to: - be able to reuse the interface of an existing object (examples are traits or 'mixins' such as Enumerable, Comparable, Observable, ...) - be able to access the interface of an existing object without having to qualify access. This is especially useful when applied to namespace objects. E.g. 'import: at.collections' allows the importer to subsequently write Vector.new() rather than at.collections.Vector.new() def import: sourceObject { def newHost := thisContext.lexicalScope; def allFields := (reflect: sourceObject).listFields().base; def allMethods := (reflect: sourceObject).listMethods().base; allFields.each: { |field| (reflect: newHost).addField(field) } allMethods.each: { |method| (reflect: newHost).addMethod(aliasFor(method.name), `[@args], `#sourceObject^#(method.name)(@args)) } nil } All duplicate slot exceptions, which signify that an imported method or field already exists, are caught during import. These exceptions are bundled into an XImportConflict exception, which can be inspected by the caller to detect the conflicting, unimported, fields or methods.


_PRIM_IMPORT_ALIAS_

protected static final PrimitiveMethod _PRIM_IMPORT_ALIAS_
def import: sourceObject alias: [ `oldname -> `newname , ... ]


_PRIM_IMPORT_EXCLUDE_

protected static final PrimitiveMethod _PRIM_IMPORT_EXCLUDE_
def import: sourceObject excludes: [ `name1, `name2, ... ]


_PRIM_IMPORT_ALIAS_EXCLUDE_

protected static final PrimitiveMethod _PRIM_IMPORT_ALIAS_EXCLUDE_
def import: sourceObject alias: [ `oldname -> `newname, ... ] excludes: [ `name1, `name2, ... ]


_DEFAULT_EXCLUDED_SLOTS_

private static java.util.HashSet _DEFAULT_EXCLUDED_SLOTS_
Constructor Detail

OBJLexicalRoot

private OBJLexicalRoot()
Constructor made private for singleton design pattern

Method Detail

getDefaultExcludedSlots

private static java.util.HashSet getDefaultExcludedSlots()

preprocessAliases

private static java.util.Hashtable preprocessAliases(ATTable aliases)
                                              throws InterpreterException
Given a table of tables, of the form [ [oldname, newname], ... ], returns a hashtable mapping the old names to the new names.

Throws:
InterpreterException

preprocessExcludes

private static java.util.HashSet preprocessExcludes(ATTable exclusions)
                                             throws InterpreterException
Given a table of symbols, returns a hashset containing all the names.

Throws:
InterpreterException

performImport

private static ATObject performImport(ATObject sourceObject,
                                      ATContext ctx,
                                      java.util.Hashtable aliases,
                                      java.util.HashSet exclude)
                               throws InterpreterException
Performs the actual copying of the slots from the source object to the importing object.

Parameters:
sourceObject - the object that performed the import, lexically
ctx - the runtime context during which the import is performed
aliases - a mapping from old names (ATSymbol) to new names (ATSymbol)
exclude - a set containing slot names (ATSymbol) to disregard
Throws:
InterpreterException

initializeRoot

public static void initializeRoot(NATObject root)
Invoked whenever a new true AmbientTalk object is created that should represent the root. This gives the lexical root a chance to install its primitive methods.


base_getNil

public ATNil base_getNil()
nil


base_getTrue

public ATBoolean base_getTrue()
true


base_getFalse

public ATBoolean base_getFalse()
false


base_get_opdiv_

public ATObject base_get_opdiv_()
'/' (the global namespace) '/' is an alias for 'lobby'


base_getLobby

public ATObject base_getLobby()
lobby (the global namespace initialized using the objectpath)


base_getRoot

public ATObject base_getRoot()
root (the global scope)


base_getJlobby

public ATObject base_getJlobby()
jlobby (the Java class package root, initialized using the Java classpath)


base_getNetwork

public ATObject base_getNetwork()
network (the network control object, to go online and offline)


base_if_then_

public ATObject base_if_then_(ATBoolean cond,
                              ATClosure consequent)
                       throws InterpreterException
The if:then: primitive, which calls back on the boolean using ifTrue: usage: if: booleanCondition then: { consequent }

Parameters:
cond - a boolean object
consequent - a closure containing the code to execute if the boolean is true
Returns:
the result of invoking booleanCondition.ifTrue: { consequent }
Throws:
InterpreterException - if raised inside the consequent closure.

base_if_then_else_

public ATObject base_if_then_else_(ATBoolean cond,
                                   ATClosure consequent,
                                   ATClosure alternative)
                            throws InterpreterException
The if:then:else primitive, which calls back on the boolean using ifTrue:ifFalse: usage: if: booleanCondition then: { consequent } else: { alternative } pseudo-implementation: booleanCondition.ifTrue: { consequent } ifFalse: { alternative }

Parameters:
cond - a boolean object
consequent - a closure containing the code to execute if the boolean is true
alternative - a closure containing the code to execute if the boolean is false
Returns:
the result of invoking booleanCondition.ifTrue: { consequent }
Throws:
InterpreterException - if raised inside the consequent or alternative closure.

base_while_do_

public ATObject base_while_do_(ATClosure condition,
                               ATClosure body)
                        throws InterpreterException
The while:do: primitive, which calls back on the closure using whileTrue: usage: while: { condition } do: { body } pseudo-implementation: { condition }.whileTrue: { body }

Parameters:
condition - a closure expected to return a boolean object
body - a closure containing the code to execute as long as the condition closure returns true
Returns:
the result of invoking { body }.whileTrue: { condition }
Throws:
InterpreterException - if raised inside the condition or body closures.

base_foreach_in_

public ATObject base_foreach_in_(ATClosure body,
                                 ATTable tab)
                          throws InterpreterException
The foreach:in: primitive, which calls back on the table using each: usage: foreach: { |v| body } in: [ table ] pseudo-implementation: [ table ].each: { |v| body }

Parameters:
body - a closure expected to take one argument to be applied to each element of the table
tab - a table to apply the iterator block to
Returns:
the result of invoking [ table ].each: { |v| body }
Throws:
InterpreterException - if raised inside the iterator block.

base_do_if_

public ATObject base_do_if_(ATClosure body,
                            ATBoolean condition)
                     throws InterpreterException
The do:if: primitive, which in Ruby terminology is a 'statement modifier' usage: do: { body } if: condition pseudo-implementation: condition.ifTrue: { body }

Parameters:
body - a zero-argument closure to execute if the condition is true
condition - a boolean expression
Returns:
the result of invoking body if the condition is true or nil if the condition is false
Throws:
InterpreterException - if raised inside the body block.

base_do_unless_

public ATObject base_do_unless_(ATClosure body,
                                ATBoolean condition)
                         throws InterpreterException
The do:unless: primitive, which in Ruby terminology is a 'statement modifier' usage: do: { body } unless: condition pseudo-implementation: condition.ifFalse: { body }

Parameters:
body - a zero-argument closure to execute if the condition is false
condition - a boolean expression
Returns:
the result of invoking body if the condition is false or nil if the condition is true
Throws:
InterpreterException - if raised inside the body block.

base_let_

public ATObject base_let_(ATClosure body)
                   throws InterpreterException
The let: primitive, which allows for the easy creation of temporary local variables. This primitive should be used in conjunction with a closure that declares optional parameters. Because the closure will be invoked with zero arguments, all of the parameters will be given their corresponding default initial value. The parameters are defined local to the closure's body. Note: this let behaves like Scheme's let* and letrec, i.e. the following is legal: let: { |var1 := value1, var2 := var1, var3 := { ... var3() ... } | ... } usage: let: { |var := value| body } pseudo-implementation: def let: closure { closure() }

Parameters:
body - a closure which is supposed to declare some optional parameters
Returns:
the result of invoking the body closure
Throws:
InterpreterException - if raised inside the body block.

base_actor_

public ATObject base_actor_(ATClosure code)
                     throws InterpreterException
actor: { code } == actor: { code } mirroredBy: The semantics of actor creation is as follows: - Mandatory parameters to the block of initialization code are treated as lexically visible variables that have to remain available in the new actor behaviour. Hence, these variables are evaluated to values immediately at creation-time and parameter-passed to the new actor. - The closure containing the initialization code is unpacked, its lexical scope is disregarded and the unwrapped method is serialized and sent to the new actor, which can use it to initialize his behaviour object. - The creating actor waits for the created actor to spawn a new behaviour and to return a far reference to this behaviour. From that point on, the creating actor can run in parallel with the created actor, which only then evaluates the initialization code to initialize its behaviour.

Throws:
InterpreterException

base_getActor

public ATActorMirror base_getActor()
                            throws InterpreterException
actor => a reference to a mirror on the current actor

Throws:
InterpreterException

base_export_as_

public ATObject base_export_as_(ATObject object,
                                ATStripe topic)
                         throws InterpreterException
export: object as: topic => object becomes discoverable by objects in other actors via topic returns a publication object that can be used to cancel the export

Throws:
InterpreterException

base_when_discovered_

public ATObject base_when_discovered_(ATStripe topic,
                                      ATClosure handler)
                               throws InterpreterException
when: topic discovered: { code } => when an object is exported by another actor under topic, trigger the code returns a subscription object that can be used to cancel the handler Once the code block has run once, it will not be triggered again.

Throws:
InterpreterException

base_whenever_discovered_

public ATObject base_whenever_discovered_(ATStripe topic,
                                          ATClosure handler)
                                   throws InterpreterException
whenever: topic discovered: { code } => when an object is exported by another actor under topic, trigger the code returns a subscription object that can be used to cancel the handler The code block can be fired multiple times. To stop the block from triggering upon new publications, it must be explicitly cancelled

Throws:
InterpreterException

base_when_disconnected_

public ATObject base_when_disconnected_(ATFarReference farReference,
                                        ATClosure listener)
                                 throws InterpreterException
when: farReference disconnected: { code } => when the remote reference is broken due to network disconnections, trigger the code returns a subscription object that can be used to cancel the listener

Throws:
InterpreterException

base_when_reconnected_

public ATObject base_when_reconnected_(ATFarReference farReference,
                                       ATClosure listener)
                                throws InterpreterException
when: farReference reconnected: { code } => when the remote reference is reinstated after a network disconnection, trigger the code returns a subscription object that can be used to cancel the listener

Throws:
InterpreterException

base_retract_

public ATTable base_retract_(ATFarReference farReference)
                      throws InterpreterException
retract: farReference => retract all currently unsent messages from the far reference's outbox This has the side effect that the returned messages will *not* be sent automatically anymore, the programmer is responsible to resend all messages that still need to be sent by hand. Note that the returned messages are copies of the original.

Returns:
a table with a copy of all the messages being sent.
Throws:
InterpreterException

base_extend_with_

public ATObject base_extend_with_(ATObject parent,
                                  ATClosure code)
                           throws InterpreterException
The extend:with: primitive, which delegates to the extend meta operation on the parent object. usage: extend: anObject with: { someCode } pseudo-implementation: mirrorOf(anObject).extend(someCode)

Parameters:
parent - the object to extend
code - a closure containing the code to extend the parent object with
Returns:
an object whose dynamic parent is an is-a link to the parent parameter
Throws:
InterpreterException - if raised inside the code closure.

base_object_

public ATObject base_object_(ATClosure code)
                      throws InterpreterException
The object: primitive, implemented as base-level code. object: expects to be passed a closure such that it can extract the correct scope to be used as the object's lexical parent. usage: object: { someCode } pseudo-implementation: { def obj := objectP.new(mirrorOf(someCode).context.lexicalScope); mirrorOf(someCode).method.body.eval(contextP.new(obj, obj, nil)); obj } The code block used to initialize the object may contain formal parameters. If this is the case, the formals are evaluated in the context of the lexical scope of the code block to values. These values are then bound to the formal parameters in the object itself. This is primarily useful for copying surrounding variables within the object, e.g. for isolates which lose access to their surrounding scope.

Parameters:
code - a closure containing both the code with which to initialize the object and the new object's lexical parent
Returns:
a new object whose dynamic parent is NIL, whose lexical parent is the closure's lexical scope, initialized by the closure's code
Throws:
InterpreterException - if raised inside the code closure.

base_isolate_

public ATObject base_isolate_(ATClosure code)
                       throws InterpreterException
isolate: { code } => create an isolate object Equivalent to: object: { code } stripedWith: [ at.stripes.Isolate ]

Throws:
InterpreterException

base_share_with_

public ATObject base_share_with_(ATObject parent,
                                 ATClosure code)
                          throws InterpreterException
The share:with: primitive, which delegates to the share meta operation on the parent object. usage: share: anObject with: { someCode } pseudo-implementation: mirrorOf(anObject).share(someCode)

Parameters:
parent - the object to extend
code - a closure containing the code to extend the parent object with
Returns:
an object whose dynamic parent is a shares-a link to the parent parameter
Throws:
InterpreterException - if raised inside the code closure.

base_reflect_

public ATObject base_reflect_(ATObject reflectee)
                       throws InterpreterException
The reflect: primitive, which returns a mirror on an object. usage: reflect: anObject pseudo-implementation: at.mirrors.mirrorfactory.createMirror(anObject)

Parameters:
reflectee - the object to reflect upon
Returns:
a mirror reflecting the given object
Throws:
InterpreterException

base_clone_

public ATObject base_clone_(ATObject original)
                     throws InterpreterException
The clone: primitive, which returns a clone of an object. usage: clone: anObject pseudo-implementation: (reflect: anObject).clone()

Parameters:
original - the object to copy
Returns:
a clone of the given object
Throws:
InterpreterException

base_mirror_

public ATObject base_mirror_(ATClosure code)
                      throws InterpreterException
The mirror: primitive, which allows creating custom mirrors which can be used to allow intercessive reflection on objects created from this mirror. usage: mirror: { someCode } pseudo-implementation: defaultMirror.extend(somecode)

Parameters:
code - a closure containing both the code with which to initialize the mirror and the new mirror's lexical parent
Returns:
a new mirror containing the specified definitions
Throws:
InterpreterException

base_object_mirroredBy_

public ATObject base_object_mirroredBy_(ATClosure code,
                                        NATIntercessiveMirror mirror)
                                 throws InterpreterException
object: { code } mirroredBy: mirror => return an object mirage initialized with code

Throws:
InterpreterException

base_extend_with_mirroredBy_

public ATObject base_extend_with_mirroredBy_(ATObject parent,
                                             ATClosure code,
                                             NATIntercessiveMirror mirror)
                                      throws InterpreterException
Throws:
InterpreterException

base_share_with_mirroredBy_

public ATObject base_share_with_mirroredBy_(ATObject parent,
                                            ATClosure code,
                                            NATIntercessiveMirror mirror)
                                     throws InterpreterException
Throws:
InterpreterException

base_is_stripedWith_

public ATBoolean base_is_stripedWith_(ATObject object,
                                      ATStripe stripe)
                               throws InterpreterException
is: object stripedWith: stripe => returns true if the given object is striped with the given stripe

Throws:
InterpreterException

base_stripesOf_

public ATTable base_stripesOf_(ATObject object)
                        throws InterpreterException
stripesOf: object => returns all of the stripes of an object

Throws:
InterpreterException

base_object_stripedWith_

public ATObject base_object_stripedWith_(ATClosure code,
                                         ATTable stripes)
                                  throws InterpreterException
object: { code } stripedWith: [ s1, s2, ... ] => creates a new object tagged with the given stripes

Throws:
InterpreterException

base_try_usingHandlers_

public ATObject base_try_usingHandlers_(ATClosure tryBlock,
                                        ATTable exceptionHandlers)
                                 throws InterpreterException
try: { tryBlock } usingHandlers: [ handler1, handler2, ... ] Applies the given closure (to []) and handles exceptions using the given exception handlers. This is the most general means of doing exception handling in AmbientTalk/2. The handlers given in the handler table represent first-class handler objects, which should respond to the 'canHandle' message.

Throws:
InterpreterException

base_try_using_

public ATObject base_try_using_(ATClosure tryBlock,
                                ATHandler handler)
                         throws InterpreterException
try: { tryBlock} using: handler Ad-hoc code for one exception handler

Throws:
InterpreterException

base_try_using_using_

public ATObject base_try_using_using_(ATClosure tryBlock,
                                      ATHandler hdl1,
                                      ATHandler hdl2)
                               throws InterpreterException
try: { tryBlock} using: handler1 using: handler2 Ad-hoc code for two exception handlers

Throws:
InterpreterException

base_try_using_using_using_

public ATObject base_try_using_using_using_(ATClosure tryBlock,
                                            ATHandler hdl1,
                                            ATHandler hdl2,
                                            ATHandler hdl3)
                                     throws InterpreterException
try: { tryBlock} using: hdl1 using: hdl2 using: hdl3 Ad-hoc code for three exception handlers

Throws:
InterpreterException

base_try_catch_using_

public ATObject base_try_catch_using_(ATClosure tryBlock,
                                      ATStripe filter,
                                      ATClosure replacementCode)
                               throws InterpreterException
try: { tryBlock} catch: stripe using: { |e| replacementCode } 'Syntactic sugar' for one in-line handler

Throws:
InterpreterException

base_try_catch_using_catch_using_

public ATObject base_try_catch_using_catch_using_(ATClosure tryBlock,
                                                  ATStripe filter1,
                                                  ATClosure hdl1,
                                                  ATStripe filter2,
                                                  ATClosure hdl2)
                                           throws InterpreterException
try: { tryBlock } catch: stripe using: { |e| replacementCode } catch: stripe2 using: { |e| replacementCode2 } 'Syntactic sugar' for two in-line handlers

Throws:
InterpreterException

base_try_catch_using_catch_using_catch_using_

public ATObject base_try_catch_using_catch_using_catch_using_(ATClosure tryBlock,
                                                              ATStripe filter1,
                                                              ATClosure hdl1,
                                                              ATStripe filter2,
                                                              ATClosure hdl2,
                                                              ATStripe filter3,
                                                              ATClosure hdl3)
                                                       throws InterpreterException
try: { tryBlock } catch: stripe using: { |e| replacementCode } catch: stripe2 using: { |e| replacementCode2 } catch: stripe3 using: { |e| replacementCode3 } 'Syntactic sugar' for three in-line handlers

Throws:
InterpreterException

base_handle_with_

public ATObject base_handle_with_(ATStripe filter,
                                  ATClosure replacementCode)
handle: stripe with: { |e| replacementCode } Creates a first-class handler from a filter prototype and some handler code.


base_raise_

public ATNil base_raise_(ATObject anExceptionObject)
                  throws InterpreterException
raise: exception Raises an exception which can be caught by dynamically installed try-catch-using blocks.

Throws:
InterpreterException

base__opnot_

public ATBoolean base__opnot_(ATBoolean b)
                       throws InterpreterException
The unary ! primitive: !b == b.not()

Throws:
InterpreterException

base__opmns_

public ATNumber base__opmns_(ATNumber n)
                      throws InterpreterException
The unary - primitive: -NBR(n) == NBR(-n)

Throws:
InterpreterException

base__oppls_

public ATNumber base__oppls_(ATNumber n)
                      throws InterpreterException
The unary + primitive: +NBR(n) == NBR(n)

Throws:
InterpreterException

base_read_

public ATAbstractGrammar base_read_(ATText source)
                             throws InterpreterException
read: "text" => parses the given string into an AST

Throws:
InterpreterException

base_eval_in_

public ATObject base_eval_in_(ATAbstractGrammar ast,
                              ATObject obj)
                       throws InterpreterException
eval: ast in: obj => evaluates the given AST in the context of the given object, returning its value

Throws:
InterpreterException

base_print_

public ATText base_print_(ATObject obj)
                   throws InterpreterException
print: expression => string representing the expression

Throws:
InterpreterException

base__opeql__opeql_

public ATBoolean base__opeql__opeql_(ATObject comparand)
Description copied from interface: ATObject
The pointer equality == operator. OBJ(o1) == OBJ(o2) => BLN(o1.equals(o2))

Specified by:
base__opeql__opeql_ in interface ATObject
Overrides:
base__opeql__opeql_ in class NATNil

base_new

public ATObject base_new(ATObject[] initargs)
                  throws InterpreterException
Invoking root.new(args) results in an exception for reasons of safety. We could also have opted to simply return 'root' (i.e. make it a singleton) The reason for being conservative and throwing an exception is that when writing 'new(args)' in an object that does not implement new itself, this will implicitly lead to invoking root.new(args), not self.new(args), as the user will probably have intended. To catch such bugs quickly, root.new throws an exception rather than silently returning the root itself.

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

meta_resolve

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

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