[Vm-dev] [commit][2721] Sources as per VMMaker-dtl.317

commits at squeakvm.org commits at squeakvm.org
Sat Apr 13 14:52:46 UTC 2013


Revision: 2721
Author:   lewis
Date:     2013-04-13 07:52:46 -0700 (Sat, 13 Apr 2013)
Log Message:
-----------
Sources as per VMMaker-dtl.317
VMMaker 4.12.1

Caution: FloatMathPluginTests now included in  VMMaker-Tests will crash
the VM if compiled 64-bit (Mantis 7760)

Merge changes from oscog plugins.

Update to VM_PROXY_MINOR 11 (was 9). Requires some support code
functions not present in SVN trunk, so temporary implementations are
provided in InterpreterPrimitives method category "FIXME" for:
        add: ticker HighPriorityTickee: periodms
        add: ticker Synchronous: periodms Tickee: roundms
        amInVMThread
        ioUTCMicroseconds
These methods must be removed when platform sources are updated.

Not included in merge:
        FilePlugin>>primitiveDirectoryEntry requires support code
        SocketPlugin>>primitiveSocketCreateRaw:... requires support code.

Revert previous cosmetic changes (e.g.  space added to
<returnTypeC:'void*'> declaration) in order to eliminate unnecessary
differences versus oscog.

Add missing __buildInfo[] and comment generation for src/vm files.

Modified Paths:
--------------
    trunk/src/ckformat.c
    trunk/src/plugins/ADPCMCodecPlugin/ADPCMCodecPlugin.c
    trunk/src/plugins/AioPlugin/AioPlugin.c
    trunk/src/plugins/AsynchFilePlugin/AsynchFilePlugin.c
    trunk/src/plugins/B2DPlugin/B2DPlugin.c
    trunk/src/plugins/B3DAcceleratorPlugin/B3DAcceleratorPlugin.c
    trunk/src/plugins/BMPReadWriterPlugin/BMPReadWriterPlugin.c
    trunk/src/plugins/BitBltPlugin/BitBltPlugin.c
    trunk/src/plugins/CameraPlugin/CameraPlugin.c
    trunk/src/plugins/ClipboardExtendedPlugin/ClipboardExtendedPlugin.c
    trunk/src/plugins/CroquetPlugin/CroquetPlugin.c
    trunk/src/plugins/DBusPlugin/DBusPlugin.c
    trunk/src/plugins/DSAPrims/DSAPrims.c
    trunk/src/plugins/DropPlugin/DropPlugin.c
    trunk/src/plugins/FFTPlugin/FFTPlugin.c
    trunk/src/plugins/FT2Plugin/FT2Plugin.c
    trunk/src/plugins/FileCopyPlugin/FileCopyPlugin.c
    trunk/src/plugins/FilePlugin/FilePlugin.c
    trunk/src/plugins/FloatArrayPlugin/FloatArrayPlugin.c
    trunk/src/plugins/FloatMathPlugin/FloatMathPlugin.c
    trunk/src/plugins/GeniePlugin/GeniePlugin.c
    trunk/src/plugins/HostWindowPlugin/HostWindowPlugin.c
    trunk/src/plugins/JPEGReadWriter2Plugin/JPEGReadWriter2Plugin.c
    trunk/src/plugins/JPEGReaderPlugin/JPEGReaderPlugin.c
    trunk/src/plugins/JoystickTabletPlugin/JoystickTabletPlugin.c
    trunk/src/plugins/Klatt/Klatt.c
    trunk/src/plugins/LargeIntegers/LargeIntegers.c
    trunk/src/plugins/LocalePlugin/LocalePlugin.c
    trunk/src/plugins/MIDIPlugin/MIDIPlugin.c
    trunk/src/plugins/Matrix2x3Plugin/Matrix2x3Plugin.c
    trunk/src/plugins/MiscPrimitivePlugin/MiscPrimitivePlugin.c
    trunk/src/plugins/Mpeg3Plugin/Mpeg3Plugin.c
    trunk/src/plugins/RePlugin/RePlugin.c
    trunk/src/plugins/RomePlugin/RomePlugin.c
    trunk/src/plugins/ScratchPlugin/ScratchPlugin.c
    trunk/src/plugins/SecurityPlugin/SecurityPlugin.c
    trunk/src/plugins/SerialPlugin/SerialPlugin.c
    trunk/src/plugins/SocketPlugin/SocketPlugin.c
    trunk/src/plugins/SoundCodecPrims/SoundCodecPrims.c
    trunk/src/plugins/SoundGenerationPlugin/SoundGenerationPlugin.c
    trunk/src/plugins/SoundPlugin/SoundPlugin.c
    trunk/src/plugins/Squeak3D/Squeak3D.c
    trunk/src/plugins/SqueakFFIPrims/SqueakFFIPrims.c
    trunk/src/plugins/SqueakSSL/SqueakSSL.c
    trunk/src/plugins/StarSqueakPlugin/StarSqueakPlugin.c
    trunk/src/plugins/UUIDPlugin/UUIDPlugin.c
    trunk/src/plugins/UnicodePlugin/UnicodePlugin.c
    trunk/src/plugins/UnixOSProcessPlugin/UnixOSProcessPlugin.c
    trunk/src/plugins/WeDoPlugin/WeDoPlugin.c
    trunk/src/plugins/XDisplayControlPlugin/XDisplayControlPlugin.c
    trunk/src/plugins/ZipPlugin/ZipPlugin.c
    trunk/src/vm/interp.c
    trunk/src/vm/interp.h
    trunk/src/vm/sqNamedPrims.h

Modified: trunk/src/ckformat.c
===================================================================
--- trunk/src/ckformat.c	2013-04-12 22:16:14 UTC (rev 2720)
+++ trunk/src/ckformat.c	2013-04-13 14:52:46 UTC (rev 2721)
@@ -5,7 +5,7 @@
 /* Usage: ckformat imageFileName */
 
 /* --- DO NOT EDIT THIS FILE --- */
-/* --- Automatically generated from class ImageFormat 2013-04-06T10:59:51.052-05:00--- */
+/* --- Automatically generated from class ImageFormat 2013-04-13T10:48:51.504-05:00--- */
 /* --- Source code is in package ImageFormat in the VMMaker repository --- */
 /* --- DO NOT EDIT THIS FILE --- */
 

Modified: trunk/src/plugins/ADPCMCodecPlugin/ADPCMCodecPlugin.c
===================================================================
--- trunk/src/plugins/ADPCMCodecPlugin/ADPCMCodecPlugin.c	2013-04-12 22:16:14 UTC (rev 2720)
+++ trunk/src/plugins/ADPCMCodecPlugin/ADPCMCodecPlugin.c	2013-04-13 14:52:46 UTC (rev 2721)
@@ -1,10 +1,10 @@
-/* Smalltalk from Squeak4.3 with VMMaker 4.11.5 translated as C source on 6 April 2013 10:59:34 am */
+/* Smalltalk from Squeak4.3 with VMMaker 4.12.1 translated as C source on 13 April 2013 10:48:31 am */
 /* Automatically generated by
-	VMPluginCodeGenerator * VMMaker-dtl.314 uuid: 27bc9a3b-01be-47b3-8e3a-b5f5554a389d
+	VMPluginCodeGenerator VMMaker-dtl.317 uuid: cc922d07-b988-4034-9bf9-31e7b86e9a14
    from
-	ADPCMCodecPlugin * VMMaker-dtl.314 uuid: 27bc9a3b-01be-47b3-8e3a-b5f5554a389d
+	ADPCMCodecPlugin VMMaker-dtl.317 uuid: cc922d07-b988-4034-9bf9-31e7b86e9a14
  */
-static char __buildInfo[] = "ADPCMCodecPlugin * VMMaker-dtl.314 uuid: 27bc9a3b-01be-47b3-8e3a-b5f5554a389d " __DATE__ ;
+static char __buildInfo[] = "ADPCMCodecPlugin VMMaker-dtl.317 uuid: cc922d07-b988-4034-9bf9-31e7b86e9a14 " __DATE__ ;
 
 
 
@@ -70,9 +70,9 @@
 struct VirtualMachine* interpreterProxy;
 static const char *moduleName =
 #ifdef SQUEAK_BUILTIN_PLUGIN
-	"ADPCMCodecPlugin 6 April 2013 (i)"
+	"ADPCMCodecPlugin 13 April 2013 (i)"
 #else
-	"ADPCMCodecPlugin 6 April 2013 (e)"
+	"ADPCMCodecPlugin 13 April 2013 (e)"
 #endif
 ;
 

