PageRenderTime 48ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/interpreter/tags/at2dist091109/src/edu/vub/at/objects/ATObject.java

http://ambienttalk.googlecode.com/
Java | 1057 lines | 69 code | 62 blank | 926 comment | 0 complexity | 97e3d39e2b8690822df7304796093f38 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.0, LGPL-2.1
  1. /**
  2. * AmbientTalk/2 Project
  3. * ATObject.java created on 13-jul-2006 at 15:33:42
  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. */
  28. package edu.vub.at.objects;
  29. import edu.vub.at.actors.ATAsyncMessage;
  30. import edu.vub.at.exceptions.InterpreterException;
  31. import edu.vub.at.exceptions.XArityMismatch;
  32. import edu.vub.at.exceptions.XDuplicateSlot;
  33. import edu.vub.at.exceptions.XIllegalQuote;
  34. import edu.vub.at.exceptions.XIllegalUnquote;
  35. import edu.vub.at.exceptions.XObjectOffline;
  36. import edu.vub.at.exceptions.XSelectorNotFound;
  37. import edu.vub.at.exceptions.XUnassignableField;
  38. import edu.vub.at.exceptions.XUndefinedSlot;
  39. import edu.vub.at.objects.coercion.ATConversions;
  40. import edu.vub.at.objects.grammar.ATAssignmentSymbol;
  41. import edu.vub.at.objects.grammar.ATSymbol;
  42. import edu.vub.at.objects.mirrors.NATMirage;
  43. import edu.vub.at.objects.mirrors.NATMirrorRoot;
  44. import edu.vub.at.objects.natives.NATCallframe;
  45. import edu.vub.at.objects.natives.NATObject;
  46. import edu.vub.at.objects.natives.NATText;
  47. import edu.vub.at.objects.natives.NativeATObject;
  48. import edu.vub.at.objects.symbiosis.JavaClass;
  49. import edu.vub.at.objects.symbiosis.JavaObject;
  50. /**
  51. * ATObject represents the public interface common to any AmbientTalk/2 object.
  52. * Any value representing an ambienttalk object should implement this interface.
  53. *
  54. * More specifically, this interface actually defines two interfaces all at once:
  55. * <ul>
  56. * <li>A <b>base-level</b> interface to AmbientTalk objects, describing all
  57. * methods and fields that a regular AmbientTalk object understands.
  58. * <li>A <b>meta-level</b> interface to AmbientTalk objects, describing all
  59. * methods and fields that the <b>mirror</b> on any AmbientTalk object
  60. * understands.
  61. * </ul>
  62. *
  63. * In the AmbientTalk/2 Interpreter implementation, there are only a few classes
  64. * that (almost) fully implement this interface. The principal implementors are:
  65. *
  66. * <ul>
  67. * <li>{@link NativeATObject}: provides a default implementation for all <i>native</i> data types.
  68. * For example, native methods, closures, abstract grammar nodes, booleans, numbers, etc.
  69. * are all represented as AmbientTalk objects with 'native' behaviour.
  70. * <li>{@link NATCallframe}: overrides most of the default behaviour of {@link NativeATObject} to
  71. * implement the behaviour of call frames, also known as <i>activation records</i>. In
  72. * AmbientTalk, call frames are the objects that together define the runtime stack.
  73. * They are objects with support for fields but without support for actual methods.
  74. * <li>{@link NATObject}: extends the behaviour of call frames to include support for
  75. * full-fledged, programmer-defined objects with support for methods and delegation.
  76. * <li>{@link JavaClass} and {@link JavaObject}: adapt the behaviour of native AmbientTalk
  77. * objects to engage in symbiosis with either a Java class or a Java object.
  78. * This implementation makes use of the Java Reflection API to regard Java objects
  79. * as though it were AmbientTalk objects.
  80. * <li>{@link NATMirage} and {@link NATMirrorRoot}: these two classes work in tandem to
  81. * enable reflection on AmbientTalk objects. That is, because of these two classes, an
  82. * AmbientTalk programmer can himself invoke the methods provided in this interface.
  83. * {@link NATMirage} implements each operation in this interface by forwarding a
  84. * downed invocation to a custom so-called <i>mirror</i> object. This mirror object
  85. * can delegate to {@link NATMirrorRoot}, which is a special object that implements
  86. * each meta-level operation of this interface as a base-level operation. Hence, in
  87. * a sense, {@link NATMirrorRoot} also 'implements' this interface, but at the
  88. * AmbientTalk level, rather than at the Java level.
  89. * </ul>
  90. *
  91. * @author tvcutsem
  92. */
  93. public interface ATObject extends ATConversions {
  94. /* ------------------------------
  95. * -- Message Sending Protocol --
  96. * ------------------------------ */
  97. /**
  98. * This behavioural meta-level operation reifies the act of sending
  99. * an asynchronous message.
  100. *
  101. * When the base-level AmbientTalk code <code>rcv<-m()</code> is
  102. * evaluated in the context of an object <tt>o</tt>, an asynchronous message
  103. * <code><-m()</code> is first created by the current actor mirror.
  104. * Subsequently, this message needs to be sent to the receiver. This
  105. * meta-level operation is reified by this method, as if by invoking:
  106. * <pre>(reflect: o).send(message)</pre>
  107. * The default behaviour is to access the current actor's mirror and to
  108. * ask the actor to send the message in this object's stead by invoking
  109. * <pre>actor.send(message)</pre>
  110. * @param receiver the object designated to receive the asynchronous message
  111. * @param message the asynchronous message to be sent by this object
  112. *
  113. * @return the result of message sending, which will be the value of an
  114. * asynchronous message send expression.
  115. */
  116. public ATObject meta_send(ATObject receiver, ATAsyncMessage message) throws InterpreterException;
  117. /**
  118. * This behavioural meta-level operation reifies the act of receiving
  119. * an asynchronous message.
  120. *
  121. * When an asynchronous message is sent to an AmbientTalk object, its mirror
  122. * is notified of this event by the invocation of this method. The method
  123. * is invoked in the same execution turn as the turn in which the message
  124. * is sent. This allows the receiver (e.g. a custom eventual reference proxy)
  125. * to intervene in the message sending process and return a value different
  126. * than the default <tt>nil</tt> value.
  127. * <p>
  128. * The default behaviour of a mirror on a local reference in response to
  129. * the reception of an async
  130. * message is to schedule this message for execution in a later turn
  131. * in its owner's message queue. The actor will then later process
  132. * the message by invoking
  133. * <pre>msg.process(self)</pre>
  134. * In turn, the default message processing behaviour is to invoke
  135. * the method corresponding to the message's selector on this object.
  136. * Hence, usually a <tt>receive</tt> operation is translated into
  137. * a <tt>invoke</tt> operation in a later turn. The reason for having a
  138. * separate <tt>receive</tt>
  139. * operation is that this enables the AmbientTalk meta-level programmer to
  140. * distinguish between synchronously and asynchronously received messages.
  141. *
  142. * Far references react to <tt>receive</tt> by transmitting their message
  143. * to their remote target.
  144. *
  145. * @param message the message that was asynchronously sent to this object
  146. * @return <tt>nil</tt>, by default
  147. */
  148. public ATObject meta_receive(ATAsyncMessage message) throws InterpreterException;
  149. /**
  150. * This meta-level operation reifies synchronous message sending ("method invocation").
  151. * Hence, the meta-level equivalent
  152. * of the base-level code <code>o.m()</code> is:
  153. * <pre>(reflect: o).invoke(o,`m,[])</pre>.
  154. *
  155. * Method invocation comprises selector lookup and the application of the value
  156. * bound to the selector. Selector lookup first queries an object's local
  157. * fields, then the method dictionary:
  158. * <ul>
  159. * <li>If the selector ends with <tt>:=</tt> and matches a field, the field
  160. * is assigned if a unary argument list is specified (i.e. the field is treated
  161. * as a mutator method).
  162. * <li>Otherwise, if the selector is bound to a field containing
  163. * a closure, that closure is applied to the given arguments.
  164. * <li>If the field is not bound to a closure, the field value is returned provided no arguments were
  165. * specified (i.e. the field is treated like an accessor method).
  166. * <li>If the selector is bound to a method, the method is applied.
  167. * <li>If the selector is not found, the search continues in the objects <i>dynamic parent</i>.
  168. * </ul>
  169. * <p>
  170. * Note also that the first argument to <tt>invoke</tt> denotes the
  171. * so-called "receiver" of the invocation. It is this object to which
  172. * the <tt>self</tt> pseudo-variable should be bound during method execution.
  173. *
  174. * @see #meta_doesNotUnderstand(ATSymbol) for what happens if the selector
  175. * is not found.
  176. *
  177. * @param delegate the object to which <tt>self</tt> is bound during execution
  178. * of the method
  179. * @param invocation an object encapsulating at least the invocation's
  180. * <tt>selector</tt> (a {@link ATSymbol}) and <tt>arguments</tt> (a {@link ATTable}).
  181. * @return by default, the object returned from the invoked method
  182. */
  183. public ATObject meta_invoke(ATObject delegate, ATMethodInvocation invocation) throws InterpreterException;
  184. /**
  185. * This meta-level operation reifies "field selection".
  186. * In other words, the base-level code
  187. * <code>o.m</code>
  188. * is interpreted at the meta-level as:
  189. * <code>(reflect: o).invokeField(o, `m)</code>
  190. *
  191. * This meta-level operation is nearly identical to {@link #meta_invoke(ATObject, ATMethodInvocation)} with one
  192. * important difference. When the selector is bound to a field storing a closure, this meta-level operation
  193. * does <b>not</b> auto-apply the closure, but returns the closure instead.
  194. *
  195. * For all other cases, the following equality holds:
  196. * <code>o.m == o.m()</code>
  197. * or, at the meta-level:
  198. * <code>(reflect: o).invokeField(o, `m) == (reflect: o).invoke(o, MethodInvocation.new(`m, []))</code>
  199. *
  200. * This effectively means that for client objects, it should not matter whether
  201. * a property is implemented as a field or as a pair of accessor/mutator methods.
  202. *
  203. * @param receiver the base-level object from which the 'field' should be selected.
  204. * @param selector a symbol denoting the name of the method, accessor or mutator to be invoked
  205. * @return the value of a field, or the return value of a nullary method.
  206. */
  207. public ATObject meta_invokeField(ATObject receiver, ATSymbol selector) throws InterpreterException;
  208. /**
  209. * This meta-level method is used to determine whether an object has a
  210. * field or method corresponding to the given selector, without actually invoking
  211. * or selecting any value associated with that selector.
  212. * <p>
  213. * The lookup process is the same as that for the <tt>invoke</tt> operation (i.e.
  214. * not only the object's own fields and methods are searched, but also those of
  215. * its dynamic parents).
  216. *
  217. * @param selector a symbol denoting the name of a field (accessor or mutator) or method
  218. * @return a boolean denoting whether the object responds to <tt>o.selector</tt>
  219. */
  220. public ATBoolean meta_respondsTo(ATSymbol selector) throws InterpreterException;
  221. /**
  222. * This behavioural meta-level operation reifies a failed dynamic method or field lookup.
  223. *
  224. * When method invocation or field selection fails to find the selector in
  225. * the dynamic parent chain of an object, rather than immediately raising an
  226. * {@link XSelectorNotFound} exception, the mirror of the original receiver
  227. * of the method invocation or field selection is asked to handle failed lookup.
  228. * <p>
  229. * The default behaviour of <tt>doesNotUnderstand</tt> is to raise an
  230. * {@link XSelectorNotFound} exception.
  231. * <p>
  232. * This method is very reminiscent of Smalltalk's well-known
  233. * <tt>doesNotUnderstand:</tt> and of Ruby's <tt>method_missing</tt> methods.
  234. * There are, however, two important differences:
  235. * <ul>
  236. * <li> <tt>doesNotUnderstand</tt> is a <b>meta</b>-level operation in AmbientTalk.
  237. * It is an operation defined on mirrors, not on regular objects.
  238. * <li> <tt>doesNotUnderstand</tt> in AmbientTalk relates to <i>attribute
  239. * selection</i>, not to <i>method invocation</i>. Hence, this operation is
  240. * more general in AmbientTalk than in Smalltalk: it intercepts both failed
  241. * method invocations as well as failed field selections. Hence, it can be used
  242. * to model "virtual" fields. This shows in the interface: this operation
  243. * does not consume the actual arguments of a failed method invocation. Moreover,
  244. * a closure should be returned which can subsequently be applied for failed invocations.
  245. * Failed selections can simply return this closure without application. Hence, arguments
  246. * should be consumed by means of currying, e.g. by making <tt>doesNotUnderstand</tt>
  247. * return a block which can then take the arguments table as its sole parameter.
  248. * </ul>
  249. *
  250. * @param selector a symbol denoting the name of a method or field that could not be found
  251. * @return by default, this operation does not return a value, but raises an exception instead.
  252. * @throws edu.vub.at.exceptions.XSelectorNotFound the default reaction to a failed selection
  253. */
  254. public ATClosure meta_doesNotUnderstand(ATSymbol selector) throws InterpreterException;
  255. /* -----------------------------
  256. * -- Object Passing protocol --
  257. * ----------------------------- */
  258. /**
  259. * This behavioural meta-level operation reifies object serialization.
  260. *
  261. * When an AmbientTalk object crosses actor boundaries, e.g. by means of
  262. * parameter passing, as a return value or because it was explicitly
  263. * exported, this meta-level operation is invoked on the object's mirror.
  264. * <p>
  265. * This operation allows objects to specify themselves how they should
  266. * be parameter-passed during inter-actor communication. The interpreter
  267. * will never pass an object to another actor directly, but instead always
  268. * parameter-passes the <i>return value</i> of invoing <tt>pass()</tt> on
  269. * the object's mirror.
  270. * <p>
  271. * Mirrors on by-copy objects implement <tt>pass</tt> as follows:
  272. * <pre>def pass() { base }</pre>
  273. * Mirrors on by-reference objects implement <tt>pass</tt> by returning
  274. * a far reference to their base-level object.
  275. *
  276. * @return the object to be parameter-passed instead of this object. For objects,
  277. * the default is a far reference to themselves. For isolates, the default is
  278. * to return themselves.
  279. */
  280. public ATObject meta_pass() throws InterpreterException;
  281. /**
  282. * This behavioural meta-level operation reifies object deserialization.
  283. *
  284. * When an AmbientTalk object has just crossed an actor boundary (e.g.
  285. * because of inter-actor message sending) this meta-level operation
  286. * is invoked on the object's mirror.
  287. * <p>
  288. * This meta-level operation gives objects a chance to tell the interpreter
  289. * which object they actually represent, because the object retained
  290. * after parameter passing is the return value of the <tt>resolve</tt>
  291. * operation.
  292. * <p>
  293. * Mirrors on by-copy objects, like isolates, implement <tt>resolve</tt> as follows:
  294. * <pre>def resolve() { base }</pre>
  295. * In other words, by-copy objects represent themselves. By-reference objects
  296. * are paremeter passed as far references. Mirrors on far references implement
  297. * <tt>resolve</tt> by trying to resolve the far reference into a local, regular
  298. * object reference (which is possible if the object they point to is located
  299. * in the actor in which they just arrived). If it is not possible to resolve
  300. * a far reference into a local object, the far reference remains a far reference.
  301. * <p>
  302. * Note that for isolates, this operation also ensures that the isolate's
  303. * lexical scope is rebound to the lexical root of the recipient actor.
  304. *
  305. * @return the object represented by this object
  306. * @throws XObjectOffline if a far reference to a local object can no longer be resolved
  307. * because the object has been taken offline
  308. */
  309. public ATObject meta_resolve() throws InterpreterException;
  310. /* ------------------------------------------
  311. * -- Slot accessing and mutating protocol --
  312. * ------------------------------------------ */
  313. /**
  314. * This meta-level operation reifies first-class field or method selection. Hence, the
  315. * base-level evaluation of <code>o.&x</code> is interpreted at the meta-level as:
  316. * <pre>(reflect: o).select(o, `x)</pre>
  317. *
  318. * The selector lookup follows the same search rules as those for <tt>invoke</tt>.
  319. * That is: first an object's local fields and method dictionary are searched,
  320. * and only then the object's <i>dynamic parent</i>.
  321. * <p>
  322. * The <tt>select</tt> operation can be used to both select fields or methods from
  323. * an object. When the selector is bound to a method, the return value of
  324. * <tt>select</tt> is a closure that wraps the found method in the object in which
  325. * the method was found. This ensures that the method retains its context information,
  326. * such as the lexical scope in which it was defined and the value of <tt>self</tt>, which
  327. * will be bound to the original receiver, i.e. the first argument of <tt>select</tt>.
  328. * <p>
  329. * If the selector matches a field, an accessor is returned. If the selector ends with
  330. * <tt>:=</tt>, a mutator is returned instead. An accessor is a nullary closure which upon
  331. * application yields the field's value. A mutator is a unary closure which upon
  332. * application assigns the field to the specified value.
  333. * Even for fields already bound to a closure, selecting the field returns an accessor
  334. * closure, not the bound closure itself.
  335. *
  336. * @see #meta_doesNotUnderstand(ATSymbol) for what happens if the selector is not found.
  337. *
  338. * @param receiver the dynamic receiver of the selection. If the result of the selection is
  339. * a method, the closure wrapping the method will bind <tt>self</tt> to this object.
  340. * @param selector a symbol denoting the name of the field or method to select.
  341. * @return if selector is bound to a field, an accessor or mutator for the field; otherwise if
  342. * the selector is bound to a method, a closure wrapping the method.
  343. */
  344. public ATClosure meta_select(ATObject receiver, ATSymbol selector) throws InterpreterException;
  345. /**
  346. * This meta-level operation reifies field definition. Hence, the base-level
  347. * code <code>def x := v</code> evaluated in a lexical scope <tt>lex</tt>
  348. * is interpreted at the meta-level as:
  349. * <pre>(reflect: lex).defineField(`x, v)</pre>
  350. *
  351. * Invoking this meta-level operation on an object's mirror adds a new field
  352. * to that object. An object cannot contain two or more fields with the
  353. * same name.
  354. *
  355. * @param name a symbol denoting the name of the new field
  356. * @param value the value of the new field
  357. * @return nil
  358. * @throws edu.vub.at.exceptions.XDuplicateSlot if the object already has a
  359. * local field with the given name
  360. */
  361. public ATNil meta_defineField(ATSymbol name, ATObject value) throws InterpreterException;
  362. /* -----------------------------------------
  363. * -- Cloning and instantiation protocol --
  364. * ---------------------------------------- */
  365. /**
  366. * This meta-level operation reifies the act of cloning the base-level object.
  367. * Hence, the code <code>clone: o</code> is interpreted at the meta-level as
  368. * <pre>(reflect: o).clone()</pre>
  369. *
  370. * AmbientTalk's default cloning semantics are based on shallow copying.
  371. * A cloned object has copies of the original object's fields, but the values
  372. * of the fields are shared between the clones. A clone has the same methods
  373. * as the original object. Methods added at a later stage to the original
  374. * will not affect the clone's methods and vice versa. This means that each
  375. * objects has its own independent fields and methods.
  376. * <p>
  377. * If the cloned AmbientTalk object contains programmer-defined field objects,
  378. * each of these fields is re-instantiated with the clone as a parameter. The
  379. * clone is intialized with the re-instantiated fields rather than with the
  380. * fields of the original object. This property helps to ensure that each
  381. * object has its own independent fields.
  382. * <p>
  383. * If the object has a <i>shares-a</i> relationship with its parent, the object
  384. * and its clone will <b>share</b> the same parent object. Shares-a relationships
  385. * are the default in AmbientTalk, and they match with the semantics of
  386. * shallow copying: the dynamic parent of an object is a regular field, hence
  387. * its contents is shallow-copied.
  388. * <p>
  389. * If the object has an <i>is-a</i> relationship with its parent object, a
  390. * clone of the object will receive a clone of the parent object as its parent.
  391. * Hence, is-a relationships "override" the default shallow copying semantics
  392. * and recursively clone the parent of an object up to a shares-a relationship.
  393. * <p>
  394. * If a mirage is cloned, its mirror is automatically re-instantiated with
  395. * the new mirage, to ensure that each mirage has its independent mirror.
  396. * @return a clone of the mirror's <tt>base</tt> object
  397. */
  398. public ATObject meta_clone() throws InterpreterException;
  399. /**
  400. * This meta-level operation reifies instance creation. The default
  401. * implementation of an AmbientTalk object's <tt>new</tt> method is:
  402. * <pre>def new(@initargs) { (reflect: self).newInstance(initargs) }</pre>
  403. *
  404. * Creating a new instance of an object is a combination of:
  405. * <ul>
  406. * <li>creating a clone of the object
  407. * <li>initializing the clone by invoking its <tt>init</tt> method
  408. * </ul>
  409. *
  410. * The default implementation is:
  411. * <pre>def newInstance(initargs) {
  412. * def instance := self.clone();
  413. * instance.init(@initargs);
  414. * instance;
  415. *}
  416. * </pre>
  417. *
  418. * Instance creation in AmbientTalk is designed to mimick class instantiation
  419. * in a class-based language. Instantiating a class <tt>c</tt> requires <i>allocating</i>
  420. * a new instance <tt>i</tt> and then invoking the <i>constructor</i> on that
  421. * new instance. In AmbientTalk, class allocation is replaced by object
  422. * <i>cloning</i>. The benefit is that an instantiated object its variables are
  423. * already initialized to useful values, being those of the object from which
  424. * it is instantiated. The <tt>init</tt> method plays the role of "constructor"
  425. * in AmbientTalk.
  426. *
  427. * @param initargs a table denoting the actual arguments to be passed to
  428. * the <tt>init</tt> method
  429. * @return the new instance
  430. */
  431. public ATObject meta_newInstance(ATTable initargs) throws InterpreterException;
  432. /* ---------------------------------
  433. * -- Structural Access Protocol --
  434. * --------------------------------- */
  435. /**
  436. * This structural meta-level operation adds a field object to the receiver mirror's
  437. * base object. An object cannot contain two or more fields with the same name.
  438. *
  439. * Note that the field object passed as an argument serves as a <i>prototype</i>
  440. * object: the actual field object added is an <i>instance</i> of the passed field object.
  441. * A field object should always have an <tt>init</tt> method that takes as an argument
  442. * the new host object to which it is added. This is often useful, as the behaviour
  443. * of a field may depend on the object in which it resides. Because <tt>addField</tt>
  444. * creates a new instance of the field, this gives the field object a chance to
  445. * properly refer to its new host.
  446. * <p>
  447. * As an example, here is how to add a read-only field <tt>foo</tt> initialized
  448. * to <tt>5</tt> to an object <tt>obj</tt>:
  449. * <pre>def makeConstantField(nam, val) {
  450. * object: {
  451. * def new(newHost) { self }; // singleton pattern
  452. * def name := nam;
  453. * def readField() { val };
  454. * def writeField(newVal) { nil };
  455. * def accessor() { (&readField).method };
  456. * def mutator() { (&writeField).method };
  457. * } taggedAs: [/.at.types.Field]
  458. * };
  459. * (reflect: obj).addField(makeConstantField(`foo, 5));
  460. * </pre>
  461. *
  462. * @param field the prototype field object whose instance should be added
  463. * to the receiver's base object
  464. * @return nil
  465. * @throws XDuplicateSlot if the base object already has a field with the
  466. * same name as the new field
  467. */
  468. public ATNil meta_addField(ATField field) throws InterpreterException;
  469. /**
  470. * This structural meta-level operation adds a method to the receiver
  471. * mirror's base object. An object cannot contain two or more methods
  472. * with the same name.
  473. *
  474. * @param method a method object to add to the receiver's base object's
  475. * method dictionary.
  476. * @return nil
  477. * @throws XDuplicateSlot if a method with the new method's selector already
  478. * exists in the base object.
  479. */
  480. public ATNil meta_addMethod(ATMethod method) throws InterpreterException;
  481. /**
  482. * This structural meta-level operation allows the metaprogrammer to reify a
  483. * field of the receiver mirror's base object. Hence, unlike <tt>select</tt>
  484. * and <tt>lookup</tt>, <tt>grabField</tt> returns a <i>field object</i> rather
  485. * than the <i>value</i> bound to the field. For example: one could express
  486. * <code>obj.super := val</code> at the meta-level as:
  487. *
  488. * <pre>
  489. * def superField := (reflect: obj).grabField(`super);
  490. * superField.writeField(val);
  491. * </pre>
  492. *
  493. * Another important difference between <tt>select</tt>, <tt>lookup</tt> and
  494. * <tt>grabField</tt> is that <tt>grabField</tt> only considers the fields
  495. * <i>local</i> to the receiver's base object. Fields of lexical or dynamic
  496. * parent objects are <i>not</i> considered.
  497. *
  498. * @param selector a symbol representing the name of the field to select.
  499. * @return a mirror on this object's field slot.
  500. * @throws XUndefinedSlot if the field cannot be found within the receiver's
  501. * base object.
  502. */
  503. public ATField meta_grabField(ATSymbol selector) throws InterpreterException;
  504. /**
  505. * This structural meta-level operation allows the metaprogrammer to
  506. * reify a method defined on the receiver mirror's base object. Note that,
  507. * unlike the <tt>select</tt> or <tt>lookup</tt> operations, <tt>grabMethod</tt>
  508. * returns the bare method object, i.e. <i>not</i> a closure wrapping the method.
  509. * <p>
  510. * Also, unlike <tt>select</tt> and <tt>lookup</tt>, <tt>grabField</tt> only
  511. * considers the locally defined methods of an object, methods of lexical or
  512. * dynamic parent objects are <i>not</i> considered.
  513. *
  514. * @param selector a symbol representing the name of the method to grab from
  515. * the receiver's base object.
  516. * @return the bare method object bound to the given selector.
  517. * @throws XSelectorNotFound if the method object cannot be found within the
  518. * receiver's base object.
  519. */
  520. public ATMethod meta_grabMethod(ATSymbol selector) throws InterpreterException;
  521. /**
  522. * This structural meta-level operation allows access to all of the
  523. * fields defined on the receiver mirror's base object. Note that
  524. * this method only returns the base object's <i>locally</i> defined
  525. * fields. Fields from parent objects are not returned.
  526. *
  527. * @see ATObject#meta_grabField(ATSymbol) for details about the returned
  528. * field objects.
  529. * @return a table of field objects (of type {@link ATField}).
  530. */
  531. public ATTable meta_listFields() throws InterpreterException;
  532. /**
  533. * This structural meta-level operation allows access to all of the
  534. * methods defined on the receiver mirror's base object. Note that
  535. * this method only returns the base object's <i>locally</i> defined
  536. * methods. Methods from parent objects are not returned.
  537. *
  538. * @see ATObject#meta_grabMethod(ATSymbol) for details about the returned
  539. * method objects.
  540. * @return a table of method objects (of type {@link ATMethod}).
  541. */
  542. public ATTable meta_listMethods() throws InterpreterException;
  543. /**
  544. * This structural meta-level operation adds a slot object to the receiver mirror's
  545. * base object. An object cannot contain two or more slots with the same name.
  546. *
  547. * A slot is either a method or a closure. A closure serves to encapsulate access to
  548. * or mutation of a field.
  549. *
  550. * Care must be taken with closures when the object to which they are added is
  551. * cloned or instantiated: the closure will be shared between clones!
  552. * <p>
  553. * As an example, here is how to add a read-only field <tt>foo</tt> initialized
  554. * to <tt>5</tt> to an object <tt>obj</tt>:
  555. * <pre>
  556. * def [accessor,mutator] := /.at.lang.values.createFieldSlot(`foo, 5);
  557. * (reflect: obj).addSlot(accessor);
  558. * </pre>
  559. *
  560. * @param slot the method representing the slot to be added
  561. * to the receiver's base object
  562. * @return nil
  563. * @throws XDuplicateSlot if the base object already has a slot with the
  564. * same name as the new slot
  565. */
  566. public ATNil meta_addSlot(ATMethod slot) throws InterpreterException;
  567. /**
  568. * This structural meta-level operation allows the metaprogrammer to reify a
  569. * slot of the receiver mirror's base object. Hence, unlike <tt>select</tt>
  570. * and <tt>lookup</tt>, <tt>grabSlot</tt> returns a <i>slot object</i> rather
  571. * than the <i>value</i> bound to the slot. For example: one could express
  572. * <code>obj.super := val</code> at the meta-level as:
  573. *
  574. * <pre>
  575. * def superMutator := (reflect: obj).grabSlot(`super:=);
  576. * superMutator(val);
  577. * </pre>
  578. *
  579. * Another important difference between <tt>select</tt>, <tt>lookup</tt> and
  580. * <tt>grabSlot</tt> is that <tt>grabSlot</tt> only considers the slots
  581. * <i>local</i> to the receiver's base object. Slots of lexical or dynamic
  582. * parent objects are <i>not</i> considered.
  583. *
  584. * @param selector a symbol representing the name of the slot to select.
  585. * @return a method representing the selected slot.
  586. * @throws XUndefinedSlot if the field cannot be found within the receiver's
  587. * base object.
  588. */
  589. public ATMethod meta_grabSlot(ATSymbol selector) throws InterpreterException;
  590. /**
  591. * This structural meta-level operation allows access to all of the
  592. * slots defined on the receiver mirror's base object. Note that
  593. * this method only returns the base object's <i>locally</i> defined
  594. * slots. Slots from parent objects are not returned.
  595. *
  596. * @see ATObject#meta_grabSlot(ATSymbol) for details about the returned
  597. * slot objects.
  598. * @return a table of slot objects (of type {@link ATMethod}).
  599. */
  600. public ATTable meta_listSlots() throws InterpreterException;
  601. /**
  602. * This structural meta-level operation removes a slot from the
  603. * object. Note that this method only removes slots that are
  604. * <i>locally</i> defined in the object.
  605. *
  606. * @param selector the name of the slot to remove
  607. * @return the value to which the slot was previously bound
  608. * (e.g. a value or a method object)
  609. * @throws XSelectorNotFound if no slot with the given name is found in the object
  610. */
  611. public ATObject meta_removeSlot(ATSymbol selector) throws InterpreterException;
  612. /**
  613. * This structural meta-level operation returns whether or not
  614. * the receiver mirror's base object is an <i>extension</i> of its
  615. * parent object.
  616. * <p>
  617. * In AmbientTalk, all objects are part of a dynamic parent delegation chain:
  618. * each object has a <tt>super</tt> field that denotes the object to which to
  619. * delegate messages the object cannot understand itself. There are, however,
  620. * two kinds of delegation links:
  621. * <ul>
  622. * <li><b>IS-A</b> links: this kind of link denotes that the child object is
  623. * a true extension of its parent, and cannot meaningfully exist without the
  624. * parent's state. When the child is cloned, its parent will be cloned as well.
  625. * <li><b>SHARES-A</b> links: this kind of link denotes that the child object
  626. * simply delegates to its parent for purposes of sharing or code reuse. The
  627. * child can meaningfully exist without the parent's state. When the child is
  628. * cloned, the clone will delegate to the same parent.
  629. * </ul>
  630. *
  631. * Examples:
  632. * <pre>(reflect: (extend: parent with: code)).isExtensionOfParent() => true
  633. *(reflect: (share: parent with: code)).isExtensionOfParent() => false
  634. * </pre>
  635. *
  636. * Note that accessing the dynamic parent itself is not a meta-level operation,
  637. * the dynamic parent can simply be accessed from the base level by performing
  638. * <code>obj.super</code>.
  639. *
  640. * @return whether the base object extends its parent object via an
  641. * <b>IS-A</b> link or not.
  642. */
  643. public ATBoolean meta_isExtensionOfParent() throws InterpreterException;
  644. /* ------------------------------------------
  645. * -- Abstract Grammar evaluation protocol --
  646. * ------------------------------------------ */
  647. /**
  648. * This behavioural meta-level operation reifies the evaluation of
  649. * abstract grammar objects into values. For objects, this operation
  650. * returns the base object itself, signifying that the evaluation
  651. * function defined on objects is the identity function. In other words,
  652. * objects are <i>self-evaluating</i>. Parse tree objects (first-class
  653. * abstract grammar elements), however, have dedicated evaluation
  654. * functions. For example, evaluating <code>x</code> is equivalent to
  655. * evaluating <code>(reflect: `x).eval(ctx)</code> where <tt>ctx</tt>
  656. * is a reification of the current evaluation context.
  657. *
  658. * @param ctx a context object that stores the current lexical scope and
  659. * the current value of <tt>self</tt>
  660. * @return the value of the abstract grammar element denoted by this mirror's
  661. * base object.
  662. * @throws XIllegalUnquote if an unquote abstract grammar element is evaluated. Such
  663. * abstract grammar elements should only be encountered in a quoted parse tree.
  664. */
  665. public ATObject meta_eval(ATContext ctx) throws InterpreterException;
  666. /**
  667. * This behavioural meta-level operation reifies the quotation of
  668. * abstract grammar elements. Regular objects simply return themselves
  669. * upon quotation. When an abstract grammar element is quoted, rather
  670. * than tree-recursively invoking <tt>eval</tt> on the parse trees,
  671. * <tt>quote</tt> is tree-recursively invoked. When encountering
  672. * an unquote, <tt>eval</tt> is again invoked on the unquoted subtree,
  673. * with the context passed as an argument to <tt>quote</tt>.
  674. *
  675. * @param ctx a context object passed on to be used in subsequent evaluations.
  676. * @throws XIllegalQuote exception whenever an unquote-splice unquotation is discovered
  677. * in an Abstract Grammar node where the resulting table cannot be spliced.
  678. */
  679. public ATObject meta_quote(ATContext ctx) throws InterpreterException;
  680. /**
  681. * This behavioural meta-level operation reifies the act of printing
  682. * the base object in the read-eval-print loop. This operation may be
  683. * overridden by mirrors to customise the printed representation of
  684. * their base object.
  685. *
  686. * @return a text value denoting a human-readable representation of the object.
  687. */
  688. public NATText meta_print() throws InterpreterException;
  689. /* ----------------------------------
  690. * -- Object Relational Comparison --
  691. * ---------------------------------- */
  692. /**
  693. * This meta-level operation determines whether this mirror's base object
  694. * is related to the parameter object by a combination of cloning and
  695. * extension operators. The default implementation is:
  696. *
  697. * <pre>def isRelatedTo(object) {
  698. * self.isCloneOf(object).or: { (reflect: base.super).isRelatedTo(object) }
  699. *}</pre>
  700. *
  701. * @param object the object to compare this mirror's base object to
  702. * @return true if the given object is a clone of the base object or a clone
  703. * of the base object's parents.
  704. */
  705. public ATBoolean meta_isRelatedTo(ATObject object) throws InterpreterException;
  706. /**
  707. * This meta-level operation determines whether this mirror's base object
  708. * is a clone of the parameter object. The <i>is-clone-of</i> relation is transitive,
  709. * so if <tt>martin</tt> is a clone of <tt>sally</tt> and <tt>sally</tt> is a clone of
  710. * <tt>dolly</tt>, then <tt>martin</tt> is a clone of <tt>dolly</tt> as well.
  711. * The relation is reflexive: <tt>dolly</tt> is a clone of itself.
  712. * The relation is symmetric: <tt>dolly</tt> is also a clone of <tt>sally</tt>.
  713. *
  714. * @param other the object to check the is-clone-of relationship with.
  715. * @return true if the base object and the parameter object are clones (i.e. one
  716. * was created by cloning the other), false otherwise.
  717. */
  718. public ATBoolean meta_isCloneOf(ATObject other) throws InterpreterException;
  719. /* ---------------------------------
  720. * -- Type Testing and Querying --
  721. * --------------------------------- */
  722. /**
  723. * Tests whether the receiver mirror's base object is tagged as a particular type.
  724. *
  725. * The default implementation first compares the object's local type tags to the given type
  726. * by means of the {@link ATTypeTag#base_isSubtypeOf(ATTypeTag)} method. If no local type
  727. * is found, the test is applied recursively on this object's dynamic parent. In code:
  728. * <pre>def isTaggedAs(type) {
  729. * (nil != (self.tagsOf: object).find: { |localType|
  730. * localType.isSubtypeOf(type)
  731. * }).or: { (reflect: base.super).isTaggedAs(type) }
  732. * };
  733. * </pre>
  734. *
  735. * The primitive method <tt>is: obj taggedAs: type</tt> is defined in terms of this
  736. * method:
  737. * <pre>
  738. * def is: obj taggedAs: type {
  739. * (reflect: obj).isTaggedAs(type)
  740. *};
  741. * </pre>
  742. *
  743. * @param type the type tag object to check for
  744. * @return true if this mirror's base object or one of its parent objects is tagged
  745. * with a subtype of the given type, false otherwise.
  746. */
  747. public ATBoolean meta_isTaggedAs(ATTypeTag type) throws InterpreterException;
  748. /**
  749. * Returns all of the local type tags of this object. The primitive method
  750. * <tt>tagsOf: obj</tt> is defined in terms of this method:
  751. *
  752. * <pre>
  753. * def tagsOf: obj {
  754. * (reflect: obj).typeTags
  755. *};
  756. * </pre>
  757. *
  758. * @return a table of the type tags that were attached directly to this mirror's base
  759. * object. The type tags of its parent objects are not returned.
  760. */
  761. public ATTable meta_typeTags() throws InterpreterException;
  762. /* -------------------------------
  763. * - Base Level Object interface -
  764. * ------------------------------- */
  765. /**
  766. * Bound to the dynamic parent of this object.
  767. *
  768. * The dynamic parent of an object is the object to which failed
  769. * selection or invocation requests or type tests are delegated to.
  770. *
  771. * @return the current dynamic parent of this object.
  772. */
  773. public ATObject base_super() throws InterpreterException;
  774. /**
  775. * The identity operator. In AmbientTalk, equality of objects
  776. * is by default pointer-equality (i.e. objects are equal only
  777. * if they are identical).
  778. *
  779. * @return by default, true if the parameter object and this object are identical,
  780. * false otherwise.
  781. */
  782. // public ATBoolean base__opeql__opeql_(ATObject other) throws InterpreterException;
  783. /**
  784. * The object instantiation method. Note that in class-based OO languages,
  785. * this method is usually at the level of the <i>class</i>. In AmbientTalk,
  786. * this method is situated at the object-level directly. It can be overridden
  787. * to e.g. enforce the singleton pattern or to return instances of other
  788. * objects.
  789. *
  790. * The default implementation of this method is:
  791. * <pre>def new(@args) {
  792. * (reflect: self).newInstance(@args)
  793. *};
  794. * </pre>
  795. *
  796. * This is a primitive method, present by default in every AmbientTalk
  797. * object but redefinable by the programmer.
  798. *
  799. * @see ATObject#meta_newInstance(ATTable) for a description of object instantiation.
  800. * @param initargs the variable argument list to pass to the <tt>init</tt> method.
  801. * @return by default, the new instance of this mirror's base object.
  802. */
  803. // public ATObject base_new(ATObject[] initargs) throws InterpreterException;
  804. /**
  805. * The object initialisation method. In class-based languages, this method
  806. * is often called the constructor. AmbientTalk only supports one constructor
  807. * per object, but thanks to variable argument lists and optional parameters,
  808. * the same flexibility as defining multiple constructors can often be achieved.
  809. * Also, by overriding <tt>new</tt>, the developer may invoke additional methods
  810. * on newly created objects if this is desirable.
  811. *
  812. * The default implementation of this method is:
  813. * <pre>def init(@args) {
  814. * super^init(@args)
  815. *};
  816. * </pre>
  817. *
  818. * This is a primitive method, present by default in every AmbientTalk
  819. * object but redefinable by the programmer.
  820. *
  821. * @see ATObject#meta_newInstance(ATTable) for a description of object initialisation.
  822. * @param initargs the arguments to the <tt>init</tt> constructor method.
  823. * @return the return value of invoking the <tt>init</tt> method. Note that
  824. * this value is <i>discarded</i> when <tt>init</tt> is invoked from the
  825. * <tt>newInstance</tt> meta-level operation.
  826. */
  827. // public ATObject base_init(ATObject[] initargs) throws InterpreterException;
  828. /* -----------------------------------------
  829. * - Implementation-Level Object interface -
  830. * ----------------------------------------- */
  831. /**
  832. * Implementation-level shortcut for method invocation that foregoes the creation of
  833. * a 'method invocation' object, but rather passes the selector and arguments directly
  834. * to the implementation.
  835. */
  836. public ATObject impl_invoke(ATObject delegate, ATSymbol selector, ATTable arguments) throws InterpreterException;
  837. /**
  838. * The <tt>lexicalParent</tt> field of a mirror denotes the lexical parent
  839. * pointer of the mirror's base object. The lexical parent is the enclosing
  840. * <i>lexical scope</i> in which the object was defined.
  841. *
  842. * @return the object denoting this mirror's base object's lexically
  843. * enclosing scope.
  844. */
  845. public ATObject impl_lexicalParent() throws InterpreterException;
  846. /**
  847. * Interprets <code>o.x()</code> or <code>o.m(arg)</code>.
  848. * Implements slot access. This method is an implementation-level method (not part of the MOP).
  849. * @param receiver the dynamic receiver of the slot invocation.
  850. * @param selector a regular symbol denoting the slot accessor.
  851. * @param arguments the actual arguments to the slot invocation.
  852. * @return the result of applying the accessor.
  853. * @throws XArityMismatch if a field accessor is not invoked with exactly zero arguments.
  854. */
  855. public ATObject impl_invokeAccessor(ATObject receiver, ATSymbol selector, ATTable arguments) throws InterpreterException;
  856. /**
  857. * Interprets <code>o.x := v</code>.
  858. * Implements slot mutation. This method is an implementation-level method (not part of the MOP).
  859. * @param receiver the dynamic receiver of the slot invocation.
  860. * @param selector an assignment symbol denoting which slot to invoke.
  861. * @param arguments the actual arguments to the slot invocation.
  862. * @return the result of applying the mutator.
  863. * @throws XArityMismatch if a field mutator is not invoked with exactly one argument.
  864. */
  865. public ATObject impl_invokeMutator(ATObject receiver, ATAssignmentSymbol selector, ATTable arguments) throws InterpreterException;
  866. /**
  867. * Interprets <code>o.&m</code>.
  868. * Implements slot accessor selection. This method is an implementation-level method (not part of the MOP).
  869. * @param receiver the dynamic receiver of the slot selection.
  870. * @param selector a regular symbol denoting the accessor to select.
  871. * @return a closure wrapping the selected method or an accessor for a field.
  872. */
  873. public ATClosure impl_selectAccessor(ATObject receiver, ATSymbol selector) throws InterpreterException;
  874. /**
  875. * Interprets <code>o.&m:=</code>.
  876. * Implements slot mutator selection. This method is an implementation-level method (not part of the MOP).
  877. * @param receiver the dynamic receiver of the slot selection.
  878. * @param selector an assignment symbol denoting the mutator to select.
  879. * @return a closure representing the mutator of a given slot.
  880. */
  881. public ATClosure impl_selectMutator(ATObject receiver, ATAssignmentSymbol selector) throws InterpreterException;
  882. /**
  883. * Interprets <code>x := v</code> (equivalent to <code>x:=(v)</code>) or <code>f(v)</code>.
  884. * Implements functions calls and lexical access to variables.
  885. * This method is an implementation-level method (not part of the MOP).
  886. * Variable lookup first queries the local fields of this object, then the local
  887. * method dictionary. If the selector is not found, the search continues in
  888. * this object's <i>lexical parent</i>. Hence, variable lookup follows
  889. * <b>lexical scoping rules</b>.
  890. * <p>
  891. * Similar to the behaviour of <tt>invoke</tt>, if the selector is bound to a
  892. * field rather than a method, <tt>call</tt> treats the field as an accessor
  893. * or mutator method (depending on the selector).
  894. * <p>
  895. * Note that, unlike <tt>invoke</tt> and <tt>select</tt>, <tt>call</tt> does
  896. * not give rise to the invocation of <tt>doesNotUnderstand</tt> if the selector
  897. * was not found. The reason for this is that lexical lookup is a static process
  898. * for which it makes less sense to provide dynamic interception facilities.
  899. *
  900. * @param selector a symbol denoting the name of the field or method to look up lexically.
  901. * @param arguments the arguments to the lexically scoped function call.
  902. * @return if selector is bound to a field, the value of the field; otherwise if selector
  903. * is bound to a method, the return value of the method.
  904. * @throws XUndefinedSlot if the selector could not be found in the lexical scope of this object.
  905. */
  906. public ATObject impl_call(ATSymbol selector, ATTable arguments) throws InterpreterException;
  907. /**
  908. * Interprets <code>f(v)</code>.
  909. * Implements the protocol to access lexical variables and methods. This operation (which is not exposed
  910. * as part of the MOP) locates the lexically visible binding with the given selector and will return
  911. * the value of the slot.
  912. * <p>
  913. * When this object has a local slot corresponding to the selector:
  914. * <ul>
  915. * <li> and the slot contains a method or closure, it will be applied with the given arguments (within a context
  916. * where self is bound to this object)
  917. * <li> and the slot contains a value and the argumentlist is empty, the value is returned
  918. * <li> and the slot contains a value and the argumentlist is not empty, an arity mismatch exception is raised
  919. * </ul>
  920. * <p>
  921. * When no local slot is found, lookup continues along the lexical parent chain. When the lexical chain is
  922. * completely traversed, an undefined slot exception is raised.
  923. */
  924. public ATObject impl_callAccessor(ATSymbol selector, ATTable arguments) throws InterpreterException;
  925. /**
  926. * Interprets <code>x := v</code> (which is equivalent to <code>x:=(v)</code>.
  927. * Implements the protocol to assign lexical variables. This operation (which is not exposed as part of the MOP)
  928. * locates slots to assign corresponding to a specific assignment symbol (selector + ":=") and looks for:
  929. * <ol>
  930. * <li> a mutator method with the specified assignment symbol (i.e. including the ":=") which can then be
  931. * invoked with the provided arguments.
  932. * <li> a field with a corresponding selector (i.e. without the ":=") which is then treated as if it were
  933. * a unary mutator method.
  934. * </ol>
  935. *
  936. * If the slot is a method slot, an {@link XUnassignableField} exception is raised, otherwise the arity of the
  937. * arguments is verified (should be precisely 1) and the first argument is used as the new value of the slot.
  938. * <p>
  939. * When no local slot is found, lookup continues along the lexical parent chain. When the lexical chain is
  940. * completely traversed, a selector not found exception is reported.
  941. */
  942. public ATObject impl_callMutator(ATAssignmentSymbol selector, ATTable arguments) throws InterpreterException;
  943. /**
  944. * Interprets <code>x</code>.
  945. * This method is an implementation-level method (not part of the MOP).
  946. *
  947. * This method is equivalent to {@link #impl_call(ATSymbol, ATTable)} where
  948. * the arguments equal <tt>[]</tt>, except for one case: when the selector
  949. * resolves to a field containing a closure, the closure is not auto-applied
  950. * with zero arguments, but is instead returned. For all other purposes,
  951. * evaluating <tt>m</tt> is equivalent to evaluating <tt>m()</tt> such that
  952. * fields and nullary methods can be uniformly accessed.
  953. *
  954. * @param selector the name of a lexically visible field or method.
  955. * @return the value of a field or the return value of an accessor method.
  956. */
  957. public ATObject impl_callField(ATSymbol selector) throws InterpreterException;
  958. /**
  959. * Interprets <code>&x</code> or <code>&x:=</code>.
  960. * This method is an implementation-level method (not part of the MOP).
  961. *
  962. * This operation is the lexical counterpart of {@link #meta_select(ATObject, ATSymbol)}.
  963. * @param selector the name of a lexically visible field or method.
  964. * @return a closure wrapping a method, or an accessor or mutator linked to a lexically visible field.
  965. */
  966. public ATClosure impl_lookup(ATSymbol selector) throws InterpreterException;
  967. /**
  968. * Interprets <code>&x</code>.
  969. * This method is an implementation-level method (not part of the MOP).
  970. *
  971. * @param selector the name of a lexically visible field or method.
  972. * @return a closure wrapping a method, or an accessor linked to a lexically visible field.
  973. */
  974. public ATClosure impl_lookupAccessor(ATSymbol selector) throws InterpreterException;
  975. /**
  976. * Interprets <code>&x:=</code>.
  977. * This method is an implementation-level method (not part of the MOP).
  978. *
  979. * If the selector minus <tt>:=</tt> is bound to a field, the field is assigned
  980. * i
  981. * @param selector the name of a lexically visible method or of a field (whose name does not have the <tt>:=</tt> prefix).
  982. * @return a closure wrapping a method, or a mutator linked to a lexically visible field.
  983. */
  984. public ATClosure impl_lookupMutator(ATAssignmentSymbol selector) throws InterpreterException;
  985. /**
  986. * This is a callback method used in AmbientTalk's native equality protocol.
  987. * When evaluating <tt>o1 == o2</tt> in AmbientTalk, <tt>o1</tt>'s <tt>==</tt>
  988. * method will invoke <tt>o2.identityEquals(o1)</tt>.
  989. *
  990. * The native implementation can make use of Java's <tt>==</tt> operator where
  991. * appropriate.
  992. */
  993. public ATBoolean impl_identityEquals(ATObject other) throws InterpreterException;
  994. }