PageRenderTime 47ms CodeModel.GetById 13ms app.highlight 22ms RepoModel.GetById 1ms app.codeStats 0ms

/interpreter/tags/at2dist110511/src/edu/vub/at/objects/natives/OBJLexicalRoot.java

http://ambienttalk.googlecode.com/
Java | 2542 lines | 1226 code | 123 blank | 1193 comment | 158 complexity | 9bfdd6fde26521118313086642bb7591 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1/**
   2 * AmbientTalk/2 Project
   3 * OBJLexicalRoot.java created on 8-aug-2006 at 16:51:10
   4 * (c) Programming Technology Lab, 2006 - 2007
   5 * Authors: Tom Van Cutsem & Stijn Mostinckx
   6 * 
   7 * Permission is hereby granted, free of charge, to any person
   8 * obtaining a copy of this software and associated documentation
   9 * files (the "Software"), to deal in the Software without
  10 * restriction, including without limitation the rights to use,
  11 * copy, modify, merge, publish, distribute, sublicense, and/or
  12 * sell copies of the Software, and to permit persons to whom the
  13 * Software is furnished to do so, subject to the following
  14 * conditions:
  15 *
  16 * The above copyright notice and this permission notice shall be
  17 * included in all copies or substantial portions of the Software.
  18 *
  19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 * OTHER DEALINGS IN THE SOFTWARE.
  27 */
  28package edu.vub.at.objects.natives;
  29
  30import edu.vub.at.actors.ATActorMirror;
  31import edu.vub.at.actors.ATFarReference;
  32import edu.vub.at.actors.natives.ELActor;
  33import edu.vub.at.actors.natives.ELVirtualMachine;
  34import edu.vub.at.actors.natives.NATFarReference;
  35import edu.vub.at.actors.natives.Packet;
  36import edu.vub.at.actors.net.OBJNetwork;
  37import edu.vub.at.eval.Evaluator;
  38import edu.vub.at.exceptions.InterpreterException;
  39import edu.vub.at.exceptions.XIllegalOperation;
  40import edu.vub.at.exceptions.XUnassignableField;
  41import edu.vub.at.exceptions.XUndefinedSlot;
  42import edu.vub.at.objects.ATAbstractGrammar;
  43import edu.vub.at.objects.ATBoolean;
  44import edu.vub.at.objects.ATClosure;
  45import edu.vub.at.objects.ATContext;
  46import edu.vub.at.objects.ATHandler;
  47import edu.vub.at.objects.ATMethod;
  48import edu.vub.at.objects.ATNil;
  49import edu.vub.at.objects.ATNumber;
  50import edu.vub.at.objects.ATNumeric;
  51import edu.vub.at.objects.ATObject;
  52import edu.vub.at.objects.ATTable;
  53import edu.vub.at.objects.ATText;
  54import edu.vub.at.objects.ATTypeTag;
  55import edu.vub.at.objects.coercion.NativeTypeTags;
  56import edu.vub.at.objects.grammar.ATAssignmentSymbol;
  57import edu.vub.at.objects.grammar.ATSymbol;
  58import edu.vub.at.objects.mirrors.DirectNativeMethod;
  59import edu.vub.at.objects.mirrors.JavaInterfaceAdaptor;
  60import edu.vub.at.objects.mirrors.NATMirage;
  61import edu.vub.at.objects.mirrors.NATMirrorRoot;
  62import edu.vub.at.objects.mirrors.NativeClosure;
  63import edu.vub.at.parser.NATParser;
  64import edu.vub.at.util.logging.Logging;
  65
  66import java.lang.reflect.Method;
  67import java.util.HashMap;
  68import java.util.Iterator;
  69import java.util.LinkedList;
  70import java.util.List;
  71import java.util.Set;
  72import java.util.Map.Entry;
  73import java.util.concurrent.atomic.AtomicInteger;
  74
  75/**
  76 * The singleton instance of this class represents the lexical root of an actor.
  77 * Since this lexical root is constant (it cannot be modified) and contains no mutable fields,
  78 * it is possible to share a singleton instance of this class among all actors.
  79 * <p>
  80 * The lexical root is an object containing globally visible AmbientTalk native methods.
  81 * Such methods include control structures such as <tt>if:then:else:</tt>
  82 * but also object creation methods like <tt>object:</tt> and reflective constructs
  83 * like <tt>reflect:</tt>.
  84 * 
  85 * Furthermore, the lexical root is also the root of the lexical parent hierarchy for objects.
  86 * This means that this object's mirror is responsible for ending recursive meta-level methods
  87 * such as <tt>lookup</tt> and <tt>assignField</tt>.
  88 * <p>
  89 * Like any class whose instances represent native AmbientTalk objects, this class is a subclass
  90 * of {@link NativeATObject}. This means that this class can use the typical protocol of native objects
  91 * to implement base-level AmbientTalk methods as Java methods whose name is prefixed with
  92 * <tt>base_</tt>.
  93 * <p>
  94 * Note that OBJLexicalRoot is a <i>sentinel</i> class. The actual object bound to the
  95 * lexical root of an actor (accessible via the field <tt>root</tt> will be a normal
  96 * AmbientTalk object whose lexical parent is this object.
  97 * The real, empty, root object is local to each actor and is mutable. The definitions
  98 * from the <tt>init.at</tt> file are added to that object.
  99 * 
 100 * @author smostinc
 101 * @author tvcutsem
 102 */
 103public final class OBJLexicalRoot extends NATByCopy {
 104	
 105	/**
 106	 * The singleton instance of the sentinel lexical root
 107	 */
 108	static public final OBJLexicalRoot _INSTANCE_ = new OBJLexicalRoot();
 109	
 110	/**
 111	 * Constructor made private for singleton design pattern
 112	 */
 113	private OBJLexicalRoot() { }
 114	
 115	/**
 116	 * The lexical root has a special lexical parent object which ends the recursion
 117	 * along the lexical lookup chain. These methods cannot be implemented
 118	 * directly in this class because this class still implements useful
 119	 * <tt>base_</tt> Java methods which have to be invoked by means of the
 120	 * implementations defined in {@link NativeATObject}.
 121	 */
 122	private final NativeATObject lexicalSentinel_ = new NATByCopy() {
 123		// METHODS THAT END THE LEXICAL LOOKUP CHAIN
 124		
 125		public ATObject impl_callAccessor(ATSymbol selector, ATTable arguments) throws InterpreterException {
 126			throw new XUndefinedSlot("variable access", selector.toString());
 127		}
 128
 129		public ATObject impl_callMutator(ATAssignmentSymbol selector, ATTable arguments) throws InterpreterException {
 130			throw new XUnassignableField(selector.toString());
 131		}	
 132		
 133		public ATObject impl_callField(ATSymbol selector) throws InterpreterException {
 134			throw new XUndefinedSlot("variable access", selector.toString());
 135		}
 136		
 137		public ATClosure impl_lookupAccessor(final ATSymbol selector) throws InterpreterException {
 138			throw new XUndefinedSlot("accessor", selector.toString());
 139		}
 140
 141		public ATClosure impl_lookupMutator(ATAssignmentSymbol selector) throws InterpreterException {
 142			throw new XUnassignableField(selector.toString());
 143		}
 144
 145		public NATText meta_print() throws InterpreterException {
 146			return NATText.atValue("lexicalrootsentinel");
 147		}
 148	};
 149	
 150	public ATObject impl_lexicalParent() {
 151		return lexicalSentinel_;
 152	}
 153	
 154	/* -----------------------
 155	 * -- Primitive Methods --
 156	 * ----------------------- */
 157	
 158	/* ===============================================================================
 159	 * NOTE: the code below has been replaced by dedicated syntax and AST elements.
 160	 * However, the skeleton of this code may still prove useful in the future, if
 161	 * we ever plan to implement all base_ native methods as true AmbientTalk methods
 162	 * (i.e. as PrimitiveMethod instances).
 163	 * ===============================================================================
 164	 */
 165	
 166	
 167	/*
 168	private static final AGSymbol _IMPORT_NAME_ = AGSymbol.jAlloc("import:");
 169	private static final AGSymbol _IMPORT_ALIAS_NAME_ = AGSymbol.jAlloc("import:alias:");
 170	private static final AGSymbol _IMPORT_EXCLUDE_NAME_ = AGSymbol.jAlloc("import:exclude:");
 171	private static final AGSymbol _IMPORT_ALIAS_EXCLUDE_NAME_ = AGSymbol.jAlloc("import:alias:exclude:");
 172	
 173	private static final AGSymbol _SRC_PARAM_ = AGSymbol.jAlloc("sourceObject");
 174	private static final AGSymbol _ALIAS_PARAM_ = AGSymbol.jAlloc("aliases");
 175	private static final AGSymbol _EXCLUDE_PARAM_ = AGSymbol.jAlloc("exclude");
 176	*/
 177	
 178	
 179	/*protected static final PrimitiveMethod _PRIM_IMPORT_ = new PrimitiveMethod(_IMPORT_NAME_, NATTable.atValue(new ATObject[] { _SRC_PARAM_ })) {
 180		public ATObject base_apply(ATTable arguments, ATContext ctx) throws InterpreterException {
 181			  ATObject sourceObject = arguments.base_at(NATNumber.ONE);
 182			  return performImport(sourceObject, ctx, new Hashtable(), OBJLexicalRoot.getDefaultExcludedSlots());
 183		}
 184	};*/
 185	
 186	/**
 187	 * def import: sourceObject alias: [ `oldname -> `newname , ... ]
 188	 */
 189	/*protected static final PrimitiveMethod _PRIM_IMPORT_ALIAS_ = new PrimitiveMethod(_IMPORT_ALIAS_NAME_, NATTable.atValue(new ATObject[] { _SRC_PARAM_, _ALIAS_PARAM_ })) {
 190		public ATObject base_apply(ATTable arguments, ATContext ctx) throws InterpreterException {
 191			  ATObject sourceObject = arguments.base_at(NATNumber.ONE);
 192			  ATObject aliases = arguments.base_at(NATNumber.atValue(2));
 193			  return performImport(sourceObject, ctx, preprocessAliases(aliases.base_asTable()), OBJLexicalRoot.getDefaultExcludedSlots());
 194		}
 195	};*/
 196	
 197	/**
 198	 * def import: sourceObject excludes: [ `name1, `name2, ... ]
 199	 */
 200	/*protected static final PrimitiveMethod _PRIM_IMPORT_EXCLUDE_ = new PrimitiveMethod(_IMPORT_EXCLUDE_NAME_, NATTable.atValue(new ATObject[] { _SRC_PARAM_, _EXCLUDE_PARAM_ })) {
 201		public ATObject base_apply(ATTable arguments, ATContext ctx) throws InterpreterException {
 202			  ATObject sourceObject = arguments.base_at(NATNumber.ONE);
 203			  ATObject exclusions = arguments.base_at(NATNumber.atValue(2));
 204			  return performImport(sourceObject, ctx, new Hashtable(), preprocessExcludes(exclusions.base_asTable()));
 205		}
 206	};*/
 207	
 208	/**
 209	 * def import: sourceObject alias: [ `oldname -> `newname, ... ] excludes: [ `name1, `name2, ... ]
 210	 */
 211	/*protected static final PrimitiveMethod _PRIM_IMPORT_ALIAS_EXCLUDE_ = new PrimitiveMethod(_IMPORT_ALIAS_EXCLUDE_NAME_,
 212			                                                                                 NATTable.atValue(new ATObject[] { _SRC_PARAM_, _ALIAS_PARAM_, _EXCLUDE_PARAM_ })) {
 213		public ATObject base_apply(ATTable arguments, ATContext ctx) throws InterpreterException {
 214			  ATObject sourceObject = arguments.base_at(NATNumber.ONE);
 215			  ATObject aliases = arguments.base_at(NATNumber.atValue(2));
 216			  ATObject exclusions = arguments.base_at(NATNumber.atValue(3));
 217			  return performImport(sourceObject, ctx, preprocessAliases(aliases.base_asTable()), preprocessExcludes(exclusions.base_asTable()));
 218		}
 219	};*/
 220	
 221	/**
 222	 * Invoked whenever a new true AmbientTalk object is created that should
 223	 * represent the root. This gives the lexical root a chance to install its
 224	 * primitive methods.
 225	 */
 226	/*public static void initializeRoot(NATObject root) {
 227		try {
 228			// add import: native
 229			root.meta_addMethod(_PRIM_IMPORT_);
 230			// add import:alias: native
 231			root.meta_addMethod(_PRIM_IMPORT_ALIAS_);
 232			// add import:exclude: native
 233			root.meta_addMethod(_PRIM_IMPORT_EXCLUDE_);
 234			// add import:alias:exclude: native
 235			root.meta_addMethod(_PRIM_IMPORT_ALIAS_EXCLUDE_);
 236		} catch (InterpreterException e) {
 237			Logging.Init_LOG.fatal("Failed to initialize the root!", e);
 238		}
 239	}*/
 240	
 241	/* ----------------------
 242	 * -- Global variables --
 243	 * ---------------------- */
 244	
 245	/**
 246	 * <tt>nil</tt> evaluates to the nil object, which is
 247	 * the empty, dynamic parent of all AmbientTalk objects. 
 248	 */
 249	public ATNil base_nil() {
 250		return Evaluator.getNil();
 251	}
 252	
 253	/**
 254	 * <tt>true</tt> evaluates to the unique boolean true object.
 255	 */
 256	public ATBoolean base_true() {
 257		return NATBoolean._TRUE_;
 258	}
 259	
 260	/**
 261	 * <tt>false</tt> evaluates to the unique boolean false object.
 262	 */
 263	public ATBoolean base_false() {
 264		return NATBoolean._FALSE_;
 265	}
 266	
 267	/**
 268	 * <tt>/</tt> evaluates to the global namespace. It is
 269	 * simply an alias for <tt>lobby</tt>.
 270	 * @see #base_lobby()
 271	 */
 272	public ATObject base__opdiv_() {
 273		return base_lobby();
 274	}
 275	
 276	/**
 277	 * <tt>lobby</tt> evaluates to the global namespace object.
 278	 * For each <tt>name=path</tt> entry on AmbientTalk's
 279	 * <i>object path</i>, the lobby object contains a slot
 280	 * <tt>name</tt> bound to a namespace object bound to
 281	 * the directory referred to by <tt>path</tt>.
 282	 * <p>
 283	 * Accessing the lobby allows loading in AmbientTalk source code
 284	 * from external files.
 285	 */
 286	public ATObject base_lobby() {
 287		return Evaluator.getLobbyNamespace();
 288	}
 289	
 290	/**
 291	 * <tt>root</tt> evaluates to the global lexical scope object.
 292	 * This is the top-level object in which the definitions of
 293	 * the file <tt>at/init/init.at</tt> are evaluated. All code
 294	 * is assumed to be "nested" in the lexical root, so all definitions
 295	 * of this object are lexically accessible.
 296	 */
 297	public ATObject base_root() {
 298		return Evaluator.getGlobalLexicalScope();
 299	}
 300	
 301	/**
 302	 * <tt>jlobby</tt> evaluates to the Java namespace root. It is a
 303	 * special object which is part of the symbiosis infrastructure of
 304	 * AmbientTalk. <tt>jlobby</tt> acts like an object that has field
 305	 * names that correspond to Java package names. By selecting fields
 306	 * from this object, an appropriate Java package can be created
 307	 * from which a Java class can be accessed. Only the Java classes
 308	 * accessible in the Java classpath are accessible.
 309	 * 
 310	 * Example:
 311	 * <code>jlobby.java.util.Vector</code> evaluates to a reference to
 312	 * the Java <tt>Vector</tt> class.
 313	 */
 314	public ATObject base_jlobby() {
 315		return Evaluator.getJLobbyRoot();
 316	}
 317
 318	/**
 319	 * <tt>network</tt> evaluates to the unique network control object.
 320	 * It is a simple native object with two methods:
 321	 * <ul>
 322	 *  <li><tt>network.online()</tt> makes the interpreter go online. This allows
 323	 *  publications of local actors to be discovered by remote objects and vice versa.
 324	 *  <li><tt>network.offline()</tt> makes the interpreter go offline. All
 325	 *  remote references to remote objects will become disconnected.
 326	 * </ul>
 327	 */
 328	public ATObject base_network() {
 329		return OBJNetwork._INSTANCE_;
 330	}
 331	
 332	/**
 333	 * <tt>defaultMirror</tt> evaluates to the default mirror on objects. This
 334	 * is the mirror encapsulating the standard AmbientTalk object semantics.
 335	 * That is, it is a mirror with similar behaviour as the mirror created by
 336	 * executing: <code>reflect: (object: { ... })</code>.
 337	 * 
 338	 * The default mirror is an object with a read-only <tt>base</tt> field
 339	 * that signifies the base-level object of this mirror. The main purpose
 340	 * of this object is to serve as a prototype whose methods can be overridden
 341	 * by custom mirrors. The syntax:
 342	 * <pre>
 343	 * mirror: { ... }
 344	 * </pre>
 345	 * is syntactic sugar for:
 346	 * <pre>
 347	 * extend: defaultMirror with: { ... }
 348	 * </pre>
 349	 * 
 350	 * Note that the default mirror is typed with the <tt>/.at.types.Mirror</tt> type.
 351	 */
 352	public ATObject base_defaultMirror() {
 353		return Evaluator.getMirrorRoot();
 354	}
 355	
 356	/* ------------------------
 357	 * -- Control Structures --
 358	 * ------------------------ */
 359	
 360	/**
 361	 * The <tt>if:then:</tt> control structure. Usage:
 362	 *  <pre>if: cond then: consequent</pre>
 363	 * 
 364	 * pseudo-implementation:
 365	 * <pre>cond.ifTrue: consequent</pre>
 366	 * 
 367	 * Note that the consequent parameter should be a <i>closure</i>, i.e.
 368	 * the caller is responsible for delaying the evaluation of the consequent!
 369	 * 
 370	 * @param cond a boolean object
 371	 * @param consequent a closure containing the code to execute if the boolean is true
 372	 * @return if <tt>cond</tt> is true, the value of applying the consequent, <tt>nil</tt> otherwise
 373	 */
 374	public ATObject base_if_then_(ATBoolean cond, ATClosure consequent) throws InterpreterException {
 375		return cond.base_ifTrue_(consequent);
 376	}
 377	
 378	/**
 379	 * The <tt>if:then:else:</tt> control structure. Usage:
 380	 *  <pre>if: cond then: consequent else: alternative</pre>
 381	 * 
 382	 * pseudo-implementation:
 383	 * <pre>cond.ifTrue: consequent ifFalse: alternative</pre>
 384	 * 
 385	 * Note that the consequent and alternative parameters should be <i>closures</i>, i.e.
 386	 * the caller is responsible for delaying the evaluation of these arguments!
 387	 * 
 388	 * @param cond a boolean object
 389	 * @param consequent a closure containing the code to execute if the boolean is true
 390	 * @param alternative a closure containing the code to execute if the boolean is false
 391	 * @return the value of consequent if the boolean is true, the value of the alternative otherwise.
 392	 */
 393	public ATObject base_if_then_else_(ATBoolean cond, ATClosure consequent, ATClosure alternative) throws InterpreterException {
 394		return cond.base_ifTrue_ifFalse_(consequent, alternative);
 395	}
 396	
 397	/**
 398	 * The <tt>while:do:</tt> control structure. Usage:
 399	 * <pre>while: condition do: body</pre>
 400	 * 
 401	 * pseudo-implementation:
 402	 * <pre>condition.whileTrue: body</pre>
 403	 * 
 404	 * Note that <i>both</i> the condition and the body should be <i>closures</i>, because
 405	 * they represent pieces of code that have to be executed repeatedly. Because of traditional
 406	 * syntax, novice programmers are inclined to make the mistake of writing, e.g.:
 407	 * <pre>while: (i < 10) do: { i := i + 1 }</pre>
 408	 * Which is wrong because the first parameter should evaluate to a closure that itself
 409	 * returns a boolean value, not to a boolean value directly.
 410	 * 
 411	 * @param condition a closure expected to return a boolean object
 412	 * @param body a closure containing the code to execute as long as the condition closure returns true
 413	 * @return if conditions is true at least once, the last value of body, <tt>nil</tt> otherwise.
 414	 */
 415	public ATObject base_while_do_(ATClosure condition, ATClosure body) throws InterpreterException {
 416		return condition.base_whileTrue_(body);
 417	}
 418	
 419	/**
 420	 * The <tt>foreach:in:</tt> control structure. Usage:
 421	 * 
 422	 * <pre>foreach: body in: table</pre>
 423	 * 
 424	 * pseudo-implementation:
 425	 * <pre>table.each: body</pre>
 426	 * 
 427	 * Example: <code>[1,2,3].each: { |i| system.println(i) }</code>
 428	 * 
 429	 * @param body a one-arity closure that is to be applied to each element of the table
 430	 * @param tab a table to apply the body closure to
 431	 * @return <tt>nil</tt>, by default
 432	 */
 433	public ATObject base_foreach_in_(ATClosure body, ATTable tab) throws InterpreterException {
 434		return tab.base_each_(body);
 435	}
 436
 437	/**
 438	 * The <tt>do:if:</tt> control structure. Usage:
 439	 * <pre>do: body if: condition</pre>
 440	 * 
 441	 * pseudo-implementation:
 442	 * <pre>condition.ifTrue: body</pre>
 443	 *
 444	 * In Ruby, this kind of control structure is called a <i>statement modifier</i>.
 445	 * 
 446	 * @param body a zero-argument closure to execute if the condition is true
 447	 * @param condition a boolean value
 448	 * @return the result of invoking body if the condition is true or nil if the
 449	 * condition is false
 450	 */
 451	public ATObject base_do_if_(ATClosure body, ATBoolean condition) throws InterpreterException {
 452		return condition.base_ifTrue_(body);
 453	}
 454	
 455	/**
 456	 * The <tt>do:unless:</tt> control structure. Usage:
 457	 * <pre>do: body unless: condition</pre>
 458	 * 
 459	 * pseudo-implementation:
 460	 * <pre>condition.ifFalse: body</pre>
 461	 *
 462	 * In Ruby, this kind of control structure is called a <i>statement modifier</i>.
 463	 * Example: <code>do: { file.close() } unless: (nil == file)</code>
 464	 * 
 465	 * @param body a zero-argument closure to execute only if the condition is false
 466	 * @param condition a boolean value
 467	 * @return the result of invoking body if the condition is false, nil otherwise
 468	 */
 469	public ATObject base_do_unless_(ATClosure body, ATBoolean condition) throws InterpreterException {
 470		return condition.base_ifFalse_(body);
 471	}
 472	
 473	/**
 474	 * The <tt>let:</tt> construct. Usage:
 475	 * <pre>let: { |var := value| body }</pre>
 476	 * 
 477	 * pseudo-implementation:
 478	 * <pre>closure()</pre>
 479	 * 
 480	 * <tt>let:</tt> allows for the easy creation of temporary local variables.
 481	 * This construct should be used in conjunction with a closure that declares optional
 482	 * parameters. Because the closure will be invoked with zero arguments, all of the
 483	 * parameters will be given their corresponding default initial value. The parameters
 484	 * are defined local to the closure's body.
 485	 * 
 486	 * AmbientTalk's <tt>let:</tt> behaves like Scheme's <tt>let*</tt> and <tt>letrec</tt>,
 487	 * i.e. the following is legal:
 488	 * <pre>let: {
 489	 *  |var1 := value1,
 490	 *   var2 := var1,
 491	 *   var3 := { ... var3() ... }|
 492	 *  ...
 493	 *}</pre>
 494	 * 
 495	 * @param body a closure which is supposed to declare some optional parameters
 496	 * @return the result of invoking the body closure
 497	 */
 498	public ATObject base_let_(ATClosure body) throws InterpreterException {
 499		return body.base_apply(NATTable.EMPTY);
 500	}
 501	
 502	/* ------------------------------------------
 503	 * -- Actor Creation and accessing Methods --
 504	 * ------------------------------------------ */
 505	
 506	/**
 507	 * The <tt>actor: closure</tt> construct.
 508	 *  
 509	 * The semantics of actor creation is as follows:
 510	 * <ul>
 511	 *  <li> Mandatory parameters to the block of initialization code are treated as lexically visible
 512	 *   variables that have to remain available in the new actor behaviour. Hence, these variables
 513	 *   are evaluated to values immediately at creation-time and parameter-passed to the new actor.
 514	 *  <li> The closure containing the initialization code is unpacked, its lexical scope is disregarded
 515	 *   and the unwrapped method is serialized and sent to the new actor, which can use it to
 516	 *   initialize his behaviour object.
 517	 *  <li>The creating actor waits for the created actor to spawn a new behaviour and to return a far
 518	 *   reference to this behaviour. From that point on, the creating actor can run in parallel with
 519	 *   the created actor, which only then evaluates the initialization code to initialize its behaviour.
 520	 * </ul>
 521	 * 
 522	 * @param closure the closure whose parameters define lexical fields to be copied and whose
 523	 * method specifies the code of the new actor's behaviour object
 524	 * @return a far reference to the behaviour of the new actor
 525	 */
 526	public ATObject base_actor_(ATClosure closure) throws InterpreterException {
 527		ATMethod method = closure.base_method();
 528		ATObject copiedBindings;
 529
 530		// if no variables were specified to pass along to the new actor, calculate the
 531		// set of free variables for the actor
 532		if (method.base_parameters().base_isEmpty().asNativeBoolean().javaValue) {
 533			// introduce a private scope object that will hold copies
 534			// of the lexically free variables of the actor
 535			copiedBindings = new NATObject(OBJLexicalRoot._INSTANCE_, new ATTypeTag[] { NativeTypeTags._ISOLATE_ });
 536			
 537			// calculate the set of free variables of the initialization expression
 538			Set freeVars = method.base_bodyExpression().impl_freeVariables();
 539			// add all these free variables manually as fields to a custom 
 540			Iterator it = freeVars.iterator();
 541			while (it.hasNext()) {
 542				ATSymbol freeVar = (ATSymbol) it.next();
 543				
 544				// extra check to weed out special variables like "super" and variables available in the lexical root
 545				if (! (Evaluator.getGlobalLexicalScope().meta_respondsTo(freeVar).asNativeBoolean().javaValue
 546				      || OBJLexicalRoot._INSTANCE_.meta_respondsTo(freeVar).asNativeBoolean().javaValue)) {
 547
 548					// lookup the variable in the lexical scope
 549					try {
 550						ATClosure accessor = closure.base_context().base_lexicalScope().impl_lookup(freeVar);
 551						// only add the variable if it refers to a field, rather than to a method
 552						if (accessor instanceof NativeClosure.Accessor) {
 553							copiedBindings.meta_defineField(freeVar, accessor.base_apply(NATTable.EMPTY));
 554						}
 555					} catch(XUndefinedSlot exc) {
 556						// silently ignore lexically free variables which cannot be found
 557						// the assumption is that these variables will be bound by means of
 558						// import statements
 559						Logging.Actor_LOG.warn("Undefined lexically free var while constructing actor: "+exc.getFieldName());
 560					}
 561				}
 562			}
 563		} else {
 564			copiedBindings = Evaluator.evalMandatoryPars(
 565					method.base_parameters(),
 566					closure.base_context());
 567		}
 568		
 569		Packet serializedBindings = new Packet("actor-bindings", copiedBindings);
 570		Packet serializedInitCode = new Packet("actor-initcode", method);
 571		return ELVirtualMachine.currentVM().createActor(serializedBindings, serializedInitCode);
 572	}
 573	
 574	/**
 575	 * <tt>reflectOnActor</tt> evaluates to the mirror on the actor executing this code.
 576	 * The actor mirror is an object whose behaviour is consulted for operations
 577	 * such as creating and sending asynchronous messages or creating mirrors on
 578	 * other objects. It can be replaced by a custom mirror by means of the actor
 579	 * mirror's <tt>getExplicitActorMirror</tt> method.
 580	 */
 581	public ATActorMirror base_reflectOnActor() throws InterpreterException {
 582		return ELActor.currentActor().getImplicitActorMirror().base_getExplicitActorMirror();
 583	}
 584	
 585	/**
 586	 * The <tt>export: object as: topic</tt> construct. Pseudo-implementation:
 587	 * <pre>actor.provide(topic, object)</pre>
 588	 * 
 589	 * This construct enables the given object to become discoverable by objects
 590	 * in other actors by means of the topic type.
 591	 * 
 592	 * @param object the object to export to remote actors' objects
 593	 * @param topic a type denoting the abstract 'publication topic' for this object's publication
 594	 * @return a publication object whose <tt>cancel</tt> method can be used to cancel the publication.
 595	 */
 596	public ATObject base_export_as_(ATObject object, ATTypeTag topic) throws InterpreterException {
 597		return ELActor.currentActor().getImplicitActorMirror().base_provide(topic, object);
 598	}
 599	
 600	/**
 601	 * The <tt>when: topic discovered: handler</tt> construct. Pseudo-implementation:
 602	 * <pre>actor.require(topic, handler, false)</pre>
 603	 * 
 604	 * When an object is exported by <i>another</i> actor under topic, this construct triggers
 605	 * the given code, passing a reference to the exported object as argument to the closure.
 606	 * 
 607	 * Once the code block has run once, it will not be triggered again.
 608	 * 
 609	 * @param topic the abstract 'subscription topic' used to find an exported object
 610	 * @param handler a one-argument closure to apply to a discovered exported object
 611	 * @return a subscription object whose <tt>cancel</tt> method can be used to cancel the subscription,
 612	 * such that the handler will no longer be invoked. Beware, however, that at the time the
 613	 * subscription is cancelled, a request to apply the closure may already have been scheduled
 614	 * for execution by the current actor. This request is not cancelled by invoking the <tt>cancel</tt> method.
 615	 */
 616	public ATObject base_when_discovered_(ATTypeTag topic, ATClosure handler) throws InterpreterException {
 617		return ELActor.currentActor().getImplicitActorMirror().base_require(topic, handler, NATBoolean._FALSE_);
 618	}
 619	
 620	/**
 621	 * The <tt>whenever: topic discovered: handler</tt> construct. Pseudo-implementation:
 622	 * <pre>actor.require(topic, handler, true)</pre>
 623	 * 
 624	 * When an object is exported by <i>another</i> actor under topic, this construct triggers
 625	 * the given code, passing a reference to the exported object as argument to the closure.
 626	 * 
 627	 * The code block can be fired multiple times upon discovering multiple exported objects.
 628	 * To stop the block from triggering upon new publications, it must be explicitly cancelled
 629	 * 
 630	 * @param topic the abstract 'subscription topic' used to find an exported object
 631	 * @param handler a one-argument closure to apply to any discovered exported object
 632	 * @return a subscription object whose <tt>cancel</tt> method can be used to cancel the subscription,
 633	 * such that the handler will no longer be invoked. Beware, however, that at the time the
 634	 * subscription is cancelled, a request to apply the closure may already have been scheduled
 635	 * for execution by the current actor. This request is not cancelled by invoking the <tt>cancel</tt> method.
 636	 */
 637	public ATObject base_whenever_discovered_(ATTypeTag topic, ATClosure handler) throws InterpreterException {
 638		return ELActor.currentActor().getImplicitActorMirror().base_require(topic, handler, NATBoolean._TRUE_);
 639	}
 640	
 641	/**
 642	 * The <tt>whenever: farReference disconnected: listener</tt> construct.
 643	 * When the far reference is broken due to network disconnections, triggers the zero-arity listener
 644	 * closure. It is possible to register listeners on local far references. These may trigger if the
 645	 * local actor takes its object offline. In this case, these listeners will trigger as well.
 646	 * 
 647	 * @param farReference a native far reference
 648	 * @param listener a zero-arity closure to invoke if the far reference becomes disconnected
 649	 * @return a subscription object whose <tt>cancel</tt> method can be used to cancel future
 650	 * notifications of the listener.
 651	 */
 652	public ATObject base_whenever_disconnected_(ATFarReference farReference, ATClosure listener) throws InterpreterException {
 653		farReference.asNativeFarReference().addDisconnectionListener(listener);
 654		return new NATFarReference.NATDisconnectionSubscription(farReference.asNativeFarReference(), listener);
 655	}
 656	
 657	/**
 658	 * The <tt>whenever: farReference reconnected: listener</tt> construct.
 659	 * When the remote reference is reinstated after a network disconnection, trigger the zero-arity
 660	 * listener. Although it is allowed to register these listeners on local far references,
 661	 * these are normally not invoked because the only possibility for a local far ref to become
 662	 * disconnected is because the object was taken offline, and this is a permanent disconnect.
 663	 * 
 664	 * @param farReference a native far reference
 665	 * @param listener a zero-arity closure to invoke if the far reference becomes reconnected
 666	 * @return a subscription object whose <tt>cancel</tt> method can be used to cancel future
 667	 * notifications of the listener.
 668	 */
 669	public ATObject base_whenever_reconnected_(ATFarReference farReference, ATClosure listener) throws InterpreterException {
 670		farReference.asNativeFarReference().addReconnectionListener(listener);
 671		return new NATFarReference.NATReconnectionSubscription(farReference.asNativeFarReference(), listener);
 672	}
 673	
 674	/**
 675	 * The <tt>when: farReference takenOffline:</tt> construct.
 676	 *  When the (remote/local) far reference is broken because the object referenced was 
 677	 *  taken offline, trigger the code.
 678	 *  
 679	 * @param farReference a native far reference
 680	 * @param listener a zero-arity closure to invoke if the referenced object has been taken offline.
 681	 * @return a subscription object whose <tt>cancel</tt> method can be used to cancel future
 682	 * notifications of the listener.
 683	 */
 684	public ATObject base_when_takenOffline_(ATFarReference farReference, ATClosure listener) throws InterpreterException {
 685		farReference.asNativeFarReference().addTakenOfflineListener(listener);
 686		return new NATFarReference.NATExpiredSubscription(farReference.asNativeFarReference(), listener);
 687	}
 688	
 689
 690	/**
 691	 * The <tt>retract: farReference</tt> construct. 
 692	 * Retracts all currently unsent messages from the far reference's outbox.
 693	 * This has the side effect that the returned messages will <b>not</b> be sent
 694	 * automatically anymore, the programmer is responsible to explicitly resend
 695	 * all messages that were retracted but still need to be sent.
 696	 *  
 697	 * Note that the returned messages are copies of the original.
 698	 * @param farReference the far reference of which to retract outgoing message sends
 699	 * @return a table containing copies of all messages that were sent to this far reference, but
 700	 * not yet transmitted by the far reference to its referent.
 701	 */
 702	public ATTable base_retract_(ATFarReference farReference) throws InterpreterException {
 703		return farReference.meta_retractUnsentMessages();
 704	}
 705	
 706	/* -----------------------------
 707	 * -- Object Creation Methods --
 708	 * ----------------------------- */
 709	
 710	/**
 711	 * The <tt>object:</tt> object creation primitive.
 712	 * This construct creates a new AmbientTalk object where:
 713	 * <ul>
 714	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
 715	 *  <li>The object's <b>lexical parent</b> is the lexical scope of the argument closure. 
 716	 *  <li>The object's <b>dynamic parent</b> is <tt>nil</tt>.
 717	 *  <li>The object's <b>parent type</b> is <b>SHARES-A</b> (i.e. it is not an extension of its parent).
 718	 *  <li>The object's <b>types</b> is <tt>[]</tt> (i.e. it has no types).
 719	 *  <li>The object's <b>mirror</b> is the <tt>defaultMirror</tt> on objects (i.e. it is an object
 720	 *  with a 'native' metaobject protocol).
 721	 * </ul>
 722	 * 
 723	 * Example: <code>object: { def x := 1; }</code>
 724	 * <p>
 725	 * Pseudo-implementation:
 726	 * <pre>object: code childOf: nil extends: false taggedAs: [] mirroredBy: defaultMirror</pre>
 727	 * 
 728	 * The closure used to initialize the object may contain formal parameters. The closure
 729	 * will always be invoked with <i>its own mandatory formal parameters</i>. E.g., a closure
 730	 * <code>{ |x| nil }</code> is invoked as <code>{ |x| nil }(x)</code>. The net effect of this
 731	 * mechanic is that if <tt>x</tt> is a lexically visible variable at the object-creation
 732	 * site, the value of the variable will be copied into a copy with the same name which
 733	 * resides in the newly created object. This mechanic is primarily useful for copying surrounding
 734	 * variables within the object, e.g. for isolates which lose access to their surrounding scope.
 735	 * <p>
 736	 * Also, if the closure has optional parameters, they will always be triggered.
 737	 * The expressions to initialize the formal parameters are <i>evaluated</i>
 738	 * in the context of the closure's lexical scope but are <i>added</i> to the newly created object.
 739	 * 
 740	 * @param code a closure containing both the code with which to initialize the object and the new object's lexical parent
 741	 * @return a new AmbientTalk object with the properties defined above.
 742	 * @see #base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)
 743	 */
 744	public ATObject base_object_(ATClosure code) throws InterpreterException {
 745		return base_object_childOf_extends_taggedAs_mirroredBy_(
 746				code,
 747				Evaluator.getNil(),
 748				NATBoolean._FALSE_ /* SHARES-A link */,
 749				NATTable.EMPTY,
 750				base_defaultMirror());
 751	}
 752	
 753	/**
 754	 * The <tt>extend:with:</tt> object creation primitive.
 755	 * This construct creates a new AmbientTalk object where:
 756	 * <ul>
 757	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
 758	 *  <li>The object's <b>lexical parent</b> is the lexical scope of the argument closure. 
 759	 *  <li>The object's <b>dynamic parent</b> is the argument object.
 760	 *  <li>The object's <b>parent type</b> is <b>IS-A</b> (i.e. it is an extension of its parent).
 761	 *  <li>The object's <b>types</b> is <tt>[]</tt> (i.e. it has no types).
 762	 *  <li>The object's <b>mirror</b> is the <tt>defaultMirror</tt> on objects (i.e. it is an object
 763	 *  with a 'native' metaobject protocol).
 764	 * </ul>
 765	 * 
 766	 * Example: <code>extend: parent with: { def x := 1; }</code>
 767	 * <p>
 768	 * Pseudo-implementation:
 769	 * <pre>object: code childOf: parent extends: true taggedAs: [] mirroredBy: defaultMirror</pre>
 770	 * 
 771	 * @param parent the dynamic parent object of the newly created object.
 772	 * @param code a closure containing both the code with which to initialize the object and the new object's lexical parent
 773	 * @return a new AmbientTalk object with the properties defined above.
 774	 * @see #base_object_(ATClosure)
 775	 * @see #base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)
 776	 */
 777	public ATObject base_extend_with_(ATObject parent, ATClosure code) throws InterpreterException {
 778		return base_object_childOf_extends_taggedAs_mirroredBy_(
 779				code,
 780				parent,
 781				NATBoolean._TRUE_ /* IS-A link */,
 782				NATTable.EMPTY,
 783				base_defaultMirror());
 784	}
 785	
 786    /**
 787     * The <tt>extend:with:taggedAs:</tt> object creation primitive.
 788	 * This construct creates a new AmbientTalk object where:
 789	 * <ul>
 790	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
 791	 *  <li>The object's <b>lexical parent</b> is the lexical scope of the argument closure. 
 792	 *  <li>The object's <b>dynamic parent</b> is the argument object.
 793	 *  <li>The object's <b>parent type</b> is <b>IS-A</b> (i.e. it is an extension of its parent).
 794	 *  <li>The object's <b>types</b> are initialized to the argument types table.
 795	 *  <li>The object's <b>mirror</b> is the <tt>defaultMirror</tt> on objects (i.e. it is an object
 796	 *  with a 'native' metaobject protocol).
 797	 * </ul>
 798	 * 
 799	 * Example: <code>extend: parent with: { def x := 1; } taggedAs: [foo,bar]</code>
 800	 * <p>
 801	 * Pseudo-implementation:
 802	 * <pre>object: code childOf: parent extends: true taggedAs: types mirroredBy: defaultMirror</pre>
 803	 * 
 804	 * @param parent the dynamic parent object of the newly created object.
 805	 * @param code a closure containing both the code with which to initialize the object and the new object's lexical parent.
 806	 * @param types a table of types with which to type the newly created object.
 807	 * @return a new AmbientTalk object with the properties defined above.
 808	 * @see #base_object_(ATClosure)
 809	 * @see #base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)
 810	 */
 811	public ATObject base_extend_with_taggedAs_(ATObject parent, ATClosure code, ATTable types) throws InterpreterException {
 812		return base_object_childOf_extends_taggedAs_mirroredBy_(
 813				code,
 814				parent,
 815				NATBoolean._TRUE_ /* IS-A link */,
 816				types,
 817				base_defaultMirror());
 818	}
 819	
 820    /**
 821     * The <tt>extend:with:mirroredBy:</tt> object creation primitive.
 822	 * This construct creates a new AmbientTalk object where:
 823	 * <ul>
 824	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
 825	 *  <li>The object's <b>lexical parent</b> is the lexical scope of the argument closure. 
 826	 *  <li>The object's <b>dynamic parent</b> is the argument object.
 827	 *  <li>The object's <b>parent type</b> is <b>IS-A</b> (i.e. it is an extension of its parent).
 828	 *  <li>The object's <b>types</b> are set to <tt>[]</tt> (i.e. the object has no types).
 829	 *  <li>The object's <b>mirror</b> is the given mirror. This means that this object is a <i>mirage</i>
 830	 *  whose metaobject protocol is entirely dictated by the given mirror.
 831	 * </ul>
 832	 * 
 833	 * Example: <code>extend: parent with: { def x := 1; } mirroredBy: (mirror: {...})</code>
 834	 * <p>
 835	 * Pseudo-implementation:
 836	 * <pre>object: code childOf: parent extends: true taggedAs: [] mirroredBy: mirror</pre>
 837	 * 
 838	 * @param parent the dynamic parent object of the newly created object.
 839	 * @param code a closure containing both the code with which to initialize the object and the new object's lexical parent.
 840	 * @param mirror the mirror of the newly created mirage object.
 841	 * @return a new AmbientTalk object with the properties defined above.
 842	 * @see #base_object_(ATClosure)
 843	 * @see #base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)
 844	 */
 845	public ATObject base_extend_with_mirroredBy_(ATObject parent, ATClosure code, ATObject mirror) throws InterpreterException {
 846		return base_object_childOf_extends_taggedAs_mirroredBy_(
 847				code,
 848				parent,
 849				NATBoolean._TRUE_ /* IS-A link */,
 850				NATTable.EMPTY,
 851				mirror);
 852	}
 853	
 854    /**
 855     * The <tt>extend:with:taggedAs:mirroredBy:</tt> object creation primitive.
 856	 * This construct creates a new AmbientTalk object where:
 857	 * <ul>
 858	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
 859	 *  <li>The object's <b>lexical parent</b> is the lexical scope of the argument closure. 
 860	 *  <li>The object's <b>dynamic parent</b> is the argument object.
 861	 *  <li>The object's <b>parent type</b> is <b>IS-A</b> (i.e. it is an extension of its parent).
 862	 *  <li>The object's <b>types</b> are initialized to the argument types table.
 863	 *  <li>The object's <b>mirror</b> is the given argument mirror. This means that the newly
 864	 *  created object is a <i>mirage</i> whose metaobject protocol is dictated by the given mirror.
 865	 * </ul>
 866	 * 
 867	 * Example: <code>extend: parent with: { def x := 1; } taggedAs: [foo,bar] mirroredBy: mirror</code>
 868	 * <p>
 869	 * Pseudo-implementation:
 870	 * <pre>object: code childOf: parent extends: true taggedAs: types mirroredBy: mirror</pre>
 871	 * 
 872	 * @param parent the dynamic parent object of the newly created object.
 873	 * @param code a closure containing both the code with which to initialize the object and the new object's lexical parent.
 874	 * @param types a table of types with which to type the newly created object.
 875	 * @param the mirror object of the newly created mirage object.
 876	 * @return a new AmbientTalk object with the properties defined above.
 877	 * @see #base_object_(ATClosure)
 878	 * @see #base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)
 879	 */
 880	public ATObject base_extend_with_taggedAs_mirroredBy_(ATObject parent, ATClosure code, ATTable types, ATObject mirror) throws InterpreterException {
 881		return base_object_childOf_extends_taggedAs_mirroredBy_(
 882				code,
 883				parent,
 884				NATBoolean._TRUE_ /* IS-A link */,
 885				types,
 886				mirror);
 887	}
 888	
 889	/**
 890	 * The <tt>share:with:</tt> object creation primitive.
 891	 * This construct creates a new AmbientTalk object where:
 892	 * <ul>
 893	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
 894	 *  <li>The object's <b>lexical parent</b> is the lexical scope of the argument closure. 
 895	 *  <li>The object's <b>dynamic parent</b> is the argument object.
 896	 *  <li>The object's <b>parent type</b> is <b>SHARES-A</b> (i.e. it is not an extension of its parent).
 897	 *  <li>The object's <b>types</b> is <tt>[]</tt> (i.e. it has no types).
 898	 *  <li>The object's <b>mirror</b> is the <tt>defaultMirror</tt> on objects (i.e. it is an object
 899	 *  with a 'native' metaobject protocol).
 900	 * </ul>
 901	 * 
 902	 * Example: <code>share: parent with: { def x := 1; }</code>
 903	 * <p>
 904	 * Pseudo-implementation:
 905	 * <pre>object: code childOf: parent extends: false taggedAs: [] mirroredBy: defaultMirror</pre>
 906	 * 
 907	 * @param parent the dynamic parent object of the newly created object.
 908	 * @param code a closure containing both the code with which to initialize the object and the new object's lexical parent
 909	 * @return a new AmbientTalk object with the properties defined above.
 910	 * @see #base_object_(ATClosure)
 911	 * @see #base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)
 912	 */
 913	public ATObject base_share_with_(ATObject parent, ATClosure code) throws InterpreterException {
 914		return base_object_childOf_extends_taggedAs_mirroredBy_(
 915				code,
 916				parent,
 917				NATBoolean._FALSE_ /* SHARES-A link */,
 918				NATTable.EMPTY,
 919				base_defaultMirror());
 920	}
 921
 922    /**
 923     * The <tt>share:with:taggedAs:</tt> object creation primitive.
 924	 * This construct creates a new AmbientTalk object where:
 925	 * <ul>
 926	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
 927	 *  <li>The object's <b>lexical parent</b> is the lexical scope of the argument closure. 
 928	 *  <li>The object's <b>dynamic parent</b> is the argument object.
 929	 *  <li>The object's <b>parent type</b> is <b>SHARES-A</b> (i.e. it is not an extension of its parent).
 930	 *  <li>The object's <b>types</b> are initialized to the argument types table.
 931	 *  <li>The object's <b>mirror</b> is the <tt>defaultMirror</tt> on objects (i.e. it is an object
 932	 *  with a 'native' metaobject protocol).
 933	 * </ul>
 934	 * 
 935	 * Example: <code>share: parent with: { def x := 1; } taggedAs: [foo,bar]</code>
 936	 * <p>
 937	 * Pseudo-implementation:
 938	 * <pre>object: code childOf: parent extends: false taggedAs: types mirroredBy: defaultMirror</pre>
 939	 * 
 940	 * @param parent the dynamic parent object of the newly created object.
 941	 * @param code a closure containing both the code with which to initialize the object and the new object's lexical parent.
 942	 * @param types a table of types with which to type the newly created object.
 943	 * @return a new AmbientTalk object with the properties defined above.
 944	 * @see #base_object_(ATClosure)
 945	 * @see #base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)
 946	 */
 947	public ATObject base_share_with_taggedAs_(ATObject parent, ATClosure code, ATTable types) throws InterpreterException {
 948		return base_object_childOf_extends_taggedAs_mirroredBy_(
 949				code,
 950				parent,
 951				NATBoolean._FALSE_ /* SHARES-A link */,
 952				types,
 953				base_defaultMirror());
 954	}
 955	
 956    /**
 957     * The <tt>share:with:mirroredBy:</tt> object creation primitive.
 958	 * This construct creates a new AmbientTalk object where:
 959	 * <ul>
 960	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
 961	 *  <li>The object's <b>lexical parent</b> is the lexical scope of the argument closure. 
 962	 *  <li>The object's <b>dynamic parent</b> is the argument object.
 963	 *  <li>The object's <b>parent type</b> is <b>SHARES-A</b> (i.e. it is not an extension of its parent).
 964	 *  <li>The object's <b>types</b> are set to <tt>[]</tt> (i.e. the object has no types).
 965	 *  <li>The object's <b>mirror</b> is the given mirror. This means that this object is a <i>mirage</i>
 966	 *  whose metaobject protocol is entirely dictated by the given mirror.
 967	 * </ul>
 968	 * 
 969	 * Example: <code>share: parent with: { def x := 1; } mirroredBy: (mirror: {...})</code>
 970	 * <p>
 971	 * Pseudo-implementation:
 972	 * <pre>object: code childOf: parent extends: false taggedAs: [] mirroredBy: mirror</pre>
 973	 * 
 974	 * @param parent the dynamic parent object of the newly created object.
 975	 * @param code a closure containing both the code with which to initialize the object and the new object's lexical parent.
 976	 * @param mirror the mirror of the newly created mirage object.
 977	 * @return a new AmbientTalk object with the properties defined above.
 978	 * @see #base_object_(ATClosure)
 979	 * @see #base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)
 980	 */
 981	public ATObject base_share_with_mirroredBy_(ATObject parent, ATClosure code, ATObject mirror) throws InterpreterException {
 982		return base_object_childOf_extends_taggedAs_mirroredBy_(
 983				code,
 984				parent,
 985				NATBoolean._FALSE_ /* SHARES-A link */,
 986				NATTable.EMPTY,
 987				mirror);
 988	}
 989	
 990    /**
 991     * The <tt>share:with:taggedAs:mirroredBy:</tt> object creation primitive.
 992	 * This construct creates a new AmbientTalk object where:
 993	 * <ul>
 994	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
 995	 *  <li>The object's <b>lexical parent</b> is the lexical scope of the argument closure. 
 996	 *  <li>The object's <b>dynamic parent</b> is the argument object.
 997	 *  <li>The object's <b>parent type</b> is <b>SHARES-A</b> (i.e. it is not an extension of its parent).
 998	 *  <li>The object's <b>types</b> are initialized to the argument types table.
 999	 *  <li>The object's <b>mirror</b> is the given argument mirror. This means that the newly
1000	 *  created object is a <i>mirage</i> whose metaobject protocol is dictated by the given mirror.
1001	 * </ul>
1002	 * 
1003	 * Example: <code>share: parent with: { def x := 1; } taggedAs: [foo,bar] mirroredBy: mirror</code>
1004	 * <p>
1005	 * Pseudo-implementation:
1006	 * <pre>object: code childOf: parent extends: false taggedAs: types mirroredBy: mirror</pre>
1007	 * 
1008	 * @param parent the dynamic parent object of the newly created object.
1009	 * @param code a closure containing both the code with which to initialize the object and the new object's lexical parent.
1010	 * @param types a table of types with which to type the newly created object.
1011	 * @param mirror the mirror object of the newly created mirage object.
1012	 * @return a new AmbientTalk object with the properties defined above.
1013	 * @see #base_object_(ATClosure)
1014	 * @see #base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)
1015	 */
1016	public ATObject base_share_with_taggedAs_mirroredBy_(ATObject parent, ATClosure code, ATTable types, ATObject mirror) throws InterpreterException {
1017		return base_object_childOf_extends_taggedAs_mirroredBy_(
1018				code,
1019				parent,
1020				NATBoolean._FALSE_ /* SHARES-A link */,
1021				types,
1022				mirror);
1023	}
1024	
1025    /**
1026     * The <tt>object:taggedAs:</tt> object creation primitive.
1027	 * This construct creates a new AmbientTalk object where:
1028	 * <ul>
1029	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
1030	 *  <li>The object's <b>lexical parent</b> is the lexical scope of the argument closure. 
1031	 *  <li>The object's <b>dynamic parent</b> is <tt>nil</tt>.
1032	 *  <li>The object's <b>parent type</b> is <b>SHARES-A</b> (i.e. it is not an extension of its parent).
1033	 *  <li>The object's <b>types</b> are initialized to the argument types table.
1034	 *  <li>The object's <b>mirror</b> is <tt>defaultMirror</tt> (i.e. the object has the
1035	 *  default metaobject protocol).
1036	 * </ul>
1037	 * 
1038	 * Example: <code>object: { def x := 1; } taggedAs: [foo,bar]</code>
1039	 * <p>
1040	 * Pseudo-implementation:
1041	 * <pre>object: code childOf: nil extends: false taggedAs: types mirroredBy: defaultMirror</pre>
1042	 * 
1043	 * @param code a closure containing both the code with which to initialize the object and the new object's lexical parent.
1044	 * @param types a table of type tags with which to type the newly created object.
1045	 * @return a new AmbientTalk object with the properties defined above.
1046	 * @see #base_object_(ATClosure)
1047	 * @see #base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)
1048	 */
1049	public ATObject base_object_taggedAs_(ATClosure code, ATTable types) throws InterpreterException {
1050		return base_object_childOf_extends_taggedAs_mirroredBy_(
1051				code,
1052				Evaluator.getNil(),
1053				NATBoolean._FALSE_ /* SHARES-A link */,
1054				types,
1055				base_defaultMirror());
1056	}
1057	
1058    /**
1059     * The <tt>isolate:</tt> object creation primitive.
1060	 * This construct creates a new AmbientTalk object where:
1061	 * <ul>
1062	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
1063	 *  <li>The object's <b>lexical parent</b> is initialized to the lexical scope of the argument closure,
1064	 *  but because it is typed as an isolate, the parent link is replaced by a link to the lexical <tt>root</tt>.
1065	 *  <li>The object's <b>dynamic parent</b> is <tt>nil</tt>.
1066	 *  <li>The object's <b>parent type</b> is <b>SHARES-A</b> (i.e. it is not an extension of its parent).
1067	 *  <li>The object's <b>types</b> are initialized to <tt>[/.at.types.Isolate]</tt>, i.e.
1068	 *  the object is typed as an isolate.
1069	 *  <li>The object's <b>mirror</b> is <tt>defaultMirror</tt> (i.e. the object has the
1070	 *  default metaobject protocol).
1071	 * </ul>
1072	 * 
1073	 * Example: <code>isolate: { def x := 1; }</code>
1074	 * <p>
1075	 * Pseudo-implementation:
1076	 * <pre>object: code childOf: nil extends: false taggedAs: [/.at.types.Isolate] mirroredBy: defaultMirror</pre>
1077	 * 
1078	 * An iso

Large files files are truncated, but you can click here to view the full file