Modified: trunk/src/plugins/AioPlugin/AioPlugin.c
===================================================================
--- trunk/src/plugins/AioPlugin/AioPlugin.c	2013-04-12 22:16:14 UTC (rev 2720)
+++ trunk/src/plugins/AioPlugin/AioPlugin.c	2013-04-13 14:52:46 UTC (rev 2721)
@@ -1,6 +1,6 @@
-/* Smalltalk from Squeak4.3 with VMMaker 4.11.5 translated as C source on 6 April 2013 10:59:50 am */
+/* Smalltalk from Squeak4.3 with VMMaker 4.12.1 translated as C source on 13 April 2013 10:48:50 am */
 /* Automatically generated by
-	VMPluginCodeGenerator * VMMaker-dtl.314 uuid: 27bc9a3b-01be-47b3-8e3a-b5f5554a389d
+	VMPluginCodeGenerator VMMaker-dtl.317 uuid: cc922d07-b988-4034-9bf9-31e7b86e9a14
    from
 	UnixAioPlugin VMConstruction-Plugins-AioPlugin-dtl.14 uuid: 965d54b7-4309-42fd-adb0-64400d3c780b
  */
@@ -88,9 +88,9 @@
 struct VirtualMachine* interpreterProxy;
 static const char *moduleName =
 #ifdef SQUEAK_BUILTIN_PLUGIN
-	"AioPlugin 6 April 2013 (i)"
+	"AioPlugin 13 April 2013 (i)"
 #else
-	"AioPlugin 6 April 2013 (e)"
+	"AioPlugin 13 April 2013 (e)"
 #endif
 ;
 

Modified: trunk/src/plugins/AsynchFilePlugin/AsynchFilePlugin.c
===================================================================
--- trunk/src/plugins/AsynchFilePlugin/AsynchFilePlugin.c	2013-04-12 22:16:14 UTC (rev 2720)
+++ trunk/src/plugins/AsynchFilePlugin/AsynchFilePlugin.c	2013-04-13 14:52:46 UTC (rev 2721)
@@ -1,10 +1,10 @@
-/* Smalltalk from Squeak4.3 with VMMaker 4.11.5 translated as C source on 6 April 2013 10:59:34 am */
+/* Smalltalk from Squeak4.3 with VMMaker 4.12.1 translated as C source on 13 April 2013 10:48:31 am */
 /* Automatically generated by
-	SmartSyntaxPluginCodeGenerator * VMMaker-dtl.314 uuid: 27bc9a3b-01be-47b3-8e3a-b5f5554a389d
+	SmartSyntaxPluginCodeGenerator VMMaker-dtl.317 uuid: cc922d07-b988-4034-9bf9-31e7b86e9a14
    from
-	AsynchFilePlugin * VMMaker-dtl.314 uuid: 27bc9a3b-01be-47b3-8e3a-b5f5554a389d
+	AsynchFilePlugin VMMaker-dtl.317 uuid: cc922d07-b988-4034-9bf9-31e7b86e9a14
  */
-static char __buildInfo[] = "AsynchFilePlugin * VMMaker-dtl.314 uuid: 27bc9a3b-01be-47b3-8e3a-b5f5554a389d " __DATE__ ;
+static char __buildInfo[] = "AsynchFilePlugin VMMaker-dtl.317 uuid: cc922d07-b988-4034-9bf9-31e7b86e9a14 " __DATE__ ;
 
 
 
@@ -67,9 +67,9 @@
 struct VirtualMachine* interpreterProxy;
 static const char *moduleName =
 #ifdef SQUEAK_BUILTIN_PLUGIN
-	"AsynchFilePlugin 6 April 2013 (i)"
+	"AsynchFilePlugin 13 April 2013 (i)"
 #else
-	"AsynchFilePlugin 6 April 2013 (e)"
+	"AsynchFilePlugin 13 April 2013 (e)"
 #endif
 ;
 static void * sCOAFfn;

Modified: trunk/src/plugins/B2DPlugin/B2DPlugin.c
===================================================================
--- trunk/src/plugins/B2DPlugin/B2DPlugin.c	2013-04-12 22:16:14 UTC (rev 2720)
+++ trunk/src/plugins/B2DPlugin/B2DPlugin.c	2013-04-13 14:52:46 UTC (rev 2721)
@@ -1,10 +1,10 @@
-/* Smalltalk from Squeak4.3 with VMMaker 4.11.5 translated as C source on 6 April 2013 10:59:36 am */
+/* Smalltalk from Squeak4.3 with VMMaker 4.12.1 translated as C source on 13 April 2013 10:48:33 am */
 /* Automatically generated by
-	VMPluginCodeGenerator * VMMaker-dtl.314 uuid: 27bc9a3b-01be-47b3-8e3a-b5f5554a389d
+	VMPluginCodeGenerator VMMaker-dtl.317 uuid: cc922d07-b988-4034-9bf9-31e7b86e9a14
    from
-	BalloonEnginePlugin * VMMaker-dtl.314 uuid: 27bc9a3b-01be-47b3-8e3a-b5f5554a389d
+	BalloonEnginePlugin VMMaker-dtl.317 uuid: cc922d07-b988-4034-9bf9-31e7b86e9a14
  */
-static char __buildInfo[] = "BalloonEnginePlugin * VMMaker-dtl.314 uuid: 27bc9a3b-01be-47b3-8e3a-b5f5554a389d " __DATE__ ;
+static char __buildInfo[] = "BalloonEnginePlugin VMMaker-dtl.317 uuid: cc922d07-b988-4034-9bf9-31e7b86e9a14 " __DATE__ ;
 
 
 
@@ -87,6 +87,30 @@
 #define GEBaseEdgeSize 10
 #define GEBaseFillSize 4
 #define GEEdgeFillsInvalid 65536
+#define GEFAlreadyFailed 100
+#define GEFBadPoint 121
+#define GEFBitBltLoadFailed 122
+#define GEFClassMismatch 114
+#define GEFEdgeDataTooSmall 112
+#define GEFEngineIsInteger 101
+#define GEFEngineIsWords 102
+#define GEFEngineStopped 104
+#define GEFEngineTooSmall 103
+#define GEFEntityCheckFailed 120
+#define GEFEntityLoadFailed 119
+#define GEFFillDataTooSmall 113
+#define GEFFormLoadFailed 123
+#define GEFSizeMismatch 115
+#define GEFWorkBufferBadMagic 108
+#define GEFWorkBufferIsInteger 105
+#define GEFWorkBufferIsPointers 106
+#define GEFWorkBufferStartWrong 110
+#define GEFWorkBufferTooSmall 107
+#define GEFWorkBufferWrongSize 109
+#define GEFWorkTooBig 111
+#define GEFWrongEdge 118
+#define GEFWrongFill 117
+#define GEFWrongState 116
 #define GEFillIndexLeft 8
 #define GEFillIndexRight 9
 #define GENumLines 7
@@ -221,6 +245,8 @@
 #define GWTimeNextAETEntry 104
 #define GWTimeNextFillEntry 98
 #define GWTimeNextGETEntry 94
+#define PrimErrBadArgument 3
+#define PrimErrBadNumArgs 5
 
 /*** Function Prototypes ***/
 static sqInt accurateLengthOfwith(sqInt deltaX, sqInt deltaY);
@@ -421,9 +447,9 @@
 static void * loadBBFn;
 static const char *moduleName =
 #ifdef SQUEAK_BUILTIN_PLUGIN
-	"B2DPlugin 6 April 2013 (i)"
+	"B2DPlugin 13 April 2013 (i)"
 #else
-	"B2DPlugin 6 April 2013 (e)"
+	"B2DPlugin 13 April 2013 (e)"
 #endif
 ;
 static int* objBuffer;
@@ -3570,7 +3596,7 @@
 
 	edge = workBuffer[GWLastExportedEdge];
 	if ((interpreterProxy->slotSizeOf(edgeOop)) < ETBalloonEdgeDataSize) {
-		return interpreterProxy->primitiveFail();
+		return null;
 	}
 	/* begin edgeXValueOf:put: */
 	value = interpreterProxy->fetchIntegerofObject(ETXValueIndex, edgeOop);
@@ -3912,45 +3938,46 @@
 }
 
 
