|
|||||||||||
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.NATByCopy
edu.vub.at.objects.natives.OBJLexicalRoot
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.
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: |
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 java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final OBJLexicalRoot _INSTANCE_
private static final AGSymbol _IMPORT_NAME_
private static final AGSymbol _IMPORT_ALIAS_NAME_
private static final AGSymbol _IMPORT_EXCLUDE_NAME_
private static final AGSymbol _IMPORT_ALIAS_EXCLUDE_NAME_
private static final AGSymbol _SRC_PARAM_
private static final AGSymbol _ALIAS_PARAM_
private static final AGSymbol _EXCLUDE_PARAM_
protected static final PrimitiveMethod _PRIM_IMPORT_
protected static final PrimitiveMethod _PRIM_IMPORT_ALIAS_
protected static final PrimitiveMethod _PRIM_IMPORT_EXCLUDE_
protected static final PrimitiveMethod _PRIM_IMPORT_ALIAS_EXCLUDE_
private static java.util.HashSet _DEFAULT_EXCLUDED_SLOTS_
Constructor Detail |
private OBJLexicalRoot()
Method Detail |
private static java.util.HashSet getDefaultExcludedSlots()
private static java.util.Hashtable preprocessAliases(ATTable aliases) throws InterpreterException
InterpreterException
private static java.util.HashSet preprocessExcludes(ATTable exclusions) throws InterpreterException
InterpreterException
private static ATObject performImport(ATObject sourceObject, ATContext ctx, java.util.Hashtable aliases, java.util.HashSet exclude) throws InterpreterException
sourceObject
- the object that performed the import, lexicallyctx
- the runtime context during which the import is performedaliases
- a mapping from old names (ATSymbol) to new names (ATSymbol)exclude
- a set containing slot names (ATSymbol) to disregard
InterpreterException
public static void initializeRoot(NATObject root)
public ATNil base_getNil()
public ATBoolean base_getTrue()
public ATBoolean base_getFalse()
public ATObject base_get_opdiv_()
public ATObject base_getLobby()
public ATObject base_getRoot()
public ATObject base_getJlobby()
public ATObject base_getNetwork()
public ATObject base_if_then_(ATBoolean cond, ATClosure consequent) throws InterpreterException
cond
- a boolean objectconsequent
- a closure containing the code to execute if the boolean is true
InterpreterException
- if raised inside the consequent closure.public ATObject base_if_then_else_(ATBoolean cond, ATClosure consequent, ATClosure alternative) throws InterpreterException
cond
- a boolean objectconsequent
- a closure containing the code to execute if the boolean is truealternative
- a closure containing the code to execute if the boolean is false
InterpreterException
- if raised inside the consequent or alternative closure.public ATObject base_while_do_(ATClosure condition, ATClosure body) throws InterpreterException
condition
- a closure expected to return a boolean objectbody
- a closure containing the code to execute as long as the condition closure returns true
InterpreterException
- if raised inside the condition or body closures.public ATObject base_foreach_in_(ATClosure body, ATTable tab) throws InterpreterException
body
- a closure expected to take one argument to be applied to each element of the tabletab
- a table to apply the iterator block to
InterpreterException
- if raised inside the iterator block.public ATObject base_do_if_(ATClosure body, ATBoolean condition) throws InterpreterException
body
- a zero-argument closure to execute if the condition is truecondition
- a boolean expression
InterpreterException
- if raised inside the body block.public ATObject base_do_unless_(ATClosure body, ATBoolean condition) throws InterpreterException
body
- a zero-argument closure to execute if the condition is falsecondition
- a boolean expression
InterpreterException
- if raised inside the body block.public ATObject base_let_(ATClosure body) throws InterpreterException
body
- a closure which is supposed to declare some optional parameters
InterpreterException
- if raised inside the body block.public ATObject base_actor_(ATClosure code) throws InterpreterException
InterpreterException
public ATActorMirror base_getActor() throws InterpreterException
InterpreterException
public ATObject base_export_as_(ATObject object, ATStripe topic) throws InterpreterException
InterpreterException
public ATObject base_when_discovered_(ATStripe topic, ATClosure handler) throws InterpreterException
InterpreterException
public ATObject base_whenever_discovered_(ATStripe topic, ATClosure handler) throws InterpreterException
InterpreterException
public ATObject base_when_disconnected_(ATFarReference farReference, ATClosure listener) throws InterpreterException
InterpreterException
public ATObject base_when_reconnected_(ATFarReference farReference, ATClosure listener) throws InterpreterException
InterpreterException
public ATTable base_retract_(ATFarReference farReference) throws InterpreterException
InterpreterException
public ATObject base_extend_with_(ATObject parent, ATClosure code) throws InterpreterException
parent
- the object to extendcode
- a closure containing the code to extend the parent object with
InterpreterException
- if raised inside the code closure.public ATObject base_object_(ATClosure code) throws InterpreterException
code
- a closure containing both the code with which to initialize the object and the new object's lexical parent
InterpreterException
- if raised inside the code closure.public ATObject base_isolate_(ATClosure code) throws InterpreterException
InterpreterException
public ATObject base_share_with_(ATObject parent, ATClosure code) throws InterpreterException
parent
- the object to extendcode
- a closure containing the code to extend the parent object with
InterpreterException
- if raised inside the code closure.public ATObject base_reflect_(ATObject reflectee) throws InterpreterException
reflectee
- the object to reflect upon
InterpreterException
public ATObject base_clone_(ATObject original) throws InterpreterException
original
- the object to copy
InterpreterException
public ATObject base_mirror_(ATClosure code) throws InterpreterException
code
- a closure containing both the code with which to initialize the mirror and the new mirror's lexical parent
InterpreterException
public ATObject base_object_mirroredBy_(ATClosure code, NATIntercessiveMirror mirror) throws InterpreterException
InterpreterException
public ATObject base_extend_with_mirroredBy_(ATObject parent, ATClosure code, NATIntercessiveMirror mirror) throws InterpreterException
InterpreterException
public ATObject base_share_with_mirroredBy_(ATObject parent, ATClosure code, NATIntercessiveMirror mirror) throws InterpreterException
InterpreterException
public ATBoolean base_is_stripedWith_(ATObject object, ATStripe stripe) throws InterpreterException
InterpreterException
public ATTable base_stripesOf_(ATObject object) throws InterpreterException
InterpreterException
public ATObject base_object_stripedWith_(ATClosure code, ATTable stripes) throws InterpreterException
InterpreterException
public ATObject base_try_usingHandlers_(ATClosure tryBlock, ATTable exceptionHandlers) throws InterpreterException
InterpreterException
public ATObject base_try_using_(ATClosure tryBlock, ATHandler handler) throws InterpreterException
InterpreterException
public ATObject base_try_using_using_(ATClosure tryBlock, ATHandler hdl1, ATHandler hdl2) throws InterpreterException
InterpreterException
public ATObject base_try_using_using_using_(ATClosure tryBlock, ATHandler hdl1, ATHandler hdl2, ATHandler hdl3) throws InterpreterException
InterpreterException
public ATObject base_try_catch_using_(ATClosure tryBlock, ATStripe filter, ATClosure replacementCode) throws InterpreterException
InterpreterException
public ATObject base_try_catch_using_catch_using_(ATClosure tryBlock, ATStripe filter1, ATClosure hdl1, ATStripe filter2, ATClosure hdl2) throws InterpreterException
InterpreterException
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
InterpreterException
public ATObject base_handle_with_(ATStripe filter, ATClosure replacementCode)
public ATNil base_raise_(ATObject anExceptionObject) throws InterpreterException
InterpreterException
public ATBoolean base__opnot_(ATBoolean b) throws InterpreterException
InterpreterException
public ATNumber base__opmns_(ATNumber n) throws InterpreterException
InterpreterException
public ATNumber base__oppls_(ATNumber n) throws InterpreterException
InterpreterException
public ATAbstractGrammar base_read_(ATText source) throws InterpreterException
InterpreterException
public ATObject base_eval_in_(ATAbstractGrammar ast, ATObject obj) throws InterpreterException
InterpreterException
public ATText base_print_(ATObject obj) throws InterpreterException
InterpreterException
public ATBoolean base__opeql__opeql_(ATObject comparand)
ATObject
base__opeql__opeql_
in interface ATObject
base__opeql__opeql_
in class NATNil
public ATObject base_new(ATObject[] initargs) throws InterpreterException
base_new
in interface ATObject
base_new
in class NATNil
InterpreterException
public ATObject meta_resolve() throws InterpreterException
meta_resolve
in interface ATObject
meta_resolve
in class NATByCopy
InterpreterException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |