PageRenderTime 46ms CodeModel.GetById 12ms app.highlight 28ms RepoModel.GetById 1ms app.codeStats 0ms

/interpreter/tags/at2dist220411/src/edu/vub/at/objects/coercion/NativeTypeTags.java

http://ambienttalk.googlecode.com/
Java | 269 lines | 91 code | 75 blank | 103 comment | 4 complexity | 557efdba57e7c85c7e166a80a25bcc02 MD5 | raw file
  1/**
  2 * AmbientTalk/2 Project
  3 * NativeTypeTags.java created on 26-feb-2007 at 16:29:25
  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 java.lang.reflect.Field;
 31import java.util.HashSet;
 32import java.util.Vector;
 33
 34import edu.vub.at.objects.ATObject;
 35import edu.vub.at.objects.ATTypeTag;
 36import edu.vub.at.objects.natives.NATTypeTag;
 37
 38/**
 39 * This class serves to hold references to the native type tags with which native
 40 * AmbientTalk objects are tagged.
 41 *
 42 * @author tvcutsem
 43 */
 44public final class NativeTypeTags {
 45	
 46	private static HashSet<NATTypeTag> nativeTypeTags_ = null;
 47
 48	/* Java implementation of lobby.at.types.at: */
 49
 50//deftype Isolate;
 51	public final static NATTypeTag _ISOLATE_ = NATTypeTag.atValue("Isolate");
 52
 53//deftype Meta;
 54	public final static NATTypeTag _META_ = NATTypeTag.atValue("Meta");
 55	
 56//deftype Boolean;
 57	public final static NATTypeTag _BOOLEAN_ = NATTypeTag.atValue("Boolean");
 58	
 59//deftype Closure;
 60	public final static NATTypeTag _CLOSURE_ = NATTypeTag.atValue("Closure");
 61	
 62//deftype Context;
 63	public final static NATTypeTag _CONTEXT_ = NATTypeTag.atValue("Context");
 64	
 65//deftype Field;
 66	public final static NATTypeTag _FIELD_ = NATTypeTag.atValue("Field");
 67	
 68//deftype Handler;
 69	public final static NATTypeTag _HANDLER_ = NATTypeTag.atValue("Handler");
 70	
 71//deftype Method;
 72	public final static NATTypeTag _METHOD_ = NATTypeTag.atValue("Method");
 73	
 74//deftype Message;
 75	public final static NATTypeTag _MESSAGE_ = NATTypeTag.atValue("Message");
 76	
 77//deftype MethodInvocation <: Message;
 78	public final static NATTypeTag _METHODINV_ = NATTypeTag.atValue("MethodInvocation", _MESSAGE_);
 79
 80//deftype FieldSelection <: Message;
 81    public final static NATTypeTag _FIELDSEL_ = NATTypeTag.atValue("FieldSelection", _MESSAGE_);
 82
 83	
 84//deftype Delegation <: Message;
 85	public final static NATTypeTag _DELEGATION_ = NATTypeTag.atValue("Delegation", _MESSAGE_);
 86	
 87//deftype AsyncMessage <: Message;
 88	public final static NATTypeTag _ASYNCMSG_ = NATTypeTag.atValue("AsyncMessage", _MESSAGE_);
 89	
 90//deftype Letter;
 91	public final static NATTypeTag _LETTER_ = NATTypeTag.atValue("Letter");
 92	
 93//deftype Mirror;
 94	public final static NATTypeTag _MIRROR_ = NATTypeTag.atValue("Mirror");
 95	
 96//deftype ActorMirror;
 97	public final static NATTypeTag _ACTORMIRROR_ = NATTypeTag.atValue("ActorMirror");
 98	
 99//deftype TypeTag;
100	public final static NATTypeTag _TYPETAG_ = NATTypeTag.atValue("TypeTag");
101	
102//deftype FarReference;
103	public final static NATTypeTag _FARREF_ = NATTypeTag.atValue("FarReference");	
104
105// abstract grammar
106//deftype AbstractGrammar;
107	public final static NATTypeTag _ABSTRACTGRAMMAR_ = NATTypeTag.atValue("AbstractGrammar");
108	
109//deftype Statement;
110	public final static NATTypeTag _STATEMENT_ = NATTypeTag.atValue("Statement", _ABSTRACTGRAMMAR_);
111	
112//	deftype Expression;
113	public final static NATTypeTag _EXPRESSION_ = NATTypeTag.atValue("Expression", _STATEMENT_);
114	
115// literal values
116//deftype Table <: Expression;
117	public final static NATTypeTag _TABLE_ = NATTypeTag.atValue("Table", _EXPRESSION_);
118	
119//deftype Text <: Expression;
120	public final static NATTypeTag _TEXT_ = NATTypeTag.atValue("Text", _EXPRESSION_);
121	
122//deftype Numeric <: Expression;
123	public final static NATTypeTag _NUMERIC_ = NATTypeTag.atValue("Numeric", _EXPRESSION_);
124	
125//deftype Number <: Numeric;
126	public final static NATTypeTag _NUMBER_ = NATTypeTag.atValue("Number", _EXPRESSION_);
127	
128//deftype Fraction <: Numeric;
129	public final static NATTypeTag _FRACTION_ = NATTypeTag.atValue("Fraction", _EXPRESSION_);
130
131//deftype Symbol <: Expression;
132	public final static NATTypeTag _SYMBOL_ = NATTypeTag.atValue("Symbol", _EXPRESSION_);
133
134//deftype Begin <: AbstractGrammar;
135	public final static NATTypeTag _BEGIN_ = NATTypeTag.atValue("Begin", _ABSTRACTGRAMMAR_);
136	
137//deftype Splice <: Expression;
138	public final static NATTypeTag _SPLICE_ = NATTypeTag.atValue("Splice", _EXPRESSION_);
139	
140//deftype UnquoteSplice <: Expression;
141	public final static NATTypeTag _UQSPLICE_ = NATTypeTag.atValue("UnquoteSplice", _EXPRESSION_);
142	
143//deftype MessageCreation <: Expression;
144	public final static NATTypeTag _MSGCREATION_ = NATTypeTag.atValue("MessageCreation", _EXPRESSION_);
145	
146//deftype Definition <: Statement;
147	public final static NATTypeTag _DEFINITION_ = NATTypeTag.atValue("Definition", _STATEMENT_);
148	
149//	deftype MethodDefinition <: Definition;
150	public final static NATTypeTag _METHOD_DEFINITION_ = NATTypeTag.atValue("MethodDefinition", _DEFINITION_);
151
152	
153//
154//// exception types
155//deftype Exception;
156	public final static NATTypeTag _EXCEPTION_ = NATTypeTag.atValue("Exception");
157	
158//deftype ArityMismatch <: Exception;
159	public final static NATTypeTag _ARITYMISMATCH_ = NATTypeTag.atValue("ArityMismatch", _EXCEPTION_);
160	
161//deftype ClassNotFound <: Exception;
162	public final static NATTypeTag _CLASSNOTFOUND_ = NATTypeTag.atValue("ClassNotFound", _EXCEPTION_);
163	
164//deftype DuplicateSlot <: Exception;
165	public final static NATTypeTag _DUPLICATESLOT_ = NATTypeTag.atValue("DuplicateSlot", _EXCEPTION_);
166	
167//deftype IllegalApplication <: Exception;
168	public final static NATTypeTag _ILLAPP_ = NATTypeTag.atValue("IllegalApplication", _EXCEPTION_);
169	
170//deftype IllegalArgument <: Exception;
171	public final static NATTypeTag _ILLARG_ = NATTypeTag.atValue("IllegalArgument", _EXCEPTION_);
172	
173//deftype IllegalIndex <: Exception;
174	public final static NATTypeTag _ILLIDX_ = NATTypeTag.atValue("IllegalIndex", _EXCEPTION_);
175	
176//deftype IllegalOperation <: Exception;
177	public final static NATTypeTag _ILLOP_ = NATTypeTag.atValue("IllegalOperation", _EXCEPTION_);
178	
179//deftype IllegalParameter <: Exception;
180	public final static NATTypeTag _ILLPARAM_ = NATTypeTag.atValue("IllegalParameter", _EXCEPTION_);
181	
182//deftype IllegalQuote <: Exception;
183	public final static NATTypeTag _ILLQUOTE_ = NATTypeTag.atValue("IllegalQuote", _EXCEPTION_);
184	
185//deftype IllegalSplice <: Exception;
186	public final static NATTypeTag _ILLSPLICE_ = NATTypeTag.atValue("IllegalSplice", _EXCEPTION_);
187	
188//deftype IllegalUnquote <: Exception;
189	public final static NATTypeTag _ILLUQUOTE_ = NATTypeTag.atValue("IllegalUnquote", _EXCEPTION_);
190	
191//deftype IndexOutOfBounds <: Exception;
192	public final static NATTypeTag _IDXOUTOFBOUNDS_ = NATTypeTag.atValue("IndexOutOfBounds", _EXCEPTION_);
193	
194//deftype IOProblem <: Exception;
195	public final static NATTypeTag _IOPROBLEM_ = NATTypeTag.atValue("IOProblem", _EXCEPTION_);
196	
197//deftype NotInstantiatable <: Exception;
198	public final static NATTypeTag _NOTINSTANTIATABLE_ = NATTypeTag.atValue("NotInstantiatable", _EXCEPTION_);
199	
200//deftype ParseError <: Exception;
201	public final static NATTypeTag _PARSEERROR_ = NATTypeTag.atValue("ParseError", _EXCEPTION_);
202	
203//deftype ReflectionFailure <: Exception;
204	public final static NATTypeTag _REFLECTIONFAILURE_ = NATTypeTag.atValue("ReflectionFailure", _EXCEPTION_);
205
206//	deftype SelectorNotFound <: Exception;
207	public final static NATTypeTag _SELECTORNOTFOUND_ = NATTypeTag.atValue("SelectorNotFound", _EXCEPTION_);
208	
209//deftype SymbiosisFailure <: Exception;
210	public final static NATTypeTag _SYMBIOSISFAILURE_ = NATTypeTag.atValue("SymbiosisFailure", _EXCEPTION_);
211	
212//deftype TypeMismatch <: Exception;
213	public final static NATTypeTag _TYPEMISMATCH_ = NATTypeTag.atValue("TypeMismatch", _EXCEPTION_);
214	
215//deftype UnassignableField <: Exception;
216	public final static NATTypeTag _UNASSIGNABLEFIELD_ = NATTypeTag.atValue("UnassignableField", _EXCEPTION_);
217	
218//deftype UndefinedField <: Exception;
219	public final static NATTypeTag _UNDEFINEDSLOT_ = NATTypeTag.atValue("UndefinedSlot", _EXCEPTION_);
220	
221//deftype CustomException <: Exception;
222	public final static NATTypeTag _CUSTOMEXCEPTION_ = NATTypeTag.atValue("CustomException", _EXCEPTION_);
223
224//deftype JavaException <: Exception;
225	public final static NATTypeTag _JAVAEXCEPTION_ = NATTypeTag.atValue("JavaException", _EXCEPTION_);
226
227//deftype ImportConflict <: Exception;
228	public final static NATTypeTag _IMPORTCONFLICT_ = NATTypeTag.atValue("ImportConflict", _EXCEPTION_);
229
230//deftype ObjectOffline <: Exception;
231    public final static NATTypeTag _OBJECTOFFLINE_ = NATTypeTag.atValue("ObjectOffline", _EXCEPTION_);
232    
233//deftype SerializationError <: Exception;
234	public final static NATTypeTag _SERIALIZATIONERROR_ = NATTypeTag.atValue("SerializationError", _EXCEPTION_);
235
236    // misc
237    
238
239  //deftype Required;
240    public final static NATTypeTag _REQUIRED_ = NATTypeTag.atValue("Required");
241    
242    //deftype ExternalEvent;
243    public final static NATTypeTag _EXTERNAL_MSG_ = NATTypeTag.atValue("ExternalMessage");
244    
245    public static HashSet<NATTypeTag> getNativeTypeTags() {
246    	if (nativeTypeTags_ == null) {
247
248    		nativeTypeTags_ = new HashSet<NATTypeTag>();
249    		Field[] fields = NativeTypeTags.class.getFields();
250    		for (Field f : fields) {
251    			Object fi;
252    			try {
253    				fi = f.get(NativeTypeTags.class);
254    				if (fi instanceof NATTypeTag) {
255    					NATTypeTag tt = (NATTypeTag) fi;
256    					nativeTypeTags_.add(tt);
257    				}
258    			} catch (SecurityException e) {
259    				// ignore
260    			} catch (IllegalAccessException e) {
261    				// ignore
262    			}
263    		}
264    	}
265    	return nativeTypeTags_;
266    }
267
268    
269}