-/*	Load the entire state from the interpreter for the rendering primitives */
+/*	Load the entire state from the interpreter for the rendering primitives.
+	 Answer 0 on success or a non-zero failure code on failure. */
 
 static sqInt loadRenderingState(void) {
     sqInt edgeOop;
+    sqInt failCode;
     sqInt fillOop;
     sqInt state;
 
 	if (!((interpreterProxy->methodArgumentCount()) == 2)) {
-		return interpreterProxy->primitiveFail();
+		return PrimErrBadNumArgs;
 	}
+	if (((failCode = quickLoadEngineFrom(interpreterProxy->stackValue(2)))) != 0) {
+		return failCode;
+	}
 	fillOop = interpreterProxy->stackObjectValue(0);
 	edgeOop = interpreterProxy->stackObjectValue(1);
-	engine = interpreterProxy->stackObjectValue(2);
 	if (interpreterProxy->failed()) {
-		return 0;
+		return PrimErrBadArgument;
 	}
-	if (!(quickLoadEngineFrom(engine))) {
-		return 0;
+	if (!(((failCode = loadSpanBufferFrom(interpreterProxy->fetchPointerofObject(BESpanIndex, engine)))) == 0)) {
+		return failCode;
 	}
-	if (!(loadSpanBufferFrom(interpreterProxy->fetchPointerofObject(BESpanIndex, engine)))) {
-		return 0;
-	}
 	if (!(loadBitBltFrom(interpreterProxy->fetchPointerofObject(BEBitBltIndex, engine)))) {
-		return 0;
+		return GEFBitBltLoadFailed;
 	}
 	if (!(loadFormsFrom(interpreterProxy->fetchPointerofObject(BEFormsIndex, engine)))) {
-		return 0;
+		return GEFFormLoadFailed;
 	}
 	if ((interpreterProxy->slotSizeOf(edgeOop)) < ETBalloonEdgeDataSize) {
-		return 0;
+		return GEFEdgeDataTooSmall;
 	}
 	if ((interpreterProxy->slotSizeOf(fillOop)) < FTBalloonFillDataSize) {
-		return 0;
+		return GEFFillDataTooSmall;
 	}
 	state = workBuffer[GWState];
 	if ((state == GEStateWaitingForEdge) || ((state == GEStateWaitingForFill) || (state == GEStateWaitingChange))) {
-		return 0;
+		return GEFWrongState;
 	}
-	return 1;
+	return 0;
 }
 
 static sqInt loadShapenSegmentsfilllineWidthlineFillpointsShort(int *points, sqInt nSegments, sqInt fillIndex, sqInt lineWidth, sqInt lineFill, sqInt pointsShort) {
@@ -4041,13 +4068,14 @@
 }
 
 
-/*	Load the span buffer from the given oop. */
+/*	Load the span buffer from the given oop.
+	 Answer 0 on success or a non-zero failure code on failure. */
 
 static sqInt loadSpanBufferFrom(sqInt spanOop) {
     sqInt value;
 
 	if (!((interpreterProxy->fetchClassOf(spanOop)) == (interpreterProxy->classBitmap()))) {
-		return 0;
+		return GEFClassMismatch;
 	}
 
 	/* Leave last entry unused to avoid complications */
@@ -4056,7 +4084,7 @@
 	/* begin spanSizePut: */
 	value = (interpreterProxy->slotSizeOf(spanOop)) - 1;
 	workBuffer[GWSpanSize] = value;
-	return 1;
+	return 0;
 }
 
 
@@ -4211,24 +4239,24 @@
 
 static sqInt loadWorkBufferFrom(sqInt wbOop) {
 	if ((wbOop & 1)) {
-		return 0;
+		return GEFWorkBufferIsInteger;
 	}
 	if (!(interpreterProxy->isWords(wbOop))) {
-		return 0;
+		return GEFWorkBufferIsPointers;
 	}
 	if ((interpreterProxy->slotSizeOf(wbOop)) < GWMinimalSize) {
-		return 0;
+		return GEFWorkBufferTooSmall;
 	}
 	/* begin workBufferPut: */
 	workBuffer = interpreterProxy->firstIndexableField(wbOop);
 	if (!((workBuffer[GWMagicIndex]) == GWMagicNumber)) {
-		return 0;
+		return GEFWorkBufferBadMagic;
 	}
 	if (!((workBuffer[GWSize]) == (interpreterProxy->slotSizeOf(wbOop)))) {
-		return 0;
+		return GEFWorkBufferWrongSize;
 	}
 	if (!((workBuffer[GWObjStart]) == GWHeaderSize)) {
-		return 0;
+		return GEFWorkBufferStartWrong;
 	}
 	objBuffer = workBuffer + (workBuffer[GWObjStart]);
 	getBuffer = objBuffer + (workBuffer[GWObjUsed]);
@@ -4237,9 +4265,9 @@
 
 	aetBuffer = getBuffer + (workBuffer[GWGETUsed]);
 	if ((((GWHeaderSize + (workBuffer[GWObjUsed])) + (workBuffer[GWGETUsed])) + (workBuffer[GWAETUsed])) > (workBuffer[GWSize])) {
-		return 0;
+		return GEFWorkTooBig;
 	}
-	return 1;
+	return 0;
 }
 
 
@@ -4306,16 +4334,14 @@
 }
 
 EXPORT(sqInt) primitiveAbortProcessing(void) {
+    sqInt failureCode;
+
 	if (!((interpreterProxy->methodArgumentCount()) == 0)) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(PrimErrBadNumArgs);
 	}
-	engine = interpreterProxy->stackObjectValue(0);
-	if (interpreterProxy->failed()) {
-		return null;
+	if (!(((failureCode = quickLoadEngineFrom(interpreterProxy->stackValue(0)))) == 0)) {
+		return interpreterProxy->primitiveFailFor(failureCode);
 	}
-	if (!(quickLoadEngineFrom(engine))) {
-		return interpreterProxy->primitiveFail();
-	}
 	workBuffer[GWState] = GEStateCompleted;
 	/* begin storeEngineStateInto: */
 	workBuffer[GWObjUsed] = objUsed;
@@ -4327,34 +4353,34 @@
 EXPORT(sqInt) primitiveAddActiveEdgeEntry(void) {
     sqInt edge;
     sqInt edgeOop;
+    sqInt failureCode;
     sqInt value;
 
 	if (doProfileStats) {
 		geProfileTime = interpreterProxy->ioMicroMSecs();
 	}
 	if (!((interpreterProxy->methodArgumentCount()) == 1)) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(PrimErrBadNumArgs);
 	}
+	if (!(((failureCode = quickLoadEngineFromrequiredState(interpreterProxy->stackValue(1), GEStateWaitingForEdge))) == 0)) {
+		return interpreterProxy->primitiveFailFor(failureCode);
+	}
 	edgeOop = interpreterProxy->stackObjectValue(0);
-	engine = interpreterProxy->stackObjectValue(1);
 	if (interpreterProxy->failed()) {
-		return null;
+		return interpreterProxy->primitiveFailFor(PrimErrBadArgument);
 	}
-	if (!(quickLoadEngineFromrequiredState(engine, GEStateWaitingForEdge))) {
-		return interpreterProxy->primitiveFail();
-	}
 	edge = loadEdgeStateFrom(edgeOop);
-	if (interpreterProxy->failed()) {
-		return null;
+	if (edge == null) {
+		return interpreterProxy->primitiveFailFor(GEFEdgeDataTooSmall);
 	}
 	if (!(needAvailableSpace(1))) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFWorkTooBig);
 	}
 	if ((objBuffer[edge + GENumLines]) > 0) {
 		insertEdgeIntoAET(edge);
 	}
 	if (engineStopped) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFEngineStopped);
 	}
 	workBuffer[GWState] = GEStateAddingFromGET;
 	/* begin storeEngineStateInto: */
@@ -4370,6 +4396,7 @@
 
 EXPORT(sqInt) primitiveAddBezier(void) {
     sqInt endOop;
+    sqInt failureCode;
     sqInt leftFill;
     sqInt nSegments;
     sqInt rightFill;
@@ -4380,7 +4407,7 @@
 	/* Fail if we have the wrong number of arguments */
 
 	if (!((interpreterProxy->methodArgumentCount()) == 5)) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(PrimErrBadNumArgs);
 	}
 	rightFill = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(0));
 	leftFill = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(1));
@@ -4388,13 +4415,13 @@
 	endOop = interpreterProxy->stackObjectValue(3);
 	startOop = interpreterProxy->stackObjectValue(4);
 	if (interpreterProxy->failed()) {
-		return null;
+		return interpreterProxy->primitiveFailFor(PrimErrBadArgument);
 	}
