00001 /* Copyright 1994, 1995 LongView Technologies L.L.C. $Revision: 1.25 $ */ 00002 /* Copyright (c) 2006, Sun Microsystems, Inc. 00003 All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 00006 following conditions are met: 00007 00008 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 00009 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 00010 disclaimer in the documentation and/or other materials provided with the distribution. 00011 * Neither the name of Sun Microsystems nor the names of its contributors may be used to endorse or promote products derived 00012 from this software without specific prior written permission. 00013 00014 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 00015 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 00016 THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00017 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00018 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 00019 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 00020 00021 00022 */ 00023 00024 // primitives for classes 00025 00026 class behaviorPrimitives : AllStatic { 00027 private: 00028 static void inc_calls() { number_of_calls++; } 00029 public: 00030 static int number_of_calls; 00031 00032 //%prim 00033 // <Behavior> primitiveNewIfFail: failBlock <PrimFailBlock> ^<Instance> = 00034 // Internal { error = #(ReceiverIsIndexable) 00035 // name = 'behaviorPrimitives::allocate' 00036 // flags = #Allocate } 00037 //% 00038 static PRIM_DECL_1(allocate, oop receiver); 00039 00040 // MIXIN 00041 00042 //%prim 00043 // <NoReceiver> primitiveBehaviorMixinOf: behavior <Behavior> 00044 // ifFail: failBlock <PrimFailBlock> ^<Mixin> = 00045 // Internal { name = 'behaviorPrimitives::mixinOf' } 00046 //% 00047 static PRIM_DECL_1(mixinOf, oop behavior); 00048 00049 //%prim 00050 // <NoReceiver> primitiveBehaviorHeaderSizeOf: behavior <Behavior> 00051 // ifFail: failBlock <PrimFailBlock> ^<SmallInteger> = 00052 // Internal { name = 'behaviorPrimitives::headerSize' } 00053 //% 00054 static PRIM_DECL_1(headerSize, oop behavior); 00055 00056 //%prim 00057 // <NoReceiver> primitiveBehaviorNonIndexableSizeOf: behavior <Behavior> 00058 // ifFail: failBlock <PrimFailBlock> ^<SmallInteger> = 00059 // Internal { name = 'behaviorPrimitives::nonIndexableSize' } 00060 //% 00061 static PRIM_DECL_1(nonIndexableSize, oop behavior); 00062 00063 //%prim 00064 // <NoReceiver> primitiveBehaviorIsSpecializedClass: behavior <Behavior> 00065 // ifFail: failBlock <PrimFailBlock> ^<Boolean> = 00066 // Internal { name = 'behaviorPrimitives::is_specialized_class' } 00067 //% 00068 static PRIM_DECL_1(is_specialized_class, oop behavior); 00069 00070 //%prim 00071 // <NoReceiver> primitiveBehaviorCanBeSubclassed: behavior <Behavior> 00072 // ifFail: failBlock <PrimFailBlock> ^<Boolean> = 00073 // Internal { name = 'behaviorPrimitives::can_be_subclassed' } 00074 //% 00075 static PRIM_DECL_1(can_be_subclassed, oop behavior); 00076 00077 //%prim 00078 // <NoReceiver> primitiveBehaviorCanHaveInstanceVariables: behavior <Behavior> 00079 // ifFail: failBlock <PrimFailBlock> ^<Boolean> = 00080 // Internal { name = 'behaviorPrimitives::can_have_instance_variables' } 00081 //% 00082 static PRIM_DECL_1(can_have_instance_variables, oop behavior); 00083 00084 //%prim 00085 // <Behavior> primitiveSuperclass ^<Behavior|Nil> = 00086 // Internal { name = 'behaviorPrimitives::superclass' } 00087 //% 00088 static PRIM_DECL_1(superclass, oop receiver); 00089 00090 //%prim 00091 // <NoReceiver> primitiveSuperclassOf: class <Behavior> 00092 // ifFail: failBlock <PrimFailBlock> ^<Behavior|Nil> = 00093 // Internal { name = 'behaviorPrimitives::superclass_of' } 00094 //% 00095 static PRIM_DECL_1(superclass_of, oop klass); 00096 00097 // CLASS VARIABLES 00098 00099 //%prim 00100 // <NoReceiver> primitiveBehavior: behavior <Behavior> 00101 // classVariableAt: index <SmallInteger> 00102 // ifFail: failBlock <PrimFailBlock> ^<GlobalAssociation> = 00103 // Internal { error = #(OutOfBounds) 00104 // name = 'behaviorPrimitives::classVariableAt' } 00105 //% 00106 static PRIM_DECL_2(classVariableAt, oop behavior, oop index); 00107 00108 00109 //%prim 00110 // <NoReceiver> primitiveBehavior: behavior <Behavior> 00111 // classVariablesIfFail: failBlock <PrimFailBlock> ^<IndexedInstanceVariables> = 00112 // Internal { error = #(OutOfBounds) 00113 // name = 'behaviorPrimitives::classVariables' } 00114 //% 00115 static PRIM_DECL_1(classVariables, oop behavior); 00116 00117 // METHODS 00118 00119 //%prim 00120 // <Behavior> primitivePrintMethod: selector <ByteArray> 00121 // ifFail: failBlock <PrimFailBlock> ^<Behavior> = 00122 // Internal { name = 'behaviorPrimitives::printMethod' } 00123 //% 00124 static PRIM_DECL_2(printMethod, oop receiver, oop name); 00125 00126 //%prim 00127 // <Behavior> primitiveMethodFor: selector <CompressedSymbol> 00128 // ifFail: failBlock <PrimFailBlock> ^<Method> = 00129 // Internal { name = 'behaviorPrimitives::methodFor' 00130 // error = #(NotFound) 00131 // } 00132 //% 00133 static PRIM_DECL_2(methodFor, oop receiver, oop selector); 00134 00135 //%prim 00136 // <NoReceiver> primitiveBehaviorFormat: behavior <Behavior> 00137 // ifFail: failBlock <PrimFailBlock> ^<Symbol> = 00138 // Internal { name = 'behaviorPrimitives::format' } 00139 //% 00140 static PRIM_DECL_1(format, oop behavior); 00141 00142 //%prim 00143 // <NoReceiver> primitiveBehaviorVMType: behavior <Behavior> 00144 // ifFail: failBlock <PrimFailBlock> ^<Symbol> = 00145 // Internal { doc = 'Oops, SmallInteger, GlobalAssociation, Method, Float, Array, WeakArray, ' 00146 // doc = 'DoubleByteArray, FloatValueArray, ByteArray, Symbol, ' 00147 // doc = 'Block, Context, Process, Proxy, Activation, Mixin, and Class' 00148 // name = 'behaviorPrimitives::vm_type' } 00149 //% 00150 static PRIM_DECL_1(vm_type, oop behavior); 00151 00152 //%prim 00153 // <Behavior> primitiveBehaviorIsClassOf: obj <Object> ^<Boolean> = 00154 // Internal { 00155 // flags = #(LastDeltaFrameNotNeeded) 00156 // name = 'behaviorPrimitives::is_class_of' } 00157 //% 00158 static PRIM_DECL_2(is_class_of, oop receiver, oop obj); 00159 }; 00160 00161 //%prim 00162 // <Behavior> primitiveNew0 ^<Object> = 00163 // Internal { flags = #(Internal Allocate LastDeltaFrameNotNeeded) 00164 // name = 'primitiveNew0' } 00165 //% 00166 extern "C" oop primitiveNew0(oop receiver); 00167 00168 //%prim 00169 // <Behavior> primitiveNew1 ^<Instance> = 00170 // Internal { flags = #(Internal Allocate LastDeltaFrameNotNeeded) 00171 // name = 'primitiveNew1' } 00172 //% 00173 extern "C" oop primitiveNew1(oop receiver); 00174 00175 //%prim 00176 // <Behavior> primitiveNew2 ^<Instance> = 00177 // Internal { flags = #(Internal Allocate LastDeltaFrameNotNeeded) 00178 // name = 'primitiveNew2' } 00179 //% 00180 extern "C" oop primitiveNew2(oop receiver); 00181 00182 //%prim 00183 // <Behavior> primitiveNew3 ^<Instance> = 00184 // Internal { flags = #(Internal Allocate LastDeltaFrameNotNeeded) 00185 // name = 'primitiveNew3' } 00186 //% 00187 extern "C" oop primitiveNew3(oop receiver); 00188 00189 //%prim 00190 // <Behavior> primitiveNew4 ^<Instance> = 00191 // Internal { flags = #(Internal Allocate LastDeltaFrameNotNeeded) 00192 // name = 'primitiveNew4' } 00193 //% 00194 extern "C" oop primitiveNew4(oop receiver); 00195 00196 //%prim 00197 // <Behavior> primitiveNew5 ^<Instance> = 00198 // Internal { flags = #(Internal Allocate LastDeltaFrameNotNeeded) 00199 // name = 'primitiveNew5' } 00200 //% 00201 extern "C" oop primitiveNew5(oop receiver); 00202 00203 //%prim 00204 // <Behavior> primitiveNew6 ^<Instance> = 00205 // Internal { flags = #(Internal Allocate LastDeltaFrameNotNeeded) 00206 // name = 'primitiveNew6' } 00207 //% 00208 extern "C" oop primitiveNew6(oop receiver); 00209 00210 //%prim 00211 // <Behavior> primitiveNew7 ^<Instance> = 00212 // Internal { flags = #(Internal Allocate LastDeltaFrameNotNeeded) 00213 // name = 'primitiveNew7' } 00214 //% 00215 extern "C" oop primitiveNew7(oop receiver); 00216 00217 //%prim 00218 // <Behavior> primitiveNew8 ^<Instance> = 00219 // Internal { flags = #(Internal Allocate LastDeltaFrameNotNeeded) 00220 // name = 'primitiveNew8' } 00221 //% 00222 extern "C" oop primitiveNew8(oop receiver); 00223 00224 //%prim 00225 // <Behavior> primitiveNew9 ^<Instance> = 00226 // Internal { flags = #(Internal Allocate LastDeltaFrameNotNeeded) 00227 // name = 'primitiveNew9' } 00228 //% 00229 extern "C" oop primitiveNew9(oop receiver);