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