-	if (!(quickLoadEngineFromrequiredState(interpreterProxy->stackObjectValue(5), GEStateUnlocked))) {
-		return interpreterProxy->primitiveFail();
+	if (!(((failureCode = quickLoadEngineFromrequiredState(interpreterProxy->stackValue(5), GEStateUnlocked))) == 0)) {
+		return interpreterProxy->primitiveFailFor(failureCode);
 	}
 	if (!((isFillOkay(leftFill)) && (isFillOkay(rightFill)))) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFWrongFill);
 	}
 	if ((leftFill == rightFill) && 0) {
 		return interpreterProxy->pop(6);
@@ -4403,7 +4430,7 @@
 	loadPointfrom(((int *) (workBuffer + GWPoint2)), viaOop);
 	loadPointfrom(((int *) (workBuffer + GWPoint3)), endOop);
 	if (interpreterProxy->failed()) {
-		return 0;
+		return interpreterProxy->primitiveFailFor(PrimErrBadArgument);
 	}
 	/* begin transformPoints: */
 	if (3 > 0) {
@@ -4440,30 +4467,32 @@
 
 		/* begin wbStackClear */
 		workBuffer[GWBufferTop] = (workBuffer[GWSize]);
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFEngineStopped);
 	}
-	if (!(interpreterProxy->failed())) {
-		/* begin storeEngineStateInto: */
-		workBuffer[GWObjUsed] = objUsed;
-		interpreterProxy->pop(5);
+	if (interpreterProxy->failed()) {
+		return interpreterProxy->primitiveFailFor(GEFEntityLoadFailed);
 	}
+	/* begin storeEngineStateInto: */
+	workBuffer[GWObjUsed] = objUsed;
+	interpreterProxy->pop(5);
 }
 
 EXPORT(sqInt) primitiveAddBezierShape(void) {
+    sqInt failureCode;
     sqInt fillIndex;
-    sqInt isArray;
     sqInt length;
     sqInt lineFill;
     sqInt lineWidth;
     sqInt nSegments;
     sqInt points;
+    sqInt pointsIsArray;
     sqInt segSize;
 
 
 	/* Fail if we have the wrong number of arguments */
 
 	if (!((interpreterProxy->methodArgumentCount()) == 5)) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(PrimErrBadNumArgs);
 	}
 	lineFill = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(0));
 	lineWidth = interpreterProxy->stackIntegerValue(1);
@@ -4471,31 +4500,31 @@
 	nSegments = interpreterProxy->stackIntegerValue(3);
 	points = interpreterProxy->stackObjectValue(4);
 	if (interpreterProxy->failed()) {
-		return null;
+		return interpreterProxy->primitiveFailFor(PrimErrBadArgument);
 	}
-	if (!(quickLoadEngineFromrequiredState(interpreterProxy->stackObjectValue(5), GEStateUnlocked))) {
-		return interpreterProxy->primitiveFail();
+	if (!(((failureCode = quickLoadEngineFromrequiredState(interpreterProxy->stackValue(5), GEStateUnlocked))) == 0)) {
+		return interpreterProxy->primitiveFailFor(failureCode);
 	}
 	length = interpreterProxy->slotSizeOf(points);
 	if (interpreterProxy->isWords(points)) {
 
 		/* Either PointArray or ShortPointArray */
 
-		isArray = 0;
+		pointsIsArray = 0;
 		if (!((length == (nSegments * 3)) || (length == (nSegments * 6)))) {
-			return interpreterProxy->primitiveFail();
+			return interpreterProxy->primitiveFailFor(PrimErrBadArgument);
 		}
 	} else {
 
 		/* Must be Array of points */
 
 		if (!(interpreterProxy->isArray(points))) {
-			return interpreterProxy->primitiveFail();
+			return interpreterProxy->primitiveFailFor(PrimErrBadArgument);
 		}
 		if (!(length == (nSegments * 3))) {
-			return interpreterProxy->primitiveFail();
+			return interpreterProxy->primitiveFailFor(PrimErrBadArgument);
 		}
-		isArray = 1;
+		pointsIsArray = 1;
 	}
 	if ((lineWidth == 0) || (lineFill == 0)) {
 		segSize = GLBaseSize;
@@ -4503,15 +4532,15 @@
 		segSize = GLWideSize;
 	}
 	if (!(needAvailableSpace(segSize * nSegments))) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFWorkTooBig);
 	}
 	if (!((isFillOkay(lineFill)) && (isFillOkay(fillIndex)))) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFWrongFill);
 	}
 	lineFill = transformColor(lineFill);
 	fillIndex = transformColor(fillIndex);
 	if (engineStopped) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFEngineStopped);
 	}
 	if (((lineFill == 0) || (lineWidth == 0)) && (fillIndex == 0)) {
 		return interpreterProxy->pop(5);
@@ -4522,25 +4551,27 @@
 			lineWidth = 1;
 		}
 	}
-	if (isArray) {
+	if (pointsIsArray) {
 		loadArrayShapenSegmentsfilllineWidthlineFill(points, nSegments, fillIndex, lineWidth, lineFill);
 	} else {
 		loadShapenSegmentsfilllineWidthlineFillpointsShort(interpreterProxy->firstIndexableField(points), nSegments, fillIndex, lineWidth, lineFill, (nSegments * 3) == length);
 	}
 	if (engineStopped) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFEngineStopped);
 	}
-	if (!(interpreterProxy->failed())) {
-		workBuffer[GWNeedsFlush] = 1;
-		/* begin storeEngineStateInto: */
-		workBuffer[GWObjUsed] = objUsed;
-		interpreterProxy->pop(5);
+	if (interpreterProxy->failed()) {
+		return interpreterProxy->primitiveFailFor(GEFEntityLoadFailed);
 	}
+	workBuffer[GWNeedsFlush] = 1;
+	/* begin storeEngineStateInto: */
+	workBuffer[GWObjUsed] = objUsed;
+	interpreterProxy->pop(5);
 }
 
 EXPORT(sqInt) primitiveAddBitmapFill(void) {
     sqInt cmOop;
     sqInt dirOop;
+    sqInt failureCode;
     sqInt fill;
     sqInt formOop;
     sqInt nrmOop;
@@ -4552,51 +4583,49 @@
 	/* Fail if we have the wrong number of arguments */
 
 	if (!((interpreterProxy->methodArgumentCount()) == 7)) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(PrimErrBadNumArgs);
 	}
 	xIndex = interpreterProxy->stackIntegerValue(0);
 	if (xIndex <= 0) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(PrimErrBadArgument);
 	}
 	nrmOop = interpreterProxy->stackObjectValue(1);
 	dirOop = interpreterProxy->stackObjectValue(2);
 	originOop = interpreterProxy->stackObjectValue(3);
 	tileFlag = interpreterProxy->booleanValueOf(interpreterProxy->stackValue(4));
-	if (tileFlag) {
-		tileFlag = 1;
-	} else {
-		tileFlag = 0;
-	}
 	cmOop = interpreterProxy->stackObjectValue(5);
 	formOop = interpreterProxy->stackObjectValue(6);
 	if (interpreterProxy->failed()) {
-		return null;
+		return interpreterProxy->primitiveFailFor(PrimErrBadArgument);
 	}
-	if (!(quickLoadEngineFromrequiredState(interpreterProxy->stackObjectValue(7), GEStateUnlocked))) {
-		return interpreterProxy->primitiveFail();
+	if (!(((failureCode = quickLoadEngineFromrequiredState(interpreterProxy->stackValue(7), GEStateUnlocked))) == 0)) {
+		return interpreterProxy->primitiveFailFor(failureCode);
 	}
 	loadPointfrom(((int *) (workBuffer + GWPoint1)), originOop);
 	loadPointfrom(((int *) (workBuffer + GWPoint2)), dirOop);
 	loadPointfrom(((int *) (workBuffer + GWPoint3)), nrmOop);
 	if (interpreterProxy->failed()) {
-		return 0;
+		return interpreterProxy->primitiveFailFor(GEFBadPoint);
 	}
-	fill = loadBitmapFillcolormaptilefromalongnormalxIndex(formOop, cmOop, tileFlag, ((int *) (workBuffer + GWPoint1)), ((int *) (workBuffer + GWPoint2)), ((int *) (workBuffer + GWPoint3)), xIndex - 1);
+	fill = loadBitmapFillcolormaptilefromalongnormalxIndex(formOop, cmOop, (tileFlag
+		? 1
+		: 0), ((int *) (workBuffer + GWPoint1)), ((int *) (workBuffer + GWPoint2)), ((int *) (workBuffer + GWPoint3)), xIndex - 1);
 	if (engineStopped) {
 
 		/* Make sure the stack is okay */
 
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFEngineStopped);
 	}
