PageRenderTime 50ms CodeModel.GetById 13ms app.highlight 28ms RepoModel.GetById 2ms app.codeStats 0ms

/interpreter/tags/reactive-pattern-matching/src/edu/vub/at/objects/coercion/ATConversions.java

http://ambienttalk.googlecode.com/
Java | 190 lines | 108 code | 15 blank | 67 comment | 0 complexity | bbeef956b5c3f4c7b614a3cae69bbbed MD5 | raw file
  1/**
  2 * AmbientTalk/2 Project
  3 * ATConversions.java created on Jul 23, 2006 at 2:20:16 PM
  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.coercion;
 29
 30import edu.vub.at.actors.ATActorMirror;
 31import edu.vub.at.actors.ATAsyncMessage;
 32import edu.vub.at.actors.ATFarReference;
 33import edu.vub.at.actors.ATLetter;
 34import edu.vub.at.actors.natives.NATFarReference;
 35import edu.vub.at.eval.Import.DelegateMethod;
 36import edu.vub.at.exceptions.InterpreterException;
 37import edu.vub.at.exceptions.XTypeMismatch;
 38import edu.vub.at.objects.ATBoolean;
 39import edu.vub.at.objects.ATClosure;
 40import edu.vub.at.objects.ATField;
 41import edu.vub.at.objects.ATHandler;
 42import edu.vub.at.objects.ATMessage;
 43import edu.vub.at.objects.ATMethod;
 44import edu.vub.at.objects.ATMethodInvocation;
 45import edu.vub.at.objects.ATNumber;
 46import edu.vub.at.objects.ATTable;
 47import edu.vub.at.objects.ATTypeTag;
 48import edu.vub.at.objects.grammar.ATAssignVariable;
 49import edu.vub.at.objects.grammar.ATBegin;
 50import edu.vub.at.objects.grammar.ATDefinition;
 51import edu.vub.at.objects.grammar.ATExpression;
 52import edu.vub.at.objects.grammar.ATMessageCreation;
 53import edu.vub.at.objects.grammar.ATQuote;
 54import edu.vub.at.objects.grammar.ATSplice;
 55import edu.vub.at.objects.grammar.ATStatement;
 56import edu.vub.at.objects.grammar.ATSymbol;
 57import edu.vub.at.objects.grammar.ATUnquoteSplice;
 58import edu.vub.at.objects.mirrors.NATIntrospectiveMirror;
 59import edu.vub.at.objects.mirrors.NATMirage;
 60import edu.vub.at.objects.natives.NATBoolean;
 61import edu.vub.at.objects.natives.NATFraction;
 62import edu.vub.at.objects.natives.NATNumber;
 63import edu.vub.at.objects.natives.NATNumeric;
 64import edu.vub.at.objects.natives.NATObject;
 65import edu.vub.at.objects.natives.NATTable;
 66import edu.vub.at.objects.natives.NATText;
 67import edu.vub.at.objects.symbiosis.JavaClass;
 68import edu.vub.at.objects.symbiosis.JavaMethod;
 69import edu.vub.at.objects.symbiosis.JavaObject;
 70import edu.vub.at.signals.ATBehavior;
 71import edu.vub.at.signals.ATEventSource;
 72
 73/**
 74 * ATConversions is an interface defining all conversion methods between different
 75 * types of ambienttalk language elements. They are hidden from the language level
 76 * because they neither belong to base- nor meta-level.
 77 * 
 78 * @author smostinc
 79 */
 80public interface ATConversions {
 81
 82	/**
 83	 * Used to distinguish between symbol, assignment, splice in formal param list.
 84	 */
 85	public boolean isSymbol() throws InterpreterException;
 86	/**
 87	 * Used to check in <tt>o.m()@exp</tt> if exp is a table or not.
 88	 */
 89	public boolean isTable() throws InterpreterException;
 90	/**
 91	 * Used to recognize unquote-splice elements when quoting a table.
 92	 */
 93	public boolean isUnquoteSplice() throws InterpreterException;
 94	/**
 95	 * Used to distinguish between symbol, assignment, splice in formal param list
 96	 */
 97	public boolean isVariableAssignment() throws InterpreterException;
 98	/**
 99	 * Used to distinguish between symbol, assignment, splice in formal param list and
100	 * to recognize spliced elements during table evaluation.
101	 */
102	public boolean isSplice() throws InterpreterException;
103	/**
104	 * Used in message send expressions to print, to check between <tt><+</tt> and
105	 * <tt>./^/<-</tt> operators.
106	 */
107	public boolean isMessageCreation() throws InterpreterException;
108	/**
109	 * Used to identify type tags for comparison using <tt>==</tt>.
110	 */
111	public boolean isTypeTag() throws InterpreterException;
112	/**
113	 * Used when sending an asynchronous message, to determine whether to
114	 * invoke <tt>receive</tt> on the receiver object directly, or to pass
115	 * via the actor's queue first.
116	 */
117	public boolean isFarReference() throws InterpreterException;
118	
119	public boolean isBehavior() throws InterpreterException;
120	
121	public ATClosure	asClosure() throws InterpreterException;
122	public ATSymbol		asSymbol() throws InterpreterException;
123	public ATTable		asTable() throws InterpreterException;
124	public ATBoolean	asBoolean() throws InterpreterException;
125	public ATNumber		asNumber() throws InterpreterException;
126	public ATMessage	asMessage() throws InterpreterException;
127	public ATField		asField() throws InterpreterException;
128	public ATMethod		asMethod() throws InterpreterException;
129	public ATMethodInvocation asMethodInvocation() throws InterpreterException;
130	public ATHandler   asHandler() throws InterpreterException;
131
132	public ATTypeTag    asTypeTag() throws InterpreterException;
133	public ATFarReference asFarReference() throws InterpreterException;
134	public ATAsyncMessage asAsyncMessage() throws InterpreterException;
135	public ATActorMirror asActorMirror() throws InterpreterException;
136	public ATLetter    asLetter() throws InterpreterException;
137	
138	public ATBehavior	 asBehavior() throws InterpreterException;
139	public ATEventSource asEventSource() throws InterpreterException;
140	
141	// Abstract Grammar Elements
142	
143	public ATStatement  		asStatement() throws InterpreterException;
144	public ATDefinition 		asDefinition() throws InterpreterException;
145	public ATExpression 		asExpression() throws InterpreterException;
146	public ATBegin      		asBegin() throws InterpreterException;
147	public ATQuote				asQuote() throws InterpreterException;
148	public ATMessageCreation 	asMessageCreation() throws InterpreterException;
149	public ATUnquoteSplice 		asUnquoteSplice() throws InterpreterException;
150	public ATAssignVariable 	asVariableAssignment() throws InterpreterException;
151	public ATSplice 			asSplice() throws InterpreterException;
152
153	// Native Value Elements
154	
155	// The isNative / asNative type-casting protocol is crucial for correct
156	// semantics in the case of e.g. wrapped natives in a Coercer (for symbiosis)
157	// Never use Java type-casts explicitly!
158	
159	public boolean isNativeBoolean();
160	public boolean isNativeText();
161	public boolean isAmbientTalkObject(); // distinguish native from non-native objects
162	public boolean isCallFrame() throws InterpreterException; // distinguish call frames from objects
163	public boolean isJavaObjectUnderSymbiosis();
164	public boolean isJavaClassUnderSymbiosis();
165	public boolean isJavaMethodUnderSymbiosis();
166	public boolean isNativeField();
167	public boolean isNativeFarReference();
168	public boolean isNativeFraction();
169	public boolean isNativeNumber();
170	public boolean isNativeIntrospectiveMirror();
171	public boolean isNativeDelegateMethod();
172	public boolean isMirage();
173	
174	public NATObject   asAmbientTalkObject() throws XTypeMismatch;
175	public NATMirage   asMirage() throws XTypeMismatch;
176	public NATNumber   asNativeNumber() throws XTypeMismatch;
177	public NATFraction asNativeFraction() throws XTypeMismatch;
178	public NATText     asNativeText() throws XTypeMismatch;
179	public NATTable    asNativeTable() throws XTypeMismatch;
180	public NATBoolean  asNativeBoolean() throws XTypeMismatch;
181	public NATNumeric  asNativeNumeric() throws XTypeMismatch;
182	public NATFarReference asNativeFarReference() throws XTypeMismatch;
183	public NATIntrospectiveMirror asNativeIntrospectiveMirror() throws XTypeMismatch;
184	public DelegateMethod asNativeDelegateMethod() throws XTypeMismatch;
185	public JavaObject  asJavaObjectUnderSymbiosis() throws XTypeMismatch;
186	public JavaClass   asJavaClassUnderSymbiosis() throws XTypeMismatch;
187	public JavaMethod  asJavaMethodUnderSymbiosis() throws XTypeMismatch;
188	
189
190}