-	if (!(interpreterProxy->failed())) {
-		/* begin storeEngineStateInto: */
-		workBuffer[GWObjUsed] = objUsed;
-		interpreterProxy->pop(8);
-		interpreterProxy->push(interpreterProxy->positive32BitIntegerFor(fill));
+	if (interpreterProxy->failed()) {
+		return interpreterProxy->primitiveFailFor(GEFEntityLoadFailed);
 	}
+	/* begin storeEngineStateInto: */
+	workBuffer[GWObjUsed] = objUsed;
+	interpreterProxy->popthenPush(8, interpreterProxy->positive32BitIntegerFor(fill));
 }
 
 EXPORT(sqInt) primitiveAddCompressedShape(void) {
+    sqInt failureCode;
     sqInt fillIndexList;
     sqInt leftFills;
     sqInt lineFills;
@@ -4610,7 +4639,7 @@
 	/* Fail if we have the wrong number of arguments */
 
 	if (!((interpreterProxy->methodArgumentCount()) == 7)) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(PrimErrBadNumArgs);
 	}
 	fillIndexList = interpreterProxy->stackObjectValue(0);
 	lineFills = interpreterProxy->stackObjectValue(1);
@@ -4620,16 +4649,16 @@
 	nSegments = interpreterProxy->stackIntegerValue(5);
 	points = interpreterProxy->stackObjectValue(6);
 	if (interpreterProxy->failed()) {
-		return null;
+		return interpreterProxy->primitiveFailFor(PrimErrBadArgument);
 	}
-	if (!(quickLoadEngineFromrequiredState(interpreterProxy->stackObjectValue(7), GEStateUnlocked))) {
-		return interpreterProxy->primitiveFail();
+	if (!(((failureCode = quickLoadEngineFromrequiredState(interpreterProxy->stackValue(7), GEStateUnlocked))) == 0)) {
+		return interpreterProxy->primitiveFailFor(failureCode);
 	}
 	if (!(checkCompressedShapesegmentsleftFillsrightFillslineWidthslineFillsfillIndexList(points, nSegments, leftFills, rightFills, lineWidths, lineFills, fillIndexList))) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFEntityCheckFailed);
 	}
 	if (!(needAvailableSpace((((GBBaseSize < GLBaseSize) ? GLBaseSize : GBBaseSize)) * nSegments))) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFWorkTooBig);
 	}
 
 	/* Then actually load the compressed shape */
@@ -4637,18 +4666,20 @@
 	pointsShort = (interpreterProxy->slotSizeOf(points)) == (nSegments * 3);
 	loadCompressedShapesegmentsleftFillsrightFillslineWidthslineFillsfillIndexListpointShort(interpreterProxy->firstIndexableField(points), nSegments, interpreterProxy->firstIndexableField(leftFills), interpreterProxy->firstIndexableField(rightFills), interpreterProxy->firstIndexableField(lineWidths), interpreterProxy->firstIndexableField(lineFills), interpreterProxy->firstIndexableField(fillIndexList), pointsShort);
 	if (engineStopped) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFEngineStopped);
 	}
-	if (!(interpreterProxy->failed())) {
-		workBuffer[GWNeedsFlush] = 1;
-		/* begin storeEngineStateInto: */
-		workBuffer[GWObjUsed] = objUsed;
-		interpreterProxy->pop(7);
+	if (interpreterProxy->failed()) {
+		return interpreterProxy->primitiveFailFor(GEFEntityLoadFailed);
 	}
+	workBuffer[GWNeedsFlush] = 1;
+	/* begin storeEngineStateInto: */
+	workBuffer[GWObjUsed] = objUsed;
+	interpreterProxy->pop(7);
 }
 
 EXPORT(sqInt) primitiveAddGradientFill(void) {
     sqInt dirOop;
+    sqInt failureCode;
     sqInt fill;
     sqInt isRadial;
     sqInt nrmOop;
@@ -4659,7 +4690,7 @@
 	/* Fail if we have the wrong number of arguments */
 
 	if (!((interpreterProxy->methodArgumentCount()) == 5)) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(PrimErrBadNumArgs);
 	}
 	isRadial = interpreterProxy->booleanValueOf(interpreterProxy->stackValue(0));
 	nrmOop = interpreterProxy->stackValue(1);
@@ -4667,34 +4698,35 @@
 	originOop = interpreterProxy->stackValue(3);
 	rampOop = interpreterProxy->stackValue(4);
 	if (interpreterProxy->failed()) {
-		return null;
+		return interpreterProxy->primitiveFailFor(PrimErrBadArgument);
 	}
-	if (!(quickLoadEngineFromrequiredState(interpreterProxy->stackObjectValue(5), GEStateUnlocked))) {
-		return interpreterProxy->primitiveFail();
+	if (!(((failureCode = quickLoadEngineFromrequiredState(interpreterProxy->stackValue(5), GEStateUnlocked))) == 0)) {
+		return interpreterProxy->primitiveFailFor(failureCode);
 	}
 	loadPointfrom(((int *) (workBuffer + GWPoint1)), originOop);
 	loadPointfrom(((int *) (workBuffer + GWPoint2)), dirOop);
 	loadPointfrom(((int *) (workBuffer + GWPoint3)), nrmOop);
 	if (interpreterProxy->failed()) {
-		return 0;
+		return interpreterProxy->primitiveFailFor(GEFBadPoint);
 	}
 	fill = loadGradientFillfromalongnormalisRadial(rampOop, ((int *) (workBuffer + GWPoint1)), ((int *) (workBuffer + GWPoint2)), ((int *) (workBuffer + GWPoint3)), isRadial);
 	if (engineStopped) {
 
 		/* Make sure the stack is okay */
 
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFEngineStopped);
 	}
-	if (!(interpreterProxy->failed())) {
-		/* begin storeEngineStateInto: */
-		workBuffer[GWObjUsed] = objUsed;
-		interpreterProxy->pop(6);
-		interpreterProxy->push(interpreterProxy->positive32BitIntegerFor(fill));
+	if (interpreterProxy->failed()) {
+		return interpreterProxy->primitiveFailFor(GEFEntityLoadFailed);
 	}
+	/* begin storeEngineStateInto: */
+	workBuffer[GWObjUsed] = objUsed;
+	interpreterProxy->popthenPush(6, interpreterProxy->positive32BitIntegerFor(fill));
 }
 
 EXPORT(sqInt) primitiveAddLine(void) {
     sqInt endOop;
+    sqInt failureCode;
     sqInt leftFill;
     sqInt rightFill;
     sqInt startOop;
@@ -4703,25 +4735,25 @@
 	/* Fail if we have the wrong number of arguments */
 
 	if (!((interpreterProxy->methodArgumentCount()) == 4)) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(PrimErrBadNumArgs);
 	}
 	rightFill = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(0));
 	leftFill = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(1));
 	endOop = interpreterProxy->stackObjectValue(2);
 	startOop = interpreterProxy->stackObjectValue(3);
 	if (interpreterProxy->failed()) {
-		return null;
+		return interpreterProxy->primitiveFailFor(PrimErrBadArgument);
 	}
-	if (!(quickLoadEngineFromrequiredState(interpreterProxy->stackObjectValue(4), GEStateUnlocked))) {
-		return interpreterProxy->primitiveFail();
+	if (!(((failureCode = quickLoadEngineFromrequiredState(interpreterProxy->stackValue(4), GEStateUnlocked))) == 0)) {
+		return interpreterProxy->primitiveFailFor(failureCode);
 	}
 	if (!((isFillOkay(leftFill)) && (isFillOkay(rightFill)))) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFWrongFill);
 	}
 	loadPointfrom(((int *) (workBuffer + GWPoint1)), startOop);
 	loadPointfrom(((int *) (workBuffer + GWPoint2)), endOop);
 	if (interpreterProxy->failed()) {
-		return 0;
+		return interpreterProxy->primitiveFailFor(GEFBadPoint);
 	}
 	/* begin transformPoints: */
 	if (2 > 0) {
@@ -4739,23 +4771,25 @@
 	leftFill = transformColor(leftFill);
 	rightFill = transformColor(rightFill);
 	if (engineStopped) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFEngineStopped);
 	}
 	loadWideLinefromtolineFillleftFillrightFill(0, ((int *) (workBuffer + GWPoint1)), ((int *) (workBuffer + GWPoint2)), 0, leftFill, rightFill);
 	if (engineStopped) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFEngineStopped);
 	}
-	if (!(interpreterProxy->failed())) {
-		/* begin storeEngineStateInto: */
-		workBuffer[GWObjUsed] = objUsed;
-		interpreterProxy->pop(4);
+	if (interpreterProxy->failed()) {
+		return interpreterProxy->primitiveFailFor(GEFEntityLoadFailed);
 	}
+	/* begin storeEngineStateInto: */
+	workBuffer[GWObjUsed] = objUsed;
+	interpreterProxy->pop(4);
 }
 
 EXPORT(sqInt) primitiveAddOval(void) {
     sqInt borderIndex;
     sqInt borderWidth;
     sqInt endOop;
+    sqInt failureCode;
     sqInt fillIndex;
     sqInt startOop;
 
@@ -4763,7 +4797,7 @@
 	/* Fail if we have the wrong number of arguments */
 
 	if (!((interpreterProxy->methodArgumentCount()) == 5)) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(PrimErrBadNumArgs);
 	}
 	borderIndex = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(0));
 	borderWidth = interpreterProxy->stackIntegerValue(1);
@@ -4771,24 +4805,24 @@
 	endOop = interpreterProxy->stackObjectValue(3);
 	startOop = interpreterProxy->stackObjectValue(4);
 	if (interpreterProxy->failed()) {
-		return null;
+		return interpreterProxy->primitiveFailFor(PrimErrBadArgument);
 	}
-	if (!(quickLoadEngineFromrequiredState(interpreterProxy->stackObjectValue(5), GEStateUnlocked))) {
-		return interpreterProxy->primitiveFail();
+	if (!(((failureCode = quickLoadEngineFromrequiredState(interpreterProxy->stackValue(5), GEStateUnlocked))) == 0)) {
+		return interpreterProxy->primitiveFailFor(failureCode);
 	}
 	if (!((isFillOkay(borderIndex)) && (isFillOkay(fillIndex)))) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFWrongFill);
 	}
 	fillIndex = transformColor(fillIndex);
 	borderIndex = transformColor(borderIndex);
 	if (engineStopped) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFEngineStopped);
 	}
 	if ((fillIndex == 0) && ((borderIndex == 0) || (borderWidth <= 0))) {
 		return interpreterProxy->pop(5);
 	}
 	if (!(needAvailableSpace(16 * GBBaseSize))) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFWorkTooBig);
 	}
 	if ((borderWidth > 0) && (borderIndex != 0)) {
 		borderWidth = transformWidth(borderWidth);
@@ -4798,30 +4832,32 @@
 	loadPointfrom(((int *) (workBuffer + GWPoint1)), startOop);
 	loadPointfrom(((int *) (workBuffer + GWPoint2)), endOop);
 	if (interpreterProxy->failed()) {
-		return 0;
+		return interpreterProxy->primitiveFailFor(GEFBadPoint);
 	}
 	loadOvallineFillleftFillrightFill(borderWidth, borderIndex, 0, fillIndex);
 	if (engineStopped) {
 		/* begin wbStackClear */
 		workBuffer[GWBufferTop] = (workBuffer[GWSize]);
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFEngineStopped);
 	}
-	if (!(interpreterProxy->failed())) {
-		workBuffer[GWNeedsFlush] = 1;
-		/* begin storeEngineStateInto: */
-		workBuffer[GWObjUsed] = objUsed;
-		interpreterProxy->pop(5);
+	if (interpreterProxy->failed()) {
+		return interpreterProxy->primitiveFailFor(GEFEntityLoadFailed);
 	}
+	workBuffer[GWNeedsFlush] = 1;
+	/* begin storeEngineStateInto: */
+	workBuffer[GWObjUsed] = objUsed;
+	interpreterProxy->pop(5);
 }
 
 EXPORT(sqInt) primitiveAddPolygon(void) {
+    sqInt failureCode;
     sqInt fillIndex;
-    sqInt isArray;
     sqInt length;
     sqInt lineFill;
     sqInt lineWidth;
     sqInt nPoints;
     sqInt points;
+    sqInt pointsIsArray;
     sqInt segSize;
     sqInt i;
     sqInt x0;
@@ -4833,7 +4869,7 @@
 	/* Fail if we have the wrong number of arguments */
 
 	if (!((interpreterProxy->methodArgumentCount()) == 5)) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(PrimErrBadNumArgs);
 	}
 	lineFill = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(0));
 	lineWidth = interpreterProxy->stackIntegerValue(1);
@@ -4841,31 +4877,31 @@
 	nPoints = interpreterProxy->stackIntegerValue(3);
 	points = interpreterProxy->stackObjectValue(4);
 	if (interpreterProxy->failed()) {
-		return null;
+		return interpreterProxy->primitiveFailFor(PrimErrBadArgument);
 	}
-	if (!(quickLoadEngineFromrequiredState(interpreterProxy->stackObjectValue(5), GEStateUnlocked))) {
-		return interpreterProxy->primitiveFail();
+	if (!(((failureCode = quickLoadEngineFromrequiredState(interpreterProxy->stackValue(5), GEStateUnlocked))) == 0)) {
+		return interpreterProxy->primitiveFailFor(failureCode);
 	}
 	length = interpreterProxy->slotSizeOf(points);
 	if (interpreterProxy->isWords(points)) {
 
 		/* Either PointArray or ShortPointArray */
 
-		isArray = 0;
+		pointsIsArray = 0;
 		if (!((length == nPoints) || ((nPoints * 2) == length))) {
-			return interpreterProxy->primitiveFail();
+			return interpreterProxy->primitiveFailFor(PrimErrBadArgument);
 		}
 	} else {
 
 		/* Must be Array of points */
 
 		if (!(interpreterProxy->isArray(points))) {
-			return interpreterProxy->primitiveFail();
+			return interpreterProxy->primitiveFailFor(PrimErrBadArgument);
 		}
 		if (!(length == nPoints)) {
-			return interpreterProxy->primitiveFail();
+			return interpreterProxy->primitiveFailFor(PrimErrBadArgument);
 		}
-		isArray = 1;
+		pointsIsArray = 1;
 	}
 	if ((lineWidth == 0) || (lineFill == 0)) {
 		segSize = GLBaseSize;
@@ -4876,20 +4912,20 @@
 		return interpreterProxy->primitiveFail();
 	}
 	if (!((isFillOkay(lineFill)) && (isFillOkay(fillIndex)))) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFWrongFill);
 	}
 	lineFill = transformColor(lineFill);
 	fillIndex = transformColor(fillIndex);
 	if (engineStopped) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFEngineStopped);
 	}
 	if (((lineFill == 0) || (lineWidth == 0)) && (fillIndex == 0)) {
-		return interpreterProxy->pop(6);
+		return interpreterProxy->pop(5);
 	}
 	if (!(lineWidth == 0)) {
 		lineWidth = transformWidth(lineWidth);
 	}
-	if (isArray) {
+	if (pointsIsArray) {
 		/* begin loadArrayPolygon:nPoints:fill:lineWidth:lineFill: */
 		loadPointfrom(((int *) (workBuffer + GWPoint1)), interpreterProxy->fetchPointerofObject(0, points));
 		if (interpreterProxy->failed()) {
@@ -4933,20 +4969,22 @@
 		loadPolygonnPointsfilllineWidthlineFillpointsShort(interpreterProxy->firstIndexableField(points), nPoints, fillIndex, lineWidth, lineFill, nPoints == length);
 	}
 	if (engineStopped) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFEngineStopped);
 	}
-	if (!(interpreterProxy->failed())) {
-		workBuffer[GWNeedsFlush] = 1;
-		/* begin storeEngineStateInto: */
-		workBuffer[GWObjUsed] = objUsed;
-		interpreterProxy->pop(5);
+	if (interpreterProxy->failed()) {
+		return interpreterProxy->primitiveFailFor(GEFEntityLoadFailed);
 	}
+	workBuffer[GWNeedsFlush] = 1;
+	/* begin storeEngineStateInto: */
+	workBuffer[GWObjUsed] = objUsed;
+	interpreterProxy->pop(5);
 }
 
 EXPORT(sqInt) primitiveAddRect(void) {
     sqInt borderIndex;
     sqInt borderWidth;
     sqInt endOop;
+    sqInt failureCode;
     sqInt fillIndex;
     sqInt startOop;
 
@@ -4954,7 +4992,7 @@
 	/* Fail if we have the wrong number of arguments */
 
 	if (!((interpreterProxy->methodArgumentCount()) == 5)) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(PrimErrBadNumArgs);
 	}
 	borderIndex = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(0));
 	borderWidth = interpreterProxy->stackIntegerValue(1);
@@ -4962,24 +5000,24 @@
 	endOop = interpreterProxy->stackObjectValue(3);
 	startOop = interpreterProxy->stackObjectValue(4);
 	if (interpreterProxy->failed()) {
-		return null;
+		return interpreterProxy->primitiveFailFor(PrimErrBadArgument);
 	}
-	if (!(quickLoadEngineFromrequiredState(interpreterProxy->stackObjectValue(5), GEStateUnlocked))) {
-		return interpreterProxy->primitiveFail();
+	if (!(((failureCode = quickLoadEngineFromrequiredState(interpreterProxy->stackValue(5), GEStateUnlocked))) == 0)) {
+		return interpreterProxy->primitiveFailFor(failureCode);
 	}
 	if (!((isFillOkay(borderIndex)) && (isFillOkay(fillIndex)))) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFWrongFill);
 	}
 	borderIndex = transformColor(borderIndex);
 	fillIndex = transformColor(fillIndex);
 	if (engineStopped) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFEngineStopped);
 	}
 	if ((fillIndex == 0) && ((borderIndex == 0) || (borderWidth == 0))) {
 		return interpreterProxy->pop(5);
 	}
 	if (!(needAvailableSpace(4 * GLBaseSize))) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFWorkTooBig);
 	}
 	if ((borderWidth > 0) && (borderIndex != 0)) {
 		borderWidth = transformWidth(borderWidth);
@@ -4989,7 +5027,7 @@
 	loadPointfrom(((int *) (workBuffer + GWPoint1)), startOop);
 	loadPointfrom(((int *) (workBuffer + GWPoint3)), endOop);
 	if (interpreterProxy->failed()) {
-		return null;
+		return interpreterProxy->primitiveFailFor(GEFBadPoint);
 	}
 	(((int *) (workBuffer + GWPoint2)))[0] = ((((int *) (workBuffer + GWPoint3)))[0]);
 	(((int *) (workBuffer + GWPoint2)))[1] = ((((int *) (workBuffer + GWPoint1)))[1]);
@@ -5013,12 +5051,13 @@
 	loadWideLinefromtolineFillleftFillrightFill(borderWidth, ((int *) (workBuffer + GWPoint2)), ((int *) (workBuffer + GWPoint3)), borderIndex, 0, fillIndex);
 	loadWideLinefromtolineFillleftFillrightFill(borderWidth, ((int *) (workBuffer + GWPoint3)), ((int *) (workBuffer + GWPoint4)), borderIndex, 0, fillIndex);
 	loadWideLinefromtolineFillleftFillrightFill(borderWidth, ((int *) (workBuffer + GWPoint4)), ((int *) (workBuffer + GWPoint1)), borderIndex, 0, fillIndex);
-	if (!(interpreterProxy->failed())) {
-		workBuffer[GWNeedsFlush] = 1;
-		/* begin storeEngineStateInto: */
-		workBuffer[GWObjUsed] = objUsed;
-		interpreterProxy->pop(5);
+	if (interpreterProxy->failed()) {
+		return interpreterProxy->primitiveFailFor(GEFEntityLoadFailed);
 	}
+	workBuffer[GWNeedsFlush] = 1;
+	/* begin storeEngineStateInto: */
+	workBuffer[GWObjUsed] = objUsed;
+	interpreterProxy->pop(5);
 }
 
 
@@ -5027,25 +5066,25 @@
 EXPORT(sqInt) primitiveChangedActiveEdgeEntry(void) {
     sqInt edge;
     sqInt edgeOop;
+    sqInt failureCode;
     sqInt value;
 
 	if (doProfileStats) {
 		geProfileTime = interpreterProxy->ioMicroMSecs();
 	}
 	if (!((interpreterProxy->methodArgumentCount()) == 1)) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(PrimErrBadNumArgs);
 	}
+	if (!(((failureCode = quickLoadEngineFromrequiredState(interpreterProxy->stackValue(1), GEStateWaitingChange))) == 0)) {
+		return interpreterProxy->primitiveFailFor(failureCode);
+	}
 	edgeOop = interpreterProxy->stackObjectValue(0);
-	engine = interpreterProxy->stackObjectValue(1);
 	if (interpreterProxy->failed()) {
-		return null;
+		return interpreterProxy->primitiveFailFor(PrimErrBadArgument);
 	}
-	if (!(quickLoadEngineFromrequiredState(engine, GEStateWaitingChange))) {
-		return interpreterProxy->primitiveFail();
-	}
 	edge = loadEdgeStateFrom(edgeOop);
-	if (interpreterProxy->failed()) {
-		return null;
+	if (edge == null) {
+		return interpreterProxy->primitiveFailFor(GEFEdgeDataTooSmall);
 	}
 	if ((objBuffer[edge + GENumLines]) == 0) {
 		removeFirstAETEntry();
@@ -5070,27 +5109,28 @@
     sqInt buf2;
     sqInt diff;
     int *  dst;
+    sqInt failCode;
     sqInt i;
     int *  src;
     sqInt iLimiT;
 
 	if (!((interpreterProxy->methodArgumentCount()) == 2)) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(PrimErrBadNumArgs);
 	}
-	buf2 = interpreterProxy->stackObjectValue(0);
-	buf1 = interpreterProxy->stackObjectValue(1);
-	if (interpreterProxy->failed()) {
-		return null;
+	buf2 = interpreterProxy->stackValue(0);
+
+	/* Make sure the old buffer is properly initialized */
+
+	buf1 = interpreterProxy->stackValue(1);
+	if (!(((failCode = loadWorkBufferFrom(buf1))) == 0)) {
+		return interpreterProxy->primitiveFailFor(failCode);
 	}
-	if (!(loadWorkBufferFrom(buf1))) {
-		return interpreterProxy->primitiveFail();
-	}
 	if (!((interpreterProxy->fetchClassOf(buf1)) == (interpreterProxy->fetchClassOf(buf2)))) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFClassMismatch);
 	}
 	diff = (interpreterProxy->slotSizeOf(buf2)) - (interpreterProxy->slotSizeOf(buf1));
 	if (diff < 0) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFSizeMismatch);
 	}
 	src = workBuffer;
 	dst = interpreterProxy->firstIndexableField(buf2);
@@ -5104,8 +5144,8 @@
 	for (i = 0, iLimiT = (((workBuffer[GWSize]) - (workBuffer[GWBufferTop])) - 1); i <= iLimiT; i += 1) {
 		dst[i] = (src[i]);
 	}
-	if (!(loadWorkBufferFrom(buf2))) {
-		return interpreterProxy->primitiveFail();
+	if (!(((failCode = loadWorkBufferFrom(buf2))) == 0)) {
+		return interpreterProxy->primitiveFailFor(failCode);
 	}
 	interpreterProxy->pop(2);
 }
@@ -5114,26 +5154,23 @@
 /*	Note: Must load bitBlt and spanBuffer */
 
 EXPORT(sqInt) primitiveDisplaySpanBuffer(void) {
+    sqInt failureCode;
     sqInt value;
 
 	if (doProfileStats) {
 		geProfileTime = interpreterProxy->ioMicroMSecs();
 	}
 	if (!((interpreterProxy->methodArgumentCount()) == 0)) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(PrimErrBadNumArgs);
 	}
-	engine = interpreterProxy->stackObjectValue(0);
-	if (interpreterProxy->failed()) {
-		return null;
+	if (!(((failureCode = quickLoadEngineFromrequiredState(interpreterProxy->stackValue(0), GEStateBlitBuffer))) == 0)) {
+		return interpreterProxy->primitiveFailFor(failureCode);
 	}
-	if (!(quickLoadEngineFromrequiredState(engine, GEStateBlitBuffer))) {
-		return interpreterProxy->primitiveFail();
+	if (!(((failureCode = loadSpanBufferFrom(interpreterProxy->fetchPointerofObject(BESpanIndex, engine)))) == 0)) {
+		return interpreterProxy->primitiveFailFor(failureCode);
 	}
-	if (!(loadSpanBufferFrom(interpreterProxy->fetchPointerofObject(BESpanIndex, engine)))) {
-		return interpreterProxy->primitiveFail();
-	}
 	if (!(loadBitBltFrom(interpreterProxy->fetchPointerofObject(BEBitBltIndex, engine)))) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(GEFBitBltLoadFailed);
 	}
 	if (((workBuffer[GWCurrentY]) & (workBuffer[GWAAScanMask])) == (workBuffer[GWAAScanMask])) {
 		displaySpanBufferAt(workBuffer[GWCurrentY]);
@@ -5172,6 +5209,7 @@
 }
 
 EXPORT(sqInt) primitiveFinishedProcessing(void) {
+    sqInt failureCode;
     sqInt finished;
     sqInt value;
 
@@ -5179,15 +5217,11 @@
 		geProfileTime = interpreterProxy->ioMicroMSecs();
 	}
 	if (!((interpreterProxy->methodArgumentCount()) == 0)) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(PrimErrBadNumArgs);
 	}
-	engine = interpreterProxy->stackObjectValue(0);
-	if (interpreterProxy->failed()) {
-		return null;
+	if (!(((failureCode = quickLoadEngineFrom(interpreterProxy->stackValue(0)))) == 0)) {
+		return interpreterProxy->primitiveFailFor(failureCode);
 	}
-	if (!(quickLoadEngineFrom(engine))) {
-		return interpreterProxy->primitiveFail();
-	}
 	finished = (workBuffer[GWState]) == GEStateCompleted;
 	/* begin storeEngineStateInto: */
 	workBuffer[GWObjUsed] = objUsed;
@@ -5202,41 +5236,33 @@
 }
 
 EXPORT(sqInt) primitiveGetAALevel(void) {
+    sqInt failureCode;
+
 	if (!((interpreterProxy->methodArgumentCount()) == 0)) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(PrimErrBadNumArgs);
 	}
-	engine = interpreterProxy->stackObjectValue(0);
-	if (interpreterProxy->failed()) {
-		return null;
+	if (!(((failureCode = quickLoadEngineFrom(interpreterProxy->stackValue(0)))) == 0)) {
+		return interpreterProxy->primitiveFailFor(failureCode);
 	}
-	if (!(quickLoadEngineFrom(engine))) {
-		return interpreterProxy->primitiveFail();
-	}
 	interpreterProxy->pop(1);
 	interpreterProxy->pushInteger(workBuffer[GWAALevel]);
 }
 
 EXPORT(sqInt) primitiveGetBezierStats(void) {
+    sqInt failureCode;
     sqInt statOop;
     int *stats;
 
 	if (!((interpreterProxy->methodArgumentCount()) == 1)) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(PrimErrBadNumArgs);
 	}
+	if (!(((failureCode = quickLoadEngineFrom(interpreterProxy->stackValue(1)))) == 0)) {
+		return interpreterProxy->primitiveFailFor(failureCode);
+	}
 	statOop = interpreterProxy->stackObjectValue(0);
-	engine = interpreterProxy->stackObjectValue(1);
-	if (interpreterProxy->failed()) {
-		return null;
+	if (!((!(interpreterProxy->failed())) && ((interpreterProxy->isWords(statOop)) && ((interpreterProxy->slotSizeOf(statOop)) >= 4)))) {
+		return interpreterProxy->primitiveFailFor(PrimErrBadArgument);
 	}
-	if (!(quickLoadEngineFrom(engine))) {
-		return interpreterProxy->primitiveFail();
-	}
-	if (!(interpreterProxy->isWords(statOop))) {
-		return interpreterProxy->primitiveFail();
-	}
-	if ((interpreterProxy->slotSizeOf(statOop)) < 4) {
-		return interpreterProxy->primitiveFail();
-	}
 	stats = interpreterProxy->firstIndexableField(statOop);
 	stats[0] = ((stats[0]) + (workBuffer[GWBezierMonotonSubdivisions]));
 	stats[1] = ((stats[1]) + (workBuffer[GWBezierHeightSubdivisions]));
@@ -5246,59 +5272,44 @@
 }
 
 EXPORT(sqInt) primitiveGetClipRect(void) {
+    sqInt failureCode;
     sqInt pointOop;
     sqInt rectOop;
 
 	if (!((interpreterProxy->methodArgumentCount()) == 1)) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(PrimErrBadNumArgs);
 	}
+	if (!(((failureCode = quickLoadEngineFrom(interpreterProxy->stackValue(1)))) == 0)) {
+		return interpreterProxy->primitiveFailFor(failureCode);
+	}
 	rectOop = interpreterProxy->stackObjectValue(0);
-	engine = interpreterProxy->stackObjectValue(1);
-	if (interpreterProxy->failed()) {
-		return null;
+	if (!((!(interpreterProxy->failed())) && ((interpreterProxy->isPointers(rectOop)) && ((interpreterProxy->slotSizeOf(rectOop)) >= 2)))) {
+		return interpreterProxy->primitiveFailFor(PrimErrBadArgument);
 	}
-	if (!(quickLoadEngineFrom(engine))) {
-		return interpreterProxy->primitiveFail();
-	}
-	if (!(interpreterProxy->isPointers(rectOop))) {
-		return interpreterProxy->primitiveFail();
-	}
-	if ((interpreterProxy->slotSizeOf(rectOop)) < 2) {
-		return interpreterProxy->primitiveFail();
-	}
 	interpreterProxy->pushRemappableOop(rectOop);
 	pointOop = interpreterProxy->makePointwithxValueyValue(workBuffer[GWClipMinX], workBuffer[GWClipMinY]);
-	rectOop = interpreterProxy->popRemappableOop();
-	interpreterProxy->storePointerofObjectwithValue(0, rectOop, pointOop);
-	interpreterProxy->pushRemappableOop(rectOop);
+	interpreterProxy->storePointerofObjectwithValue(0, interpreterProxy->topRemappableOop(), pointOop);
 	pointOop = interpreterProxy->makePointwithxValueyValue(workBuffer[GWClipMaxX], workBuffer[GWClipMaxY]);
 	rectOop = interpreterProxy->popRemappableOop();
 	interpreterProxy->storePointerofObjectwithValue(1, rectOop, pointOop);
-	interpreterProxy->pop(2);
-	interpreterProxy->push(rectOop);
+	interpreterProxy->popthenPush(2, rectOop);
 }
 
 EXPORT(sqInt) primitiveGetCounts(void) {
+    sqInt failureCode;
     sqInt statOop;
     int *stats;
 
 	if (!((interpreterProxy->methodArgumentCount()) == 1)) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(PrimErrBadNumArgs);
 	}
+	if (!(((failureCode = quickLoadEngineFrom(interpreterProxy->stackValue(1)))) == 0)) {
+		return interpreterProxy->primitiveFailFor(failureCode);
+	}
 	statOop = interpreterProxy->stackObjectValue(0);
-	engine = interpreterProxy->stackObjectValue(1);
-	if (interpreterProxy->failed()) {
-		return null;
+	if (!((!(interpreterProxy->failed())) && ((interpreterProxy->isWords(statOop)) && ((interpreterProxy->slotSizeOf(statOop)) >= 9)))) {
+		return interpreterProxy->primitiveFailFor(PrimErrBadArgument);
 	}
-	if (!(quickLoadEngineFrom(engine))) {
-		return interpreterProxy->primitiveFail();
-	}
-	if (!(interpreterProxy->isWords(statOop))) {
-		return interpreterProxy->primitiveFail();
-	}
-	if ((interpreterProxy->slotSizeOf(statOop)) < 9) {
-		return interpreterProxy->primitiveFail();
-	}
 	stats = interpreterProxy->firstIndexableField(statOop);
 	stats[0] = ((stats[0]) + (workBuffer[GWCountInitializing]));
 	stats[1] = ((stats[1]) + (workBuffer[GWCountFinishTest]));
@@ -5313,16 +5324,14 @@
 }
 
 EXPORT(sqInt) primitiveGetDepth(void) {
+    sqInt failureCode;
+
 	if (!((interpreterProxy->methodArgumentCount()) == 0)) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(PrimErrBadNumArgs);
 	}
-	engine = interpreterProxy->stackObjectValue(0);
-	if (interpreterProxy->failed()) {
-		return null;
+	if (!(((failureCode = quickLoadEngineFrom(interpreterProxy->stackValue(0)))) == 0)) {
+		return interpreterProxy->primitiveFailFor(failureCode);
 	}
-	if (!(quickLoadEngineFrom(engine))) {
-		return interpreterProxy->primitiveFail();
-	}
 	interpreterProxy->pop(1);
 	interpreterProxy->pushInteger(workBuffer[GWCurrentZ]);
 }
@@ -5331,68 +5340,60 @@
 /*	Return the reason why the last operation failed. */
 
 EXPORT(sqInt) primitiveGetFailureReason(void) {
+    sqInt failCode;
+
 	if (!((interpreterProxy->methodArgumentCount()) == 0)) {
-		return interpreterProxy->primitiveFail();
+		return interpreterProxy->primitiveFailFor(PrimErrBadNumArgs);
 	}
-	engine = interpreterProxy->stackObjectValue(0);
-	if (interpreterProxy->failed()) {
-		return null;
-	}
+

@@ Diff output truncated at 50000 characters. @@


More information about the Vm-dev mailing list