diff --git a/Makefile b/Makefile index 2028be4..8151223 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ ASOPT=--warn -mcpu=arm1176jzf-s # available CCOPT=-O6 -ffreestanding -marm -mcpu=arm1176jzf-s -std=c99 -fpack-struct -Wno-packed-bitfield-compat -CFLAGS=-DSQ_CONFIG_DONE=1 -DNO_ISNAN=1 -fshort-wchar -DTYPE_LOWLEVEL -DTARGET_RPI -DLIB_HUB -DLIB_HID -DLIB_KBD -DFINAL -Iusb -Isqueak -Ibcm2835 -Ilib +CFLAGS=-DSQ_CONFIG_DONE=1 -DSQUEAK_BUILTIN_PLUGIN=1 -DNO_ISNAN=1 -fshort-wchar -DTYPE_LOWLEVEL -DTARGET_RPI -DLIB_HUB -DLIB_HID -DLIB_KBD -DFINAL -Iusb -Isqueak -Ibcm2835 -Ilib BUILDDIR=build diff --git a/bcm2835/config.h b/bcm2835/config.h new file mode 100644 index 0000000..5ff86b2 --- /dev/null +++ b/bcm2835/config.h @@ -0,0 +1,66 @@ +/* config.h. Generated automatically by configure. */ +/* config.h.in -- template for config.h -*- C -*- + * + * Copyright (C) 1996-2002 Ian Piumarta and other authors/contributors + * as listed elsewhere in this file. + * All rights reserved. + * + * This file is part of Unix Squeak. + * + * This file is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You may use and/or distribute this file ONLY as part of Squeak, under + * the terms of the Squeak License as described in `LICENSE' in the base of + * this distribution, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment to the original author(s) (and any + * other contributors mentioned herein) in the product documentation + * would be appreciated but is not required. + * + * 2. This notice must not be removed or altered in any source distribution. + * + * Using (or modifying this file for use) in any context other than Squeak + * changes these copyright conditions. Read the file `COPYING' in the + * directory `platforms/unix/doc' before proceeding with any such use. + * + * You are not allowed to distribute a modified version of this file + * under its original name without explicit permission to do so. If + * you change it, rename it. + */ + +/* Author: Ian.Piumarta@INRIA.Fr + * + * Last edited: 2002-11-30 16:00:59 by piumarta on calvin.inria.fr + */ + +/* typedefs */ + +/* #undef size_t */ +/* #undef socklen_t */ + +#define squeakInt64 long long + +/* architecture */ + +#define OS_TYPE "unix" + +#define VM_HOST "armv6l-none-eabi" +#define VM_HOST_CPU "armv6l" +/* #undef VM_HOST_VENDOR */ +#define VM_HOST_OS "none-eabi" + +#undef WORDS_BIGENDIAN +#undef DOUBLE_WORD_ALIGNMENT +#define DOUBLE_WORD_ORDER 1 + +/* other configured variables */ + +#define SQ_VERSION "3.4-5170" +#define VM_VERSION "3.4-1" +#define VM_LIBDIR "/usr/local/lib/squeak/3.4-1" +#define VM_MODULE_PREFIX "" +/* #undef VM_DLSYM_PREFIX */ diff --git a/bcm2835/sqPlatformSpecific.h b/bcm2835/sqPlatformSpecific.h index 6b177db..495e9e2 100644 --- a/bcm2835/sqPlatformSpecific.h +++ b/bcm2835/sqPlatformSpecific.h @@ -8,6 +8,9 @@ #undef sqImageFileWrite #undef sqAllocateMemory +#undef ioMSecs +#undef ioLowResMSecs +#undef ioMicroMSecs typedef struct _rpiImageFile { unsigned char *base; @@ -16,6 +19,7 @@ typedef struct _rpiImageFile { } rpiImageFile; #define sqImageFile rpiImageFile * +#define squeakFileOffsetType unsigned int void sqImageFileClose(sqImageFile f); sqImageFile sqImageFileOpen(char *fileName, char *mode); @@ -25,8 +29,4 @@ void sqImageFileSeek(sqImageFile f, int pos); int sqImageFileWrite(void *ptr, int elementSize, int count, sqImageFile f); void * sqAllocateMemory(int minHeapSize, int desiredHeapSize); -#undef ioMSecs -#undef ioLowResMSecs -#undef ioMicroMSecs - #define ScreenDepth 32 diff --git a/bcm2835/sqRpiDisplay.c b/bcm2835/sqRpiDisplay.c index f8c4955..689dda3 100644 --- a/bcm2835/sqRpiDisplay.c +++ b/bcm2835/sqRpiDisplay.c @@ -1,4 +1,6 @@ #include "sq.h" +#include "sqRpiDisplay.h" + #include "framebuffer.h" #include "types.h" #include "barrier.h" @@ -123,8 +125,11 @@ int ioSetFullScreen(int fullScreen) { return 0; } +int ioScreenDepth(void) { + return ScreenDepth; +} + int ioHasDisplayDepth(int depth) { - printf("%s depth=%i\n", __PRETTY_FUNCTION__, depth); if (depth == ScreenDepth) { return true; } diff --git a/bcm2835/sqRpiDisplay.h b/bcm2835/sqRpiDisplay.h new file mode 100644 index 0000000..7a369e7 --- /dev/null +++ b/bcm2835/sqRpiDisplay.h @@ -0,0 +1,6 @@ +#ifndef __RPI_DISPLAY +#define __RPI_DISPLAY + +void moveCursor(int x, int y); + +#endif \ No newline at end of file diff --git a/bcm2835/sqRpiHid.c b/bcm2835/sqRpiHid.c index cdd603a..12954aa 100644 --- a/bcm2835/sqRpiHid.c +++ b/bcm2835/sqRpiHid.c @@ -1,4 +1,6 @@ #include "sq.h" +#include "sqRpiDisplay.h" + #include "keyboard.h" #include "mouse.h" #include "timer.h" // watchdog @@ -16,6 +18,18 @@ extern int interruptCheckCounter; extern int interruptKeycode; extern int interruptPending; /* set to true by RecordKeystroke if interrupt key is pressed */ +/*** Variables -- Event Recording ***/ +#define MillisecondClockMask 536870911 +#define MAX_EVENT_BUFFER 64 +static sqInputEvent eventBuffer[MAX_EVENT_BUFFER]; +static int eventBufferGet = 0; +static int eventBufferPut = 0; + +static char lastKeys[255]; +static int lastMouseX = 0; +static int lastMouseY = 0; +static int lastMouseButton = 0; + void RecordKeystroke(unsigned char key, struct KeyboardModifiers modifiers) { int keystate; @@ -33,7 +47,7 @@ void RecordKeystroke(unsigned char key, struct KeyboardModifiers modifiers) { if (modifiers.LeftGui || modifiers.RightGui) { keyModifier = 1 << 11; } - keystate = (keyModifier) | (key & 0xff); + keystate = (keyModifier << 8) | (key & 0xff); if (keystate == interruptKeycode) { /* Note: interrupt key is "meta"; it not reported as a keystroke */ @@ -76,6 +90,143 @@ int ioPeekKeystroke(void) { return ioGetKeystrokeAndAdvance(false); } +sqInputEvent *nextEventPut(void) { + sqInputEvent *evt; + evt = eventBuffer + eventBufferPut; + eventBufferPut = (eventBufferPut + 1) % MAX_EVENT_BUFFER; + if (eventBufferGet == eventBufferPut) { + /* buffer overflow; drop the last event */ + eventBufferGet = (eventBufferGet + 1) % MAX_EVENT_BUFFER; + } + return evt; +} + +void rpiProcessMouseEvents(void) { + int mouseCount = MouseCount(); + if (mouseCount == 0) { + return; + } + + uint32_t mouse = MouseGetAddress(0); + int position = MouseGetPosition(mouse); + int posX = (position >> 16) & 0xffff; + int posY = position & 0xffff; + + int mouseButtons = MouseGetButtons(mouse); + int buttonState = 0; + if (mouseButtons & 0x01) { + buttonState |= RedButtonBit; + } + if (mouseButtons & 0x02) { + buttonState |= BlueButtonBit; + } + if (mouseButtons & 0x04) { + buttonState |= YellowButtonBit; + } + + if (posX != lastMouseX || posY != lastMouseY || buttonState != lastMouseButton) { + lastMouseX = posX; + lastMouseY = posY; + lastMouseButton = buttonState; + moveCursor(lastMouseX, lastMouseY); + + sqMouseEvent *event = (sqMouseEvent*) nextEventPut(); + + /* first the basics */ + event->type = EventTypeMouse; + event->timeStamp = ioMSecs() & MillisecondClockMask; + event->x = lastMouseX; + event->y = lastMouseY; + /* then the buttons */ + event->buttons = lastMouseButton & 0x07; + /* then the modifiers */ + event->modifiers = 0; //buttonState >> 3; + /* clean up reserved */ + event->reserved1 = 0; + } +} + +void rpiRegisterKeyboardEvent(int keyCode, int pressCode, int modifiers) { + sqKeyboardEvent *evt = (sqKeyboardEvent*) nextEventPut(); + /* first the basics */ + evt->type = EventTypeKeyboard; + evt->timeStamp = ioMSecs() & MillisecondClockMask; + /* now the key code */ + /* press code must differentiate */ + evt->charCode = keyCode; + evt->pressCode = pressCode; + evt->modifiers = modifiers; + + evt->reserved1=evt->reserved2=evt->reserved3= 0; +} + +void rpiProcessKeyboardEvents(void) { + int keyboardCount = KeyboardCount(); + if (keyboardCount == 0) { + return; + } + + uint32_t keyboard = KeyboardGetAddress(0); + int keysDown = KeyboardGetKeyDownCount(keyboard); + + struct KeyboardModifiers keyModifiers = KeyboardGetModifiers(keyboard); + int modifiers = 0; + if (keyModifiers.LeftControl || keyModifiers.RightControl) { + modifiers |= CtrlKeyBit; + } + if (keyModifiers.LeftShift || keyModifiers.RightShift) { + modifiers |= ShiftKeyBit; + } + if (keyModifiers.LeftAlt || keyModifiers.RightAlt) { + modifiers |= OptionKeyBit; + } + if (keyModifiers.LeftGui || keyModifiers.RightGui) { + modifiers |= CommandKeyBit; + } + + char theseKeys[keysDown]; + + for (int i=0; i>16)&0xffff), (position&0xffff)); } watchdog_reset(); diff --git a/bcm2835/sqRpiMinimal.c b/bcm2835/sqRpiMinimal.c index f868824..72e456c 100644 --- a/bcm2835/sqRpiMinimal.c +++ b/bcm2835/sqRpiMinimal.c @@ -26,13 +26,6 @@ int ioExit(void) { while(1) __asm__("nop"); } - -/*** Directory ***/ - -int dir_Delimitor(void) { - return '/'; -} - /*** System Attributes ***/ extern char vmPath[]; extern char shortImageName[]; diff --git a/bcm2835/sqRpiStubs.c b/bcm2835/sqRpiStubs.c index f02c84b..0b744e7 100644 --- a/bcm2835/sqRpiStubs.c +++ b/bcm2835/sqRpiStubs.c @@ -1,85 +1,26 @@ #include "sq.h" +#include "FilePlugin.h" -#define STUBBED_OUT { /*printf("%s\n", __PRETTY_FUNCTION__);*/ success(false); } +void *os_exports[][3]= +{ + { 0, 0, 0 }, +}; -void sqSocketAcceptFromRecvBytesSendBytesSemaID( - SocketPtr s, SocketPtr serverSocket, - int recvBufSize, int sendBufSize, int semaIndex) STUBBED_OUT +#define STUBBED_OUT { /*printf("%s\n", __PRETTY_FUNCTION__);*/ /*success(false);*/ return 0; } -void sqSocketListenOnPortBacklogSize( - SocketPtr s, int port, int backlogSize) STUBBED_OUT +int ioDisablePowerManager(int disableIfNonZero) { return true; } +int ioSetInputSemaphore(int semaIndex) STUBBED_OUT +int ioFindExternalFunctionIn(char *lookupName, int moduleHandle) { +// printf("%s lookupName=%s\n", __PRETTY_FUNCTION__, lookupName); + return 0; +} +int ioLoadModule(char *pluginName) { +// printf("%s pluginName=%s\n", __PRETTY_FUNCTION__, pluginName); + return 0; +} +int ioFreeModule(int moduleHandle) STUBBED_OUT -/*** File stubs ***/ -int sqFileAtEnd(SQFile *f) STUBBED_OUT -int sqFileClose(SQFile *f) STUBBED_OUT -int sqFileDeleteNameSize(int sqFileNameIndex, int sqFileNameSize) STUBBED_OUT -int sqFileGetPosition(SQFile *f) STUBBED_OUT -int sqFileInit(void) STUBBED_OUT -int sqFileOpen(SQFile *f, int sqFileNameIndex, int sqFileNameSize, int writeFlag) STUBBED_OUT -int sqFileReadIntoAt(SQFile *f, int count, int byteArrayIndex, int startIndex) STUBBED_OUT -int sqFileRenameOldSizeNewSize(int oldNameIndex, int oldNameSize, int newNameIndex, int newNameSize) STUBBED_OUT -int sqFileSetPosition(SQFile *f, int position) STUBBED_OUT -int sqFileSize(SQFile *f) STUBBED_OUT -int sqFileWriteFromAt(SQFile *f, int count, int byteArrayIndex, int startIndex) STUBBED_OUT - -/*** Directory Stubs ***/ - -int dir_Delete(char *pathString, int pathStringLength) STUBBED_OUT -int dir_Create(char *pathString, int pathStringLength) STUBBED_OUT -int dir_Lookup(char *pathString, int pathStringLength, int index, - char *name, int *nameLength, int *creationDate, int *modificationDate, - int *isDirectory, int *sizeIfFile) STUBBED_OUT -int dir_SetMacFileTypeAndCreator(char *filename, int filenameSize, - char *fType, char *fCreator) STUBBED_OUT - -/*** Joystick Stubs ***/ - -int joystickRead(int stickIndex) STUBBED_OUT - -/*** MIDI Stubs ***/ - -int sqMIDIClosePort(int portNum) STUBBED_OUT -int sqMIDIGetClock(void) STUBBED_OUT -int sqMIDIGetPortCount(void) STUBBED_OUT -int sqMIDIGetPortDirectionality(int portNum) STUBBED_OUT -int sqMIDIGetPortName(int portNum, int namePtr, int length) STUBBED_OUT -int sqMIDIOpenPort(int portNum, int readSemaIndex, int interfaceClockRate) STUBBED_OUT -int sqMIDIParameter(int whichParameter, int modify, int newValue) STUBBED_OUT -int sqMIDIPortReadInto(int portNum, int count, int bufferPtr) STUBBED_OUT -int sqMIDIPortWriteFromAt(int portNum, int count, int bufferPtr, int time) STUBBED_OUT - -/*** Networking Stubs ***/ - -int sqNetworkInit(int resolverSemaIndex) STUBBED_OUT -void sqNetworkShutdown(void) STUBBED_OUT -void sqResolverAbort(void) STUBBED_OUT -void sqResolverAddrLookupResult(char *nameForAddress, int nameSize) STUBBED_OUT -int sqResolverAddrLookupResultSize(void) STUBBED_OUT -int sqResolverError(void) STUBBED_OUT -int sqResolverLocalAddress(void) STUBBED_OUT -int sqResolverNameLookupResult(void) STUBBED_OUT -void sqResolverStartAddrLookup(int address) STUBBED_OUT -void sqResolverStartNameLookup(char *hostName, int nameSize) STUBBED_OUT -int sqResolverStatus(void) STUBBED_OUT -void sqSocketAbortConnection(SocketPtr s) STUBBED_OUT -void sqSocketCloseConnection(SocketPtr s) STUBBED_OUT -int sqSocketConnectionStatus(SocketPtr s) STUBBED_OUT -void sqSocketConnectToPort(SocketPtr s, int addr, int port) STUBBED_OUT -void sqSocketCreateNetTypeSocketTypeRecvBytesSendBytesSemaID( - SocketPtr s, int netType, int socketType, - int recvBufSize, int sendBufSize, int semaIndex) STUBBED_OUT -void sqSocketDestroy(SocketPtr s) STUBBED_OUT -int sqSocketError(SocketPtr s) STUBBED_OUT -void sqSocketListenOnPort(SocketPtr s, int port) STUBBED_OUT -int sqSocketLocalAddress(SocketPtr s) STUBBED_OUT -int sqSocketLocalPort(SocketPtr s) STUBBED_OUT -int sqSocketReceiveDataAvailable(SocketPtr s) STUBBED_OUT -int sqSocketReceiveDataBufCount(SocketPtr s, int buf, int bufSize) STUBBED_OUT -int sqSocketRemoteAddress(SocketPtr s) STUBBED_OUT -int sqSocketRemotePort(SocketPtr s) STUBBED_OUT -int sqSocketSendDataBufCount(SocketPtr s, int buf, int bufSize) STUBBED_OUT -int sqSocketSendDone(SocketPtr s) STUBBED_OUT /*** Profiling Stubs ***/ @@ -88,83 +29,65 @@ int dumpProfile(void) STUBBED_OUT int startProfiling(void) STUBBED_OUT int stopProfiling(void) STUBBED_OUT -/*** Serial Port Functions Stubs ***/ - -int serialPortClose(int portNum) STUBBED_OUT -int serialPortOpen( - int portNum, int baudRate, int stopBitsType, - int parityType, int dataBits, int inFlowCtrl, int outFlowCtrl, - int xOnChar, int xOffChar) STUBBED_OUT -int serialPortReadInto(int portNum, int count, int bufferPtr) STUBBED_OUT -int serialPortWriteFrom(int portNum, int count, int bufferPtr) STUBBED_OUT - -/*** Sound Output Stubs ***/ - -int snd_AvailableSpace(void) STUBBED_OUT -int snd_PlaySamplesFromAtLength( - int frameCount, int arrayIndex, int startIndex) STUBBED_OUT -int snd_InsertSamplesFromLeadTime( - int frameCount, int srcBufPtr, int samplesOfLeadTime) STUBBED_OUT -int snd_PlaySilence(void) STUBBED_OUT -int snd_Start(int frameCount, int samplesPerSec, int stereo, int semaIndex) STUBBED_OUT -int snd_Stop(void) STUBBED_OUT - -/*** Sound Input Stubs ***/ - -int snd_SetRecordLevel(int level) STUBBED_OUT -int snd_StartRecording(int desiredSamplesPerSec, int stereo, int semaIndex) STUBBED_OUT -int snd_StopRecording(void) STUBBED_OUT -double snd_GetRecordingSampleRate(void) STUBBED_OUT -int snd_RecordSamplesIntoAtLength( - int buf, int startSliceIndex, int bufferSizeInBytes) STUBBED_OUT - -/*** Sound Synthesis Primitives Stubs ***/ - -int primFMSoundmixSampleCountintostartingAtleftVolrightVol(void) STUBBED_OUT -int primLoopedSampledSoundmixSampleCountintostartingAtleftVolrightVol(void) STUBBED_OUT -int primPluckedSoundmixSampleCountintostartingAtleftVolrightVol(void) STUBBED_OUT -int primReverbSoundapplyReverbTostartingAtcount(void) STUBBED_OUT -int primSampledSoundmixSampleCountintostartingAtleftVolrightVol(void) STUBBED_OUT - -/*** Old Sound Synthesis Primitives Stubs ***/ - -int primFMSoundmixSampleCountintostartingAtpan(void) STUBBED_OUT -int primPluckedSoundmixSampleCountintostartingAtpan(void) STUBBED_OUT -int primSampledSoundmixSampleCountintostartingAtpan(void) STUBBED_OUT -int primWaveTableSoundmixSampleCountintostartingAtpan(void) STUBBED_OUT - -/*** Experimental Asynchronous File I/O ***/ - -int asyncFileClose(AsyncFile *f) STUBBED_OUT -int asyncFileOpen( - AsyncFile *f, int fileNamePtr, int fileNameSize, - int writeFlag, int semaIndex) STUBBED_OUT -int asyncFileRecordSize() STUBBED_OUT -int asyncFileReadResult(AsyncFile *f, int bufferPtr, int bufferSize) STUBBED_OUT -int asyncFileReadStart(AsyncFile *f, int fPosition, int count) STUBBED_OUT -int asyncFileWriteResult(AsyncFile *f) STUBBED_OUT -int asyncFileWriteStart( - AsyncFile *f, int fPosition, int bufferPtr, int bufferSize) STUBBED_OUT /*** Clipboard Stubs ***/ int clipboardReadIntoAt(int count, int byteArrayIndex, int startIndex) STUBBED_OUT int clipboardSize(void) STUBBED_OUT int clipboardWriteFromAt(int count, int byteArrayIndex, int startIndex) STUBBED_OUT - -/*** Tablet/joystick (?) stubs ***/ -int tabletRead(int cursorIndex, int result[]) STUBBED_OUT -int tabletResultSize(void) STUBBED_OUT -int tabletGetParameters(int cursorIndex, int result[]) STUBBED_OUT - -/*** FFI (?) stubs ***/ -int ioLoadExternalFunctionOfLengthFromModuleOfLength( - int functionNameIndex, int functionNameLength, - int moduleNameIndex, int moduleNameLength) STUBBED_OUT - -/*** Sound primitive stubs ***/ -int oldprimSampledSoundmixSampleCountintostartingAtleftVolrightVol(void) STUBBED_OUT -int primADPCMCodecprivateDecodeMono(void) STUBBED_OUT -int primADPCMCodecprivateDecodeStereo(void) STUBBED_OUT -int primADPCMCodecprivateEncodeMono(void) STUBBED_OUT -int primADPCMCodecprivateEncodeStereo(void) STUBBED_OUT +/* file i/o */ +int sqFileAtEnd(SQFile *f) STUBBED_OUT +int sqFileClose(SQFile *f) STUBBED_OUT +int sqFileDeleteNameSize(int sqFileNameIndex, int sqFileNameSize) STUBBED_OUT +squeakFileOffsetType sqFileGetPosition(SQFile *f) STUBBED_OUT +int sqFileInit(void) { return true; } +int sqFileShutdown(void) STUBBED_OUT +int sqFileOpen(SQFile *f, int sqFileNameIndex, int sqFileNameSize, int writeFlag) STUBBED_OUT +size_t sqFileReadIntoAt(SQFile *f, size_t count, int byteArrayIndex, size_t startIndex) STUBBED_OUT +int sqFileRenameOldSizeNewSize(int oldNameIndex, int oldNameSize, int newNameIndex, int newNameSize) STUBBED_OUT +int sqFileSetPosition(SQFile *f, squeakFileOffsetType position) STUBBED_OUT +squeakFileOffsetType sqFileSize(SQFile *f) STUBBED_OUT +int sqFileValid(SQFile *f) STUBBED_OUT +size_t sqFileWriteFromAt(SQFile *f, size_t count, int byteArrayIndex, size_t startIndex) STUBBED_OUT +int sqFileFlush(SQFile *f) STUBBED_OUT +int sqFileTruncate(SQFile *f,squeakFileOffsetType offset) STUBBED_OUT +int sqFileThisSession(void) STUBBED_OUT + +/* directories */ +int dir_Delimitor(void) { + return '/'; +} +int dir_Create(char *pathString, int pathStringLength) STUBBED_OUT +int dir_Delete(char *pathString, int pathStringLength) STUBBED_OUT +int dir_Lookup(char *pathString, int pathStringLength, int index, + /* outputs: */ + char *name, int *nameLength, int *creationDate, int *modificationDate, + int *isDirectory, squeakFileOffsetType *sizeIfFile) STUBBED_OUT + +int dir_PathToWorkingDir(char *pathName, int pathNameMax) STUBBED_OUT +int dir_SetMacFileTypeAndCreator(char *filename, int filenameSize, char *fType, char *fCreator) STUBBED_OUT +int dir_GetMacFileTypeAndCreator(char *filename, int filenameSize, char *fType, char *fCreator) STUBBED_OUT + +/* security stubs */ +int ioCanConnectToPort(int netAddr, int port) STUBBED_OUT +int ioCanCreatePathOfSize(char* pathString, int pathStringLength) STUBBED_OUT +int ioCanCreateSocketOfType(int netType, int socketType) STUBBED_OUT +int ioCanDeleteFileOfSize(char* pathString, int pathStringLength) STUBBED_OUT +int ioCanDeletePathOfSize(char* pathString, int pathStringLength) STUBBED_OUT +int ioCanGetFileTypeOfSize(char* pathString, int pathStringLength) STUBBED_OUT +int ioCanListPathOfSize(char* pathString, int pathStringLength) STUBBED_OUT +int ioCanListenOnPort(int s, int port) STUBBED_OUT +int ioCanOpenAsyncFileOfSizeWritable(char* pathString, int pathStringLength, int writeFlag) STUBBED_OUT +int ioCanOpenFileOfSizeWritable(char* pathString, int pathStringLength, int writeFlag) STUBBED_OUT +int ioCanRenameFileOfSize(char* pathString, int pathStringLength) STUBBED_OUT +int ioCanRenameImage(void) STUBBED_OUT +int ioCanSetFileTypeOfSize(char* pathString, int pathStringLength) STUBBED_OUT +int ioCanWriteImage(void) STUBBED_OUT +int ioDisableFileAccess(void) STUBBED_OUT +int ioDisableImageWrite(void) STUBBED_OUT +int ioDisableSocketAccess() STUBBED_OUT +char *ioGetSecureUserDirectory(void) STUBBED_OUT +char *ioGetUntrustedUserDirectory(void) STUBBED_OUT +int ioHasFileAccess(void) STUBBED_OUT +int ioHasSocketAccess() STUBBED_OUT +int ioInitSecurity(void) { return true; } diff --git a/lib/math.h b/lib/math.h index 06f3260..f7bfd09 100644 --- a/lib/math.h +++ b/lib/math.h @@ -15,3 +15,4 @@ double NaN(void); int isNaN(double d); double Inf(int sign); int isInf(double d, int sign); +int abs(int a); diff --git a/lib/memutils.c b/lib/memutils.c index d86b3b8..78b7a09 100644 --- a/lib/memutils.c +++ b/lib/memutils.c @@ -22,6 +22,12 @@ void * malloc ( unsigned int size ) return(ret); } +void *calloc(unsigned int nmemb, unsigned int size) { + void *result = malloc(nmemb * size); + memclr(result, nmemb * size); + return result; +} + void *memalign(unsigned int alignment, unsigned int n) { void *ret; printf("malloc(%i) => (malloc_base was: 0x%08x, ", n, malloc_base); diff --git a/lib/strings.c b/lib/strings.c index c53eb72..c90ad08 100644 --- a/lib/strings.c +++ b/lib/strings.c @@ -42,6 +42,40 @@ strcpy(char *s1, char *s2) long strlen(char *s) { - return strchr(s, 0) - s; } + + +int strcmp(char *s1, char *s2) { + unsigned c1, c2; + + for(;;) { + c1 = *s1++; + c2 = *s2++; + if(c1 != c2) { + if(c1 > c2) + return 1; + return -1; + } + if(c1 == 0) + return 0; + } +} + +int strncmp(char *s1, char *s2, long n) { + unsigned c1, c2; + + while(n > 0) { + c1 = *s1++; + c2 = *s2++; + n--; + if(c1 != c2) { + if(c1 > c2) + return 1; + return -1; + } + if(c1 == 0) + break; + } + return 0; +} diff --git a/sd-card-ready.zip b/sd-card-ready.zip index 56d6378..95b6894 100644 Binary files a/sd-card-ready.zip and b/sd-card-ready.zip differ diff --git a/squeak/B2DPlugin.c b/squeak/B2DPlugin.c new file mode 100644 index 0000000..579062b --- /dev/null +++ b/squeak/B2DPlugin.c @@ -0,0 +1,9865 @@ +/* Automatically generated from Squeak on #(4 March 2003 4:22:42 am) */ + +#include +#include +#include +#include +#include + +/* Default EXPORT macro that does nothing (see comment in sq.h): */ +#define EXPORT(returnType) returnType + +/* Do not include the entire sq.h file but just those parts needed. */ +/* The virtual machine proxy definition */ +#include "sqVirtualMachine.h" +/* Configuration options */ +#include "sqConfig.h" +/* Platform specific definitions */ +#include "sqPlatformSpecific.h" + +#define true 1 +#define false 0 +#define null 0 /* using 'null' because nil is predefined in Think C */ +#ifdef SQUEAK_BUILTIN_PLUGIN +#undef EXPORT +// was #undef EXPORT(returnType) but screws NorCroft cc +#define EXPORT(returnType) static returnType +#endif + +/* memory access macros */ +#define byteAt(i) (*((unsigned char *) (i))) +#define byteAtput(i, val) (*((unsigned char *) (i)) = val) +#define longAt(i) (*((int *) (i))) +#define longAtput(i, val) (*((int *) (i)) = val) + + +/*** Variables ***/ +static int* aetBuffer; +static char bbPluginName[256] = "BitBltPlugin"; +static int copyBitsFn; +static int dispatchReturnValue; +static int dispatchedValue; +static int doProfileStats = 0; +static int engine; +static int engineStopped; +static int formArray; +static int geProfileTime; +static int* getBuffer; + +#ifdef SQUEAK_BUILTIN_PLUGIN +extern +#endif +struct VirtualMachine* interpreterProxy; +static int loadBBFn; +static const char *moduleName = +#ifdef SQUEAK_BUILTIN_PLUGIN + "B2DPlugin 4 March 2003 (i)" +#else + "B2DPlugin 4 March 2003 (e)" +#endif +; +static int* objBuffer; +static int objUsed; +static unsigned int* spanBuffer; +static int* workBuffer; + +/*** Function Prototypes ***/ +static int aaColorMaskGet(void); +static int aaColorMaskPut(int value); +static int aaColorShiftGet(void); +static int aaColorShiftPut(int value); +static int aaFirstPixelFromto(int leftX, int rightX); +static int aaHalfPixelGet(void); +static int aaHalfPixelPut(int value); +static int aaLastPixelFromto(int leftX, int rightX); +static int aaLevelGet(void); +static int aaLevelPut(int value); +static int aaScanMaskGet(void); +static int aaScanMaskPut(int value); +static int aaShiftGet(void); +static int aaShiftPut(int value); +static int absoluteSquared8Dot24(int value); +static int accurateLengthOfwith(int deltaX, int deltaY); +static int addEdgeToGET(int edge); +static int adjustAALevel(void); +static int adjustWideBezierLeftwidthoffsetendX(int bezier, int lineWidth, int lineOffset, int endX); +static int adjustWideBezierRightwidthoffsetendX(int bezier, int lineWidth, int lineOffset, int endX); +static int adjustWideLineafterSteppingFromto(int line, int lastX, int nextX); +static int aetStartGet(void); +static int aetStartPut(int value); +static int aetUsedGet(void); +static int aetUsedPut(int value); +static int allocateAETEntry(int nSlots); +static int allocateBezier(void); +static int allocateBezierStackEntry(void); +static int allocateBitmapFillcolormap(int cmSize, int *cmBits); +static int allocateGETEntry(int nSlots); +static int allocateGradientFillrampWidthisRadial(int *ramp, int rampWidth, int isRadial); +static int allocateLine(void); +static int allocateObjEntry(int nSlots); +static int allocateStackEntry(int nSlots); +static int allocateStackFillEntry(void); +static int allocateWideBezier(void); +static int allocateWideLine(void); +static int areEdgeFillsValid(int edge); +static int assureValuebetweenand(int val1, int val2, int val3); +static int bezierEndXOf(int bezier); +static int bezierEndXOfput(int bezier, int value); +static int bezierEndYOf(int bezier); +static int bezierEndYOfput(int bezier, int value); +static int bezierFinalXOf(int bezier); +static int bezierFinalXOfput(int bezier, int value); +static int * bezierUpdateDataOf(int bezier); +static int bezierViaXOf(int bezier); +static int bezierViaXOfput(int bezier, int value); +static int bezierViaYOf(int bezier); +static int bezierViaYOfput(int bezier, int value); +static int bitmapCmSizeOf(int bmFill); +static int bitmapCmSizeOfput(int bmFill, int value); +static int bitmapDepthOf(int bmFill); +static int bitmapDepthOfput(int bmFill, int value); +static int bitmapHeightOf(int bmFill); +static int bitmapHeightOfput(int bmFill, int value); +static int bitmapRasterOf(int bmFill); +static int bitmapRasterOfput(int bmFill, int value); +static int bitmapSizeOf(int bmFill); +static int bitmapSizeOfput(int bmFill, int value); +static int bitmapTileFlagOf(int bmFill); +static int bitmapTileFlagOfput(int bmFill, int value); +static int bitmapValuebitsatXy(int bmFill, int bits, int xp, int yp); +static int bitmapWidthOf(int bmFill); +static int bitmapWidthOfput(int bmFill, int value); +static int bzEndX(int index); +static int bzEndXput(int index, int value); +static int bzEndY(int index); +static int bzEndYput(int index, int value); +static int bzStartX(int index); +static int bzStartXput(int index, int value); +static int bzStartY(int index); +static int bzStartYput(int index, int value); +static int bzViaX(int index); +static int bzViaXput(int index, int value); +static int bzViaY(int index); +static int bzViaYput(int index, int value); +static int checkCompressedFillIndexListmaxsegments(int fillList, int maxIndex, int nSegs); +static int checkCompressedFills(int indexList); +static int checkCompressedLineWidthssegments(int lineWidthList, int nSegments); +static int checkCompressedPointssegments(int points, int nSegments); +static int checkCompressedShapesegmentsleftFillsrightFillslineWidthslineFillsfillIndexList(int points, int nSegments, int leftFills, int rightFills, int lineWidths, int lineFills, int fillIndexList); +static int checkedAddBezierToGET(int bezier); +static int checkedAddEdgeToGET(int edge); +static int checkedAddLineToGET(int line); +static double * circleCosTable(void); +static double * circleSinTable(void); +static int clampValuemax(int value, int maxValue); +static int clearSpanBuffer(void); +static int clearSpanBufferGet(void); +static int clearSpanBufferPut(int value); +static int clipMaxXGet(void); +static int clipMaxXPut(int value); +static int clipMaxYGet(void); +static int clipMaxYPut(int value); +static int clipMinXGet(void); +static int clipMinXPut(int value); +static int clipMinYGet(void); +static int clipMinYPut(int value); +static float * colorTransform(void); +static int * colormapOf(int bmFill); +static int computeBeziersplitAt(int index, double param); +static int computeBezierSplitAtHalf(int index); +static int computeFinalWideBezierValueswidth(int bezier, int lineWidth); +static int computeSqrt(int length2); +static int copyBitsFromtoat(int x0, int x1, int yValue); +static int createGlobalEdgeTable(void); +static int currentYGet(void); +static int currentYPut(int value); +static int currentZGet(void); +static int currentZPut(int value); +static int destOffsetXGet(void); +static int destOffsetXPut(int value); +static int destOffsetYGet(void); +static int destOffsetYPut(int value); +static int displaySpanBufferAt(int y); +static int drawWideEdgefrom(int edge, int leftX); +static int edgeFillsInvalidate(int edge); +static int edgeFillsValidate(int edge); +static int edgeLeftFillOf(int edge); +static int edgeLeftFillOfput(int edge, int value); +static int edgeNumLinesOf(int edge); +static int edgeNumLinesOfput(int edge, int value); +static int edgeRightFillOf(int edge); +static int edgeRightFillOfput(int edge, int value); +static float * edgeTransform(void); +static int edgeTypeOf(int edge); +static int edgeXValueOf(int edge); +static int edgeXValueOfput(int edge, int value); +static int edgeYValueOf(int edge); +static int edgeYValueOfput(int edge, int value); +static int edgeZValueOf(int edge); +static int edgeZValueOfput(int edge, int value); +static int errorWrongIndex(void); +static int estimatedLengthOfwith(int deltaX, int deltaY); +static int fillAllFromto(int leftX, int rightX); +static int fillBitmapSpan(void); +static int fillBitmapSpanfromto(int *bits, int leftX, int rightX); +static int fillBitmapSpanfromtoat(int bmFill, int leftX, int rightX, int yValue); +static int fillBitmapSpanAAfromtoat(int bmFill, int leftX, int rightX, int yValue); +static int fillColorSpanfromto(int pixelValue32, int leftX, int rightX); +static int fillColorSpanAAx0x1(int pixelValue32, int leftX, int rightX); +static int fillDirectionXOf(int fill); +static int fillDirectionXOfput(int fill, int value); +static int fillDirectionYOf(int fill); +static int fillDirectionYOfput(int fill, int value); +static int fillLinearGradient(void); +static int fillLinearGradientfromtoat(int fill, int leftX, int rightX, int yValue); +static int fillLinearGradientAArampdsdsXfromto(int fill, int *ramp, int deltaS, int dsX, int leftX, int rightX); +static int fillMaxXGet(void); +static int fillMaxXPut(int value); +static int fillMaxYGet(void); +static int fillMaxYPut(int value); +static int fillMinXGet(void); +static int fillMinXPut(int value); +static int fillMinYGet(void); +static int fillMinYPut(int value); +static int fillNormalXOf(int fill); +static int fillNormalXOfput(int fill, int value); +static int fillNormalYOf(int fill); +static int fillNormalYOfput(int fill, int value); +static int fillOffsetXGet(void); +static int fillOffsetXPut(int value); +static int fillOffsetYGet(void); +static int fillOffsetYPut(int value); +static int fillOriginXOf(int fill); +static int fillOriginXOfput(int fill, int value); +static int fillOriginYOf(int fill); +static int fillOriginYOfput(int fill, int value); +static int fillRadialDecreasingrampdeltaSTdsXdtXfromto(int fill, int ramp, int deltaST, int dsX, int dtX, int leftX, int rightX); +static int fillRadialDecreasingAArampdeltaSTdsXdtXfromto(int fill, int *ramp, int *deltaST, int dsX, int dtX, int leftX, int rightX); +static int fillRadialGradient(void); +static int fillRadialGradientfromtoat(int fill, int leftX, int rightX, int yValue); +static int fillRadialIncreasingrampdeltaSTdsXdtXfromto(int fill, int ramp, int deltaST, int dsX, int dtX, int leftX, int rightX); +static int fillRadialIncreasingAArampdeltaSTdsXdtXfromto(int fill, int *ramp, int *deltaST, int dsX, int dtX, int leftX, int rightX); +static int fillSortsbefore(int fillEntry1, int fillEntry2); +static int fillSpanfromto(int fill, int leftX, int rightX); +static int fillSpanfromtomax(int fill, int leftX, int rightX, int maxRightX); +static int fillTypeOf(int fill); +static int findNextAETEdgeFrom(int leftEdge); +static int findNextExternalEntryFromGET(void); +static int findNextExternalFillFromAET(void); +static int findNextExternalUpdateFromAET(void); +static int findStackFilldepth(int fillIndex, int depth); +static int finishedProcessing(void); +static int firstPointListGet(void); +static int firstPointListPut(int value); +static int freeStackFillEntry(void); +#pragma export on +EXPORT(const char*) getModuleName(void); +#pragma export off +static int getSortsbefore(int edge1, int edge2); +static int getStartGet(void); +static int getStartPut(int value); +static int getUsedGet(void); +static int getUsedPut(int value); +static int gradientRampLengthOf(int fill); +static int gradientRampLengthOfput(int fill, int value); +static int * gradientRampOf(int fill); +static int halt(void); +static int hasColorTransform(void); +static int hasColorTransformGet(void); +static int hasColorTransformPut(int value); +static int hasEdgeTransform(void); +static int hasEdgeTransformGet(void); +static int hasEdgeTransformPut(int value); +static int hideFilldepth(int fillIndex, int depth); +static int incrementPointby(int *point, int delta); +static int incrementStatby(int statIndex, int value); +static int indexForInsertingIntoAET(int edge); +static int initColorTransform(void); +static int initEdgeTransform(void); +#pragma export on +EXPORT(int) initialiseModule(void); +#pragma export off +static int initializeGETProcessing(void); +static int insertEdgeIntoAET(int edge); +static int insertToAETbeforeIndex(int edge, int index); +static int isBezier(int bezier); +static int isEdge(int edge); +static int isFill(int fill); +static int isFillColor(int fill); +static int isFillOkay(int fill); +static int isLine(int line); +static int isObject(int obj); +static int isRealFill(int fill); +static int isStackEntry(int entry); +static int isStackIndex(int index); +static int isWide(int object); +static int isWideBezier(int bezier); +static int isWideLine(int line); +static int lastExportedEdgeGet(void); +static int lastExportedEdgePut(int value); +static int lastExportedFillGet(void); +static int lastExportedFillPut(int value); +static int lastExportedLeftXGet(void); +static int lastExportedLeftXPut(int value); +static int lastExportedRightXGet(void); +static int lastExportedRightXPut(int value); +static int lineEndXOf(int line); +static int lineEndXOfput(int line, int value); +static int lineEndYOf(int line); +static int lineEndYOfput(int line, int value); +static int lineErrorAdjDownOf(int line); +static int lineErrorAdjDownOfput(int line, int value); +static int lineErrorAdjUpOf(int line); +static int lineErrorAdjUpOfput(int line, int value); +static int lineErrorOf(int line); +static int lineErrorOfput(int line, int value); +static int lineXDirectionOf(int line); +static int lineXDirectionOfput(int line, int value); +static int lineXIncrementOf(int line); +static int lineXIncrementOfput(int line, int value); +static int lineYDirectionOf(int line); +static int lineYDirectionOfput(int line, int value); +static int loadAndSubdivideBezierFromviatoisWide(int *point1, int *point2, int *point3, int wideFlag); +static int loadArrayPolygonnPointsfilllineWidthlineFill(int points, int nPoints, int fillIndex, int lineWidth, int lineFill); +static int loadArrayShapenSegmentsfilllineWidthlineFill(int points, int nSegments, int fillIndex, int lineWidth, int lineFill); +static int loadArrayTransformFromintolength(int transformOop, float *destPtr, int n); +static int loadBeziersegmentleftFillrightFilloffset(int bezier, int index, int leftFillIndex, int rightFillIndex, int yOffset); +static int loadBitBltFrom(int bbObj); +static int loadBitmapFillcolormaptilefromalongnormalxIndex(int formOop, int cmOop, int tileFlag, int *point1, int *point2, int *point3, int xIndex); +static int * loadBitsFrom(int bmFill); +static int loadColorTransformFrom(int transformOop); +static int loadCompressedSegmentfromshortleftFillrightFilllineWidthlineColor(int segmentIndex, int points, int pointsShort, int leftFill, int rightFill, int lineWidth, int lineFill); +static int loadCompressedShapesegmentsleftFillsrightFillslineWidthslineFillsfillIndexListpointShort(int *points, int nSegments, int *leftFills, int *rightFills, int *lineWidths, int *lineFills, int *fillIndexList, int pointsShort); +static int loadEdgeStateFrom(int edgeOop); +static int loadEdgeTransformFrom(int transformOop); +static int loadFillOrientationfromalongnormalwidthheight(int fill, int *point1, int *point2, int *point3, int fillWidth, int fillHeight); +static int loadFormsFrom(int arrayOop); +static int loadGradientFillfromalongnormalisRadial(int rampOop, int *point1, int *point2, int *point3, int isRadial); +static int loadLinefromtooffsetleftFillrightFill(int line, int *point1, int *point2, int yOffset, int leftFill, int rightFill); +static int loadOvallineFillleftFillrightFill(int lineWidth, int lineFill, int leftFill, int rightFill); +static int loadOvalSegmentwhcxcy(int seg, int w, int h, int cx, int cy); +static int loadPointfrom(int *pointArray, int pointOop); +static int loadPointIntAtfrom(int index, int intArray); +static short loadPointShortAtfrom(int index, int shortArray); +static int loadPolygonnPointsfilllineWidthlineFillpointsShort(int *points, int nPoints, int fillIndex, int lineWidth, int lineFill, int isShort); +static int loadRectanglelineFillleftFillrightFill(int lineWidth, int lineFill, int leftFill, int rightFill); +static int loadRenderingState(void); +static int loadShapenSegmentsfilllineWidthlineFillpointsShort(int *points, int nSegments, int fillIndex, int lineWidth, int lineFill, int pointsShort); +static int loadSpanBufferFrom(int spanOop); +static int loadTransformFromintolength(int transformOop, float *destPtr, int n); +static int loadWideBezierlineFillleftFillrightFilln(int lineWidth, int lineFill, int leftFill, int rightFill, int nSegments); +static int loadWideLinefromtolineFillleftFillrightFill(int lineWidth, int *p1, int *p2, int lineFill, int leftFill, int rightFill); +static int loadWordTransformFromintolength(int transformOop, float *destPtr, int n); +static int loadWorkBufferFrom(int wbOop); +static int magicNumberGet(void); +static int magicNumberPut(int value); +static int makeRectFromPoints(void); +static int makeUnsignedFrom(int someIntegerValue); +#pragma export on +EXPORT(int) moduleUnloaded(char * aModuleName); +#pragma export off +static int moveAETEntryFromedgex(int index, int edge, int xValue); +static int msg(char *s); +static int needAvailableSpace(int nSlots); +static int needsFlush(void); +static int needsFlushGet(void); +static int needsFlushPut(int value); +static int objat(int object, int index); +static int objatput(int object, int index, int value); +static int objStartGet(void); +static int objStartPut(int value); +static int objUsedGet(void); +static int objUsedPut(int value); +static int objectHeaderOf(int obj); +static int objectIndexOf(int obj); +static int objectIndexOfput(int obj, int value); +static int objectLengthOf(int obj); +static int objectLengthOfput(int obj, int value); +static int objectTypeOf(int obj); +static int objectTypeOfput(int obj, int value); +static int offsetFromWidth(int lineWidth); +static int * point1Get(void); +static int * point2Get(void); +static int * point3Get(void); +static int * point4Get(void); +static int postDisplayAction(void); +#pragma export on +EXPORT(int) primitiveAbortProcessing(void); +EXPORT(int) primitiveAddActiveEdgeEntry(void); +EXPORT(int) primitiveAddBezier(void); +EXPORT(int) primitiveAddBezierShape(void); +EXPORT(int) primitiveAddBitmapFill(void); +EXPORT(int) primitiveAddCompressedShape(void); +EXPORT(int) primitiveAddGradientFill(void); +EXPORT(int) primitiveAddLine(void); +EXPORT(int) primitiveAddOval(void); +EXPORT(int) primitiveAddPolygon(void); +EXPORT(int) primitiveAddRect(void); +EXPORT(int) primitiveChangedActiveEdgeEntry(void); +EXPORT(int) primitiveCopyBuffer(void); +EXPORT(int) primitiveDisplaySpanBuffer(void); +EXPORT(int) primitiveDoProfileStats(void); +EXPORT(int) primitiveFinishedProcessing(void); +EXPORT(int) primitiveGetAALevel(void); +EXPORT(int) primitiveGetBezierStats(void); +EXPORT(int) primitiveGetClipRect(void); +EXPORT(int) primitiveGetCounts(void); +EXPORT(int) primitiveGetDepth(void); +EXPORT(int) primitiveGetFailureReason(void); +EXPORT(int) primitiveGetOffset(void); +EXPORT(int) primitiveGetTimes(void); +EXPORT(int) primitiveInitializeBuffer(void); +EXPORT(int) primitiveInitializeProcessing(void); +EXPORT(int) primitiveMergeFillFrom(void); +EXPORT(int) primitiveNeedsFlush(void); +EXPORT(int) primitiveNeedsFlushPut(void); +EXPORT(int) primitiveNextActiveEdgeEntry(void); +EXPORT(int) primitiveNextFillEntry(void); +EXPORT(int) primitiveNextGlobalEdgeEntry(void); +EXPORT(int) primitiveRegisterExternalEdge(void); +EXPORT(int) primitiveRegisterExternalFill(void); +EXPORT(int) primitiveRenderImage(void); +EXPORT(int) primitiveRenderScanline(void); +EXPORT(int) primitiveSetAALevel(void); +EXPORT(int) primitiveSetBitBltPlugin(void); +EXPORT(int) primitiveSetClipRect(void); +EXPORT(int) primitiveSetColorTransform(void); +EXPORT(int) primitiveSetDepth(void); +EXPORT(int) primitiveSetEdgeTransform(void); +EXPORT(int) primitiveSetOffset(void); +#pragma export off +static int proceedRenderingImage(void); +static int proceedRenderingScanline(void); +static int quickLoadEngineFrom(int engineOop); +static int quickLoadEngineFromrequiredState(int oop, int requiredState); +static int quickLoadEngineFromrequiredStateor(int oop, int requiredState, int alternativeState); +static int quickRemoveInvalidFillsAt(int leftX); +static int quickSortGlobalEdgeTablefromto(int *array, int i, int j); +static int * rShiftTable(void); +static int removeFirstAETEntry(void); +static int repeatValuemax(int delta, int maxValue); +static int resetGraphicsEngineStats(void); +static int resortFirstAETEntry(void); +static int returnWideBezierFill(void); +static int returnWideBezierWidth(void); +static int returnWideLineFill(void); +static int returnWideLineWidth(void); +static int setAALevel(int level); +#pragma export on +EXPORT(int) setInterpreter(struct VirtualMachine* anInterpreter); +#pragma export off +static int shortRunLengthAtfrom(int i, int runArray); +static int shortRunValueAtfrom(int i, int runArray); +static int showFilldepthrightX(int fillIndex, int depth, int rightX); +static int * smallSqrtTable(void); +static int sortGlobalEdgeTable(void); +static int spanEndAAGet(void); +static int spanEndAAPut(int value); +static int spanEndGet(void); +static int spanEndPut(int value); +static int spanSizeGet(void); +static int spanSizePut(int value); +static int spanStartGet(void); +static int spanStartPut(int value); +static int squaredLengthOfwith(int deltaX, int deltaY); +static int stackFillDepth(int index); +static int stackFillDepthput(int index, int value); +static int stackFillEntryLength(void); +static int stackFillRightX(int index); +static int stackFillRightXput(int index, int value); +static int stackFillSize(void); +static int stackFillValue(int index); +static int stackFillValueput(int index, int value); +static int stateGet(void); +static int statePut(int value); +static int stepToFirstBezier(void); +static int stepToFirstBezierInat(int bezier, int yValue); +static int stepToFirstLine(void); +static int stepToFirstLineInat(int line, int yValue); +static int stepToFirstWideBezier(void); +static int stepToFirstWideBezierInat(int bezier, int yValue); +static int stepToFirstWideLine(void); +static int stepToFirstWideLineInat(int line, int yValue); +static int stepToNextBezier(void); +static int stepToNextBezierForwardat(int updateData, int yValue); +static int stepToNextBezierInat(int bezier, int yValue); +static int stepToNextLine(void); +static int stepToNextLineInat(int line, int yValue); +static int stepToNextWideBezier(void); +static int stepToNextWideBezierInat(int bezier, int yValue); +static int stepToNextWideLine(void); +static int stepToNextWideLineInat(int line, int yValue); +static int stopBecauseOf(int stopReason); +static int stopReasonGet(void); +static int stopReasonPut(int value); +static int storeEdgeStateFrominto(int edge, int edgeOop); +static int storeEngineStateInto(int oop); +static int storeFillStateInto(int fillOop); +static int storeRenderingState(void); +static int storeStopStateIntoEdgefill(int edgeOop, int fillOop); +static int subdivideBezier(int index); +static int subdivideBezierFrom(int index); +static int subdivideToBeMonotoninX(int base, int doTestX); +static int subdivideToBeMonotonInX(int index); +static int subdivideToBeMonotonInY(int index); +static int toggleFilldepthrightX(int fillIndex, int depth, int rightX); +static int toggleFillsOf(int edge); +static int toggleWideFillOf(int edge); +static int topDepth(void); +static int topFill(void); +static int topFillDepth(void); +static int topFillDepthPut(int value); +static int topFillRightX(void); +static int topFillRightXPut(int value); +static int topFillValue(void); +static int topFillValuePut(int value); +static int topRightX(void); +static int transformColor(int fillIndex); +static int transformPoint(int *point); +static int transformPointinto(int srcPoint, int dstPoint); +static int transformPointXyinto(double xValue, double yValue, int *dstPoint); +static int transformPoints(int n); +static int transformWidth(int w); +static int uncheckedTransformColor(int fillIndex); +static int wbSizeGet(void); +static int wbSizePut(int value); +static int wbStackClear(void); +static int wbStackPop(int nItems); +static int wbStackPush(int nItems); +static int wbStackSize(void); +static int wbStackValue(int index); +static int wbStackValueput(int index, int value); +static int wbTopGet(void); +static int wbTopPut(int value); +static int wideBezierEntryOf(int line); +static int wideBezierEntryOfput(int line, int value); +static int wideBezierExitOf(int line); +static int wideBezierExitOfput(int line, int value); +static int wideBezierExtentOf(int bezier); +static int wideBezierExtentOfput(int bezier, int value); +static int wideBezierFillOf(int bezier); +static int wideBezierFillOfput(int bezier, int value); +static int * wideBezierUpdateDataOf(int bezier); +static int wideBezierWidthOf(int line); +static int wideBezierWidthOfput(int line, int value); +static int wideLineEntryOf(int line); +static int wideLineEntryOfput(int line, int value); +static int wideLineExitOf(int line); +static int wideLineExitOfput(int line, int value); +static int wideLineExtentOf(int line); +static int wideLineExtentOfput(int line, int value); +static int wideLineFillOf(int line); +static int wideLineFillOfput(int line, int value); +static int wideLineWidthOf(int line); +static int wideLineWidthOfput(int line, int value); + +static int aaColorMaskGet(void) { + return workBuffer[51]; +} + +static int aaColorMaskPut(int value) { + return workBuffer[51] = value; +} + +static int aaColorShiftGet(void) { + return workBuffer[50]; +} + +static int aaColorShiftPut(int value) { + return workBuffer[50] = value; +} + + +/* Common function to compute the first full pixel for AA drawing */ + +static int aaFirstPixelFromto(int leftX, int rightX) { + int firstPixel; + + firstPixel = ((leftX + (workBuffer[48])) - 1) & (~((workBuffer[48]) - 1)); + if (firstPixel > rightX) { + return rightX; + } else { + return firstPixel; + } +} + +static int aaHalfPixelGet(void) { + return workBuffer[53]; +} + +static int aaHalfPixelPut(int value) { + return workBuffer[53] = value; +} + + +/* Common function to compute the last full pixel for AA drawing */ + +static int aaLastPixelFromto(int leftX, int rightX) { + return (rightX - 1) & (~((workBuffer[48]) - 1)); +} + +static int aaLevelGet(void) { + return workBuffer[48]; +} + +static int aaLevelPut(int value) { + return workBuffer[48] = value; +} + +static int aaScanMaskGet(void) { + return workBuffer[52]; +} + +static int aaScanMaskPut(int value) { + return workBuffer[52] = value; +} + +static int aaShiftGet(void) { + return workBuffer[49]; +} + +static int aaShiftPut(int value) { + return workBuffer[49] = value; +} + + +/* Compute the squared value of a 8.24 number with 0.0 <= value < 1.0, + e.g., compute (value * value) bitShift: -24 */ + +static int absoluteSquared8Dot24(int value) { + int word1; + int word2; + + word1 = value & 65535; + word2 = (((unsigned) value >> 16)) & 255; + return ((unsigned) (((((unsigned) (((unsigned) (word1 * word1))) >> 16)) + ((word1 * word2) * 2)) + (((unsigned) (word2 * word2) << 16))) >> 8); +} + + +/* Return the accurate length of the vector described by deltaX and deltaY */ + +static int accurateLengthOfwith(int deltaX, int deltaY) { + int length2; + + if (deltaX == 0) { + if (deltaY < 0) { + return 0 - deltaY; + } else { + return deltaY; + } + } + if (deltaY == 0) { + if (deltaX < 0) { + return 0 - deltaX; + } else { + return deltaX; + } + } + length2 = (deltaX * deltaX) + (deltaY * deltaY); + /* begin computeSqrt: */ + if (length2 < 32) { + return (smallSqrtTable())[length2]; + } else { + return ((int) ((sqrt(((double) length2 ))) + 0.5) ); + } + return null; +} + +static int addEdgeToGET(int edge) { + if (!(allocateGETEntry(1))) { + return 0; + } + getBuffer[workBuffer[12]] = edge; + workBuffer[12] = ((workBuffer[12]) + 1); +} + + +/* NOTE: This method is (hopefully) obsolete due to unrolling + the fill loops to deal with full pixels. */ +/* Adjust the span buffers values by the appropriate color offset for anti-aliasing. + We do this by replicating the top bits of each color in the lower bits. The idea is that we can scale each color value uniquely from 0 to 255 and thus fill the entire range of colors. */ + +static int adjustAALevel(void) { + int adjustShift; + int x0; + int x1; + int pixelValue; + int adjustMask; + + adjustShift = 8 - (workBuffer[50]); + adjustMask = ~(workBuffer[51]); + x0 = ((unsigned) (workBuffer[32])) >> (workBuffer[49]); + x1 = ((unsigned) (workBuffer[34])) >> (workBuffer[49]); + while (x0 < x1) { + pixelValue = spanBuffer[x0]; + spanBuffer[x0] = (pixelValue | ((((unsigned) pixelValue) >> adjustShift) & adjustMask)); + x0 += 1; + } +} + + +/* Adjust the wide bezier curve (dx < 0) to start/end at the right point */ + +static int adjustWideBezierLeftwidthoffsetendX(int bezier, int lineWidth, int lineOffset, int endX) { + int lastX; + int lastY; + + ((objBuffer + bezier) + 10)[0] = ((((objBuffer + bezier) + 10)[0]) - (lineOffset * 256)); + lastX = ((objBuffer + bezier) + 22)[0]; + ((objBuffer + bezier) + 22)[0] = (lastX + ((lineWidth - lineOffset) * 256)); + lastY = ((objBuffer + bezier) + 22)[1]; + ((objBuffer + bezier) + 22)[1] = (lastY + (lineWidth * 256)); + objBuffer[bezier + 21] = (endX - lineOffset); +} + + +/* Adjust the wide bezier curve (dx >= 0) to start/end at the right point */ + +static int adjustWideBezierRightwidthoffsetendX(int bezier, int lineWidth, int lineOffset, int endX) { + int lastX; + int lastY; + + ((objBuffer + bezier) + 10)[0] = ((((objBuffer + bezier) + 10)[0]) + (lineOffset * 256)); + lastX = ((objBuffer + bezier) + 22)[0]; + ((objBuffer + bezier) + 22)[0] = (lastX - ((lineWidth - lineOffset) * 256)); + + /* Set lineWidth pixels down */ + + lastY = ((objBuffer + bezier) + 22)[1]; + ((objBuffer + bezier) + 22)[1] = (lastY + (lineWidth * 256)); + objBuffer[bezier + 21] = ((endX - lineOffset) + lineWidth); +} + + +/* Adjust the wide line after it has been stepped from lastX to nextX. + Special adjustments of line width and start position are made here + to simulate a rectangular brush */ + +static int adjustWideLineafterSteppingFromto(int line, int lastX, int nextX) { + int lineOffset; + int lineWidth; + int xDir; + int baseWidth; + int yExit; + int deltaX; + int yEntry; + + yEntry = objBuffer[line + 18]; + yExit = objBuffer[line + 19]; + baseWidth = objBuffer[line + 20]; + lineOffset = ((int) baseWidth >> 1); + lineWidth = objBuffer[line + 17]; + xDir = objBuffer[line + 10]; + + /* Adjust the start of the line to fill an entire rectangle */ + + deltaX = nextX - lastX; + if (yEntry < baseWidth) { + if (xDir < 0) { + + /* effectively adding */ + + lineWidth -= deltaX; + } else { + lineWidth += deltaX; + objBuffer[line + 4] = lastX; + } + } + if ((yExit + lineOffset) == 0) { + if (xDir > 0) { + lineWidth -= objBuffer[line + 12]; + } else { + + /* effectively subtracting */ + + lineWidth += objBuffer[line + 12]; + objBuffer[line + 4] = lastX; + } + } + if ((yExit + lineOffset) > 0) { + if (xDir < 0) { + + /* effectively subtracting */ + + lineWidth += deltaX; + objBuffer[line + 4] = lastX; + } else { + lineWidth -= deltaX; + } + } + objBuffer[line + 17] = lineWidth; +} + +static int aetStartGet(void) { + return workBuffer[13]; +} + +static int aetStartPut(int value) { + return workBuffer[13] = value; +} + +static int aetUsedGet(void) { + return workBuffer[14]; +} + +static int aetUsedPut(int value) { + return workBuffer[14] = value; +} + + +/* Allocate n slots in the active edge table */ + +static int allocateAETEntry(int nSlots) { + /* begin needAvailableSpace: */ + if (((((128 + objUsed) + (workBuffer[12])) + (workBuffer[14])) + nSlots) > (workBuffer[10])) { + /* begin stopBecauseOf: */ + workBuffer[64] = 1; + engineStopped = 1; + return 0; + } + return 1; +} + +static int allocateBezier(void) { + int bezier; + + if (!(allocateObjEntry(16))) { + return 0; + } + bezier = objUsed; + objUsed = bezier + 16; + objBuffer[bezier + 0] = 6; + objBuffer[bezier + 2] = 0; + objBuffer[bezier + 1] = 16; + return bezier; +} + +static int allocateBezierStackEntry(void) { + /* begin wbStackPush: */ + if (!(needAvailableSpace(6))) { + goto l1; + } + workBuffer[10] = ((workBuffer[10]) - 6); +l1: /* end wbStackPush: */; + return (workBuffer[1]) - (workBuffer[10]); +} + +static int allocateBitmapFillcolormap(int cmSize, int *cmBits) { + int fillSize; + int fill; + int *cm; + int i; + + fillSize = 18 + cmSize; + if (!(allocateObjEntry(fillSize))) { + return 0; + } + fill = objUsed; + objUsed = fill + fillSize; + objBuffer[fill + 0] = 1024; + objBuffer[fill + 2] = 0; + objBuffer[fill + 1] = fillSize; + cm = (objBuffer + fill) + 18; + if ((workBuffer[17]) != 0) { + for (i = 0; i <= (cmSize - 1); i += 1) { + cm[i] = (transformColor(cmBits[i])); + } + } else { + for (i = 0; i <= (cmSize - 1); i += 1) { + cm[i] = (cmBits[i]); + } + } + objBuffer[fill + 15] = cmSize; + return fill; +} + + +/* Allocate n slots in the global edge table */ + +static int allocateGETEntry(int nSlots) { + int dstIndex; + int i; + int srcIndex; + + if (!(needAvailableSpace(nSlots))) { + return 0; + } + if (!((workBuffer[14]) == 0)) { + srcIndex = workBuffer[14]; + dstIndex = (workBuffer[14]) + nSlots; + for (i = 1; i <= (workBuffer[14]); i += 1) { + aetBuffer[dstIndex -= 1] = (aetBuffer[srcIndex -= 1]); + } + } + aetBuffer += nSlots; + return 1; +} + +static int allocateGradientFillrampWidthisRadial(int *ramp, int rampWidth, int isRadial) { + int fillSize; + int fill; + int *rampPtr; + int i; + + fillSize = 12 + rampWidth; + if (!(allocateObjEntry(fillSize))) { + return 0; + } + fill = objUsed; + objUsed = fill + fillSize; + if (isRadial) { + objBuffer[fill + 0] = 768; + } else { + objBuffer[fill + 0] = 512; + } + objBuffer[fill + 2] = 0; + objBuffer[fill + 1] = fillSize; + rampPtr = (objBuffer + fill) + 12; + if ((workBuffer[17]) != 0) { + for (i = 0; i <= (rampWidth - 1); i += 1) { + rampPtr[i] = (transformColor(ramp[i])); + } + } else { + for (i = 0; i <= (rampWidth - 1); i += 1) { + rampPtr[i] = (ramp[i]); + } + } + objBuffer[fill + 10] = rampWidth; + return fill; +} + +static int allocateLine(void) { + int line; + + if (!(allocateObjEntry(16))) { + return 0; + } + line = objUsed; + objUsed = line + 16; + objBuffer[line + 0] = 4; + objBuffer[line + 2] = 0; + objBuffer[line + 1] = 16; + return line; +} + + +/* Allocate n slots in the object buffer */ + +static int allocateObjEntry(int nSlots) { + int dstIndex; + int i; + int srcIndex; + + if (!(allocateGETEntry(nSlots))) { + return 0; + } + if (!((workBuffer[12]) == 0)) { + srcIndex = workBuffer[12]; + dstIndex = (workBuffer[12]) + nSlots; + for (i = 1; i <= (workBuffer[12]); i += 1) { + getBuffer[dstIndex -= 1] = (getBuffer[srcIndex -= 1]); + } + } + getBuffer += nSlots; + return 1; +} + + +/* AET and Stack allocation are symmetric */ + +static int allocateStackEntry(int nSlots) { + /* begin needAvailableSpace: */ + if (((((128 + objUsed) + (workBuffer[12])) + (workBuffer[14])) + nSlots) > (workBuffer[10])) { + /* begin stopBecauseOf: */ + workBuffer[64] = 1; + engineStopped = 1; + return 0; + } + return 1; +} + +static int allocateStackFillEntry(void) { + /* begin wbStackPush: */ + if (!(needAvailableSpace(3))) { + return 0; + } + workBuffer[10] = ((workBuffer[10]) - 3); + return 1; +} + +static int allocateWideBezier(void) { + int bezier; + + if (!(allocateObjEntry(28))) { + return 0; + } + bezier = objUsed; + objUsed = bezier + 28; + objBuffer[bezier + 0] = 7; + objBuffer[bezier + 2] = 0; + objBuffer[bezier + 1] = 28; + return bezier; +} + +static int allocateWideLine(void) { + int line; + + if (!(allocateObjEntry(21))) { + return 0; + } + line = objUsed; + objUsed = line + 21; + objBuffer[line + 0] = 5; + objBuffer[line + 2] = 0; + objBuffer[line + 1] = 21; + return line; +} + +static int areEdgeFillsValid(int edge) { + return ((objBuffer[edge + 0]) & 65536) == 0; +} + + +/* Make sure that val1 is between val2 and val3. */ + +static int assureValuebetweenand(int val1, int val2, int val3) { + if (val2 > val3) { + if (val1 > val2) { + return val2; + } + if (val1 < val3) { + return val3; + } + } else { + if (val1 < val2) { + return val2; + } + if (val1 > val3) { + return val3; + } + } + return val1; +} + +static int bezierEndXOf(int bezier) { + return objBuffer[bezier + 14]; +} + +static int bezierEndXOfput(int bezier, int value) { + return objBuffer[bezier + 14] = value; +} + +static int bezierEndYOf(int bezier) { + return objBuffer[bezier + 15]; +} + +static int bezierEndYOfput(int bezier, int value) { + return objBuffer[bezier + 15] = value; +} + +static int bezierFinalXOf(int bezier) { + return objBuffer[bezier + 21]; +} + +static int bezierFinalXOfput(int bezier, int value) { + return objBuffer[bezier + 21] = value; +} + +static int * bezierUpdateDataOf(int bezier) { + return (objBuffer + bezier) + 10; +} + +static int bezierViaXOf(int bezier) { + return objBuffer[bezier + 12]; +} + +static int bezierViaXOfput(int bezier, int value) { + return objBuffer[bezier + 12] = value; +} + +static int bezierViaYOf(int bezier) { + return objBuffer[bezier + 13]; +} + +static int bezierViaYOfput(int bezier, int value) { + return objBuffer[bezier + 13] = value; +} + +static int bitmapCmSizeOf(int bmFill) { + return objBuffer[bmFill + 15]; +} + +static int bitmapCmSizeOfput(int bmFill, int value) { + return objBuffer[bmFill + 15] = value; +} + +static int bitmapDepthOf(int bmFill) { + return objBuffer[bmFill + 12]; +} + +static int bitmapDepthOfput(int bmFill, int value) { + return objBuffer[bmFill + 12] = value; +} + +static int bitmapHeightOf(int bmFill) { + return objBuffer[bmFill + 11]; +} + +static int bitmapHeightOfput(int bmFill, int value) { + return objBuffer[bmFill + 11] = value; +} + +static int bitmapRasterOf(int bmFill) { + return objBuffer[bmFill + 14]; +} + +static int bitmapRasterOfput(int bmFill, int value) { + return objBuffer[bmFill + 14] = value; +} + +static int bitmapSizeOf(int bmFill) { + return objBuffer[bmFill + 13]; +} + +static int bitmapSizeOfput(int bmFill, int value) { + return objBuffer[bmFill + 13] = value; +} + +static int bitmapTileFlagOf(int bmFill) { + return objBuffer[bmFill + 16]; +} + +static int bitmapTileFlagOfput(int bmFill, int value) { + return objBuffer[bmFill + 16] = value; +} + +static int bitmapValuebitsatXy(int bmFill, int bits, int xp, int yp) { + int g; + int cMask; + int bmDepth; + int rShift; + int r; + int bmRaster; + int value; + int b; + int a; + + bmDepth = objBuffer[bmFill + 12]; + bmRaster = objBuffer[bmFill + 14]; + if (bmDepth == 32) { + value = (((int*) bits))[(bmRaster * yp) + xp]; + if ((value != 0) && ((value & 4278190080U) == 0)) { + value = value | 4278190080U; + } + return uncheckedTransformColor(value); + } + rShift = (rShiftTable())[bmDepth]; + + /* cMask - mask out the pixel from the word */ + + value = (((int*) bits))[(bmRaster * yp) + (((unsigned) xp) >> rShift)]; + + /* rShift - shift value to move the pixel in the word to the lowest bit position */ + + cMask = (1 << bmDepth) - 1; + rShift = (32 - bmDepth) - ((xp & ((1 << rShift) - 1)) * bmDepth); + value = (((unsigned) value) >> rShift) & cMask; + if (bmDepth == 16) { + if (!(value == 0)) { + b = (value & 31) << 3; + b += ((unsigned) b) >> 5; + g = ((((unsigned) value) >> 5) & 31) << 3; + g += ((unsigned) g) >> 5; + r = ((((unsigned) value) >> 10) & 31) << 3; + r += ((unsigned) r) >> 5; + a = 255; + value = ((b + (g << 8)) + (r << 16)) + (a << 24); + } + } else { + if ((objBuffer[bmFill + 15]) == 0) { + value = 0; + } else { + value = ((objBuffer + bmFill) + 18)[value]; + } + } + return uncheckedTransformColor(value); +} + +static int bitmapWidthOf(int bmFill) { + return objBuffer[bmFill + 10]; +} + +static int bitmapWidthOfput(int bmFill, int value) { + return objBuffer[bmFill + 10] = value; +} + +static int bzEndX(int index) { + return workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 4)]; +} + +static int bzEndXput(int index, int value) { + return workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 4)] = value; +} + +static int bzEndY(int index) { + return workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 5)]; +} + +static int bzEndYput(int index, int value) { + return workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 5)] = value; +} + +static int bzStartX(int index) { + return workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 0)]; +} + +static int bzStartXput(int index, int value) { + return workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 0)] = value; +} + +static int bzStartY(int index) { + return workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 1)]; +} + +static int bzStartYput(int index, int value) { + return workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 1)] = value; +} + +static int bzViaX(int index) { + return workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 2)]; +} + +static int bzViaXput(int index, int value) { + return workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 2)] = value; +} + +static int bzViaY(int index) { + return workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 3)]; +} + +static int bzViaYput(int index, int value) { + return workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 3)] = value; +} + + +/* Check the fill indexes in the run-length encoded fillList */ + +static int checkCompressedFillIndexListmaxsegments(int fillList, int maxIndex, int nSegs) { + int length; + int *fillPtr; + int i; + int runValue; + int nFills; + int runLength; + + length = interpreterProxy->slotSizeOf(fillList); + fillPtr = interpreterProxy->firstIndexableField(fillList); + nFills = 0; + for (i = 0; i <= (length - 1); i += 1) { + runLength = ((unsigned) ((((int *) fillPtr))[i]) >> 16); + runValue = ((((int *) fillPtr))[0]) & 65535; + if (!((runValue >= 0) && (runValue <= maxIndex))) { + return 0; + } + nFills += runLength; + } + return nFills == nSegs; +} + + +/* Check if the indexList (containing fill handles) is okay. */ + +static int checkCompressedFills(int indexList) { + int length; + int *fillPtr; + int i; + int fillIndex; + + if (!(interpreterProxy->isWords(indexList))) { + return 0; + } + length = interpreterProxy->slotSizeOf(indexList); + fillPtr = interpreterProxy->firstIndexableField(indexList); + for (i = 1; i <= length; i += 1) { + + /* Make sure the fill is okay */ + + fillIndex = fillPtr[0]; + if (!(isFillOkay(fillIndex))) { + return 0; + } + fillPtr += 1; + } + return 1; +} + + +/* Check the run-length encoded lineWidthList matches nSegments */ + +static int checkCompressedLineWidthssegments(int lineWidthList, int nSegments) { + int runLength; + int length; + int *ptr; + int nItems; + int i; + + length = interpreterProxy->slotSizeOf(lineWidthList); + ptr = interpreterProxy->firstIndexableField(lineWidthList); + nItems = 0; + for (i = 0; i <= (length - 1); i += 1) { + runLength = ((unsigned) ((((int *) ptr))[i]) >> 16); + nItems += runLength; + } + return nItems == nSegments; +} + + +/* Check if the given point array can be handled by the engine. */ + +static int checkCompressedPointssegments(int points, int nSegments) { + int pSize; + + if (!(interpreterProxy->isWords(points))) { + return 0; + } + + /* The points must be either in PointArray format or ShortPointArray format. + Also, we currently handle only quadratic segments (e.g., 3 points each) and thus either + pSize = nSegments * 3, for ShortPointArrays or, + pSize = nSegments * 6, for PointArrays */ + + pSize = interpreterProxy->slotSizeOf(points); + if (!((pSize == (nSegments * 3)) || (pSize == (nSegments * 6)))) { + return 0; + } + return 1; +} + + +/* Check if the given shape can be handled by the engine. + Since there are a number of requirements this is an extra method. */ + +static int checkCompressedShapesegmentsleftFillsrightFillslineWidthslineFillsfillIndexList(int points, int nSegments, int leftFills, int rightFills, int lineWidths, int lineFills, int fillIndexList) { + int maxFillIndex; + + if (!(checkCompressedPointssegments(points, nSegments))) { + return 0; + } + if (!(checkCompressedFills(fillIndexList))) { + return 0; + } + maxFillIndex = interpreterProxy->slotSizeOf(fillIndexList); + if (!(checkCompressedFillIndexListmaxsegments(leftFills, maxFillIndex, nSegments))) { + return 0; + } + if (!(checkCompressedFillIndexListmaxsegments(rightFills, maxFillIndex, nSegments))) { + return 0; + } + if (!(checkCompressedFillIndexListmaxsegments(lineFills, maxFillIndex, nSegments))) { + return 0; + } + if (!(checkCompressedLineWidthssegments(lineWidths, nSegments))) { + return 0; + } + return 1; +} + + +/* Add the bezier to the global edge table if it intersects the clipping region */ + +static int checkedAddBezierToGET(int bezier) { + int lineWidth; + + if ((((objBuffer[bezier + 0]) & 65535) & 1) != 0) { + lineWidth = objBuffer[bezier + 20]; + } else { + lineWidth = 0; + } + if (((objBuffer[bezier + 15]) + lineWidth) < (workBuffer[38])) { + return 0; + } + if ((((objBuffer[bezier + 4]) - lineWidth) >= (workBuffer[37])) && (((objBuffer[bezier + 14]) - lineWidth) >= (workBuffer[37]))) { + return 0; + } + addEdgeToGET(bezier); +} + + +/* Add the edge to the global edge table. + For known edge types, check if the edge intersects the visible region */ + +static int checkedAddEdgeToGET(int edge) { + int lineWidth; + int lineWidth1; + + if ((((objBuffer[edge + 0]) & 65535) & 254) == 4) { + /* begin checkedAddLineToGET: */ + if ((((objBuffer[edge + 0]) & 65535) & 1) != 0) { + lineWidth = objBuffer[edge + 20]; + } else { + lineWidth = 0; + } + if (((objBuffer[edge + 15]) + lineWidth) < (workBuffer[38])) { + return 0; + } + if ((((objBuffer[edge + 4]) - lineWidth) >= (workBuffer[37])) && (((objBuffer[edge + 14]) - lineWidth) >= (workBuffer[37]))) { + return 0; + } + addEdgeToGET(edge); + return null; + } + if ((((objBuffer[edge + 0]) & 65535) & 254) == 6) { + /* begin checkedAddBezierToGET: */ + if ((((objBuffer[edge + 0]) & 65535) & 1) != 0) { + lineWidth1 = objBuffer[edge + 20]; + } else { + lineWidth1 = 0; + } + if (((objBuffer[edge + 15]) + lineWidth1) < (workBuffer[38])) { + return 0; + } + if ((((objBuffer[edge + 4]) - lineWidth1) >= (workBuffer[37])) && (((objBuffer[edge + 14]) - lineWidth1) >= (workBuffer[37]))) { + return 0; + } + addEdgeToGET(edge); + return null; + } + addEdgeToGET(edge); +} + + +/* Add the line to the global edge table if it intersects the clipping region */ + +static int checkedAddLineToGET(int line) { + int lineWidth; + + if ((((objBuffer[line + 0]) & 65535) & 1) != 0) { + lineWidth = objBuffer[line + 20]; + } else { + lineWidth = 0; + } + if (((objBuffer[line + 15]) + lineWidth) < (workBuffer[38])) { + return 0; + } + if ((((objBuffer[line + 4]) - lineWidth) >= (workBuffer[37])) && (((objBuffer[line + 14]) - lineWidth) >= (workBuffer[37]))) { + return 0; + } + addEdgeToGET(line); +} + +static double * circleCosTable(void) { + static double theTable[33] = + {1.0, 0.98078528040323, 0.923879532511287, 0.831469612302545, + 0.7071067811865475, 0.555570233019602, 0.38268343236509, 0.1950903220161286, + 0.0, -0.1950903220161283, -0.3826834323650896, -0.555570233019602, + -0.707106781186547, -0.831469612302545, -0.9238795325112865, -0.98078528040323, + -1.0, -0.98078528040323, -0.923879532511287, -0.831469612302545, + -0.707106781186548, -0.555570233019602, -0.3826834323650903, -0.1950903220161287, + 0.0, 0.1950903220161282, 0.38268343236509, 0.555570233019602, + 0.707106781186547, 0.831469612302545, 0.9238795325112865, 0.98078528040323, + 1.0 }; + + return theTable; +} + +static double * circleSinTable(void) { + static double theTable[33] = + {0.0, 0.1950903220161282, 0.3826834323650897, 0.555570233019602, + 0.707106781186547, 0.831469612302545, 0.923879532511287, 0.98078528040323, + 1.0, 0.98078528040323, 0.923879532511287, 0.831469612302545, + 0.7071067811865475, 0.555570233019602, 0.38268343236509, 0.1950903220161286, + 0.0, -0.1950903220161283, -0.3826834323650896, -0.555570233019602, + -0.707106781186547, -0.831469612302545, -0.9238795325112865, -0.98078528040323, + -1.0, -0.98078528040323, -0.923879532511287, -0.831469612302545, + -0.707106781186548, -0.555570233019602, -0.3826834323650903, -0.1950903220161287, + 0.0 }; + + return theTable; +} + +static int clampValuemax(int value, int maxValue) { + if (value < 0) { + return 0; + } else { + if (value >= maxValue) { + return maxValue - 1; + } else { + return value; + } + } +} + + +/* Clear the current span buffer. + The span buffer is only cleared in the area that has been used by the previous scan line. */ + +static int clearSpanBuffer(void) { + int x0; + int x1; + + x0 = ((unsigned) (workBuffer[32])) >> (workBuffer[49]); + x1 = (((unsigned) (workBuffer[34])) >> (workBuffer[49])) + 1; + if (x0 < 0) { + x0 = 0; + } + if (x1 > (workBuffer[33])) { + x1 = workBuffer[33]; + } + while (x0 < x1) { + spanBuffer[x0] = 0; + x0 += 1; + } + workBuffer[32] = (workBuffer[33]); + workBuffer[34] = 0; +} + +static int clearSpanBufferGet(void) { + return workBuffer[69]; +} + +static int clearSpanBufferPut(int value) { + return workBuffer[69] = value; +} + +static int clipMaxXGet(void) { + return workBuffer[43]; +} + +static int clipMaxXPut(int value) { + return workBuffer[43] = value; +} + +static int clipMaxYGet(void) { + return workBuffer[45]; +} + +static int clipMaxYPut(int value) { + return workBuffer[45] = value; +} + +static int clipMinXGet(void) { + return workBuffer[42]; +} + +static int clipMinXPut(int value) { + return workBuffer[42] = value; +} + +static int clipMinYGet(void) { + return workBuffer[44]; +} + +static int clipMinYPut(int value) { + return workBuffer[44] = value; +} + +static float * colorTransform(void) { + return ((float *) (workBuffer + 24)); +} + +static int * colormapOf(int bmFill) { + return (objBuffer + bmFill) + 18; +} + + +/* Split the bezier curve at the given parametric value. + Note: Since this method is only invoked to make non-monoton + beziers monoton we must check for the resulting y values + to be *really* between the start and end value. */ + +static int computeBeziersplitAt(int index, double param) { + int rightViaX; + int rightViaY; + int endX; + int sharedX; + int endY; + int sharedY; + int newIndex; + int startX; + int startY; + int viaX; + int leftViaX; + int viaY; + int leftViaY; + + leftViaX = startX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 0)]; + leftViaY = startY = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 1)]; + rightViaX = viaX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 2)]; + rightViaY = viaY = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 3)]; + endX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 4)]; + + /* Compute intermediate points */ + + endY = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 5)]; + sharedX = leftViaX += ((int) ((((double) (viaX - startX) )) * param) ); + sharedY = leftViaY += ((int) ((((double) (viaY - startY) )) * param) ); + rightViaX += ((int) ((((double) (endX - viaX) )) * param) ); + + /* Compute new shared point */ + + rightViaY += ((int) ((((double) (endY - viaY) )) * param) ); + sharedX += ((int) ((((double) (rightViaX - leftViaX) )) * param) ); + + /* Check the new via points */ + + sharedY += ((int) ((((double) (rightViaY - leftViaY) )) * param) ); + /* begin assureValue:between:and: */ + if (startY > sharedY) { + if (leftViaY > startY) { + leftViaY = startY; + goto l1; + } + if (leftViaY < sharedY) { + leftViaY = sharedY; + goto l1; + } + } else { + if (leftViaY < startY) { + leftViaY = startY; + goto l1; + } + if (leftViaY > sharedY) { + leftViaY = sharedY; + goto l1; + } + } + leftViaY = leftViaY; +l1: /* end assureValue:between:and: */; + /* begin assureValue:between:and: */ + if (sharedY > endY) { + if (rightViaY > sharedY) { + rightViaY = sharedY; + goto l2; + } + if (rightViaY < endY) { + rightViaY = endY; + goto l2; + } + } else { + if (rightViaY < sharedY) { + rightViaY = sharedY; + goto l2; + } + if (rightViaY > endY) { + rightViaY = endY; + goto l2; + } + } + rightViaY = rightViaY; +l2: /* end assureValue:between:and: */; + /* begin allocateBezierStackEntry */ + /* begin wbStackPush: */ + if (!(needAvailableSpace(6))) { + goto l3; + } + workBuffer[10] = ((workBuffer[10]) - 6); +l3: /* end wbStackPush: */; + newIndex = (workBuffer[1]) - (workBuffer[10]); + if (engineStopped) { + return 0; + } + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 2)] = leftViaX; + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 3)] = leftViaY; + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 4)] = sharedX; + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 5)] = sharedY; + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 0)] = sharedX; + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 1)] = sharedY; + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 2)] = rightViaX; + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 3)] = rightViaY; + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 4)] = endX; + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 5)] = endY; + return newIndex; +} + + +/* Split the bezier curve at 0.5. */ + +static int computeBezierSplitAtHalf(int index) { + int rightViaX; + int rightViaY; + int endX; + int sharedX; + int endY; + int sharedY; + int newIndex; + int startX; + int startY; + int viaX; + int leftViaX; + int leftViaY; + int viaY; + + /* begin allocateBezierStackEntry */ + /* begin wbStackPush: */ + if (!(needAvailableSpace(6))) { + goto l1; + } + workBuffer[10] = ((workBuffer[10]) - 6); +l1: /* end wbStackPush: */; + newIndex = (workBuffer[1]) - (workBuffer[10]); + if (engineStopped) { + return 0; + } + leftViaX = startX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 0)]; + leftViaY = startY = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 1)]; + rightViaX = viaX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 2)]; + rightViaY = viaY = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 3)]; + endX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 4)]; + + /* Compute intermediate points */ + + endY = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 5)]; + leftViaX += ((int) (viaX - startX) >> 1); + leftViaY += ((int) (viaY - startY) >> 1); + sharedX = rightViaX += ((int) (endX - viaX) >> 1); + + /* Compute new shared point */ + + sharedY = rightViaY += ((int) (endY - viaY) >> 1); + sharedX += ((int) (leftViaX - rightViaX) >> 1); + + /* Store the first part back */ + + sharedY += ((int) (leftViaY - rightViaY) >> 1); + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 2)] = leftViaX; + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 3)] = leftViaY; + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 4)] = sharedX; + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 5)] = sharedY; + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 0)] = sharedX; + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 1)] = sharedY; + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 2)] = rightViaX; + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 3)] = rightViaY; + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 4)] = endX; + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 5)] = endY; + return newIndex; +} + + +/* Get both values from the two boundaries of the given bezier + and compute the actual position/width of the line */ + +static int computeFinalWideBezierValueswidth(int bezier, int lineWidth) { + int leftX; + int rightX; + int temp; + + leftX = ((int) (((objBuffer + bezier) + 10)[0]) >> 8); + rightX = ((int) (((objBuffer + bezier) + 22)[0]) >> 8); + if (leftX > rightX) { + temp = leftX; + leftX = rightX; + rightX = temp; + } + objBuffer[bezier + 4] = leftX; + if ((rightX - leftX) > lineWidth) { + objBuffer[bezier + 17] = (rightX - leftX); + } else { + objBuffer[bezier + 17] = lineWidth; + } +} + +static int computeSqrt(int length2) { + if (length2 < 32) { + return (smallSqrtTable())[length2]; + } else { + return ((int) ((sqrt(((double) length2 ))) + 0.5) ); + } +} + +static int copyBitsFromtoat(int x0, int x1, int yValue) { + if (copyBitsFn == 0) { + if (!(initialiseModule())) { + return 0; + } + } + return ((int (*) (int, int, int)) copyBitsFn)(x0, x1, yValue); +} + + +/* Create the global edge table */ + +static int createGlobalEdgeTable(void) { + int end; + int object; + int lineWidth; + int lineWidth1; + + object = 0; + end = objUsed; + while (object < end) { + if (isEdge(object)) { + if (!((objBuffer[object + 5]) >= (workBuffer[39]))) { + /* begin checkedAddEdgeToGET: */ + if ((((objBuffer[object + 0]) & 65535) & 254) == 4) { + /* begin checkedAddLineToGET: */ + if ((((objBuffer[object + 0]) & 65535) & 1) != 0) { + lineWidth = objBuffer[object + 20]; + } else { + lineWidth = 0; + } + if (((objBuffer[object + 15]) + lineWidth) < (workBuffer[38])) { + goto l2; + } + if ((((objBuffer[object + 4]) - lineWidth) >= (workBuffer[37])) && (((objBuffer[object + 14]) - lineWidth) >= (workBuffer[37]))) { + goto l2; + } + addEdgeToGET(object); + l2: /* end checkedAddLineToGET: */; + goto l1; + } + if ((((objBuffer[object + 0]) & 65535) & 254) == 6) { + /* begin checkedAddBezierToGET: */ + if ((((objBuffer[object + 0]) & 65535) & 1) != 0) { + lineWidth1 = objBuffer[object + 20]; + } else { + lineWidth1 = 0; + } + if (((objBuffer[object + 15]) + lineWidth1) < (workBuffer[38])) { + goto l3; + } + if ((((objBuffer[object + 4]) - lineWidth1) >= (workBuffer[37])) && (((objBuffer[object + 14]) - lineWidth1) >= (workBuffer[37]))) { + goto l3; + } + addEdgeToGET(object); + l3: /* end checkedAddBezierToGET: */; + goto l1; + } + addEdgeToGET(object); + l1: /* end checkedAddEdgeToGET: */; + } + } + object += objBuffer[object + 1]; + } +} + +static int currentYGet(void) { + return workBuffer[88]; +} + +static int currentYPut(int value) { + return workBuffer[88] = value; +} + +static int currentZGet(void) { + return workBuffer[113]; +} + +static int currentZPut(int value) { + return workBuffer[113] = value; +} + +static int destOffsetXGet(void) { + return workBuffer[46]; +} + +static int destOffsetXPut(int value) { + return workBuffer[46] = value; +} + +static int destOffsetYGet(void) { + return workBuffer[47]; +} + +static int destOffsetYPut(int value) { + return workBuffer[47] = value; +} + + +/* Display the span buffer at the current scan line. */ + +static int displaySpanBufferAt(int y) { + int targetY; + int targetX0; + int targetX1; + + targetX0 = ((unsigned) (workBuffer[32])) >> (workBuffer[49]); + if (targetX0 < (workBuffer[42])) { + targetX0 = workBuffer[42]; + } + targetX1 = ((unsigned) (((workBuffer[34]) + (workBuffer[48])) - 1)) >> (workBuffer[49]); + if (targetX1 > (workBuffer[43])) { + targetX1 = workBuffer[43]; + } + targetY = ((unsigned) y) >> (workBuffer[49]); + if ((targetY < (workBuffer[44])) || ((targetY >= (workBuffer[45])) || ((targetX1 < (workBuffer[42])) || (targetX0 >= (workBuffer[43]))))) { + return 0; + } + copyBitsFromtoat(targetX0, targetX1, targetY); +} + + +/* Draw the given edge starting from leftX with the edge's fill. + Return the end value of the drawing operation. */ + +static int drawWideEdgefrom(int edge, int leftX) { + int fill; + int lineWidth; + int rightX; + int type; + + type = ((unsigned) ((objBuffer[edge + 0]) & 65535)) >> 1; + dispatchedValue = edge; + switch (type) { + case 0: + case 1: + errorWrongIndex(); + break; + case 2: + dispatchReturnValue = objBuffer[dispatchedValue + 17]; + break; + case 3: + dispatchReturnValue = objBuffer[dispatchedValue + 17]; + break; + } + lineWidth = dispatchReturnValue; + switch (type) { + case 0: + case 1: + errorWrongIndex(); + break; + case 2: + dispatchReturnValue = objBuffer[dispatchedValue + 16]; + break; + case 3: + dispatchReturnValue = objBuffer[dispatchedValue + 16]; + break; + } + fill = dispatchReturnValue; + if (fill == 0) { + return leftX; + } + rightX = leftX + lineWidth; + fillSpanfromto(fill, leftX, rightX); + return rightX; +} + +static int edgeFillsInvalidate(int edge) { + return objBuffer[edge + 0] = (((objBuffer[edge + 0]) & 65535) | 65536); +} + +static int edgeFillsValidate(int edge) { + return objBuffer[edge + 0] = (((objBuffer[edge + 0]) & 65535) & (~65536)); +} + +static int edgeLeftFillOf(int edge) { + return objBuffer[edge + 8]; +} + +static int edgeLeftFillOfput(int edge, int value) { + return objBuffer[edge + 8] = value; +} + +static int edgeNumLinesOf(int edge) { + return objBuffer[edge + 7]; +} + +static int edgeNumLinesOfput(int edge, int value) { + return objBuffer[edge + 7] = value; +} + +static int edgeRightFillOf(int edge) { + return objBuffer[edge + 9]; +} + +static int edgeRightFillOfput(int edge, int value) { + return objBuffer[edge + 9] = value; +} + +static float * edgeTransform(void) { + return ((float *) (workBuffer + 18)); +} + + +/* Return the edge type (e.g., witout the wide edge flag) */ + +static int edgeTypeOf(int edge) { + return ((unsigned) ((objBuffer[edge + 0]) & 65535)) >> 1; +} + +static int edgeXValueOf(int edge) { + return objBuffer[edge + 4]; +} + +static int edgeXValueOfput(int edge, int value) { + return objBuffer[edge + 4] = value; +} + +static int edgeYValueOf(int edge) { + return objBuffer[edge + 5]; +} + +static int edgeYValueOfput(int edge, int value) { + return objBuffer[edge + 5] = value; +} + +static int edgeZValueOf(int edge) { + return objBuffer[edge + 6]; +} + +static int edgeZValueOfput(int edge, int value) { + return objBuffer[edge + 6] = value; +} + + +/* Ignore dispatch errors when translating to C + (since we have no entry point for #error in the VM proxy) */ + +static int errorWrongIndex(void) { + ; +} + + +/* Estimate the length of the vector described by deltaX and deltaY. + This method may be extremely inaccurate - use it only + if you know exactly that this doesn't matter. Otherwise + use #accurateLengthOf:width: */ + +static int estimatedLengthOfwith(int deltaX, int deltaY) { + int absDy; + int absDx; + + if (deltaX >= 0) { + absDx = deltaX; + } else { + absDx = 0 - deltaX; + } + if (deltaY >= 0) { + absDy = deltaY; + } else { + absDy = 0 - deltaY; + } + if (absDx > absDy) { + return absDx + (((int) absDy >> 1)); + } else { + return absDy + (((int) absDx >> 1)); + } +} + + +/* Fill the span buffer from leftX to rightX with the given fill. */ + +static int fillAllFromto(int leftX, int rightX) { + int startX; + int fill; + int stopX; + int someIntegerValue; + int someIntegerValue1; + + /* begin topFill */ + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + fill = 0; + goto l5; + } else { + fill = workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)]; + goto l5; + } +l5: /* end topFill */; + startX = leftX; + /* begin topRightX */ + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + stopX = 999999999; + goto l3; + } else { + stopX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 2)]; + goto l3; + } +l3: /* end topRightX */; + while (stopX < rightX) { + /* begin makeUnsignedFrom: */ + /* begin topFill */ + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + someIntegerValue = 0; + goto l4; + } else { + someIntegerValue = workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)]; + goto l4; + } + l4: /* end topFill */; + fill = someIntegerValue; + if (!(fill == 0)) { + if (fillSpanfromto(fill, startX, stopX)) { + return 1; + } + } + /* begin quickRemoveInvalidFillsAt: */ + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + goto l1; + } + while ((topRightX()) <= stopX) { + hideFilldepth(topFill(), topDepth()); + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + goto l1; + } + } + l1: /* end quickRemoveInvalidFillsAt: */; + startX = stopX; + /* begin topRightX */ + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + stopX = 999999999; + goto l2; + } else { + stopX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 2)]; + goto l2; + } + l2: /* end topRightX */; + } + /* begin makeUnsignedFrom: */ + /* begin topFill */ + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + someIntegerValue1 = 0; + goto l6; + } else { + someIntegerValue1 = workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)]; + goto l6; + } +l6: /* end topFill */; + fill = someIntegerValue1; + if (!(fill == 0)) { + return fillSpanfromto(fill, startX, rightX); + } + return 0; +} + +static int fillBitmapSpan(void) { + return fillBitmapSpanfromtoat(workBuffer[66], workBuffer[67], workBuffer[68], workBuffer[88]); +} + + +/* Fill the span buffer between leftEdge and rightEdge using the given bits. + Note: We always start from zero - this avoids using huge bitmap buffers if the bitmap is to be displayed at the very far right hand side and also gives us a chance of using certain bitmaps (e.g., those with depth 32) directly. */ + +static int fillBitmapSpanfromto(int *bits, int leftX, int rightX) { + int colorMask; + int x; + int x0; + int x1; + int fillValue; + int bitX; + int colorShift; + int baseShift; + + x0 = leftX; + x1 = rightX; + + /* Hack for pre-increment */ + + bitX = -1; + if ((workBuffer[48]) == 1) { + while (x0 < x1) { + fillValue = (((int *) bits))[bitX += 1]; + spanBuffer[x0] = fillValue; + x0 += 1; + } + } else { + colorMask = workBuffer[51]; + colorShift = workBuffer[50]; + baseShift = workBuffer[49]; + while (x0 < x1) { + x = ((unsigned) x0) >> baseShift; + fillValue = (((int *) bits))[bitX += 1]; + fillValue = ((unsigned) (fillValue & colorMask)) >> colorShift; + spanBuffer[x] = ((spanBuffer[x]) + fillValue); + x0 += 1; + } + } + if (x1 > (workBuffer[34])) { + workBuffer[34] = x1; + } + if (x1 > (workBuffer[35])) { + workBuffer[35] = x1; + } +} + +static int fillBitmapSpanfromtoat(int bmFill, int leftX, int rightX, int yValue) { + int *bits; + int ds; + int dt; + int x; + int x1; + int dtX; + int fillValue; + int yp; + int tileFlag; + int deltaX; + int dsX; + int deltaY; + int xp; + int bmWidth; + int bmHeight; + int newDelta; + int newDelta1; + int g; + int cMask; + int bmDepth; + int rShift; + int r; + int bmRaster; + int value; + int b; + int a; + + if (!((workBuffer[48]) == 1)) { + return fillBitmapSpanAAfromtoat(bmFill, leftX, rightX, yValue); + } + bits = loadBitsFrom(bmFill); + if (bits == null) { + return null; + } + bmWidth = objBuffer[bmFill + 10]; + bmHeight = objBuffer[bmFill + 11]; + tileFlag = (objBuffer[bmFill + 16]) == 1; + deltaX = leftX - (objBuffer[bmFill + 4]); + deltaY = yValue - (objBuffer[bmFill + 5]); + dsX = objBuffer[bmFill + 6]; + dtX = objBuffer[bmFill + 8]; + ds = (deltaX * dsX) + (deltaY * (objBuffer[bmFill + 7])); + dt = (deltaX * dtX) + (deltaY * (objBuffer[bmFill + 9])); + x = leftX; + x1 = rightX; + while (x < x1) { + if (tileFlag) { + /* begin repeatValue:max: */ + newDelta = ds; + while (newDelta < 0) { + newDelta += bmWidth << 16; + } + while (newDelta >= (bmWidth << 16)) { + newDelta -= bmWidth << 16; + } + ds = newDelta; + /* begin repeatValue:max: */ + newDelta1 = dt; + while (newDelta1 < 0) { + newDelta1 += bmHeight << 16; + } + while (newDelta1 >= (bmHeight << 16)) { + newDelta1 -= bmHeight << 16; + } + dt = newDelta1; + } + xp = ((int) ds >> 16); + yp = ((int) dt >> 16); + if (!(tileFlag)) { + /* begin clampValue:max: */ + if (xp < 0) { + xp = 0; + goto l1; + } else { + if (xp >= bmWidth) { + xp = bmWidth - 1; + goto l1; + } else { + xp = xp; + goto l1; + } + } + l1: /* end clampValue:max: */; + /* begin clampValue:max: */ + if (yp < 0) { + yp = 0; + goto l2; + } else { + if (yp >= bmHeight) { + yp = bmHeight - 1; + goto l2; + } else { + yp = yp; + goto l2; + } + } + l2: /* end clampValue:max: */; + } + if ((xp >= 0) && ((yp >= 0) && ((xp < bmWidth) && (yp < bmHeight)))) { + /* begin bitmapValue:bits:atX:y: */ + bmDepth = objBuffer[bmFill + 12]; + bmRaster = objBuffer[bmFill + 14]; + if (bmDepth == 32) { + value = (((int*) bits))[(bmRaster * yp) + xp]; + if ((value != 0) && ((value & 4278190080U) == 0)) { + value = value | 4278190080U; + } + fillValue = uncheckedTransformColor(value); + goto l3; + } + rShift = (rShiftTable())[bmDepth]; + value = (((int*) bits))[(bmRaster * yp) + (((unsigned) xp) >> rShift)]; + cMask = (1 << bmDepth) - 1; + rShift = (32 - bmDepth) - ((xp & ((1 << rShift) - 1)) * bmDepth); + value = (((unsigned) value) >> rShift) & cMask; + if (bmDepth == 16) { + if (!(value == 0)) { + b = (value & 31) << 3; + b += ((unsigned) b) >> 5; + g = ((((unsigned) value) >> 5) & 31) << 3; + g += ((unsigned) g) >> 5; + r = ((((unsigned) value) >> 10) & 31) << 3; + r += ((unsigned) r) >> 5; + a = 255; + value = ((b + (g << 8)) + (r << 16)) + (a << 24); + } + } else { + if ((objBuffer[bmFill + 15]) == 0) { + value = 0; + } else { + value = ((objBuffer + bmFill) + 18)[value]; + } + } + fillValue = uncheckedTransformColor(value); + l3: /* end bitmapValue:bits:atX:y: */; + spanBuffer[x] = fillValue; + } + ds += dsX; + dt += dtX; + x += 1; + } +} + +static int fillBitmapSpanAAfromtoat(int bmFill, int leftX, int rightX, int yValue) { + int *bits; + int ds; + int idx; + int firstPixel; + int dt; + int x; + int cShift; + int dtX; + int fillValue; + int cMask; + int yp; + int tileFlag; + int aaLevel; + int deltaX; + int lastPixel; + int dsX; + int deltaY; + int xp; + int bmWidth; + int bmHeight; + int baseShift; + int newDelta; + int newDelta1; + int newDelta2; + int newDelta3; + int newDelta4; + int newDelta5; + int firstPixel1; + int g; + int cMask1; + int bmDepth; + int rShift; + int r; + int bmRaster; + int value; + int b; + int a; + int g1; + int cMask2; + int bmDepth1; + int rShift1; + int r1; + int bmRaster1; + int value1; + int b1; + int a1; + int g2; + int cMask3; + int bmDepth2; + int rShift2; + int r2; + int bmRaster2; + int value2; + int b2; + int a2; + + bits = loadBitsFrom(bmFill); + if (bits == null) { + return null; + } + bmWidth = objBuffer[bmFill + 10]; + bmHeight = objBuffer[bmFill + 11]; + tileFlag = (objBuffer[bmFill + 16]) == 1; + deltaX = leftX - (objBuffer[bmFill + 4]); + deltaY = yValue - (objBuffer[bmFill + 5]); + dsX = objBuffer[bmFill + 6]; + dtX = objBuffer[bmFill + 8]; + ds = (deltaX * dsX) + (deltaY * (objBuffer[bmFill + 7])); + dt = (deltaX * dtX) + (deltaY * (objBuffer[bmFill + 9])); + aaLevel = workBuffer[48]; + /* begin aaFirstPixelFrom:to: */ + firstPixel1 = ((leftX + (workBuffer[48])) - 1) & (~((workBuffer[48]) - 1)); + if (firstPixel1 > rightX) { + firstPixel = rightX; + goto l7; + } else { + firstPixel = firstPixel1; + goto l7; + } +l7: /* end aaFirstPixelFrom:to: */; + lastPixel = (rightX - 1) & (~((workBuffer[48]) - 1)); + baseShift = workBuffer[49]; + cMask = workBuffer[51]; + cShift = workBuffer[50]; + x = leftX; + while (x < firstPixel) { + if (tileFlag) { + /* begin repeatValue:max: */ + newDelta = ds; + while (newDelta < 0) { + newDelta += bmWidth << 16; + } + while (newDelta >= (bmWidth << 16)) { + newDelta -= bmWidth << 16; + } + ds = newDelta; + /* begin repeatValue:max: */ + newDelta1 = dt; + while (newDelta1 < 0) { + newDelta1 += bmHeight << 16; + } + while (newDelta1 >= (bmHeight << 16)) { + newDelta1 -= bmHeight << 16; + } + dt = newDelta1; + } + xp = ((int) ds >> 16); + yp = ((int) dt >> 16); + if (!(tileFlag)) { + /* begin clampValue:max: */ + if (xp < 0) { + xp = 0; + goto l1; + } else { + if (xp >= bmWidth) { + xp = bmWidth - 1; + goto l1; + } else { + xp = xp; + goto l1; + } + } + l1: /* end clampValue:max: */; + /* begin clampValue:max: */ + if (yp < 0) { + yp = 0; + goto l2; + } else { + if (yp >= bmHeight) { + yp = bmHeight - 1; + goto l2; + } else { + yp = yp; + goto l2; + } + } + l2: /* end clampValue:max: */; + } + if ((xp >= 0) && ((yp >= 0) && ((xp < bmWidth) && (yp < bmHeight)))) { + /* begin bitmapValue:bits:atX:y: */ + bmDepth = objBuffer[bmFill + 12]; + bmRaster = objBuffer[bmFill + 14]; + if (bmDepth == 32) { + value = (((int*) bits))[(bmRaster * yp) + xp]; + if ((value != 0) && ((value & 4278190080U) == 0)) { + value = value | 4278190080U; + } + fillValue = uncheckedTransformColor(value); + goto l8; + } + rShift = (rShiftTable())[bmDepth]; + value = (((int*) bits))[(bmRaster * yp) + (((unsigned) xp) >> rShift)]; + cMask1 = (1 << bmDepth) - 1; + rShift = (32 - bmDepth) - ((xp & ((1 << rShift) - 1)) * bmDepth); + value = (((unsigned) value) >> rShift) & cMask1; + if (bmDepth == 16) { + if (!(value == 0)) { + b = (value & 31) << 3; + b += ((unsigned) b) >> 5; + g = ((((unsigned) value) >> 5) & 31) << 3; + g += ((unsigned) g) >> 5; + r = ((((unsigned) value) >> 10) & 31) << 3; + r += ((unsigned) r) >> 5; + a = 255; + value = ((b + (g << 8)) + (r << 16)) + (a << 24); + } + } else { + if ((objBuffer[bmFill + 15]) == 0) { + value = 0; + } else { + value = ((objBuffer + bmFill) + 18)[value]; + } + } + fillValue = uncheckedTransformColor(value); + l8: /* end bitmapValue:bits:atX:y: */; + fillValue = ((unsigned) (fillValue & cMask)) >> cShift; + idx = ((unsigned) x) >> baseShift; + spanBuffer[idx] = ((spanBuffer[idx]) + fillValue); + } + ds += dsX; + dt += dtX; + x += 1; + } + cMask = (((unsigned) (workBuffer[51])) >> (workBuffer[49])) | 4042322160U; + cShift = workBuffer[49]; + while (x < lastPixel) { + if (tileFlag) { + /* begin repeatValue:max: */ + newDelta2 = ds; + while (newDelta2 < 0) { + newDelta2 += bmWidth << 16; + } + while (newDelta2 >= (bmWidth << 16)) { + newDelta2 -= bmWidth << 16; + } + ds = newDelta2; + /* begin repeatValue:max: */ + newDelta3 = dt; + while (newDelta3 < 0) { + newDelta3 += bmHeight << 16; + } + while (newDelta3 >= (bmHeight << 16)) { + newDelta3 -= bmHeight << 16; + } + dt = newDelta3; + } + xp = ((int) ds >> 16); + yp = ((int) dt >> 16); + if (!(tileFlag)) { + /* begin clampValue:max: */ + if (xp < 0) { + xp = 0; + goto l3; + } else { + if (xp >= bmWidth) { + xp = bmWidth - 1; + goto l3; + } else { + xp = xp; + goto l3; + } + } + l3: /* end clampValue:max: */; + /* begin clampValue:max: */ + if (yp < 0) { + yp = 0; + goto l4; + } else { + if (yp >= bmHeight) { + yp = bmHeight - 1; + goto l4; + } else { + yp = yp; + goto l4; + } + } + l4: /* end clampValue:max: */; + } + if ((xp >= 0) && ((yp >= 0) && ((xp < bmWidth) && (yp < bmHeight)))) { + /* begin bitmapValue:bits:atX:y: */ + bmDepth1 = objBuffer[bmFill + 12]; + bmRaster1 = objBuffer[bmFill + 14]; + if (bmDepth1 == 32) { + value1 = (((int*) bits))[(bmRaster1 * yp) + xp]; + if ((value1 != 0) && ((value1 & 4278190080U) == 0)) { + value1 = value1 | 4278190080U; + } + fillValue = uncheckedTransformColor(value1); + goto l9; + } + rShift1 = (rShiftTable())[bmDepth1]; + value1 = (((int*) bits))[(bmRaster1 * yp) + (((unsigned) xp) >> rShift1)]; + cMask2 = (1 << bmDepth1) - 1; + rShift1 = (32 - bmDepth1) - ((xp & ((1 << rShift1) - 1)) * bmDepth1); + value1 = (((unsigned) value1) >> rShift1) & cMask2; + if (bmDepth1 == 16) { + if (!(value1 == 0)) { + b1 = (value1 & 31) << 3; + b1 += ((unsigned) b1) >> 5; + g1 = ((((unsigned) value1) >> 5) & 31) << 3; + g1 += ((unsigned) g1) >> 5; + r1 = ((((unsigned) value1) >> 10) & 31) << 3; + r1 += ((unsigned) r1) >> 5; + a1 = 255; + value1 = ((b1 + (g1 << 8)) + (r1 << 16)) + (a1 << 24); + } + } else { + if ((objBuffer[bmFill + 15]) == 0) { + value1 = 0; + } else { + value1 = ((objBuffer + bmFill) + 18)[value1]; + } + } + fillValue = uncheckedTransformColor(value1); + l9: /* end bitmapValue:bits:atX:y: */; + fillValue = ((unsigned) (fillValue & cMask)) >> cShift; + idx = ((unsigned) x) >> baseShift; + spanBuffer[idx] = ((spanBuffer[idx]) + fillValue); + } + ds += dsX << cShift; + dt += dtX << cShift; + x += aaLevel; + } + cMask = workBuffer[51]; + cShift = workBuffer[50]; + while (x < rightX) { + if (tileFlag) { + /* begin repeatValue:max: */ + newDelta4 = ds; + while (newDelta4 < 0) { + newDelta4 += bmWidth << 16; + } + while (newDelta4 >= (bmWidth << 16)) { + newDelta4 -= bmWidth << 16; + } + ds = newDelta4; + /* begin repeatValue:max: */ + newDelta5 = dt; + while (newDelta5 < 0) { + newDelta5 += bmHeight << 16; + } + while (newDelta5 >= (bmHeight << 16)) { + newDelta5 -= bmHeight << 16; + } + dt = newDelta5; + } + xp = ((int) ds >> 16); + yp = ((int) dt >> 16); + if (!(tileFlag)) { + /* begin clampValue:max: */ + if (xp < 0) { + xp = 0; + goto l5; + } else { + if (xp >= bmWidth) { + xp = bmWidth - 1; + goto l5; + } else { + xp = xp; + goto l5; + } + } + l5: /* end clampValue:max: */; + /* begin clampValue:max: */ + if (yp < 0) { + yp = 0; + goto l6; + } else { + if (yp >= bmHeight) { + yp = bmHeight - 1; + goto l6; + } else { + yp = yp; + goto l6; + } + } + l6: /* end clampValue:max: */; + } + if ((xp >= 0) && ((yp >= 0) && ((xp < bmWidth) && (yp < bmHeight)))) { + /* begin bitmapValue:bits:atX:y: */ + bmDepth2 = objBuffer[bmFill + 12]; + bmRaster2 = objBuffer[bmFill + 14]; + if (bmDepth2 == 32) { + value2 = (((int*) bits))[(bmRaster2 * yp) + xp]; + if ((value2 != 0) && ((value2 & 4278190080U) == 0)) { + value2 = value2 | 4278190080U; + } + fillValue = uncheckedTransformColor(value2); + goto l10; + } + rShift2 = (rShiftTable())[bmDepth2]; + value2 = (((int*) bits))[(bmRaster2 * yp) + (((unsigned) xp) >> rShift2)]; + cMask3 = (1 << bmDepth2) - 1; + rShift2 = (32 - bmDepth2) - ((xp & ((1 << rShift2) - 1)) * bmDepth2); + value2 = (((unsigned) value2) >> rShift2) & cMask3; + if (bmDepth2 == 16) { + if (!(value2 == 0)) { + b2 = (value2 & 31) << 3; + b2 += ((unsigned) b2) >> 5; + g2 = ((((unsigned) value2) >> 5) & 31) << 3; + g2 += ((unsigned) g2) >> 5; + r2 = ((((unsigned) value2) >> 10) & 31) << 3; + r2 += ((unsigned) r2) >> 5; + a2 = 255; + value2 = ((b2 + (g2 << 8)) + (r2 << 16)) + (a2 << 24); + } + } else { + if ((objBuffer[bmFill + 15]) == 0) { + value2 = 0; + } else { + value2 = ((objBuffer + bmFill) + 18)[value2]; + } + } + fillValue = uncheckedTransformColor(value2); + l10: /* end bitmapValue:bits:atX:y: */; + fillValue = ((unsigned) (fillValue & cMask)) >> cShift; + idx = ((unsigned) x) >> baseShift; + spanBuffer[idx] = ((spanBuffer[idx]) + fillValue); + } + ds += dsX; + dt += dtX; + x += 1; + } +} + + +/* Fill the span buffer between leftEdge and rightEdge with the given pixel value. */ + +static int fillColorSpanfromto(int pixelValue32, int leftX, int rightX) { + int x0; + int x1; + + if (!((workBuffer[48]) == 1)) { + return fillColorSpanAAx0x1(pixelValue32, leftX, rightX); + } + x0 = leftX; + + /* Unroll the inner loop four times, since we're only storing data. */ + + x1 = rightX; + while ((x0 + 4) < x1) { + spanBuffer[x0] = pixelValue32; + spanBuffer[x0 + 1] = pixelValue32; + spanBuffer[x0 + 2] = pixelValue32; + spanBuffer[x0 + 3] = pixelValue32; + x0 += 4; + } + while (x0 < x1) { + spanBuffer[x0] = pixelValue32; + x0 += 1; + } +} + + +/* This is the inner loop for solid color fills with anti-aliasing. + This loop has been unrolled for speed and quality into three parts: + a) copy all pixels that fall into the first full pixel. + b) copy aaLevel pixels between the first and the last full pixel + c) copy all pixels that fall in the last full pixel */ + +static int fillColorSpanAAx0x1(int pixelValue32, int leftX, int rightX) { + int firstPixel; + int idx; + int colorMask; + int x; + int pv32; + int aaLevel; + int lastPixel; + int baseShift; + int firstPixel1; + + /* begin aaFirstPixelFrom:to: */ + firstPixel1 = ((leftX + (workBuffer[48])) - 1) & (~((workBuffer[48]) - 1)); + if (firstPixel1 > rightX) { + firstPixel = rightX; + goto l1; + } else { + firstPixel = firstPixel1; + goto l1; + } +l1: /* end aaFirstPixelFrom:to: */; + lastPixel = (rightX - 1) & (~((workBuffer[48]) - 1)); + aaLevel = workBuffer[48]; + baseShift = workBuffer[49]; + + /* Part a: Deal with the first n sub-pixels */ + + x = leftX; + if (x < firstPixel) { + pv32 = ((unsigned) (pixelValue32 & (workBuffer[51]))) >> (workBuffer[50]); + while (x < firstPixel) { + idx = ((unsigned) x) >> baseShift; + spanBuffer[idx] = ((spanBuffer[idx]) + pv32); + x += 1; + } + } + if (x < lastPixel) { + colorMask = (((unsigned) (workBuffer[51])) >> (workBuffer[49])) | 4042322160U; + pv32 = ((unsigned) (pixelValue32 & colorMask)) >> (workBuffer[49]); + while (x < lastPixel) { + idx = ((unsigned) x) >> baseShift; + spanBuffer[idx] = ((spanBuffer[idx]) + pv32); + x += aaLevel; + } + } + if (x < rightX) { + pv32 = ((unsigned) (pixelValue32 & (workBuffer[51]))) >> (workBuffer[50]); + while (x < rightX) { + idx = ((unsigned) x) >> baseShift; + spanBuffer[idx] = ((spanBuffer[idx]) + pv32); + x += 1; + } + } +} + +static int fillDirectionXOf(int fill) { + return objBuffer[fill + 6]; +} + +static int fillDirectionXOfput(int fill, int value) { + return objBuffer[fill + 6] = value; +} + +static int fillDirectionYOf(int fill) { + return objBuffer[fill + 7]; +} + +static int fillDirectionYOfput(int fill, int value) { + return objBuffer[fill + 7] = value; +} + +static int fillLinearGradient(void) { + return fillLinearGradientfromtoat(workBuffer[66], workBuffer[67], workBuffer[68], workBuffer[88]); +} + + +/* Draw a linear gradient fill. */ + +static int fillLinearGradientfromtoat(int fill, int leftX, int rightX, int yValue) { + int ds; + int x; + int x0; + int x1; + int *ramp; + int rampSize; + int dsX; + int rampIndex; + int x01; + int x11; + int x02; + int x12; + + ramp = (objBuffer + fill) + 12; + rampSize = objBuffer[fill + 10]; + dsX = objBuffer[fill + 6]; + ds = ((leftX - (objBuffer[fill + 4])) * dsX) + ((yValue - (objBuffer[fill + 5])) * (objBuffer[fill + 7])); + x = x0 = leftX; + + /* Note: The inner loop has been divided into three parts for speed */ + /* Part one: Fill everything outside the left boundary */ + + x1 = rightX; + while ((((rampIndex = ((int) ds >> 16)) < 0) || (rampIndex >= rampSize)) && (x < x1)) { + x += 1; + ds += dsX; + } + if (x > x0) { + if (rampIndex < 0) { + rampIndex = 0; + } + if (rampIndex >= rampSize) { + rampIndex = rampSize - 1; + } + /* begin fillColorSpan:from:to: */ + if (!((workBuffer[48]) == 1)) { + fillColorSpanAAx0x1(ramp[rampIndex], x0, x); + goto l1; + } + x01 = x0; + x11 = x; + while ((x01 + 4) < x11) { + spanBuffer[x01] = (ramp[rampIndex]); + spanBuffer[x01 + 1] = (ramp[rampIndex]); + spanBuffer[x01 + 2] = (ramp[rampIndex]); + spanBuffer[x01 + 3] = (ramp[rampIndex]); + x01 += 4; + } + while (x01 < x11) { + spanBuffer[x01] = (ramp[rampIndex]); + x01 += 1; + } + l1: /* end fillColorSpan:from:to: */; + } + if ((workBuffer[48]) == 1) { + while ((((rampIndex = ((int) ds >> 16)) < rampSize) && (rampIndex >= 0)) && (x < x1)) { + spanBuffer[x] = (ramp[rampIndex]); + x += 1; + ds += dsX; + } + } else { + x = fillLinearGradientAArampdsdsXfromto(fill, ramp, ds, dsX, x, rightX); + } + if (x < x1) { + if (rampIndex < 0) { + rampIndex = 0; + } + if (rampIndex >= rampSize) { + rampIndex = rampSize - 1; + } + /* begin fillColorSpan:from:to: */ + if (!((workBuffer[48]) == 1)) { + fillColorSpanAAx0x1(ramp[rampIndex], x, x1); + goto l2; + } + x02 = x; + x12 = x1; + while ((x02 + 4) < x12) { + spanBuffer[x02] = (ramp[rampIndex]); + spanBuffer[x02 + 1] = (ramp[rampIndex]); + spanBuffer[x02 + 2] = (ramp[rampIndex]); + spanBuffer[x02 + 3] = (ramp[rampIndex]); + x02 += 4; + } + while (x02 < x12) { + spanBuffer[x02] = (ramp[rampIndex]); + x02 += 1; + } + l2: /* end fillColorSpan:from:to: */; + } +} + + +/* This is the AA version of linear gradient filling. */ + +static int fillLinearGradientAArampdsdsXfromto(int fill, int *ramp, int deltaS, int dsX, int leftX, int rightX) { + int firstPixel; + int ds; + int idx; + int colorMask; + int x; + int rampValue; + int aaLevel; + int rampSize; + int lastPixel; + int colorShift; + int baseShift; + int rampIndex; + int firstPixel1; + + aaLevel = workBuffer[48]; + baseShift = workBuffer[49]; + rampSize = objBuffer[fill + 10]; + ds = deltaS; + x = leftX; + rampIndex = ((int) ds >> 16); + /* begin aaFirstPixelFrom:to: */ + firstPixel1 = ((leftX + (workBuffer[48])) - 1) & (~((workBuffer[48]) - 1)); + if (firstPixel1 > rightX) { + firstPixel = rightX; + goto l1; + } else { + firstPixel = firstPixel1; + goto l1; + } +l1: /* end aaFirstPixelFrom:to: */; + + /* Deal with the first n sub-pixels */ + + lastPixel = (rightX - 1) & (~((workBuffer[48]) - 1)); + colorMask = workBuffer[51]; + colorShift = workBuffer[50]; + while ((x < firstPixel) && ((rampIndex < rampSize) && (rampIndex >= 0))) { + rampValue = (((int *) ramp))[rampIndex]; + + /* Copy as many pixels as possible */ + + rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; + while ((x < firstPixel) && ((((int) ds >> 16)) == rampIndex)) { + idx = ((unsigned) x) >> baseShift; + spanBuffer[idx] = ((spanBuffer[idx]) + rampValue); + x += 1; + ds += dsX; + } + rampIndex = ((int) ds >> 16); + } + colorMask = (((unsigned) (workBuffer[51])) >> (workBuffer[49])) | 4042322160U; + colorShift = workBuffer[49]; + while ((x < lastPixel) && ((rampIndex < rampSize) && (rampIndex >= 0))) { + rampValue = (((int *) ramp))[rampIndex]; + + /* Copy as many pixels as possible */ + + rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; + while ((x < lastPixel) && ((((int) ds >> 16)) == rampIndex)) { + idx = ((unsigned) x) >> baseShift; + spanBuffer[idx] = ((spanBuffer[idx]) + rampValue); + x += aaLevel; + ds += dsX << colorShift; + } + rampIndex = ((int) ds >> 16); + } + colorMask = workBuffer[51]; + colorShift = workBuffer[50]; + while ((x < rightX) && ((rampIndex < rampSize) && (rampIndex >= 0))) { + rampValue = (((int *) ramp))[rampIndex]; + + /* Copy as many pixels as possible */ + + rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; + while ((x < rightX) && ((((int) ds >> 16)) == rampIndex)) { + idx = ((unsigned) x) >> baseShift; + spanBuffer[idx] = ((spanBuffer[idx]) + rampValue); + x += 1; + ds += dsX; + } + rampIndex = ((int) ds >> 16); + } + return x; +} + +static int fillMaxXGet(void) { + return workBuffer[37]; +} + +static int fillMaxXPut(int value) { + return workBuffer[37] = value; +} + +static int fillMaxYGet(void) { + return workBuffer[39]; +} + +static int fillMaxYPut(int value) { + return workBuffer[39] = value; +} + +static int fillMinXGet(void) { + return workBuffer[36]; +} + +static int fillMinXPut(int value) { + return workBuffer[36] = value; +} + +static int fillMinYGet(void) { + return workBuffer[38]; +} + +static int fillMinYPut(int value) { + return workBuffer[38] = value; +} + +static int fillNormalXOf(int fill) { + return objBuffer[fill + 8]; +} + +static int fillNormalXOfput(int fill, int value) { + return objBuffer[fill + 8] = value; +} + +static int fillNormalYOf(int fill) { + return objBuffer[fill + 9]; +} + +static int fillNormalYOfput(int fill, int value) { + return objBuffer[fill + 9] = value; +} + +static int fillOffsetXGet(void) { + return workBuffer[40]; +} + +static int fillOffsetXPut(int value) { + return workBuffer[40] = value; +} + +static int fillOffsetYGet(void) { + return workBuffer[41]; +} + +static int fillOffsetYPut(int value) { + return workBuffer[41] = value; +} + +static int fillOriginXOf(int fill) { + return objBuffer[fill + 4]; +} + +static int fillOriginXOfput(int fill, int value) { + return objBuffer[fill + 4] = value; +} + +static int fillOriginYOf(int fill) { + return objBuffer[fill + 5]; +} + +static int fillOriginYOfput(int fill, int value) { + return objBuffer[fill + 5] = value; +} + + +/* Part 2a) Compute the decreasing part of the ramp */ + +static int fillRadialDecreasingrampdeltaSTdsXdtXfromto(int fill, int ramp, int deltaST, int dsX, int dtX, int leftX, int rightX) { + int ds; + int dt; + int x; + int x1; + int rampValue; + int length2; + int nextLength; + int rampIndex; + + ds = (((int*) deltaST))[0]; + dt = (((int*) deltaST))[1]; + rampIndex = accurateLengthOfwith(((int) ds >> 16), ((int) dt >> 16)); + rampValue = (((int *) ramp))[rampIndex]; + length2 = (rampIndex - 1) * (rampIndex - 1); + x = leftX; + x1 = rightX; + if (x1 > (objBuffer[fill + 4])) { + x1 = objBuffer[fill + 4]; + } + while (x < x1) { + while ((x < x1) && ((((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16)))) >= length2)) { + spanBuffer[x] = rampValue; + x += 1; + ds += dsX; + dt += dtX; + } + nextLength = ((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16))); + while (nextLength < length2) { + rampIndex -= 1; + rampValue = (((int *) ramp))[rampIndex]; + length2 = (rampIndex - 1) * (rampIndex - 1); + } + } + (((int *) deltaST))[0] = ds; + (((int *) deltaST))[1] = dt; + return x; +} + + +/* Part 2a) Compute the decreasing part of the ramp */ + +static int fillRadialDecreasingAArampdeltaSTdsXdtXfromto(int fill, int *ramp, int *deltaST, int dsX, int dtX, int leftX, int rightX) { + int firstPixel; + int ds; + int dt; + int x; + int colorMask; + int x1; + int rampValue; + int index; + int aaLevel; + int lastPixel; + int length2; + int nextLength; + int colorShift; + int rampIndex; + int baseShift; + int firstPixel1; + + ds = (((int*) deltaST))[0]; + dt = (((int*) deltaST))[1]; + aaLevel = workBuffer[48]; + baseShift = workBuffer[49]; + rampIndex = accurateLengthOfwith(((int) ds >> 16), ((int) dt >> 16)); + length2 = (rampIndex - 1) * (rampIndex - 1); + x = leftX; + x1 = objBuffer[fill + 4]; + if (x1 > rightX) { + x1 = rightX; + } + /* begin aaFirstPixelFrom:to: */ + firstPixel1 = ((leftX + (workBuffer[48])) - 1) & (~((workBuffer[48]) - 1)); + if (firstPixel1 > x1) { + firstPixel = x1; + goto l1; + } else { + firstPixel = firstPixel1; + goto l1; + } +l1: /* end aaFirstPixelFrom:to: */; + + /* Deal with the first n sub-pixels */ + + lastPixel = (x1 - 1) & (~((workBuffer[48]) - 1)); + if (x < firstPixel) { + colorMask = workBuffer[51]; + colorShift = workBuffer[50]; + rampValue = (((int *) ramp))[rampIndex]; + rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; + while (x < firstPixel) { + while ((x < firstPixel) && ((((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16)))) >= length2)) { + index = ((unsigned) x) >> baseShift; + spanBuffer[index] = ((spanBuffer[index]) + rampValue); + x += 1; + ds += dsX; + dt += dtX; + } + nextLength = ((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16))); + while (nextLength < length2) { + rampIndex -= 1; + rampValue = (((int *) ramp))[rampIndex]; + rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; + length2 = (rampIndex - 1) * (rampIndex - 1); + } + } + } + if (x < lastPixel) { + colorMask = (((unsigned) (workBuffer[51])) >> (workBuffer[49])) | 4042322160U; + colorShift = workBuffer[49]; + rampValue = (((int *) ramp))[rampIndex]; + rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; + while (x < lastPixel) { + while ((x < lastPixel) && ((((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16)))) >= length2)) { + index = ((unsigned) x) >> baseShift; + spanBuffer[index] = ((spanBuffer[index]) + rampValue); + x += aaLevel; + ds += dsX << colorShift; + dt += dtX << colorShift; + } + nextLength = ((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16))); + while (nextLength < length2) { + rampIndex -= 1; + rampValue = (((int *) ramp))[rampIndex]; + rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; + length2 = (rampIndex - 1) * (rampIndex - 1); + } + } + } + if (x < x1) { + colorMask = workBuffer[51]; + colorShift = workBuffer[50]; + rampValue = (((int *) ramp))[rampIndex]; + rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; + while (x < x1) { + while ((x < x1) && ((((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16)))) >= length2)) { + index = ((unsigned) x) >> baseShift; + spanBuffer[index] = ((spanBuffer[index]) + rampValue); + x += 1; + ds += dsX; + dt += dtX; + } + nextLength = ((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16))); + while (nextLength < length2) { + rampIndex -= 1; + rampValue = (((int *) ramp))[rampIndex]; + rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; + length2 = (rampIndex - 1) * (rampIndex - 1); + } + } + } + (((int *) deltaST))[0] = ds; + (((int *) deltaST))[1] = dt; + return x; +} + +static int fillRadialGradient(void) { + return fillRadialGradientfromtoat(workBuffer[66], workBuffer[67], workBuffer[68], workBuffer[88]); +} + + +/* Draw a radial gradient fill. */ + +static int fillRadialGradientfromtoat(int fill, int leftX, int rightX, int yValue) { + int ds; + int dt; + int x; + int x1; + int dtX; + int *ramp; + int rampSize; + int length2; + int deltaX; + int dsX; + int deltaY; + int *deltaST; + int x0; + int x11; + int ds1; + int dt1; + int x2; + int x12; + int rampValue; + int length21; + int nextLength; + int rampIndex; + int ds2; + int dt2; + int x3; + int x13; + int rampValue1; + int lastLength; + int rampSize1; + int length22; + int nextLength1; + int rampIndex1; + int x01; + int x14; + + ramp = (objBuffer + fill) + 12; + rampSize = objBuffer[fill + 10]; + deltaX = leftX - (objBuffer[fill + 4]); + deltaY = yValue - (objBuffer[fill + 5]); + dsX = objBuffer[fill + 6]; + dtX = objBuffer[fill + 8]; + ds = (deltaX * dsX) + (deltaY * (objBuffer[fill + 7])); + dt = (deltaX * dtX) + (deltaY * (objBuffer[fill + 9])); + x = leftX; + + /* Note: The inner loop has been divided into three parts for speed */ + /* Part one: Fill everything outside the left boundary */ + + x1 = rightX; + + /* This is the upper bound */ + + length2 = (rampSize - 1) * (rampSize - 1); + while (((((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16)))) >= length2) && (x < x1)) { + x += 1; + ds += dsX; + dt += dtX; + } + if (x > leftX) { + /* begin fillColorSpan:from:to: */ + if (!((workBuffer[48]) == 1)) { + fillColorSpanAAx0x1(ramp[rampSize - 1], leftX, x); + goto l1; + } + x0 = leftX; + x11 = x; + while ((x0 + 4) < x11) { + spanBuffer[x0] = (ramp[rampSize - 1]); + spanBuffer[x0 + 1] = (ramp[rampSize - 1]); + spanBuffer[x0 + 2] = (ramp[rampSize - 1]); + spanBuffer[x0 + 3] = (ramp[rampSize - 1]); + x0 += 4; + } + while (x0 < x11) { + spanBuffer[x0] = (ramp[rampSize - 1]); + x0 += 1; + } + l1: /* end fillColorSpan:from:to: */; + } + deltaST = ((int *) (workBuffer + 80)); + deltaST[0] = ds; + deltaST[1] = dt; + if (x < (objBuffer[fill + 4])) { + if ((workBuffer[48]) == 1) { + /* begin fillRadialDecreasing:ramp:deltaST:dsX:dtX:from:to: */ + ds1 = (((int*) deltaST))[0]; + dt1 = (((int*) deltaST))[1]; + rampIndex = accurateLengthOfwith(((int) ds1 >> 16), ((int) dt1 >> 16)); + rampValue = (((int *) ramp))[rampIndex]; + length21 = (rampIndex - 1) * (rampIndex - 1); + x2 = x; + x12 = x1; + if (x12 > (objBuffer[fill + 4])) { + x12 = objBuffer[fill + 4]; + } + while (x2 < x12) { + while ((x2 < x12) && ((((((int) ds1 >> 16)) * (((int) ds1 >> 16))) + ((((int) dt1 >> 16)) * (((int) dt1 >> 16)))) >= length21)) { + spanBuffer[x2] = rampValue; + x2 += 1; + ds1 += dsX; + dt1 += dtX; + } + nextLength = ((((int) ds1 >> 16)) * (((int) ds1 >> 16))) + ((((int) dt1 >> 16)) * (((int) dt1 >> 16))); + while (nextLength < length21) { + rampIndex -= 1; + rampValue = (((int *) ramp))[rampIndex]; + length21 = (rampIndex - 1) * (rampIndex - 1); + } + } + (((int *) deltaST))[0] = ds1; + (((int *) deltaST))[1] = dt1; + x = x2; + } else { + x = fillRadialDecreasingAArampdeltaSTdsXdtXfromto(fill, ramp, deltaST, dsX, dtX, x, x1); + } + } + if (x < x1) { + if ((workBuffer[48]) == 1) { + /* begin fillRadialIncreasing:ramp:deltaST:dsX:dtX:from:to: */ + ds2 = (((int*) deltaST))[0]; + dt2 = (((int*) deltaST))[1]; + rampIndex1 = accurateLengthOfwith(((int) ds2 >> 16), ((int) dt2 >> 16)); + rampValue1 = (((int *) ramp))[rampIndex1]; + rampSize1 = objBuffer[fill + 10]; + length22 = (rampSize1 - 1) * (rampSize1 - 1); + nextLength1 = (rampIndex1 + 1) * (rampIndex1 + 1); + lastLength = ((((int) ds2 >> 16)) * (((int) ds2 >> 16))) + ((((int) dt2 >> 16)) * (((int) dt2 >> 16))); + x3 = x; + x13 = x1; + while ((x3 < x13) && (lastLength < length22)) { + while ((x3 < x13) && ((((((int) ds2 >> 16)) * (((int) ds2 >> 16))) + ((((int) dt2 >> 16)) * (((int) dt2 >> 16)))) <= nextLength1)) { + spanBuffer[x3] = rampValue1; + x3 += 1; + ds2 += dsX; + dt2 += dtX; + } + lastLength = ((((int) ds2 >> 16)) * (((int) ds2 >> 16))) + ((((int) dt2 >> 16)) * (((int) dt2 >> 16))); + while (lastLength > nextLength1) { + rampIndex1 += 1; + rampValue1 = (((int *) ramp))[rampIndex1]; + nextLength1 = (rampIndex1 + 1) * (rampIndex1 + 1); + } + } + (((int *) deltaST))[0] = ds2; + (((int *) deltaST))[1] = dt2; + x = x3; + } else { + x = fillRadialIncreasingAArampdeltaSTdsXdtXfromto(fill, ramp, deltaST, dsX, dtX, x, x1); + } + } + if (x < rightX) { + /* begin fillColorSpan:from:to: */ + if (!((workBuffer[48]) == 1)) { + fillColorSpanAAx0x1(ramp[rampSize - 1], x, rightX); + goto l2; + } + x01 = x; + x14 = rightX; + while ((x01 + 4) < x14) { + spanBuffer[x01] = (ramp[rampSize - 1]); + spanBuffer[x01 + 1] = (ramp[rampSize - 1]); + spanBuffer[x01 + 2] = (ramp[rampSize - 1]); + spanBuffer[x01 + 3] = (ramp[rampSize - 1]); + x01 += 4; + } + while (x01 < x14) { + spanBuffer[x01] = (ramp[rampSize - 1]); + x01 += 1; + } + l2: /* end fillColorSpan:from:to: */; + } +} + + +/* Part 2b) Compute the increasing part of the ramp */ + +static int fillRadialIncreasingrampdeltaSTdsXdtXfromto(int fill, int ramp, int deltaST, int dsX, int dtX, int leftX, int rightX) { + int ds; + int dt; + int x; + int x1; + int rampValue; + int lastLength; + int rampSize; + int length2; + int nextLength; + int rampIndex; + + ds = (((int*) deltaST))[0]; + dt = (((int*) deltaST))[1]; + rampIndex = accurateLengthOfwith(((int) ds >> 16), ((int) dt >> 16)); + rampValue = (((int *) ramp))[rampIndex]; + rampSize = objBuffer[fill + 10]; + + /* This is the upper bound */ + + length2 = (rampSize - 1) * (rampSize - 1); + nextLength = (rampIndex + 1) * (rampIndex + 1); + lastLength = ((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16))); + x = leftX; + x1 = rightX; + while ((x < x1) && (lastLength < length2)) { + while ((x < x1) && ((((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16)))) <= nextLength)) { + spanBuffer[x] = rampValue; + x += 1; + ds += dsX; + dt += dtX; + } + lastLength = ((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16))); + while (lastLength > nextLength) { + rampIndex += 1; + rampValue = (((int *) ramp))[rampIndex]; + nextLength = (rampIndex + 1) * (rampIndex + 1); + } + } + (((int *) deltaST))[0] = ds; + (((int *) deltaST))[1] = dt; + return x; +} + + +/* Part 2b) Compute the increasing part of the ramp */ + +static int fillRadialIncreasingAArampdeltaSTdsXdtXfromto(int fill, int *ramp, int *deltaST, int dsX, int dtX, int leftX, int rightX) { + int firstPixel; + int ds; + int dt; + int x; + int colorMask; + int rampValue; + int index; + int lastLength; + int aaLevel; + int rampSize; + int length2; + int lastPixel; + int nextLength; + int colorShift; + int rampIndex; + int baseShift; + int firstPixel1; + + ds = (((int*) deltaST))[0]; + dt = (((int*) deltaST))[1]; + aaLevel = workBuffer[48]; + baseShift = workBuffer[49]; + rampIndex = accurateLengthOfwith(((int) ds >> 16), ((int) dt >> 16)); + rampSize = objBuffer[fill + 10]; + + /* This is the upper bound */ + + length2 = (rampSize - 1) * (rampSize - 1); + nextLength = (rampIndex + 1) * (rampIndex + 1); + lastLength = ((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16))); + x = leftX; + /* begin aaFirstPixelFrom:to: */ + firstPixel1 = ((leftX + (workBuffer[48])) - 1) & (~((workBuffer[48]) - 1)); + if (firstPixel1 > rightX) { + firstPixel = rightX; + goto l1; + } else { + firstPixel = firstPixel1; + goto l1; + } +l1: /* end aaFirstPixelFrom:to: */; + + /* Deal with the first n subPixels */ + + lastPixel = (rightX - 1) & (~((workBuffer[48]) - 1)); + if ((x < firstPixel) && (lastLength < length2)) { + colorMask = workBuffer[51]; + colorShift = workBuffer[50]; + rampValue = (((int *) ramp))[rampIndex]; + rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; + while ((x < firstPixel) && (lastLength < length2)) { + while ((x < firstPixel) && ((((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16)))) <= nextLength)) { + index = ((unsigned) x) >> baseShift; + spanBuffer[index] = ((spanBuffer[index]) + rampValue); + x += 1; + ds += dsX; + dt += dtX; + } + lastLength = ((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16))); + while (lastLength > nextLength) { + rampIndex += 1; + rampValue = (((int *) ramp))[rampIndex]; + rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; + nextLength = (rampIndex + 1) * (rampIndex + 1); + } + } + } + if ((x < lastPixel) && (lastLength < length2)) { + colorMask = (((unsigned) (workBuffer[51])) >> (workBuffer[49])) | 4042322160U; + colorShift = workBuffer[49]; + rampValue = (((int *) ramp))[rampIndex]; + rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; + while ((x < lastPixel) && (lastLength < length2)) { + while ((x < lastPixel) && ((((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16)))) <= nextLength)) { + index = ((unsigned) x) >> baseShift; + spanBuffer[index] = ((spanBuffer[index]) + rampValue); + x += aaLevel; + ds += dsX << colorShift; + dt += dtX << colorShift; + } + lastLength = ((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16))); + while (lastLength > nextLength) { + rampIndex += 1; + rampValue = (((int *) ramp))[rampIndex]; + rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; + nextLength = (rampIndex + 1) * (rampIndex + 1); + } + } + } + if ((x < rightX) && (lastLength < length2)) { + colorMask = workBuffer[51]; + colorShift = workBuffer[50]; + rampValue = (((int *) ramp))[rampIndex]; + rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; + while ((x < rightX) && (lastLength < length2)) { + while ((x < rightX) && ((((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16)))) <= nextLength)) { + index = ((unsigned) x) >> baseShift; + spanBuffer[index] = ((spanBuffer[index]) + rampValue); + x += 1; + ds += dsX; + dt += dtX; + } + lastLength = ((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16))); + while (lastLength > nextLength) { + rampIndex += 1; + rampValue = (((int *) ramp))[rampIndex]; + rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; + nextLength = (rampIndex + 1) * (rampIndex + 1); + } + } + } + (((int *) deltaST))[0] = ds; + (((int *) deltaST))[1] = dt; + return x; +} + + +/* Return true if fillEntry1 should be drawn before fillEntry2 */ + +static int fillSortsbefore(int fillEntry1, int fillEntry2) { + int diff; + + diff = (workBuffer[(workBuffer[10]) + (fillEntry1 + 1)]) - (workBuffer[(workBuffer[10]) + (fillEntry2 + 1)]); + if (!(diff == 0)) { + return diff > 0; + } + return (((unsigned) (workBuffer[(workBuffer[10]) + fillEntry1]))) < (((unsigned) (workBuffer[(workBuffer[10]) + fillEntry2]))); +} + + +/* Fill the span buffer from leftX to rightX with the given fill. + Clip before performing any operations. Return true if the fill must + be handled by some Smalltalk code. */ + +static int fillSpanfromto(int fill, int leftX, int rightX) { + int x0; + int x1; + int type; + int x01; + int x11; + + if (fill == 0) { + return 0; + } + if (leftX < (workBuffer[35])) { + x0 = workBuffer[35]; + } else { + x0 = leftX; + } + if (rightX > ((workBuffer[33]) << (workBuffer[49]))) { + x1 = (workBuffer[33]) << (workBuffer[49]); + } else { + x1 = rightX; + } + if (x0 < (workBuffer[36])) { + x0 = workBuffer[36]; + } + if (x1 > (workBuffer[37])) { + x1 = workBuffer[37]; + } + if (x0 < (workBuffer[32])) { + workBuffer[32] = x0; + } + if (x1 > (workBuffer[34])) { + workBuffer[34] = x1; + } + if (x1 > (workBuffer[35])) { + workBuffer[35] = x1; + } + if (x0 >= x1) { + return 0; + } + if ((fill & 4278190080U) != 0) { + /* begin fillColorSpan:from:to: */ + if (!((workBuffer[48]) == 1)) { + fillColorSpanAAx0x1(fill, x0, x1); + goto l1; + } + x01 = x0; + x11 = x1; + while ((x01 + 4) < x11) { + spanBuffer[x01] = fill; + spanBuffer[x01 + 1] = fill; + spanBuffer[x01 + 2] = fill; + spanBuffer[x01 + 3] = fill; + x01 += 4; + } + while (x01 < x11) { + spanBuffer[x01] = fill; + x01 += 1; + } + l1: /* end fillColorSpan:from:to: */; + } else { + workBuffer[66] = fill; + workBuffer[67] = x0; + workBuffer[68] = x1; + type = ((unsigned) (((objBuffer[fill + 0]) & 65535) & 65280)) >> 8; + if (type <= 1) { + return 1; + } + switch (type) { + case 0: + case 1: + errorWrongIndex(); + break; + case 2: + fillLinearGradientfromtoat(workBuffer[66], workBuffer[67], workBuffer[68], workBuffer[88]); + break; + case 3: + fillRadialGradientfromtoat(workBuffer[66], workBuffer[67], workBuffer[68], workBuffer[88]); + break; + case 4: + case 5: + fillBitmapSpanfromtoat(workBuffer[66], workBuffer[67], workBuffer[68], workBuffer[88]); + break; + } + } + return 0; +} + + +/* Fill the span buffer from leftX to rightX with the given fill. + Clip before performing any operations. Return true if the fill must + be handled by some Smalltalk code. */ + +static int fillSpanfromtomax(int fill, int leftX, int rightX, int maxRightX) { + int x0; + int x1; + int type; + int x01; + int x11; + + if (fill == 0) { + return 0; + } + if (leftX < (workBuffer[35])) { + x0 = workBuffer[35]; + } else { + x0 = leftX; + } + if (rightX > ((workBuffer[33]) << (workBuffer[49]))) { + x1 = (workBuffer[33]) << (workBuffer[49]); + } else { + x1 = rightX; + } + if (maxRightX < x1) { + x1 = maxRightX; + } + if (x0 < (workBuffer[36])) { + x0 = workBuffer[36]; + } + if (x1 > (workBuffer[37])) { + x1 = workBuffer[37]; + } + if (x0 < (workBuffer[32])) { + workBuffer[32] = x0; + } + if (x1 > (workBuffer[34])) { + workBuffer[34] = x1; + } + if (x1 > (workBuffer[35])) { + workBuffer[35] = x1; + } + if (x0 >= x1) { + return 0; + } + if ((fill & 4278190080U) != 0) { + /* begin fillColorSpan:from:to: */ + if (!((workBuffer[48]) == 1)) { + fillColorSpanAAx0x1(fill, x0, x1); + goto l1; + } + x01 = x0; + x11 = x1; + while ((x01 + 4) < x11) { + spanBuffer[x01] = fill; + spanBuffer[x01 + 1] = fill; + spanBuffer[x01 + 2] = fill; + spanBuffer[x01 + 3] = fill; + x01 += 4; + } + while (x01 < x11) { + spanBuffer[x01] = fill; + x01 += 1; + } + l1: /* end fillColorSpan:from:to: */; + } else { + workBuffer[66] = fill; + workBuffer[67] = x0; + workBuffer[68] = x1; + type = ((unsigned) (((objBuffer[fill + 0]) & 65535) & 65280)) >> 8; + if (type <= 1) { + return 1; + } + switch (type) { + case 0: + case 1: + errorWrongIndex(); + break; + case 2: + fillLinearGradientfromtoat(workBuffer[66], workBuffer[67], workBuffer[68], workBuffer[88]); + break; + case 3: + fillRadialGradientfromtoat(workBuffer[66], workBuffer[67], workBuffer[68], workBuffer[88]); + break; + case 4: + case 5: + fillBitmapSpanfromtoat(workBuffer[66], workBuffer[67], workBuffer[68], workBuffer[88]); + break; + } + } + return 0; +} + +static int fillTypeOf(int fill) { + return ((unsigned) (((objBuffer[fill + 0]) & 65535) & 65280)) >> 8; +} + +static int findNextAETEdgeFrom(int leftEdge) { + int depth; + int rightEdge; + + depth = objBuffer[leftEdge + 6]; + while ((workBuffer[13]) < (workBuffer[14])) { + rightEdge = aetBuffer[workBuffer[13]]; + if ((objBuffer[rightEdge + 6]) >= depth) { + return rightEdge; + } + workBuffer[13] = ((workBuffer[13]) + 1); + } + return null; +} + + +/* Check the global edge table for any entries that cannot be handled by the engine itself. + If there are any, return true. Otherwise, initialize the the edge and add it to the AET */ + +static int findNextExternalEntryFromGET(void) { + int edge; + int type; + int yValue; + + + /* As long as we have entries in the GET */ + + yValue = workBuffer[88]; + while ((workBuffer[11]) < (workBuffer[12])) { + edge = getBuffer[workBuffer[11]]; + if ((objBuffer[edge + 5]) > yValue) { + return 0; + } + type = (objBuffer[edge + 0]) & 65535; + if ((type & 254) == 2) { + return 1; + } + if (!(needAvailableSpace(1))) { + return 0; + } + switch (type) { + case 0: + case 1: + case 2: + case 3: + errorWrongIndex(); + break; + case 4: + stepToFirstLineInat(getBuffer[workBuffer[11]], workBuffer[88]); + break; + case 5: + stepToFirstWideLineInat(getBuffer[workBuffer[11]], workBuffer[88]); + break; + case 6: + stepToFirstBezierInat(getBuffer[workBuffer[11]], workBuffer[88]); + break; + case 7: + stepToFirstWideBezierInat(getBuffer[workBuffer[11]], workBuffer[88]); + break; + } + insertEdgeIntoAET(edge); + workBuffer[11] = ((workBuffer[11]) + 1); + } + return 0; +} + + +/* Scan the active edge table. If there is any fill that cannot be handled by the engine itself, return true. Otherwise handle the fills and return false. */ +/* self currentYGet >= 680 ifTrue:[ +self printAET. +self halt. +]. */ + +static int findNextExternalFillFromAET(void) { + int leftEdge; + int leftX; + int rightEdge; + int rightX; + int startX; + int fill; + int stopX; + int someIntegerValue; + int someIntegerValue1; + int rightX1; + int startX1; + int fill1; + int stopX1; + int someIntegerValue2; + int someIntegerValue11; + + leftX = rightX = workBuffer[37]; + while ((workBuffer[13]) < (workBuffer[14])) { + + /* TODO: We should check if leftX from last operation + is greater than leftX from next edge. + Currently, we rely here on spanEndAA + from the span buffer fill. */ + + leftEdge = rightEdge = aetBuffer[workBuffer[13]]; + leftX = rightX = objBuffer[leftEdge + 4]; + if (leftX >= (workBuffer[37])) { + return 0; + } + /* begin quickRemoveInvalidFillsAt: */ + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + goto l3; + } + while ((topRightX()) <= leftX) { + hideFilldepth(topFill(), topDepth()); + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + goto l3; + } + } + l3: /* end quickRemoveInvalidFillsAt: */; + if ((((objBuffer[leftEdge + 0]) & 65535) & 1) != 0) { + toggleWideFillOf(leftEdge); + } + if (((objBuffer[leftEdge + 0]) & 65536) == 0) { + toggleFillsOf(leftEdge); + if (engineStopped) { + return 0; + } + } + workBuffer[13] = ((workBuffer[13]) + 1); + if ((workBuffer[13]) < (workBuffer[14])) { + rightEdge = aetBuffer[workBuffer[13]]; + rightX = objBuffer[rightEdge + 4]; + if (rightX >= (workBuffer[36])) { + /* begin fillAllFrom:to: */ + /* begin topFill */ + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + fill = 0; + goto l8; + } else { + fill = workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)]; + goto l8; + } + l8: /* end topFill */; + startX = leftX; + /* begin topRightX */ + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + stopX = 999999999; + goto l9; + } else { + stopX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 2)]; + goto l9; + } + l9: /* end topRightX */; + while (stopX < rightX) { + /* begin makeUnsignedFrom: */ + /* begin topFill */ + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + someIntegerValue = 0; + goto l6; + } else { + someIntegerValue = workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)]; + goto l6; + } + l6: /* end topFill */; + fill = someIntegerValue; + if (!(fill == 0)) { + if (fillSpanfromto(fill, startX, stopX)) { + goto l2; + } + } + /* begin quickRemoveInvalidFillsAt: */ + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + goto l1; + } + while ((topRightX()) <= stopX) { + hideFilldepth(topFill(), topDepth()); + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + goto l1; + } + } + l1: /* end quickRemoveInvalidFillsAt: */; + startX = stopX; + /* begin topRightX */ + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + stopX = 999999999; + goto l7; + } else { + stopX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 2)]; + goto l7; + } + l7: /* end topRightX */; + } + /* begin makeUnsignedFrom: */ + /* begin topFill */ + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + someIntegerValue1 = 0; + goto l10; + } else { + someIntegerValue1 = workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)]; + goto l10; + } + l10: /* end topFill */; + fill = someIntegerValue1; + if (!(fill == 0)) { + fillSpanfromto(fill, startX, rightX); + goto l2; + } + l2: /* end fillAllFrom:to: */; + } + } + } + if (rightX < (workBuffer[37])) { + /* begin fillAllFrom:to: */ + rightX1 = workBuffer[37]; + /* begin topFill */ + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + fill1 = 0; + goto l13; + } else { + fill1 = workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)]; + goto l13; + } + l13: /* end topFill */; + startX1 = rightX; + /* begin topRightX */ + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + stopX1 = 999999999; + goto l14; + } else { + stopX1 = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 2)]; + goto l14; + } + l14: /* end topRightX */; + while (stopX1 < rightX1) { + /* begin makeUnsignedFrom: */ + /* begin topFill */ + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + someIntegerValue2 = 0; + goto l11; + } else { + someIntegerValue2 = workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)]; + goto l11; + } + l11: /* end topFill */; + fill1 = someIntegerValue2; + if (!(fill1 == 0)) { + if (fillSpanfromto(fill1, startX1, stopX1)) { + goto l5; + } + } + /* begin quickRemoveInvalidFillsAt: */ + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + goto l4; + } + while ((topRightX()) <= stopX1) { + hideFilldepth(topFill(), topDepth()); + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + goto l4; + } + } + l4: /* end quickRemoveInvalidFillsAt: */; + startX1 = stopX1; + /* begin topRightX */ + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + stopX1 = 999999999; + goto l12; + } else { + stopX1 = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 2)]; + goto l12; + } + l12: /* end topRightX */; + } + /* begin makeUnsignedFrom: */ + /* begin topFill */ + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + someIntegerValue11 = 0; + goto l15; + } else { + someIntegerValue11 = workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)]; + goto l15; + } + l15: /* end topFill */; + fill1 = someIntegerValue11; + if (!(fill1 == 0)) { + fillSpanfromto(fill1, startX1, rightX1); + goto l5; + } + l5: /* end fillAllFrom:to: */; + } + return 0; +} + + +/* Check the active edge table for any entries that cannot be handled by the engine itself. + If there are any, return true. Otherwise, step the the edge to the next y value. */ + +static int findNextExternalUpdateFromAET(void) { + int edge; + int count; + int type; + + while ((workBuffer[13]) < (workBuffer[14])) { + edge = aetBuffer[workBuffer[13]]; + count = (objBuffer[edge + 7]) - 1; + if (count == 0) { + removeFirstAETEntry(); + } else { + objBuffer[edge + 7] = count; + type = (objBuffer[edge + 0]) & 65535; + if ((type & 254) == 2) { + return 1; + } + switch (type) { + case 0: + case 1: + case 2: + case 3: + errorWrongIndex(); + break; + case 4: + stepToNextLineInat(aetBuffer[workBuffer[13]], workBuffer[88]); + break; + case 5: + stepToNextWideLineInat(aetBuffer[workBuffer[13]], workBuffer[88]); + break; + case 6: + stepToNextBezierInat(aetBuffer[workBuffer[13]], workBuffer[88]); + break; + case 7: + stepToNextWideBezier(); + break; + } + resortFirstAETEntry(); + workBuffer[13] = ((workBuffer[13]) + 1); + } + } + return 0; +} + +static int findStackFilldepth(int fillIndex, int depth) { + int index; + + index = 0; + while ((index < ((workBuffer[1]) - (workBuffer[10]))) && (((workBuffer[(workBuffer[10]) + index]) != fillIndex) || ((workBuffer[(workBuffer[10]) + (index + 1)]) != depth))) { + index += 3; + } + if (index >= ((workBuffer[1]) - (workBuffer[10]))) { + return -1; + } else { + return index; + } +} + + +/* Return true if processing is finished */ + +static int finishedProcessing(void) { + return (workBuffer[2]) == 8; +} + +static int firstPointListGet(void) { + return workBuffer[70]; +} + +static int firstPointListPut(int value) { + return workBuffer[70] = value; +} + +static int freeStackFillEntry(void) { + /* begin wbStackPop: */ + workBuffer[10] = ((workBuffer[10]) + 3); +} + + +/* Note: This is hardcoded so it can be run from Squeak. + The module name is used for validating a module *after* + it is loaded to check if it does really contain the module + we're thinking it contains. This is important! */ + +EXPORT(const char*) getModuleName(void) { + return moduleName; +} + + +/* Return true if the edge at index i should sort before the edge at index j. */ + +static int getSortsbefore(int edge1, int edge2) { + int diff; + + if (edge1 == edge2) { + return 1; + } + diff = (objBuffer[edge1 + 5]) - (objBuffer[edge2 + 5]); + if (!(diff == 0)) { + return diff < 0; + } + diff = (objBuffer[edge1 + 4]) - (objBuffer[edge2 + 4]); + return diff < 0; +} + +static int getStartGet(void) { + return workBuffer[11]; +} + +static int getStartPut(int value) { + return workBuffer[11] = value; +} + +static int getUsedGet(void) { + return workBuffer[12]; +} + +static int getUsedPut(int value) { + return workBuffer[12] = value; +} + +static int gradientRampLengthOf(int fill) { + return objBuffer[fill + 10]; +} + +static int gradientRampLengthOfput(int fill, int value) { + return objBuffer[fill + 10] = value; +} + +static int * gradientRampOf(int fill) { + return (objBuffer + fill) + 12; +} + +static int halt(void) { + ; +} + +static int hasColorTransform(void) { + return (workBuffer[17]) != 0; +} + +static int hasColorTransformGet(void) { + return workBuffer[17]; +} + +static int hasColorTransformPut(int value) { + return workBuffer[17] = value; +} + +static int hasEdgeTransform(void) { + return (workBuffer[16]) != 0; +} + +static int hasEdgeTransformGet(void) { + return workBuffer[16]; +} + +static int hasEdgeTransformPut(int value) { + return workBuffer[16] = value; +} + + +/* Make the fill style with the given index invisible */ + +static int hideFilldepth(int fillIndex, int depth) { + int newTopIndex; + int newDepth; + int newTop; + int newRightX; + int index; + + index = findStackFilldepth(fillIndex, depth); + if (index == -1) { + return 0; + } + if (index == 0) { + /* begin freeStackFillEntry */ + /* begin wbStackPop: */ + workBuffer[10] = ((workBuffer[10]) + 3); + return 1; + } + workBuffer[(workBuffer[10]) + index] = (workBuffer[(workBuffer[10]) + 0]); + workBuffer[(workBuffer[10]) + (index + 1)] = (workBuffer[(workBuffer[10]) + (0 + 1)]); + workBuffer[(workBuffer[10]) + (index + 2)] = (workBuffer[(workBuffer[10]) + (0 + 2)]); + /* begin freeStackFillEntry */ + /* begin wbStackPop: */ + workBuffer[10] = ((workBuffer[10]) + 3); + if (((workBuffer[1]) - (workBuffer[10])) <= 3) { + return 1; + } + newTopIndex = 0; + index = 3; + while (index < ((workBuffer[1]) - (workBuffer[10]))) { + if (fillSortsbefore(index, newTopIndex)) { + newTopIndex = index; + } + index += 3; + } + if ((newTopIndex + 3) == ((workBuffer[1]) - (workBuffer[10]))) { + return 1; + } + newTop = workBuffer[(workBuffer[10]) + newTopIndex]; + workBuffer[(workBuffer[10]) + newTopIndex] = (workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)]); + workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)] = newTop; + newDepth = workBuffer[(workBuffer[10]) + (newTopIndex + 1)]; + workBuffer[(workBuffer[10]) + (newTopIndex + 1)] = (workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 1)]); + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 1)] = newDepth; + newRightX = workBuffer[(workBuffer[10]) + (newTopIndex + 2)]; + workBuffer[(workBuffer[10]) + (newTopIndex + 2)] = (workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 2)]); + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 2)] = newRightX; + return 1; +} + +static int incrementPointby(int *point, int delta) { + point[0] = ((point[0]) + delta); + point[1] = ((point[1]) + delta); +} + +static int incrementStatby(int statIndex, int value) { + return workBuffer[statIndex] = ((workBuffer[statIndex]) + value); +} + + +/* Find insertion point for the given edge in the AET */ + +static int indexForInsertingIntoAET(int edge) { + int initialX; + int index; + + initialX = objBuffer[edge + 4]; + index = 0; + while ((index < (workBuffer[14])) && ((objBuffer[(aetBuffer[index]) + 4]) < initialX)) { + index += 1; + } + while ((index < (workBuffer[14])) && (((objBuffer[(aetBuffer[index]) + 4]) == initialX) && (getSortsbefore(aetBuffer[index], edge)))) { + index += 1; + } + return index; +} + +static int initColorTransform(void) { + float *transform; + + transform = ((float *) (workBuffer + 24)); + transform[0] = (((float) 1.0)); + transform[1] = (((float) 0.0)); + transform[2] = (((float) 1.0)); + transform[3] = (((float) 0.0)); + transform[4] = (((float) 1.0)); + transform[5] = (((float) 0.0)); + transform[6] = (((float) 1.0)); + transform[7] = (((float) 0.0)); + workBuffer[17] = 0; +} + +static int initEdgeTransform(void) { + float *transform; + + transform = ((float *) (workBuffer + 18)); + transform[0] = (((float) 1.0)); + transform[1] = (((float) 0.0)); + transform[2] = (((float) 0.0)); + transform[3] = (((float) 0.0)); + transform[4] = (((float) 1.0)); + transform[5] = (((float) 0.0)); + workBuffer[16] = 0; +} + +EXPORT(int) initialiseModule(void) { + loadBBFn = interpreterProxy->ioLoadFunctionFrom("loadBitBltFrom", bbPluginName); + copyBitsFn = interpreterProxy->ioLoadFunctionFrom("copyBitsFromtoat", bbPluginName); + return (loadBBFn != 0) && (copyBitsFn != 0); +} + + +/* Initialization stuff that needs to be done before any processing can take place. */ + +static int initializeGETProcessing(void) { + setAALevel(workBuffer[48]); + if ((workBuffer[42]) < 0) { + workBuffer[42] = 0; + } + if ((workBuffer[43]) > (workBuffer[33])) { + workBuffer[43] = (workBuffer[33]); + } + workBuffer[36] = ((workBuffer[42]) << (workBuffer[49])); + workBuffer[38] = ((workBuffer[44]) << (workBuffer[49])); + workBuffer[37] = ((workBuffer[43]) << (workBuffer[49])); + workBuffer[39] = ((workBuffer[45]) << (workBuffer[49])); + workBuffer[12] = 0; + workBuffer[14] = 0; + + /* Create the global edge table */ + + getBuffer = aetBuffer = objBuffer + objUsed; + createGlobalEdgeTable(); + if (engineStopped) { + return null; + } + if ((workBuffer[12]) == 0) { + workBuffer[88] = (workBuffer[39]); + return 0; + } + /* begin sortGlobalEdgeTable */ + quickSortGlobalEdgeTablefromto(getBuffer, 0, (workBuffer[12]) - 1); + workBuffer[88] = (objBuffer[(getBuffer[0]) + 5]); + if ((workBuffer[88]) < (workBuffer[38])) { + workBuffer[88] = (workBuffer[38]); + } + workBuffer[32] = 0; + workBuffer[34] = (((workBuffer[33]) << (workBuffer[49])) - 1); + clearSpanBuffer(); +} + + +/* Insert the edge with the given index from the global edge table into the active edge table. + The edge has already been stepped to the initial yValue -- thus remainingLines and rasterX + are both set. */ + +static int insertEdgeIntoAET(int edge) { + int index; + + if ((objBuffer[edge + 7]) <= 0) { + return null; + } + + /* And insert edge */ + + index = indexForInsertingIntoAET(edge); + insertToAETbeforeIndex(edge, index); +} + + +/* Insert the given edge into the AET. */ + +static int insertToAETbeforeIndex(int edge, int index) { + int i; + + if (!(needAvailableSpace(1))) { + return null; + } + i = (workBuffer[14]) - 1; + while (!(i < index)) { + aetBuffer[i + 1] = (aetBuffer[i]); + i -= 1; + } + aetBuffer[index] = edge; + workBuffer[14] = ((workBuffer[14]) + 1); +} + +static int isBezier(int bezier) { + return (((objBuffer[bezier + 0]) & 65535) & 254) == 6; +} + +static int isEdge(int edge) { + int type; + + type = (objBuffer[edge + 0]) & 65535; + if (type > 255) { + return 0; + } + return (((objBuffer[edge + 0]) & 65535) & 255) != 0; +} + +static int isFill(int fill) { + return ((fill & 4278190080U) != 0) || ((((objBuffer[fill + 0]) & 65535) & 65280) != 0); +} + +static int isFillColor(int fill) { + return (fill & 4278190080U) != 0; +} + +static int isFillOkay(int fill) { + return (fill == 0) || (((fill & 4278190080U) != 0) || (((fill >= 0) && (fill < objUsed)) && (((fill & 4278190080U) != 0) || ((((objBuffer[fill + 0]) & 65535) & 65280) != 0)))); +} + +static int isLine(int line) { + return (((objBuffer[line + 0]) & 65535) & 254) == 4; +} + +static int isObject(int obj) { + return (obj >= 0) && (obj < objUsed); +} + +static int isRealFill(int fill) { + return (((objBuffer[fill + 0]) & 65535) & 65280) != 0; +} + +static int isStackEntry(int entry) { + return (entry >= (workBuffer[10])) && (entry < (workBuffer[1])); +} + +static int isStackIndex(int index) { + return (index >= 0) && (index < ((workBuffer[1]) - (workBuffer[10]))); +} + +static int isWide(int object) { + return (((objBuffer[object + 0]) & 65535) & 1) != 0; +} + +static int isWideBezier(int bezier) { + return ((((objBuffer[bezier + 0]) & 65535) & 254) == 6) && ((((objBuffer[bezier + 0]) & 65535) & 1) != 0); +} + +static int isWideLine(int line) { + return ((((objBuffer[line + 0]) & 65535) & 254) == 4) && ((((objBuffer[line + 0]) & 65535) & 1) != 0); +} + +static int lastExportedEdgeGet(void) { + return workBuffer[65]; +} + +static int lastExportedEdgePut(int value) { + return workBuffer[65] = value; +} + +static int lastExportedFillGet(void) { + return workBuffer[66]; +} + +static int lastExportedFillPut(int value) { + return workBuffer[66] = value; +} + +static int lastExportedLeftXGet(void) { + return workBuffer[67]; +} + +static int lastExportedLeftXPut(int value) { + return workBuffer[67] = value; +} + +static int lastExportedRightXGet(void) { + return workBuffer[68]; +} + +static int lastExportedRightXPut(int value) { + return workBuffer[68] = value; +} + +static int lineEndXOf(int line) { + return objBuffer[line + 14]; +} + +static int lineEndXOfput(int line, int value) { + return objBuffer[line + 14] = value; +} + +static int lineEndYOf(int line) { + return objBuffer[line + 15]; +} + +static int lineEndYOfput(int line, int value) { + return objBuffer[line + 15] = value; +} + +static int lineErrorAdjDownOf(int line) { + return objBuffer[line + 15]; +} + +static int lineErrorAdjDownOfput(int line, int value) { + return objBuffer[line + 15] = value; +} + +static int lineErrorAdjUpOf(int line) { + return objBuffer[line + 14]; +} + +static int lineErrorAdjUpOfput(int line, int value) { + return objBuffer[line + 14] = value; +} + +static int lineErrorOf(int line) { + return objBuffer[line + 13]; +} + +static int lineErrorOfput(int line, int value) { + return objBuffer[line + 13] = value; +} + +static int lineXDirectionOf(int line) { + return objBuffer[line + 10]; +} + +static int lineXDirectionOfput(int line, int value) { + return objBuffer[line + 10] = value; +} + +static int lineXIncrementOf(int line) { + return objBuffer[line + 12]; +} + +static int lineXIncrementOfput(int line, int value) { + return objBuffer[line + 12] = value; +} + +static int lineYDirectionOf(int line) { + return objBuffer[line + 11]; +} + +static int lineYDirectionOfput(int line, int value) { + return objBuffer[line + 11] = value; +} + + +/* Load and subdivide the bezier curve from point1/point2/point3. + If wideFlag is set then make sure the curve is monoton in X. */ + +static int loadAndSubdivideBezierFromviatoisWide(int *point1, int *point2, int *point3, int wideFlag) { + int index2; + int index; + int index1; + int bz1; + int bz2; + + /* begin allocateBezierStackEntry */ + /* begin wbStackPush: */ + if (!(needAvailableSpace(6))) { + goto l1; + } + workBuffer[10] = ((workBuffer[10]) - 6); +l1: /* end wbStackPush: */; + bz1 = (workBuffer[1]) - (workBuffer[10]); + if (engineStopped) { + return 0; + } + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - bz1) + 0)] = (point1[0]); + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - bz1) + 1)] = (point1[1]); + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - bz1) + 2)] = (point2[0]); + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - bz1) + 3)] = (point2[1]); + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - bz1) + 4)] = (point3[0]); + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - bz1) + 5)] = (point3[1]); + index2 = bz2 = subdivideToBeMonotoninX(bz1, wideFlag); + for (index = bz1; index <= bz2; index += 6) { + index1 = subdivideBezierFrom(index); + if (index1 > index2) { + index2 = index1; + } + if (engineStopped) { + return 0; + } + } + return index2 / 6; +} + +static int loadArrayPolygonnPointsfilllineWidthlineFill(int points, int nPoints, int fillIndex, int lineWidth, int lineFill) { + int x0; + int x1; + int i; + int y0; + int y1; + + loadPointfrom(((int *) (workBuffer + 80)), interpreterProxy->fetchPointerofObject(0, points)); + if (interpreterProxy->failed()) { + return null; + } + x0 = (((int *) (workBuffer + 80)))[0]; + y0 = (((int *) (workBuffer + 80)))[1]; + for (i = 1; i <= (nPoints - 1); i += 1) { + loadPointfrom(((int *) (workBuffer + 80)), interpreterProxy->fetchPointerofObject(i, points)); + if (interpreterProxy->failed()) { + return null; + } + x1 = (((int *) (workBuffer + 80)))[0]; + y1 = (((int *) (workBuffer + 80)))[1]; + (((int *) (workBuffer + 80)))[0] = x0; + (((int *) (workBuffer + 80)))[1] = y0; + (((int *) (workBuffer + 82)))[0] = x1; + (((int *) (workBuffer + 82)))[1] = y1; + /* begin transformPoints: */ + if (2 > 0) { + transformPoint(((int *) (workBuffer + 80))); + } + if (2 > 1) { + transformPoint(((int *) (workBuffer + 82))); + } + if (2 > 2) { + transformPoint(((int *) (workBuffer + 84))); + } + if (2 > 3) { + transformPoint(((int *) (workBuffer + 86))); + } + loadWideLinefromtolineFillleftFillrightFill(lineWidth, ((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), lineFill, fillIndex, 0); + if (engineStopped) { + return null; + } + x0 = x1; + y0 = y1; + } +} + +static int loadArrayShapenSegmentsfilllineWidthlineFill(int points, int nSegments, int fillIndex, int lineWidth, int lineFill) { + int x0; + int segs; + int x1; + int x2; + int i; + int pointOop; + int y0; + int y1; + int y2; + + for (i = 0; i <= (nSegments - 1); i += 1) { + pointOop = interpreterProxy->fetchPointerofObject(i * 3, points); + loadPointfrom(((int *) (workBuffer + 80)), pointOop); + pointOop = interpreterProxy->fetchPointerofObject((i * 3) + 1, points); + loadPointfrom(((int *) (workBuffer + 82)), pointOop); + pointOop = interpreterProxy->fetchPointerofObject((i * 3) + 2, points); + loadPointfrom(((int *) (workBuffer + 84)), pointOop); + if (interpreterProxy->failed()) { + return null; + } + /* begin transformPoints: */ + if (3 > 0) { + transformPoint(((int *) (workBuffer + 80))); + } + if (3 > 1) { + transformPoint(((int *) (workBuffer + 82))); + } + if (3 > 2) { + transformPoint(((int *) (workBuffer + 84))); + } + if (3 > 3) { + transformPoint(((int *) (workBuffer + 86))); + } + x0 = (((int *) (workBuffer + 80)))[0]; + y0 = (((int *) (workBuffer + 80)))[1]; + x1 = (((int *) (workBuffer + 82)))[0]; + y1 = (((int *) (workBuffer + 82)))[1]; + x2 = (((int *) (workBuffer + 84)))[0]; + + /* Check if we can use a line */ + + y2 = (((int *) (workBuffer + 84)))[1]; + if (((x0 == y0) && (x1 == y1)) || ((x1 == x2) && (y1 == y2))) { + loadWideLinefromtolineFillleftFillrightFill(lineWidth, ((int *) (workBuffer + 80)), ((int *) (workBuffer + 84)), lineFill, fillIndex, 0); + } else { + segs = loadAndSubdivideBezierFromviatoisWide(((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), ((int *) (workBuffer + 84)), (lineWidth != 0) && (lineFill != 0)); + if (engineStopped) { + return null; + } + loadWideBezierlineFillleftFillrightFilln(lineWidth, lineFill, fillIndex, 0, segs); + } + if (engineStopped) { + return null; + } + } +} + + +/* Load a transformation from the given array. */ + +static int loadArrayTransformFromintolength(int transformOop, float *destPtr, int n) { + int value; + int i; + + for (i = 0; i <= (n - 1); i += 1) { + value = interpreterProxy->fetchPointerofObject(i, transformOop); + if (!(((value & 1)) || (interpreterProxy->isFloatObject(value)))) { + return interpreterProxy->primitiveFail(); + } + if ((value & 1)) { + destPtr[i] = (((float) (((double) ((value >> 1)) )))); + } else { + destPtr[i] = (((float) (interpreterProxy->floatValueOf(value)))); + } + } +} + + +/* Initialize the bezier segment stored on the stack */ + +static int loadBeziersegmentleftFillrightFilloffset(int bezier, int index, int leftFillIndex, int rightFillIndex, int yOffset) { + if ((workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 5)]) >= (workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 1)])) { + objBuffer[bezier + 4] = (workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 0)]); + objBuffer[bezier + 5] = ((workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 1)]) - yOffset); + objBuffer[bezier + 12] = (workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 2)]); + objBuffer[bezier + 13] = ((workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 3)]) - yOffset); + objBuffer[bezier + 14] = (workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 4)]); + objBuffer[bezier + 15] = ((workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 5)]) - yOffset); + } else { + objBuffer[bezier + 4] = (workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 4)]); + objBuffer[bezier + 5] = ((workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 5)]) - yOffset); + objBuffer[bezier + 12] = (workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 2)]); + objBuffer[bezier + 13] = ((workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 3)]) - yOffset); + objBuffer[bezier + 14] = (workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 0)]); + objBuffer[bezier + 15] = ((workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 1)]) - yOffset); + } + objBuffer[bezier + 6] = (workBuffer[113]); + objBuffer[bezier + 8] = leftFillIndex; + objBuffer[bezier + 9] = rightFillIndex; +} + +static int loadBitBltFrom(int bbObj) { + if (loadBBFn == 0) { + if (!(initialiseModule())) { + return 0; + } + } + return ((int (*) (int))loadBBFn)(bbObj); +} + + +/* Load the bitmap fill. */ + +static int loadBitmapFillcolormaptilefromalongnormalxIndex(int formOop, int cmOop, int tileFlag, int *point1, int *point2, int *point3, int xIndex) { + int ppw; + int bmBitsSize; + int *cmBits; + int bmDepth; + int bmBits; + int cmSize; + int bmWidth; + int bmFill; + int bmHeight; + int bmRaster; + + if (cmOop == (interpreterProxy->nilObject())) { + cmSize = 0; + cmBits = null; + } else { + if (!((interpreterProxy->fetchClassOf(cmOop)) == (interpreterProxy->classBitmap()))) { + return interpreterProxy->primitiveFail(); + } + cmSize = interpreterProxy->slotSizeOf(cmOop); + cmBits = interpreterProxy->firstIndexableField(cmOop); + } + if ((formOop & 1)) { + return interpreterProxy->primitiveFail(); + } + if (!(interpreterProxy->isPointers(formOop))) { + return interpreterProxy->primitiveFail(); + } + if ((interpreterProxy->slotSizeOf(formOop)) < 5) { + return interpreterProxy->primitiveFail(); + } + bmBits = interpreterProxy->fetchPointerofObject(0, formOop); + if (!((interpreterProxy->fetchClassOf(bmBits)) == (interpreterProxy->classBitmap()))) { + return interpreterProxy->primitiveFail(); + } + bmBitsSize = interpreterProxy->slotSizeOf(bmBits); + bmWidth = interpreterProxy->fetchIntegerofObject(1, formOop); + bmHeight = interpreterProxy->fetchIntegerofObject(2, formOop); + bmDepth = interpreterProxy->fetchIntegerofObject(3, formOop); + if (interpreterProxy->failed()) { + return null; + } + if (!((bmWidth >= 0) && (bmHeight >= 0))) { + return interpreterProxy->primitiveFail(); + } + if (!((((((bmDepth == 32) || (bmDepth == 8)) || (bmDepth == 16)) || (bmDepth == 1)) || (bmDepth == 2)) || (bmDepth == 4))) { + return interpreterProxy->primitiveFail(); + } + if (!((cmSize == 0) || (cmSize == (1 << bmDepth)))) { + return interpreterProxy->primitiveFail(); + } + ppw = 32 / bmDepth; + bmRaster = (bmWidth + (ppw - 1)) / ppw; + if (!(bmBitsSize == (bmRaster * bmHeight))) { + return interpreterProxy->primitiveFail(); + } + bmFill = allocateBitmapFillcolormap(cmSize, cmBits); + if (engineStopped) { + return null; + } + objBuffer[bmFill + 10] = bmWidth; + objBuffer[bmFill + 11] = bmHeight; + objBuffer[bmFill + 12] = bmDepth; + objBuffer[bmFill + 14] = bmRaster; + objBuffer[bmFill + 13] = bmBitsSize; + objBuffer[bmFill + 16] = tileFlag; + objBuffer[bmFill + 2] = xIndex; + loadFillOrientationfromalongnormalwidthheight(bmFill, point1, point2, point3, bmWidth, bmHeight); + return bmFill; +} + + +/* Note: Assumes that the contents of formArray has been checked before */ + +static int * loadBitsFrom(int bmFill) { + int formOop; + int xIndex; + int bitsLen; + int bitsOop; + + xIndex = objBuffer[bmFill + 2]; + if (xIndex > (interpreterProxy->slotSizeOf(formArray))) { + return null; + } + formOop = interpreterProxy->fetchPointerofObject(xIndex, formArray); + bitsOop = interpreterProxy->fetchPointerofObject(0, formOop); + bitsLen = interpreterProxy->slotSizeOf(bitsOop); + if (!(bitsLen == (objBuffer[bmFill + 13]))) { + return null; + } + return interpreterProxy->firstIndexableField(bitsOop); +} + + +/* Load a 2x3 transformation matrix from the given oop. + Return true if the matrix is not nil, false otherwise */ + +static int loadColorTransformFrom(int transformOop) { + float *transform; + int okay; + + transform = ((float *) (workBuffer + 24)); + workBuffer[17] = 0; + okay = loadTransformFromintolength(transformOop, transform, 8); + if (!(okay)) { + return 0; + } + workBuffer[17] = 1; + transform[1] = ((transform[1]) * (((float) 256.0))); + transform[3] = ((transform[3]) * (((float) 256.0))); + transform[5] = ((transform[5]) * (((float) 256.0))); + transform[7] = ((transform[7]) * (((float) 256.0))); + return okay; +} + + +/* Load the compressed segment identified by segment index */ + +static int loadCompressedSegmentfromshortleftFillrightFilllineWidthlineColor(int segmentIndex, int points, int pointsShort, int leftFill, int rightFill, int lineWidth, int lineFill) { + int x0; + int segs; + int x1; + int x2; + int index; + int y0; + int y1; + int y2; + + if ((leftFill == rightFill) && ((lineWidth == 0) || (lineFill == 0))) { + return null; + } + + /* 3 points with x/y each */ + + index = segmentIndex * 6; + if (pointsShort) { + x0 = (((short *) points))[index + 0]; + y0 = (((short *) points))[index + 1]; + x1 = (((short *) points))[index + 2]; + y1 = (((short *) points))[index + 3]; + x2 = (((short *) points))[index + 4]; + y2 = (((short *) points))[index + 5]; + } else { + x0 = (((int *) points))[index + 0]; + y0 = (((int *) points))[index + 1]; + x1 = (((int *) points))[index + 2]; + y1 = (((int *) points))[index + 3]; + x2 = (((int *) points))[index + 4]; + y2 = (((int *) points))[index + 5]; + } + if (((x0 == x1) && (y0 == y1)) || ((x1 == x2) && (y1 == y2))) { + if ((x0 == x2) && (y0 == y2)) { + return null; + } + (((int *) (workBuffer + 80)))[0] = x0; + (((int *) (workBuffer + 80)))[1] = y0; + (((int *) (workBuffer + 82)))[0] = x2; + (((int *) (workBuffer + 82)))[1] = y2; + /* begin transformPoints: */ + if (2 > 0) { + transformPoint(((int *) (workBuffer + 80))); + } + if (2 > 1) { + transformPoint(((int *) (workBuffer + 82))); + } + if (2 > 2) { + transformPoint(((int *) (workBuffer + 84))); + } + if (2 > 3) { + transformPoint(((int *) (workBuffer + 86))); + } + return loadWideLinefromtolineFillleftFillrightFill(lineWidth, ((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), lineFill, leftFill, rightFill); + } + (((int *) (workBuffer + 80)))[0] = x0; + (((int *) (workBuffer + 80)))[1] = y0; + (((int *) (workBuffer + 82)))[0] = x1; + (((int *) (workBuffer + 82)))[1] = y1; + (((int *) (workBuffer + 84)))[0] = x2; + (((int *) (workBuffer + 84)))[1] = y2; + /* begin transformPoints: */ + if (3 > 0) { + transformPoint(((int *) (workBuffer + 80))); + } + if (3 > 1) { + transformPoint(((int *) (workBuffer + 82))); + } + if (3 > 2) { + transformPoint(((int *) (workBuffer + 84))); + } + if (3 > 3) { + transformPoint(((int *) (workBuffer + 86))); + } + segs = loadAndSubdivideBezierFromviatoisWide(((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), ((int *) (workBuffer + 84)), (lineWidth != 0) && (lineFill != 0)); + if (engineStopped) { + return null; + } + loadWideBezierlineFillleftFillrightFilln(lineWidth, lineFill, leftFill, rightFill, segs); +} + + +/* Load a compressed shape into the engine. + WARNING: THIS METHOD NEEDS THE FULL FRAME SIZE!!!! + */ + +static int loadCompressedShapesegmentsleftFillsrightFillslineWidthslineFillsfillIndexListpointShort(int *points, int nSegments, int *leftFills, int *rightFills, int *lineWidths, int *lineFills, int *fillIndexList, int pointsShort) { + int widthRun; + int rightLength; + int rightRun; + int i; + int rightValue; + int leftValue; + int widthValue; + int lineFillLength; + int lineFillRun; + int leftLength; + int leftRun; + int widthLength; + int lineFillValue; + int x0; + int segs; + int x1; + int x2; + int index; + int y0; + int y1; + int y2; + + if (nSegments == 0) { + return 0; + } + leftRun = rightRun = widthRun = lineFillRun = -1; + leftLength = rightLength = widthLength = lineFillLength = 1; + leftValue = rightValue = widthValue = lineFillValue = 0; + for (i = 1; i <= nSegments; i += 1) { + if ((leftLength -= 1) <= 0) { + leftRun += 1; + leftLength = ((unsigned) ((((int *) leftFills))[leftRun]) >> 16); + leftValue = ((((int *) leftFills))[leftRun]) & 65535; + if (!(leftValue == 0)) { + leftValue = fillIndexList[leftValue - 1]; + leftValue = transformColor(leftValue); + if (engineStopped) { + return null; + } + } + } + if ((rightLength -= 1) <= 0) { + rightRun += 1; + rightLength = ((unsigned) ((((int *) rightFills))[rightRun]) >> 16); + rightValue = ((((int *) rightFills))[rightRun]) & 65535; + if (!(rightValue == 0)) { + rightValue = fillIndexList[rightValue - 1]; + rightValue = transformColor(rightValue); + } + } + if ((widthLength -= 1) <= 0) { + widthRun += 1; + widthLength = ((unsigned) ((((int *) lineWidths))[widthRun]) >> 16); + widthValue = ((((int *) lineWidths))[widthRun]) & 65535; + if (!(widthValue == 0)) { + widthValue = transformWidth(widthValue); + } + } + if ((lineFillLength -= 1) <= 0) { + lineFillRun += 1; + lineFillLength = ((unsigned) ((((int *) lineFills))[lineFillRun]) >> 16); + lineFillValue = ((((int *) lineFills))[lineFillRun]) & 65535; + if (!(lineFillValue == 0)) { + lineFillValue = fillIndexList[lineFillValue - 1]; + } + } + /* begin loadCompressedSegment:from:short:leftFill:rightFill:lineWidth:lineColor: */ + if ((leftValue == rightValue) && ((widthValue == 0) || (lineFillValue == 0))) { + goto l1; + } + index = (i - 1) * 6; + if (pointsShort) { + x0 = (((short *) points))[index + 0]; + y0 = (((short *) points))[index + 1]; + x1 = (((short *) points))[index + 2]; + y1 = (((short *) points))[index + 3]; + x2 = (((short *) points))[index + 4]; + y2 = (((short *) points))[index + 5]; + } else { + x0 = (((int *) points))[index + 0]; + y0 = (((int *) points))[index + 1]; + x1 = (((int *) points))[index + 2]; + y1 = (((int *) points))[index + 3]; + x2 = (((int *) points))[index + 4]; + y2 = (((int *) points))[index + 5]; + } + if (((x0 == x1) && (y0 == y1)) || ((x1 == x2) && (y1 == y2))) { + if ((x0 == x2) && (y0 == y2)) { + goto l1; + } + (((int *) (workBuffer + 80)))[0] = x0; + (((int *) (workBuffer + 80)))[1] = y0; + (((int *) (workBuffer + 82)))[0] = x2; + (((int *) (workBuffer + 82)))[1] = y2; + /* begin transformPoints: */ + if (2 > 0) { + transformPoint(((int *) (workBuffer + 80))); + } + if (2 > 1) { + transformPoint(((int *) (workBuffer + 82))); + } + if (2 > 2) { + transformPoint(((int *) (workBuffer + 84))); + } + if (2 > 3) { + transformPoint(((int *) (workBuffer + 86))); + } + loadWideLinefromtolineFillleftFillrightFill(widthValue, ((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), lineFillValue, leftValue, rightValue); + goto l1; + } + (((int *) (workBuffer + 80)))[0] = x0; + (((int *) (workBuffer + 80)))[1] = y0; + (((int *) (workBuffer + 82)))[0] = x1; + (((int *) (workBuffer + 82)))[1] = y1; + (((int *) (workBuffer + 84)))[0] = x2; + (((int *) (workBuffer + 84)))[1] = y2; + /* begin transformPoints: */ + if (3 > 0) { + transformPoint(((int *) (workBuffer + 80))); + } + if (3 > 1) { + transformPoint(((int *) (workBuffer + 82))); + } + if (3 > 2) { + transformPoint(((int *) (workBuffer + 84))); + } + if (3 > 3) { + transformPoint(((int *) (workBuffer + 86))); + } + segs = loadAndSubdivideBezierFromviatoisWide(((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), ((int *) (workBuffer + 84)), (widthValue != 0) && (lineFillValue != 0)); + if (engineStopped) { + goto l1; + } + loadWideBezierlineFillleftFillrightFilln(widthValue, lineFillValue, leftValue, rightValue, segs); + l1: /* end loadCompressedSegment:from:short:leftFill:rightFill:lineWidth:lineColor: */; + if (engineStopped) { + return null; + } + } +} + +static int loadEdgeStateFrom(int edgeOop) { + int edge; + int value; + int value1; + int value2; + int value3; + + edge = workBuffer[65]; + if ((interpreterProxy->slotSizeOf(edgeOop)) < 6) { + return interpreterProxy->primitiveFail(); + } + /* begin edgeXValueOf:put: */ + value = interpreterProxy->fetchIntegerofObject(1, edgeOop); + objBuffer[edge + 4] = value; + /* begin edgeYValueOf:put: */ + value2 = interpreterProxy->fetchIntegerofObject(2, edgeOop); + objBuffer[edge + 5] = value2; + /* begin edgeZValueOf:put: */ + value3 = interpreterProxy->fetchIntegerofObject(3, edgeOop); + objBuffer[edge + 6] = value3; + /* begin edgeNumLinesOf:put: */ + value1 = interpreterProxy->fetchIntegerofObject(4, edgeOop); + objBuffer[edge + 7] = value1; + return edge; +} + + +/* Load a 2x3 transformation matrix from the given oop. + Return true if the matrix is not nil, false otherwise */ + +static int loadEdgeTransformFrom(int transformOop) { + float *transform; + int okay; + + workBuffer[16] = 0; + transform = ((float *) (workBuffer + 18)); + okay = loadTransformFromintolength(transformOop, transform, 6); + if (interpreterProxy->failed()) { + return null; + } + if (!(okay)) { + return 0; + } + workBuffer[16] = 1; + transform[2] = (((float) ((transform[2]) + (((double) (workBuffer[46]) ))))); + transform[5] = (((float) ((transform[5]) + (((double) (workBuffer[47]) ))))); + return 1; +} + + +/* Transform the points */ + +static int loadFillOrientationfromalongnormalwidthheight(int fill, int *point1, int *point2, int *point3, int fillWidth, int fillHeight) { + int dirY; + int dtX; + int dtY; + int nrmX; + int nrmY; + int dtLength2; + int dsX; + int dsLength2; + int dsY; + int dirX; + + point2[0] = ((point2[0]) + (point1[0])); + point2[1] = ((point2[1]) + (point1[1])); + point3[0] = ((point3[0]) + (point1[0])); + point3[1] = ((point3[1]) + (point1[1])); + transformPoint(point1); + transformPoint(point2); + transformPoint(point3); + dirX = (point2[0]) - (point1[0]); + dirY = (point2[1]) - (point1[1]); + nrmX = (point3[0]) - (point1[0]); + + /* Compute the scale from direction/normal into ramp size */ + + nrmY = (point3[1]) - (point1[1]); + dsLength2 = (dirX * dirX) + (dirY * dirY); + if (dsLength2 > 0) { + dsX = ((int) ((((((double) dirX )) * (((double) fillWidth ))) * 65536.0) / (((double) dsLength2 ))) ); + dsY = ((int) ((((((double) dirY )) * (((double) fillWidth ))) * 65536.0) / (((double) dsLength2 ))) ); + } else { + dsX = 0; + dsY = 0; + } + dtLength2 = (nrmX * nrmX) + (nrmY * nrmY); + if (dtLength2 > 0) { + dtX = ((int) ((((((double) nrmX )) * (((double) fillHeight ))) * 65536.0) / (((double) dtLength2 ))) ); + dtY = ((int) ((((((double) nrmY )) * (((double) fillHeight ))) * 65536.0) / (((double) dtLength2 ))) ); + } else { + dtX = 0; + dtY = 0; + } + objBuffer[fill + 4] = (point1[0]); + objBuffer[fill + 5] = (point1[1]); + objBuffer[fill + 6] = dsX; + objBuffer[fill + 7] = dsY; + objBuffer[fill + 8] = dtX; + objBuffer[fill + 9] = dtY; +} + + +/* Check all the forms from arrayOop. */ + +static int loadFormsFrom(int arrayOop) { + int ppw; + int bmBitsSize; + int i; + int bmDepth; + int formOop; + int bmBits; + int bmWidth; + int bmHeight; + int bmRaster; + + if (!((interpreterProxy->fetchClassOf(arrayOop)) == (interpreterProxy->classArray()))) { + return 0; + } + formArray = arrayOop; + for (i = 0; i <= ((interpreterProxy->slotSizeOf(formArray)) - 1); i += 1) { + formOop = interpreterProxy->fetchPointerofObject(i, formArray); + if ((formOop & 1)) { + return 0; + } + if (!(interpreterProxy->isPointers(formOop))) { + return 0; + } + if ((interpreterProxy->slotSizeOf(formOop)) < 5) { + return 0; + } + bmBits = interpreterProxy->fetchPointerofObject(0, formOop); + if (!((interpreterProxy->fetchClassOf(bmBits)) == (interpreterProxy->classBitmap()))) { + return 0; + } + bmBitsSize = interpreterProxy->slotSizeOf(bmBits); + bmWidth = interpreterProxy->fetchIntegerofObject(1, formOop); + bmHeight = interpreterProxy->fetchIntegerofObject(2, formOop); + bmDepth = interpreterProxy->fetchIntegerofObject(3, formOop); + if (interpreterProxy->failed()) { + return 0; + } + if (!((bmWidth >= 0) && (bmHeight >= 0))) { + return 0; + } + ppw = 32 / bmDepth; + bmRaster = (bmWidth + (ppw - 1)) / ppw; + if (!(bmBitsSize == (bmRaster * bmHeight))) { + return 0; + } + } + return 1; +} + + +/* Load the gradient fill as defined by the color ramp. */ + +static int loadGradientFillfromalongnormalisRadial(int rampOop, int *point1, int *point2, int *point3, int isRadial) { + int fill; + int rampWidth; + + if (!((interpreterProxy->fetchClassOf(rampOop)) == (interpreterProxy->classBitmap()))) { + return interpreterProxy->primitiveFail(); + } + rampWidth = interpreterProxy->slotSizeOf(rampOop); + fill = allocateGradientFillrampWidthisRadial(interpreterProxy->firstIndexableField(rampOop), rampWidth, isRadial); + if (engineStopped) { + return null; + } + loadFillOrientationfromalongnormalwidthheight(fill, point1, point2, point3, rampWidth, rampWidth); + return fill; +} + + +/* Load the line defined by point1 and point2. */ + +static int loadLinefromtooffsetleftFillrightFill(int line, int *point1, int *point2, int yOffset, int leftFill, int rightFill) { + int *p1; + int *p2; + int yDir; + + if ((point1[1]) <= (point2[1])) { + p1 = point1; + p2 = point2; + yDir = 1; + } else { + p1 = point2; + p2 = point1; + yDir = -1; + } + objBuffer[line + 4] = (p1[0]); + objBuffer[line + 5] = ((p1[1]) - yOffset); + objBuffer[line + 6] = (workBuffer[113]); + objBuffer[line + 8] = leftFill; + objBuffer[line + 9] = rightFill; + objBuffer[line + 14] = (p2[0]); + objBuffer[line + 15] = ((p2[1]) - yOffset); + objBuffer[line + 11] = yDir; +} + + +/* Load a rectangular oval currently defined by point1/point2 */ + +static int loadOvallineFillleftFillrightFill(int lineWidth, int lineFill, int leftFill, int rightFill) { + int w; + int h; + int i; + int nSegments; + int cx; + int cy; + + w = ((int) (((((int *) (workBuffer + 82)))[0]) - ((((int *) (workBuffer + 80)))[0])) >> 1); + h = ((int) (((((int *) (workBuffer + 82)))[1]) - ((((int *) (workBuffer + 80)))[1])) >> 1); + cx = ((int) (((((int *) (workBuffer + 82)))[0]) + ((((int *) (workBuffer + 80)))[0])) >> 1); + cy = ((int) (((((int *) (workBuffer + 82)))[1]) + ((((int *) (workBuffer + 80)))[1])) >> 1); + for (i = 0; i <= 15; i += 1) { + loadOvalSegmentwhcxcy(i, w, h, cx, cy); + /* begin transformPoints: */ + if (3 > 0) { + transformPoint(((int *) (workBuffer + 80))); + } + if (3 > 1) { + transformPoint(((int *) (workBuffer + 82))); + } + if (3 > 2) { + transformPoint(((int *) (workBuffer + 84))); + } + if (3 > 3) { + transformPoint(((int *) (workBuffer + 86))); + } + nSegments = loadAndSubdivideBezierFromviatoisWide(((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), ((int *) (workBuffer + 84)), (lineWidth != 0) && (lineFill != 0)); + if (engineStopped) { + return null; + } + loadWideBezierlineFillleftFillrightFilln(lineWidth, lineFill, leftFill, rightFill, nSegments); + if (engineStopped) { + return null; + } + } +} + +static int loadOvalSegmentwhcxcy(int seg, int w, int h, int cx, int cy) { + int x0; + int x1; + int x2; + int y0; + int y1; + int y2; + + x0 = ((int) ((((circleCosTable())[(seg * 2) + 0]) * (((double) w ))) + cx) ); + y0 = ((int) ((((circleSinTable())[(seg * 2) + 0]) * (((double) h ))) + cy) ); + (((int *) (workBuffer + 80)))[0] = x0; + (((int *) (workBuffer + 80)))[1] = y0; + x2 = ((int) ((((circleCosTable())[(seg * 2) + 2]) * (((double) w ))) + cx) ); + y2 = ((int) ((((circleSinTable())[(seg * 2) + 2]) * (((double) h ))) + cy) ); + (((int *) (workBuffer + 84)))[0] = x2; + (((int *) (workBuffer + 84)))[1] = y2; + x1 = ((int) ((((circleCosTable())[(seg * 2) + 1]) * (((double) w ))) + cx) ); + + /* NOTE: The intermediate point is the point ON the curve + and not yet the control point (which is OFF the curve) */ + + y1 = ((int) ((((circleSinTable())[(seg * 2) + 1]) * (((double) h ))) + cy) ); + x1 = (x1 * 2) - (((int) (x0 + x2) >> 1)); + y1 = (y1 * 2) - (((int) (y0 + y2) >> 1)); + (((int *) (workBuffer + 82)))[0] = x1; + (((int *) (workBuffer + 82)))[1] = y1; +} + + +/* Load the contents of pointOop into pointArray */ + +static int loadPointfrom(int *pointArray, int pointOop) { + int value; + + if (!((interpreterProxy->fetchClassOf(pointOop)) == (interpreterProxy->classPoint()))) { + return interpreterProxy->primitiveFail(); + } + value = interpreterProxy->fetchPointerofObject(0, pointOop); + if (!(((value & 1)) || (interpreterProxy->isFloatObject(value)))) { + return interpreterProxy->primitiveFail(); + } + if ((value & 1)) { + pointArray[0] = ((value >> 1)); + } else { + pointArray[0] = (((int) (interpreterProxy->floatValueOf(value)) )); + } + value = interpreterProxy->fetchPointerofObject(1, pointOop); + if (!(((value & 1)) || (interpreterProxy->isFloatObject(value)))) { + return interpreterProxy->primitiveFail(); + } + if ((value & 1)) { + pointArray[1] = ((value >> 1)); + } else { + pointArray[1] = (((int) (interpreterProxy->floatValueOf(value)) )); + } +} + + +/* Load the int value from the given index in intArray */ + +static int loadPointIntAtfrom(int index, int intArray) { + return (((int *) intArray))[index]; +} + + +/* Load the short value from the given index in shortArray */ + +static short loadPointShortAtfrom(int index, int shortArray) { + return (((short *) shortArray))[index]; +} + +static int loadPolygonnPointsfilllineWidthlineFillpointsShort(int *points, int nPoints, int fillIndex, int lineWidth, int lineFill, int isShort) { + int x0; + int x1; + int i; + int y0; + int y1; + + if (isShort) { + x0 = (((short *) points))[0]; + y0 = (((short *) points))[1]; + } else { + x0 = (((int *) points))[0]; + y0 = (((int *) points))[1]; + } + for (i = 1; i <= (nPoints - 1); i += 1) { + if (isShort) { + x1 = (((short *) points))[i * 2]; + y1 = (((short *) points))[(i * 2) + 1]; + } else { + x1 = (((int *) points))[i * 2]; + y1 = (((int *) points))[(i * 2) + 1]; + } + (((int *) (workBuffer + 80)))[0] = x0; + (((int *) (workBuffer + 80)))[1] = y0; + (((int *) (workBuffer + 82)))[0] = x1; + (((int *) (workBuffer + 82)))[1] = y1; + /* begin transformPoints: */ + if (2 > 0) { + transformPoint(((int *) (workBuffer + 80))); + } + if (2 > 1) { + transformPoint(((int *) (workBuffer + 82))); + } + if (2 > 2) { + transformPoint(((int *) (workBuffer + 84))); + } + if (2 > 3) { + transformPoint(((int *) (workBuffer + 86))); + } + loadWideLinefromtolineFillleftFillrightFill(lineWidth, ((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), lineFill, fillIndex, 0); + if (engineStopped) { + return null; + } + x0 = x1; + y0 = y1; + } +} + + +/* Load a rectangle currently defined by point1-point4 */ + +static int loadRectanglelineFillleftFillrightFill(int lineWidth, int lineFill, int leftFill, int rightFill) { + loadWideLinefromtolineFillleftFillrightFill(lineWidth, ((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), lineFill, leftFill, rightFill); + loadWideLinefromtolineFillleftFillrightFill(lineWidth, ((int *) (workBuffer + 82)), ((int *) (workBuffer + 84)), lineFill, leftFill, rightFill); + loadWideLinefromtolineFillleftFillrightFill(lineWidth, ((int *) (workBuffer + 84)), ((int *) (workBuffer + 86)), lineFill, leftFill, rightFill); + loadWideLinefromtolineFillleftFillrightFill(lineWidth, ((int *) (workBuffer + 86)), ((int *) (workBuffer + 80)), lineFill, leftFill, rightFill); +} + + +/* Load the entire state from the interpreter for the rendering primitives */ + +static int loadRenderingState(void) { + int edgeOop; + int state; + int fillOop; + + if (!((interpreterProxy->methodArgumentCount()) == 2)) { + return interpreterProxy->primitiveFail(); + } + fillOop = interpreterProxy->stackObjectValue(0); + edgeOop = interpreterProxy->stackObjectValue(1); + engine = interpreterProxy->stackObjectValue(2); + if (interpreterProxy->failed()) { + return 0; + } + if (!(quickLoadEngineFrom(engine))) { + return 0; + } + if (!(loadSpanBufferFrom(interpreterProxy->fetchPointerofObject(1, engine)))) { + return 0; + } + if (!(loadBitBltFrom(interpreterProxy->fetchPointerofObject(2, engine)))) { + return 0; + } + if (!(loadFormsFrom(interpreterProxy->fetchPointerofObject(3, engine)))) { + return 0; + } + if ((interpreterProxy->slotSizeOf(edgeOop)) < 6) { + return 0; + } + if ((interpreterProxy->slotSizeOf(fillOop)) < 6) { + return 0; + } + state = workBuffer[2]; + if ((state == 2) || ((state == 4) || (state == 7))) { + return 0; + } + return 1; +} + +static int loadShapenSegmentsfilllineWidthlineFillpointsShort(int *points, int nSegments, int fillIndex, int lineWidth, int lineFill, int pointsShort) { + int i; + int x0; + int segs; + int x1; + int x2; + int index; + int y0; + int y1; + int y2; + + for (i = 1; i <= nSegments; i += 1) { + /* begin loadCompressedSegment:from:short:leftFill:rightFill:lineWidth:lineColor: */ + if ((fillIndex == 0) && ((lineWidth == 0) || (lineFill == 0))) { + goto l1; + } + index = (i - 1) * 6; + if (pointsShort) { + x0 = (((short *) points))[index + 0]; + y0 = (((short *) points))[index + 1]; + x1 = (((short *) points))[index + 2]; + y1 = (((short *) points))[index + 3]; + x2 = (((short *) points))[index + 4]; + y2 = (((short *) points))[index + 5]; + } else { + x0 = (((int *) points))[index + 0]; + y0 = (((int *) points))[index + 1]; + x1 = (((int *) points))[index + 2]; + y1 = (((int *) points))[index + 3]; + x2 = (((int *) points))[index + 4]; + y2 = (((int *) points))[index + 5]; + } + if (((x0 == x1) && (y0 == y1)) || ((x1 == x2) && (y1 == y2))) { + if ((x0 == x2) && (y0 == y2)) { + goto l1; + } + (((int *) (workBuffer + 80)))[0] = x0; + (((int *) (workBuffer + 80)))[1] = y0; + (((int *) (workBuffer + 82)))[0] = x2; + (((int *) (workBuffer + 82)))[1] = y2; + /* begin transformPoints: */ + if (2 > 0) { + transformPoint(((int *) (workBuffer + 80))); + } + if (2 > 1) { + transformPoint(((int *) (workBuffer + 82))); + } + if (2 > 2) { + transformPoint(((int *) (workBuffer + 84))); + } + if (2 > 3) { + transformPoint(((int *) (workBuffer + 86))); + } + loadWideLinefromtolineFillleftFillrightFill(lineWidth, ((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), lineFill, fillIndex, 0); + goto l1; + } + (((int *) (workBuffer + 80)))[0] = x0; + (((int *) (workBuffer + 80)))[1] = y0; + (((int *) (workBuffer + 82)))[0] = x1; + (((int *) (workBuffer + 82)))[1] = y1; + (((int *) (workBuffer + 84)))[0] = x2; + (((int *) (workBuffer + 84)))[1] = y2; + /* begin transformPoints: */ + if (3 > 0) { + transformPoint(((int *) (workBuffer + 80))); + } + if (3 > 1) { + transformPoint(((int *) (workBuffer + 82))); + } + if (3 > 2) { + transformPoint(((int *) (workBuffer + 84))); + } + if (3 > 3) { + transformPoint(((int *) (workBuffer + 86))); + } + segs = loadAndSubdivideBezierFromviatoisWide(((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), ((int *) (workBuffer + 84)), (lineWidth != 0) && (lineFill != 0)); + if (engineStopped) { + goto l1; + } + loadWideBezierlineFillleftFillrightFilln(lineWidth, lineFill, fillIndex, 0, segs); + l1: /* end loadCompressedSegment:from:short:leftFill:rightFill:lineWidth:lineColor: */; + if (engineStopped) { + return null; + } + } +} + + +/* Load the span buffer from the given oop. */ + +static int loadSpanBufferFrom(int spanOop) { + int value; + + if (!((interpreterProxy->fetchClassOf(spanOop)) == (interpreterProxy->classBitmap()))) { + return 0; + } + + /* Leave last entry unused to avoid complications */ + + spanBuffer = interpreterProxy->firstIndexableField(spanOop); + /* begin spanSizePut: */ + value = (interpreterProxy->slotSizeOf(spanOop)) - 1; + workBuffer[33] = value; + return 1; +} + + +/* Load a transformation from transformOop into the float array + defined by destPtr. The transformation is assumed to be either + an array or a FloatArray of length n. */ + +static int loadTransformFromintolength(int transformOop, float *destPtr, int n) { + if (transformOop == (interpreterProxy->nilObject())) { + return 0; + } + if ((transformOop & 1)) { + return interpreterProxy->primitiveFail(); + } + if (!((interpreterProxy->slotSizeOf(transformOop)) == n)) { + return interpreterProxy->primitiveFail(); + } + if (interpreterProxy->isWords(transformOop)) { + loadWordTransformFromintolength(transformOop, destPtr, n); + } else { + loadArrayTransformFromintolength(transformOop, destPtr, n); + } + return 1; +} + + +/* Load the (possibly wide) bezier from the segments currently on the bezier stack. */ + +static int loadWideBezierlineFillleftFillrightFilln(int lineWidth, int lineFill, int leftFill, int rightFill, int nSegments) { + int index; + int bezier; + int wide; + int offset; + int bezier1; + int bezier2; + + if ((lineWidth == 0) || (lineFill == 0)) { + wide = 0; + offset = 0; + } else { + wide = 1; + offset = ((int) lineWidth >> 1); + } + index = nSegments * 6; + while (index > 0) { + if (wide) { + /* begin allocateWideBezier */ + if (!(allocateObjEntry(28))) { + bezier = 0; + goto l2; + } + bezier2 = objUsed; + objUsed = bezier2 + 28; + objBuffer[bezier2 + 0] = 7; + objBuffer[bezier2 + 2] = 0; + objBuffer[bezier2 + 1] = 28; + bezier = bezier2; + l2: /* end allocateWideBezier */; + } else { + /* begin allocateBezier */ + if (!(allocateObjEntry(16))) { + bezier = 0; + goto l1; + } + bezier1 = objUsed; + objUsed = bezier1 + 16; + objBuffer[bezier1 + 0] = 6; + objBuffer[bezier1 + 2] = 0; + objBuffer[bezier1 + 1] = 16; + bezier = bezier1; + l1: /* end allocateBezier */; + } + if (engineStopped) { + return 0; + } + loadBeziersegmentleftFillrightFilloffset(bezier, index, leftFill, rightFill, offset); + if (wide) { + objBuffer[bezier + 16] = lineFill; + objBuffer[bezier + 17] = lineWidth; + objBuffer[bezier + 20] = lineWidth; + } + index -= 6; + } + /* begin wbStackClear */ + workBuffer[10] = (workBuffer[1]); +} + + +/* Load a (possibly wide) line defined by the points p1 and p2 */ + +static int loadWideLinefromtolineFillleftFillrightFill(int lineWidth, int *p1, int *p2, int lineFill, int leftFill, int rightFill) { + int line; + int offset; + int line1; + int line2; + + if ((lineWidth == 0) || (lineFill == 0)) { + /* begin allocateLine */ + if (!(allocateObjEntry(16))) { + line = 0; + goto l1; + } + line1 = objUsed; + objUsed = line1 + 16; + objBuffer[line1 + 0] = 4; + objBuffer[line1 + 2] = 0; + objBuffer[line1 + 1] = 16; + line = line1; + l1: /* end allocateLine */; + offset = 0; + } else { + /* begin allocateWideLine */ + if (!(allocateObjEntry(21))) { + line = 0; + goto l2; + } + line2 = objUsed; + objUsed = line2 + 21; + objBuffer[line2 + 0] = 5; + objBuffer[line2 + 2] = 0; + objBuffer[line2 + 1] = 21; + line = line2; + l2: /* end allocateWideLine */; + offset = ((int) lineWidth >> 1); + } + if (engineStopped) { + return 0; + } + loadLinefromtooffsetleftFillrightFill(line, p1, p2, offset, leftFill, rightFill); + if ((((objBuffer[line + 0]) & 65535) & 1) != 0) { + objBuffer[line + 16] = lineFill; + objBuffer[line + 17] = lineWidth; + objBuffer[line + 20] = lineWidth; + } +} + + +/* Load a float array transformation from the given oop */ + +static int loadWordTransformFromintolength(int transformOop, float *destPtr, int n) { + float *srcPtr; + int i; + + srcPtr = ((float *) (interpreterProxy->firstIndexableField(transformOop))); + for (i = 0; i <= (n - 1); i += 1) { + destPtr[i] = (srcPtr[i]); + } +} + + +/* Load the working buffer from the given oop */ + +static int loadWorkBufferFrom(int wbOop) { + if ((wbOop & 1)) { + return 0; + } + if (!(interpreterProxy->isWords(wbOop))) { + return 0; + } + if ((interpreterProxy->slotSizeOf(wbOop)) < 256) { + return 0; + } + workBuffer = interpreterProxy->firstIndexableField(wbOop); + if (!((workBuffer[0]) == 1097753705)) { + return 0; + } + if (!((workBuffer[1]) == (interpreterProxy->slotSizeOf(wbOop)))) { + return 0; + } + if (!((workBuffer[8]) == 128)) { + return 0; + } + objBuffer = workBuffer + (workBuffer[8]); + getBuffer = objBuffer + (workBuffer[9]); + + /* Make sure we don't exceed the work buffer */ + + aetBuffer = getBuffer + (workBuffer[12]); + if ((((128 + (workBuffer[9])) + (workBuffer[12])) + (workBuffer[14])) > (workBuffer[1])) { + return 0; + } + return 1; +} + +static int magicNumberGet(void) { + return workBuffer[0]; +} + +static int magicNumberPut(int value) { + return workBuffer[0] = value; +} + +static int makeRectFromPoints(void) { + (((int *) (workBuffer + 82)))[0] = ((((int *) (workBuffer + 84)))[0]); + (((int *) (workBuffer + 82)))[1] = ((((int *) (workBuffer + 80)))[1]); + (((int *) (workBuffer + 86)))[0] = ((((int *) (workBuffer + 80)))[0]); + (((int *) (workBuffer + 86)))[1] = ((((int *) (workBuffer + 84)))[1]); +} + +static int makeUnsignedFrom(int someIntegerValue) { + return someIntegerValue; +} + + +/* The module with the given name was just unloaded. + Make sure we have no dangling references. */ + +EXPORT(int) moduleUnloaded(char * aModuleName) { + if ((strcmp(aModuleName, bbPluginName)) == 0) { + loadBBFn = 0; + copyBitsFn = 0; + } +} + + +/* The entry at index is not in the right position of the AET. + Move it to the left until the position is okay. */ + +static int moveAETEntryFromedgex(int index, int edge, int xValue) { + int newIndex; + + newIndex = index; + while ((newIndex > 0) && ((objBuffer[(aetBuffer[newIndex - 1]) + 4]) > xValue)) { + aetBuffer[newIndex] = (aetBuffer[newIndex - 1]); + newIndex -= 1; + } + aetBuffer[newIndex] = edge; +} + +static int msg(char *s) { + fprintf(stderr, "\n%s: %s", moduleName, s); +} + + +/* Check if we have n slots available */ + +static int needAvailableSpace(int nSlots) { + if (((((128 + objUsed) + (workBuffer[12])) + (workBuffer[14])) + nSlots) > (workBuffer[10])) { + /* begin stopBecauseOf: */ + workBuffer[64] = 1; + engineStopped = 1; + return 0; + } + return 1; +} + +static int needsFlush(void) { + return (workBuffer[63]) != 0; +} + +static int needsFlushGet(void) { + return workBuffer[63]; +} + +static int needsFlushPut(int value) { + return workBuffer[63] = value; +} + +static int objat(int object, int index) { + return objBuffer[object + index]; +} + +static int objatput(int object, int index, int value) { + return objBuffer[object + index] = value; +} + +static int objStartGet(void) { + return workBuffer[8]; +} + +static int objStartPut(int value) { + return workBuffer[8] = value; +} + +static int objUsedGet(void) { + return workBuffer[9]; +} + +static int objUsedPut(int value) { + return workBuffer[9] = value; +} + +static int objectHeaderOf(int obj) { + return objBuffer[obj + 0]; +} + +static int objectIndexOf(int obj) { + return objBuffer[obj + 2]; +} + +static int objectIndexOfput(int obj, int value) { + return objBuffer[obj + 2] = value; +} + +static int objectLengthOf(int obj) { + return objBuffer[obj + 1]; +} + +static int objectLengthOfput(int obj, int value) { + return objBuffer[obj + 1] = value; +} + +static int objectTypeOf(int obj) { + return (objBuffer[obj + 0]) & 65535; +} + +static int objectTypeOfput(int obj, int value) { + return objBuffer[obj + 0] = value; +} + + +/* Common function so that we don't compute that wrong in any place + and can easily find all the places where we deal with one-pixel offsets. */ + +static int offsetFromWidth(int lineWidth) { + return ((int) lineWidth >> 1); +} + +static int * point1Get(void) { + return ((int *) (workBuffer + 80)); +} + +static int * point2Get(void) { + return ((int *) (workBuffer + 82)); +} + +static int * point3Get(void) { + return ((int *) (workBuffer + 84)); +} + +static int * point4Get(void) { + return ((int *) (workBuffer + 86)); +} + + +/* We have just blitted a scan line to the screen. + Do whatever seems to be a good idea here. */ +/* Note: In the future we may check the time needed for this scan line and interrupt processing to give the Smalltalk code a chance to run at a certain time. */ + +static int postDisplayAction(void) { + if (((workBuffer[11]) >= (workBuffer[12])) && ((workBuffer[14]) == 0)) { + workBuffer[2] = 8; + } + if ((workBuffer[88]) >= (workBuffer[39])) { + workBuffer[2] = 8; + } +} + +EXPORT(int) primitiveAbortProcessing(void) { + if (!((interpreterProxy->methodArgumentCount()) == 0)) { + return interpreterProxy->primitiveFail(); + } + engine = interpreterProxy->stackObjectValue(0); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFrom(engine))) { + return interpreterProxy->primitiveFail(); + } + workBuffer[2] = 8; + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; +} + + +/* Note: No need to load either bitBlt or spanBuffer */ + +EXPORT(int) primitiveAddActiveEdgeEntry(void) { + int edge; + int edgeOop; + int value; + + if (doProfileStats) { + geProfileTime = interpreterProxy->ioMicroMSecs(); + } + if (!((interpreterProxy->methodArgumentCount()) == 1)) { + return interpreterProxy->primitiveFail(); + } + edgeOop = interpreterProxy->stackObjectValue(0); + engine = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredState(engine, 2))) { + return interpreterProxy->primitiveFail(); + } + edge = loadEdgeStateFrom(edgeOop); + if (interpreterProxy->failed()) { + return null; + } + if (!(needAvailableSpace(1))) { + return interpreterProxy->primitiveFail(); + } + if ((objBuffer[edge + 7]) > 0) { + insertEdgeIntoAET(edge); + } + if (engineStopped) { + return interpreterProxy->primitiveFail(); + } + workBuffer[2] = 1; + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(1); + if (doProfileStats) { + workBuffer[97] = ((workBuffer[97]) + 1); + /* begin incrementStat:by: */ + value = (interpreterProxy->ioMicroMSecs()) - geProfileTime; + workBuffer[96] = ((workBuffer[96]) + value); + } +} + +EXPORT(int) primitiveAddBezier(void) { + int endOop; + int leftFill; + int viaOop; + int startOop; + int rightFill; + int nSegments; + + if (!((interpreterProxy->methodArgumentCount()) == 5)) { + return interpreterProxy->primitiveFail(); + } + rightFill = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(0)); + leftFill = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(1)); + viaOop = interpreterProxy->stackObjectValue(2); + endOop = interpreterProxy->stackObjectValue(3); + startOop = interpreterProxy->stackObjectValue(4); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredState(interpreterProxy->stackObjectValue(5), 0))) { + return interpreterProxy->primitiveFail(); + } + if (!((isFillOkay(leftFill)) && (isFillOkay(rightFill)))) { + return interpreterProxy->primitiveFail(); + } + if ((leftFill == rightFill) && 0) { + return interpreterProxy->pop(6); + } + loadPointfrom(((int *) (workBuffer + 80)), startOop); + loadPointfrom(((int *) (workBuffer + 82)), viaOop); + loadPointfrom(((int *) (workBuffer + 84)), endOop); + if (interpreterProxy->failed()) { + return 0; + } + /* begin transformPoints: */ + if (3 > 0) { + transformPoint(((int *) (workBuffer + 80))); + } + if (3 > 1) { + transformPoint(((int *) (workBuffer + 82))); + } + if (3 > 2) { + transformPoint(((int *) (workBuffer + 84))); + } + if (3 > 3) { + transformPoint(((int *) (workBuffer + 86))); + } + nSegments = loadAndSubdivideBezierFromviatoisWide(((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), ((int *) (workBuffer + 84)), 0); + /* begin needAvailableSpace: */ + if (((((128 + objUsed) + (workBuffer[12])) + (workBuffer[14])) + (nSegments * 16)) > (workBuffer[10])) { + /* begin stopBecauseOf: */ + workBuffer[64] = 1; + engineStopped = 1; + goto l1; + } +l1: /* end needAvailableSpace: */; + if (!(engineStopped)) { + leftFill = transformColor(leftFill); + rightFill = transformColor(rightFill); + } + if (!(engineStopped)) { + loadWideBezierlineFillleftFillrightFilln(0, 0, leftFill, rightFill, nSegments); + } + if (engineStopped) { + /* begin wbStackClear */ + workBuffer[10] = (workBuffer[1]); + return interpreterProxy->primitiveFail(); + } + if (!(interpreterProxy->failed())) { + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(5); + } +} + +EXPORT(int) primitiveAddBezierShape(void) { + int points; + int length; + int lineWidth; + int lineFill; + int isArray; + int fillIndex; + int segSize; + int nSegments; + + if (!((interpreterProxy->methodArgumentCount()) == 5)) { + return interpreterProxy->primitiveFail(); + } + lineFill = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(0)); + lineWidth = interpreterProxy->stackIntegerValue(1); + fillIndex = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(2)); + nSegments = interpreterProxy->stackIntegerValue(3); + points = interpreterProxy->stackObjectValue(4); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredState(interpreterProxy->stackObjectValue(5), 0))) { + return interpreterProxy->primitiveFail(); + } + length = interpreterProxy->slotSizeOf(points); + if (interpreterProxy->isWords(points)) { + + /* Either PointArray or ShortPointArray */ + + isArray = 0; + if (!((length == (nSegments * 3)) || (length == (nSegments * 6)))) { + return interpreterProxy->primitiveFail(); + } + } else { + if (!((interpreterProxy->fetchClassOf(points)) == (interpreterProxy->classArray()))) { + return interpreterProxy->primitiveFail(); + } + if (!(length == (nSegments * 3))) { + return interpreterProxy->primitiveFail(); + } + isArray = 1; + } + if ((lineWidth == 0) || (lineFill == 0)) { + segSize = 16; + } else { + segSize = 21; + } + if (!(needAvailableSpace(segSize * nSegments))) { + return interpreterProxy->primitiveFail(); + } + if (!((isFillOkay(lineFill)) && (isFillOkay(fillIndex)))) { + return interpreterProxy->primitiveFail(); + } + lineFill = transformColor(lineFill); + fillIndex = transformColor(fillIndex); + if (engineStopped) { + return interpreterProxy->primitiveFail(); + } + if (((lineFill == 0) || (lineWidth == 0)) && (fillIndex == 0)) { + return interpreterProxy->pop(5); + } + if (!(lineWidth == 0)) { + lineWidth = transformWidth(lineWidth); + if (lineWidth < 1) { + lineWidth = 1; + } + } + if (isArray) { + loadArrayShapenSegmentsfilllineWidthlineFill(points, nSegments, fillIndex, lineWidth, lineFill); + } else { + loadShapenSegmentsfilllineWidthlineFillpointsShort(interpreterProxy->firstIndexableField(points), nSegments, fillIndex, lineWidth, lineFill, (nSegments * 3) == length); + } + if (engineStopped) { + return interpreterProxy->primitiveFail(); + } + if (!(interpreterProxy->failed())) { + workBuffer[63] = 1; + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(5); + } +} + +EXPORT(int) primitiveAddBitmapFill(void) { + int tileFlag; + int formOop; + int xIndex; + int nrmOop; + int fill; + int cmOop; + int originOop; + int dirOop; + + if (!((interpreterProxy->methodArgumentCount()) == 7)) { + return interpreterProxy->primitiveFail(); + } + xIndex = interpreterProxy->stackIntegerValue(0); + if (xIndex <= 0) { + return interpreterProxy->primitiveFail(); + } + 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; + } + if (!(quickLoadEngineFromrequiredState(interpreterProxy->stackObjectValue(7), 0))) { + return interpreterProxy->primitiveFail(); + } + loadPointfrom(((int *) (workBuffer + 80)), originOop); + loadPointfrom(((int *) (workBuffer + 82)), dirOop); + loadPointfrom(((int *) (workBuffer + 84)), nrmOop); + if (interpreterProxy->failed()) { + return 0; + } + fill = loadBitmapFillcolormaptilefromalongnormalxIndex(formOop, cmOop, tileFlag, ((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), ((int *) (workBuffer + 84)), xIndex - 1); + if (engineStopped) { + return interpreterProxy->primitiveFail(); + } + if (!(interpreterProxy->failed())) { + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(8); + interpreterProxy->push(interpreterProxy->positive32BitIntegerFor(fill)); + } +} + +EXPORT(int) primitiveAddCompressedShape(void) { + int lineWidths; + int leftFills; + int points; + int lineFills; + int fillIndexList; + int pointsShort; + int rightFills; + int nSegments; + + if (!((interpreterProxy->methodArgumentCount()) == 7)) { + return interpreterProxy->primitiveFail(); + } + fillIndexList = interpreterProxy->stackObjectValue(0); + lineFills = interpreterProxy->stackObjectValue(1); + lineWidths = interpreterProxy->stackObjectValue(2); + rightFills = interpreterProxy->stackObjectValue(3); + leftFills = interpreterProxy->stackObjectValue(4); + nSegments = interpreterProxy->stackIntegerValue(5); + points = interpreterProxy->stackObjectValue(6); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredState(interpreterProxy->stackObjectValue(7), 0))) { + return interpreterProxy->primitiveFail(); + } + if (!(checkCompressedShapesegmentsleftFillsrightFillslineWidthslineFillsfillIndexList(points, nSegments, leftFills, rightFills, lineWidths, lineFills, fillIndexList))) { + return interpreterProxy->primitiveFail(); + } + if (!(needAvailableSpace((((16 < 16) ? 16 : 16)) * nSegments))) { + return interpreterProxy->primitiveFail(); + } + + /* Then actually load the compressed shape */ + + 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(); + } + if (!(interpreterProxy->failed())) { + workBuffer[63] = 1; + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(7); + } +} + +EXPORT(int) primitiveAddGradientFill(void) { + int rampOop; + int nrmOop; + int fill; + int isRadial; + int originOop; + int dirOop; + + if (!((interpreterProxy->methodArgumentCount()) == 5)) { + return interpreterProxy->primitiveFail(); + } + isRadial = interpreterProxy->booleanValueOf(interpreterProxy->stackValue(0)); + nrmOop = interpreterProxy->stackValue(1); + dirOop = interpreterProxy->stackValue(2); + originOop = interpreterProxy->stackValue(3); + rampOop = interpreterProxy->stackValue(4); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredState(interpreterProxy->stackObjectValue(5), 0))) { + return interpreterProxy->primitiveFail(); + } + loadPointfrom(((int *) (workBuffer + 80)), originOop); + loadPointfrom(((int *) (workBuffer + 82)), dirOop); + loadPointfrom(((int *) (workBuffer + 84)), nrmOop); + if (interpreterProxy->failed()) { + return 0; + } + fill = loadGradientFillfromalongnormalisRadial(rampOop, ((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), ((int *) (workBuffer + 84)), isRadial); + if (engineStopped) { + return interpreterProxy->primitiveFail(); + } + if (!(interpreterProxy->failed())) { + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(6); + interpreterProxy->push(interpreterProxy->positive32BitIntegerFor(fill)); + } +} + +EXPORT(int) primitiveAddLine(void) { + int endOop; + int leftFill; + int startOop; + int rightFill; + + if (!((interpreterProxy->methodArgumentCount()) == 4)) { + return interpreterProxy->primitiveFail(); + } + 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; + } + if (!(quickLoadEngineFromrequiredState(interpreterProxy->stackObjectValue(4), 0))) { + return interpreterProxy->primitiveFail(); + } + if (!((isFillOkay(leftFill)) && (isFillOkay(rightFill)))) { + return interpreterProxy->primitiveFail(); + } + loadPointfrom(((int *) (workBuffer + 80)), startOop); + loadPointfrom(((int *) (workBuffer + 82)), endOop); + if (interpreterProxy->failed()) { + return 0; + } + /* begin transformPoints: */ + if (2 > 0) { + transformPoint(((int *) (workBuffer + 80))); + } + if (2 > 1) { + transformPoint(((int *) (workBuffer + 82))); + } + if (2 > 2) { + transformPoint(((int *) (workBuffer + 84))); + } + if (2 > 3) { + transformPoint(((int *) (workBuffer + 86))); + } + leftFill = transformColor(leftFill); + rightFill = transformColor(rightFill); + if (engineStopped) { + return interpreterProxy->primitiveFail(); + } + loadWideLinefromtolineFillleftFillrightFill(0, ((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), 0, leftFill, rightFill); + if (engineStopped) { + return interpreterProxy->primitiveFail(); + } + if (!(interpreterProxy->failed())) { + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(4); + } +} + +EXPORT(int) primitiveAddOval(void) { + int endOop; + int borderWidth; + int borderIndex; + int startOop; + int fillIndex; + + if (!((interpreterProxy->methodArgumentCount()) == 5)) { + return interpreterProxy->primitiveFail(); + } + borderIndex = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(0)); + borderWidth = interpreterProxy->stackIntegerValue(1); + fillIndex = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(2)); + endOop = interpreterProxy->stackObjectValue(3); + startOop = interpreterProxy->stackObjectValue(4); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredState(interpreterProxy->stackObjectValue(5), 0))) { + return interpreterProxy->primitiveFail(); + } + if (!((isFillOkay(borderIndex)) && (isFillOkay(fillIndex)))) { + return interpreterProxy->primitiveFail(); + } + fillIndex = transformColor(fillIndex); + borderIndex = transformColor(borderIndex); + if (engineStopped) { + return interpreterProxy->primitiveFail(); + } + if ((fillIndex == 0) && ((borderIndex == 0) || (borderWidth <= 0))) { + return interpreterProxy->pop(5); + } + if (!(needAvailableSpace(16 * 16))) { + return interpreterProxy->primitiveFail(); + } + if ((borderWidth > 0) && (borderIndex != 0)) { + borderWidth = transformWidth(borderWidth); + } else { + borderWidth = 0; + } + loadPointfrom(((int *) (workBuffer + 80)), startOop); + loadPointfrom(((int *) (workBuffer + 82)), endOop); + if (interpreterProxy->failed()) { + return 0; + } + loadOvallineFillleftFillrightFill(borderWidth, borderIndex, 0, fillIndex); + if (engineStopped) { + /* begin wbStackClear */ + workBuffer[10] = (workBuffer[1]); + return interpreterProxy->primitiveFail(); + } + if (!(interpreterProxy->failed())) { + workBuffer[63] = 1; + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(5); + } +} + +EXPORT(int) primitiveAddPolygon(void) { + int points; + int length; + int lineWidth; + int lineFill; + int nPoints; + int fillIndex; + int isArray; + int segSize; + int x0; + int x1; + int i; + int y0; + int y1; + + if (!((interpreterProxy->methodArgumentCount()) == 5)) { + return interpreterProxy->primitiveFail(); + } + lineFill = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(0)); + lineWidth = interpreterProxy->stackIntegerValue(1); + fillIndex = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(2)); + nPoints = interpreterProxy->stackIntegerValue(3); + points = interpreterProxy->stackObjectValue(4); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredState(interpreterProxy->stackObjectValue(5), 0))) { + return interpreterProxy->primitiveFail(); + } + length = interpreterProxy->slotSizeOf(points); + if (interpreterProxy->isWords(points)) { + + /* Either PointArray or ShortPointArray */ + + isArray = 0; + if (!((length == nPoints) || ((nPoints * 2) == length))) { + return interpreterProxy->primitiveFail(); + } + } else { + if (!((interpreterProxy->fetchClassOf(points)) == (interpreterProxy->classArray()))) { + return interpreterProxy->primitiveFail(); + } + if (!(length == nPoints)) { + return interpreterProxy->primitiveFail(); + } + isArray = 1; + } + if ((lineWidth == 0) || (lineFill == 0)) { + segSize = 16; + } else { + segSize = 21; + } + if (!(needAvailableSpace(segSize * nPoints))) { + return interpreterProxy->primitiveFail(); + } + if (!((isFillOkay(lineFill)) && (isFillOkay(fillIndex)))) { + return interpreterProxy->primitiveFail(); + } + lineFill = transformColor(lineFill); + fillIndex = transformColor(fillIndex); + if (engineStopped) { + return interpreterProxy->primitiveFail(); + } + if (((lineFill == 0) || (lineWidth == 0)) && (fillIndex == 0)) { + return interpreterProxy->pop(6); + } + if (!(lineWidth == 0)) { + lineWidth = transformWidth(lineWidth); + } + if (isArray) { + /* begin loadArrayPolygon:nPoints:fill:lineWidth:lineFill: */ + loadPointfrom(((int *) (workBuffer + 80)), interpreterProxy->fetchPointerofObject(0, points)); + if (interpreterProxy->failed()) { + goto l1; + } + x0 = (((int *) (workBuffer + 80)))[0]; + y0 = (((int *) (workBuffer + 80)))[1]; + for (i = 1; i <= (nPoints - 1); i += 1) { + loadPointfrom(((int *) (workBuffer + 80)), interpreterProxy->fetchPointerofObject(i, points)); + if (interpreterProxy->failed()) { + goto l1; + } + x1 = (((int *) (workBuffer + 80)))[0]; + y1 = (((int *) (workBuffer + 80)))[1]; + (((int *) (workBuffer + 80)))[0] = x0; + (((int *) (workBuffer + 80)))[1] = y0; + (((int *) (workBuffer + 82)))[0] = x1; + (((int *) (workBuffer + 82)))[1] = y1; + /* begin transformPoints: */ + if (2 > 0) { + transformPoint(((int *) (workBuffer + 80))); + } + if (2 > 1) { + transformPoint(((int *) (workBuffer + 82))); + } + if (2 > 2) { + transformPoint(((int *) (workBuffer + 84))); + } + if (2 > 3) { + transformPoint(((int *) (workBuffer + 86))); + } + loadWideLinefromtolineFillleftFillrightFill(lineWidth, ((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), lineFill, fillIndex, 0); + if (engineStopped) { + goto l1; + } + x0 = x1; + y0 = y1; + } + l1: /* end loadArrayPolygon:nPoints:fill:lineWidth:lineFill: */; + } else { + loadPolygonnPointsfilllineWidthlineFillpointsShort(interpreterProxy->firstIndexableField(points), nPoints, fillIndex, lineWidth, lineFill, nPoints == length); + } + if (engineStopped) { + return interpreterProxy->primitiveFail(); + } + if (!(interpreterProxy->failed())) { + workBuffer[63] = 1; + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(5); + } +} + +EXPORT(int) primitiveAddRect(void) { + int endOop; + int borderWidth; + int borderIndex; + int startOop; + int fillIndex; + + if (!((interpreterProxy->methodArgumentCount()) == 5)) { + return interpreterProxy->primitiveFail(); + } + borderIndex = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(0)); + borderWidth = interpreterProxy->stackIntegerValue(1); + fillIndex = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(2)); + endOop = interpreterProxy->stackObjectValue(3); + startOop = interpreterProxy->stackObjectValue(4); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredState(interpreterProxy->stackObjectValue(5), 0))) { + return interpreterProxy->primitiveFail(); + } + if (!((isFillOkay(borderIndex)) && (isFillOkay(fillIndex)))) { + return interpreterProxy->primitiveFail(); + } + borderIndex = transformColor(borderIndex); + fillIndex = transformColor(fillIndex); + if (engineStopped) { + return interpreterProxy->primitiveFail(); + } + if ((fillIndex == 0) && ((borderIndex == 0) || (borderWidth == 0))) { + return interpreterProxy->pop(5); + } + if (!(needAvailableSpace(4 * 16))) { + return interpreterProxy->primitiveFail(); + } + if ((borderWidth > 0) && (borderIndex != 0)) { + borderWidth = transformWidth(borderWidth); + } else { + borderWidth = 0; + } + loadPointfrom(((int *) (workBuffer + 80)), startOop); + loadPointfrom(((int *) (workBuffer + 84)), endOop); + if (interpreterProxy->failed()) { + return null; + } + (((int *) (workBuffer + 82)))[0] = ((((int *) (workBuffer + 84)))[0]); + (((int *) (workBuffer + 82)))[1] = ((((int *) (workBuffer + 80)))[1]); + (((int *) (workBuffer + 86)))[0] = ((((int *) (workBuffer + 80)))[0]); + (((int *) (workBuffer + 86)))[1] = ((((int *) (workBuffer + 84)))[1]); + /* begin transformPoints: */ + if (4 > 0) { + transformPoint(((int *) (workBuffer + 80))); + } + if (4 > 1) { + transformPoint(((int *) (workBuffer + 82))); + } + if (4 > 2) { + transformPoint(((int *) (workBuffer + 84))); + } + if (4 > 3) { + transformPoint(((int *) (workBuffer + 86))); + } + /* begin loadRectangle:lineFill:leftFill:rightFill: */ + loadWideLinefromtolineFillleftFillrightFill(borderWidth, ((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), borderIndex, 0, fillIndex); + loadWideLinefromtolineFillleftFillrightFill(borderWidth, ((int *) (workBuffer + 82)), ((int *) (workBuffer + 84)), borderIndex, 0, fillIndex); + loadWideLinefromtolineFillleftFillrightFill(borderWidth, ((int *) (workBuffer + 84)), ((int *) (workBuffer + 86)), borderIndex, 0, fillIndex); + loadWideLinefromtolineFillleftFillrightFill(borderWidth, ((int *) (workBuffer + 86)), ((int *) (workBuffer + 80)), borderIndex, 0, fillIndex); + if (!(interpreterProxy->failed())) { + workBuffer[63] = 1; + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(5); + } +} + + +/* Note: No need to load either bitBlt or spanBuffer */ + +EXPORT(int) primitiveChangedActiveEdgeEntry(void) { + int edge; + int edgeOop; + int value; + + if (doProfileStats) { + geProfileTime = interpreterProxy->ioMicroMSecs(); + } + if (!((interpreterProxy->methodArgumentCount()) == 1)) { + return interpreterProxy->primitiveFail(); + } + edgeOop = interpreterProxy->stackObjectValue(0); + engine = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredState(engine, 7))) { + return interpreterProxy->primitiveFail(); + } + edge = loadEdgeStateFrom(edgeOop); + if (interpreterProxy->failed()) { + return null; + } + if ((objBuffer[edge + 7]) == 0) { + removeFirstAETEntry(); + } else { + resortFirstAETEntry(); + workBuffer[13] = ((workBuffer[13]) + 1); + } + workBuffer[2] = 6; + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(1); + if (doProfileStats) { + workBuffer[107] = ((workBuffer[107]) + 1); + /* begin incrementStat:by: */ + value = (interpreterProxy->ioMicroMSecs()) - geProfileTime; + workBuffer[106] = ((workBuffer[106]) + value); + } +} + +EXPORT(int) primitiveCopyBuffer(void) { + int diff; + int buf1; + int buf2; + int * src; + int * dst; + int i; + + if (!((interpreterProxy->methodArgumentCount()) == 2)) { + return interpreterProxy->primitiveFail(); + } + buf2 = interpreterProxy->stackObjectValue(0); + buf1 = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + if (!(loadWorkBufferFrom(buf1))) { + return interpreterProxy->primitiveFail(); + } + if (!((interpreterProxy->fetchClassOf(buf1)) == (interpreterProxy->fetchClassOf(buf2)))) { + return interpreterProxy->primitiveFail(); + } + diff = (interpreterProxy->slotSizeOf(buf2)) - (interpreterProxy->slotSizeOf(buf1)); + if (diff < 0) { + return interpreterProxy->primitiveFail(); + } + src = workBuffer; + dst = interpreterProxy->firstIndexableField(buf2); + for (i = 0; i <= ((workBuffer[10]) - 1); i += 1) { + dst[i] = (src[i]); + } + dst[10] = ((workBuffer[10]) + diff); + dst[1] = ((workBuffer[1]) + diff); + src += workBuffer[10]; + dst = (dst + (workBuffer[10])) + diff; + for (i = 0; i <= (((workBuffer[1]) - (workBuffer[10])) - 1); i += 1) { + dst[i] = (src[i]); + } + if (!(loadWorkBufferFrom(buf2))) { + return interpreterProxy->primitiveFail(); + } + interpreterProxy->pop(2); +} + + +/* Note: Must load bitBlt and spanBuffer */ + +EXPORT(int) primitiveDisplaySpanBuffer(void) { + int value; + + if (doProfileStats) { + geProfileTime = interpreterProxy->ioMicroMSecs(); + } + if (!((interpreterProxy->methodArgumentCount()) == 0)) { + return interpreterProxy->primitiveFail(); + } + engine = interpreterProxy->stackObjectValue(0); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredState(engine, 5))) { + return interpreterProxy->primitiveFail(); + } + if (!(loadSpanBufferFrom(interpreterProxy->fetchPointerofObject(1, engine)))) { + return interpreterProxy->primitiveFail(); + } + if (!(loadBitBltFrom(interpreterProxy->fetchPointerofObject(2, engine)))) { + return interpreterProxy->primitiveFail(); + } + if (((workBuffer[88]) & (workBuffer[52])) == (workBuffer[52])) { + displaySpanBufferAt(workBuffer[88]); + postDisplayAction(); + } + if (!((workBuffer[2]) == 8)) { + workBuffer[13] = 0; + workBuffer[88] = ((workBuffer[88]) + 1); + workBuffer[2] = 6; + } + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + if (doProfileStats) { + workBuffer[103] = ((workBuffer[103]) + 1); + /* begin incrementStat:by: */ + value = (interpreterProxy->ioMicroMSecs()) - geProfileTime; + workBuffer[102] = ((workBuffer[102]) + value); + } +} + + +/* Turn on/off profiling. Return the old value of the flag. */ + +EXPORT(int) primitiveDoProfileStats(void) { + int oldValue; + int newValue; + + oldValue = doProfileStats; + newValue = interpreterProxy->stackObjectValue(0); + newValue = interpreterProxy->booleanValueOf(newValue); + if (!(interpreterProxy->failed())) { + doProfileStats = newValue; + interpreterProxy->pop(2); + interpreterProxy->pushBool(oldValue); + } +} + +EXPORT(int) primitiveFinishedProcessing(void) { + int finished; + int value; + + if (doProfileStats) { + geProfileTime = interpreterProxy->ioMicroMSecs(); + } + if (!((interpreterProxy->methodArgumentCount()) == 0)) { + return interpreterProxy->primitiveFail(); + } + engine = interpreterProxy->stackObjectValue(0); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFrom(engine))) { + return interpreterProxy->primitiveFail(); + } + finished = (workBuffer[2]) == 8; + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(1); + interpreterProxy->pushBool(finished); + if (doProfileStats) { + workBuffer[93] = ((workBuffer[93]) + 1); + /* begin incrementStat:by: */ + value = (interpreterProxy->ioMicroMSecs()) - geProfileTime; + workBuffer[92] = ((workBuffer[92]) + value); + } +} + +EXPORT(int) primitiveGetAALevel(void) { + if (!((interpreterProxy->methodArgumentCount()) == 0)) { + return interpreterProxy->primitiveFail(); + } + engine = interpreterProxy->stackObjectValue(0); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFrom(engine))) { + return interpreterProxy->primitiveFail(); + } + interpreterProxy->pop(1); + interpreterProxy->pushInteger(workBuffer[48]); +} + +EXPORT(int) primitiveGetBezierStats(void) { + int *stats; + int statOop; + + if (!((interpreterProxy->methodArgumentCount()) == 1)) { + return interpreterProxy->primitiveFail(); + } + statOop = interpreterProxy->stackObjectValue(0); + engine = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + 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[108])); + stats[1] = ((stats[1]) + (workBuffer[109])); + stats[2] = ((stats[2]) + (workBuffer[110])); + stats[3] = ((stats[3]) + (workBuffer[111])); + interpreterProxy->pop(1); +} + +EXPORT(int) primitiveGetClipRect(void) { + int pointOop; + int rectOop; + + if (!((interpreterProxy->methodArgumentCount()) == 1)) { + return interpreterProxy->primitiveFail(); + } + rectOop = interpreterProxy->stackObjectValue(0); + engine = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + 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[42], workBuffer[44]); + rectOop = interpreterProxy->popRemappableOop(); + interpreterProxy->storePointerofObjectwithValue(0, rectOop, pointOop); + interpreterProxy->pushRemappableOop(rectOop); + pointOop = interpreterProxy->makePointwithxValueyValue(workBuffer[43], workBuffer[45]); + rectOop = interpreterProxy->popRemappableOop(); + interpreterProxy->storePointerofObjectwithValue(1, rectOop, pointOop); + interpreterProxy->pop(2); + interpreterProxy->push(rectOop); +} + +EXPORT(int) primitiveGetCounts(void) { + int *stats; + int statOop; + + if (!((interpreterProxy->methodArgumentCount()) == 1)) { + return interpreterProxy->primitiveFail(); + } + statOop = interpreterProxy->stackObjectValue(0); + engine = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + 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[91])); + stats[1] = ((stats[1]) + (workBuffer[93])); + stats[2] = ((stats[2]) + (workBuffer[95])); + stats[3] = ((stats[3]) + (workBuffer[97])); + stats[4] = ((stats[4]) + (workBuffer[99])); + stats[5] = ((stats[5]) + (workBuffer[101])); + stats[6] = ((stats[6]) + (workBuffer[103])); + stats[7] = ((stats[7]) + (workBuffer[105])); + stats[8] = ((stats[8]) + (workBuffer[107])); + interpreterProxy->pop(1); +} + +EXPORT(int) primitiveGetDepth(void) { + if (!((interpreterProxy->methodArgumentCount()) == 0)) { + return interpreterProxy->primitiveFail(); + } + engine = interpreterProxy->stackObjectValue(0); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFrom(engine))) { + return interpreterProxy->primitiveFail(); + } + interpreterProxy->pop(1); + interpreterProxy->pushInteger(workBuffer[113]); +} + + +/* Return the reason why the last operation failed. */ + +EXPORT(int) primitiveGetFailureReason(void) { + if (!((interpreterProxy->methodArgumentCount()) == 0)) { + return interpreterProxy->primitiveFail(); + } + engine = interpreterProxy->stackObjectValue(0); + if (interpreterProxy->failed()) { + return null; + } + if ((engine & 1)) { + return 0; + } + if (!(interpreterProxy->isPointers(engine))) { + return 0; + } + if ((interpreterProxy->slotSizeOf(engine)) < 12) { + return 0; + } + if (!(loadWorkBufferFrom(interpreterProxy->fetchPointerofObject(0, engine)))) { + return interpreterProxy->primitiveFail(); + } + interpreterProxy->pop(1); + interpreterProxy->pushInteger(workBuffer[64]); +} + +EXPORT(int) primitiveGetOffset(void) { + int pointOop; + + if (!((interpreterProxy->methodArgumentCount()) == 0)) { + return interpreterProxy->primitiveFail(); + } + engine = interpreterProxy->stackObjectValue(0); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFrom(engine))) { + return interpreterProxy->primitiveFail(); + } + pointOop = interpreterProxy->makePointwithxValueyValue(workBuffer[46], workBuffer[47]); + interpreterProxy->pop(1); + interpreterProxy->push(pointOop); +} + +EXPORT(int) primitiveGetTimes(void) { + int *stats; + int statOop; + + if (!((interpreterProxy->methodArgumentCount()) == 1)) { + return interpreterProxy->primitiveFail(); + } + statOop = interpreterProxy->stackObjectValue(0); + engine = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + 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[90])); + stats[1] = ((stats[1]) + (workBuffer[92])); + stats[2] = ((stats[2]) + (workBuffer[94])); + stats[3] = ((stats[3]) + (workBuffer[96])); + stats[4] = ((stats[4]) + (workBuffer[98])); + stats[5] = ((stats[5]) + (workBuffer[100])); + stats[6] = ((stats[6]) + (workBuffer[102])); + stats[7] = ((stats[7]) + (workBuffer[104])); + stats[8] = ((stats[8]) + (workBuffer[106])); + interpreterProxy->pop(1); +} + +EXPORT(int) primitiveInitializeBuffer(void) { + int size; + int wbOop; + + if (!((interpreterProxy->methodArgumentCount()) == 1)) { + return interpreterProxy->primitiveFail(); + } + wbOop = interpreterProxy->stackObjectValue(0); + if (interpreterProxy->failed()) { + return null; + } + if (!(interpreterProxy->isWords(wbOop))) { + return interpreterProxy->primitiveFail(); + } + if ((size = interpreterProxy->slotSizeOf(wbOop)) < 256) { + return interpreterProxy->primitiveFail(); + } + workBuffer = interpreterProxy->firstIndexableField(wbOop); + objBuffer = workBuffer + 128; + workBuffer[0] = 1097753705; + workBuffer[1] = size; + workBuffer[10] = size; + workBuffer[2] = 0; + workBuffer[8] = 128; + workBuffer[9] = 4; + objBuffer[0 + 0] = 256; + objBuffer[0 + 1] = 4; + objBuffer[0 + 2] = 0; + workBuffer[11] = 0; + workBuffer[12] = 0; + workBuffer[13] = 0; + workBuffer[14] = 0; + workBuffer[64] = 0; + workBuffer[63] = 0; + workBuffer[42] = 0; + workBuffer[43] = 0; + workBuffer[44] = 0; + workBuffer[45] = 0; + workBuffer[113] = 0; + resetGraphicsEngineStats(); + initEdgeTransform(); + initColorTransform(); + interpreterProxy->pop(2); + interpreterProxy->push(wbOop); +} + + +/* Note: No need to load bitBlt but must load spanBuffer */ + +EXPORT(int) primitiveInitializeProcessing(void) { + int value; + + if (doProfileStats) { + geProfileTime = interpreterProxy->ioMicroMSecs(); + } + if (!((interpreterProxy->methodArgumentCount()) == 0)) { + return interpreterProxy->primitiveFail(); + } + engine = interpreterProxy->stackObjectValue(0); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredState(engine, 0))) { + return interpreterProxy->primitiveFail(); + } + if (!(loadSpanBufferFrom(interpreterProxy->fetchPointerofObject(1, engine)))) { + return interpreterProxy->primitiveFail(); + } + initializeGETProcessing(); + if (engineStopped) { + return interpreterProxy->primitiveFail(); + } + workBuffer[2] = 1; + if (!(interpreterProxy->failed())) { + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + } + if (doProfileStats) { + workBuffer[91] = ((workBuffer[91]) + 1); + /* begin incrementStat:by: */ + value = (interpreterProxy->ioMicroMSecs()) - geProfileTime; + workBuffer[90] = ((workBuffer[90]) + value); + } +} + + +/* Note: No need to load bitBlt but must load spanBuffer */ + +EXPORT(int) primitiveMergeFillFrom(void) { + int bitsOop; + int value; + int fillOop; + int value1; + + if (doProfileStats) { + geProfileTime = interpreterProxy->ioMicroMSecs(); + } + if (!((interpreterProxy->methodArgumentCount()) == 2)) { + return interpreterProxy->primitiveFail(); + } + fillOop = interpreterProxy->stackObjectValue(0); + bitsOop = interpreterProxy->stackObjectValue(1); + engine = interpreterProxy->stackObjectValue(2); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredState(engine, 4))) { + return interpreterProxy->primitiveFail(); + } + if (!(loadSpanBufferFrom(interpreterProxy->fetchPointerofObject(1, engine)))) { + return interpreterProxy->primitiveFail(); + } + if (!((interpreterProxy->fetchClassOf(bitsOop)) == (interpreterProxy->classBitmap()))) { + return interpreterProxy->primitiveFail(); + } + if ((interpreterProxy->slotSizeOf(fillOop)) < 6) { + return interpreterProxy->primitiveFail(); + } + value = interpreterProxy->fetchIntegerofObject(0, fillOop); + if (!((objBuffer[(workBuffer[66]) + 2]) == value)) { + return interpreterProxy->primitiveFail(); + } + value = interpreterProxy->fetchIntegerofObject(1, fillOop); + if (!((workBuffer[67]) == value)) { + return interpreterProxy->primitiveFail(); + } + value = interpreterProxy->fetchIntegerofObject(2, fillOop); + if (!((workBuffer[68]) == value)) { + return interpreterProxy->primitiveFail(); + } + if ((interpreterProxy->slotSizeOf(bitsOop)) < ((workBuffer[68]) - (workBuffer[67]))) { + return interpreterProxy->primitiveFail(); + } + if (interpreterProxy->failed()) { + return null; + } + fillBitmapSpanfromto(interpreterProxy->firstIndexableField(bitsOop), workBuffer[67], workBuffer[68]); + workBuffer[2] = 3; + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(2); + if (doProfileStats) { + workBuffer[101] = ((workBuffer[101]) + 1); + /* begin incrementStat:by: */ + value1 = (interpreterProxy->ioMicroMSecs()) - geProfileTime; + workBuffer[100] = ((workBuffer[100]) + value1); + } +} + +EXPORT(int) primitiveNeedsFlush(void) { + int needFlush; + + if (!((interpreterProxy->methodArgumentCount()) == 0)) { + return interpreterProxy->primitiveFail(); + } + engine = interpreterProxy->stackObjectValue(0); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFrom(engine))) { + return interpreterProxy->primitiveFail(); + } + needFlush = (workBuffer[63]) != 0; + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(1); + interpreterProxy->pushBool(needFlush); +} + +EXPORT(int) primitiveNeedsFlushPut(void) { + int needFlush; + + if (!((interpreterProxy->methodArgumentCount()) == 1)) { + return interpreterProxy->primitiveFail(); + } + needFlush = interpreterProxy->stackObjectValue(0); + engine = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + needFlush = interpreterProxy->booleanValueOf(needFlush); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFrom(engine))) { + return interpreterProxy->primitiveFail(); + } + if (needFlush == 1) { + workBuffer[63] = 1; + } else { + workBuffer[63] = 0; + } + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(1); +} + + +/* Note: No need to load either bitBlt or spanBuffer */ + +EXPORT(int) primitiveNextActiveEdgeEntry(void) { + int edge; + int edgeOop; + int hasEdge; + int value; + + if (doProfileStats) { + geProfileTime = interpreterProxy->ioMicroMSecs(); + } + if (!((interpreterProxy->methodArgumentCount()) == 1)) { + return interpreterProxy->primitiveFail(); + } + edgeOop = interpreterProxy->stackObjectValue(0); + engine = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredStateor(engine, 6, 8))) { + return interpreterProxy->primitiveFail(); + } + hasEdge = 0; + if (!((workBuffer[2]) == 8)) { + hasEdge = findNextExternalUpdateFromAET(); + if (hasEdge) { + edge = aetBuffer[workBuffer[13]]; + storeEdgeStateFrominto(edge, edgeOop); + workBuffer[2] = 7; + } else { + workBuffer[2] = 1; + } + } + if (interpreterProxy->failed()) { + return null; + } + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(2); + interpreterProxy->pushBool(!hasEdge); + if (doProfileStats) { + workBuffer[105] = ((workBuffer[105]) + 1); + /* begin incrementStat:by: */ + value = (interpreterProxy->ioMicroMSecs()) - geProfileTime; + workBuffer[104] = ((workBuffer[104]) + value); + } +} + + +/* Note: No need to load bitBlt but must load spanBuffer */ + +EXPORT(int) primitiveNextFillEntry(void) { + int hasFill; + int fillOop; + int value; + + if (doProfileStats) { + geProfileTime = interpreterProxy->ioMicroMSecs(); + } + if (!((interpreterProxy->methodArgumentCount()) == 1)) { + return interpreterProxy->primitiveFail(); + } + fillOop = interpreterProxy->stackObjectValue(0); + engine = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredState(engine, 3))) { + return interpreterProxy->primitiveFail(); + } + if (!(loadSpanBufferFrom(interpreterProxy->fetchPointerofObject(1, engine)))) { + return interpreterProxy->primitiveFail(); + } + if (!(loadFormsFrom(interpreterProxy->fetchPointerofObject(3, engine)))) { + return interpreterProxy->primitiveFail(); + } + if (!((workBuffer[69]) == 0)) { + if (((workBuffer[88]) & (workBuffer[52])) == 0) { + clearSpanBuffer(); + } + workBuffer[69] = 0; + } + hasFill = findNextExternalFillFromAET(); + if (engineStopped) { + return interpreterProxy->primitiveFail(); + } + if (hasFill) { + storeFillStateInto(fillOop); + } + if (!(interpreterProxy->failed())) { + if (hasFill) { + workBuffer[2] = 4; + } else { + /* begin wbStackClear */ + workBuffer[10] = (workBuffer[1]); + workBuffer[35] = 0; + workBuffer[2] = 5; + } + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(2); + interpreterProxy->pushBool(!hasFill); + if (doProfileStats) { + workBuffer[99] = ((workBuffer[99]) + 1); + /* begin incrementStat:by: */ + value = (interpreterProxy->ioMicroMSecs()) - geProfileTime; + workBuffer[98] = ((workBuffer[98]) + value); + } + } +} + + +/* Note: No need to load either bitBlt or spanBuffer */ + +EXPORT(int) primitiveNextGlobalEdgeEntry(void) { + int edge; + int edgeOop; + int hasEdge; + int value; + + if (doProfileStats) { + geProfileTime = interpreterProxy->ioMicroMSecs(); + } + if (!((interpreterProxy->methodArgumentCount()) == 1)) { + return interpreterProxy->primitiveFail(); + } + edgeOop = interpreterProxy->stackObjectValue(0); + engine = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredState(engine, 1))) { + return interpreterProxy->primitiveFail(); + } + hasEdge = findNextExternalEntryFromGET(); + if (hasEdge) { + edge = getBuffer[workBuffer[11]]; + storeEdgeStateFrominto(edge, edgeOop); + workBuffer[11] = ((workBuffer[11]) + 1); + } + if (interpreterProxy->failed()) { + return null; + } + if (hasEdge) { + workBuffer[2] = 2; + } else { + workBuffer[2] = 3; + workBuffer[69] = 1; + workBuffer[13] = 0; + /* begin wbStackClear */ + workBuffer[10] = (workBuffer[1]); + } + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(2); + interpreterProxy->pushBool(!hasEdge); + if (doProfileStats) { + workBuffer[95] = ((workBuffer[95]) + 1); + /* begin incrementStat:by: */ + value = (interpreterProxy->ioMicroMSecs()) - geProfileTime; + workBuffer[94] = ((workBuffer[94]) + value); + } +} + +EXPORT(int) primitiveRegisterExternalEdge(void) { + int index; + int edge; + int rightFillIndex; + int initialY; + int initialX; + int leftFillIndex; + int initialZ; + int value; + int value1; + + if (!((interpreterProxy->methodArgumentCount()) == 6)) { + return interpreterProxy->primitiveFail(); + } + rightFillIndex = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(0)); + leftFillIndex = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(1)); + initialZ = interpreterProxy->stackIntegerValue(2); + initialY = interpreterProxy->stackIntegerValue(3); + initialX = interpreterProxy->stackIntegerValue(4); + index = interpreterProxy->stackIntegerValue(5); + engine = interpreterProxy->stackObjectValue(6); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredState(engine, 0))) { + return interpreterProxy->primitiveFail(); + } + if (!(allocateObjEntry(10))) { + return interpreterProxy->primitiveFail(); + } + if (!(isFillOkay(leftFillIndex))) { + return interpreterProxy->primitiveFail(); + } + if (!(isFillOkay(rightFillIndex))) { + return interpreterProxy->primitiveFail(); + } + edge = objUsed; + + /* Install type and length */ + + objUsed = edge + 10; + objBuffer[edge + 0] = 2; + objBuffer[edge + 1] = 10; + objBuffer[edge + 2] = index; + objBuffer[edge + 4] = initialX; + objBuffer[edge + 5] = initialY; + objBuffer[edge + 6] = initialZ; + /* begin edgeLeftFillOf:put: */ + value = transformColor(leftFillIndex); + objBuffer[edge + 8] = value; + /* begin edgeRightFillOf:put: */ + value1 = transformColor(rightFillIndex); + objBuffer[edge + 9] = value1; + if (engineStopped) { + return interpreterProxy->primitiveFail(); + } + if (!(interpreterProxy->failed())) { + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(6); + } +} + +EXPORT(int) primitiveRegisterExternalFill(void) { + int fill; + int index; + + if (!((interpreterProxy->methodArgumentCount()) == 1)) { + return interpreterProxy->primitiveFail(); + } + index = interpreterProxy->stackIntegerValue(0); + engine = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredState(engine, 0))) { + return interpreterProxy->primitiveFail(); + } + fill = 0; + while (fill == 0) { + if (!(allocateObjEntry(10))) { + return interpreterProxy->primitiveFail(); + } + fill = objUsed; + + /* Install type and length */ + + objUsed = fill + 4; + objBuffer[fill + 0] = 256; + objBuffer[fill + 1] = 4; + objBuffer[fill + 2] = index; + } + if (!(interpreterProxy->failed())) { + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(2); + interpreterProxy->pushInteger(fill); + } +} + + +/* Start/Proceed rendering the entire image */ + +EXPORT(int) primitiveRenderImage(void) { + if (!(loadRenderingState())) { + return interpreterProxy->primitiveFail(); + } + proceedRenderingScanline(); + if (engineStopped) { + return storeRenderingState(); + } + proceedRenderingImage(); + storeRenderingState(); +} + + +/* Start rendering the entire image */ + +EXPORT(int) primitiveRenderScanline(void) { + if (!(loadRenderingState())) { + return interpreterProxy->primitiveFail(); + } + proceedRenderingScanline(); + storeRenderingState(); +} + +EXPORT(int) primitiveSetAALevel(void) { + int level; + + if (!((interpreterProxy->methodArgumentCount()) == 1)) { + return interpreterProxy->primitiveFail(); + } + level = interpreterProxy->stackIntegerValue(0); + engine = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredState(engine, 0))) { + return interpreterProxy->primitiveFail(); + } + setAALevel(level); + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(1); +} + + +/* Primitive. Set the BitBlt plugin to use. */ + +EXPORT(int) primitiveSetBitBltPlugin(void) { + int length; + char *ptr; + int pluginName; + int i; + int needReload; + + + /* Must be string to work */ + + pluginName = interpreterProxy->stackValue(0); + if (!(interpreterProxy->isBytes(pluginName))) { + return interpreterProxy->primitiveFail(); + } + length = interpreterProxy->byteSizeOf(pluginName); + if (length >= 256) { + return interpreterProxy->primitiveFail(); + } + ptr = interpreterProxy->firstIndexableField(pluginName); + needReload = 0; + for (i = 0; i <= (length - 1); i += 1) { + if (!((bbPluginName[i]) == (ptr[i]))) { + bbPluginName[i] = (ptr[i]); + needReload = 1; + } + } + if (!((bbPluginName[length]) == 0)) { + bbPluginName[length] = 0; + needReload = 1; + } + if (needReload) { + if (!(initialiseModule())) { + return interpreterProxy->primitiveFail(); + } + } + interpreterProxy->pop(1); +} + +EXPORT(int) primitiveSetClipRect(void) { + int rectOop; + + if (!((interpreterProxy->methodArgumentCount()) == 1)) { + return interpreterProxy->primitiveFail(); + } + rectOop = interpreterProxy->stackObjectValue(0); + engine = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredState(engine, 0))) { + return interpreterProxy->primitiveFail(); + } + if (!(interpreterProxy->isPointers(rectOop))) { + return interpreterProxy->primitiveFail(); + } + if ((interpreterProxy->slotSizeOf(rectOop)) < 2) { + return interpreterProxy->primitiveFail(); + } + loadPointfrom(((int *) (workBuffer + 80)), interpreterProxy->fetchPointerofObject(0, rectOop)); + loadPointfrom(((int *) (workBuffer + 82)), interpreterProxy->fetchPointerofObject(1, rectOop)); + if (!(interpreterProxy->failed())) { + workBuffer[42] = ((((int *) (workBuffer + 80)))[0]); + workBuffer[44] = ((((int *) (workBuffer + 80)))[1]); + workBuffer[43] = ((((int *) (workBuffer + 82)))[0]); + workBuffer[45] = ((((int *) (workBuffer + 82)))[1]); + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(1); + } +} + +EXPORT(int) primitiveSetColorTransform(void) { + int transformOop; + + if (!((interpreterProxy->methodArgumentCount()) == 1)) { + return interpreterProxy->primitiveFail(); + } + transformOop = interpreterProxy->stackObjectValue(0); + engine = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredState(engine, 0))) { + return interpreterProxy->primitiveFail(); + } + loadColorTransformFrom(transformOop); + if (!(interpreterProxy->failed())) { + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(1); + } +} + +EXPORT(int) primitiveSetDepth(void) { + int depth; + + if (!((interpreterProxy->methodArgumentCount()) == 1)) { + return interpreterProxy->primitiveFail(); + } + depth = interpreterProxy->stackIntegerValue(0); + engine = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredState(engine, 0))) { + return interpreterProxy->primitiveFail(); + } + workBuffer[113] = depth; + if (!(interpreterProxy->failed())) { + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(1); + } +} + +EXPORT(int) primitiveSetEdgeTransform(void) { + int transformOop; + + if (!((interpreterProxy->methodArgumentCount()) == 1)) { + return interpreterProxy->primitiveFail(); + } + transformOop = interpreterProxy->stackObjectValue(0); + engine = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredState(engine, 0))) { + return interpreterProxy->primitiveFail(); + } + loadEdgeTransformFrom(transformOop); + if (!(interpreterProxy->failed())) { + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(1); + } +} + +EXPORT(int) primitiveSetOffset(void) { + int pointOop; + + if (!((interpreterProxy->methodArgumentCount()) == 1)) { + return interpreterProxy->primitiveFail(); + } + pointOop = interpreterProxy->stackObjectValue(0); + engine = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + if (!(quickLoadEngineFromrequiredState(engine, 0))) { + return interpreterProxy->primitiveFail(); + } + if (!((interpreterProxy->fetchClassOf(pointOop)) == (interpreterProxy->classPoint()))) { + return interpreterProxy->primitiveFail(); + } + loadPointfrom(((int *) (workBuffer + 80)), pointOop); + if (!(interpreterProxy->failed())) { + workBuffer[46] = ((((int *) (workBuffer + 80)))[0]); + workBuffer[47] = ((((int *) (workBuffer + 80)))[1]); + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(1); + } +} + + +/* This is the main rendering entry */ + +static int proceedRenderingImage(void) { + int external; + int value; + int value1; + int value2; + int value3; + + while (!((workBuffer[2]) == 8)) { + if (doProfileStats) { + geProfileTime = interpreterProxy->ioMicroMSecs(); + } + external = findNextExternalEntryFromGET(); + if (doProfileStats) { + workBuffer[95] = ((workBuffer[95]) + 1); + /* begin incrementStat:by: */ + value = (interpreterProxy->ioMicroMSecs()) - geProfileTime; + workBuffer[94] = ((workBuffer[94]) + value); + } + if (engineStopped) { + return workBuffer[2] = 1; + } + if (external) { + workBuffer[2] = 2; + /* begin stopBecauseOf: */ + workBuffer[64] = 4; + engineStopped = 1; + return null; + } + workBuffer[13] = 0; + /* begin wbStackClear */ + workBuffer[10] = (workBuffer[1]); + workBuffer[69] = 1; + if (doProfileStats) { + geProfileTime = interpreterProxy->ioMicroMSecs(); + } + if (((workBuffer[69]) != 0) && (((workBuffer[88]) & (workBuffer[52])) == 0)) { + clearSpanBuffer(); + } + workBuffer[69] = 0; + external = findNextExternalFillFromAET(); + if (doProfileStats) { + workBuffer[99] = ((workBuffer[99]) + 1); + /* begin incrementStat:by: */ + value1 = (interpreterProxy->ioMicroMSecs()) - geProfileTime; + workBuffer[98] = ((workBuffer[98]) + value1); + } + if (engineStopped) { + return workBuffer[2] = 3; + } + if (external) { + workBuffer[2] = 4; + /* begin stopBecauseOf: */ + workBuffer[64] = 5; + engineStopped = 1; + return null; + } + /* begin wbStackClear */ + workBuffer[10] = (workBuffer[1]); + workBuffer[35] = 0; + if (doProfileStats) { + geProfileTime = interpreterProxy->ioMicroMSecs(); + } + if (((workBuffer[88]) & (workBuffer[52])) == (workBuffer[52])) { + displaySpanBufferAt(workBuffer[88]); + postDisplayAction(); + } + if (doProfileStats) { + workBuffer[103] = ((workBuffer[103]) + 1); + /* begin incrementStat:by: */ + value2 = (interpreterProxy->ioMicroMSecs()) - geProfileTime; + workBuffer[102] = ((workBuffer[102]) + value2); + } + if (engineStopped) { + return workBuffer[2] = 5; + } + if ((workBuffer[2]) == 8) { + return 0; + } + workBuffer[13] = 0; + workBuffer[88] = ((workBuffer[88]) + 1); + if (doProfileStats) { + geProfileTime = interpreterProxy->ioMicroMSecs(); + } + external = findNextExternalUpdateFromAET(); + if (doProfileStats) { + workBuffer[105] = ((workBuffer[105]) + 1); + /* begin incrementStat:by: */ + value3 = (interpreterProxy->ioMicroMSecs()) - geProfileTime; + workBuffer[104] = ((workBuffer[104]) + value3); + } + if (engineStopped) { + return workBuffer[2] = 6; + } + if (external) { + workBuffer[2] = 7; + /* begin stopBecauseOf: */ + workBuffer[64] = 6; + engineStopped = 1; + return null; + } + } +} + + +/* Proceed rendering the current scan line. + This method may be called after some Smalltalk code has been executed inbetween. */ +/* This is the main rendering entry */ + +static int proceedRenderingScanline(void) { + int external; + int state; + int value; + int value1; + int value2; + int value3; + + state = workBuffer[2]; + if (state == 0) { + initializeGETProcessing(); + if (engineStopped) { + return 0; + } + state = 1; + } + if (state == 1) { + if (doProfileStats) { + geProfileTime = interpreterProxy->ioMicroMSecs(); + } + external = findNextExternalEntryFromGET(); + if (doProfileStats) { + workBuffer[95] = ((workBuffer[95]) + 1); + /* begin incrementStat:by: */ + value = (interpreterProxy->ioMicroMSecs()) - geProfileTime; + workBuffer[94] = ((workBuffer[94]) + value); + } + if (engineStopped) { + return workBuffer[2] = 1; + } + if (external) { + workBuffer[2] = 2; + /* begin stopBecauseOf: */ + workBuffer[64] = 4; + engineStopped = 1; + return null; + } + workBuffer[13] = 0; + /* begin wbStackClear */ + workBuffer[10] = (workBuffer[1]); + workBuffer[69] = 1; + state = 3; + } + if (state == 3) { + if (doProfileStats) { + geProfileTime = interpreterProxy->ioMicroMSecs(); + } + if (((workBuffer[69]) != 0) && (((workBuffer[88]) & (workBuffer[52])) == 0)) { + clearSpanBuffer(); + } + workBuffer[69] = 0; + external = findNextExternalFillFromAET(); + if (doProfileStats) { + workBuffer[99] = ((workBuffer[99]) + 1); + /* begin incrementStat:by: */ + value1 = (interpreterProxy->ioMicroMSecs()) - geProfileTime; + workBuffer[98] = ((workBuffer[98]) + value1); + } + if (engineStopped) { + return workBuffer[2] = 3; + } + if (external) { + workBuffer[2] = 4; + /* begin stopBecauseOf: */ + workBuffer[64] = 5; + engineStopped = 1; + return null; + } + state = 5; + /* begin wbStackClear */ + workBuffer[10] = (workBuffer[1]); + workBuffer[35] = 0; + } + if (state == 5) { + if (doProfileStats) { + geProfileTime = interpreterProxy->ioMicroMSecs(); + } + if (((workBuffer[88]) & (workBuffer[52])) == (workBuffer[52])) { + displaySpanBufferAt(workBuffer[88]); + postDisplayAction(); + } + if (doProfileStats) { + workBuffer[103] = ((workBuffer[103]) + 1); + /* begin incrementStat:by: */ + value2 = (interpreterProxy->ioMicroMSecs()) - geProfileTime; + workBuffer[102] = ((workBuffer[102]) + value2); + } + if (engineStopped) { + return workBuffer[2] = 5; + } + if ((workBuffer[2]) == 8) { + return 0; + } + state = 6; + workBuffer[13] = 0; + workBuffer[88] = ((workBuffer[88]) + 1); + } + if (state == 6) { + if (doProfileStats) { + geProfileTime = interpreterProxy->ioMicroMSecs(); + } + external = findNextExternalUpdateFromAET(); + if (doProfileStats) { + workBuffer[105] = ((workBuffer[105]) + 1); + /* begin incrementStat:by: */ + value3 = (interpreterProxy->ioMicroMSecs()) - geProfileTime; + workBuffer[104] = ((workBuffer[104]) + value3); + } + if (engineStopped) { + return workBuffer[2] = 6; + } + if (external) { + workBuffer[2] = 7; + /* begin stopBecauseOf: */ + workBuffer[64] = 6; + engineStopped = 1; + return null; + } + workBuffer[2] = 1; + } +} + + +/* Load the minimal required state from the engineOop, e.g., just the work buffer. */ + +static int quickLoadEngineFrom(int engineOop) { + if (interpreterProxy->failed()) { + return 0; + } + if ((engineOop & 1)) { + return 0; + } + if (!(interpreterProxy->isPointers(engineOop))) { + return 0; + } + if ((interpreterProxy->slotSizeOf(engineOop)) < 12) { + return 0; + } + engine = engineOop; + if (!(loadWorkBufferFrom(interpreterProxy->fetchPointerofObject(0, engineOop)))) { + return 0; + } + workBuffer[64] = 0; + objUsed = workBuffer[9]; + engineStopped = 0; + return 1; +} + +static int quickLoadEngineFromrequiredState(int oop, int requiredState) { + if (!(quickLoadEngineFrom(oop))) { + return 0; + } + if ((workBuffer[2]) == requiredState) { + return 1; + } + workBuffer[64] = 2; + return 0; +} + +static int quickLoadEngineFromrequiredStateor(int oop, int requiredState, int alternativeState) { + if (!(quickLoadEngineFrom(oop))) { + return 0; + } + if ((workBuffer[2]) == requiredState) { + return 1; + } + if ((workBuffer[2]) == alternativeState) { + return 1; + } + workBuffer[64] = 2; + return 0; +} + + +/* Remove any top fills if they have become invalid. */ + +static int quickRemoveInvalidFillsAt(int leftX) { + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + return null; + } + while ((topRightX()) <= leftX) { + hideFilldepth(topFill(), topDepth()); + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + return null; + } + } +} + + +/* Sort elements i through j of self to be nondescending according to + sortBlock. */ +/* Note: The original loop has been heavily re-written for C translation */ + +static int quickSortGlobalEdgeTablefromto(int *array, int i, int j) { + int before; + int k; + int l; + int di; + int ij; + int dj; + int n; + int tmp; + int tt; + int again; + int dij; + + if ((n = (j + 1) - i) <= 1) { + return 0; + } + di = array[i]; + dj = array[j]; + + /* i.e., should di precede dj? */ + + before = getSortsbefore(di, dj); + if (!(before)) { + tmp = array[i]; + array[i] = (array[j]); + array[j] = tmp; + tt = di; + di = dj; + dj = tt; + } + if (n <= 2) { + return 0; + } + + /* ij is the midpoint of i and j. */ + + ij = ((int) (i + j) >> 1); + + /* Sort di,dij,dj. Make dij be their median. */ + + dij = array[ij]; + + /* i.e. should di precede dij? */ + + before = getSortsbefore(di, dij); + if (before) { + + /* i.e., should dij precede dj? */ + + before = getSortsbefore(dij, dj); + if (!(before)) { + tmp = array[j]; + array[j] = (array[ij]); + array[ij] = tmp; + dij = dj; + } + } else { + tmp = array[i]; + array[i] = (array[ij]); + array[ij] = tmp; + dij = di; + } + if (n <= 3) { + return 0; + } + k = i; + l = j; + again = 1; + while (again) { + before = 1; + while (before) { + if (k <= (l -= 1)) { + tmp = array[l]; + before = getSortsbefore(dij, tmp); + } else { + before = 0; + } + } + before = 1; + while (before) { + if ((k += 1) <= l) { + tmp = array[k]; + before = getSortsbefore(tmp, dij); + } else { + before = 0; + } + } + again = k <= l; + if (again) { + tmp = array[k]; + array[k] = (array[l]); + array[l] = tmp; + } + } + quickSortGlobalEdgeTablefromto(array, i, l); + quickSortGlobalEdgeTablefromto(array, k, j); +} + +static int * rShiftTable(void) { + static int theTable[17] = + {0, 5, 4, 0, 3, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1}; + + return theTable; +} + +static int removeFirstAETEntry(void) { + int index; + + index = workBuffer[13]; + workBuffer[14] = ((workBuffer[14]) - 1); + while (index < (workBuffer[14])) { + aetBuffer[index] = (aetBuffer[index + 1]); + index += 1; + } +} + +static int repeatValuemax(int delta, int maxValue) { + int newDelta; + + newDelta = delta; + while (newDelta < 0) { + newDelta += maxValue; + } + while (newDelta >= maxValue) { + newDelta -= maxValue; + } + return newDelta; +} + +static int resetGraphicsEngineStats(void) { + workBuffer[90] = 0; + workBuffer[92] = 0; + workBuffer[94] = 0; + workBuffer[96] = 0; + workBuffer[98] = 0; + workBuffer[100] = 0; + workBuffer[102] = 0; + workBuffer[104] = 0; + workBuffer[106] = 0; + workBuffer[91] = 0; + workBuffer[93] = 0; + workBuffer[95] = 0; + workBuffer[97] = 0; + workBuffer[99] = 0; + workBuffer[101] = 0; + workBuffer[103] = 0; + workBuffer[105] = 0; + workBuffer[107] = 0; + workBuffer[108] = 0; + workBuffer[109] = 0; + workBuffer[110] = 0; + workBuffer[111] = 0; +} + +static int resortFirstAETEntry(void) { + int edge; + int leftEdge; + int xValue; + + if ((workBuffer[13]) == 0) { + return null; + } + edge = aetBuffer[workBuffer[13]]; + xValue = objBuffer[edge + 4]; + leftEdge = aetBuffer[(workBuffer[13]) - 1]; + if ((objBuffer[leftEdge + 4]) <= xValue) { + return null; + } + moveAETEntryFromedgex(workBuffer[13], edge, xValue); +} + +static int returnWideBezierFill(void) { + return dispatchReturnValue = objBuffer[dispatchedValue + 16]; +} + +static int returnWideBezierWidth(void) { + return dispatchReturnValue = objBuffer[dispatchedValue + 17]; +} + + +/* Return the fill of the (wide) line - this method is called from a case. */ + +static int returnWideLineFill(void) { + return dispatchReturnValue = objBuffer[dispatchedValue + 16]; +} + + +/* Return the width of the (wide) line - this method is called from a case. */ + +static int returnWideLineWidth(void) { + return dispatchReturnValue = objBuffer[dispatchedValue + 17]; +} + + +/* Set the anti-aliasing level. Three levels are supported: + 1 - No antialiasing + 2 - 2x2 unweighted anti-aliasing + 4 - 4x4 unweighted anti-aliasing. + */ + +static int setAALevel(int level) { + int aaLevel; + + if (level >= 4) { + aaLevel = 4; + } + if ((level >= 2) && (level < 4)) { + aaLevel = 2; + } + if (level < 2) { + aaLevel = 1; + } + workBuffer[48] = aaLevel; + if (aaLevel == 1) { + workBuffer[49] = 0; + workBuffer[51] = 4294967295U; + workBuffer[52] = 0; + } + if (aaLevel == 2) { + workBuffer[49] = 1; + workBuffer[51] = 4244438268U; + workBuffer[52] = 1; + } + if (aaLevel == 4) { + workBuffer[49] = 2; + workBuffer[51] = 4042322160U; + workBuffer[52] = 3; + } + workBuffer[50] = ((workBuffer[49]) * 2); + workBuffer[53] = (workBuffer[49]); +} + + +/* Note: This is coded so that is can be run from Squeak. */ + +EXPORT(int) setInterpreter(struct VirtualMachine* anInterpreter) { + int ok; + + interpreterProxy = anInterpreter; + ok = interpreterProxy->majorVersion() == VM_PROXY_MAJOR; + if (ok == 0) { + return 0; + } + ok = interpreterProxy->minorVersion() >= VM_PROXY_MINOR; + return ok; +} + + +/* Return the run-length value from the given ShortRunArray. */ + +static int shortRunLengthAtfrom(int i, int runArray) { + return ((unsigned) ((((int *) runArray))[i]) >> 16); +} + + +/* Return the run-length value from the given ShortRunArray. + Note: We don't need any coercion to short/int here, since + we deal basically only with unsigned values. */ + +static int shortRunValueAtfrom(int i, int runArray) { + return ((((int *) runArray))[i]) & 65535; +} + +static int showFilldepthrightX(int fillIndex, int depth, int rightX) { + if (!(wbStackPush(3))) { + return null; + } + workBuffer[(workBuffer[10]) + 0] = fillIndex; + workBuffer[(workBuffer[10]) + (0 + 1)] = depth; + workBuffer[(workBuffer[10]) + (0 + 2)] = rightX; + if (((workBuffer[1]) - (workBuffer[10])) == 3) { + return null; + } + if (fillSortsbefore(0, ((workBuffer[1]) - (workBuffer[10])) - 3)) { + workBuffer[(workBuffer[10]) + 0] = (workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)]); + workBuffer[(workBuffer[10]) + (0 + 1)] = (workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 1)]); + workBuffer[(workBuffer[10]) + (0 + 2)] = (workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 2)]); + workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)] = fillIndex; + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 1)] = depth; + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 2)] = rightX; + } +} + +static int * smallSqrtTable(void) { + static int theTable[32] = + {0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6}; + + return theTable; +} + + +/* Sort the entire global edge table */ + +static int sortGlobalEdgeTable(void) { + quickSortGlobalEdgeTablefromto(getBuffer, 0, (workBuffer[12]) - 1); +} + +static int spanEndAAGet(void) { + return workBuffer[35]; +} + +static int spanEndAAPut(int value) { + return workBuffer[35] = value; +} + +static int spanEndGet(void) { + return workBuffer[34]; +} + +static int spanEndPut(int value) { + return workBuffer[34] = value; +} + +static int spanSizeGet(void) { + return workBuffer[33]; +} + +static int spanSizePut(int value) { + return workBuffer[33] = value; +} + +static int spanStartGet(void) { + return workBuffer[32]; +} + +static int spanStartPut(int value) { + return workBuffer[32] = value; +} + +static int squaredLengthOfwith(int deltaX, int deltaY) { + return (deltaX * deltaX) + (deltaY * deltaY); +} + +static int stackFillDepth(int index) { + return workBuffer[(workBuffer[10]) + (index + 1)]; +} + +static int stackFillDepthput(int index, int value) { + return workBuffer[(workBuffer[10]) + (index + 1)] = value; +} + +static int stackFillEntryLength(void) { + return 3; +} + +static int stackFillRightX(int index) { + return workBuffer[(workBuffer[10]) + (index + 2)]; +} + +static int stackFillRightXput(int index, int value) { + return workBuffer[(workBuffer[10]) + (index + 2)] = value; +} + +static int stackFillSize(void) { + return (workBuffer[1]) - (workBuffer[10]); +} + +static int stackFillValue(int index) { + return workBuffer[(workBuffer[10]) + index]; +} + +static int stackFillValueput(int index, int value) { + return workBuffer[(workBuffer[10]) + index] = value; +} + +static int stateGet(void) { + return workBuffer[2]; +} + +static int statePut(int value) { + return workBuffer[2] = value; +} + + +/* Initialize the current entry in the GET by stepping to the current scan line */ + +static int stepToFirstBezier(void) { + return stepToFirstBezierInat(getBuffer[workBuffer[11]], workBuffer[88]); +} + + +/* Initialize the bezier at yValue. + TODO: Check if reducing maxSteps from 2*deltaY to deltaY + brings a *significant* performance improvement. + In theory this should make for double step performance + but will cost in quality. Might be that the AA stuff will + compensate for this - but I'm not really sure. */ + +static int stepToFirstBezierInat(int bezier, int yValue) { + int squaredStepSize; + int *updateData; + int fwY1; + int fwY2; + int endX; + int endY; + int fwX1; + int fwDDx; + int fwX2; + int fwDDy; + int fwDx; + int startX; + int startY; + int fwDy; + int maxSteps; + int scaledStepSize; + int deltaY; + int viaX; + int viaY; + int xValue; + int minY; + int fwDx1; + int fwDy1; + int lastX; + int lastY; + int word1; + int word2; + + if ((!((((objBuffer[bezier + 0]) & 65535) & 1) != 0)) && (yValue >= (objBuffer[bezier + 15]))) { + return objBuffer[bezier + 7] = 0; + } + startX = objBuffer[bezier + 4]; + startY = objBuffer[bezier + 5]; + viaX = objBuffer[bezier + 12]; + viaY = objBuffer[bezier + 13]; + endX = objBuffer[bezier + 14]; + endY = objBuffer[bezier + 15]; + + /* Initialize integer forward differencing */ + + deltaY = endY - startY; + fwX1 = (viaX - startX) * 2; + fwX2 = (startX + endX) - (viaX * 2); + fwY1 = (viaY - startY) * 2; + fwY2 = (startY + endY) - (viaY * 2); + maxSteps = deltaY * 2; + if (maxSteps < 2) { + maxSteps = 2; + } + scaledStepSize = 16777216 / maxSteps; + /* begin absoluteSquared8Dot24: */ + word1 = scaledStepSize & 65535; + word2 = (((unsigned) scaledStepSize >> 16)) & 255; + squaredStepSize = ((unsigned) (((((unsigned) (((unsigned) (word1 * word1))) >> 16)) + ((word1 * word2) * 2)) + (((unsigned) (word2 * word2) << 16))) >> 8); + fwDx = fwX1 * scaledStepSize; + fwDDx = (fwX2 * squaredStepSize) * 2; + fwDx += ((int) fwDDx >> 1); + fwDy = fwY1 * scaledStepSize; + fwDDy = (fwY2 * squaredStepSize) * 2; + + /* Store the values */ + + fwDy += ((int) fwDDy >> 1); + objBuffer[bezier + 7] = deltaY; + updateData = (objBuffer + bezier) + 10; + updateData[0] = (startX * 256); + updateData[1] = (startY * 256); + updateData[2] = fwDx; + updateData[3] = fwDy; + updateData[4] = fwDDx; + updateData[5] = fwDDy; + if (!((startY = objBuffer[bezier + 5]) == yValue)) { + /* begin stepToNextBezierIn:at: */ + /* begin stepToNextBezierForward:at: */ + lastX = (((int*) ((objBuffer + bezier) + 10)))[0]; + lastY = (((int*) ((objBuffer + bezier) + 10)))[1]; + fwDx1 = (((int*) ((objBuffer + bezier) + 10)))[2]; + fwDy1 = (((int*) ((objBuffer + bezier) + 10)))[3]; + minY = yValue * 256; + while ((minY > lastY) && (fwDy1 >= 0)) { + lastX += ((int) (fwDx1 + 32768) >> 16); + lastY += ((int) (fwDy1 + 32768) >> 16); + fwDx1 += (((int*) ((objBuffer + bezier) + 10)))[4]; + fwDy1 += (((int*) ((objBuffer + bezier) + 10)))[5]; + } + (((int*) ((objBuffer + bezier) + 10)))[0] = lastX; + (((int*) ((objBuffer + bezier) + 10)))[1] = lastY; + (((int*) ((objBuffer + bezier) + 10)))[2] = fwDx1; + (((int*) ((objBuffer + bezier) + 10)))[3] = fwDy1; + xValue = ((int) lastX >> 8); + objBuffer[bezier + 4] = xValue; + objBuffer[bezier + 7] = (deltaY - (yValue - startY)); + } +} + + +/* Initialize the current entry in the GET by stepping to the current scan line */ + +static int stepToFirstLine(void) { + return stepToFirstLineInat(getBuffer[workBuffer[11]], workBuffer[88]); +} + + +/* Initialize the line at yValue */ + +static int stepToFirstLineInat(int line, int yValue) { + int error; + int xDir; + int i; + int errorAdjUp; + int startY; + int widthX; + int deltaX; + int deltaY; + int xInc; + int x; + int err; + + if ((!((((objBuffer[line + 0]) & 65535) & 1) != 0)) && (yValue >= (objBuffer[line + 15]))) { + return objBuffer[line + 7] = 0; + } + deltaX = (objBuffer[line + 14]) - (objBuffer[line + 4]); + + /* Check if edge goes left to right */ + + deltaY = (objBuffer[line + 15]) - (objBuffer[line + 5]); + if (deltaX >= 0) { + xDir = 1; + widthX = deltaX; + error = 0; + } else { + xDir = -1; + widthX = 0 - deltaX; + error = 1 - deltaY; + } + if (deltaY == 0) { + + /* No error for horizontal edges */ + + error = 0; + + /* Encodes width and direction */ + + xInc = deltaX; + errorAdjUp = 0; + } else { + if (deltaY > widthX) { + xInc = 0; + errorAdjUp = widthX; + } else { + xInc = (widthX / deltaY) * xDir; + errorAdjUp = widthX % deltaY; + } + } + objBuffer[line + 7] = deltaY; + objBuffer[line + 10] = xDir; + objBuffer[line + 12] = xInc; + objBuffer[line + 13] = error; + objBuffer[line + 14] = errorAdjUp; + objBuffer[line + 15] = deltaY; + if (!((startY = objBuffer[line + 5]) == yValue)) { + for (i = startY; i <= (yValue - 1); i += 1) { + /* begin stepToNextLineIn:at: */ + x = (objBuffer[line + 4]) + (objBuffer[line + 12]); + err = (objBuffer[line + 13]) + (objBuffer[line + 14]); + if (err > 0) { + x += objBuffer[line + 10]; + err -= objBuffer[line + 15]; + } + objBuffer[line + 13] = err; + objBuffer[line + 4] = x; + } + objBuffer[line + 7] = (deltaY - (yValue - startY)); + } +} + + +/* Initialize the current entry in the GET by stepping to the current scan line */ + +static int stepToFirstWideBezier(void) { + return stepToFirstWideBezierInat(getBuffer[workBuffer[11]], workBuffer[88]); +} + + +/* Initialize the bezier at yValue */ + +static int stepToFirstWideBezierInat(int bezier, int yValue) { + int lineOffset; + int nLines; + int lineWidth; + int xDir; + int i; + int endX; + int yExit; + int startY; + int yEntry; + + lineWidth = objBuffer[bezier + 20]; + + /* Compute the incremental values of the bezier */ + + lineOffset = ((int) lineWidth >> 1); + endX = objBuffer[bezier + 14]; + startY = objBuffer[bezier + 5]; + stepToFirstBezierInat(bezier, startY); + + /* Copy the incremental update data */ + + nLines = objBuffer[bezier + 7]; + for (i = 0; i <= 5; i += 1) { + ((objBuffer + bezier) + 22)[i] = (((objBuffer + bezier) + 10)[i]); + } + xDir = ((objBuffer + bezier) + 10)[2]; + if (xDir == 0) { + ((objBuffer + bezier) + 10)[4]; + } + if (xDir >= 0) { + xDir = 1; + } else { + xDir = -1; + } + if (xDir < 0) { + adjustWideBezierLeftwidthoffsetendX(bezier, lineWidth, lineOffset, endX); + } else { + adjustWideBezierRightwidthoffsetendX(bezier, lineWidth, lineOffset, endX); + } + if (nLines == 0) { + ((objBuffer + bezier) + 10)[0] = ((objBuffer[bezier + 21]) * 256); + } + objBuffer[bezier + 7] = (nLines + lineWidth); + + /* turned on at lineOffset */ + + yEntry = 0; + + /* turned off at zero */ + + yExit = (0 - nLines) - lineOffset; + objBuffer[bezier + 18] = yEntry; + objBuffer[bezier + 19] = yExit; + if ((yEntry >= lineOffset) && (yExit < 0)) { + objBuffer[bezier + 0] = (((objBuffer[bezier + 0]) & 65535) & (~65536)); + } else { + objBuffer[bezier + 0] = (((objBuffer[bezier + 0]) & 65535) | 65536); + } + computeFinalWideBezierValueswidth(bezier, lineWidth); + if (!(startY == yValue)) { + for (i = startY; i <= (yValue - 1); i += 1) { + stepToNextWideBezierInat(bezier, i); + } + objBuffer[bezier + 7] = ((objBuffer[bezier + 7]) - (yValue - startY)); + } +} + + +/* Initialize the current entry in the GET by stepping to the current scan line */ + +static int stepToFirstWideLine(void) { + return stepToFirstWideLineInat(getBuffer[workBuffer[11]], workBuffer[88]); +} + + +/* Initialize the wide line at yValue. */ + +static int stepToFirstWideLineInat(int line, int yValue) { + int lineOffset; + int nLines; + int lineWidth; + int xDir; + int i; + int yExit; + int startX; + int startY; + int yEntry; + int lineOffset1; + int yExit1; + int nextX; + int lineWidth1; + int lastX; + int yEntry1; + int x; + int err; + + lineWidth = objBuffer[line + 20]; + + /* Compute the incremental values of the line */ + + lineOffset = ((int) lineWidth >> 1); + startX = objBuffer[line + 4]; + startY = objBuffer[line + 5]; + stepToFirstLineInat(line, startY); + nLines = objBuffer[line + 7]; + + /* Adjust the line to start at the correct X position */ + + xDir = objBuffer[line + 10]; + objBuffer[line + 4] = (startX - lineOffset); + objBuffer[line + 7] = (nLines + lineWidth); + if (xDir > 0) { + objBuffer[line + 17] = ((objBuffer[line + 12]) + lineWidth); + } else { + objBuffer[line + 17] = (lineWidth - (objBuffer[line + 12])); + objBuffer[line + 4] = ((objBuffer[line + 4]) + (objBuffer[line + 12])); + } + + /* turned on at lineOffset */ + + yEntry = 0; + + /* turned off at zero */ + + yExit = (0 - nLines) - lineOffset; + objBuffer[line + 18] = yEntry; + objBuffer[line + 19] = yExit; + if ((yEntry >= lineOffset) && (yExit < 0)) { + objBuffer[line + 0] = (((objBuffer[line + 0]) & 65535) & (~65536)); + } else { + objBuffer[line + 0] = (((objBuffer[line + 0]) & 65535) | 65536); + } + if (!(startY == yValue)) { + for (i = startY; i <= (yValue - 1); i += 1) { + /* begin stepToNextWideLineIn:at: */ + yEntry1 = (objBuffer[line + 18]) + 1; + yExit1 = (objBuffer[line + 19]) + 1; + objBuffer[line + 18] = yEntry1; + objBuffer[line + 19] = yExit1; + lineWidth1 = objBuffer[line + 20]; + lineOffset1 = ((int) lineWidth1 >> 1); + if (yEntry1 >= lineOffset1) { + objBuffer[line + 0] = (((objBuffer[line + 0]) & 65535) & (~65536)); + } + if (yExit1 >= 0) { + objBuffer[line + 0] = (((objBuffer[line + 0]) & 65535) | 65536); + } + lastX = objBuffer[line + 4]; + /* begin stepToNextLineIn:at: */ + x = (objBuffer[line + 4]) + (objBuffer[line + 12]); + err = (objBuffer[line + 13]) + (objBuffer[line + 14]); + if (err > 0) { + x += objBuffer[line + 10]; + err -= objBuffer[line + 15]; + } + objBuffer[line + 13] = err; + objBuffer[line + 4] = x; + nextX = objBuffer[line + 4]; + if ((yEntry1 <= lineWidth1) || ((yExit1 + lineOffset1) >= 0)) { + adjustWideLineafterSteppingFromto(line, lastX, nextX); + } + } + objBuffer[line + 7] = ((objBuffer[line + 7]) - (yValue - startY)); + } +} + + +/* Process the current entry in the AET by stepping to the next scan line */ + +static int stepToNextBezier(void) { + int xValue; + int minY; + int fwDx; + int fwDy; + int lastX; + int lastY; + + /* begin stepToNextBezierIn:at: */ + /* begin stepToNextBezierForward:at: */ + lastX = (((int*) ((objBuffer + (aetBuffer[workBuffer[13]])) + 10)))[0]; + lastY = (((int*) ((objBuffer + (aetBuffer[workBuffer[13]])) + 10)))[1]; + fwDx = (((int*) ((objBuffer + (aetBuffer[workBuffer[13]])) + 10)))[2]; + fwDy = (((int*) ((objBuffer + (aetBuffer[workBuffer[13]])) + 10)))[3]; + minY = (workBuffer[88]) * 256; + while ((minY > lastY) && (fwDy >= 0)) { + lastX += ((int) (fwDx + 32768) >> 16); + lastY += ((int) (fwDy + 32768) >> 16); + fwDx += (((int*) ((objBuffer + (aetBuffer[workBuffer[13]])) + 10)))[4]; + fwDy += (((int*) ((objBuffer + (aetBuffer[workBuffer[13]])) + 10)))[5]; + } + (((int*) ((objBuffer + (aetBuffer[workBuffer[13]])) + 10)))[0] = lastX; + (((int*) ((objBuffer + (aetBuffer[workBuffer[13]])) + 10)))[1] = lastY; + (((int*) ((objBuffer + (aetBuffer[workBuffer[13]])) + 10)))[2] = fwDx; + (((int*) ((objBuffer + (aetBuffer[workBuffer[13]])) + 10)))[3] = fwDy; + xValue = ((int) lastX >> 8); + objBuffer[(aetBuffer[workBuffer[13]]) + 4] = xValue; + return null; +} + + +/* Incrementally step to the next scan line in the given bezier update data. + Note: This method has been written so that inlining works, e.g., + not declaring updateData as 'int*' but casting it on every use. */ + +static int stepToNextBezierForwardat(int updateData, int yValue) { + int minY; + int fwDx; + int fwDy; + int lastX; + int lastY; + + lastX = (((int*) updateData))[0]; + lastY = (((int*) updateData))[1]; + fwDx = (((int*) updateData))[2]; + fwDy = (((int*) updateData))[3]; + + /* Step as long as we haven't yet reached minY and also + as long as fwDy is greater than zero thus stepping down. + Note: The test for fwDy should not be necessary in theory + but is a good insurance in practice. */ + + minY = yValue * 256; + while ((minY > lastY) && (fwDy >= 0)) { + lastX += ((int) (fwDx + 32768) >> 16); + lastY += ((int) (fwDy + 32768) >> 16); + fwDx += (((int*) updateData))[4]; + fwDy += (((int*) updateData))[5]; + } + (((int*) updateData))[0] = lastX; + (((int*) updateData))[1] = lastY; + (((int*) updateData))[2] = fwDx; + (((int*) updateData))[3] = fwDy; + return ((int) lastX >> 8); +} + + +/* Incrementally step to the next scan line in the given bezier */ + +static int stepToNextBezierInat(int bezier, int yValue) { + int xValue; + int minY; + int fwDx; + int fwDy; + int lastX; + int lastY; + + /* begin stepToNextBezierForward:at: */ + lastX = (((int*) ((objBuffer + bezier) + 10)))[0]; + lastY = (((int*) ((objBuffer + bezier) + 10)))[1]; + fwDx = (((int*) ((objBuffer + bezier) + 10)))[2]; + fwDy = (((int*) ((objBuffer + bezier) + 10)))[3]; + minY = yValue * 256; + while ((minY > lastY) && (fwDy >= 0)) { + lastX += ((int) (fwDx + 32768) >> 16); + lastY += ((int) (fwDy + 32768) >> 16); + fwDx += (((int*) ((objBuffer + bezier) + 10)))[4]; + fwDy += (((int*) ((objBuffer + bezier) + 10)))[5]; + } + (((int*) ((objBuffer + bezier) + 10)))[0] = lastX; + (((int*) ((objBuffer + bezier) + 10)))[1] = lastY; + (((int*) ((objBuffer + bezier) + 10)))[2] = fwDx; + (((int*) ((objBuffer + bezier) + 10)))[3] = fwDy; + xValue = ((int) lastX >> 8); + objBuffer[bezier + 4] = xValue; +} + + +/* Process the current entry in the AET by stepping to the next scan line */ + +static int stepToNextLine(void) { + int x; + int err; + + /* begin stepToNextLineIn:at: */ + x = (objBuffer[(aetBuffer[workBuffer[13]]) + 4]) + (objBuffer[(aetBuffer[workBuffer[13]]) + 12]); + err = (objBuffer[(aetBuffer[workBuffer[13]]) + 13]) + (objBuffer[(aetBuffer[workBuffer[13]]) + 14]); + if (err > 0) { + x += objBuffer[(aetBuffer[workBuffer[13]]) + 10]; + err -= objBuffer[(aetBuffer[workBuffer[13]]) + 15]; + } + objBuffer[(aetBuffer[workBuffer[13]]) + 13] = err; + objBuffer[(aetBuffer[workBuffer[13]]) + 4] = x; + return null; +} + + +/* Incrementally step to the next scan line in the given line */ + +static int stepToNextLineInat(int line, int yValue) { + int x; + int err; + + x = (objBuffer[line + 4]) + (objBuffer[line + 12]); + err = (objBuffer[line + 13]) + (objBuffer[line + 14]); + if (err > 0) { + x += objBuffer[line + 10]; + err -= objBuffer[line + 15]; + } + objBuffer[line + 13] = err; + objBuffer[line + 4] = x; +} + + +/* Initialize the current entry in the GET by stepping to the current scan line */ + +static int stepToNextWideBezier(void) { + stepToNextWideBezierInat(aetBuffer[workBuffer[13]], workBuffer[88]); +} + + +/* Incrementally step to the next scan line in the given wide bezier */ + +static int stepToNextWideBezierInat(int bezier, int yValue) { + int lineOffset; + int yExit; + int lineWidth; + int yEntry; + int minY; + int fwDx; + int fwDy; + int lastX; + int lastY; + int minY1; + int fwDx1; + int fwDy1; + int lastX1; + int lastY1; + + lineWidth = objBuffer[bezier + 20]; + lineOffset = ((int) lineWidth >> 1); + yEntry = (objBuffer[bezier + 18]) + 1; + yExit = (objBuffer[bezier + 19]) + 1; + objBuffer[bezier + 18] = yEntry; + objBuffer[bezier + 19] = yExit; + if (yEntry >= lineOffset) { + objBuffer[bezier + 0] = (((objBuffer[bezier + 0]) & 65535) & (~65536)); + } + if (yExit >= 0) { + objBuffer[bezier + 0] = (((objBuffer[bezier + 0]) & 65535) | 65536); + } + if ((yExit + lineOffset) < 0) { + /* begin stepToNextBezierForward:at: */ + lastX = (((int*) ((objBuffer + bezier) + 10)))[0]; + lastY = (((int*) ((objBuffer + bezier) + 10)))[1]; + fwDx = (((int*) ((objBuffer + bezier) + 10)))[2]; + fwDy = (((int*) ((objBuffer + bezier) + 10)))[3]; + minY = yValue * 256; + while ((minY > lastY) && (fwDy >= 0)) { + lastX += ((int) (fwDx + 32768) >> 16); + lastY += ((int) (fwDy + 32768) >> 16); + fwDx += (((int*) ((objBuffer + bezier) + 10)))[4]; + fwDy += (((int*) ((objBuffer + bezier) + 10)))[5]; + } + (((int*) ((objBuffer + bezier) + 10)))[0] = lastX; + (((int*) ((objBuffer + bezier) + 10)))[1] = lastY; + (((int*) ((objBuffer + bezier) + 10)))[2] = fwDx; + (((int*) ((objBuffer + bezier) + 10)))[3] = fwDy; + ((int) lastX >> 8); + } else { + ((objBuffer + bezier) + 10)[0] = ((objBuffer[bezier + 21]) * 256); + } + /* begin stepToNextBezierForward:at: */ + lastX1 = (((int*) ((objBuffer + bezier) + 22)))[0]; + lastY1 = (((int*) ((objBuffer + bezier) + 22)))[1]; + fwDx1 = (((int*) ((objBuffer + bezier) + 22)))[2]; + fwDy1 = (((int*) ((objBuffer + bezier) + 22)))[3]; + minY1 = yValue * 256; + while ((minY1 > lastY1) && (fwDy1 >= 0)) { + lastX1 += ((int) (fwDx1 + 32768) >> 16); + lastY1 += ((int) (fwDy1 + 32768) >> 16); + fwDx1 += (((int*) ((objBuffer + bezier) + 22)))[4]; + fwDy1 += (((int*) ((objBuffer + bezier) + 22)))[5]; + } + (((int*) ((objBuffer + bezier) + 22)))[0] = lastX1; + (((int*) ((objBuffer + bezier) + 22)))[1] = lastY1; + (((int*) ((objBuffer + bezier) + 22)))[2] = fwDx1; + (((int*) ((objBuffer + bezier) + 22)))[3] = fwDy1; + ((int) lastX1 >> 8); + computeFinalWideBezierValueswidth(bezier, lineWidth); +} + + +/* Process the current entry in the AET by stepping to the next scan line */ + +static int stepToNextWideLine(void) { + int line; + int yValue; + int lineOffset; + int yExit; + int nextX; + int lineWidth; + int lastX; + int yEntry; + int x; + int err; + + /* begin stepToNextWideLineIn:at: */ + line = aetBuffer[workBuffer[13]]; + yValue = workBuffer[88]; + yEntry = (objBuffer[line + 18]) + 1; + yExit = (objBuffer[line + 19]) + 1; + objBuffer[line + 18] = yEntry; + objBuffer[line + 19] = yExit; + lineWidth = objBuffer[line + 20]; + lineOffset = ((int) lineWidth >> 1); + if (yEntry >= lineOffset) { + objBuffer[line + 0] = (((objBuffer[line + 0]) & 65535) & (~65536)); + } + if (yExit >= 0) { + objBuffer[line + 0] = (((objBuffer[line + 0]) & 65535) | 65536); + } + lastX = objBuffer[line + 4]; + /* begin stepToNextLineIn:at: */ + x = (objBuffer[line + 4]) + (objBuffer[line + 12]); + err = (objBuffer[line + 13]) + (objBuffer[line + 14]); + if (err > 0) { + x += objBuffer[line + 10]; + err -= objBuffer[line + 15]; + } + objBuffer[line + 13] = err; + objBuffer[line + 4] = x; + nextX = objBuffer[line + 4]; + if ((yEntry <= lineWidth) || ((yExit + lineOffset) >= 0)) { + adjustWideLineafterSteppingFromto(line, lastX, nextX); + } + return null; +} + + +/* Incrementally step to the next scan line in the given wide line */ + +static int stepToNextWideLineInat(int line, int yValue) { + int lineOffset; + int yExit; + int nextX; + int lineWidth; + int lastX; + int yEntry; + int x; + int err; + + yEntry = (objBuffer[line + 18]) + 1; + yExit = (objBuffer[line + 19]) + 1; + objBuffer[line + 18] = yEntry; + objBuffer[line + 19] = yExit; + lineWidth = objBuffer[line + 20]; + lineOffset = ((int) lineWidth >> 1); + if (yEntry >= lineOffset) { + objBuffer[line + 0] = (((objBuffer[line + 0]) & 65535) & (~65536)); + } + if (yExit >= 0) { + objBuffer[line + 0] = (((objBuffer[line + 0]) & 65535) | 65536); + } + lastX = objBuffer[line + 4]; + /* begin stepToNextLineIn:at: */ + x = (objBuffer[line + 4]) + (objBuffer[line + 12]); + err = (objBuffer[line + 13]) + (objBuffer[line + 14]); + if (err > 0) { + x += objBuffer[line + 10]; + err -= objBuffer[line + 15]; + } + objBuffer[line + 13] = err; + objBuffer[line + 4] = x; + + /* Check for special start/end adjustments */ + + nextX = objBuffer[line + 4]; + if ((yEntry <= lineWidth) || ((yExit + lineOffset) >= 0)) { + adjustWideLineafterSteppingFromto(line, lastX, nextX); + } +} + +static int stopBecauseOf(int stopReason) { + workBuffer[64] = stopReason; + engineStopped = 1; +} + +static int stopReasonGet(void) { + return workBuffer[64]; +} + +static int stopReasonPut(int value) { + return workBuffer[64] = value; +} + +static int storeEdgeStateFrominto(int edge, int edgeOop) { + if ((interpreterProxy->slotSizeOf(edgeOop)) < 6) { + return interpreterProxy->primitiveFail(); + } + interpreterProxy->storeIntegerofObjectwithValue(0, edgeOop, objBuffer[edge + 2]); + interpreterProxy->storeIntegerofObjectwithValue(1, edgeOop, objBuffer[edge + 4]); + interpreterProxy->storeIntegerofObjectwithValue(2, edgeOop, workBuffer[88]); + interpreterProxy->storeIntegerofObjectwithValue(3, edgeOop, objBuffer[edge + 6]); + interpreterProxy->storeIntegerofObjectwithValue(4, edgeOop, objBuffer[edge + 7]); + workBuffer[65] = edge; +} + +static int storeEngineStateInto(int oop) { + workBuffer[9] = objUsed; +} + +static int storeFillStateInto(int fillOop) { + int leftX; + int rightX; + int fillIndex; + + fillIndex = workBuffer[66]; + leftX = workBuffer[67]; + rightX = workBuffer[68]; + if ((interpreterProxy->slotSizeOf(fillOop)) < 6) { + return interpreterProxy->primitiveFail(); + } + interpreterProxy->storeIntegerofObjectwithValue(0, fillOop, objBuffer[fillIndex + 2]); + interpreterProxy->storeIntegerofObjectwithValue(1, fillOop, leftX); + interpreterProxy->storeIntegerofObjectwithValue(2, fillOop, rightX); + interpreterProxy->storeIntegerofObjectwithValue(3, fillOop, workBuffer[88]); +} + +static int storeRenderingState(void) { + int edgeOop; + int fillOop; + int edge; + int reason; + + if (interpreterProxy->failed()) { + return null; + } + if (engineStopped) { + /* begin storeStopStateIntoEdge:fill: */ + edgeOop = interpreterProxy->stackObjectValue(1); + fillOop = interpreterProxy->stackObjectValue(0); + reason = workBuffer[64]; + if (reason == 4) { + edge = getBuffer[workBuffer[11]]; + storeEdgeStateFrominto(edge, edgeOop); + workBuffer[11] = ((workBuffer[11]) + 1); + } + if (reason == 5) { + storeFillStateInto(fillOop); + } + if (reason == 6) { + edge = aetBuffer[workBuffer[13]]; + storeEdgeStateFrominto(edge, edgeOop); + } + } + /* begin storeEngineStateInto: */ + workBuffer[9] = objUsed; + interpreterProxy->pop(3); + interpreterProxy->pushInteger(workBuffer[64]); +} + +static int storeStopStateIntoEdgefill(int edgeOop, int fillOop) { + int edge; + int reason; + + reason = workBuffer[64]; + if (reason == 4) { + edge = getBuffer[workBuffer[11]]; + storeEdgeStateFrominto(edge, edgeOop); + workBuffer[11] = ((workBuffer[11]) + 1); + } + if (reason == 5) { + storeFillStateInto(fillOop); + } + if (reason == 6) { + edge = aetBuffer[workBuffer[13]]; + storeEdgeStateFrominto(edge, edgeOop); + } +} + + +/* Subdivide the given bezier curve if necessary */ + +static int subdivideBezier(int index) { + int startX; + int startY; + int deltaX; + int deltaY; + int endX; + int endY; + + startY = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 1)]; + + /* If the receiver is horizontal, don't do anything */ + + endY = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 5)]; + if (endY == startY) { + return index; + } + deltaY = endY - startY; + if (deltaY < 0) { + deltaY = 0 - deltaY; + } + if (deltaY > 255) { + workBuffer[109] = ((workBuffer[109]) + 1); + return computeBezierSplitAtHalf(index); + } + startX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 0)]; + endX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 4)]; + deltaX = endX - startX; + if (deltaX < 0) { + deltaX = 0 - deltaX; + } + if ((deltaY * 32) < deltaX) { + workBuffer[110] = ((workBuffer[110]) + 1); + return computeBezierSplitAtHalf(index); + } + return index; +} + + +/* Recursively subdivide the curve on the bezier stack. */ + +static int subdivideBezierFrom(int index) { + int index1; + int otherIndex; + int index2; + + otherIndex = subdivideBezier(index); + if (!(otherIndex == index)) { + index1 = subdivideBezierFrom(index); + if (engineStopped) { + return 0; + } + index2 = subdivideBezierFrom(otherIndex); + if (engineStopped) { + return 0; + } + if (index1 >= index2) { + return index1; + } else { + return index2; + } + } + return index; +} + + +/* Check if the given bezier curve is monoton in Y, and, if desired in X. + If not, subdivide it */ + +static int subdivideToBeMonotoninX(int base, int doTestX) { + int base2; + int index1; + int index2; + + base2 = index1 = index2 = subdivideToBeMonotonInY(base); + if (doTestX) { + index1 = subdivideToBeMonotonInX(base); + } + if (index1 > index2) { + index2 = index1; + } + if ((base != base2) && (doTestX)) { + index1 = subdivideToBeMonotonInX(base2); + } + if (index1 > index2) { + index2 = index1; + } + return index2; +} + + +/* Check if the given bezier curve is monoton in X. If not, subdivide it */ + +static int subdivideToBeMonotonInX(int index) { + int dx1; + int dx2; + int num; + int startX; + int denom; + int viaX; + int endX; + + startX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 0)]; + viaX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 2)]; + endX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 4)]; + dx1 = viaX - startX; + dx2 = endX - viaX; + if ((dx1 * dx2) >= 0) { + return index; + } + workBuffer[108] = ((workBuffer[108]) + 1); + denom = dx2 - dx1; + num = dx1; + if (num < 0) { + num = 0 - num; + } + if (denom < 0) { + denom = 0 - denom; + } + return computeBeziersplitAt(index, (((double) num )) / (((double) denom ))); +} + + +/* Check if the given bezier curve is monoton in Y. If not, subdivide it */ + +static int subdivideToBeMonotonInY(int index) { + int endY; + int dy1; + int num; + int dy2; + int startY; + int denom; + int viaY; + + startY = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 1)]; + viaY = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 3)]; + endY = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 5)]; + dy1 = viaY - startY; + dy2 = endY - viaY; + if ((dy1 * dy2) >= 0) { + return index; + } + workBuffer[108] = ((workBuffer[108]) + 1); + denom = dy2 - dy1; + num = dy1; + if (num < 0) { + num = 0 - num; + } + if (denom < 0) { + denom = 0 - denom; + } + return computeBeziersplitAt(index, (((double) num )) / (((double) denom ))); +} + + +/* Make the fill style with the given index either visible or invisible */ + +static int toggleFilldepthrightX(int fillIndex, int depth, int rightX) { + int hidden; + + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + if (wbStackPush(3)) { + workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)] = fillIndex; + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 1)] = depth; + workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 2)] = rightX; + } + } else { + hidden = hideFilldepth(fillIndex, depth); + if (!(hidden)) { + showFilldepthrightX(fillIndex, depth, rightX); + } + } +} + +static int toggleFillsOf(int edge) { + int depth; + int fillIndex; + int leftX; + + if (!(needAvailableSpace(3 * 2))) { + return null; + } + depth = (objBuffer[edge + 6]) << 1; + fillIndex = objBuffer[edge + 8]; + if (!(fillIndex == 0)) { + toggleFilldepthrightX(fillIndex, depth, 999999999); + } + fillIndex = objBuffer[edge + 9]; + if (!(fillIndex == 0)) { + toggleFilldepthrightX(fillIndex, depth, 999999999); + } + /* begin quickRemoveInvalidFillsAt: */ + leftX = objBuffer[edge + 4]; + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + goto l1; + } + while ((topRightX()) <= leftX) { + hideFilldepth(topFill(), topDepth()); + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + goto l1; + } + } +l1: /* end quickRemoveInvalidFillsAt: */; +} + +static int toggleWideFillOf(int edge) { + int depth; + int fill; + int lineWidth; + int rightX; + int type; + int index; + int leftX; + + type = ((unsigned) ((objBuffer[edge + 0]) & 65535)) >> 1; + dispatchedValue = edge; + switch (type) { + case 0: + case 1: + errorWrongIndex(); + break; + case 2: + dispatchReturnValue = objBuffer[dispatchedValue + 17]; + break; + case 3: + dispatchReturnValue = objBuffer[dispatchedValue + 17]; + break; + } + lineWidth = dispatchReturnValue; + switch (type) { + case 0: + case 1: + errorWrongIndex(); + break; + case 2: + dispatchReturnValue = objBuffer[dispatchedValue + 16]; + break; + case 3: + dispatchReturnValue = objBuffer[dispatchedValue + 16]; + break; + } + fill = dispatchReturnValue; + if (fill == 0) { + return null; + } + if (!(needAvailableSpace(3))) { + return null; + } + + /* So lines sort before interior fills */ + + depth = ((objBuffer[edge + 6]) << 1) + 1; + rightX = (objBuffer[edge + 4]) + lineWidth; + index = findStackFilldepth(fill, depth); + if (index == -1) { + showFilldepthrightX(fill, depth, rightX); + } else { + if ((workBuffer[(workBuffer[10]) + (index + 2)]) < rightX) { + workBuffer[(workBuffer[10]) + (index + 2)] = rightX; + } + } + /* begin quickRemoveInvalidFillsAt: */ + leftX = objBuffer[edge + 4]; + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + goto l1; + } + while ((topRightX()) <= leftX) { + hideFilldepth(topFill(), topDepth()); + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + goto l1; + } + } +l1: /* end quickRemoveInvalidFillsAt: */; +} + +static int topDepth(void) { + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + return -1; + } else { + return workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 1)]; + } +} + +static int topFill(void) { + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + return 0; + } else { + return workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)]; + } +} + +static int topFillDepth(void) { + return workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 1)]; +} + +static int topFillDepthPut(int value) { + return workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 1)] = value; +} + +static int topFillRightX(void) { + return workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 2)]; +} + +static int topFillRightXPut(int value) { + return workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 2)] = value; +} + +static int topFillValue(void) { + return workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)]; +} + +static int topFillValuePut(int value) { + return workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)] = value; +} + +static int topRightX(void) { + if (((workBuffer[1]) - (workBuffer[10])) == 0) { + return 999999999; + } else { + return workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 2)]; + } +} + +static int transformColor(int fillIndex) { + float *transform; + int g; + int r; + int b; + int a; + double alphaScale; + + if (!((fillIndex == 0) || ((fillIndex & 4278190080U) != 0))) { + return fillIndex; + } + b = fillIndex & 255; + g = (((unsigned) fillIndex) >> 8) & 255; + r = (((unsigned) fillIndex) >> 16) & 255; + a = (((unsigned) fillIndex) >> 24) & 255; + if ((workBuffer[17]) != 0) { + transform = ((float *) (workBuffer + 24)); + alphaScale = ((a * (transform[6])) + (transform[7])) / a; + r = ((int) (((r * (transform[0])) + (transform[1])) * alphaScale) ); + g = ((int) (((g * (transform[2])) + (transform[3])) * alphaScale) ); + b = ((int) (((b * (transform[4])) + (transform[5])) * alphaScale) ); + a = a * alphaScale; + r = ((r < 0) ? 0 : r); + r = ((r < 255) ? r : 255); + g = ((g < 0) ? 0 : g); + g = ((g < 255) ? g : 255); + b = ((b < 0) ? 0 : b); + b = ((b < 255) ? b : 255); + a = ((a < 0) ? 0 : a); + a = ((a < 255) ? a : 255); + } + if (a < 1) { + return 0; + } + if ((a < 255) && ((workBuffer[63]) != 0)) { + /* begin stopBecauseOf: */ + workBuffer[64] = 3; + engineStopped = 1; + } + return ((b + (g << 8)) + (r << 16)) + (a << 24); +} + + +/* Transform the given point. If haveMatrix is true then use the current transformation. */ + +static int transformPoint(int *point) { + if ((workBuffer[16]) != 0) { + /* begin transformPoint:into: */ + transformPointXyinto(((double) ((((int *) point))[0]) ), ((double) ((((int *) point))[1]) ), ((int *) point)); + } else { + point[0] = (((point[0]) + (workBuffer[46])) * (workBuffer[48])); + point[1] = (((point[1]) + (workBuffer[47])) * (workBuffer[48])); + } +} + + +/* Transform srcPoint into dstPoint by using the currently loaded matrix */ +/* Note: This method has been rewritten so that inlining works (e.g., removing + the declarations and adding argument coercions at the appropriate points) */ + +static int transformPointinto(int srcPoint, int dstPoint) { + transformPointXyinto(((double) ((((int *) srcPoint))[0]) ), ((double) ((((int *) srcPoint))[1]) ), ((int *) dstPoint)); +} + + +/* Transform srcPoint into dstPoint by using the currently loaded matrix */ +/* Note: This should be rewritten so that inlining works (e.g., removing + the declarations and adding argument coercions at the appropriate points) */ + +static int transformPointXyinto(double xValue, double yValue, int *dstPoint) { + float *transform; + int x; + int y; + + transform = ((float *) (workBuffer + 18)); + x = ((int) (((((transform[0]) * xValue) + ((transform[1]) * yValue)) + (transform[2])) * (((double) (workBuffer[48]) ))) ); + y = ((int) (((((transform[3]) * xValue) + ((transform[4]) * yValue)) + (transform[5])) * (((double) (workBuffer[48]) ))) ); + dstPoint[0] = x; + dstPoint[1] = y; +} + + +/* Transform n (n=1,2,3) points. + If haveMatrix is true then the matrix contains the actual transformation. */ + +static int transformPoints(int n) { + if (n > 0) { + transformPoint(((int *) (workBuffer + 80))); + } + if (n > 1) { + transformPoint(((int *) (workBuffer + 82))); + } + if (n > 2) { + transformPoint(((int *) (workBuffer + 84))); + } + if (n > 3) { + transformPoint(((int *) (workBuffer + 86))); + } +} + + +/* Transform the given width */ + +static int transformWidth(int w) { + double deltaX; + double deltaY; + int dstWidth2; + int dstWidth; + + if (w == 0) { + return 0; + } + (((int *) (workBuffer + 80)))[0] = 0; + (((int *) (workBuffer + 80)))[1] = 0; + (((int *) (workBuffer + 82)))[0] = (w * 256); + (((int *) (workBuffer + 82)))[1] = 0; + (((int *) (workBuffer + 84)))[0] = 0; + (((int *) (workBuffer + 84)))[1] = (w * 256); + /* begin transformPoints: */ + if (3 > 0) { + transformPoint(((int *) (workBuffer + 80))); + } + if (3 > 1) { + transformPoint(((int *) (workBuffer + 82))); + } + if (3 > 2) { + transformPoint(((int *) (workBuffer + 84))); + } + if (3 > 3) { + transformPoint(((int *) (workBuffer + 86))); + } + deltaX = ((double) (((((int *) (workBuffer + 82)))[0]) - ((((int *) (workBuffer + 80)))[0])) ); + deltaY = ((double) (((((int *) (workBuffer + 82)))[1]) - ((((int *) (workBuffer + 80)))[1])) ); + dstWidth = ((int) ((((int) (sqrt((deltaX * deltaX) + (deltaY * deltaY))) )) + 128) >> 8); + deltaX = ((double) (((((int *) (workBuffer + 84)))[0]) - ((((int *) (workBuffer + 80)))[0])) ); + deltaY = ((double) (((((int *) (workBuffer + 84)))[1]) - ((((int *) (workBuffer + 80)))[1])) ); + dstWidth2 = ((int) ((((int) (sqrt((deltaX * deltaX) + (deltaY * deltaY))) )) + 128) >> 8); + if (dstWidth2 < dstWidth) { + dstWidth = dstWidth2; + } + if (dstWidth == 0) { + return 1; + } else { + return dstWidth; + } +} + +static int uncheckedTransformColor(int fillIndex) { + float *transform; + int g; + int r; + int b; + int a; + + if (!((workBuffer[17]) != 0)) { + return fillIndex; + } + b = fillIndex & 255; + g = (((unsigned) fillIndex) >> 8) & 255; + r = (((unsigned) fillIndex) >> 16) & 255; + a = (((unsigned) fillIndex) >> 24) & 255; + transform = ((float *) (workBuffer + 24)); + r = ((int) ((r * (transform[0])) + (transform[1])) ); + g = ((int) ((g * (transform[2])) + (transform[3])) ); + b = ((int) ((b * (transform[4])) + (transform[5])) ); + a = ((int) ((a * (transform[6])) + (transform[7])) ); + r = ((r < 0) ? 0 : r); + r = ((r < 255) ? r : 255); + g = ((g < 0) ? 0 : g); + g = ((g < 255) ? g : 255); + b = ((b < 0) ? 0 : b); + b = ((b < 255) ? b : 255); + a = ((a < 0) ? 0 : a); + a = ((a < 255) ? a : 255); + if (a < 16) { + return 0; + } + return ((b + (g << 8)) + (r << 16)) + (a << 24); +} + +static int wbSizeGet(void) { + return workBuffer[1]; +} + +static int wbSizePut(int value) { + return workBuffer[1] = value; +} + +static int wbStackClear(void) { + workBuffer[10] = (workBuffer[1]); +} + +static int wbStackPop(int nItems) { + workBuffer[10] = ((workBuffer[10]) + nItems); +} + +static int wbStackPush(int nItems) { + if (!(needAvailableSpace(nItems))) { + return 0; + } + workBuffer[10] = ((workBuffer[10]) - nItems); + return 1; +} + +static int wbStackSize(void) { + return (workBuffer[1]) - (workBuffer[10]); +} + +static int wbStackValue(int index) { + return workBuffer[(workBuffer[10]) + index]; +} + +static int wbStackValueput(int index, int value) { + return workBuffer[(workBuffer[10]) + index] = value; +} + +static int wbTopGet(void) { + return workBuffer[10]; +} + +static int wbTopPut(int value) { + return workBuffer[10] = value; +} + +static int wideBezierEntryOf(int line) { + return objBuffer[line + 18]; +} + +static int wideBezierEntryOfput(int line, int value) { + return objBuffer[line + 18] = value; +} + +static int wideBezierExitOf(int line) { + return objBuffer[line + 19]; +} + +static int wideBezierExitOfput(int line, int value) { + return objBuffer[line + 19] = value; +} + +static int wideBezierExtentOf(int bezier) { + return objBuffer[bezier + 20]; +} + +static int wideBezierExtentOfput(int bezier, int value) { + return objBuffer[bezier + 20] = value; +} + +static int wideBezierFillOf(int bezier) { + return objBuffer[bezier + 16]; +} + +static int wideBezierFillOfput(int bezier, int value) { + return objBuffer[bezier + 16] = value; +} + +static int * wideBezierUpdateDataOf(int bezier) { + return (objBuffer + bezier) + 22; +} + +static int wideBezierWidthOf(int line) { + return objBuffer[line + 17]; +} + +static int wideBezierWidthOfput(int line, int value) { + return objBuffer[line + 17] = value; +} + +static int wideLineEntryOf(int line) { + return objBuffer[line + 18]; +} + +static int wideLineEntryOfput(int line, int value) { + return objBuffer[line + 18] = value; +} + +static int wideLineExitOf(int line) { + return objBuffer[line + 19]; +} + +static int wideLineExitOfput(int line, int value) { + return objBuffer[line + 19] = value; +} + +static int wideLineExtentOf(int line) { + return objBuffer[line + 20]; +} + +static int wideLineExtentOfput(int line, int value) { + return objBuffer[line + 20] = value; +} + +static int wideLineFillOf(int line) { + return objBuffer[line + 16]; +} + +static int wideLineFillOfput(int line, int value) { + return objBuffer[line + 16] = value; +} + +static int wideLineWidthOf(int line) { + return objBuffer[line + 17]; +} + +static int wideLineWidthOfput(int line, int value) { + return objBuffer[line + 17] = value; +} + + +#ifdef SQUEAK_BUILTIN_PLUGIN + + +void* B2DPlugin_exports[][3] = { + {"B2DPlugin", "primitiveSetColorTransform", (void*)primitiveSetColorTransform}, + {"B2DPlugin", "primitiveDisplaySpanBuffer", (void*)primitiveDisplaySpanBuffer}, + {"B2DPlugin", "primitiveSetBitBltPlugin", (void*)primitiveSetBitBltPlugin}, + {"B2DPlugin", "primitiveSetEdgeTransform", (void*)primitiveSetEdgeTransform}, + {"B2DPlugin", "primitiveNextFillEntry", (void*)primitiveNextFillEntry}, + {"B2DPlugin", "primitiveAddActiveEdgeEntry", (void*)primitiveAddActiveEdgeEntry}, + {"B2DPlugin", "primitiveRenderImage", (void*)primitiveRenderImage}, + {"B2DPlugin", "primitiveInitializeProcessing", (void*)primitiveInitializeProcessing}, + {"B2DPlugin", "primitiveAddBitmapFill", (void*)primitiveAddBitmapFill}, + {"B2DPlugin", "primitiveNextActiveEdgeEntry", (void*)primitiveNextActiveEdgeEntry}, + {"B2DPlugin", "primitiveAddRect", (void*)primitiveAddRect}, + {"B2DPlugin", "primitiveChangedActiveEdgeEntry", (void*)primitiveChangedActiveEdgeEntry}, + {"B2DPlugin", "primitiveSetAALevel", (void*)primitiveSetAALevel}, + {"B2DPlugin", "primitiveFinishedProcessing", (void*)primitiveFinishedProcessing}, + {"B2DPlugin", "primitiveGetOffset", (void*)primitiveGetOffset}, + {"B2DPlugin", "primitiveSetDepth", (void*)primitiveSetDepth}, + {"B2DPlugin", "primitiveAddBezier", (void*)primitiveAddBezier}, + {"B2DPlugin", "primitiveGetCounts", (void*)primitiveGetCounts}, + {"B2DPlugin", "primitiveGetTimes", (void*)primitiveGetTimes}, + {"B2DPlugin", "primitiveNeedsFlushPut", (void*)primitiveNeedsFlushPut}, + {"B2DPlugin", "primitiveGetFailureReason", (void*)primitiveGetFailureReason}, + {"B2DPlugin", "primitiveGetDepth", (void*)primitiveGetDepth}, + {"B2DPlugin", "primitiveGetAALevel", (void*)primitiveGetAALevel}, + {"B2DPlugin", "primitiveGetBezierStats", (void*)primitiveGetBezierStats}, + {"B2DPlugin", "primitiveAbortProcessing", (void*)primitiveAbortProcessing}, + {"B2DPlugin", "primitiveAddPolygon", (void*)primitiveAddPolygon}, + {"B2DPlugin", "primitiveAddGradientFill", (void*)primitiveAddGradientFill}, + {"B2DPlugin", "primitiveSetOffset", (void*)primitiveSetOffset}, + {"B2DPlugin", "initialiseModule", (void*)initialiseModule}, + {"B2DPlugin", "primitiveMergeFillFrom", (void*)primitiveMergeFillFrom}, + {"B2DPlugin", "primitiveAddLine", (void*)primitiveAddLine}, + {"B2DPlugin", "getModuleName", (void*)getModuleName}, + {"B2DPlugin", "setInterpreter", (void*)setInterpreter}, + {"B2DPlugin", "primitiveSetClipRect", (void*)primitiveSetClipRect}, + {"B2DPlugin", "primitiveDoProfileStats", (void*)primitiveDoProfileStats}, + {"B2DPlugin", "primitiveInitializeBuffer", (void*)primitiveInitializeBuffer}, + {"B2DPlugin", "primitiveRegisterExternalEdge", (void*)primitiveRegisterExternalEdge}, + {"B2DPlugin", "primitiveGetClipRect", (void*)primitiveGetClipRect}, + {"B2DPlugin", "primitiveRegisterExternalFill", (void*)primitiveRegisterExternalFill}, + {"B2DPlugin", "primitiveAddOval", (void*)primitiveAddOval}, + {"B2DPlugin", "primitiveNeedsFlush", (void*)primitiveNeedsFlush}, + {"B2DPlugin", "primitiveAddCompressedShape", (void*)primitiveAddCompressedShape}, + {"B2DPlugin", "primitiveNextGlobalEdgeEntry", (void*)primitiveNextGlobalEdgeEntry}, + {"B2DPlugin", "primitiveCopyBuffer", (void*)primitiveCopyBuffer}, + {"B2DPlugin", "primitiveAddBezierShape", (void*)primitiveAddBezierShape}, + {"B2DPlugin", "moduleUnloaded", (void*)moduleUnloaded}, + {"B2DPlugin", "primitiveRenderScanline", (void*)primitiveRenderScanline}, + {NULL, NULL, NULL} +}; + + +#endif /* ifdef SQ_BUILTIN_PLUGIN */ + diff --git a/squeak/BitBltPlugin.c b/squeak/BitBltPlugin.c new file mode 100644 index 0000000..053eb7a --- /dev/null +++ b/squeak/BitBltPlugin.c @@ -0,0 +1,5363 @@ +/* Automatically generated from Squeak on #(4 March 2003 4:22:46 am) */ + +#include +#include +#include +#include +#include + +/* Default EXPORT macro that does nothing (see comment in sq.h): */ +#define EXPORT(returnType) returnType + +/* Do not include the entire sq.h file but just those parts needed. */ +/* The virtual machine proxy definition */ +#include "sqVirtualMachine.h" +/* Configuration options */ +#include "sqConfig.h" +/* Platform specific definitions */ +#include "sqPlatformSpecific.h" + +#define true 1 +#define false 0 +#define null 0 /* using 'null' because nil is predefined in Think C */ +#ifdef SQUEAK_BUILTIN_PLUGIN +#undef EXPORT +// was #undef EXPORT(returnType) but screws NorCroft cc +#define EXPORT(returnType) static returnType +#endif + +/* memory access macros */ +#define byteAt(i) (*((unsigned char *) (i))) +#define byteAtput(i, val) (*((unsigned char *) (i)) = val) +#define longAt(i) (*((int *) (i))) +#define longAtput(i, val) (*((int *) (i)) = val) + + +/*** Variables ***/ +static int affectedB; +static int affectedL; +static int affectedR; +static int affectedT; +static int bbH; +static int bbW; +static int bitBltOop; +static int bitCount; +static int clipHeight; +static int clipWidth; +static int clipX; +static int clipY; +static int cmBitsPerColor; +static int cmFlags; +static unsigned int *cmLookupTable; +static int cmMask; +static unsigned int *cmMaskTable; +static int *cmShiftTable; +static int combinationRule; +static int destBits; +static int destDelta; +static int destDepth; +static int destForm; +static int destHeight; +static int destIndex; +static int destMSB; +static int destMask; +static int destPPW; +static int destPitch; +static int destWidth; +static int destX; +static int destY; +static const int ditherMatrix4x4[16] = { +0, 8, 2, 10, +12, 4, 14, 6, +3, 11, 1, 9, +15, 7, 13, 5 +}; +static const int ditherThresholds16[8] = { 0, 2, 4, 6, 8, 12, 14, 16 }; +static const int ditherValues16[32] = { +0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, +15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 +}; +static int dstBitShift; +static int dx; +static int dy; +static int hDir; +static int halftoneBase; +static int halftoneForm; +static int halftoneHeight; +static int hasSurfaceLock; +static int height; + +#ifdef SQUEAK_BUILTIN_PLUGIN +extern +#endif +struct VirtualMachine* interpreterProxy; +static int isWarping; +static int lockSurfaceFn; +static int mask1; +static int mask2; +static int maskTable[33] = { +0, 1, 3, 0, 15, 31, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 65535, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1 +}; +static const char *moduleName = +#ifdef SQUEAK_BUILTIN_PLUGIN + "BitBltPlugin 4 March 2003 (i)" +#else + "BitBltPlugin 4 March 2003 (e)" +#endif +; +static int nWords; +static int noHalftone; +static int noSource; +static int opTable[42]; +static int preload; +static int querySurfaceFn; +static int skew; +static int sourceAlpha; +static int sourceBits; +static int sourceDelta; +static int sourceDepth; +static int sourceForm; +static int sourceHeight; +static int sourceIndex; +static int sourceMSB; +static int sourcePPW; +static int sourcePitch; +static int sourceWidth; +static int sourceX; +static int sourceY; +static int srcBitShift; +static int sx; +static int sy; +static int unlockSurfaceFn; +static int vDir; +static int warpAlignMask; +static int warpAlignShift; +static int warpBitShiftTable[32]; +static int warpSrcMask; +static int warpSrcShift; +static int width; + +/*** Function Prototypes ***/ +static int OLDrgbDiffwith(int sourceWord, int destinationWord); +static int OLDtallyIntoMapwith(int sourceWord, int destinationWord); +static int addWordwith(int sourceWord, int destinationWord); +static int affectedBottom(void); +static int affectedLeft(void); +static int affectedRight(void); +static int affectedTop(void); +static int alphaBlendwith(int sourceWord, int destinationWord); +static int alphaBlendConstwith(int sourceWord, int destinationWord); +static int alphaBlendConstwithpaintMode(int sourceWord, int destinationWord, int paintMode); +static int alphaBlendScaledwith(int sourceWord, int destinationWord); +static int alphaPaintConstwith(int sourceWord, int destinationWord); +static int alphaSourceBlendBits16(void); +static int alphaSourceBlendBits32(void); +static int alphaSourceBlendBits8(void); +static int bitAndwith(int sourceWord, int destinationWord); +static int bitAndInvertwith(int sourceWord, int destinationWord); +static int bitInvertAndwith(int sourceWord, int destinationWord); +static int bitInvertAndInvertwith(int sourceWord, int destinationWord); +static int bitInvertDestinationwith(int sourceWord, int destinationWord); +static int bitInvertOrwith(int sourceWord, int destinationWord); +static int bitInvertOrInvertwith(int sourceWord, int destinationWord); +static int bitInvertSourcewith(int sourceWord, int destinationWord); +static int bitInvertXorwith(int sourceWord, int destinationWord); +static int bitOrwith(int sourceWord, int destinationWord); +static int bitOrInvertwith(int sourceWord, int destinationWord); +static int bitXorwith(int sourceWord, int destinationWord); +static int checkSourceOverlap(void); +static int clearWordwith(int source, int destination); +static int clipRange(void); +#pragma export on +EXPORT(int) copyBits(void); +EXPORT(int) copyBitsFromtoat(int startX, int stopX, int yValue); +#pragma export off +static int copyBitsLockedAndClipped(void); +static int copyLoop(void); +static int copyLoopNoSource(void); +static int copyLoopPixMap(void); +static unsigned int * default8To32Table(void); +static int deltaFromtonSteps(int x1, int x2, int n); +static int destMaskAndPointerInit(void); +static int destinationWordwith(int sourceWord, int destinationWord); +static int dither32To16threshold(int srcWord, int ditherValue); +static int drawLoopXY(int xDelta, int yDelta); +static int dstLongAt(int idx); +static int dstLongAtput(int idx, int value); +static int dstLongAtputmask(int idx, int srcValue, int dstMask); +static int fetchIntOrFloatofObject(int fieldIndex, int objectPointer); +static int fetchIntOrFloatofObjectifNil(int fieldIndex, int objectPointer, int defaultValue); +static int fixAlphawith(int sourceWord, int destinationWord); +#pragma export on +EXPORT(const char*) getModuleName(void); +#pragma export off +static int halftoneAt(int idx); +static int halt(void); +static int ignoreSourceOrHalftone(int formPointer); +static int initBBOpTable(void); +#pragma export on +EXPORT(int) initialiseModule(void); +#pragma export off +static int isIdentityMapwith(int *shifts, unsigned int *masks); +static int loadBitBltDestForm(void); +#pragma export on +EXPORT(int) loadBitBltFrom(int bbObj); +#pragma export off +static int loadBitBltFromwarping(int bbObj, int aBool); +static int loadBitBltSourceForm(void); +static int loadColorMap(void); +static void * loadColorMapShiftOrMaskFrom(int mapOop); +static int loadHalftoneForm(void); +static int loadSurfacePlugin(void); +static int loadWarpBltFrom(int bbObj); +static int lockSurfaces(void); +static int mapPixelflags(int sourcePixel, int mapperFlags); +static int mergewith(int sourceWord, int destinationWord); +#pragma export on +EXPORT(int) moduleUnloaded(char * aModuleName); +#pragma export off +static int msg(char *s); +static int partitionedANDtonBitsnPartitions(int word1, int word2, int nBits, int nParts); +static int partitionedAddtonBitsnPartitions(int word1, int word2, int nBits, int nParts); +static int partitionedMaxwithnBitsnPartitions(int word1, int word2, int nBits, int nParts); +static int partitionedMinwithnBitsnPartitions(int word1, int word2, int nBits, int nParts); +static int partitionedMulwithnBitsnPartitions(int word1, int word2, int nBits, int nParts); +static int partitionedSubfromnBitsnPartitions(int word1, int word2, int nBits, int nParts); +static int performCopyLoop(void); +static int pickSourcePixelsflagssrcMaskdestMasksrcShiftIncdstShiftInc(int nPixels, int mapperFlags, int srcMask, int dstMask, int srcShiftInc, int dstShiftInc); +static int pickWarpPixelAtXy(int xx, int yy); +static int pixClearwith(int sourceWord, int destinationWord); +static int pixMaskwith(int sourceWord, int destinationWord); +static int pixPaintwith(int sourceWord, int destinationWord); +static int pixSwapwith(int sourceWord, int destWord); +#pragma export on +EXPORT(int) primitiveCopyBits(void); +EXPORT(int) primitiveDisplayString(void); +EXPORT(int) primitiveDrawLoop(void); +EXPORT(int) primitiveWarpBits(void); +#pragma export off +static int queryDestSurface(int handle); +static int querySourceSurface(int handle); +static int rgbAddwith(int sourceWord, int destinationWord); +static int rgbDiffwith(int sourceWord, int destinationWord); +static int rgbMap16To32(int sourcePixel); +static int rgbMap32To32(int sourcePixel); +static int rgbMapfromto(int sourcePixel, int nBitsIn, int nBitsOut); +static int rgbMapPixelflags(int sourcePixel, int mapperFlags); +static int rgbMaxwith(int sourceWord, int destinationWord); +static int rgbMinwith(int sourceWord, int destinationWord); +static int rgbMinInvertwith(int wordToInvert, int destinationWord); +static int rgbMulwith(int sourceWord, int destinationWord); +static int rgbSubwith(int sourceWord, int destinationWord); +#pragma export on +EXPORT(int) setInterpreter(struct VirtualMachine* anInterpreter); +#pragma export off +static int setupColorMasks(void); +static int setupColorMasksFromto(int srcBits, int targetBits); +static int showDisplayBits(void); +static int sourceSkewAndPointerInit(void); +static int sourceWordwith(int sourceWord, int destinationWord); +static int srcLongAt(int idx); +static int subWordwith(int sourceWord, int destinationWord); +static int tableLookupat(int table, int index); +static int tallyIntoMapwith(int sourceWord, int destinationWord); +static int tallyMapAt(int idx); +static int tallyMapAtput(int idx, int value); +static int tryCopyingBitsQuickly(void); +static int unlockSurfaces(void); +static int warpBits(void); +static int warpLoop(void); +static int warpLoopSetup(void); +static int warpPickSmoothPixelsxDeltahyDeltahxDeltavyDeltavsourceMapsmoothingdstShiftInc(int nPixels, int xDeltah, int yDeltah, int xDeltav, int yDeltav, int sourceMap, int n, int dstShiftInc); +static int warpPickSourcePixelsxDeltahyDeltahxDeltavyDeltavdstShiftIncflags(int nPixels, int xDeltah, int yDeltah, int xDeltav, int yDeltav, int dstShiftInc, int mapperFlags); + + +/* Subract the pixels in the source and destination, color by color, + and return the sum of the absolute value of all the differences. + For non-rgb, XOR the two and return the number of differing pixels. + Note that the region is not clipped to bit boundaries, but only to the + nearest (enclosing) word. This is because copyLoop does not do + pre-merge masking. For accurate results, you must subtract the + values obtained from the left and right fringes. */ + +static int OLDrgbDiffwith(int sourceWord, int destinationWord) { + int diff; + int pixMask; + + if (destDepth < 16) { + diff = sourceWord ^ destinationWord; + pixMask = maskTable[destDepth]; + while (!(diff == 0)) { + if ((diff & pixMask) != 0) { + bitCount += 1; + } + diff = ((unsigned) diff) >> destDepth; + } + return destinationWord; + } + if (destDepth == 16) { + diff = partitionedSubfromnBitsnPartitions(sourceWord, destinationWord, 5, 3); + bitCount = ((bitCount + (diff & 31)) + ((((unsigned) diff) >> 5) & 31)) + ((((unsigned) diff) >> 10) & 31); + diff = partitionedSubfromnBitsnPartitions(((unsigned) sourceWord) >> 16, ((unsigned) destinationWord) >> 16, 5, 3); + bitCount = ((bitCount + (diff & 31)) + ((((unsigned) diff) >> 5) & 31)) + ((((unsigned) diff) >> 10) & 31); + } else { + diff = partitionedSubfromnBitsnPartitions(sourceWord, destinationWord, 8, 3); + bitCount = ((bitCount + (diff & 255)) + ((((unsigned) diff) >> 8) & 255)) + ((((unsigned) diff) >> 16) & 255); + } + return destinationWord; +} + + +/* Tally pixels into the color map. Note that the source should be + specified = destination, in order for the proper color map checks + to be performed at setup. + Note that the region is not clipped to bit boundaries, but only to the + nearest (enclosing) word. This is because copyLoop does not do + pre-merge masking. For accurate results, you must subtract the + values obtained from the left and right fringes. */ + +static int OLDtallyIntoMapwith(int sourceWord, int destinationWord) { + int shiftWord; + int i; + int pixMask; + int mapIndex; + int srcPix; + int destPix; + int d; + int mask; + int srcPix1; + int destPix1; + int d1; + int mask3; + int srcPix2; + int destPix2; + int d2; + int mask4; + + if (!((cmFlags & (1 | 4)) == (1 | 4))) { + return destinationWord; + } + if (destDepth < 16) { + pixMask = (maskTable[destDepth]) & cmMask; + shiftWord = destinationWord; + for (i = 1; i <= destPPW; i += 1) { + mapIndex = shiftWord & pixMask; + cmLookupTable[mapIndex & cmMask] = ((cmLookupTable[mapIndex & cmMask]) + 1); + shiftWord = ((unsigned) shiftWord) >> destDepth; + } + return destinationWord; + } + if (destDepth == 16) { + /* begin rgbMap:from:to: */ + if ((d = cmBitsPerColor - 5) > 0) { + mask = (1 << 5) - 1; + srcPix = (destinationWord & 65535) << d; + mask = mask << d; + destPix = srcPix & mask; + mask = mask << cmBitsPerColor; + srcPix = srcPix << d; + mapIndex = (destPix + (srcPix & mask)) + ((srcPix << d) & (mask << cmBitsPerColor)); + goto l1; + } else { + if (d == 0) { + if (5 == 5) { + mapIndex = (destinationWord & 65535) & 32767; + goto l1; + } + if (5 == 8) { + mapIndex = (destinationWord & 65535) & 16777215; + goto l1; + } + mapIndex = destinationWord & 65535; + goto l1; + } + if ((destinationWord & 65535) == 0) { + mapIndex = destinationWord & 65535; + goto l1; + } + d = 5 - cmBitsPerColor; + mask = (1 << cmBitsPerColor) - 1; + srcPix = ((unsigned) (destinationWord & 65535)) >> d; + destPix = srcPix & mask; + mask = mask << cmBitsPerColor; + srcPix = ((unsigned) srcPix) >> d; + destPix = (destPix + (srcPix & mask)) + ((((unsigned) srcPix) >> d) & (mask << cmBitsPerColor)); + if (destPix == 0) { + mapIndex = 1; + goto l1; + } + mapIndex = destPix; + goto l1; + } + l1: /* end rgbMap:from:to: */; + cmLookupTable[mapIndex & cmMask] = ((cmLookupTable[mapIndex & cmMask]) + 1); + /* begin rgbMap:from:to: */ + if ((d1 = cmBitsPerColor - 5) > 0) { + mask3 = (1 << 5) - 1; + srcPix1 = (((unsigned) destinationWord) >> 16) << d1; + mask3 = mask3 << d1; + destPix1 = srcPix1 & mask3; + mask3 = mask3 << cmBitsPerColor; + srcPix1 = srcPix1 << d1; + mapIndex = (destPix1 + (srcPix1 & mask3)) + ((srcPix1 << d1) & (mask3 << cmBitsPerColor)); + goto l2; + } else { + if (d1 == 0) { + if (5 == 5) { + mapIndex = (((unsigned) destinationWord) >> 16) & 32767; + goto l2; + } + if (5 == 8) { + mapIndex = (((unsigned) destinationWord) >> 16) & 16777215; + goto l2; + } + mapIndex = ((unsigned) destinationWord) >> 16; + goto l2; + } + if ((((unsigned) destinationWord) >> 16) == 0) { + mapIndex = ((unsigned) destinationWord) >> 16; + goto l2; + } + d1 = 5 - cmBitsPerColor; + mask3 = (1 << cmBitsPerColor) - 1; + srcPix1 = ((unsigned) (((unsigned) destinationWord) >> 16)) >> d1; + destPix1 = srcPix1 & mask3; + mask3 = mask3 << cmBitsPerColor; + srcPix1 = ((unsigned) srcPix1) >> d1; + destPix1 = (destPix1 + (srcPix1 & mask3)) + ((((unsigned) srcPix1) >> d1) & (mask3 << cmBitsPerColor)); + if (destPix1 == 0) { + mapIndex = 1; + goto l2; + } + mapIndex = destPix1; + goto l2; + } + l2: /* end rgbMap:from:to: */; + cmLookupTable[mapIndex & cmMask] = ((cmLookupTable[mapIndex & cmMask]) + 1); + } else { + /* begin rgbMap:from:to: */ + if ((d2 = cmBitsPerColor - 8) > 0) { + mask4 = (1 << 8) - 1; + srcPix2 = destinationWord << d2; + mask4 = mask4 << d2; + destPix2 = srcPix2 & mask4; + mask4 = mask4 << cmBitsPerColor; + srcPix2 = srcPix2 << d2; + mapIndex = (destPix2 + (srcPix2 & mask4)) + ((srcPix2 << d2) & (mask4 << cmBitsPerColor)); + goto l3; + } else { + if (d2 == 0) { + if (8 == 5) { + mapIndex = destinationWord & 32767; + goto l3; + } + if (8 == 8) { + mapIndex = destinationWord & 16777215; + goto l3; + } + mapIndex = destinationWord; + goto l3; + } + if (destinationWord == 0) { + mapIndex = destinationWord; + goto l3; + } + d2 = 8 - cmBitsPerColor; + mask4 = (1 << cmBitsPerColor) - 1; + srcPix2 = ((unsigned) destinationWord) >> d2; + destPix2 = srcPix2 & mask4; + mask4 = mask4 << cmBitsPerColor; + srcPix2 = ((unsigned) srcPix2) >> d2; + destPix2 = (destPix2 + (srcPix2 & mask4)) + ((((unsigned) srcPix2) >> d2) & (mask4 << cmBitsPerColor)); + if (destPix2 == 0) { + mapIndex = 1; + goto l3; + } + mapIndex = destPix2; + goto l3; + } + l3: /* end rgbMap:from:to: */; + cmLookupTable[mapIndex & cmMask] = ((cmLookupTable[mapIndex & cmMask]) + 1); + } + return destinationWord; +} + +static int addWordwith(int sourceWord, int destinationWord) { + return sourceWord + destinationWord; +} + +static int affectedBottom(void) { + return affectedB; +} + +static int affectedLeft(void) { + return affectedL; +} + +static int affectedRight(void) { + return affectedR; +} + +static int affectedTop(void) { + return affectedT; +} + + +/* Blend sourceWord with destinationWord, assuming both are 32-bit pixels. + The source is assumed to have 255*alpha in the high 8 bits of each pixel, + while the high 8 bits of the destinationWord will be ignored. + The blend produced is alpha*source + (1-alpha)*dest, with + the computation being performed independently on each color + component. The high byte of the result will be 0. */ + +static int alphaBlendwith(int sourceWord, int destinationWord) { + int unAlpha; + int i; + int blend; + int result; + int colorMask; + int alpha; + int shift; + + + /* High 8 bits of source pixel */ + + alpha = ((unsigned) sourceWord) >> 24; + if (alpha == 0) { + return destinationWord; + } + if (alpha == 255) { + return sourceWord; + } + unAlpha = 255 - alpha; + colorMask = 255; + + /* ar 9/9/2000 - include alpha in computation */ + + result = 0; + for (i = 1; i <= 4; i += 1) { + shift = (i - 1) * 8; + blend = ((((((((unsigned) sourceWord) >> shift) & colorMask) * alpha) + (((((unsigned) destinationWord) >> shift) & colorMask) * unAlpha)) + 254) / 255) & colorMask; + result = result | (blend << shift); + } + return result; +} + +static int alphaBlendConstwith(int sourceWord, int destinationWord) { + return alphaBlendConstwithpaintMode(sourceWord, destinationWord, 0); +} + + +/* Blend sourceWord with destinationWord using a constant alpha. + Alpha is encoded as 0 meaning 0.0, and 255 meaning 1.0. + The blend produced is alpha*source + (1.0-alpha)*dest, with the + computation being performed independently on each color component. + This function could eventually blend into any depth destination, + using the same color averaging and mapping as warpBlt. + paintMode = true means do nothing if the source pixel value is zero. */ +/* This first implementation works with dest depths of 16 and 32 bits only. + Normal color mapping will allow sources of lower depths in this case, + and results can be mapped directly by truncation, so no extra color maps are needed. + To allow storing into any depth will require subsequent addition of two other + colormaps, as is the case with WarpBlt. */ + +static int alphaBlendConstwithpaintMode(int sourceWord, int destinationWord, int paintMode) { + int unAlpha; + int i; + int blend; + int sourceShifted; + int result; + int rgbMask; + int destShifted; + int j; + int pixMask; + int maskShifted; + int shift; + int pixBlend; + int bitsPerColor; + int sourcePixVal; + int destPixVal; + + if (destDepth < 16) { + return destinationWord; + } + unAlpha = 255 - sourceAlpha; + pixMask = maskTable[destDepth]; + if (destDepth == 16) { + bitsPerColor = 5; + } else { + bitsPerColor = 8; + } + rgbMask = (1 << bitsPerColor) - 1; + maskShifted = destMask; + destShifted = destinationWord; + sourceShifted = sourceWord; + result = destinationWord; + if (destPPW == 1) { + if (!(paintMode && (sourceWord == 0))) { + result = 0; + for (i = 1; i <= 4; i += 1) { + shift = (i - 1) * 8; + blend = ((((((((unsigned) sourceWord) >> shift) & rgbMask) * sourceAlpha) + (((((unsigned) destinationWord) >> shift) & rgbMask) * unAlpha)) + 254) / 255) & rgbMask; + result = result | (blend << shift); + } + } + } else { + for (j = 1; j <= destPPW; j += 1) { + sourcePixVal = sourceShifted & pixMask; + if (!(((maskShifted & pixMask) == 0) || (paintMode && (sourcePixVal == 0)))) { + destPixVal = destShifted & pixMask; + pixBlend = 0; + for (i = 1; i <= 3; i += 1) { + shift = (i - 1) * bitsPerColor; + blend = ((((((((unsigned) sourcePixVal) >> shift) & rgbMask) * sourceAlpha) + (((((unsigned) destPixVal) >> shift) & rgbMask) * unAlpha)) + 254) / 255) & rgbMask; + pixBlend = pixBlend | (blend << shift); + } + if (destDepth == 16) { + result = (result & (~(pixMask << ((j - 1) * 16)))) | (pixBlend << ((j - 1) * 16)); + } else { + result = pixBlend; + } + } + maskShifted = ((unsigned) maskShifted) >> destDepth; + sourceShifted = ((unsigned) sourceShifted) >> destDepth; + destShifted = ((unsigned) destShifted) >> destDepth; + } + } + return result; +} + + +/* Blend sourceWord with destinationWord using the alpha value from sourceWord. + Alpha is encoded as 0 meaning 0.0, and 255 meaning 1.0. + In contrast to alphaBlend:with: the color produced is + + srcColor + (1-srcAlpha) * dstColor + + e.g., it is assumed that the source color is already scaled. */ + +static int alphaBlendScaledwith(int sourceWord, int destinationWord) { + int unAlpha; + int g; + int srcMask; + int b; + int dstMask; + int r; + int a; + + + /* High 8 bits of source pixel */ + + unAlpha = 255 - (((unsigned) sourceWord) >> 24); + dstMask = destinationWord; + srcMask = sourceWord; + b = (((unsigned) ((dstMask & 255) * unAlpha)) >> 8) + (srcMask & 255); + if (b > 255) { + b = 255; + } + dstMask = ((unsigned) dstMask) >> 8; + srcMask = ((unsigned) srcMask) >> 8; + g = (((unsigned) ((dstMask & 255) * unAlpha)) >> 8) + (srcMask & 255); + if (g > 255) { + g = 255; + } + dstMask = ((unsigned) dstMask) >> 8; + srcMask = ((unsigned) srcMask) >> 8; + r = (((unsigned) ((dstMask & 255) * unAlpha)) >> 8) + (srcMask & 255); + if (r > 255) { + r = 255; + } + dstMask = ((unsigned) dstMask) >> 8; + srcMask = ((unsigned) srcMask) >> 8; + a = (((unsigned) ((dstMask & 255) * unAlpha)) >> 8) + (srcMask & 255); + if (a > 255) { + a = 255; + } + return (((((a << 8) + r) << 8) + g) << 8) + b; +} + +static int alphaPaintConstwith(int sourceWord, int destinationWord) { + if (sourceWord == 0) { + return destinationWord; + } + return alphaBlendConstwithpaintMode(sourceWord, destinationWord, 1); +} + + +/* This version assumes + combinationRule = 34 + sourcePixSize = 32 + destPixSize = 16 + sourceForm ~= destForm. + */ + +static int alphaSourceBlendBits16(void) { + int dstY; + int ditherThreshold; + int srcY; + int sourceWord; + int deltaY; + int ditherBase; + int dstIndex; + int dstMask; + int destWord; + int srcIndex; + int srcAlpha; + int deltaX; + int srcShift; + int ditherIndex; + int pv; + int value; + int out; + int threshold; + int pv1; + int value1; + int out1; + int threshold1; + int dstValue; + int dstValue1; + + + /* So we can pre-decrement */ + + deltaY = bbH + 1; + srcY = sy; + dstY = dy; + srcShift = (dx & 1) * 16; + if (destMSB) { + srcShift = 16 - srcShift; + } + + /* This is the outer loop */ + + mask1 = 65535 << (16 - srcShift); + while ((deltaY -= 1) != 0) { + srcIndex = (sourceBits + (srcY * sourcePitch)) + (sx * 4); + dstIndex = (destBits + (dstY * destPitch)) + ((((int) dx >> 1)) * 4); + ditherBase = (dstY & 3) * 4; + + /* For pre-increment */ + + ditherIndex = (sx & 3) - 1; + + /* So we can pre-decrement */ + + deltaX = bbW + 1; + dstMask = mask1; + if (dstMask == 65535) { + srcShift = 16; + } else { + srcShift = 0; + } + while ((deltaX -= 1) != 0) { + ditherThreshold = ditherMatrix4x4[ditherBase + (ditherIndex = (ditherIndex + 1) & 3)]; + sourceWord = longAt(srcIndex); + srcAlpha = ((unsigned) sourceWord) >> 24; + if (srcAlpha == 255) { + /* begin dither32To16:threshold: */ + pv = sourceWord & 255; + threshold = ditherThresholds16[pv & 7]; + value = ditherValues16[((unsigned) pv >> 3)]; + if (ditherThreshold < threshold) { + out = value + 1; + } else { + out = value; + } + pv = (((unsigned) sourceWord >> 8)) & 255; + threshold = ditherThresholds16[pv & 7]; + value = ditherValues16[((unsigned) pv >> 3)]; + if (ditherThreshold < threshold) { + out = out | (((unsigned) (value + 1) << 5)); + } else { + out = out | (((unsigned) value << 5)); + } + pv = (((unsigned) sourceWord >> 16)) & 255; + threshold = ditherThresholds16[pv & 7]; + value = ditherValues16[((unsigned) pv >> 3)]; + if (ditherThreshold < threshold) { + out = out | (((unsigned) (value + 1) << 10)); + } else { + out = out | (((unsigned) value << 10)); + } + sourceWord = out; + if (sourceWord == 0) { + sourceWord = 1; + } + + /* Store masked value */ + + sourceWord = sourceWord << srcShift; + /* begin dstLongAt:put:mask: */ + dstValue = longAt(dstIndex); + dstValue = dstValue & dstMask; + dstValue = dstValue | sourceWord; + longAtput(dstIndex, dstValue); + } else { + if (srcAlpha == 0) { + null; + } else { + destWord = longAt(dstIndex); + destWord = destWord & (~dstMask); + + /* Expand from 16 to 32 bit by adding zero bits */ + + destWord = ((unsigned) destWord) >> srcShift; + + /* Mix colors */ + + destWord = ((((unsigned) (destWord & 31744) << 9)) | (((unsigned) (destWord & 992) << 6))) | ((((unsigned) (destWord & 31) << 3)) | 4278190080U); + + /* And dither */ + + sourceWord = alphaBlendScaledwith(sourceWord, destWord); + /* begin dither32To16:threshold: */ + pv1 = sourceWord & 255; + threshold1 = ditherThresholds16[pv1 & 7]; + value1 = ditherValues16[((unsigned) pv1 >> 3)]; + if (ditherThreshold < threshold1) { + out1 = value1 + 1; + } else { + out1 = value1; + } + pv1 = (((unsigned) sourceWord >> 8)) & 255; + threshold1 = ditherThresholds16[pv1 & 7]; + value1 = ditherValues16[((unsigned) pv1 >> 3)]; + if (ditherThreshold < threshold1) { + out1 = out1 | (((unsigned) (value1 + 1) << 5)); + } else { + out1 = out1 | (((unsigned) value1 << 5)); + } + pv1 = (((unsigned) sourceWord >> 16)) & 255; + threshold1 = ditherThresholds16[pv1 & 7]; + value1 = ditherValues16[((unsigned) pv1 >> 3)]; + if (ditherThreshold < threshold1) { + out1 = out1 | (((unsigned) (value1 + 1) << 10)); + } else { + out1 = out1 | (((unsigned) value1 << 10)); + } + sourceWord = out1; + if (sourceWord == 0) { + sourceWord = 1; + } + + /* Store back */ + + sourceWord = sourceWord << srcShift; + /* begin dstLongAt:put:mask: */ + dstValue1 = longAt(dstIndex); + dstValue1 = dstValue1 & dstMask; + dstValue1 = dstValue1 | sourceWord; + longAtput(dstIndex, dstValue1); + } + } + srcIndex += 4; + if (destMSB) { + if (srcShift == 0) { + dstIndex += 4; + } + } else { + if (!(srcShift == 0)) { + dstIndex += 4; + } + } + + /* Toggle between 0 and 16 */ + + srcShift = srcShift ^ 16; + dstMask = ~dstMask; + } + srcY += 1; + dstY += 1; + } +} + + +/* This version assumes + combinationRule = 34 + sourcePixSize = destPixSize = 32 + sourceForm ~= destForm. + Note: The inner loop has been optimized for dealing + with the special cases of srcAlpha = 0.0 and srcAlpha = 1.0 + */ + +static int alphaSourceBlendBits32(void) { + int dstY; + int srcY; + register int sourceWord; + int deltaY; + register int dstIndex; + int destWord; + register int srcIndex; + int srcAlpha; + register int deltaX; + + + /* So we can pre-decrement */ + + deltaY = bbH + 1; + srcY = sy; + + /* This is the outer loop */ + + dstY = dy; + while ((deltaY -= 1) != 0) { + srcIndex = (sourceBits + (srcY * sourcePitch)) + (sx * 4); + dstIndex = (destBits + (dstY * destPitch)) + (dx * 4); + + /* So we can pre-decrement */ + /* This is the inner loop */ + + deltaX = bbW + 1; + while ((deltaX -= 1) != 0) { + sourceWord = longAt(srcIndex); + srcAlpha = ((unsigned) sourceWord) >> 24; + if (srcAlpha == 255) { + longAtput(dstIndex, sourceWord); + srcIndex += 4; + + /* Now copy as many words as possible with alpha = 255 */ + + dstIndex += 4; + while (((deltaX -= 1) != 0) && ((((unsigned) (sourceWord = longAt(srcIndex))) >> 24) == 255)) { + longAtput(dstIndex, sourceWord); + srcIndex += 4; + dstIndex += 4; + } + deltaX += 1; + } else { + if (srcAlpha == 0) { + srcIndex += 4; + + /* Now skip as many words as possible, */ + + dstIndex += 4; + while (((deltaX -= 1) != 0) && ((((unsigned) (sourceWord = longAt(srcIndex))) >> 24) == 0)) { + srcIndex += 4; + dstIndex += 4; + } + deltaX += 1; + } else { + destWord = longAt(dstIndex); + destWord = alphaBlendScaledwith(sourceWord, destWord); + longAtput(dstIndex, destWord); + srcIndex += 4; + dstIndex += 4; + } + } + } + srcY += 1; + dstY += 1; + } +} + + +/* This version assumes + combinationRule = 34 + sourcePixSize = 32 + destPixSize = 8 + sourceForm ~= destForm. + Note: This is not real blending since we don't have the source colors available. + */ + +static int alphaSourceBlendBits8(void) { + int dstY; + int srcY; + int sourceWord; + int deltaY; + int dstIndex; + int dstMask; + int mapperFlags; + int destWord; + unsigned int *mappingTable; + int srcIndex; + int srcAlpha; + int adjust; + int deltaX; + int srcShift; + int pv; + int val; + int dstValue; + + mappingTable = default8To32Table(); + mapperFlags = cmFlags & (~8); + + /* So we can pre-decrement */ + + deltaY = bbH + 1; + srcY = sy; + dstY = dy; + mask1 = (dx & 3) * 8; + if (destMSB) { + mask1 = 24 - mask1; + } + mask2 = 4294967295U ^ (255 << mask1); + if ((dx & 1) == 0) { + adjust = 0; + } else { + adjust = 522133279; + } + if ((dy & 1) == 0) { + adjust = adjust ^ 522133279; + } + while ((deltaY -= 1) != 0) { + adjust = adjust ^ 522133279; + srcIndex = (sourceBits + (srcY * sourcePitch)) + (sx * 4); + dstIndex = (destBits + (dstY * destPitch)) + ((((int) dx >> 2)) * 4); + + /* So we can pre-decrement */ + + deltaX = bbW + 1; + srcShift = mask1; + + /* This is the inner loop */ + + dstMask = mask2; + while ((deltaX -= 1) != 0) { + sourceWord = ((longAt(srcIndex)) & (~adjust)) + adjust; + srcAlpha = ((unsigned) sourceWord) >> 24; + if (srcAlpha > 31) { + if (srcAlpha < 224) { + destWord = longAt(dstIndex); + destWord = destWord & (~dstMask); + destWord = ((unsigned) destWord) >> srcShift; + destWord = mappingTable[destWord]; + sourceWord = alphaBlendScaledwith(sourceWord, destWord); + } + /* begin mapPixel:flags: */ + pv = sourceWord; + if ((mapperFlags & 1) != 0) { + if ((mapperFlags & 2) != 0) { + /* begin rgbMapPixel:flags: */ + val = (((cmShiftTable[0]) < 0) ? ((unsigned) (sourceWord & (cmMaskTable[0])) >> -(cmShiftTable[0])) : ((unsigned) (sourceWord & (cmMaskTable[0])) << (cmShiftTable[0]))); + val = val | ((((cmShiftTable[1]) < 0) ? ((unsigned) (sourceWord & (cmMaskTable[1])) >> -(cmShiftTable[1])) : ((unsigned) (sourceWord & (cmMaskTable[1])) << (cmShiftTable[1])))); + val = val | ((((cmShiftTable[2]) < 0) ? ((unsigned) (sourceWord & (cmMaskTable[2])) >> -(cmShiftTable[2])) : ((unsigned) (sourceWord & (cmMaskTable[2])) << (cmShiftTable[2])))); + pv = val | ((((cmShiftTable[3]) < 0) ? ((unsigned) (sourceWord & (cmMaskTable[3])) >> -(cmShiftTable[3])) : ((unsigned) (sourceWord & (cmMaskTable[3])) << (cmShiftTable[3])))); + if ((pv == 0) && (sourceWord != 0)) { + pv = 1; + } + } + if ((mapperFlags & 4) != 0) { + pv = cmLookupTable[pv & cmMask]; + } + } + sourceWord = pv; + + /* Store back */ + + sourceWord = sourceWord << srcShift; + /* begin dstLongAt:put:mask: */ + dstValue = longAt(dstIndex); + dstValue = dstValue & dstMask; + dstValue = dstValue | sourceWord; + longAtput(dstIndex, dstValue); + } + srcIndex += 4; + if (destMSB) { + if (srcShift == 0) { + dstIndex += 4; + srcShift = 24; + dstMask = 16777215; + } else { + srcShift -= 8; + dstMask = (((unsigned) dstMask) >> 8) | 4278190080U; + } + } else { + if (srcShift == 32) { + dstIndex += 4; + srcShift = 0; + dstMask = 4294967040U; + } else { + srcShift += 8; + dstMask = (dstMask << 8) | 255; + } + } + adjust = adjust ^ 522133279; + } + srcY += 1; + dstY += 1; + } +} + +static int bitAndwith(int sourceWord, int destinationWord) { + return sourceWord & destinationWord; +} + +static int bitAndInvertwith(int sourceWord, int destinationWord) { + return sourceWord & (~destinationWord); +} + +static int bitInvertAndwith(int sourceWord, int destinationWord) { + return (~sourceWord) & destinationWord; +} + +static int bitInvertAndInvertwith(int sourceWord, int destinationWord) { + return (~sourceWord) & (~destinationWord); +} + +static int bitInvertDestinationwith(int sourceWord, int destinationWord) { + return ~destinationWord; +} + +static int bitInvertOrwith(int sourceWord, int destinationWord) { + return (~sourceWord) | destinationWord; +} + +static int bitInvertOrInvertwith(int sourceWord, int destinationWord) { + return (~sourceWord) | (~destinationWord); +} + +static int bitInvertSourcewith(int sourceWord, int destinationWord) { + return ~sourceWord; +} + +static int bitInvertXorwith(int sourceWord, int destinationWord) { + return (~sourceWord) ^ destinationWord; +} + +static int bitOrwith(int sourceWord, int destinationWord) { + return sourceWord | destinationWord; +} + +static int bitOrInvertwith(int sourceWord, int destinationWord) { + return sourceWord | (~destinationWord); +} + +static int bitXorwith(int sourceWord, int destinationWord) { + return sourceWord ^ destinationWord; +} + + +/* check for possible overlap of source and destination */ +/* ar 10/19/1999: This method requires surfaces to be locked. */ + +static int checkSourceOverlap(void) { + int t; + + if ((sourceForm == destForm) && (dy >= sy)) { + if (dy > sy) { + vDir = -1; + sy = (sy + bbH) - 1; + dy = (dy + bbH) - 1; + } else { + if ((dy == sy) && (dx > sx)) { + hDir = -1; + + /* start at right */ + + sx = (sx + bbW) - 1; + + /* and fix up masks */ + + dx = (dx + bbW) - 1; + if (nWords > 1) { + t = mask1; + mask1 = mask2; + mask2 = t; + } + } + } + destIndex = (destBits + (dy * destPitch)) + ((dx / destPPW) * 4); + destDelta = (destPitch * vDir) - (4 * (nWords * hDir)); + } +} + +static int clearWordwith(int source, int destination) { + return 0; +} + + +/* clip and adjust source origin and extent appropriately */ +/* first in x */ + +static int clipRange(void) { + if (destX >= clipX) { + sx = sourceX; + dx = destX; + bbW = width; + } else { + sx = sourceX + (clipX - destX); + bbW = width - (clipX - destX); + dx = clipX; + } + if ((dx + bbW) > (clipX + clipWidth)) { + bbW -= (dx + bbW) - (clipX + clipWidth); + } + if (destY >= clipY) { + sy = sourceY; + dy = destY; + bbH = height; + } else { + sy = (sourceY + clipY) - destY; + bbH = height - (clipY - destY); + dy = clipY; + } + if ((dy + bbH) > (clipY + clipHeight)) { + bbH -= (dy + bbH) - (clipY + clipHeight); + } + if (noSource) { + return null; + } + if (sx < 0) { + dx -= sx; + bbW += sx; + sx = 0; + } + if ((sx + bbW) > sourceWidth) { + bbW -= (sx + bbW) - sourceWidth; + } + if (sy < 0) { + dy -= sy; + bbH += sy; + sy = 0; + } + if ((sy + bbH) > sourceHeight) { + bbH -= (sy + bbH) - sourceHeight; + } +} + + +/* This function is exported for the Balloon engine */ + +EXPORT(int) copyBits(void) { + int done; + int pixPerM1; + int dxLowBits; + int dWid; + int sxLowBits; + int t; + int pixPerM11; + int endBits; + int startBits; + + clipRange(); + if ((bbW <= 0) || (bbH <= 0)) { + affectedL = affectedR = affectedT = affectedB = 0; + return null; + } + if (!(lockSurfaces())) { + return interpreterProxy->primitiveFail(); + } + /* begin copyBitsLockedAndClipped */ + /* begin tryCopyingBitsQuickly */ + if (noSource) { + done = 0; + goto l1; + } + if (!(combinationRule == 34)) { + done = 0; + goto l1; + } + if (!(sourceDepth == 32)) { + done = 0; + goto l1; + } + if (sourceForm == destForm) { + done = 0; + goto l1; + } + if (destDepth < 8) { + done = 0; + goto l1; + } + if ((destDepth == 8) && ((cmFlags & 1) == 0)) { + done = 0; + goto l1; + } + if (destDepth == 32) { + alphaSourceBlendBits32(); + } + if (destDepth == 16) { + alphaSourceBlendBits16(); + } + if (destDepth == 8) { + alphaSourceBlendBits8(); + } + affectedL = dx; + affectedR = dx + bbW; + affectedT = dy; + affectedB = dy + bbH; + done = 1; +l1: /* end tryCopyingBitsQuickly */; + if (done) { + goto l2; + } + if ((combinationRule == 30) || (combinationRule == 31)) { + if ((interpreterProxy->methodArgumentCount()) == 1) { + sourceAlpha = interpreterProxy->stackIntegerValue(0); + if (!((!(interpreterProxy->failed())) && ((sourceAlpha >= 0) && (sourceAlpha <= 255)))) { + interpreterProxy->primitiveFail(); + goto l2; + } + } else { + interpreterProxy->primitiveFail(); + goto l2; + } + } + bitCount = 0; + /* begin performCopyLoop */ + /* begin destMaskAndPointerInit */ + pixPerM11 = destPPW - 1; + startBits = destPPW - (dx & pixPerM11); + if (destMSB) { + mask1 = ((unsigned) 4294967295U) >> (32 - (startBits * destDepth)); + } else { + mask1 = 4294967295U << (32 - (startBits * destDepth)); + } + endBits = (((dx + bbW) - 1) & pixPerM11) + 1; + if (destMSB) { + mask2 = 4294967295U << (32 - (endBits * destDepth)); + } else { + mask2 = ((unsigned) 4294967295U) >> (32 - (endBits * destDepth)); + } + if (bbW < startBits) { + mask1 = mask1 & mask2; + mask2 = 0; + nWords = 1; + } else { + nWords = (((bbW - startBits) + pixPerM11) / destPPW) + 1; + } + hDir = vDir = 1; + destIndex = (destBits + (dy * destPitch)) + ((dx / destPPW) * 4); + destDelta = (destPitch * vDir) - (4 * (nWords * hDir)); + if (noSource) { + copyLoopNoSource(); + } else { + /* begin checkSourceOverlap */ + if ((sourceForm == destForm) && (dy >= sy)) { + if (dy > sy) { + vDir = -1; + sy = (sy + bbH) - 1; + dy = (dy + bbH) - 1; + } else { + if ((dy == sy) && (dx > sx)) { + hDir = -1; + sx = (sx + bbW) - 1; + dx = (dx + bbW) - 1; + if (nWords > 1) { + t = mask1; + mask1 = mask2; + mask2 = t; + } + } + } + destIndex = (destBits + (dy * destPitch)) + ((dx / destPPW) * 4); + destDelta = (destPitch * vDir) - (4 * (nWords * hDir)); + } + if ((sourceDepth != destDepth) || ((cmFlags != 0) || (sourceMSB != destMSB))) { + copyLoopPixMap(); + } else { + /* begin sourceSkewAndPointerInit */ + pixPerM1 = destPPW - 1; + sxLowBits = sx & pixPerM1; + dxLowBits = dx & pixPerM1; + if (hDir > 0) { + dWid = ((bbW < (destPPW - dxLowBits)) ? bbW : (destPPW - dxLowBits)); + preload = (sxLowBits + dWid) > pixPerM1; + } else { + dWid = ((bbW < (dxLowBits + 1)) ? bbW : (dxLowBits + 1)); + preload = ((sxLowBits - dWid) + 1) < 0; + } + if (sourceMSB) { + skew = (sxLowBits - dxLowBits) * destDepth; + } else { + skew = (dxLowBits - sxLowBits) * destDepth; + } + if (preload) { + if (skew < 0) { + skew += 32; + } else { + skew -= 32; + } + } + sourceIndex = (sourceBits + (sy * sourcePitch)) + ((sx / (32 / sourceDepth)) * 4); + sourceDelta = (sourcePitch * vDir) - (4 * (nWords * hDir)); + if (preload) { + sourceDelta -= 4 * hDir; + } + copyLoop(); + } + } + if ((combinationRule == 22) || (combinationRule == 32)) { + affectedL = affectedR = affectedT = affectedB = 0; + } + if (hDir > 0) { + affectedL = dx; + affectedR = dx + bbW; + } else { + affectedL = (dx - bbW) + 1; + affectedR = dx + 1; + } + if (vDir > 0) { + affectedT = dy; + affectedB = dy + bbH; + } else { + affectedT = (dy - bbH) + 1; + affectedB = dy + 1; + } +l2: /* end copyBitsLockedAndClipped */; + unlockSurfaces(); +} + + +/* Support for the balloon engine. */ + +EXPORT(int) copyBitsFromtoat(int startX, int stopX, int yValue) { + destX = startX; + destY = yValue; + sourceX = startX; + width = stopX - startX; + copyBits(); + /* begin showDisplayBits */ + interpreterProxy->showDisplayBitsLeftTopRightBottom(destForm, affectedL, affectedT, affectedR, affectedB); +} + + +/* Perform the actual copyBits operation. + Assume: Surfaces have been locked and clipping was performed. */ + +static int copyBitsLockedAndClipped(void) { + int done; + int pixPerM1; + int dxLowBits; + int dWid; + int sxLowBits; + int t; + int pixPerM11; + int endBits; + int startBits; + + /* begin tryCopyingBitsQuickly */ + if (noSource) { + done = 0; + goto l1; + } + if (!(combinationRule == 34)) { + done = 0; + goto l1; + } + if (!(sourceDepth == 32)) { + done = 0; + goto l1; + } + if (sourceForm == destForm) { + done = 0; + goto l1; + } + if (destDepth < 8) { + done = 0; + goto l1; + } + if ((destDepth == 8) && ((cmFlags & 1) == 0)) { + done = 0; + goto l1; + } + if (destDepth == 32) { + alphaSourceBlendBits32(); + } + if (destDepth == 16) { + alphaSourceBlendBits16(); + } + if (destDepth == 8) { + alphaSourceBlendBits8(); + } + affectedL = dx; + affectedR = dx + bbW; + affectedT = dy; + affectedB = dy + bbH; + done = 1; +l1: /* end tryCopyingBitsQuickly */; + if (done) { + return null; + } + if ((combinationRule == 30) || (combinationRule == 31)) { + if ((interpreterProxy->methodArgumentCount()) == 1) { + sourceAlpha = interpreterProxy->stackIntegerValue(0); + if (!((!(interpreterProxy->failed())) && ((sourceAlpha >= 0) && (sourceAlpha <= 255)))) { + return interpreterProxy->primitiveFail(); + } + } else { + return interpreterProxy->primitiveFail(); + } + } + + /* Choose and perform the actual copy loop. */ + + bitCount = 0; + /* begin performCopyLoop */ + /* begin destMaskAndPointerInit */ + pixPerM11 = destPPW - 1; + startBits = destPPW - (dx & pixPerM11); + if (destMSB) { + mask1 = ((unsigned) 4294967295U) >> (32 - (startBits * destDepth)); + } else { + mask1 = 4294967295U << (32 - (startBits * destDepth)); + } + endBits = (((dx + bbW) - 1) & pixPerM11) + 1; + if (destMSB) { + mask2 = 4294967295U << (32 - (endBits * destDepth)); + } else { + mask2 = ((unsigned) 4294967295U) >> (32 - (endBits * destDepth)); + } + if (bbW < startBits) { + mask1 = mask1 & mask2; + mask2 = 0; + nWords = 1; + } else { + nWords = (((bbW - startBits) + pixPerM11) / destPPW) + 1; + } + hDir = vDir = 1; + destIndex = (destBits + (dy * destPitch)) + ((dx / destPPW) * 4); + destDelta = (destPitch * vDir) - (4 * (nWords * hDir)); + if (noSource) { + copyLoopNoSource(); + } else { + /* begin checkSourceOverlap */ + if ((sourceForm == destForm) && (dy >= sy)) { + if (dy > sy) { + vDir = -1; + sy = (sy + bbH) - 1; + dy = (dy + bbH) - 1; + } else { + if ((dy == sy) && (dx > sx)) { + hDir = -1; + sx = (sx + bbW) - 1; + dx = (dx + bbW) - 1; + if (nWords > 1) { + t = mask1; + mask1 = mask2; + mask2 = t; + } + } + } + destIndex = (destBits + (dy * destPitch)) + ((dx / destPPW) * 4); + destDelta = (destPitch * vDir) - (4 * (nWords * hDir)); + } + if ((sourceDepth != destDepth) || ((cmFlags != 0) || (sourceMSB != destMSB))) { + copyLoopPixMap(); + } else { + /* begin sourceSkewAndPointerInit */ + pixPerM1 = destPPW - 1; + sxLowBits = sx & pixPerM1; + dxLowBits = dx & pixPerM1; + if (hDir > 0) { + dWid = ((bbW < (destPPW - dxLowBits)) ? bbW : (destPPW - dxLowBits)); + preload = (sxLowBits + dWid) > pixPerM1; + } else { + dWid = ((bbW < (dxLowBits + 1)) ? bbW : (dxLowBits + 1)); + preload = ((sxLowBits - dWid) + 1) < 0; + } + if (sourceMSB) { + skew = (sxLowBits - dxLowBits) * destDepth; + } else { + skew = (dxLowBits - sxLowBits) * destDepth; + } + if (preload) { + if (skew < 0) { + skew += 32; + } else { + skew -= 32; + } + } + sourceIndex = (sourceBits + (sy * sourcePitch)) + ((sx / (32 / sourceDepth)) * 4); + sourceDelta = (sourcePitch * vDir) - (4 * (nWords * hDir)); + if (preload) { + sourceDelta -= 4 * hDir; + } + copyLoop(); + } + } + if ((combinationRule == 22) || (combinationRule == 32)) { + affectedL = affectedR = affectedT = affectedB = 0; + } + if (hDir > 0) { + affectedL = dx; + affectedR = dx + bbW; + } else { + affectedL = (dx - bbW) + 1; + affectedR = dx + 1; + } + if (vDir > 0) { + affectedT = dy; + affectedB = dy + bbH; + } else { + affectedT = (dy - bbH) + 1; + affectedB = dy + 1; + } +} + + +/* This version of the inner loop assumes noSource = false. */ + +static int copyLoop(void) { + int mergeWord; + int skewMask; + int notSkewMask; + int word; + int prevWord; + int unskew; + int (*mergeFnwith)(int, int); + int i; + int halftoneWord; + int skewWord; + int y; + int destWord; + int hInc; + int thisWord; + + mergeFnwith = ((int (*)(int, int)) (opTable[combinationRule + 1])); + mergeFnwith; + + /* Byte delta */ + /* degenerate skew fixed for Sparc. 10/20/96 ikp */ + + hInc = hDir * 4; + if (skew == -32) { + skew = unskew = skewMask = 0; + } else { + if (skew < 0) { + unskew = skew + 32; + skewMask = 4294967295U << (0 - skew); + } else { + if (skew == 0) { + unskew = 0; + skewMask = 4294967295U; + } else { + unskew = skew - 32; + skewMask = ((unsigned) 4294967295U) >> skew; + } + } + } + notSkewMask = ~skewMask; + if (noHalftone) { + halftoneWord = 4294967295U; + halftoneHeight = 0; + } else { + halftoneWord = longAt(halftoneBase + ((0 % halftoneHeight) * 4)); + } + y = dy; + for (i = 1; i <= bbH; i += 1) { + if (halftoneHeight > 1) { + halftoneWord = longAt(halftoneBase + ((y % halftoneHeight) * 4)); + y += vDir; + } + if (preload) { + prevWord = longAt(sourceIndex); + sourceIndex += hInc; + } else { + prevWord = 0; + } + destMask = mask1; + + /* pick up next word */ + + thisWord = longAt(sourceIndex); + sourceIndex += hInc; + + /* 32-bit rotate */ + + skewWord = (((unskew < 0) ? ((unsigned) (prevWord & notSkewMask) >> -unskew) : ((unsigned) (prevWord & notSkewMask) << unskew))) | (((skew < 0) ? ((unsigned) (thisWord & skewMask) >> -skew) : ((unsigned) (thisWord & skewMask) << skew))); + prevWord = thisWord; + destWord = longAt(destIndex); + mergeWord = mergeFnwith(skewWord & halftoneWord, destWord); + destWord = (destMask & mergeWord) | (destWord & (~destMask)); + longAtput(destIndex, destWord); + + /* This central horizontal loop requires no store masking */ + + destIndex += hInc; + destMask = 4294967295U; + if (combinationRule == 3) { + if ((skew == 0) && (halftoneWord == 4294967295U)) { + if (hDir == -1) { + for (word = 2; word <= (nWords - 1); word += 1) { + thisWord = longAt(sourceIndex); + sourceIndex += hInc; + longAtput(destIndex, thisWord); + destIndex += hInc; + } + } else { + for (word = 2; word <= (nWords - 1); word += 1) { + longAtput(destIndex, prevWord); + destIndex += hInc; + prevWord = longAt(sourceIndex); + sourceIndex += hInc; + } + } + } else { + for (word = 2; word <= (nWords - 1); word += 1) { + thisWord = longAt(sourceIndex); + sourceIndex += hInc; + + /* 32-bit rotate */ + + skewWord = (((unskew < 0) ? ((unsigned) (prevWord & notSkewMask) >> -unskew) : ((unsigned) (prevWord & notSkewMask) << unskew))) | (((skew < 0) ? ((unsigned) (thisWord & skewMask) >> -skew) : ((unsigned) (thisWord & skewMask) << skew))); + prevWord = thisWord; + longAtput(destIndex, skewWord & halftoneWord); + destIndex += hInc; + } + } + } else { + for (word = 2; word <= (nWords - 1); word += 1) { + + /* pick up next word */ + + thisWord = longAt(sourceIndex); + sourceIndex += hInc; + + /* 32-bit rotate */ + + skewWord = (((unskew < 0) ? ((unsigned) (prevWord & notSkewMask) >> -unskew) : ((unsigned) (prevWord & notSkewMask) << unskew))) | (((skew < 0) ? ((unsigned) (thisWord & skewMask) >> -skew) : ((unsigned) (thisWord & skewMask) << skew))); + prevWord = thisWord; + mergeWord = mergeFnwith(skewWord & halftoneWord, longAt(destIndex)); + longAtput(destIndex, mergeWord); + destIndex += hInc; + } + } + if (nWords > 1) { + destMask = mask2; + + /* pick up next word */ + + thisWord = longAt(sourceIndex); + sourceIndex += hInc; + + /* 32-bit rotate */ + + skewWord = (((unskew < 0) ? ((unsigned) (prevWord & notSkewMask) >> -unskew) : ((unsigned) (prevWord & notSkewMask) << unskew))) | (((skew < 0) ? ((unsigned) (thisWord & skewMask) >> -skew) : ((unsigned) (thisWord & skewMask) << skew))); + destWord = longAt(destIndex); + mergeWord = mergeFnwith(skewWord & halftoneWord, destWord); + destWord = (destMask & mergeWord) | (destWord & (~destMask)); + longAtput(destIndex, destWord); + destIndex += hInc; + } + sourceIndex += sourceDelta; + destIndex += destDelta; + } +} + + +/* Faster copyLoop when source not used. hDir and vDir are both + positive, and perload and skew are unused */ + +static int copyLoopNoSource(void) { + int mergeWord; + int word; + int i; + int (*mergeFnwith)(int, int); + int halftoneWord; + int destWord; + + mergeFnwith = ((int (*)(int, int)) (opTable[combinationRule + 1])); + mergeFnwith; + for (i = 1; i <= bbH; i += 1) { + if (noHalftone) { + halftoneWord = 4294967295U; + } else { + halftoneWord = longAt(halftoneBase + ((((dy + i) - 1) % halftoneHeight) * 4)); + } + destMask = mask1; + destWord = longAt(destIndex); + mergeWord = mergeFnwith(halftoneWord, destWord); + destWord = (destMask & mergeWord) | (destWord & (~destMask)); + longAtput(destIndex, destWord); + + /* This central horizontal loop requires no store masking */ + + destIndex += 4; + destMask = 4294967295U; + if (combinationRule == 3) { + destWord = halftoneWord; + for (word = 2; word <= (nWords - 1); word += 1) { + longAtput(destIndex, destWord); + destIndex += 4; + } + } else { + for (word = 2; word <= (nWords - 1); word += 1) { + destWord = longAt(destIndex); + mergeWord = mergeFnwith(halftoneWord, destWord); + longAtput(destIndex, mergeWord); + destIndex += 4; + } + } + if (nWords > 1) { + destMask = mask2; + destWord = longAt(destIndex); + mergeWord = mergeFnwith(halftoneWord, destWord); + destWord = (destMask & mergeWord) | (destWord & (~destMask)); + longAtput(destIndex, destWord); + destIndex += 4; + } + destIndex += destDelta; + } +} + + +/* This version of the inner loop maps source pixels + to a destination form with different depth. Because it is already + unweildy, the loop is not unrolled as in the other versions. + Preload, skew and skewMask are all overlooked, since pickSourcePixels + delivers its destination word already properly aligned. + Note that pickSourcePixels could be copied in-line at the top of + the horizontal loop, and some of its inits moved out of the loop. */ +/* ar 12/7/1999: + The loop has been rewritten to use only one pickSourcePixels call. + The idea is that the call itself could be inlined. If we decide not + to inline pickSourcePixels we could optimize the loop instead. */ + +static int copyLoopPixMap(void) { + int mergeWord; + int i; + int (*mergeFnwith)(int, int); + int destPixMask; + int nPix; + int endBits; + int nSourceIncs; + int halftoneWord; + int sourcePixMask; + int skewWord; + int words; + int mapperFlags; + int destWord; + int dstShiftInc; + int startBits; + int dstShift; + int srcShiftInc; + int dstShiftLeft; + int srcShift; + int scrStartBits; + int sourcePix; + int nPix1; + int sourceWord; + int destPix; + int destWord1; + int dstShift1; + int srcShift1; + int idx; + int idx1; + int pv; + int val; + + mergeFnwith = ((int (*)(int, int)) (opTable[combinationRule + 1])); + mergeFnwith; + sourcePPW = 32 / sourceDepth; + sourcePixMask = maskTable[sourceDepth]; + destPixMask = maskTable[destDepth]; + mapperFlags = cmFlags & (~8); + sourceIndex = (sourceBits + (sy * sourcePitch)) + ((sx / sourcePPW) * 4); + scrStartBits = sourcePPW - (sx & (sourcePPW - 1)); + if (bbW < scrStartBits) { + nSourceIncs = 0; + } else { + nSourceIncs = ((bbW - scrStartBits) / sourcePPW) + 1; + } + + /* Note following two items were already calculated in destmask setup! */ + + sourceDelta = sourcePitch - (nSourceIncs * 4); + startBits = destPPW - (dx & (destPPW - 1)); + endBits = (((dx + bbW) - 1) & (destPPW - 1)) + 1; + if (bbW < startBits) { + startBits = bbW; + } + srcShift = (sx & (sourcePPW - 1)) * sourceDepth; + dstShift = (dx & (destPPW - 1)) * destDepth; + srcShiftInc = sourceDepth; + dstShiftInc = destDepth; + dstShiftLeft = 0; + if (sourceMSB) { + srcShift = (32 - sourceDepth) - srcShift; + srcShiftInc = 0 - srcShiftInc; + } + if (destMSB) { + dstShift = (32 - destDepth) - dstShift; + dstShiftInc = 0 - dstShiftInc; + dstShiftLeft = 32 - destDepth; + } + for (i = 1; i <= bbH; i += 1) { + if (noHalftone) { + halftoneWord = 4294967295U; + } else { + halftoneWord = longAt(halftoneBase + ((((dy + i) - 1) % halftoneHeight) * 4)); + } + srcBitShift = srcShift; + dstBitShift = dstShift; + destMask = mask1; + + /* Here is the horizontal loop... */ + + nPix = startBits; + words = nWords; + do { + /* begin pickSourcePixels:flags:srcMask:destMask:srcShiftInc:dstShiftInc: */ + sourceWord = longAt(sourceIndex); + destWord1 = 0; + srcShift1 = srcBitShift; + dstShift1 = dstBitShift; + nPix1 = nPix; + if (mapperFlags == (1 | 4)) { + do { + sourcePix = (((unsigned) sourceWord) >> srcShift1) & sourcePixMask; + destPix = (((int*) cmLookupTable))[sourcePix & cmMask]; + destWord1 = destWord1 | ((destPix & destPixMask) << dstShift1); + dstShift1 += dstShiftInc; + if (!(((srcShift1 += srcShiftInc) & 4294967264U) == 0)) { + if (sourceMSB) { + srcShift1 += 32; + } else { + srcShift1 -= 32; + } + /* begin srcLongAt: */ + idx = sourceIndex += 4; + sourceWord = longAt(idx); + } + } while(!((nPix1 -= 1) == 0)); + } else { + do { + sourcePix = (((unsigned) sourceWord) >> srcShift1) & sourcePixMask; + /* begin mapPixel:flags: */ + pv = sourcePix; + if ((mapperFlags & 1) != 0) { + if ((mapperFlags & 2) != 0) { + /* begin rgbMapPixel:flags: */ + val = (((cmShiftTable[0]) < 0) ? ((unsigned) (sourcePix & (cmMaskTable[0])) >> -(cmShiftTable[0])) : ((unsigned) (sourcePix & (cmMaskTable[0])) << (cmShiftTable[0]))); + val = val | ((((cmShiftTable[1]) < 0) ? ((unsigned) (sourcePix & (cmMaskTable[1])) >> -(cmShiftTable[1])) : ((unsigned) (sourcePix & (cmMaskTable[1])) << (cmShiftTable[1])))); + val = val | ((((cmShiftTable[2]) < 0) ? ((unsigned) (sourcePix & (cmMaskTable[2])) >> -(cmShiftTable[2])) : ((unsigned) (sourcePix & (cmMaskTable[2])) << (cmShiftTable[2])))); + pv = val | ((((cmShiftTable[3]) < 0) ? ((unsigned) (sourcePix & (cmMaskTable[3])) >> -(cmShiftTable[3])) : ((unsigned) (sourcePix & (cmMaskTable[3])) << (cmShiftTable[3])))); + if ((pv == 0) && (sourcePix != 0)) { + pv = 1; + } + } + if ((mapperFlags & 4) != 0) { + pv = cmLookupTable[pv & cmMask]; + } + } + destPix = pv; + destWord1 = destWord1 | ((destPix & destPixMask) << dstShift1); + dstShift1 += dstShiftInc; + if (!(((srcShift1 += srcShiftInc) & 4294967264U) == 0)) { + if (sourceMSB) { + srcShift1 += 32; + } else { + srcShift1 -= 32; + } + /* begin srcLongAt: */ + idx1 = sourceIndex += 4; + sourceWord = longAt(idx1); + } + } while(!((nPix1 -= 1) == 0)); + } + srcBitShift = srcShift1; + skewWord = destWord1; + dstBitShift = dstShiftLeft; + if (destMask == 4294967295U) { + mergeWord = mergeFnwith(skewWord & halftoneWord, longAt(destIndex)); + longAtput(destIndex, destMask & mergeWord); + } else { + destWord = longAt(destIndex); + mergeWord = mergeFnwith(skewWord & halftoneWord, destWord & destMask); + destWord = (destMask & mergeWord) | (destWord & (~destMask)); + longAtput(destIndex, destWord); + } + destIndex += 4; + if (words == 2) { + destMask = mask2; + nPix = endBits; + } else { + destMask = 4294967295U; + nPix = destPPW; + } + } while(!((words -= 1) == 0)); + sourceIndex += sourceDelta; + destIndex += destDelta; + } +} + + +/* Return the default translation table from 1..8 bit indexed colors to 32bit */ +/* The table has been generated by the following statements */ +/* | pvs hex | + String streamContents:[:s| + s nextPutAll:'static unsigned int theTable[256] = { '. + pvs _ (Color colorMapIfNeededFrom: 8 to: 32) asArray. + 1 to: pvs size do:[:i| + i > 1 ifTrue:[s nextPutAll:', ']. + (i-1 \\ 8) = 0 ifTrue:[s cr]. + s nextPutAll:'0x'. + hex _ (pvs at: i) printStringBase: 16. + s nextPutAll: (hex copyFrom: 4 to: hex size). + ]. + s nextPutAll:'};'. + ]. */ + +static unsigned int * default8To32Table(void) { + static unsigned int theTable[256] = { +0x0, 0xFF000001, 0xFFFFFFFF, 0xFF808080, 0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 0xFF00FFFF, +0xFFFFFF00, 0xFFFF00FF, 0xFF202020, 0xFF404040, 0xFF606060, 0xFF9F9F9F, 0xFFBFBFBF, 0xFFDFDFDF, +0xFF080808, 0xFF101010, 0xFF181818, 0xFF282828, 0xFF303030, 0xFF383838, 0xFF484848, 0xFF505050, +0xFF585858, 0xFF686868, 0xFF707070, 0xFF787878, 0xFF878787, 0xFF8F8F8F, 0xFF979797, 0xFFA7A7A7, +0xFFAFAFAF, 0xFFB7B7B7, 0xFFC7C7C7, 0xFFCFCFCF, 0xFFD7D7D7, 0xFFE7E7E7, 0xFFEFEFEF, 0xFFF7F7F7, +0xFF000001, 0xFF003300, 0xFF006600, 0xFF009900, 0xFF00CC00, 0xFF00FF00, 0xFF000033, 0xFF003333, +0xFF006633, 0xFF009933, 0xFF00CC33, 0xFF00FF33, 0xFF000066, 0xFF003366, 0xFF006666, 0xFF009966, +0xFF00CC66, 0xFF00FF66, 0xFF000099, 0xFF003399, 0xFF006699, 0xFF009999, 0xFF00CC99, 0xFF00FF99, +0xFF0000CC, 0xFF0033CC, 0xFF0066CC, 0xFF0099CC, 0xFF00CCCC, 0xFF00FFCC, 0xFF0000FF, 0xFF0033FF, +0xFF0066FF, 0xFF0099FF, 0xFF00CCFF, 0xFF00FFFF, 0xFF330000, 0xFF333300, 0xFF336600, 0xFF339900, +0xFF33CC00, 0xFF33FF00, 0xFF330033, 0xFF333333, 0xFF336633, 0xFF339933, 0xFF33CC33, 0xFF33FF33, +0xFF330066, 0xFF333366, 0xFF336666, 0xFF339966, 0xFF33CC66, 0xFF33FF66, 0xFF330099, 0xFF333399, +0xFF336699, 0xFF339999, 0xFF33CC99, 0xFF33FF99, 0xFF3300CC, 0xFF3333CC, 0xFF3366CC, 0xFF3399CC, +0xFF33CCCC, 0xFF33FFCC, 0xFF3300FF, 0xFF3333FF, 0xFF3366FF, 0xFF3399FF, 0xFF33CCFF, 0xFF33FFFF, +0xFF660000, 0xFF663300, 0xFF666600, 0xFF669900, 0xFF66CC00, 0xFF66FF00, 0xFF660033, 0xFF663333, +0xFF666633, 0xFF669933, 0xFF66CC33, 0xFF66FF33, 0xFF660066, 0xFF663366, 0xFF666666, 0xFF669966, +0xFF66CC66, 0xFF66FF66, 0xFF660099, 0xFF663399, 0xFF666699, 0xFF669999, 0xFF66CC99, 0xFF66FF99, +0xFF6600CC, 0xFF6633CC, 0xFF6666CC, 0xFF6699CC, 0xFF66CCCC, 0xFF66FFCC, 0xFF6600FF, 0xFF6633FF, +0xFF6666FF, 0xFF6699FF, 0xFF66CCFF, 0xFF66FFFF, 0xFF990000, 0xFF993300, 0xFF996600, 0xFF999900, +0xFF99CC00, 0xFF99FF00, 0xFF990033, 0xFF993333, 0xFF996633, 0xFF999933, 0xFF99CC33, 0xFF99FF33, +0xFF990066, 0xFF993366, 0xFF996666, 0xFF999966, 0xFF99CC66, 0xFF99FF66, 0xFF990099, 0xFF993399, +0xFF996699, 0xFF999999, 0xFF99CC99, 0xFF99FF99, 0xFF9900CC, 0xFF9933CC, 0xFF9966CC, 0xFF9999CC, +0xFF99CCCC, 0xFF99FFCC, 0xFF9900FF, 0xFF9933FF, 0xFF9966FF, 0xFF9999FF, 0xFF99CCFF, 0xFF99FFFF, +0xFFCC0000, 0xFFCC3300, 0xFFCC6600, 0xFFCC9900, 0xFFCCCC00, 0xFFCCFF00, 0xFFCC0033, 0xFFCC3333, +0xFFCC6633, 0xFFCC9933, 0xFFCCCC33, 0xFFCCFF33, 0xFFCC0066, 0xFFCC3366, 0xFFCC6666, 0xFFCC9966, +0xFFCCCC66, 0xFFCCFF66, 0xFFCC0099, 0xFFCC3399, 0xFFCC6699, 0xFFCC9999, 0xFFCCCC99, 0xFFCCFF99, +0xFFCC00CC, 0xFFCC33CC, 0xFFCC66CC, 0xFFCC99CC, 0xFFCCCCCC, 0xFFCCFFCC, 0xFFCC00FF, 0xFFCC33FF, +0xFFCC66FF, 0xFFCC99FF, 0xFFCCCCFF, 0xFFCCFFFF, 0xFFFF0000, 0xFFFF3300, 0xFFFF6600, 0xFFFF9900, +0xFFFFCC00, 0xFFFFFF00, 0xFFFF0033, 0xFFFF3333, 0xFFFF6633, 0xFFFF9933, 0xFFFFCC33, 0xFFFFFF33, +0xFFFF0066, 0xFFFF3366, 0xFFFF6666, 0xFFFF9966, 0xFFFFCC66, 0xFFFFFF66, 0xFFFF0099, 0xFFFF3399, +0xFFFF6699, 0xFFFF9999, 0xFFFFCC99, 0xFFFFFF99, 0xFFFF00CC, 0xFFFF33CC, 0xFFFF66CC, 0xFFFF99CC, +0xFFFFCCCC, 0xFFFFFFCC, 0xFFFF00FF, 0xFFFF33FF, 0xFFFF66FF, 0xFFFF99FF, 0xFFFFCCFF, 0xFFFFFFFF};; + + return theTable; +} + + +/* Utility routine for computing Warp increments. */ + +static int deltaFromtonSteps(int x1, int x2, int n) { + if (x2 > x1) { + return (((x2 - x1) + 16384) / (n + 1)) + 1; + } else { + if (x2 == x1) { + return 0; + } + return 0 - ((((x1 - x2) + 16384) / (n + 1)) + 1); + } +} + + +/* Compute masks for left and right destination words */ + +static int destMaskAndPointerInit(void) { + int pixPerM1; + int endBits; + int startBits; + + + /* A mask, assuming power of two */ + /* how many pixels in first word */ + + pixPerM1 = destPPW - 1; + startBits = destPPW - (dx & pixPerM1); + if (destMSB) { + mask1 = ((unsigned) 4294967295U) >> (32 - (startBits * destDepth)); + } else { + mask1 = 4294967295U << (32 - (startBits * destDepth)); + } + endBits = (((dx + bbW) - 1) & pixPerM1) + 1; + if (destMSB) { + mask2 = 4294967295U << (32 - (endBits * destDepth)); + } else { + mask2 = ((unsigned) 4294967295U) >> (32 - (endBits * destDepth)); + } + if (bbW < startBits) { + mask1 = mask1 & mask2; + mask2 = 0; + nWords = 1; + } else { + nWords = (((bbW - startBits) + pixPerM1) / destPPW) + 1; + } + + /* defaults for no overlap with source */ + /* calculate byte addr and delta, based on first word of data */ + /* Note pitch is bytes and nWords is longs, not bytes */ + + hDir = vDir = 1; + destIndex = (destBits + (dy * destPitch)) + ((dx / destPPW) * 4); + destDelta = (destPitch * vDir) - (4 * (nWords * hDir)); +} + +static int destinationWordwith(int sourceWord, int destinationWord) { + return destinationWord; +} + + +/* Dither the given 32bit word to 16 bit. Ignore alpha. */ + +static int dither32To16threshold(int srcWord, int ditherValue) { + int pv; + int value; + int out; + int threshold; + + pv = srcWord & 255; + threshold = ditherThresholds16[pv & 7]; + value = ditherValues16[((unsigned) pv >> 3)]; + if (ditherValue < threshold) { + out = value + 1; + } else { + out = value; + } + pv = (((unsigned) srcWord >> 8)) & 255; + threshold = ditherThresholds16[pv & 7]; + value = ditherValues16[((unsigned) pv >> 3)]; + if (ditherValue < threshold) { + out = out | (((unsigned) (value + 1) << 5)); + } else { + out = out | (((unsigned) value << 5)); + } + pv = (((unsigned) srcWord >> 16)) & 255; + threshold = ditherThresholds16[pv & 7]; + value = ditherValues16[((unsigned) pv >> 3)]; + if (ditherValue < threshold) { + out = out | (((unsigned) (value + 1) << 10)); + } else { + out = out | (((unsigned) value << 10)); + } + return out; +} + + +/* This is the primitive implementation of the line-drawing loop. + See the comments in BitBlt>>drawLoopX:Y: */ + +static int drawLoopXY(int xDelta, int yDelta) { + int i; + int py; + int affL; + int dy1; + int affR; + int affB; + int affT; + int dx1; + int px; + int P; + + if (xDelta > 0) { + dx1 = 1; + } else { + if (xDelta == 0) { + dx1 = 0; + } else { + dx1 = -1; + } + } + if (yDelta > 0) { + dy1 = 1; + } else { + if (yDelta == 0) { + dy1 = 0; + } else { + dy1 = -1; + } + } + px = abs(yDelta); + py = abs(xDelta); + + /* init null rectangle */ + + affL = affT = 9999; + affR = affB = -9999; + if (py > px) { + P = ((int) py >> 1); + for (i = 1; i <= py; i += 1) { + destX += dx1; + if ((P -= px) < 0) { + destY += dy1; + P += py; + } + if (i < py) { + copyBits(); + if (interpreterProxy->failed()) { + return null; + } + if ((affectedL < affectedR) && (affectedT < affectedB)) { + affL = ((affL < affectedL) ? affL : affectedL); + affR = ((affR < affectedR) ? affectedR : affR); + affT = ((affT < affectedT) ? affT : affectedT); + affB = ((affB < affectedB) ? affectedB : affB); + if (((affR - affL) * (affB - affT)) > 4000) { + affectedL = affL; + affectedR = affR; + affectedT = affT; + affectedB = affB; + /* begin showDisplayBits */ + interpreterProxy->showDisplayBitsLeftTopRightBottom(destForm, affectedL, affectedT, affectedR, affectedB); + + /* init null rectangle */ + + affL = affT = 9999; + affR = affB = -9999; + } + } + } + } + } else { + P = ((int) px >> 1); + for (i = 1; i <= px; i += 1) { + destY += dy1; + if ((P -= py) < 0) { + destX += dx1; + P += px; + } + if (i < px) { + copyBits(); + if (interpreterProxy->failed()) { + return null; + } + if ((affectedL < affectedR) && (affectedT < affectedB)) { + affL = ((affL < affectedL) ? affL : affectedL); + affR = ((affR < affectedR) ? affectedR : affR); + affT = ((affT < affectedT) ? affT : affectedT); + affB = ((affB < affectedB) ? affectedB : affB); + if (((affR - affL) * (affB - affT)) > 4000) { + affectedL = affL; + affectedR = affR; + affectedT = affT; + affectedB = affB; + /* begin showDisplayBits */ + interpreterProxy->showDisplayBitsLeftTopRightBottom(destForm, affectedL, affectedT, affectedR, affectedB); + + /* init null rectangle */ + + affL = affT = 9999; + affR = affB = -9999; + } + } + } + } + } + affectedL = affL; + affectedR = affR; + affectedT = affT; + + /* store destX, Y back */ + + affectedB = affB; + interpreterProxy->storeIntegerofObjectwithValue(4, bitBltOop, destX); + interpreterProxy->storeIntegerofObjectwithValue(5, bitBltOop, destY); +} + +static int dstLongAt(int idx) { + return longAt(idx); +} + +static int dstLongAtput(int idx, int value) { + return longAtput(idx, value); +} + + +/* Store the given value back into destination form, using dstMask + to mask out the bits to be modified. This is an essiantial + read-modify-write operation on the destination form. */ + +static int dstLongAtputmask(int idx, int srcValue, int dstMask) { + int dstValue; + + dstValue = longAt(idx); + dstValue = dstValue & dstMask; + dstValue = dstValue | srcValue; + longAtput(idx, dstValue); +} + + +/* Return the integer value of the given field of the given object. If the field contains a Float, truncate it and return its integral part. Fail if the given field does not contain a small integer or Float, or if the truncated Float is out of the range of small integers. */ + +static int fetchIntOrFloatofObject(int fieldIndex, int objectPointer) { + double floatValue; + int fieldOop; + + fieldOop = interpreterProxy->fetchPointerofObject(fieldIndex, objectPointer); + if ((fieldOop & 1)) { + return (fieldOop >> 1); + } + floatValue = interpreterProxy->floatValueOf(fieldOop); + if (!((-2.147483648e9 <= floatValue) && (floatValue <= 2.147483647e9))) { + interpreterProxy->primitiveFail(); + return 0; + } + return ((int) floatValue ); +} + + +/* Return the integer value of the given field of the given object. If the field contains a Float, truncate it and return its integral part. Fail if the given field does not contain a small integer or Float, or if the truncated Float is out of the range of small integers. */ + +static int fetchIntOrFloatofObjectifNil(int fieldIndex, int objectPointer, int defaultValue) { + double floatValue; + int fieldOop; + + fieldOop = interpreterProxy->fetchPointerofObject(fieldIndex, objectPointer); + if ((fieldOop & 1)) { + return (fieldOop >> 1); + } + if (fieldOop == (interpreterProxy->nilObject())) { + return defaultValue; + } + floatValue = interpreterProxy->floatValueOf(fieldOop); + if (!((-2.147483648e9 <= floatValue) && (floatValue <= 2.147483647e9))) { + interpreterProxy->primitiveFail(); + return 0; + } + return ((int) floatValue ); +} + + +/* For any non-zero pixel value in destinationWord with zero alpha channel take the alpha from sourceWord and fill it in. Intended for fixing alpha channels left at zero during 16->32 bpp conversions. */ + +static int fixAlphawith(int sourceWord, int destinationWord) { + if (!(destDepth == 32)) { + return destinationWord; + } + if (destinationWord == 0) { + return 0; + } + if (!((destinationWord & 4278190080U) == 0)) { + return destinationWord; + } + return destinationWord | (sourceWord & 4278190080U); +} + + +/* Note: This is hardcoded so it can be run from Squeak. + The module name is used for validating a module *after* + it is loaded to check if it does really contain the module + we're thinking it contains. This is important! */ + +EXPORT(const char*) getModuleName(void) { + return moduleName; +} + + +/* Return a value from the halftone pattern. */ + +static int halftoneAt(int idx) { + return longAt(halftoneBase + ((idx % halftoneHeight) * 4)); +} + +static int halt(void) { + ; +} + +static int ignoreSourceOrHalftone(int formPointer) { + if (formPointer == (interpreterProxy->nilObject())) { + return 1; + } + if (combinationRule == 0) { + return 1; + } + if (combinationRule == 5) { + return 1; + } + if (combinationRule == 10) { + return 1; + } + if (combinationRule == 15) { + return 1; + } + return 0; +} + +static int initBBOpTable(void) { + opTable[0+1] = (int)clearWordwith; + opTable[1+1] = (int)bitAndwith; + opTable[2+1] = (int)bitAndInvertwith; + opTable[3+1] = (int)sourceWordwith; + opTable[4+1] = (int)bitInvertAndwith; + opTable[5+1] = (int)destinationWordwith; + opTable[6+1] = (int)bitXorwith; + opTable[7+1] = (int)bitOrwith; + opTable[8+1] = (int)bitInvertAndInvertwith; + opTable[9+1] = (int)bitInvertXorwith; + opTable[10+1] = (int)bitInvertDestinationwith; + opTable[11+1] = (int)bitOrInvertwith; + opTable[12+1] = (int)bitInvertSourcewith; + opTable[13+1] = (int)bitInvertOrwith; + opTable[14+1] = (int)bitInvertOrInvertwith; + opTable[15+1] = (int)destinationWordwith; + opTable[16+1] = (int)destinationWordwith; + opTable[17+1] = (int)destinationWordwith; + opTable[18+1] = (int)addWordwith; + opTable[19+1] = (int)subWordwith; + opTable[20+1] = (int)rgbAddwith; + opTable[21+1] = (int)rgbSubwith; + opTable[22+1] = (int)OLDrgbDiffwith; + opTable[23+1] = (int)OLDtallyIntoMapwith; + opTable[24+1] = (int)alphaBlendwith; + opTable[25+1] = (int)pixPaintwith; + opTable[26+1] = (int)pixMaskwith; + opTable[27+1] = (int)rgbMaxwith; + opTable[28+1] = (int)rgbMinwith; + opTable[29+1] = (int)rgbMinInvertwith; + opTable[30+1] = (int)alphaBlendConstwith; + opTable[31+1] = (int)alphaPaintConstwith; + opTable[32+1] = (int)rgbDiffwith; + opTable[33+1] = (int)tallyIntoMapwith; + opTable[34+1] = (int)alphaBlendScaledwith; + opTable[35+1] = (int)alphaBlendScaledwith; + opTable[36+1] = (int)alphaBlendScaledwith; + opTable[37+1] = (int)rgbMulwith; + opTable[38+1] = (int)pixSwapwith; + opTable[39+1] = (int)pixClearwith; + opTable[40+1] = (int)fixAlphawith; +} + +EXPORT(int) initialiseModule(void) { + initBBOpTable(); + return 1; +} + + +/* Return true if shiftTable/maskTable define an identity mapping. */ + +static int isIdentityMapwith(int *shifts, unsigned int *masks) { + if ((shifts == null) || (masks == null)) { + return 1; + } + if (((shifts[0]) == 0) && (((shifts[1]) == 0) && (((shifts[2]) == 0) && (((shifts[3]) == 0) && (((masks[0]) == 16711680) && (((masks[1]) == 65280) && (((masks[2]) == 255) && ((masks[3]) == 4278190080U)))))))) { + return 1; + } + return 0; +} + + +/* Load the dest form for BitBlt. Return false if anything is wrong, true otherwise. */ + +static int loadBitBltDestForm(void) { + int destBitsSize; + + destBits = interpreterProxy->fetchPointerofObject(0, destForm); + destWidth = interpreterProxy->fetchIntegerofObject(1, destForm); + destHeight = interpreterProxy->fetchIntegerofObject(2, destForm); + if (!((destWidth >= 0) && (destHeight >= 0))) { + return 0; + } + destDepth = interpreterProxy->fetchIntegerofObject(3, destForm); + destMSB = destDepth > 0; + if (destDepth < 0) { + destDepth = 0 - destDepth; + } + if ((destBits & 1)) { + if (!(queryDestSurface((destBits >> 1)))) { + return 0; + } + destPPW = 32 / destDepth; + destBits = destPitch = 0; + } else { + destPPW = 32 / destDepth; + destPitch = ((destWidth + (destPPW - 1)) / destPPW) * 4; + destBitsSize = interpreterProxy->byteSizeOf(destBits); + if (!((interpreterProxy->isWordsOrBytes(destBits)) && (destBitsSize == (destPitch * destHeight)))) { + return 0; + } + destBits = ((int) (interpreterProxy->firstIndexableField(destBits))); + } + return 1; +} + + +/* Load BitBlt from the oop. + This function is exported for the Balloon engine. */ + +EXPORT(int) loadBitBltFrom(int bbObj) { + return loadBitBltFromwarping(bbObj, 0); +} + + +/* Load context from BitBlt instance. Return false if anything is amiss */ +/* NOTE this should all be changed to minX/maxX coordinates for simpler clipping + -- once it works! */ + +static int loadBitBltFromwarping(int bbObj, int aBool) { + int ok; + int sourceBitsSize; + int formPointer; + int formPointer1; + int destBitsSize; + int halftoneBits; + int oop; + int oldStyle; + int cmOop; + int cmSize; + int mapOop; + int mapOop1; + + bitBltOop = bbObj; + isWarping = aBool; + combinationRule = interpreterProxy->fetchIntegerofObject(3, bitBltOop); + if ((interpreterProxy->failed()) || ((combinationRule < 0) || (combinationRule > (42 - 2)))) { + return 0; + } + if ((combinationRule >= 16) && (combinationRule <= 17)) { + return 0; + } + sourceForm = interpreterProxy->fetchPointerofObject(1, bitBltOop); + /* begin ignoreSourceOrHalftone: */ + formPointer = sourceForm; + if (formPointer == (interpreterProxy->nilObject())) { + noSource = 1; + goto l2; + } + if (combinationRule == 0) { + noSource = 1; + goto l2; + } + if (combinationRule == 5) { + noSource = 1; + goto l2; + } + if (combinationRule == 10) { + noSource = 1; + goto l2; + } + if (combinationRule == 15) { + noSource = 1; + goto l2; + } + noSource = 0; +l2: /* end ignoreSourceOrHalftone: */; + halftoneForm = interpreterProxy->fetchPointerofObject(2, bitBltOop); + /* begin ignoreSourceOrHalftone: */ + formPointer1 = halftoneForm; + if (formPointer1 == (interpreterProxy->nilObject())) { + noHalftone = 1; + goto l3; + } + if (combinationRule == 0) { + noHalftone = 1; + goto l3; + } + if (combinationRule == 5) { + noHalftone = 1; + goto l3; + } + if (combinationRule == 10) { + noHalftone = 1; + goto l3; + } + if (combinationRule == 15) { + noHalftone = 1; + goto l3; + } + noHalftone = 0; +l3: /* end ignoreSourceOrHalftone: */; + destForm = interpreterProxy->fetchPointerofObject(0, bbObj); + if (!((interpreterProxy->isPointers(destForm)) && ((interpreterProxy->slotSizeOf(destForm)) >= 4))) { + return 0; + } + /* begin loadBitBltDestForm */ + destBits = interpreterProxy->fetchPointerofObject(0, destForm); + destWidth = interpreterProxy->fetchIntegerofObject(1, destForm); + destHeight = interpreterProxy->fetchIntegerofObject(2, destForm); + if (!((destWidth >= 0) && (destHeight >= 0))) { + ok = 0; + goto l4; + } + destDepth = interpreterProxy->fetchIntegerofObject(3, destForm); + destMSB = destDepth > 0; + if (destDepth < 0) { + destDepth = 0 - destDepth; + } + if ((destBits & 1)) { + if (!(queryDestSurface((destBits >> 1)))) { + ok = 0; + goto l4; + } + destPPW = 32 / destDepth; + destBits = destPitch = 0; + } else { + destPPW = 32 / destDepth; + destPitch = ((destWidth + (destPPW - 1)) / destPPW) * 4; + destBitsSize = interpreterProxy->byteSizeOf(destBits); + if (!((interpreterProxy->isWordsOrBytes(destBits)) && (destBitsSize == (destPitch * destHeight)))) { + ok = 0; + goto l4; + } + destBits = ((int) (interpreterProxy->firstIndexableField(destBits))); + } + ok = 1; +l4: /* end loadBitBltDestForm */; + if (!(ok)) { + return 0; + } + destX = fetchIntOrFloatofObjectifNil(4, bitBltOop, 0); + destY = fetchIntOrFloatofObjectifNil(5, bitBltOop, 0); + width = fetchIntOrFloatofObjectifNil(6, bitBltOop, destWidth); + height = fetchIntOrFloatofObjectifNil(7, bitBltOop, destHeight); + if (interpreterProxy->failed()) { + return 0; + } + if (noSource) { + sourceX = sourceY = 0; + } else { + if (!((interpreterProxy->isPointers(sourceForm)) && ((interpreterProxy->slotSizeOf(sourceForm)) >= 4))) { + return 0; + } + /* begin loadBitBltSourceForm */ + sourceBits = interpreterProxy->fetchPointerofObject(0, sourceForm); + sourceWidth = fetchIntOrFloatofObject(1, sourceForm); + sourceHeight = fetchIntOrFloatofObject(2, sourceForm); + if (!((sourceWidth >= 0) && (sourceHeight >= 0))) { + ok = 0; + goto l1; + } + sourceDepth = interpreterProxy->fetchIntegerofObject(3, sourceForm); + sourceMSB = sourceDepth > 0; + if (sourceDepth < 0) { + sourceDepth = 0 - sourceDepth; + } + if ((sourceBits & 1)) { + if (!(querySourceSurface((sourceBits >> 1)))) { + ok = 0; + goto l1; + } + sourcePPW = 32 / sourceDepth; + sourceBits = sourcePitch = 0; + } else { + sourcePPW = 32 / sourceDepth; + sourcePitch = ((sourceWidth + (sourcePPW - 1)) / sourcePPW) * 4; + sourceBitsSize = interpreterProxy->byteSizeOf(sourceBits); + if (!((interpreterProxy->isWordsOrBytes(sourceBits)) && (sourceBitsSize == (sourcePitch * sourceHeight)))) { + ok = 0; + goto l1; + } + sourceBits = ((int) (interpreterProxy->firstIndexableField(sourceBits))); + } + ok = 1; + l1: /* end loadBitBltSourceForm */; + if (!(ok)) { + return 0; + } + /* begin loadColorMap */ + cmFlags = cmMask = cmBitsPerColor = 0; + cmShiftTable = null; + cmMaskTable = null; + cmLookupTable = null; + cmOop = interpreterProxy->fetchPointerofObject(14, bitBltOop); + if (cmOop == (interpreterProxy->nilObject())) { + ok = 1; + goto l8; + } + cmFlags = 1; + oldStyle = 0; + if (interpreterProxy->isWords(cmOop)) { + cmSize = interpreterProxy->slotSizeOf(cmOop); + cmLookupTable = interpreterProxy->firstIndexableField(cmOop); + oldStyle = 1; + } else { + if (!((interpreterProxy->isPointers(cmOop)) && ((interpreterProxy->slotSizeOf(cmOop)) >= 3))) { + ok = 0; + goto l8; + } + /* begin loadColorMapShiftOrMaskFrom: */ + mapOop = interpreterProxy->fetchPointerofObject(0, cmOop); + if (mapOop == (interpreterProxy->nilObject())) { + cmShiftTable = null; + goto l6; + } + if ((mapOop & 1)) { + interpreterProxy->primitiveFail(); + cmShiftTable = null; + goto l6; + } + if (!((interpreterProxy->isWords(mapOop)) && ((interpreterProxy->slotSizeOf(mapOop)) == 4))) { + interpreterProxy->primitiveFail(); + cmShiftTable = null; + goto l6; + } + cmShiftTable = interpreterProxy->firstIndexableField(mapOop); + l6: /* end loadColorMapShiftOrMaskFrom: */; + /* begin loadColorMapShiftOrMaskFrom: */ + mapOop1 = interpreterProxy->fetchPointerofObject(1, cmOop); + if (mapOop1 == (interpreterProxy->nilObject())) { + cmMaskTable = null; + goto l7; + } + if ((mapOop1 & 1)) { + interpreterProxy->primitiveFail(); + cmMaskTable = null; + goto l7; + } + if (!((interpreterProxy->isWords(mapOop1)) && ((interpreterProxy->slotSizeOf(mapOop1)) == 4))) { + interpreterProxy->primitiveFail(); + cmMaskTable = null; + goto l7; + } + cmMaskTable = interpreterProxy->firstIndexableField(mapOop1); + l7: /* end loadColorMapShiftOrMaskFrom: */; + oop = interpreterProxy->fetchPointerofObject(2, cmOop); + if (oop == (interpreterProxy->nilObject())) { + cmSize = 0; + } else { + if (!(interpreterProxy->isWords(oop))) { + ok = 0; + goto l8; + } + cmSize = interpreterProxy->slotSizeOf(oop); + cmLookupTable = interpreterProxy->firstIndexableField(oop); + } + cmFlags = cmFlags | 8; + } + if (!((cmSize & (cmSize - 1)) == 0)) { + ok = 0; + goto l8; + } + cmMask = cmSize - 1; + cmBitsPerColor = 0; + if (cmSize == 512) { + cmBitsPerColor = 3; + } + if (cmSize == 4096) { + cmBitsPerColor = 4; + } + if (cmSize == 32768) { + cmBitsPerColor = 5; + } + if (cmSize == 0) { + cmLookupTable = null; + cmMask = 0; + } else { + cmFlags = cmFlags | 4; + } + if (oldStyle) { + setupColorMasks(); + } + if (isIdentityMapwith(cmShiftTable, cmMaskTable)) { + cmMaskTable = null; + cmShiftTable = null; + } else { + cmFlags = cmFlags | 2; + } + ok = 1; + l8: /* end loadColorMap */; + if (!(ok)) { + return 0; + } + if ((cmFlags & 8) == 0) { + setupColorMasks(); + } + sourceX = fetchIntOrFloatofObjectifNil(8, bitBltOop, 0); + sourceY = fetchIntOrFloatofObjectifNil(9, bitBltOop, 0); + } + /* begin loadHalftoneForm */ + if (noHalftone) { + halftoneBase = null; + ok = 1; + goto l5; + } + if ((interpreterProxy->isPointers(halftoneForm)) && ((interpreterProxy->slotSizeOf(halftoneForm)) >= 4)) { + halftoneBits = interpreterProxy->fetchPointerofObject(0, halftoneForm); + halftoneHeight = interpreterProxy->fetchIntegerofObject(2, halftoneForm); + if (!(interpreterProxy->isWords(halftoneBits))) { + noHalftone = 1; + } + } else { + if (!((!(interpreterProxy->isPointers(halftoneForm))) && (interpreterProxy->isWords(halftoneForm)))) { + ok = 0; + goto l5; + } + halftoneBits = halftoneForm; + halftoneHeight = interpreterProxy->slotSizeOf(halftoneBits); + } + halftoneBase = ((int) (interpreterProxy->firstIndexableField(halftoneBits))); + ok = 1; +l5: /* end loadHalftoneForm */; + if (!(ok)) { + return 0; + } + clipX = fetchIntOrFloatofObjectifNil(10, bitBltOop, 0); + clipY = fetchIntOrFloatofObjectifNil(11, bitBltOop, 0); + clipWidth = fetchIntOrFloatofObjectifNil(12, bitBltOop, destWidth); + clipHeight = fetchIntOrFloatofObjectifNil(13, bitBltOop, destHeight); + if (interpreterProxy->failed()) { + return 0; + } + if (clipX < 0) { + clipWidth += clipX; + clipX = 0; + } + if (clipY < 0) { + clipHeight += clipY; + clipY = 0; + } + if ((clipX + clipWidth) > destWidth) { + clipWidth = destWidth - clipX; + } + if ((clipY + clipHeight) > destHeight) { + clipHeight = destHeight - clipY; + } + return 1; +} + + +/* Load the source form for BitBlt. Return false if anything is wrong, true otherwise. */ + +static int loadBitBltSourceForm(void) { + int sourceBitsSize; + + sourceBits = interpreterProxy->fetchPointerofObject(0, sourceForm); + sourceWidth = fetchIntOrFloatofObject(1, sourceForm); + sourceHeight = fetchIntOrFloatofObject(2, sourceForm); + if (!((sourceWidth >= 0) && (sourceHeight >= 0))) { + return 0; + } + sourceDepth = interpreterProxy->fetchIntegerofObject(3, sourceForm); + sourceMSB = sourceDepth > 0; + if (sourceDepth < 0) { + sourceDepth = 0 - sourceDepth; + } + if ((sourceBits & 1)) { + if (!(querySourceSurface((sourceBits >> 1)))) { + return 0; + } + sourcePPW = 32 / sourceDepth; + sourceBits = sourcePitch = 0; + } else { + sourcePPW = 32 / sourceDepth; + sourcePitch = ((sourceWidth + (sourcePPW - 1)) / sourcePPW) * 4; + sourceBitsSize = interpreterProxy->byteSizeOf(sourceBits); + if (!((interpreterProxy->isWordsOrBytes(sourceBits)) && (sourceBitsSize == (sourcePitch * sourceHeight)))) { + return 0; + } + sourceBits = ((int) (interpreterProxy->firstIndexableField(sourceBits))); + } + return 1; +} + + +/* ColorMap, if not nil, must be longWords, and + 2^N long, where N = sourceDepth for 1, 2, 4, 8 bits, + or N = 9, 12, or 15 (3, 4, 5 bits per color) for 16 or 32 bits. */ + +static int loadColorMap(void) { + int oop; + int oldStyle; + int cmOop; + int cmSize; + int mapOop; + int mapOop1; + + cmFlags = cmMask = cmBitsPerColor = 0; + cmShiftTable = null; + cmMaskTable = null; + cmLookupTable = null; + cmOop = interpreterProxy->fetchPointerofObject(14, bitBltOop); + if (cmOop == (interpreterProxy->nilObject())) { + return 1; + } + + /* even if identity or somesuch - may be cleared later */ + + cmFlags = 1; + oldStyle = 0; + if (interpreterProxy->isWords(cmOop)) { + cmSize = interpreterProxy->slotSizeOf(cmOop); + cmLookupTable = interpreterProxy->firstIndexableField(cmOop); + oldStyle = 1; + } else { + if (!((interpreterProxy->isPointers(cmOop)) && ((interpreterProxy->slotSizeOf(cmOop)) >= 3))) { + return 0; + } + /* begin loadColorMapShiftOrMaskFrom: */ + mapOop = interpreterProxy->fetchPointerofObject(0, cmOop); + if (mapOop == (interpreterProxy->nilObject())) { + cmShiftTable = null; + goto l1; + } + if ((mapOop & 1)) { + interpreterProxy->primitiveFail(); + cmShiftTable = null; + goto l1; + } + if (!((interpreterProxy->isWords(mapOop)) && ((interpreterProxy->slotSizeOf(mapOop)) == 4))) { + interpreterProxy->primitiveFail(); + cmShiftTable = null; + goto l1; + } + cmShiftTable = interpreterProxy->firstIndexableField(mapOop); + l1: /* end loadColorMapShiftOrMaskFrom: */; + /* begin loadColorMapShiftOrMaskFrom: */ + mapOop1 = interpreterProxy->fetchPointerofObject(1, cmOop); + if (mapOop1 == (interpreterProxy->nilObject())) { + cmMaskTable = null; + goto l2; + } + if ((mapOop1 & 1)) { + interpreterProxy->primitiveFail(); + cmMaskTable = null; + goto l2; + } + if (!((interpreterProxy->isWords(mapOop1)) && ((interpreterProxy->slotSizeOf(mapOop1)) == 4))) { + interpreterProxy->primitiveFail(); + cmMaskTable = null; + goto l2; + } + cmMaskTable = interpreterProxy->firstIndexableField(mapOop1); + l2: /* end loadColorMapShiftOrMaskFrom: */; + oop = interpreterProxy->fetchPointerofObject(2, cmOop); + if (oop == (interpreterProxy->nilObject())) { + cmSize = 0; + } else { + if (!(interpreterProxy->isWords(oop))) { + return 0; + } + cmSize = interpreterProxy->slotSizeOf(oop); + cmLookupTable = interpreterProxy->firstIndexableField(oop); + } + cmFlags = cmFlags | 8; + } + if (!((cmSize & (cmSize - 1)) == 0)) { + return 0; + } + cmMask = cmSize - 1; + cmBitsPerColor = 0; + if (cmSize == 512) { + cmBitsPerColor = 3; + } + if (cmSize == 4096) { + cmBitsPerColor = 4; + } + if (cmSize == 32768) { + cmBitsPerColor = 5; + } + if (cmSize == 0) { + cmLookupTable = null; + cmMask = 0; + } else { + cmFlags = cmFlags | 4; + } + if (oldStyle) { + setupColorMasks(); + } + if (isIdentityMapwith(cmShiftTable, cmMaskTable)) { + cmMaskTable = null; + cmShiftTable = null; + } else { + cmFlags = cmFlags | 2; + } + return 1; +} + +static void * loadColorMapShiftOrMaskFrom(int mapOop) { + if (mapOop == (interpreterProxy->nilObject())) { + return null; + } + if ((mapOop & 1)) { + interpreterProxy->primitiveFail(); + return null; + } + if (!((interpreterProxy->isWords(mapOop)) && ((interpreterProxy->slotSizeOf(mapOop)) == 4))) { + interpreterProxy->primitiveFail(); + return null; + } + return interpreterProxy->firstIndexableField(mapOop); +} + + +/* Load the halftone form */ + +static int loadHalftoneForm(void) { + int halftoneBits; + + if (noHalftone) { + halftoneBase = null; + return 1; + } + if ((interpreterProxy->isPointers(halftoneForm)) && ((interpreterProxy->slotSizeOf(halftoneForm)) >= 4)) { + halftoneBits = interpreterProxy->fetchPointerofObject(0, halftoneForm); + halftoneHeight = interpreterProxy->fetchIntegerofObject(2, halftoneForm); + if (!(interpreterProxy->isWords(halftoneBits))) { + noHalftone = 1; + } + } else { + if (!((!(interpreterProxy->isPointers(halftoneForm))) && (interpreterProxy->isWords(halftoneForm)))) { + return 0; + } + halftoneBits = halftoneForm; + halftoneHeight = interpreterProxy->slotSizeOf(halftoneBits); + } + halftoneBase = ((int) (interpreterProxy->firstIndexableField(halftoneBits))); + return 1; +} + + +/* Load the surface support plugin */ + +static int loadSurfacePlugin(void) { + querySurfaceFn = interpreterProxy->ioLoadFunctionFrom("ioGetSurfaceFormat", "SurfacePlugin"); + lockSurfaceFn = interpreterProxy->ioLoadFunctionFrom("ioLockSurface", "SurfacePlugin"); + unlockSurfaceFn = interpreterProxy->ioLoadFunctionFrom("ioUnlockSurface", "SurfacePlugin"); + return (querySurfaceFn != 0) && ((lockSurfaceFn != 0) && (unlockSurfaceFn != 0)); +} + +static int loadWarpBltFrom(int bbObj) { + return loadBitBltFromwarping(bbObj, 1); +} + + +/* Get a pointer to the bits of any OS surfaces. */ +/* Notes: + * For equal source/dest handles only one locking operation is performed. + This is to prevent locking of overlapping areas which does not work with + certain APIs (as an example, DirectDraw prevents locking of overlapping areas). + A special case for non-overlapping but equal source/dest handle would + be possible but we would have to transfer this information over to + unlockSurfaces somehow (currently, only one unlock operation is + performed for equal source and dest handles). Also, this would require + a change in the notion of ioLockSurface() which is right now interpreted + as a hint and not as a requirement to lock only the specific portion of + the surface. + + * The arguments in ioLockSurface() provide the implementation with + an explicit hint what area is affected. It can be very useful to + know the max. affected area beforehand if getting the bits requires expensive + copy operations (e.g., like a roundtrip to the X server or a glReadPixel op). + However, the returned pointer *MUST* point to the virtual origin of the surface + and not to the beginning of the rectangle. The promise made by BitBlt + is to never access data outside the given rectangle (aligned to 4byte boundaries!) + so it is okay to return a pointer to the virtual origin that is actually outside + the valid memory area. + + * The area provided in ioLockSurface() is already clipped (e.g., it will always + be inside the source and dest boundingBox) but it is not aligned to word boundaries + yet. It is up to the support code to compute accurate alignment if necessary. + + * Warping always requires the entire source surface to be locked because + there is no beforehand knowledge about what area will actually be traversed. + + */ + +static int lockSurfaces(void) { + int sourceHandle; + int destHandle; + int b; + int l; + int r; + int t; + int (*fn)(int, int*, int, int, int, int); + + hasSurfaceLock = 0; + if (destBits == 0) { + if (lockSurfaceFn == 0) { + if (!(loadSurfacePlugin())) { + return null; + } + } + fn = ((int (*)(int, int*, int, int, int, int)) lockSurfaceFn); + destHandle = interpreterProxy->fetchIntegerofObject(0, destForm); + if ((sourceBits == 0) && (!noSource)) { + + /* Handle the special case of equal source and dest handles */ + + sourceHandle = interpreterProxy->fetchIntegerofObject(0, sourceForm); + if (sourceHandle == destHandle) { + if (isWarping) { + l = ((sx < dx) ? sx : dx); + r = (((sx < dx) ? dx : sx)) + bbW; + t = ((sy < dy) ? sy : dy); + b = (((sy < sy) ? sy : sy)) + bbH; + sourceBits = fn(sourceHandle, &sourcePitch, l, t, r-l, b-t); + } else { + sourceBits = fn(sourceHandle, &sourcePitch, 0,0, sourceWidth, sourceHeight); + } + destBits = sourceBits; + destPitch = sourcePitch; + hasSurfaceLock = 1; + return destBits != 0; + } + } + destBits = fn(destHandle, &destPitch, dx, dy, bbW, bbH); + hasSurfaceLock = 1; + } + if ((sourceBits == 0) && (!noSource)) { + sourceHandle = interpreterProxy->fetchIntegerofObject(0, sourceForm); + if (lockSurfaceFn == 0) { + if (!(loadSurfacePlugin())) { + return null; + } + } + + /* Warping requiring the entire surface */ + + fn = ((int (*)(int, int*, int, int, int, int)) lockSurfaceFn); + if (isWarping) { + sourceBits = fn(sourceHandle, &sourcePitch, 0, 0, sourceWidth, sourceHeight); + } else { + sourceBits = fn(sourceHandle, &sourcePitch, sx, sy, bbW, bbH); + } + hasSurfaceLock = 1; + } + return (destBits != 0) && ((sourceBits != 0) || (noSource)); +} + + +/* Color map the given source pixel. */ + +static int mapPixelflags(int sourcePixel, int mapperFlags) { + int pv; + int val; + + pv = sourcePixel; + if ((mapperFlags & 1) != 0) { + if ((mapperFlags & 2) != 0) { + /* begin rgbMapPixel:flags: */ + val = (((cmShiftTable[0]) < 0) ? ((unsigned) (sourcePixel & (cmMaskTable[0])) >> -(cmShiftTable[0])) : ((unsigned) (sourcePixel & (cmMaskTable[0])) << (cmShiftTable[0]))); + val = val | ((((cmShiftTable[1]) < 0) ? ((unsigned) (sourcePixel & (cmMaskTable[1])) >> -(cmShiftTable[1])) : ((unsigned) (sourcePixel & (cmMaskTable[1])) << (cmShiftTable[1])))); + val = val | ((((cmShiftTable[2]) < 0) ? ((unsigned) (sourcePixel & (cmMaskTable[2])) >> -(cmShiftTable[2])) : ((unsigned) (sourcePixel & (cmMaskTable[2])) << (cmShiftTable[2])))); + pv = val | ((((cmShiftTable[3]) < 0) ? ((unsigned) (sourcePixel & (cmMaskTable[3])) >> -(cmShiftTable[3])) : ((unsigned) (sourcePixel & (cmMaskTable[3])) << (cmShiftTable[3])))); + if ((pv == 0) && (sourcePixel != 0)) { + pv = 1; + } + } + if ((mapperFlags & 4) != 0) { + pv = cmLookupTable[pv & cmMask]; + } + } + return pv; +} + + +/* Sender warpLoop is too big to include this in-line */ + +static int mergewith(int sourceWord, int destinationWord) { + int (*mergeFnwith)(int, int); + + mergeFnwith = ((int (*)(int, int)) (opTable[combinationRule + 1])); + mergeFnwith; + return mergeFnwith(sourceWord, destinationWord); +} + + +/* The module with the given name was just unloaded. + Make sure we have no dangling references. */ + +EXPORT(int) moduleUnloaded(char * aModuleName) { + if ((strcmp(aModuleName, "SurfacePlugin")) == 0) { + querySurfaceFn = lockSurfaceFn = unlockSurfaceFn = 0; + } +} + +static int msg(char *s) { + fprintf(stderr, "\n%s: %s", moduleName, s); +} + + +/* AND word1 to word2 as nParts partitions of nBits each. + Any field of word1 not all-ones is treated as all-zeroes. + Used for erasing, eg, brush shapes prior to ORing in a color */ + +static int partitionedANDtonBitsnPartitions(int word1, int word2, int nBits, int nParts) { + int i; + int result; + int mask; + + + /* partition mask starts at the right */ + + mask = maskTable[nBits]; + result = 0; + for (i = 1; i <= nParts; i += 1) { + if ((word1 & mask) == mask) { + result = result | (word2 & mask); + } + + /* slide left to next partition */ + + mask = mask << nBits; + } + return result; +} + + +/* Add word1 to word2 as nParts partitions of nBits each. + This is useful for packed pixels, or packed colors */ + +static int partitionedAddtonBitsnPartitions(int word1, int word2, int nBits, int nParts) { + int i; + int result; + int mask; + int sum; + + + /* partition mask starts at the right */ + + mask = maskTable[nBits]; + result = 0; + for (i = 1; i <= nParts; i += 1) { + sum = (word1 & mask) + (word2 & mask); + if (sum <= mask) { + result = result | sum; + } else { + result = result | mask; + } + + /* slide left to next partition */ + + mask = mask << nBits; + } + return result; +} + + +/* Max word1 to word2 as nParts partitions of nBits each */ + +static int partitionedMaxwithnBitsnPartitions(int word1, int word2, int nBits, int nParts) { + int i; + int result; + int mask; + + + /* partition mask starts at the right */ + + mask = maskTable[nBits]; + result = 0; + for (i = 1; i <= nParts; i += 1) { + result = result | ((((word2 & mask) < (word1 & mask)) ? (word1 & mask) : (word2 & mask))); + + /* slide left to next partition */ + + mask = mask << nBits; + } + return result; +} + + +/* Min word1 to word2 as nParts partitions of nBits each */ + +static int partitionedMinwithnBitsnPartitions(int word1, int word2, int nBits, int nParts) { + int i; + int result; + int mask; + + + /* partition mask starts at the right */ + + mask = maskTable[nBits]; + result = 0; + for (i = 1; i <= nParts; i += 1) { + result = result | ((((word2 & mask) < (word1 & mask)) ? (word2 & mask) : (word1 & mask))); + + /* slide left to next partition */ + + mask = mask << nBits; + } + return result; +} + + +/* Multiply word1 with word2 as nParts partitions of nBits each. + This is useful for packed pixels, or packed colors. + Bug in loop version when non-white background */ + +static int partitionedMulwithnBitsnPartitions(int word1, int word2, int nBits, int nParts) { + int sMask; + int result; + int dMask; + int product; + + + /* partition mask starts at the right */ + + sMask = maskTable[nBits]; + dMask = sMask << nBits; + + /* optimized first step */ + + result = ((unsigned) (((((word1 & sMask) + 1) * ((word2 & sMask) + 1)) - 1) & dMask)) >> nBits; + product = (((((((unsigned) word1) >> nBits) & sMask) + 1) * (((((unsigned) word2) >> nBits) & sMask) + 1)) - 1) & dMask; + result = result | (product & dMask); + product = (((((((unsigned) word1) >> (2 * nBits)) & sMask) + 1) * (((((unsigned) word2) >> (2 * nBits)) & sMask) + 1)) - 1) & dMask; + result = result | ((product & dMask) << nBits); + return result; +} + + +/* Subtract word1 from word2 as nParts partitions of nBits each. + This is useful for packed pixels, or packed colors */ + +static int partitionedSubfromnBitsnPartitions(int word1, int word2, int nBits, int nParts) { + int i; + int p2; + int result; + int mask; + int p1; + + + /* partition mask starts at the right */ + + mask = maskTable[nBits]; + result = 0; + for (i = 1; i <= nParts; i += 1) { + p1 = word1 & mask; + p2 = word2 & mask; + if (p1 < p2) { + result = result | (p2 - p1); + } else { + result = result | (p1 - p2); + } + + /* slide left to next partition */ + + mask = mask << nBits; + } + return result; +} + + +/* Based on the values provided during setup choose and + perform the appropriate inner loop function. */ + +static int performCopyLoop(void) { + int pixPerM1; + int dxLowBits; + int dWid; + int sxLowBits; + int t; + int pixPerM11; + int endBits; + int startBits; + + /* begin destMaskAndPointerInit */ + pixPerM11 = destPPW - 1; + startBits = destPPW - (dx & pixPerM11); + if (destMSB) { + mask1 = ((unsigned) 4294967295U) >> (32 - (startBits * destDepth)); + } else { + mask1 = 4294967295U << (32 - (startBits * destDepth)); + } + endBits = (((dx + bbW) - 1) & pixPerM11) + 1; + if (destMSB) { + mask2 = 4294967295U << (32 - (endBits * destDepth)); + } else { + mask2 = ((unsigned) 4294967295U) >> (32 - (endBits * destDepth)); + } + if (bbW < startBits) { + mask1 = mask1 & mask2; + mask2 = 0; + nWords = 1; + } else { + nWords = (((bbW - startBits) + pixPerM11) / destPPW) + 1; + } + hDir = vDir = 1; + destIndex = (destBits + (dy * destPitch)) + ((dx / destPPW) * 4); + destDelta = (destPitch * vDir) - (4 * (nWords * hDir)); + if (noSource) { + copyLoopNoSource(); + } else { + /* begin checkSourceOverlap */ + if ((sourceForm == destForm) && (dy >= sy)) { + if (dy > sy) { + vDir = -1; + sy = (sy + bbH) - 1; + dy = (dy + bbH) - 1; + } else { + if ((dy == sy) && (dx > sx)) { + hDir = -1; + sx = (sx + bbW) - 1; + dx = (dx + bbW) - 1; + if (nWords > 1) { + t = mask1; + mask1 = mask2; + mask2 = t; + } + } + } + destIndex = (destBits + (dy * destPitch)) + ((dx / destPPW) * 4); + destDelta = (destPitch * vDir) - (4 * (nWords * hDir)); + } + if ((sourceDepth != destDepth) || ((cmFlags != 0) || (sourceMSB != destMSB))) { + copyLoopPixMap(); + } else { + /* begin sourceSkewAndPointerInit */ + pixPerM1 = destPPW - 1; + sxLowBits = sx & pixPerM1; + dxLowBits = dx & pixPerM1; + if (hDir > 0) { + dWid = ((bbW < (destPPW - dxLowBits)) ? bbW : (destPPW - dxLowBits)); + preload = (sxLowBits + dWid) > pixPerM1; + } else { + dWid = ((bbW < (dxLowBits + 1)) ? bbW : (dxLowBits + 1)); + preload = ((sxLowBits - dWid) + 1) < 0; + } + if (sourceMSB) { + skew = (sxLowBits - dxLowBits) * destDepth; + } else { + skew = (dxLowBits - sxLowBits) * destDepth; + } + if (preload) { + if (skew < 0) { + skew += 32; + } else { + skew -= 32; + } + } + sourceIndex = (sourceBits + (sy * sourcePitch)) + ((sx / (32 / sourceDepth)) * 4); + sourceDelta = (sourcePitch * vDir) - (4 * (nWords * hDir)); + if (preload) { + sourceDelta -= 4 * hDir; + } + copyLoop(); + } + } +} + + +/* Pick nPix pixels starting at srcBitIndex from the source, map by the + color map, and justify them according to dstBitIndex in the resulting destWord. */ + +static int pickSourcePixelsflagssrcMaskdestMasksrcShiftIncdstShiftInc(int nPixels, int mapperFlags, int srcMask, int dstMask, int srcShiftInc, int dstShiftInc) { + int sourcePix; + int nPix; + int sourceWord; + int destPix; + int destWord; + int dstShift; + int srcShift; + int idx; + int idx1; + int pv; + int val; + + sourceWord = longAt(sourceIndex); + destWord = 0; + + /* Hint: Keep in register */ + + srcShift = srcBitShift; + + /* Hint: Keep in register */ + + dstShift = dstBitShift; + + /* always > 0 so we can use do { } while(--nPix); */ + + nPix = nPixels; + if (mapperFlags == (1 | 4)) { + do { + sourcePix = (((unsigned) sourceWord) >> srcShift) & srcMask; + destPix = (((int*) cmLookupTable))[sourcePix & cmMask]; + + /* adjust dest pix index */ + + destWord = destWord | ((destPix & dstMask) << dstShift); + + /* adjust source pix index */ + + dstShift += dstShiftInc; + if (!(((srcShift += srcShiftInc) & 4294967264U) == 0)) { + if (sourceMSB) { + srcShift += 32; + } else { + srcShift -= 32; + } + /* begin srcLongAt: */ + idx = sourceIndex += 4; + sourceWord = longAt(idx); + } + } while(!((nPix -= 1) == 0)); + } else { + do { + sourcePix = (((unsigned) sourceWord) >> srcShift) & srcMask; + /* begin mapPixel:flags: */ + pv = sourcePix; + if ((mapperFlags & 1) != 0) { + if ((mapperFlags & 2) != 0) { + /* begin rgbMapPixel:flags: */ + val = (((cmShiftTable[0]) < 0) ? ((unsigned) (sourcePix & (cmMaskTable[0])) >> -(cmShiftTable[0])) : ((unsigned) (sourcePix & (cmMaskTable[0])) << (cmShiftTable[0]))); + val = val | ((((cmShiftTable[1]) < 0) ? ((unsigned) (sourcePix & (cmMaskTable[1])) >> -(cmShiftTable[1])) : ((unsigned) (sourcePix & (cmMaskTable[1])) << (cmShiftTable[1])))); + val = val | ((((cmShiftTable[2]) < 0) ? ((unsigned) (sourcePix & (cmMaskTable[2])) >> -(cmShiftTable[2])) : ((unsigned) (sourcePix & (cmMaskTable[2])) << (cmShiftTable[2])))); + pv = val | ((((cmShiftTable[3]) < 0) ? ((unsigned) (sourcePix & (cmMaskTable[3])) >> -(cmShiftTable[3])) : ((unsigned) (sourcePix & (cmMaskTable[3])) << (cmShiftTable[3])))); + if ((pv == 0) && (sourcePix != 0)) { + pv = 1; + } + } + if ((mapperFlags & 4) != 0) { + pv = cmLookupTable[pv & cmMask]; + } + } + destPix = pv; + + /* adjust dest pix index */ + + destWord = destWord | ((destPix & dstMask) << dstShift); + + /* adjust source pix index */ + + dstShift += dstShiftInc; + if (!(((srcShift += srcShiftInc) & 4294967264U) == 0)) { + if (sourceMSB) { + srcShift += 32; + } else { + srcShift -= 32; + } + /* begin srcLongAt: */ + idx1 = sourceIndex += 4; + sourceWord = longAt(idx1); + } + } while(!((nPix -= 1) == 0)); + } + + /* Store back */ + + srcBitShift = srcShift; + return destWord; +} + + +/* Pick a single pixel from the source for WarpBlt. + Note: This method is crucial for WarpBlt speed w/o smoothing + and still relatively important when smoothing is used. */ + +static int pickWarpPixelAtXy(int xx, int yy) { + int x; + int sourcePix; + int sourceWord; + int y; + int srcIndex; + + if ((xx < 0) || ((yy < 0) || (((x = ((unsigned) xx) >> 14) >= sourceWidth) || ((y = ((unsigned) yy) >> 14) >= sourceHeight)))) { + return 0; + } + srcIndex = (sourceBits + (y * sourcePitch)) + ((((unsigned) x) >> warpAlignShift) * 4); + + /* Extract pixel from word */ + + sourceWord = longAt(srcIndex); + srcBitShift = warpBitShiftTable[x & warpAlignMask]; + sourcePix = (((unsigned) sourceWord) >> srcBitShift) & warpSrcMask; + return sourcePix; +} + + +/* Clear all pixels in destinationWord for which the pixels of sourceWord have the same values. Used to clear areas of some constant color to zero. */ + +static int pixClearwith(int sourceWord, int destinationWord) { + int i; + int pv; + int result; + int mask; + int nBits; + + if (destDepth == 32) { + if (sourceWord == destinationWord) { + return 0; + } else { + return destinationWord; + } + } + nBits = destDepth; + + /* partition mask starts at the right */ + + mask = maskTable[nBits]; + result = 0; + for (i = 1; i <= destPPW; i += 1) { + pv = destinationWord & mask; + if ((sourceWord & mask) == pv) { + pv = 0; + } + result = result | pv; + + /* slide left to next partition */ + + mask = mask << nBits; + } + return result; +} + +static int pixMaskwith(int sourceWord, int destinationWord) { + int i; + int result; + int mask; + + /* begin partitionedAND:to:nBits:nPartitions: */ + mask = maskTable[destDepth]; + result = 0; + for (i = 1; i <= destPPW; i += 1) { + if (((~sourceWord) & mask) == mask) { + result = result | (destinationWord & mask); + } + mask = mask << destDepth; + } + return result; +} + +static int pixPaintwith(int sourceWord, int destinationWord) { + if (sourceWord == 0) { + return destinationWord; + } + return sourceWord | (partitionedANDtonBitsnPartitions(~sourceWord, destinationWord, destDepth, destPPW)); +} + + +/* Swap the pixels in destWord */ + +static int pixSwapwith(int sourceWord, int destWord) { + int lowMask; + int i; + int result; + int highMask; + int shift; + + if (destPPW == 1) { + return destWord; + } + result = 0; + + /* mask low pixel */ + + lowMask = (1 << destDepth) - 1; + + /* mask high pixel */ + + highMask = lowMask << ((destPPW - 1) * destDepth); + shift = 32 - destDepth; + result = result | (((destWord & lowMask) << shift) | (((unsigned) (destWord & highMask)) >> shift)); + if (destPPW <= 2) { + return result; + } + for (i = 2; i <= (((int) destPPW >> 1)); i += 1) { + lowMask = lowMask << destDepth; + highMask = ((unsigned) highMask) >> destDepth; + shift -= destDepth * 2; + result = result | (((destWord & lowMask) << shift) | (((unsigned) (destWord & highMask)) >> shift)); + } + return result; +} + + +/* Invoke the copyBits primitive. If the destination is the display, then copy it to the screen. */ + +EXPORT(int) primitiveCopyBits(void) { + int rcvr; + + rcvr = interpreterProxy->stackValue(interpreterProxy->methodArgumentCount()); + if (!(loadBitBltFromwarping(rcvr, 0))) { + return interpreterProxy->primitiveFail(); + } + copyBits(); + if (interpreterProxy->failed()) { + return null; + } + /* begin showDisplayBits */ + interpreterProxy->showDisplayBitsLeftTopRightBottom(destForm, affectedL, affectedT, affectedR, affectedB); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->pop(interpreterProxy->methodArgumentCount()); + if ((combinationRule == 22) || (combinationRule == 32)) { + interpreterProxy->pop(1); + return interpreterProxy->pushInteger(bitCount); + } +} + +EXPORT(int) primitiveDisplayString(void) { + int maxGlyph; + int left; + int sourceString; + int glyphIndex; + int quickBlt; + int stopIndex; + int bbObj; + int xTable; + int kernDelta; + int startIndex; + int glyphMap; + unsigned char * sourcePtr; + int charIndex; + int ascii; + int pixPerM1; + int endBits; + int startBits; + + if (!((interpreterProxy->methodArgumentCount()) == 6)) { + return interpreterProxy->primitiveFail(); + } + kernDelta = interpreterProxy->stackIntegerValue(0); + xTable = interpreterProxy->stackObjectValue(1); + glyphMap = interpreterProxy->stackObjectValue(2); + if (!(((interpreterProxy->fetchClassOf(xTable)) == (interpreterProxy->classArray())) && ((interpreterProxy->fetchClassOf(glyphMap)) == (interpreterProxy->classArray())))) { + return interpreterProxy->primitiveFail(); + } + if (!((interpreterProxy->slotSizeOf(glyphMap)) == 256)) { + return interpreterProxy->primitiveFail(); + } + if (interpreterProxy->failed()) { + return null; + } + maxGlyph = (interpreterProxy->slotSizeOf(xTable)) - 2; + stopIndex = interpreterProxy->stackIntegerValue(3); + startIndex = interpreterProxy->stackIntegerValue(4); + sourceString = interpreterProxy->stackObjectValue(5); + if (!(interpreterProxy->isBytes(sourceString))) { + return interpreterProxy->primitiveFail(); + } + if (!((startIndex > 0) && ((stopIndex > 0) && (stopIndex <= (interpreterProxy->byteSizeOf(sourceString)))))) { + return interpreterProxy->primitiveFail(); + } + bbObj = interpreterProxy->stackObjectValue(6); + if (!(loadBitBltFromwarping(bbObj, 0))) { + return interpreterProxy->primitiveFail(); + } + if ((combinationRule == 30) || (combinationRule == 31)) { + return interpreterProxy->primitiveFail(); + } + quickBlt = (destBits != 0) && ((sourceBits != 0) && ((noSource == 0) && ((sourceForm != destForm) && ((cmFlags != 0) || ((sourceMSB != destMSB) || (sourceDepth != destDepth)))))); + left = destX; + sourcePtr = interpreterProxy->firstIndexableField(sourceString); + for (charIndex = startIndex; charIndex <= stopIndex; charIndex += 1) { + ascii = byteAt((sourcePtr + charIndex) - 1); + glyphIndex = interpreterProxy->fetchIntegerofObject(ascii, glyphMap); + if ((glyphIndex < 0) || (glyphIndex > maxGlyph)) { + return interpreterProxy->primitiveFail(); + } + sourceX = interpreterProxy->fetchIntegerofObject(glyphIndex, xTable); + width = (interpreterProxy->fetchIntegerofObject(glyphIndex + 1, xTable)) - sourceX; + if (interpreterProxy->failed()) { + return null; + } + clipRange(); + if ((bbW > 0) && (bbH > 0)) { + if (quickBlt) { + /* begin destMaskAndPointerInit */ + pixPerM1 = destPPW - 1; + startBits = destPPW - (dx & pixPerM1); + if (destMSB) { + mask1 = ((unsigned) 4294967295U) >> (32 - (startBits * destDepth)); + } else { + mask1 = 4294967295U << (32 - (startBits * destDepth)); + } + endBits = (((dx + bbW) - 1) & pixPerM1) + 1; + if (destMSB) { + mask2 = 4294967295U << (32 - (endBits * destDepth)); + } else { + mask2 = ((unsigned) 4294967295U) >> (32 - (endBits * destDepth)); + } + if (bbW < startBits) { + mask1 = mask1 & mask2; + mask2 = 0; + nWords = 1; + } else { + nWords = (((bbW - startBits) + pixPerM1) / destPPW) + 1; + } + hDir = vDir = 1; + destIndex = (destBits + (dy * destPitch)) + ((dx / destPPW) * 4); + destDelta = (destPitch * vDir) - (4 * (nWords * hDir)); + copyLoopPixMap(); + affectedL = dx; + affectedR = dx + bbW; + affectedT = dy; + affectedB = dy + bbH; + } else { + copyBits(); + } + } + if (interpreterProxy->failed()) { + return null; + } + destX = (destX + width) + kernDelta; + } + affectedL = left; + /* begin showDisplayBits */ + interpreterProxy->showDisplayBitsLeftTopRightBottom(destForm, affectedL, affectedT, affectedR, affectedB); + interpreterProxy->pop(6); +} + + +/* Invoke the line drawing primitive. */ + +EXPORT(int) primitiveDrawLoop(void) { + int yDelta; + int xDelta; + int rcvr; + int i; + int py; + int affL; + int dy1; + int affR; + int affB; + int affT; + int dx1; + int px; + int P; + + rcvr = interpreterProxy->stackValue(2); + xDelta = interpreterProxy->stackIntegerValue(1); + yDelta = interpreterProxy->stackIntegerValue(0); + if (!(loadBitBltFromwarping(rcvr, 0))) { + return interpreterProxy->primitiveFail(); + } + if (!(interpreterProxy->failed())) { + /* begin drawLoopX:Y: */ + if (xDelta > 0) { + dx1 = 1; + } else { + if (xDelta == 0) { + dx1 = 0; + } else { + dx1 = -1; + } + } + if (yDelta > 0) { + dy1 = 1; + } else { + if (yDelta == 0) { + dy1 = 0; + } else { + dy1 = -1; + } + } + px = abs(yDelta); + py = abs(xDelta); + affL = affT = 9999; + affR = affB = -9999; + if (py > px) { + P = ((int) py >> 1); + for (i = 1; i <= py; i += 1) { + destX += dx1; + if ((P -= px) < 0) { + destY += dy1; + P += py; + } + if (i < py) { + copyBits(); + if (interpreterProxy->failed()) { + goto l1; + } + if ((affectedL < affectedR) && (affectedT < affectedB)) { + affL = ((affL < affectedL) ? affL : affectedL); + affR = ((affR < affectedR) ? affectedR : affR); + affT = ((affT < affectedT) ? affT : affectedT); + affB = ((affB < affectedB) ? affectedB : affB); + if (((affR - affL) * (affB - affT)) > 4000) { + affectedL = affL; + affectedR = affR; + affectedT = affT; + affectedB = affB; + /* begin showDisplayBits */ + interpreterProxy->showDisplayBitsLeftTopRightBottom(destForm, affectedL, affectedT, affectedR, affectedB); + affL = affT = 9999; + affR = affB = -9999; + } + } + } + } + } else { + P = ((int) px >> 1); + for (i = 1; i <= px; i += 1) { + destY += dy1; + if ((P -= py) < 0) { + destX += dx1; + P += px; + } + if (i < px) { + copyBits(); + if (interpreterProxy->failed()) { + goto l1; + } + if ((affectedL < affectedR) && (affectedT < affectedB)) { + affL = ((affL < affectedL) ? affL : affectedL); + affR = ((affR < affectedR) ? affectedR : affR); + affT = ((affT < affectedT) ? affT : affectedT); + affB = ((affB < affectedB) ? affectedB : affB); + if (((affR - affL) * (affB - affT)) > 4000) { + affectedL = affL; + affectedR = affR; + affectedT = affT; + affectedB = affB; + /* begin showDisplayBits */ + interpreterProxy->showDisplayBitsLeftTopRightBottom(destForm, affectedL, affectedT, affectedR, affectedB); + affL = affT = 9999; + affR = affB = -9999; + } + } + } + } + } + affectedL = affL; + affectedR = affR; + affectedT = affT; + affectedB = affB; + interpreterProxy->storeIntegerofObjectwithValue(4, bitBltOop, destX); + interpreterProxy->storeIntegerofObjectwithValue(5, bitBltOop, destY); + l1: /* end drawLoopX:Y: */; + /* begin showDisplayBits */ + interpreterProxy->showDisplayBitsLeftTopRightBottom(destForm, affectedL, affectedT, affectedR, affectedB); + } + if (!(interpreterProxy->failed())) { + interpreterProxy->pop(2); + } +} + + +/* Invoke the warpBits primitive. If the destination is the display, then copy it to the screen. */ + +EXPORT(int) primitiveWarpBits(void) { + int rcvr; + int ns; + int pixPerM1; + int endBits; + int startBits; + + rcvr = interpreterProxy->stackValue(interpreterProxy->methodArgumentCount()); + if (!(loadBitBltFromwarping(rcvr, 1))) { + return interpreterProxy->primitiveFail(); + } + /* begin warpBits */ + ns = noSource; + noSource = 1; + clipRange(); + noSource = ns; + if (noSource || ((bbW <= 0) || (bbH <= 0))) { + affectedL = affectedR = affectedT = affectedB = 0; + goto l1; + } + lockSurfaces(); + /* begin destMaskAndPointerInit */ + pixPerM1 = destPPW - 1; + startBits = destPPW - (dx & pixPerM1); + if (destMSB) { + mask1 = ((unsigned) 4294967295U) >> (32 - (startBits * destDepth)); + } else { + mask1 = 4294967295U << (32 - (startBits * destDepth)); + } + endBits = (((dx + bbW) - 1) & pixPerM1) + 1; + if (destMSB) { + mask2 = 4294967295U << (32 - (endBits * destDepth)); + } else { + mask2 = ((unsigned) 4294967295U) >> (32 - (endBits * destDepth)); + } + if (bbW < startBits) { + mask1 = mask1 & mask2; + mask2 = 0; + nWords = 1; + } else { + nWords = (((bbW - startBits) + pixPerM1) / destPPW) + 1; + } + hDir = vDir = 1; + destIndex = (destBits + (dy * destPitch)) + ((dx / destPPW) * 4); + destDelta = (destPitch * vDir) - (4 * (nWords * hDir)); + warpLoop(); + if (hDir > 0) { + affectedL = dx; + affectedR = dx + bbW; + } else { + affectedL = (dx - bbW) + 1; + affectedR = dx + 1; + } + if (vDir > 0) { + affectedT = dy; + affectedB = dy + bbH; + } else { + affectedT = (dy - bbH) + 1; + affectedB = dy + 1; + } + unlockSurfaces(); +l1: /* end warpBits */; + if (interpreterProxy->failed()) { + return null; + } + /* begin showDisplayBits */ + interpreterProxy->showDisplayBitsLeftTopRightBottom(destForm, affectedL, affectedT, affectedR, affectedB); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->pop(interpreterProxy->methodArgumentCount()); +} + + +/* Query the dimension of an OS surface. + This method is provided so that in case the inst vars of the + source form are broken, *actual* values of the OS surface + can be obtained. This might, for instance, happen if the user + resizes the main window. + Note: Moved to a separate function for better inlining of the caller. */ + +static int queryDestSurface(int handle) { + if (querySurfaceFn == 0) { + if (!(loadSurfacePlugin())) { + return 0; + } + } + return ((int (*) (int, int*, int*, int*, int*))querySurfaceFn) + (handle, &destWidth, &destHeight, &destDepth, &destMSB); +} + + +/* Query the dimension of an OS surface. + This method is provided so that in case the inst vars of the + source form are broken, *actual* values of the OS surface + can be obtained. This might, for instance, happen if the user + resizes the main window. + Note: Moved to a separate function for better inlining of the caller. */ + +static int querySourceSurface(int handle) { + if (querySurfaceFn == 0) { + if (!(loadSurfacePlugin())) { + return 0; + } + } + return ((int (*) (int, int*, int*, int*, int*))querySurfaceFn) + (handle, &sourceWidth, &sourceHeight, &sourceDepth, &sourceMSB); +} + +static int rgbAddwith(int sourceWord, int destinationWord) { + if (destDepth < 16) { + return partitionedAddtonBitsnPartitions(sourceWord, destinationWord, destDepth, destPPW); + } + if (destDepth == 16) { + return (partitionedAddtonBitsnPartitions(sourceWord, destinationWord, 5, 3)) + ((partitionedAddtonBitsnPartitions(((unsigned) sourceWord) >> 16, ((unsigned) destinationWord) >> 16, 5, 3)) << 16); + } else { + return partitionedAddtonBitsnPartitions(sourceWord, destinationWord, 8, 3); + } +} + + +/* Subract the pixels in the source and destination, color by color, + and return the sum of the absolute value of all the differences. + For non-rgb, return the number of differing pixels. */ + +static int rgbDiffwith(int sourceWord, int destinationWord) { + int i; + int sourceShifted; + int diff; + int rgbMask; + int destShifted; + int pixMask; + int maskShifted; + int bitsPerColor; + int sourcePixVal; + int destPixVal; + + pixMask = maskTable[destDepth]; + if (destDepth == 16) { + bitsPerColor = 5; + rgbMask = 31; + } else { + bitsPerColor = 8; + rgbMask = 255; + } + maskShifted = destMask; + destShifted = destinationWord; + sourceShifted = sourceWord; + for (i = 1; i <= destPPW; i += 1) { + if ((maskShifted & pixMask) > 0) { + destPixVal = destShifted & pixMask; + sourcePixVal = sourceShifted & pixMask; + if (destDepth < 16) { + if (sourcePixVal == destPixVal) { + diff = 0; + } else { + diff = 1; + } + } else { + diff = partitionedSubfromnBitsnPartitions(sourcePixVal, destPixVal, bitsPerColor, 3); + diff = ((diff & rgbMask) + ((((unsigned) diff) >> bitsPerColor) & rgbMask)) + ((((unsigned) (((unsigned) diff) >> bitsPerColor)) >> bitsPerColor) & rgbMask); + } + bitCount += diff; + } + maskShifted = ((unsigned) maskShifted) >> destDepth; + sourceShifted = ((unsigned) sourceShifted) >> destDepth; + destShifted = ((unsigned) destShifted) >> destDepth; + } + return destinationWord; +} + + +/* Convert the given 16bit pixel value to a 32bit RGBA value. + Note: This method is intended to deal with different source formats. */ + +static int rgbMap16To32(int sourcePixel) { + return (((sourcePixel & 31) << 3) | ((sourcePixel & 992) << 6)) | ((sourcePixel & 31744) << 9); +} + + +/* Convert the given 32bit pixel value to a 32bit RGBA value. + Note: This method is intended to deal with different source formats. */ + +static int rgbMap32To32(int sourcePixel) { + return sourcePixel; +} + + +/* Convert the given pixel value with nBitsIn bits for each color component to a pixel value with nBitsOut bits for each color component. Typical values for nBitsIn/nBitsOut are 3, 5, or 8. */ + +static int rgbMapfromto(int sourcePixel, int nBitsIn, int nBitsOut) { + int srcPix; + int destPix; + int d; + int mask; + + if ((d = nBitsOut - nBitsIn) > 0) { + + /* Transfer mask */ + + mask = (1 << nBitsIn) - 1; + srcPix = sourcePixel << d; + mask = mask << d; + destPix = srcPix & mask; + mask = mask << nBitsOut; + srcPix = srcPix << d; + return (destPix + (srcPix & mask)) + ((srcPix << d) & (mask << nBitsOut)); + } else { + if (d == 0) { + if (nBitsIn == 5) { + return sourcePixel & 32767; + } + if (nBitsIn == 8) { + return sourcePixel & 16777215; + } + return sourcePixel; + } + if (sourcePixel == 0) { + return sourcePixel; + } + d = nBitsIn - nBitsOut; + + /* Transfer mask */ + + mask = (1 << nBitsOut) - 1; + srcPix = ((unsigned) sourcePixel) >> d; + destPix = srcPix & mask; + mask = mask << nBitsOut; + srcPix = ((unsigned) srcPix) >> d; + destPix = (destPix + (srcPix & mask)) + ((((unsigned) srcPix) >> d) & (mask << nBitsOut)); + if (destPix == 0) { + return 1; + } + return destPix; + } +} + + +/* Perform the RGBA conversion for the given source pixel */ + +static int rgbMapPixelflags(int sourcePixel, int mapperFlags) { + int val; + + val = (((cmShiftTable[0]) < 0) ? ((unsigned) (sourcePixel & (cmMaskTable[0])) >> -(cmShiftTable[0])) : ((unsigned) (sourcePixel & (cmMaskTable[0])) << (cmShiftTable[0]))); + val = val | ((((cmShiftTable[1]) < 0) ? ((unsigned) (sourcePixel & (cmMaskTable[1])) >> -(cmShiftTable[1])) : ((unsigned) (sourcePixel & (cmMaskTable[1])) << (cmShiftTable[1])))); + val = val | ((((cmShiftTable[2]) < 0) ? ((unsigned) (sourcePixel & (cmMaskTable[2])) >> -(cmShiftTable[2])) : ((unsigned) (sourcePixel & (cmMaskTable[2])) << (cmShiftTable[2])))); + return val | ((((cmShiftTable[3]) < 0) ? ((unsigned) (sourcePixel & (cmMaskTable[3])) >> -(cmShiftTable[3])) : ((unsigned) (sourcePixel & (cmMaskTable[3])) << (cmShiftTable[3])))); +} + +static int rgbMaxwith(int sourceWord, int destinationWord) { + int i; + int result; + int mask; + int i1; + int result1; + int mask3; + + if (destDepth < 16) { + /* begin partitionedMax:with:nBits:nPartitions: */ + mask = maskTable[destDepth]; + result = 0; + for (i = 1; i <= destPPW; i += 1) { + result = result | ((((destinationWord & mask) < (sourceWord & mask)) ? (sourceWord & mask) : (destinationWord & mask))); + mask = mask << destDepth; + } + return result; + } + if (destDepth == 16) { + return (partitionedMaxwithnBitsnPartitions(sourceWord, destinationWord, 5, 3)) + ((partitionedMaxwithnBitsnPartitions(((unsigned) sourceWord) >> 16, ((unsigned) destinationWord) >> 16, 5, 3)) << 16); + } else { + /* begin partitionedMax:with:nBits:nPartitions: */ + mask3 = maskTable[8]; + result1 = 0; + for (i1 = 1; i1 <= 3; i1 += 1) { + result1 = result1 | ((((destinationWord & mask3) < (sourceWord & mask3)) ? (sourceWord & mask3) : (destinationWord & mask3))); + mask3 = mask3 << 8; + } + return result1; + } +} + +static int rgbMinwith(int sourceWord, int destinationWord) { + int i; + int result; + int mask; + int i1; + int result1; + int mask3; + + if (destDepth < 16) { + /* begin partitionedMin:with:nBits:nPartitions: */ + mask = maskTable[destDepth]; + result = 0; + for (i = 1; i <= destPPW; i += 1) { + result = result | ((((destinationWord & mask) < (sourceWord & mask)) ? (destinationWord & mask) : (sourceWord & mask))); + mask = mask << destDepth; + } + return result; + } + if (destDepth == 16) { + return (partitionedMinwithnBitsnPartitions(sourceWord, destinationWord, 5, 3)) + ((partitionedMinwithnBitsnPartitions(((unsigned) sourceWord) >> 16, ((unsigned) destinationWord) >> 16, 5, 3)) << 16); + } else { + /* begin partitionedMin:with:nBits:nPartitions: */ + mask3 = maskTable[8]; + result1 = 0; + for (i1 = 1; i1 <= 3; i1 += 1) { + result1 = result1 | ((((destinationWord & mask3) < (sourceWord & mask3)) ? (destinationWord & mask3) : (sourceWord & mask3))); + mask3 = mask3 << 8; + } + return result1; + } +} + +static int rgbMinInvertwith(int wordToInvert, int destinationWord) { + int sourceWord; + int i; + int result; + int mask; + int i1; + int result1; + int mask3; + + sourceWord = ~wordToInvert; + if (destDepth < 16) { + /* begin partitionedMin:with:nBits:nPartitions: */ + mask = maskTable[destDepth]; + result = 0; + for (i = 1; i <= destPPW; i += 1) { + result = result | ((((destinationWord & mask) < (sourceWord & mask)) ? (destinationWord & mask) : (sourceWord & mask))); + mask = mask << destDepth; + } + return result; + } + if (destDepth == 16) { + return (partitionedMinwithnBitsnPartitions(sourceWord, destinationWord, 5, 3)) + ((partitionedMinwithnBitsnPartitions(((unsigned) sourceWord) >> 16, ((unsigned) destinationWord) >> 16, 5, 3)) << 16); + } else { + /* begin partitionedMin:with:nBits:nPartitions: */ + mask3 = maskTable[8]; + result1 = 0; + for (i1 = 1; i1 <= 3; i1 += 1) { + result1 = result1 | ((((destinationWord & mask3) < (sourceWord & mask3)) ? (destinationWord & mask3) : (sourceWord & mask3))); + mask3 = mask3 << 8; + } + return result1; + } +} + +static int rgbMulwith(int sourceWord, int destinationWord) { + if (destDepth < 16) { + return partitionedMulwithnBitsnPartitions(sourceWord, destinationWord, destDepth, destPPW); + } + if (destDepth == 16) { + return (partitionedMulwithnBitsnPartitions(sourceWord, destinationWord, 5, 3)) + ((partitionedMulwithnBitsnPartitions(((unsigned) sourceWord) >> 16, ((unsigned) destinationWord) >> 16, 5, 3)) << 16); + } else { + return partitionedMulwithnBitsnPartitions(sourceWord, destinationWord, 8, 3); + } +} + +static int rgbSubwith(int sourceWord, int destinationWord) { + if (destDepth < 16) { + return partitionedSubfromnBitsnPartitions(sourceWord, destinationWord, destDepth, destPPW); + } + if (destDepth == 16) { + return (partitionedSubfromnBitsnPartitions(sourceWord, destinationWord, 5, 3)) + ((partitionedSubfromnBitsnPartitions(((unsigned) sourceWord) >> 16, ((unsigned) destinationWord) >> 16, 5, 3)) << 16); + } else { + return partitionedSubfromnBitsnPartitions(sourceWord, destinationWord, 8, 3); + } +} + + +/* Note: This is coded so that is can be run from Squeak. */ + +EXPORT(int) setInterpreter(struct VirtualMachine* anInterpreter) { + int ok; + + interpreterProxy = anInterpreter; + ok = interpreterProxy->majorVersion() == VM_PROXY_MAJOR; + if (ok == 0) { + return 0; + } + ok = interpreterProxy->minorVersion() >= VM_PROXY_MINOR; + return ok; +} + + +/* WARNING: For WarpBlt w/ smoothing the source depth is wrong here! */ + +static int setupColorMasks(void) { + int bits; + int targetBits; + + bits = targetBits = 0; + if (sourceDepth <= 8) { + return null; + } + if (sourceDepth == 16) { + bits = 5; + } + if (sourceDepth == 32) { + bits = 8; + } + if (cmBitsPerColor == 0) { + if (destDepth <= 8) { + return null; + } + if (destDepth == 16) { + targetBits = 5; + } + if (destDepth == 32) { + targetBits = 8; + } + } else { + targetBits = cmBitsPerColor; + } + setupColorMasksFromto(bits, targetBits); +} + + +/* Setup color masks for converting an incoming RGB pixel value from srcBits to targetBits. */ + +static int setupColorMasksFromto(int srcBits, int targetBits) { + int mask; + static int shifts[4] = {0, 0, 0, 0}; + int deltaBits; + static unsigned int masks[4] = {0, 0, 0, 0}; + + ; + deltaBits = targetBits - srcBits; + if (deltaBits == 0) { + return 0; + } + if (deltaBits <= 0) { + + /* Mask for extracting a color part of the source */ + + mask = (1 << targetBits) - 1; + masks[0] = (mask << ((srcBits * 2) - deltaBits)); + masks[1] = (mask << (srcBits - deltaBits)); + masks[2] = (mask << (0 - deltaBits)); + masks[3] = 0; + } else { + + /* Mask for extracting a color part of the source */ + + mask = (1 << srcBits) - 1; + masks[0] = (mask << (srcBits * 2)); + masks[1] = (mask << srcBits); + masks[2] = mask; + } + shifts[0] = (deltaBits * 3); + shifts[1] = (deltaBits * 2); + shifts[2] = deltaBits; + shifts[3] = 0; + cmShiftTable = shifts; + cmMaskTable = masks; + cmFlags = cmFlags | (1 | 2); +} + +static int showDisplayBits(void) { + interpreterProxy->showDisplayBitsLeftTopRightBottom(destForm, affectedL, affectedT, affectedR, affectedB); +} + + +/* This is only used when source and dest are same depth, + ie, when the barrel-shift copy loop is used. */ + +static int sourceSkewAndPointerInit(void) { + int pixPerM1; + int dxLowBits; + int dWid; + int sxLowBits; + + + /* A mask, assuming power of two */ + + pixPerM1 = destPPW - 1; + sxLowBits = sx & pixPerM1; + + /* check if need to preload buffer + (i.e., two words of source needed for first word of destination) */ + + dxLowBits = dx & pixPerM1; + if (hDir > 0) { + dWid = ((bbW < (destPPW - dxLowBits)) ? bbW : (destPPW - dxLowBits)); + preload = (sxLowBits + dWid) > pixPerM1; + } else { + dWid = ((bbW < (dxLowBits + 1)) ? bbW : (dxLowBits + 1)); + preload = ((sxLowBits - dWid) + 1) < 0; + } + if (sourceMSB) { + skew = (sxLowBits - dxLowBits) * destDepth; + } else { + skew = (dxLowBits - sxLowBits) * destDepth; + } + if (preload) { + if (skew < 0) { + skew += 32; + } else { + skew -= 32; + } + } + + /* calculate increments from end of 1 line to start of next */ + + sourceIndex = (sourceBits + (sy * sourcePitch)) + ((sx / (32 / sourceDepth)) * 4); + sourceDelta = (sourcePitch * vDir) - (4 * (nWords * hDir)); + if (preload) { + sourceDelta -= 4 * hDir; + } +} + +static int sourceWordwith(int sourceWord, int destinationWord) { + return sourceWord; +} + +static int srcLongAt(int idx) { + return longAt(idx); +} + +static int subWordwith(int sourceWord, int destinationWord) { + return sourceWord - destinationWord; +} + + +/* Note: Nasty coercion only necessary for the non-inlined version of this method in C. Duh? Oh well, here's the full story. The code below will definitely be inlined so everything that calls this method is fine. But... the translator doesn't quite prune this method so it generates a C function that tries to attempt an array access on an int - and most compilers don't like this. If you don't know what I'm talking about try to remove the C coercion and you'll see what happens when you try to compile a new VM... */ + +static int tableLookupat(int table, int index) { + return (((int*) table))[index]; +} + + +/* Tally pixels into the color map. Those tallied are exactly those + in the destination rectangle. Note that the source should be + specified == destination, in order for the proper color map checks + to be performed at setup. */ + +static int tallyIntoMapwith(int sourceWord, int destinationWord) { + int i; + int destShifted; + int pixVal; + int pixMask; + int maskShifted; + int mapIndex; + int srcPix; + int destPix; + int d; + int mask; + int srcPix1; + int destPix1; + int d1; + int mask3; + + if (!((cmFlags & (1 | 4)) == (1 | 4))) { + return destinationWord; + } + pixMask = maskTable[destDepth]; + destShifted = destinationWord; + maskShifted = destMask; + for (i = 1; i <= destPPW; i += 1) { + if (!((maskShifted & pixMask) == 0)) { + pixVal = destShifted & pixMask; + if (destDepth < 16) { + mapIndex = pixVal; + } else { + if (destDepth == 16) { + /* begin rgbMap:from:to: */ + if ((d = cmBitsPerColor - 5) > 0) { + mask = (1 << 5) - 1; + srcPix = pixVal << d; + mask = mask << d; + destPix = srcPix & mask; + mask = mask << cmBitsPerColor; + srcPix = srcPix << d; + mapIndex = (destPix + (srcPix & mask)) + ((srcPix << d) & (mask << cmBitsPerColor)); + goto l1; + } else { + if (d == 0) { + if (5 == 5) { + mapIndex = pixVal & 32767; + goto l1; + } + if (5 == 8) { + mapIndex = pixVal & 16777215; + goto l1; + } + mapIndex = pixVal; + goto l1; + } + if (pixVal == 0) { + mapIndex = pixVal; + goto l1; + } + d = 5 - cmBitsPerColor; + mask = (1 << cmBitsPerColor) - 1; + srcPix = ((unsigned) pixVal) >> d; + destPix = srcPix & mask; + mask = mask << cmBitsPerColor; + srcPix = ((unsigned) srcPix) >> d; + destPix = (destPix + (srcPix & mask)) + ((((unsigned) srcPix) >> d) & (mask << cmBitsPerColor)); + if (destPix == 0) { + mapIndex = 1; + goto l1; + } + mapIndex = destPix; + goto l1; + } + l1: /* end rgbMap:from:to: */; + } else { + /* begin rgbMap:from:to: */ + if ((d1 = cmBitsPerColor - 8) > 0) { + mask3 = (1 << 8) - 1; + srcPix1 = pixVal << d1; + mask3 = mask3 << d1; + destPix1 = srcPix1 & mask3; + mask3 = mask3 << cmBitsPerColor; + srcPix1 = srcPix1 << d1; + mapIndex = (destPix1 + (srcPix1 & mask3)) + ((srcPix1 << d1) & (mask3 << cmBitsPerColor)); + goto l2; + } else { + if (d1 == 0) { + if (8 == 5) { + mapIndex = pixVal & 32767; + goto l2; + } + if (8 == 8) { + mapIndex = pixVal & 16777215; + goto l2; + } + mapIndex = pixVal; + goto l2; + } + if (pixVal == 0) { + mapIndex = pixVal; + goto l2; + } + d1 = 8 - cmBitsPerColor; + mask3 = (1 << cmBitsPerColor) - 1; + srcPix1 = ((unsigned) pixVal) >> d1; + destPix1 = srcPix1 & mask3; + mask3 = mask3 << cmBitsPerColor; + srcPix1 = ((unsigned) srcPix1) >> d1; + destPix1 = (destPix1 + (srcPix1 & mask3)) + ((((unsigned) srcPix1) >> d1) & (mask3 << cmBitsPerColor)); + if (destPix1 == 0) { + mapIndex = 1; + goto l2; + } + mapIndex = destPix1; + goto l2; + } + l2: /* end rgbMap:from:to: */; + } + } + cmLookupTable[mapIndex & cmMask] = ((cmLookupTable[mapIndex & cmMask]) + 1); + } + maskShifted = ((unsigned) maskShifted) >> destDepth; + destShifted = ((unsigned) destShifted) >> destDepth; + } + return destinationWord; +} + + +/* Return the word at position idx from the colorMap */ + +static int tallyMapAt(int idx) { + return cmLookupTable[idx & cmMask]; +} + + +/* Store the word at position idx in the colorMap */ + +static int tallyMapAtput(int idx, int value) { + return cmLookupTable[idx & cmMask] = value; +} + + +/* Shortcut for stuff that's being run from the balloon engine. + Since we do this at each scan line we should avoid the expensive + setup for source and destination. */ + +static int tryCopyingBitsQuickly(void) { + if (noSource) { + return 0; + } + if (!(combinationRule == 34)) { + return 0; + } + if (!(sourceDepth == 32)) { + return 0; + } + if (sourceForm == destForm) { + return 0; + } + if (destDepth < 8) { + return 0; + } + if ((destDepth == 8) && ((cmFlags & 1) == 0)) { + return 0; + } + if (destDepth == 32) { + alphaSourceBlendBits32(); + } + if (destDepth == 16) { + alphaSourceBlendBits16(); + } + if (destDepth == 8) { + alphaSourceBlendBits8(); + } + affectedL = dx; + affectedR = dx + bbW; + affectedT = dy; + affectedB = dy + bbH; + return 1; +} + + +/* Unlock the bits of any OS surfaces. */ +/* See the comment in lockSurfaces. Similar rules apply. That is, the area provided in ioUnlockSurface can be used to determine the dirty region after drawing. If a source is unlocked, then the area will be (0,0,0,0) to indicate that no portion is dirty. */ + +static int unlockSurfaces(void) { + int destLocked; + int sourceHandle; + int destHandle; + int (*fn)(int, int, int, int, int); + + if (hasSurfaceLock) { + if (unlockSurfaceFn == 0) { + if (!(loadSurfacePlugin())) { + return null; + } + } + fn = ((int (*)(int, int, int, int, int)) unlockSurfaceFn); + destLocked = 0; + destHandle = interpreterProxy->fetchPointerofObject(0, destForm); + if ((destHandle & 1)) { + + /* The destBits are always assumed to be dirty */ + + destHandle = (destHandle >> 1); + fn(destHandle, affectedL, affectedT, affectedR-affectedL, affectedB-affectedT); + destBits = destPitch = 0; + destLocked = 1; + } + if (!(noSource)) { + sourceHandle = interpreterProxy->fetchPointerofObject(0, sourceForm); + if ((sourceHandle & 1)) { + + /* Only unlock sourceHandle if different from destHandle */ + + sourceHandle = (sourceHandle >> 1); + if (!(destLocked && (sourceHandle == destHandle))) { + fn(sourceHandle, 0, 0, 0, 0); + } + sourceBits = sourcePitch = 0; + } + } + hasSurfaceLock = 0; + } +} + +static int warpBits(void) { + int ns; + int pixPerM1; + int endBits; + int startBits; + + ns = noSource; + noSource = 1; + clipRange(); + noSource = ns; + if (noSource || ((bbW <= 0) || (bbH <= 0))) { + affectedL = affectedR = affectedT = affectedB = 0; + return null; + } + lockSurfaces(); + /* begin destMaskAndPointerInit */ + pixPerM1 = destPPW - 1; + startBits = destPPW - (dx & pixPerM1); + if (destMSB) { + mask1 = ((unsigned) 4294967295U) >> (32 - (startBits * destDepth)); + } else { + mask1 = 4294967295U << (32 - (startBits * destDepth)); + } + endBits = (((dx + bbW) - 1) & pixPerM1) + 1; + if (destMSB) { + mask2 = 4294967295U << (32 - (endBits * destDepth)); + } else { + mask2 = ((unsigned) 4294967295U) >> (32 - (endBits * destDepth)); + } + if (bbW < startBits) { + mask1 = mask1 & mask2; + mask2 = 0; + nWords = 1; + } else { + nWords = (((bbW - startBits) + pixPerM1) / destPPW) + 1; + } + hDir = vDir = 1; + destIndex = (destBits + (dy * destPitch)) + ((dx / destPPW) * 4); + destDelta = (destPitch * vDir) - (4 * (nWords * hDir)); + warpLoop(); + if (hDir > 0) { + affectedL = dx; + affectedR = dx + bbW; + } else { + affectedL = (dx - bbW) + 1; + affectedR = dx + 1; + } + if (vDir > 0) { + affectedT = dy; + affectedB = dy + bbH; + } else { + affectedT = (dy - bbH) + 1; + affectedB = dy + 1; + } + unlockSurfaces(); +} + + +/* This version of the inner loop traverses an arbirary quadrilateral + source, thus producing a general affine transformation. */ + +static int warpLoop(void) { + int mergeWord; + int i; + int deltaP43x; + int (*mergeFnwith)(int, int); + int yDelta; + int nPix; + int pBx; + int endBits; + int deltaP12y; + int xDelta; + int halftoneWord; + int smoothingCount; + int pAy; + int skewWord; + int words; + int mapperFlags; + int destWord; + int sourceMapOop; + int dstShiftInc; + int startBits; + int deltaP43y; + int nSteps; + int pBy; + int dstShiftLeft; + int deltaP12x; + int pAx; + int sourcePix; + int nPix1; + int destPix; + int dstMask; + int destWord1; + int i1; + int words1; + int x; + int sourcePix1; + int sourceWord; + int y; + int srcIndex; + int x1; + int sourcePix2; + int sourceWord1; + int y1; + int srcIndex1; + int pv; + int val; + + mergeFnwith = ((int (*)(int, int)) (opTable[combinationRule + 1])); + mergeFnwith; + if (!((interpreterProxy->slotSizeOf(bitBltOop)) >= (15 + 12))) { + return interpreterProxy->primitiveFail(); + } + nSteps = height - 1; + if (nSteps <= 0) { + nSteps = 1; + } + pAx = fetchIntOrFloatofObject(15, bitBltOop); + words = fetchIntOrFloatofObject(15 + 3, bitBltOop); + /* begin deltaFrom:to:nSteps: */ + if (words > pAx) { + deltaP12x = (((words - pAx) + 16384) / (nSteps + 1)) + 1; + goto l3; + } else { + if (words == pAx) { + deltaP12x = 0; + goto l3; + } + deltaP12x = 0 - ((((pAx - words) + 16384) / (nSteps + 1)) + 1); + goto l3; + } +l3: /* end deltaFrom:to:nSteps: */; + if (deltaP12x < 0) { + pAx = words - (nSteps * deltaP12x); + } + pAy = fetchIntOrFloatofObject(15 + 1, bitBltOop); + words = fetchIntOrFloatofObject(15 + 4, bitBltOop); + /* begin deltaFrom:to:nSteps: */ + if (words > pAy) { + deltaP12y = (((words - pAy) + 16384) / (nSteps + 1)) + 1; + goto l4; + } else { + if (words == pAy) { + deltaP12y = 0; + goto l4; + } + deltaP12y = 0 - ((((pAy - words) + 16384) / (nSteps + 1)) + 1); + goto l4; + } +l4: /* end deltaFrom:to:nSteps: */; + if (deltaP12y < 0) { + pAy = words - (nSteps * deltaP12y); + } + pBx = fetchIntOrFloatofObject(15 + 9, bitBltOop); + words = fetchIntOrFloatofObject(15 + 6, bitBltOop); + /* begin deltaFrom:to:nSteps: */ + if (words > pBx) { + deltaP43x = (((words - pBx) + 16384) / (nSteps + 1)) + 1; + goto l5; + } else { + if (words == pBx) { + deltaP43x = 0; + goto l5; + } + deltaP43x = 0 - ((((pBx - words) + 16384) / (nSteps + 1)) + 1); + goto l5; + } +l5: /* end deltaFrom:to:nSteps: */; + if (deltaP43x < 0) { + pBx = words - (nSteps * deltaP43x); + } + pBy = fetchIntOrFloatofObject(15 + 10, bitBltOop); + words = fetchIntOrFloatofObject(15 + 7, bitBltOop); + /* begin deltaFrom:to:nSteps: */ + if (words > pBy) { + deltaP43y = (((words - pBy) + 16384) / (nSteps + 1)) + 1; + goto l6; + } else { + if (words == pBy) { + deltaP43y = 0; + goto l6; + } + deltaP43y = 0 - ((((pBy - words) + 16384) / (nSteps + 1)) + 1); + goto l6; + } +l6: /* end deltaFrom:to:nSteps: */; + if (deltaP43y < 0) { + pBy = words - (nSteps * deltaP43y); + } + if (interpreterProxy->failed()) { + return 0; + } + if ((interpreterProxy->methodArgumentCount()) == 2) { + smoothingCount = interpreterProxy->stackIntegerValue(1); + sourceMapOop = interpreterProxy->stackValue(0); + if (sourceMapOop == (interpreterProxy->nilObject())) { + if (sourceDepth < 16) { + return interpreterProxy->primitiveFail(); + } + } else { + if ((interpreterProxy->slotSizeOf(sourceMapOop)) < (1 << sourceDepth)) { + return interpreterProxy->primitiveFail(); + } + sourceMapOop = ((int) (interpreterProxy->firstIndexableField(sourceMapOop))); + } + } else { + smoothingCount = 1; + sourceMapOop = interpreterProxy->nilObject(); + } + nSteps = width - 1; + if (nSteps <= 0) { + nSteps = 1; + } + startBits = destPPW - (dx & (destPPW - 1)); + endBits = (((dx + bbW) - 1) & (destPPW - 1)) + 1; + if (bbW < startBits) { + startBits = bbW; + } + if (destY < clipY) { + pAx += (clipY - destY) * deltaP12x; + pAy += (clipY - destY) * deltaP12y; + pBx += (clipY - destY) * deltaP43x; + pBy += (clipY - destY) * deltaP43y; + } + /* begin warpLoopSetup */ + warpSrcShift = 0; + words1 = sourceDepth; + while (!(words1 == 1)) { + warpSrcShift += 1; + words1 = ((unsigned) words1) >> 1; + } + warpSrcMask = maskTable[sourceDepth]; + warpAlignShift = 5 - warpSrcShift; + warpAlignMask = (1 << warpAlignShift) - 1; + for (i1 = 0; i1 <= warpAlignMask; i1 += 1) { + if (sourceMSB) { + warpBitShiftTable[i1] = (32 - ((i1 + 1) << warpSrcShift)); + } else { + warpBitShiftTable[i1] = (i1 << warpSrcShift); + } + } + if ((smoothingCount > 1) && ((cmFlags & 8) == 0)) { + if (cmLookupTable == null) { + if (destDepth == 16) { + setupColorMasksFromto(8, 5); + } + } else { + setupColorMasksFromto(8, cmBitsPerColor); + } + } + mapperFlags = cmFlags & (~8); + if (destMSB) { + dstShiftInc = 0 - destDepth; + dstShiftLeft = 32 - destDepth; + } else { + dstShiftInc = destDepth; + dstShiftLeft = 0; + } + for (i = 1; i <= bbH; i += 1) { + /* begin deltaFrom:to:nSteps: */ + if (pBx > pAx) { + xDelta = (((pBx - pAx) + 16384) / (nSteps + 1)) + 1; + goto l1; + } else { + if (pBx == pAx) { + xDelta = 0; + goto l1; + } + xDelta = 0 - ((((pAx - pBx) + 16384) / (nSteps + 1)) + 1); + goto l1; + } + l1: /* end deltaFrom:to:nSteps: */; + if (xDelta >= 0) { + sx = pAx; + } else { + sx = pBx - (nSteps * xDelta); + } + /* begin deltaFrom:to:nSteps: */ + if (pBy > pAy) { + yDelta = (((pBy - pAy) + 16384) / (nSteps + 1)) + 1; + goto l2; + } else { + if (pBy == pAy) { + yDelta = 0; + goto l2; + } + yDelta = 0 - ((((pAy - pBy) + 16384) / (nSteps + 1)) + 1); + goto l2; + } + l2: /* end deltaFrom:to:nSteps: */; + if (yDelta >= 0) { + sy = pAy; + } else { + sy = pBy - (nSteps * yDelta); + } + if (destMSB) { + dstBitShift = 32 - (((dx & (destPPW - 1)) + 1) * destDepth); + } else { + dstBitShift = (dx & (destPPW - 1)) * destDepth; + } + if (destX < clipX) { + sx += (clipX - destX) * xDelta; + sy += (clipX - destX) * yDelta; + } + if (noHalftone) { + halftoneWord = 4294967295U; + } else { + halftoneWord = longAt(halftoneBase + ((((dy + i) - 1) % halftoneHeight) * 4)); + } + destMask = mask1; + + /* Here is the inner loop... */ + + nPix = startBits; + words = nWords; + do { + if (smoothingCount == 1) { + /* begin warpPickSourcePixels:xDeltah:yDeltah:xDeltav:yDeltav:dstShiftInc:flags: */ + dstMask = maskTable[destDepth]; + destWord1 = 0; + nPix1 = nPix; + if (mapperFlags == (1 | 4)) { + do { + /* begin pickWarpPixelAtX:y: */ + if ((sx < 0) || ((sy < 0) || (((x = ((unsigned) sx) >> 14) >= sourceWidth) || ((y = ((unsigned) sy) >> 14) >= sourceHeight)))) { + sourcePix = 0; + goto l7; + } + srcIndex = (sourceBits + (y * sourcePitch)) + ((((unsigned) x) >> warpAlignShift) * 4); + sourceWord = longAt(srcIndex); + srcBitShift = warpBitShiftTable[x & warpAlignMask]; + sourcePix1 = (((unsigned) sourceWord) >> srcBitShift) & warpSrcMask; + sourcePix = sourcePix1; + l7: /* end pickWarpPixelAtX:y: */; + destPix = cmLookupTable[sourcePix & cmMask]; + destWord1 = destWord1 | ((destPix & dstMask) << dstBitShift); + dstBitShift += dstShiftInc; + sx += xDelta; + sy += yDelta; + } while(!((nPix1 -= 1) == 0)); + } else { + do { + /* begin pickWarpPixelAtX:y: */ + if ((sx < 0) || ((sy < 0) || (((x1 = ((unsigned) sx) >> 14) >= sourceWidth) || ((y1 = ((unsigned) sy) >> 14) >= sourceHeight)))) { + sourcePix = 0; + goto l8; + } + srcIndex1 = (sourceBits + (y1 * sourcePitch)) + ((((unsigned) x1) >> warpAlignShift) * 4); + sourceWord1 = longAt(srcIndex1); + srcBitShift = warpBitShiftTable[x1 & warpAlignMask]; + sourcePix2 = (((unsigned) sourceWord1) >> srcBitShift) & warpSrcMask; + sourcePix = sourcePix2; + l8: /* end pickWarpPixelAtX:y: */; + /* begin mapPixel:flags: */ + pv = sourcePix; + if ((mapperFlags & 1) != 0) { + if ((mapperFlags & 2) != 0) { + /* begin rgbMapPixel:flags: */ + val = (((cmShiftTable[0]) < 0) ? ((unsigned) (sourcePix & (cmMaskTable[0])) >> -(cmShiftTable[0])) : ((unsigned) (sourcePix & (cmMaskTable[0])) << (cmShiftTable[0]))); + val = val | ((((cmShiftTable[1]) < 0) ? ((unsigned) (sourcePix & (cmMaskTable[1])) >> -(cmShiftTable[1])) : ((unsigned) (sourcePix & (cmMaskTable[1])) << (cmShiftTable[1])))); + val = val | ((((cmShiftTable[2]) < 0) ? ((unsigned) (sourcePix & (cmMaskTable[2])) >> -(cmShiftTable[2])) : ((unsigned) (sourcePix & (cmMaskTable[2])) << (cmShiftTable[2])))); + pv = val | ((((cmShiftTable[3]) < 0) ? ((unsigned) (sourcePix & (cmMaskTable[3])) >> -(cmShiftTable[3])) : ((unsigned) (sourcePix & (cmMaskTable[3])) << (cmShiftTable[3])))); + if ((pv == 0) && (sourcePix != 0)) { + pv = 1; + } + } + if ((mapperFlags & 4) != 0) { + pv = cmLookupTable[pv & cmMask]; + } + } + destPix = pv; + destWord1 = destWord1 | ((destPix & dstMask) << dstBitShift); + dstBitShift += dstShiftInc; + sx += xDelta; + sy += yDelta; + } while(!((nPix1 -= 1) == 0)); + } + skewWord = destWord1; + } else { + skewWord = warpPickSmoothPixelsxDeltahyDeltahxDeltavyDeltavsourceMapsmoothingdstShiftInc(nPix, xDelta, yDelta, deltaP12x, deltaP12y, sourceMapOop, smoothingCount, dstShiftInc); + } + dstBitShift = dstShiftLeft; + if (destMask == 4294967295U) { + mergeWord = mergeFnwith(skewWord & halftoneWord, longAt(destIndex)); + longAtput(destIndex, destMask & mergeWord); + } else { + destWord = longAt(destIndex); + mergeWord = mergeFnwith(skewWord & halftoneWord, destWord & destMask); + destWord = (destMask & mergeWord) | (destWord & (~destMask)); + longAtput(destIndex, destWord); + } + destIndex += 4; + if (words == 2) { + destMask = mask2; + nPix = endBits; + } else { + destMask = 4294967295U; + nPix = destPPW; + } + } while(!((words -= 1) == 0)); + pAx += deltaP12x; + pAy += deltaP12y; + pBx += deltaP43x; + pBy += deltaP43y; + destIndex += destDelta; + } +} + + +/* Setup values for faster pixel fetching. */ + +static int warpLoopSetup(void) { + int i; + int words; + + warpSrcShift = 0; + + /* recycle temp */ + + words = sourceDepth; + while (!(words == 1)) { + warpSrcShift += 1; + words = ((unsigned) words) >> 1; + } + + /* warpAlignShift: Shift for aligning x position to word boundary */ + + warpSrcMask = maskTable[sourceDepth]; + + /* warpAlignMask: Mask for extracting the pixel position from an x position */ + + warpAlignShift = 5 - warpSrcShift; + + /* Setup the lookup table for source bit shifts */ + /* warpBitShiftTable: given an sub-word x value what's the bit shift? */ + + warpAlignMask = (1 << warpAlignShift) - 1; + for (i = 0; i <= warpAlignMask; i += 1) { + if (sourceMSB) { + warpBitShiftTable[i] = (32 - ((i + 1) << warpSrcShift)); + } else { + warpBitShiftTable[i] = (i << warpSrcShift); + } + } +} + + +/* Pick n (sub-) pixels from the source form, mapped by sourceMap, + average the RGB values, map by colorMap and return the new word. + This version is only called from WarpBlt with smoothingCount > 1 */ + +static int warpPickSmoothPixelsxDeltahyDeltahxDeltavyDeltavsourceMapsmoothingdstShiftInc(int nPixels, int xDeltah, int yDeltah, int xDeltav, int yDeltav, int sourceMap, int n, int dstShiftInc) { + int x; + int g; + int i; + int k; + int nPix; + int b; + int yy; + int ydv; + int dstMask; + int y; + int ydh; + int destWord; + int xx; + int xdv; + int j; + int xdh; + int r; + int rgb; + int a; + int x1; + int sourcePix; + int sourceWord; + int y1; + int srcIndex; + int pv; + int val; + + dstMask = maskTable[destDepth]; + destWord = 0; + if (n == 2) { + xdh = ((int) xDeltah >> 1); + ydh = ((int) yDeltah >> 1); + xdv = ((int) xDeltav >> 1); + ydv = ((int) yDeltav >> 1); + } else { + xdh = xDeltah / n; + ydh = yDeltah / n; + xdv = xDeltav / n; + ydv = yDeltav / n; + } + i = nPixels; + do { + x = sx; + y = sy; + + /* Pick and average n*n subpixels */ + + a = r = g = b = 0; + + /* actual number of pixels (not clipped and not transparent) */ + + nPix = 0; + j = n; + do { + xx = x; + yy = y; + k = n; + do { + /* begin pickWarpPixelAtX:y: */ + if ((xx < 0) || ((yy < 0) || (((x1 = ((unsigned) xx) >> 14) >= sourceWidth) || ((y1 = ((unsigned) yy) >> 14) >= sourceHeight)))) { + rgb = 0; + goto l1; + } + srcIndex = (sourceBits + (y1 * sourcePitch)) + ((((unsigned) x1) >> warpAlignShift) * 4); + sourceWord = longAt(srcIndex); + srcBitShift = warpBitShiftTable[x1 & warpAlignMask]; + sourcePix = (((unsigned) sourceWord) >> srcBitShift) & warpSrcMask; + rgb = sourcePix; + l1: /* end pickWarpPixelAtX:y: */; + if (!((combinationRule == 25) && (rgb == 0))) { + nPix += 1; + if (sourceDepth < 16) { + rgb = longAt(sourceMap + (rgb << 2)); + } else { + if (sourceDepth == 16) { + rgb = (((rgb & 31) << 3) | ((rgb & 992) << 6)) | ((rgb & 31744) << 9); + } else { + rgb = rgb; + } + } + b += rgb & 255; + g += (((unsigned) rgb) >> 8) & 255; + r += (((unsigned) rgb) >> 16) & 255; + a += ((unsigned) rgb) >> 24; + } + xx += xdh; + yy += ydh; + } while(!((k -= 1) == 0)); + x += xdv; + y += ydv; + } while(!((j -= 1) == 0)); + if ((nPix == 0) || ((combinationRule == 25) && (nPix < (((int) (n * n) >> 1))))) { + + /* All pixels were 0, or most were transparent */ + + rgb = 0; + } else { + if (nPix == 4) { + r = ((unsigned) r) >> 2; + g = ((unsigned) g) >> 2; + b = ((unsigned) b) >> 2; + a = ((unsigned) a) >> 2; + } else { + r = r / nPix; + g = g / nPix; + b = b / nPix; + a = a / nPix; + } + + /* map the pixel */ + + rgb = (((a << 24) + (r << 16)) + (g << 8)) + b; + if (rgb == 0) { + if ((((r + g) + b) + a) > 0) { + rgb = 1; + } + } + /* begin mapPixel:flags: */ + pv = rgb; + if ((cmFlags & 1) != 0) { + if ((cmFlags & 2) != 0) { + /* begin rgbMapPixel:flags: */ + val = (((cmShiftTable[0]) < 0) ? ((unsigned) (rgb & (cmMaskTable[0])) >> -(cmShiftTable[0])) : ((unsigned) (rgb & (cmMaskTable[0])) << (cmShiftTable[0]))); + val = val | ((((cmShiftTable[1]) < 0) ? ((unsigned) (rgb & (cmMaskTable[1])) >> -(cmShiftTable[1])) : ((unsigned) (rgb & (cmMaskTable[1])) << (cmShiftTable[1])))); + val = val | ((((cmShiftTable[2]) < 0) ? ((unsigned) (rgb & (cmMaskTable[2])) >> -(cmShiftTable[2])) : ((unsigned) (rgb & (cmMaskTable[2])) << (cmShiftTable[2])))); + pv = val | ((((cmShiftTable[3]) < 0) ? ((unsigned) (rgb & (cmMaskTable[3])) >> -(cmShiftTable[3])) : ((unsigned) (rgb & (cmMaskTable[3])) << (cmShiftTable[3])))); + if ((pv == 0) && (rgb != 0)) { + pv = 1; + } + } + if ((cmFlags & 4) != 0) { + pv = cmLookupTable[pv & cmMask]; + } + } + rgb = pv; + } + destWord = destWord | ((rgb & dstMask) << dstBitShift); + dstBitShift += dstShiftInc; + sx += xDeltah; + sy += yDeltah; + } while(!((i -= 1) == 0)); + return destWord; +} + + +/* Pick n pixels from the source form, + map by colorMap and return aligned by dstBitShift. + This version is only called from WarpBlt with smoothingCount = 1 */ + +static int warpPickSourcePixelsxDeltahyDeltahxDeltavyDeltavdstShiftIncflags(int nPixels, int xDeltah, int yDeltah, int xDeltav, int yDeltav, int dstShiftInc, int mapperFlags) { + int sourcePix; + int nPix; + int destPix; + int dstMask; + int destWord; + int x; + int sourcePix1; + int sourceWord; + int y; + int srcIndex; + int x1; + int sourcePix2; + int sourceWord1; + int y1; + int srcIndex1; + int pv; + int val; + + dstMask = maskTable[destDepth]; + destWord = 0; + nPix = nPixels; + if (mapperFlags == (1 | 4)) { + do { + /* begin pickWarpPixelAtX:y: */ + if ((sx < 0) || ((sy < 0) || (((x = ((unsigned) sx) >> 14) >= sourceWidth) || ((y = ((unsigned) sy) >> 14) >= sourceHeight)))) { + sourcePix = 0; + goto l1; + } + srcIndex = (sourceBits + (y * sourcePitch)) + ((((unsigned) x) >> warpAlignShift) * 4); + sourceWord = longAt(srcIndex); + srcBitShift = warpBitShiftTable[x & warpAlignMask]; + sourcePix1 = (((unsigned) sourceWord) >> srcBitShift) & warpSrcMask; + sourcePix = sourcePix1; + l1: /* end pickWarpPixelAtX:y: */; + destPix = cmLookupTable[sourcePix & cmMask]; + destWord = destWord | ((destPix & dstMask) << dstBitShift); + dstBitShift += dstShiftInc; + sx += xDeltah; + sy += yDeltah; + } while(!((nPix -= 1) == 0)); + } else { + do { + /* begin pickWarpPixelAtX:y: */ + if ((sx < 0) || ((sy < 0) || (((x1 = ((unsigned) sx) >> 14) >= sourceWidth) || ((y1 = ((unsigned) sy) >> 14) >= sourceHeight)))) { + sourcePix = 0; + goto l2; + } + srcIndex1 = (sourceBits + (y1 * sourcePitch)) + ((((unsigned) x1) >> warpAlignShift) * 4); + sourceWord1 = longAt(srcIndex1); + srcBitShift = warpBitShiftTable[x1 & warpAlignMask]; + sourcePix2 = (((unsigned) sourceWord1) >> srcBitShift) & warpSrcMask; + sourcePix = sourcePix2; + l2: /* end pickWarpPixelAtX:y: */; + /* begin mapPixel:flags: */ + pv = sourcePix; + if ((mapperFlags & 1) != 0) { + if ((mapperFlags & 2) != 0) { + /* begin rgbMapPixel:flags: */ + val = (((cmShiftTable[0]) < 0) ? ((unsigned) (sourcePix & (cmMaskTable[0])) >> -(cmShiftTable[0])) : ((unsigned) (sourcePix & (cmMaskTable[0])) << (cmShiftTable[0]))); + val = val | ((((cmShiftTable[1]) < 0) ? ((unsigned) (sourcePix & (cmMaskTable[1])) >> -(cmShiftTable[1])) : ((unsigned) (sourcePix & (cmMaskTable[1])) << (cmShiftTable[1])))); + val = val | ((((cmShiftTable[2]) < 0) ? ((unsigned) (sourcePix & (cmMaskTable[2])) >> -(cmShiftTable[2])) : ((unsigned) (sourcePix & (cmMaskTable[2])) << (cmShiftTable[2])))); + pv = val | ((((cmShiftTable[3]) < 0) ? ((unsigned) (sourcePix & (cmMaskTable[3])) >> -(cmShiftTable[3])) : ((unsigned) (sourcePix & (cmMaskTable[3])) << (cmShiftTable[3])))); + if ((pv == 0) && (sourcePix != 0)) { + pv = 1; + } + } + if ((mapperFlags & 4) != 0) { + pv = cmLookupTable[pv & cmMask]; + } + } + destPix = pv; + destWord = destWord | ((destPix & dstMask) << dstBitShift); + dstBitShift += dstShiftInc; + sx += xDeltah; + sy += yDeltah; + } while(!((nPix -= 1) == 0)); + } + return destWord; +} + + +#ifdef SQUEAK_BUILTIN_PLUGIN + + +void* BitBltPlugin_exports[][3] = { + {"BitBltPlugin", "primitiveDrawLoop", (void*)primitiveDrawLoop}, + {"BitBltPlugin", "initialiseModule", (void*)initialiseModule}, + {"BitBltPlugin", "copyBitsFromtoat", (void*)copyBitsFromtoat}, + {"BitBltPlugin", "loadBitBltFrom", (void*)loadBitBltFrom}, + {"BitBltPlugin", "primitiveWarpBits", (void*)primitiveWarpBits}, + {"BitBltPlugin", "copyBits", (void*)copyBits}, + {"BitBltPlugin", "moduleUnloaded", (void*)moduleUnloaded}, + {"BitBltPlugin", "primitiveCopyBits", (void*)primitiveCopyBits}, + {"BitBltPlugin", "getModuleName", (void*)getModuleName}, + {"BitBltPlugin", "primitiveDisplayString", (void*)primitiveDisplayString}, + {"BitBltPlugin", "setInterpreter", (void*)setInterpreter}, + {NULL, NULL, NULL} +}; + + +#endif /* ifdef SQ_BUILTIN_PLUGIN */ + diff --git a/squeak/FilePlugin.c b/squeak/FilePlugin.c new file mode 100644 index 0000000..2de504c --- /dev/null +++ b/squeak/FilePlugin.c @@ -0,0 +1,892 @@ +/* Automatically generated from Squeak on #(4 March 2003 4:22:51 am) */ + +#include +#include +#include +#include +#include + +/* Default EXPORT macro that does nothing (see comment in sq.h): */ +#define EXPORT(returnType) returnType + +/* Do not include the entire sq.h file but just those parts needed. */ +/* The virtual machine proxy definition */ +#include "sqVirtualMachine.h" +/* Configuration options */ +#include "sqConfig.h" +/* Platform specific definitions */ +#include "sqPlatformSpecific.h" + +#define true 1 +#define false 0 +#define null 0 /* using 'null' because nil is predefined in Think C */ +#ifdef SQUEAK_BUILTIN_PLUGIN +#undef EXPORT +// was #undef EXPORT(returnType) but screws NorCroft cc +#define EXPORT(returnType) static returnType +#endif +#include "FilePlugin.h" + +/* memory access macros */ +#define byteAt(i) (*((unsigned char *) (i))) +#define byteAtput(i, val) (*((unsigned char *) (i)) = val) +#define longAt(i) (*((int *) (i))) +#define longAtput(i, val) (*((int *) (i)) = val) + + +/*** Variables ***/ + +#ifdef SQUEAK_BUILTIN_PLUGIN +extern +#endif +struct VirtualMachine* interpreterProxy; +static const char *moduleName = +#ifdef SQUEAK_BUILTIN_PLUGIN + "FilePlugin 4 March 2003 (i)" +#else + "FilePlugin 4 March 2003 (e)" +#endif +; +static int sCCPfn; +static int sCDFfn; +static int sCDPfn; +static int sCGFTfn; +static int sCLPfn; +static int sCOFfn; +static int sCRFfn; +static int sCSFTfn; +static int sDFAfn; +static int sHFAfn; + +/*** Function Prototypes ***/ +static int asciiDirectoryDelimiter(void); +#pragma export on +EXPORT(int) fileOpenNamesizewritesecure(char * nameIndex, int nameSize, int writeFlag, int secureFlag); +#pragma export off +int fileRecordSize(void); +SQFile * fileValueOf(int objectPointer); +#pragma export on +EXPORT(const char*) getModuleName(void); +EXPORT(int) getThisSession(void); +#pragma export off +static int halt(void); +#pragma export on +EXPORT(int) initialiseModule(void); +#pragma export off +static int makeDirEntryNamesizecreateDatemodDateisDirfileSize(char *entryName, int entryNameSize, int createDate, int modifiedDate, int dirFlag, squeakFileOffsetType fileSize); +#pragma export on +EXPORT(int) moduleUnloaded(char * aModuleName); +#pragma export off +static int msg(char *s); +#pragma export on +EXPORT(int) primitiveDirectoryCreate(void); +EXPORT(int) primitiveDirectoryDelete(void); +EXPORT(int) primitiveDirectoryDelimitor(void); +EXPORT(int) primitiveDirectoryGetMacTypeAndCreator(void); +EXPORT(int) primitiveDirectoryLookup(void); +EXPORT(int) primitiveDirectorySetMacTypeAndCreator(void); +EXPORT(int) primitiveDisableFileAccess(void); +EXPORT(int) primitiveFileAtEnd(void); +EXPORT(int) primitiveFileClose(void); +EXPORT(int) primitiveFileDelete(void); +EXPORT(int) primitiveFileFlush(void); +EXPORT(int) primitiveFileGetPosition(void); +EXPORT(int) primitiveFileOpen(void); +EXPORT(int) primitiveFileRead(void); +EXPORT(int) primitiveFileRename(void); +EXPORT(int) primitiveFileSetPosition(void); +EXPORT(int) primitiveFileSize(void); +EXPORT(int) primitiveFileTruncate(void); +EXPORT(int) primitiveFileWrite(void); +EXPORT(int) primitiveHasFileAccess(void); +EXPORT(int) setInterpreter(struct VirtualMachine* anInterpreter); +EXPORT(int) setMacFileTypeAndCreator(char * fileName, char * typeString, char * creatorString); +EXPORT(int) shutdownModule(void); +#pragma export off + +static int asciiDirectoryDelimiter(void) { + return dir_Delimitor(); +} + + +/* Open the named file, possibly checking security. Answer the file oop. */ + +EXPORT(int) fileOpenNamesizewritesecure(char * nameIndex, int nameSize, int writeFlag, int secureFlag) { + int fileOop; + SQFile * file; + int okToOpen; + + fileOop = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classByteArray(), fileRecordSize()); + /* begin fileValueOf: */ + if (!((interpreterProxy->isBytes(fileOop)) && ((interpreterProxy->byteSizeOf(fileOop)) == (fileRecordSize())))) { + interpreterProxy->primitiveFail(); + file = null; + goto l1; + } + file = interpreterProxy->firstIndexableField(fileOop); +l1: /* end fileValueOf: */; + if (!(interpreterProxy->failed())) { + if (secureFlag) { + if (sCOFfn != 0) { + okToOpen = ((int (*) (char *, int, int)) sCOFfn)(nameIndex, nameSize, writeFlag); + if (!(okToOpen)) { + interpreterProxy->primitiveFail(); + } + } + } + } + if (!(interpreterProxy->failed())) { + sqFileOpen(file, (int)nameIndex, nameSize, writeFlag); + } + return fileOop; +} + + +/* Return the size of a Smalltalk file record in bytes. */ + +int fileRecordSize(void) { + return sizeof(SQFile); +} + + +/* Return a pointer to the first byte of of the file record within the given Smalltalk object, or nil if objectPointer is not a file record. */ + +SQFile * fileValueOf(int objectPointer) { + if (!((interpreterProxy->isBytes(objectPointer)) && ((interpreterProxy->byteSizeOf(objectPointer)) == (fileRecordSize())))) { + interpreterProxy->primitiveFail(); + return null; + } + return interpreterProxy->firstIndexableField(objectPointer); +} + + +/* Note: This is hardcoded so it can be run from Squeak. + The module name is used for validating a module *after* + it is loaded to check if it does really contain the module + we're thinking it contains. This is important! */ + +EXPORT(const char*) getModuleName(void) { + return moduleName; +} + + +/* Exported entry point for the VM. */ + +EXPORT(int) getThisSession(void) { + return sqFileThisSession(); +} + +static int halt(void) { + ; +} + +EXPORT(int) initialiseModule(void) { + sCCPfn = interpreterProxy->ioLoadFunctionFrom("secCanCreatePathOfSize", "SecurityPlugin"); + sCDPfn = interpreterProxy->ioLoadFunctionFrom("secCanDeletePathOfSize", "SecurityPlugin"); + sCGFTfn = interpreterProxy->ioLoadFunctionFrom("secCanGetFileTypeOfSize", "SecurityPlugin"); + sCLPfn = interpreterProxy->ioLoadFunctionFrom("secCanListPathOfSize", "SecurityPlugin"); + sCSFTfn = interpreterProxy->ioLoadFunctionFrom("secCanSetFileTypeOfSize", "SecurityPlugin"); + sDFAfn = interpreterProxy->ioLoadFunctionFrom("secDisableFileAccess", "SecurityPlugin"); + sCDFfn = interpreterProxy->ioLoadFunctionFrom("secCanDeleteFileOfSize", "SecurityPlugin"); + sCOFfn = interpreterProxy->ioLoadFunctionFrom("secCanOpenFileOfSizeWritable", "SecurityPlugin"); + sCRFfn = interpreterProxy->ioLoadFunctionFrom("secCanRenameFileOfSize", "SecurityPlugin"); + sHFAfn = interpreterProxy->ioLoadFunctionFrom("secHasFileAccess", "SecurityPlugin"); + return sqFileInit(); +} + +static int makeDirEntryNamesizecreateDatemodDateisDirfileSize(char *entryName, int entryNameSize, int createDate, int modifiedDate, int dirFlag, squeakFileOffsetType fileSize) { + char *stringPtr; + int results; + int i; + int createDateOop; + int modDateOop; + int nameString; + int fileSizeOop; + + interpreterProxy->pushRemappableOop(interpreterProxy->instantiateClassindexableSize(interpreterProxy->classArray(), 5)); + interpreterProxy->pushRemappableOop(interpreterProxy->instantiateClassindexableSize(interpreterProxy->classString(), entryNameSize)); + interpreterProxy->pushRemappableOop(interpreterProxy->positive32BitIntegerFor(createDate)); + interpreterProxy->pushRemappableOop(interpreterProxy->positive32BitIntegerFor(modifiedDate)); + interpreterProxy->pushRemappableOop(interpreterProxy->positive64BitIntegerFor(fileSize)); + fileSizeOop = interpreterProxy->popRemappableOop(); + modDateOop = interpreterProxy->popRemappableOop(); + createDateOop = interpreterProxy->popRemappableOop(); + nameString = interpreterProxy->popRemappableOop(); + + /* copy name into Smalltalk string */ + + results = interpreterProxy->popRemappableOop(); + stringPtr = interpreterProxy->firstIndexableField(nameString); + for (i = 0; i <= (entryNameSize - 1); i += 1) { + stringPtr[i] = (entryName[i]); + } + interpreterProxy->storePointerofObjectwithValue(0, results, nameString); + interpreterProxy->storePointerofObjectwithValue(1, results, createDateOop); + interpreterProxy->storePointerofObjectwithValue(2, results, modDateOop); + if (dirFlag) { + interpreterProxy->storePointerofObjectwithValue(3, results, interpreterProxy->trueObject()); + } else { + interpreterProxy->storePointerofObjectwithValue(3, results, interpreterProxy->falseObject()); + } + interpreterProxy->storePointerofObjectwithValue(4, results, fileSizeOop); + return results; +} + + +/* The module with the given name was just unloaded. + Make sure we have no dangling references. */ + +EXPORT(int) moduleUnloaded(char * aModuleName) { + if ((strcmp(aModuleName, "SecurityPlugin")) == 0) { + sCCPfn = sCDPfn = sCGFTfn = sCLPfn = sCSFTfn = sDFAfn = sCDFfn = sCOFfn = sCRFfn = sHFAfn = 0; + } +} + +static int msg(char *s) { + fprintf(stderr, "\n%s: %s", moduleName, s); +} + +EXPORT(int) primitiveDirectoryCreate(void) { + int dirName; + int okToCreate; + char * dirNameIndex; + int dirNameSize; + + dirName = interpreterProxy->stackValue(0); + if (!(interpreterProxy->isBytes(dirName))) { + return interpreterProxy->primitiveFail(); + } + dirNameIndex = interpreterProxy->firstIndexableField(dirName); + + /* If the security plugin can be loaded, use it to check for permission. + If + not, assume it's ok */ + + dirNameSize = interpreterProxy->byteSizeOf(dirName); + if (sCCPfn != 0) { + okToCreate = ((int (*) (char *, int)) sCCPfn)(dirNameIndex, dirNameSize); + if (!(okToCreate)) { + return interpreterProxy->primitiveFail(); + } + } + if (!(dir_Create((char *) dirNameIndex, dirNameSize))) { + return interpreterProxy->primitiveFail(); + } + interpreterProxy->pop(1); +} + +EXPORT(int) primitiveDirectoryDelete(void) { + int okToDelete; + int dirName; + char * dirNameIndex; + int dirNameSize; + + dirName = interpreterProxy->stackValue(0); + if (!(interpreterProxy->isBytes(dirName))) { + return interpreterProxy->primitiveFail(); + } + dirNameIndex = interpreterProxy->firstIndexableField(dirName); + + /* If the security plugin can be loaded, use it to check for permission. + If + not, assume it's ok */ + + dirNameSize = interpreterProxy->byteSizeOf(dirName); + if (sCDPfn != 0) { + okToDelete = ((int (*) (char *, int)) sCDPfn)(dirNameIndex, dirNameSize); + if (!(okToDelete)) { + return interpreterProxy->primitiveFail(); + } + } + if (!(dir_Delete((char *) dirNameIndex, dirNameSize))) { + return interpreterProxy->primitiveFail(); + } + interpreterProxy->pop(1); +} + +EXPORT(int) primitiveDirectoryDelimitor(void) { + int ascii; + + ascii = asciiDirectoryDelimiter(); + if (!((ascii >= 0) && (ascii <= 255))) { + return interpreterProxy->primitiveFail(); + } + interpreterProxy->pop(1); + interpreterProxy->push(interpreterProxy->fetchPointerofObject(ascii, interpreterProxy->characterTable())); +} + +EXPORT(int) primitiveDirectoryGetMacTypeAndCreator(void) { + int typeString; + int okToGet; + int fileName; + int creatorString; + int fileNameSize; + char * typeStringIndex; + char * creatorStringIndex; + char * fileNameIndex; + + creatorString = interpreterProxy->stackValue(0); + typeString = interpreterProxy->stackValue(1); + fileName = interpreterProxy->stackValue(2); + if (!((interpreterProxy->isBytes(creatorString)) && ((interpreterProxy->byteSizeOf(creatorString)) == 4))) { + return interpreterProxy->primitiveFail(); + } + if (!((interpreterProxy->isBytes(typeString)) && ((interpreterProxy->byteSizeOf(typeString)) == 4))) { + return interpreterProxy->primitiveFail(); + } + if (!(interpreterProxy->isBytes(fileName))) { + return interpreterProxy->primitiveFail(); + } + creatorStringIndex = interpreterProxy->firstIndexableField(creatorString); + typeStringIndex = interpreterProxy->firstIndexableField(typeString); + fileNameIndex = interpreterProxy->firstIndexableField(fileName); + + /* If the security plugin can be loaded, use it to check for permission. + If + not, assume it's ok */ + + fileNameSize = interpreterProxy->byteSizeOf(fileName); + if (sCGFTfn != 0) { + okToGet = ((int (*) (char *, int)) sCGFTfn)(fileNameIndex, fileNameSize); + if (!(okToGet)) { + return interpreterProxy->primitiveFail(); + } + } + if (!(dir_GetMacFileTypeAndCreator( + (char *) fileNameIndex, fileNameSize, + (char *) typeStringIndex, (char *) creatorStringIndex))) { + return interpreterProxy->primitiveFail(); + } + interpreterProxy->pop(3); +} + +EXPORT(int) primitiveDirectoryLookup(void) { + char entryName[256]; + int pathNameSize; + int status; + int createDate; + int dirFlag; + int entryNameSize; + int modifiedDate; + squeakFileOffsetType fileSize; + int okToList; + int pathName; + char * pathNameIndex; + int index; + + index = interpreterProxy->stackIntegerValue(0); + pathName = interpreterProxy->stackValue(1); + if (!(interpreterProxy->isBytes(pathName))) { + return interpreterProxy->primitiveFail(); + } + pathNameIndex = interpreterProxy->firstIndexableField(pathName); + + /* If the security plugin can be loaded, use it to check for permission. + If not, assume it's ok */ + + pathNameSize = interpreterProxy->byteSizeOf(pathName); + if (sCLPfn != 0) { + okToList = ((int (*) (char *, int)) sCLPfn)(pathNameIndex, pathNameSize); + } else { + okToList = 1; + } + if (okToList) { + status = dir_Lookup( + (char *) pathNameIndex, pathNameSize, index, + entryName, &entryNameSize, &createDate, &modifiedDate, + &dirFlag, &fileSize); + } else { + status = 1; + } + if (interpreterProxy->failed()) { + return null; + } + if (status == 1) { + interpreterProxy->pop(3); + interpreterProxy->push(interpreterProxy->nilObject()); + return null; + } + if (status == 2) { + return interpreterProxy->primitiveFail(); + } + interpreterProxy->pop(3); + interpreterProxy->push(makeDirEntryNamesizecreateDatemodDateisDirfileSize(entryName, entryNameSize, createDate, modifiedDate, dirFlag, fileSize)); +} + +EXPORT(int) primitiveDirectorySetMacTypeAndCreator(void) { + int okToSet; + int typeString; + int fileName; + int creatorString; + int fileNameSize; + char * typeStringIndex; + char * creatorStringIndex; + char * fileNameIndex; + + creatorString = interpreterProxy->stackValue(0); + typeString = interpreterProxy->stackValue(1); + fileName = interpreterProxy->stackValue(2); + if (!((interpreterProxy->isBytes(creatorString)) && ((interpreterProxy->byteSizeOf(creatorString)) == 4))) { + return interpreterProxy->primitiveFail(); + } + if (!((interpreterProxy->isBytes(typeString)) && ((interpreterProxy->byteSizeOf(typeString)) == 4))) { + return interpreterProxy->primitiveFail(); + } + if (!(interpreterProxy->isBytes(fileName))) { + return interpreterProxy->primitiveFail(); + } + creatorStringIndex = interpreterProxy->firstIndexableField(creatorString); + typeStringIndex = interpreterProxy->firstIndexableField(typeString); + fileNameIndex = interpreterProxy->firstIndexableField(fileName); + + /* If the security plugin can be loaded, use it to check for permission. + If + not, assume it's ok */ + + fileNameSize = interpreterProxy->byteSizeOf(fileName); + if (sCSFTfn != 0) { + okToSet = ((int (*) (char *, int)) sCSFTfn)(fileNameIndex, fileNameSize); + if (!(okToSet)) { + return interpreterProxy->primitiveFail(); + } + } + if (!(dir_SetMacFileTypeAndCreator( + (char *) fileNameIndex, fileNameSize, + (char *) typeStringIndex, (char *) creatorStringIndex))) { + return interpreterProxy->primitiveFail(); + } + interpreterProxy->pop(3); +} + +EXPORT(int) primitiveDisableFileAccess(void) { + if (sDFAfn != 0) { + ((int (*) (void)) sDFAfn)(); + } + if (!(interpreterProxy->failed())) { + interpreterProxy->pop(1); + } +} + +EXPORT(int) primitiveFileAtEnd(void) { + SQFile * file; + int atEnd; + int objectPointer; + + /* begin fileValueOf: */ + objectPointer = interpreterProxy->stackValue(0); + if (!((interpreterProxy->isBytes(objectPointer)) && ((interpreterProxy->byteSizeOf(objectPointer)) == (fileRecordSize())))) { + interpreterProxy->primitiveFail(); + file = null; + goto l1; + } + file = interpreterProxy->firstIndexableField(objectPointer); +l1: /* end fileValueOf: */; + if (!(interpreterProxy->failed())) { + atEnd = sqFileAtEnd(file); + } + if (!(interpreterProxy->failed())) { + interpreterProxy->pop(2); + interpreterProxy->pushBool(atEnd); + } +} + +EXPORT(int) primitiveFileClose(void) { + SQFile * file; + int objectPointer; + + /* begin fileValueOf: */ + objectPointer = interpreterProxy->stackValue(0); + if (!((interpreterProxy->isBytes(objectPointer)) && ((interpreterProxy->byteSizeOf(objectPointer)) == (fileRecordSize())))) { + interpreterProxy->primitiveFail(); + file = null; + goto l1; + } + file = interpreterProxy->firstIndexableField(objectPointer); +l1: /* end fileValueOf: */; + if (!(interpreterProxy->failed())) { + sqFileClose(file); + } + if (!(interpreterProxy->failed())) { + interpreterProxy->pop(1); + } +} + +EXPORT(int) primitiveFileDelete(void) { + char * nameIndex; + int namePointer; + int okToDelete; + int nameSize; + + namePointer = interpreterProxy->stackValue(0); + if (!(interpreterProxy->isBytes(namePointer))) { + return interpreterProxy->primitiveFail(); + } + nameIndex = interpreterProxy->firstIndexableField(namePointer); + + /* If the security plugin can be loaded, use it to check for permission. + If + not, assume it's ok */ + + nameSize = interpreterProxy->byteSizeOf(namePointer); + if (sCDFfn != 0) { + okToDelete = ((int (*) (char *, int)) sCDFfn)(nameIndex, nameSize); + if (!(okToDelete)) { + return interpreterProxy->primitiveFail(); + } + } + sqFileDeleteNameSize(((int) nameIndex), nameSize); + if (!(interpreterProxy->failed())) { + interpreterProxy->pop(1); + } +} + +EXPORT(int) primitiveFileFlush(void) { + SQFile * file; + int objectPointer; + + /* begin fileValueOf: */ + objectPointer = interpreterProxy->stackValue(0); + if (!((interpreterProxy->isBytes(objectPointer)) && ((interpreterProxy->byteSizeOf(objectPointer)) == (fileRecordSize())))) { + interpreterProxy->primitiveFail(); + file = null; + goto l1; + } + file = interpreterProxy->firstIndexableField(objectPointer); +l1: /* end fileValueOf: */; + if (!(interpreterProxy->failed())) { + sqFileFlush(file); + } + if (!(interpreterProxy->failed())) { + interpreterProxy->pop(1); + } +} + +EXPORT(int) primitiveFileGetPosition(void) { + squeakFileOffsetType position; + SQFile * file; + int objectPointer; + + /* begin fileValueOf: */ + objectPointer = interpreterProxy->stackValue(0); + if (!((interpreterProxy->isBytes(objectPointer)) && ((interpreterProxy->byteSizeOf(objectPointer)) == (fileRecordSize())))) { + interpreterProxy->primitiveFail(); + file = null; + goto l1; + } + file = interpreterProxy->firstIndexableField(objectPointer); +l1: /* end fileValueOf: */; + if (!(interpreterProxy->failed())) { + position = sqFileGetPosition(file); + } + if (!(interpreterProxy->failed())) { + interpreterProxy->pop(2); + interpreterProxy->push(interpreterProxy->positive64BitIntegerFor(position)); + } +} + +EXPORT(int) primitiveFileOpen(void) { + int writeFlag; + char * nameIndex; + int namePointer; + int filePointer; + int nameSize; + + writeFlag = interpreterProxy->booleanValueOf(interpreterProxy->stackValue(0)); + namePointer = interpreterProxy->stackValue(1); + if (!(interpreterProxy->isBytes(namePointer))) { + return interpreterProxy->primitiveFail(); + } + nameIndex = interpreterProxy->firstIndexableField(namePointer); + nameSize = interpreterProxy->byteSizeOf(namePointer); + filePointer = fileOpenNamesizewritesecure(nameIndex, nameSize, writeFlag, 1); + if (!(interpreterProxy->failed())) { + interpreterProxy->pop(3); + interpreterProxy->push(filePointer); + } +} + +EXPORT(int) primitiveFileRead(void) { + size_t byteSize; + size_t count; + int array; + SQFile * file; + int bytesRead; + size_t startIndex; + char * arrayIndex; + int objectPointer; + + count = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(0)); + startIndex = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(1)); + array = interpreterProxy->stackValue(2); + /* begin fileValueOf: */ + objectPointer = interpreterProxy->stackValue(3); + if (!((interpreterProxy->isBytes(objectPointer)) && ((interpreterProxy->byteSizeOf(objectPointer)) == (fileRecordSize())))) { + interpreterProxy->primitiveFail(); + file = null; + goto l1; + } + file = interpreterProxy->firstIndexableField(objectPointer); +l1: /* end fileValueOf: */; + if (!(interpreterProxy->isWordsOrBytes(array))) { + return interpreterProxy->primitiveFail(); + } + if (interpreterProxy->isWords(array)) { + byteSize = 4; + } else { + byteSize = 1; + } + if (!((startIndex >= 1) && (((startIndex + count) - 1) <= (interpreterProxy->slotSizeOf(array))))) { + return interpreterProxy->primitiveFail(); + } + + /* Note: adjust startIndex for zero-origin indexing */ + + arrayIndex = interpreterProxy->firstIndexableField(array); + bytesRead = sqFileReadIntoAt(file, count * byteSize, ((int) arrayIndex), (startIndex - 1) * byteSize); + if (!(interpreterProxy->failed())) { + interpreterProxy->pop(5); + interpreterProxy->pushInteger(bytesRead / byteSize); + } +} + +EXPORT(int) primitiveFileRename(void) { + char * newNameIndex; + char * oldNameIndex; + int newNamePointer; + int okToRename; + int oldNameSize; + int oldNamePointer; + int newNameSize; + + newNamePointer = interpreterProxy->stackValue(0); + oldNamePointer = interpreterProxy->stackValue(1); + if (!((interpreterProxy->isBytes(newNamePointer)) && (interpreterProxy->isBytes(oldNamePointer)))) { + return interpreterProxy->primitiveFail(); + } + newNameIndex = interpreterProxy->firstIndexableField(newNamePointer); + newNameSize = interpreterProxy->byteSizeOf(newNamePointer); + oldNameIndex = interpreterProxy->firstIndexableField(oldNamePointer); + + /* If the security plugin can be loaded, use it to check for rename + permission. + If not, assume it's ok */ + + oldNameSize = interpreterProxy->byteSizeOf(oldNamePointer); + if (sCRFfn != 0) { + okToRename = ((int (*) (char *, int)) sCRFfn)(oldNameIndex, oldNameSize); + if (!(okToRename)) { + return interpreterProxy->primitiveFail(); + } + } + sqFileRenameOldSizeNewSize(((int) oldNameIndex), oldNameSize, ((int) newNameIndex), newNameSize); + if (!(interpreterProxy->failed())) { + interpreterProxy->pop(2); + } +} + +EXPORT(int) primitiveFileSetPosition(void) { + squeakFileOffsetType newPosition; + SQFile * file; + int sz; + int objectPointer; + + if (!(((interpreterProxy->stackValue(0)) & 1))) { + sz = sizeof(squeakFileOffsetType); + if ((interpreterProxy->byteSizeOf(interpreterProxy->stackValue(0))) > sz) { + return interpreterProxy->primitiveFail(); + } + } + newPosition = interpreterProxy->positive64BitValueOf(interpreterProxy->stackValue(0)); + /* begin fileValueOf: */ + objectPointer = interpreterProxy->stackValue(1); + if (!((interpreterProxy->isBytes(objectPointer)) && ((interpreterProxy->byteSizeOf(objectPointer)) == (fileRecordSize())))) { + interpreterProxy->primitiveFail(); + file = null; + goto l1; + } + file = interpreterProxy->firstIndexableField(objectPointer); +l1: /* end fileValueOf: */; + if (!(interpreterProxy->failed())) { + sqFileSetPosition(file, newPosition); + } + if (!(interpreterProxy->failed())) { + interpreterProxy->pop(2); + } +} + +EXPORT(int) primitiveFileSize(void) { + squeakFileOffsetType size; + SQFile * file; + int objectPointer; + + /* begin fileValueOf: */ + objectPointer = interpreterProxy->stackValue(0); + if (!((interpreterProxy->isBytes(objectPointer)) && ((interpreterProxy->byteSizeOf(objectPointer)) == (fileRecordSize())))) { + interpreterProxy->primitiveFail(); + file = null; + goto l1; + } + file = interpreterProxy->firstIndexableField(objectPointer); +l1: /* end fileValueOf: */; + if (!(interpreterProxy->failed())) { + size = sqFileSize(file); + } + if (!(interpreterProxy->failed())) { + interpreterProxy->pop(2); + interpreterProxy->push(interpreterProxy->positive64BitIntegerFor(size)); + } +} + +EXPORT(int) primitiveFileTruncate(void) { + SQFile * file; + squeakFileOffsetType truncatePosition; + int sz; + int objectPointer; + + if (!(((interpreterProxy->stackValue(0)) & 1))) { + sz = sizeof(squeakFileOffsetType); + if ((interpreterProxy->byteSizeOf(interpreterProxy->stackValue(0))) > sz) { + return interpreterProxy->primitiveFail(); + } + } + truncatePosition = interpreterProxy->positive64BitValueOf(interpreterProxy->stackValue(0)); + /* begin fileValueOf: */ + objectPointer = interpreterProxy->stackValue(1); + if (!((interpreterProxy->isBytes(objectPointer)) && ((interpreterProxy->byteSizeOf(objectPointer)) == (fileRecordSize())))) { + interpreterProxy->primitiveFail(); + file = null; + goto l1; + } + file = interpreterProxy->firstIndexableField(objectPointer); +l1: /* end fileValueOf: */; + if (!(interpreterProxy->failed())) { + sqFileTruncate(file, truncatePosition); + } + if (!(interpreterProxy->failed())) { + interpreterProxy->pop(2); + } +} + +EXPORT(int) primitiveFileWrite(void) { + size_t byteSize; + size_t count; + int array; + SQFile * file; + int bytesWritten; + size_t startIndex; + char * arrayIndex; + int objectPointer; + + count = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(0)); + startIndex = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(1)); + array = interpreterProxy->stackValue(2); + /* begin fileValueOf: */ + objectPointer = interpreterProxy->stackValue(3); + if (!((interpreterProxy->isBytes(objectPointer)) && ((interpreterProxy->byteSizeOf(objectPointer)) == (fileRecordSize())))) { + interpreterProxy->primitiveFail(); + file = null; + goto l1; + } + file = interpreterProxy->firstIndexableField(objectPointer); +l1: /* end fileValueOf: */; + if (!(interpreterProxy->isWordsOrBytes(array))) { + return interpreterProxy->primitiveFail(); + } + if (interpreterProxy->isWords(array)) { + byteSize = 4; + } else { + byteSize = 1; + } + if (!((startIndex >= 1) && (((startIndex + count) - 1) <= (interpreterProxy->slotSizeOf(array))))) { + return interpreterProxy->primitiveFail(); + } + if (!(interpreterProxy->failed())) { + + /* Note: adjust startIndex for zero-origin indexing */ + + arrayIndex = interpreterProxy->firstIndexableField(array); + bytesWritten = sqFileWriteFromAt(file, count * byteSize, ((int) arrayIndex), (startIndex - 1) * byteSize); + } + if (!(interpreterProxy->failed())) { + interpreterProxy->pop(5); + interpreterProxy->pushInteger(bytesWritten / byteSize); + } +} + +EXPORT(int) primitiveHasFileAccess(void) { + int hasAccess; + + if (sHFAfn != 0) { + hasAccess = ((int (*) (void)) sHFAfn)(); + } else { + hasAccess = 1; + } + interpreterProxy->pop(1); + interpreterProxy->pushBool(hasAccess); +} + + +/* Note: This is coded so that is can be run from Squeak. */ + +EXPORT(int) setInterpreter(struct VirtualMachine* anInterpreter) { + int ok; + + interpreterProxy = anInterpreter; + ok = interpreterProxy->majorVersion() == VM_PROXY_MAJOR; + if (ok == 0) { + return 0; + } + ok = interpreterProxy->minorVersion() >= VM_PROXY_MINOR; + return ok; +} + + +/* Exported entry point for the VM. Needed for image saving only and no-op on anything but Macs. */ + +EXPORT(int) setMacFileTypeAndCreator(char * fileName, char * typeString, char * creatorString) { + return dir_SetMacFileTypeAndCreator(fileName, strlen(fileName), typeString, creatorString); +} + +EXPORT(int) shutdownModule(void) { + return sqFileShutdown(); +} + + +#ifdef SQUEAK_BUILTIN_PLUGIN + + +void* FilePlugin_exports[][3] = { + {"FilePlugin", "primitiveHasFileAccess", (void*)primitiveHasFileAccess}, + {"FilePlugin", "primitiveFileFlush", (void*)primitiveFileFlush}, + {"FilePlugin", "primitiveFileTruncate", (void*)primitiveFileTruncate}, + {"FilePlugin", "initialiseModule", (void*)initialiseModule}, + {"FilePlugin", "primitiveFileGetPosition", (void*)primitiveFileGetPosition}, + {"FilePlugin", "primitiveDirectoryCreate", (void*)primitiveDirectoryCreate}, + {"FilePlugin", "fileOpenNamesizewritesecure", (void*)fileOpenNamesizewritesecure}, + {"FilePlugin", "primitiveDirectoryDelimitor", (void*)primitiveDirectoryDelimitor}, + {"FilePlugin", "primitiveDisableFileAccess", (void*)primitiveDisableFileAccess}, + {"FilePlugin", "getModuleName", (void*)getModuleName}, + {"FilePlugin", "primitiveFileDelete", (void*)primitiveFileDelete}, + {"FilePlugin", "primitiveDirectoryDelete", (void*)primitiveDirectoryDelete}, + {"FilePlugin", "primitiveFileSetPosition", (void*)primitiveFileSetPosition}, + {"FilePlugin", "setInterpreter", (void*)setInterpreter}, + {"FilePlugin", "primitiveDirectoryLookup", (void*)primitiveDirectoryLookup}, + {"FilePlugin", "primitiveFileAtEnd", (void*)primitiveFileAtEnd}, + {"FilePlugin", "primitiveDirectorySetMacTypeAndCreator", (void*)primitiveDirectorySetMacTypeAndCreator}, + {"FilePlugin", "primitiveFileClose", (void*)primitiveFileClose}, + {"FilePlugin", "primitiveFileSize", (void*)primitiveFileSize}, + {"FilePlugin", "primitiveFileRename", (void*)primitiveFileRename}, + {"FilePlugin", "shutdownModule", (void*)shutdownModule}, + {"FilePlugin", "primitiveFileOpen", (void*)primitiveFileOpen}, + {"FilePlugin", "setMacFileTypeAndCreator", (void*)setMacFileTypeAndCreator}, + {"FilePlugin", "moduleUnloaded", (void*)moduleUnloaded}, + {"FilePlugin", "primitiveDirectoryGetMacTypeAndCreator", (void*)primitiveDirectoryGetMacTypeAndCreator}, + {"FilePlugin", "getThisSession", (void*)getThisSession}, + {"FilePlugin", "primitiveFileWrite", (void*)primitiveFileWrite}, + {"FilePlugin", "primitiveFileRead", (void*)primitiveFileRead}, + {NULL, NULL, NULL} +}; + + +#endif /* ifdef SQ_BUILTIN_PLUGIN */ + diff --git a/squeak/FilePlugin.h b/squeak/FilePlugin.h new file mode 100644 index 0000000..706ccab --- /dev/null +++ b/squeak/FilePlugin.h @@ -0,0 +1,52 @@ +/**************************************************************************** +* PROJECT: Common include +* FILE: FilePlugin.h +* CONTENT: +* +* AUTHOR: +* ADDRESS: +* EMAIL: +* RCSID: $Id: FilePlugin.h,v 1.4 2002/01/29 05:18:38 rowledge Exp $ +* +* 01/22/2002 JMM change off_t to squeakOffsetFileType +*/ +/* File support definitions */ + +/* squeak file record; see sqFilePrims.c for details */ +typedef struct { + FILE *file; + int sessionID; + int writable; + squeakFileOffsetType fileSize; + int lastOp; /* 0 = uncommitted, 1 = read, 2 = write */ +} SQFile; + +/* file i/o */ +int sqFileAtEnd(SQFile *f); +int sqFileClose(SQFile *f); +int sqFileDeleteNameSize(int sqFileNameIndex, int sqFileNameSize); +squeakFileOffsetType sqFileGetPosition(SQFile *f); +int sqFileInit(void); +int sqFileShutdown(void); +int sqFileOpen(SQFile *f, int sqFileNameIndex, int sqFileNameSize, int writeFlag); +size_t sqFileReadIntoAt(SQFile *f, size_t count, int byteArrayIndex, size_t startIndex); +int sqFileRenameOldSizeNewSize(int oldNameIndex, int oldNameSize, int newNameIndex, int newNameSize); +int sqFileSetPosition(SQFile *f, squeakFileOffsetType position); +squeakFileOffsetType sqFileSize(SQFile *f); +int sqFileValid(SQFile *f); +size_t sqFileWriteFromAt(SQFile *f, size_t count, int byteArrayIndex, size_t startIndex); +int sqFileFlush(SQFile *f); +int sqFileTruncate(SQFile *f,squeakFileOffsetType offset); +int sqFileThisSession(void); + +/* directories */ +int dir_Create(char *pathString, int pathStringLength); +int dir_Delete(char *pathString, int pathStringLength); +int dir_Delimitor(void); +int dir_Lookup(char *pathString, int pathStringLength, int index, + /* outputs: */ + char *name, int *nameLength, int *creationDate, int *modificationDate, + int *isDirectory, squeakFileOffsetType *sizeIfFile); +int dir_PathToWorkingDir(char *pathName, int pathNameMax); +int dir_SetMacFileTypeAndCreator(char *filename, int filenameSize, char *fType, char *fCreator); +int dir_GetMacFileTypeAndCreator(char *filename, int filenameSize, char *fType, char *fCreator); diff --git a/squeak/FloatArrayPlugin.c b/squeak/FloatArrayPlugin.c new file mode 100644 index 0000000..78bd4fe --- /dev/null +++ b/squeak/FloatArrayPlugin.c @@ -0,0 +1,536 @@ +/* Automatically generated from Squeak on #(4 March 2003 4:22:52 am) */ + +#include +#include +#include +#include +#include + +/* Default EXPORT macro that does nothing (see comment in sq.h): */ +#define EXPORT(returnType) returnType + +/* Do not include the entire sq.h file but just those parts needed. */ +/* The virtual machine proxy definition */ +#include "sqVirtualMachine.h" +/* Configuration options */ +#include "sqConfig.h" +/* Platform specific definitions */ +#include "sqPlatformSpecific.h" + +#define true 1 +#define false 0 +#define null 0 /* using 'null' because nil is predefined in Think C */ +#ifdef SQUEAK_BUILTIN_PLUGIN +#undef EXPORT +// was #undef EXPORT(returnType) but screws NorCroft cc +#define EXPORT(returnType) static returnType +#endif + +/* memory access macros */ +#define byteAt(i) (*((unsigned char *) (i))) +#define byteAtput(i, val) (*((unsigned char *) (i)) = val) +#define longAt(i) (*((int *) (i))) +#define longAtput(i, val) (*((int *) (i)) = val) + + +/*** Variables ***/ + +#ifdef SQUEAK_BUILTIN_PLUGIN +extern +#endif +struct VirtualMachine* interpreterProxy; +static const char *moduleName = +#ifdef SQUEAK_BUILTIN_PLUGIN + "FloatArrayPlugin 4 March 2003 (i)" +#else + "FloatArrayPlugin 4 March 2003 (e)" +#endif +; + +/*** Function Prototypes ***/ +#pragma export on +EXPORT(const char*) getModuleName(void); +#pragma export off +static int halt(void); +static int msg(char *s); +#pragma export on +EXPORT(int) primitiveAddFloatArray(void); +EXPORT(int) primitiveAddScalar(void); +EXPORT(int) primitiveAt(void); +EXPORT(int) primitiveAtPut(void); +EXPORT(int) primitiveDivFloatArray(void); +EXPORT(int) primitiveDivScalar(void); +EXPORT(int) primitiveDotProduct(void); +EXPORT(int) primitiveEqual(void); +EXPORT(int) primitiveHashArray(void); +EXPORT(int) primitiveMulFloatArray(void); +EXPORT(int) primitiveMulScalar(void); +EXPORT(int) primitiveSubFloatArray(void); +EXPORT(int) primitiveSubScalar(void); +EXPORT(int) setInterpreter(struct VirtualMachine* anInterpreter); +#pragma export off + + +/* Note: This is hardcoded so it can be run from Squeak. + The module name is used for validating a module *after* + it is loaded to check if it does really contain the module + we're thinking it contains. This is important! */ + +EXPORT(const char*) getModuleName(void) { + return moduleName; +} + +static int halt(void) { + ; +} + +static int msg(char *s) { + fprintf(stderr, "\n%s: %s", moduleName, s); +} + + +/* Primitive. Add the receiver and the argument, both FloatArrays and store the result into the receiver. */ + +EXPORT(int) primitiveAddFloatArray(void) { + int i; + int length; + int rcvr; + float *rcvrPtr; + float *argPtr; + int arg; + + arg = interpreterProxy->stackObjectValue(0); + rcvr = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->success(interpreterProxy->isWords(arg)); + interpreterProxy->success(interpreterProxy->isWords(rcvr)); + if (interpreterProxy->failed()) { + return null; + } + length = interpreterProxy->stSizeOf(arg); + interpreterProxy->success(length == (interpreterProxy->stSizeOf(rcvr))); + if (interpreterProxy->failed()) { + return null; + } + rcvrPtr = ((float *) (interpreterProxy->firstIndexableField(rcvr))); + argPtr = ((float *) (interpreterProxy->firstIndexableField(arg))); + for (i = 0; i <= (length - 1); i += 1) { + rcvrPtr[i] = ((rcvrPtr[i]) + (argPtr[i])); + } + interpreterProxy->pop(1); +} + + +/* Primitive. Add the argument, a scalar value to the receiver, a FloatArray */ + +EXPORT(int) primitiveAddScalar(void) { + int i; + int length; + int rcvr; + double value; + float *rcvrPtr; + + value = interpreterProxy->stackFloatValue(0); + rcvr = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->success(interpreterProxy->isWords(rcvr)); + if (interpreterProxy->failed()) { + return null; + } + length = interpreterProxy->stSizeOf(rcvr); + rcvrPtr = ((float *) (interpreterProxy->firstIndexableField(rcvr))); + for (i = 0; i <= (length - 1); i += 1) { + rcvrPtr[i] = ((rcvrPtr[i]) + value); + } + interpreterProxy->pop(1); +} + +EXPORT(int) primitiveAt(void) { + int rcvr; + int index; + double floatValue; + float *floatPtr; + + index = interpreterProxy->stackIntegerValue(0); + rcvr = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->success(interpreterProxy->isWords(rcvr)); + interpreterProxy->success((index > 0) && (index <= (interpreterProxy->slotSizeOf(rcvr)))); + if (interpreterProxy->failed()) { + return null; + } + floatPtr = interpreterProxy->firstIndexableField(rcvr); + floatValue = ((double) (floatPtr[index - 1]) ); + interpreterProxy->pop(2); + interpreterProxy->pushFloat(floatValue); +} + +EXPORT(int) primitiveAtPut(void) { + int value; + int rcvr; + int index; + double floatValue; + float *floatPtr; + + value = interpreterProxy->stackValue(0); + if ((value & 1)) { + floatValue = ((double) ((value >> 1)) ); + } else { + floatValue = interpreterProxy->floatValueOf(value); + } + index = interpreterProxy->stackIntegerValue(1); + rcvr = interpreterProxy->stackObjectValue(2); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->success(interpreterProxy->isWords(rcvr)); + interpreterProxy->success((index > 0) && (index <= (interpreterProxy->slotSizeOf(rcvr)))); + if (interpreterProxy->failed()) { + return null; + } + floatPtr = interpreterProxy->firstIndexableField(rcvr); + floatPtr[index - 1] = (((float) floatValue)); + if (!(interpreterProxy->failed())) { + interpreterProxy->popthenPush(3, value); + } +} + + +/* Primitive. Add the receiver and the argument, both FloatArrays and store the result into the receiver. */ + +EXPORT(int) primitiveDivFloatArray(void) { + int i; + int length; + int rcvr; + float *rcvrPtr; + float *argPtr; + int arg; + + arg = interpreterProxy->stackObjectValue(0); + rcvr = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->success(interpreterProxy->isWords(arg)); + interpreterProxy->success(interpreterProxy->isWords(rcvr)); + if (interpreterProxy->failed()) { + return null; + } + length = interpreterProxy->stSizeOf(arg); + interpreterProxy->success(length == (interpreterProxy->stSizeOf(rcvr))); + if (interpreterProxy->failed()) { + return null; + } + rcvrPtr = ((float *) (interpreterProxy->firstIndexableField(rcvr))); + + /* Check if any of the argument's values is zero */ + + argPtr = ((float *) (interpreterProxy->firstIndexableField(arg))); + for (i = 0; i <= (length - 1); i += 1) { + if ((longAt(argPtr + i)) == 0) { + return interpreterProxy->primitiveFail(); + } + } + for (i = 0; i <= (length - 1); i += 1) { + rcvrPtr[i] = ((rcvrPtr[i]) / (argPtr[i])); + } + interpreterProxy->pop(1); +} + + +/* Primitive. Add the argument, a scalar value to the receiver, a FloatArray */ + +EXPORT(int) primitiveDivScalar(void) { + int i; + int length; + int rcvr; + double value; + float *rcvrPtr; + double inverse; + + value = interpreterProxy->stackFloatValue(0); + rcvr = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + if (value == 0.0) { + return interpreterProxy->primitiveFail(); + } + interpreterProxy->success(interpreterProxy->isWords(rcvr)); + if (interpreterProxy->failed()) { + return null; + } + length = interpreterProxy->stSizeOf(rcvr); + rcvrPtr = ((float *) (interpreterProxy->firstIndexableField(rcvr))); + inverse = 1.0 / value; + for (i = 0; i <= (length - 1); i += 1) { + rcvrPtr[i] = ((rcvrPtr[i]) * inverse); + } + interpreterProxy->pop(1); +} + + +/* Primitive. Compute the dot product of the receiver and the argument. + The dot product is defined as the sum of the products of the individual elements. */ + +EXPORT(int) primitiveDotProduct(void) { + int i; + int length; + int rcvr; + float *rcvrPtr; + float *argPtr; + double result; + int arg; + + arg = interpreterProxy->stackObjectValue(0); + rcvr = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->success(interpreterProxy->isWords(arg)); + interpreterProxy->success(interpreterProxy->isWords(rcvr)); + if (interpreterProxy->failed()) { + return null; + } + length = interpreterProxy->stSizeOf(arg); + interpreterProxy->success(length == (interpreterProxy->stSizeOf(rcvr))); + if (interpreterProxy->failed()) { + return null; + } + rcvrPtr = ((float *) (interpreterProxy->firstIndexableField(rcvr))); + argPtr = ((float *) (interpreterProxy->firstIndexableField(arg))); + result = 0.0; + for (i = 0; i <= (length - 1); i += 1) { + result += (rcvrPtr[i]) * (argPtr[i]); + } + interpreterProxy->pop(2); + interpreterProxy->pushFloat(result); +} + +EXPORT(int) primitiveEqual(void) { + int i; + int length; + int rcvr; + float *rcvrPtr; + float *argPtr; + int arg; + + arg = interpreterProxy->stackObjectValue(0); + rcvr = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->success(interpreterProxy->isWords(arg)); + interpreterProxy->success(interpreterProxy->isWords(rcvr)); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->pop(2); + length = interpreterProxy->stSizeOf(arg); + if (!(length == (interpreterProxy->stSizeOf(rcvr)))) { + return interpreterProxy->pushBool(0); + } + rcvrPtr = ((float *) (interpreterProxy->firstIndexableField(rcvr))); + argPtr = ((float *) (interpreterProxy->firstIndexableField(arg))); + for (i = 0; i <= (length - 1); i += 1) { + if (!((rcvrPtr[i]) == (argPtr[i]))) { + return interpreterProxy->pushBool(0); + } + } + return interpreterProxy->pushBool(1); +} + +EXPORT(int) primitiveHashArray(void) { + int i; + int length; + int rcvr; + int *rcvrPtr; + int result; + + rcvr = interpreterProxy->stackObjectValue(0); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->success(interpreterProxy->isWords(rcvr)); + if (interpreterProxy->failed()) { + return null; + } + length = interpreterProxy->stSizeOf(rcvr); + rcvrPtr = ((int *) (interpreterProxy->firstIndexableField(rcvr))); + result = 0; + for (i = 0; i <= (length - 1); i += 1) { + result += rcvrPtr[i]; + } + interpreterProxy->pop(1); + return interpreterProxy->pushInteger(result & 536870911); +} + + +/* Primitive. Add the receiver and the argument, both FloatArrays and store the result into the receiver. */ + +EXPORT(int) primitiveMulFloatArray(void) { + int i; + int length; + int rcvr; + float *rcvrPtr; + float *argPtr; + int arg; + + arg = interpreterProxy->stackObjectValue(0); + rcvr = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->success(interpreterProxy->isWords(arg)); + interpreterProxy->success(interpreterProxy->isWords(rcvr)); + if (interpreterProxy->failed()) { + return null; + } + length = interpreterProxy->stSizeOf(arg); + interpreterProxy->success(length == (interpreterProxy->stSizeOf(rcvr))); + if (interpreterProxy->failed()) { + return null; + } + rcvrPtr = ((float *) (interpreterProxy->firstIndexableField(rcvr))); + argPtr = ((float *) (interpreterProxy->firstIndexableField(arg))); + for (i = 0; i <= (length - 1); i += 1) { + rcvrPtr[i] = ((rcvrPtr[i]) * (argPtr[i])); + } + interpreterProxy->pop(1); +} + + +/* Primitive. Add the argument, a scalar value to the receiver, a FloatArray */ + +EXPORT(int) primitiveMulScalar(void) { + int i; + int length; + int rcvr; + double value; + float *rcvrPtr; + + value = interpreterProxy->stackFloatValue(0); + rcvr = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->success(interpreterProxy->isWords(rcvr)); + if (interpreterProxy->failed()) { + return null; + } + length = interpreterProxy->stSizeOf(rcvr); + rcvrPtr = ((float *) (interpreterProxy->firstIndexableField(rcvr))); + for (i = 0; i <= (length - 1); i += 1) { + rcvrPtr[i] = ((rcvrPtr[i]) * value); + } + interpreterProxy->pop(1); +} + + +/* Primitive. Add the receiver and the argument, both FloatArrays and store the result into the receiver. */ + +EXPORT(int) primitiveSubFloatArray(void) { + int i; + int length; + int rcvr; + float *rcvrPtr; + float *argPtr; + int arg; + + arg = interpreterProxy->stackObjectValue(0); + rcvr = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->success(interpreterProxy->isWords(arg)); + interpreterProxy->success(interpreterProxy->isWords(rcvr)); + if (interpreterProxy->failed()) { + return null; + } + length = interpreterProxy->stSizeOf(arg); + interpreterProxy->success(length == (interpreterProxy->stSizeOf(rcvr))); + if (interpreterProxy->failed()) { + return null; + } + rcvrPtr = ((float *) (interpreterProxy->firstIndexableField(rcvr))); + argPtr = ((float *) (interpreterProxy->firstIndexableField(arg))); + for (i = 0; i <= (length - 1); i += 1) { + rcvrPtr[i] = ((rcvrPtr[i]) - (argPtr[i])); + } + interpreterProxy->pop(1); +} + + +/* Primitive. Add the argument, a scalar value to the receiver, a FloatArray */ + +EXPORT(int) primitiveSubScalar(void) { + int i; + int length; + int rcvr; + double value; + float *rcvrPtr; + + value = interpreterProxy->stackFloatValue(0); + rcvr = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->success(interpreterProxy->isWords(rcvr)); + if (interpreterProxy->failed()) { + return null; + } + length = interpreterProxy->stSizeOf(rcvr); + rcvrPtr = ((float *) (interpreterProxy->firstIndexableField(rcvr))); + for (i = 0; i <= (length - 1); i += 1) { + rcvrPtr[i] = ((rcvrPtr[i]) - value); + } + interpreterProxy->pop(1); +} + + +/* Note: This is coded so that is can be run from Squeak. */ + +EXPORT(int) setInterpreter(struct VirtualMachine* anInterpreter) { + int ok; + + interpreterProxy = anInterpreter; + ok = interpreterProxy->majorVersion() == VM_PROXY_MAJOR; + if (ok == 0) { + return 0; + } + ok = interpreterProxy->minorVersion() >= VM_PROXY_MINOR; + return ok; +} + + +#ifdef SQUEAK_BUILTIN_PLUGIN + + +void* FloatArrayPlugin_exports[][3] = { + {"FloatArrayPlugin", "primitiveAtPut", (void*)primitiveAtPut}, + {"FloatArrayPlugin", "primitiveMulScalar", (void*)primitiveMulScalar}, + {"FloatArrayPlugin", "primitiveDivScalar", (void*)primitiveDivScalar}, + {"FloatArrayPlugin", "primitiveDotProduct", (void*)primitiveDotProduct}, + {"FloatArrayPlugin", "primitiveAddScalar", (void*)primitiveAddScalar}, + {"FloatArrayPlugin", "primitiveEqual", (void*)primitiveEqual}, + {"FloatArrayPlugin", "primitiveSubScalar", (void*)primitiveSubScalar}, + {"FloatArrayPlugin", "primitiveDivFloatArray", (void*)primitiveDivFloatArray}, + {"FloatArrayPlugin", "primitiveMulFloatArray", (void*)primitiveMulFloatArray}, + {"FloatArrayPlugin", "primitiveAddFloatArray", (void*)primitiveAddFloatArray}, + {"FloatArrayPlugin", "primitiveSubFloatArray", (void*)primitiveSubFloatArray}, + {"FloatArrayPlugin", "primitiveAt", (void*)primitiveAt}, + {"FloatArrayPlugin", "getModuleName", (void*)getModuleName}, + {"FloatArrayPlugin", "primitiveHashArray", (void*)primitiveHashArray}, + {"FloatArrayPlugin", "setInterpreter", (void*)setInterpreter}, + {NULL, NULL, NULL} +}; + + +#endif /* ifdef SQ_BUILTIN_PLUGIN */ + diff --git a/squeak/IntegerPokerPlugin.c b/squeak/IntegerPokerPlugin.c new file mode 100644 index 0000000..c77dc64 --- /dev/null +++ b/squeak/IntegerPokerPlugin.c @@ -0,0 +1,236 @@ +/* Automatically generated from Squeak on #(4 March 2003 4:22:52 am) */ + +#include +#include +#include +#include +#include + +/* Default EXPORT macro that does nothing (see comment in sq.h): */ +#define EXPORT(returnType) returnType + +/* Do not include the entire sq.h file but just those parts needed. */ +/* The virtual machine proxy definition */ +#include "sqVirtualMachine.h" +/* Configuration options */ +#include "sqConfig.h" +/* Platform specific definitions */ +#include "sqPlatformSpecific.h" + +#define true 1 +#define false 0 +#define null 0 /* using 'null' because nil is predefined in Think C */ +#ifdef SQUEAK_BUILTIN_PLUGIN +#undef EXPORT +// was #undef EXPORT(returnType) but screws NorCroft cc +#define EXPORT(returnType) static returnType +#endif + +/* memory access macros */ +#define byteAt(i) (*((unsigned char *) (i))) +#define byteAtput(i, val) (*((unsigned char *) (i)) = val) +#define longAt(i) (*((int *) (i))) +#define longAtput(i, val) (*((int *) (i)) = val) + + +/*** Variables ***/ + +#ifdef SQUEAK_BUILTIN_PLUGIN +extern +#endif +struct VirtualMachine* interpreterProxy; +static const char *moduleName = +#ifdef SQUEAK_BUILTIN_PLUGIN + "IntegerPokerPlugin 4 March 2003 (i)" +#else + "IntegerPokerPlugin 4 March 2003 (e)" +#endif +; + +/*** Function Prototypes ***/ +static int asCharacter(int anInteger); +static int asInteger(int aChar); +static int cutOffForPositives(void); +#pragma export on +EXPORT(int) getInteger(void); +EXPORT(const char*) getModuleName(void); +#pragma export off +static int halt(void); +static int msg(char *s); +static int negated(int anInteger); +#pragma export on +EXPORT(int) putInteger(void); +EXPORT(int) setInterpreter(struct VirtualMachine* anInterpreter); +#pragma export off + +static int asCharacter(int anInteger) { + return anInteger; +} + +static int asInteger(int aChar) { + return aChar; +} + + +/* return the largest positive integer that we can encode */ + +static int cutOffForPositives(void) { + return 1 << 30; +} + +EXPORT(int) getInteger(void) { + int integer; + int stringOop; + unsigned char *stringData; + int locationOop; + int location; + + stringOop = interpreterProxy->stackValue(1); + if (!(interpreterProxy->isBytes(stringOop))) { + interpreterProxy->success(0); + return null; + } + + /* decode the location */ + + stringData = interpreterProxy->arrayValueOf(stringOop); + locationOop = interpreterProxy->stackValue(0); + if (!(interpreterProxy->isIntegerValue(locationOop))) { + interpreterProxy->success(0); + return null; + } + location = (locationOop >> 1); + location -= 1; + if (location < 0) { + interpreterProxy->success(0); + return null; + } + if ((location + 4) > (interpreterProxy->stSizeOf(stringOop))) { + interpreterProxy->success(0); + return null; + } + integer = (((int) (stringData[location]) )) << 24; + integer = ((((int) (stringData[location + 1]) )) << 16) + integer; + integer = ((((int) (stringData[location + 2]) )) << 8) + integer; + + /* convert it to a negative number, if it's too large */ + + integer = (((int) (stringData[location + 3]) )) + integer; + if (integer > (1 << 30)) { + integer = (1 << 30) - integer; + } + interpreterProxy->pop(2); + interpreterProxy->pushInteger(integer); +} + + +/* Note: This is hardcoded so it can be run from Squeak. + The module name is used for validating a module *after* + it is loaded to check if it does really contain the module + we're thinking it contains. This is important! */ + +EXPORT(const char*) getModuleName(void) { + return moduleName; +} + +static int halt(void) { + ; +} + +static int msg(char *s) { + fprintf(stderr, "\n%s: %s", moduleName, s); +} + +static int negated(int anInteger) { + return -1 * anInteger; +} + +EXPORT(int) putInteger(void) { + int integer; + int stringOop; + unsigned char *stringData; + int locationOop; + int location; + int integerOop; + + stringOop = interpreterProxy->stackValue(2); + if (!(interpreterProxy->isBytes(stringOop))) { + interpreterProxy->success(0); + return null; + } + + /* decode the integer to be stored */ + + stringData = interpreterProxy->arrayValueOf(stringOop); + integerOop = interpreterProxy->stackValue(1); + if (!(interpreterProxy->isIntegerValue(integerOop))) { + interpreterProxy->success(0); + return null; + } + + /* decode the location */ + + integer = (integerOop >> 1); + locationOop = interpreterProxy->stackValue(0); + if (!(interpreterProxy->isIntegerValue(locationOop))) { + interpreterProxy->success(0); + return null; + } + location = (locationOop >> 1); + location -= 1; + if (location < 0) { + interpreterProxy->success(0); + return null; + } + if ((location + 4) > (interpreterProxy->stSizeOf(stringOop))) { + interpreterProxy->success(0); + return null; + } + if (integer > (1 << 30)) { + interpreterProxy->success(0); + return null; + } + if (integer < (negated(1 << 30))) { + interpreterProxy->success(0); + return null; + } + if (integer < 0) { + integer = (1 << 30) - integer; + } + stringData[location + 3] = (asCharacter(integer % 256)); + stringData[location + 2] = (asCharacter((((unsigned) integer) >> 8) % 256)); + stringData[location + 1] = (asCharacter((((unsigned) integer) >> 16) % 256)); + stringData[location + 0] = (asCharacter((((unsigned) integer) >> 24) % 256)); + interpreterProxy->pop(2); +} + + +/* Note: This is coded so that is can be run from Squeak. */ + +EXPORT(int) setInterpreter(struct VirtualMachine* anInterpreter) { + int ok; + + interpreterProxy = anInterpreter; + ok = interpreterProxy->majorVersion() == VM_PROXY_MAJOR; + if (ok == 0) { + return 0; + } + ok = interpreterProxy->minorVersion() >= VM_PROXY_MINOR; + return ok; +} + + +#ifdef SQUEAK_BUILTIN_PLUGIN + + +void* IntegerPokerPlugin_exports[][3] = { + {"IntegerPokerPlugin", "getInteger", (void*)getInteger}, + {"IntegerPokerPlugin", "getModuleName", (void*)getModuleName}, + {"IntegerPokerPlugin", "putInteger", (void*)putInteger}, + {"IntegerPokerPlugin", "setInterpreter", (void*)setInterpreter}, + {NULL, NULL, NULL} +}; + + +#endif /* ifdef SQ_BUILTIN_PLUGIN */ + diff --git a/squeak/LargeIntegers.c b/squeak/LargeIntegers.c new file mode 100644 index 0000000..aab2667 --- /dev/null +++ b/squeak/LargeIntegers.c @@ -0,0 +1,2211 @@ +/* Automatically generated from Squeak on #(4 March 2003 4:22:56 am) */ + +#include +#include +#include +#include +#include + +/* Default EXPORT macro that does nothing (see comment in sq.h): */ +#define EXPORT(returnType) returnType + +/* Do not include the entire sq.h file but just those parts needed. */ +/* The virtual machine proxy definition */ +#include "sqVirtualMachine.h" +/* Configuration options */ +#include "sqConfig.h" +/* Platform specific definitions */ +#include "sqPlatformSpecific.h" + +#define true 1 +#define false 0 +#define null 0 /* using 'null' because nil is predefined in Think C */ +#ifdef SQUEAK_BUILTIN_PLUGIN +#undef EXPORT +// was #undef EXPORT(returnType) but screws NorCroft cc +#define EXPORT(returnType) static returnType +#endif + +/* memory access macros */ +#define byteAt(i) (*((unsigned char *) (i))) +#define byteAtput(i, val) (*((unsigned char *) (i)) = val) +#define longAt(i) (*((int *) (i))) +#define longAtput(i, val) (*((int *) (i)) = val) + + +/*** Variables ***/ +static const int andOpIndex = 0; + +#ifdef SQUEAK_BUILTIN_PLUGIN +extern +#endif +struct VirtualMachine* interpreterProxy; +static const char *moduleName = +#ifdef SQUEAK_BUILTIN_PLUGIN + "LargeIntegers v1.2 4 March 2003 (i)" +#else + "LargeIntegers v1.2 4 March 2003 (e)" +#endif +; +static const int orOpIndex = 1; +static const int xorOpIndex = 2; + +/*** Function Prototypes ***/ +#pragma export on +EXPORT(int) _primDigitBitShift(void); +#pragma export off +static int anyBitOfBytesfromto(int aBytesOop, int start, int stopArg); +static int byteSizeOfBytes(int bytesOop); +static int bytesLshift(int aBytesOop, int shiftCount); +static int bytesRshiftbyteslookfirst(int aBytesOop, int anInteger, int b, int a); +static int bytesgrowTo(int aBytesObject, int newLen); +static int bytesOrIntgrowTo(int oop, int len); +static int cByteOpshortlenlongleninto(int opIndex, unsigned char * pByteShort, int shortLen, unsigned char * pByteLong, int longLen, unsigned char * pByteRes); +static int cBytesCopyFromtolen(unsigned char * pFrom, unsigned char * pTo, int len); +static int cBytesHighBitlen(unsigned char * pByte, int len); +static int cBytesLshiftfromlentolen(int shiftCount, unsigned char * pFrom, int lenFrom, unsigned char * pTo, int lenTo); +static int cBytesReplacefromtowithstartingAt(unsigned char * pTo, int start, int stop, unsigned char * pFrom, int repStart); +static int cCopyIntValtoBytes(int val, int bytes); +static int cCoreBytesRshiftCountnmfbytesfromlentolen(int count, int n, int m, int f, int b, unsigned char * pFrom, int fromLen, unsigned char * pTo, int toLen); +static int cCoreDigitDivDivlenremlenquolen(unsigned char * pDiv, int divLen, unsigned char * pRem, int remLen, unsigned char * pQuo, int quoLen); +static unsigned char cDigitAddlenwithleninto(unsigned char * pByteShort, int shortLen, unsigned char * pByteLong, int longLen, unsigned char * pByteRes); +static int cDigitComparewithlen(unsigned char * pFirst, unsigned char * pSecond, int len); +static int cDigitLengthOfCSI(int csi); +static unsigned char cDigitMultiplylenwithleninto(unsigned char * pByteShort, int shortLen, unsigned char * pByteLong, int longLen, unsigned char * pByteRes); +static int cDigitOfCSIat(int csi, int ix); +static int cDigitSublenwithleninto(unsigned char * pByteSmall, int smallLen, unsigned char * pByteLarge, int largeLen, unsigned char * pByteRes); +static int cHighBit(int uint); +static int createLargeFromSmallInteger(int anOop); +static int digitAddLargewith(int firstInteger, int secondInteger); +static int digitBitLogicwithopIndex(int firstInteger, int secondInteger, int opIx); +static int digitCompareLargewith(int firstInteger, int secondInteger); +static int digitDivLargewithnegative(int firstInteger, int secondInteger, int neg); +static int digitLength(int oop); +static int digitMultiplyLargewithnegative(int firstInteger, int secondInteger, int neg); +static int digitOfat(int oop, int ix); +static int digitOfBytesat(int aBytesOop, int ix); +static int digitSubLargewith(int firstInteger, int secondInteger); +#pragma export on +EXPORT(const char*) getModuleName(void); +#pragma export off +static int halt(void); +static int highBitOfBytes(int aBytesOop); +static void initialize(void); +static int msg(char *s); +static int negative(int aLarge); +static int normalize(int aLargeInteger); +static int normalizeNegative(int aLargeNegativeInteger); +static int normalizePositive(int aLargePositiveInteger); +#pragma export on +EXPORT(int) primAnyBitFromTo(void); +EXPORT(int) primAsLargeInteger(void); +EXPORT(int) primCheckIfCModuleExists(void); +EXPORT(int) primDigitAdd(void); +EXPORT(int) primDigitAddWith(void); +EXPORT(int) primDigitBitAnd(void); +EXPORT(int) primDigitBitLogicWithOp(void); +EXPORT(int) primDigitBitOr(void); +EXPORT(int) primDigitBitShift(void); +EXPORT(int) primDigitBitShiftMagnitude(void); +EXPORT(int) primDigitBitXor(void); +EXPORT(int) primDigitCompare(void); +EXPORT(int) primDigitCompareWith(void); +EXPORT(int) primDigitDivNegative(void); +EXPORT(int) primDigitDivWithNegative(void); +EXPORT(int) primDigitMultiplyNegative(void); +EXPORT(int) primDigitMultiplyWithNegative(void); +EXPORT(int) primDigitSubtract(void); +EXPORT(int) primDigitSubtractWith(void); +EXPORT(int) primGetModuleName(void); +EXPORT(int) primNormalize(void); +EXPORT(int) primNormalizeNegative(void); +EXPORT(int) primNormalizePositive(void); +EXPORT(int) setInterpreter(struct VirtualMachine* anInterpreter); +#pragma export off +static int sqAssert(int aBool); +static int think(void); +static int unsafeByteOfat(int bytesOop, int ix); + +EXPORT(int) _primDigitBitShift(void) { + int rShift; + int aLarge; + int anInteger; + int shiftCount; + int _return_value; + int aLargeInteger; + + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(1), "Integer")); + anInteger = interpreterProxy->stackValue(1); + shiftCount = interpreterProxy->stackIntegerValue(0); + /* missing DebugCode */; + if (interpreterProxy->failed()) { + return null; + } + if ((anInteger & 1)) { + aLarge = createLargeFromSmallInteger(anInteger); + } else { + aLarge = anInteger; + } + if (shiftCount >= 0) { + _return_value = bytesLshift(aLarge, shiftCount); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(3, _return_value); + return null; + } else { + rShift = 0 - shiftCount; + /* begin normalize: */ + aLargeInteger = bytesRshiftbyteslookfirst(aLarge, rShift & 7, ((unsigned) rShift >> 3), interpreterProxy->slotSizeOf(aLarge)); + /* missing DebugCode */; + if ((interpreterProxy->fetchClassOf(aLargeInteger)) == (interpreterProxy->classLargePositiveInteger())) { + _return_value = normalizePositive(aLargeInteger); + goto l1; + } else { + _return_value = normalizeNegative(aLargeInteger); + goto l1; + } + l1: /* end normalize: */; + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(3, _return_value); + return null; + } +} + + +/* Argument has to be aBytesOop! */ +/* Tests for any magnitude bits in the interval from start to stopArg. */ + +static int anyBitOfBytesfromto(int aBytesOop, int start, int stopArg) { + int magnitude; + int lastByteIx; + int mask; + int stop; + int digit; + int ix; + int leftShift; + int firstByteIx; + int rightShift; + + /* missing DebugCode */; + if ((start < 1) || (stopArg < 1)) { + return interpreterProxy->primitiveFail(); + } + magnitude = aBytesOop; + stop = ((stopArg < (cBytesHighBitlen(interpreterProxy->firstIndexableField(magnitude), interpreterProxy->slotSizeOf(magnitude)))) ? stopArg : (cBytesHighBitlen(interpreterProxy->firstIndexableField(magnitude), interpreterProxy->slotSizeOf(magnitude)))); + if (start > stop) { + return 0; + } + firstByteIx = (((int) (start - 1) >> 3)) + 1; + lastByteIx = (((int) (stop - 1) >> 3)) + 1; + rightShift = 0 - ((start - 1) % 8); + leftShift = 7 - ((stop - 1) % 8); + if (firstByteIx == lastByteIx) { + mask = ((((0 - rightShift) < 0) ? ((unsigned) 255 >> -(0 - rightShift)) : ((unsigned) 255 << (0 - rightShift)))) & ((((0 - leftShift) < 0) ? ((unsigned) 255 >> -(0 - leftShift)) : ((unsigned) 255 << (0 - leftShift)))); + /* begin digitOfBytes:at: */ + if (firstByteIx > (interpreterProxy->slotSizeOf(magnitude))) { + digit = 0; + goto l1; + } else { + digit = ((interpreterProxy->stObjectat(magnitude, firstByteIx)) >> 1); + goto l1; + } + l1: /* end digitOfBytes:at: */; + return (digit & mask) != 0; + } + if ((((rightShift < 0) ? ((unsigned) (digitOfBytesat(magnitude, firstByteIx)) >> -rightShift) : ((unsigned) (digitOfBytesat(magnitude, firstByteIx)) << rightShift))) != 0) { + return 1; + } + for (ix = (firstByteIx + 1); ix <= (lastByteIx - 1); ix += 1) { + if ((digitOfBytesat(magnitude, ix)) != 0) { + return 1; + } + } + if (((((leftShift < 0) ? ((unsigned) (digitOfBytesat(magnitude, lastByteIx)) >> -leftShift) : ((unsigned) (digitOfBytesat(magnitude, lastByteIx)) << leftShift))) & 255) != 0) { + return 1; + } + return 0; +} + + +/* Precondition: bytesOop is not anInteger and a bytes object. */ +/* Function #byteSizeOf: is used by the interpreter, be careful with name + clashes... */ + +static int byteSizeOfBytes(int bytesOop) { + return interpreterProxy->slotSizeOf(bytesOop); +} + + +/* Attention: this method invalidates all oop's! Only newBytes is valid at + return. */ +/* Does not normalize. */ + +static int bytesLshift(int aBytesOop, int shiftCount) { + int newBytes; + int highBit; + int newLen; + int oldLen; + + oldLen = interpreterProxy->slotSizeOf(aBytesOop); + if ((highBit = cBytesHighBitlen(interpreterProxy->firstIndexableField(aBytesOop), oldLen)) == 0) { + return interpreterProxy->integerObjectOf(0); + } + newLen = ((int) ((highBit + shiftCount) + 7) >> 3); + interpreterProxy->pushRemappableOop(aBytesOop); + newBytes = interpreterProxy->instantiateClassindexableSize(interpreterProxy->fetchClassOf(aBytesOop), newLen); + aBytesOop = interpreterProxy->popRemappableOop(); + cBytesLshiftfromlentolen(shiftCount, interpreterProxy->firstIndexableField(aBytesOop), oldLen, interpreterProxy->firstIndexableField(newBytes), newLen); + return newBytes; +} + + +/* Attention: this method invalidates all oop's! Only newBytes is valid at + return. */ +/* Shift right 8*b+anInteger bits, 0<=n<8. + Discard all digits beyond a, and all zeroes at or below a. */ +/* Does not normalize. */ + +static int bytesRshiftbyteslookfirst(int aBytesOop, int anInteger, int b, int a) { + int m; + int newLen; + int n; + int f; + int x; + int digit; + int newBytes; + int i; + int oldLen; + + n = 0 - anInteger; + x = 0; + f = n + 8; + i = a; + m = (((0 - f) < 0) ? ((unsigned) 255 >> -(0 - f)) : ((unsigned) 255 << (0 - f))); + /* begin digitOfBytes:at: */ + if (i > (interpreterProxy->slotSizeOf(aBytesOop))) { + digit = 0; + goto l2; + } else { + digit = ((interpreterProxy->stObjectat(aBytesOop, i)) >> 1); + goto l2; + } +l2: /* end digitOfBytes:at: */; + while ((((((n < 0) ? ((unsigned) digit >> -n) : ((unsigned) digit << n))) | x) == 0) && (i != 1)) { + + /* Can't exceed 8 bits */ + + x = ((f < 0) ? ((unsigned) digit >> -f) : ((unsigned) digit << f)); + i -= 1; + /* begin digitOfBytes:at: */ + if (i > (interpreterProxy->slotSizeOf(aBytesOop))) { + digit = 0; + goto l1; + } else { + digit = ((interpreterProxy->stObjectat(aBytesOop, i)) >> 1); + goto l1; + } + l1: /* end digitOfBytes:at: */; + } + if (i <= b) { + return interpreterProxy->instantiateClassindexableSize(interpreterProxy->fetchClassOf(aBytesOop), 0); + } + oldLen = interpreterProxy->slotSizeOf(aBytesOop); + newLen = i - b; + interpreterProxy->pushRemappableOop(aBytesOop); + newBytes = interpreterProxy->instantiateClassindexableSize(interpreterProxy->fetchClassOf(aBytesOop), newLen); + aBytesOop = interpreterProxy->popRemappableOop(); + cCoreBytesRshiftCountnmfbytesfromlentolen(i, n, m, f, b, interpreterProxy->firstIndexableField(aBytesOop), oldLen, interpreterProxy->firstIndexableField(newBytes), newLen); + return newBytes; +} + + +/* Attention: this method invalidates all oop's! Only newBytes is valid at + return. */ +/* Does not normalize. */ + +static int bytesgrowTo(int aBytesObject, int newLen) { + int newBytes; + int oldLen; + int copyLen; + + interpreterProxy->pushRemappableOop(aBytesObject); + newBytes = interpreterProxy->instantiateClassindexableSize(interpreterProxy->fetchClassOf(aBytesObject), newLen); + aBytesObject = interpreterProxy->popRemappableOop(); + oldLen = interpreterProxy->slotSizeOf(aBytesObject); + if (oldLen < newLen) { + copyLen = oldLen; + } else { + copyLen = newLen; + } + cBytesCopyFromtolen(interpreterProxy->firstIndexableField(aBytesObject), interpreterProxy->firstIndexableField(newBytes), copyLen); + return newBytes; +} + + +/* Attention: this method invalidates all oop's! Only newBytes is valid at + return. */ + +static int bytesOrIntgrowTo(int oop, int len) { + int newBytes; + int class; + int val; + + if ((oop & 1)) { + val = (oop >> 1); + if (val < 0) { + class = interpreterProxy->classLargeNegativeInteger(); + } else { + class = interpreterProxy->classLargePositiveInteger(); + } + newBytes = interpreterProxy->instantiateClassindexableSize(class, len); + cCopyIntValtoBytes(val, newBytes); + } else { + newBytes = bytesgrowTo(oop, len); + } + return newBytes; +} + + +/* pByteRes len = longLen. */ + +static int cByteOpshortlenlongleninto(int opIndex, unsigned char * pByteShort, int shortLen, unsigned char * pByteLong, int longLen, unsigned char * pByteRes) { + int i; + int limit; + + limit = shortLen - 1; + if (opIndex == andOpIndex) { + for (i = 0; i <= limit; i += 1) { + pByteRes[i] = ((pByteShort[i]) & (pByteLong[i])); + } + limit = longLen - 1; + for (i = shortLen; i <= limit; i += 1) { + pByteRes[i] = 0; + } + return 0; + } + if (opIndex == orOpIndex) { + for (i = 0; i <= limit; i += 1) { + pByteRes[i] = ((pByteShort[i]) | (pByteLong[i])); + } + limit = longLen - 1; + for (i = shortLen; i <= limit; i += 1) { + pByteRes[i] = (pByteLong[i]); + } + return 0; + } + if (opIndex == xorOpIndex) { + for (i = 0; i <= limit; i += 1) { + pByteRes[i] = ((pByteShort[i]) ^ (pByteLong[i])); + } + limit = longLen - 1; + for (i = shortLen; i <= limit; i += 1) { + pByteRes[i] = (pByteLong[i]); + } + return 0; + } + return interpreterProxy->primitiveFail(); +} + + +/* */ + +static int cBytesCopyFromtolen(unsigned char * pFrom, unsigned char * pTo, int len) { + int limit; + int i; + + ; + limit = len - 1; + for (i = 0; i <= limit; i += 1) { + pTo[i] = (pFrom[i]); + } + return 0; +} + + +/* Answer the index (in bits) of the high order bit of the receiver, or zero if the + receiver is zero. This method is allowed (and needed) for + LargeNegativeIntegers as well, since Squeak's LargeIntegers are + sign/magnitude. */ + +static int cBytesHighBitlen(unsigned char * pByte, int len) { + int lastDigit; + int realLength; + + realLength = len; + while ((lastDigit = pByte[realLength - 1]) == 0) { + if ((realLength -= 1) == 0) { + return 0; + } + } + return (cHighBit(lastDigit)) + (8 * (realLength - 1)); +} + + +/* C indexed! */ + +static int cBytesLshiftfromlentolen(int shiftCount, unsigned char * pFrom, int lenFrom, unsigned char * pTo, int lenTo) { + int lastIx; + int bitShift; + int carry; + int rShift; + int mask; + int digit; + int i; + int byteShift; + int limit; + + byteShift = ((int) shiftCount >> 3); + bitShift = shiftCount % 8; + if (bitShift == 0) { + return cBytesReplacefromtowithstartingAt(pTo, byteShift, lenTo - 1, pFrom, 0); + } + carry = 0; + rShift = bitShift - 8; + mask = (((0 - bitShift) < 0) ? ((unsigned) 255 >> -(0 - bitShift)) : ((unsigned) 255 << (0 - bitShift))); + limit = byteShift - 1; + for (i = 0; i <= limit; i += 1) { + pTo[i] = 0; + } + limit = (lenTo - byteShift) - 2; + /* begin sqAssert: */ + /* missing DebugCode */; +l1: /* end sqAssert: */; + for (i = 0; i <= limit; i += 1) { + digit = pFrom[i]; + pTo[i + byteShift] = ((((bitShift < 0) ? ((unsigned) (digit & mask) >> -bitShift) : ((unsigned) (digit & mask) << bitShift))) | carry); + carry = ((rShift < 0) ? ((unsigned) digit >> -rShift) : ((unsigned) digit << rShift)); + } + lastIx = limit + 1; + if (lastIx > (lenFrom - 1)) { + digit = 0; + } else { + digit = pFrom[lastIx]; + } + pTo[lastIx + byteShift] = ((((bitShift < 0) ? ((unsigned) (digit & mask) >> -bitShift) : ((unsigned) (digit & mask) << bitShift))) | carry); + carry = ((rShift < 0) ? ((unsigned) digit >> -rShift) : ((unsigned) digit << rShift)); + /* begin sqAssert: */ + /* missing DebugCode */; +l2: /* end sqAssert: */; +} + + +/* C indexed! */ + +static int cBytesReplacefromtowithstartingAt(unsigned char * pTo, int start, int stop, unsigned char * pFrom, int repStart) { + return cBytesCopyFromtolen(pFrom + repStart, pTo + start, (stop - start) + 1); +} + +static int cCopyIntValtoBytes(int val, int bytes) { + int ix; + unsigned char * pByte; + + pByte = interpreterProxy->firstIndexableField(bytes); + for (ix = 1; ix <= (cDigitLengthOfCSI(val)); ix += 1) { + pByte[ix - 1] = (cDigitOfCSIat(val, ix)); + } +} + +static int cCoreBytesRshiftCountnmfbytesfromlentolen(int count, int n, int m, int f, int b, unsigned char * pFrom, int fromLen, unsigned char * pTo, int toLen) { + int x; + int digit; + int j; + + /* begin sqAssert: */ + /* missing DebugCode */; +l1: /* end sqAssert: */; + x = ((n < 0) ? ((unsigned) (pFrom[b]) >> -n) : ((unsigned) (pFrom[b]) << n)); + /* begin sqAssert: */ + /* missing DebugCode */; +l2: /* end sqAssert: */; + for (j = (b + 1); j <= (count - 1); j += 1) { + digit = pFrom[j]; + pTo[(j - b) - 1] = ((((f < 0) ? ((unsigned) (digit & m) >> -f) : ((unsigned) (digit & m) << f))) | x); + x = ((n < 0) ? ((unsigned) digit >> -n) : ((unsigned) digit << n)); + } + if (count == fromLen) { + digit = 0; + } else { + digit = pFrom[count]; + } + pTo[(count - b) - 1] = ((((f < 0) ? ((unsigned) (digit & m) >> -f) : ((unsigned) (digit & m) << f))) | x); +} + +static int cCoreDigitDivDivlenremlenquolen(unsigned char * pDiv, int divLen, unsigned char * pRem, int remLen, unsigned char * pQuo, int quoLen) { + int cond; + int i; + int j; + int mul; + int k; + int dh; + int ql; + int l; + int lo; + int dl; + int dnh; + int r3; + int q; + int a; + int r1r2; + int hi; + int t; + + + /* Last actual byte of data (ST ix) */ + + dl = divLen - 1; + ql = quoLen; + dh = pDiv[dl - 1]; + if (dl == 1) { + dnh = 0; + } else { + dnh = pDiv[dl - 2]; + } + for (k = 1; k <= ql; k += 1) { + + /* r1 _ rem digitAt: j. */ + + j = (remLen + 1) - k; + if ((pRem[j - 1]) == dh) { + q = 255; + } else { + r1r2 = (((unsigned) (pRem[j - 1]) << 8)) + (pRem[j - 2]); + t = r1r2 % dh; + + /* Next compute (hi,lo) _ q*dnh */ + + q = r1r2 / dh; + mul = q * dnh; + hi = ((unsigned) mul >> 8); + + /* Correct overestimate of q. + Max of 2 iterations through loop -- see Knuth vol. 2 */ + + lo = mul & 255; + if (j < 3) { + r3 = 0; + } else { + r3 = pRem[j - 3]; + } + while (1) { + if ((t < hi) || ((t == hi) && (r3 < lo))) { + q -= 1; + lo -= dnh; + if (lo < 0) { + hi -= 1; + lo += 256; + } + cond = hi >= dh; + } else { + cond = 0; + } + if (!(cond)) break; + hi -= dh; + } + } + l = j - dl; + a = 0; + for (i = 1; i <= divLen; i += 1) { + hi = (pDiv[i - 1]) * (((unsigned) q >> 8)); + + /* pRem at: l - 1 put: lo - (lo // 256 * 256). */ + /* sign-tolerant form of (lo bitAnd: 255) -> obsolete... */ + + lo = (a + (pRem[l - 1])) - ((pDiv[i - 1]) * (q & 255)); + pRem[l - 1] = (lo & 255); + a = (((int) lo >> 8)) - hi; + l += 1; + } + if (a < 0) { + q -= 1; + l = j - dl; + a = 0; + for (i = 1; i <= divLen; i += 1) { + a = ((((unsigned) a >> 8)) + (pRem[l - 1])) + (pDiv[i - 1]); + pRem[l - 1] = (a & 255); + l += 1; + } + } + pQuo[quoLen - k] = q; + } +} + + +/* pByteRes len = longLen; returns over.. */ + +static unsigned char cDigitAddlenwithleninto(unsigned char * pByteShort, int shortLen, unsigned char * pByteLong, int longLen, unsigned char * pByteRes) { + int i; + int limit; + int accum; + + accum = 0; + limit = shortLen - 1; + for (i = 0; i <= limit; i += 1) { + accum = ((((unsigned) accum >> 8)) + (pByteShort[i])) + (pByteLong[i]); + pByteRes[i] = (accum & 255); + } + limit = longLen - 1; + for (i = shortLen; i <= limit; i += 1) { + accum = (((unsigned) accum >> 8)) + (pByteLong[i]); + pByteRes[i] = (accum & 255); + } + return ((unsigned) accum >> 8); +} + + +/* Precondition: pFirst len = pSecond len. */ + +static int cDigitComparewithlen(unsigned char * pFirst, unsigned char * pSecond, int len) { + int ix; + int secondDigit; + int firstDigit; + + ix = len - 1; + while (ix >= 0) { + if ((secondDigit = pSecond[ix]) != (firstDigit = pFirst[ix])) { + if (secondDigit < firstDigit) { + return 1; + } else { + return -1; + } + } + ix -= 1; + } + return 0; +} + + +/* Answer the number of indexable fields of a CSmallInteger. This value is + the same as the largest legal subscript. */ + +static int cDigitLengthOfCSI(int csi) { + if ((csi < 256) && (csi > -256)) { + return 1; + } + if ((csi < 65536) && (csi > -65536)) { + return 2; + } + if ((csi < 16777216) && (csi > -16777216)) { + return 3; + } + return 4; +} + + +/* pByteRes len = longLen * shortLen */ + +static unsigned char cDigitMultiplylenwithleninto(unsigned char * pByteShort, int shortLen, unsigned char * pByteLong, int longLen, unsigned char * pByteRes) { + int limitShort; + int carry; + int digit; + int i; + int ab; + int j; + int limitLong; + int k; + + if ((shortLen == 1) && ((pByteShort[0]) == 0)) { + return 0; + } + if ((longLen == 1) && ((pByteLong[0]) == 0)) { + return 0; + } + limitShort = shortLen - 1; + for (i = 0; i <= limitShort; i += 1) { + if ((digit = pByteShort[i]) != 0) { + k = i; + + /* Loop invariant: 0<=carry<=0377, k=i+j-1 (ST) */ + /* -> Loop invariant: 0<=carry<=0377, k=i+j (C) (?) */ + + carry = 0; + limitLong = longLen - 1; + for (j = 0; j <= limitLong; j += 1) { + ab = (((pByteLong[j]) * digit) + carry) + (pByteRes[k]); + carry = ((unsigned) ab >> 8); + pByteRes[k] = (ab & 255); + k += 1; + } + pByteRes[k] = carry; + } + } + return 0; +} + + +/* Answer the value of an indexable field in the receiver. + LargePositiveInteger uses bytes of base two number, and each is a + 'digit' base 256. */ +/* ST indexed! */ + +static int cDigitOfCSIat(int csi, int ix) { + if (ix < 0) { + interpreterProxy->primitiveFail(); + } + if (ix > 4) { + return 0; + } + if (csi < 0) { + ; + return (((((1 - ix) * 8) < 0) ? ((unsigned) (0 - csi) >> -((1 - ix) * 8)) : ((unsigned) (0 - csi) << ((1 - ix) * 8)))) & 255; + } else { + return (((((1 - ix) * 8) < 0) ? ((unsigned) csi >> -((1 - ix) * 8)) : ((unsigned) csi << ((1 - ix) * 8)))) & 255; + } +} + +static int cDigitSublenwithleninto(unsigned char * pByteSmall, int smallLen, unsigned char * pByteLarge, int largeLen, unsigned char * pByteRes) { + int z; + int i; + int limit; + + + /* Loop invariant is -1<=z<=1 */ + + z = 0; + limit = smallLen - 1; + for (i = 0; i <= limit; i += 1) { + z = (z + (pByteLarge[i])) - (pByteSmall[i]); + pByteRes[i] = (z - ((((int) z >> 8)) * 256)); + z = ((int) z >> 8); + } + limit = largeLen - 1; + for (i = smallLen; i <= limit; i += 1) { + z += pByteLarge[i]; + pByteRes[i] = (z - ((((int) z >> 8)) * 256)); + z = ((int) z >> 8); + } +} + + +/* Answer the index of the high order bit of the argument, or zero if the + argument is zero. */ + +static int cHighBit(int uint) { + unsigned int shifted; + int bitNo; + + shifted = uint; + bitNo = 0; + while (!(shifted < 16)) { + shifted = ((unsigned) shifted >> 4); + bitNo += 4; + } + while (!(shifted == 0)) { + shifted = ((unsigned) shifted >> 1); + bitNo += 1; + } + return bitNo; +} + + +/* anOop has to be a SmallInteger! */ + +static int createLargeFromSmallInteger(int anOop) { + int size; + int val; + int res; + unsigned char * pByte; + int class; + int ix; + + val = (anOop >> 1); + if (val < 0) { + class = interpreterProxy->classLargeNegativeInteger(); + } else { + class = interpreterProxy->classLargePositiveInteger(); + } + size = cDigitLengthOfCSI(val); + res = interpreterProxy->instantiateClassindexableSize(class, size); + pByte = interpreterProxy->firstIndexableField(res); + for (ix = 1; ix <= size; ix += 1) { + pByte[ix - 1] = (cDigitOfCSIat(val, ix)); + } + return res; +} + + +/* Does not need to normalize! */ + +static int digitAddLargewith(int firstInteger, int secondInteger) { + int shortInt; + int secondLen; + int longInt; + int resClass; + int firstLen; + unsigned char over; + int shortLen; + int longLen; + int newSum; + int sum; + + firstLen = interpreterProxy->slotSizeOf(firstInteger); + secondLen = interpreterProxy->slotSizeOf(secondInteger); + resClass = interpreterProxy->fetchClassOf(firstInteger); + if (firstLen <= secondLen) { + shortInt = firstInteger; + shortLen = firstLen; + longInt = secondInteger; + longLen = secondLen; + } else { + shortInt = secondInteger; + shortLen = secondLen; + longInt = firstInteger; + longLen = firstLen; + } + interpreterProxy->pushRemappableOop(shortInt); + interpreterProxy->pushRemappableOop(longInt); + sum = interpreterProxy->instantiateClassindexableSize(resClass, longLen); + longInt = interpreterProxy->popRemappableOop(); + shortInt = interpreterProxy->popRemappableOop(); + over = cDigitAddlenwithleninto(interpreterProxy->firstIndexableField(shortInt), shortLen, interpreterProxy->firstIndexableField(longInt), longLen, interpreterProxy->firstIndexableField(sum)); + if (over > 0) { + interpreterProxy->pushRemappableOop(sum); + newSum = interpreterProxy->instantiateClassindexableSize(resClass, longLen + 1); + sum = interpreterProxy->popRemappableOop(); + cBytesCopyFromtolen(interpreterProxy->firstIndexableField(sum), interpreterProxy->firstIndexableField(newSum), longLen); + + /* C index! */ + + sum = newSum; + (((unsigned char *) (interpreterProxy->firstIndexableField(sum))))[longLen] = over; + } + return sum; +} + + +/* Bit logic here is only implemented for positive integers or Zero; if rec + or arg is negative, it fails. */ + +static int digitBitLogicwithopIndex(int firstInteger, int secondInteger, int opIx) { + int firstLarge; + int shortLarge; + int secondLen; + int firstLen; + int secondLarge; + int result; + int shortLen; + int longLen; + int longLarge; + + if ((firstInteger & 1)) { + if (((firstInteger >> 1)) < 0) { + return interpreterProxy->primitiveFail(); + } + interpreterProxy->pushRemappableOop(secondInteger); + firstLarge = createLargeFromSmallInteger(firstInteger); + secondInteger = interpreterProxy->popRemappableOop(); + } else { + if ((interpreterProxy->fetchClassOf(firstInteger)) == (interpreterProxy->classLargeNegativeInteger())) { + return interpreterProxy->primitiveFail(); + } + firstLarge = firstInteger; + } + if ((secondInteger & 1)) { + if (((secondInteger >> 1)) < 0) { + return interpreterProxy->primitiveFail(); + } + interpreterProxy->pushRemappableOop(firstLarge); + secondLarge = createLargeFromSmallInteger(secondInteger); + firstLarge = interpreterProxy->popRemappableOop(); + } else { + if ((interpreterProxy->fetchClassOf(secondInteger)) == (interpreterProxy->classLargeNegativeInteger())) { + return interpreterProxy->primitiveFail(); + } + secondLarge = secondInteger; + } + firstLen = interpreterProxy->slotSizeOf(firstLarge); + secondLen = interpreterProxy->slotSizeOf(secondLarge); + if (firstLen < secondLen) { + shortLen = firstLen; + shortLarge = firstLarge; + longLen = secondLen; + longLarge = secondLarge; + } else { + shortLen = secondLen; + shortLarge = secondLarge; + longLen = firstLen; + longLarge = firstLarge; + } + interpreterProxy->pushRemappableOop(shortLarge); + interpreterProxy->pushRemappableOop(longLarge); + result = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classLargePositiveInteger(), longLen); + longLarge = interpreterProxy->popRemappableOop(); + shortLarge = interpreterProxy->popRemappableOop(); + cByteOpshortlenlongleninto(opIx, interpreterProxy->firstIndexableField(shortLarge), shortLen, interpreterProxy->firstIndexableField(longLarge), longLen, interpreterProxy->firstIndexableField(result)); + if (interpreterProxy->failed()) { + return 0; + } + return normalizePositive(result); +} + + +/* Compare the magnitude of firstInteger with that of secondInteger. + Return a code of 1, 0, -1 for firstInteger >, = , < secondInteger */ + +static int digitCompareLargewith(int firstInteger, int secondInteger) { + int secondLen; + int firstLen; + + firstLen = interpreterProxy->slotSizeOf(firstInteger); + secondLen = interpreterProxy->slotSizeOf(secondInteger); + if (secondLen != firstLen) { + if (secondLen > firstLen) { + return interpreterProxy->integerObjectOf(-1); + } else { + return interpreterProxy->integerObjectOf(1); + } + } + return interpreterProxy->integerObjectOf((cDigitComparewithlen(interpreterProxy->firstIndexableField(firstInteger), interpreterProxy->firstIndexableField(secondInteger), firstLen))); +} + + +/* Does not normalize. */ +/* Division by zero has to be checked in caller. */ + +static int digitDivLargewithnegative(int firstInteger, int secondInteger, int neg) { + int d; + int div; + int secondLen; + int firstLen; + int resultClass; + int quo; + int result; + int rem; + int l; + + firstLen = interpreterProxy->slotSizeOf(firstInteger); + secondLen = interpreterProxy->slotSizeOf(secondInteger); + if (neg) { + resultClass = interpreterProxy->classLargeNegativeInteger(); + } else { + resultClass = interpreterProxy->classLargePositiveInteger(); + } + l = (firstLen - secondLen) + 1; + if (l <= 0) { + interpreterProxy->pushRemappableOop(firstInteger); + result = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classArray(), 2); + firstInteger = interpreterProxy->popRemappableOop(); + interpreterProxy->stObjectatput(result,1,(interpreterProxy->integerObjectOf(0))); + interpreterProxy->stObjectatput(result,2,firstInteger); + return result; + } + d = 8 - (cHighBit(((interpreterProxy->stObjectat(secondInteger, secondLen)) >> 1))); + interpreterProxy->pushRemappableOop(firstInteger); + div = bytesLshift(secondInteger, d); + div = bytesOrIntgrowTo(div, (digitLength(div)) + 1); + firstInteger = interpreterProxy->popRemappableOop(); + interpreterProxy->pushRemappableOop(div); + rem = bytesLshift(firstInteger, d); + if ((digitLength(rem)) == firstLen) { + rem = bytesOrIntgrowTo(rem, firstLen + 1); + } + div = interpreterProxy->popRemappableOop(); + interpreterProxy->pushRemappableOop(div); + interpreterProxy->pushRemappableOop(rem); + quo = interpreterProxy->instantiateClassindexableSize(resultClass, l); + rem = interpreterProxy->popRemappableOop(); + div = interpreterProxy->popRemappableOop(); + cCoreDigitDivDivlenremlenquolen(interpreterProxy->firstIndexableField(div), digitLength(div), interpreterProxy->firstIndexableField(rem), digitLength(rem), interpreterProxy->firstIndexableField(quo), digitLength(quo)); + interpreterProxy->pushRemappableOop(quo); + rem = bytesRshiftbyteslookfirst(rem, d, 0, (digitLength(div)) - 1); + quo = interpreterProxy->popRemappableOop(); + interpreterProxy->pushRemappableOop(quo); + interpreterProxy->pushRemappableOop(rem); + result = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classArray(), 2); + rem = interpreterProxy->popRemappableOop(); + quo = interpreterProxy->popRemappableOop(); + interpreterProxy->stObjectatput(result,1,quo); + interpreterProxy->stObjectatput(result,2,rem); + return result; +} + +static int digitLength(int oop) { + if ((oop & 1)) { + return cDigitLengthOfCSI((oop >> 1)); + } else { + return interpreterProxy->slotSizeOf(oop); + } +} + + +/* Normalizes. */ + +static int digitMultiplyLargewithnegative(int firstInteger, int secondInteger, int neg) { + int shortInt; + int secondLen; + int longInt; + int prod; + int firstLen; + int resultClass; + int shortLen; + int longLen; + + firstLen = interpreterProxy->slotSizeOf(firstInteger); + secondLen = interpreterProxy->slotSizeOf(secondInteger); + if (firstLen <= secondLen) { + shortInt = firstInteger; + shortLen = firstLen; + longInt = secondInteger; + longLen = secondLen; + } else { + shortInt = secondInteger; + shortLen = secondLen; + longInt = firstInteger; + longLen = firstLen; + } + if (neg) { + resultClass = interpreterProxy->classLargeNegativeInteger(); + } else { + resultClass = interpreterProxy->classLargePositiveInteger(); + } + interpreterProxy->pushRemappableOop(shortInt); + interpreterProxy->pushRemappableOop(longInt); + prod = interpreterProxy->instantiateClassindexableSize(resultClass, longLen + shortLen); + longInt = interpreterProxy->popRemappableOop(); + shortInt = interpreterProxy->popRemappableOop(); + cDigitMultiplylenwithleninto(interpreterProxy->firstIndexableField(shortInt), shortLen, interpreterProxy->firstIndexableField(longInt), longLen, interpreterProxy->firstIndexableField(prod)); + /* begin normalize: */ + /* missing DebugCode */; + if ((interpreterProxy->fetchClassOf(prod)) == (interpreterProxy->classLargePositiveInteger())) { + return normalizePositive(prod); + } else { + return normalizeNegative(prod); + } + return null; +} + +static int digitOfat(int oop, int ix) { + if ((oop & 1)) { + return cDigitOfCSIat((oop >> 1), ix); + } else { + /* begin digitOfBytes:at: */ + if (ix > (interpreterProxy->slotSizeOf(oop))) { + return 0; + } else { + return ((interpreterProxy->stObjectat(oop, ix)) >> 1); + } + return null; + } +} + + +/* Argument has to be aLargeInteger! */ + +static int digitOfBytesat(int aBytesOop, int ix) { + if (ix > (interpreterProxy->slotSizeOf(aBytesOop))) { + return 0; + } else { + return ((interpreterProxy->stObjectat(aBytesOop, ix)) >> 1); + } +} + + +/* Normalizes. */ + +static int digitSubLargewith(int firstInteger, int secondInteger) { + int larger; + int secondLen; + int largerLen; + int neg; + int res; + int firstNeg; + int firstLen; + int class; + int smallerLen; + int resLen; + int smaller; + + firstNeg = (interpreterProxy->fetchClassOf(firstInteger)) == (interpreterProxy->classLargeNegativeInteger()); + firstLen = interpreterProxy->slotSizeOf(firstInteger); + secondLen = interpreterProxy->slotSizeOf(secondInteger); + if (firstLen == secondLen) { + while (((digitOfBytesat(firstInteger, firstLen)) == (digitOfBytesat(secondInteger, firstLen))) && (firstLen > 1)) { + firstLen -= 1; + } + secondLen = firstLen; + } + if ((firstLen < secondLen) || ((firstLen == secondLen) && ((digitOfBytesat(firstInteger, firstLen)) < (digitOfBytesat(secondInteger, firstLen))))) { + larger = secondInteger; + largerLen = secondLen; + smaller = firstInteger; + smallerLen = firstLen; + neg = firstNeg == 0; + } else { + larger = firstInteger; + largerLen = firstLen; + smaller = secondInteger; + smallerLen = secondLen; + neg = firstNeg; + } + resLen = largerLen; + if (neg) { + class = interpreterProxy->classLargeNegativeInteger(); + } else { + class = interpreterProxy->classLargePositiveInteger(); + } + interpreterProxy->pushRemappableOop(smaller); + interpreterProxy->pushRemappableOop(larger); + res = interpreterProxy->instantiateClassindexableSize(class, resLen); + larger = interpreterProxy->popRemappableOop(); + smaller = interpreterProxy->popRemappableOop(); + cDigitSublenwithleninto(interpreterProxy->firstIndexableField(smaller), smallerLen, interpreterProxy->firstIndexableField(larger), largerLen, interpreterProxy->firstIndexableField(res)); + /* begin normalize: */ + /* missing DebugCode */; + if ((interpreterProxy->fetchClassOf(res)) == (interpreterProxy->classLargePositiveInteger())) { + return normalizePositive(res); + } else { + return normalizeNegative(res); + } + return null; +} + + +/* Note: This is hardcoded so it can be run from Squeak. + The module name is used for validating a module *after* + it is loaded to check if it does really contain the module + we're thinking it contains. This is important! */ + +EXPORT(const char*) getModuleName(void) { + return moduleName; +} + +static int halt(void) { + ; +} + +static int highBitOfBytes(int aBytesOop) { + return cBytesHighBitlen(interpreterProxy->firstIndexableField(aBytesOop), interpreterProxy->slotSizeOf(aBytesOop)); +} + + +/* Initializes ST constants; C's are set by class>>declareCVarsIn:. */ + +static void initialize(void) { + "nothing to do here"; +} + +static int msg(char *s) { + fprintf(stderr, "\n%s: %s", moduleName, s); +} + +static int negative(int aLarge) { + return (interpreterProxy->fetchClassOf(aLarge)) == (interpreterProxy->classLargeNegativeInteger()); +} + + +/* Check for leading zeroes and return shortened copy if so. */ + +static int normalize(int aLargeInteger) { + /* missing DebugCode */; + if ((interpreterProxy->fetchClassOf(aLargeInteger)) == (interpreterProxy->classLargePositiveInteger())) { + return normalizePositive(aLargeInteger); + } else { + return normalizeNegative(aLargeInteger); + } +} + + +/* Check for leading zeroes and return shortened copy if so */ +/* First establish len = significant length */ + +static int normalizeNegative(int aLargeNegativeInteger) { + int val; + int len; + int i; + int minVal; + int oldLen; + int sLen; + + len = oldLen = digitLength(aLargeNegativeInteger); + while ((len != 0) && ((((interpreterProxy->stObjectat(aLargeNegativeInteger, len)) >> 1)) == 0)) { + len -= 1; + } + if (len == 0) { + return interpreterProxy->integerObjectOf(0); + } + + /* SmallInteger minVal digitLength */ + + sLen = 4; + if (len <= sLen) { + minVal = -1073741824; + if ((len < sLen) || ((digitOfBytesat(aLargeNegativeInteger, sLen)) < (cDigitOfCSIat(minVal, sLen)))) { + val = 0; + for (i = len; i >= 1; i += -1) { + val = (val * 256) - (((interpreterProxy->stObjectat(aLargeNegativeInteger, i)) >> 1)); + } + return interpreterProxy->integerObjectOf(val); + } + for (i = 1; i <= sLen; i += 1) { + if (!((digitOfBytesat(aLargeNegativeInteger, i)) == (cDigitOfCSIat(minVal, i)))) { + if (len < oldLen) { + return bytesgrowTo(aLargeNegativeInteger, len); + } else { + return aLargeNegativeInteger; + } + } + } + return interpreterProxy->integerObjectOf(minVal); + } + if (len < oldLen) { + return bytesgrowTo(aLargeNegativeInteger, len); + } else { + return aLargeNegativeInteger; + } +} + + +/* Check for leading zeroes and return shortened copy if so */ +/* First establish len = significant length */ + +static int normalizePositive(int aLargePositiveInteger) { + int val; + int i; + int len; + int oldLen; + int sLen; + + len = oldLen = digitLength(aLargePositiveInteger); + while ((len != 0) && ((((interpreterProxy->stObjectat(aLargePositiveInteger, len)) >> 1)) == 0)) { + len -= 1; + } + if (len == 0) { + return interpreterProxy->integerObjectOf(0); + } + + /* SmallInteger maxVal digitLength. */ + + sLen = 4; + if ((len <= sLen) && ((digitOfBytesat(aLargePositiveInteger, sLen)) <= (cDigitOfCSIat(1073741823, sLen)))) { + val = 0; + for (i = len; i >= 1; i += -1) { + val = (val * 256) + (((interpreterProxy->stObjectat(aLargePositiveInteger, i)) >> 1)); + } + return interpreterProxy->integerObjectOf(val); + } + if (len < oldLen) { + return bytesgrowTo(aLargePositiveInteger, len); + } else { + return aLargePositiveInteger; + } +} + +EXPORT(int) primAnyBitFromTo(void) { + int integer; + int large; + int from; + int to; + int _return_value; + + from = interpreterProxy->stackIntegerValue(1); + to = interpreterProxy->stackIntegerValue(0); + /* missing DebugCode */; + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(2), "Integer")); + integer = interpreterProxy->stackValue(2); + if (interpreterProxy->failed()) { + return null; + } + if ((integer & 1)) { + large = createLargeFromSmallInteger(integer); + } else { + large = integer; + } + _return_value = ((anyBitOfBytesfromto(large, from, to))? interpreterProxy->trueObject(): interpreterProxy->falseObject()); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(3, _return_value); + return null; +} + + +/* Converts a SmallInteger into a - non normalized! - LargeInteger; + aLargeInteger will be returned unchanged. */ +/* Do not check for forced fail, because we need this conversion to test the + plugin in ST during forced fail, too. */ + +EXPORT(int) primAsLargeInteger(void) { + int anInteger; + int _return_value; + + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(0), "Integer")); + anInteger = interpreterProxy->stackValue(0); + /* missing DebugCode */; + if (interpreterProxy->failed()) { + return null; + } + if ((anInteger & 1)) { + _return_value = createLargeFromSmallInteger(anInteger); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(2, _return_value); + return null; + } else { + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(2, anInteger); + return null; + } +} + + +/* If calling this primitive fails, then C module does not exist. Do not check for forced fail, because we want to know if module exists during forced fail, too. */ + +EXPORT(int) primCheckIfCModuleExists(void) { + int _return_value; + + _return_value = (1? interpreterProxy->trueObject(): interpreterProxy->falseObject()); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(1, _return_value); + return null; +} + + +/* */ + +EXPORT(int) primDigitAdd(void) { + int firstLarge; + int firstInteger; + int secondLarge; + int secondInteger; + int _return_value; + + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(0), "Integer")); + secondInteger = interpreterProxy->stackValue(0); + /* missing DebugCode */; + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(1), "Integer")); + firstInteger = interpreterProxy->stackValue(1); + if (interpreterProxy->failed()) { + return null; + } + if ((firstInteger & 1)) { + interpreterProxy->pushRemappableOop(secondInteger); + firstLarge = createLargeFromSmallInteger(firstInteger); + secondInteger = interpreterProxy->popRemappableOop(); + } else { + firstLarge = firstInteger; + } + if ((secondInteger & 1)) { + interpreterProxy->pushRemappableOop(firstLarge); + secondLarge = createLargeFromSmallInteger(secondInteger); + firstLarge = interpreterProxy->popRemappableOop(); + } else { + secondLarge = secondInteger; + } + _return_value = digitAddLargewith(firstLarge, secondLarge); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(2, _return_value); + return null; +} + + +/* */ + +EXPORT(int) primDigitAddWith(void) { + int firstLarge; + int secondLarge; + int firstInteger; + int secondInteger; + int _return_value; + + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(1), "Integer")); + firstInteger = interpreterProxy->stackValue(1); + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(0), "Integer")); + secondInteger = interpreterProxy->stackValue(0); + /* missing DebugCode */; + if (interpreterProxy->failed()) { + return null; + } + if ((firstInteger & 1)) { + interpreterProxy->pushRemappableOop(secondInteger); + firstLarge = createLargeFromSmallInteger(firstInteger); + secondInteger = interpreterProxy->popRemappableOop(); + } else { + firstLarge = firstInteger; + } + if ((secondInteger & 1)) { + interpreterProxy->pushRemappableOop(firstLarge); + secondLarge = createLargeFromSmallInteger(secondInteger); + firstLarge = interpreterProxy->popRemappableOop(); + } else { + secondLarge = secondInteger; + } + _return_value = digitAddLargewith(firstLarge, secondLarge); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(3, _return_value); + return null; +} + + +/* Bit logic here is only implemented for positive integers or Zero; if rec + or arg is negative, it fails. */ + +EXPORT(int) primDigitBitAnd(void) { + int firstInteger; + int secondInteger; + int _return_value; + + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(0), "Integer")); + secondInteger = interpreterProxy->stackValue(0); + /* missing DebugCode */; + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(1), "Integer")); + firstInteger = interpreterProxy->stackValue(1); + if (interpreterProxy->failed()) { + return null; + } + _return_value = digitBitLogicwithopIndex(firstInteger, secondInteger, andOpIndex); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(2, _return_value); + return null; +} + + +/* Bit logic here is only implemented for positive integers or Zero; if any arg is negative, it fails. */ + +EXPORT(int) primDigitBitLogicWithOp(void) { + int firstInteger; + int secondInteger; + int opIndex; + int _return_value; + + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(2), "Integer")); + firstInteger = interpreterProxy->stackValue(2); + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(1), "Integer")); + secondInteger = interpreterProxy->stackValue(1); + opIndex = interpreterProxy->stackIntegerValue(0); + /* missing DebugCode */; + if (interpreterProxy->failed()) { + return null; + } + _return_value = digitBitLogicwithopIndex(firstInteger, secondInteger, opIndex); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(4, _return_value); + return null; +} + + +/* Bit logic here is only implemented for positive integers or Zero; if rec + or arg is negative, it fails. */ + +EXPORT(int) primDigitBitOr(void) { + int firstInteger; + int secondInteger; + int _return_value; + + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(0), "Integer")); + secondInteger = interpreterProxy->stackValue(0); + /* missing DebugCode */; + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(1), "Integer")); + firstInteger = interpreterProxy->stackValue(1); + if (interpreterProxy->failed()) { + return null; + } + _return_value = digitBitLogicwithopIndex(firstInteger, secondInteger, orOpIndex); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(2, _return_value); + return null; +} + +EXPORT(int) primDigitBitShift(void) { + int rShift; + int anInteger; + int aLarge; + int shiftCount; + int _return_value; + int aLargeInteger; + + shiftCount = interpreterProxy->stackIntegerValue(0); + /* missing DebugCode */; + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(1), "Integer")); + anInteger = interpreterProxy->stackValue(1); + if (interpreterProxy->failed()) { + return null; + } + if ((anInteger & 1)) { + aLarge = createLargeFromSmallInteger(anInteger); + } else { + aLarge = anInteger; + } + if (shiftCount >= 0) { + _return_value = bytesLshift(aLarge, shiftCount); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(2, _return_value); + return null; + } else { + rShift = 0 - shiftCount; + /* begin normalize: */ + aLargeInteger = bytesRshiftbyteslookfirst(aLarge, rShift & 7, ((unsigned) rShift >> 3), interpreterProxy->slotSizeOf(aLarge)); + /* missing DebugCode */; + if ((interpreterProxy->fetchClassOf(aLargeInteger)) == (interpreterProxy->classLargePositiveInteger())) { + _return_value = normalizePositive(aLargeInteger); + goto l1; + } else { + _return_value = normalizeNegative(aLargeInteger); + goto l1; + } + l1: /* end normalize: */; + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(2, _return_value); + return null; + } +} + +EXPORT(int) primDigitBitShiftMagnitude(void) { + int rShift; + int anInteger; + int aLarge; + int shiftCount; + int _return_value; + int aLargeInteger; + + shiftCount = interpreterProxy->stackIntegerValue(0); + /* missing DebugCode */; + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(1), "Integer")); + anInteger = interpreterProxy->stackValue(1); + if (interpreterProxy->failed()) { + return null; + } + if ((anInteger & 1)) { + aLarge = createLargeFromSmallInteger(anInteger); + } else { + aLarge = anInteger; + } + if (shiftCount >= 0) { + _return_value = bytesLshift(aLarge, shiftCount); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(2, _return_value); + return null; + } else { + rShift = 0 - shiftCount; + /* begin normalize: */ + aLargeInteger = bytesRshiftbyteslookfirst(aLarge, rShift & 7, ((unsigned) rShift >> 3), interpreterProxy->slotSizeOf(aLarge)); + /* missing DebugCode */; + if ((interpreterProxy->fetchClassOf(aLargeInteger)) == (interpreterProxy->classLargePositiveInteger())) { + _return_value = normalizePositive(aLargeInteger); + goto l1; + } else { + _return_value = normalizeNegative(aLargeInteger); + goto l1; + } + l1: /* end normalize: */; + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(2, _return_value); + return null; + } +} + + +/* Bit logic here is only implemented for positive integers or Zero; if rec + or arg is negative, it fails. */ + +EXPORT(int) primDigitBitXor(void) { + int firstInteger; + int secondInteger; + int _return_value; + + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(0), "Integer")); + secondInteger = interpreterProxy->stackValue(0); + /* missing DebugCode */; + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(1), "Integer")); + firstInteger = interpreterProxy->stackValue(1); + if (interpreterProxy->failed()) { + return null; + } + _return_value = digitBitLogicwithopIndex(firstInteger, secondInteger, xorOpIndex); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(2, _return_value); + return null; +} + +EXPORT(int) primDigitCompare(void) { + int secondVal; + int firstVal; + int firstInteger; + int secondInteger; + int _return_value; + + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(0), "Integer")); + secondInteger = interpreterProxy->stackValue(0); + /* missing DebugCode */; + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(1), "Integer")); + firstInteger = interpreterProxy->stackValue(1); + if (interpreterProxy->failed()) { + return null; + } + if ((firstInteger & 1)) { + if ((secondInteger & 1)) { + if ((firstVal = (firstInteger >> 1)) > (secondVal = (secondInteger >> 1))) { + _return_value = interpreterProxy->integerObjectOf(1); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(2, _return_value); + return null; + } else { + if (firstVal < secondVal) { + _return_value = interpreterProxy->integerObjectOf(-1); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(2, _return_value); + return null; + } else { + _return_value = interpreterProxy->integerObjectOf(0); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(2, _return_value); + return null; + } + } + } else { + _return_value = interpreterProxy->integerObjectOf(-1); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(2, _return_value); + return null; + } + } else { + if ((secondInteger & 1)) { + _return_value = interpreterProxy->integerObjectOf(1); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(2, _return_value); + return null; + } else { + _return_value = digitCompareLargewith(firstInteger, secondInteger); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(2, _return_value); + return null; + } + } +} + +EXPORT(int) primDigitCompareWith(void) { + int secondVal; + int firstVal; + int firstInteger; + int secondInteger; + int _return_value; + + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(1), "Integer")); + firstInteger = interpreterProxy->stackValue(1); + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(0), "Integer")); + secondInteger = interpreterProxy->stackValue(0); + /* missing DebugCode */; + if (interpreterProxy->failed()) { + return null; + } + if ((firstInteger & 1)) { + if ((secondInteger & 1)) { + if ((firstVal = (firstInteger >> 1)) > (secondVal = (secondInteger >> 1))) { + _return_value = interpreterProxy->integerObjectOf(1); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(3, _return_value); + return null; + } else { + if (firstVal < secondVal) { + _return_value = interpreterProxy->integerObjectOf(-1); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(3, _return_value); + return null; + } else { + _return_value = interpreterProxy->integerObjectOf(0); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(3, _return_value); + return null; + } + } + } else { + _return_value = interpreterProxy->integerObjectOf(-1); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(3, _return_value); + return null; + } + } else { + if ((secondInteger & 1)) { + _return_value = interpreterProxy->integerObjectOf(1); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(3, _return_value); + return null; + } else { + _return_value = digitCompareLargewith(firstInteger, secondInteger); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(3, _return_value); + return null; + } + } +} + + +/* Answer the result of dividing firstInteger by secondInteger. Fail if + parameters are not integers or secondInteger is zero. */ + +EXPORT(int) primDigitDivNegative(void) { + int firstAsLargeInteger; + int firstInteger; + int secondAsLargeInteger; + int secondInteger; + int neg; + int _return_value; + + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(1), "Integer")); + secondInteger = interpreterProxy->stackValue(1); + neg = interpreterProxy->booleanValueOf(interpreterProxy->stackValue(0)); + /* missing DebugCode */; + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(2), "Integer")); + firstInteger = interpreterProxy->stackValue(2); + if (interpreterProxy->failed()) { + return null; + } + if ((firstInteger & 1)) { + interpreterProxy->pushRemappableOop(secondInteger); + firstAsLargeInteger = createLargeFromSmallInteger(firstInteger); + secondInteger = interpreterProxy->popRemappableOop(); + } else { + firstAsLargeInteger = firstInteger; + } + if ((secondInteger & 1)) { + if (((secondInteger >> 1)) == 0) { + interpreterProxy->primitiveFail(); + return null; + } + interpreterProxy->pushRemappableOop(firstAsLargeInteger); + secondAsLargeInteger = createLargeFromSmallInteger(secondInteger); + firstAsLargeInteger = interpreterProxy->popRemappableOop(); + } else { + secondAsLargeInteger = secondInteger; + } + _return_value = digitDivLargewithnegative(firstAsLargeInteger, secondAsLargeInteger, neg); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(3, _return_value); + return null; +} + + +/* Answer the result of dividing firstInteger by secondInteger. Fail if + parameters are not integers or secondInteger is zero. */ + +EXPORT(int) primDigitDivWithNegative(void) { + int firstAsLargeInteger; + int secondAsLargeInteger; + int firstInteger; + int secondInteger; + int neg; + int _return_value; + + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(2), "Integer")); + firstInteger = interpreterProxy->stackValue(2); + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(1), "Integer")); + secondInteger = interpreterProxy->stackValue(1); + neg = interpreterProxy->booleanValueOf(interpreterProxy->stackValue(0)); + /* missing DebugCode */; + if (interpreterProxy->failed()) { + return null; + } + if ((firstInteger & 1)) { + interpreterProxy->pushRemappableOop(secondInteger); + firstAsLargeInteger = createLargeFromSmallInteger(firstInteger); + secondInteger = interpreterProxy->popRemappableOop(); + } else { + firstAsLargeInteger = firstInteger; + } + if ((secondInteger & 1)) { + if (((secondInteger >> 1)) == 0) { + interpreterProxy->primitiveFail(); + return null; + } + interpreterProxy->pushRemappableOop(firstAsLargeInteger); + secondAsLargeInteger = createLargeFromSmallInteger(secondInteger); + firstAsLargeInteger = interpreterProxy->popRemappableOop(); + } else { + secondAsLargeInteger = secondInteger; + } + _return_value = digitDivLargewithnegative(firstAsLargeInteger, secondAsLargeInteger, neg); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(4, _return_value); + return null; +} + + +/* */ + +EXPORT(int) primDigitMultiplyNegative(void) { + int firstLarge; + int firstInteger; + int secondLarge; + int secondInteger; + int neg; + int _return_value; + + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(1), "Integer")); + secondInteger = interpreterProxy->stackValue(1); + neg = interpreterProxy->booleanValueOf(interpreterProxy->stackValue(0)); + /* missing DebugCode */; + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(2), "Integer")); + firstInteger = interpreterProxy->stackValue(2); + if (interpreterProxy->failed()) { + return null; + } + if ((firstInteger & 1)) { + interpreterProxy->pushRemappableOop(secondInteger); + firstLarge = createLargeFromSmallInteger(firstInteger); + secondInteger = interpreterProxy->popRemappableOop(); + } else { + firstLarge = firstInteger; + } + if ((secondInteger & 1)) { + interpreterProxy->pushRemappableOop(firstLarge); + secondLarge = createLargeFromSmallInteger(secondInteger); + firstLarge = interpreterProxy->popRemappableOop(); + } else { + secondLarge = secondInteger; + } + _return_value = digitMultiplyLargewithnegative(firstLarge, secondLarge, neg); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(3, _return_value); + return null; +} + + +/* */ + +EXPORT(int) primDigitMultiplyWithNegative(void) { + int firstLarge; + int secondLarge; + int firstInteger; + int secondInteger; + int neg; + int _return_value; + + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(2), "Integer")); + firstInteger = interpreterProxy->stackValue(2); + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(1), "Integer")); + secondInteger = interpreterProxy->stackValue(1); + neg = interpreterProxy->booleanValueOf(interpreterProxy->stackValue(0)); + /* missing DebugCode */; + if (interpreterProxy->failed()) { + return null; + } + if ((firstInteger & 1)) { + interpreterProxy->pushRemappableOop(secondInteger); + firstLarge = createLargeFromSmallInteger(firstInteger); + secondInteger = interpreterProxy->popRemappableOop(); + } else { + firstLarge = firstInteger; + } + if ((secondInteger & 1)) { + interpreterProxy->pushRemappableOop(firstLarge); + secondLarge = createLargeFromSmallInteger(secondInteger); + firstLarge = interpreterProxy->popRemappableOop(); + } else { + secondLarge = secondInteger; + } + _return_value = digitMultiplyLargewithnegative(firstLarge, secondLarge, neg); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(4, _return_value); + return null; +} + + +/* */ + +EXPORT(int) primDigitSubtract(void) { + int firstLarge; + int firstInteger; + int secondLarge; + int secondInteger; + int _return_value; + + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(0), "Integer")); + secondInteger = interpreterProxy->stackValue(0); + /* missing DebugCode */; + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(1), "Integer")); + firstInteger = interpreterProxy->stackValue(1); + if (interpreterProxy->failed()) { + return null; + } + if ((firstInteger & 1)) { + interpreterProxy->pushRemappableOop(secondInteger); + firstLarge = createLargeFromSmallInteger(firstInteger); + secondInteger = interpreterProxy->popRemappableOop(); + } else { + firstLarge = firstInteger; + } + if ((secondInteger & 1)) { + interpreterProxy->pushRemappableOop(firstLarge); + secondLarge = createLargeFromSmallInteger(secondInteger); + firstLarge = interpreterProxy->popRemappableOop(); + } else { + secondLarge = secondInteger; + } + _return_value = digitSubLargewith(firstLarge, secondLarge); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(2, _return_value); + return null; +} + + +/* */ + +EXPORT(int) primDigitSubtractWith(void) { + int firstLarge; + int secondLarge; + int firstInteger; + int secondInteger; + int _return_value; + + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(1), "Integer")); + firstInteger = interpreterProxy->stackValue(1); + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(0), "Integer")); + secondInteger = interpreterProxy->stackValue(0); + /* missing DebugCode */; + if (interpreterProxy->failed()) { + return null; + } + if ((firstInteger & 1)) { + interpreterProxy->pushRemappableOop(secondInteger); + firstLarge = createLargeFromSmallInteger(firstInteger); + secondInteger = interpreterProxy->popRemappableOop(); + } else { + firstLarge = firstInteger; + } + if ((secondInteger & 1)) { + interpreterProxy->pushRemappableOop(firstLarge); + secondLarge = createLargeFromSmallInteger(secondInteger); + firstLarge = interpreterProxy->popRemappableOop(); + } else { + secondLarge = secondInteger; + } + _return_value = digitSubLargewith(firstLarge, secondLarge); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(3, _return_value); + return null; +} + + +/* If calling this primitive fails, then C module does not exist. */ + +EXPORT(int) primGetModuleName(void) { + int strOop; + char *strPtr; + int i; + int strLen; + + /* missing DebugCode */; + strLen = strlen(moduleName); + strOop = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classString(), strLen); + strPtr = interpreterProxy->firstIndexableField(strOop); + for (i = 0; i <= (strLen - 1); i += 1) { + strPtr[i] = (moduleName[i]); + } + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(1, strOop); + return null; +} + + +/* Parameter specification #(Integer) doesn't convert! */ + +EXPORT(int) primNormalize(void) { + int anInteger; + int _return_value; + + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(0), "Integer")); + anInteger = interpreterProxy->stackValue(0); + /* missing DebugCode */; + if (interpreterProxy->failed()) { + return null; + } + if ((anInteger & 1)) { + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(2, anInteger); + return null; + } + /* begin normalize: */ + /* missing DebugCode */; + if ((interpreterProxy->fetchClassOf(anInteger)) == (interpreterProxy->classLargePositiveInteger())) { + _return_value = normalizePositive(anInteger); + goto l1; + } else { + _return_value = normalizeNegative(anInteger); + goto l1; + } +l1: /* end normalize: */; + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(2, _return_value); + return null; +} + + +/* */ + +EXPORT(int) primNormalizeNegative(void) { + int rcvr; + int _return_value; + + /* missing DebugCode */; + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(0), "LargeNegativeInteger")); + rcvr = interpreterProxy->stackValue(0); + if (interpreterProxy->failed()) { + return null; + } + _return_value = normalizeNegative(rcvr); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(1, _return_value); + return null; +} + + +/* */ + +EXPORT(int) primNormalizePositive(void) { + int rcvr; + int _return_value; + + /* missing DebugCode */; + interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(0), "LargePositiveInteger")); + rcvr = interpreterProxy->stackValue(0); + if (interpreterProxy->failed()) { + return null; + } + _return_value = normalizePositive(rcvr); + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->popthenPush(1, _return_value); + return null; +} + + +/* Note: This is coded so that is can be run from Squeak. */ + +EXPORT(int) setInterpreter(struct VirtualMachine* anInterpreter) { + int ok; + + interpreterProxy = anInterpreter; + ok = interpreterProxy->majorVersion() == VM_PROXY_MAJOR; + if (ok == 0) { + return 0; + } + ok = interpreterProxy->minorVersion() >= VM_PROXY_MINOR; + return ok; +} + +static int sqAssert(int aBool) { + /* missing DebugCode */; +} + + +/* Flag for marking methods for later thinking. */ + +static int think(void) { + return msg("#think should not be called"); +} + + +/* Argument bytesOop must not be aSmallInteger! */ + +static int unsafeByteOfat(int bytesOop, int ix) { + return ((interpreterProxy->stObjectat(bytesOop, ix)) >> 1); +} + + +#ifdef SQUEAK_BUILTIN_PLUGIN + + +void* LargeIntegers_exports[][3] = { + {"LargeIntegers", "primAnyBitFromTo", (void*)primAnyBitFromTo}, + {"LargeIntegers", "primDigitSubtractWith", (void*)primDigitSubtractWith}, + {"LargeIntegers", "primDigitBitShift", (void*)primDigitBitShift}, + {"LargeIntegers", "primDigitBitLogicWithOp", (void*)primDigitBitLogicWithOp}, + {"LargeIntegers", "primDigitMultiplyNegative", (void*)primDigitMultiplyNegative}, + {"LargeIntegers", "primDigitMultiplyWithNegative", (void*)primDigitMultiplyWithNegative}, + {"LargeIntegers", "primCheckIfCModuleExists", (void*)primCheckIfCModuleExists}, + {"LargeIntegers", "primDigitCompare", (void*)primDigitCompare}, + {"LargeIntegers", "primDigitCompareWith", (void*)primDigitCompareWith}, + {"LargeIntegers", "primDigitBitOr", (void*)primDigitBitOr}, + {"LargeIntegers", "primNormalizePositive", (void*)primNormalizePositive}, + {"LargeIntegers", "primDigitAdd", (void*)primDigitAdd}, + {"LargeIntegers", "primDigitDivWithNegative", (void*)primDigitDivWithNegative}, + {"LargeIntegers", "getModuleName", (void*)getModuleName}, + {"LargeIntegers", "setInterpreter", (void*)setInterpreter}, + {"LargeIntegers", "primNormalizeNegative", (void*)primNormalizeNegative}, + {"LargeIntegers", "_primDigitBitShift", (void*)_primDigitBitShift}, + {"LargeIntegers", "primDigitBitAnd", (void*)primDigitBitAnd}, + {"LargeIntegers", "primDigitBitXor", (void*)primDigitBitXor}, + {"LargeIntegers", "primDigitAddWith", (void*)primDigitAddWith}, + {"LargeIntegers", "primDigitDivNegative", (void*)primDigitDivNegative}, + {"LargeIntegers", "primAsLargeInteger", (void*)primAsLargeInteger}, + {"LargeIntegers", "primDigitSubtract", (void*)primDigitSubtract}, + {"LargeIntegers", "primGetModuleName", (void*)primGetModuleName}, + {"LargeIntegers", "primDigitBitShiftMagnitude", (void*)primDigitBitShiftMagnitude}, + {"LargeIntegers", "primNormalize", (void*)primNormalize}, + {NULL, NULL, NULL} +}; + + +#endif /* ifdef SQ_BUILTIN_PLUGIN */ + diff --git a/squeak/Matrix2x3Plugin.c b/squeak/Matrix2x3Plugin.c new file mode 100644 index 0000000..9f7f1f5 --- /dev/null +++ b/squeak/Matrix2x3Plugin.c @@ -0,0 +1,664 @@ +/* Automatically generated from Squeak on #(4 March 2003 4:22:57 am) */ + +#include +#include +#include +#include +#include + +/* Default EXPORT macro that does nothing (see comment in sq.h): */ +#define EXPORT(returnType) returnType + +/* Do not include the entire sq.h file but just those parts needed. */ +/* The virtual machine proxy definition */ +#include "sqVirtualMachine.h" +/* Configuration options */ +#include "sqConfig.h" +/* Platform specific definitions */ +#include "sqPlatformSpecific.h" + +#define true 1 +#define false 0 +#define null 0 /* using 'null' because nil is predefined in Think C */ +#ifdef SQUEAK_BUILTIN_PLUGIN +#undef EXPORT +// was #undef EXPORT(returnType) but screws NorCroft cc +#define EXPORT(returnType) static returnType +#endif + +/* memory access macros */ +#define byteAt(i) (*((unsigned char *) (i))) +#define byteAtput(i, val) (*((unsigned char *) (i)) = val) +#define longAt(i) (*((int *) (i))) +#define longAtput(i, val) (*((int *) (i)) = val) + + +/*** Variables ***/ + +#ifdef SQUEAK_BUILTIN_PLUGIN +extern +#endif +struct VirtualMachine* interpreterProxy; +static double m23ArgX; +static double m23ArgY; +static double m23ResultX; +static double m23ResultY; +static const char *moduleName = +#ifdef SQUEAK_BUILTIN_PLUGIN + "Matrix2x3Plugin 4 March 2003 (i)" +#else + "Matrix2x3Plugin 4 March 2003 (e)" +#endif +; + +/*** Function Prototypes ***/ +#pragma export on +EXPORT(const char*) getModuleName(void); +#pragma export off +static int halt(void); +static float * loadArgumentMatrix(int matrix); +static int loadArgumentPoint(int point); +static int matrix2x3ComposeMatrixwithinto(const float *m1, const float *m2, float *m3); +static int matrix2x3InvertPoint(float *m); +static int matrix2x3TransformPoint(float *m); +static int msg(char *s); +static int okayIntValue(int value); +#pragma export on +EXPORT(int) primitiveComposeMatrix(void); +EXPORT(int) primitiveInvertPoint(void); +EXPORT(int) primitiveInvertRectInto(void); +EXPORT(int) primitiveIsIdentity(void); +EXPORT(int) primitiveIsPureTranslation(void); +EXPORT(int) primitiveTransformPoint(void); +EXPORT(int) primitiveTransformRectInto(void); +#pragma export off +static int roundAndStoreResultPoint(int nItemsToPop); +static int roundAndStoreResultRectx0y0x1y1(int dstOop, double x0, double y0, double x1, double y1); +#pragma export on +EXPORT(int) setInterpreter(struct VirtualMachine* anInterpreter); +#pragma export off + + +/* Note: This is hardcoded so it can be run from Squeak. + The module name is used for validating a module *after* + it is loaded to check if it does really contain the module + we're thinking it contains. This is important! */ + +EXPORT(const char*) getModuleName(void) { + return moduleName; +} + +static int halt(void) { + ; +} + + +/* Load the argument matrix */ + +static float * loadArgumentMatrix(int matrix) { + if (interpreterProxy->failed()) { + return null; + } + if (!((interpreterProxy->isWords(matrix)) && ((interpreterProxy->slotSizeOf(matrix)) == 6))) { + interpreterProxy->primitiveFail(); + return null; + } + return ((float *) (interpreterProxy->firstIndexableField(matrix))); +} + + +/* Load the argument point into m23ArgX and m23ArgY */ + +static int loadArgumentPoint(int point) { + int oop; + int isInt; + + if (interpreterProxy->failed()) { + return null; + } + if (!((interpreterProxy->fetchClassOf(point)) == (interpreterProxy->classPoint()))) { + return interpreterProxy->primitiveFail(); + } + oop = interpreterProxy->fetchPointerofObject(0, point); + isInt = (oop & 1); + if (!(isInt || (interpreterProxy->isFloatObject(oop)))) { + return interpreterProxy->primitiveFail(); + } + if (isInt) { + m23ArgX = (oop >> 1); + } else { + m23ArgX = interpreterProxy->floatValueOf(oop); + } + oop = interpreterProxy->fetchPointerofObject(1, point); + isInt = (oop & 1); + if (!(isInt || (interpreterProxy->isFloatObject(oop)))) { + return interpreterProxy->primitiveFail(); + } + if (isInt) { + m23ArgY = (oop >> 1); + } else { + m23ArgY = interpreterProxy->floatValueOf(oop); + } +} + + +/* Multiply matrix m1 with m2 and store the result into m3. */ + +static int matrix2x3ComposeMatrixwithinto(const float *m1, const float *m2, float *m3) { + double a11; + double a12; + double a13; + double a21; + double a22; + double a23; + + a11 = ((m1[0]) * (m2[0])) + ((m1[1]) * (m2[3])); + a12 = ((m1[0]) * (m2[1])) + ((m1[1]) * (m2[4])); + a13 = (((m1[0]) * (m2[2])) + ((m1[1]) * (m2[5]))) + (m1[2]); + a21 = ((m1[3]) * (m2[0])) + ((m1[4]) * (m2[3])); + a22 = ((m1[3]) * (m2[1])) + ((m1[4]) * (m2[4])); + a23 = (((m1[3]) * (m2[2])) + ((m1[4]) * (m2[5]))) + (m1[5]); + m3[0] = (((float) a11)); + m3[1] = (((float) a12)); + m3[2] = (((float) a13)); + m3[3] = (((float) a21)); + m3[4] = (((float) a22)); + m3[5] = (((float) a23)); +} + + +/* Invert the pre-loaded argument point by the given matrix */ + +static int matrix2x3InvertPoint(float *m) { + double det; + double x; + double y; + double detX; + double detY; + + x = m23ArgX - (m[2]); + y = m23ArgY - (m[5]); + det = ((m[0]) * (m[4])) - ((m[1]) * (m[3])); + if (det == 0.0) { + return interpreterProxy->primitiveFail(); + } + det = 1.0 / det; + detX = (x * (m[4])) - ((m[1]) * y); + detY = ((m[0]) * y) - (x * (m[3])); + m23ResultX = detX * det; + m23ResultY = detY * det; +} + + +/* Transform the pre-loaded argument point by the given matrix */ + +static int matrix2x3TransformPoint(float *m) { + m23ResultX = ((m23ArgX * (m[0])) + (m23ArgY * (m[1]))) + (m[2]); + m23ResultY = ((m23ArgX * (m[3])) + (m23ArgY * (m[4]))) + (m[5]); +} + +static int msg(char *s) { + fprintf(stderr, "\n%s: %s", moduleName, s); +} + +static int okayIntValue(int value) { + return (value >= (((double) -1073741824 ))) && (m23ResultX <= (((double) 1073741823 ))); +} + +EXPORT(int) primitiveComposeMatrix(void) { + int result; + float * m3; + float * m1; + float * m2; + int matrix; + int matrix1; + int matrix2; + + /* begin loadArgumentMatrix: */ + matrix = result = interpreterProxy->stackObjectValue(0); + if (interpreterProxy->failed()) { + m3 = null; + goto l1; + } + if (!((interpreterProxy->isWords(matrix)) && ((interpreterProxy->slotSizeOf(matrix)) == 6))) { + interpreterProxy->primitiveFail(); + m3 = null; + goto l1; + } + m3 = ((float *) (interpreterProxy->firstIndexableField(matrix))); +l1: /* end loadArgumentMatrix: */; + /* begin loadArgumentMatrix: */ + matrix1 = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + m2 = null; + goto l2; + } + if (!((interpreterProxy->isWords(matrix1)) && ((interpreterProxy->slotSizeOf(matrix1)) == 6))) { + interpreterProxy->primitiveFail(); + m2 = null; + goto l2; + } + m2 = ((float *) (interpreterProxy->firstIndexableField(matrix1))); +l2: /* end loadArgumentMatrix: */; + /* begin loadArgumentMatrix: */ + matrix2 = interpreterProxy->stackObjectValue(2); + if (interpreterProxy->failed()) { + m1 = null; + goto l3; + } + if (!((interpreterProxy->isWords(matrix2)) && ((interpreterProxy->slotSizeOf(matrix2)) == 6))) { + interpreterProxy->primitiveFail(); + m1 = null; + goto l3; + } + m1 = ((float *) (interpreterProxy->firstIndexableField(matrix2))); +l3: /* end loadArgumentMatrix: */; + if (interpreterProxy->failed()) { + return null; + } + matrix2x3ComposeMatrixwithinto(m1, m2, m3); + interpreterProxy->pop(3); + interpreterProxy->push(result); +} + +EXPORT(int) primitiveInvertPoint(void) { + float * matrix; + int matrix1; + + loadArgumentPoint(interpreterProxy->stackObjectValue(0)); + /* begin loadArgumentMatrix: */ + matrix1 = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + matrix = null; + goto l1; + } + if (!((interpreterProxy->isWords(matrix1)) && ((interpreterProxy->slotSizeOf(matrix1)) == 6))) { + interpreterProxy->primitiveFail(); + matrix = null; + goto l1; + } + matrix = ((float *) (interpreterProxy->firstIndexableField(matrix1))); +l1: /* end loadArgumentMatrix: */; + if (interpreterProxy->failed()) { + return null; + } + matrix2x3InvertPoint(matrix); + if (!(interpreterProxy->failed())) { + /* begin roundAndStoreResultPoint: */ + m23ResultX += 0.5; + m23ResultY += 0.5; + if (!((m23ResultX >= (((double) -1073741824 ))) && (m23ResultX <= (((double) 1073741823 ))))) { + interpreterProxy->primitiveFail(); + goto l2; + } + if (!((m23ResultY >= (((double) -1073741824 ))) && (m23ResultX <= (((double) 1073741823 ))))) { + interpreterProxy->primitiveFail(); + goto l2; + } + interpreterProxy->pop(2); + interpreterProxy->push(interpreterProxy->makePointwithxValueyValue(((int) m23ResultX ), ((int) m23ResultY ))); + l2: /* end roundAndStoreResultPoint: */; + } +} + +EXPORT(int) primitiveInvertRectInto(void) { + int srcOop; + double cornerY; + double minX; + double maxX; + double minY; + double maxY; + float * matrix; + int dstOop; + double originX; + double originY; + double cornerX; + int matrix1; + + dstOop = interpreterProxy->stackObjectValue(0); + srcOop = interpreterProxy->stackObjectValue(1); + /* begin loadArgumentMatrix: */ + matrix1 = interpreterProxy->stackObjectValue(2); + if (interpreterProxy->failed()) { + matrix = null; + goto l1; + } + if (!((interpreterProxy->isWords(matrix1)) && ((interpreterProxy->slotSizeOf(matrix1)) == 6))) { + interpreterProxy->primitiveFail(); + matrix = null; + goto l1; + } + matrix = ((float *) (interpreterProxy->firstIndexableField(matrix1))); +l1: /* end loadArgumentMatrix: */; + if (interpreterProxy->failed()) { + return null; + } + if (!((interpreterProxy->fetchClassOf(srcOop)) == (interpreterProxy->fetchClassOf(dstOop)))) { + return interpreterProxy->primitiveFail(); + } + if (!(interpreterProxy->isPointers(srcOop))) { + return interpreterProxy->primitiveFail(); + } + if (!((interpreterProxy->slotSizeOf(srcOop)) == 2)) { + return interpreterProxy->primitiveFail(); + } + loadArgumentPoint(interpreterProxy->fetchPointerofObject(0, srcOop)); + if (interpreterProxy->failed()) { + return null; + } + originX = m23ArgX; + originY = m23ArgY; + matrix2x3InvertPoint(matrix); + minX = maxX = m23ResultX; + + /* Load bottom-right point */ + + minY = maxY = m23ResultY; + loadArgumentPoint(interpreterProxy->fetchPointerofObject(1, srcOop)); + if (interpreterProxy->failed()) { + return null; + } + cornerX = m23ArgX; + cornerY = m23ArgY; + matrix2x3InvertPoint(matrix); + minX = ((minX < m23ResultX) ? minX : m23ResultX); + maxX = ((maxX < m23ResultX) ? m23ResultX : maxX); + minY = ((minY < m23ResultY) ? minY : m23ResultY); + + /* Load top-right point */ + + maxY = ((maxY < m23ResultY) ? m23ResultY : maxY); + m23ArgX = cornerX; + m23ArgY = originY; + matrix2x3InvertPoint(matrix); + minX = ((minX < m23ResultX) ? minX : m23ResultX); + maxX = ((maxX < m23ResultX) ? m23ResultX : maxX); + minY = ((minY < m23ResultY) ? minY : m23ResultY); + + /* Load bottom-left point */ + + maxY = ((maxY < m23ResultY) ? m23ResultY : maxY); + m23ArgX = originX; + m23ArgY = cornerY; + matrix2x3InvertPoint(matrix); + minX = ((minX < m23ResultX) ? minX : m23ResultX); + maxX = ((maxX < m23ResultX) ? m23ResultX : maxX); + minY = ((minY < m23ResultY) ? minY : m23ResultY); + maxY = ((maxY < m23ResultY) ? m23ResultY : maxY); + if (!(interpreterProxy->failed())) { + dstOop = roundAndStoreResultRectx0y0x1y1(dstOop, minX, minY, maxX, maxY); + } + if (!(interpreterProxy->failed())) { + interpreterProxy->pop(3); + interpreterProxy->push(dstOop); + } +} + +EXPORT(int) primitiveIsIdentity(void) { + float * matrix; + int matrix1; + + /* begin loadArgumentMatrix: */ + matrix1 = interpreterProxy->stackObjectValue(0); + if (interpreterProxy->failed()) { + matrix = null; + goto l1; + } + if (!((interpreterProxy->isWords(matrix1)) && ((interpreterProxy->slotSizeOf(matrix1)) == 6))) { + interpreterProxy->primitiveFail(); + matrix = null; + goto l1; + } + matrix = ((float *) (interpreterProxy->firstIndexableField(matrix1))); +l1: /* end loadArgumentMatrix: */; + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->pop(1); + interpreterProxy->pushBool(((((((matrix[0]) == (((float) 1.0))) && ((matrix[1]) == (((float) 0.0)))) && ((matrix[2]) == (((float) 0.0)))) && ((matrix[3]) == (((float) 0.0)))) && ((matrix[4]) == (((float) 1.0)))) && ((matrix[5]) == (((float) 0.0)))); +} + +EXPORT(int) primitiveIsPureTranslation(void) { + float * matrix; + int matrix1; + + /* begin loadArgumentMatrix: */ + matrix1 = interpreterProxy->stackObjectValue(0); + if (interpreterProxy->failed()) { + matrix = null; + goto l1; + } + if (!((interpreterProxy->isWords(matrix1)) && ((interpreterProxy->slotSizeOf(matrix1)) == 6))) { + interpreterProxy->primitiveFail(); + matrix = null; + goto l1; + } + matrix = ((float *) (interpreterProxy->firstIndexableField(matrix1))); +l1: /* end loadArgumentMatrix: */; + if (interpreterProxy->failed()) { + return null; + } + interpreterProxy->pop(1); + interpreterProxy->pushBool(((((matrix[0]) == (((float) 1.0))) && ((matrix[1]) == (((float) 0.0)))) && ((matrix[3]) == (((float) 0.0)))) && ((matrix[4]) == (((float) 1.0)))); +} + +EXPORT(int) primitiveTransformPoint(void) { + float * matrix; + int matrix1; + + loadArgumentPoint(interpreterProxy->stackObjectValue(0)); + /* begin loadArgumentMatrix: */ + matrix1 = interpreterProxy->stackObjectValue(1); + if (interpreterProxy->failed()) { + matrix = null; + goto l1; + } + if (!((interpreterProxy->isWords(matrix1)) && ((interpreterProxy->slotSizeOf(matrix1)) == 6))) { + interpreterProxy->primitiveFail(); + matrix = null; + goto l1; + } + matrix = ((float *) (interpreterProxy->firstIndexableField(matrix1))); +l1: /* end loadArgumentMatrix: */; + if (interpreterProxy->failed()) { + return null; + } + matrix2x3TransformPoint(matrix); + /* begin roundAndStoreResultPoint: */ + m23ResultX += 0.5; + m23ResultY += 0.5; + if (!((m23ResultX >= (((double) -1073741824 ))) && (m23ResultX <= (((double) 1073741823 ))))) { + interpreterProxy->primitiveFail(); + goto l2; + } + if (!((m23ResultY >= (((double) -1073741824 ))) && (m23ResultX <= (((double) 1073741823 ))))) { + interpreterProxy->primitiveFail(); + goto l2; + } + interpreterProxy->pop(2); + interpreterProxy->push(interpreterProxy->makePointwithxValueyValue(((int) m23ResultX ), ((int) m23ResultY ))); +l2: /* end roundAndStoreResultPoint: */; +} + +EXPORT(int) primitiveTransformRectInto(void) { + int srcOop; + double cornerY; + double minX; + double maxX; + double minY; + double maxY; + float * matrix; + int dstOop; + double originX; + double originY; + double cornerX; + int matrix1; + + dstOop = interpreterProxy->stackObjectValue(0); + srcOop = interpreterProxy->stackObjectValue(1); + /* begin loadArgumentMatrix: */ + matrix1 = interpreterProxy->stackObjectValue(2); + if (interpreterProxy->failed()) { + matrix = null; + goto l1; + } + if (!((interpreterProxy->isWords(matrix1)) && ((interpreterProxy->slotSizeOf(matrix1)) == 6))) { + interpreterProxy->primitiveFail(); + matrix = null; + goto l1; + } + matrix = ((float *) (interpreterProxy->firstIndexableField(matrix1))); +l1: /* end loadArgumentMatrix: */; + if (interpreterProxy->failed()) { + return null; + } + if (!((interpreterProxy->fetchClassOf(srcOop)) == (interpreterProxy->fetchClassOf(dstOop)))) { + return interpreterProxy->primitiveFail(); + } + if (!(interpreterProxy->isPointers(srcOop))) { + return interpreterProxy->primitiveFail(); + } + if (!((interpreterProxy->slotSizeOf(srcOop)) == 2)) { + return interpreterProxy->primitiveFail(); + } + loadArgumentPoint(interpreterProxy->fetchPointerofObject(0, srcOop)); + if (interpreterProxy->failed()) { + return null; + } + originX = m23ArgX; + originY = m23ArgY; + matrix2x3TransformPoint(matrix); + minX = maxX = m23ResultX; + + /* Load bottom-right point */ + + minY = maxY = m23ResultY; + loadArgumentPoint(interpreterProxy->fetchPointerofObject(1, srcOop)); + if (interpreterProxy->failed()) { + return null; + } + cornerX = m23ArgX; + cornerY = m23ArgY; + matrix2x3TransformPoint(matrix); + minX = ((minX < m23ResultX) ? minX : m23ResultX); + maxX = ((maxX < m23ResultX) ? m23ResultX : maxX); + minY = ((minY < m23ResultY) ? minY : m23ResultY); + + /* Load top-right point */ + + maxY = ((maxY < m23ResultY) ? m23ResultY : maxY); + m23ArgX = cornerX; + m23ArgY = originY; + matrix2x3TransformPoint(matrix); + minX = ((minX < m23ResultX) ? minX : m23ResultX); + maxX = ((maxX < m23ResultX) ? m23ResultX : maxX); + minY = ((minY < m23ResultY) ? minY : m23ResultY); + + /* Load bottom-left point */ + + maxY = ((maxY < m23ResultY) ? m23ResultY : maxY); + m23ArgX = originX; + m23ArgY = cornerY; + matrix2x3TransformPoint(matrix); + minX = ((minX < m23ResultX) ? minX : m23ResultX); + maxX = ((maxX < m23ResultX) ? m23ResultX : maxX); + minY = ((minY < m23ResultY) ? minY : m23ResultY); + maxY = ((maxY < m23ResultY) ? m23ResultY : maxY); + dstOop = roundAndStoreResultRectx0y0x1y1(dstOop, minX, minY, maxX, maxY); + if (!(interpreterProxy->failed())) { + interpreterProxy->pop(3); + interpreterProxy->push(dstOop); + } +} + + +/* Store the result of a previous operation. + Fail if we cannot represent the result as SmallInteger */ + +static int roundAndStoreResultPoint(int nItemsToPop) { + m23ResultX += 0.5; + m23ResultY += 0.5; + if (!((m23ResultX >= (((double) -1073741824 ))) && (m23ResultX <= (((double) 1073741823 ))))) { + return interpreterProxy->primitiveFail(); + } + if (!((m23ResultY >= (((double) -1073741824 ))) && (m23ResultX <= (((double) 1073741823 ))))) { + return interpreterProxy->primitiveFail(); + } + interpreterProxy->pop(nItemsToPop); + interpreterProxy->push(interpreterProxy->makePointwithxValueyValue(((int) m23ResultX ), ((int) m23ResultY ))); +} + + +/* Check, round and store the result of a rectangle operation */ + +static int roundAndStoreResultRectx0y0x1y1(int dstOop, double x0, double y0, double x1, double y1) { + double maxX; + double minX; + double maxY; + double minY; + int rectOop; + int originOop; + int cornerOop; + + minX = x0 + 0.5; + if (!((minX >= (((double) -1073741824 ))) && (m23ResultX <= (((double) 1073741823 ))))) { + return interpreterProxy->primitiveFail(); + } + maxX = x1 + 0.5; + if (!((maxX >= (((double) -1073741824 ))) && (m23ResultX <= (((double) 1073741823 ))))) { + return interpreterProxy->primitiveFail(); + } + minY = y0 + 0.5; + if (!((minY >= (((double) -1073741824 ))) && (m23ResultX <= (((double) 1073741823 ))))) { + return interpreterProxy->primitiveFail(); + } + maxY = y1 + 0.5; + if (!((maxY >= (((double) -1073741824 ))) && (m23ResultX <= (((double) 1073741823 ))))) { + return interpreterProxy->primitiveFail(); + } + interpreterProxy->pushRemappableOop(dstOop); + originOop = interpreterProxy->makePointwithxValueyValue(((int) minX ), ((int) minY )); + interpreterProxy->pushRemappableOop(originOop); + cornerOop = interpreterProxy->makePointwithxValueyValue(((int) maxX ), ((int) maxY )); + originOop = interpreterProxy->popRemappableOop(); + rectOop = interpreterProxy->popRemappableOop(); + interpreterProxy->storePointerofObjectwithValue(0, rectOop, originOop); + interpreterProxy->storePointerofObjectwithValue(1, rectOop, cornerOop); + return rectOop; +} + + +/* Note: This is coded so that is can be run from Squeak. */ + +EXPORT(int) setInterpreter(struct VirtualMachine* anInterpreter) { + int ok; + + interpreterProxy = anInterpreter; + ok = interpreterProxy->majorVersion() == VM_PROXY_MAJOR; + if (ok == 0) { + return 0; + } + ok = interpreterProxy->minorVersion() >= VM_PROXY_MINOR; + return ok; +} + + +#ifdef SQUEAK_BUILTIN_PLUGIN + + +void* Matrix2x3Plugin_exports[][3] = { + {"Matrix2x3Plugin", "primitiveTransformPoint", (void*)primitiveTransformPoint}, + {"Matrix2x3Plugin", "primitiveIsIdentity", (void*)primitiveIsIdentity}, + {"Matrix2x3Plugin", "primitiveTransformRectInto", (void*)primitiveTransformRectInto}, + {"Matrix2x3Plugin", "primitiveInvertPoint", (void*)primitiveInvertPoint}, + {"Matrix2x3Plugin", "primitiveComposeMatrix", (void*)primitiveComposeMatrix}, + {"Matrix2x3Plugin", "getModuleName", (void*)getModuleName}, + {"Matrix2x3Plugin", "primitiveIsPureTranslation", (void*)primitiveIsPureTranslation}, + {"Matrix2x3Plugin", "primitiveInvertRectInto", (void*)primitiveInvertRectInto}, + {"Matrix2x3Plugin", "setInterpreter", (void*)setInterpreter}, + {NULL, NULL, NULL} +}; + + +#endif /* ifdef SQ_BUILTIN_PLUGIN */ + diff --git a/squeak/MiscPrimitivePlugin.c b/squeak/MiscPrimitivePlugin.c new file mode 100644 index 0000000..7cfdad4 --- /dev/null +++ b/squeak/MiscPrimitivePlugin.c @@ -0,0 +1,691 @@ +/* Automatically generated from Squeak on #(4 March 2003 4:22:57 am) */ + +#include +#include +#include +#include +#include + +/* Default EXPORT macro that does nothing (see comment in sq.h): */ +#define EXPORT(returnType) returnType + +/* Do not include the entire sq.h file but just those parts needed. */ +/* The virtual machine proxy definition */ +#include "sqVirtualMachine.h" +/* Configuration options */ +#include "sqConfig.h" +/* Platform specific definitions */ +#include "sqPlatformSpecific.h" + +#define true 1 +#define false 0 +#define null 0 /* using 'null' because nil is predefined in Think C */ +#ifdef SQUEAK_BUILTIN_PLUGIN +#undef EXPORT +// was #undef EXPORT(returnType) but screws NorCroft cc +#define EXPORT(returnType) static returnType +#endif + +/* memory access macros */ +#define byteAt(i) (*((unsigned char *) (i))) +#define byteAtput(i, val) (*((unsigned char *) (i)) = val) +#define longAt(i) (*((int *) (i))) +#define longAtput(i, val) (*((int *) (i)) = val) + + + +/*** Proxy Functions ***/ +#define stackValue(i) (interpreterProxy->stackValue(i)) +#define stackIntegerValue(i) (interpreterProxy->stackIntegerValue(i)) +#define successFlag (!interpreterProxy->failed()) +#define success(bool) (interpreterProxy->success(bool)) +#define arrayValueOf(oop) (interpreterProxy->arrayValueOf(oop)) +#define checkedIntegerValueOf(oop) (interpreterProxy->checkedIntegerValueOf(oop)) +#define fetchArrayofObject(idx,oop) (interpreterProxy->fetchArrayofObject(idx,oop)) +#define fetchFloatofObject(idx,oop) (interpreterProxy->fetchFloatofObject(idx,oop)) +#define fetchIntegerofObject(idx,oop) (interpreterProxy->fetchIntegerofObject(idx,oop)) +#define floatValueOf(oop) (interpreterProxy->floatValueOf(oop)) +#define pop(n) (interpreterProxy->pop(n)) +#define pushInteger(n) (interpreterProxy->pushInteger(n)) +#define sizeOfSTArrayFromCPrimitive(cPtr) (interpreterProxy->sizeOfSTArrayFromCPrimitive(cPtr)) +#define storeIntegerofObjectwithValue(idx,oop,value) (interpreterProxy->storeIntegerofObjectwithValue(idx,oop,value)) +#define primitiveFail() interpreterProxy->primitiveFail() +/* allows accessing Strings in both C and Smalltalk */ +#define asciiValue(c) c + + +/*** Variables ***/ + +#ifdef SQUEAK_BUILTIN_PLUGIN +extern +#endif +struct VirtualMachine* interpreterProxy; +static const char *moduleName = +#ifdef SQUEAK_BUILTIN_PLUGIN + "MiscPrimitivePlugin 4 March 2003 (i)" +#else + "MiscPrimitivePlugin 4 March 2003 (e)" +#endif +; + +/*** Function Prototypes ***/ +static int encodeBytesOfinat(int anInt, unsigned char *ba, int i); +static int encodeIntinat(int anInt, unsigned char *ba, int i); +#pragma export on +EXPORT(const char*) getModuleName(void); +#pragma export off +static int halt(void); +static int msg(char *s); +#pragma export on +EXPORT(int) primitiveCompareString(void); +EXPORT(int) primitiveCompressToByteArray(void); +EXPORT(int) primitiveConvert8BitSigned(void); +EXPORT(int) primitiveDecompressFromByteArray(void); +EXPORT(int) primitiveFindFirstInString(void); +EXPORT(int) primitiveFindSubstring(void); +EXPORT(int) primitiveIndexOfAsciiInString(void); +EXPORT(int) primitiveStringHash(void); +EXPORT(int) primitiveTranslateStringWithTable(void); +EXPORT(int) setInterpreter(struct VirtualMachine* anInterpreter); +#pragma export off + + +/* Copy the integer anInt into byteArray ba at index i, and return the next index */ + +static int encodeBytesOfinat(int anInt, unsigned char *ba, int i) { + int j; + + for (j = 0; j <= 3; j += 1) { + ba[i + j] = ((((unsigned) anInt) >> ((3 - j) * 8)) & 255); + } + return i + 4; +} + + +/* Encode the integer anInt in byteArray ba at index i, and return the next index. + The encoding is as follows... + 0-223 0-223 + 224-254 (0-30)*256 + next byte (0-7935) + 255 next 4 bytes */ + +static int encodeIntinat(int anInt, unsigned char *ba, int i) { + if (anInt <= 223) { + ba[i] = anInt; + return i + 1; + } + if (anInt <= 7935) { + ba[i] = ((((int) anInt >> 8)) + 224); + ba[i + 1] = (anInt % 256); + return i + 2; + } + ba[i] = 255; + return encodeBytesOfinat(anInt, ba, i + 1); +} + + +/* Note: This is hardcoded so it can be run from Squeak. + The module name is used for validating a module *after* + it is loaded to check if it does really contain the module + we're thinking it contains. This is important! */ + +EXPORT(const char*) getModuleName(void) { + return moduleName; +} + +static int halt(void) { + ; +} + +static int msg(char *s) { + fprintf(stderr, "\n%s: %s", moduleName, s); +} + + +/* Return 1, 2 or 3, if string1 is <, =, or > string2, with the collating order of characters given by the order array. */ + +EXPORT(int) primitiveCompareString(void) { + int rcvr; + unsigned char *string1; + unsigned char *string2; + unsigned char *order; + int len1; + int i; + int len2; + int c1; + int c2; + + rcvr = stackValue(3); + string1 = arrayValueOf(stackValue(2)); + string1 -= 1; + string2 = arrayValueOf(stackValue(1)); + string2 -= 1; + order = arrayValueOf(stackValue(0)); + order -= 1; + if (!(successFlag)) { + return null; + } + len1 = sizeOfSTArrayFromCPrimitive(string1 + 1); + len2 = sizeOfSTArrayFromCPrimitive(string2 + 1); + for (i = 1; i <= (((len1 < len2) ? len1 : len2)); i += 1) { + c1 = order[(string1[i]) + 1]; + c2 = order[(string2[i]) + 1]; + if (!(c1 == c2)) { + if (c1 < c2) { + if (!(successFlag)) { + return null; + } + pop(4); + pushInteger(1); + return null; + } else { + if (!(successFlag)) { + return null; + } + pop(4); + pushInteger(3); + return null; + } + } + } + if (len1 == len2) { + if (!(successFlag)) { + return null; + } + pop(4); + pushInteger(2); + return null; + } + if (len1 < len2) { + if (!(successFlag)) { + return null; + } + pop(4); + pushInteger(1); + return null; + } else { + if (!(successFlag)) { + return null; + } + pop(4); + pushInteger(3); + return null; + } + if (!(successFlag)) { + return null; + } + pop(3); +} + + +/* Store a run-coded compression of the receiver into the byteArray ba, + and return the last index stored into. ba is assumed to be large enough. + The encoding is as follows... + S {N D}*. + S is the size of the original bitmap, followed by run-coded pairs. + N is a run-length * 4 + data code. + D, the data, depends on the data code... + 0 skip N words, D is absent + 1 N words with all 4 bytes = D (1 byte) + 2 N words all = D (4 bytes) + 3 N words follow in D (4N bytes) + S and N are encoded as follows... + 0-223 0-223 + 224-254 (0-30)*256 + next byte (0-7935) + 255 next 4 bytes */ + +EXPORT(int) primitiveCompressToByteArray(void) { + int rcvr; + int *bm; + unsigned char *ba; + int size; + int eqBytes; + int i; + int j; + int m; + int k; + int lowByte; + int word; + + rcvr = stackValue(2); + bm = arrayValueOf(stackValue(1)); + bm -= 1; + ba = arrayValueOf(stackValue(0)); + ba -= 1; + if (!(successFlag)) { + return null; + } + size = sizeOfSTArrayFromCPrimitive(bm + 1); + i = encodeIntinat(size, ba, 1); + k = 1; + while (k <= size) { + word = bm[k]; + lowByte = word & 255; + eqBytes = (((((unsigned) word) >> 8) & 255) == lowByte) && ((((((unsigned) word) >> 16) & 255) == lowByte) && (((((unsigned) word) >> 24) & 255) == lowByte)); + j = k; + while ((j < size) && (word == (bm[j + 1]))) { + j += 1; + } + if (j > k) { + if (eqBytes) { + i = encodeIntinat((((j - k) + 1) * 4) + 1, ba, i); + ba[i] = lowByte; + i += 1; + } else { + i = encodeIntinat((((j - k) + 1) * 4) + 2, ba, i); + i = encodeBytesOfinat(word, ba, i); + } + k = j + 1; + } else { + if (eqBytes) { + i = encodeIntinat((1 * 4) + 1, ba, i); + ba[i] = lowByte; + i += 1; + k += 1; + } else { + while ((j < size) && ((bm[j]) != (bm[j + 1]))) { + j += 1; + } + if (j == size) { + j += 1; + } + i = encodeIntinat(((j - k) * 4) + 3, ba, i); + for (m = k; m <= (j - 1); m += 1) { + i = encodeBytesOfinat(bm[m], ba, i); + } + k = j; + } + } + } + if (!(successFlag)) { + return null; + } + pop(3); + pushInteger(i - 1); + return null; +} + + +/* Copy the contents of the given array of signed 8-bit samples into the given array of 16-bit signed samples. */ + +EXPORT(int) primitiveConvert8BitSigned(void) { + int rcvr; + unsigned char *aByteArray; + unsigned short *aSoundBuffer; + int n; + int i; + int s; + + rcvr = stackValue(2); + aByteArray = arrayValueOf(stackValue(1)); + aByteArray -= 1; + aSoundBuffer = arrayValueOf(stackValue(0)); + aSoundBuffer -= 1; + if (!(successFlag)) { + return null; + } + n = sizeOfSTArrayFromCPrimitive(aByteArray + 1); + for (i = 1; i <= n; i += 1) { + s = aByteArray[i]; + if (s > 127) { + aSoundBuffer[i] = (((unsigned) (s - 256) << 8)); + } else { + aSoundBuffer[i] = (((unsigned) s << 8)); + } + } + if (!(successFlag)) { + return null; + } + pop(2); +} + + +/* Decompress the body of a byteArray encoded by compressToByteArray (qv)... + The format is simply a sequence of run-coded pairs, {N D}*. + N is a run-length * 4 + data code. + D, the data, depends on the data code... + 0 skip N words, D is absent + (could be used to skip from one raster line to the next) + 1 N words with all 4 bytes = D (1 byte) + 2 N words all = D (4 bytes) + 3 N words follow in D (4N bytes) + S and N are encoded as follows (see decodeIntFrom:)... + 0-223 0-223 + 224-254 (0-30)*256 + next byte (0-7935) + 255 next 4 bytes */ +/* NOTE: If fed with garbage, this routine could read past the end of ba, but it should fail before writing past the ned of bm. */ + +EXPORT(int) primitiveDecompressFromByteArray(void) { + int rcvr; + int *bm; + unsigned char *ba; + int index; + int m; + int n; + int data; + int code; + int end; + int pastEnd; + int i; + int j; + int k; + int anInt; + + rcvr = stackValue(3); + bm = arrayValueOf(stackValue(2)); + bm -= 1; + ba = arrayValueOf(stackValue(1)); + ba -= 1; + index = stackIntegerValue(0); + if (!(successFlag)) { + return null; + } + + /* byteArray read index */ + + i = index; + end = sizeOfSTArrayFromCPrimitive(ba + 1); + + /* bitmap write index */ + + k = 1; + pastEnd = (sizeOfSTArrayFromCPrimitive(bm + 1)) + 1; + while (i <= end) { + anInt = ba[i]; + i += 1; + if (!(anInt <= 223)) { + if (anInt <= 254) { + anInt = ((anInt - 224) * 256) + (ba[i]); + i += 1; + } else { + anInt = 0; + for (j = 1; j <= 4; j += 1) { + anInt = (((unsigned) anInt << 8)) + (ba[i]); + i += 1; + } + } + } + n = ((unsigned) anInt) >> 2; + if ((k + n) > pastEnd) { + primitiveFail(); + return null; + } + code = anInt & 3; + if (code == 0) { + null; + } + if (code == 1) { + data = ba[i]; + i += 1; + data = data | (((unsigned) data << 8)); + data = data | (((unsigned) data << 16)); + for (j = 1; j <= n; j += 1) { + bm[k] = data; + k += 1; + } + } + if (code == 2) { + data = 0; + for (j = 1; j <= 4; j += 1) { + data = (((unsigned) data << 8)) | (ba[i]); + i += 1; + } + for (j = 1; j <= n; j += 1) { + bm[k] = data; + k += 1; + } + } + if (code == 3) { + for (m = 1; m <= n; m += 1) { + data = 0; + for (j = 1; j <= 4; j += 1) { + data = (((unsigned) data << 8)) | (ba[i]); + i += 1; + } + bm[k] = data; + k += 1; + } + } + } + if (!(successFlag)) { + return null; + } + pop(3); +} + +EXPORT(int) primitiveFindFirstInString(void) { + int rcvr; + unsigned char *aString; + char *inclusionMap; + int start; + int stringSize; + int i; + + rcvr = stackValue(3); + aString = arrayValueOf(stackValue(2)); + aString -= 1; + inclusionMap = arrayValueOf(stackValue(1)); + inclusionMap -= 1; + start = stackIntegerValue(0); + if (!(successFlag)) { + return null; + } + if ((sizeOfSTArrayFromCPrimitive(inclusionMap + 1)) != 256) { + if (!(successFlag)) { + return null; + } + pop(4); + pushInteger(0); + return null; + } + i = start; + stringSize = sizeOfSTArrayFromCPrimitive(aString + 1); + while ((i <= stringSize) && ((inclusionMap[(asciiValue(aString[i])) + 1]) == 0)) { + i += 1; + } + if (i > stringSize) { + if (!(successFlag)) { + return null; + } + pop(4); + pushInteger(0); + return null; + } + if (!(successFlag)) { + return null; + } + pop(4); + pushInteger(i); + return null; +} + + +/* Answer the index in the string body at which the substring key first occurs, at or beyond start. The match is determined using matchTable, which can be used to effect, eg, case-insensitive matches. If no match is found, zero will be returned. + + The algorithm below is not optimum -- it is intended to be translated to C which will go so fast that it wont matter. */ + +EXPORT(int) primitiveFindSubstring(void) { + int rcvr; + unsigned char *key; + unsigned char *body; + int start; + unsigned char *matchTable; + int startIndex; + int index; + + rcvr = stackValue(4); + key = arrayValueOf(stackValue(3)); + key -= 1; + body = arrayValueOf(stackValue(2)); + body -= 1; + start = stackIntegerValue(1); + matchTable = arrayValueOf(stackValue(0)); + matchTable -= 1; + if (!(successFlag)) { + return null; + } + if ((sizeOfSTArrayFromCPrimitive(key + 1)) == 0) { + if (!(successFlag)) { + return null; + } + pop(5); + pushInteger(0); + return null; + } + for (startIndex = start; startIndex <= (((sizeOfSTArrayFromCPrimitive(body + 1)) - (sizeOfSTArrayFromCPrimitive(key + 1))) + 1); startIndex += 1) { + index = 1; + while ((matchTable[(asciiValue(body[(startIndex + index) - 1])) + 1]) == (matchTable[(asciiValue(key[index])) + 1])) { + if (index == (sizeOfSTArrayFromCPrimitive(key + 1))) { + if (!(successFlag)) { + return null; + } + pop(5); + pushInteger(startIndex); + return null; + } + index += 1; + } + } + if (!(successFlag)) { + return null; + } + pop(5); + pushInteger(0); + return null; +} + +EXPORT(int) primitiveIndexOfAsciiInString(void) { + int rcvr; + int anInteger; + unsigned char *aString; + int start; + int stringSize; + int pos; + + rcvr = stackValue(3); + anInteger = stackIntegerValue(2); + aString = arrayValueOf(stackValue(1)); + aString -= 1; + start = stackIntegerValue(0); + if (!(successFlag)) { + return null; + } + stringSize = sizeOfSTArrayFromCPrimitive(aString + 1); + for (pos = start; pos <= stringSize; pos += 1) { + if ((asciiValue(aString[pos])) == anInteger) { + if (!(successFlag)) { + return null; + } + pop(4); + pushInteger(pos); + return null; + } + } + if (!(successFlag)) { + return null; + } + pop(4); + pushInteger(0); + return null; +} + +EXPORT(int) primitiveStringHash(void) { + int rcvr; + unsigned char *aString; + int speciesHash; + int stringSize; + int hash; + int low; + int pos; + + rcvr = stackValue(2); + aString = arrayValueOf(stackValue(1)); + aString -= 1; + speciesHash = stackIntegerValue(0); + if (!(successFlag)) { + return null; + } + stringSize = sizeOfSTArrayFromCPrimitive(aString + 1); + hash = speciesHash & 268435455; + for (pos = 1; pos <= stringSize; pos += 1) { + + /* Begin hashMultiply */ + + hash += asciiValue(aString[pos]); + low = hash & 16383; + hash = ((9741 * low) + ((((9741 * (((unsigned) hash >> 14))) + (101 * low)) & 16383) * 16384)) & 268435455; + } + if (!(successFlag)) { + return null; + } + pop(3); + pushInteger(hash); + return null; +} + + +/* translate the characters in the string by the given table, in place */ + +EXPORT(int) primitiveTranslateStringWithTable(void) { + int rcvr; + unsigned char *aString; + int start; + int stop; + unsigned char *table; + int i; + + rcvr = stackValue(4); + aString = arrayValueOf(stackValue(3)); + aString -= 1; + start = stackIntegerValue(2); + stop = stackIntegerValue(1); + table = arrayValueOf(stackValue(0)); + table -= 1; + if (!(successFlag)) { + return null; + } + for (i = start; i <= stop; i += 1) { + aString[i] = (table[(asciiValue(aString[i])) + 1]); + } + if (!(successFlag)) { + return null; + } + pop(4); +} + + +/* Note: This is coded so that is can be run from Squeak. */ + +EXPORT(int) setInterpreter(struct VirtualMachine* anInterpreter) { + int ok; + + interpreterProxy = anInterpreter; + ok = interpreterProxy->majorVersion() == VM_PROXY_MAJOR; + if (ok == 0) { + return 0; + } + ok = interpreterProxy->minorVersion() >= VM_PROXY_MINOR; + return ok; +} + + +#ifdef SQUEAK_BUILTIN_PLUGIN + + +void* MiscPrimitivePlugin_exports[][3] = { + {"MiscPrimitivePlugin", "primitiveIndexOfAsciiInString", (void*)primitiveIndexOfAsciiInString}, + {"MiscPrimitivePlugin", "primitiveCompareString", (void*)primitiveCompareString}, + {"MiscPrimitivePlugin", "primitiveStringHash", (void*)primitiveStringHash}, + {"MiscPrimitivePlugin", "primitiveConvert8BitSigned", (void*)primitiveConvert8BitSigned}, + {"MiscPrimitivePlugin", "primitiveFindFirstInString", (void*)primitiveFindFirstInString}, + {"MiscPrimitivePlugin", "primitiveDecompressFromByteArray", (void*)primitiveDecompressFromByteArray}, + {"MiscPrimitivePlugin", "primitiveTranslateStringWithTable", (void*)primitiveTranslateStringWithTable}, + {"MiscPrimitivePlugin", "getModuleName", (void*)getModuleName}, + {"MiscPrimitivePlugin", "primitiveFindSubstring", (void*)primitiveFindSubstring}, + {"MiscPrimitivePlugin", "primitiveCompressToByteArray", (void*)primitiveCompressToByteArray}, + {"MiscPrimitivePlugin", "setInterpreter", (void*)setInterpreter}, + {NULL, NULL, NULL} +}; + + +#endif /* ifdef SQ_BUILTIN_PLUGIN */ + diff --git a/squeak/SecurityPlugin.c b/squeak/SecurityPlugin.c new file mode 100644 index 0000000..07cd501 --- /dev/null +++ b/squeak/SecurityPlugin.c @@ -0,0 +1,296 @@ +/* Automatically generated from Squeak on #(4 March 2003 4:22:58 am) */ + +#include +#include +#include +#include +#include + +/* Default EXPORT macro that does nothing (see comment in sq.h): */ +#define EXPORT(returnType) returnType + +/* Do not include the entire sq.h file but just those parts needed. */ +/* The virtual machine proxy definition */ +#include "sqVirtualMachine.h" +/* Configuration options */ +#include "sqConfig.h" +/* Platform specific definitions */ +#include "sqPlatformSpecific.h" + +#define true 1 +#define false 0 +#define null 0 /* using 'null' because nil is predefined in Think C */ +#ifdef SQUEAK_BUILTIN_PLUGIN +#undef EXPORT +// was #undef EXPORT(returnType) but screws NorCroft cc +#define EXPORT(returnType) static returnType +#endif +#include "SecurityPlugin.h" + +/* memory access macros */ +#define byteAt(i) (*((unsigned char *) (i))) +#define byteAtput(i, val) (*((unsigned char *) (i)) = val) +#define longAt(i) (*((int *) (i))) +#define longAtput(i, val) (*((int *) (i)) = val) + + +/*** Variables ***/ + +#ifdef SQUEAK_BUILTIN_PLUGIN +extern +#endif +struct VirtualMachine* interpreterProxy; +static const char *moduleName = +#ifdef SQUEAK_BUILTIN_PLUGIN + "SecurityPlugin 4 March 2003 (i)" +#else + "SecurityPlugin 4 March 2003 (e)" +#endif +; + +/*** Function Prototypes ***/ +#pragma export on +EXPORT(const char*) getModuleName(void); +#pragma export off +static int halt(void); +#pragma export on +EXPORT(int) initialiseModule(void); +#pragma export off +static int msg(char *s); +#pragma export on +EXPORT(int) primitiveCanWriteImage(void); +EXPORT(int) primitiveDisableImageWrite(void); +EXPORT(int) primitiveGetSecureUserDirectory(void); +EXPORT(int) primitiveGetUntrustedUserDirectory(void); +EXPORT(int) secCanListenOnPort(int socket, int port); +EXPORT(int) secCanConnectToPort(int addr, int port); +EXPORT(int) secCanCreateSocketOfType(int netType, int socketType); +EXPORT(int) secCanCreatePathOfSize(char * dirName, int dirNameSize); +EXPORT(int) secCanDeleteFileOfSize(char * fileName, int fileNameSize); +EXPORT(int) secCanDeletePathOfSize(char * dirName, int dirNameSize); +EXPORT(int) secCanGetFileTypeOfSize(char * fileName, int fileNameSize); +EXPORT(int) secCanListPathOfSize(char * pathName, int pathNameSize); +EXPORT(int) secCanOpenAsyncFileOfSizeWritable(char * fileName, int fileNameSize, int writeFlag); +EXPORT(int) secCanOpenFileOfSizeWritable(char * fileName, int fileNameSize, int writeFlag); +EXPORT(int) secCanRenameFileOfSize(char * fileName, int fileNameSize); +EXPORT(int) secCanRenameImage(void); +EXPORT(int) secCanSetFileTypeOfSize(char * fileName, int fileNameSize); +EXPORT(int) secCanWriteImage(void); +EXPORT(int) secDisableFileAccess(void); +EXPORT(int) secDisableSocketAccess(void); +EXPORT(int) secHasFileAccess(void); +EXPORT(int) secHasSocketAccess(void); +EXPORT(int) setInterpreter(struct VirtualMachine* anInterpreter); +#pragma export off + + +/* Note: This is hardcoded so it can be run from Squeak. + The module name is used for validating a module *after* + it is loaded to check if it does really contain the module + we're thinking it contains. This is important! */ + +EXPORT(const char*) getModuleName(void) { + return moduleName; +} + +static int halt(void) { + ; +} + +EXPORT(int) initialiseModule(void) { + return ioInitSecurity(); +} + +static int msg(char *s) { + fprintf(stderr, "\n%s: %s", moduleName, s); +} + +EXPORT(int) primitiveCanWriteImage(void) { + interpreterProxy->pop(1); + interpreterProxy->pushBool(ioCanWriteImage()); +} + +EXPORT(int) primitiveDisableImageWrite(void) { + ioDisableImageWrite(); + if (!(interpreterProxy->failed())) { + interpreterProxy->pop(1); + } +} + + +/* Primitive. Return the secure directory for the current user. */ + +EXPORT(int) primitiveGetSecureUserDirectory(void) { + char * dirName; + int dirLen; + char * dirPtr; + int i; + int dirOop; + + dirName = ioGetSecureUserDirectory(); + if ((dirName == null) || (interpreterProxy->failed())) { + return interpreterProxy->primitiveFail(); + } + dirLen = strlen(dirName); + dirOop = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classString(), dirLen); + if (interpreterProxy->failed()) { + return null; + } + dirPtr = interpreterProxy->firstIndexableField(dirOop); + for (i = 0; i <= (dirLen - 1); i += 1) { + dirPtr[i] = (dirName[i]); + } + interpreterProxy->pop(1); + interpreterProxy->push(dirOop); +} + + +/* Primitive. Return the untrusted user directory name. */ + +EXPORT(int) primitiveGetUntrustedUserDirectory(void) { + char * dirName; + int dirLen; + char * dirPtr; + int i; + int dirOop; + + dirName = ioGetUntrustedUserDirectory(); + if ((dirName == null) || (interpreterProxy->failed())) { + return interpreterProxy->primitiveFail(); + } + dirLen = strlen(dirName); + dirOop = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classString(), dirLen); + if (interpreterProxy->failed()) { + return null; + } + dirPtr = interpreterProxy->firstIndexableField(dirOop); + for (i = 0; i <= (dirLen - 1); i += 1) { + dirPtr[i] = (dirName[i]); + } + interpreterProxy->pop(1); + interpreterProxy->push(dirOop); +} + +EXPORT(int) secCanListenOnPort(int socket, int port) { + return ioCanListenOnPort(socket, port); +} + +EXPORT(int) secCanConnectToPort(int addr, int port) { + return ioCanConnectToPort(addr, port); +} + +EXPORT(int) secCanCreateSocketOfType(int netType, int socketType) { + return ioCanCreateSocketOfType(netType, socketType); +} + +EXPORT(int) secCanCreatePathOfSize(char * dirName, int dirNameSize) { + return ioCanCreatePathOfSize(dirName, dirNameSize); +} + +EXPORT(int) secCanDeleteFileOfSize(char * fileName, int fileNameSize) { + return ioCanDeleteFileOfSize(fileName, fileNameSize); +} + +EXPORT(int) secCanDeletePathOfSize(char * dirName, int dirNameSize) { + return ioCanDeletePathOfSize(dirName, dirNameSize); +} + +EXPORT(int) secCanGetFileTypeOfSize(char * fileName, int fileNameSize) { + return ioCanGetFileTypeOfSize(fileName, fileNameSize); +} + +EXPORT(int) secCanListPathOfSize(char * pathName, int pathNameSize) { + return ioCanListPathOfSize(pathName, pathNameSize); +} + +EXPORT(int) secCanOpenAsyncFileOfSizeWritable(char * fileName, int fileNameSize, int writeFlag) { + return ioCanOpenAsyncFileOfSizeWritable(fileName, fileNameSize, writeFlag); +} + +EXPORT(int) secCanOpenFileOfSizeWritable(char * fileName, int fileNameSize, int writeFlag) { + return ioCanOpenFileOfSizeWritable(fileName, fileNameSize, writeFlag); +} + +EXPORT(int) secCanRenameFileOfSize(char * fileName, int fileNameSize) { + return ioCanRenameFileOfSize(fileName, fileNameSize); +} + +EXPORT(int) secCanRenameImage(void) { + return ioCanRenameImage(); +} + +EXPORT(int) secCanSetFileTypeOfSize(char * fileName, int fileNameSize) { + return ioCanSetFileTypeOfSize(fileName, fileNameSize); +} + +EXPORT(int) secCanWriteImage(void) { + return ioCanWriteImage(); +} + +EXPORT(int) secDisableFileAccess(void) { + return ioDisableFileAccess(); +} + +EXPORT(int) secDisableSocketAccess(void) { + return ioDisableSocketAccess(); +} + +EXPORT(int) secHasFileAccess(void) { + return ioHasFileAccess(); +} + +EXPORT(int) secHasSocketAccess(void) { + return ioHasSocketAccess(); +} + + +/* Note: This is coded so that is can be run from Squeak. */ + +EXPORT(int) setInterpreter(struct VirtualMachine* anInterpreter) { + int ok; + + interpreterProxy = anInterpreter; + ok = interpreterProxy->majorVersion() == VM_PROXY_MAJOR; + if (ok == 0) { + return 0; + } + ok = interpreterProxy->minorVersion() >= VM_PROXY_MINOR; + return ok; +} + + +#ifdef SQUEAK_BUILTIN_PLUGIN + + +void* SecurityPlugin_exports[][3] = { + {"SecurityPlugin", "secCanSetFileTypeOfSize", (void*)secCanSetFileTypeOfSize}, + {"SecurityPlugin", "secCanCreateSocketOfType", (void*)secCanCreateSocketOfType}, + {"SecurityPlugin", "secHasSocketAccess", (void*)secHasSocketAccess}, + {"SecurityPlugin", "secCanWriteImage", (void*)secCanWriteImage}, + {"SecurityPlugin", "secCanGetFileTypeOfSize", (void*)secCanGetFileTypeOfSize}, + {"SecurityPlugin", "initialiseModule", (void*)initialiseModule}, + {"SecurityPlugin", "secCanListPathOfSize", (void*)secCanListPathOfSize}, + {"SecurityPlugin", "getModuleName", (void*)getModuleName}, + {"SecurityPlugin", "secCanRenameFileOfSize", (void*)secCanRenameFileOfSize}, + {"SecurityPlugin", "setInterpreter", (void*)setInterpreter}, + {"SecurityPlugin", "secCanListenOnPort", (void*)secCanListenOnPort}, + {"SecurityPlugin", "secCanRenameImage", (void*)secCanRenameImage}, + {"SecurityPlugin", "secHasFileAccess", (void*)secHasFileAccess}, + {"SecurityPlugin", "secCanConnectToPort", (void*)secCanConnectToPort}, + {"SecurityPlugin", "primitiveDisableImageWrite", (void*)primitiveDisableImageWrite}, + {"SecurityPlugin", "secCanCreatePathOfSize", (void*)secCanCreatePathOfSize}, + {"SecurityPlugin", "secDisableFileAccess", (void*)secDisableFileAccess}, + {"SecurityPlugin", "secDisableSocketAccess", (void*)secDisableSocketAccess}, + {"SecurityPlugin", "secCanOpenFileOfSizeWritable", (void*)secCanOpenFileOfSizeWritable}, + {"SecurityPlugin", "primitiveCanWriteImage", (void*)primitiveCanWriteImage}, + {"SecurityPlugin", "primitiveGetUntrustedUserDirectory", (void*)primitiveGetUntrustedUserDirectory}, + {"SecurityPlugin", "primitiveGetSecureUserDirectory", (void*)primitiveGetSecureUserDirectory}, + {"SecurityPlugin", "secCanDeletePathOfSize", (void*)secCanDeletePathOfSize}, + {"SecurityPlugin", "secCanDeleteFileOfSize", (void*)secCanDeleteFileOfSize}, + {"SecurityPlugin", "secCanOpenAsyncFileOfSizeWritable", (void*)secCanOpenAsyncFileOfSizeWritable}, + {NULL, NULL, NULL} +}; + + +#endif /* ifdef SQ_BUILTIN_PLUGIN */ + diff --git a/squeak/SecurityPlugin.h b/squeak/SecurityPlugin.h new file mode 100644 index 0000000..81df570 --- /dev/null +++ b/squeak/SecurityPlugin.h @@ -0,0 +1,31 @@ +/* security plugin header file */ + +/* image writing */ +int ioDisableImageWrite(void); +int ioCanWriteImage(void); + +/* untrusted and secure directory locations */ +char *ioGetSecureUserDirectory(void); +char *ioGetUntrustedUserDirectory(void); + +/* following must be called by the VM before interpret() */ +int ioInitSecurity(void); +int ioCanListenOnPort(int s, int port); +int ioCanConnectToPort(int netAddr, int port); +int ioCanCreateSocketOfType(int netType, int socketType); +int ioCanCreateSocketOfType(int netType, int socketType); +int ioCanConnectToPort(int netAddr, int port); +int ioDisableSocketAccess(); +int ioHasSocketAccess(); +int ioCanCreatePathOfSize(char* pathString, int pathStringLength); +int ioCanDeleteFileOfSize(char* pathString, int pathStringLength); +int ioCanDeletePathOfSize(char* pathString, int pathStringLength); +int ioCanGetFileTypeOfSize(char* pathString, int pathStringLength); +int ioCanListPathOfSize(char* pathString, int pathStringLength); +int ioCanOpenAsyncFileOfSizeWritable(char* pathString, int pathStringLength, int writeFlag); +int ioCanOpenFileOfSizeWritable(char* pathString, int pathStringLength, int writeFlag); +int ioCanRenameFileOfSize(char* pathString, int pathStringLength); +int ioCanRenameImage(void); +int ioCanSetFileTypeOfSize(char* pathString, int pathStringLength); +int ioDisableFileAccess(void); +int ioHasFileAccess(void); diff --git a/squeak/interp.c b/squeak/interp.c index 8eba97a..7661c28 100644 --- a/squeak/interp.c +++ b/squeak/interp.c @@ -1,4 +1,4 @@ -/* Automatically generated from Squeak on (18 October 1999 5:00:14 pm ) */ +/* Automatically generated from Squeak on #(4 March 2003 4:22:28 am) */ #include "sq.h" @@ -20,164 +20,854 @@ void error(char *s) { printingStack = true; printCallStack(); } - //exit(-1); +// exit(-1); ioExit(); } /*** Variables ***/ int activeContext; -int *aetBuffer; -int affectedB; -int affectedL; -int affectedR; -int affectedT; int allocationCount; int allocationsBetweenGCs; int argumentCount; int atCache[65]; -int bbH; -int bbW; -int bitBltOop; -int bitCount; int child; -int clipHeight; -int clipWidth; -int clipX; -int clipY; -int cmBitsPerColor; -int colorMap; -int combinationRule; int compEnd; int compStart; -int (*compilerHooks[11])(); +int (*compilerHooks[16])(); int compilerInitialized; int deferDisplayUpdates; -int destBits; -int destDelta; -int destForm; -int destIndex; -int destMask; -int destPixSize; -int destRaster; -int destX; -int destY; -int dispatchReturnValue; -int dispatchedValue; int displayBits; -const int ditherMatrix4x4[16] = { -0, 8, 2, 10, -12, 4, 14, 6, -3, 11, 1, 9, -15, 7, 13, 5 -}; -const int ditherThresholds16[8] = { 0, 2, 4, 6, 8, 12, 14, 16 }; -const int ditherValues16[32] = { -0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, -15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 -}; -int doProfileStats = 0; -int dx; -int dy; int endOfMemory; -int engine; -int engineStopped; +int externalPrimitiveTable[4097]; int extraVMMemory; int falseObj; -int fftSize; int field; -int formArray; int freeBlock; int freeContexts; +int freeLargeContexts; int fullScreenFlag; int fwdTableLast; int fwdTableNext; -int geProfileTime; -int *getBuffer; -int hDir; -int halftoneBase; -int halftoneForm; -int halftoneHeight; -int height; -float *imagData; -int imagDataSize; +int growHeadroom; int instructionPointer; -int interpreterProxy; +struct VirtualMachine* interpreterProxy; +const char *interpreterVersion = "Squeak3.4 of 1 March 2003 [latest update: #5170]"; int interruptCheckCounter; +int interruptCheckCounterFeedBackReset; +int interruptChecksEveryNms; int interruptKeycode; int interruptPending; int lastHash; int lastTick; int lkupClass; int lowSpaceThreshold; -double m23ArgX; -double m23ArgY; -double m23ResultX; -double m23ResultY; -int mask1; -int mask2; -int maskTable[33] = { -0, 1, 3, 0, 15, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 65535, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1 -}; -unsigned char *memory; +unsigned char* memory; int memoryLimit; int messageSelector; int method; -int methodCache[2049]; -int nWords; +int methodCache[4097]; +int methodClass; int newMethod; +int newNativeMethod; int nextPollTick; int nextWakeupTick; int nilObj; -int noHalftone; -int noSource; -int nu; -int *objBuffer; -int objUsed; -int opTable[36]; +char* obsoleteIndexedPrimitiveTable[][3] = { +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ "BitBltPlugin", "primitiveCopyBits", NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ "BitBltPlugin", "primitiveDrawLoop", NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ "JoystickTabletPlugin", "primitiveReadJoystick", NULL }, +{ "BitBltPlugin", "primitiveWarpBits", NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ "FilePlugin", "primitiveFileAtEnd", NULL }, +{ "FilePlugin", "primitiveFileClose", NULL }, +{ "FilePlugin", "primitiveFileGetPosition", NULL }, +{ "FilePlugin", "primitiveFileOpen", NULL }, +{ "FilePlugin", "primitiveFileRead", NULL }, +{ "FilePlugin", "primitiveFileSetPosition", NULL }, +{ "FilePlugin", "primitiveFileDelete", NULL }, +{ "FilePlugin", "primitiveFileSize", NULL }, +{ "FilePlugin", "primitiveFileWrite", NULL }, +{ "FilePlugin", "primitiveFileRename", NULL }, +{ "FilePlugin", "primitiveDirectoryCreate", NULL }, +{ "FilePlugin", "primitiveDirectoryDelimitor", NULL }, +{ "FilePlugin", "primitiveDirectoryLookup", NULL }, +{ "FilePlugin", "primitiveDirectoryDelete", NULL }, +{ "FilePlugin", "primitiveDirectoryGetMacTypeAndCreator", NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ "FilePlugin", "primitiveDirectorySetMacTypeAndCreator", NULL }, +{ "SoundPlugin", "primitiveSoundStart", NULL }, +{ "SoundPlugin", "primitiveSoundStartWithSemaphore", NULL }, +{ "SoundPlugin", "primitiveSoundStop", NULL }, +{ "SoundPlugin", "primitiveSoundAvailableSpace", NULL }, +{ "SoundPlugin", "primitiveSoundPlaySamples", NULL }, +{ "SoundPlugin", "primitiveSoundPlaySilence", NULL }, +{ "SoundGenerationPlugin", "primitiveWaveTableSoundMix", NULL }, +{ "SoundGenerationPlugin", "primitiveFMSoundMix", NULL }, +{ "SoundGenerationPlugin", "primitivePluckedSoundMix", NULL }, +{ "SoundGenerationPlugin", "primitiveSampledSoundMix", NULL }, +{ "SoundGenerationPlugin", "primitiveMixFMSound", NULL }, +{ "SoundGenerationPlugin", "primitiveMixPluckedSound", NULL }, +{ "SoundGenerationPlugin", "primitiveOldSampledSoundMix", NULL }, +{ "SoundGenerationPlugin", "primitiveApplyReverb", NULL }, +{ "SoundGenerationPlugin", "primitiveMixLoopedSampledSound", NULL }, +{ "SoundGenerationPlugin", "primitiveMixSampledSound", NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ "SoundPlugin", "primitiveSoundInsertSamples", NULL }, +{ "SoundPlugin", "primitiveSoundStartRecording", NULL }, +{ "SoundPlugin", "primitiveSoundStopRecording", NULL }, +{ "SoundPlugin", "primitiveSoundGetRecordingSampleRate", NULL }, +{ "SoundPlugin", "primitiveSoundRecordSamples", NULL }, +{ "SoundPlugin", "primitiveSoundSetRecordLevel", NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ "SocketPlugin", "primitiveInitializeNetwork", NULL }, +{ "SocketPlugin", "primitiveResolverStartNameLookup", NULL }, +{ "SocketPlugin", "primitiveResolverNameLookupResult", NULL }, +{ "SocketPlugin", "primitiveResolverStartAddressLookup", NULL }, +{ "SocketPlugin", "primitiveResolverAddressLookupResult", NULL }, +{ "SocketPlugin", "primitiveResolverAbortLookup", NULL }, +{ "SocketPlugin", "primitiveResolverLocalAddress", NULL }, +{ "SocketPlugin", "primitiveResolverStatus", NULL }, +{ "SocketPlugin", "primitiveResolverError", NULL }, +{ "SocketPlugin", "primitiveSocketCreate", NULL }, +{ "SocketPlugin", "primitiveSocketDestroy", NULL }, +{ "SocketPlugin", "primitiveSocketConnectionStatus", NULL }, +{ "SocketPlugin", "primitiveSocketError", NULL }, +{ "SocketPlugin", "primitiveSocketLocalAddress", NULL }, +{ "SocketPlugin", "primitiveSocketLocalPort", NULL }, +{ "SocketPlugin", "primitiveSocketRemoteAddress", NULL }, +{ "SocketPlugin", "primitiveSocketRemotePort", NULL }, +{ "SocketPlugin", "primitiveSocketConnectToPort", NULL }, +{ "SocketPlugin", "primitiveSocketListenWithOrWithoutBacklog", NULL }, +{ "SocketPlugin", "primitiveSocketCloseConnection", NULL }, +{ "SocketPlugin", "primitiveSocketAbortConnection", NULL }, +{ "SocketPlugin", "primitiveSocketReceiveDataBufCount", NULL }, +{ "SocketPlugin", "primitiveSocketReceiveDataAvailable", NULL }, +{ "SocketPlugin", "primitiveSocketSendDataBufCount", NULL }, +{ "SocketPlugin", "primitiveSocketSendDone", NULL }, +{ "SocketPlugin", "primitiveSocketAccept", NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ "MiscPrimitivePlugin", "primitiveDecompressFromByteArray", NULL }, +{ "MiscPrimitivePlugin", "primitiveCompareString", NULL }, +{ "MiscPrimitivePlugin", "primitiveConvert8BitSigned", NULL }, +{ "MiscPrimitivePlugin", "primitiveCompressToByteArray", NULL }, +{ "SerialPlugin", "primitiveSerialPortOpen", NULL }, +{ "SerialPlugin", "primitiveSerialPortClose", NULL }, +{ "SerialPlugin", "primitiveSerialPortWrite", NULL }, +{ "SerialPlugin", "primitiveSerialPortRead", NULL }, +{ NULL, NULL, NULL }, +{ "MiscPrimitivePlugin", "primitiveTranslateStringWithTable", NULL }, +{ "MiscPrimitivePlugin", "primitiveFindFirstInString", NULL }, +{ "MiscPrimitivePlugin", "primitiveIndexOfAsciiInString", NULL }, +{ "MiscPrimitivePlugin", "primitiveFindSubstring", NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ "MIDIPlugin", "primitiveMIDIClosePort", NULL }, +{ "MIDIPlugin", "primitiveMIDIGetClock", NULL }, +{ "MIDIPlugin", "primitiveMIDIGetPortCount", NULL }, +{ "MIDIPlugin", "primitiveMIDIGetPortDirectionality", NULL }, +{ "MIDIPlugin", "primitiveMIDIGetPortName", NULL }, +{ "MIDIPlugin", "primitiveMIDIOpenPort", NULL }, +{ "MIDIPlugin", "primitiveMIDIParameterGetOrSet", NULL }, +{ "MIDIPlugin", "primitiveMIDIRead", NULL }, +{ "MIDIPlugin", "primitiveMIDIWrite", NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ "AsynchFilePlugin", "primitiveAsyncFileClose", NULL }, +{ "AsynchFilePlugin", "primitiveAsyncFileOpen", NULL }, +{ "AsynchFilePlugin", "primitiveAsyncFileReadResult", NULL }, +{ "AsynchFilePlugin", "primitiveAsyncFileReadStart", NULL }, +{ "AsynchFilePlugin", "primitiveAsyncFileWriteResult", NULL }, +{ "AsynchFilePlugin", "primitiveAsyncFileWriteStart", NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ "JoystickTabletPlugin", "primitiveGetTabletParameters", NULL }, +{ "JoystickTabletPlugin", "primitiveReadTablet", NULL }, +{ "ADPCMCodecPlugin", "primitiveDecodeMono", NULL }, +{ "ADPCMCodecPlugin", "primitiveDecodeStereo", NULL }, +{ "ADPCMCodecPlugin", "primitiveEncodeMono", NULL }, +{ "ADPCMCodecPlugin", "primitiveEncodeStereo", NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL }, +{ NULL, NULL, NULL } +}; +const char* obsoleteNamedPrimitiveTable[][3] = { +{ "gePrimitiveMergeFillFrom", "B2DPlugin", "primitiveMergeFillFrom" }, +{ "gePrimitiveSetClipRect", "B2DPlugin", "primitiveSetClipRect" }, +{ "gePrimitiveDoProfileStats", "B2DPlugin", "primitiveDoProfileStats" }, +{ "gePrimitiveAddCompressedShape", "B2DPlugin", "primitiveAddCompressedShape" }, +{ "gePrimitiveFinishedProcessing", "B2DPlugin", "primitiveFinishedProcessing" }, +{ "gePrimitiveGetBezierStats", "B2DPlugin", "primitiveGetBezierStats" }, +{ "gePrimitiveSetDepth", "B2DPlugin", "primitiveSetDepth" }, +{ "gePrimitiveAbortProcessing", "B2DPlugin", "primitiveAbortProcessing" }, +{ "gePrimitiveGetTimes", "B2DPlugin", "primitiveGetTimes" }, +{ "gePrimitiveNextActiveEdgeEntry", "B2DPlugin", "primitiveNextActiveEdgeEntry" }, +{ "gePrimitiveAddBezier", "B2DPlugin", "primitiveAddBezier" }, +{ "gePrimitiveRenderScanline", "B2DPlugin", "primitiveRenderScanline" }, +{ "gePrimitiveAddBezierShape", "B2DPlugin", "primitiveAddBezierShape" }, +{ "gePrimitiveAddLine", "B2DPlugin", "primitiveAddLine" }, +{ "gePrimitiveRenderImage", "B2DPlugin", "primitiveRenderImage" }, +{ "gePrimitiveGetAALevel", "B2DPlugin", "primitiveGetAALevel" }, +{ "gePrimitiveRegisterExternalEdge", "B2DPlugin", "primitiveRegisterExternalEdge" }, +{ "gePrimitiveInitializeBuffer", "B2DPlugin", "primitiveInitializeBuffer" }, +{ "gePrimitiveAddRect", "B2DPlugin", "primitiveAddRect" }, +{ "gePrimitiveInitializeProcessing", "B2DPlugin", "primitiveInitializeProcessing" }, +{ "gePrimitiveAddBitmapFill", "B2DPlugin", "primitiveAddBitmapFill" }, +{ "gePrimitiveGetClipRect", "B2DPlugin", "primitiveGetClipRect" }, +{ "gePrimitiveGetFailureReason", "B2DPlugin", "primitiveGetFailureReason" }, +{ "gePrimitiveNextGlobalEdgeEntry", "B2DPlugin", "primitiveNextGlobalEdgeEntry" }, +{ "gePrimitiveNextFillEntry", "B2DPlugin", "primitiveNextFillEntry" }, +{ "gePrimitiveSetColorTransform", "B2DPlugin", "primitiveSetColorTransform" }, +{ "gePrimitiveDisplaySpanBuffer", "B2DPlugin", "primitiveDisplaySpanBuffer" }, +{ "gePrimitiveGetOffset", "B2DPlugin", "primitiveGetOffset" }, +{ "gePrimitiveAddPolygon", "B2DPlugin", "primitiveAddPolygon" }, +{ "gePrimitiveNeedsFlush", "B2DPlugin", "primitiveNeedsFlush" }, +{ "gePrimitiveAddOval", "B2DPlugin", "primitiveAddOval" }, +{ "gePrimitiveSetAALevel", "B2DPlugin", "primitiveSetAALevel" }, +{ "gePrimitiveCopyBuffer", "B2DPlugin", "primitiveCopyBuffer" }, +{ "gePrimitiveAddActiveEdgeEntry", "B2DPlugin", "primitiveAddActiveEdgeEntry" }, +{ "gePrimitiveGetCounts", "B2DPlugin", "primitiveGetCounts" }, +{ "gePrimitiveSetOffset", "B2DPlugin", "primitiveSetOffset" }, +{ "gePrimitiveAddGradientFill", "B2DPlugin", "primitiveAddGradientFill" }, +{ "gePrimitiveChangedActiveEdgeEntry", "B2DPlugin", "primitiveChangedActiveEdgeEntry" }, +{ "gePrimitiveRegisterExternalFill", "B2DPlugin", "primitiveRegisterExternalFill" }, +{ "gePrimitiveGetDepth", "B2DPlugin", "primitiveGetDepth" }, +{ "gePrimitiveSetEdgeTransform", "B2DPlugin", "primitiveSetEdgeTransform" }, +{ "gePrimitiveNeedsFlushPut", "B2DPlugin", "primitiveNeedsFlushPut" }, +{ "primitiveFloatArrayAt", "FloatArrayPlugin", "primitiveAt" }, +{ "primitiveFloatArrayMulFloatArray", "FloatArrayPlugin", "primitiveMulFloatArray" }, +{ "primitiveFloatArrayAddScalar", "FloatArrayPlugin", "primitiveAddScalar" }, +{ "primitiveFloatArrayDivFloatArray", "FloatArrayPlugin", "primitiveDivFloatArray" }, +{ "primitiveFloatArrayDivScalar", "FloatArrayPlugin", "primitiveDivScalar" }, +{ "primitiveFloatArrayHash", "FloatArrayPlugin", "primitiveHashArray" }, +{ "primitiveFloatArrayAtPut", "FloatArrayPlugin", "primitiveAtPut" }, +{ "primitiveFloatArrayMulScalar", "FloatArrayPlugin", "primitiveMulScalar" }, +{ "primitiveFloatArrayAddFloatArray", "FloatArrayPlugin", "primitiveAddFloatArray" }, +{ "primitiveFloatArraySubScalar", "FloatArrayPlugin", "primitiveSubScalar" }, +{ "primitiveFloatArraySubFloatArray", "FloatArrayPlugin", "primitiveSubFloatArray" }, +{ "primitiveFloatArrayEqual", "FloatArrayPlugin", "primitiveEqual" }, +{ "primitiveFloatArrayDotProduct", "FloatArrayPlugin", "primitiveDotProduct" }, +{ "m23PrimitiveInvertRectInto", "Matrix2x3Plugin", "primitiveInvertRectInto" }, +{ "m23PrimitiveTransformPoint", "Matrix2x3Plugin", "primitiveTransformPoint" }, +{ "m23PrimitiveIsPureTranslation", "Matrix2x3Plugin", "primitiveIsPureTranslation" }, +{ "m23PrimitiveComposeMatrix", "Matrix2x3Plugin", "primitiveComposeMatrix" }, +{ "m23PrimitiveTransformRectInto", "Matrix2x3Plugin", "primitiveTransformRectInto" }, +{ "m23PrimitiveIsIdentity", "Matrix2x3Plugin", "primitiveIsIdentity" }, +{ "m23PrimitiveInvertPoint", "Matrix2x3Plugin", "primitiveInvertPoint" }, +{ "primitiveDeflateBlock", "ZipPlugin", "primitiveDeflateBlock" }, +{ "primitiveDeflateUpdateHashTable", "ZipPlugin", "primitiveDeflateUpdateHashTable" }, +{ "primitiveUpdateGZipCrc32", "ZipPlugin", "primitiveUpdateGZipCrc32" }, +{ "primitiveInflateDecompressBlock", "ZipPlugin", "primitiveInflateDecompressBlock" }, +{ "primitiveZipSendBlock", "ZipPlugin", "primitiveZipSendBlock" }, +{ "primitiveFFTTransformData", "FFTPlugin", "primitiveFFTTransformData" }, +{ "primitiveFFTScaleData", "FFTPlugin", "primitiveFFTScaleData" }, +{ "primitiveFFTPermuteData", "FFTPlugin", "primitiveFFTPermuteData" }, +{ NULL, NULL, NULL } +}; int parentField; int pendingFinalizationSignals; -unsigned int *permTable; -int permTableSize; -int pixPerWord; -int preload; int primitiveIndex; -float *realData; -int realDataSize; int receiver; +int receiverClass; int reclaimableContextCount; int remapBuffer[26]; int remapBufferCount; int rootTable[2501]; int rootTableCount; int savedWindowSize; -int scanDisplayFlag; -int scanRightX; -int scanStart; -int scanStop; -int scanStopArray; -int scanString; -int scanXTable; -int semaphoresToSignal[26]; -int semaphoresToSignalCount; +int semaphoresToSignalA[501]; +int semaphoresToSignalB[501]; +int semaphoresToSignalCountA; +int semaphoresToSignalCountB; +int semaphoresUseBufferA; +int showSurfaceFn; +int shrinkThreshold; int signalLowSpace; -float *sinTable; -int sinTableSize; -int skew; -int sourceAlpha; -int sourceBits; -int sourceDelta; -int sourceForm; -int sourceIndex; -int sourcePixSize; -int sourceRaster; -int sourceX; -int sourceY; -unsigned int *spanBuffer; int specialObjectsOop; -int srcBitIndex; -int srcHeight; -int srcWidth; int stackPointer; int statFullGCMSecs; int statFullGCs; @@ -185,99 +875,60 @@ int statIncrGCMSecs; int statIncrGCs; int statRootTableOverflows; int statTenures; -int stopCode; int successFlag; -int sx; -int sy; int tenuringThreshold; int theHomeContext; +int totalObjectCount; int trueObj; -int vDir; -int width; -int *workBuffer; int youngStart; /*** Function Prototypes ***/ -int OLDrgbDiffwith(int sourceWord, int destinationWord); -int OLDtallyIntoMapwith(int sourceWord, int destinationWord); int accessibleObjectAfter(int oop); -int accurateLengthOfwith(int deltaX, int deltaY); -int addEdgeToGET(int edge); -int addToMethodCacheSelclassmethodprimIndex(int selector, int class, int meth, int primIndex); -int addWordwith(int sourceWord, int destinationWord); -int adjustWideBezierLeftwidthoffsetendX(int bezier, int lineWidth, int lineOffset, int endX); -int adjustWideBezierRightwidthoffsetendX(int bezier, int lineWidth, int lineOffset, int endX); -int adjustWideLineafterSteppingFromto(int line, int lastX, int nextX); +int addNewMethodToCache(void); int allYoungand(int array1, int array2); -int allocateBitmapFillcolormap(int cmSize, int *cmBits); -int allocateGETEntry(int nSlots); -int allocateGradientFillrampWidthisRadial(int *ramp, int rampWidth, int isRadial); -int allocateObjEntry(int nSlots); -int alphaBlendwith(int sourceWord, int destinationWord); -int alphaBlendConstwith(int sourceWord, int destinationWord); -int alphaBlendConstwithpaintMode(int sourceWord, int destinationWord, int paintMode); -int alphaBlendScaledwith(int sourceWord, int destinationWord); -int alphaPaintConstwith(int sourceWord, int destinationWord); -int alphaSourceBlendBits16(void); -int alphaSourceBlendBits32(void); -int alphaSourceBlendBits8(void); +int allocateChunk(int byteSize); +int allocateOrRecycleContext(int needsLarge); int argumentCountOf(int methodPointer); void * arrayValueOf(int arrayOop); -int asciiDirectoryDelimiter(void); int asciiOfCharacter(int characterObj); -AsyncFile * asyncFileValueOf(int oop); +int balancedStackafterPrimitivewithArgs(int delta, int primIdx, int nArgs); int beRootIfOld(int oop); int becomewith(int array1, int array2); int becomewithtwoWay(int array1, int array2, int twoWayFlag); -int bitAndwith(int sourceWord, int destinationWord); -int bitAndInvertwith(int sourceWord, int destinationWord); -int bitInvertAndwith(int sourceWord, int destinationWord); -int bitInvertAndInvertwith(int sourceWord, int destinationWord); -int bitInvertDestinationwith(int sourceWord, int destinationWord); -int bitInvertOrwith(int sourceWord, int destinationWord); -int bitInvertOrInvertwith(int sourceWord, int destinationWord); -int bitInvertSourcewith(int sourceWord, int destinationWord); -int bitInvertXorwith(int sourceWord, int destinationWord); -int bitOrwith(int sourceWord, int destinationWord); -int bitOrInvertwith(int sourceWord, int destinationWord); -int bitXorwith(int sourceWord, int destinationWord); int booleanValueOf(int obj); -int byteLengthOf(int oop); int byteSizeOf(int oop); +int byteSwapByteObjectsFromto(int startOop, int stopAddr); int byteSwapped(int w); -int bytecodeActivateNewMethod(void); +int characterForAscii(int ascii); int characterTable(void); -int checkCompressedFillIndexListmaxsegments(int fillList, int maxIndex, int nSegs); -int checkCompressedFills(int indexList); -int checkCompressedLineWidthssegments(int lineWidthList, int nSegments); -int checkCompressedPointssegments(int points, int nSegments); -int checkCompressedShapesegmentsleftFillsrightFillslineWidthslineFillsfillIndexList(int points, int nSegments, int leftFills, int rightFills, int lineWidths, int lineFills, int fillIndexList); int checkForInterrupts(void); -int checkImageVersionFromstartingAt(sqImageFile f, int imageOffset); +int checkImageVersionFromstartingAt(sqImageFile f, squeakFileOffsetType imageOffset); int checkedIntegerValueOf(int intOop); int checkedLongAt(int byteAddress); -double * circleCosTable(void); -double * circleSinTable(void); int classArray(void); int classBitmap(void); int classByteArray(void); int classCharacter(void); +int classExternalAddress(void); +int classExternalData(void); +int classExternalFunction(void); +int classExternalLibrary(void); +int classExternalStructure(void); int classFloat(void); +int classLargeNegativeInteger(void); int classLargePositiveInteger(void); int classNameOfIs(int aClass, char *className); int classPoint(void); int classSemaphore(void); int classSmallInteger(void); int classString(void); -int clearSpanBuffer(void); -int clearWordwith(int source, int destination); -int clipRange(void); +int cleanUpContexts(void); int clone(int oop); int commonAt(int stringy); int commonAtPut(int stringy); int commonVariableatcacheIndex(int rcvr, int index, int atIx); int compare31or32Bitsequal(int obj1, int obj2); -int compilerActivateMethod(void); +int compilerCreateActualMessagestoringArgs(int aMessage, int argArray); int compilerFlushCache(int aCompiledMethod); int compilerMapFromto(int memStart, int memEnd); int compilerMark(void); @@ -286,27 +937,18 @@ int compilerPostSnapshot(void); int compilerPreGC(int fullGCFlag); int compilerPreSnapshot(void); int compilerProcessChange(void); -int computeBeziersplitAt(int index, double param); -int computeBezierSplitAtHalf(int index); -int computeFinalWideBezierValueswidth(int bezier, int lineWidth); +int compilerProcessChangeto(int oldProc, int newProc); +int compilerTranslateMethod(void); int containOnlyOopsand(int array1, int array2); +int contexthasSender(int thisCntx, int aContext); int copyBits(void); -int copyBitsFromtoat(int startX, int stopX, int yValue); -int copyLoop(void); -int copyLoopNoSource(void); -int copyLoopPixMap(void); +int copyBitsFromtoat(int x0, int x1, int y); int copyObjtoSegmentaddrstopAtsaveOopAtheaderAt(int oop, int segmentWordArray, int lastSeg, int stopAddr, int oopPtr, int hdrPtr); int createActualMessageTo(int aClass); -int createGlobalEdgeTable(void); -unsigned int * default8To32Table(void); -int deltaFromtonSteps(int x1, int x2, int n); -int destMaskAndPointerInit(void); -int destinationWordwith(int sourceWord, int destinationWord); +int displayBitsOfLeftTopRightBottom(int aForm, int l, int t, int r, int b); int displayObject(void); -int displaySpanBufferAt(int y); int doPrimitiveDivby(int rcvr, int arg); int doPrimitiveModby(int rcvr, int arg); -int errorWrongIndex(void); int extraHeaderBytes(int oopOrChunk); int failed(void); int falseObject(void); @@ -315,102 +957,37 @@ int fetchClassOf(int oop); int fetchClassOfNonInt(int oop); double fetchFloatofObject(int fieldIndex, int objectPointer); int fetchIntegerofObject(int fieldIndex, int objectPointer); -int fetchIntegerOrTruncFloatofObject(int fieldIndex, int objectPointer); int fetchPointerofObject(int fieldIndex, int oop); int fetchStackPointerOf(int aContext); int fetchWordofObject(int fieldIndex, int oop); -int fetchWordLengthOf(int objectPointer); -int fileRecordSize(void); -SQFile * fileValueOf(int objectPointer); -int fillBitmapSpanfromto(int *bits, int leftX, int rightX); -int fillBitmapSpanfromtoat(int bmFill, int leftX, int rightX, int yValue); -int fillBitmapSpanAAfromtoat(int bmFill, int leftX, int rightX, int yValue); -int fillColorSpanAAx0x1(int pixelValue32, int leftX, int rightX); -int fillLinearGradientfromtoat(int fill, int leftX, int rightX, int yValue); -int fillLinearGradientAArampdsdsXfromto(int fill, int *ramp, int deltaS, int dsX, int leftX, int rightX); -int fillRadialDecreasingAArampdeltaSTdsXdtXfromto(int fill, int *ramp, int *deltaST, int dsX, int dtX, int leftX, int rightX); -int fillRadialGradientfromtoat(int fill, int leftX, int rightX, int yValue); -int fillRadialIncreasingAArampdeltaSTdsXdtXfromto(int fill, int *ramp, int *deltaST, int dsX, int dtX, int leftX, int rightX); -int fillSortsbefore(int fillEntry1, int fillEntry2); -int fillSpanfromto(int fill, int leftX, int rightX); int finalizeReference(int oop); +int findClassOfMethodforReceiver(int meth, int rcvr); int findNewMethodInClass(int class); -int findNextExternalEntryFromGET(void); -int findNextExternalFillFromAET(void); -int findNextExternalUpdateFromAET(void); -int findStackFilldepth(int fillIndex, int depth); +int findObsoleteNamedPrimitivelength(char * functionName, int functionLength); +int findSelectorOfMethodforReceiver(int meth, int rcvr); +int firstAccessibleObject(void); void * firstFixedField(int oop); void * firstIndexableField(int oop); int floatObjectOf(double aFloat); double floatValueOf(int oop); +int flushExternalPrimitives(void); int fullDisplayUpdate(void); int fullGC(void); int fwdTableInit(int blkSize); -#pragma export on -EXPORT(int) gePrimitiveAbortProcessing(void); -EXPORT(int) gePrimitiveAddActiveEdgeEntry(void); -EXPORT(int) gePrimitiveAddBezier(void); -EXPORT(int) gePrimitiveAddBezierShape(void); -EXPORT(int) gePrimitiveAddBitmapFill(void); -EXPORT(int) gePrimitiveAddCompressedShape(void); -EXPORT(int) gePrimitiveAddGradientFill(void); -EXPORT(int) gePrimitiveAddLine(void); -EXPORT(int) gePrimitiveAddOval(void); -EXPORT(int) gePrimitiveAddPolygon(void); -EXPORT(int) gePrimitiveAddRect(void); -EXPORT(int) gePrimitiveChangedActiveEdgeEntry(void); -EXPORT(int) gePrimitiveCopyBuffer(void); -EXPORT(int) gePrimitiveDisplaySpanBuffer(void); -EXPORT(int) gePrimitiveDoProfileStats(void); -EXPORT(int) gePrimitiveFinishedProcessing(void); -EXPORT(int) gePrimitiveGetAALevel(void); -EXPORT(int) gePrimitiveGetBezierStats(void); -EXPORT(int) gePrimitiveGetClipRect(void); -EXPORT(int) gePrimitiveGetCounts(void); -EXPORT(int) gePrimitiveGetDepth(void); -EXPORT(int) gePrimitiveGetFailureReason(void); -EXPORT(int) gePrimitiveGetOffset(void); -EXPORT(int) gePrimitiveGetTimes(void); -EXPORT(int) gePrimitiveInitializeBuffer(void); -EXPORT(int) gePrimitiveInitializeProcessing(void); -EXPORT(int) gePrimitiveMergeFillFrom(void); -EXPORT(int) gePrimitiveNeedsFlush(void); -EXPORT(int) gePrimitiveNeedsFlushPut(void); -EXPORT(int) gePrimitiveNextActiveEdgeEntry(void); -EXPORT(int) gePrimitiveNextFillEntry(void); -EXPORT(int) gePrimitiveNextGlobalEdgeEntry(void); -EXPORT(int) gePrimitiveRegisterExternalEdge(void); -EXPORT(int) gePrimitiveRegisterExternalFill(void); -EXPORT(int) gePrimitiveRenderImage(void); -EXPORT(int) gePrimitiveRenderScanline(void); -EXPORT(int) gePrimitiveSetAALevel(void); -EXPORT(int) gePrimitiveSetClipRect(void); -EXPORT(int) gePrimitiveSetColorTransform(void); -EXPORT(int) gePrimitiveSetDepth(void); -EXPORT(int) gePrimitiveSetEdgeTransform(void); -EXPORT(int) gePrimitiveSetOffset(void); -#pragma export off +int fwdTableSize(int blkSize); int getCurrentBytecode(void); int getLongFromFileswap(sqImageFile f, int swapFlag); -int getSortsbefore(int edge1, int edge2); -int hideFilldepth(int fillIndex, int depth); +int imageSegmentVersion(void); int incCompBody(void); +int includesBehaviorThatOf(int aClass, int aSuperclass); int incrementalGC(void); -int indexForInsertingIntoAET(int edge); -int initBBOpTable(void); -int initColorTransform(void); int initCompilerHooks(void); -int initEdgeTransform(void); -int initializeGETProcessing(void); int initializeMemoryFirstFree(int firstFree); int initializeObjectMemory(int bytesToShift); -int insertEdgeIntoAET(int edge); -int insertToAETbeforeIndex(int edge, int index); int installinAtCacheatstring(int rcvr, int *cache, int atIx, int stringy); int instantiateClassindexableSize(int classPointer, int size); int instantiateContextsizeInBytes(int classPointer, int sizeInBytes); int instantiateSmallClasssizeInBytesfill(int classPointer, int sizeInBytes, int fillValue); -int intToNetAddress(int addr); int integerObjectOf(int value); int integerValueOf(int objectPointer); int interpret(void); @@ -418,13 +995,14 @@ int isKindOf(int oop, char *className); int isMemberOf(int oop, char *className); int isBytes(int oop); int isContextHeader(int aHeader); -int isEdge(int edge); -int isFillOkay(int fill); int isFloatObject(int oop); +int isHandlerMarked(int aContext); +int isInMemory(int address); int isIndexable(int oop); int isIntegerObject(int objectPointer); int isIntegerValue(int intValue); int isPointers(int oop); +int isUnwindMarked(int aContext); int isWeak(int oop); int isWords(int oop); int isWordsOrBytes(int oop); @@ -432,64 +1010,24 @@ int lastPointerOf(int oop); int lengthOf(int oop); int literalofMethod(int offset, int methodPointer); int literalCountOf(int methodPointer); -int loadAndSubdivideBezierFromviatoisWide(int *point1, int *point2, int *point3, int wideFlag); -int loadArgumentPoint(int point); -int loadArrayShapenSegmentsfilllineWidthlineFill(int points, int nSegments, int fillIndex, int lineWidth, int lineFill); -int loadArrayTransformFromintolength(int transformOop, float *destPtr, int n); -int loadBeziersegmentleftFillrightFilloffset(int bezier, int index, int leftFillIndex, int rightFillIndex, int yOffset); -int loadBitBltFrom(int bbObj); -int loadBitmapFillcolormaptilefromalongnormalxIndex(int formOop, int cmOop, int tileFlag, int *point1, int *point2, int *point3, int xIndex); -int * loadBitsFrom(int bmFill); -int loadColorTransformFrom(int transformOop); -int loadCompressedShapesegmentsleftFillsrightFillslineWidthslineFillsfillIndexListpointShort(int *points, int nSegments, int *leftFills, int *rightFills, int *lineWidths, int *lineFills, int *fillIndexList, int pointsShort); -int loadEdgeStateFrom(int edgeOop); -int loadEdgeTransformFrom(int transformOop); -int loadFFTFrom(int fftOop); -int loadFillOrientationfromalongnormalwidthheight(int fill, int *point1, int *point2, int *point3, int fillWidth, int fillHeight); +int loadBitBltFrom(int bb); double loadFloatOrIntFrom(int floatOrInt); -int loadFormsFrom(int arrayOop); -int loadGradientFillfromalongnormalisRadial(int rampOop, int *point1, int *point2, int *point3, int isRadial); -int loadLinefromtooffsetleftFillrightFill(int line, int *point1, int *point2, int yOffset, int leftFill, int rightFill); -int loadOvallineFillleftFillrightFill(int lineWidth, int lineFill, int leftFill, int rightFill); -int loadOvalSegmentwhcxcy(int seg, int w, int h, int cx, int cy); -int loadPointfrom(int *pointArray, int pointOop); -int loadPolygonnPointsfilllineWidthlineFillpointsShort(int *points, int nPoints, int fillIndex, int lineWidth, int lineFill, int isShort); -int loadRenderingState(void); -int loadScannerFromstartstopstringrightXstopArraydisplayFlag(int bbObj, int start, int stop, int string, int rightX, int stopArray, int displayFlag); -int loadShapenSegmentsfilllineWidthlineFillpointsShort(int *points, int nSegments, int fillIndex, int lineWidth, int lineFill, int pointsShort); -int loadSpanBufferFrom(int spanOop); -int loadTransformFromintolength(int transformOop, float *destPtr, int n); -int loadWideBezierlineFillleftFillrightFilln(int lineWidth, int lineFill, int leftFill, int rightFill, int nSegments); -int loadWideLinefromtolineFillleftFillrightFill(int lineWidth, int *p1, int *p2, int lineFill, int leftFill, int rightFill); -int loadWordTransformFromintolength(int transformOop, float *destPtr, int n); -int loadWorkBufferFrom(int wbOop); +int loadInitialContext(void); int lookupMethodInClass(int class); int lowestFreeAfter(int chunk); -#pragma export on -EXPORT(int) m23PrimitiveComposeMatrix(void); -EXPORT(int) m23PrimitiveInvertPoint(void); -EXPORT(int) m23PrimitiveInvertRectInto(void); -EXPORT(int) m23PrimitiveIsIdentity(void); -EXPORT(int) m23PrimitiveIsPureTranslation(void); -EXPORT(int) m23PrimitiveTransformPoint(void); -EXPORT(int) m23PrimitiveTransformRectInto(void); -#pragma export off -int makeDirEntryNamesizecreateDatemodDateisDirfileSize(char *entryName, int entryNameSize, int createDate, int modifiedDate, int dirFlag, int fileSize); int makePointwithxValueyValue(int xValue, int yValue); int mapPointersInObjectsFromto(int memStart, int memEnd); int markAndTrace(int oop); +int markAndTraceInterpreterOops(void); int markPhase(void); -int matrix2x3ComposeMatrixwithinto(const float *m1, const float *m2, float *m3); -int matrix2x3InvertPoint(float *m); -int matrix2x3TransformPoint(float *m); -int mergewith(int sourceWord, int destinationWord); int methodArgumentCount(void); int methodPrimitiveIndex(void); -int moveAETEntryFromedgex(int index, int edge, int xValue); -int needAvailableSpace(int nSlots); -int netAddressToInt(int oop); +#pragma export on +EXPORT(int) moduleUnloaded(char * aModuleName); +#pragma export off int nilObject(void); int nonWeakFieldsOf(int oop); +int noteAsRootheaderLoc(int oop, int headerLoc); int nullCompilerHook(void); int objectAfter(int oop); int okayFields(int oop); @@ -497,17 +1035,6 @@ int okayOop(int oop); int oopFromChunk(int chunk); int oopHasOKclass(int oop); int oopHasOkayClass(int oop); -int partitionedANDtonBitsnPartitions(int word1, int word2, int nBits, int nParts); -int partitionedAddtonBitsnPartitions(int word1, int word2, int nBits, int nParts); -int partitionedMaxwithnBitsnPartitions(int word1, int word2, int nBits, int nParts); -int partitionedMinwithnBitsnPartitions(int word1, int word2, int nBits, int nParts); -int partitionedSubfromnBitsnPartitions(int word1, int word2, int nBits, int nParts); -int permuteData(void); -int pickSourcePixelssrcMaskdestMask(int nPix, int sourcePixMask, int destPixMask); -int pickSourcePixelsNullMapsrcMaskdestMask(int nPix, int sourcePixMask, int destPixMask); -int pickSourcePixelsRGBnullMapsrcMaskdestMask(int nPix, int nullMap, int sourcePixMask, int destPixMask); -int pixMaskwith(int sourceWord, int destinationWord); -int pixPaintwith(int sourceWord, int destinationWord); int pop(int nItems); int popthenPush(int nItems, int oop); double popFloat(void); @@ -515,8 +1042,9 @@ int popRemappableOop(void); int popStack(void); int positive32BitIntegerFor(int integerValue); int positive32BitValueOf(int oop); +int positive64BitIntegerFor(squeakInt64 integerValue); +squeakInt64 positive64BitValueOf(int oop); int possibleRootStoreIntovalue(int oop, int valueObj); -int postDisplayAction(void); int prepareForwardingTableForBecomingwithtwoWay(int array1, int array2, int twoWayFlag); int primitiveAdd(void); int primitiveArctan(void); @@ -524,12 +1052,6 @@ int primitiveArrayBecome(void); int primitiveArrayBecomeOneWay(void); int primitiveAsFloat(void); int primitiveAsOop(void); -int primitiveAsyncFileClose(void); -int primitiveAsyncFileOpen(void); -int primitiveAsyncFileReadResult(void); -int primitiveAsyncFileReadStart(void); -int primitiveAsyncFileWriteResult(void); -int primitiveAsyncFileWriteStart(void); int primitiveAt(void); int primitiveAtEnd(void); int primitiveAtPut(void); @@ -542,58 +1064,31 @@ int primitiveBitShift(void); int primitiveBitXor(void); int primitiveBlockCopy(void); int primitiveBytesLeft(void); +int primitiveCalloutToFFI(void); +int primitiveChangeClass(void); int primitiveClass(void); int primitiveClipboardText(void); int primitiveClone(void); int primitiveConstantFill(void); -int primitiveCopyBits(void); int primitiveDeferDisplayUpdates(void); -int primitiveDirectoryCreate(void); -int primitiveDirectoryDelete(void); -int primitiveDirectoryDelimitor(void); -int primitiveDirectoryLookup(void); -int primitiveDirectorySetMacTypeAndCreator(void); +#pragma export on +EXPORT(int) primitiveDisablePowerManager(void); +#pragma export off int primitiveDiv(void); int primitiveDivide(void); int primitiveDoPrimitiveWithArgs(void); -int primitiveDrawLoop(void); int primitiveEqual(void); int primitiveEquivalent(void); int primitiveExitToDebugger(void); int primitiveExp(void); int primitiveExponent(void); int primitiveExternalCall(void); -#pragma export on -EXPORT(int) primitiveFFTPermuteData(void); -EXPORT(int) primitiveFFTScaleData(void); -EXPORT(int) primitiveFFTTransformData(void); -#pragma export off int primitiveFail(void); -int primitiveFileAtEnd(void); -int primitiveFileClose(void); -int primitiveFileDelete(void); -int primitiveFileGetPosition(void); -int primitiveFileOpen(void); -int primitiveFileRead(void); -int primitiveFileRename(void); -int primitiveFileSetPosition(void); -int primitiveFileSize(void); -int primitiveFileWrite(void); +int primitiveFindHandlerContext(void); +int primitiveFindNextUnwindContext(void); +int primitiveFloatAdd(void); int primitiveFloatAddtoArg(int rcvrOop, int argOop); -#pragma export on -EXPORT(int) primitiveFloatArrayAddFloatArray(void); -EXPORT(int) primitiveFloatArrayAddScalar(void); -EXPORT(int) primitiveFloatArrayAt(void); -EXPORT(int) primitiveFloatArrayAtPut(void); -EXPORT(int) primitiveFloatArrayDivFloatArray(void); -EXPORT(int) primitiveFloatArrayDivScalar(void); -EXPORT(int) primitiveFloatArrayEqual(void); -EXPORT(int) primitiveFloatArrayHash(void); -EXPORT(int) primitiveFloatArrayMulFloatArray(void); -EXPORT(int) primitiveFloatArrayMulScalar(void); -EXPORT(int) primitiveFloatArraySubFloatArray(void); -EXPORT(int) primitiveFloatArraySubScalar(void); -#pragma export off +int primitiveFloatDivide(void); int primitiveFloatDividebyArg(int rcvrOop, int argOop); int primitiveFloatEqual(void); int primitiveFloatEqualtoArg(int rcvrOop, int argOop); @@ -603,48 +1098,46 @@ int primitiveFloatGreaterThan(void); int primitiveFloatLessthanArg(int rcvrOop, int argOop); int primitiveFloatLessOrEqual(void); int primitiveFloatLessThan(void); +int primitiveFloatMultiply(void); int primitiveFloatMultiplybyArg(int rcvrOop, int argOop); int primitiveFloatNotEqual(void); +int primitiveFloatSubtract(void); int primitiveFloatSubtractfromArg(int rcvrOop, int argOop); int primitiveFlushCache(void); int primitiveFlushCacheByMethod(void); int primitiveFlushCacheSelective(void); +int primitiveFlushExternalPrimitives(void); int primitiveForceDisplayUpdate(void); int primitiveFormPrint(void); int primitiveFractionalPart(void); int primitiveFullGC(void); int primitiveGetAttribute(void); -int primitiveGetTabletParameters(void); +int primitiveGetNextEvent(void); int primitiveGreaterOrEqual(void); int primitiveGreaterThan(void); int primitiveImageName(void); int primitiveIncrementalGC(void); int primitiveIndexOf(int methodPointer); -int primitiveInitializeNetwork(void); int primitiveInputSemaphore(void); int primitiveInputWord(void); int primitiveInstVarAt(void); int primitiveInstVarAtPut(void); int primitiveInstVarsPutFromStack(void); +int primitiveIntegerAt(void); +int primitiveIntegerAtPut(void); int primitiveInterruptSemaphore(void); int primitiveKbdNext(void); int primitiveKbdPeek(void); int primitiveLessOrEqual(void); int primitiveLessThan(void); +int primitiveListBuiltinModule(void); +int primitiveListExternalModule(void); int primitiveLoadImageSegment(void); int primitiveLoadInstVar(void); int primitiveLogN(void); int primitiveLowSpaceSemaphore(void); -int primitiveMIDIClosePort(void); -int primitiveMIDIGetClock(void); -int primitiveMIDIGetPortCount(void); -int primitiveMIDIGetPortDirectionality(void); -int primitiveMIDIGetPortName(void); -int primitiveMIDIOpenPort(void); -int primitiveMIDIParameterGetOrSet(void); -int primitiveMIDIRead(void); -int primitiveMIDIWrite(void); int primitiveMakePoint(void); +int primitiveMethod(void); int primitiveMillisecondClock(void); int primitiveMod(void); int primitiveMouseButtons(void); @@ -662,6 +1155,7 @@ int primitiveNotEqual(void); int primitiveObjectAt(void); int primitiveObjectAtPut(void); int primitiveObjectPointsTo(void); +int primitiveObsoleteIndexedPrimitive(void); int primitivePerform(void); int primitivePerformAt(int lookupClass); int primitivePerformInSuperclass(void); @@ -678,26 +1172,15 @@ int primitivePushTwo(void); int primitivePushZero(void); int primitiveQuit(void); int primitiveQuo(void); -int primitiveReadJoystick(void); -int primitiveReadTablet(void); int primitiveRelinquishProcessor(void); -int primitiveResolverAbortLookup(void); -int primitiveResolverAddressLookupResult(void); -int primitiveResolverError(void); -int primitiveResolverLocalAddress(void); -int primitiveResolverNameLookupResult(void); -int primitiveResolverStartAddressLookup(void); -int primitiveResolverStartNameLookup(void); -int primitiveResolverStatus(void); int primitiveResponse(void); int primitiveResume(void); int primitiveScanCharacters(void); +#pragma export on +EXPORT(int) primitiveScreenDepth(void); +#pragma export off int primitiveScreenSize(void); int primitiveSecondsClock(void); -int primitiveSerialPortClose(void); -int primitiveSerialPortOpen(void); -int primitiveSerialPortRead(void); -int primitiveSerialPortWrite(void); int primitiveSetDisplayMode(void); int primitiveSetFullScreen(void); int primitiveSetInterruptKey(void); @@ -710,37 +1193,9 @@ int primitiveSignalAtMilliseconds(void); int primitiveSine(void); int primitiveSize(void); int primitiveSnapshot(void); -int primitiveSocketAbortConnection(void); -int primitiveSocketAccept(void); -int primitiveSocketCloseConnection(void); -int primitiveSocketConnectToPort(void); -int primitiveSocketConnectionStatus(void); -int primitiveSocketCreate(void); -int primitiveSocketDestroy(void); -int primitiveSocketError(void); -int primitiveSocketListenOnPort(void); -int primitiveSocketLocalAddress(void); -int primitiveSocketLocalPort(void); -int primitiveSocketReceiveDataAvailable(void); -int primitiveSocketReceiveDataBufCount(void); -int primitiveSocketRemoteAddress(void); -int primitiveSocketRemotePort(void); -int primitiveSocketSendDataBufCount(void); -int primitiveSocketSendDone(void); +int primitiveSnapshotEmbedded(void); int primitiveSomeInstance(void); int primitiveSomeObject(void); -int primitiveSoundAvailableSpace(void); -int primitiveSoundGetRecordingSampleRate(void); -int primitiveSoundInsertSamples(void); -int primitiveSoundPlaySamples(void); -int primitiveSoundPlaySilence(void); -int primitiveSoundRecordSamples(void); -int primitiveSoundSetRecordLevel(void); -int primitiveSoundStart(void); -int primitiveSoundStartRecording(void); -int primitiveSoundStartWithSemaphore(void); -int primitiveSoundStop(void); -int primitiveSoundStopRecording(void); int primitiveSpecialObjectsOop(void); int primitiveSquareRoot(void); int primitiveStoreImageSegment(void); @@ -750,69 +1205,49 @@ int primitiveStringAtPut(void); int primitiveStringReplace(void); int primitiveSubtract(void); int primitiveSuspend(void); +int primitiveTerminateTo(void); int primitiveTestDisplayDepth(void); int primitiveTimesTwoPower(void); int primitiveTruncated(void); +int primitiveUnloadModule(void); int primitiveVMParameter(void); int primitiveVMPath(void); int primitiveValue(void); int primitiveValueWithArgs(void); int primitiveWait(void); -int primitiveWarpBits(void); int print(char *s); +int printAllStacks(void); int printCallStack(void); +int printCallStackOf(int aContext); int printNameOfClasscount(int classOop, int cnt); int printNum(int n); int printStringOf(int oop); -int proceedRenderingImage(void); -int proceedRenderingScanline(void); +int printUnbalancedStack(int primIdx); +int printUnbalancedStackFromNamedPrimitive(void); int push(int object); int pushBool(int trueOrFalse); int pushFloat(double f); int pushInteger(int integerValue); int pushRemappableOop(int oop); int putLongtoFile(int n, sqImageFile f); -int quickLoadEngineFrom(int engineOop); -int quickLoadEngineFromrequiredState(int oop, int requiredState); -int quickLoadEngineFromrequiredStateor(int oop, int requiredState, int alternativeState); -int quickSortGlobalEdgeTablefromto(int *array, int i, int j); -int * rShiftTable(void); -int readImageFromFileHeapSizeStartingAt(sqImageFile f, int desiredHeapSize, int imageOffset); +int readImageFromFileHeapSizeStartingAt(sqImageFile f, int desiredHeapSize, squeakFileOffsetType imageOffset); int readableFormat(int imageVersion); int remap(int oop); -int removeFirstAETEntry(void); int removeFirstLinkOfList(int aList); -int resetGraphicsEngineStats(void); -int resortFirstAETEntry(void); int restoreHeadersFromtofromandtofrom(int firstIn, int lastIn, int hdrBaseIn, int firstOut, int lastOut, int hdrBaseOut); int resume(int aProcess); int reverseDisplayFromto(int startIndex, int endIndex); -int rgbAddwith(int sourceWord, int destinationWord); -int rgbDiffwith(int sourceWord, int destinationWord); -int rgbMaxwith(int sourceWord, int destinationWord); -int rgbMinwith(int sourceWord, int destinationWord); -int rgbMinInvertwith(int wordToInvert, int destinationWord); -int rgbSubwith(int sourceWord, int destinationWord); -int roundAndStoreResultRectx0y0x1y1(int dstOop, double x0, double y0, double x1, double y1); -int scaleData(void); -int setAALevel(int level); +int rewriteMethodCacheSelclassprimIndex(int selector, int class, int localPrimIndex); int setCompilerInitialized(int newFlag); -#pragma export on -EXPORT(int) setInterpreter(int anInterpreter); -#pragma export off -int showDisplayBits(void); -int showDisplayBitsLeftTopRightBottom(int aForm, int affectedRectL, int affectedRectT, int affectedRectR, int affectedRectB); -int showFilldepthrightX(int fillIndex, int depth, int rightX); +int showDisplayBitsLeftTopRightBottom(int aForm, int l, int t, int r, int b); int signalSemaphoreWithIndex(int index); +int signed32BitIntegerFor(int integerValue); +int signed32BitValueOf(int oop); +int signed64BitIntegerFor(squeakInt64 integerValue); +squeakInt64 signed64BitValueOf(int oop); int sizeBitsOf(int oop); int sizeOfSTArrayFromCPrimitive(void *cPtr); int slotSizeOf(int oop); -int * smallSqrtTable(void); -int smoothPixatXfyfdxhdyhdxvdyvpixPerWordpixelMasksourceMap(int n, int xf, int yf, int dxh, int dyh, int dxv, int dyv, int srcPixPerWord, int sourcePixMask, int sourceMap); -int socketRecordSize(void); -SQSocket * socketValueOf(int socketOop); -int sourcePixAtXypixPerWord(int x, int y, int srcPixPerWord); -int sourceWordwith(int sourceWord, int destinationWord); int splObj(int index); int stObjectat(int array, int index); int stObjectatput(int array, int index, int value); @@ -822,257 +1257,35 @@ int stackIntegerValue(int offset); int stackObjectValue(int offset); int stackValue(int offset); int startOfMemory(void); -int stepToFirstBezierInat(int bezier, int yValue); -int stepToFirstLineInat(int line, int yValue); -int stepToFirstWideBezierInat(int bezier, int yValue); -int stepToFirstWideLineInat(int line, int yValue); -int stepToNextBezierInat(int bezier, int yValue); -int stepToNextLineInat(int line, int yValue); -int stepToNextWideBezier(void); -int stepToNextWideBezierInat(int bezier, int yValue); -int stepToNextWideLineInat(int line, int yValue); -int storeEdgeStateFrominto(int edge, int edgeOop); -int storeFillStateInto(int fillOop); int storeIntegerofObjectwithValue(int fieldIndex, int objectPointer, int integerValue); int storePointerofObjectwithValue(int fieldIndex, int oop, int valuePointer); -int storeRenderingState(void); -int subWordwith(int sourceWord, int destinationWord); -int subdivideBezier(int index); -int subdivideBezierFrom(int index); -int subdivideToBeMonotoninX(int base, int doTestX); -int subdivideToBeMonotonInX(int index); -int subdivideToBeMonotonInY(int index); int success(int successValue); int sufficientSpaceAfterGC(int minFree); int superclassOf(int classPointer); int sweepPhase(void); int synchronousSignal(int aSemaphore); -int tallyIntoMapwith(int sourceWord, int destinationWord); -int toggleFilldepthrightX(int fillIndex, int depth, int rightX); -int toggleFillsOf(int edge); -int toggleWideFillOf(int edge); -int topDepth(void); -int topFill(void); -int topRightX(void); int transferTo(int aProc); -int transformColor(int fillIndex); -int transformForward(int forward); -int transformPoint(int *point); -int transformPointXyinto(double xValue, double yValue, int *dstPoint); -int transformWidth(int w); int trueObject(void); -int uncheckedTransformColor(int fillIndex); int verifyCleanHeaders(void); int wakeHighestPriority(void); -int warpSourcePixelsxDeltahyDeltahxDeltavyDeltavsmoothingsourceMap(int nPix, int xDeltah, int yDeltah, int xDeltav, int yDeltav, int n, int sourceMapOop); -int wbStackPush(int nItems); int writeImageFile(int imageBytes); +int writeImageFileIO(int imageBytes); -int OLDrgbDiffwith(int sourceWord, int destinationWord) { - int diff; - int pixMask; - - if (destPixSize < 16) { - diff = sourceWord ^ destinationWord; - pixMask = maskTable[destPixSize]; - while (!(diff == 0)) { - if ((diff & pixMask) != 0) { - bitCount += 1; - } - diff = ((unsigned) diff) >> destPixSize; - } - return destinationWord; - } - if (destPixSize == 16) { - diff = partitionedSubfromnBitsnPartitions(sourceWord, destinationWord, 5, 3); - bitCount = ((bitCount + (diff & 31)) + ((((unsigned) diff) >> 5) & 31)) + ((((unsigned) diff) >> 10) & 31); - diff = partitionedSubfromnBitsnPartitions(((unsigned) sourceWord) >> 16, ((unsigned) destinationWord) >> 16, 5, 3); - bitCount = ((bitCount + (diff & 31)) + ((((unsigned) diff) >> 5) & 31)) + ((((unsigned) diff) >> 10) & 31); - } else { - diff = partitionedSubfromnBitsnPartitions(sourceWord, destinationWord, 8, 3); - bitCount = ((bitCount + (diff & 255)) + ((((unsigned) diff) >> 8) & 255)) + ((((unsigned) diff) >> 16) & 255); - } - return destinationWord; -} -int OLDtallyIntoMapwith(int sourceWord, int destinationWord) { - int mapIndex; - int pixMask; - int shiftWord; - int i; - int mask; - int srcPix; - int destPix; - int d; - int mask3; - int srcPix1; - int destPix1; - int d1; - int mask4; - int srcPix2; - int destPix2; - int d2; - - if (colorMap == nilObj) { - return destinationWord; - } - if (destPixSize < 16) { - pixMask = maskTable[destPixSize]; - shiftWord = destinationWord; - for (i = 1; i <= pixPerWord; i += 1) { - mapIndex = shiftWord & pixMask; - longAtput(((((char *) colorMap)) + 4) + (mapIndex << 2), (longAt(((((char *) colorMap)) + 4) + (mapIndex << 2))) + 1); - shiftWord = ((unsigned) shiftWord) >> destPixSize; - } - return destinationWord; - } - if (destPixSize == 16) { - /* begin rgbMap:from:to: */ - if ((d = cmBitsPerColor - 5) > 0) { - mask = (1 << 5) - 1; - srcPix = (destinationWord & 65535) << d; - mask = mask << d; - destPix = srcPix & mask; - mask = mask << cmBitsPerColor; - srcPix = srcPix << d; - mapIndex = (destPix + (srcPix & mask)) + ((srcPix << d) & (mask << cmBitsPerColor)); - goto l1; - } else { - if (d == 0) { - if (5 == 5) { - mapIndex = (destinationWord & 65535) & 32767; - goto l1; - } - if (5 == 8) { - mapIndex = (destinationWord & 65535) & 16777215; - goto l1; - } - mapIndex = destinationWord & 65535; - goto l1; - } - if ((destinationWord & 65535) == 0) { - mapIndex = destinationWord & 65535; - goto l1; - } - d = 5 - cmBitsPerColor; - mask = (1 << cmBitsPerColor) - 1; - srcPix = ((unsigned) (destinationWord & 65535)) >> d; - destPix = srcPix & mask; - mask = mask << cmBitsPerColor; - srcPix = ((unsigned) srcPix) >> d; - destPix = (destPix + (srcPix & mask)) + ((((unsigned) srcPix) >> d) & (mask << cmBitsPerColor)); - if (destPix == 0) { - mapIndex = 1; - goto l1; - } - mapIndex = destPix; - goto l1; - } - l1: /* end rgbMap:from:to: */; - longAtput(((((char *) colorMap)) + 4) + (mapIndex << 2), (longAt(((((char *) colorMap)) + 4) + (mapIndex << 2))) + 1); - /* begin rgbMap:from:to: */ - if ((d1 = cmBitsPerColor - 5) > 0) { - mask3 = (1 << 5) - 1; - srcPix1 = (((unsigned) destinationWord) >> 16) << d1; - mask3 = mask3 << d1; - destPix1 = srcPix1 & mask3; - mask3 = mask3 << cmBitsPerColor; - srcPix1 = srcPix1 << d1; - mapIndex = (destPix1 + (srcPix1 & mask3)) + ((srcPix1 << d1) & (mask3 << cmBitsPerColor)); - goto l2; - } else { - if (d1 == 0) { - if (5 == 5) { - mapIndex = (((unsigned) destinationWord) >> 16) & 32767; - goto l2; - } - if (5 == 8) { - mapIndex = (((unsigned) destinationWord) >> 16) & 16777215; - goto l2; - } - mapIndex = ((unsigned) destinationWord) >> 16; - goto l2; - } - if ((((unsigned) destinationWord) >> 16) == 0) { - mapIndex = ((unsigned) destinationWord) >> 16; - goto l2; - } - d1 = 5 - cmBitsPerColor; - mask3 = (1 << cmBitsPerColor) - 1; - srcPix1 = ((unsigned) (((unsigned) destinationWord) >> 16)) >> d1; - destPix1 = srcPix1 & mask3; - mask3 = mask3 << cmBitsPerColor; - srcPix1 = ((unsigned) srcPix1) >> d1; - destPix1 = (destPix1 + (srcPix1 & mask3)) + ((((unsigned) srcPix1) >> d1) & (mask3 << cmBitsPerColor)); - if (destPix1 == 0) { - mapIndex = 1; - goto l2; - } - mapIndex = destPix1; - goto l2; - } - l2: /* end rgbMap:from:to: */; - longAtput(((((char *) colorMap)) + 4) + (mapIndex << 2), (longAt(((((char *) colorMap)) + 4) + (mapIndex << 2))) + 1); - } else { - /* begin rgbMap:from:to: */ - if ((d2 = cmBitsPerColor - 8) > 0) { - mask4 = (1 << 8) - 1; - srcPix2 = destinationWord << d2; - mask4 = mask4 << d2; - destPix2 = srcPix2 & mask4; - mask4 = mask4 << cmBitsPerColor; - srcPix2 = srcPix2 << d2; - mapIndex = (destPix2 + (srcPix2 & mask4)) + ((srcPix2 << d2) & (mask4 << cmBitsPerColor)); - goto l3; - } else { - if (d2 == 0) { - if (8 == 5) { - mapIndex = destinationWord & 32767; - goto l3; - } - if (8 == 8) { - mapIndex = destinationWord & 16777215; - goto l3; - } - mapIndex = destinationWord; - goto l3; - } - if (destinationWord == 0) { - mapIndex = destinationWord; - goto l3; - } - d2 = 8 - cmBitsPerColor; - mask4 = (1 << cmBitsPerColor) - 1; - srcPix2 = ((unsigned) destinationWord) >> d2; - destPix2 = srcPix2 & mask4; - mask4 = mask4 << cmBitsPerColor; - srcPix2 = ((unsigned) srcPix2) >> d2; - destPix2 = (destPix2 + (srcPix2 & mask4)) + ((((unsigned) srcPix2) >> d2) & (mask4 << cmBitsPerColor)); - if (destPix2 == 0) { - mapIndex = 1; - goto l3; - } - mapIndex = destPix2; - goto l3; - } - l3: /* end rgbMap:from:to: */; - longAtput(((((char *) colorMap)) + 4) + (mapIndex << 2), (longAt(((((char *) colorMap)) + 4) + (mapIndex << 2))) + 1); - } - return destinationWord; -} +/* Return the accessible object following the given object or free chunk in the heap. Return nil when heap is exhausted. */ int accessibleObjectAfter(int oop) { int obj; int sz; int extra; int header; - int type; int extra1; + int type; int sz1; int extra2; int header1; - int type1; int extra11; + int type1; /* begin objectAfter: */ ; @@ -1142,145 +1355,63 @@ int accessibleObjectAfter(int oop) { return null; } -int accurateLengthOfwith(int deltaX, int deltaY) { - int length2; - - if (deltaX == 0) { - if (deltaY < 0) { - return 0 - deltaY; - } else { - return deltaY; - } - } - if (deltaY == 0) { - if (deltaX < 0) { - return 0 - deltaX; - } else { - return deltaX; - } - } - length2 = (deltaX * deltaX) + (deltaY * deltaY); - /* begin computeSqrt: */ - if (length2 < 32) { - return (smallSqrtTable())[length2]; - } else { - return ((int) ((sqrt(((double) length2 ))) + 0.5) ); - } - return null; -} -int addEdgeToGET(int edge) { - if (!(allocateGETEntry(1))) { - return 0; - } - getBuffer[workBuffer[12]] = edge; - workBuffer[12] = ((workBuffer[12]) + 1); -} +/* Add the given entry to the method cache. + The policy is as follows: + Look for an empty entry anywhere in the reprobe chain. + If found, install the new entry there. + If not found, then install the new entry at the first probe position + and delete the entries in the rest of the reprobe chain. + This has two useful purposes: + If there is active contention over the first slot, the second + or third will likely be free for reentry after ejection. + Also, flushing is good when reprobe chains are getting full. */ -int addToMethodCacheSelclassmethodprimIndex(int selector, int class, int meth, int primIndex) { +int addNewMethodToCache(void) { + int hash; int probe; int p; - int hash; - hash = selector ^ class; + compilerInitialized && (compilerTranslateMethod()); + + /* drop low-order zeros from addresses */ + + hash = messageSelector ^ lkupClass; for (p = 0; p <= (3 - 1); p += 1) { - probe = (((unsigned) hash) >> p) & 2044; + probe = (((unsigned) hash) >> p) & 4088; if ((methodCache[probe + 1]) == 0) { - methodCache[probe + 1] = selector; - methodCache[probe + 2] = class; - methodCache[probe + 3] = meth; - methodCache[probe + 4] = primIndex; + methodCache[probe + 1] = messageSelector; + methodCache[probe + 2] = lkupClass; + methodCache[probe + 3] = newMethod; + methodCache[probe + 4] = primitiveIndex; + methodCache[probe + 5] = newNativeMethod; return null; } } - probe = hash & 2044; - methodCache[probe + 1] = selector; - methodCache[probe + 2] = class; - methodCache[probe + 3] = meth; - methodCache[probe + 4] = primIndex; + + /* first probe */ + + probe = hash & 4088; + methodCache[probe + 1] = messageSelector; + methodCache[probe + 2] = lkupClass; + methodCache[probe + 3] = newMethod; + methodCache[probe + 4] = primitiveIndex; + methodCache[probe + 5] = newNativeMethod; for (p = 1; p <= (3 - 1); p += 1) { - probe = (((unsigned) hash) >> p) & 2044; + probe = (((unsigned) hash) >> p) & 4088; methodCache[probe + 1] = 0; } } -int addWordwith(int sourceWord, int destinationWord) { - return sourceWord + destinationWord; -} - -int adjustWideBezierLeftwidthoffsetendX(int bezier, int lineWidth, int lineOffset, int endX) { - int lastX; - int lastY; - - ((objBuffer + bezier) + 10)[0] = ((((objBuffer + bezier) + 10)[0]) - (lineOffset * 256)); - lastX = ((objBuffer + bezier) + 22)[0]; - ((objBuffer + bezier) + 22)[0] = (lastX + ((lineWidth - lineOffset) * 256)); - lastY = ((objBuffer + bezier) + 22)[1]; - ((objBuffer + bezier) + 22)[1] = (lastY + (lineWidth * 256)); - objBuffer[bezier + 21] = (endX - lineOffset); -} - -int adjustWideBezierRightwidthoffsetendX(int bezier, int lineWidth, int lineOffset, int endX) { - int lastX; - int lastY; - - ((objBuffer + bezier) + 10)[0] = ((((objBuffer + bezier) + 10)[0]) + (lineOffset * 256)); - lastX = ((objBuffer + bezier) + 22)[0]; - ((objBuffer + bezier) + 22)[0] = (lastX - ((lineWidth - lineOffset) * 256)); - lastY = ((objBuffer + bezier) + 22)[1]; - ((objBuffer + bezier) + 22)[1] = (lastY + (lineWidth * 256)); - objBuffer[bezier + 21] = ((endX - lineOffset) + lineWidth); -} - -int adjustWideLineafterSteppingFromto(int line, int lastX, int nextX) { - int baseWidth; - int deltaX; - int yExit; - int yEntry; - int lineOffset; - int xDir; - int lineWidth; - yEntry = objBuffer[line + 18]; - yExit = objBuffer[line + 19]; - baseWidth = objBuffer[line + 20]; - lineOffset = ((int) baseWidth >> 1); - lineWidth = objBuffer[line + 17]; - xDir = objBuffer[line + 10]; - deltaX = nextX - lastX; - if (yEntry < baseWidth) { - if (xDir < 0) { - lineWidth -= deltaX; - } else { - lineWidth += deltaX; - objBuffer[line + 4] = lastX; - } - } - if ((yExit + lineOffset) == 0) { - if (xDir > 0) { - lineWidth -= objBuffer[line + 12]; - } else { - lineWidth += objBuffer[line + 12]; - objBuffer[line + 4] = lastX; - } - } - if ((yExit + lineOffset) > 0) { - if (xDir < 0) { - lineWidth += deltaX; - objBuffer[line + 4] = lastX; - } else { - lineWidth -= deltaX; - } - } - objBuffer[line + 17] = lineWidth; -} +/* Return true if all the oops in both arrays, and the arrays themselves, are in the young object space. */ int allYoungand(int array1, int array2) { int fieldOffset; + int header; + int fmt; int methodHeader; int sz; - int fmt; - int header; int header1; int type; @@ -1344,591 +1475,140 @@ int allYoungand(int array1, int array2) { return 1; } -int allocateBitmapFillcolormap(int cmSize, int *cmBits) { - int fill; - int *cm; - int i; - int fillSize; - fillSize = 18 + cmSize; - if (!(allocateObjEntry(fillSize))) { - return 0; +/* Allocate a chunk of the given size. Sender must be sure that the requested size includes enough space for the header word(s). */ +/* Details: To limit the time per incremental GC, do one every so many allocations. */ + +int allocateChunk(int byteSize) { + int enoughSpace; + int newChunk; + int newFreeSize; + int minFree; + + if (allocationCount >= allocationsBetweenGCs) { + incrementalGC(); } - fill = objUsed; - objUsed = fill + fillSize; - objBuffer[fill + 0] = 1024; - objBuffer[fill + 2] = 0; - objBuffer[fill + 1] = fillSize; - cm = (objBuffer + fill) + 18; - if ((workBuffer[17]) != 0) { - for (i = 0; i <= (cmSize - 1); i += 1) { - cm[i] = (transformColor(cmBits[i])); - } + /* begin sufficientSpaceToAllocate: */ + minFree = (lowSpaceThreshold + byteSize) + 4; + if ((((unsigned ) ((longAt(freeBlock)) & 4294967292U))) >= (((unsigned ) minFree))) { + enoughSpace = 1; + goto l1; } else { - for (i = 0; i <= (cmSize - 1); i += 1) { - cm[i] = (cmBits[i]); - } + enoughSpace = sufficientSpaceAfterGC(minFree); + goto l1; } - objBuffer[fill + 15] = cmSize; - return fill; -} +l1: /* end sufficientSpaceToAllocate: */; + if (!(enoughSpace)) { + signalLowSpace = 1; -int allocateGETEntry(int nSlots) { - int i; - int srcIndex; - int dstIndex; + /* disable additional interrupts until lowSpaceThreshold is reset by image */ - if (!(needAvailableSpace(nSlots))) { - return 0; + lowSpaceThreshold = 0; + interruptCheckCounter = 0; } - if (!((workBuffer[14]) == 0)) { - srcIndex = workBuffer[14]; - dstIndex = (workBuffer[14]) + nSlots; - for (i = 1; i <= (workBuffer[14]); i += 1) { - aetBuffer[dstIndex -= 1] = (aetBuffer[srcIndex -= 1]); - } + if ((((unsigned ) ((longAt(freeBlock)) & 4294967292U))) < (((unsigned ) (byteSize + 4)))) { + error("out of memory"); } - aetBuffer += nSlots; - return 1; + newFreeSize = ((longAt(freeBlock)) & 4294967292U) - byteSize; + newChunk = freeBlock; + + /* Assume: client will initialize object header of free chunk, so following is not needed: */ + /* self setSizeOfFree: newChunk to: byteSize. */ + + freeBlock += byteSize; + /* begin setSizeOfFree:to: */ + longAtput(freeBlock, (newFreeSize & 4294967292U) | 2); + allocationCount += 1; + return newChunk; } -int allocateGradientFillrampWidthisRadial(int *ramp, int rampWidth, int isRadial) { - int fill; - int i; - int *rampPtr; - int fillSize; - fillSize = 12 + rampWidth; - if (!(allocateObjEntry(fillSize))) { - return 0; - } - fill = objUsed; - objUsed = fill + fillSize; - if (isRadial) { - objBuffer[fill + 0] = 768; - } else { - objBuffer[fill + 0] = 512; - } - objBuffer[fill + 2] = 0; - objBuffer[fill + 1] = fillSize; - rampPtr = (objBuffer + fill) + 12; - if ((workBuffer[17]) != 0) { - for (i = 0; i <= (rampWidth - 1); i += 1) { - rampPtr[i] = (transformColor(ramp[i])); +/* Return a recycled context or a newly allocated one if none is available for recycling. */ + +int allocateOrRecycleContext(int needsLarge) { + int cntxt; + + if (needsLarge == 0) { + if (freeContexts != 1) { + cntxt = freeContexts; + freeContexts = longAt(((((char *) cntxt)) + 4) + (0 << 2)); + return cntxt; } } else { - for (i = 0; i <= (rampWidth - 1); i += 1) { - rampPtr[i] = (ramp[i]); + if (freeLargeContexts != 1) { + cntxt = freeLargeContexts; + freeLargeContexts = longAt(((((char *) cntxt)) + 4) + (0 << 2)); + return cntxt; } } - objBuffer[fill + 10] = rampWidth; - return fill; + if (needsLarge == 0) { + cntxt = instantiateContextsizeInBytes(longAt(((((char *) specialObjectsOop)) + 4) + (10 << 2)), 92); + } else { + cntxt = instantiateContextsizeInBytes(longAt(((((char *) specialObjectsOop)) + 4) + (10 << 2)), 252); + } + longAtput(((((char *) cntxt)) + 4) + (4 << 2), nilObj); + return cntxt; } -int allocateObjEntry(int nSlots) { - int i; - int srcIndex; - int dstIndex; - - if (!(allocateGETEntry(nSlots))) { - return 0; - } - if (!((workBuffer[12]) == 0)) { - srcIndex = workBuffer[12]; - dstIndex = (workBuffer[12]) + nSlots; - for (i = 1; i <= (workBuffer[12]); i += 1) { - getBuffer[dstIndex -= 1] = (getBuffer[srcIndex -= 1]); - } - } - getBuffer += nSlots; - return 1; +int argumentCountOf(int methodPointer) { + return (((unsigned) (longAt(((((char *) methodPointer)) + 4) + (0 << 2)))) >> 25) & 15; } -int alphaBlendwith(int sourceWord, int destinationWord) { - int shift; - int alpha; - int i; - int blend; - int unAlpha; - int result; - int colorMask; - alpha = ((unsigned) sourceWord) >> 24; - unAlpha = 255 - alpha; - colorMask = 255; - result = 0; - for (i = 1; i <= 3; i += 1) { - shift = (i - 1) * 8; - blend = ((((((((unsigned) sourceWord) >> shift) & colorMask) * alpha) + (((((unsigned) destinationWord) >> shift) & colorMask) * unAlpha)) + 254) / 255) & colorMask; - result = result | (blend << shift); +/* Return the address of first indexable field of resulting array object, or fail if the instance variable does not contain an indexable bytes or words object. */ +/* Note: May be called by translated primitive code. */ + +void * arrayValueOf(int arrayOop) { + if ((!((arrayOop & 1))) && (isWordsOrBytes(arrayOop))) { + return (void *) (arrayOop + 4); } - return result; + /* begin primitiveFail */ + successFlag = 0; } -int alphaBlendConstwith(int sourceWord, int destinationWord) { - return alphaBlendConstwithpaintMode(sourceWord, destinationWord, 0); -} -int alphaBlendConstwithpaintMode(int sourceWord, int destinationWord, int paintMode) { - int j; - int destPixVal; - int pixMask; - int destShifted; - int sourceShifted; - int sourcePixVal; - int pixBlend; - int shift; - int blend; - int maskShifted; - int bitsPerColor; - int i; - int unAlpha; - int result; - int rgbMask; - - if (destPixSize < 16) { - return destinationWord; - } - unAlpha = 255 - sourceAlpha; - pixMask = maskTable[destPixSize]; - if (destPixSize == 16) { - bitsPerColor = 5; - } else { - bitsPerColor = 8; - } - rgbMask = (1 << bitsPerColor) - 1; - maskShifted = destMask; - destShifted = destinationWord; - sourceShifted = sourceWord; - result = destinationWord; - for (j = 1; j <= pixPerWord; j += 1) { - sourcePixVal = sourceShifted & pixMask; - if (!(((maskShifted & pixMask) == 0) || (paintMode && (sourcePixVal == 0)))) { - destPixVal = destShifted & pixMask; - pixBlend = 0; - for (i = 1; i <= 3; i += 1) { - shift = (i - 1) * bitsPerColor; - blend = ((((((((unsigned) sourcePixVal) >> shift) & rgbMask) * sourceAlpha) + (((((unsigned) destPixVal) >> shift) & rgbMask) * unAlpha)) + 254) / 255) & rgbMask; - pixBlend = pixBlend | (blend << shift); - } - if (destPixSize == 16) { - result = (result & (~(pixMask << ((j - 1) * 16)))) | (pixBlend << ((j - 1) * 16)); - } else { - result = pixBlend; - } - } - maskShifted = ((unsigned) maskShifted) >> destPixSize; - sourceShifted = ((unsigned) sourceShifted) >> destPixSize; - destShifted = ((unsigned) destShifted) >> destPixSize; - } - return result; -} +/* Returns an integer object */ -int alphaBlendScaledwith(int sourceWord, int destinationWord) { - int dstMask; - int srcMask; - int b; - int a; - int unAlpha; - int g; - int r; +int asciiOfCharacter(int characterObj) { + int cl; + int ccIndex; - unAlpha = 255 - (((unsigned) sourceWord) >> 24); - dstMask = destinationWord; - srcMask = sourceWord; - b = (((unsigned) ((dstMask & 255) * unAlpha)) >> 8) + (srcMask & 255); - if (b > 255) { - b = 255; - } - dstMask = ((unsigned) dstMask) >> 8; - srcMask = ((unsigned) srcMask) >> 8; - g = (((unsigned) ((dstMask & 255) * unAlpha)) >> 8) + (srcMask & 255); - if (g > 255) { - g = 255; + /* begin assertClassOf:is: */ + if ((characterObj & 1)) { + successFlag = 0; + goto l1; } - dstMask = ((unsigned) dstMask) >> 8; - srcMask = ((unsigned) srcMask) >> 8; - r = (((unsigned) ((dstMask & 255) * unAlpha)) >> 8) + (srcMask & 255); - if (r > 255) { - r = 255; + ccIndex = (((unsigned) (longAt(characterObj))) >> 12) & 31; + if (ccIndex == 0) { + cl = (longAt(characterObj - 4)) & 4294967292U; + } else { + cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } - dstMask = ((unsigned) dstMask) >> 8; - srcMask = ((unsigned) srcMask) >> 8; - a = (((unsigned) ((dstMask & 255) * unAlpha)) >> 8) + (srcMask & 255); - if (a > 255) { - a = 255; + /* begin success: */ + successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (19 << 2)))) && successFlag; +l1: /* end assertClassOf:is: */; + if (successFlag) { + return longAt(((((char *) characterObj)) + 4) + (0 << 2)); + } else { + return 1; } - return (((((a << 8) + r) << 8) + g) << 8) + b; } -int alphaPaintConstwith(int sourceWord, int destinationWord) { - if (sourceWord == 0) { - return destinationWord; - } - return alphaBlendConstwithpaintMode(sourceWord, destinationWord, 1); -} -int alphaSourceBlendBits16(void) { - int deltaX; - int deltaY; - int srcIndex; - int dstIndex; - int sourceWord; - int srcAlpha; - int destWord; - int srcY; - int dstY; - int dstMask; - int srcShift; - int ditherBase; - int ditherIndex; - int ditherThreshold; - int pv; - int value; - int threshold; - int out; - int pv1; - int value1; - int threshold1; - int out1; +/* Return true if the stack is still balanced after executing primitive primIndex with nArgs args. Delta is 'stackPointer - activeContext' which is a relative measure for the stack pointer (so we don't have to relocate it during the primitive) */ - deltaY = bbH + 1; - srcY = sy; - dstY = dy; - if ((dx & 1) == 0) { - mask1 = 65535; - srcShift = 16; - } else { - mask1 = 4294901760U; - srcShift = 0; - } - while ((deltaY -= 1) != 0) { - srcIndex = (sourceBits + 4) + (((srcY * sourceRaster) + sx) * 4); - dstIndex = (destBits + 4) + (((dstY * destRaster) + (((int) dx >> 1))) * 4); - ditherBase = (dstY & 3) * 4; - ditherIndex = (sx & 3) - 1; - deltaX = bbW + 1; - dstMask = mask1; - if (dstMask == 65535) { - srcShift = 16; - } else { - srcShift = 0; - } - while ((deltaX -= 1) != 0) { - ditherThreshold = ditherMatrix4x4[ditherBase + (ditherIndex = (ditherIndex + 1) & 3)]; - sourceWord = longAt(srcIndex); - srcAlpha = ((unsigned) sourceWord) >> 24; - if (srcAlpha == 255) { - /* begin dither32To16:threshold: */ - pv = sourceWord & 255; - threshold = ditherThresholds16[pv & 7]; - value = ditherValues16[((unsigned) pv >> 3)]; - if (ditherThreshold < threshold) { - out = value + 1; - } else { - out = value; - } - pv = (((unsigned) sourceWord >> 8)) & 255; - threshold = ditherThresholds16[pv & 7]; - value = ditherValues16[((unsigned) pv >> 3)]; - if (ditherThreshold < threshold) { - out = out | (((unsigned) (value + 1) << 5)); - } else { - out = out | (((unsigned) value << 5)); - } - pv = (((unsigned) sourceWord >> 16)) & 255; - threshold = ditherThresholds16[pv & 7]; - value = ditherValues16[((unsigned) pv >> 3)]; - if (ditherThreshold < threshold) { - out = out | (((unsigned) (value + 1) << 10)); - } else { - out = out | (((unsigned) value << 10)); - } - sourceWord = out; - if (sourceWord == 0) { - sourceWord = 1; - } - sourceWord = sourceWord << srcShift; - destWord = longAt(dstIndex); - destWord = destWord & dstMask; - longAtput(dstIndex, sourceWord | destWord); - } else { - if (srcAlpha == 0) { - null; - } else { - destWord = longAt(dstIndex); - destWord = destWord & (~dstMask); - destWord = ((unsigned) destWord) >> srcShift; - destWord = ((((unsigned) (destWord & 31744) << 9)) | (((unsigned) (destWord & 992) << 6))) | ((((unsigned) (destWord & 31) << 3)) | 4278190080U); - sourceWord = alphaBlendScaledwith(sourceWord, destWord); - /* begin dither32To16:threshold: */ - pv1 = sourceWord & 255; - threshold1 = ditherThresholds16[pv1 & 7]; - value1 = ditherValues16[((unsigned) pv1 >> 3)]; - if (ditherThreshold < threshold1) { - out1 = value1 + 1; - } else { - out1 = value1; - } - pv1 = (((unsigned) sourceWord >> 8)) & 255; - threshold1 = ditherThresholds16[pv1 & 7]; - value1 = ditherValues16[((unsigned) pv1 >> 3)]; - if (ditherThreshold < threshold1) { - out1 = out1 | (((unsigned) (value1 + 1) << 5)); - } else { - out1 = out1 | (((unsigned) value1 << 5)); - } - pv1 = (((unsigned) sourceWord >> 16)) & 255; - threshold1 = ditherThresholds16[pv1 & 7]; - value1 = ditherValues16[((unsigned) pv1 >> 3)]; - if (ditherThreshold < threshold1) { - out1 = out1 | (((unsigned) (value1 + 1) << 10)); - } else { - out1 = out1 | (((unsigned) value1 << 10)); - } - sourceWord = out1; - if (sourceWord == 0) { - sourceWord = 1; - } - sourceWord = sourceWord << srcShift; - destWord = longAt(dstIndex); - destWord = destWord & dstMask; - longAtput(dstIndex, sourceWord | destWord); - } - } - srcIndex += 4; - if (srcShift == 0) { - dstIndex += 4; - } - srcShift = srcShift ^ 16; - dstMask = ~dstMask; - } - srcY += 1; - dstY += 1; - } -} - -int alphaSourceBlendBits32(void) { - register int deltaX; - int deltaY; - register int srcIndex; - register int dstIndex; - register int sourceWord; - int srcAlpha; - int destWord; - int srcY; - int dstY; - - deltaY = bbH + 1; - srcY = sy; - dstY = dy; - while ((deltaY -= 1) != 0) { - srcIndex = (sourceBits + 4) + (((srcY * sourceRaster) + sx) * 4); - dstIndex = (destBits + 4) + (((dstY * destRaster) + dx) * 4); - deltaX = bbW + 1; - while ((deltaX -= 1) != 0) { - sourceWord = longAt(srcIndex); - srcAlpha = ((unsigned) sourceWord) >> 24; - if (srcAlpha == 255) { - longAtput(dstIndex, sourceWord); - srcIndex += 4; - dstIndex += 4; - while (((deltaX -= 1) != 0) && ((((unsigned) (sourceWord = longAt(srcIndex))) >> 24) == 255)) { - longAtput(dstIndex, sourceWord); - srcIndex += 4; - dstIndex += 4; - } - deltaX += 1; - } else { - if (srcAlpha == 0) { - srcIndex += 4; - dstIndex += 4; - while (((deltaX -= 1) != 0) && ((((unsigned) (sourceWord = longAt(srcIndex))) >> 24) == 0)) { - srcIndex += 4; - dstIndex += 4; - } - deltaX += 1; - } else { - destWord = longAt(dstIndex); - destWord = alphaBlendScaledwith(sourceWord, destWord); - longAtput(dstIndex, destWord); - srcIndex += 4; - dstIndex += 4; - } - } - } - srcY += 1; - dstY += 1; +int balancedStackafterPrimitivewithArgs(int delta, int primIdx, int nArgs) { + if ((primIdx >= 81) && (primIdx <= 88)) { + return 1; } + if (successFlag) { + return ((stackPointer - activeContext) + (nArgs * 4)) == delta; + } + return (stackPointer - activeContext) == delta; } -int alphaSourceBlendBits8(void) { - int deltaX; - int deltaY; - int srcIndex; - int dstIndex; - int sourceWord; - int srcAlpha; - int destWord; - int srcY; - int dstY; - int dstMask; - int srcShift; - int adjust; - unsigned int *mappingTable; - int mask; - int srcPix; - int destPix; - int d; - mappingTable = default8To32Table(); - deltaY = bbH + 1; - srcY = sy; - dstY = dy; - mask1 = 24 - ((dx & 3) * 8); - mask2 = 4294967295U ^ (255 << mask1); - if ((dx & 1) == 0) { - adjust = 0; - } else { - adjust = 522133279; - } - if ((dy & 1) == 0) { - adjust = adjust ^ 522133279; - } - while ((deltaY -= 1) != 0) { - adjust = adjust ^ 522133279; - srcIndex = (sourceBits + 4) + (((srcY * sourceRaster) + sx) * 4); - dstIndex = (destBits + 4) + (((dstY * destRaster) + (((int) dx >> 2))) * 4); - deltaX = bbW + 1; - srcShift = mask1; - dstMask = mask2; - while ((deltaX -= 1) != 0) { - sourceWord = ((longAt(srcIndex)) & (~adjust)) + adjust; - srcAlpha = ((unsigned) sourceWord) >> 24; - if (srcAlpha > 31) { - if (srcAlpha < 224) { - destWord = longAt(dstIndex); - destWord = destWord & (~dstMask); - destWord = ((unsigned) destWord) >> srcShift; - destWord = mappingTable[destWord]; - sourceWord = alphaBlendScaledwith(sourceWord, destWord); - } - /* begin rgbMap:from:to: */ - if ((d = cmBitsPerColor - 8) > 0) { - mask = (1 << 8) - 1; - srcPix = sourceWord << d; - mask = mask << d; - destPix = srcPix & mask; - mask = mask << cmBitsPerColor; - srcPix = srcPix << d; - sourceWord = (destPix + (srcPix & mask)) + ((srcPix << d) & (mask << cmBitsPerColor)); - goto l1; - } else { - if (d == 0) { - if (8 == 5) { - sourceWord = sourceWord & 32767; - goto l1; - } - if (8 == 8) { - sourceWord = sourceWord & 16777215; - goto l1; - } - sourceWord = sourceWord; - goto l1; - } - if (sourceWord == 0) { - sourceWord = sourceWord; - goto l1; - } - d = 8 - cmBitsPerColor; - mask = (1 << cmBitsPerColor) - 1; - srcPix = ((unsigned) sourceWord) >> d; - destPix = srcPix & mask; - mask = mask << cmBitsPerColor; - srcPix = ((unsigned) srcPix) >> d; - destPix = (destPix + (srcPix & mask)) + ((((unsigned) srcPix) >> d) & (mask << cmBitsPerColor)); - if (destPix == 0) { - sourceWord = 1; - goto l1; - } - sourceWord = destPix; - goto l1; - } - l1: /* end rgbMap:from:to: */; - sourceWord = longAt(((((char *) colorMap)) + 4) + (sourceWord << 2)); - sourceWord = sourceWord << srcShift; - destWord = longAt(dstIndex); - destWord = destWord & dstMask; - longAtput(dstIndex, sourceWord | destWord); - } - srcIndex += 4; - if (srcShift == 0) { - dstIndex += 4; - srcShift = 24; - dstMask = 16777215; - } else { - srcShift -= 8; - dstMask = (((unsigned) dstMask) >> 8) | 4278190080U; - } - adjust = adjust ^ 522133279; - } - srcY += 1; - dstY += 1; - } -} - -int argumentCountOf(int methodPointer) { - return (((unsigned) (longAt(((((char *) methodPointer)) + 4) + (0 << 2)))) >> 25) & 15; -} - -void * arrayValueOf(int arrayOop) { - if ((!((arrayOop & 1))) && (isWordsOrBytes(arrayOop))) { - return (void *) (arrayOop + 4); - } - /* begin primitiveFail */ - successFlag = 0; -} - -int asciiDirectoryDelimiter(void) { - return dir_Delimitor(); -} - -int asciiOfCharacter(int characterObj) { - int ccIndex; - int cl; - - /* begin assertClassOf:is: */ - if ((characterObj & 1)) { - successFlag = 0; - goto l1; - } - ccIndex = (((unsigned) (longAt(characterObj))) >> 12) & 31; - if (ccIndex == 0) { - cl = (longAt(characterObj - 4)) & 4294967292U; - } else { - cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - } - /* begin success: */ - successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (19 << 2)))) && successFlag; -l1: /* end assertClassOf:is: */; - if (successFlag) { - return longAt(((((char *) characterObj)) + 4) + (0 << 2)); - } else { - return 1; - } -} - -AsyncFile * asyncFileValueOf(int oop) { - int successValue; - - /* begin success: */ - successValue = (!((oop & 1))) && ((((((unsigned) (longAt(oop))) >> 8) & 15) >= 8) && ((lengthOf(oop)) == (sizeof(AsyncFile)))); - successFlag = successValue && successFlag; - if (!(successFlag)) { - return null; - } - return (AsyncFile *) (oop + 4); -} +/* If this object is old, mark it as a root (because a new object may be stored into it) */ int beRootIfOld(int oop) { int header; @@ -1950,27 +1630,31 @@ int becomewith(int array1, int array2) { return becomewithtwoWay(array1, array2, 1); } + +/* All references to each object in array1 are swapped with all references to the corresponding object in array2. That is, all pointers to one object are replaced with with pointers to the other. The arguments must be arrays of the same length. Returns true if the primitive succeeds. */ +/* Implementation: Uses forwarding blocks to update references as done in compaction. */ + int becomewithtwoWay(int array1, int array2, int twoWayFlag) { - int fieldOffset; int oop1; int oop2; int hdr1; int hdr2; + int fieldOffset; int fwdBlock; int fwdHeader; int fwdBlock1; int fwdHeader1; - int fwdBlock2; int oop11; int oop21; int hdr11; + int fwdBlock2; int hdr21; + int fwdBlock11; + int fwdHeader2; + int header; + int fmt; int methodHeader; int sz; - int fmt; - int header; - int fwdBlock3; - int fwdHeader2; int header1; int type; @@ -2002,42 +1686,42 @@ int becomewithtwoWay(int array1, int array2, int twoWayFlag) { if (fmt <= 4) { if ((fmt == 3) && (isContextHeader(header))) { fieldOffset = (6 + (fetchStackPointerOf(array1))) * 4; - goto l1; + goto l3; } /* begin sizeBitsOfSafe: */ header1 = longAt(array1); /* begin rightType: */ if ((header1 & 252) == 0) { type = 0; - goto l2; + goto l1; } else { if ((header1 & 126976) == 0) { type = 1; - goto l2; + goto l1; } else { type = 3; - goto l2; + goto l1; } } - l2: /* end rightType: */; + l1: /* end rightType: */; if (type == 0) { sz = (longAt(array1 - 8)) & 4294967292U; - goto l3; + goto l2; } else { sz = header1 & 252; - goto l3; + goto l2; } - l3: /* end sizeBitsOfSafe: */; + l2: /* end sizeBitsOfSafe: */; fieldOffset = sz - 4; - goto l1; + goto l3; } if (fmt < 12) { fieldOffset = 0; - goto l1; + goto l3; } methodHeader = longAt(array1 + 4); fieldOffset = (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; - l1: /* end lastPointerOf: */; + l3: /* end lastPointerOf: */; while (fieldOffset >= 4) { oop1 = longAt(array1 + fieldOffset); oop2 = longAt(array2 + fieldOffset); @@ -2066,9 +1750,9 @@ int becomewithtwoWay(int array1, int array2, int twoWayFlag) { oop21 = longAt(fwdBlock2); /* begin restoreHeaderOf: */ fwdHeader2 = longAt(oop11); - fwdBlock3 = (fwdHeader2 & 2147483644) << 1; + fwdBlock11 = (fwdHeader2 & 2147483644) << 1; ; - longAtput(oop11, longAt(fwdBlock3 + 4)); + longAtput(oop11, longAt(fwdBlock11 + 4)); hdr11 = longAt(oop11); hdr21 = longAt(oop21); longAtput(oop21, (hdr21 & 3758227455U) | (hdr11 & 536739840)); @@ -2079,54 +1763,6 @@ int becomewithtwoWay(int array1, int array2, int twoWayFlag) { return 1; } -int bitAndwith(int sourceWord, int destinationWord) { - return sourceWord & destinationWord; -} - -int bitAndInvertwith(int sourceWord, int destinationWord) { - return sourceWord & (~destinationWord); -} - -int bitInvertAndwith(int sourceWord, int destinationWord) { - return (~sourceWord) & destinationWord; -} - -int bitInvertAndInvertwith(int sourceWord, int destinationWord) { - return (~sourceWord) & (~destinationWord); -} - -int bitInvertDestinationwith(int sourceWord, int destinationWord) { - return ~destinationWord; -} - -int bitInvertOrwith(int sourceWord, int destinationWord) { - return (~sourceWord) | destinationWord; -} - -int bitInvertOrInvertwith(int sourceWord, int destinationWord) { - return (~sourceWord) | (~destinationWord); -} - -int bitInvertSourcewith(int sourceWord, int destinationWord) { - return ~sourceWord; -} - -int bitInvertXorwith(int sourceWord, int destinationWord) { - return (~sourceWord) ^ destinationWord; -} - -int bitOrwith(int sourceWord, int destinationWord) { - return sourceWord | destinationWord; -} - -int bitOrInvertwith(int sourceWord, int destinationWord) { - return sourceWord | (~destinationWord); -} - -int bitXorwith(int sourceWord, int destinationWord) { - return sourceWord ^ destinationWord; -} - int booleanValueOf(int obj) { if (obj == trueObj) { return 1; @@ -2138,25 +1774,6 @@ int booleanValueOf(int obj) { return null; } -int byteLengthOf(int oop) { - int sz; - int header; - int fmt; - - header = longAt(oop); - if ((header & 3) == 0) { - sz = (longAt(oop - 8)) & 4294967292U; - } else { - sz = header & 252; - } - fmt = (((unsigned) header) >> 8) & 15; - if (fmt < 8) { - return sz - 4; - } else { - return (sz - 4) - (fmt & 3); - } -} - int byteSizeOf(int oop) { int slots; int header; @@ -2185,7 +1802,8 @@ int byteSizeOf(int oop) { slots = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); goto l2; } -l2: /* end lengthOf:baseHeader:format: */; + slots = null; +l2: /* end lengthOf: */; l1: /* end slotSizeOf: */; if (((((unsigned) (longAt(oop))) >> 8) & 15) >= 8) { return slots; @@ -2194,320 +1812,141 @@ int byteSizeOf(int oop) { } } -int byteSwapped(int w) { - return ((((((unsigned) w >> 24)) & 255) + ((((unsigned) w >> 8)) & 65280)) + ((((unsigned) w << 8)) & 16711680)) + ((((unsigned) w << 24)) & 4278190080U); -} -int bytecodeActivateNewMethod(void) { +/* Byte-swap the words of all bytes objects in a range of the image, including Strings, ByteArrays, and CompiledMethods. This returns these objects to their original byte ordering after blindly byte-swapping the entire image. For compiled methods, byte-swap only their bytecodes part. */ + +int byteSwapByteObjectsFromto(int startOop, int stopAddr) { + int oop; + int wordAddr; + int fmt; int methodHeader; - int i; - int nilOop; - int tempCount; - int newContext; - int initialIP; - int cntxt; - int tmp; + int stopAddr1; + int addr; + int sz; + int extra; + int header; + int extra1; + int type; - methodHeader = longAt(((((char *) newMethod)) + 4) + (0 << 2)); - /* begin allocateOrRecycleContext */ - if (freeContexts != 1) { - cntxt = freeContexts; - freeContexts = longAt(((((char *) cntxt)) + 4) + (0 << 2)); - newContext = cntxt; - goto l1; - } - cntxt = instantiateContextsizeInBytes(longAt(((((char *) specialObjectsOop)) + 4) + (10 << 2)), 156); - longAtput(((((char *) cntxt)) + 4) + (4 << 2), nilObj); - newContext = cntxt; -l1: /* end allocateOrRecycleContext */; - initialIP = ((1 + ((((unsigned) methodHeader) >> 10) & 255)) * 4) + 1; - tempCount = (((unsigned) methodHeader) >> 19) & 63; - longAtput(((((char *) newContext)) + 4) + (0 << 2), activeContext); - longAtput(((((char *) newContext)) + 4) + (1 << 2), ((initialIP << 1) | 1)); - longAtput(((((char *) newContext)) + 4) + (2 << 2), ((tempCount << 1) | 1)); - longAtput(((((char *) newContext)) + 4) + (3 << 2), newMethod); - for (i = 0; i <= argumentCount; i += 1) { - longAtput(((((char *) newContext)) + 4) + ((5 + i) << 2), longAt(stackPointer - ((argumentCount - i) * 4))); - } - nilOop = nilObj; - for (i = (argumentCount + 1); i <= tempCount; i += 1) { - longAtput(((((char *) newContext)) + 4) + ((5 + i) << 2), nilOop); - } - /* begin pop: */ - stackPointer -= (argumentCount + 1) * 4; - reclaimableContextCount += 1; - /* begin newActiveContext: */ - /* begin storeContextRegisters: */ - longAtput(((((char *) activeContext)) + 4) + (1 << 2), ((((instructionPointer - method) - (4 - 2)) << 1) | 1)); - longAtput(((((char *) activeContext)) + 4) + (2 << 2), (((((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) - 6) + 1) << 1) | 1)); - if (newContext < youngStart) { - beRootIfOld(newContext); - } - activeContext = newContext; - /* begin fetchContextRegisters: */ - tmp = longAt(((((char *) newContext)) + 4) + (3 << 2)); - if ((tmp & 1)) { - tmp = longAt(((((char *) newContext)) + 4) + (5 << 2)); - if (tmp < youngStart) { - beRootIfOld(tmp); + oop = startOop; + while (oop < stopAddr) { + if (!(((longAt(oop)) & 3) == 2)) { + fmt = (((unsigned) (longAt(oop))) >> 8) & 15; + if (fmt >= 8) { + wordAddr = oop + 4; + if (fmt >= 12) { + methodHeader = longAt(oop + 4); + wordAddr = (wordAddr + 4) + (((((unsigned) methodHeader) >> 10) & 255) * 4); + } + /* begin reverseBytesFrom:to: */ + stopAddr1 = oop + (sizeBitsOf(oop)); + addr = wordAddr; + while (addr < stopAddr1) { + longAtput(addr, ((((((unsigned) (longAt(addr)) >> 24)) & 255) + ((((unsigned) (longAt(addr)) >> 8)) & 65280)) + ((((unsigned) (longAt(addr)) << 8)) & 16711680)) + ((((unsigned) (longAt(addr)) << 24)) & 4278190080U)); + addr += 4; + } + } } - } else { - tmp = newContext; + /* begin objectAfter: */ + ; + if (((longAt(oop)) & 3) == 2) { + sz = (longAt(oop)) & 4294967292U; + } else { + /* begin sizeBitsOf: */ + header = longAt(oop); + if ((header & 3) == 0) { + sz = (longAt(oop - 8)) & 4294967292U; + goto l1; + } else { + sz = header & 252; + goto l1; + } + l1: /* end sizeBitsOf: */; + } + /* begin oopFromChunk: */ + /* begin extraHeaderBytes: */ + type = (longAt(oop + sz)) & 3; + if (type > 1) { + extra1 = 0; + } else { + if (type == 1) { + extra1 = 4; + } else { + extra1 = 8; + } + } + extra = extra1; + oop = (oop + sz) + extra; } - theHomeContext = tmp; - receiver = longAt(((((char *) tmp)) + 4) + (5 << 2)); - method = longAt(((((char *) tmp)) + 4) + (3 << 2)); - tmp = ((longAt(((((char *) newContext)) + 4) + (1 << 2))) >> 1); - instructionPointer = ((method + tmp) + 4) - 2; - tmp = ((longAt(((((char *) newContext)) + 4) + (2 << 2))) >> 1); - stackPointer = (newContext + 4) + (((6 + tmp) - 1) * 4); +} + + +/* Return the given integer with its bytes in the reverse order. */ + +int byteSwapped(int w) { + return ((((((unsigned) w >> 24)) & 255) + ((((unsigned) w >> 8)) & 65280)) + ((((unsigned) w << 8)) & 16711680)) + ((((unsigned) w << 24)) & 4278190080U); +} + + +/* Arg must lie in range 0-255! */ + +int characterForAscii(int ascii) { + return longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (24 << 2))))) + 4) + (ascii << 2)); } int characterTable(void) { return longAt(((((char *) specialObjectsOop)) + 4) + (24 << 2)); } -int checkCompressedFillIndexListmaxsegments(int fillList, int maxIndex, int nSegs) { + +/* Check for possible interrupts and handle one if necessary. */ + +int checkForInterrupts(void) { + int now; + int sema; + int xArray; int i; - int length; - int *fillPtr; - int runLength; - int runValue; - int nFills; - int header; + int sema1; + int index; + int xSize; + int hdr; + int totalLength; + int fixedFields; + int fmt; + int sp; int sz; + int classFormat; + int class; + int ccIndex; - /* begin slotSizeOf: */ - if ((fillList & 1)) { - length = 0; - goto l1; - } - /* begin lengthOf: */ - header = longAt(fillList); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(fillList - 8)) & 4294967292U; - } else { - sz = header & 252; + now = (ioMSecs()) & 536870911; + if (now < lastTick) { + nextPollTick = now + (nextPollTick - lastTick); + if (nextWakeupTick != 0) { + nextWakeupTick = now + (nextWakeupTick - lastTick); + } } - if (((((unsigned) header) >> 8) & 15) < 8) { - length = ((unsigned) (sz - 4)) >> 2; - goto l2; + if ((now - lastTick) < interruptChecksEveryNms) { + interruptCheckCounterFeedBackReset += 10; } else { - length = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l2; + if (interruptCheckCounterFeedBackReset <= 1000) { + interruptCheckCounterFeedBackReset = 1000; + } else { + interruptCheckCounterFeedBackReset -= 12; + } } -l2: /* end lengthOf:baseHeader:format: */; -l1: /* end slotSizeOf: */; - fillPtr = firstIndexableField(fillList); - nFills = 0; - for (i = 0; i <= (length - 1); i += 1) { - runLength = ((unsigned) ((((int *) fillPtr))[i]) >> 16); - runValue = ((((int *) fillPtr))[0]) & 65535; - if (!((runValue >= 0) && (runValue <= maxIndex))) { - return 0; - } - nFills += runLength; - } - return nFills == nSegs; -} - -int checkCompressedFills(int indexList) { - int fillIndex; - int i; - int *fillPtr; - int length; - int header; - int sz; - - if (!(((((unsigned) (longAt(indexList))) >> 8) & 15) == 6)) { - return 0; - } - /* begin slotSizeOf: */ - if ((indexList & 1)) { - length = 0; - goto l1; - } - /* begin lengthOf: */ - header = longAt(indexList); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(indexList - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - length = ((unsigned) (sz - 4)) >> 2; - goto l1; - } else { - length = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l1; - } - length = null; -l1: /* end slotSizeOf: */; - fillPtr = firstIndexableField(indexList); - for (i = 1; i <= length; i += 1) { - fillIndex = fillPtr[0]; - if (!(isFillOkay(fillIndex))) { - return 0; - } - fillPtr += 1; - } - return 1; -} - -int checkCompressedLineWidthssegments(int lineWidthList, int nSegments) { - int *ptr; - int i; - int length; - int runLength; - int nItems; - int header; - int sz; - - /* begin slotSizeOf: */ - if ((lineWidthList & 1)) { - length = 0; - goto l1; - } - /* begin lengthOf: */ - header = longAt(lineWidthList); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(lineWidthList - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - length = ((unsigned) (sz - 4)) >> 2; - goto l2; - } else { - length = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l2; - } -l2: /* end lengthOf:baseHeader:format: */; -l1: /* end slotSizeOf: */; - ptr = firstIndexableField(lineWidthList); - nItems = 0; - for (i = 0; i <= (length - 1); i += 1) { - runLength = ((unsigned) ((((int *) ptr))[i]) >> 16); - nItems += runLength; - } - return nItems == nSegments; -} - -int checkCompressedPointssegments(int points, int nSegments) { - int pSize; - int header; - int sz; - if (!(((((unsigned) (longAt(points))) >> 8) & 15) == 6)) { - return 0; - } - /* begin slotSizeOf: */ - if ((points & 1)) { - pSize = 0; - goto l1; - } - /* begin lengthOf: */ - header = longAt(points); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(points - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - pSize = ((unsigned) (sz - 4)) >> 2; - goto l2; - } else { - pSize = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l2; - } -l2: /* end lengthOf:baseHeader:format: */; -l1: /* end slotSizeOf: */; - if (!((pSize == (nSegments * 3)) || (pSize == (nSegments * 6)))) { - return 0; - } - return 1; -} - -int checkCompressedShapesegmentsleftFillsrightFillslineWidthslineFillsfillIndexList(int points, int nSegments, int leftFills, int rightFills, int lineWidths, int lineFills, int fillIndexList) { - int maxFillIndex; - int header; - int sz; + /* reset the interrupt check counter */ - if (!(checkCompressedPointssegments(points, nSegments))) { - return 0; - } - if (!(checkCompressedFills(fillIndexList))) { - return 0; - } - /* begin slotSizeOf: */ - if ((fillIndexList & 1)) { - maxFillIndex = 0; - goto l1; - } - /* begin lengthOf: */ - header = longAt(fillIndexList); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(fillIndexList - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - maxFillIndex = ((unsigned) (sz - 4)) >> 2; - goto l2; - } else { - maxFillIndex = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l2; - } -l2: /* end lengthOf:baseHeader:format: */; -l1: /* end slotSizeOf: */; - if (!(checkCompressedFillIndexListmaxsegments(leftFills, maxFillIndex, nSegments))) { - return 0; - } - if (!(checkCompressedFillIndexListmaxsegments(rightFills, maxFillIndex, nSegments))) { - return 0; - } - if (!(checkCompressedFillIndexListmaxsegments(lineFills, maxFillIndex, nSegments))) { - return 0; - } - if (!(checkCompressedLineWidthssegments(lineWidths, nSegments))) { - return 0; - } - return 1; -} + interruptCheckCounter = interruptCheckCounterFeedBackReset; -int checkForInterrupts(void) { - int sema; - int now; - int sema1; - int i; - int xArray; - int index; - int xSize; - int hdr; - int totalLength; - int fmt; - int fixedFields; - int sp; - int classFormat; - int class; - int sz; - int ccIndex; + /* used to detect millisecond clock wrapping */ - interruptCheckCounter = 1000; - now = (ioMSecs()) & 536870911; - if (now < lastTick) { - nextPollTick = now + (nextPollTick - lastTick); - if (nextWakeupTick != 0) { - nextWakeupTick = now + (nextWakeupTick - lastTick); - } - } lastTick = now; if (signalLowSpace) { + + /* reset flag */ + signalLowSpace = 0; sema = longAt(((((char *) specialObjectsOop)) + 4) + (17 << 2)); if (!(sema == nilObj)) { @@ -2516,9 +1955,12 @@ int checkForInterrupts(void) { } if (now >= nextPollTick) { ioProcessEvents(); - nextPollTick = now + 100; + nextPollTick = now + 500; } if (interruptPending) { + + /* reset interrupt flag */ + interruptPending = 0; sema = longAt(((((char *) specialObjectsOop)) + 4) + (30 << 2)); if (!(sema == nilObj)) { @@ -2526,6 +1968,9 @@ int checkForInterrupts(void) { } } if ((nextWakeupTick != 0) && (now >= nextWakeupTick)) { + + /* reset timer interrupt */ + nextWakeupTick = 0; sema = longAt(((((char *) specialObjectsOop)) + 4) + (29 << 2)); if (!(sema == nilObj)) { @@ -2539,8 +1984,9 @@ int checkForInterrupts(void) { } pendingFinalizationSignals = 0; } - if (semaphoresToSignalCount > 0) { + if ((semaphoresToSignalCountA > 0) || (semaphoresToSignalCountB > 0)) { /* begin signalExternalSemaphores */ + semaphoresUseBufferA = !semaphoresUseBufferA; xArray = longAt(((((char *) specialObjectsOop)) + 4) + (38 << 2)); /* begin stSizeOf: */ hdr = longAt(xArray); @@ -2553,20 +1999,20 @@ int checkForInterrupts(void) { } if (fmt < 8) { totalLength = ((unsigned) (sz - 4)) >> 2; - goto l2; + goto l1; } else { totalLength = (sz - 4) - (fmt & 3); - goto l2; + goto l1; } - l2: /* end lengthOf:baseHeader:format: */; + l1: /* end lengthOf:baseHeader:format: */; /* begin fixedFieldsOf:format:length: */ if ((fmt > 4) || (fmt == 2)) { fixedFields = 0; - goto l1; + goto l2; } if (fmt < 2) { fixedFields = totalLength; - goto l1; + goto l2; } /* begin fetchClassOf: */ if ((xArray & 1)) { @@ -2584,7 +2030,7 @@ int checkForInterrupts(void) { l3: /* end fetchClassOf: */; classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; - l1: /* end fixedFieldsOf:format:length: */; + l2: /* end fixedFieldsOf:format:length: */; if ((fmt == 3) && (isContextHeader(hdr))) { /* begin fetchStackPointerOf: */ sp = longAt(((((char *) xArray)) + 4) + (2 << 2)); @@ -2599,20 +2045,37 @@ int checkForInterrupts(void) { goto l4; } l4: /* end stSizeOf: */; - for (i = 1; i <= semaphoresToSignalCount; i += 1) { - index = semaphoresToSignal[i]; - if ((index > 0) && (index <= xSize)) { - sema1 = longAt(((((char *) xArray)) + 4) + ((index - 1) << 2)); - if ((fetchClassOf(sema1)) == (longAt(((((char *) specialObjectsOop)) + 4) + (18 << 2)))) { - synchronousSignal(sema1); + if (semaphoresUseBufferA) { + for (i = 1; i <= semaphoresToSignalCountB; i += 1) { + index = semaphoresToSignalB[i]; + if (index <= xSize) { + sema1 = longAt(((((char *) xArray)) + 4) + ((index - 1) << 2)); + if ((fetchClassOf(sema1)) == (longAt(((((char *) specialObjectsOop)) + 4) + (18 << 2)))) { + synchronousSignal(sema1); + } + } + } + semaphoresToSignalCountB = 0; + } else { + for (i = 1; i <= semaphoresToSignalCountA; i += 1) { + index = semaphoresToSignalA[i]; + if (index <= xSize) { + sema1 = longAt(((((char *) xArray)) + 4) + ((index - 1) << 2)); + if ((fetchClassOf(sema1)) == (longAt(((((char *) specialObjectsOop)) + 4) + (18 << 2)))) { + synchronousSignal(sema1); + } } } + semaphoresToSignalCountA = 0; } - semaphoresToSignalCount = 0; } } -int checkImageVersionFromstartingAt(sqImageFile f, int imageOffset) { + +/* Read and verify the image file version number and return true if the the given image file needs to be byte-swapped. As a side effect, position the file stream just after the version number of the image header. This code prints a warning and does a hard-exit if it cannot find a valid version number. */ +/* This code is based on C code by Ian Piumarta. */ + +int checkImageVersionFromstartingAt(sqImageFile f, squeakFileOffsetType imageOffset) { int version; int firstVersion; @@ -2649,6 +2112,9 @@ int checkImageVersionFromstartingAt(sqImageFile f, int imageOffset) { ioExit(); } + +/* Note: May be called by translated primitive code. */ + int checkedIntegerValueOf(int intOop) { if ((intOop & 1)) { return (intOop >> 1); @@ -2659,6 +2125,9 @@ int checkedIntegerValueOf(int intOop) { } } + +/* Assumes zero-based array indexing. For testing in Smalltalk, this method should be overridden in a subclass. */ + int checkedLongAt(int byteAddress) { /* begin checkAddress: */ if (byteAddress < (startOfMemory())) { @@ -2677,36 +2146,6 @@ int checkedLongAt(int byteAddress) { return longAt(byteAddress); } -double * circleCosTable(void) { - static double theTable[33] = - {1.0, 0.98078528040323, 0.923879532511287, 0.831469612302545, - 0.7071067811865475, 0.555570233019602, 0.38268343236509, 0.1950903220161286, - 0.0, -0.1950903220161283, -0.3826834323650896, -0.555570233019602, - -0.707106781186547, -0.831469612302545, -0.9238795325112865, -0.98078528040323, - -1.0, -0.98078528040323, -0.923879532511287, -0.831469612302545, - -0.707106781186548, -0.555570233019602, -0.3826834323650903, -0.1950903220161287, - 0.0, 0.1950903220161282, 0.38268343236509, 0.555570233019602, - 0.707106781186547, 0.831469612302545, 0.9238795325112865, 0.98078528040323, - 1.0 }; - - return theTable; -} - -double * circleSinTable(void) { - static double theTable[33] = - {0.0, 0.1950903220161282, 0.3826834323650897, 0.555570233019602, - 0.707106781186547, 0.831469612302545, 0.923879532511287, 0.98078528040323, - 1.0, 0.98078528040323, 0.923879532511287, 0.831469612302545, - 0.7071067811865475, 0.555570233019602, 0.38268343236509, 0.1950903220161286, - 0.0, -0.1950903220161283, -0.3826834323650896, -0.555570233019602, - -0.707106781186547, -0.831469612302545, -0.9238795325112865, -0.98078528040323, - -1.0, -0.98078528040323, -0.923879532511287, -0.831469612302545, - -0.707106781186548, -0.555570233019602, -0.3826834323650903, -0.1950903220161287, - 0.0 }; - - return theTable; -} - int classArray(void) { return longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)); } @@ -2723,27 +2162,54 @@ int classCharacter(void) { return longAt(((((char *) specialObjectsOop)) + 4) + (19 << 2)); } +int classExternalAddress(void) { + return longAt(((((char *) specialObjectsOop)) + 4) + (43 << 2)); +} + +int classExternalData(void) { + return longAt(((((char *) specialObjectsOop)) + 4) + (45 << 2)); +} + +int classExternalFunction(void) { + return longAt(((((char *) specialObjectsOop)) + 4) + (46 << 2)); +} + +int classExternalLibrary(void) { + return longAt(((((char *) specialObjectsOop)) + 4) + (47 << 2)); +} + +int classExternalStructure(void) { + return longAt(((((char *) specialObjectsOop)) + 4) + (44 << 2)); +} + int classFloat(void) { return longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)); } +int classLargeNegativeInteger(void) { + return longAt(((((char *) specialObjectsOop)) + 4) + (42 << 2)); +} + int classLargePositiveInteger(void) { return longAt(((((char *) specialObjectsOop)) + 4) + (13 << 2)); } + +/* Check if aClass' name is className */ + int classNameOfIs(int aClass, char *className) { - char *srcName; + int length; int i; int name; - int length; + char *srcName; int hdr; int totalLength; - int fmt; int fixedFields; + int fmt; int sp; + int sz; int classFormat; int class; - int sz; int ccIndex; if ((lengthOf(aClass)) <= 6) { @@ -2764,20 +2230,20 @@ int classNameOfIs(int aClass, char *className) { } if (fmt < 8) { totalLength = ((unsigned) (sz - 4)) >> 2; - goto l2; + goto l1; } else { totalLength = (sz - 4) - (fmt & 3); - goto l2; + goto l1; } -l2: /* end lengthOf:baseHeader:format: */; +l1: /* end lengthOf:baseHeader:format: */; /* begin fixedFieldsOf:format:length: */ if ((fmt > 4) || (fmt == 2)) { fixedFields = 0; - goto l1; + goto l2; } if (fmt < 2) { fixedFields = totalLength; - goto l1; + goto l2; } /* begin fetchClassOf: */ if ((name & 1)) { @@ -2795,7 +2261,7 @@ int classNameOfIs(int aClass, char *className) { l3: /* end fetchClassOf: */; classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; -l1: /* end fixedFieldsOf:format:length: */; +l2: /* end fixedFieldsOf:format:length: */; if ((fmt == 3) && (isContextHeader(hdr))) { /* begin fetchStackPointerOf: */ sp = longAt(((((char *) name)) + 4) + (2 << 2)); @@ -2835,94 +2301,116 @@ int classString(void) { return longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)); } -int clearSpanBuffer(void) { - int x0; - int x1; - x0 = ((unsigned) (workBuffer[32])) >> (workBuffer[49]); - x1 = (((unsigned) (workBuffer[34])) >> (workBuffer[49])) + 1; - if (x0 < 0) { - x0 = 0; - } - if (x1 > (workBuffer[33])) { - x1 = workBuffer[33]; - } - while (x0 < x1) { - spanBuffer[x0] = 0; - x0 += 1; - } - workBuffer[32] = (workBuffer[33]); - workBuffer[34] = 0; -} +/* Sweep memory, nilling out all fields of contexts above the stack pointer. */ -int clearWordwith(int source, int destination) { - return 0; -} +int cleanUpContexts(void) { + int header; + int i; + int oop; + int fmt; + int sz; + int header1; + int chunk; + int extra; + int extra1; + int type; + int sz1; + int extra2; + int header2; + int extra11; + int type1; -int clipRange(void) { - if (destX >= clipX) { - sx = sourceX; - dx = destX; - bbW = width; - } else { - sx = sourceX + (clipX - destX); - bbW = width - (clipX - destX); - dx = clipX; - } - if ((dx + bbW) > (clipX + clipWidth)) { - bbW -= (dx + bbW) - (clipX + clipWidth); - } - if (destY >= clipY) { - sy = sourceY; - dy = destY; - bbH = height; + /* begin oopFromChunk: */ + chunk = startOfMemory(); + /* begin extraHeaderBytes: */ + type = (longAt(chunk)) & 3; + if (type > 1) { + extra1 = 0; } else { - sy = (sourceY + clipY) - destY; - bbH = height - (clipY - destY); - dy = clipY; - } - if ((dy + bbH) > (clipY + clipHeight)) { - bbH -= (dy + bbH) - (clipY + clipHeight); - } - if (noSource) { - return null; - } - if (sx < 0) { - dx -= sx; - bbW += sx; - sx = 0; - } - if ((sx + bbW) > srcWidth) { - bbW -= (sx + bbW) - srcWidth; - } - if (sy < 0) { - dy -= sy; - bbH += sy; - sy = 0; - } - if ((sy + bbH) > srcHeight) { - bbH -= (sy + bbH) - srcHeight; + if (type == 1) { + extra1 = 4; + } else { + extra1 = 8; + } } -} - -int clone(int oop) { - int hash; - int fromIndex; - int lastFrom; - int bytes; + extra = extra1; + oop = chunk + extra; + while (oop < endOfMemory) { + if (!(((longAt(oop)) & 3) == 2)) { + header = longAt(oop); + fmt = (((unsigned) header) >> 8) & 15; + if ((fmt == 3) && (isContextHeader(header))) { + /* begin sizeBitsOf: */ + header1 = longAt(oop); + if ((header1 & 3) == 0) { + sz = (longAt(oop - 8)) & 4294967292U; + goto l1; + } else { + sz = header1 & 252; + goto l1; + } + l1: /* end sizeBitsOf: */; + for (i = ((lastPointerOf(oop)) + 4); i <= (sz - 4); i += 4) { + longAtput(oop + i, nilObj); + } + } + } + /* begin objectAfter: */ + ; + if (((longAt(oop)) & 3) == 2) { + sz1 = (longAt(oop)) & 4294967292U; + } else { + /* begin sizeBitsOf: */ + header2 = longAt(oop); + if ((header2 & 3) == 0) { + sz1 = (longAt(oop - 8)) & 4294967292U; + goto l2; + } else { + sz1 = header2 & 252; + goto l2; + } + l2: /* end sizeBitsOf: */; + } + /* begin oopFromChunk: */ + /* begin extraHeaderBytes: */ + type1 = (longAt(oop + sz1)) & 3; + if (type1 > 1) { + extra11 = 0; + } else { + if (type1 == 1) { + extra11 = 4; + } else { + extra11 = 8; + } + } + extra2 = extra11; + oop = (oop + sz1) + extra2; + } +} + + +/* Return a shallow copy of the given object. */ +/* Assume: Oop is a real object, not a small integer. */ + +int clone(int oop) { int extraHdrBytes; - int remappedOop; + int fromIndex; int toIndex; + int header; int newOop; int newChunk; - int header; + int hash; + int lastFrom; + int bytes; + int remappedOop; int oop1; - int type; int extra; + int type; int header1; - int newFreeSize; int enoughSpace; int newChunk1; + int newFreeSize; int minFree; /* begin extraHeaderBytes: */ @@ -2947,6 +2435,9 @@ int clone(int oop) { goto l1; } l1: /* end sizeBitsOf: */; + + /* allocate space for the copy, remapping oop in case of a GC */ + bytes += extraHdrBytes; /* begin pushRemappableOop: */ remapBuffer[remapBufferCount += 1] = oop; @@ -2983,30 +2474,48 @@ int clone(int oop) { oop1 = remapBuffer[remapBufferCount]; remapBufferCount -= 1; remappedOop = oop1; + + /* loop below uses pre-increment */ + toIndex = newChunk - 4; fromIndex = (remappedOop - extraHdrBytes) - 4; lastFrom = fromIndex + bytes; while (fromIndex < lastFrom) { longAtput(toIndex += 4, longAt(fromIndex += 4)); } + + /* convert from chunk to oop */ + /* fix base header: compute new hash and clear Mark and Root bits */ + newOop = newChunk + extraHdrBytes; /* begin newObjectHash */ lastHash = (13849 + (27181 * lastHash)) & 65535; hash = lastHash; + + /* use old ccIndex, format, size, and header-type fields */ + header = (longAt(newOop)) & 131071; header = header | ((hash << 17) & 536739840); longAtput(newOop, header); return newOop; } + +/* This code is called if the receiver responds primitively to at:. + If this is so, it will be installed in the atCache so that subsequent calls of at: + or next may be handled immediately in bytecode primitive routines. */ + int commonAt(int stringy) { - int index; - int rcvr; - int atIx; int result; + int atIx; + int rcvr; + int index; int sp; int sp1; + + /* Sets successFlag */ + index = positive32BitValueOf(longAt(stackPointer - (0 * 4))); rcvr = longAt(stackPointer - (1 * 4)); if (!(successFlag && (!((rcvr & 1))))) { @@ -3015,6 +2524,9 @@ int commonAt(int stringy) { return null; } if ((messageSelector == (longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((16 * 2) << 2)))) && (lkupClass == (fetchClassOfNonInt(rcvr)))) { + + /* Index into atCache = 4N, for N = 0 ... 7 */ + atIx = rcvr & 28; if (!((atCache[atIx + 1]) == rcvr)) { installinAtCacheatstring(rcvr, atCache, atIx, stringy); @@ -3042,19 +2554,27 @@ int commonAt(int stringy) { } } + +/* This code is called if the receiver responds primitively to at:Put:. + If this is so, it will be installed in the atPutCache so that subsequent calls of at: + or next may be handled immediately in bytecode primitive routines. */ + int commonAtPut(int stringy) { + int atIx; int value; - int index; int rcvr; - int atIx; - int stSize; - int valToPut; - int fmt; + int index; int fixedFields; + int fmt; + int valToPut; + int stSize; int sp; int sp1; value = longAt(stackPointer - (0 * 4)); + + /* Sets successFlag */ + index = positive32BitValueOf(longAt(stackPointer - (1 * 4))); rcvr = longAt(stackPointer - (2 * 4)); if (!(successFlag && (!((rcvr & 1))))) { @@ -3063,6 +2583,9 @@ int commonAtPut(int stringy) { return null; } if ((messageSelector == (longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((17 * 2) << 2)))) && (lkupClass == (fetchClassOfNonInt(rcvr)))) { + + /* Index into atPutCache */ + atIx = (rcvr & 28) + 32; if (!((atCache[atIx + 1]) == rcvr)) { installinAtCacheatstring(rcvr, atCache, atIx, stringy); @@ -3097,7 +2620,13 @@ int commonAtPut(int stringy) { valToPut = value; } if ((valToPut & 1)) { - byteAtput(((((char *) rcvr)) + 4) + (index - 1), (valToPut >> 1)); + valToPut = (valToPut >> 1); + if (!((valToPut >= 0) && (valToPut <= 255))) { + /* begin primitiveFail */ + successFlag = 0; + goto l1; + } + byteAtput(((((char *) rcvr)) + 4) + (index - 1), valToPut); goto l1; } } @@ -3126,11 +2655,14 @@ int commonAtPut(int stringy) { } } + +/* This code assumes the reciever has been identified at location atIx in the atCache. */ + int commonVariableatcacheIndex(int rcvr, int index, int atIx) { - int stSize; - int fmt; int fixedFields; int result; + int fmt; + int stSize; stSize = atCache[atIx + 2]; if (((((unsigned ) index)) >= 1) && ((((unsigned ) index)) <= (((unsigned ) stSize)))) { @@ -3154,6 +2686,10 @@ int commonVariableatcacheIndex(int rcvr, int index, int atIx) { successFlag = 0; } + +/* May set success to false */ +/* First compare two ST integers... */ + int compare31or32Bitsequal(int obj1, int obj2) { if (((obj1 & 1)) && ((obj2 & 1))) { return obj1 == obj2; @@ -3161,8 +2697,8 @@ int compare31or32Bitsequal(int obj1, int obj2) { return (positive32BitValueOf(obj1)) == (positive32BitValueOf(obj2)); } -int compilerActivateMethod(void) { - return compilerHooks[1](); +int compilerCreateActualMessagestoringArgs(int aMessage, int argArray) { + return compilerHooks[14](aMessage, argArray); } int compilerFlushCache(int aCompiledMethod) { @@ -3197,178 +2733,23 @@ int compilerProcessChange(void) { return compilerHooks[6](); } -int computeBeziersplitAt(int index, double param) { - int viaX; - int viaY; - int sharedX; - int sharedY; - int startX; - int startY; - int leftViaX; - int leftViaY; - int rightViaX; - int rightViaY; - int endX; - int endY; - int newIndex; - - leftViaX = startX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 0)]; - leftViaY = startY = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 1)]; - rightViaX = viaX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 2)]; - rightViaY = viaY = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 3)]; - endX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 4)]; - endY = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 5)]; - sharedX = leftViaX += ((int) ((((double) (viaX - startX) )) * param) ); - sharedY = leftViaY += ((int) ((((double) (viaY - startY) )) * param) ); - rightViaX += ((int) ((((double) (endX - viaX) )) * param) ); - rightViaY += ((int) ((((double) (endY - viaY) )) * param) ); - sharedX += ((int) ((((double) (rightViaX - leftViaX) )) * param) ); - sharedY += ((int) ((((double) (rightViaY - leftViaY) )) * param) ); - /* begin assureValue:between:and: */ - if (startY > sharedY) { - if (leftViaY > startY) { - leftViaY = startY; - goto l1; - } - if (leftViaY < sharedY) { - leftViaY = sharedY; - goto l1; - } - } else { - if (leftViaY < startY) { - leftViaY = startY; - goto l1; - } - if (leftViaY > sharedY) { - leftViaY = sharedY; - goto l1; - } - } - leftViaY = leftViaY; -l1: /* end assureValue:between:and: */; - /* begin assureValue:between:and: */ - if (sharedY > endY) { - if (rightViaY > sharedY) { - rightViaY = sharedY; - goto l2; - } - if (rightViaY < endY) { - rightViaY = endY; - goto l2; - } - } else { - if (rightViaY < sharedY) { - rightViaY = sharedY; - goto l2; - } - if (rightViaY > endY) { - rightViaY = endY; - goto l2; - } - } - rightViaY = rightViaY; -l2: /* end assureValue:between:and: */; - /* begin allocateBezierStackEntry */ - /* begin wbStackPush: */ - if (!(needAvailableSpace(6))) { - goto l3; - } - workBuffer[10] = ((workBuffer[10]) - 6); -l3: /* end wbStackPush: */; - newIndex = (workBuffer[1]) - (workBuffer[10]); - if (engineStopped) { - return 0; - } - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 2)] = leftViaX; - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 3)] = leftViaY; - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 4)] = sharedX; - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 5)] = sharedY; - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 0)] = sharedX; - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 1)] = sharedY; - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 2)] = rightViaX; - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 3)] = rightViaY; - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 4)] = endX; - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 5)] = endY; - return newIndex; -} - -int computeBezierSplitAtHalf(int index) { - int viaX; - int viaY; - int sharedX; - int sharedY; - int startX; - int startY; - int leftViaX; - int leftViaY; - int rightViaX; - int rightViaY; - int endX; - int endY; - int newIndex; - - /* begin allocateBezierStackEntry */ - /* begin wbStackPush: */ - if (!(needAvailableSpace(6))) { - goto l1; - } - workBuffer[10] = ((workBuffer[10]) - 6); -l1: /* end wbStackPush: */; - newIndex = (workBuffer[1]) - (workBuffer[10]); - if (engineStopped) { - return 0; - } - leftViaX = startX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 0)]; - leftViaY = startY = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 1)]; - rightViaX = viaX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 2)]; - rightViaY = viaY = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 3)]; - endX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 4)]; - endY = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 5)]; - leftViaX += ((int) (viaX - startX) >> 1); - leftViaY += ((int) (viaY - startY) >> 1); - sharedX = rightViaX += ((int) (endX - viaX) >> 1); - sharedY = rightViaY += ((int) (endY - viaY) >> 1); - sharedX += ((int) (leftViaX - rightViaX) >> 1); - sharedY += ((int) (leftViaY - rightViaY) >> 1); - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 2)] = leftViaX; - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 3)] = leftViaY; - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 4)] = sharedX; - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 5)] = sharedY; - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 0)] = sharedX; - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 1)] = sharedY; - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 2)] = rightViaX; - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 3)] = rightViaY; - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 4)] = endX; - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - newIndex) + 5)] = endY; - return newIndex; -} - -int computeFinalWideBezierValueswidth(int bezier, int lineWidth) { - int leftX; - int rightX; - int temp; - - leftX = ((int) (((objBuffer + bezier) + 10)[0]) >> 8); - rightX = ((int) (((objBuffer + bezier) + 22)[0]) >> 8); - if (leftX > rightX) { - temp = leftX; - leftX = rightX; - rightX = temp; - } - objBuffer[bezier + 4] = leftX; - if ((rightX - leftX) > lineWidth) { - objBuffer[bezier + 17] = (rightX - leftX); - } else { - objBuffer[bezier + 17] = lineWidth; - } +int compilerProcessChangeto(int oldProc, int newProc) { + return compilerHooks[6](oldProc, newProc); +} + +int compilerTranslateMethod(void) { + return compilerHooks[1](); } + +/* Return true if neither array contains a small integer. You can't become: integers! */ + int containOnlyOopsand(int array1, int array2) { int fieldOffset; + int header; + int fmt; int methodHeader; int sz; - int fmt; - int header; int header1; int type; @@ -3426,448 +2807,80 @@ int containOnlyOopsand(int array1, int array2) { return 1; } -int copyBits(void) { - int done; - int integerPointer; - int dWid; - int sxLowBits; - int dxLowBits; - int pixPerM1; - int t; - int sp; - clipRange(); - if ((bbW <= 0) || (bbH <= 0)) { - affectedL = affectedR = affectedT = affectedB = 0; - return null; - } - /* begin tryCopyingBitsQuickly */ - if (noSource) { - done = 0; - goto l2; - } - if (!(combinationRule == 34)) { - done = 0; - goto l2; - } - if (!(sourcePixSize == 32)) { - done = 0; - goto l2; - } - if (sourceForm == destForm) { - done = 0; - goto l2; - } - if (destPixSize < 8) { - done = 0; - goto l2; - } - if ((destPixSize == 8) && (colorMap == nilObj)) { - done = 0; - goto l2; - } - if (destPixSize == 32) { - alphaSourceBlendBits32(); - } - if (destPixSize == 16) { - alphaSourceBlendBits16(); - } - if (destPixSize == 8) { - alphaSourceBlendBits8(); - } - affectedL = dx; - affectedR = dx + bbW; - affectedT = dy; - affectedB = dy + bbH; - done = 1; -l2: /* end tryCopyingBitsQuickly */; - if (done) { - return null; - } - destMaskAndPointerInit(); - bitCount = 0; - if ((combinationRule == 30) || (combinationRule == 31)) { - if (argumentCount == 1) { - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - sourceAlpha = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - sourceAlpha = 0; - goto l1; - } - l1: /* end stackIntegerValue: */; - if ((!(!successFlag)) && ((sourceAlpha >= 0) && (sourceAlpha <= 255))) { - /* begin pop: */ - stackPointer -= 1 * 4; - } else { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - } else { - /* begin primitiveFail */ - successFlag = 0; - return null; - } +/* Does thisCntx have aContext in its sender chain? */ + +int contexthasSender(int thisCntx, int aContext) { + int s; + int nilOop; + + if (thisCntx == aContext) { + return 0; } - if (noSource) { - copyLoopNoSource(); - } else { - /* begin checkSourceOverlap */ - if ((sourceForm == destForm) && (dy >= sy)) { - if (dy > sy) { - vDir = -1; - sy = (sy + bbH) - 1; - dy = (dy + bbH) - 1; - } else { - if ((dy == sy) && (dx > sx)) { - hDir = -1; - sx = (sx + bbW) - 1; - dx = (dx + bbW) - 1; - if (nWords > 1) { - t = mask1; - mask1 = mask2; - mask2 = t; - } - } - } - destIndex = (destBits + 4) + (((dy * destRaster) + (dx / pixPerWord)) * 4); - destDelta = 4 * ((destRaster * vDir) - (nWords * hDir)); - } - if ((sourcePixSize != destPixSize) || (colorMap != nilObj)) { - copyLoopPixMap(); - } else { - /* begin sourceSkewAndPointerInit */ - pixPerM1 = pixPerWord - 1; - sxLowBits = sx & pixPerM1; - dxLowBits = dx & pixPerM1; - if (hDir > 0) { - dWid = ((bbW < (pixPerWord - dxLowBits)) ? bbW : (pixPerWord - dxLowBits)); - preload = (sxLowBits + dWid) > pixPerM1; - } else { - dWid = ((bbW < (dxLowBits + 1)) ? bbW : (dxLowBits + 1)); - preload = ((sxLowBits - dWid) + 1) < 0; - } - skew = (sxLowBits - dxLowBits) * destPixSize; - if (preload) { - if (skew < 0) { - skew += 32; - } else { - skew -= 32; - } - } - sourceIndex = (sourceBits + 4) + (((sy * sourceRaster) + (sx / (32 / sourcePixSize))) * 4); - sourceDelta = 4 * ((sourceRaster * vDir) - (nWords * hDir)); - if (preload) { - sourceDelta -= 4 * hDir; - } - copyLoop(); + nilOop = nilObj; + s = longAt(((((char *) thisCntx)) + 4) + (0 << 2)); + while (!(s == nilOop)) { + if (s == aContext) { + return 1; } + s = longAt(((((char *) s)) + 4) + (0 << 2)); } - if ((combinationRule == 22) || (combinationRule == 32)) { - affectedL = affectedR = affectedT = affectedB = 0; - /* begin pop: */ - stackPointer -= 1 * 4; - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, ((bitCount << 1) | 1)); - stackPointer = sp; + return 0; +} + + +/* This entry point needs to be implemented for the interpreter proxy. + Since BitBlt is now a plugin we need to look up BitBltPlugin_copyBits + and call it. This entire mechanism should eventually go away and be + replaced with a dynamic lookup from BitBltPlugin itself but for backward + compatibility this stub is provided */ + +int copyBits(void) { + int fn; + + fn = ioLoadFunctionFrom("copyBits", "BitBltPlugin"); + if (fn == 0) { + /* begin primitiveFail */ + successFlag = 0; return null; } - if (hDir > 0) { - affectedL = dx; - affectedR = dx + bbW; - } else { - affectedL = (dx - bbW) + 1; - affectedR = dx + 1; - } - if (vDir > 0) { - affectedT = dy; - affectedB = dy + bbH; - } else { - affectedT = (dy - bbH) + 1; - affectedB = dy + 1; - } + return ((int (*) (void)) fn)(); } -int copyBitsFromtoat(int startX, int stopX, int yValue) { - destX = startX; - destY = yValue; - sourceX = startX; - width = stopX - startX; - copyBits(); -} -int copyLoop(void) { - int y; - int prevWord; - int skewWord; - int mergeWord; - int hInc; - int skewMask; - int (*mergeFnwith)(int, int); - int i; - int thisWord; - int word; - int halftoneWord; - int notSkewMask; - int unskew; - - mergeFnwith = ((int (*)(int, int)) (opTable[combinationRule + 1])); - mergeFnwith; - hInc = hDir * 4; - if (skew == -32) { - skew = unskew = skewMask = 0; - } else { - if (skew < 0) { - unskew = skew + 32; - skewMask = 4294967295U << (0 - skew); - } else { - if (skew == 0) { - unskew = 0; - skewMask = 4294967295U; - } else { - unskew = skew - 32; - skewMask = ((unsigned) 4294967295U) >> skew; - } - } - } - notSkewMask = ~skewMask; - if (noHalftone) { - halftoneWord = 4294967295U; - halftoneHeight = 0; - } else { - halftoneWord = longAt(halftoneBase); - } - y = dy; - for (i = 1; i <= bbH; i += 1) { - if (halftoneHeight > 1) { - halftoneWord = longAt(halftoneBase + ((y % halftoneHeight) * 4)); - y += vDir; - } - if (preload) { - prevWord = longAt(sourceIndex); - sourceIndex += hInc; - } else { - prevWord = 0; - } - destMask = mask1; - thisWord = longAt(sourceIndex); - sourceIndex += hInc; - skewWord = (((unskew < 0) ? ((unsigned) (prevWord & notSkewMask) >> -unskew) : ((unsigned) (prevWord & notSkewMask) << unskew))) | (((skew < 0) ? ((unsigned) (thisWord & skewMask) >> -skew) : ((unsigned) (thisWord & skewMask) << skew))); - prevWord = thisWord; - mergeWord = mergeFnwith(skewWord & halftoneWord, longAt(destIndex)); - longAtput(destIndex, (destMask & mergeWord) | ((~destMask) & (longAt(destIndex)))); - destIndex += hInc; - destMask = 4294967295U; - if (combinationRule == 3) { - if (noHalftone && (notSkewMask == 0)) { - for (word = 2; word <= (nWords - 1); word += 1) { - thisWord = longAt(sourceIndex); - sourceIndex += hInc; - longAtput(destIndex, thisWord); - destIndex += hInc; - } - } else { - for (word = 2; word <= (nWords - 1); word += 1) { - thisWord = longAt(sourceIndex); - sourceIndex += hInc; - skewWord = (((unskew < 0) ? ((unsigned) (prevWord & notSkewMask) >> -unskew) : ((unsigned) (prevWord & notSkewMask) << unskew))) | (((skew < 0) ? ((unsigned) (thisWord & skewMask) >> -skew) : ((unsigned) (thisWord & skewMask) << skew))); - prevWord = thisWord; - longAtput(destIndex, skewWord & halftoneWord); - destIndex += hInc; - } - } - } else { - for (word = 2; word <= (nWords - 1); word += 1) { - thisWord = longAt(sourceIndex); - sourceIndex += hInc; - skewWord = (((unskew < 0) ? ((unsigned) (prevWord & notSkewMask) >> -unskew) : ((unsigned) (prevWord & notSkewMask) << unskew))) | (((skew < 0) ? ((unsigned) (thisWord & skewMask) >> -skew) : ((unsigned) (thisWord & skewMask) << skew))); - prevWord = thisWord; - mergeWord = mergeFnwith(skewWord & halftoneWord, longAt(destIndex)); - longAtput(destIndex, mergeWord); - destIndex += hInc; - } - } - if (nWords > 1) { - destMask = mask2; - thisWord = longAt(sourceIndex); - sourceIndex += hInc; - skewWord = (((unskew < 0) ? ((unsigned) (prevWord & notSkewMask) >> -unskew) : ((unsigned) (prevWord & notSkewMask) << unskew))) | (((skew < 0) ? ((unsigned) (thisWord & skewMask) >> -skew) : ((unsigned) (thisWord & skewMask) << skew))); - mergeWord = mergeFnwith(skewWord & halftoneWord, longAt(destIndex)); - longAtput(destIndex, (destMask & mergeWord) | ((~destMask) & (longAt(destIndex)))); - destIndex += hInc; - } - sourceIndex += sourceDelta; - destIndex += destDelta; +/* This entry point needs to be implemented for the interpreter proxy. + Since BitBlt is now a plugin we need to look up BitBltPlugin_copyBitsFrom:to:at: + and call it. This entire mechanism should eventually go away and be + replaced with a dynamic lookup from BitBltPlugin itself but for backward + compatibility this stub is provided */ + +int copyBitsFromtoat(int x0, int x1, int y) { + int fn; + + fn = ioLoadFunctionFrom("copyBitsFromtoat", "BitBltPlugin"); + if (fn == 0) { + /* begin primitiveFail */ + successFlag = 0; + return null; } + return ((int (*) (int, int, int)) fn)(x0, x1, y); } -int copyLoopNoSource(void) { - int mergeWord; - int (*mergeFnwith)(int, int); - int i; - int word; - int halftoneWord; - - mergeFnwith = ((int (*)(int, int)) (opTable[combinationRule + 1])); - mergeFnwith; - for (i = 1; i <= bbH; i += 1) { - if (noHalftone) { - halftoneWord = 4294967295U; - } else { - halftoneWord = longAt(halftoneBase + ((((dy + i) - 1) % halftoneHeight) * 4)); - } - destMask = mask1; - mergeWord = mergeFnwith(halftoneWord, longAt(destIndex)); - longAtput(destIndex, (destMask & mergeWord) | ((~destMask) & (longAt(destIndex)))); - destIndex += 4; - destMask = 4294967295U; - if (combinationRule == 3) { - for (word = 2; word <= (nWords - 1); word += 1) { - longAtput(destIndex, halftoneWord); - destIndex += 4; - } - } else { - for (word = 2; word <= (nWords - 1); word += 1) { - mergeWord = mergeFnwith(halftoneWord, longAt(destIndex)); - longAtput(destIndex, mergeWord); - destIndex += 4; - } - } - if (nWords > 1) { - destMask = mask2; - mergeWord = mergeFnwith(halftoneWord, longAt(destIndex)); - longAtput(destIndex, (destMask & mergeWord) | ((~destMask) & (longAt(destIndex)))); - destIndex += 4; - } - destIndex += destDelta; - } -} - -int copyLoopPixMap(void) { - int skewWord; - int mergeWord; - int srcPixPerWord; - int scrStartBits; - int nSourceIncs; - int startBits; - int sourcePixMask; - int endBits; - int destPixMask; - int halftoneWord; - int nullMap; - int (*mergeFnwith)(int, int); - int i; - int word; - int nPix; - int nPix1; - - mergeFnwith = ((int (*)(int, int)) (opTable[combinationRule + 1])); - mergeFnwith; - srcPixPerWord = 32 / sourcePixSize; - sourcePixMask = maskTable[sourcePixSize]; - destPixMask = maskTable[destPixSize]; - nullMap = colorMap == nilObj; - sourceIndex = (sourceBits + 4) + (((sy * sourceRaster) + (sx / srcPixPerWord)) * 4); - scrStartBits = srcPixPerWord - (sx & (srcPixPerWord - 1)); - if (bbW < scrStartBits) { - nSourceIncs = 0; - } else { - nSourceIncs = ((bbW - scrStartBits) / srcPixPerWord) + 1; - } - sourceDelta = (sourceRaster - nSourceIncs) * 4; - startBits = pixPerWord - (dx & (pixPerWord - 1)); - endBits = (((dx + bbW) - 1) & (pixPerWord - 1)) + 1; - for (i = 1; i <= bbH; i += 1) { - if (noHalftone) { - halftoneWord = 4294967295U; - } else { - halftoneWord = longAt(halftoneBase + ((((dy + i) - 1) % halftoneHeight) * 4)); - } - srcBitIndex = (sx & (srcPixPerWord - 1)) * sourcePixSize; - destMask = mask1; - if (bbW < startBits) { - /* begin pickSourcePixels:nullMap:srcMask:destMask: */ - nPix = bbW; - if (sourcePixSize >= 16) { - skewWord = pickSourcePixelsRGBnullMapsrcMaskdestMask(nPix, nullMap, sourcePixMask, destPixMask); - goto l1; - } - if (nullMap) { - skewWord = pickSourcePixelsNullMapsrcMaskdestMask(nPix, sourcePixMask, destPixMask); - goto l1; - } - skewWord = pickSourcePixelssrcMaskdestMask(nPix, sourcePixMask, destPixMask); - l1: /* end pickSourcePixels:nullMap:srcMask:destMask: */; - skewWord = ((((startBits - bbW) * destPixSize) < 0) ? ((unsigned) skewWord >> -((startBits - bbW) * destPixSize)) : ((unsigned) skewWord << ((startBits - bbW) * destPixSize))); - } else { - /* begin pickSourcePixels:nullMap:srcMask:destMask: */ - if (sourcePixSize >= 16) { - skewWord = pickSourcePixelsRGBnullMapsrcMaskdestMask(startBits, nullMap, sourcePixMask, destPixMask); - goto l2; - } - if (nullMap) { - skewWord = pickSourcePixelsNullMapsrcMaskdestMask(startBits, sourcePixMask, destPixMask); - goto l2; - } - skewWord = pickSourcePixelssrcMaskdestMask(startBits, sourcePixMask, destPixMask); - l2: /* end pickSourcePixels:nullMap:srcMask:destMask: */; - } - for (word = 1; word <= nWords; word += 1) { - mergeWord = mergeFnwith(skewWord & halftoneWord, (longAt(destIndex)) & destMask); - longAtput(destIndex, (destMask & mergeWord) | ((~destMask) & (longAt(destIndex)))); - destIndex += 4; - if (word >= (nWords - 1)) { - if (!(word == nWords)) { - destMask = mask2; - /* begin pickSourcePixels:nullMap:srcMask:destMask: */ - if (sourcePixSize >= 16) { - skewWord = pickSourcePixelsRGBnullMapsrcMaskdestMask(endBits, nullMap, sourcePixMask, destPixMask); - goto l3; - } - if (nullMap) { - skewWord = pickSourcePixelsNullMapsrcMaskdestMask(endBits, sourcePixMask, destPixMask); - goto l3; - } - skewWord = pickSourcePixelssrcMaskdestMask(endBits, sourcePixMask, destPixMask); - l3: /* end pickSourcePixels:nullMap:srcMask:destMask: */; - skewWord = ((((pixPerWord - endBits) * destPixSize) < 0) ? ((unsigned) skewWord >> -((pixPerWord - endBits) * destPixSize)) : ((unsigned) skewWord << ((pixPerWord - endBits) * destPixSize))); - } - } else { - destMask = 4294967295U; - /* begin pickSourcePixels:nullMap:srcMask:destMask: */ - nPix1 = pixPerWord; - if (sourcePixSize >= 16) { - skewWord = pickSourcePixelsRGBnullMapsrcMaskdestMask(nPix1, nullMap, sourcePixMask, destPixMask); - goto l4; - } - if (nullMap) { - skewWord = pickSourcePixelsNullMapsrcMaskdestMask(nPix1, sourcePixMask, destPixMask); - goto l4; - } - skewWord = pickSourcePixelssrcMaskdestMask(nPix1, sourcePixMask, destPixMask); - l4: /* end pickSourcePixels:nullMap:srcMask:destMask: */; - } - } - sourceIndex += sourceDelta; - destIndex += destDelta; - } -} + +/* Copy this object into the segment beginning at lastSeg. + Install a forwarding pointer, and save oop and header. + Fail if out of space. Return the next segmentAddr if successful. */ +/* Copy the object... */ int copyObjtoSegmentaddrstopAtsaveOopAtheaderAt(int oop, int segmentWordArray, int lastSeg, int stopAddr, int oopPtr, int hdrPtr) { - int hdrAddr; int bodySize; + int hdrAddr; int extraSize; + int out; int lastIn; int in; - int out; - int type; int extra; + int type; int header; if (!(successFlag)) { @@ -3916,20 +2929,30 @@ int copyObjtoSegmentaddrstopAtsaveOopAtheaderAt(int oop, int segmentWordArray, i return (lastSeg + extraSize) + bodySize; } + +/* Bundle up the selector, arguments and lookupClass into a Message object. + In the process it pops the arguments off the stack, and pushes the message object. + This can then be presented as the argument of e.g. #doesNotUnderstand:. + ikp 11/20/1999 03:59 -- added hook for external runtime compilers. */ +/* remap lookupClass in case GC happens during allocation */ + int createActualMessageTo(int aClass) { int argumentArray; int message; int lookupClass; - int oop; - int oop1; + int out; int lastIn; int in; - int out; - int valuePointer; int sp; + int oop; + int oop1; + int valuePointer; /* begin pushRemappableOop: */ remapBuffer[remapBufferCount += 1] = aClass; + + /* remap argumentArray in case GC happens during allocation */ + argumentArray = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)), argumentCount); /* begin pushRemappableOop: */ remapBuffer[remapBufferCount += 1] = argumentArray; @@ -3943,13 +2966,21 @@ int createActualMessageTo(int aClass) { remapBufferCount -= 1; lookupClass = oop1; beRootIfOld(argumentArray); - /* begin transfer:from:to: */ - in = (stackPointer - ((argumentCount - 1) * 4)) - 4; - lastIn = in + (argumentCount * 4); - out = (argumentArray + 4) - 4; - while (in < lastIn) { - longAtput(out += 4, longAt(in += 4)); + if (compilerInitialized) { + compilerCreateActualMessagestoringArgs(message, argumentArray); + } else { + /* begin transfer:from:to: */ + in = (stackPointer - ((argumentCount - 1) * 4)) - 4; + lastIn = in + (argumentCount * 4); + out = (argumentArray + 4) - 4; + while (in < lastIn) { + longAtput(out += 4, longAt(in += 4)); + } + /* begin pop:thenPush: */ + longAtput(sp = stackPointer - ((argumentCount - 1) * 4), message); + stackPointer = sp; } + argumentCount = 1; /* begin storePointer:ofObject:withValue: */ valuePointer = messageSelector; if (message < youngStart) { @@ -3968,175 +2999,96 @@ int createActualMessageTo(int aClass) { } longAtput(((((char *) message)) + 4) + (2 << 2), lookupClass); } - /* begin pop:thenPush: */ - longAtput(sp = stackPointer - ((argumentCount - 1) * 4), message); - stackPointer = sp; - argumentCount = 1; } -int createGlobalEdgeTable(void) { - int end; - int object; - int lineWidth; - int lineWidth1; - - object = 0; - end = objUsed; - while (object < end) { - if (isEdge(object)) { - if (!((objBuffer[object + 5]) >= (workBuffer[39]))) { - /* begin checkedAddEdgeToGET: */ - if ((((objBuffer[object + 0]) & 65535) & 254) == 4) { - /* begin checkedAddLineToGET: */ - if ((((objBuffer[object + 0]) & 65535) & 1) != 0) { - lineWidth = objBuffer[object + 20]; - } else { - lineWidth = 0; - } - if (((objBuffer[object + 15]) + lineWidth) < (workBuffer[38])) { - goto l1; - } - if ((((objBuffer[object + 4]) - lineWidth) >= (workBuffer[37])) && (((objBuffer[object + 14]) - lineWidth) >= (workBuffer[37]))) { - goto l1; - } - addEdgeToGET(object); - goto l1; - } - if ((((objBuffer[object + 0]) & 65535) & 254) == 6) { - /* begin checkedAddBezierToGET: */ - if ((((objBuffer[object + 0]) & 65535) & 1) != 0) { - lineWidth1 = objBuffer[object + 20]; - } else { - lineWidth1 = 0; - } - if (((objBuffer[object + 15]) + lineWidth1) < (workBuffer[38])) { - goto l1; - } - if ((((objBuffer[object + 4]) - lineWidth1) >= (workBuffer[37])) && (((objBuffer[object + 14]) - lineWidth1) >= (workBuffer[37]))) { - goto l1; - } - addEdgeToGET(object); - goto l1; - } - addEdgeToGET(object); - l1: /* end checkedAddEdgeToGET: */; - } - } - object += objBuffer[object + 1]; - } -} - -unsigned int * default8To32Table(void) { - static unsigned int theTable[256] = { -0x0, 0xFF000001, 0xFFFFFFFF, 0xFF808080, 0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 0xFF00FFFF, -0xFFFFFF00, 0xFFFF00FF, 0xFF202020, 0xFF404040, 0xFF606060, 0xFF9F9F9F, 0xFFBFBFBF, 0xFFDFDFDF, -0xFF080808, 0xFF101010, 0xFF181818, 0xFF282828, 0xFF303030, 0xFF383838, 0xFF484848, 0xFF505050, -0xFF585858, 0xFF686868, 0xFF707070, 0xFF787878, 0xFF878787, 0xFF8F8F8F, 0xFF979797, 0xFFA7A7A7, -0xFFAFAFAF, 0xFFB7B7B7, 0xFFC7C7C7, 0xFFCFCFCF, 0xFFD7D7D7, 0xFFE7E7E7, 0xFFEFEFEF, 0xFFF7F7F7, -0xFF000001, 0xFF003300, 0xFF006600, 0xFF009900, 0xFF00CC00, 0xFF00FF00, 0xFF000033, 0xFF003333, -0xFF006633, 0xFF009933, 0xFF00CC33, 0xFF00FF33, 0xFF000066, 0xFF003366, 0xFF006666, 0xFF009966, -0xFF00CC66, 0xFF00FF66, 0xFF000099, 0xFF003399, 0xFF006699, 0xFF009999, 0xFF00CC99, 0xFF00FF99, -0xFF0000CC, 0xFF0033CC, 0xFF0066CC, 0xFF0099CC, 0xFF00CCCC, 0xFF00FFCC, 0xFF0000FF, 0xFF0033FF, -0xFF0066FF, 0xFF0099FF, 0xFF00CCFF, 0xFF00FFFF, 0xFF330000, 0xFF333300, 0xFF336600, 0xFF339900, -0xFF33CC00, 0xFF33FF00, 0xFF330033, 0xFF333333, 0xFF336633, 0xFF339933, 0xFF33CC33, 0xFF33FF33, -0xFF330066, 0xFF333366, 0xFF336666, 0xFF339966, 0xFF33CC66, 0xFF33FF66, 0xFF330099, 0xFF333399, -0xFF336699, 0xFF339999, 0xFF33CC99, 0xFF33FF99, 0xFF3300CC, 0xFF3333CC, 0xFF3366CC, 0xFF3399CC, -0xFF33CCCC, 0xFF33FFCC, 0xFF3300FF, 0xFF3333FF, 0xFF3366FF, 0xFF3399FF, 0xFF33CCFF, 0xFF33FFFF, -0xFF660000, 0xFF663300, 0xFF666600, 0xFF669900, 0xFF66CC00, 0xFF66FF00, 0xFF660033, 0xFF663333, -0xFF666633, 0xFF669933, 0xFF66CC33, 0xFF66FF33, 0xFF660066, 0xFF663366, 0xFF666666, 0xFF669966, -0xFF66CC66, 0xFF66FF66, 0xFF660099, 0xFF663399, 0xFF666699, 0xFF669999, 0xFF66CC99, 0xFF66FF99, -0xFF6600CC, 0xFF6633CC, 0xFF6666CC, 0xFF6699CC, 0xFF66CCCC, 0xFF66FFCC, 0xFF6600FF, 0xFF6633FF, -0xFF6666FF, 0xFF6699FF, 0xFF66CCFF, 0xFF66FFFF, 0xFF990000, 0xFF993300, 0xFF996600, 0xFF999900, -0xFF99CC00, 0xFF99FF00, 0xFF990033, 0xFF993333, 0xFF996633, 0xFF999933, 0xFF99CC33, 0xFF99FF33, -0xFF990066, 0xFF993366, 0xFF996666, 0xFF999966, 0xFF99CC66, 0xFF99FF66, 0xFF990099, 0xFF993399, -0xFF996699, 0xFF999999, 0xFF99CC99, 0xFF99FF99, 0xFF9900CC, 0xFF9933CC, 0xFF9966CC, 0xFF9999CC, -0xFF99CCCC, 0xFF99FFCC, 0xFF9900FF, 0xFF9933FF, 0xFF9966FF, 0xFF9999FF, 0xFF99CCFF, 0xFF99FFFF, -0xFFCC0000, 0xFFCC3300, 0xFFCC6600, 0xFFCC9900, 0xFFCCCC00, 0xFFCCFF00, 0xFFCC0033, 0xFFCC3333, -0xFFCC6633, 0xFFCC9933, 0xFFCCCC33, 0xFFCCFF33, 0xFFCC0066, 0xFFCC3366, 0xFFCC6666, 0xFFCC9966, -0xFFCCCC66, 0xFFCCFF66, 0xFFCC0099, 0xFFCC3399, 0xFFCC6699, 0xFFCC9999, 0xFFCCCC99, 0xFFCCFF99, -0xFFCC00CC, 0xFFCC33CC, 0xFFCC66CC, 0xFFCC99CC, 0xFFCCCCCC, 0xFFCCFFCC, 0xFFCC00FF, 0xFFCC33FF, -0xFFCC66FF, 0xFFCC99FF, 0xFFCCCCFF, 0xFFCCFFFF, 0xFFFF0000, 0xFFFF3300, 0xFFFF6600, 0xFFFF9900, -0xFFFFCC00, 0xFFFFFF00, 0xFFFF0033, 0xFFFF3333, 0xFFFF6633, 0xFFFF9933, 0xFFFFCC33, 0xFFFFFF33, -0xFFFF0066, 0xFFFF3366, 0xFFFF6666, 0xFFFF9966, 0xFFFFCC66, 0xFFFFFF66, 0xFFFF0099, 0xFFFF3399, -0xFFFF6699, 0xFFFF9999, 0xFFFFCC99, 0xFFFFFF99, 0xFFFF00CC, 0xFFFF33CC, 0xFFFF66CC, 0xFFFF99CC, -0xFFFFCCCC, 0xFFFFFFCC, 0xFFFF00FF, 0xFFFF33FF, 0xFFFF66FF, 0xFFFF99FF, 0xFFFFCCFF, 0xFFFFFFFF};; - - return theTable; -} - -int deltaFromtonSteps(int x1, int x2, int n) { - if (x2 > x1) { - return (((x2 - x1) + 16384) / (n + 1)) + 1; - } else { - if (x2 == x1) { - return 0; - } - return 0 - ((((x1 - x2) + 16384) / (n + 1)) + 1); - } -} -int destMaskAndPointerInit(void) { - int startBits; - int endBits; - int pixPerM1; +/* Repaint the portion of the Smalltalk screen bounded by the affected rectangle. Used to synchronize the screen after a Bitblt to the Smalltalk Display object. */ + +int displayBitsOfLeftTopRightBottom(int aForm, int l, int t, int r, int b) { + int left; + int dispBitsIndex; + int top; + int d; + int surfaceHandle; + int dispBits; + int w; + int right; + int displayObj; + int h; + int bottom; + int successValue; - pixPerM1 = pixPerWord - 1; - startBits = pixPerWord - (dx & pixPerM1); - mask1 = ((unsigned) 4294967295U) >> (32 - (startBits * destPixSize)); - endBits = (((dx + bbW) - 1) & pixPerM1) + 1; - mask2 = 4294967295U << (32 - (endBits * destPixSize)); - if (bbW < startBits) { - mask1 = mask1 & mask2; - mask2 = 0; - nWords = 1; + displayObj = longAt(((((char *) specialObjectsOop)) + 4) + (14 << 2)); + if (!(aForm == displayObj)) { + return null; + } + /* begin success: */ + successValue = (((((unsigned) (longAt(displayObj))) >> 8) & 15) <= 4) && ((lengthOf(displayObj)) >= 4); + successFlag = successValue && successFlag; + if (successFlag) { + dispBits = longAt(((((char *) displayObj)) + 4) + (0 << 2)); + w = fetchIntegerofObject(1, displayObj); + h = fetchIntegerofObject(2, displayObj); + d = fetchIntegerofObject(3, displayObj); + } + if (l < 0) { + left = 0; } else { - nWords = (((bbW - startBits) + pixPerM1) / pixPerWord) + 1; + left = l; } - hDir = vDir = 1; - destIndex = (destBits + 4) + (((dy * destRaster) + (dx / pixPerWord)) * 4); - destDelta = 4 * ((destRaster * vDir) - (nWords * hDir)); -} + if (r > w) { + right = w; + } else { + right = r; + } + if (t < 0) { + top = 0; + } else { + top = t; + } + if (b > h) { + bottom = h; + } else { + bottom = b; + } + if (!((left <= right) && (top <= bottom))) { + return null; + } + if (successFlag) { + if ((dispBits & 1)) { + surfaceHandle = (dispBits >> 1); + if (showSurfaceFn == 0) { + showSurfaceFn = ioLoadFunctionFrom("ioShowSurface", "SurfacePlugin"); + if (showSurfaceFn == 0) { + /* begin success: */ + successFlag = 0 && successFlag; + return null; + } + } + ((int (*) (int, int, int, int, int))showSurfaceFn)(surfaceHandle, left, top, right-left, bottom-top); + } else { + + /* index in memory byte array */ -int destinationWordwith(int sourceWord, int destinationWord) { - return destinationWord; + dispBitsIndex = dispBits + 4; + ioShowDisplay(dispBitsIndex, w, h, d, left, right, top, bottom); + } + } } int displayObject(void) { return longAt(((((char *) specialObjectsOop)) + 4) + (14 << 2)); } -int displaySpanBufferAt(int y) { - int targetY; - int targetX0; - int targetX1; - targetX0 = ((unsigned) (workBuffer[32])) >> (workBuffer[49]); - if (targetX0 < (workBuffer[42])) { - targetX0 = workBuffer[42]; - } - targetX1 = ((unsigned) (((workBuffer[34]) + (workBuffer[48])) - 1)) >> (workBuffer[49]); - if (targetX1 > (workBuffer[43])) { - targetX1 = workBuffer[43]; - } - targetY = ((unsigned) y) >> (workBuffer[49]); - if ((targetY < (workBuffer[44])) || ((targetY >= (workBuffer[45])) || ((targetX1 < (workBuffer[42])) || (targetX0 >= (workBuffer[43]))))) { - return 0; - } - /* begin copyBitsFrom:to:at: */ - destX = targetX0; - destY = targetY; - sourceX = targetX0; - width = targetX1 - targetX0; - copyBits(); - showDisplayBits(); -} +/* Rounds negative results towards negative infinity, rather than zero. */ int doPrimitiveDivby(int rcvr, int arg) { int posArg; int posRcvr; int result; - int integerRcvr; int integerArg; + int integerRcvr; if (((rcvr & arg) & 1) != 0) { integerRcvr = (rcvr >> 1); @@ -4173,8 +3125,8 @@ int doPrimitiveDivby(int rcvr, int arg) { int doPrimitiveModby(int rcvr, int arg) { int integerResult; - int integerRcvr; int integerArg; + int integerRcvr; if (((rcvr & arg) & 1) != 0) { integerRcvr = (rcvr >> 1); @@ -4188,6 +3140,9 @@ int doPrimitiveModby(int rcvr, int arg) { if (!(successFlag)) { return 1; } + + /* ensure that the result has the same sign as the integerArg */ + integerResult = integerRcvr % integerArg; if (integerArg < 0) { if (integerResult > 0) { @@ -4203,13 +3158,13 @@ int doPrimitiveModby(int rcvr, int arg) { return integerResult; } -int errorWrongIndex(void) { - error("BalloonEngine: Fatal dispatch error"); -} + +/* Return the number of extra bytes used by the given object's header. */ +/* Warning: This method should not be used during marking, when the header type bits of an object may be incorrect. */ int extraHeaderBytes(int oopOrChunk) { - int type; int extra; + int type; type = (longAt(oopOrChunk)) & 3; if (type > 1) { @@ -4232,6 +3187,10 @@ int falseObject(void) { return falseObj; } + +/* Fetch the instance variable at the given index of the given object. Return the address of first indexable field of resulting array object, or fail if the instance variable does not contain an indexable bytes or words object. */ +/* Note: May be called by translated primitive code. */ + void * fetchArrayofObject(int fieldIndex, int objectPointer) { int arrayOop; @@ -4264,6 +3223,10 @@ int fetchClassOfNonInt(int oop) { } } + +/* Fetch the instance variable at the given index of the given object. Return the C double precision floating point value of that instance variable, or fail if it is not a Float. */ +/* Note: May be called by translated primitive code. */ + double fetchFloatofObject(int fieldIndex, int objectPointer) { int floatOop; @@ -4271,6 +3234,9 @@ double fetchFloatofObject(int fieldIndex, int objectPointer) { return floatValueOf(floatOop); } + +/* Note: May be called by translated primitive code. */ + int fetchIntegerofObject(int fieldIndex, int objectPointer) { int intOop; @@ -4284,49 +3250,13 @@ int fetchIntegerofObject(int fieldIndex, int objectPointer) { } } -int fetchIntegerOrTruncFloatofObject(int fieldIndex, int objectPointer) { - double trunc; - double frac; - double floatVal; - int intOrFloat; - int ccIndex; - int cl; - - intOrFloat = longAt(((((char *) objectPointer)) + 4) + (fieldIndex << 2)); - if ((intOrFloat & 1)) { - return (intOrFloat >> 1); - } - /* begin assertClassOf:is: */ - if ((intOrFloat & 1)) { - successFlag = 0; - goto l1; - } - ccIndex = (((unsigned) (longAt(intOrFloat))) >> 12) & 31; - if (ccIndex == 0) { - cl = (longAt(intOrFloat - 4)) & 4294967292U; - } else { - cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - } - /* begin success: */ - successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)))) && successFlag; -l1: /* end assertClassOf:is: */; - if (successFlag) { - ; - fetchFloatAtinto(intOrFloat + 4, floatVal); - frac = modf(floatVal, &trunc); - success((-2147483648.0 <= trunc) && (trunc <= 2147483647.0)); - } - if (successFlag) { - return ((int) trunc); - } else { - return 0; - } -} - int fetchPointerofObject(int fieldIndex, int oop) { return longAt(((((char *) oop)) + 4) + (fieldIndex << 2)); } + +/* Return the stackPointer of a Context or BlockContext. */ + int fetchStackPointerOf(int aContext) { int sp; @@ -4341,1817 +3271,438 @@ int fetchWordofObject(int fieldIndex, int oop) { return longAt(((((char *) oop)) + 4) + (fieldIndex << 2)); } -int fetchWordLengthOf(int objectPointer) { - int sz; + +/* During sweep phase we have encountered a weak reference. Check if + its object has gone away (or is about to) and if so, signal a semaphore. */ +/* Do *not* inline this in sweepPhase - it is quite an unlikely case to run into a weak reference */ + +int finalizeReference(int oop) { + int weakOop; + int chunk; + int firstField; + int i; + int oopGone; + int lastField; + int extra; int header; + int fmt; + int methodHeader; + int sz; + int header1; + int type; + int extra1; + int type1; - /* begin sizeBitsOf: */ - header = longAt(objectPointer); - if ((header & 3) == 0) { - sz = (longAt(objectPointer - 8)) & 4294967292U; + firstField = 4 + ((nonWeakFieldsOf(oop)) << 2); + /* begin lastPointerOf: */ + header = longAt(oop); + fmt = (((unsigned) header) >> 8) & 15; + if (fmt <= 4) { + if ((fmt == 3) && (isContextHeader(header))) { + lastField = (6 + (fetchStackPointerOf(oop))) * 4; + goto l1; + } + /* begin sizeBitsOfSafe: */ + header1 = longAt(oop); + /* begin rightType: */ + if ((header1 & 252) == 0) { + type = 0; + goto l2; + } else { + if ((header1 & 126976) == 0) { + type = 1; + goto l2; + } else { + type = 3; + goto l2; + } + } + l2: /* end rightType: */; + if (type == 0) { + sz = (longAt(oop - 8)) & 4294967292U; + goto l3; + } else { + sz = header1 & 252; + goto l3; + } + l3: /* end sizeBitsOfSafe: */; + lastField = sz - 4; goto l1; - } else { - sz = header & 252; + } + if (fmt < 12) { + lastField = 0; goto l1; } -l1: /* end sizeBitsOf: */; - return ((unsigned) (sz - 4)) >> 2; -} - -int fileRecordSize(void) { - return sizeof(SQFile); -} - -SQFile * fileValueOf(int objectPointer) { - int fileIndex; - int successValue; - - /* begin success: */ - successValue = (((((unsigned) (longAt(objectPointer))) >> 8) & 15) >= 8) && ((lengthOf(objectPointer)) == (fileRecordSize())); - successFlag = successValue && successFlag; - if (successFlag) { - fileIndex = objectPointer + 4; - return (SQFile *) fileIndex; - } else { - return null; - } -} - -int fillBitmapSpanfromto(int *bits, int leftX, int rightX) { - int bitX; - int colorShift; - int x0; - int x1; - int x; - int colorMask; - int fillValue; - int baseShift; - - x0 = leftX; - x1 = rightX; - bitX = -1; - if ((workBuffer[48]) == 1) { - while (x0 < x1) { - fillValue = (((int *) bits))[bitX += 1]; - spanBuffer[x0] = fillValue; - x0 += 1; - } - } else { - colorMask = workBuffer[51]; - colorShift = workBuffer[50]; - baseShift = workBuffer[49]; - while (x0 < x1) { - x = ((unsigned) x0) >> baseShift; - fillValue = (((int *) bits))[bitX += 1]; - fillValue = ((unsigned) (fillValue & colorMask)) >> colorShift; - spanBuffer[x] = ((spanBuffer[x]) + fillValue); - x0 += 1; - } - } - if (x1 > (workBuffer[34])) { - workBuffer[34] = x1; - } - if (x1 > (workBuffer[35])) { - workBuffer[35] = x1; - } -} - -int fillBitmapSpanfromtoat(int bmFill, int leftX, int rightX, int yValue) { - int *bits; - int bmWidth; - int deltaX; - int deltaY; - int yp; - int ds; - int dsX; - int dtX; - int dt; - int xp; - int x; - int x1; - int fillValue; - int tileFlag; - int bmHeight; - int newDelta; - int newDelta1; - int bmDepth; - int b; - int value; - int rShift; - int g; - int cMask; - int a; - int bmRaster; - int r; - - if (!((workBuffer[48]) == 1)) { - return fillBitmapSpanAAfromtoat(bmFill, leftX, rightX, yValue); - } - bits = loadBitsFrom(bmFill); - if (bits == null) { - return null; - } - bmWidth = objBuffer[bmFill + 10]; - bmHeight = objBuffer[bmFill + 11]; - tileFlag = (objBuffer[bmFill + 16]) == 1; - deltaX = leftX - (objBuffer[bmFill + 4]); - deltaY = yValue - (objBuffer[bmFill + 5]); - dsX = objBuffer[bmFill + 6]; - dtX = objBuffer[bmFill + 8]; - ds = (deltaX * dsX) + (deltaY * (objBuffer[bmFill + 7])); - dt = (deltaX * dtX) + (deltaY * (objBuffer[bmFill + 9])); - x = leftX; - x1 = rightX; - while (x < x1) { - if (tileFlag) { - /* begin repeatValue:max: */ - newDelta = ds; - while (newDelta < 0) { - newDelta += bmWidth << 16; - } - while (newDelta >= (bmWidth << 16)) { - newDelta -= bmWidth << 16; - } - ds = newDelta; - /* begin repeatValue:max: */ - newDelta1 = dt; - while (newDelta1 < 0) { - newDelta1 += bmHeight << 16; - } - while (newDelta1 >= (bmHeight << 16)) { - newDelta1 -= bmHeight << 16; - } - dt = newDelta1; - } - xp = ((int) ds >> 16); - yp = ((int) dt >> 16); - if (!(tileFlag)) { - /* begin clampValue:max: */ - if (xp < 0) { - xp = 0; - goto l1; - } else { - if (xp >= bmWidth) { - xp = bmWidth - 1; - goto l1; - } else { - xp = xp; - goto l1; - } - } - l1: /* end clampValue:max: */; - /* begin clampValue:max: */ - if (yp < 0) { - yp = 0; - goto l2; - } else { - if (yp >= bmHeight) { - yp = bmHeight - 1; - goto l2; - } else { - yp = yp; - goto l2; - } - } - l2: /* end clampValue:max: */; - } - if ((xp >= 0) && ((yp >= 0) && ((xp < bmWidth) && (yp < bmHeight)))) { - /* begin bitmapValue:bits:atX:y: */ - bmDepth = objBuffer[bmFill + 12]; - bmRaster = objBuffer[bmFill + 14]; - if (bmDepth == 32) { - value = (((int*) bits))[(bmRaster * yp) + xp]; - if ((value != 0) && ((value & 4278190080U) == 0)) { - value = value | 4278190080U; - } - fillValue = uncheckedTransformColor(value); - goto l3; - } - rShift = (rShiftTable())[bmDepth]; - value = (((int*) bits))[(bmRaster * yp) + (((unsigned) xp) >> rShift)]; - cMask = (1 << bmDepth) - 1; - rShift = (32 - bmDepth) - ((xp & ((1 << rShift) - 1)) * bmDepth); - value = (((unsigned) value) >> rShift) & cMask; - if (bmDepth == 16) { - if (!(value == 0)) { - b = (value & 31) << 3; - b += ((unsigned) b) >> 5; - g = ((((unsigned) value) >> 5) & 31) << 3; - g += ((unsigned) g) >> 5; - r = ((((unsigned) value) >> 10) & 31) << 3; - r += ((unsigned) r) >> 5; - a = 255; - value = ((b + (g << 8)) + (r << 16)) + (a << 24); - } - } else { - if ((objBuffer[bmFill + 15]) == 0) { - value = 0; - } else { - value = ((objBuffer + bmFill) + 18)[value]; - } - } - fillValue = uncheckedTransformColor(value); - l3: /* end bitmapValue:bits:atX:y: */; - spanBuffer[x] = fillValue; - } - ds += dsX; - dt += dtX; - x += 1; - } -} - -int fillBitmapSpanAAfromtoat(int bmFill, int leftX, int rightX, int yValue) { - int *bits; - int bmWidth; - int deltaX; - int deltaY; - int aaLevel; - int yp; - int ds; - int dsX; - int dtX; - int dt; - int idx; - int cShift; - int firstPixel; - int xp; - int lastPixel; - int x; - int cMask; - int fillValue; - int tileFlag; - int bmHeight; - int baseShift; - int newDelta; - int newDelta1; - int newDelta2; - int newDelta3; - int newDelta4; - int newDelta5; - int firstPixel1; - int bmDepth; - int b; - int value; - int rShift; - int g; - int cMask1; - int a; - int bmRaster; - int r; - int bmDepth1; - int b1; - int value1; - int rShift1; - int g1; - int cMask2; - int a1; - int bmRaster1; - int r1; - int bmDepth2; - int b2; - int value2; - int rShift2; - int g2; - int cMask3; - int a2; - int bmRaster2; - int r2; - - bits = loadBitsFrom(bmFill); - if (bits == null) { - return null; - } - bmWidth = objBuffer[bmFill + 10]; - bmHeight = objBuffer[bmFill + 11]; - tileFlag = (objBuffer[bmFill + 16]) == 1; - deltaX = leftX - (objBuffer[bmFill + 4]); - deltaY = yValue - (objBuffer[bmFill + 5]); - dsX = objBuffer[bmFill + 6]; - dtX = objBuffer[bmFill + 8]; - ds = (deltaX * dsX) + (deltaY * (objBuffer[bmFill + 7])); - dt = (deltaX * dtX) + (deltaY * (objBuffer[bmFill + 9])); - aaLevel = workBuffer[48]; - /* begin aaFirstPixelFrom:to: */ - firstPixel1 = ((leftX + (workBuffer[48])) - 1) & (~((workBuffer[48]) - 1)); - if (firstPixel1 > rightX) { - firstPixel = rightX; - goto l7; - } else { - firstPixel = firstPixel1; - goto l7; - } -l7: /* end aaFirstPixelFrom:to: */; - lastPixel = (rightX - 1) & (~((workBuffer[48]) - 1)); - baseShift = workBuffer[49]; - cMask = workBuffer[51]; - cShift = workBuffer[50]; - x = leftX; - while (x < firstPixel) { - if (tileFlag) { - /* begin repeatValue:max: */ - newDelta = ds; - while (newDelta < 0) { - newDelta += bmWidth << 16; - } - while (newDelta >= (bmWidth << 16)) { - newDelta -= bmWidth << 16; - } - ds = newDelta; - /* begin repeatValue:max: */ - newDelta1 = dt; - while (newDelta1 < 0) { - newDelta1 += bmHeight << 16; - } - while (newDelta1 >= (bmHeight << 16)) { - newDelta1 -= bmHeight << 16; - } - dt = newDelta1; - } - xp = ((int) ds >> 16); - yp = ((int) dt >> 16); - if (!(tileFlag)) { - /* begin clampValue:max: */ - if (xp < 0) { - xp = 0; - goto l1; - } else { - if (xp >= bmWidth) { - xp = bmWidth - 1; - goto l1; - } else { - xp = xp; - goto l1; - } - } - l1: /* end clampValue:max: */; - /* begin clampValue:max: */ - if (yp < 0) { - yp = 0; - goto l2; - } else { - if (yp >= bmHeight) { - yp = bmHeight - 1; - goto l2; - } else { - yp = yp; - goto l2; - } - } - l2: /* end clampValue:max: */; - } - if ((xp >= 0) && ((yp >= 0) && ((xp < bmWidth) && (yp < bmHeight)))) { - /* begin bitmapValue:bits:atX:y: */ - bmDepth = objBuffer[bmFill + 12]; - bmRaster = objBuffer[bmFill + 14]; - if (bmDepth == 32) { - value = (((int*) bits))[(bmRaster * yp) + xp]; - if ((value != 0) && ((value & 4278190080U) == 0)) { - value = value | 4278190080U; - } - fillValue = uncheckedTransformColor(value); - goto l8; - } - rShift = (rShiftTable())[bmDepth]; - value = (((int*) bits))[(bmRaster * yp) + (((unsigned) xp) >> rShift)]; - cMask1 = (1 << bmDepth) - 1; - rShift = (32 - bmDepth) - ((xp & ((1 << rShift) - 1)) * bmDepth); - value = (((unsigned) value) >> rShift) & cMask1; - if (bmDepth == 16) { - if (!(value == 0)) { - b = (value & 31) << 3; - b += ((unsigned) b) >> 5; - g = ((((unsigned) value) >> 5) & 31) << 3; - g += ((unsigned) g) >> 5; - r = ((((unsigned) value) >> 10) & 31) << 3; - r += ((unsigned) r) >> 5; - a = 255; - value = ((b + (g << 8)) + (r << 16)) + (a << 24); - } - } else { - if ((objBuffer[bmFill + 15]) == 0) { - value = 0; - } else { - value = ((objBuffer + bmFill) + 18)[value]; - } - } - fillValue = uncheckedTransformColor(value); - l8: /* end bitmapValue:bits:atX:y: */; - fillValue = ((unsigned) (fillValue & cMask)) >> cShift; - idx = ((unsigned) x) >> baseShift; - spanBuffer[idx] = ((spanBuffer[idx]) + fillValue); - } - ds += dsX; - dt += dtX; - x += 1; - } - cMask = (((unsigned) (workBuffer[51])) >> (workBuffer[49])) | 4042322160U; - cShift = workBuffer[49]; - while (x < lastPixel) { - if (tileFlag) { - /* begin repeatValue:max: */ - newDelta2 = ds; - while (newDelta2 < 0) { - newDelta2 += bmWidth << 16; - } - while (newDelta2 >= (bmWidth << 16)) { - newDelta2 -= bmWidth << 16; - } - ds = newDelta2; - /* begin repeatValue:max: */ - newDelta3 = dt; - while (newDelta3 < 0) { - newDelta3 += bmHeight << 16; - } - while (newDelta3 >= (bmHeight << 16)) { - newDelta3 -= bmHeight << 16; - } - dt = newDelta3; - } - xp = ((int) ds >> 16); - yp = ((int) dt >> 16); - if (!(tileFlag)) { - /* begin clampValue:max: */ - if (xp < 0) { - xp = 0; - goto l3; - } else { - if (xp >= bmWidth) { - xp = bmWidth - 1; - goto l3; - } else { - xp = xp; - goto l3; - } - } - l3: /* end clampValue:max: */; - /* begin clampValue:max: */ - if (yp < 0) { - yp = 0; - goto l4; - } else { - if (yp >= bmHeight) { - yp = bmHeight - 1; - goto l4; - } else { - yp = yp; - goto l4; - } - } - l4: /* end clampValue:max: */; - } - if ((xp >= 0) && ((yp >= 0) && ((xp < bmWidth) && (yp < bmHeight)))) { - /* begin bitmapValue:bits:atX:y: */ - bmDepth1 = objBuffer[bmFill + 12]; - bmRaster1 = objBuffer[bmFill + 14]; - if (bmDepth1 == 32) { - value1 = (((int*) bits))[(bmRaster1 * yp) + xp]; - if ((value1 != 0) && ((value1 & 4278190080U) == 0)) { - value1 = value1 | 4278190080U; - } - fillValue = uncheckedTransformColor(value1); - goto l9; - } - rShift1 = (rShiftTable())[bmDepth1]; - value1 = (((int*) bits))[(bmRaster1 * yp) + (((unsigned) xp) >> rShift1)]; - cMask2 = (1 << bmDepth1) - 1; - rShift1 = (32 - bmDepth1) - ((xp & ((1 << rShift1) - 1)) * bmDepth1); - value1 = (((unsigned) value1) >> rShift1) & cMask2; - if (bmDepth1 == 16) { - if (!(value1 == 0)) { - b1 = (value1 & 31) << 3; - b1 += ((unsigned) b1) >> 5; - g1 = ((((unsigned) value1) >> 5) & 31) << 3; - g1 += ((unsigned) g1) >> 5; - r1 = ((((unsigned) value1) >> 10) & 31) << 3; - r1 += ((unsigned) r1) >> 5; - a1 = 255; - value1 = ((b1 + (g1 << 8)) + (r1 << 16)) + (a1 << 24); - } - } else { - if ((objBuffer[bmFill + 15]) == 0) { - value1 = 0; - } else { - value1 = ((objBuffer + bmFill) + 18)[value1]; - } - } - fillValue = uncheckedTransformColor(value1); - l9: /* end bitmapValue:bits:atX:y: */; - fillValue = ((unsigned) (fillValue & cMask)) >> cShift; - idx = ((unsigned) x) >> baseShift; - spanBuffer[idx] = ((spanBuffer[idx]) + fillValue); - } - ds += dsX << cShift; - dt += dtX << cShift; - x += aaLevel; - } - cMask = workBuffer[51]; - cShift = workBuffer[50]; - while (x < rightX) { - if (tileFlag) { - /* begin repeatValue:max: */ - newDelta4 = ds; - while (newDelta4 < 0) { - newDelta4 += bmWidth << 16; - } - while (newDelta4 >= (bmWidth << 16)) { - newDelta4 -= bmWidth << 16; - } - ds = newDelta4; - /* begin repeatValue:max: */ - newDelta5 = dt; - while (newDelta5 < 0) { - newDelta5 += bmHeight << 16; - } - while (newDelta5 >= (bmHeight << 16)) { - newDelta5 -= bmHeight << 16; - } - dt = newDelta5; - } - xp = ((int) ds >> 16); - yp = ((int) dt >> 16); - if (!(tileFlag)) { - /* begin clampValue:max: */ - if (xp < 0) { - xp = 0; - goto l5; - } else { - if (xp >= bmWidth) { - xp = bmWidth - 1; - goto l5; + methodHeader = longAt(oop + 4); + lastField = (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; +l1: /* end lastPointerOf: */; + for (i = firstField; i <= lastField; i += 4) { + weakOop = longAt(oop + i); + if (!((weakOop == nilObj) || ((weakOop & 1)))) { + if (weakOop < oop) { + /* begin chunkFromOop: */ + /* begin extraHeaderBytes: */ + type1 = (longAt(weakOop)) & 3; + if (type1 > 1) { + extra1 = 0; } else { - xp = xp; - goto l5; + if (type1 == 1) { + extra1 = 4; + } else { + extra1 = 8; + } } - } - l5: /* end clampValue:max: */; - /* begin clampValue:max: */ - if (yp < 0) { - yp = 0; - goto l6; + extra = extra1; + chunk = weakOop - extra; + oopGone = ((longAt(chunk)) & 3) == 2; } else { - if (yp >= bmHeight) { - yp = bmHeight - 1; - goto l6; - } else { - yp = yp; - goto l6; - } + oopGone = ((longAt(weakOop)) & 2147483648U) == 0; } - l6: /* end clampValue:max: */; - } - if ((xp >= 0) && ((yp >= 0) && ((xp < bmWidth) && (yp < bmHeight)))) { - /* begin bitmapValue:bits:atX:y: */ - bmDepth2 = objBuffer[bmFill + 12]; - bmRaster2 = objBuffer[bmFill + 14]; - if (bmDepth2 == 32) { - value2 = (((int*) bits))[(bmRaster2 * yp) + xp]; - if ((value2 != 0) && ((value2 & 4278190080U) == 0)) { - value2 = value2 | 4278190080U; - } - fillValue = uncheckedTransformColor(value2); - goto l10; - } - rShift2 = (rShiftTable())[bmDepth2]; - value2 = (((int*) bits))[(bmRaster2 * yp) + (((unsigned) xp) >> rShift2)]; - cMask3 = (1 << bmDepth2) - 1; - rShift2 = (32 - bmDepth2) - ((xp & ((1 << rShift2) - 1)) * bmDepth2); - value2 = (((unsigned) value2) >> rShift2) & cMask3; - if (bmDepth2 == 16) { - if (!(value2 == 0)) { - b2 = (value2 & 31) << 3; - b2 += ((unsigned) b2) >> 5; - g2 = ((((unsigned) value2) >> 5) & 31) << 3; - g2 += ((unsigned) g2) >> 5; - r2 = ((((unsigned) value2) >> 10) & 31) << 3; - r2 += ((unsigned) r2) >> 5; - a2 = 255; - value2 = ((b2 + (g2 << 8)) + (r2 << 16)) + (a2 << 24); - } - } else { - if ((objBuffer[bmFill + 15]) == 0) { - value2 = 0; - } else { - value2 = ((objBuffer + bmFill) + 18)[value2]; - } + if (oopGone) { + longAtput(oop + i, nilObj); + /* begin signalFinalization: */ + interruptCheckCounter = 0; + pendingFinalizationSignals += 1; } - fillValue = uncheckedTransformColor(value2); - l10: /* end bitmapValue:bits:atX:y: */; - fillValue = ((unsigned) (fillValue & cMask)) >> cShift; - idx = ((unsigned) x) >> baseShift; - spanBuffer[idx] = ((spanBuffer[idx]) + fillValue); } - ds += dsX; - dt += dtX; - x += 1; } } -int fillColorSpanAAx0x1(int pixelValue32, int leftX, int rightX) { - int aaLevel; - int idx; - int pv32; - int firstPixel; - int lastPixel; - int x; - int colorMask; - int baseShift; - int firstPixel1; - - /* begin aaFirstPixelFrom:to: */ - firstPixel1 = ((leftX + (workBuffer[48])) - 1) & (~((workBuffer[48]) - 1)); - if (firstPixel1 > rightX) { - firstPixel = rightX; - goto l1; +int findClassOfMethodforReceiver(int meth, int rcvr) { + int classDict; + int classDictSize; + int i; + int done; + int methodArray; + int currClass; + int sz; + int header; + int ccIndex; + int ccIndex1; + + /* begin fetchClassOf: */ + if ((rcvr & 1)) { + currClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); + goto l2; + } + ccIndex = (((unsigned) (longAt(rcvr))) >> 12) & 31; + if (ccIndex == 0) { + currClass = (longAt(rcvr - 4)) & 4294967292U; + goto l2; } else { - firstPixel = firstPixel1; - goto l1; + currClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); + goto l2; } -l1: /* end aaFirstPixelFrom:to: */; - lastPixel = (rightX - 1) & (~((workBuffer[48]) - 1)); - aaLevel = workBuffer[48]; - baseShift = workBuffer[49]; - x = leftX; - if (x < firstPixel) { - pv32 = ((unsigned) (pixelValue32 & (workBuffer[51]))) >> (workBuffer[50]); - while (x < firstPixel) { - idx = ((unsigned) x) >> baseShift; - spanBuffer[idx] = ((spanBuffer[idx]) + pv32); - x += 1; - } - } - if (x < lastPixel) { - colorMask = (((unsigned) (workBuffer[51])) >> (workBuffer[49])) | 4042322160U; - pv32 = ((unsigned) (pixelValue32 & colorMask)) >> (workBuffer[49]); - while (x < lastPixel) { - idx = ((unsigned) x) >> baseShift; - spanBuffer[idx] = ((spanBuffer[idx]) + pv32); - x += aaLevel; - } - } - if (x < rightX) { - pv32 = ((unsigned) (pixelValue32 & (workBuffer[51]))) >> (workBuffer[50]); - while (x < rightX) { - idx = ((unsigned) x) >> baseShift; - spanBuffer[idx] = ((spanBuffer[idx]) + pv32); - x += 1; - } - } -} - -int fillLinearGradientfromtoat(int fill, int leftX, int rightX, int yValue) { - int ds; - int dsX; - int rampIndex; - int *ramp; - int x0; - int x1; - int x; - int rampSize; - int x01; - int x11; - int x02; - int x12; - - ramp = (objBuffer + fill) + 12; - rampSize = objBuffer[fill + 10]; - dsX = objBuffer[fill + 6]; - ds = ((leftX - (objBuffer[fill + 4])) * dsX) + ((yValue - (objBuffer[fill + 5])) * (objBuffer[fill + 7])); - x = x0 = leftX; - x1 = rightX; - while (((rampIndex = ((int) ds >> 16)) < 0) && (x < x1)) { - x += 1; - ds += dsX; - } - if (x > x0) { - /* begin fillColorSpan:from:to: */ - if (!((workBuffer[48]) == 1)) { - fillColorSpanAAx0x1(ramp[0], x0, x); +l2: /* end fetchClassOf: */; + done = 0; + while (!(done)) { + classDict = longAt(((((char *) currClass)) + 4) + (1 << 2)); + /* begin fetchWordLengthOf: */ + /* begin sizeBitsOf: */ + header = longAt(classDict); + if ((header & 3) == 0) { + sz = (longAt(classDict - 8)) & 4294967292U; + goto l1; + } else { + sz = header & 252; goto l1; } - x01 = x0; - x11 = x; - while ((x01 + 4) < x11) { - spanBuffer[x01] = (ramp[0]); - spanBuffer[x01 + 1] = (ramp[0]); - spanBuffer[x01 + 2] = (ramp[0]); - spanBuffer[x01 + 3] = (ramp[0]); - x01 += 4; - } - while (x01 < x11) { - spanBuffer[x01] = (ramp[0]); - x01 += 1; + l1: /* end sizeBitsOf: */; + classDictSize = ((unsigned) (sz - 4)) >> 2; + methodArray = longAt(((((char *) classDict)) + 4) + (1 << 2)); + i = 0; + while (i < (classDictSize - 2)) { + if (meth == (longAt(((((char *) methodArray)) + 4) + (i << 2)))) { + return currClass; + } + i += 1; } - l1: /* end fillColorSpan:from:to: */; + currClass = longAt(((((char *) currClass)) + 4) + (0 << 2)); + done = currClass == nilObj; } - if ((workBuffer[48]) == 1) { - while ((((rampIndex = ((int) ds >> 16)) < rampSize) && (rampIndex >= 0)) && (x < x1)) { - spanBuffer[x] = (ramp[rampIndex]); - x += 1; - ds += dsX; - } - } else { - x = fillLinearGradientAArampdsdsXfromto(fill, ramp, ds, dsX, x, rightX); + /* begin fetchClassOf: */ + if ((rcvr & 1)) { + return longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); } - if (x < x1) { - if (rampIndex < 0) { - rampIndex = 0; - } - if (rampIndex >= rampSize) { - rampIndex = rampSize - 1; - } - /* begin fillColorSpan:from:to: */ - if (!((workBuffer[48]) == 1)) { - fillColorSpanAAx0x1(ramp[rampIndex], x, x1); - goto l2; - } - x02 = x; - x12 = x1; - while ((x02 + 4) < x12) { - spanBuffer[x02] = (ramp[rampIndex]); - spanBuffer[x02 + 1] = (ramp[rampIndex]); - spanBuffer[x02 + 2] = (ramp[rampIndex]); - spanBuffer[x02 + 3] = (ramp[rampIndex]); - x02 += 4; - } - while (x02 < x12) { - spanBuffer[x02] = (ramp[rampIndex]); - x02 += 1; - } - l2: /* end fillColorSpan:from:to: */; + ccIndex1 = (((unsigned) (longAt(rcvr))) >> 12) & 31; + if (ccIndex1 == 0) { + return (longAt(rcvr - 4)) & 4294967292U; + } else { + return longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex1 - 1) << 2)); } + return null; } -int fillLinearGradientAArampdsdsXfromto(int fill, int *ramp, int deltaS, int dsX, int leftX, int rightX) { - int aaLevel; - int ds; - int idx; - int rampIndex; - int colorShift; - int firstPixel; - int lastPixel; - int x; - int colorMask; - int rampValue; - int rampSize; - int baseShift; - int firstPixel1; - - aaLevel = workBuffer[48]; - baseShift = workBuffer[49]; - rampSize = objBuffer[fill + 10]; - ds = deltaS; - x = leftX; - rampIndex = ((int) ds >> 16); - /* begin aaFirstPixelFrom:to: */ - firstPixel1 = ((leftX + (workBuffer[48])) - 1) & (~((workBuffer[48]) - 1)); - if (firstPixel1 > rightX) { - firstPixel = rightX; - goto l1; - } else { - firstPixel = firstPixel1; + +/* Find the compiled method to be run when the current messageSelector is sent to the given class, setting the values of 'newMethod' and 'primitiveIndex'. */ + +int findNewMethodInClass(int class) { + int ok; + int hash; + int probe; + + /* begin lookupInMethodCacheSel:class: */ + hash = messageSelector ^ class; + probe = hash & 4088; + if (((methodCache[probe + 1]) == messageSelector) && ((methodCache[probe + 2]) == class)) { + newMethod = methodCache[probe + 3]; + primitiveIndex = methodCache[probe + 4]; + newNativeMethod = methodCache[probe + 5]; + ok = 1; goto l1; } -l1: /* end aaFirstPixelFrom:to: */; - lastPixel = (rightX - 1) & (~((workBuffer[48]) - 1)); - colorMask = workBuffer[51]; - colorShift = workBuffer[50]; - while ((x < firstPixel) && ((rampIndex < rampSize) && (rampIndex >= 0))) { - rampValue = (((int *) ramp))[rampIndex]; - rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; - while ((x < firstPixel) && ((((int) ds >> 16)) == rampIndex)) { - idx = ((unsigned) x) >> baseShift; - spanBuffer[idx] = ((spanBuffer[idx]) + rampValue); - x += 1; - ds += dsX; - } - rampIndex = ((int) ds >> 16); - } - colorMask = (((unsigned) (workBuffer[51])) >> (workBuffer[49])) | 4042322160U; - colorShift = workBuffer[49]; - while ((x < lastPixel) && ((rampIndex < rampSize) && (rampIndex >= 0))) { - rampValue = (((int *) ramp))[rampIndex]; - rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; - while ((x < lastPixel) && ((((int) ds >> 16)) == rampIndex)) { - idx = ((unsigned) x) >> baseShift; - spanBuffer[idx] = ((spanBuffer[idx]) + rampValue); - x += aaLevel; - ds += dsX << colorShift; - } - rampIndex = ((int) ds >> 16); - } - colorMask = workBuffer[51]; - colorShift = workBuffer[50]; - while ((x < rightX) && ((rampIndex < rampSize) && (rampIndex >= 0))) { - rampValue = (((int *) ramp))[rampIndex]; - rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; - while ((x < rightX) && ((((int) ds >> 16)) == rampIndex)) { - idx = ((unsigned) x) >> baseShift; - spanBuffer[idx] = ((spanBuffer[idx]) + rampValue); - x += 1; - ds += dsX; - } - rampIndex = ((int) ds >> 16); - } - return x; -} - -int fillRadialDecreasingAArampdeltaSTdsXdtXfromto(int fill, int *ramp, int *deltaST, int dsX, int dtX, int leftX, int rightX) { - int nextLength; - int aaLevel; - int ds; - int dt; - int rampIndex; - int length2; - int colorShift; - int index; - int firstPixel; - int lastPixel; - int x; - int x1; - int colorMask; - int rampValue; - int baseShift; - int firstPixel1; - - ds = (((int*) deltaST))[0]; - dt = (((int*) deltaST))[1]; - aaLevel = workBuffer[48]; - baseShift = workBuffer[49]; - rampIndex = accurateLengthOfwith(((int) ds >> 16), ((int) dt >> 16)); - length2 = (rampIndex - 1) * (rampIndex - 1); - x = leftX; - x1 = objBuffer[fill + 4]; - if (x1 > rightX) { - x1 = rightX; - } - /* begin aaFirstPixelFrom:to: */ - firstPixel1 = ((leftX + (workBuffer[48])) - 1) & (~((workBuffer[48]) - 1)); - if (firstPixel1 > x1) { - firstPixel = x1; + probe = (((unsigned) hash) >> 1) & 4088; + if (((methodCache[probe + 1]) == messageSelector) && ((methodCache[probe + 2]) == class)) { + newMethod = methodCache[probe + 3]; + primitiveIndex = methodCache[probe + 4]; + newNativeMethod = methodCache[probe + 5]; + ok = 1; goto l1; - } else { - firstPixel = firstPixel1; + } + probe = (((unsigned) hash) >> 2) & 4088; + if (((methodCache[probe + 1]) == messageSelector) && ((methodCache[probe + 2]) == class)) { + newMethod = methodCache[probe + 3]; + primitiveIndex = methodCache[probe + 4]; + newNativeMethod = methodCache[probe + 5]; + ok = 1; goto l1; } -l1: /* end aaFirstPixelFrom:to: */; - lastPixel = (x1 - 1) & (~((workBuffer[48]) - 1)); - if (x < firstPixel) { - colorMask = workBuffer[51]; - colorShift = workBuffer[50]; - rampValue = (((int *) ramp))[rampIndex]; - rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; - while (x < firstPixel) { - while ((x < firstPixel) && ((((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16)))) >= length2)) { - index = ((unsigned) x) >> baseShift; - spanBuffer[index] = ((spanBuffer[index]) + rampValue); - x += 1; - ds += dsX; - dt += dtX; - } - nextLength = ((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16))); - while (nextLength < length2) { - rampIndex -= 1; - rampValue = (((int *) ramp))[rampIndex]; - rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; - length2 = (rampIndex - 1) * (rampIndex - 1); - } - } - } - if (x < lastPixel) { - colorMask = (((unsigned) (workBuffer[51])) >> (workBuffer[49])) | 4042322160U; - colorShift = workBuffer[49]; - rampValue = (((int *) ramp))[rampIndex]; - rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; - while (x < lastPixel) { - while ((x < lastPixel) && ((((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16)))) >= length2)) { - index = ((unsigned) x) >> baseShift; - spanBuffer[index] = ((spanBuffer[index]) + rampValue); - x += aaLevel; - ds += dsX << colorShift; - dt += dtX << colorShift; - } - nextLength = ((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16))); - while (nextLength < length2) { - rampIndex -= 1; - rampValue = (((int *) ramp))[rampIndex]; - rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; - length2 = (rampIndex - 1) * (rampIndex - 1); - } - } - } - if (x < x1) { - colorMask = workBuffer[51]; - colorShift = workBuffer[50]; - rampValue = (((int *) ramp))[rampIndex]; - rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; - while (x < x1) { - while ((x < x1) && ((((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16)))) >= length2)) { - index = ((unsigned) x) >> baseShift; - spanBuffer[index] = ((spanBuffer[index]) + rampValue); - x += 1; - ds += dsX; - dt += dtX; - } - nextLength = ((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16))); - while (nextLength < length2) { - rampIndex -= 1; - rampValue = (((int *) ramp))[rampIndex]; - rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; - length2 = (rampIndex - 1) * (rampIndex - 1); - } - } - } - (((int *) deltaST))[0] = ds; - (((int *) deltaST))[1] = dt; - return x; -} - -int fillRadialGradientfromtoat(int fill, int leftX, int rightX, int yValue) { - int deltaX; - int deltaY; - int ds; - int dsX; - int dtX; - int dt; - int length2; - int *ramp; - int x; - int x1; - int rampSize; - int *deltaST; - int x0; - int x11; - int nextLength; - int ds1; - int dt1; - int rampIndex; - int length21; - int x2; - int x12; - int rampValue; - int lastLength; - int rampSize1; - int x01; - int x13; - int nextLength1; - int ds2; - int dt2; - int rampIndex1; - int length22; - int x3; - int x14; - int rampValue1; - - ramp = (objBuffer + fill) + 12; - rampSize = objBuffer[fill + 10]; - deltaX = leftX - (objBuffer[fill + 4]); - deltaY = yValue - (objBuffer[fill + 5]); - dsX = objBuffer[fill + 6]; - dtX = objBuffer[fill + 8]; - ds = (deltaX * dsX) + (deltaY * (objBuffer[fill + 7])); - dt = (deltaX * dtX) + (deltaY * (objBuffer[fill + 9])); - x = leftX; - x1 = rightX; - length2 = (rampSize - 1) * (rampSize - 1); - while (((((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16)))) >= length2) && (x < x1)) { - x += 1; - ds += dsX; - dt += dtX; - } - if (x > leftX) { - /* begin fillColorSpan:from:to: */ - if (!((workBuffer[48]) == 1)) { - fillColorSpanAAx0x1(ramp[rampSize - 1], leftX, x); - goto l1; - } - x0 = leftX; - x11 = x; - while ((x0 + 4) < x11) { - spanBuffer[x0] = (ramp[rampSize - 1]); - spanBuffer[x0 + 1] = (ramp[rampSize - 1]); - spanBuffer[x0 + 2] = (ramp[rampSize - 1]); - spanBuffer[x0 + 3] = (ramp[rampSize - 1]); - x0 += 4; - } - while (x0 < x11) { - spanBuffer[x0] = (ramp[rampSize - 1]); - x0 += 1; - } - l1: /* end fillColorSpan:from:to: */; - } - deltaST = ((int *) (workBuffer + 80)); - deltaST[0] = ds; - deltaST[1] = dt; - if (x < (objBuffer[fill + 4])) { - if ((workBuffer[48]) == 1) { - /* begin fillRadialDecreasing:ramp:deltaST:dsX:dtX:from:to: */ - ds2 = (((int*) deltaST))[0]; - dt2 = (((int*) deltaST))[1]; - rampIndex1 = accurateLengthOfwith(((int) ds2 >> 16), ((int) dt2 >> 16)); - rampValue1 = (((int *) ramp))[rampIndex1]; - length22 = (rampIndex1 - 1) * (rampIndex1 - 1); - x3 = x; - x14 = x1; - if (x14 > (objBuffer[fill + 4])) { - x14 = objBuffer[fill + 4]; - } - while (x3 < x14) { - while ((x3 < x14) && ((((((int) ds2 >> 16)) * (((int) ds2 >> 16))) + ((((int) dt2 >> 16)) * (((int) dt2 >> 16)))) >= length22)) { - spanBuffer[x3] = rampValue1; - x3 += 1; - ds2 += dsX; - dt2 += dtX; - } - nextLength1 = ((((int) ds2 >> 16)) * (((int) ds2 >> 16))) + ((((int) dt2 >> 16)) * (((int) dt2 >> 16))); - while (nextLength1 < length22) { - rampIndex1 -= 1; - rampValue1 = (((int *) ramp))[rampIndex1]; - length22 = (rampIndex1 - 1) * (rampIndex1 - 1); - } - } - (((int *) deltaST))[0] = ds2; - (((int *) deltaST))[1] = dt2; - x = x3; - } else { - x = fillRadialDecreasingAArampdeltaSTdsXdtXfromto(fill, ramp, deltaST, dsX, dtX, x, x1); - } - } - if (x < x1) { - if ((workBuffer[48]) == 1) { - /* begin fillRadialIncreasing:ramp:deltaST:dsX:dtX:from:to: */ - ds1 = (((int*) deltaST))[0]; - dt1 = (((int*) deltaST))[1]; - rampIndex = accurateLengthOfwith(((int) ds1 >> 16), ((int) dt1 >> 16)); - rampValue = (((int *) ramp))[rampIndex]; - rampSize1 = objBuffer[fill + 10]; - length21 = (rampSize1 - 1) * (rampSize1 - 1); - nextLength = (rampIndex + 1) * (rampIndex + 1); - lastLength = ((((int) ds1 >> 16)) * (((int) ds1 >> 16))) + ((((int) dt1 >> 16)) * (((int) dt1 >> 16))); - x2 = x; - x12 = x1; - while ((x2 < x12) && (lastLength < length21)) { - while ((x2 < x12) && ((((((int) ds1 >> 16)) * (((int) ds1 >> 16))) + ((((int) dt1 >> 16)) * (((int) dt1 >> 16)))) <= nextLength)) { - spanBuffer[x2] = rampValue; - x2 += 1; - ds1 += dsX; - dt1 += dtX; - } - lastLength = ((((int) ds1 >> 16)) * (((int) ds1 >> 16))) + ((((int) dt1 >> 16)) * (((int) dt1 >> 16))); - while (lastLength > nextLength) { - rampIndex += 1; - rampValue = (((int *) ramp))[rampIndex]; - nextLength = (rampIndex + 1) * (rampIndex + 1); - } - } - (((int *) deltaST))[0] = ds1; - (((int *) deltaST))[1] = dt1; - x = x2; - } else { - x = fillRadialIncreasingAArampdeltaSTdsXdtXfromto(fill, ramp, deltaST, dsX, dtX, x, x1); - } + ok = 0; +l1: /* end lookupInMethodCacheSel:class: */; + if (!(ok)) { + lookupMethodInClass(class); + lkupClass = class; + addNewMethodToCache(); } - if (x < rightX) { - /* begin fillColorSpan:from:to: */ - if (!((workBuffer[48]) == 1)) { - fillColorSpanAAx0x1(ramp[rampSize - 1], x, rightX); - goto l2; +} + + +/* Search the obsolete named primitive table for the given function. + Return the index if it's found, -1 otherwise. */ + +int findObsoleteNamedPrimitivelength(char * functionName, int functionLength) { + const char * entry; + int index; + int chIndex; + + index = 0; + while (1) { + entry = (obsoleteNamedPrimitiveTable[index])[0]; + if (entry == null) { + return -1; } - x01 = x; - x13 = rightX; - while ((x01 + 4) < x13) { - spanBuffer[x01] = (ramp[rampSize - 1]); - spanBuffer[x01 + 1] = (ramp[rampSize - 1]); - spanBuffer[x01 + 2] = (ramp[rampSize - 1]); - spanBuffer[x01 + 3] = (ramp[rampSize - 1]); - x01 += 4; + chIndex = 0; + while (((entry[chIndex]) == (functionName[chIndex])) && (chIndex < functionLength)) { + chIndex += 1; } - while (x01 < x13) { - spanBuffer[x01] = (ramp[rampSize - 1]); - x01 += 1; + if ((chIndex == functionLength) && ((entry[chIndex]) == 0)) { + return index; } - l2: /* end fillColorSpan:from:to: */; + index += 1; } } -int fillRadialIncreasingAArampdeltaSTdsXdtXfromto(int fill, int *ramp, int *deltaST, int dsX, int dtX, int leftX, int rightX) { - int nextLength; - int aaLevel; - int ds; - int dt; - int rampIndex; - int length2; - int colorShift; - int index; - int firstPixel; - int lastPixel; - int x; - int colorMask; - int rampValue; - int lastLength; - int rampSize; - int baseShift; - int firstPixel1; - - ds = (((int*) deltaST))[0]; - dt = (((int*) deltaST))[1]; - aaLevel = workBuffer[48]; - baseShift = workBuffer[49]; - rampIndex = accurateLengthOfwith(((int) ds >> 16), ((int) dt >> 16)); - rampSize = objBuffer[fill + 10]; - length2 = (rampSize - 1) * (rampSize - 1); - nextLength = (rampIndex + 1) * (rampIndex + 1); - lastLength = ((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16))); - x = leftX; - /* begin aaFirstPixelFrom:to: */ - firstPixel1 = ((leftX + (workBuffer[48])) - 1) & (~((workBuffer[48]) - 1)); - if (firstPixel1 > rightX) { - firstPixel = rightX; - goto l1; - } else { - firstPixel = firstPixel1; - goto l1; - } -l1: /* end aaFirstPixelFrom:to: */; - lastPixel = (rightX - 1) & (~((workBuffer[48]) - 1)); - if ((x < firstPixel) && (lastLength < length2)) { - colorMask = workBuffer[51]; - colorShift = workBuffer[50]; - rampValue = (((int *) ramp))[rampIndex]; - rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; - while ((x < firstPixel) && (lastLength < length2)) { - while ((x < firstPixel) && ((((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16)))) <= nextLength)) { - index = ((unsigned) x) >> baseShift; - spanBuffer[index] = ((spanBuffer[index]) + rampValue); - x += 1; - ds += dsX; - dt += dtX; - } - lastLength = ((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16))); - while (lastLength > nextLength) { - rampIndex += 1; - rampValue = (((int *) ramp))[rampIndex]; - rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; - nextLength = (rampIndex + 1) * (rampIndex + 1); - } - } - } - if ((x < lastPixel) && (lastLength < length2)) { - colorMask = (((unsigned) (workBuffer[51])) >> (workBuffer[49])) | 4042322160U; - colorShift = workBuffer[49]; - rampValue = (((int *) ramp))[rampIndex]; - rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; - while ((x < lastPixel) && (lastLength < length2)) { - while ((x < lastPixel) && ((((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16)))) <= nextLength)) { - index = ((unsigned) x) >> baseShift; - spanBuffer[index] = ((spanBuffer[index]) + rampValue); - x += aaLevel; - ds += dsX << colorShift; - dt += dtX << colorShift; - } - lastLength = ((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16))); - while (lastLength > nextLength) { - rampIndex += 1; - rampValue = (((int *) ramp))[rampIndex]; - rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; - nextLength = (rampIndex + 1) * (rampIndex + 1); - } - } - } - if ((x < rightX) && (lastLength < length2)) { - colorMask = workBuffer[51]; - colorShift = workBuffer[50]; - rampValue = (((int *) ramp))[rampIndex]; - rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; - while ((x < rightX) && (lastLength < length2)) { - while ((x < rightX) && ((((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16)))) <= nextLength)) { - index = ((unsigned) x) >> baseShift; - spanBuffer[index] = ((spanBuffer[index]) + rampValue); - x += 1; - ds += dsX; - dt += dtX; - } - lastLength = ((((int) ds >> 16)) * (((int) ds >> 16))) + ((((int) dt >> 16)) * (((int) dt >> 16))); - while (lastLength > nextLength) { - rampIndex += 1; - rampValue = (((int *) ramp))[rampIndex]; - rampValue = ((unsigned) (rampValue & colorMask)) >> colorShift; - nextLength = (rampIndex + 1) * (rampIndex + 1); - } - } - } - (((int *) deltaST))[0] = ds; - (((int *) deltaST))[1] = dt; - return x; -} - -int fillSortsbefore(int fillEntry1, int fillEntry2) { - int diff; - - diff = (workBuffer[(workBuffer[10]) + (fillEntry1 + 1)]) - (workBuffer[(workBuffer[10]) + (fillEntry2 + 1)]); - if (!(diff == 0)) { - return diff > 0; - } - return (((unsigned) (workBuffer[(workBuffer[10]) + fillEntry1]))) < (((unsigned) (workBuffer[(workBuffer[10]) + fillEntry2]))); -} - -int fillSpanfromto(int fill, int leftX, int rightX) { - int x0; - int x1; - int type; - int x01; - int x11; +int findSelectorOfMethodforReceiver(int meth, int rcvr) { + int classDict; + int classDictSize; + int i; + int done; + int methodArray; + int currClass; + int sz; + int header; + int ccIndex; - if (fill == 0) { - return 0; - } - if (leftX < (workBuffer[35])) { - x0 = workBuffer[35]; - } else { - x0 = leftX; + /* begin fetchClassOf: */ + if ((rcvr & 1)) { + currClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); + goto l2; } - if (rightX > ((workBuffer[33]) << (workBuffer[49]))) { - x1 = (workBuffer[33]) << (workBuffer[49]); + ccIndex = (((unsigned) (longAt(rcvr))) >> 12) & 31; + if (ccIndex == 0) { + currClass = (longAt(rcvr - 4)) & 4294967292U; + goto l2; } else { - x1 = rightX; - } - if (x0 < (workBuffer[36])) { - x0 = workBuffer[36]; - } - if (x1 > (workBuffer[37])) { - x1 = workBuffer[37]; - } - if (x0 < (workBuffer[32])) { - workBuffer[32] = x0; + currClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); + goto l2; } - if (x1 > (workBuffer[34])) { - workBuffer[34] = x1; - } - if (x1 > (workBuffer[35])) { - workBuffer[35] = x1; - } - if (x0 >= x1) { - return 0; - } - if ((fill & 4278190080U) != 0) { - /* begin fillColorSpan:from:to: */ - if (!((workBuffer[48]) == 1)) { - fillColorSpanAAx0x1(fill, x0, x1); +l2: /* end fetchClassOf: */; + done = 0; + while (!(done)) { + classDict = longAt(((((char *) currClass)) + 4) + (1 << 2)); + /* begin fetchWordLengthOf: */ + /* begin sizeBitsOf: */ + header = longAt(classDict); + if ((header & 3) == 0) { + sz = (longAt(classDict - 8)) & 4294967292U; + goto l1; + } else { + sz = header & 252; goto l1; } - x01 = x0; - x11 = x1; - while ((x01 + 4) < x11) { - spanBuffer[x01] = fill; - spanBuffer[x01 + 1] = fill; - spanBuffer[x01 + 2] = fill; - spanBuffer[x01 + 3] = fill; - x01 += 4; - } - while (x01 < x11) { - spanBuffer[x01] = fill; - x01 += 1; - } - l1: /* end fillColorSpan:from:to: */; - } else { - workBuffer[66] = fill; - workBuffer[67] = x0; - workBuffer[68] = x1; - type = ((unsigned) (((objBuffer[fill + 0]) & 65535) & 65280)) >> 8; - if (type <= 1) { - return 1; - } - switch (type) { - case 0: - case 1: - errorWrongIndex(); - break; - case 2: - fillLinearGradientfromtoat(workBuffer[66], workBuffer[67], workBuffer[68], workBuffer[88]); - break; - case 3: - fillRadialGradientfromtoat(workBuffer[66], workBuffer[67], workBuffer[68], workBuffer[88]); - break; - case 4: - case 5: - fillBitmapSpanfromtoat(workBuffer[66], workBuffer[67], workBuffer[68], workBuffer[88]); - break; + l1: /* end sizeBitsOf: */; + classDictSize = ((unsigned) (sz - 4)) >> 2; + methodArray = longAt(((((char *) classDict)) + 4) + (1 << 2)); + i = 0; + while (i <= (classDictSize - 2)) { + if (meth == (longAt(((((char *) methodArray)) + 4) + (i << 2)))) { + return longAt(((((char *) classDict)) + 4) + ((i + 2) << 2)); + } + i += 1; } + currClass = longAt(((((char *) currClass)) + 4) + (0 << 2)); + done = currClass == nilObj; } - return 0; + return longAt(((((char *) specialObjectsOop)) + 4) + (20 << 2)); } -int finalizeReference(int oop) { + +/* Return the first accessible object in the heap. */ + +int firstAccessibleObject(void) { + int obj; int chunk; - int oopGone; - int firstField; - int lastField; - int i; - int weakOop; int extra; - int methodHeader; + int extra1; + int type; int sz; - int fmt; + int extra2; int header; - int header1; - int type; + int extra11; int type1; - int extra1; - firstField = 4 + ((nonWeakFieldsOf(oop)) << 2); - /* begin lastPointerOf: */ - header = longAt(oop); - fmt = (((unsigned) header) >> 8) & 15; - if (fmt <= 4) { - if ((fmt == 3) && (isContextHeader(header))) { - lastField = (6 + (fetchStackPointerOf(oop))) * 4; - goto l1; + /* begin oopFromChunk: */ + chunk = startOfMemory(); + /* begin extraHeaderBytes: */ + type = (longAt(chunk)) & 3; + if (type > 1) { + extra1 = 0; + } else { + if (type == 1) { + extra1 = 4; + } else { + extra1 = 8; } - /* begin sizeBitsOfSafe: */ - header1 = longAt(oop); - /* begin rightType: */ - if ((header1 & 252) == 0) { - type = 0; - goto l2; + } + extra = extra1; + obj = chunk + extra; + while (obj < endOfMemory) { + if (!(((longAt(obj)) & 3) == 2)) { + return obj; + } + /* begin objectAfter: */ + ; + if (((longAt(obj)) & 3) == 2) { + sz = (longAt(obj)) & 4294967292U; } else { - if ((header1 & 126976) == 0) { - type = 1; - goto l2; + /* begin sizeBitsOf: */ + header = longAt(obj); + if ((header & 3) == 0) { + sz = (longAt(obj - 8)) & 4294967292U; + goto l1; } else { - type = 3; - goto l2; + sz = header & 252; + goto l1; } + l1: /* end sizeBitsOf: */; } - l2: /* end rightType: */; - if (type == 0) { - sz = (longAt(oop - 8)) & 4294967292U; - goto l3; + /* begin oopFromChunk: */ + /* begin extraHeaderBytes: */ + type1 = (longAt(obj + sz)) & 3; + if (type1 > 1) { + extra11 = 0; } else { - sz = header1 & 252; - goto l3; - } - l3: /* end sizeBitsOfSafe: */; - lastField = sz - 4; - goto l1; - } - if (fmt < 12) { - lastField = 0; - goto l1; - } - methodHeader = longAt(oop + 4); - lastField = (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; -l1: /* end lastPointerOf: */; - for (i = firstField; i <= lastField; i += 4) { - weakOop = longAt(oop + i); - if (!((weakOop == nilObj) || ((weakOop & 1)))) { - if (weakOop < oop) { - /* begin chunkFromOop: */ - /* begin extraHeaderBytes: */ - type1 = (longAt(weakOop)) & 3; - if (type1 > 1) { - extra1 = 0; - } else { - if (type1 == 1) { - extra1 = 4; - } else { - extra1 = 8; - } - } - extra = extra1; - chunk = weakOop - extra; - oopGone = ((longAt(chunk)) & 3) == 2; + if (type1 == 1) { + extra11 = 4; } else { - oopGone = ((longAt(weakOop)) & 2147483648U) == 0; - } - if (oopGone) { - longAtput(oop + i, nilObj); - /* begin signalFinalization: */ - interruptCheckCounter = 0; - pendingFinalizationSignals += 1; + extra11 = 8; } } + extra2 = extra11; + obj = (obj + sz) + extra2; } + error("heap is empty"); } -int findNewMethodInClass(int class) { - int ok; - int probe; - int hash; +void * firstFixedField(int oop) { + return ((void *) (oop + 4)); +} - /* begin lookupInMethodCacheSel:class: */ - hash = messageSelector ^ class; - probe = hash & 2044; - if (((methodCache[probe + 1]) == messageSelector) && ((methodCache[probe + 2]) == class)) { - newMethod = methodCache[probe + 3]; - primitiveIndex = methodCache[probe + 4]; - ok = 1; - goto l1; +void * firstIndexableField(int oop) { + int hdr; + int totalLength; + int fixedFields; + int fmt; + int sz; + int classFormat; + int class; + int ccIndex; + + hdr = longAt(oop); + fmt = (((unsigned) hdr) >> 8) & 15; + /* begin lengthOf:baseHeader:format: */ + if ((hdr & 3) == 0) { + sz = (longAt(oop - 8)) & 4294967292U; + } else { + sz = hdr & 252; } - probe = (((unsigned) hash) >> 1) & 2044; - if (((methodCache[probe + 1]) == messageSelector) && ((methodCache[probe + 2]) == class)) { - newMethod = methodCache[probe + 3]; - primitiveIndex = methodCache[probe + 4]; - ok = 1; + if (fmt < 8) { + totalLength = ((unsigned) (sz - 4)) >> 2; goto l1; - } - probe = (((unsigned) hash) >> 2) & 2044; - if (((methodCache[probe + 1]) == messageSelector) && ((methodCache[probe + 2]) == class)) { - newMethod = methodCache[probe + 3]; - primitiveIndex = methodCache[probe + 4]; - ok = 1; + } else { + totalLength = (sz - 4) - (fmt & 3); goto l1; } - ok = 0; -l1: /* end lookupInMethodCacheSel:class: */; - if (!(ok)) { - lookupMethodInClass(class); - addToMethodCacheSelclassmethodprimIndex(messageSelector, class, newMethod, primitiveIndex); +l1: /* end lengthOf:baseHeader:format: */; + /* begin fixedFieldsOf:format:length: */ + if ((fmt > 4) || (fmt == 2)) { + fixedFields = 0; + goto l2; + } + if (fmt < 2) { + fixedFields = totalLength; + goto l2; + } + /* begin fetchClassOf: */ + if ((oop & 1)) { + class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); + goto l3; + } + ccIndex = (((unsigned) (longAt(oop))) >> 12) & 31; + if (ccIndex == 0) { + class = (longAt(oop - 4)) & 4294967292U; + goto l3; + } else { + class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); + goto l3; + } +l3: /* end fetchClassOf: */; + classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; + fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; +l2: /* end fixedFieldsOf:format:length: */; + if (fmt < 8) { + return ((void *) ((oop + 4) + (fixedFields << 2))); + } else { + return ((void *) ((oop + 4) + fixedFields)); } } -int findNextExternalEntryFromGET(void) { - int edge; - int yValue; - int type; +int floatObjectOf(double aFloat) { + int newFloatObj; - yValue = workBuffer[88]; - while ((workBuffer[11]) < (workBuffer[12])) { - edge = getBuffer[workBuffer[11]]; - if ((objBuffer[edge + 5]) > yValue) { - return 0; - } - type = (objBuffer[edge + 0]) & 65535; - if ((type & 254) == 2) { - return 1; - } - if (!(needAvailableSpace(1))) { - return 0; - } - switch (type) { - case 0: - case 1: - case 2: - case 3: - errorWrongIndex(); - break; - case 4: - stepToFirstLineInat(getBuffer[workBuffer[11]], workBuffer[88]); - break; - case 5: - stepToFirstWideLineInat(getBuffer[workBuffer[11]], workBuffer[88]); - break; - case 6: - stepToFirstBezierInat(getBuffer[workBuffer[11]], workBuffer[88]); - break; - case 7: - stepToFirstWideBezierInat(getBuffer[workBuffer[11]], workBuffer[88]); - break; - } - insertEdgeIntoAET(edge); - workBuffer[11] = ((workBuffer[11]) + 1); - } - return 0; + newFloatObj = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)), 12, 0); + storeFloatAtfrom(newFloatObj + 4, aFloat); + return newFloatObj; } -int findNextExternalFillFromAET(void) { - int leftEdge; - int rightEdge; - int leftX; - int rightX; - int fill; - int stopX; - int startX; - int someIntegerValue; - int someIntegerValue1; - int rightX1; - int fill1; - int stopX1; - int startX1; - int someIntegerValue2; - int someIntegerValue11; - - leftX = rightX = workBuffer[37]; - while ((workBuffer[13]) < (workBuffer[14])) { - leftEdge = rightEdge = aetBuffer[workBuffer[13]]; - leftX = rightX = objBuffer[leftEdge + 4]; - if (leftX >= (workBuffer[37])) { - return 0; - } - /* begin quickRemoveInvalidFillsAt: */ - if (((workBuffer[1]) - (workBuffer[10])) == 0) { - goto l3; - } - while ((topRightX()) <= leftX) { - hideFilldepth(topFill(), topDepth()); - if (((workBuffer[1]) - (workBuffer[10])) == 0) { - goto l3; - } - } - l3: /* end quickRemoveInvalidFillsAt: */; - if ((((objBuffer[leftEdge + 0]) & 65535) & 1) != 0) { - toggleWideFillOf(leftEdge); - } - if (((objBuffer[leftEdge + 0]) & 65536) == 0) { - toggleFillsOf(leftEdge); - if (engineStopped) { - return 0; - } - } - workBuffer[13] = ((workBuffer[13]) + 1); - if ((workBuffer[13]) < (workBuffer[14])) { - rightEdge = aetBuffer[workBuffer[13]]; - rightX = objBuffer[rightEdge + 4]; - if (rightX >= (workBuffer[36])) { - /* begin fillAllFrom:to: */ - /* begin topFill */ - if (((workBuffer[1]) - (workBuffer[10])) == 0) { - fill = 0; - goto l8; - } else { - fill = workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)]; - goto l8; - } - l8: /* end topFill */; - startX = leftX; - /* begin topRightX */ - if (((workBuffer[1]) - (workBuffer[10])) == 0) { - stopX = 999999999; - goto l9; - } else { - stopX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 2)]; - goto l9; - } - l9: /* end topRightX */; - while (stopX < rightX) { - /* begin makeUnsignedFrom: */ - /* begin topFill */ - if (((workBuffer[1]) - (workBuffer[10])) == 0) { - someIntegerValue = 0; - goto l6; - } else { - someIntegerValue = workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)]; - goto l6; - } - l6: /* end topFill */; - fill = someIntegerValue; - if (!(fill == 0)) { - if (fillSpanfromto(fill, startX, stopX)) { - goto l2; - } - } - /* begin quickRemoveInvalidFillsAt: */ - if (((workBuffer[1]) - (workBuffer[10])) == 0) { - goto l1; - } - while ((topRightX()) <= stopX) { - hideFilldepth(topFill(), topDepth()); - if (((workBuffer[1]) - (workBuffer[10])) == 0) { - goto l1; - } - } - l1: /* end quickRemoveInvalidFillsAt: */; - startX = stopX; - /* begin topRightX */ - if (((workBuffer[1]) - (workBuffer[10])) == 0) { - stopX = 999999999; - goto l7; - } else { - stopX = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 2)]; - goto l7; - } - l7: /* end topRightX */; - } - /* begin makeUnsignedFrom: */ - /* begin topFill */ - if (((workBuffer[1]) - (workBuffer[10])) == 0) { - someIntegerValue1 = 0; - goto l10; - } else { - someIntegerValue1 = workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)]; - goto l10; - } - l10: /* end topFill */; - fill = someIntegerValue1; - if (!(fill == 0)) { - fillSpanfromto(fill, startX, rightX); - goto l2; - } - l2: /* end fillAllFrom:to: */; - } - } - } - if (rightX < (workBuffer[37])) { - /* begin fillAllFrom:to: */ - rightX1 = workBuffer[37]; - /* begin topFill */ - if (((workBuffer[1]) - (workBuffer[10])) == 0) { - fill1 = 0; - goto l13; - } else { - fill1 = workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)]; - goto l13; - } - l13: /* end topFill */; - startX1 = rightX; - /* begin topRightX */ - if (((workBuffer[1]) - (workBuffer[10])) == 0) { - stopX1 = 999999999; - goto l14; - } else { - stopX1 = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 2)]; - goto l14; - } - l14: /* end topRightX */; - while (stopX1 < rightX1) { - /* begin makeUnsignedFrom: */ - /* begin topFill */ - if (((workBuffer[1]) - (workBuffer[10])) == 0) { - someIntegerValue2 = 0; - goto l11; - } else { - someIntegerValue2 = workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)]; - goto l11; - } - l11: /* end topFill */; - fill1 = someIntegerValue2; - if (!(fill1 == 0)) { - if (fillSpanfromto(fill1, startX1, stopX1)) { - goto l5; - } - } - /* begin quickRemoveInvalidFillsAt: */ - if (((workBuffer[1]) - (workBuffer[10])) == 0) { - goto l4; - } - while ((topRightX()) <= stopX1) { - hideFilldepth(topFill(), topDepth()); - if (((workBuffer[1]) - (workBuffer[10])) == 0) { - goto l4; - } - } - l4: /* end quickRemoveInvalidFillsAt: */; - startX1 = stopX1; - /* begin topRightX */ - if (((workBuffer[1]) - (workBuffer[10])) == 0) { - stopX1 = 999999999; - goto l12; - } else { - stopX1 = workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 2)]; - goto l12; - } - l12: /* end topRightX */; - } - /* begin makeUnsignedFrom: */ - /* begin topFill */ - if (((workBuffer[1]) - (workBuffer[10])) == 0) { - someIntegerValue11 = 0; - goto l15; - } else { - someIntegerValue11 = workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)]; - goto l15; - } - l15: /* end topFill */; - fill1 = someIntegerValue11; - if (!(fill1 == 0)) { - fillSpanfromto(fill1, startX1, rightX1); - goto l5; - } - l5: /* end fillAllFrom:to: */; - } - return 0; -} - -int findNextExternalUpdateFromAET(void) { - int count; - int edge; - int type; - - while ((workBuffer[13]) < (workBuffer[14])) { - edge = aetBuffer[workBuffer[13]]; - count = (objBuffer[edge + 7]) - 1; - if (count == 0) { - removeFirstAETEntry(); - } else { - objBuffer[edge + 7] = count; - type = (objBuffer[edge + 0]) & 65535; - if ((type & 254) == 2) { - return 1; - } - switch (type) { - case 0: - case 1: - case 2: - case 3: - errorWrongIndex(); - break; - case 4: - stepToNextLineInat(aetBuffer[workBuffer[13]], workBuffer[88]); - break; - case 5: - stepToNextWideLineInat(aetBuffer[workBuffer[13]], workBuffer[88]); - break; - case 6: - stepToNextBezierInat(aetBuffer[workBuffer[13]], workBuffer[88]); - break; - case 7: - stepToNextWideBezier(); - break; - } - resortFirstAETEntry(); - workBuffer[13] = ((workBuffer[13]) + 1); - } - } - return 0; -} - -int findStackFilldepth(int fillIndex, int depth) { - int index; - - index = 0; - while ((index < ((workBuffer[1]) - (workBuffer[10]))) && (((workBuffer[(workBuffer[10]) + index]) != fillIndex) || ((workBuffer[(workBuffer[10]) + (index + 1)]) != depth))) { - index += 3; - } - if (index >= ((workBuffer[1]) - (workBuffer[10]))) { - return -1; - } else { - return index; - } -} - -void * firstFixedField(int oop) { - return ((void *) (oop + 4)); -} - -void * firstIndexableField(int oop) { - int hdr; - int totalLength; - int fmt; - int fixedFields; - int sz; - int classFormat; - int class; - int ccIndex; - - hdr = longAt(oop); - fmt = (((unsigned) hdr) >> 8) & 15; - /* begin lengthOf:baseHeader:format: */ - if ((hdr & 3) == 0) { - sz = (longAt(oop - 8)) & 4294967292U; - } else { - sz = hdr & 252; - } - if (fmt < 8) { - totalLength = ((unsigned) (sz - 4)) >> 2; - goto l1; - } else { - totalLength = (sz - 4) - (fmt & 3); - goto l1; - } -l1: /* end lengthOf:baseHeader:format: */; - /* begin fixedFieldsOf:format:length: */ - if ((fmt > 4) || (fmt == 2)) { - fixedFields = 0; - goto l2; - } - if (fmt < 2) { - fixedFields = totalLength; - goto l2; - } - /* begin fetchClassOf: */ - if ((oop & 1)) { - class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l3; - } - ccIndex = (((unsigned) (longAt(oop))) >> 12) & 31; - if (ccIndex == 0) { - class = (longAt(oop - 4)) & 4294967292U; - goto l3; - } else { - class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l3; - } -l3: /* end fetchClassOf: */; - classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; - fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; -l2: /* end fixedFieldsOf:format:length: */; - if (fmt < 8) { - return ((void *) ((oop + 4) + (fixedFields << 2))); - } else { - return ((void *) ((oop + 4) + fixedFields)); - } -} - -int floatObjectOf(double aFloat) { - int newFloatObj; - newFloatObj = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)), 12, 0); - storeFloatAtfrom(newFloatObj + 4, aFloat); - return newFloatObj; -} +/* Fetch the instance variable at the given index of the given object. Return the C double precision floating point value of that instance variable, or fail if it is not a Float. */ +/* Note: May be called by translated primitive code. */ double floatValueOf(int oop) { double result; - int ccIndex; int cl; + int ccIndex; /* begin assertClassOf:is: */ if ((oop & 1)) { @@ -6176,38 +3727,170 @@ double floatValueOf(int oop) { return result; } + +/* Flush the references to external functions from plugin primitives. + This will force a reload of those primitives when accessed next. + Note: We must flush the method cache here so that any failed + primitives are looked up again. */ + +int flushExternalPrimitives(void) { + int oop; + int fmt; + int primIdx; + int chunk; + int extra; + int i; + int i1; + int i2; + int primBits; + int extra1; + int type; + int sz; + int extra2; + int header; + int extra11; + int type1; + int lit; + + /* begin oopFromChunk: */ + chunk = startOfMemory(); + /* begin extraHeaderBytes: */ + type = (longAt(chunk)) & 3; + if (type > 1) { + extra1 = 0; + } else { + if (type == 1) { + extra1 = 4; + } else { + extra1 = 8; + } + } + extra = extra1; + oop = chunk + extra; + while (oop < endOfMemory) { + if (!(((longAt(oop)) & 3) == 2)) { + fmt = (((unsigned) (longAt(oop))) >> 8) & 15; + if (fmt >= 12) { + /* begin primitiveIndexOf: */ + primBits = (((unsigned) (longAt(((((char *) oop)) + 4) + (0 << 2)))) >> 1) & 805306879; + if (primBits > 511) { + primIdx = (primBits & 511) + (((unsigned) primBits) >> 19); + goto l1; + } else { + primIdx = primBits; + goto l1; + } + l1: /* end primitiveIndexOf: */; + if (primIdx == 117) { + /* begin flushExternalPrimitiveOf: */ + if (!(((((unsigned) (longAt(((((char *) oop)) + 4) + (0 << 2)))) >> 10) & 255) > 0)) { + goto l3; + } + lit = longAt(((((char *) oop)) + 4) + ((0 + 1) << 2)); + if (!(((fetchClassOf(lit)) == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)))) && ((lengthOf(lit)) == 4))) { + goto l3; + } + /* begin storeInteger:ofObject:withValue: */ + if ((0 ^ (0 << 1)) >= 0) { + longAtput(((((char *) lit)) + 4) + (2 << 2), ((0 << 1) | 1)); + } else { + /* begin primitiveFail */ + successFlag = 0; + } + /* begin storeInteger:ofObject:withValue: */ + if ((0 ^ (0 << 1)) >= 0) { + longAtput(((((char *) lit)) + 4) + (3 << 2), ((0 << 1) | 1)); + } else { + /* begin primitiveFail */ + successFlag = 0; + } + l3: /* end flushExternalPrimitiveOf: */; + } + } + } + /* begin objectAfter: */ + ; + if (((longAt(oop)) & 3) == 2) { + sz = (longAt(oop)) & 4294967292U; + } else { + /* begin sizeBitsOf: */ + header = longAt(oop); + if ((header & 3) == 0) { + sz = (longAt(oop - 8)) & 4294967292U; + goto l2; + } else { + sz = header & 252; + goto l2; + } + l2: /* end sizeBitsOf: */; + } + /* begin oopFromChunk: */ + /* begin extraHeaderBytes: */ + type1 = (longAt(oop + sz)) & 3; + if (type1 > 1) { + extra11 = 0; + } else { + if (type1 == 1) { + extra11 = 4; + } else { + extra11 = 8; + } + } + extra2 = extra11; + oop = (oop + sz) + extra2; + } + /* begin flushMethodCache */ + for (i = 1; i <= 4096; i += 1) { + methodCache[i] = 0; + } + for (i = 1; i <= 64; i += 1) { + atCache[i] = 0; + } + /* begin flushObsoleteIndexedPrimitives */ + for (i1 = 1; i1 <= 700; i1 += 1) { + (obsoleteIndexedPrimitiveTable[i1])[2] = null; + } + /* begin flushExternalPrimitiveTable */ + for (i2 = 0; i2 <= (4096 - 1); i2 += 1) { + externalPrimitiveTable[i2] = 0; + } +} + + +/* Repaint the entire smalltalk screen, ignoring the affected rectangle. Used when the Smalltalk window is brought to the front or uncovered. */ + int fullDisplayUpdate(void) { + int w; int displayObj; - int dispBits; - int dispBitsIndex; int h; - int w; - int d; displayObj = longAt(((((char *) specialObjectsOop)) + 4) + (14 << 2)); if ((((((unsigned) (longAt(displayObj))) >> 8) & 15) <= 4) && ((lengthOf(displayObj)) >= 4)) { - dispBits = longAt(((((char *) displayObj)) + 4) + (0 << 2)); w = fetchIntegerofObject(1, displayObj); h = fetchIntegerofObject(2, displayObj); - d = fetchIntegerofObject(3, displayObj); - dispBitsIndex = dispBits + 4; - ioShowDisplay(dispBitsIndex, w, h, d, 0, w, 0, h); + displayBitsOfLeftTopRightBottom(displayObj, 0, 0, w, h); ioForceDisplayUpdate(); } } + +/* Do a mark/sweep garbage collection of the entire object memory. Free inaccessible objects but do not move them. */ + int fullGC(void) { int startTime; - int oop; int i; - + int oop; + int sz; + int delta; + int limit; + int delta1; + int limit1; + ; /* begin preGCAction: */ - /* begin compilerPreGCHook: */ if (compilerInitialized) { compilerPreGC(1); - } - if (!(activeContext == nilObj)) { + } else { /* begin storeContextRegisters: */ longAtput(((((char *) activeContext)) + 4) + (1 << 2), ((((instructionPointer - method) - (4 - 2)) << 1) | 1)); longAtput(((((char *) activeContext)) + 4) + (2 << 2), (((((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) - 6) + 1) << 1) | 1)); @@ -6220,15 +3903,27 @@ int fullGC(void) { rootTable[i] = 0; } rootTableCount = 0; + + /* process all of memory */ + youngStart = startOfMemory(); markPhase(); - sweepPhase(); + totalObjectCount = sweepPhase(); /* begin fullCompaction */ compStart = lowestFreeAfter(startOfMemory()); if (compStart == freeBlock) { initializeMemoryFirstFree(freeBlock); goto l1; } + if ((sz = fwdTableSize(8)) < totalObjectCount) { + /* begin growObjectMemory: */ + delta = ((totalObjectCount - sz) + 10000) * 8; + limit = sqGrowMemoryBy(memoryLimit, delta); + if (!(limit == memoryLimit)) { + memoryLimit = limit - 24; + initializeMemoryFirstFree(freeBlock); + } + } while (compStart < freeBlock) { compStart = incCompBody(); } @@ -6236,20730 +3931,10095 @@ int fullGC(void) { allocationCount = 0; statFullGCs += 1; statFullGCMSecs += (ioMicroMSecs()) - startTime; + + /* reset the young object boundary */ + youngStart = freeBlock; /* begin postGCAction */ - /* begin compilerPostGCHook */ if (compilerInitialized) { compilerPostGC(); + } else { + if (activeContext < youngStart) { + beRootIfOld(activeContext); + } + if (theHomeContext < youngStart) { + beRootIfOld(theHomeContext); + } } - if (activeContext < youngStart) { - beRootIfOld(activeContext); - } - if (theHomeContext < youngStart) { - beRootIfOld(theHomeContext); + if (((longAt(freeBlock)) & 4294967292U) > shrinkThreshold) { + /* begin shrinkObjectMemory: */ + delta1 = ((longAt(freeBlock)) & 4294967292U) - growHeadroom; + limit1 = sqShrinkMemoryBy(memoryLimit, delta1); + if (!(limit1 == memoryLimit)) { + memoryLimit = limit1 - 24; + initializeMemoryFirstFree(freeBlock); + } } ; } + +/* Set the limits for a table of two- or three-word forwarding blocks above the last used oop. The pointer fwdTableNext moves up to fwdTableLast. Used for compaction of memory and become-ing objects. Returns the number of forwarding blocks available. */ + int fwdTableInit(int blkSize) { /* begin setSizeOfFree:to: */ longAtput(freeBlock, (4 & 4294967292U) | 2); + + /* make a fake free chunk at endOfMemory for use as a sentinal in memory scans */ + endOfMemory = freeBlock + 4; /* begin setSizeOfFree:to: */ longAtput(endOfMemory, (4 & 4294967292U) | 2); fwdTableNext = ((endOfMemory + 4) + 7) & 4294967288U; + + /* last forwarding table entry */ + /* return the number of forwarding blocks available */ + fwdTableLast = memoryLimit - blkSize; return (fwdTableLast - fwdTableNext) / blkSize; } -EXPORT(int) gePrimitiveAbortProcessing(void) { - int oop; - if (!(argumentCount == 0)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l1; - } - engine = oop; -l1: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFrom(engine))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - workBuffer[2] = 8; - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; +/* Estimate the number of forwarding blocks available for compaction */ + +int fwdTableSize(int blkSize) { + int eom; + int fwdLast; + int fwdFirst; + + + /* use all memory free between freeBlock and memoryLimit for forwarding table */ + /* Note: Forward blocks must be quadword aligned. */ + + eom = freeBlock + 4; + fwdFirst = ((eom + 4) + 7) & 4294967288U; + + /* last forwarding table entry */ + /* return the number of forwarding blocks available */ + + fwdLast = memoryLimit - blkSize; + return (fwdLast - fwdFirst) / blkSize; } -EXPORT(int) gePrimitiveAddActiveEdgeEntry(void) { - int edgeOop; - int edge; - int value; - int oop; - int oop1; - if (doProfileStats) { - geProfileTime = ioMicroMSecs(); - } - if (!(argumentCount == 1)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - edgeOop = null; - goto l1; - } - edgeOop = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l2; - } - engine = oop1; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFromrequiredState(engine, 2))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - edge = loadEdgeStateFrom(edgeOop); - if (!successFlag) { - return null; - } - if (!(needAvailableSpace(1))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if ((objBuffer[edge + 7]) > 0) { - insertEdgeIntoAET(edge); - } - if (engineStopped) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - workBuffer[2] = 1; - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 1 * 4; - if (doProfileStats) { - workBuffer[97] = ((workBuffer[97]) + 1); - /* begin incrementStat:by: */ - value = (ioMicroMSecs()) - geProfileTime; - workBuffer[96] = ((workBuffer[96]) + value); - } +/* currentBytecode will be private to the main dispatch loop in the generated code. This method allows the currentBytecode to be retrieved from global variables. */ + +int getCurrentBytecode(void) { + return byteAt(instructionPointer); } -EXPORT(int) gePrimitiveAddBezier(void) { - int nSegments; - int leftFill; - int rightFill; - int viaOop; - int startOop; - int endOop; - int oop; - int oop1; - int oop2; - if (!(argumentCount == 5)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - rightFill = positive32BitValueOf(longAt(stackPointer - (0 * 4))); - leftFill = positive32BitValueOf(longAt(stackPointer - (1 * 4))); - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (2 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - viaOop = null; - goto l1; - } - viaOop = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (3 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - endOop = null; - goto l2; - } - endOop = oop1; -l2: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop2 = longAt(stackPointer - (4 * 4)); - if ((oop2 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - startOop = null; - goto l3; - } - startOop = oop2; -l3: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFromrequiredState(stackObjectValue(5), 0))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!((isFillOkay(leftFill)) && (isFillOkay(rightFill)))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if ((leftFill == rightFill) && 0) { - /* begin pop: */ - stackPointer -= 6 * 4; - return null; - } - loadPointfrom(((int *) (workBuffer + 80)), startOop); - loadPointfrom(((int *) (workBuffer + 82)), viaOop); - loadPointfrom(((int *) (workBuffer + 84)), endOop); - if (!successFlag) { - return 0; - } - /* begin transformPoints: */ - if (3 > 0) { - transformPoint(((int *) (workBuffer + 80))); - } - if (3 > 1) { - transformPoint(((int *) (workBuffer + 82))); - } - if (3 > 2) { - transformPoint(((int *) (workBuffer + 84))); - } - if (3 > 3) { - transformPoint(((int *) (workBuffer + 86))); - } - nSegments = loadAndSubdivideBezierFromviatoisWide(((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), ((int *) (workBuffer + 84)), 0); - /* begin needAvailableSpace: */ - if (((((128 + objUsed) + (workBuffer[12])) + (workBuffer[14])) + (nSegments * 16)) > (workBuffer[10])) { - /* begin stopBecauseOf: */ - workBuffer[64] = 1; - engineStopped = 1; - goto l4; - } -l4: /* end needAvailableSpace: */; - if (!(engineStopped)) { - leftFill = transformColor(leftFill); - rightFill = transformColor(rightFill); - } - if (!(engineStopped)) { - loadWideBezierlineFillleftFillrightFilln(0, 0, leftFill, rightFill, nSegments); - } - if (engineStopped) { - /* begin wbStackClear */ - workBuffer[10] = (workBuffer[1]); - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(!successFlag)) { - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 5 * 4; +/* Return the next 4-byte word of the given file, byte-swapped according to the given flag. */ + +int getLongFromFileswap(sqImageFile f, int swapFlag) { + int w; + + sqImageFileRead(&w, sizeof(char), 4, f); + if (swapFlag) { + return ((((((unsigned) w >> 24)) & 255) + ((((unsigned) w >> 8)) & 65280)) + ((((unsigned) w << 8)) & 16711680)) + ((((unsigned) w << 24)) & 4278190080U); + } else { + return w; } } -EXPORT(int) gePrimitiveAddBezierShape(void) { - int nSegments; - int points; - int isArray; - int segSize; - int fillIndex; - int lineFill; - int length; - int lineWidth; - int integerPointer; - int integerPointer1; + +/* a more complex version that tells both the word reversal and the endianness of the machine it came from. Low half of word is 6502. Top byte is top byte of #doesNotUnderstand: on this machine. ($d on the Mac or $s on the PC) */ + +int imageSegmentVersion(void) { + int wholeWord; + + + /* first data word, 'does' */ + + wholeWord = longAt((longAt(((((char *) specialObjectsOop)) + 4) + (20 << 2))) + 4); + return 6502 | (wholeWord & 4278190080U); +} + + +/* Move objects to consolidate free space into one big chunk. Return the newly created free chunk. */ + +int incCompBody(void) { + int bytesFreed; + int newOop; int oop; + int fwdBlock; + int bytesFreed1; + int extra; + int originalHeaderType; + int originalHeader; + int chunk; + int extra1; + int extra2; + int type; + int extra3; + int type1; int header; + int w; + int newOop1; + int newFreeChunk; + int oop1; + int lastWord; int sz; + int fwdBlock1; + int firstWord; + int next; + int bytesToMove; + int header1; + int chunk2; + int extra4; + int chunk1; + int extra11; + int extra21; + int type2; + int extra31; + int type11; + int header2; + int sz2; + int fwdBlock2; + int realHeader; + int extra5; + int extra12; + int type3; + int sz1; + int extra22; + int header11; + int extra111; + int type12; + int header3; + int sz3; + int fwdBlock3; + int realHeader1; + int extra6; + int extra13; + int type4; + int sz11; + int extra23; + int header12; + int extra112; + int type13; - if (!(argumentCount == 5)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - lineFill = positive32BitValueOf(longAt(stackPointer - (0 * 4))); - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (1 * 4)); - if ((integerPointer & 1)) { - lineWidth = (integerPointer >> 1); - goto l1; + fwdTableInit(8); + /* begin incCompMakeFwd */ + bytesFreed1 = 0; + /* begin oopFromChunk: */ + chunk = compStart; + /* begin extraHeaderBytes: */ + type1 = (longAt(chunk)) & 3; + if (type1 > 1) { + extra3 = 0; } else { - /* begin primitiveFail */ - successFlag = 0; - lineWidth = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - fillIndex = positive32BitValueOf(longAt(stackPointer - (2 * 4))); - /* begin stackIntegerValue: */ - integerPointer1 = longAt(stackPointer - (3 * 4)); - if ((integerPointer1 & 1)) { - nSegments = (integerPointer1 >> 1); - goto l2; - } else { - /* begin primitiveFail */ - successFlag = 0; - nSegments = 0; - goto l2; - } -l2: /* end stackIntegerValue: */; - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (4 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - points = null; - goto l3; - } - points = oop; -l3: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFromrequiredState(stackObjectValue(5), 0))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin slotSizeOf: */ - if ((points & 1)) { - length = 0; - goto l4; - } - /* begin lengthOf: */ - header = longAt(points); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(points - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - length = ((unsigned) (sz - 4)) >> 2; - goto l4; - } else { - length = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l4; + if (type1 == 1) { + extra3 = 4; + } else { + extra3 = 8; + } } - length = null; -l4: /* end slotSizeOf: */; - if (((((unsigned) (longAt(points))) >> 8) & 15) == 6) { - isArray = 0; - if (!((length == (nSegments * 3)) || (length == (nSegments * 6)))) { - /* begin primitiveFail */ - successFlag = 0; - return null; + extra1 = extra3; + oop = chunk + extra1; + while (oop < endOfMemory) { + if (((longAt(oop)) & 3) == 2) { + bytesFreed1 += (longAt(oop)) & 4294967292U; + } else { + /* begin fwdBlockGet: */ + fwdTableNext += 8; + if (fwdTableNext <= fwdTableLast) { + fwdBlock = fwdTableNext; + goto l1; + } else { + fwdBlock = null; + goto l1; + } + l1: /* end fwdBlockGet: */; + if (fwdBlock == null) { + /* begin chunkFromOop: */ + /* begin extraHeaderBytes: */ + type = (longAt(oop)) & 3; + if (type > 1) { + extra2 = 0; + } else { + if (type == 1) { + extra2 = 4; + } else { + extra2 = 8; + } + } + extra = extra2; + compEnd = oop - extra; + bytesFreed = bytesFreed1; + goto l2; + } + newOop = oop - bytesFreed1; + /* begin initForwardBlock:mapping:to:withBackPtr: */ + originalHeader = longAt(oop); + ; + originalHeaderType = originalHeader & 3; + longAtput(fwdBlock, newOop); + longAtput(fwdBlock + 4, originalHeader); + ; + longAtput(oop, (((unsigned) fwdBlock) >> 1) | (2147483648U | originalHeaderType)); } - } else { - if (!((fetchClassOf(points)) == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2))))) { - /* begin primitiveFail */ - successFlag = 0; - return null; + /* begin objectAfterWhileForwarding: */ + header2 = longAt(oop); + if ((header2 & 2147483648U) == 0) { + /* begin objectAfter: */ + ; + if (((longAt(oop)) & 3) == 2) { + sz1 = (longAt(oop)) & 4294967292U; + } else { + /* begin sizeBitsOf: */ + header11 = longAt(oop); + if ((header11 & 3) == 0) { + sz1 = (longAt(oop - 8)) & 4294967292U; + goto l4; + } else { + sz1 = header11 & 252; + goto l4; + } + l4: /* end sizeBitsOf: */; + } + /* begin oopFromChunk: */ + /* begin extraHeaderBytes: */ + type12 = (longAt(oop + sz1)) & 3; + if (type12 > 1) { + extra111 = 0; + } else { + if (type12 == 1) { + extra111 = 4; + } else { + extra111 = 8; + } + } + extra22 = extra111; + oop = (oop + sz1) + extra22; + goto l5; } - if (!(length == (nSegments * 3))) { - /* begin primitiveFail */ - successFlag = 0; - return null; + fwdBlock2 = (header2 & 2147483644) << 1; + ; + realHeader = longAt(fwdBlock2 + 4); + if ((realHeader & 3) == 0) { + sz2 = (longAt(oop - 8)) & 4294967292U; + } else { + sz2 = realHeader & 252; } - isArray = 1; - } - if ((lineWidth == 0) || (lineFill == 0)) { - segSize = 16; - } else { - segSize = 21; - } - if (!(needAvailableSpace(segSize * nSegments))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!((isFillOkay(lineFill)) && (isFillOkay(fillIndex)))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - lineFill = transformColor(lineFill); - fillIndex = transformColor(fillIndex); - if (engineStopped) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (((lineFill == 0) || (lineWidth == 0)) && (fillIndex == 0)) { - /* begin pop: */ - stackPointer -= 5 * 4; - return null; - } - if (!(lineWidth == 0)) { - lineWidth = transformWidth(lineWidth); - if (lineWidth < 1) { - lineWidth = 1; + /* begin oopFromChunk: */ + /* begin extraHeaderBytes: */ + type3 = (longAt(oop + sz2)) & 3; + if (type3 > 1) { + extra12 = 0; + } else { + if (type3 == 1) { + extra12 = 4; + } else { + extra12 = 8; + } } + extra5 = extra12; + oop = (oop + sz2) + extra5; + l5: /* end objectAfterWhileForwarding: */; } - if (isArray) { - loadArrayShapenSegmentsfilllineWidthlineFill(points, nSegments, fillIndex, lineWidth, lineFill); - } else { - loadShapenSegmentsfilllineWidthlineFillpointsShort(firstIndexableField(points), nSegments, fillIndex, lineWidth, lineFill, (nSegments * 3) == length); - } - if (engineStopped) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(!successFlag)) { - workBuffer[63] = 1; - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 5 * 4; - } -} - -EXPORT(int) gePrimitiveAddBitmapFill(void) { - int dirOop; - int xIndex; - int fill; - int cmOop; - int formOop; - int originOop; - int tileFlag; - int nrmOop; - int object; - int sp; - int integerPointer; - int oop; - int oop1; - int oop2; - int oop3; - int oop4; - - if (!(argumentCount == 7)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - xIndex = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - xIndex = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - if (xIndex <= 0) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (1 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - nrmOop = null; - goto l2; - } - nrmOop = oop; -l2: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (2 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - dirOop = null; - goto l3; - } - dirOop = oop1; -l3: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop2 = longAt(stackPointer - (3 * 4)); - if ((oop2 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - originOop = null; - goto l4; - } - originOop = oop2; -l4: /* end stackObjectValue: */; - /* begin booleanValueOf: */ - if ((longAt(stackPointer - (4 * 4))) == trueObj) { - tileFlag = 1; - goto l5; - } - if ((longAt(stackPointer - (4 * 4))) == falseObj) { - tileFlag = 0; - goto l5; - } - successFlag = 0; - tileFlag = null; -l5: /* end booleanValueOf: */; - if (tileFlag) { - tileFlag = 1; + compEnd = endOfMemory; + bytesFreed = bytesFreed1; +l2: /* end incCompMakeFwd */; + mapPointersInObjectsFromto(youngStart, endOfMemory); + /* begin incCompMove: */ + newOop1 = null; + /* begin oopFromChunk: */ + chunk1 = compStart; + /* begin extraHeaderBytes: */ + type11 = (longAt(chunk1)) & 3; + if (type11 > 1) { + extra31 = 0; } else { - tileFlag = 0; - } - /* begin stackObjectValue: */ - oop3 = longAt(stackPointer - (5 * 4)); - if ((oop3 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - cmOop = null; - goto l6; + if (type11 == 1) { + extra31 = 4; + } else { + extra31 = 8; + } } - cmOop = oop3; -l6: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop4 = longAt(stackPointer - (6 * 4)); - if ((oop4 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - formOop = null; - goto l7; - } - formOop = oop4; -l7: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFromrequiredState(stackObjectValue(7), 0))) { - /* begin primitiveFail */ - successFlag = 0; - return null; + extra11 = extra31; + oop1 = chunk1 + extra11; + while (oop1 < compEnd) { + /* begin objectAfterWhileForwarding: */ + header3 = longAt(oop1); + if ((header3 & 2147483648U) == 0) { + /* begin objectAfter: */ + ; + if (((longAt(oop1)) & 3) == 2) { + sz11 = (longAt(oop1)) & 4294967292U; + } else { + /* begin sizeBitsOf: */ + header12 = longAt(oop1); + if ((header12 & 3) == 0) { + sz11 = (longAt(oop1 - 8)) & 4294967292U; + goto l6; + } else { + sz11 = header12 & 252; + goto l6; + } + l6: /* end sizeBitsOf: */; + } + /* begin oopFromChunk: */ + /* begin extraHeaderBytes: */ + type13 = (longAt(oop1 + sz11)) & 3; + if (type13 > 1) { + extra112 = 0; + } else { + if (type13 == 1) { + extra112 = 4; + } else { + extra112 = 8; + } + } + extra23 = extra112; + next = (oop1 + sz11) + extra23; + goto l7; + } + fwdBlock3 = (header3 & 2147483644) << 1; + ; + realHeader1 = longAt(fwdBlock3 + 4); + if ((realHeader1 & 3) == 0) { + sz3 = (longAt(oop1 - 8)) & 4294967292U; + } else { + sz3 = realHeader1 & 252; + } + /* begin oopFromChunk: */ + /* begin extraHeaderBytes: */ + type4 = (longAt(oop1 + sz3)) & 3; + if (type4 > 1) { + extra13 = 0; + } else { + if (type4 == 1) { + extra13 = 4; + } else { + extra13 = 8; + } + } + extra6 = extra13; + next = (oop1 + sz3) + extra6; + l7: /* end objectAfterWhileForwarding: */; + if (!(((longAt(oop1)) & 3) == 2)) { + fwdBlock1 = ((longAt(oop1)) & 2147483644) << 1; + ; + newOop1 = longAt(fwdBlock1); + header = longAt(fwdBlock1 + 4); + longAtput(oop1, header); + bytesToMove = oop1 - newOop1; + /* begin sizeBitsOf: */ + header1 = longAt(oop1); + if ((header1 & 3) == 0) { + sz = (longAt(oop1 - 8)) & 4294967292U; + goto l3; + } else { + sz = header1 & 252; + goto l3; + } + l3: /* end sizeBitsOf: */; + firstWord = oop1 - (extraHeaderBytes(oop1)); + lastWord = (oop1 + sz) - 4; + for (w = firstWord; w <= lastWord; w += 4) { + longAtput(w - bytesToMove, longAt(w)); + } + } + oop1 = next; } - loadPointfrom(((int *) (workBuffer + 80)), originOop); - loadPointfrom(((int *) (workBuffer + 82)), dirOop); - loadPointfrom(((int *) (workBuffer + 84)), nrmOop); - if (!successFlag) { - return 0; + if (newOop1 == null) { + /* begin oopFromChunk: */ + chunk2 = compStart; + /* begin extraHeaderBytes: */ + type2 = (longAt(chunk2)) & 3; + if (type2 > 1) { + extra21 = 0; + } else { + if (type2 == 1) { + extra21 = 4; + } else { + extra21 = 8; + } + } + extra4 = extra21; + oop1 = chunk2 + extra4; + if ((((longAt(oop1)) & 3) == 2) && ((objectAfter(oop1)) == (oopFromChunk(compEnd)))) { + newFreeChunk = oop1; + } else { + newFreeChunk = freeBlock; + } + } else { + newFreeChunk = newOop1 + (sizeBitsOf(newOop1)); + /* begin setSizeOfFree:to: */ + longAtput(newFreeChunk, (bytesFreed & 4294967292U) | 2); } - fill = loadBitmapFillcolormaptilefromalongnormalxIndex(formOop, cmOop, tileFlag, ((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), ((int *) (workBuffer + 84)), xIndex - 1); - if (engineStopped) { - /* begin primitiveFail */ - successFlag = 0; - return null; + ; + if ((objectAfter(newFreeChunk)) == endOfMemory) { + initializeMemoryFirstFree(newFreeChunk); + } else { + initializeMemoryFirstFree(freeBlock); } - if (!(!successFlag)) { - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 8 * 4; - /* begin push: */ - object = positive32BitIntegerFor(fill); - longAtput(sp = stackPointer + 4, object); - stackPointer = sp; + return newFreeChunk; +} + + +/* Return the equivalent of + aClass includesBehavior: aSuperclass. + Note: written for efficiency and better inlining (only 1 temp) */ + +int includesBehaviorThatOf(int aClass, int aSuperclass) { + int theClass; + + if (((theClass = aClass) == aSuperclass) || (aSuperclass == nilObj)) { + return 1; } + do { + if ((theClass = longAt(((((char *) theClass)) + 4) + (0 << 2))) == aSuperclass) { + return 1; + } + } while(theClass != nilObj); + return 0; } -EXPORT(int) gePrimitiveAddCompressedShape(void) { - int nSegments; - int points; - int pointsShort; - int lineWidths; - int lineFills; - int rightFills; - int leftFills; - int fillIndexList; + +/* Do a mark/sweep garbage collection of just the young object area of object memory (i.e., objects above youngStart), using the root table to identify objects containing pointers to young objects from the old object area. */ + +int incrementalGC(void) { + int startTime; + int survivorCount; + int i; int oop; + int delta; + int limit; + int header; int oop1; - int oop2; - int oop3; - int oop4; - int integerPointer; - int oop5; + int badRoot; + int fieldOop; + int fieldAddr; + int chunk; + int extra; + int extra1; + int type; + int sz; + int extra2; + int header1; + int extra11; + int type1; - if (!(argumentCount == 7)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - fillIndexList = null; - goto l1; - } - fillIndexList = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - lineFills = null; - goto l2; + if (rootTableCount >= 2500) { + statRootTableOverflows += 1; + return fullGC(); } - lineFills = oop1; -l2: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop2 = longAt(stackPointer - (2 * 4)); - if ((oop2 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - lineWidths = null; - goto l3; + ; + ; + /* begin preGCAction: */ + if (compilerInitialized) { + compilerPreGC(0); + } else { + /* begin storeContextRegisters: */ + longAtput(((((char *) activeContext)) + 4) + (1 << 2), ((((instructionPointer - method) - (4 - 2)) << 1) | 1)); + longAtput(((((char *) activeContext)) + 4) + (2 << 2), (((((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) - 6) + 1) << 1) | 1)); } - lineWidths = oop2; -l3: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop3 = longAt(stackPointer - (3 * 4)); - if ((oop3 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - rightFills = null; - goto l4; + startTime = ioMicroMSecs(); + markPhase(); + survivorCount = sweepPhase(); + /* begin incrementalCompaction */ + if (compStart == freeBlock) { + initializeMemoryFirstFree(freeBlock); + } else { + incCompBody(); } - rightFills = oop3; -l4: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop4 = longAt(stackPointer - (4 * 4)); - if ((oop4 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - leftFills = null; - goto l5; + allocationCount = 0; + statIncrGCs += 1; + statIncrGCMSecs += (ioMicroMSecs()) - startTime; + if (survivorCount > tenuringThreshold) { + statTenures += 1; + /* begin clearRootsTable */ + for (i = 1; i <= rootTableCount; i += 1) { + oop = rootTable[i]; + longAtput(oop, (longAt(oop)) & 3221225471U); + rootTable[i] = 0; + } + rootTableCount = 0; + youngStart = freeBlock; } - leftFills = oop4; -l5: /* end stackObjectValue: */; - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (5 * 4)); - if ((integerPointer & 1)) { - nSegments = (integerPointer >> 1); - goto l6; + /* begin postGCAction */ + if (compilerInitialized) { + compilerPostGC(); } else { - /* begin primitiveFail */ - successFlag = 0; - nSegments = 0; - goto l6; - } -l6: /* end stackIntegerValue: */; - /* begin stackObjectValue: */ - oop5 = longAt(stackPointer - (6 * 4)); - if ((oop5 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - points = null; - goto l7; + if (activeContext < youngStart) { + beRootIfOld(activeContext); + } + if (theHomeContext < youngStart) { + beRootIfOld(theHomeContext); + } } - points = oop5; -l7: /* end stackObjectValue: */; - if (!successFlag) { - return null; + if (((longAt(freeBlock)) & 4294967292U) > shrinkThreshold) { + /* begin shrinkObjectMemory: */ + delta = ((longAt(freeBlock)) & 4294967292U) - growHeadroom; + limit = sqShrinkMemoryBy(memoryLimit, delta); + if (!(limit == memoryLimit)) { + memoryLimit = limit - 24; + initializeMemoryFirstFree(freeBlock); + } } - if (!(quickLoadEngineFromrequiredState(stackObjectValue(7), 0))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(checkCompressedShapesegmentsleftFillsrightFillslineWidthslineFillsfillIndexList(points, nSegments, leftFills, rightFills, lineWidths, lineFills, fillIndexList))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(needAvailableSpace((((16 < 16) ? 16 : 16)) * nSegments))) { - /* begin primitiveFail */ - successFlag = 0; - return null; + ; +} + + +/* Initialize hooks for the 'null compiler' */ + +int initCompilerHooks(void) { + compilerHooks[1]= nullCompilerHook; + compilerHooks[2]= nullCompilerHook; + compilerHooks[3]= nullCompilerHook; + compilerHooks[4]= nullCompilerHook; + compilerHooks[5]= nullCompilerHook; + compilerHooks[6]= nullCompilerHook; + compilerHooks[7]= nullCompilerHook; + compilerHooks[8]= nullCompilerHook; + compilerHooks[9]= nullCompilerHook; + compilerHooks[10]= nullCompilerHook; + compilerHooks[11]= nullCompilerHook; + compilerHooks[12]= nullCompilerHook; + compilerHooks[13]= nullCompilerHook; + compilerHooks[14]= nullCompilerHook; + compilerInitialized = 0; +} + + +/* Initialize endOfMemory to the top of oop storage space, reserving some space for forwarding blocks, and create the freeBlock from which space is allocated. Also create a fake free chunk at endOfMemory to act as a sentinal for memory scans. */ +/* Note: The amount of space reserved for forwarding blocks should be chosen to ensure that incremental compactions can usually be done in a single pass. However, there should be enough forwarding blocks so a full compaction can be done in a reasonable number of passes, say ten. (A full compaction requires N object-moving passes, where N = number of non-garbage objects / number of forwarding blocks). +di 11/18/2000 Re totalObjectCount: Provide a margin of one byte per object to be used for forwarding pointers at GC time. Since fwd blocks are 8 bytes, this means an absolute worst case of 8 passes to compact memory. In most cases it will be adequate to do compaction in a single pass. */ +/* reserve space for forwarding blocks */ + +int initializeMemoryFirstFree(int firstFree) { + int fwdBlockBytes; + + fwdBlockBytes = totalObjectCount & 4294967292U; + if (!((memoryLimit - fwdBlockBytes) >= (firstFree + 4))) { + fwdBlockBytes = memoryLimit - (firstFree + 4); } - pointsShort = (slotSizeOf(points)) == (nSegments * 3); - loadCompressedShapesegmentsleftFillsrightFillslineWidthslineFillsfillIndexListpointShort(firstIndexableField(points), nSegments, firstIndexableField(leftFills), firstIndexableField(rightFills), firstIndexableField(lineWidths), firstIndexableField(lineFills), firstIndexableField(fillIndexList), pointsShort); - if (engineStopped) { - /* begin primitiveFail */ - successFlag = 0; - return null; + endOfMemory = memoryLimit - fwdBlockBytes; + freeBlock = firstFree; + /* begin setSizeOfFree:to: */ + longAtput(freeBlock, ((endOfMemory - firstFree) & 4294967292U) | 2); + /* begin setSizeOfFree:to: */ + longAtput(endOfMemory, (4 & 4294967292U) | 2); + ; +} + + +/* Initialize object memory variables at startup time. Assume endOfMemory is initially set (by the image-reading code) to the end of the last object in the image. Initialization redefines endOfMemory to be the end of the object allocation area based on the total available memory, but reserving some space for forwarding blocks. */ +/* Assume: image reader initializes the following variables: + memory + endOfMemory + memoryLimit + specialObjectsOop + lastHash + */ +/* di 11/18/2000 fix slow full GC */ + +int initializeObjectMemory(int bytesToShift) { + int header; + int oop; + int totalObjects; + int chunk; + int extra; + int fieldOop; + int newClassOop; + int fieldAddr; + int classHeader; + int extra1; + int type; + int sz; + int extra2; + int header1; + int extra11; + int type1; + + + /* image may be at a different address; adjust oops for new location */ + + youngStart = endOfMemory; + /* begin adjustAllOopsBy: */ + totalObjects = 0; + /* begin oopFromChunk: */ + chunk = startOfMemory(); + /* begin extraHeaderBytes: */ + type = (longAt(chunk)) & 3; + if (type > 1) { + extra1 = 0; + } else { + if (type == 1) { + extra1 = 4; + } else { + extra1 = 8; + } } - if (!(!successFlag)) { - workBuffer[63] = 1; - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 7 * 4; + extra = extra1; + oop = chunk + extra; + while (oop < endOfMemory) { + if (!(((longAt(oop)) & 3) == 2)) { + totalObjects += 1; + header = longAt(oop); + longAtput(oop, header & 3221225471U); + /* begin adjustFieldsAndClassOf:by: */ + fieldAddr = oop + (lastPointerOf(oop)); + while (fieldAddr > oop) { + fieldOop = longAt(fieldAddr); + if (!((fieldOop & 1))) { + longAtput(fieldAddr, fieldOop + bytesToShift); + } + fieldAddr -= 4; + } + if (((longAt(oop)) & 3) != 3) { + classHeader = longAt(oop - 4); + newClassOop = (classHeader & 4294967292U) + bytesToShift; + longAtput(oop - 4, newClassOop | (classHeader & 3)); + } + } + /* begin objectAfter: */ + ; + if (((longAt(oop)) & 3) == 2) { + sz = (longAt(oop)) & 4294967292U; + } else { + /* begin sizeBitsOf: */ + header1 = longAt(oop); + if ((header1 & 3) == 0) { + sz = (longAt(oop - 8)) & 4294967292U; + goto l1; + } else { + sz = header1 & 252; + goto l1; + } + l1: /* end sizeBitsOf: */; + } + /* begin oopFromChunk: */ + /* begin extraHeaderBytes: */ + type1 = (longAt(oop + sz)) & 3; + if (type1 > 1) { + extra11 = 0; + } else { + if (type1 == 1) { + extra11 = 4; + } else { + extra11 = 8; + } + } + extra2 = extra11; + oop = (oop + sz) + extra2; } + totalObjectCount = totalObjects; + initializeMemoryFirstFree(endOfMemory); + + /* heavily used special objects */ + + specialObjectsOop += bytesToShift; + nilObj = longAt(((((char *) specialObjectsOop)) + 4) + (0 << 2)); + falseObj = longAt(((((char *) specialObjectsOop)) + 4) + (1 << 2)); + trueObj = longAt(((((char *) specialObjectsOop)) + 4) + (2 << 2)); + rootTableCount = 0; + child = 0; + field = 0; + parentField = 0; + freeContexts = 1; + freeLargeContexts = 1; + allocationCount = 0; + lowSpaceThreshold = 0; + signalLowSpace = 0; + compStart = 0; + compEnd = 0; + fwdTableNext = 0; + fwdTableLast = 0; + remapBufferCount = 0; + + /* do incremental GC after this many allocations */ + + allocationsBetweenGCs = 4000; + + /* tenure all suriving objects if count is over this threshold */ + + tenuringThreshold = 2000; + + /* four megabyte of headroom when growing */ + + growHeadroom = (4 * 1024) * 1024; + + /* eight megabyte of free space before shrinking */ + /* garbage collection statistics */ + + shrinkThreshold = (8 * 1024) * 1024; + statFullGCs = 0; + statFullGCMSecs = 0; + statIncrGCs = 0; + statIncrGCMSecs = 0; + statTenures = 0; + statRootTableOverflows = 0; + displayBits = 0; } -EXPORT(int) gePrimitiveAddGradientFill(void) { - int nrmOop; - int fill; - int originOop; - int rampOop; - int dirOop; - int isRadial; - int object; - int sp; - if (!(argumentCount == 5)) { +/* Install the oop of this object in the given cache (at or atPut), along with + its size, format and fixedSize */ + +int installinAtCacheatstring(int rcvr, int *cache, int atIx, int stringy) { + int hdr; + int totalLength; + int fixedFields; + int fmt; + int sz; + int classFormat; + int class; + int ccIndex; + + hdr = longAt(rcvr); + fmt = (((unsigned) hdr) >> 8) & 15; + if ((fmt == 3) && (isContextHeader(hdr))) { /* begin primitiveFail */ successFlag = 0; return null; } - /* begin booleanValueOf: */ - if ((longAt(stackPointer - (0 * 4))) == trueObj) { - isRadial = 1; - goto l1; + /* begin lengthOf:baseHeader:format: */ + if ((hdr & 3) == 0) { + sz = (longAt(rcvr - 8)) & 4294967292U; + } else { + sz = hdr & 252; } - if ((longAt(stackPointer - (0 * 4))) == falseObj) { - isRadial = 0; + if (fmt < 8) { + totalLength = ((unsigned) (sz - 4)) >> 2; + goto l1; + } else { + totalLength = (sz - 4) - (fmt & 3); goto l1; } - successFlag = 0; - isRadial = null; -l1: /* end booleanValueOf: */; - nrmOop = longAt(stackPointer - (1 * 4)); - dirOop = longAt(stackPointer - (2 * 4)); - originOop = longAt(stackPointer - (3 * 4)); - rampOop = longAt(stackPointer - (4 * 4)); - if (!successFlag) { - return null; +l1: /* end lengthOf:baseHeader:format: */; + /* begin fixedFieldsOf:format:length: */ + if ((fmt > 4) || (fmt == 2)) { + fixedFields = 0; + goto l2; } - if (!(quickLoadEngineFromrequiredState(stackObjectValue(5), 0))) { - /* begin primitiveFail */ - successFlag = 0; - return null; + if (fmt < 2) { + fixedFields = totalLength; + goto l2; } - loadPointfrom(((int *) (workBuffer + 80)), originOop); - loadPointfrom(((int *) (workBuffer + 82)), dirOop); - loadPointfrom(((int *) (workBuffer + 84)), nrmOop); - if (!successFlag) { - return 0; + /* begin fetchClassOf: */ + if ((rcvr & 1)) { + class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); + goto l3; } - fill = loadGradientFillfromalongnormalisRadial(rampOop, ((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), ((int *) (workBuffer + 84)), isRadial); - if (engineStopped) { - /* begin primitiveFail */ - successFlag = 0; - return null; + ccIndex = (((unsigned) (longAt(rcvr))) >> 12) & 31; + if (ccIndex == 0) { + class = (longAt(rcvr - 4)) & 4294967292U; + goto l3; + } else { + class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); + goto l3; } - if (!(!successFlag)) { - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 6 * 4; - /* begin push: */ - object = positive32BitIntegerFor(fill); - longAtput(sp = stackPointer + 4, object); - stackPointer = sp; +l3: /* end fetchClassOf: */; + classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; + fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; +l2: /* end fixedFieldsOf:format:length: */; + cache[atIx + 1] = rcvr; + if (stringy) { + cache[atIx + 3] = (fmt + 16); + } else { + cache[atIx + 3] = fmt; } + cache[atIx + 4] = fixedFields; + cache[atIx + 2] = (totalLength - fixedFields); } -EXPORT(int) gePrimitiveAddLine(void) { - int leftFill; - int rightFill; - int startOop; - int endOop; - int oop; - int oop1; - if (!(argumentCount == 4)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - rightFill = positive32BitValueOf(longAt(stackPointer - (0 * 4))); - leftFill = positive32BitValueOf(longAt(stackPointer - (1 * 4))); - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (2 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - endOop = null; - goto l1; +/* + NOTE: This method supports the backward-compatible split instSize field of the + class format word. The sizeHiBits will go away and other shifts change by 2 + when the split fields get merged in an (incompatible) image change. + */ + +int instantiateClassindexableSize(int classPointer, int size) { + int byteSize; + int newObj; + int fillWord; + int hash; + int format; + int sizeHiBits; + int binc; + int header1; + int hdrSize; + int header2; + int header3; + int cClass; + int inc; + int remappedClassOop; + int newObj1; + int end; + int i; + int oop; + int enoughSpace; + int newChunk; + int newFreeSize; + int minFree; + + ; + /* begin newObjectHash */ + lastHash = (13849 + (27181 * lastHash)) & 65535; + hash = lastHash; + + /* Low 2 bits are 0 */ + + header1 = (longAt(((((char *) classPointer)) + 4) + (2 << 2))) - 1; + sizeHiBits = ((unsigned) (header1 & 393216)) >> 9; + header1 = (header1 & 131071) | ((hash << 17) & 536739840); + header2 = classPointer; + header3 = 0; + + /* compact class field from format word */ + + cClass = header1 & 126976; + + /* size in bytes -- low 2 bits are 0 */ + + byteSize = (header1 & 252) + sizeHiBits; + format = (((unsigned) header1) >> 8) & 15; + if (format < 8) { + inc = size * 4; + } else { + + /* round up */ + + inc = (size + 3) & 4294967292U; + + /* odd bytes */ + /* low bits of byte size go in format field */ + + binc = 3 - ((size + 3) & 3); + header1 = header1 | (binc << 8); } - endOop = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (3 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - startOop = null; - goto l2; + if ((byteSize + inc) > 255) { + header3 = byteSize + inc; + header1 -= byteSize & 255; + } else { + header1 += inc; } - startOop = oop1; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; + byteSize += inc; + if (header3 > 0) { + hdrSize = 3; + } else { + if (cClass == 0) { + hdrSize = 2; + } else { + hdrSize = 1; + } } - if (!(quickLoadEngineFromrequiredState(stackObjectValue(4), 0))) { - /* begin primitiveFail */ - successFlag = 0; - return null; + if (format <= 4) { + fillWord = nilObj; + } else { + fillWord = 0; } - if (!((isFillOkay(leftFill)) && (isFillOkay(rightFill)))) { - /* begin primitiveFail */ - successFlag = 0; - return null; + /* begin allocate:headerSize:h1:h2:h3:doFill:with: */ + if (hdrSize > 1) { + /* begin pushRemappableOop: */ + remapBuffer[remapBufferCount += 1] = header2; } - loadPointfrom(((int *) (workBuffer + 80)), startOop); - loadPointfrom(((int *) (workBuffer + 82)), endOop); - if (!successFlag) { - return 0; + /* begin allocateChunk: */ + if (allocationCount >= allocationsBetweenGCs) { + incrementalGC(); } - /* begin transformPoints: */ - if (2 > 0) { - transformPoint(((int *) (workBuffer + 80))); + /* begin sufficientSpaceToAllocate: */ + minFree = (lowSpaceThreshold + (byteSize + ((hdrSize - 1) * 4))) + 4; + if ((((unsigned ) ((longAt(freeBlock)) & 4294967292U))) >= (((unsigned ) minFree))) { + enoughSpace = 1; + goto l1; + } else { + enoughSpace = sufficientSpaceAfterGC(minFree); + goto l1; } - if (2 > 1) { - transformPoint(((int *) (workBuffer + 82))); +l1: /* end sufficientSpaceToAllocate: */; + if (!(enoughSpace)) { + signalLowSpace = 1; + lowSpaceThreshold = 0; + interruptCheckCounter = 0; } - if (2 > 2) { - transformPoint(((int *) (workBuffer + 84))); + if ((((unsigned ) ((longAt(freeBlock)) & 4294967292U))) < (((unsigned ) ((byteSize + ((hdrSize - 1) * 4)) + 4)))) { + error("out of memory"); } - if (2 > 3) { - transformPoint(((int *) (workBuffer + 86))); + newFreeSize = ((longAt(freeBlock)) & 4294967292U) - (byteSize + ((hdrSize - 1) * 4)); + newChunk = freeBlock; + freeBlock += byteSize + ((hdrSize - 1) * 4); + /* begin setSizeOfFree:to: */ + longAtput(freeBlock, (newFreeSize & 4294967292U) | 2); + allocationCount += 1; + newObj1 = newChunk; + if (hdrSize > 1) { + /* begin popRemappableOop */ + oop = remapBuffer[remapBufferCount]; + remapBufferCount -= 1; + remappedClassOop = oop; } - leftFill = transformColor(leftFill); - rightFill = transformColor(rightFill); - if (engineStopped) { - /* begin primitiveFail */ - successFlag = 0; - return null; + if (hdrSize == 3) { + longAtput(newObj1, header3 | 0); + longAtput(newObj1 + 4, remappedClassOop | 0); + longAtput(newObj1 + 8, header1 | 0); + newObj1 += 8; } - loadWideLinefromtolineFillleftFillrightFill(0, ((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), 0, leftFill, rightFill); - if (engineStopped) { - /* begin primitiveFail */ - successFlag = 0; - return null; + if (hdrSize == 2) { + longAtput(newObj1, remappedClassOop | 1); + longAtput(newObj1 + 4, header1 | 1); + newObj1 += 4; } - if (!(!successFlag)) { - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 4 * 4; + if (hdrSize == 1) { + longAtput(newObj1, header1 | 3); + } + end = newObj1 + byteSize; + i = newObj1 + 4; + while (i < end) { + longAtput(i, fillWord); + i += 4; } +; + ; + newObj = newObj1; + return newObj; } -EXPORT(int) gePrimitiveAddOval(void) { - int fillIndex; - int borderWidth; - int startOop; - int borderIndex; - int endOop; - int integerPointer; + +/* This version of instantiateClass assumes that the total object size is under 256 bytes, the limit for objects with only one or two header words. Note that the size is specified in bytes and should include four bytes for the base header word. */ + +int instantiateContextsizeInBytes(int classPointer, int sizeInBytes) { + int hash; + int header1; + int hdrSize; + int header2; + int remappedClassOop; + int newObj; + int end; + int i; int oop; - int oop1; + int enoughSpace; + int newChunk; + int newFreeSize; + int minFree; - if (!(argumentCount == 5)) { - /* begin primitiveFail */ - successFlag = 0; - return null; + /* begin newObjectHash */ + lastHash = (13849 + (27181 * lastHash)) & 65535; + hash = lastHash; + header1 = ((hash << 17) & 536739840) | ((longAt(((((char *) classPointer)) + 4) + (2 << 2))) - 1); + header1 += sizeInBytes - (header1 & 252); + header2 = classPointer; + if ((header1 & 126976) == 0) { + hdrSize = 2; + } else { + hdrSize = 1; } - borderIndex = positive32BitValueOf(longAt(stackPointer - (0 * 4))); - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (1 * 4)); - if ((integerPointer & 1)) { - borderWidth = (integerPointer >> 1); + /* begin allocate:headerSize:h1:h2:h3:doFill:with: */ + if (hdrSize > 1) { + /* begin pushRemappableOop: */ + remapBuffer[remapBufferCount += 1] = header2; + } + /* begin allocateChunk: */ + if (allocationCount >= allocationsBetweenGCs) { + incrementalGC(); + } + /* begin sufficientSpaceToAllocate: */ + minFree = (lowSpaceThreshold + (sizeInBytes + ((hdrSize - 1) * 4))) + 4; + if ((((unsigned ) ((longAt(freeBlock)) & 4294967292U))) >= (((unsigned ) minFree))) { + enoughSpace = 1; goto l1; } else { - /* begin primitiveFail */ - successFlag = 0; - borderWidth = 0; + enoughSpace = sufficientSpaceAfterGC(minFree); goto l1; } -l1: /* end stackIntegerValue: */; - fillIndex = positive32BitValueOf(longAt(stackPointer - (2 * 4))); - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (3 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - endOop = null; - goto l2; +l1: /* end sufficientSpaceToAllocate: */; + if (!(enoughSpace)) { + signalLowSpace = 1; + lowSpaceThreshold = 0; + interruptCheckCounter = 0; } - endOop = oop; -l2: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (4 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - startOop = null; - goto l3; + if ((((unsigned ) ((longAt(freeBlock)) & 4294967292U))) < (((unsigned ) ((sizeInBytes + ((hdrSize - 1) * 4)) + 4)))) { + error("out of memory"); } - startOop = oop1; -l3: /* end stackObjectValue: */; - if (!successFlag) { - return null; + newFreeSize = ((longAt(freeBlock)) & 4294967292U) - (sizeInBytes + ((hdrSize - 1) * 4)); + newChunk = freeBlock; + freeBlock += sizeInBytes + ((hdrSize - 1) * 4); + /* begin setSizeOfFree:to: */ + longAtput(freeBlock, (newFreeSize & 4294967292U) | 2); + allocationCount += 1; + newObj = newChunk; + if (hdrSize > 1) { + /* begin popRemappableOop */ + oop = remapBuffer[remapBufferCount]; + remapBufferCount -= 1; + remappedClassOop = oop; } - if (!(quickLoadEngineFromrequiredState(stackObjectValue(5), 0))) { - /* begin primitiveFail */ - successFlag = 0; - return null; + if (hdrSize == 3) { + longAtput(newObj, 0 | 0); + longAtput(newObj + 4, remappedClassOop | 0); + longAtput(newObj + 8, header1 | 0); + newObj += 8; } - if (!((isFillOkay(borderIndex)) && (isFillOkay(fillIndex)))) { - /* begin primitiveFail */ - successFlag = 0; - return null; + if (hdrSize == 2) { + longAtput(newObj, remappedClassOop | 1); + longAtput(newObj + 4, header1 | 1); + newObj += 4; } - fillIndex = transformColor(fillIndex); - borderIndex = transformColor(borderIndex); - if (engineStopped) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if ((fillIndex == 0) && ((borderIndex == 0) || (borderWidth <= 0))) { - /* begin pop: */ - stackPointer -= 5 * 4; - return null; - } - if (!(needAvailableSpace(16 * 16))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if ((borderWidth > 0) && (borderIndex != 0)) { - borderWidth = transformWidth(borderWidth); - } else { - borderWidth = 0; - } - loadPointfrom(((int *) (workBuffer + 80)), startOop); - loadPointfrom(((int *) (workBuffer + 82)), endOop); - if (!successFlag) { - return 0; - } - loadOvallineFillleftFillrightFill(borderWidth, borderIndex, 0, fillIndex); - if (engineStopped) { - /* begin wbStackClear */ - workBuffer[10] = (workBuffer[1]); - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(!successFlag)) { - workBuffer[63] = 1; - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 5 * 4; + if (hdrSize == 1) { + longAtput(newObj, header1 | 3); } + ; + ; + return newObj; } -EXPORT(int) gePrimitiveAddPolygon(void) { - int nPoints; - int points; - int isArray; - int segSize; - int fillIndex; - int lineFill; - int length; - int lineWidth; - int integerPointer; - int integerPointer1; - int oop; - int header; - int y0; - int y1; + +/* This version of instantiateClass assumes that the total object size is under 256 bytes, the limit for objects with only one or two header words. Note that the size is specified in bytes and should include four bytes for the base header word. */ + +int instantiateSmallClasssizeInBytesfill(int classPointer, int sizeInBytes, int fillValue) { + int hash; + int header1; + int hdrSize; + int header2; + int remappedClassOop; + int newObj; + int end; int i; - int x0; - int x1; - int sz; + int oop; + int enoughSpace; + int newChunk; + int newFreeSize; + int minFree; - if (!(argumentCount == 5)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - lineFill = positive32BitValueOf(longAt(stackPointer - (0 * 4))); - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (1 * 4)); - if ((integerPointer & 1)) { - lineWidth = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - lineWidth = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - fillIndex = positive32BitValueOf(longAt(stackPointer - (2 * 4))); - /* begin stackIntegerValue: */ - integerPointer1 = longAt(stackPointer - (3 * 4)); - if ((integerPointer1 & 1)) { - nPoints = (integerPointer1 >> 1); - goto l2; + /* begin newObjectHash */ + lastHash = (13849 + (27181 * lastHash)) & 65535; + hash = lastHash; + header1 = ((hash << 17) & 536739840) | ((longAt(((((char *) classPointer)) + 4) + (2 << 2))) - 1); + header1 += sizeInBytes - (header1 & 252); + header2 = classPointer; + if ((header1 & 126976) == 0) { + hdrSize = 2; } else { - /* begin primitiveFail */ - successFlag = 0; - nPoints = 0; - goto l2; - } -l2: /* end stackIntegerValue: */; - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (4 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - points = null; - goto l3; - } - points = oop; -l3: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFromrequiredState(stackObjectValue(5), 0))) { - /* begin primitiveFail */ - successFlag = 0; - return null; + hdrSize = 1; } - /* begin slotSizeOf: */ - if ((points & 1)) { - length = 0; - goto l4; + /* begin allocate:headerSize:h1:h2:h3:doFill:with: */ + if (hdrSize > 1) { + /* begin pushRemappableOop: */ + remapBuffer[remapBufferCount += 1] = header2; } - /* begin lengthOf: */ - header = longAt(points); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(points - 8)) & 4294967292U; - } else { - sz = header & 252; + /* begin allocateChunk: */ + if (allocationCount >= allocationsBetweenGCs) { + incrementalGC(); } - if (((((unsigned) header) >> 8) & 15) < 8) { - length = ((unsigned) (sz - 4)) >> 2; - goto l6; + /* begin sufficientSpaceToAllocate: */ + minFree = (lowSpaceThreshold + (sizeInBytes + ((hdrSize - 1) * 4))) + 4; + if ((((unsigned ) ((longAt(freeBlock)) & 4294967292U))) >= (((unsigned ) minFree))) { + enoughSpace = 1; + goto l1; } else { - length = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l6; + enoughSpace = sufficientSpaceAfterGC(minFree); + goto l1; } -l6: /* end lengthOf:baseHeader:format: */; -l4: /* end slotSizeOf: */; - if (((((unsigned) (longAt(points))) >> 8) & 15) == 6) { - isArray = 0; - if (!((length == nPoints) || ((nPoints * 2) == length))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - } else { - if (!((fetchClassOf(points)) == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2))))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(length == nPoints)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - isArray = 1; +l1: /* end sufficientSpaceToAllocate: */; + if (!(enoughSpace)) { + signalLowSpace = 1; + lowSpaceThreshold = 0; + interruptCheckCounter = 0; } - if ((lineWidth == 0) || (lineFill == 0)) { - segSize = 16; - } else { - segSize = 21; + if ((((unsigned ) ((longAt(freeBlock)) & 4294967292U))) < (((unsigned ) ((sizeInBytes + ((hdrSize - 1) * 4)) + 4)))) { + error("out of memory"); } - if (!(needAvailableSpace(segSize * nPoints))) { - /* begin primitiveFail */ - successFlag = 0; - return null; + newFreeSize = ((longAt(freeBlock)) & 4294967292U) - (sizeInBytes + ((hdrSize - 1) * 4)); + newChunk = freeBlock; + freeBlock += sizeInBytes + ((hdrSize - 1) * 4); + /* begin setSizeOfFree:to: */ + longAtput(freeBlock, (newFreeSize & 4294967292U) | 2); + allocationCount += 1; + newObj = newChunk; + if (hdrSize > 1) { + /* begin popRemappableOop */ + oop = remapBuffer[remapBufferCount]; + remapBufferCount -= 1; + remappedClassOop = oop; } - if (!((isFillOkay(lineFill)) && (isFillOkay(fillIndex)))) { - /* begin primitiveFail */ - successFlag = 0; - return null; + if (hdrSize == 3) { + longAtput(newObj, 0 | 0); + longAtput(newObj + 4, remappedClassOop | 0); + longAtput(newObj + 8, header1 | 0); + newObj += 8; } - lineFill = transformColor(lineFill); - fillIndex = transformColor(fillIndex); - if (engineStopped) { - /* begin primitiveFail */ - successFlag = 0; - return null; + if (hdrSize == 2) { + longAtput(newObj, remappedClassOop | 1); + longAtput(newObj + 4, header1 | 1); + newObj += 4; } - if (((lineFill == 0) || (lineWidth == 0)) && (fillIndex == 0)) { - /* begin pop: */ - stackPointer -= 6 * 4; - return null; + if (hdrSize == 1) { + longAtput(newObj, header1 | 3); } - if (!(lineWidth == 0)) { - lineWidth = transformWidth(lineWidth); + end = newObj + sizeInBytes; + i = newObj + 4; + while (i < end) { + longAtput(i, fillValue); + i += 4; } - if (isArray) { - /* begin loadArrayPolygon:nPoints:fill:lineWidth:lineFill: */ - loadPointfrom(((int *) (workBuffer + 80)), longAt(((((char *) points)) + 4) + (0 << 2))); - if (!successFlag) { - goto l5; - } - x0 = (((int *) (workBuffer + 80)))[0]; - y0 = (((int *) (workBuffer + 80)))[1]; - for (i = 1; i <= (nPoints - 1); i += 1) { - loadPointfrom(((int *) (workBuffer + 80)), longAt(((((char *) points)) + 4) + (i << 2))); - if (!successFlag) { - goto l5; - } - x1 = (((int *) (workBuffer + 80)))[0]; - y1 = (((int *) (workBuffer + 80)))[1]; - (((int *) (workBuffer + 80)))[0] = x0; - (((int *) (workBuffer + 80)))[1] = y0; - (((int *) (workBuffer + 82)))[0] = x1; - (((int *) (workBuffer + 82)))[1] = y1; - /* begin transformPoints: */ - if (2 > 0) { - transformPoint(((int *) (workBuffer + 80))); - } - if (2 > 1) { - transformPoint(((int *) (workBuffer + 82))); - } - if (2 > 2) { - transformPoint(((int *) (workBuffer + 84))); - } - if (2 > 3) { - transformPoint(((int *) (workBuffer + 86))); - } - loadWideLinefromtolineFillleftFillrightFill(lineWidth, ((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), lineFill, fillIndex, 0); - if (engineStopped) { - goto l5; - } - x0 = x1; - y0 = y1; - } - l5: /* end loadArrayPolygon:nPoints:fill:lineWidth:lineFill: */; +; + ; + return newObj; +} + +int integerObjectOf(int value) { + if (value < 0) { + return ((2147483648U + value) << 1) + 1; } else { - loadPolygonnPointsfilllineWidthlineFillpointsShort(firstIndexableField(points), nPoints, fillIndex, lineWidth, lineFill, nPoints == length); - } - if (engineStopped) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(!successFlag)) { - workBuffer[63] = 1; - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 5 * 4; + return (value << 1) + 1; } } -EXPORT(int) gePrimitiveAddRect(void) { - int fillIndex; - int borderWidth; - int startOop; - int borderIndex; - int endOop; - int integerPointer; - int oop; - int oop1; - if (!(argumentCount == 5)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - borderIndex = positive32BitValueOf(longAt(stackPointer - (0 * 4))); - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (1 * 4)); - if ((integerPointer & 1)) { - borderWidth = (integerPointer >> 1); - goto l1; +/* Translator produces 'objectPointer >> 1' */ + +int integerValueOf(int objectPointer) { + if ((objectPointer & 2147483648U) != 0) { + return ((((unsigned) (objectPointer & 2147483647U)) >> 1) - 1073741823) - 1; } else { - /* begin primitiveFail */ - successFlag = 0; - borderWidth = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - fillIndex = positive32BitValueOf(longAt(stackPointer - (2 * 4))); - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (3 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - endOop = null; - goto l2; - } - endOop = oop; -l2: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (4 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - startOop = null; - goto l3; - } - startOop = oop1; -l3: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFromrequiredState(stackObjectValue(5), 0))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!((isFillOkay(borderIndex)) && (isFillOkay(fillIndex)))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - borderIndex = transformColor(borderIndex); - fillIndex = transformColor(fillIndex); - if (engineStopped) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if ((fillIndex == 0) && ((borderIndex == 0) || (borderWidth == 0))) { - /* begin pop: */ - stackPointer -= 5 * 4; - return null; - } - if (!(needAvailableSpace(4 * 16))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if ((borderWidth > 0) && (borderIndex != 0)) { - borderWidth = transformWidth(borderWidth); - } else { - borderWidth = 0; - } - loadPointfrom(((int *) (workBuffer + 80)), startOop); - loadPointfrom(((int *) (workBuffer + 84)), endOop); - if (!successFlag) { - return null; - } - (((int *) (workBuffer + 82)))[0] = ((((int *) (workBuffer + 84)))[0]); - (((int *) (workBuffer + 82)))[1] = ((((int *) (workBuffer + 80)))[1]); - (((int *) (workBuffer + 86)))[0] = ((((int *) (workBuffer + 80)))[0]); - (((int *) (workBuffer + 86)))[1] = ((((int *) (workBuffer + 84)))[1]); - /* begin transformPoints: */ - if (4 > 0) { - transformPoint(((int *) (workBuffer + 80))); - } - if (4 > 1) { - transformPoint(((int *) (workBuffer + 82))); - } - if (4 > 2) { - transformPoint(((int *) (workBuffer + 84))); - } - if (4 > 3) { - transformPoint(((int *) (workBuffer + 86))); - } - /* begin loadRectangle:lineFill:leftFill:rightFill: */ - loadWideLinefromtolineFillleftFillrightFill(borderWidth, ((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), borderIndex, 0, fillIndex); - loadWideLinefromtolineFillleftFillrightFill(borderWidth, ((int *) (workBuffer + 82)), ((int *) (workBuffer + 84)), borderIndex, 0, fillIndex); - loadWideLinefromtolineFillleftFillrightFill(borderWidth, ((int *) (workBuffer + 84)), ((int *) (workBuffer + 86)), borderIndex, 0, fillIndex); - loadWideLinefromtolineFillleftFillrightFill(borderWidth, ((int *) (workBuffer + 86)), ((int *) (workBuffer + 80)), borderIndex, 0, fillIndex); - if (!(!successFlag)) { - workBuffer[63] = 1; - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 5 * 4; - } -} - -EXPORT(int) gePrimitiveChangedActiveEdgeEntry(void) { - int edgeOop; - int edge; - int value; - int oop; - int oop1; - - if (doProfileStats) { - geProfileTime = ioMicroMSecs(); - } - if (!(argumentCount == 1)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - edgeOop = null; - goto l1; - } - edgeOop = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l2; - } - engine = oop1; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFromrequiredState(engine, 7))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - edge = loadEdgeStateFrom(edgeOop); - if (!successFlag) { - return null; - } - if ((objBuffer[edge + 7]) == 0) { - removeFirstAETEntry(); - } else { - resortFirstAETEntry(); - workBuffer[13] = ((workBuffer[13]) + 1); - } - workBuffer[2] = 6; - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 1 * 4; - if (doProfileStats) { - workBuffer[107] = ((workBuffer[107]) + 1); - /* begin incrementStat:by: */ - value = (ioMicroMSecs()) - geProfileTime; - workBuffer[106] = ((workBuffer[106]) + value); - } -} - -EXPORT(int) gePrimitiveCopyBuffer(void) { - int i; - int diff; - int * src; - int buf1; - int buf2; - int * dst; - int oop; - int oop1; - - if (!(argumentCount == 2)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - buf2 = null; - goto l1; - } - buf2 = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - buf1 = null; - goto l2; - } - buf1 = oop1; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(loadWorkBufferFrom(buf1))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!((fetchClassOf(buf1)) == (fetchClassOf(buf2)))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - diff = (slotSizeOf(buf2)) - (slotSizeOf(buf1)); - if (diff < 0) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - src = workBuffer; - dst = firstIndexableField(buf2); - for (i = 0; i <= ((workBuffer[10]) - 1); i += 1) { - dst[i] = (src[i]); - } - dst[10] = ((workBuffer[10]) + diff); - dst[1] = ((workBuffer[1]) + diff); - src += workBuffer[10]; - dst = (dst + (workBuffer[10])) + diff; - for (i = 0; i <= (((workBuffer[1]) - (workBuffer[10])) - 1); i += 1) { - dst[i] = (src[i]); - } - if (!(loadWorkBufferFrom(buf2))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin pop: */ - stackPointer -= 2 * 4; -} - -EXPORT(int) gePrimitiveDisplaySpanBuffer(void) { - int value; - int oop; - - if (doProfileStats) { - geProfileTime = ioMicroMSecs(); - } - if (!(argumentCount == 0)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l1; - } - engine = oop; -l1: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFromrequiredState(engine, 5))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(loadSpanBufferFrom(longAt(((((char *) engine)) + 4) + (1 << 2))))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(loadBitBltFrom(longAt(((((char *) engine)) + 4) + (2 << 2))))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (((workBuffer[88]) & (workBuffer[52])) == (workBuffer[52])) { - displaySpanBufferAt(workBuffer[88]); - postDisplayAction(); - } - if (!((workBuffer[2]) == 8)) { - workBuffer[13] = 0; - workBuffer[88] = ((workBuffer[88]) + 1); - workBuffer[2] = 6; - } - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - if (doProfileStats) { - workBuffer[103] = ((workBuffer[103]) + 1); - /* begin incrementStat:by: */ - value = (ioMicroMSecs()) - geProfileTime; - workBuffer[102] = ((workBuffer[102]) + value); - } -} - -EXPORT(int) gePrimitiveDoProfileStats(void) { - int newValue; - int oldValue; - int sp; - int sp1; - int oop; - - oldValue = doProfileStats; - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - newValue = null; - goto l1; - } - newValue = oop; -l1: /* end stackObjectValue: */; - /* begin booleanValueOf: */ - if (newValue == trueObj) { - newValue = 1; - goto l2; - } - if (newValue == falseObj) { - newValue = 0; - goto l2; - } - successFlag = 0; - newValue = null; -l2: /* end booleanValueOf: */; - if (!(!successFlag)) { - doProfileStats = newValue; - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin pushBool: */ - if (oldValue) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } + return ((unsigned) objectPointer) >> 1; } } -EXPORT(int) gePrimitiveFinishedProcessing(void) { - int finished; - int value; - int oop; - int sp; - int sp1; - if (doProfileStats) { - geProfileTime = ioMicroMSecs(); - } - if (!(argumentCount == 0)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l1; - } - engine = oop; -l1: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFrom(engine))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - finished = (workBuffer[2]) == 8; - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 1 * 4; - /* begin pushBool: */ - if (finished) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } - if (doProfileStats) { - workBuffer[93] = ((workBuffer[93]) + 1); - /* begin incrementStat:by: */ - value = (ioMicroMSecs()) - geProfileTime; - workBuffer[92] = ((workBuffer[92]) + value); - } -} +/* This is the main interpreter loop. It normally loops forever, fetching and executing bytecodes. When running in the context of a browser plugin VM, however, it must return control to the browser periodically. This should done only when the state of the currently running Squeak thread is safely stored in the object heap. Since this is the case at the moment that a check for interrupts is performed, that is when we return to the browser if it is time to do so. Interrupt checks happen quite frequently. */ +/* record entry time when running as a browser plug-in */ -EXPORT(int) gePrimitiveGetAALevel(void) { - int oop; - int sp; +int interpret(void) { + int localHomeContext; + char* localSP; + char* localIP; + int currentBytecode; + int t1; + int t2; + int t3; + int t4; + int t5; + int t6; + int t7; + int t8; + int t9; + int t10; + int t11; + int t12; + int t13; + int t14; + int t15; + int t16; + int t17; + int t18; + int t19; + int t20; + int t21; + int t22; + int t23; + int t24; + int t25; + int t26; + int t27; + int t28; + int t29; + int t30; + int t31; + int t32; + int t33; + int t34; + int t35; + int t36; + int t37; + int t38; + int t39; + int t40; + int t41; + int t42; + int t43; + int t44; + int t45; + int t46; + int t47; + int t48; + int t49; - if (!(argumentCount == 0)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l1; - } - engine = oop; -l1: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFrom(engine))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin pop: */ - stackPointer -= 1 * 4; - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, (((workBuffer[48]) << 1) | 1)); - stackPointer = sp; -} - -EXPORT(int) gePrimitiveGetBezierStats(void) { - int statOop; - int *stats; - int oop; - int oop1; - - if (!(argumentCount == 1)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - statOop = null; - goto l1; - } - statOop = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l2; - } - engine = oop1; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFrom(engine))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(((((unsigned) (longAt(statOop))) >> 8) & 15) == 6)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if ((slotSizeOf(statOop)) < 4) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - stats = firstIndexableField(statOop); - stats[0] = ((stats[0]) + (workBuffer[108])); - stats[1] = ((stats[1]) + (workBuffer[109])); - stats[2] = ((stats[2]) + (workBuffer[110])); - stats[3] = ((stats[3]) + (workBuffer[111])); - /* begin pop: */ - stackPointer -= 1 * 4; -} - -EXPORT(int) gePrimitiveGetClipRect(void) { - int rectOop; - int pointOop; - int oop; - int oop1; - int oop2; - int oop3; - int sp; - int xValue; - int yValue; - int pointResult; - int xValue1; - int yValue1; - int pointResult1; - - if (!(argumentCount == 1)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - rectOop = null; - goto l1; - } - rectOop = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l2; - } - engine = oop1; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFrom(engine))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(((((unsigned) (longAt(rectOop))) >> 8) & 15) <= 4)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if ((slotSizeOf(rectOop)) < 2) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin pushRemappableOop: */ - remapBuffer[remapBufferCount += 1] = rectOop; - /* begin makePointwithxValue:yValue: */ - xValue = workBuffer[42]; - yValue = workBuffer[44]; - pointResult = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2)), 12, nilObj); - /* begin storePointer:ofObject:withValue: */ - if (pointResult < youngStart) { - possibleRootStoreIntovalue(pointResult, ((xValue << 1) | 1)); - } - longAtput(((((char *) pointResult)) + 4) + (0 << 2), ((xValue << 1) | 1)); - /* begin storePointer:ofObject:withValue: */ - if (pointResult < youngStart) { - possibleRootStoreIntovalue(pointResult, ((yValue << 1) | 1)); - } - longAtput(((((char *) pointResult)) + 4) + (1 << 2), ((yValue << 1) | 1)); - pointOop = pointResult; - /* begin popRemappableOop */ - oop2 = remapBuffer[remapBufferCount]; - remapBufferCount -= 1; - rectOop = oop2; - /* begin storePointer:ofObject:withValue: */ - if (rectOop < youngStart) { - possibleRootStoreIntovalue(rectOop, pointOop); - } - longAtput(((((char *) rectOop)) + 4) + (0 << 2), pointOop); - /* begin pushRemappableOop: */ - remapBuffer[remapBufferCount += 1] = rectOop; - /* begin makePointwithxValue:yValue: */ - xValue1 = workBuffer[43]; - yValue1 = workBuffer[45]; - pointResult1 = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2)), 12, nilObj); - /* begin storePointer:ofObject:withValue: */ - if (pointResult1 < youngStart) { - possibleRootStoreIntovalue(pointResult1, ((xValue1 << 1) | 1)); - } - longAtput(((((char *) pointResult1)) + 4) + (0 << 2), ((xValue1 << 1) | 1)); - /* begin storePointer:ofObject:withValue: */ - if (pointResult1 < youngStart) { - possibleRootStoreIntovalue(pointResult1, ((yValue1 << 1) | 1)); - } - longAtput(((((char *) pointResult1)) + 4) + (1 << 2), ((yValue1 << 1) | 1)); - pointOop = pointResult1; - /* begin popRemappableOop */ - oop3 = remapBuffer[remapBufferCount]; - remapBufferCount -= 1; - rectOop = oop3; - /* begin storePointer:ofObject:withValue: */ - if (rectOop < youngStart) { - possibleRootStoreIntovalue(rectOop, pointOop); - } - longAtput(((((char *) rectOop)) + 4) + (1 << 2), pointOop); - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, rectOop); - stackPointer = sp; -} - -EXPORT(int) gePrimitiveGetCounts(void) { - int statOop; - int *stats; - int oop; - int oop1; - - if (!(argumentCount == 1)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - statOop = null; - goto l1; - } - statOop = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l2; - } - engine = oop1; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFrom(engine))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(((((unsigned) (longAt(statOop))) >> 8) & 15) == 6)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if ((slotSizeOf(statOop)) < 9) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - stats = firstIndexableField(statOop); - stats[0] = ((stats[0]) + (workBuffer[91])); - stats[1] = ((stats[1]) + (workBuffer[93])); - stats[2] = ((stats[2]) + (workBuffer[95])); - stats[3] = ((stats[3]) + (workBuffer[97])); - stats[4] = ((stats[4]) + (workBuffer[99])); - stats[5] = ((stats[5]) + (workBuffer[101])); - stats[6] = ((stats[6]) + (workBuffer[103])); - stats[7] = ((stats[7]) + (workBuffer[105])); - stats[8] = ((stats[8]) + (workBuffer[107])); - /* begin pop: */ - stackPointer -= 1 * 4; -} - -EXPORT(int) gePrimitiveGetDepth(void) { - int oop; - int sp; - - if (!(argumentCount == 0)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l1; - } - engine = oop; -l1: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFrom(engine))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin pop: */ - stackPointer -= 1 * 4; - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, (((workBuffer[113]) << 1) | 1)); - stackPointer = sp; -} - -EXPORT(int) gePrimitiveGetFailureReason(void) { - int oop; - int sp; - - if (!(argumentCount == 0)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l1; - } - engine = oop; -l1: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if ((engine & 1)) { - return 0; - } - if (!(((((unsigned) (longAt(engine))) >> 8) & 15) <= 4)) { - return 0; - } - if ((slotSizeOf(engine)) < 12) { - return 0; - } - if (!(loadWorkBufferFrom(longAt(((((char *) engine)) + 4) + (0 << 2))))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin pop: */ - stackPointer -= 1 * 4; - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, (((workBuffer[64]) << 1) | 1)); - stackPointer = sp; -} - -EXPORT(int) gePrimitiveGetOffset(void) { - int pointOop; - int oop; - int sp; - int xValue; - int yValue; - int pointResult; - - if (!(argumentCount == 0)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l1; - } - engine = oop; -l1: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFrom(engine))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin makePointwithxValue:yValue: */ - xValue = workBuffer[46]; - yValue = workBuffer[47]; - pointResult = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2)), 12, nilObj); - /* begin storePointer:ofObject:withValue: */ - if (pointResult < youngStart) { - possibleRootStoreIntovalue(pointResult, ((xValue << 1) | 1)); - } - longAtput(((((char *) pointResult)) + 4) + (0 << 2), ((xValue << 1) | 1)); - /* begin storePointer:ofObject:withValue: */ - if (pointResult < youngStart) { - possibleRootStoreIntovalue(pointResult, ((yValue << 1) | 1)); - } - longAtput(((((char *) pointResult)) + 4) + (1 << 2), ((yValue << 1) | 1)); - pointOop = pointResult; - /* begin pop: */ - stackPointer -= 1 * 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, pointOop); - stackPointer = sp; -} - -EXPORT(int) gePrimitiveGetTimes(void) { - int statOop; - int *stats; - int oop; - int oop1; - - if (!(argumentCount == 1)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - statOop = null; - goto l1; - } - statOop = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l2; - } - engine = oop1; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFrom(engine))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(((((unsigned) (longAt(statOop))) >> 8) & 15) == 6)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if ((slotSizeOf(statOop)) < 9) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - stats = firstIndexableField(statOop); - stats[0] = ((stats[0]) + (workBuffer[90])); - stats[1] = ((stats[1]) + (workBuffer[92])); - stats[2] = ((stats[2]) + (workBuffer[94])); - stats[3] = ((stats[3]) + (workBuffer[96])); - stats[4] = ((stats[4]) + (workBuffer[98])); - stats[5] = ((stats[5]) + (workBuffer[100])); - stats[6] = ((stats[6]) + (workBuffer[102])); - stats[7] = ((stats[7]) + (workBuffer[104])); - stats[8] = ((stats[8]) + (workBuffer[106])); - /* begin pop: */ - stackPointer -= 1 * 4; -} - -EXPORT(int) gePrimitiveInitializeBuffer(void) { - int size; - int wbOop; - int oop; - int sp; - - if (!(argumentCount == 1)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - wbOop = null; - goto l1; - } - wbOop = oop; -l1: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(((((unsigned) (longAt(wbOop))) >> 8) & 15) == 6)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if ((size = slotSizeOf(wbOop)) < 256) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - workBuffer = firstIndexableField(wbOop); - objBuffer = workBuffer + 128; - workBuffer[0] = 1097753705; - workBuffer[1] = size; - workBuffer[10] = size; - workBuffer[2] = 0; - workBuffer[8] = 128; - workBuffer[9] = 4; - objBuffer[0 + 0] = 256; - objBuffer[0 + 1] = 4; - objBuffer[0 + 2] = 0; - workBuffer[11] = 0; - workBuffer[12] = 0; - workBuffer[13] = 0; - workBuffer[14] = 0; - workBuffer[64] = 0; - workBuffer[63] = 0; - workBuffer[42] = 0; - workBuffer[43] = 0; - workBuffer[44] = 0; - workBuffer[45] = 0; - workBuffer[113] = 0; - resetGraphicsEngineStats(); - initEdgeTransform(); - initColorTransform(); - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, wbOop); - stackPointer = sp; -} - -EXPORT(int) gePrimitiveInitializeProcessing(void) { - int value; - int oop; - - if (doProfileStats) { - geProfileTime = ioMicroMSecs(); - } - if (!(argumentCount == 0)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l1; - } - engine = oop; -l1: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFromrequiredState(engine, 0))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(loadSpanBufferFrom(longAt(((((char *) engine)) + 4) + (1 << 2))))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - initializeGETProcessing(); - if (engineStopped) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - workBuffer[2] = 1; - if (!(!successFlag)) { - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - } - if (doProfileStats) { - workBuffer[91] = ((workBuffer[91]) + 1); - /* begin incrementStat:by: */ - value = (ioMicroMSecs()) - geProfileTime; - workBuffer[90] = ((workBuffer[90]) + value); - } -} - -EXPORT(int) gePrimitiveMergeFillFrom(void) { - int bitsOop; - int fillOop; - int value; - int value1; - int oop; - int oop1; - int oop2; - - if (doProfileStats) { - geProfileTime = ioMicroMSecs(); - } - if (!(argumentCount == 2)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - fillOop = null; - goto l1; - } - fillOop = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - bitsOop = null; - goto l2; - } - bitsOop = oop1; -l2: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop2 = longAt(stackPointer - (2 * 4)); - if ((oop2 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l3; - } - engine = oop2; -l3: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFromrequiredState(engine, 4))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(loadSpanBufferFrom(longAt(((((char *) engine)) + 4) + (1 << 2))))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!((fetchClassOf(bitsOop)) == (longAt(((((char *) specialObjectsOop)) + 4) + (4 << 2))))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if ((slotSizeOf(fillOop)) < 6) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - value = fetchIntegerofObject(0, fillOop); - if (!((objBuffer[(workBuffer[66]) + 2]) == value)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - value = fetchIntegerofObject(1, fillOop); - if (!((workBuffer[67]) == value)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - value = fetchIntegerofObject(2, fillOop); - if (!((workBuffer[68]) == value)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if ((slotSizeOf(bitsOop)) < ((workBuffer[68]) - (workBuffer[67]))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!successFlag) { - return null; - } - fillBitmapSpanfromto(firstIndexableField(bitsOop), workBuffer[67], workBuffer[68]); - workBuffer[2] = 3; - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 2 * 4; - if (doProfileStats) { - workBuffer[101] = ((workBuffer[101]) + 1); - /* begin incrementStat:by: */ - value1 = (ioMicroMSecs()) - geProfileTime; - workBuffer[100] = ((workBuffer[100]) + value1); - } -} - -EXPORT(int) gePrimitiveNeedsFlush(void) { - int needFlush; - int oop; - int sp; - int sp1; - - if (!(argumentCount == 0)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l1; - } - engine = oop; -l1: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFrom(engine))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - needFlush = (workBuffer[63]) != 0; - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 1 * 4; - /* begin pushBool: */ - if (needFlush) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } -} - -EXPORT(int) gePrimitiveNeedsFlushPut(void) { - int needFlush; - int oop; - int oop1; - - if (!(argumentCount == 1)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - needFlush = null; - goto l1; - } - needFlush = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l2; - } - engine = oop1; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - /* begin booleanValueOf: */ - if (needFlush == trueObj) { - needFlush = 1; - goto l3; - } - if (needFlush == falseObj) { - needFlush = 0; - goto l3; - } - successFlag = 0; - needFlush = null; -l3: /* end booleanValueOf: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFrom(engine))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (needFlush == 1) { - workBuffer[63] = 1; - } else { - workBuffer[63] = 0; - } - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 1 * 4; -} - -EXPORT(int) gePrimitiveNextActiveEdgeEntry(void) { - int edgeOop; - int edge; - int hasEdge; - int value; - int oop; - int oop1; - int sp; - int sp1; - - if (doProfileStats) { - geProfileTime = ioMicroMSecs(); - } - if (!(argumentCount == 1)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - edgeOop = null; - goto l1; - } - edgeOop = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l2; - } - engine = oop1; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFromrequiredStateor(engine, 6, 8))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - hasEdge = 0; - if (!((workBuffer[2]) == 8)) { - hasEdge = findNextExternalUpdateFromAET(); - if (hasEdge) { - edge = aetBuffer[workBuffer[13]]; - storeEdgeStateFrominto(edge, edgeOop); - workBuffer[2] = 7; - } else { - workBuffer[2] = 1; - } - } - if (!successFlag) { - return null; - } - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin pushBool: */ - if (!hasEdge) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } - if (doProfileStats) { - workBuffer[105] = ((workBuffer[105]) + 1); - /* begin incrementStat:by: */ - value = (ioMicroMSecs()) - geProfileTime; - workBuffer[104] = ((workBuffer[104]) + value); - } -} - -EXPORT(int) gePrimitiveNextFillEntry(void) { - int fillOop; - int hasFill; - int value; - int sp; - int sp1; - int oop; - int oop1; - - if (doProfileStats) { - geProfileTime = ioMicroMSecs(); - } - if (!(argumentCount == 1)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - fillOop = null; - goto l1; - } - fillOop = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l2; - } - engine = oop1; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFromrequiredState(engine, 3))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(loadSpanBufferFrom(longAt(((((char *) engine)) + 4) + (1 << 2))))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(loadFormsFrom(longAt(((((char *) engine)) + 4) + (3 << 2))))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!((workBuffer[69]) == 0)) { - if (((workBuffer[88]) & (workBuffer[52])) == 0) { - clearSpanBuffer(); - } - workBuffer[69] = 0; - } - hasFill = findNextExternalFillFromAET(); - if (engineStopped) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (hasFill) { - storeFillStateInto(fillOop); - } - if (!(!successFlag)) { - if (hasFill) { - workBuffer[2] = 4; - } else { - /* begin wbStackClear */ - workBuffer[10] = (workBuffer[1]); - workBuffer[35] = 0; - workBuffer[2] = 5; - } - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin pushBool: */ - if (!hasFill) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } - if (doProfileStats) { - workBuffer[99] = ((workBuffer[99]) + 1); - /* begin incrementStat:by: */ - value = (ioMicroMSecs()) - geProfileTime; - workBuffer[98] = ((workBuffer[98]) + value); - } - } -} - -EXPORT(int) gePrimitiveNextGlobalEdgeEntry(void) { - int edgeOop; - int edge; - int hasEdge; - int value; - int oop; - int oop1; - int sp; - int sp1; - - if (doProfileStats) { - geProfileTime = ioMicroMSecs(); - } - if (!(argumentCount == 1)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - edgeOop = null; - goto l1; - } - edgeOop = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l2; - } - engine = oop1; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFromrequiredState(engine, 1))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - hasEdge = findNextExternalEntryFromGET(); - if (hasEdge) { - edge = getBuffer[workBuffer[11]]; - storeEdgeStateFrominto(edge, edgeOop); - workBuffer[11] = ((workBuffer[11]) + 1); - } - if (!successFlag) { - return null; - } - if (hasEdge) { - workBuffer[2] = 2; - } else { - workBuffer[2] = 3; - workBuffer[69] = 1; - workBuffer[13] = 0; - /* begin wbStackClear */ - workBuffer[10] = (workBuffer[1]); - } - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin pushBool: */ - if (!hasEdge) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } - if (doProfileStats) { - workBuffer[95] = ((workBuffer[95]) + 1); - /* begin incrementStat:by: */ - value = (ioMicroMSecs()) - geProfileTime; - workBuffer[94] = ((workBuffer[94]) + value); - } -} - -EXPORT(int) gePrimitiveRegisterExternalEdge(void) { - int index; - int leftFillIndex; - int rightFillIndex; - int initialZ; - int initialY; - int initialX; - int edge; - int integerPointer; - int integerPointer1; - int integerPointer2; - int integerPointer3; - int oop; - int value; - int value1; - - if (!(argumentCount == 6)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - rightFillIndex = positive32BitValueOf(longAt(stackPointer - (0 * 4))); - leftFillIndex = positive32BitValueOf(longAt(stackPointer - (1 * 4))); - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (2 * 4)); - if ((integerPointer & 1)) { - initialZ = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - initialZ = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - /* begin stackIntegerValue: */ - integerPointer1 = longAt(stackPointer - (3 * 4)); - if ((integerPointer1 & 1)) { - initialY = (integerPointer1 >> 1); - goto l2; - } else { - /* begin primitiveFail */ - successFlag = 0; - initialY = 0; - goto l2; - } -l2: /* end stackIntegerValue: */; - /* begin stackIntegerValue: */ - integerPointer2 = longAt(stackPointer - (4 * 4)); - if ((integerPointer2 & 1)) { - initialX = (integerPointer2 >> 1); - goto l3; - } else { - /* begin primitiveFail */ - successFlag = 0; - initialX = 0; - goto l3; - } -l3: /* end stackIntegerValue: */; - /* begin stackIntegerValue: */ - integerPointer3 = longAt(stackPointer - (5 * 4)); - if ((integerPointer3 & 1)) { - index = (integerPointer3 >> 1); - goto l4; - } else { - /* begin primitiveFail */ - successFlag = 0; - index = 0; - goto l4; - } -l4: /* end stackIntegerValue: */; - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (6 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l5; - } - engine = oop; -l5: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFromrequiredState(engine, 0))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(allocateObjEntry(10))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(isFillOkay(leftFillIndex))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(isFillOkay(rightFillIndex))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - edge = objUsed; - objUsed = edge + 10; - objBuffer[edge + 0] = 2; - objBuffer[edge + 1] = 10; - objBuffer[edge + 2] = index; - objBuffer[edge + 4] = initialX; - objBuffer[edge + 5] = initialY; - objBuffer[edge + 6] = initialZ; - /* begin edgeLeftFillOf:put: */ - value = transformColor(leftFillIndex); - objBuffer[edge + 8] = value; - /* begin edgeRightFillOf:put: */ - value1 = transformColor(rightFillIndex); - objBuffer[edge + 9] = value1; - if (engineStopped) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(!successFlag)) { - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 6 * 4; - } -} - -EXPORT(int) gePrimitiveRegisterExternalFill(void) { - int index; - int fill; - int sp; - int integerPointer; - int oop; - - if (!(argumentCount == 1)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - index = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - index = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (1 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l2; - } - engine = oop; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFromrequiredState(engine, 0))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - fill = 0; - while (fill == 0) { - if (!(allocateObjEntry(10))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - fill = objUsed; - objUsed = fill + 4; - objBuffer[fill + 0] = 256; - objBuffer[fill + 1] = 4; - objBuffer[fill + 2] = index; - } - if (!(!successFlag)) { - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, ((fill << 1) | 1)); - stackPointer = sp; - } -} - -EXPORT(int) gePrimitiveRenderImage(void) { - if (!(loadRenderingState())) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - proceedRenderingScanline(); - if (engineStopped) { - return storeRenderingState(); - } - proceedRenderingImage(); - storeRenderingState(); -} - -EXPORT(int) gePrimitiveRenderScanline(void) { - if (!(loadRenderingState())) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - proceedRenderingScanline(); - storeRenderingState(); -} - -EXPORT(int) gePrimitiveSetAALevel(void) { - int level; - int integerPointer; - int oop; - - if (!(argumentCount == 1)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - level = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - level = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (1 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l2; - } - engine = oop; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFromrequiredState(engine, 0))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - setAALevel(level); - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 1 * 4; -} - -EXPORT(int) gePrimitiveSetClipRect(void) { - int rectOop; - int oop; - int oop1; - - if (!(argumentCount == 1)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - rectOop = null; - goto l1; - } - rectOop = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l2; - } - engine = oop1; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFromrequiredState(engine, 0))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(((((unsigned) (longAt(rectOop))) >> 8) & 15) <= 4)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if ((slotSizeOf(rectOop)) < 2) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - loadPointfrom(((int *) (workBuffer + 80)), longAt(((((char *) rectOop)) + 4) + (0 << 2))); - loadPointfrom(((int *) (workBuffer + 82)), longAt(((((char *) rectOop)) + 4) + (1 << 2))); - if (!(!successFlag)) { - workBuffer[42] = ((((int *) (workBuffer + 80)))[0]); - workBuffer[44] = ((((int *) (workBuffer + 80)))[1]); - workBuffer[43] = ((((int *) (workBuffer + 82)))[0]); - workBuffer[45] = ((((int *) (workBuffer + 82)))[1]); - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 1 * 4; - } -} - -EXPORT(int) gePrimitiveSetColorTransform(void) { - int transformOop; - int oop; - int oop1; - - if (!(argumentCount == 1)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - transformOop = null; - goto l1; - } - transformOop = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l2; - } - engine = oop1; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFromrequiredState(engine, 0))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - loadColorTransformFrom(transformOop); - if (!(!successFlag)) { - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 1 * 4; - } -} - -EXPORT(int) gePrimitiveSetDepth(void) { - int depth; - int integerPointer; - int oop; - - if (!(argumentCount == 1)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - depth = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - depth = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (1 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l2; - } - engine = oop; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFromrequiredState(engine, 0))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - workBuffer[113] = depth; - if (!(!successFlag)) { - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 1 * 4; - } -} - -EXPORT(int) gePrimitiveSetEdgeTransform(void) { - int transformOop; - int oop; - int oop1; - - if (!(argumentCount == 1)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - transformOop = null; - goto l1; - } - transformOop = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l2; - } - engine = oop1; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFromrequiredState(engine, 0))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - loadEdgeTransformFrom(transformOop); - if (!(!successFlag)) { - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 1 * 4; - } -} - -EXPORT(int) gePrimitiveSetOffset(void) { - int pointOop; - int oop; - int oop1; - - if (!(argumentCount == 1)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - pointOop = null; - goto l1; - } - pointOop = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l2; - } - engine = oop1; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (!(quickLoadEngineFromrequiredState(engine, 0))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!((fetchClassOf(pointOop)) == (longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2))))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - loadPointfrom(((int *) (workBuffer + 80)), pointOop); - if (!(!successFlag)) { - workBuffer[46] = ((((int *) (workBuffer + 80)))[0]); - workBuffer[47] = ((((int *) (workBuffer + 80)))[1]); - /* begin storeEngineStateInto: */ - workBuffer[9] = objUsed; - /* begin pop: */ - stackPointer -= 1 * 4; - } -} - -int getCurrentBytecode(void) { - return byteAt(instructionPointer); -} - -int getLongFromFileswap(sqImageFile f, int swapFlag) { - int w; - - sqImageFileRead(&w, sizeof(char), 4, f); - if (swapFlag) { - return ((((((unsigned) w >> 24)) & 255) + ((((unsigned) w >> 8)) & 65280)) + ((((unsigned) w << 8)) & 16711680)) + ((((unsigned) w << 24)) & 4278190080U); - } else { - return w; - } -} - -int getSortsbefore(int edge1, int edge2) { - int diff; - - if (edge1 == edge2) { - return 1; - } - diff = (objBuffer[edge1 + 5]) - (objBuffer[edge2 + 5]); - if (!(diff == 0)) { - return diff < 0; - } - diff = (objBuffer[edge1 + 4]) - (objBuffer[edge2 + 4]); - return diff < 0; -} - -int hideFilldepth(int fillIndex, int depth) { - int index; - int newDepth; - int newRightX; - int newTopIndex; - int newTop; - - index = findStackFilldepth(fillIndex, depth); - if (index == -1) { - return 0; - } - if (index == 0) { - /* begin freeStackFillEntry */ - /* begin wbStackPop: */ - workBuffer[10] = ((workBuffer[10]) + 3); - return 1; - } - workBuffer[(workBuffer[10]) + index] = (workBuffer[(workBuffer[10]) + 0]); - workBuffer[(workBuffer[10]) + (index + 1)] = (workBuffer[(workBuffer[10]) + (0 + 1)]); - workBuffer[(workBuffer[10]) + (index + 2)] = (workBuffer[(workBuffer[10]) + (0 + 2)]); - /* begin freeStackFillEntry */ - /* begin wbStackPop: */ - workBuffer[10] = ((workBuffer[10]) + 3); - if (((workBuffer[1]) - (workBuffer[10])) <= 3) { - return 1; - } - newTopIndex = 0; - index = 3; - while (index < ((workBuffer[1]) - (workBuffer[10]))) { - if (fillSortsbefore(index, newTopIndex)) { - newTopIndex = index; - } - index += 3; - } - if ((newTopIndex + 3) == ((workBuffer[1]) - (workBuffer[10]))) { - return 1; - } - newTop = workBuffer[(workBuffer[10]) + newTopIndex]; - workBuffer[(workBuffer[10]) + newTopIndex] = (workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)]); - workBuffer[(workBuffer[10]) + (((workBuffer[1]) - (workBuffer[10])) - 3)] = newTop; - newDepth = workBuffer[(workBuffer[10]) + (newTopIndex + 1)]; - workBuffer[(workBuffer[10]) + (newTopIndex + 1)] = (workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 1)]); - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 1)] = newDepth; - newRightX = workBuffer[(workBuffer[10]) + (newTopIndex + 2)]; - workBuffer[(workBuffer[10]) + (newTopIndex + 2)] = (workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 2)]); - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - 3) + 2)] = newRightX; - return 1; -} - -int incCompBody(void) { - int bytesFreed; - int fwdBlock; - int oop; - int bytesFreed1; - int newOop; - int extra; - int originalHeader; - int originalHeaderType; - int chunk; - int extra1; - int type; - int extra2; - int type1; - int extra3; - int newFreeChunk; - int next; - int bytesToMove; - int w; - int sz; - int fwdBlock1; - int oop1; - int header; - int firstWord; - int lastWord; - int newOop1; - int chunk2; - int extra4; - int chunk1; - int extra11; - int header1; - int type2; - int extra21; - int type11; - int extra31; - int sz2; - int fwdBlock2; - int realHeader; - int header2; - int extra5; - int type3; - int extra12; - int sz1; - int extra22; - int header11; - int type12; - int extra111; - int sz3; - int fwdBlock3; - int realHeader1; - int header3; - int extra6; - int type4; - int extra13; - int sz11; - int extra23; - int header12; - int type13; - int extra112; - - fwdTableInit(8); - /* begin incCompMakeFwd */ - bytesFreed1 = 0; - /* begin oopFromChunk: */ - chunk = compStart; - /* begin extraHeaderBytes: */ - type1 = (longAt(chunk)) & 3; - if (type1 > 1) { - extra3 = 0; - } else { - if (type1 == 1) { - extra3 = 4; - } else { - extra3 = 8; - } - } - extra1 = extra3; - oop = chunk + extra1; - while (oop < endOfMemory) { - if (((longAt(oop)) & 3) == 2) { - bytesFreed1 += (longAt(oop)) & 4294967292U; - } else { - /* begin fwdBlockGet: */ - fwdTableNext += 8; - if (fwdTableNext <= fwdTableLast) { - fwdBlock = fwdTableNext; - goto l1; - } else { - fwdBlock = null; - goto l1; - } - l1: /* end fwdBlockGet: */; - if (fwdBlock == null) { - /* begin chunkFromOop: */ - /* begin extraHeaderBytes: */ - type = (longAt(oop)) & 3; - if (type > 1) { - extra2 = 0; - } else { - if (type == 1) { - extra2 = 4; - } else { - extra2 = 8; - } - } - extra = extra2; - compEnd = oop - extra; - bytesFreed = bytesFreed1; - goto l2; - } - newOop = oop - bytesFreed1; - /* begin initForwardBlock:mapping:to:withBackPtr: */ - originalHeader = longAt(oop); - ; - originalHeaderType = originalHeader & 3; - longAtput(fwdBlock, newOop); - longAtput(fwdBlock + 4, originalHeader); - ; - longAtput(oop, (((unsigned) fwdBlock) >> 1) | (2147483648U | originalHeaderType)); - } - /* begin objectAfterWhileForwarding: */ - header2 = longAt(oop); - if ((header2 & 2147483648U) == 0) { - /* begin objectAfter: */ - ; - if (((longAt(oop)) & 3) == 2) { - sz1 = (longAt(oop)) & 4294967292U; - } else { - /* begin sizeBitsOf: */ - header11 = longAt(oop); - if ((header11 & 3) == 0) { - sz1 = (longAt(oop - 8)) & 4294967292U; - goto l4; - } else { - sz1 = header11 & 252; - goto l4; - } - l4: /* end sizeBitsOf: */; - } - /* begin oopFromChunk: */ - /* begin extraHeaderBytes: */ - type12 = (longAt(oop + sz1)) & 3; - if (type12 > 1) { - extra111 = 0; - } else { - if (type12 == 1) { - extra111 = 4; - } else { - extra111 = 8; - } - } - extra22 = extra111; - oop = (oop + sz1) + extra22; - goto l5; - } - fwdBlock2 = (header2 & 2147483644) << 1; - ; - realHeader = longAt(fwdBlock2 + 4); - if ((realHeader & 3) == 0) { - sz2 = (longAt(oop - 8)) & 4294967292U; - } else { - sz2 = realHeader & 252; - } - /* begin oopFromChunk: */ - /* begin extraHeaderBytes: */ - type3 = (longAt(oop + sz2)) & 3; - if (type3 > 1) { - extra12 = 0; - } else { - if (type3 == 1) { - extra12 = 4; - } else { - extra12 = 8; - } - } - extra5 = extra12; - oop = (oop + sz2) + extra5; - l5: /* end objectAfterWhileForwarding: */; - } - compEnd = endOfMemory; - bytesFreed = bytesFreed1; -l2: /* end incCompMakeFwd */; - mapPointersInObjectsFromto(youngStart, endOfMemory); - /* begin incCompMove: */ - newOop1 = null; - /* begin oopFromChunk: */ - chunk1 = compStart; - /* begin extraHeaderBytes: */ - type11 = (longAt(chunk1)) & 3; - if (type11 > 1) { - extra31 = 0; - } else { - if (type11 == 1) { - extra31 = 4; - } else { - extra31 = 8; - } - } - extra11 = extra31; - oop1 = chunk1 + extra11; - while (oop1 < compEnd) { - /* begin objectAfterWhileForwarding: */ - header3 = longAt(oop1); - if ((header3 & 2147483648U) == 0) { - /* begin objectAfter: */ - ; - if (((longAt(oop1)) & 3) == 2) { - sz11 = (longAt(oop1)) & 4294967292U; - } else { - /* begin sizeBitsOf: */ - header12 = longAt(oop1); - if ((header12 & 3) == 0) { - sz11 = (longAt(oop1 - 8)) & 4294967292U; - goto l6; - } else { - sz11 = header12 & 252; - goto l6; - } - l6: /* end sizeBitsOf: */; - } - /* begin oopFromChunk: */ - /* begin extraHeaderBytes: */ - type13 = (longAt(oop1 + sz11)) & 3; - if (type13 > 1) { - extra112 = 0; - } else { - if (type13 == 1) { - extra112 = 4; - } else { - extra112 = 8; - } - } - extra23 = extra112; - next = (oop1 + sz11) + extra23; - goto l7; - } - fwdBlock3 = (header3 & 2147483644) << 1; - ; - realHeader1 = longAt(fwdBlock3 + 4); - if ((realHeader1 & 3) == 0) { - sz3 = (longAt(oop1 - 8)) & 4294967292U; - } else { - sz3 = realHeader1 & 252; - } - /* begin oopFromChunk: */ - /* begin extraHeaderBytes: */ - type4 = (longAt(oop1 + sz3)) & 3; - if (type4 > 1) { - extra13 = 0; - } else { - if (type4 == 1) { - extra13 = 4; - } else { - extra13 = 8; - } - } - extra6 = extra13; - next = (oop1 + sz3) + extra6; - l7: /* end objectAfterWhileForwarding: */; - if (!(((longAt(oop1)) & 3) == 2)) { - fwdBlock1 = ((longAt(oop1)) & 2147483644) << 1; - ; - newOop1 = longAt(fwdBlock1); - header = longAt(fwdBlock1 + 4); - longAtput(oop1, header); - bytesToMove = oop1 - newOop1; - /* begin sizeBitsOf: */ - header1 = longAt(oop1); - if ((header1 & 3) == 0) { - sz = (longAt(oop1 - 8)) & 4294967292U; - goto l3; - } else { - sz = header1 & 252; - goto l3; - } - l3: /* end sizeBitsOf: */; - firstWord = oop1 - (extraHeaderBytes(oop1)); - lastWord = (oop1 + sz) - 4; - for (w = firstWord; w <= lastWord; w += 4) { - longAtput(w - bytesToMove, longAt(w)); - } - } - oop1 = next; - } - if (newOop1 == null) { - /* begin oopFromChunk: */ - chunk2 = compStart; - /* begin extraHeaderBytes: */ - type2 = (longAt(chunk2)) & 3; - if (type2 > 1) { - extra21 = 0; - } else { - if (type2 == 1) { - extra21 = 4; - } else { - extra21 = 8; - } - } - extra4 = extra21; - oop1 = chunk2 + extra4; - if ((((longAt(oop1)) & 3) == 2) && ((objectAfter(oop1)) == (oopFromChunk(compEnd)))) { - newFreeChunk = oop1; - } else { - newFreeChunk = freeBlock; - } - } else { - newFreeChunk = newOop1 + (sizeBitsOf(newOop1)); - /* begin setSizeOfFree:to: */ - longAtput(newFreeChunk, (bytesFreed & 4294967292U) | 2); - } - ; - if ((objectAfter(newFreeChunk)) == endOfMemory) { - initializeMemoryFirstFree(newFreeChunk); - } else { - initializeMemoryFirstFree(freeBlock); - } - return newFreeChunk; -} - -int incrementalGC(void) { - int startTime; - int survivorCount; - int oop; - int i; - int fieldAddr; - int oop1; - int fieldOop; - int header; - int badRoot; - int chunk; - int extra; - int type; - int extra1; - int sz; - int extra2; - int header1; - int type1; - int extra11; - - if (rootTableCount >= 2500) { - statRootTableOverflows += 1; - return fullGC(); - } - ; - ; - /* begin preGCAction: */ - /* begin compilerPreGCHook: */ - if (compilerInitialized) { - compilerPreGC(0); - } - if (!(activeContext == nilObj)) { - /* begin storeContextRegisters: */ - longAtput(((((char *) activeContext)) + 4) + (1 << 2), ((((instructionPointer - method) - (4 - 2)) << 1) | 1)); - longAtput(((((char *) activeContext)) + 4) + (2 << 2), (((((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) - 6) + 1) << 1) | 1)); - } - startTime = ioMicroMSecs(); - markPhase(); - survivorCount = sweepPhase(); - /* begin incrementalCompaction */ - if (compStart == freeBlock) { - initializeMemoryFirstFree(freeBlock); - } else { - incCompBody(); - } - allocationCount = 0; - statIncrGCs += 1; - statIncrGCMSecs += (ioMicroMSecs()) - startTime; - if (survivorCount > tenuringThreshold) { - statTenures += 1; - /* begin clearRootsTable */ - for (i = 1; i <= rootTableCount; i += 1) { - oop = rootTable[i]; - longAtput(oop, (longAt(oop)) & 3221225471U); - rootTable[i] = 0; - } - rootTableCount = 0; - youngStart = freeBlock; - } - /* begin postGCAction */ - /* begin compilerPostGCHook */ - if (compilerInitialized) { - compilerPostGC(); - } - if (activeContext < youngStart) { - beRootIfOld(activeContext); - } - if (theHomeContext < youngStart) { - beRootIfOld(theHomeContext); - } - ; -} - -int indexForInsertingIntoAET(int edge) { - int index; - int initialX; - - initialX = objBuffer[edge + 4]; - index = 0; - while ((index < (workBuffer[14])) && ((objBuffer[(aetBuffer[index]) + 4]) < initialX)) { - index += 1; - } - while ((index < (workBuffer[14])) && (((objBuffer[(aetBuffer[index]) + 4]) == initialX) && (getSortsbefore(aetBuffer[index], edge)))) { - index += 1; - } - return index; -} - -int initBBOpTable(void) { - opTable[0+1] = (int)clearWordwith; - opTable[1+1] = (int)bitAndwith; - opTable[2+1] = (int)bitAndInvertwith; - opTable[3+1] = (int)sourceWordwith; - opTable[4+1] = (int)bitInvertAndwith; - opTable[5+1] = (int)destinationWordwith; - opTable[6+1] = (int)bitXorwith; - opTable[7+1] = (int)bitOrwith; - opTable[8+1] = (int)bitInvertAndInvertwith; - opTable[9+1] = (int)bitInvertXorwith; - opTable[10+1] = (int)bitInvertDestinationwith; - opTable[11+1] = (int)bitOrInvertwith; - opTable[12+1] = (int)bitInvertSourcewith; - opTable[13+1] = (int)bitInvertOrwith; - opTable[14+1] = (int)bitInvertOrInvertwith; - opTable[15+1] = (int)destinationWordwith; - opTable[16+1] = (int)destinationWordwith; - opTable[17+1] = (int)destinationWordwith; - opTable[18+1] = (int)addWordwith; - opTable[19+1] = (int)subWordwith; - opTable[20+1] = (int)rgbAddwith; - opTable[21+1] = (int)rgbSubwith; - opTable[22+1] = (int)OLDrgbDiffwith; - opTable[23+1] = (int)OLDtallyIntoMapwith; - opTable[24+1] = (int)alphaBlendwith; - opTable[25+1] = (int)pixPaintwith; - opTable[26+1] = (int)pixMaskwith; - opTable[27+1] = (int)rgbMaxwith; - opTable[28+1] = (int)rgbMinwith; - opTable[29+1] = (int)rgbMinInvertwith; - opTable[30+1] = (int)alphaBlendConstwith; - opTable[31+1] = (int)alphaPaintConstwith; - opTable[32+1] = (int)rgbDiffwith; - opTable[33+1] = (int)tallyIntoMapwith; - opTable[34+1] = (int)alphaBlendScaledwith; -} - -int initColorTransform(void) { - float *transform; - - transform = ((float *) (workBuffer + 24)); - transform[0] = (((float) 1.0)); - transform[1] = (((float) 0.0)); - transform[2] = (((float) 1.0)); - transform[3] = (((float) 0.0)); - transform[4] = (((float) 1.0)); - transform[5] = (((float) 0.0)); - transform[6] = (((float) 1.0)); - transform[7] = (((float) 0.0)); - workBuffer[17] = 0; -} - -int initCompilerHooks(void) { - compilerHooks[1]= nullCompilerHook; - compilerHooks[2]= nullCompilerHook; - compilerHooks[3]= nullCompilerHook; - compilerHooks[4]= nullCompilerHook; - compilerHooks[5]= nullCompilerHook; - compilerHooks[6]= nullCompilerHook; - compilerHooks[7]= nullCompilerHook; - compilerHooks[8]= nullCompilerHook; - compilerInitialized = 0; -} - -int initEdgeTransform(void) { - float *transform; - - transform = ((float *) (workBuffer + 18)); - transform[0] = (((float) 1.0)); - transform[1] = (((float) 0.0)); - transform[2] = (((float) 0.0)); - transform[3] = (((float) 0.0)); - transform[4] = (((float) 1.0)); - transform[5] = (((float) 0.0)); - workBuffer[16] = 0; -} - -int initializeGETProcessing(void) { - setAALevel(workBuffer[48]); - if ((workBuffer[42]) < 0) { - workBuffer[42] = 0; - } - if ((workBuffer[43]) > (workBuffer[33])) { - workBuffer[43] = (workBuffer[33]); - } - workBuffer[36] = ((workBuffer[42]) << (workBuffer[49])); - workBuffer[38] = ((workBuffer[44]) << (workBuffer[49])); - workBuffer[37] = ((workBuffer[43]) << (workBuffer[49])); - workBuffer[39] = ((workBuffer[45]) << (workBuffer[49])); - workBuffer[12] = 0; - workBuffer[14] = 0; - getBuffer = aetBuffer = objBuffer + objUsed; - createGlobalEdgeTable(); - if (engineStopped) { - return null; - } - if ((workBuffer[12]) == 0) { - workBuffer[88] = (workBuffer[39]); - return 0; - } - /* begin sortGlobalEdgeTable */ - quickSortGlobalEdgeTablefromto(getBuffer, 0, (workBuffer[12]) - 1); - workBuffer[88] = (objBuffer[(getBuffer[0]) + 5]); - if ((workBuffer[88]) < (workBuffer[38])) { - workBuffer[88] = (workBuffer[38]); - } - workBuffer[32] = 0; - workBuffer[34] = (((workBuffer[33]) << (workBuffer[49])) - 1); - clearSpanBuffer(); -} - -int initializeMemoryFirstFree(int firstFree) { - int fwdBlockBytes; - - fwdBlockBytes = 16000; - if (!((memoryLimit - fwdBlockBytes) >= (firstFree + 4))) { - fwdBlockBytes = memoryLimit - (firstFree + 4); - } - endOfMemory = memoryLimit - fwdBlockBytes; - freeBlock = firstFree; - /* begin setSizeOfFree:to: */ - longAtput(freeBlock, ((endOfMemory - firstFree) & 4294967292U) | 2); - /* begin setSizeOfFree:to: */ - longAtput(endOfMemory, (4 & 4294967292U) | 2); - ; -} - -int initializeObjectMemory(int bytesToShift) { - int oop; - int header; - int newClassOop; - int fieldAddr; - int fieldOop; - int classHeader; - int chunk; - int extra; - int type; - int extra1; - int sz; - int extra2; - int header1; - int type1; - int extra11; - - youngStart = endOfMemory; - initializeMemoryFirstFree(endOfMemory); - /* begin adjustAllOopsBy: */ - /* begin oopFromChunk: */ - chunk = startOfMemory(); - /* begin extraHeaderBytes: */ - type = (longAt(chunk)) & 3; - if (type > 1) { - extra1 = 0; - } else { - if (type == 1) { - extra1 = 4; - } else { - extra1 = 8; - } - } - extra = extra1; - oop = chunk + extra; - while (oop < endOfMemory) { - if (!(((longAt(oop)) & 3) == 2)) { - header = longAt(oop); - longAtput(oop, header & 3221225471U); - /* begin adjustFieldsAndClassOf:by: */ - fieldAddr = oop + (lastPointerOf(oop)); - while (fieldAddr > oop) { - fieldOop = longAt(fieldAddr); - if (!((fieldOop & 1))) { - longAtput(fieldAddr, fieldOop + bytesToShift); - } - fieldAddr -= 4; - } - if (((longAt(oop)) & 3) != 3) { - classHeader = longAt(oop - 4); - newClassOop = (classHeader & 4294967292U) + bytesToShift; - longAtput(oop - 4, newClassOop | (classHeader & 3)); - } - } - /* begin objectAfter: */ - ; - if (((longAt(oop)) & 3) == 2) { - sz = (longAt(oop)) & 4294967292U; - } else { - /* begin sizeBitsOf: */ - header1 = longAt(oop); - if ((header1 & 3) == 0) { - sz = (longAt(oop - 8)) & 4294967292U; - goto l1; - } else { - sz = header1 & 252; - goto l1; - } - l1: /* end sizeBitsOf: */; - } - /* begin oopFromChunk: */ - /* begin extraHeaderBytes: */ - type1 = (longAt(oop + sz)) & 3; - if (type1 > 1) { - extra11 = 0; - } else { - if (type1 == 1) { - extra11 = 4; - } else { - extra11 = 8; - } - } - extra2 = extra11; - oop = (oop + sz) + extra2; - } - specialObjectsOop += bytesToShift; - nilObj = longAt(((((char *) specialObjectsOop)) + 4) + (0 << 2)); - falseObj = longAt(((((char *) specialObjectsOop)) + 4) + (1 << 2)); - trueObj = longAt(((((char *) specialObjectsOop)) + 4) + (2 << 2)); - rootTableCount = 0; - child = 0; - field = 0; - parentField = 0; - freeContexts = 1; - allocationCount = 0; - lowSpaceThreshold = 0; - signalLowSpace = 0; - compStart = 0; - compEnd = 0; - fwdTableNext = 0; - fwdTableLast = 0; - remapBufferCount = 0; - allocationsBetweenGCs = 4000; - tenuringThreshold = 2000; - statFullGCs = 0; - statFullGCMSecs = 0; - statIncrGCs = 0; - statIncrGCMSecs = 0; - statTenures = 0; - statRootTableOverflows = 0; - displayBits = 0; -} - -int insertEdgeIntoAET(int edge) { - int index; - - if ((objBuffer[edge + 7]) <= 0) { - return null; - } - index = indexForInsertingIntoAET(edge); - insertToAETbeforeIndex(edge, index); -} - -int insertToAETbeforeIndex(int edge, int index) { - int i; - - if (!(needAvailableSpace(1))) { - return null; - } - i = (workBuffer[14]) - 1; - while (!(i < index)) { - aetBuffer[i + 1] = (aetBuffer[i]); - i -= 1; - } - aetBuffer[index] = edge; - workBuffer[14] = ((workBuffer[14]) + 1); -} - -int installinAtCacheatstring(int rcvr, int *cache, int atIx, int stringy) { - int hdr; - int totalLength; - int fmt; - int fixedFields; - int classFormat; - int class; - int sz; - int ccIndex; - - hdr = longAt(rcvr); - fmt = (((unsigned) hdr) >> 8) & 15; - if ((fmt == 3) && (isContextHeader(hdr))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin lengthOf:baseHeader:format: */ - if ((hdr & 3) == 0) { - sz = (longAt(rcvr - 8)) & 4294967292U; - } else { - sz = hdr & 252; - } - if (fmt < 8) { - totalLength = ((unsigned) (sz - 4)) >> 2; - goto l2; - } else { - totalLength = (sz - 4) - (fmt & 3); - goto l2; - } -l2: /* end lengthOf:baseHeader:format: */; - /* begin fixedFieldsOf:format:length: */ - if ((fmt > 4) || (fmt == 2)) { - fixedFields = 0; - goto l1; - } - if (fmt < 2) { - fixedFields = totalLength; - goto l1; - } - /* begin fetchClassOf: */ - if ((rcvr & 1)) { - class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l3; - } - ccIndex = (((unsigned) (longAt(rcvr))) >> 12) & 31; - if (ccIndex == 0) { - class = (longAt(rcvr - 4)) & 4294967292U; - goto l3; - } else { - class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l3; - } -l3: /* end fetchClassOf: */; - classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; - fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; -l1: /* end fixedFieldsOf:format:length: */; - cache[atIx + 1] = rcvr; - if (stringy) { - cache[atIx + 3] = (fmt + 16); - } else { - cache[atIx + 3] = fmt; - } - cache[atIx + 4] = fixedFields; - cache[atIx + 2] = (totalLength - fixedFields); -} - -int instantiateClassindexableSize(int classPointer, int size) { - int sizeHiBits; - int newObj; - int binc; - int hash; - int header1; - int header2; - int header3; - int hdrSize; - int byteSize; - int format; - int inc; - int cClass; - int fillWord; - int i; - int newObj1; - int remappedClassOop; - int end; - int oop; - int newFreeSize; - int enoughSpace; - int newChunk; - int minFree; - - ; - /* begin newObjectHash */ - lastHash = (13849 + (27181 * lastHash)) & 65535; - hash = lastHash; - header1 = (longAt(((((char *) classPointer)) + 4) + (2 << 2))) - 1; - sizeHiBits = ((unsigned) (header1 & 393216)) >> 9; - header1 = (header1 & 131071) | ((hash << 17) & 536739840); - header2 = classPointer; - header3 = 0; - cClass = header1 & 126976; - byteSize = (header1 & 252) + sizeHiBits; - format = (((unsigned) header1) >> 8) & 15; - if (format < 8) { - inc = size * 4; - } else { - inc = (size + 3) & 4294967292U; - binc = 3 - ((size + 3) & 3); - header1 = header1 | (binc << 8); - } - if ((byteSize + inc) > 255) { - header3 = byteSize + inc; - header1 -= byteSize & 255; - } else { - header1 += inc; - } - byteSize += inc; - if (header3 > 0) { - hdrSize = 3; - } else { - if (cClass == 0) { - hdrSize = 2; - } else { - hdrSize = 1; - } - } - if (format <= 4) { - fillWord = nilObj; - } else { - fillWord = 0; - } - /* begin allocate:headerSize:h1:h2:h3:doFill:with: */ - if (hdrSize > 1) { - /* begin pushRemappableOop: */ - remapBuffer[remapBufferCount += 1] = header2; - } - /* begin allocateChunk: */ - if (allocationCount >= allocationsBetweenGCs) { - incrementalGC(); - } - /* begin sufficientSpaceToAllocate: */ - minFree = (lowSpaceThreshold + (byteSize + ((hdrSize - 1) * 4))) + 4; - if ((((unsigned ) ((longAt(freeBlock)) & 4294967292U))) >= (((unsigned ) minFree))) { - enoughSpace = 1; - goto l1; - } else { - enoughSpace = sufficientSpaceAfterGC(minFree); - goto l1; - } -l1: /* end sufficientSpaceToAllocate: */; - if (!(enoughSpace)) { - signalLowSpace = 1; - lowSpaceThreshold = 0; - interruptCheckCounter = 0; - } - if ((((unsigned ) ((longAt(freeBlock)) & 4294967292U))) < (((unsigned ) ((byteSize + ((hdrSize - 1) * 4)) + 4)))) { - error("out of memory"); - } - newFreeSize = ((longAt(freeBlock)) & 4294967292U) - (byteSize + ((hdrSize - 1) * 4)); - newChunk = freeBlock; - freeBlock += byteSize + ((hdrSize - 1) * 4); - /* begin setSizeOfFree:to: */ - longAtput(freeBlock, (newFreeSize & 4294967292U) | 2); - allocationCount += 1; - newObj1 = newChunk; - if (hdrSize > 1) { - /* begin popRemappableOop */ - oop = remapBuffer[remapBufferCount]; - remapBufferCount -= 1; - remappedClassOop = oop; - } - if (hdrSize == 3) { - longAtput(newObj1, header3 | 0); - longAtput(newObj1 + 4, remappedClassOop | 0); - longAtput(newObj1 + 8, header1 | 0); - newObj1 += 8; - } - if (hdrSize == 2) { - longAtput(newObj1, remappedClassOop | 1); - longAtput(newObj1 + 4, header1 | 1); - newObj1 += 4; - } - if (hdrSize == 1) { - longAtput(newObj1, header1 | 3); - } - end = newObj1 + byteSize; - i = newObj1 + 4; - while (i < end) { - longAtput(i, fillWord); - i += 4; - } -; - ; - newObj = newObj1; - return newObj; -} - -int instantiateContextsizeInBytes(int classPointer, int sizeInBytes) { - int header1; - int header2; - int hdrSize; - int hash; - int i; - int newObj; - int remappedClassOop; - int end; - int oop; - int newFreeSize; - int enoughSpace; - int newChunk; - int minFree; - - /* begin newObjectHash */ - lastHash = (13849 + (27181 * lastHash)) & 65535; - hash = lastHash; - header1 = ((hash << 17) & 536739840) | ((longAt(((((char *) classPointer)) + 4) + (2 << 2))) - 1); - header1 += sizeInBytes - (header1 & 252); - header2 = classPointer; - if ((header1 & 126976) == 0) { - hdrSize = 2; - } else { - hdrSize = 1; - } - /* begin allocate:headerSize:h1:h2:h3:doFill:with: */ - if (hdrSize > 1) { - /* begin pushRemappableOop: */ - remapBuffer[remapBufferCount += 1] = header2; - } - /* begin allocateChunk: */ - if (allocationCount >= allocationsBetweenGCs) { - incrementalGC(); - } - /* begin sufficientSpaceToAllocate: */ - minFree = (lowSpaceThreshold + (sizeInBytes + ((hdrSize - 1) * 4))) + 4; - if ((((unsigned ) ((longAt(freeBlock)) & 4294967292U))) >= (((unsigned ) minFree))) { - enoughSpace = 1; - goto l1; - } else { - enoughSpace = sufficientSpaceAfterGC(minFree); - goto l1; - } -l1: /* end sufficientSpaceToAllocate: */; - if (!(enoughSpace)) { - signalLowSpace = 1; - lowSpaceThreshold = 0; - interruptCheckCounter = 0; - } - if ((((unsigned ) ((longAt(freeBlock)) & 4294967292U))) < (((unsigned ) ((sizeInBytes + ((hdrSize - 1) * 4)) + 4)))) { - error("out of memory"); - } - newFreeSize = ((longAt(freeBlock)) & 4294967292U) - (sizeInBytes + ((hdrSize - 1) * 4)); - newChunk = freeBlock; - freeBlock += sizeInBytes + ((hdrSize - 1) * 4); - /* begin setSizeOfFree:to: */ - longAtput(freeBlock, (newFreeSize & 4294967292U) | 2); - allocationCount += 1; - newObj = newChunk; - if (hdrSize > 1) { - /* begin popRemappableOop */ - oop = remapBuffer[remapBufferCount]; - remapBufferCount -= 1; - remappedClassOop = oop; - } - if (hdrSize == 3) { - longAtput(newObj, 0 | 0); - longAtput(newObj + 4, remappedClassOop | 0); - longAtput(newObj + 8, header1 | 0); - newObj += 8; - } - if (hdrSize == 2) { - longAtput(newObj, remappedClassOop | 1); - longAtput(newObj + 4, header1 | 1); - newObj += 4; - } - if (hdrSize == 1) { - longAtput(newObj, header1 | 3); - } - ; - ; - return newObj; -} - -int instantiateSmallClasssizeInBytesfill(int classPointer, int sizeInBytes, int fillValue) { - int header1; - int header2; - int hdrSize; - int hash; - int i; - int newObj; - int remappedClassOop; - int end; - int oop; - int newFreeSize; - int enoughSpace; - int newChunk; - int minFree; - - /* begin newObjectHash */ - lastHash = (13849 + (27181 * lastHash)) & 65535; - hash = lastHash; - header1 = ((hash << 17) & 536739840) | ((longAt(((((char *) classPointer)) + 4) + (2 << 2))) - 1); - header1 += sizeInBytes - (header1 & 252); - header2 = classPointer; - if ((header1 & 126976) == 0) { - hdrSize = 2; - } else { - hdrSize = 1; - } - /* begin allocate:headerSize:h1:h2:h3:doFill:with: */ - if (hdrSize > 1) { - /* begin pushRemappableOop: */ - remapBuffer[remapBufferCount += 1] = header2; - } - /* begin allocateChunk: */ - if (allocationCount >= allocationsBetweenGCs) { - incrementalGC(); - } - /* begin sufficientSpaceToAllocate: */ - minFree = (lowSpaceThreshold + (sizeInBytes + ((hdrSize - 1) * 4))) + 4; - if ((((unsigned ) ((longAt(freeBlock)) & 4294967292U))) >= (((unsigned ) minFree))) { - enoughSpace = 1; - goto l1; - } else { - enoughSpace = sufficientSpaceAfterGC(minFree); - goto l1; - } -l1: /* end sufficientSpaceToAllocate: */; - if (!(enoughSpace)) { - signalLowSpace = 1; - lowSpaceThreshold = 0; - interruptCheckCounter = 0; - } - if ((((unsigned ) ((longAt(freeBlock)) & 4294967292U))) < (((unsigned ) ((sizeInBytes + ((hdrSize - 1) * 4)) + 4)))) { - error("out of memory"); - } - newFreeSize = ((longAt(freeBlock)) & 4294967292U) - (sizeInBytes + ((hdrSize - 1) * 4)); - newChunk = freeBlock; - freeBlock += sizeInBytes + ((hdrSize - 1) * 4); - /* begin setSizeOfFree:to: */ - longAtput(freeBlock, (newFreeSize & 4294967292U) | 2); - allocationCount += 1; - newObj = newChunk; - if (hdrSize > 1) { - /* begin popRemappableOop */ - oop = remapBuffer[remapBufferCount]; - remapBufferCount -= 1; - remappedClassOop = oop; - } - if (hdrSize == 3) { - longAtput(newObj, 0 | 0); - longAtput(newObj + 4, remappedClassOop | 0); - longAtput(newObj + 8, header1 | 0); - newObj += 8; - } - if (hdrSize == 2) { - longAtput(newObj, remappedClassOop | 1); - longAtput(newObj + 4, header1 | 1); - newObj += 4; - } - if (hdrSize == 1) { - longAtput(newObj, header1 | 3); - } - end = newObj + sizeInBytes; - i = newObj + 4; - while (i < end) { - longAtput(i, fillValue); - i += 4; - } -; - ; - return newObj; -} - -int intToNetAddress(int addr) { - int netAddressOop; - - netAddressOop = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (26 << 2)), 8, 0); - byteAtput(((((char *) netAddressOop)) + 4) + 0, (((unsigned) addr) >> 24) & 255); - byteAtput(((((char *) netAddressOop)) + 4) + 1, (((unsigned) addr) >> 16) & 255); - byteAtput(((((char *) netAddressOop)) + 4) + 2, (((unsigned) addr) >> 8) & 255); - byteAtput(((((char *) netAddressOop)) + 4) + 3, addr & 255); - return netAddressOop; -} - -int integerObjectOf(int value) { - if (value < 0) { - return ((2147483648U + value) << 1) + 1; - } else { - return (value << 1) + 1; - } -} - -int integerValueOf(int objectPointer) { - if ((objectPointer & 2147483648U) != 0) { - return ((((unsigned) (objectPointer & 2147483647U)) >> 1) - 1073741823) - 1; - } else { - return ((unsigned) objectPointer) >> 1; - } -} - -int interpret(void) { - int localHomeContext; - char * localSP; - char * localIP; - int currentBytecode; - int t1; - int t2; - int t3; - int t4; - int t5; - int t6; - int t7; - int t8; - int t9; - int t10; - int t11; - int t12; - int t13; - int t14; - int t15; - int t16; - int t17; - int t18; - int t19; - int t20; - int t21; - int t22; - int t23; - int t24; - int t25; - int t26; - int t27; - int t28; - int t29; - int t30; - int t31; - int t32; - int t33; - int t34; - - /* begin internalizeIPandSP */ - localIP = ((char *) instructionPointer); - localSP = ((char *) stackPointer); - localHomeContext = theHomeContext; - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - while (1) { - switch (currentBytecode) { - case 0: - /* pushReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushReceiverVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((0 & 15) << 2))); - break; - case 1: - /* pushReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushReceiverVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((1 & 15) << 2))); - break; - case 2: - /* pushReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushReceiverVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((2 & 15) << 2))); - break; - case 3: - /* pushReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushReceiverVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((3 & 15) << 2))); - break; - case 4: - /* pushReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushReceiverVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((4 & 15) << 2))); - break; - case 5: - /* pushReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushReceiverVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((5 & 15) << 2))); - break; - case 6: - /* pushReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushReceiverVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((6 & 15) << 2))); - break; - case 7: - /* pushReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushReceiverVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((7 & 15) << 2))); - break; - case 8: - /* pushReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushReceiverVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((8 & 15) << 2))); - break; - case 9: - /* pushReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushReceiverVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((9 & 15) << 2))); - break; - case 10: - /* pushReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushReceiverVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((10 & 15) << 2))); - break; - case 11: - /* pushReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushReceiverVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((11 & 15) << 2))); - break; - case 12: - /* pushReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushReceiverVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((12 & 15) << 2))); - break; - case 13: - /* pushReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushReceiverVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((13 & 15) << 2))); - break; - case 14: - /* pushReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushReceiverVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((14 & 15) << 2))); - break; - case 15: - /* pushReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushReceiverVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((15 & 15) << 2))); - break; - case 16: - /* pushTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushTemporaryVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((16 & 15) + 6) << 2))); - break; - case 17: - /* pushTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushTemporaryVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((17 & 15) + 6) << 2))); - break; - case 18: - /* pushTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushTemporaryVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((18 & 15) + 6) << 2))); - break; - case 19: - /* pushTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushTemporaryVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((19 & 15) + 6) << 2))); - break; - case 20: - /* pushTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushTemporaryVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((20 & 15) + 6) << 2))); - break; - case 21: - /* pushTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushTemporaryVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((21 & 15) + 6) << 2))); - break; - case 22: - /* pushTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushTemporaryVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((22 & 15) + 6) << 2))); - break; - case 23: - /* pushTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushTemporaryVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((23 & 15) + 6) << 2))); - break; - case 24: - /* pushTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushTemporaryVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((24 & 15) + 6) << 2))); - break; - case 25: - /* pushTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushTemporaryVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((25 & 15) + 6) << 2))); - break; - case 26: - /* pushTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushTemporaryVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((26 & 15) + 6) << 2))); - break; - case 27: - /* pushTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushTemporaryVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((27 & 15) + 6) << 2))); - break; - case 28: - /* pushTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushTemporaryVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((28 & 15) + 6) << 2))); - break; - case 29: - /* pushTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushTemporaryVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((29 & 15) + 6) << 2))); - break; - case 30: - /* pushTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushTemporaryVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((30 & 15) + 6) << 2))); - break; - case 31: - /* pushTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushTemporaryVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((31 & 15) + 6) << 2))); - break; - case 32: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((32 & 31) + 1) << 2))); - break; - case 33: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((33 & 31) + 1) << 2))); - break; - case 34: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((34 & 31) + 1) << 2))); - break; - case 35: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((35 & 31) + 1) << 2))); - break; - case 36: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((36 & 31) + 1) << 2))); - break; - case 37: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((37 & 31) + 1) << 2))); - break; - case 38: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((38 & 31) + 1) << 2))); - break; - case 39: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((39 & 31) + 1) << 2))); - break; - case 40: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((40 & 31) + 1) << 2))); - break; - case 41: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((41 & 31) + 1) << 2))); - break; - case 42: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((42 & 31) + 1) << 2))); - break; - case 43: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((43 & 31) + 1) << 2))); - break; - case 44: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((44 & 31) + 1) << 2))); - break; - case 45: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((45 & 31) + 1) << 2))); - break; - case 46: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((46 & 31) + 1) << 2))); - break; - case 47: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((47 & 31) + 1) << 2))); - break; - case 48: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((48 & 31) + 1) << 2))); - break; - case 49: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((49 & 31) + 1) << 2))); - break; - case 50: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((50 & 31) + 1) << 2))); - break; - case 51: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((51 & 31) + 1) << 2))); - break; - case 52: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((52 & 31) + 1) << 2))); - break; - case 53: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((53 & 31) + 1) << 2))); - break; - case 54: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((54 & 31) + 1) << 2))); - break; - case 55: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((55 & 31) + 1) << 2))); - break; - case 56: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((56 & 31) + 1) << 2))); - break; - case 57: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((57 & 31) + 1) << 2))); - break; - case 58: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((58 & 31) + 1) << 2))); - break; - case 59: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((59 & 31) + 1) << 2))); - break; - case 60: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((60 & 31) + 1) << 2))); - break; - case 61: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((61 & 31) + 1) << 2))); - break; - case 62: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((62 & 31) + 1) << 2))); - break; - case 63: - /* pushLiteralConstantBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((63 & 31) + 1) << 2))); - break; - case 64: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((64 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 65: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((65 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 66: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((66 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 67: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((67 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 68: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((68 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 69: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((69 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 70: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((70 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 71: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((71 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 72: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((72 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 73: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((73 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 74: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((74 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 75: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((75 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 76: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((76 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 77: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((77 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 78: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((78 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 79: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((79 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 80: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((80 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 81: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((81 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 82: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((82 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 83: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((83 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 84: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((84 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 85: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((85 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 86: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((86 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 87: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((87 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 88: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((88 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 89: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((89 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 90: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((90 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 91: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((91 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 92: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((92 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 93: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((93 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 94: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((94 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 95: - /* pushLiteralVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((95 & 31) + 1) << 2))))) + 4) + (1 << 2))); - break; - case 96: - /* storeAndPopReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - t2 = receiver; - t1 = longAt(localSP); - if (t2 < youngStart) { - possibleRootStoreIntovalue(t2, t1); - } - longAtput(((((char *) t2)) + 4) + ((96 & 7) << 2), t1); - /* begin internalPop: */ - localSP -= 1 * 4; - break; - case 97: - /* storeAndPopReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - t2 = receiver; - t1 = longAt(localSP); - if (t2 < youngStart) { - possibleRootStoreIntovalue(t2, t1); - } - longAtput(((((char *) t2)) + 4) + ((97 & 7) << 2), t1); - /* begin internalPop: */ - localSP -= 1 * 4; - break; - case 98: - /* storeAndPopReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - t2 = receiver; - t1 = longAt(localSP); - if (t2 < youngStart) { - possibleRootStoreIntovalue(t2, t1); - } - longAtput(((((char *) t2)) + 4) + ((98 & 7) << 2), t1); - /* begin internalPop: */ - localSP -= 1 * 4; - break; - case 99: - /* storeAndPopReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - t2 = receiver; - t1 = longAt(localSP); - if (t2 < youngStart) { - possibleRootStoreIntovalue(t2, t1); - } - longAtput(((((char *) t2)) + 4) + ((99 & 7) << 2), t1); - /* begin internalPop: */ - localSP -= 1 * 4; - break; - case 100: - /* storeAndPopReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - t2 = receiver; - t1 = longAt(localSP); - if (t2 < youngStart) { - possibleRootStoreIntovalue(t2, t1); - } - longAtput(((((char *) t2)) + 4) + ((100 & 7) << 2), t1); - /* begin internalPop: */ - localSP -= 1 * 4; - break; - case 101: - /* storeAndPopReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - t2 = receiver; - t1 = longAt(localSP); - if (t2 < youngStart) { - possibleRootStoreIntovalue(t2, t1); - } - longAtput(((((char *) t2)) + 4) + ((101 & 7) << 2), t1); - /* begin internalPop: */ - localSP -= 1 * 4; - break; - case 102: - /* storeAndPopReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - t2 = receiver; - t1 = longAt(localSP); - if (t2 < youngStart) { - possibleRootStoreIntovalue(t2, t1); - } - longAtput(((((char *) t2)) + 4) + ((102 & 7) << 2), t1); - /* begin internalPop: */ - localSP -= 1 * 4; - break; - case 103: - /* storeAndPopReceiverVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - t2 = receiver; - t1 = longAt(localSP); - if (t2 < youngStart) { - possibleRootStoreIntovalue(t2, t1); - } - longAtput(((((char *) t2)) + 4) + ((103 & 7) << 2), t1); - /* begin internalPop: */ - localSP -= 1 * 4; - break; - case 104: - /* storeAndPopTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - longAtput(((((char *) localHomeContext)) + 4) + (((104 & 7) + 6) << 2), longAt(localSP)); - /* begin internalPop: */ - localSP -= 1 * 4; - break; - case 105: - /* storeAndPopTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - longAtput(((((char *) localHomeContext)) + 4) + (((105 & 7) + 6) << 2), longAt(localSP)); - /* begin internalPop: */ - localSP -= 1 * 4; - break; - case 106: - /* storeAndPopTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - longAtput(((((char *) localHomeContext)) + 4) + (((106 & 7) + 6) << 2), longAt(localSP)); - /* begin internalPop: */ - localSP -= 1 * 4; - break; - case 107: - /* storeAndPopTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - longAtput(((((char *) localHomeContext)) + 4) + (((107 & 7) + 6) << 2), longAt(localSP)); - /* begin internalPop: */ - localSP -= 1 * 4; - break; - case 108: - /* storeAndPopTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - longAtput(((((char *) localHomeContext)) + 4) + (((108 & 7) + 6) << 2), longAt(localSP)); - /* begin internalPop: */ - localSP -= 1 * 4; - break; - case 109: - /* storeAndPopTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - longAtput(((((char *) localHomeContext)) + 4) + (((109 & 7) + 6) << 2), longAt(localSP)); - /* begin internalPop: */ - localSP -= 1 * 4; - break; - case 110: - /* storeAndPopTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - longAtput(((((char *) localHomeContext)) + 4) + (((110 & 7) + 6) << 2), longAt(localSP)); - /* begin internalPop: */ - localSP -= 1 * 4; - break; - case 111: - /* storeAndPopTemporaryVariableBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - longAtput(((((char *) localHomeContext)) + 4) + (((111 & 7) + 6) << 2), longAt(localSP)); - /* begin internalPop: */ - localSP -= 1 * 4; - break; - case 112: - /* pushReceiverBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin internalPush: */ - longAtput(localSP += 4, receiver); - break; - case 113: - /* pushConstantTrueBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin internalPush: */ - longAtput(localSP += 4, trueObj); - break; - case 114: - /* pushConstantFalseBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin internalPush: */ - longAtput(localSP += 4, falseObj); - break; - case 115: - /* pushConstantNilBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin internalPush: */ - longAtput(localSP += 4, nilObj); - break; - case 116: - /* pushConstantMinusOneBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin internalPush: */ - longAtput(localSP += 4, 4294967295U); - break; - case 117: - /* pushConstantZeroBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin internalPush: */ - longAtput(localSP += 4, 1); - break; - case 118: - /* pushConstantOneBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin internalPush: */ - longAtput(localSP += 4, 3); - break; - case 119: - /* pushConstantTwoBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin internalPush: */ - longAtput(localSP += 4, 5); - break; - case 120: - /* returnReceiver */ - t2 = longAt(((((char *) localHomeContext)) + 4) + (0 << 2)); - t1 = receiver; - /* begin returnValue:to: */ - commonReturn: /* */; - t3 = nilObj; - t4 = activeContext; - if ((t2 == t3) || ((longAt(((((char *) t2)) + 4) + (1 << 2))) == t3)) { - /* begin internalPush: */ - longAtput(localSP += 4, activeContext); - /* begin internalPush: */ - longAtput(localSP += 4, t1); - messageSelector = longAt(((((char *) specialObjectsOop)) + 4) + (21 << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l1: /* end fetchClassOf: */; - l2: /* end lookupInMethodCacheSel:class: */; - l5: /* end internalExecuteNewMethod */; - } - while (!(t4 == t2)) { - t5 = longAt(((((char *) t4)) + 4) + (0 << 2)); - longAtput(((((char *) t4)) + 4) + (0 << 2), t3); - longAtput(((((char *) t4)) + 4) + (1 << 2), t3); - if (reclaimableContextCount > 0) { - reclaimableContextCount -= 1; - /* begin recycleContextIfPossible: */ - if ((t4 >= youngStart) && (((((unsigned) (longAt(t4))) >> 12) & 31) == 14)) { - longAtput(((((char *) t4)) + 4) + (0 << 2), freeContexts); - freeContexts = t4; - } - } - t4 = t5; - } - activeContext = t4; - if (t4 < youngStart) { - beRootIfOld(t4); - } - /* begin internalFetchContextRegisters: */ - t7 = longAt(((((char *) t4)) + 4) + (3 << 2)); - if ((t7 & 1)) { - t7 = longAt(((((char *) t4)) + 4) + (5 << 2)); - if (t7 < youngStart) { - beRootIfOld(t7); - } - } else { - t7 = t4; - } - localHomeContext = t7; - receiver = longAt(((((char *) t7)) + 4) + (5 << 2)); - method = longAt(((((char *) t7)) + 4) + (3 << 2)); - t7 = ((longAt(((((char *) t4)) + 4) + (1 << 2))) >> 1); - localIP = ((char *) (((method + t7) + 4) - 2)); - t7 = ((longAt(((((char *) t4)) + 4) + (2 << 2))) >> 1); - localSP = ((char *) ((t4 + 4) + (((6 + t7) - 1) * 4))); - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin internalPush: */ - longAtput(localSP += 4, t1); - l3: /* end returnValue:to: */; - break; - case 121: - /* returnTrue */ - t2 = longAt(((((char *) localHomeContext)) + 4) + (0 << 2)); - t1 = trueObj; - /* begin returnValue:to: */ - goto commonReturn; - l8: /* end returnValue:to: */; - break; - case 122: - /* returnFalse */ - t2 = longAt(((((char *) localHomeContext)) + 4) + (0 << 2)); - t1 = falseObj; - /* begin returnValue:to: */ - goto commonReturn; - l13: /* end returnValue:to: */; - break; - case 123: - /* returnNil */ - t2 = longAt(((((char *) localHomeContext)) + 4) + (0 << 2)); - t1 = nilObj; - /* begin returnValue:to: */ - goto commonReturn; - l18: /* end returnValue:to: */; - break; - case 124: - /* returnTopFromMethod */ - t2 = longAt(((((char *) localHomeContext)) + 4) + (0 << 2)); - t1 = longAt(localSP); - /* begin returnValue:to: */ - goto commonReturn; - l23: /* end returnValue:to: */; - break; - case 125: - /* returnTopFromBlock */ - t2 = longAt(((((char *) activeContext)) + 4) + (0 << 2)); - t1 = longAt(localSP); - /* begin returnValue:to: */ - goto commonReturn; - l28: /* end returnValue:to: */; - break; - case 126: - case 127: - /* unknownBytecode */ - error("Unknown bytecode"); - break; - case 128: - /* extendedPushBytecode */ - t1 = byteAt(++localIP); - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - t2 = (((unsigned) t1) >> 6) & 3; - t3 = t1 & 63; - if (t2 == 0) { - /* begin pushReceiverVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + (t3 << 2))); - goto l31; - } - if (t2 == 1) { - /* begin pushTemporaryVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + ((t3 + 6) << 2))); - goto l31; - } - if (t2 == 2) { - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + ((t3 + 1) << 2))); - goto l31; - } - if (t2 == 3) { - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + ((t3 + 1) << 2))))) + 4) + (1 << 2))); - goto l31; - } - l31: /* end case */; - break; - case 129: - /* extendedStoreBytecode */ - t1 = byteAt(++localIP); - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - t2 = (((unsigned) t1) >> 6) & 3; - t3 = t1 & 63; - if (t2 == 0) { - /* begin storePointer:ofObject:withValue: */ - t5 = receiver; - t6 = longAt(localSP); - if (t5 < youngStart) { - possibleRootStoreIntovalue(t5, t6); - } - longAtput(((((char *) t5)) + 4) + (t3 << 2), t6); - goto l32; - } - if (t2 == 1) { - longAtput(((((char *) localHomeContext)) + 4) + ((t3 + 6) << 2), longAt(localSP)); - goto l32; - } - if (t2 == 2) { - error("illegal store"); - } - if (t2 == 3) { - t4 = longAt(((((char *) method)) + 4) + ((t3 + 1) << 2)); - /* begin storePointer:ofObject:withValue: */ - t7 = longAt(localSP); - if (t4 < youngStart) { - possibleRootStoreIntovalue(t4, t7); - } - longAtput(((((char *) t4)) + 4) + (1 << 2), t7); - goto l32; - } - l32: /* end case */; - break; - case 130: - /* extendedStoreAndPopBytecode */ - /* begin extendedStoreBytecode */ - t1 = byteAt(++localIP); - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - t2 = (((unsigned) t1) >> 6) & 3; - t3 = t1 & 63; - if (t2 == 0) { - /* begin storePointer:ofObject:withValue: */ - t5 = receiver; - t6 = longAt(localSP); - if (t5 < youngStart) { - possibleRootStoreIntovalue(t5, t6); - } - longAtput(((((char *) t5)) + 4) + (t3 << 2), t6); - goto l33; - } - if (t2 == 1) { - longAtput(((((char *) localHomeContext)) + 4) + ((t3 + 6) << 2), longAt(localSP)); - goto l33; - } - if (t2 == 2) { - error("illegal store"); - } - if (t2 == 3) { - t4 = longAt(((((char *) method)) + 4) + ((t3 + 1) << 2)); - /* begin storePointer:ofObject:withValue: */ - t7 = longAt(localSP); - if (t4 < youngStart) { - possibleRootStoreIntovalue(t4, t7); - } - longAtput(((((char *) t4)) + 4) + (1 << 2), t7); - goto l33; - } - l33: /* end extendedStoreBytecode */; - /* begin internalPop: */ - localSP -= 1 * 4; - break; - case 131: - /* singleExtendedSendBytecode */ - t1 = byteAt(++localIP); - messageSelector = longAt(((((char *) method)) + 4) + (((t1 & 31) + 1) << 2)); - argumentCount = ((unsigned) t1) >> 5; - /* begin normalSend */ - commonSend: /* */; - t2 = longAt(localSP - (argumentCount * 4)); - /* begin fetchClassOf: */ - if ((t2 & 1)) { - lkupClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l35; - } - t6 = (((unsigned) (longAt(t2))) >> 12) & 31; - if (t6 == 0) { - lkupClass = (longAt(t2 - 4)) & 4294967292U; - goto l35; - } else { - lkupClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((t6 - 1) << 2)); - goto l35; - } - l35: /* end fetchClassOf: */; - commonLookup: /* */; - /* begin lookupInMethodCacheSel:class: */ - t5 = messageSelector ^ lkupClass; - t4 = t5 & 2044; - if (((methodCache[t4 + 1]) == messageSelector) && ((methodCache[t4 + 2]) == lkupClass)) { - newMethod = methodCache[t4 + 3]; - primitiveIndex = methodCache[t4 + 4]; - t3 = 1; - goto l34; - } - t4 = (((unsigned) t5) >> 1) & 2044; - if (((methodCache[t4 + 1]) == messageSelector) && ((methodCache[t4 + 2]) == lkupClass)) { - newMethod = methodCache[t4 + 3]; - primitiveIndex = methodCache[t4 + 4]; - t3 = 1; - goto l34; - } - t4 = (((unsigned) t5) >> 2) & 2044; - if (((methodCache[t4 + 1]) == messageSelector) && ((methodCache[t4 + 2]) == lkupClass)) { - newMethod = methodCache[t4 + 3]; - primitiveIndex = methodCache[t4 + 4]; - t3 = 1; - goto l34; - } - t3 = 0; - l34: /* end lookupInMethodCacheSel:class: */; - if (!(t3)) { - /* begin externalizeIPandSP */ - instructionPointer = ((int) localIP); - stackPointer = ((int) localSP); - theHomeContext = localHomeContext; - lookupMethodInClass(lkupClass); - /* begin internalizeIPandSP */ - localIP = ((char *) instructionPointer); - localSP = ((char *) stackPointer); - localHomeContext = theHomeContext; - addToMethodCacheSelclassmethodprimIndex(messageSelector, lkupClass, newMethod, primitiveIndex); - } - /* begin internalExecuteNewMethod */ - t7 = primitiveIndex; - if (t7 > 0) { - if ((t7 > 255) && (t7 < 520)) { - if (t7 >= 264) { - /* begin internalPop:thenPush: */ - t8 = longAt(((((char *) (longAt(localSP)))) + 4) + ((t7 - 264) << 2)); - longAtput(localSP -= (1 - 1) * 4, t8); - goto l37; - } else { - if (t7 == 256) { - goto l37; - } - if (t7 == 257) { - /* begin internalPop:thenPush: */ - longAtput(localSP -= (1 - 1) * 4, trueObj); - goto l37; - } - if (t7 == 258) { - /* begin internalPop:thenPush: */ - longAtput(localSP -= (1 - 1) * 4, falseObj); - goto l37; - } - if (t7 == 259) { - /* begin internalPop:thenPush: */ - longAtput(localSP -= (1 - 1) * 4, nilObj); - goto l37; - } - /* begin internalPop:thenPush: */ - longAtput(localSP -= (1 - 1) * 4, (((t7 - 261) << 1) | 1)); - goto l37; - } - } else { - /* begin externalizeIPandSP */ - instructionPointer = ((int) localIP); - stackPointer = ((int) localSP); - theHomeContext = localHomeContext; - primitiveResponse(); - /* begin internalizeIPandSP */ - localIP = ((char *) instructionPointer); - localSP = ((char *) stackPointer); - localHomeContext = theHomeContext; - if (successFlag) { - goto l37; - } - } - } - /* begin internalActivateNewMethod */ - if (compilerInitialized) { - /* begin externalizeIPandSP */ - instructionPointer = ((int) localIP); - stackPointer = ((int) localSP); - theHomeContext = localHomeContext; - /* begin activateNewMethod */ - if (!(compilerInitialized && (compilerActivateMethod()))) { - bytecodeActivateNewMethod(); - } - /* begin internalizeIPandSP */ - localIP = ((char *) instructionPointer); - localSP = ((char *) stackPointer); - localHomeContext = theHomeContext; - } else { - /* begin internalBytecodeActivateNewMethod */ - t11 = longAt(((((char *) newMethod)) + 4) + (0 << 2)); - if (freeContexts != 1) { - t13 = freeContexts; - freeContexts = longAt(((((char *) t13)) + 4) + (0 << 2)); - } else { - /* begin externalizeIPandSP */ - instructionPointer = ((int) localIP); - stackPointer = ((int) localSP); - theHomeContext = localHomeContext; - /* begin allocateOrRecycleContext */ - if (freeContexts != 1) { - t15 = freeContexts; - freeContexts = longAt(((((char *) t15)) + 4) + (0 << 2)); - t13 = t15; - goto l36; - } - t15 = instantiateContextsizeInBytes(longAt(((((char *) specialObjectsOop)) + 4) + (10 << 2)), 156); - longAtput(((((char *) t15)) + 4) + (4 << 2), nilObj); - t13 = t15; - l36: /* end allocateOrRecycleContext */; - /* begin internalizeIPandSP */ - localIP = ((char *) instructionPointer); - localSP = ((char *) stackPointer); - localHomeContext = theHomeContext; - } - t12 = (((unsigned) t11) >> 19) & 63; - longAtput(((((char *) t13)) + 4) + (0 << 2), activeContext); - longAtput(((((char *) t13)) + 4) + (1 << 2), (((((1 + ((((unsigned) t11) >> 10) & 255)) * 4) + 1) << 1) | 1)); - longAtput(((((char *) t13)) + 4) + (2 << 2), ((t12 << 1) | 1)); - longAtput(((((char *) t13)) + 4) + (3 << 2), newMethod); - t9 = argumentCount; - for (t10 = 0; t10 <= t9; t10 += 1) { - longAtput(((((char *) t13)) + 4) + ((5 + t10) << 2), longAt(localSP - ((t9 - t10) * 4))); - } - t11 = nilObj; - for (t10 = (t9 + 1); t10 <= t12; t10 += 1) { - longAtput(((((char *) t13)) + 4) + ((5 + t10) << 2), t11); - } - /* begin internalPop: */ - localSP -= (t9 + 1) * 4; - reclaimableContextCount += 1; - /* begin internalNewActiveContext: */ - /* begin internalStoreContextRegisters: */ - longAtput(((((char *) activeContext)) + 4) + (1 << 2), (((((((int) localIP )) + 2) - (method + 4)) << 1) | 1)); - longAtput(((((char *) activeContext)) + 4) + (2 << 2), (((((((unsigned) ((((int) localSP )) - (activeContext + 4))) >> 2) - 6) + 1) << 1) | 1)); - if (t13 < youngStart) { - beRootIfOld(t13); - } - activeContext = t13; - /* begin internalFetchContextRegisters: */ - t14 = longAt(((((char *) t13)) + 4) + (3 << 2)); - if ((t14 & 1)) { - t14 = longAt(((((char *) t13)) + 4) + (5 << 2)); - if (t14 < youngStart) { - beRootIfOld(t14); - } - } else { - t14 = t13; - } - localHomeContext = t14; - receiver = longAt(((((char *) t14)) + 4) + (5 << 2)); - method = longAt(((((char *) t14)) + 4) + (3 << 2)); - t14 = ((longAt(((((char *) t13)) + 4) + (1 << 2))) >> 1); - localIP = ((char *) (((method + t14) + 4) - 2)); - t14 = ((longAt(((((char *) t13)) + 4) + (2 << 2))) >> 1); - localSP = ((char *) ((t13 + 4) + (((6 + t14) - 1) * 4))); - } - /* begin internalQuickCheckForInterrupts */ - if ((interruptCheckCounter -= 1) <= 0) { - /* begin externalizeIPandSP */ - instructionPointer = ((int) localIP); - stackPointer = ((int) localSP); - theHomeContext = localHomeContext; - checkForInterrupts(); - /* begin internalizeIPandSP */ - localIP = ((char *) instructionPointer); - localSP = ((char *) stackPointer); - localHomeContext = theHomeContext; - } - l37: /* end internalExecuteNewMethod */; - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - break; - case 132: - /* doubleExtendedDoAnythingBytecode */ - t1 = byteAt(++localIP); - t2 = byteAt(++localIP); - t4 = ((unsigned) t1) >> 5; - if (t4 == 0) { - messageSelector = longAt(((((char *) method)) + 4) + ((t2 + 1) << 2)); - argumentCount = t1 & 31; - /* begin normalSend */ - goto commonSend; - l40: /* end fetchClassOf: */; - l39: /* end lookupInMethodCacheSel:class: */; - l43: /* end internalExecuteNewMethod */; - } - if (t4 == 1) { - messageSelector = longAt(((((char *) method)) + 4) + ((t2 + 1) << 2)); - argumentCount = t1 & 31; - /* begin superclassSend */ - goto commonSupersend; - l41: /* end lookupInMethodCacheSel:class: */; - l45: /* end internalExecuteNewMethod */; - } - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - if (t4 == 2) { - /* begin pushReceiverVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + (t2 << 2))); - goto l38; - } - if (t4 == 3) { - /* begin pushLiteralConstant: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) method)) + 4) + ((t2 + 1) << 2))); - goto l38; - } - if (t4 == 4) { - /* begin pushLiteralVariable: */ - /* begin internalPush: */ - longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + ((t2 + 1) << 2))))) + 4) + (1 << 2))); - goto l38; - } - if (t4 == 5) { - t3 = longAt(localSP); - /* begin storePointer:ofObject:withValue: */ - t10 = receiver; - if (t10 < youngStart) { - possibleRootStoreIntovalue(t10, t3); - } - longAtput(((((char *) t10)) + 4) + (t2 << 2), t3); - goto l38; - } - if (t4 == 6) { - t3 = longAt(localSP); - /* begin internalPop: */ - localSP -= 1 * 4; - /* begin storePointer:ofObject:withValue: */ - t11 = receiver; - if (t11 < youngStart) { - possibleRootStoreIntovalue(t11, t3); - } - longAtput(((((char *) t11)) + 4) + (t2 << 2), t3); - goto l38; - } - if (t4 == 7) { - t3 = longAt(localSP); - /* begin storePointer:ofObject:withValue: */ - t12 = longAt(((((char *) method)) + 4) + ((t2 + 1) << 2)); - if (t12 < youngStart) { - possibleRootStoreIntovalue(t12, t3); - } - longAtput(((((char *) t12)) + 4) + (1 << 2), t3); - goto l38; - } - l38: /* end case */; - break; - case 133: - /* singleExtendedSuperBytecode */ - t1 = byteAt(++localIP); - messageSelector = longAt(((((char *) method)) + 4) + (((t1 & 31) + 1) << 2)); - argumentCount = ((unsigned) t1) >> 5; - /* begin superclassSend */ - commonSupersend: /* */; - /* begin superclassOf: */ - t2 = longAt(((((char *) (longAt(((((char *) method)) + 4) + (((((((unsigned) (longAt(((((char *) method)) + 4) + (0 << 2)))) >> 10) & 255) - 1) + 1) << 2))))) + 4) + (1 << 2)); - lkupClass = longAt(((((char *) t2)) + 4) + (0 << 2)); - goto commonLookup; - l46: /* end lookupInMethodCacheSel:class: */; - l48: /* end internalExecuteNewMethod */; - break; - case 134: - /* secondExtendedSendBytecode */ - t1 = byteAt(++localIP); - messageSelector = longAt(((((char *) method)) + 4) + (((t1 & 63) + 1) << 2)); - argumentCount = ((unsigned) t1) >> 6; - /* begin normalSend */ - goto commonSend; - l50: /* end fetchClassOf: */; - l49: /* end lookupInMethodCacheSel:class: */; - l52: /* end internalExecuteNewMethod */; - break; - case 135: - /* popStackBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin internalPop: */ - localSP -= 1 * 4; - break; - case 136: - /* duplicateTopBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin internalPush: */ - t1 = longAt(localSP); - longAtput(localSP += 4, t1); - break; - case 137: - /* pushActiveContextBytecode */ - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - reclaimableContextCount = 0; - /* begin internalPush: */ - longAtput(localSP += 4, activeContext); - break; - case 138: - case 139: - case 140: - case 141: - case 142: - case 143: - /* experimentalBytecode */ - t3 = longAt(((((char *) localHomeContext)) + 4) + (((currentBytecode - 138) + 6) << 2)); - t4 = byteAt(localIP + 1); - t5 = byteAt(localIP + 2); - t6 = byteAt(localIP + 3); - if ((t3 & 1)) { - t1 = (t3 >> 1); - } else { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin internalPush: */ - longAtput(localSP += 4, t3); - goto l53; - } - if (t4 < 32) { - t2 = longAt(((((char *) localHomeContext)) + 4) + (((t4 & 15) + 6) << 2)); - if ((t2 & 1)) { - t2 = (t2 >> 1); - } else { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin internalPush: */ - longAtput(localSP += 4, t3); - goto l53; - } - } else { - if (t4 > 64) { - t2 = 1; - } else { - t2 = longAt(((((char *) method)) + 4) + (((t4 & 31) + 1) << 2)); - if ((t2 & 1)) { - t2 = (t2 >> 1); - } else { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin internalPush: */ - longAtput(localSP += 4, t3); - goto l53; - } - } - } - if (t5 < 178) { - t8 = t1 + t2; - if ((t8 ^ (t8 << 1)) >= 0) { - if ((t6 > 103) && (t6 < 112)) { - localIP += 3; - longAtput(((((char *) localHomeContext)) + 4) + (((t6 & 7) + 6) << 2), ((t8 << 1) | 1)); - } else { - localIP += 2; - /* begin internalPush: */ - longAtput(localSP += 4, ((t8 << 1) | 1)); - } - } else { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin internalPush: */ - longAtput(localSP += 4, t3); - goto l53; - } - } else { - t7 = byteAt(localIP + 4); - if (t1 <= t2) { - localIP = (localIP + 3) + 1; - } else { - localIP = ((localIP + 3) + 1) + t7; - } - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - } - l53: /* end case */; - break; - case 144: - /* shortUnconditionalJump */ - /* begin jump: */ - t1 = (144 & 7) + 1; - localIP = (localIP + t1) + 1; - currentBytecode = byteAt(localIP); - break; - case 145: - /* shortUnconditionalJump */ - /* begin jump: */ - t1 = (145 & 7) + 1; - localIP = (localIP + t1) + 1; - currentBytecode = byteAt(localIP); - break; - case 146: - /* shortUnconditionalJump */ - /* begin jump: */ - t1 = (146 & 7) + 1; - localIP = (localIP + t1) + 1; - currentBytecode = byteAt(localIP); - break; - case 147: - /* shortUnconditionalJump */ - /* begin jump: */ - t1 = (147 & 7) + 1; - localIP = (localIP + t1) + 1; - currentBytecode = byteAt(localIP); - break; - case 148: - /* shortUnconditionalJump */ - /* begin jump: */ - t1 = (148 & 7) + 1; - localIP = (localIP + t1) + 1; - currentBytecode = byteAt(localIP); - break; - case 149: - /* shortUnconditionalJump */ - /* begin jump: */ - t1 = (149 & 7) + 1; - localIP = (localIP + t1) + 1; - currentBytecode = byteAt(localIP); - break; - case 150: - /* shortUnconditionalJump */ - /* begin jump: */ - t1 = (150 & 7) + 1; - localIP = (localIP + t1) + 1; - currentBytecode = byteAt(localIP); - break; - case 151: - /* shortUnconditionalJump */ - /* begin jump: */ - t1 = (151 & 7) + 1; - localIP = (localIP + t1) + 1; - currentBytecode = byteAt(localIP); - break; - case 152: - case 153: - case 154: - case 155: - case 156: - case 157: - case 158: - case 159: - /* shortConditionalJump */ - /* begin jumplfFalseBy: */ - t1 = (currentBytecode & 7) + 1; - t2 = longAt(localSP); - if (t2 == falseObj) { - /* begin jump: */ - localIP = (localIP + t1) + 1; - currentBytecode = byteAt(localIP); - } else { - if (!(t2 == trueObj)) { - messageSelector = longAt(((((char *) specialObjectsOop)) + 4) + (25 << 2)); - argumentCount = 0; - /* begin normalSend */ - goto commonSend; - l54: /* end fetchClassOf: */; - l55: /* end lookupInMethodCacheSel:class: */; - l58: /* end internalExecuteNewMethod */; - } - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - } - /* begin internalPop: */ - localSP -= 1 * 4; - l56: /* end jumplfFalseBy: */; - break; - case 160: - case 161: - case 162: - case 163: - case 164: - case 165: - case 166: - case 167: - /* longUnconditionalJump */ - t1 = (((currentBytecode & 7) - 4) * 256) + (byteAt(++localIP)); - localIP += t1; - if (t1 < 0) { - /* begin internalQuickCheckForInterrupts */ - if ((interruptCheckCounter -= 1) <= 0) { - /* begin externalizeIPandSP */ - instructionPointer = ((int) localIP); - stackPointer = ((int) localSP); - theHomeContext = localHomeContext; - checkForInterrupts(); - /* begin internalizeIPandSP */ - localIP = ((char *) instructionPointer); - localSP = ((char *) stackPointer); - localHomeContext = theHomeContext; - } - } - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - break; - case 168: - case 169: - case 170: - case 171: - /* longJumpIfTrue */ - /* begin jumplfTrueBy: */ - t1 = ((currentBytecode & 3) * 256) + (byteAt(++localIP)); - t2 = longAt(localSP); - if (t2 == trueObj) { - /* begin jump: */ - localIP = (localIP + t1) + 1; - currentBytecode = byteAt(localIP); - } else { - if (!(t2 == falseObj)) { - messageSelector = longAt(((((char *) specialObjectsOop)) + 4) + (25 << 2)); - argumentCount = 0; - /* begin normalSend */ - goto commonSend; - l60: /* end fetchClassOf: */; - l59: /* end lookupInMethodCacheSel:class: */; - l63: /* end internalExecuteNewMethod */; - } - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - } - /* begin internalPop: */ - localSP -= 1 * 4; - l61: /* end jumplfTrueBy: */; - break; - case 172: - case 173: - case 174: - case 175: - /* longJumpIfFalse */ - /* begin jumplfFalseBy: */ - t1 = ((currentBytecode & 3) * 256) + (byteAt(++localIP)); - t2 = longAt(localSP); - if (t2 == falseObj) { - /* begin jump: */ - localIP = (localIP + t1) + 1; - currentBytecode = byteAt(localIP); - } else { - if (!(t2 == trueObj)) { - messageSelector = longAt(((((char *) specialObjectsOop)) + 4) + (25 << 2)); - argumentCount = 0; - /* begin normalSend */ - goto commonSend; - l64: /* end fetchClassOf: */; - l65: /* end lookupInMethodCacheSel:class: */; - l68: /* end internalExecuteNewMethod */; - } - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - } - /* begin internalPop: */ - localSP -= 1 * 4; - l66: /* end jumplfFalseBy: */; - break; - case 176: - /* bytecodePrimAdd */ - t2 = longAt(localSP - (1 * 4)); - t1 = longAt(localSP - (0 * 4)); - if (((t2 & t1) & 1) != 0) { - t3 = ((t2 >> 1)) + ((t1 >> 1)); - if ((t3 ^ (t3 << 1)) >= 0) { - /* begin internalPop:thenPush: */ - longAtput(localSP -= (2 - 1) * 4, ((t3 << 1) | 1)); - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l69; - } - } else { - successFlag = 1; - /* begin externalizeIPandSP */ - instructionPointer = ((int) localIP); - stackPointer = ((int) localSP); - theHomeContext = localHomeContext; - primitiveFloatAddtoArg(t2, t1); - /* begin internalizeIPandSP */ - localIP = ((char *) instructionPointer); - localSP = ((char *) stackPointer); - localHomeContext = theHomeContext; - if (successFlag) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l69; - } - } - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((0 * 2) << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l71: /* end fetchClassOf: */; - l70: /* end lookupInMethodCacheSel:class: */; - l73: /* end internalExecuteNewMethod */; - l69: /* end case */; - break; - case 177: - /* bytecodePrimSubtract */ - t2 = longAt(localSP - (1 * 4)); - t1 = longAt(localSP - (0 * 4)); - if (((t2 & t1) & 1) != 0) { - t3 = ((t2 >> 1)) - ((t1 >> 1)); - if ((t3 ^ (t3 << 1)) >= 0) { - /* begin internalPop:thenPush: */ - longAtput(localSP -= (2 - 1) * 4, ((t3 << 1) | 1)); - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l74; - } - } else { - successFlag = 1; - /* begin externalizeIPandSP */ - instructionPointer = ((int) localIP); - stackPointer = ((int) localSP); - theHomeContext = localHomeContext; - primitiveFloatSubtractfromArg(t2, t1); - /* begin internalizeIPandSP */ - localIP = ((char *) instructionPointer); - localSP = ((char *) stackPointer); - localHomeContext = theHomeContext; - if (successFlag) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l74; - } - } - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((1 * 2) << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l76: /* end fetchClassOf: */; - l75: /* end lookupInMethodCacheSel:class: */; - l78: /* end internalExecuteNewMethod */; - l74: /* end case */; - break; - case 178: - /* bytecodePrimLessThan */ - t3 = longAt(localSP - (1 * 4)); - t1 = longAt(localSP - (0 * 4)); - if (((t3 & t1) & 1) != 0) { - ; - /* begin booleanCheat: */ - t6 = byteAt(++localIP); - /* begin internalPop: */ - localSP -= 2 * 4; - if ((t6 < 160) && (t6 > 151)) { - if (t3 < t1) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l79; - } else { - /* begin jump: */ - localIP = (localIP + (t6 - 151)) + 1; - currentBytecode = byteAt(localIP); - goto l79; - } - } - if (t6 == 172) { - t7 = byteAt(++localIP); - if (t3 < t1) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l79; - } else { - /* begin jump: */ - localIP = (localIP + t7) + 1; - currentBytecode = byteAt(localIP); - goto l79; - } - } - localIP -= 1; - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - if (t3 < t1) { - /* begin internalPush: */ - longAtput(localSP += 4, trueObj); - } else { - /* begin internalPush: */ - longAtput(localSP += 4, falseObj); - } - goto l79; - } - successFlag = 1; - t2 = primitiveFloatLessthanArg(t3, t1); - if (successFlag) { - /* begin booleanCheat: */ - t8 = byteAt(++localIP); - /* begin internalPop: */ - localSP -= 2 * 4; - if ((t8 < 160) && (t8 > 151)) { - if (t2) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l79; - } else { - /* begin jump: */ - localIP = (localIP + (t8 - 151)) + 1; - currentBytecode = byteAt(localIP); - goto l79; - } - } - if (t8 == 172) { - t9 = byteAt(++localIP); - if (t2) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l79; - } else { - /* begin jump: */ - localIP = (localIP + t9) + 1; - currentBytecode = byteAt(localIP); - goto l79; - } - } - localIP -= 1; - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - if (t2) { - /* begin internalPush: */ - longAtput(localSP += 4, trueObj); - } else { - /* begin internalPush: */ - longAtput(localSP += 4, falseObj); - } - goto l79; - } - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((2 * 2) << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l81: /* end fetchClassOf: */; - l80: /* end lookupInMethodCacheSel:class: */; - l83: /* end internalExecuteNewMethod */; - l79: /* end case */; - break; - case 179: - /* bytecodePrimGreaterThan */ - t3 = longAt(localSP - (1 * 4)); - t1 = longAt(localSP - (0 * 4)); - if (((t3 & t1) & 1) != 0) { - ; - /* begin booleanCheat: */ - t6 = byteAt(++localIP); - /* begin internalPop: */ - localSP -= 2 * 4; - if ((t6 < 160) && (t6 > 151)) { - if (t3 > t1) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l84; - } else { - /* begin jump: */ - localIP = (localIP + (t6 - 151)) + 1; - currentBytecode = byteAt(localIP); - goto l84; - } - } - if (t6 == 172) { - t7 = byteAt(++localIP); - if (t3 > t1) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l84; - } else { - /* begin jump: */ - localIP = (localIP + t7) + 1; - currentBytecode = byteAt(localIP); - goto l84; - } - } - localIP -= 1; - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - if (t3 > t1) { - /* begin internalPush: */ - longAtput(localSP += 4, trueObj); - } else { - /* begin internalPush: */ - longAtput(localSP += 4, falseObj); - } - goto l84; - } - successFlag = 1; - t2 = primitiveFloatGreaterthanArg(t3, t1); - if (successFlag) { - /* begin booleanCheat: */ - t8 = byteAt(++localIP); - /* begin internalPop: */ - localSP -= 2 * 4; - if ((t8 < 160) && (t8 > 151)) { - if (t2) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l84; - } else { - /* begin jump: */ - localIP = (localIP + (t8 - 151)) + 1; - currentBytecode = byteAt(localIP); - goto l84; - } - } - if (t8 == 172) { - t9 = byteAt(++localIP); - if (t2) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l84; - } else { - /* begin jump: */ - localIP = (localIP + t9) + 1; - currentBytecode = byteAt(localIP); - goto l84; - } - } - localIP -= 1; - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - if (t2) { - /* begin internalPush: */ - longAtput(localSP += 4, trueObj); - } else { - /* begin internalPush: */ - longAtput(localSP += 4, falseObj); - } - goto l84; - } - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((3 * 2) << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l86: /* end fetchClassOf: */; - l85: /* end lookupInMethodCacheSel:class: */; - l88: /* end internalExecuteNewMethod */; - l84: /* end case */; - break; - case 180: - /* bytecodePrimLessOrEqual */ - t3 = longAt(localSP - (1 * 4)); - t1 = longAt(localSP - (0 * 4)); - if (((t3 & t1) & 1) != 0) { - ; - /* begin booleanCheat: */ - t6 = byteAt(++localIP); - /* begin internalPop: */ - localSP -= 2 * 4; - if ((t6 < 160) && (t6 > 151)) { - if (t3 <= t1) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l89; - } else { - /* begin jump: */ - localIP = (localIP + (t6 - 151)) + 1; - currentBytecode = byteAt(localIP); - goto l89; - } - } - if (t6 == 172) { - t7 = byteAt(++localIP); - if (t3 <= t1) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l89; - } else { - /* begin jump: */ - localIP = (localIP + t7) + 1; - currentBytecode = byteAt(localIP); - goto l89; - } - } - localIP -= 1; - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - if (t3 <= t1) { - /* begin internalPush: */ - longAtput(localSP += 4, trueObj); - } else { - /* begin internalPush: */ - longAtput(localSP += 4, falseObj); - } - goto l89; - } - successFlag = 1; - t2 = primitiveFloatGreaterthanArg(t3, t1); - if (successFlag) { - /* begin booleanCheat: */ - t8 = byteAt(++localIP); - /* begin internalPop: */ - localSP -= 2 * 4; - if ((t8 < 160) && (t8 > 151)) { - if (!t2) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l89; - } else { - /* begin jump: */ - localIP = (localIP + (t8 - 151)) + 1; - currentBytecode = byteAt(localIP); - goto l89; - } - } - if (t8 == 172) { - t9 = byteAt(++localIP); - if (!t2) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l89; - } else { - /* begin jump: */ - localIP = (localIP + t9) + 1; - currentBytecode = byteAt(localIP); - goto l89; - } - } - localIP -= 1; - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - if (!t2) { - /* begin internalPush: */ - longAtput(localSP += 4, trueObj); - } else { - /* begin internalPush: */ - longAtput(localSP += 4, falseObj); - } - goto l89; - } - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((4 * 2) << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l91: /* end fetchClassOf: */; - l90: /* end lookupInMethodCacheSel:class: */; - l93: /* end internalExecuteNewMethod */; - l89: /* end case */; - break; - case 181: - /* bytecodePrimGreaterOrEqual */ - t3 = longAt(localSP - (1 * 4)); - t1 = longAt(localSP - (0 * 4)); - if (((t3 & t1) & 1) != 0) { - ; - /* begin booleanCheat: */ - t6 = byteAt(++localIP); - /* begin internalPop: */ - localSP -= 2 * 4; - if ((t6 < 160) && (t6 > 151)) { - if (t3 >= t1) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l94; - } else { - /* begin jump: */ - localIP = (localIP + (t6 - 151)) + 1; - currentBytecode = byteAt(localIP); - goto l94; - } - } - if (t6 == 172) { - t7 = byteAt(++localIP); - if (t3 >= t1) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l94; - } else { - /* begin jump: */ - localIP = (localIP + t7) + 1; - currentBytecode = byteAt(localIP); - goto l94; - } - } - localIP -= 1; - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - if (t3 >= t1) { - /* begin internalPush: */ - longAtput(localSP += 4, trueObj); - } else { - /* begin internalPush: */ - longAtput(localSP += 4, falseObj); - } - goto l94; - } - successFlag = 1; - t2 = primitiveFloatLessthanArg(t3, t1); - if (successFlag) { - /* begin booleanCheat: */ - t8 = byteAt(++localIP); - /* begin internalPop: */ - localSP -= 2 * 4; - if ((t8 < 160) && (t8 > 151)) { - if (!t2) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l94; - } else { - /* begin jump: */ - localIP = (localIP + (t8 - 151)) + 1; - currentBytecode = byteAt(localIP); - goto l94; - } - } - if (t8 == 172) { - t9 = byteAt(++localIP); - if (!t2) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l94; - } else { - /* begin jump: */ - localIP = (localIP + t9) + 1; - currentBytecode = byteAt(localIP); - goto l94; - } - } - localIP -= 1; - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - if (!t2) { - /* begin internalPush: */ - longAtput(localSP += 4, trueObj); - } else { - /* begin internalPush: */ - longAtput(localSP += 4, falseObj); - } - goto l94; - } - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((5 * 2) << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l96: /* end fetchClassOf: */; - l95: /* end lookupInMethodCacheSel:class: */; - l98: /* end internalExecuteNewMethod */; - l94: /* end case */; - break; - case 182: - /* bytecodePrimEqual */ - t3 = longAt(localSP - (1 * 4)); - t1 = longAt(localSP - (0 * 4)); - if (((t3 & t1) & 1) != 0) { - /* begin booleanCheat: */ - t4 = byteAt(++localIP); - /* begin internalPop: */ - localSP -= 2 * 4; - if ((t4 < 160) && (t4 > 151)) { - if (t3 == t1) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l99; - } else { - /* begin jump: */ - localIP = (localIP + (t4 - 151)) + 1; - currentBytecode = byteAt(localIP); - goto l99; - } - } - if (t4 == 172) { - t5 = byteAt(++localIP); - if (t3 == t1) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l99; - } else { - /* begin jump: */ - localIP = (localIP + t5) + 1; - currentBytecode = byteAt(localIP); - goto l99; - } - } - localIP -= 1; - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - if (t3 == t1) { - /* begin internalPush: */ - longAtput(localSP += 4, trueObj); - } else { - /* begin internalPush: */ - longAtput(localSP += 4, falseObj); - } - goto l99; - } - successFlag = 1; - t2 = primitiveFloatEqualtoArg(t3, t1); - if (successFlag) { - /* begin booleanCheat: */ - t6 = byteAt(++localIP); - /* begin internalPop: */ - localSP -= 2 * 4; - if ((t6 < 160) && (t6 > 151)) { - if (t2) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l99; - } else { - /* begin jump: */ - localIP = (localIP + (t6 - 151)) + 1; - currentBytecode = byteAt(localIP); - goto l99; - } - } - if (t6 == 172) { - t7 = byteAt(++localIP); - if (t2) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l99; - } else { - /* begin jump: */ - localIP = (localIP + t7) + 1; - currentBytecode = byteAt(localIP); - goto l99; - } - } - localIP -= 1; - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - if (t2) { - /* begin internalPush: */ - longAtput(localSP += 4, trueObj); - } else { - /* begin internalPush: */ - longAtput(localSP += 4, falseObj); - } - goto l99; - } - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((6 * 2) << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l101: /* end fetchClassOf: */; - l100: /* end lookupInMethodCacheSel:class: */; - l103: /* end internalExecuteNewMethod */; - l99: /* end case */; - break; - case 183: - /* bytecodePrimNotEqual */ - t3 = longAt(localSP - (1 * 4)); - t1 = longAt(localSP - (0 * 4)); - if (((t3 & t1) & 1) != 0) { - /* begin booleanCheat: */ - t4 = byteAt(++localIP); - /* begin internalPop: */ - localSP -= 2 * 4; - if ((t4 < 160) && (t4 > 151)) { - if (t3 != t1) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l104; - } else { - /* begin jump: */ - localIP = (localIP + (t4 - 151)) + 1; - currentBytecode = byteAt(localIP); - goto l104; - } - } - if (t4 == 172) { - t5 = byteAt(++localIP); - if (t3 != t1) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l104; - } else { - /* begin jump: */ - localIP = (localIP + t5) + 1; - currentBytecode = byteAt(localIP); - goto l104; - } - } - localIP -= 1; - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - if (t3 != t1) { - /* begin internalPush: */ - longAtput(localSP += 4, trueObj); - } else { - /* begin internalPush: */ - longAtput(localSP += 4, falseObj); - } - goto l104; - } - successFlag = 1; - t2 = primitiveFloatEqualtoArg(t3, t1); - if (successFlag) { - /* begin booleanCheat: */ - t6 = byteAt(++localIP); - /* begin internalPop: */ - localSP -= 2 * 4; - if ((t6 < 160) && (t6 > 151)) { - if (!t2) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l104; - } else { - /* begin jump: */ - localIP = (localIP + (t6 - 151)) + 1; - currentBytecode = byteAt(localIP); - goto l104; - } - } - if (t6 == 172) { - t7 = byteAt(++localIP); - if (!t2) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l104; - } else { - /* begin jump: */ - localIP = (localIP + t7) + 1; - currentBytecode = byteAt(localIP); - goto l104; - } - } - localIP -= 1; - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - if (!t2) { - /* begin internalPush: */ - longAtput(localSP += 4, trueObj); - } else { - /* begin internalPush: */ - longAtput(localSP += 4, falseObj); - } - goto l104; - } - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((7 * 2) << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l106: /* end fetchClassOf: */; - l105: /* end lookupInMethodCacheSel:class: */; - l108: /* end internalExecuteNewMethod */; - l104: /* end case */; - break; - case 184: - /* bytecodePrimMultiply */ - t2 = longAt(localSP - (1 * 4)); - t1 = longAt(localSP - (0 * 4)); - if (((t2 & t1) & 1) != 0) { - t2 = (t2 >> 1); - t1 = (t1 >> 1); - t3 = t2 * t1; - if (((t1 == 0) || ((t3 / t1) == t2)) && ((t3 ^ (t3 << 1)) >= 0)) { - /* begin internalPop:thenPush: */ - longAtput(localSP -= (2 - 1) * 4, ((t3 << 1) | 1)); - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l109; - } - } else { - successFlag = 1; - /* begin externalizeIPandSP */ - instructionPointer = ((int) localIP); - stackPointer = ((int) localSP); - theHomeContext = localHomeContext; - primitiveFloatMultiplybyArg(t2, t1); - /* begin internalizeIPandSP */ - localIP = ((char *) instructionPointer); - localSP = ((char *) stackPointer); - localHomeContext = theHomeContext; - if (successFlag) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l109; - } - } - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((8 * 2) << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l111: /* end fetchClassOf: */; - l110: /* end lookupInMethodCacheSel:class: */; - l113: /* end internalExecuteNewMethod */; - l109: /* end case */; - break; - case 185: - /* bytecodePrimDivide */ - t2 = longAt(localSP - (1 * 4)); - t1 = longAt(localSP - (0 * 4)); - if (((t2 & t1) & 1) != 0) { - t2 = (t2 >> 1); - t1 = (t1 >> 1); - if ((t1 != 0) && ((t2 % t1) == 0)) { - t3 = t2 / t1; - if ((t3 ^ (t3 << 1)) >= 0) { - /* begin internalPop:thenPush: */ - longAtput(localSP -= (2 - 1) * 4, ((t3 << 1) | 1)); - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l114; - } - } - } else { - successFlag = 1; - /* begin externalizeIPandSP */ - instructionPointer = ((int) localIP); - stackPointer = ((int) localSP); - theHomeContext = localHomeContext; - primitiveFloatDividebyArg(t2, t1); - /* begin internalizeIPandSP */ - localIP = ((char *) instructionPointer); - localSP = ((char *) stackPointer); - localHomeContext = theHomeContext; - if (successFlag) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l114; - } - } - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((9 * 2) << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l116: /* end fetchClassOf: */; - l115: /* end lookupInMethodCacheSel:class: */; - l118: /* end internalExecuteNewMethod */; - l114: /* end case */; - break; - case 186: - /* bytecodePrimMod */ - successFlag = 1; - t1 = doPrimitiveModby(longAt(localSP - (1 * 4)), longAt(localSP - (0 * 4))); - if (successFlag) { - /* begin internalPop:thenPush: */ - longAtput(localSP -= (2 - 1) * 4, ((t1 << 1) | 1)); - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l119; - } - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((10 * 2) << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l121: /* end fetchClassOf: */; - l120: /* end lookupInMethodCacheSel:class: */; - l123: /* end internalExecuteNewMethod */; - l119: /* end case */; - break; - case 187: - /* bytecodePrimMakePoint */ - successFlag = 1; - /* begin externalizeIPandSP */ - instructionPointer = ((int) localIP); - stackPointer = ((int) localSP); - theHomeContext = localHomeContext; - primitiveMakePoint(); - /* begin internalizeIPandSP */ - localIP = ((char *) instructionPointer); - localSP = ((char *) stackPointer); - localHomeContext = theHomeContext; - if (successFlag) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l124; - } - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((11 * 2) << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l126: /* end fetchClassOf: */; - l125: /* end lookupInMethodCacheSel:class: */; - l128: /* end internalExecuteNewMethod */; - l124: /* end case */; - break; - case 188: - /* bytecodePrimBitShift */ - successFlag = 1; - /* begin externalizeIPandSP */ - instructionPointer = ((int) localIP); - stackPointer = ((int) localSP); - theHomeContext = localHomeContext; - primitiveBitShift(); - /* begin internalizeIPandSP */ - localIP = ((char *) instructionPointer); - localSP = ((char *) stackPointer); - localHomeContext = theHomeContext; - if (successFlag) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l129; - } - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((12 * 2) << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l131: /* end fetchClassOf: */; - l130: /* end lookupInMethodCacheSel:class: */; - l133: /* end internalExecuteNewMethod */; - l129: /* end case */; - break; - case 189: - /* bytecodePrimDiv */ - successFlag = 1; - t1 = doPrimitiveDivby(longAt(localSP - (1 * 4)), longAt(localSP - (0 * 4))); - if (successFlag) { - /* begin internalPop:thenPush: */ - longAtput(localSP -= (2 - 1) * 4, ((t1 << 1) | 1)); - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l134; - } - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((13 * 2) << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l136: /* end fetchClassOf: */; - l135: /* end lookupInMethodCacheSel:class: */; - l138: /* end internalExecuteNewMethod */; - l134: /* end case */; - break; - case 190: - /* bytecodePrimBitAnd */ - successFlag = 1; - /* begin externalizeIPandSP */ - instructionPointer = ((int) localIP); - stackPointer = ((int) localSP); - theHomeContext = localHomeContext; - /* begin primitiveBitAnd */ - /* begin popPos32BitInteger */ - /* begin popStack */ - t6 = longAt(stackPointer); - stackPointer -= 4; - t5 = t6; - t2 = positive32BitValueOf(t5); - /* begin popPos32BitInteger */ - /* begin popStack */ - t8 = longAt(stackPointer); - stackPointer -= 4; - t7 = t8; - t1 = positive32BitValueOf(t7); - if (successFlag) { - /* begin push: */ - t3 = positive32BitIntegerFor(t1 & t2); - longAtput(t4 = stackPointer + 4, t3); - stackPointer = t4; - } else { - /* begin unPop: */ - stackPointer += 2 * 4; - } - /* begin internalizeIPandSP */ - localIP = ((char *) instructionPointer); - localSP = ((char *) stackPointer); - localHomeContext = theHomeContext; - if (successFlag) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l139; - } - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((14 * 2) << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l141: /* end fetchClassOf: */; - l140: /* end lookupInMethodCacheSel:class: */; - l143: /* end internalExecuteNewMethod */; - l139: /* end case */; - break; - case 191: - /* bytecodePrimBitOr */ - successFlag = 1; - /* begin externalizeIPandSP */ - instructionPointer = ((int) localIP); - stackPointer = ((int) localSP); - theHomeContext = localHomeContext; - /* begin primitiveBitOr */ - /* begin popPos32BitInteger */ - /* begin popStack */ - t6 = longAt(stackPointer); - stackPointer -= 4; - t5 = t6; - t2 = positive32BitValueOf(t5); - /* begin popPos32BitInteger */ - /* begin popStack */ - t8 = longAt(stackPointer); - stackPointer -= 4; - t7 = t8; - t1 = positive32BitValueOf(t7); - if (successFlag) { - /* begin push: */ - t3 = positive32BitIntegerFor(t1 | t2); - longAtput(t4 = stackPointer + 4, t3); - stackPointer = t4; - } else { - /* begin unPop: */ - stackPointer += 2 * 4; - } - /* begin internalizeIPandSP */ - localIP = ((char *) instructionPointer); - localSP = ((char *) stackPointer); - localHomeContext = theHomeContext; - if (successFlag) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l144; - } - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((15 * 2) << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l146: /* end fetchClassOf: */; - l145: /* end lookupInMethodCacheSel:class: */; - l148: /* end internalExecuteNewMethod */; - l144: /* end case */; - break; - case 192: - /* bytecodePrimAt */ - t1 = longAt(localSP); - t2 = longAt(localSP - (1 * 4)); - successFlag = (!((t2 & 1))) && ((t1 & 1)); - if (successFlag) { - t4 = t2 & 28; - if ((atCache[t4 + 1]) == t2) { - /* begin commonVariableInternal:at:cacheIndex: */ - t10 = atCache[t4 + 2]; - if (((((unsigned ) ((t1 >> 1)))) >= 1) && ((((unsigned ) ((t1 >> 1)))) <= (((unsigned ) t10)))) { - t11 = atCache[t4 + 3]; - if (t11 <= 4) { - t12 = atCache[t4 + 4]; - t3 = longAt(((((char *) t2)) + 4) + (((((t1 >> 1)) + t12) - 1) << 2)); - goto l152; - } - if (t11 < 8) { - t13 = longAt(((((char *) t2)) + 4) + ((((t1 >> 1)) - 1) << 2)); - /* begin externalizeIPandSP */ - instructionPointer = ((int) localIP); - stackPointer = ((int) localSP); - theHomeContext = localHomeContext; - t13 = positive32BitIntegerFor(t13); - /* begin internalizeIPandSP */ - localIP = ((char *) instructionPointer); - localSP = ((char *) stackPointer); - localHomeContext = theHomeContext; - t3 = t13; - goto l152; - } - if (t11 >= 16) { - t3 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (24 << 2))))) + 4) + ((byteAt(((((char *) t2)) + 4) + (((t1 >> 1)) - 1))) << 2)); - goto l152; - } else { - t3 = (((byteAt(((((char *) t2)) + 4) + (((t1 >> 1)) - 1))) << 1) | 1); - goto l152; - } - } - /* begin primitiveFail */ - successFlag = 0; - l152: /* end commonVariableInternal:at:cacheIndex: */; - if (successFlag) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin internalPop:thenPush: */ - longAtput(localSP -= (2 - 1) * 4, t3); - goto l149; - } - } - } - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((16 * 2) << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l151: /* end fetchClassOf: */; - l150: /* end lookupInMethodCacheSel:class: */; - l154: /* end internalExecuteNewMethod */; - l149: /* end case */; - break; - case 193: - /* bytecodePrimAtPut */ - t1 = longAt(localSP); - t2 = longAt(localSP - (1 * 4)); - t3 = longAt(localSP - (2 * 4)); - successFlag = (!((t3 & 1))) && ((t2 & 1)); - if (successFlag) { - t4 = (t3 & 28) + 32; - if ((atCache[t4 + 1]) == t3) { - /* begin commonVariable:at:put:cacheIndex: */ - t5 = atCache[t4 + 2]; - if (((((unsigned ) ((t2 >> 1)))) >= 1) && ((((unsigned ) ((t2 >> 1)))) <= (((unsigned ) t5)))) { - t7 = atCache[t4 + 3]; - if (t7 <= 4) { - t8 = atCache[t4 + 4]; - /* begin storePointer:ofObject:withValue: */ - if (t3 < youngStart) { - possibleRootStoreIntovalue(t3, t1); - } - longAtput(((((char *) t3)) + 4) + (((((t2 >> 1)) + t8) - 1) << 2), t1); - goto l156; - } - if (t7 < 8) { - t6 = positive32BitValueOf(t1); - if (successFlag) { - longAtput(((((char *) t3)) + 4) + ((((t2 >> 1)) - 1) << 2), t6); - } - goto l156; - } - if (t7 >= 16) { - t6 = asciiOfCharacter(t1); - if (!(successFlag)) { - goto l156; - } - } else { - t6 = t1; - } - if ((t6 & 1)) { - byteAtput(((((char *) t3)) + 4) + (((t2 >> 1)) - 1), (t6 >> 1)); - goto l156; - } - } - /* begin primitiveFail */ - successFlag = 0; - l156: /* end commonVariable:at:put:cacheIndex: */; - if (successFlag) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - /* begin internalPop:thenPush: */ - longAtput(localSP -= (3 - 1) * 4, t1); - goto l155; - } - } - } - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((17 * 2) << 2)); - argumentCount = 2; - /* begin normalSend */ - goto commonSend; - l158: /* end fetchClassOf: */; - l157: /* end lookupInMethodCacheSel:class: */; - l160: /* end internalExecuteNewMethod */; - l155: /* end case */; - break; - case 194: - /* bytecodePrimSize */ - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((18 * 2) << 2)); - argumentCount = 0; - /* begin normalSend */ - goto commonSend; - l162: /* end fetchClassOf: */; - l161: /* end lookupInMethodCacheSel:class: */; - l164: /* end internalExecuteNewMethod */; - break; - case 195: - /* bytecodePrimNext */ - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((19 * 2) << 2)); - argumentCount = 0; - /* begin normalSend */ - goto commonSend; - l166: /* end fetchClassOf: */; - l165: /* end lookupInMethodCacheSel:class: */; - l168: /* end internalExecuteNewMethod */; - break; - case 196: - /* bytecodePrimNextPut */ - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((20 * 2) << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l170: /* end fetchClassOf: */; - l169: /* end lookupInMethodCacheSel:class: */; - l172: /* end internalExecuteNewMethod */; - break; - case 197: - /* bytecodePrimAtEnd */ - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((21 * 2) << 2)); - argumentCount = 0; - /* begin normalSend */ - goto commonSend; - l174: /* end fetchClassOf: */; - l173: /* end lookupInMethodCacheSel:class: */; - l176: /* end internalExecuteNewMethod */; - break; - case 198: - /* bytecodePrimEquivalent */ - t2 = longAt(localSP - (1 * 4)); - t1 = longAt(localSP - (0 * 4)); - /* begin booleanCheat: */ - t3 = byteAt(++localIP); - /* begin internalPop: */ - localSP -= 2 * 4; - if ((t3 < 160) && (t3 > 151)) { - if (t2 == t1) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l177; - } else { - /* begin jump: */ - localIP = (localIP + (t3 - 151)) + 1; - currentBytecode = byteAt(localIP); - goto l177; - } - } - if (t3 == 172) { - t4 = byteAt(++localIP); - if (t2 == t1) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l177; - } else { - /* begin jump: */ - localIP = (localIP + t4) + 1; - currentBytecode = byteAt(localIP); - goto l177; - } - } - localIP -= 1; - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - if (t2 == t1) { - /* begin internalPush: */ - longAtput(localSP += 4, trueObj); - } else { - /* begin internalPush: */ - longAtput(localSP += 4, falseObj); - } - l177: /* end booleanCheat: */; - break; - case 199: - /* bytecodePrimClass */ - t1 = longAt(localSP); - /* begin internalPop:thenPush: */ - /* begin fetchClassOf: */ - if ((t1 & 1)) { - t2 = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l178; - } - t3 = (((unsigned) (longAt(t1))) >> 12) & 31; - if (t3 == 0) { - t2 = (longAt(t1 - 4)) & 4294967292U; - goto l178; - } else { - t2 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((t3 - 1) << 2)); - goto l178; - } - l178: /* end fetchClassOf: */; - longAtput(localSP -= (1 - 1) * 4, t2); - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - break; - case 200: - /* bytecodePrimBlockCopy */ - t2 = longAt(localSP - (1 * 4)); - successFlag = 1; - t1 = longAt(t2); - /* begin success: */ - /* begin isContextHeader: */ - t9 = (((unsigned) t1) >> 12) & 31; - t7 = (t9 == 13) || (t9 == 14); - successFlag = t7 && successFlag; - if (successFlag) { - /* begin externalizeIPandSP */ - instructionPointer = ((int) localIP); - stackPointer = ((int) localSP); - theHomeContext = localHomeContext; - primitiveBlockCopy(); - /* begin internalizeIPandSP */ - localIP = ((char *) instructionPointer); - localSP = ((char *) stackPointer); - localHomeContext = theHomeContext; - } - if (!(successFlag)) { - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((24 * 2) << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l181: /* end fetchClassOf: */; - l180: /* end lookupInMethodCacheSel:class: */; - l183: /* end internalExecuteNewMethod */; - } - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - l179: /* end case */; - break; - case 201: - /* bytecodePrimValue */ - t1 = longAt(localSP); - successFlag = 1; - argumentCount = 0; - /* begin assertClassOf:is: */ - if ((t1 & 1)) { - successFlag = 0; - goto l187; - } - t7 = (((unsigned) (longAt(t1))) >> 12) & 31; - if (t7 == 0) { - t8 = (longAt(t1 - 4)) & 4294967292U; - } else { - t8 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((t7 - 1) << 2)); - } - /* begin success: */ - successFlag = (t8 == (longAt(((((char *) specialObjectsOop)) + 4) + (11 << 2)))) && successFlag; - l187: /* end assertClassOf:is: */; - if (successFlag) { - /* begin externalizeIPandSP */ - instructionPointer = ((int) localIP); - stackPointer = ((int) localSP); - theHomeContext = localHomeContext; - primitiveValue(); - /* begin internalizeIPandSP */ - localIP = ((char *) instructionPointer); - localSP = ((char *) stackPointer); - localHomeContext = theHomeContext; - } - if (!(successFlag)) { - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((25 * 2) << 2)); - argumentCount = 0; - /* begin normalSend */ - goto commonSend; - l186: /* end fetchClassOf: */; - l185: /* end lookupInMethodCacheSel:class: */; - l189: /* end internalExecuteNewMethod */; - } - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - l184: /* end case */; - break; - case 202: - /* bytecodePrimValueWithArg */ - t1 = longAt(localSP - (1 * 4)); - successFlag = 1; - argumentCount = 1; - /* begin assertClassOf:is: */ - if ((t1 & 1)) { - successFlag = 0; - goto l193; - } - t7 = (((unsigned) (longAt(t1))) >> 12) & 31; - if (t7 == 0) { - t8 = (longAt(t1 - 4)) & 4294967292U; - } else { - t8 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((t7 - 1) << 2)); - } - /* begin success: */ - successFlag = (t8 == (longAt(((((char *) specialObjectsOop)) + 4) + (11 << 2)))) && successFlag; - l193: /* end assertClassOf:is: */; - if (successFlag) { - /* begin externalizeIPandSP */ - instructionPointer = ((int) localIP); - stackPointer = ((int) localSP); - theHomeContext = localHomeContext; - primitiveValue(); - /* begin internalizeIPandSP */ - localIP = ((char *) instructionPointer); - localSP = ((char *) stackPointer); - localHomeContext = theHomeContext; - } - if (!(successFlag)) { - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((26 * 2) << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l192: /* end fetchClassOf: */; - l191: /* end lookupInMethodCacheSel:class: */; - l195: /* end internalExecuteNewMethod */; - } - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - l190: /* end case */; - break; - case 203: - /* bytecodePrimDo */ - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((27 * 2) << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l197: /* end fetchClassOf: */; - l196: /* end lookupInMethodCacheSel:class: */; - l199: /* end internalExecuteNewMethod */; - break; - case 204: - /* bytecodePrimNew */ - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((28 * 2) << 2)); - argumentCount = 0; - /* begin normalSend */ - goto commonSend; - l201: /* end fetchClassOf: */; - l200: /* end lookupInMethodCacheSel:class: */; - l203: /* end internalExecuteNewMethod */; - break; - case 205: - /* bytecodePrimNewWithArg */ - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((29 * 2) << 2)); - argumentCount = 1; - /* begin normalSend */ - goto commonSend; - l205: /* end fetchClassOf: */; - l204: /* end lookupInMethodCacheSel:class: */; - l207: /* end internalExecuteNewMethod */; - break; - case 206: - /* bytecodePrimPointX */ - successFlag = 1; - /* begin externalizeIPandSP */ - instructionPointer = ((int) localIP); - stackPointer = ((int) localSP); - theHomeContext = localHomeContext; - primitivePointX(); - /* begin internalizeIPandSP */ - localIP = ((char *) instructionPointer); - localSP = ((char *) stackPointer); - localHomeContext = theHomeContext; - if (successFlag) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l208; - } - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((30 * 2) << 2)); - argumentCount = 0; - /* begin normalSend */ - goto commonSend; - l210: /* end fetchClassOf: */; - l209: /* end lookupInMethodCacheSel:class: */; - l212: /* end internalExecuteNewMethod */; - l208: /* end case */; - break; - case 207: - /* bytecodePrimPointY */ - successFlag = 1; - /* begin externalizeIPandSP */ - instructionPointer = ((int) localIP); - stackPointer = ((int) localSP); - theHomeContext = localHomeContext; - primitivePointY(); - /* begin internalizeIPandSP */ - localIP = ((char *) instructionPointer); - localSP = ((char *) stackPointer); - localHomeContext = theHomeContext; - if (successFlag) { - /* begin fetchNextBytecode */ - currentBytecode = byteAt(++localIP); - goto l213; - } - messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((31 * 2) << 2)); - argumentCount = 0; - /* begin normalSend */ - goto commonSend; - l215: /* end fetchClassOf: */; - l214: /* end lookupInMethodCacheSel:class: */; - l217: /* end internalExecuteNewMethod */; - l213: /* end case */; - break; - case 208: - case 209: - case 210: - case 211: - case 212: - case 213: - case 214: - case 215: - case 216: - case 217: - case 218: - case 219: - case 220: - case 221: - case 222: - case 223: - case 224: - case 225: - case 226: - case 227: - case 228: - case 229: - case 230: - case 231: - case 232: - case 233: - case 234: - case 235: - case 236: - case 237: - case 238: - case 239: - case 240: - case 241: - case 242: - case 243: - case 244: - case 245: - case 246: - case 247: - case 248: - case 249: - case 250: - case 251: - case 252: - case 253: - case 254: - case 255: - /* sendLiteralSelectorBytecode */ - /* begin literal: */ - t1 = currentBytecode & 15; - messageSelector = longAt(((((char *) method)) + 4) + ((t1 + 1) << 2)); - argumentCount = ((((unsigned) currentBytecode) >> 4) & 3) - 1; - /* begin normalSend */ - goto commonSend; - l218: /* end fetchClassOf: */; - l219: /* end lookupInMethodCacheSel:class: */; - l221: /* end internalExecuteNewMethod */; - break; - } - } - /* begin externalizeIPandSP */ - instructionPointer = ((int) localIP); - stackPointer = ((int) localSP); - theHomeContext = localHomeContext; -} - -int isKindOf(int oop, char *className) { - int oopClass; - int ccIndex; - - /* begin fetchClassOf: */ - if ((oop & 1)) { - oopClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l1; - } - ccIndex = (((unsigned) (longAt(oop))) >> 12) & 31; - if (ccIndex == 0) { - oopClass = (longAt(oop - 4)) & 4294967292U; - goto l1; - } else { - oopClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l1; - } -l1: /* end fetchClassOf: */; - while (!(oopClass == nilObj)) { - if (classNameOfIs(oopClass, className)) { - return 1; - } - oopClass = longAt(((((char *) oopClass)) + 4) + (0 << 2)); - } - return 0; -} - -int isMemberOf(int oop, char *className) { - int oopClass; - int ccIndex; - - /* begin fetchClassOf: */ - if ((oop & 1)) { - oopClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l1; - } - ccIndex = (((unsigned) (longAt(oop))) >> 12) & 31; - if (ccIndex == 0) { - oopClass = (longAt(oop - 4)) & 4294967292U; - goto l1; - } else { - oopClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l1; - } -l1: /* end fetchClassOf: */; - return classNameOfIs(oopClass, className); -} - -int isBytes(int oop) { - return ((((unsigned) (longAt(oop))) >> 8) & 15) >= 8; -} - -int isContextHeader(int aHeader) { - int ccIndex; - - ccIndex = (((unsigned) aHeader) >> 12) & 31; - return (ccIndex == 13) || (ccIndex == 14); -} - -int isEdge(int edge) { - int type; - - type = (objBuffer[edge + 0]) & 65535; - if (type > 255) { - return 0; - } - return (((objBuffer[edge + 0]) & 65535) & 255) != 0; -} - -int isFillOkay(int fill) { - return (fill == 0) || (((fill & 4278190080U) != 0) || (((fill >= 0) && (fill < objUsed)) && (((fill & 4278190080U) != 0) || ((((objBuffer[fill + 0]) & 65535) & 65280) != 0)))); -} - -int isFloatObject(int oop) { - return (fetchClassOf(oop)) == (longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2))); -} - -int isIndexable(int oop) { - return ((((unsigned) (longAt(oop))) >> 8) & 15) >= 2; -} - -int isIntegerObject(int objectPointer) { - return (objectPointer & 1) > 0; -} - -int isIntegerValue(int intValue) { - return (intValue ^ (intValue << 1)) >= 0; -} - -int isPointers(int oop) { - return ((((unsigned) (longAt(oop))) >> 8) & 15) <= 4; -} - -int isWeak(int oop) { - return ((((unsigned) (longAt(oop))) >> 8) & 15) == 4; -} - -int isWords(int oop) { - return ((((unsigned) (longAt(oop))) >> 8) & 15) == 6; -} - -int isWordsOrBytes(int oop) { - int fmt; - - fmt = (((unsigned) (longAt(oop))) >> 8) & 15; - return (fmt == 6) || ((fmt >= 8) && (fmt <= 11)); -} - -int lastPointerOf(int oop) { - int methodHeader; - int sz; - int fmt; - int header; - int header1; - int type; - - header = longAt(oop); - fmt = (((unsigned) header) >> 8) & 15; - if (fmt <= 4) { - if ((fmt == 3) && (isContextHeader(header))) { - return (6 + (fetchStackPointerOf(oop))) * 4; - } - /* begin sizeBitsOfSafe: */ - header1 = longAt(oop); - /* begin rightType: */ - if ((header1 & 252) == 0) { - type = 0; - goto l1; - } else { - if ((header1 & 126976) == 0) { - type = 1; - goto l1; - } else { - type = 3; - goto l1; - } - } - l1: /* end rightType: */; - if (type == 0) { - sz = (longAt(oop - 8)) & 4294967292U; - goto l2; - } else { - sz = header1 & 252; - goto l2; - } - l2: /* end sizeBitsOfSafe: */; - return sz - 4; - } - if (fmt < 12) { - return 0; - } - methodHeader = longAt(oop + 4); - return (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; -} - -int lengthOf(int oop) { - int header; - int sz; - - header = longAt(oop); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(oop - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - return ((unsigned) (sz - 4)) >> 2; - } else { - return (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - } - return null; -} - -int literalofMethod(int offset, int methodPointer) { - return longAt(((((char *) methodPointer)) + 4) + ((offset + 1) << 2)); -} - -int literalCountOf(int methodPointer) { - return (((unsigned) (longAt(((((char *) methodPointer)) + 4) + (0 << 2)))) >> 10) & 255; -} - -int loadAndSubdivideBezierFromviatoisWide(int *point1, int *point2, int *point3, int wideFlag) { - int bz1; - int bz2; - int index; - int index2; - int index1; - - /* begin allocateBezierStackEntry */ - /* begin wbStackPush: */ - if (!(needAvailableSpace(6))) { - goto l1; - } - workBuffer[10] = ((workBuffer[10]) - 6); -l1: /* end wbStackPush: */; - bz1 = (workBuffer[1]) - (workBuffer[10]); - if (engineStopped) { - return 0; - } - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - bz1) + 0)] = (point1[0]); - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - bz1) + 1)] = (point1[1]); - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - bz1) + 2)] = (point2[0]); - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - bz1) + 3)] = (point2[1]); - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - bz1) + 4)] = (point3[0]); - workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - bz1) + 5)] = (point3[1]); - index2 = bz2 = subdivideToBeMonotoninX(bz1, wideFlag); - for (index = bz1; index <= bz2; index += 6) { - index1 = subdivideBezierFrom(index); - if (index1 > index2) { - index2 = index1; - } - if (engineStopped) { - return 0; - } - } - return index2 / 6; -} - -int loadArgumentPoint(int point) { - int oop; - int isInt; - - if (!successFlag) { - return null; - } - if (!((fetchClassOf(point)) == (longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2))))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - oop = longAt(((((char *) point)) + 4) + (0 << 2)); - isInt = (oop & 1); - if (!(isInt || ((fetchClassOf(oop)) == (longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)))))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (isInt) { - m23ArgX = (oop >> 1); - } else { - m23ArgX = floatValueOf(oop); - } - oop = longAt(((((char *) point)) + 4) + (1 << 2)); - isInt = (oop & 1); - if (!(isInt || ((fetchClassOf(oop)) == (longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)))))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (isInt) { - m23ArgY = (oop >> 1); - } else { - m23ArgY = floatValueOf(oop); - } -} - -int loadArrayShapenSegmentsfilllineWidthlineFill(int points, int nSegments, int fillIndex, int lineWidth, int lineFill) { - int segs; - int pointOop; - int y0; - int y1; - int y2; - int i; - int x0; - int x1; - int x2; - - for (i = 0; i <= (nSegments - 1); i += 1) { - pointOop = longAt(((((char *) points)) + 4) + ((i * 3) << 2)); - loadPointfrom(((int *) (workBuffer + 80)), pointOop); - pointOop = longAt(((((char *) points)) + 4) + (((i * 3) + 1) << 2)); - loadPointfrom(((int *) (workBuffer + 82)), pointOop); - pointOop = longAt(((((char *) points)) + 4) + (((i * 3) + 2) << 2)); - loadPointfrom(((int *) (workBuffer + 84)), pointOop); - if (!successFlag) { - return null; - } - /* begin transformPoints: */ - if (3 > 0) { - transformPoint(((int *) (workBuffer + 80))); - } - if (3 > 1) { - transformPoint(((int *) (workBuffer + 82))); - } - if (3 > 2) { - transformPoint(((int *) (workBuffer + 84))); - } - if (3 > 3) { - transformPoint(((int *) (workBuffer + 86))); - } - x0 = (((int *) (workBuffer + 80)))[0]; - y0 = (((int *) (workBuffer + 80)))[1]; - x1 = (((int *) (workBuffer + 82)))[0]; - y1 = (((int *) (workBuffer + 82)))[1]; - x2 = (((int *) (workBuffer + 84)))[0]; - y2 = (((int *) (workBuffer + 84)))[1]; - if (((x0 == y0) && (x1 == y1)) || ((x1 == x2) && (y1 == y2))) { - loadWideLinefromtolineFillleftFillrightFill(lineWidth, ((int *) (workBuffer + 80)), ((int *) (workBuffer + 84)), lineFill, fillIndex, 0); - } else { - segs = loadAndSubdivideBezierFromviatoisWide(((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), ((int *) (workBuffer + 84)), (lineWidth != 0) && (lineFill != 0)); - if (engineStopped) { - return null; - } - loadWideBezierlineFillleftFillrightFilln(lineWidth, lineFill, fillIndex, 0, segs); - } - if (engineStopped) { - return null; - } - } -} - -int loadArrayTransformFromintolength(int transformOop, float *destPtr, int n) { - int i; - int value; - - for (i = 0; i <= (n - 1); i += 1) { - value = longAt(((((char *) transformOop)) + 4) + (i << 2)); - if (!(((value & 1)) || ((fetchClassOf(value)) == (longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)))))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if ((value & 1)) { - destPtr[i] = (((float) (((double) ((value >> 1)) )))); - } else { - destPtr[i] = (((float) (floatValueOf(value)))); - } - } -} - -int loadBeziersegmentleftFillrightFilloffset(int bezier, int index, int leftFillIndex, int rightFillIndex, int yOffset) { - if ((workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 5)]) >= (workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 1)])) { - objBuffer[bezier + 4] = (workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 0)]); - objBuffer[bezier + 5] = ((workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 1)]) - yOffset); - objBuffer[bezier + 12] = (workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 2)]); - objBuffer[bezier + 13] = ((workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 3)]) - yOffset); - objBuffer[bezier + 14] = (workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 4)]); - objBuffer[bezier + 15] = ((workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 5)]) - yOffset); - } else { - objBuffer[bezier + 4] = (workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 4)]); - objBuffer[bezier + 5] = ((workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 5)]) - yOffset); - objBuffer[bezier + 12] = (workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 2)]); - objBuffer[bezier + 13] = ((workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 3)]) - yOffset); - objBuffer[bezier + 14] = (workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 0)]); - objBuffer[bezier + 15] = ((workBuffer[(workBuffer[10]) + ((((workBuffer[1]) - (workBuffer[10])) - index) + 1)]) - yOffset); - } - objBuffer[bezier + 6] = (workBuffer[113]); - objBuffer[bezier + 8] = leftFillIndex; - objBuffer[bezier + 9] = rightFillIndex; -} - -int loadBitBltFrom(int bbObj) { - int destBitsSize; - int destWidth; - int destHeight; - int sourceBitsSize; - int sourcePixPerWord; - int halftoneBits; - int cmSize; - int header; - int sz; - int header1; - int sz1; - - bitBltOop = bbObj; - combinationRule = fetchIntegerofObject(3, bitBltOop); - if ((!successFlag) || ((combinationRule < 0) || (combinationRule > (36 - 2)))) { - return 0; - } - if ((combinationRule >= 16) && (combinationRule <= 17)) { - return 0; - } - sourceForm = longAt(((((char *) bitBltOop)) + 4) + (1 << 2)); - /* begin ignoreSourceOrHalftone: */ - if (sourceForm == nilObj) { - noSource = 1; - goto l3; - } - if (combinationRule == 0) { - noSource = 1; - goto l3; - } - if (combinationRule == 5) { - noSource = 1; - goto l3; - } - if (combinationRule == 10) { - noSource = 1; - goto l3; - } - if (combinationRule == 15) { - noSource = 1; - goto l3; - } - noSource = 0; -l3: /* end ignoreSourceOrHalftone: */; - halftoneForm = longAt(((((char *) bitBltOop)) + 4) + (2 << 2)); - /* begin ignoreSourceOrHalftone: */ - if (halftoneForm == nilObj) { - noHalftone = 1; - goto l4; - } - if (combinationRule == 0) { - noHalftone = 1; - goto l4; - } - if (combinationRule == 5) { - noHalftone = 1; - goto l4; - } - if (combinationRule == 10) { - noHalftone = 1; - goto l4; - } - if (combinationRule == 15) { - noHalftone = 1; - goto l4; - } - noHalftone = 0; -l4: /* end ignoreSourceOrHalftone: */; - destForm = longAt(((((char *) bitBltOop)) + 4) + (0 << 2)); - if (!((((((unsigned) (longAt(destForm))) >> 8) & 15) <= 4) && ((lengthOf(destForm)) >= 4))) { - return 0; - } - destBits = longAt(((((char *) destForm)) + 4) + (0 << 2)); - destBitsSize = byteLengthOf(destBits); - destWidth = fetchIntegerofObject(1, destForm); - destHeight = fetchIntegerofObject(2, destForm); - if (!((destWidth >= 0) && (destHeight >= 0))) { - return 0; - } - destPixSize = fetchIntegerofObject(3, destForm); - pixPerWord = 32 / destPixSize; - destRaster = (destWidth + (pixPerWord - 1)) / pixPerWord; - if (!((isWordsOrBytes(destBits)) && (destBitsSize == ((destRaster * destHeight) * 4)))) { - return 0; - } - destX = fetchIntegerOrTruncFloatofObject(4, bitBltOop); - destY = fetchIntegerOrTruncFloatofObject(5, bitBltOop); - width = fetchIntegerOrTruncFloatofObject(6, bitBltOop); - height = fetchIntegerOrTruncFloatofObject(7, bitBltOop); - if (!successFlag) { - return 0; - } - if (noSource) { - sourceX = sourceY = 0; - } else { - if (!((((((unsigned) (longAt(sourceForm))) >> 8) & 15) <= 4) && ((lengthOf(sourceForm)) >= 4))) { - return 0; - } - sourceBits = longAt(((((char *) sourceForm)) + 4) + (0 << 2)); - sourceBitsSize = byteLengthOf(sourceBits); - srcWidth = fetchIntegerOrTruncFloatofObject(1, sourceForm); - srcHeight = fetchIntegerOrTruncFloatofObject(2, sourceForm); - if (!((srcWidth >= 0) && (srcHeight >= 0))) { - return 0; - } - sourcePixSize = fetchIntegerofObject(3, sourceForm); - sourcePixPerWord = 32 / sourcePixSize; - sourceRaster = (srcWidth + (sourcePixPerWord - 1)) / sourcePixPerWord; - if (!((isWordsOrBytes(sourceBits)) && (sourceBitsSize == ((sourceRaster * srcHeight) * 4)))) { - return 0; - } - colorMap = longAt(((((char *) bitBltOop)) + 4) + (14 << 2)); - if (!(colorMap == nilObj)) { - if (((((unsigned) (longAt(colorMap))) >> 8) & 15) == 6) { - /* begin lengthOf: */ - header = longAt(colorMap); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(colorMap - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - cmSize = ((unsigned) (sz - 4)) >> 2; - goto l1; - } else { - cmSize = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l1; - } - cmSize = null; - l1: /* end lengthOf: */; - cmBitsPerColor = 0; - if (cmSize == 512) { - cmBitsPerColor = 3; - } - if (cmSize == 4096) { - cmBitsPerColor = 4; - } - if (cmSize == 32768) { - cmBitsPerColor = 5; - } - if (primitiveIndex != 147) { - if (sourcePixSize <= 8) { - if (!(cmSize == (1 << sourcePixSize))) { - return 0; - } - } else { - if (cmBitsPerColor == 0) { - return 0; - } - } - } - } else { - return 0; - } - } - sourceX = fetchIntegerOrTruncFloatofObject(8, bitBltOop); - sourceY = fetchIntegerOrTruncFloatofObject(9, bitBltOop); - } - if (!(noHalftone)) { - if ((((((unsigned) (longAt(halftoneForm))) >> 8) & 15) <= 4) && ((lengthOf(halftoneForm)) >= 4)) { - halftoneBits = longAt(((((char *) halftoneForm)) + 4) + (0 << 2)); - halftoneHeight = fetchIntegerofObject(2, halftoneForm); - if (!(((((unsigned) (longAt(halftoneBits))) >> 8) & 15) == 6)) { - noHalftone = 1; - } - } else { - if (!((!(((((unsigned) (longAt(halftoneForm))) >> 8) & 15) <= 4)) && (((((unsigned) (longAt(halftoneForm))) >> 8) & 15) == 6))) { - return 0; - } - halftoneBits = halftoneForm; - /* begin lengthOf: */ - header1 = longAt(halftoneBits); - /* begin lengthOf:baseHeader:format: */ - if ((header1 & 3) == 0) { - sz1 = (longAt(halftoneBits - 8)) & 4294967292U; - } else { - sz1 = header1 & 252; - } - if (((((unsigned) header1) >> 8) & 15) < 8) { - halftoneHeight = ((unsigned) (sz1 - 4)) >> 2; - goto l2; - } else { - halftoneHeight = (sz1 - 4) - (((((unsigned) header1) >> 8) & 15) & 3); - goto l2; - } - halftoneHeight = null; - l2: /* end lengthOf: */; - } - halftoneBase = halftoneBits + 4; - } - clipX = fetchIntegerOrTruncFloatofObject(10, bitBltOop); - clipY = fetchIntegerOrTruncFloatofObject(11, bitBltOop); - clipWidth = fetchIntegerOrTruncFloatofObject(12, bitBltOop); - clipHeight = fetchIntegerOrTruncFloatofObject(13, bitBltOop); - if (!successFlag) { - return 0; - } - if (clipX < 0) { - clipWidth += clipX; - clipX = 0; - } - if (clipY < 0) { - clipHeight += clipY; - clipY = 0; - } - if ((clipX + clipWidth) > destWidth) { - clipWidth = destWidth - clipX; - } - if ((clipY + clipHeight) > destHeight) { - clipHeight = destHeight - clipY; - } - return 1; -} - -int loadBitmapFillcolormaptilefromalongnormalxIndex(int formOop, int cmOop, int tileFlag, int *point1, int *point2, int *point3, int xIndex) { - int bmBits; - int bmWidth; - int bmDepth; - int bmBitsSize; - int ppw; - int *cmBits; - int cmSize; - int bmRaster; - int bmHeight; - int bmFill; - int header; - int header1; - int sz; - int sz1; - - if (cmOop == nilObj) { - cmSize = 0; - cmBits = null; - } else { - if (!((fetchClassOf(cmOop)) == (longAt(((((char *) specialObjectsOop)) + 4) + (4 << 2))))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin slotSizeOf: */ - if ((cmOop & 1)) { - cmSize = 0; - goto l1; - } - /* begin lengthOf: */ - header = longAt(cmOop); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(cmOop - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - cmSize = ((unsigned) (sz - 4)) >> 2; - goto l3; - } else { - cmSize = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l3; - } - l3: /* end lengthOf:baseHeader:format: */; - l1: /* end slotSizeOf: */; - cmBits = firstIndexableField(cmOop); - } - if ((formOop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(((((unsigned) (longAt(formOop))) >> 8) & 15) <= 4)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if ((slotSizeOf(formOop)) < 5) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - bmBits = longAt(((((char *) formOop)) + 4) + (0 << 2)); - if (!((fetchClassOf(bmBits)) == (longAt(((((char *) specialObjectsOop)) + 4) + (4 << 2))))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin slotSizeOf: */ - if ((bmBits & 1)) { - bmBitsSize = 0; - goto l2; - } - /* begin lengthOf: */ - header1 = longAt(bmBits); - /* begin lengthOf:baseHeader:format: */ - if ((header1 & 3) == 0) { - sz1 = (longAt(bmBits - 8)) & 4294967292U; - } else { - sz1 = header1 & 252; - } - if (((((unsigned) header1) >> 8) & 15) < 8) { - bmBitsSize = ((unsigned) (sz1 - 4)) >> 2; - goto l4; - } else { - bmBitsSize = (sz1 - 4) - (((((unsigned) header1) >> 8) & 15) & 3); - goto l4; - } -l4: /* end lengthOf:baseHeader:format: */; -l2: /* end slotSizeOf: */; - bmWidth = fetchIntegerofObject(1, formOop); - bmHeight = fetchIntegerofObject(2, formOop); - bmDepth = fetchIntegerofObject(3, formOop); - if (!successFlag) { - return null; - } - if (!((bmWidth >= 0) && (bmHeight >= 0))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!((((((bmDepth == 32) || (bmDepth == 8)) || (bmDepth == 16)) || (bmDepth == 1)) || (bmDepth == 2)) || (bmDepth == 4))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!((cmSize == 0) || (cmSize == (1 << bmDepth)))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - ppw = 32 / bmDepth; - bmRaster = (bmWidth + (ppw - 1)) / ppw; - if (!(bmBitsSize == (bmRaster * bmHeight))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - bmFill = allocateBitmapFillcolormap(cmSize, cmBits); - if (engineStopped) { - return null; - } - objBuffer[bmFill + 10] = bmWidth; - objBuffer[bmFill + 11] = bmHeight; - objBuffer[bmFill + 12] = bmDepth; - objBuffer[bmFill + 14] = bmRaster; - objBuffer[bmFill + 13] = bmBitsSize; - objBuffer[bmFill + 16] = tileFlag; - objBuffer[bmFill + 2] = xIndex; - loadFillOrientationfromalongnormalwidthheight(bmFill, point1, point2, point3, bmWidth, bmHeight); - return bmFill; -} - -int * loadBitsFrom(int bmFill) { - int xIndex; - int bitsOop; - int formOop; - int bitsLen; - int header; - int sz; - - xIndex = objBuffer[bmFill + 2]; - if (xIndex > (slotSizeOf(formArray))) { - return null; - } - formOop = longAt(((((char *) formArray)) + 4) + (xIndex << 2)); - bitsOop = longAt(((((char *) formOop)) + 4) + (0 << 2)); - /* begin slotSizeOf: */ - if ((bitsOop & 1)) { - bitsLen = 0; - goto l1; - } - /* begin lengthOf: */ - header = longAt(bitsOop); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(bitsOop - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - bitsLen = ((unsigned) (sz - 4)) >> 2; - goto l2; - } else { - bitsLen = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l2; - } -l2: /* end lengthOf:baseHeader:format: */; -l1: /* end slotSizeOf: */; - if (!(bitsLen == (objBuffer[bmFill + 13]))) { - return null; - } - return firstIndexableField(bitsOop); -} - -int loadColorTransformFrom(int transformOop) { - float *transform; - int okay; - - transform = ((float *) (workBuffer + 24)); - workBuffer[17] = 0; - okay = loadTransformFromintolength(transformOop, transform, 8); - if (!(okay)) { - return 0; - } - workBuffer[17] = 1; - transform[1] = ((transform[1]) * (((float) 256.0))); - transform[3] = ((transform[3]) * (((float) 256.0))); - transform[5] = ((transform[5]) * (((float) 256.0))); - transform[7] = ((transform[7]) * (((float) 256.0))); - return okay; -} - -int loadCompressedShapesegmentsleftFillsrightFillslineWidthslineFillsfillIndexListpointShort(int *points, int nSegments, int *leftFills, int *rightFills, int *lineWidths, int *lineFills, int *fillIndexList, int pointsShort) { - int widthRun; - int widthLength; - int widthValue; - int i; - int leftRun; - int rightRun; - int leftLength; - int rightLength; - int lineFillRun; - int lineFillLength; - int leftValue; - int rightValue; - int lineFillValue; - int segs; - int y0; - int y1; - int y2; - int index; - int x0; - int x1; - int x2; - - if (nSegments == 0) { - return 0; - } - leftRun = rightRun = widthRun = lineFillRun = -1; - leftLength = rightLength = widthLength = lineFillLength = 1; - leftValue = rightValue = widthValue = lineFillValue = 0; - for (i = 1; i <= nSegments; i += 1) { - if ((leftLength -= 1) <= 0) { - leftRun += 1; - leftLength = ((unsigned) ((((int *) leftFills))[leftRun]) >> 16); - leftValue = ((((int *) leftFills))[leftRun]) & 65535; - if (!(leftValue == 0)) { - leftValue = fillIndexList[leftValue - 1]; - leftValue = transformColor(leftValue); - if (engineStopped) { - return null; - } - } - } - if ((rightLength -= 1) <= 0) { - rightRun += 1; - rightLength = ((unsigned) ((((int *) rightFills))[rightRun]) >> 16); - rightValue = ((((int *) rightFills))[rightRun]) & 65535; - if (!(rightValue == 0)) { - rightValue = fillIndexList[rightValue - 1]; - rightValue = transformColor(rightValue); - } - } - if ((widthLength -= 1) <= 0) { - widthRun += 1; - widthLength = ((unsigned) ((((int *) lineWidths))[widthRun]) >> 16); - widthValue = ((((int *) lineWidths))[widthRun]) & 65535; - if (!(widthValue == 0)) { - widthValue = transformWidth(widthValue); - } - } - if ((lineFillLength -= 1) <= 0) { - lineFillRun += 1; - lineFillLength = ((unsigned) ((((int *) lineFills))[lineFillRun]) >> 16); - lineFillValue = ((((int *) lineFills))[lineFillRun]) & 65535; - if (!(lineFillValue == 0)) { - lineFillValue = fillIndexList[lineFillValue - 1]; - } - } - /* begin loadCompressedSegment:from:short:leftFill:rightFill:lineWidth:lineColor: */ - if ((leftValue == rightValue) && ((widthValue == 0) || (lineFillValue == 0))) { - goto l1; - } - index = (i - 1) * 6; - if (pointsShort) { - x0 = (((short *) points))[index + 0]; - y0 = (((short *) points))[index + 1]; - x1 = (((short *) points))[index + 2]; - y1 = (((short *) points))[index + 3]; - x2 = (((short *) points))[index + 4]; - y2 = (((short *) points))[index + 5]; - } else { - x0 = (((int *) points))[index + 0]; - y0 = (((int *) points))[index + 1]; - x1 = (((int *) points))[index + 2]; - y1 = (((int *) points))[index + 3]; - x2 = (((int *) points))[index + 4]; - y2 = (((int *) points))[index + 5]; - } - if (((x0 == x1) && (y0 == y1)) || ((x1 == x2) && (y1 == y2))) { - if ((x0 == x2) && (y0 == y2)) { - goto l1; - } - (((int *) (workBuffer + 80)))[0] = x0; - (((int *) (workBuffer + 80)))[1] = y0; - (((int *) (workBuffer + 82)))[0] = x2; - (((int *) (workBuffer + 82)))[1] = y2; - /* begin transformPoints: */ - if (2 > 0) { - transformPoint(((int *) (workBuffer + 80))); - } - if (2 > 1) { - transformPoint(((int *) (workBuffer + 82))); - } - if (2 > 2) { - transformPoint(((int *) (workBuffer + 84))); - } - if (2 > 3) { - transformPoint(((int *) (workBuffer + 86))); - } - loadWideLinefromtolineFillleftFillrightFill(widthValue, ((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), lineFillValue, leftValue, rightValue); - goto l1; - } - (((int *) (workBuffer + 80)))[0] = x0; - (((int *) (workBuffer + 80)))[1] = y0; - (((int *) (workBuffer + 82)))[0] = x1; - (((int *) (workBuffer + 82)))[1] = y1; - (((int *) (workBuffer + 84)))[0] = x2; - (((int *) (workBuffer + 84)))[1] = y2; - /* begin transformPoints: */ - if (3 > 0) { - transformPoint(((int *) (workBuffer + 80))); - } - if (3 > 1) { - transformPoint(((int *) (workBuffer + 82))); - } - if (3 > 2) { - transformPoint(((int *) (workBuffer + 84))); - } - if (3 > 3) { - transformPoint(((int *) (workBuffer + 86))); - } - segs = loadAndSubdivideBezierFromviatoisWide(((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), ((int *) (workBuffer + 84)), (widthValue != 0) && (lineFillValue != 0)); - if (engineStopped) { - goto l1; - } - loadWideBezierlineFillleftFillrightFilln(widthValue, lineFillValue, leftValue, rightValue, segs); - l1: /* end loadCompressedSegment:from:short:leftFill:rightFill:lineWidth:lineColor: */; - if (engineStopped) { - return null; - } - } -} - -int loadEdgeStateFrom(int edgeOop) { - int edge; - int value; - int value1; - int value2; - int value3; - - edge = workBuffer[65]; - if ((slotSizeOf(edgeOop)) < 6) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin edgeXValueOf:put: */ - value2 = fetchIntegerofObject(1, edgeOop); - objBuffer[edge + 4] = value2; - /* begin edgeYValueOf:put: */ - value = fetchIntegerofObject(2, edgeOop); - objBuffer[edge + 5] = value; - /* begin edgeZValueOf:put: */ - value3 = fetchIntegerofObject(3, edgeOop); - objBuffer[edge + 6] = value3; - /* begin edgeNumLinesOf:put: */ - value1 = fetchIntegerofObject(4, edgeOop); - objBuffer[edge + 7] = value1; - return edge; -} - -int loadEdgeTransformFrom(int transformOop) { - float *transform; - int okay; - - workBuffer[16] = 0; - transform = ((float *) (workBuffer + 18)); - okay = loadTransformFromintolength(transformOop, transform, 6); - if (!successFlag) { - return null; - } - if (!(okay)) { - return 0; - } - workBuffer[16] = 1; - transform[2] = (((float) ((transform[2]) + (((double) (workBuffer[46]) ))))); - transform[5] = (((float) ((transform[5]) + (((double) (workBuffer[47]) ))))); - return 1; -} - -int loadFFTFrom(int fftOop) { - int oop; - int successValue; - int hdr; - int totalLength; - int fmt; - int fixedFields; - int sp; - int classFormat; - int class; - int sz; - int ccIndex; - int hdr1; - int totalLength1; - int fmt1; - int fixedFields1; - int sp1; - int classFormat1; - int class1; - int sz1; - int ccIndex1; - int hdr2; - int totalLength2; - int fmt2; - int fixedFields2; - int sp2; - int classFormat2; - int class2; - int sz2; - int ccIndex2; - int hdr3; - int totalLength3; - int fmt3; - int fixedFields3; - int sp3; - int classFormat3; - int class3; - int sz3; - int ccIndex3; - - /* begin success: */ - successValue = (slotSizeOf(fftOop)) >= 6; - successFlag = successValue && successFlag; - if (!successFlag) { - return 0; - } - nu = fetchIntegerofObject(0, fftOop); - fftSize = fetchIntegerofObject(1, fftOop); - oop = longAt(((((char *) fftOop)) + 4) + (2 << 2)); - /* begin stSizeOf: */ - hdr = longAt(oop); - fmt = (((unsigned) hdr) >> 8) & 15; - /* begin lengthOf:baseHeader:format: */ - if ((hdr & 3) == 0) { - sz = (longAt(oop - 8)) & 4294967292U; - } else { - sz = hdr & 252; - } - if (fmt < 8) { - totalLength = ((unsigned) (sz - 4)) >> 2; - goto l2; - } else { - totalLength = (sz - 4) - (fmt & 3); - goto l2; - } -l2: /* end lengthOf:baseHeader:format: */; - /* begin fixedFieldsOf:format:length: */ - if ((fmt > 4) || (fmt == 2)) { - fixedFields = 0; - goto l1; - } - if (fmt < 2) { - fixedFields = totalLength; - goto l1; - } - /* begin fetchClassOf: */ - if ((oop & 1)) { - class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l3; - } - ccIndex = (((unsigned) (longAt(oop))) >> 12) & 31; - if (ccIndex == 0) { - class = (longAt(oop - 4)) & 4294967292U; - goto l3; - } else { - class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l3; - } -l3: /* end fetchClassOf: */; - classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; - fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; -l1: /* end fixedFieldsOf:format:length: */; - if ((fmt == 3) && (isContextHeader(hdr))) { - /* begin fetchStackPointerOf: */ - sp = longAt(((((char *) oop)) + 4) + (2 << 2)); - if (!((sp & 1))) { - sinTableSize = 0; - goto l4; - } - sinTableSize = (sp >> 1); - goto l4; - } else { - sinTableSize = totalLength - fixedFields; - goto l4; - } -l4: /* end stSizeOf: */; - /* begin checkedFloatPtrOf: */ - /* begin success: */ - successFlag = (((((unsigned) (longAt(oop))) >> 8) & 15) == 6) && successFlag; - if (!successFlag) { - sinTable = 0; - goto l5; - } - sinTable = ((float *) (firstIndexableField(oop))); -l5: /* end checkedFloatPtrOf: */; - oop = longAt(((((char *) fftOop)) + 4) + (3 << 2)); - /* begin stSizeOf: */ - hdr1 = longAt(oop); - fmt1 = (((unsigned) hdr1) >> 8) & 15; - /* begin lengthOf:baseHeader:format: */ - if ((hdr1 & 3) == 0) { - sz1 = (longAt(oop - 8)) & 4294967292U; - } else { - sz1 = hdr1 & 252; - } - if (fmt1 < 8) { - totalLength1 = ((unsigned) (sz1 - 4)) >> 2; - goto l7; - } else { - totalLength1 = (sz1 - 4) - (fmt1 & 3); - goto l7; - } -l7: /* end lengthOf:baseHeader:format: */; - /* begin fixedFieldsOf:format:length: */ - if ((fmt1 > 4) || (fmt1 == 2)) { - fixedFields1 = 0; - goto l6; - } - if (fmt1 < 2) { - fixedFields1 = totalLength1; - goto l6; - } - /* begin fetchClassOf: */ - if ((oop & 1)) { - class1 = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l8; - } - ccIndex1 = (((unsigned) (longAt(oop))) >> 12) & 31; - if (ccIndex1 == 0) { - class1 = (longAt(oop - 4)) & 4294967292U; - goto l8; - } else { - class1 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex1 - 1) << 2)); - goto l8; - } -l8: /* end fetchClassOf: */; - classFormat1 = (longAt(((((char *) class1)) + 4) + (2 << 2))) - 1; - fixedFields1 = (((((unsigned) classFormat1) >> 11) & 192) + ((((unsigned) classFormat1) >> 2) & 63)) - 1; -l6: /* end fixedFieldsOf:format:length: */; - if ((fmt1 == 3) && (isContextHeader(hdr1))) { - /* begin fetchStackPointerOf: */ - sp1 = longAt(((((char *) oop)) + 4) + (2 << 2)); - if (!((sp1 & 1))) { - permTableSize = 0; - goto l9; - } - permTableSize = (sp1 >> 1); - goto l9; - } else { - permTableSize = totalLength1 - fixedFields1; - goto l9; - } -l9: /* end stSizeOf: */; - /* begin checkedWordPtrOf: */ - /* begin success: */ - successFlag = (((((unsigned) (longAt(oop))) >> 8) & 15) == 6) && successFlag; - permTable = ((unsigned int *) (firstIndexableField(oop))); - oop = longAt(((((char *) fftOop)) + 4) + (4 << 2)); - /* begin stSizeOf: */ - hdr2 = longAt(oop); - fmt2 = (((unsigned) hdr2) >> 8) & 15; - /* begin lengthOf:baseHeader:format: */ - if ((hdr2 & 3) == 0) { - sz2 = (longAt(oop - 8)) & 4294967292U; - } else { - sz2 = hdr2 & 252; - } - if (fmt2 < 8) { - totalLength2 = ((unsigned) (sz2 - 4)) >> 2; - goto l11; - } else { - totalLength2 = (sz2 - 4) - (fmt2 & 3); - goto l11; - } -l11: /* end lengthOf:baseHeader:format: */; - /* begin fixedFieldsOf:format:length: */ - if ((fmt2 > 4) || (fmt2 == 2)) { - fixedFields2 = 0; - goto l10; - } - if (fmt2 < 2) { - fixedFields2 = totalLength2; - goto l10; - } - /* begin fetchClassOf: */ - if ((oop & 1)) { - class2 = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l12; - } - ccIndex2 = (((unsigned) (longAt(oop))) >> 12) & 31; - if (ccIndex2 == 0) { - class2 = (longAt(oop - 4)) & 4294967292U; - goto l12; - } else { - class2 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex2 - 1) << 2)); - goto l12; - } -l12: /* end fetchClassOf: */; - classFormat2 = (longAt(((((char *) class2)) + 4) + (2 << 2))) - 1; - fixedFields2 = (((((unsigned) classFormat2) >> 11) & 192) + ((((unsigned) classFormat2) >> 2) & 63)) - 1; -l10: /* end fixedFieldsOf:format:length: */; - if ((fmt2 == 3) && (isContextHeader(hdr2))) { - /* begin fetchStackPointerOf: */ - sp2 = longAt(((((char *) oop)) + 4) + (2 << 2)); - if (!((sp2 & 1))) { - realDataSize = 0; - goto l13; - } - realDataSize = (sp2 >> 1); - goto l13; - } else { - realDataSize = totalLength2 - fixedFields2; - goto l13; - } -l13: /* end stSizeOf: */; - /* begin checkedFloatPtrOf: */ - /* begin success: */ - successFlag = (((((unsigned) (longAt(oop))) >> 8) & 15) == 6) && successFlag; - if (!successFlag) { - realData = 0; - goto l14; - } - realData = ((float *) (firstIndexableField(oop))); -l14: /* end checkedFloatPtrOf: */; - oop = longAt(((((char *) fftOop)) + 4) + (5 << 2)); - /* begin stSizeOf: */ - hdr3 = longAt(oop); - fmt3 = (((unsigned) hdr3) >> 8) & 15; - /* begin lengthOf:baseHeader:format: */ - if ((hdr3 & 3) == 0) { - sz3 = (longAt(oop - 8)) & 4294967292U; - } else { - sz3 = hdr3 & 252; - } - if (fmt3 < 8) { - totalLength3 = ((unsigned) (sz3 - 4)) >> 2; - goto l16; - } else { - totalLength3 = (sz3 - 4) - (fmt3 & 3); - goto l16; - } -l16: /* end lengthOf:baseHeader:format: */; - /* begin fixedFieldsOf:format:length: */ - if ((fmt3 > 4) || (fmt3 == 2)) { - fixedFields3 = 0; - goto l15; - } - if (fmt3 < 2) { - fixedFields3 = totalLength3; - goto l15; - } - /* begin fetchClassOf: */ - if ((oop & 1)) { - class3 = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l17; - } - ccIndex3 = (((unsigned) (longAt(oop))) >> 12) & 31; - if (ccIndex3 == 0) { - class3 = (longAt(oop - 4)) & 4294967292U; - goto l17; - } else { - class3 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex3 - 1) << 2)); - goto l17; - } -l17: /* end fetchClassOf: */; - classFormat3 = (longAt(((((char *) class3)) + 4) + (2 << 2))) - 1; - fixedFields3 = (((((unsigned) classFormat3) >> 11) & 192) + ((((unsigned) classFormat3) >> 2) & 63)) - 1; -l15: /* end fixedFieldsOf:format:length: */; - if ((fmt3 == 3) && (isContextHeader(hdr3))) { - /* begin fetchStackPointerOf: */ - sp3 = longAt(((((char *) oop)) + 4) + (2 << 2)); - if (!((sp3 & 1))) { - imagDataSize = 0; - goto l18; - } - imagDataSize = (sp3 >> 1); - goto l18; - } else { - imagDataSize = totalLength3 - fixedFields3; - goto l18; - } -l18: /* end stSizeOf: */; - /* begin checkedFloatPtrOf: */ - /* begin success: */ - successFlag = (((((unsigned) (longAt(oop))) >> 8) & 15) == 6) && successFlag; - if (!successFlag) { - imagData = 0; - goto l19; - } - imagData = ((float *) (firstIndexableField(oop))); -l19: /* end checkedFloatPtrOf: */; - /* begin success: */ - successFlag = ((((((1 << nu) == fftSize) && (((((int) fftSize >> 2)) + 1) == sinTableSize)) && (fftSize == realDataSize)) && (fftSize == imagDataSize)) && (realDataSize == imagDataSize)) && successFlag; - return (!successFlag) == 0; -} - -int loadFillOrientationfromalongnormalwidthheight(int fill, int *point1, int *point2, int *point3, int fillWidth, int fillHeight) { - int dsLength2; - int dtLength2; - int dirX; - int dirY; - int dsX; - int dsY; - int dtX; - int dtY; - int nrmX; - int nrmY; - - point2[0] = ((point2[0]) + (point1[0])); - point2[1] = ((point2[1]) + (point1[1])); - point3[0] = ((point3[0]) + (point1[0])); - point3[1] = ((point3[1]) + (point1[1])); - transformPoint(point1); - transformPoint(point2); - transformPoint(point3); - dirX = (point2[0]) - (point1[0]); - dirY = (point2[1]) - (point1[1]); - nrmX = (point3[0]) - (point1[0]); - nrmY = (point3[1]) - (point1[1]); - dsLength2 = (dirX * dirX) + (dirY * dirY); - if (dsLength2 > 0) { - dsX = ((int) ((((((double) dirX )) * (((double) fillWidth ))) * 65536.0) / (((double) dsLength2 ))) ); - dsY = ((int) ((((((double) dirY )) * (((double) fillWidth ))) * 65536.0) / (((double) dsLength2 ))) ); - } else { - dsX = 0; - dsY = 0; - } - dtLength2 = (nrmX * nrmX) + (nrmY * nrmY); - if (dtLength2 > 0) { - dtX = ((int) ((((((double) nrmX )) * (((double) fillHeight ))) * 65536.0) / (((double) dtLength2 ))) ); - dtY = ((int) ((((((double) nrmY )) * (((double) fillHeight ))) * 65536.0) / (((double) dtLength2 ))) ); - } else { - dtX = 0; - dtY = 0; - } - objBuffer[fill + 4] = (point1[0]); - objBuffer[fill + 5] = (point1[1]); - objBuffer[fill + 6] = dsX; - objBuffer[fill + 7] = dsY; - objBuffer[fill + 8] = dtX; - objBuffer[fill + 9] = dtY; -} - -double loadFloatOrIntFrom(int floatOrInt) { - if ((floatOrInt & 1)) { - return ((double) (floatOrInt >> 1)); - } - if ((fetchClassOfNonInt(floatOrInt)) == (longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)))) { - return floatValueOf(floatOrInt); - } - successFlag = 0; -} - -int loadFormsFrom(int arrayOop) { - int bmBits; - int bmWidth; - int bmDepth; - int bmBitsSize; - int ppw; - int i; - int formOop; - int bmRaster; - int bmHeight; - int header; - int sz; - - if (!((fetchClassOf(arrayOop)) == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2))))) { - return 0; - } - formArray = arrayOop; - for (i = 0; i <= ((slotSizeOf(formArray)) - 1); i += 1) { - formOop = longAt(((((char *) formArray)) + 4) + (i << 2)); - if ((formOop & 1)) { - return 0; - } - if (!(((((unsigned) (longAt(formOop))) >> 8) & 15) <= 4)) { - return 0; - } - if ((slotSizeOf(formOop)) < 5) { - return 0; - } - bmBits = longAt(((((char *) formOop)) + 4) + (0 << 2)); - if (!((fetchClassOf(bmBits)) == (longAt(((((char *) specialObjectsOop)) + 4) + (4 << 2))))) { - return 0; - } - /* begin slotSizeOf: */ - if ((bmBits & 1)) { - bmBitsSize = 0; - goto l1; - } - /* begin lengthOf: */ - header = longAt(bmBits); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(bmBits - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - bmBitsSize = ((unsigned) (sz - 4)) >> 2; - goto l2; - } else { - bmBitsSize = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l2; - } - l2: /* end lengthOf:baseHeader:format: */; - l1: /* end slotSizeOf: */; - bmWidth = fetchIntegerofObject(1, formOop); - bmHeight = fetchIntegerofObject(2, formOop); - bmDepth = fetchIntegerofObject(3, formOop); - if (!successFlag) { - return 0; - } - if (!((bmWidth >= 0) && (bmHeight >= 0))) { - return 0; - } - ppw = 32 / bmDepth; - bmRaster = (bmWidth + (ppw - 1)) / ppw; - if (!(bmBitsSize == (bmRaster * bmHeight))) { - return 0; - } - } - return 1; -} - -int loadGradientFillfromalongnormalisRadial(int rampOop, int *point1, int *point2, int *point3, int isRadial) { - int fill; - int rampWidth; - int header; - int sz; - - if (!((fetchClassOf(rampOop)) == (longAt(((((char *) specialObjectsOop)) + 4) + (4 << 2))))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin slotSizeOf: */ - if ((rampOop & 1)) { - rampWidth = 0; - goto l1; - } - /* begin lengthOf: */ - header = longAt(rampOop); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(rampOop - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - rampWidth = ((unsigned) (sz - 4)) >> 2; - goto l2; - } else { - rampWidth = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l2; - } -l2: /* end lengthOf:baseHeader:format: */; -l1: /* end slotSizeOf: */; - fill = allocateGradientFillrampWidthisRadial(firstIndexableField(rampOop), rampWidth, isRadial); - if (engineStopped) { - return null; - } - loadFillOrientationfromalongnormalwidthheight(fill, point1, point2, point3, rampWidth, rampWidth); - return fill; -} - -int loadLinefromtooffsetleftFillrightFill(int line, int *point1, int *point2, int yOffset, int leftFill, int rightFill) { - int yDir; - int *p2; - int *p1; - - if ((point1[1]) <= (point2[1])) { - p1 = point1; - p2 = point2; - yDir = 1; - } else { - p1 = point2; - p2 = point1; - yDir = -1; - } - objBuffer[line + 4] = (p1[0]); - objBuffer[line + 5] = ((p1[1]) - yOffset); - objBuffer[line + 6] = (workBuffer[113]); - objBuffer[line + 8] = leftFill; - objBuffer[line + 9] = rightFill; - objBuffer[line + 14] = (p2[0]); - objBuffer[line + 15] = ((p2[1]) - yOffset); - objBuffer[line + 11] = yDir; -} - -int loadOvallineFillleftFillrightFill(int lineWidth, int lineFill, int leftFill, int rightFill) { - int nSegments; - int h; - int w; - int i; - int cx; - int cy; - - w = ((int) (((((int *) (workBuffer + 82)))[0]) - ((((int *) (workBuffer + 80)))[0])) >> 1); - h = ((int) (((((int *) (workBuffer + 82)))[1]) - ((((int *) (workBuffer + 80)))[1])) >> 1); - cx = ((int) (((((int *) (workBuffer + 82)))[0]) + ((((int *) (workBuffer + 80)))[0])) >> 1); - cy = ((int) (((((int *) (workBuffer + 82)))[1]) + ((((int *) (workBuffer + 80)))[1])) >> 1); - for (i = 0; i <= 15; i += 1) { - loadOvalSegmentwhcxcy(i, w, h, cx, cy); - /* begin transformPoints: */ - if (3 > 0) { - transformPoint(((int *) (workBuffer + 80))); - } - if (3 > 1) { - transformPoint(((int *) (workBuffer + 82))); - } - if (3 > 2) { - transformPoint(((int *) (workBuffer + 84))); - } - if (3 > 3) { - transformPoint(((int *) (workBuffer + 86))); - } - nSegments = loadAndSubdivideBezierFromviatoisWide(((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), ((int *) (workBuffer + 84)), (lineWidth != 0) && (lineFill != 0)); - if (engineStopped) { - return null; - } - loadWideBezierlineFillleftFillrightFilln(lineWidth, lineFill, leftFill, rightFill, nSegments); - if (engineStopped) { - return null; - } - } -} - -int loadOvalSegmentwhcxcy(int seg, int w, int h, int cx, int cy) { - int y0; - int y2; - int y1; - int x0; - int x2; - int x1; - - x0 = ((int) ((((circleCosTable())[(seg * 2) + 0]) * (((double) w ))) + cx) ); - y0 = ((int) ((((circleSinTable())[(seg * 2) + 0]) * (((double) h ))) + cy) ); - (((int *) (workBuffer + 80)))[0] = x0; - (((int *) (workBuffer + 80)))[1] = y0; - x2 = ((int) ((((circleCosTable())[(seg * 2) + 2]) * (((double) w ))) + cx) ); - y2 = ((int) ((((circleSinTable())[(seg * 2) + 2]) * (((double) h ))) + cy) ); - (((int *) (workBuffer + 84)))[0] = x2; - (((int *) (workBuffer + 84)))[1] = y2; - x1 = ((int) ((((circleCosTable())[(seg * 2) + 1]) * (((double) w ))) + cx) ); - y1 = ((int) ((((circleSinTable())[(seg * 2) + 1]) * (((double) h ))) + cy) ); - x1 = (x1 * 2) - (((int) (x0 + x2) >> 1)); - y1 = (y1 * 2) - (((int) (y0 + y2) >> 1)); - (((int *) (workBuffer + 82)))[0] = x1; - (((int *) (workBuffer + 82)))[1] = y1; -} - -int loadPointfrom(int *pointArray, int pointOop) { - int value; - - if (!((fetchClassOf(pointOop)) == (longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2))))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - value = longAt(((((char *) pointOop)) + 4) + (0 << 2)); - if (!(((value & 1)) || ((fetchClassOf(value)) == (longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)))))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if ((value & 1)) { - pointArray[0] = ((value >> 1)); - } else { - pointArray[0] = (((int) (floatValueOf(value)) )); - } - value = longAt(((((char *) pointOop)) + 4) + (1 << 2)); - if (!(((value & 1)) || ((fetchClassOf(value)) == (longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)))))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if ((value & 1)) { - pointArray[1] = ((value >> 1)); - } else { - pointArray[1] = (((int) (floatValueOf(value)) )); - } -} - -int loadPolygonnPointsfilllineWidthlineFillpointsShort(int *points, int nPoints, int fillIndex, int lineWidth, int lineFill, int isShort) { - int y0; - int y1; - int i; - int x0; - int x1; - - if (isShort) { - x0 = (((short *) points))[0]; - y0 = (((short *) points))[1]; - } else { - x0 = (((int *) points))[0]; - y0 = (((int *) points))[1]; - } - for (i = 1; i <= (nPoints - 1); i += 1) { - if (isShort) { - x1 = (((short *) points))[i * 2]; - y1 = (((short *) points))[(i * 2) + 1]; - } else { - x1 = (((int *) points))[i * 2]; - y1 = (((int *) points))[(i * 2) + 1]; - } - (((int *) (workBuffer + 80)))[0] = x0; - (((int *) (workBuffer + 80)))[1] = y0; - (((int *) (workBuffer + 82)))[0] = x1; - (((int *) (workBuffer + 82)))[1] = y1; - /* begin transformPoints: */ - if (2 > 0) { - transformPoint(((int *) (workBuffer + 80))); - } - if (2 > 1) { - transformPoint(((int *) (workBuffer + 82))); - } - if (2 > 2) { - transformPoint(((int *) (workBuffer + 84))); - } - if (2 > 3) { - transformPoint(((int *) (workBuffer + 86))); - } - loadWideLinefromtolineFillleftFillrightFill(lineWidth, ((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), lineFill, fillIndex, 0); - if (engineStopped) { - return null; - } - x0 = x1; - y0 = y1; - } -} - -int loadRenderingState(void) { - int edgeOop; - int fillOop; - int state; - int oop; - int oop1; - int oop2; - - if (!(argumentCount == 2)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - fillOop = null; - goto l1; - } - fillOop = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - edgeOop = null; - goto l2; - } - edgeOop = oop1; -l2: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop2 = longAt(stackPointer - (2 * 4)); - if ((oop2 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - engine = null; - goto l3; - } - engine = oop2; -l3: /* end stackObjectValue: */; - if (!successFlag) { - return 0; - } - if (!(quickLoadEngineFrom(engine))) { - return 0; - } - if (!(loadSpanBufferFrom(longAt(((((char *) engine)) + 4) + (1 << 2))))) { - return 0; - } - if (!(loadBitBltFrom(longAt(((((char *) engine)) + 4) + (2 << 2))))) { - return 0; - } - if (!(loadFormsFrom(longAt(((((char *) engine)) + 4) + (3 << 2))))) { - return 0; - } - if ((slotSizeOf(edgeOop)) < 6) { - return 0; - } - if ((slotSizeOf(fillOop)) < 6) { - return 0; - } - state = workBuffer[2]; - if ((state == 2) || ((state == 4) || (state == 7))) { - return 0; - } - return 1; -} - -int loadScannerFromstartstopstringrightXstopArraydisplayFlag(int bbObj, int start, int stop, int string, int rightX, int stopArray, int displayFlag) { - int successValue; - int successValue1; - int successValue2; - - scanStart = start; - scanStop = stop; - scanString = string; - scanRightX = rightX; - scanStopArray = stopArray; - scanDisplayFlag = displayFlag; - /* begin success: */ - successValue1 = (((((unsigned) (longAt(scanStopArray))) >> 8) & 15) <= 4) && ((lengthOf(scanStopArray)) >= 1); - successFlag = successValue1 && successFlag; - scanXTable = longAt(((((char *) bbObj)) + 4) + (16 << 2)); - /* begin success: */ - successValue2 = (((((unsigned) (longAt(scanXTable))) >> 8) & 15) <= 4) && ((lengthOf(scanXTable)) >= 1); - successFlag = successValue2 && successFlag; - /* begin storeInteger:ofObject:withValue: */ - if ((0 ^ (0 << 1)) >= 0) { - longAtput(((((char *) bbObj)) + 4) + (6 << 2), ((0 << 1) | 1)); - } else { - /* begin primitiveFail */ - successFlag = 0; - } - /* begin storeInteger:ofObject:withValue: */ - if ((0 ^ (0 << 1)) >= 0) { - longAtput(((((char *) bbObj)) + 4) + (8 << 2), ((0 << 1) | 1)); - } else { - /* begin primitiveFail */ - successFlag = 0; - } - if (scanDisplayFlag) { - /* begin success: */ - successValue = loadBitBltFrom(bbObj); - successFlag = successValue && successFlag; - } else { - bitBltOop = bbObj; - destX = fetchIntegerOrTruncFloatofObject(4, bbObj); - } - return !(!successFlag); -} - -int loadShapenSegmentsfilllineWidthlineFillpointsShort(int *points, int nSegments, int fillIndex, int lineWidth, int lineFill, int pointsShort) { - int i; - int segs; - int y0; - int y1; - int y2; - int index; - int x0; - int x1; - int x2; - - for (i = 1; i <= nSegments; i += 1) { - /* begin loadCompressedSegment:from:short:leftFill:rightFill:lineWidth:lineColor: */ - if ((fillIndex == 0) && ((lineWidth == 0) || (lineFill == 0))) { - goto l1; - } - index = (i - 1) * 6; - if (pointsShort) { - x0 = (((short *) points))[index + 0]; - y0 = (((short *) points))[index + 1]; - x1 = (((short *) points))[index + 2]; - y1 = (((short *) points))[index + 3]; - x2 = (((short *) points))[index + 4]; - y2 = (((short *) points))[index + 5]; - } else { - x0 = (((int *) points))[index + 0]; - y0 = (((int *) points))[index + 1]; - x1 = (((int *) points))[index + 2]; - y1 = (((int *) points))[index + 3]; - x2 = (((int *) points))[index + 4]; - y2 = (((int *) points))[index + 5]; - } - if (((x0 == x1) && (y0 == y1)) || ((x1 == x2) && (y1 == y2))) { - if ((x0 == x2) && (y0 == y2)) { - goto l1; - } - (((int *) (workBuffer + 80)))[0] = x0; - (((int *) (workBuffer + 80)))[1] = y0; - (((int *) (workBuffer + 82)))[0] = x2; - (((int *) (workBuffer + 82)))[1] = y2; - /* begin transformPoints: */ - if (2 > 0) { - transformPoint(((int *) (workBuffer + 80))); - } - if (2 > 1) { - transformPoint(((int *) (workBuffer + 82))); - } - if (2 > 2) { - transformPoint(((int *) (workBuffer + 84))); - } - if (2 > 3) { - transformPoint(((int *) (workBuffer + 86))); - } - loadWideLinefromtolineFillleftFillrightFill(lineWidth, ((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), lineFill, fillIndex, 0); - goto l1; - } - (((int *) (workBuffer + 80)))[0] = x0; - (((int *) (workBuffer + 80)))[1] = y0; - (((int *) (workBuffer + 82)))[0] = x1; - (((int *) (workBuffer + 82)))[1] = y1; - (((int *) (workBuffer + 84)))[0] = x2; - (((int *) (workBuffer + 84)))[1] = y2; - /* begin transformPoints: */ - if (3 > 0) { - transformPoint(((int *) (workBuffer + 80))); - } - if (3 > 1) { - transformPoint(((int *) (workBuffer + 82))); - } - if (3 > 2) { - transformPoint(((int *) (workBuffer + 84))); - } - if (3 > 3) { - transformPoint(((int *) (workBuffer + 86))); - } - segs = loadAndSubdivideBezierFromviatoisWide(((int *) (workBuffer + 80)), ((int *) (workBuffer + 82)), ((int *) (workBuffer + 84)), (lineWidth != 0) && (lineFill != 0)); - if (engineStopped) { - goto l1; - } - loadWideBezierlineFillleftFillrightFilln(lineWidth, lineFill, fillIndex, 0, segs); - l1: /* end loadCompressedSegment:from:short:leftFill:rightFill:lineWidth:lineColor: */; - if (engineStopped) { - return null; - } - } -} - -int loadSpanBufferFrom(int spanOop) { - int value; - - if (!((fetchClassOf(spanOop)) == (longAt(((((char *) specialObjectsOop)) + 4) + (4 << 2))))) { - return 0; - } - spanBuffer = firstIndexableField(spanOop); - /* begin spanSizePut: */ - value = (slotSizeOf(spanOop)) - 1; - workBuffer[33] = value; - return 1; -} - -int loadTransformFromintolength(int transformOop, float *destPtr, int n) { - if (transformOop == nilObj) { - return 0; - } - if ((transformOop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!((slotSizeOf(transformOop)) == n)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (((((unsigned) (longAt(transformOop))) >> 8) & 15) == 6) { - loadWordTransformFromintolength(transformOop, destPtr, n); - } else { - loadArrayTransformFromintolength(transformOop, destPtr, n); - } - return 1; -} - -int loadWideBezierlineFillleftFillrightFilln(int lineWidth, int lineFill, int leftFill, int rightFill, int nSegments) { - int index; - int offset; - int wide; - int bezier; - int bezier1; - int bezier2; - - if ((lineWidth == 0) || (lineFill == 0)) { - wide = 0; - offset = 0; - } else { - wide = 1; - offset = ((int) lineWidth >> 1); - } - index = nSegments * 6; - while (index > 0) { - if (wide) { - /* begin allocateWideBezier */ - if (!(allocateObjEntry(28))) { - bezier = 0; - goto l1; - } - bezier1 = objUsed; - objUsed = bezier1 + 28; - objBuffer[bezier1 + 0] = 7; - objBuffer[bezier1 + 2] = 0; - objBuffer[bezier1 + 1] = 28; - bezier = bezier1; - l1: /* end allocateWideBezier */; - } else { - /* begin allocateBezier */ - if (!(allocateObjEntry(16))) { - bezier = 0; - goto l2; - } - bezier2 = objUsed; - objUsed = bezier2 + 16; - objBuffer[bezier2 + 0] = 6; - objBuffer[bezier2 + 2] = 0; - objBuffer[bezier2 + 1] = 16; - bezier = bezier2; - l2: /* end allocateBezier */; - } - if (engineStopped) { - return 0; - } - loadBeziersegmentleftFillrightFilloffset(bezier, index, leftFill, rightFill, offset); - if (wide) { - objBuffer[bezier + 16] = lineFill; - objBuffer[bezier + 17] = lineWidth; - objBuffer[bezier + 20] = lineWidth; - } - index -= 6; - } - /* begin wbStackClear */ - workBuffer[10] = (workBuffer[1]); -} - -int loadWideLinefromtolineFillleftFillrightFill(int lineWidth, int *p1, int *p2, int lineFill, int leftFill, int rightFill) { - int offset; - int line; - int line1; - int line2; - - if ((lineWidth == 0) || (lineFill == 0)) { - /* begin allocateLine */ - if (!(allocateObjEntry(16))) { - line = 0; - goto l1; - } - line1 = objUsed; - objUsed = line1 + 16; - objBuffer[line1 + 0] = 4; - objBuffer[line1 + 2] = 0; - objBuffer[line1 + 1] = 16; - line = line1; - l1: /* end allocateLine */; - offset = 0; - } else { - /* begin allocateWideLine */ - if (!(allocateObjEntry(21))) { - line = 0; - goto l2; - } - line2 = objUsed; - objUsed = line2 + 21; - objBuffer[line2 + 0] = 5; - objBuffer[line2 + 2] = 0; - objBuffer[line2 + 1] = 21; - line = line2; - l2: /* end allocateWideLine */; - offset = ((int) lineWidth >> 1); - } - if (engineStopped) { - return 0; - } - loadLinefromtooffsetleftFillrightFill(line, p1, p2, offset, leftFill, rightFill); - if ((((objBuffer[line + 0]) & 65535) & 1) != 0) { - objBuffer[line + 16] = lineFill; - objBuffer[line + 17] = lineWidth; - objBuffer[line + 20] = lineWidth; - } -} - -int loadWordTransformFromintolength(int transformOop, float *destPtr, int n) { - int i; - float *srcPtr; - - srcPtr = ((float *) (firstIndexableField(transformOop))); - for (i = 0; i <= (n - 1); i += 1) { - destPtr[i] = (srcPtr[i]); - } -} - -int loadWorkBufferFrom(int wbOop) { - if ((wbOop & 1)) { - return 0; - } - if (!(((((unsigned) (longAt(wbOop))) >> 8) & 15) == 6)) { - return 0; - } - if ((slotSizeOf(wbOop)) < 256) { - return 0; - } - workBuffer = firstIndexableField(wbOop); - if (!((workBuffer[0]) == 1097753705)) { - return 0; - } - if (!((workBuffer[1]) == (slotSizeOf(wbOop)))) { - return 0; - } - if (!((workBuffer[8]) == 128)) { - return 0; - } - objBuffer = workBuffer + (workBuffer[8]); - getBuffer = objBuffer + (workBuffer[9]); - aetBuffer = getBuffer + (workBuffer[12]); - if ((((128 + (workBuffer[9])) + (workBuffer[12])) + (workBuffer[14])) > (workBuffer[1])) { - return 0; - } - return 1; -} - -int lookupMethodInClass(int class) { - int dictionary; - int currentClass; - int found; - int rclass; - int oop; - int oop1; - int methodArray; - int mask; - int wrapAround; - int nextSelector; - int index; - int length; - int primBits; - int sz; - int header; - - currentClass = class; - while (currentClass != nilObj) { - dictionary = longAt(((((char *) currentClass)) + 4) + (1 << 2)); - if (dictionary == nilObj) { - /* begin pushRemappableOop: */ - remapBuffer[remapBufferCount += 1] = currentClass; - createActualMessageTo(class); - /* begin popRemappableOop */ - oop = remapBuffer[remapBufferCount]; - remapBufferCount -= 1; - currentClass = oop; - messageSelector = longAt(((((char *) specialObjectsOop)) + 4) + (34 << 2)); - return lookupMethodInClass(longAt(((((char *) currentClass)) + 4) + (0 << 2))); - } - /* begin lookupMethodInDictionary: */ - /* begin fetchWordLengthOf: */ - /* begin sizeBitsOf: */ - header = longAt(dictionary); - if ((header & 3) == 0) { - sz = (longAt(dictionary - 8)) & 4294967292U; - goto l2; - } else { - sz = header & 252; - goto l2; - } - l2: /* end sizeBitsOf: */; - length = ((unsigned) (sz - 4)) >> 2; - mask = (length - 2) - 1; - if ((messageSelector & 1)) { - index = (mask & ((messageSelector >> 1))) + 2; - } else { - index = (mask & ((((unsigned) (longAt(messageSelector))) >> 17) & 4095)) + 2; - } - wrapAround = 0; - while (1) { - nextSelector = longAt(((((char *) dictionary)) + 4) + (index << 2)); - if (nextSelector == nilObj) { - found = 0; - goto l3; - } - if (nextSelector == messageSelector) { - methodArray = longAt(((((char *) dictionary)) + 4) + (1 << 2)); - newMethod = longAt(((((char *) methodArray)) + 4) + ((index - 2) << 2)); - /* begin primitiveIndexOf: */ - primBits = (((unsigned) (longAt(((((char *) newMethod)) + 4) + (0 << 2)))) >> 1) & 805306879; - if (primBits > 511) { - primitiveIndex = (primBits & 511) + (((unsigned) primBits) >> 19); - goto l1; - } else { - primitiveIndex = primBits; - goto l1; - } - l1: /* end primitiveIndexOf: */; - if (primitiveIndex > 700) { - primitiveIndex = 0; - } - found = 1; - goto l3; - } - index += 1; - if (index == length) { - if (wrapAround) { - found = 0; - goto l3; - } - wrapAround = 1; - index = 2; - } - } - l3: /* end lookupMethodInDictionary: */; - if (found) { - return currentClass; - } - currentClass = longAt(((((char *) currentClass)) + 4) + (0 << 2)); - } - if (messageSelector == (longAt(((((char *) specialObjectsOop)) + 4) + (20 << 2)))) { - error("Recursive not understood error encountered"); - } - /* begin pushRemappableOop: */ - remapBuffer[remapBufferCount += 1] = class; - createActualMessageTo(class); - /* begin popRemappableOop */ - oop1 = remapBuffer[remapBufferCount]; - remapBufferCount -= 1; - rclass = oop1; - messageSelector = longAt(((((char *) specialObjectsOop)) + 4) + (20 << 2)); - return lookupMethodInClass(rclass); -} - -int lowestFreeAfter(int chunk) { - int oopHeader; - int oop; - int oopHeaderType; - int oopSize; - int extra; - int extra1; - int type; - int extra2; - int type1; - int extra3; - - /* begin oopFromChunk: */ - /* begin extraHeaderBytes: */ - type1 = (longAt(chunk)) & 3; - if (type1 > 1) { - extra3 = 0; - } else { - if (type1 == 1) { - extra3 = 4; - } else { - extra3 = 8; - } - } - extra1 = extra3; - oop = chunk + extra1; - while (oop < endOfMemory) { - oopHeader = longAt(oop); - oopHeaderType = oopHeader & 3; - if (oopHeaderType == 2) { - return oop; - } else { - if (oopHeaderType == 0) { - oopSize = (longAt(oop - 8)) & 4294967292U; - } else { - oopSize = oopHeader & 252; - } - } - /* begin oopFromChunk: */ - /* begin extraHeaderBytes: */ - type = (longAt(oop + oopSize)) & 3; - if (type > 1) { - extra2 = 0; - } else { - if (type == 1) { - extra2 = 4; - } else { - extra2 = 8; - } - } - extra = extra2; - oop = (oop + oopSize) + extra; - } - error("expected to find at least one free object"); -} - -EXPORT(int) m23PrimitiveComposeMatrix(void) { - int result; - float * m1; - float * m2; - float * m3; - int sp; - int matrix; - int matrix1; - int matrix2; - int oop; - int oop1; - - /* begin loadArgumentMatrix: */ - matrix = result = stackObjectValue(0); - if (!successFlag) { - m3 = null; - goto l1; - } - if (!((((((unsigned) (longAt(matrix))) >> 8) & 15) == 6) && ((slotSizeOf(matrix)) == 6))) { - /* begin primitiveFail */ - successFlag = 0; - m3 = null; - goto l1; - } - m3 = ((float *) (firstIndexableField(matrix))); -l1: /* end loadArgumentMatrix: */; - /* begin loadArgumentMatrix: */ - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (1 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - matrix1 = null; - goto l4; - } - matrix1 = oop; -l4: /* end stackObjectValue: */; - if (!successFlag) { - m2 = null; - goto l2; - } - if (!((((((unsigned) (longAt(matrix1))) >> 8) & 15) == 6) && ((slotSizeOf(matrix1)) == 6))) { - /* begin primitiveFail */ - successFlag = 0; - m2 = null; - goto l2; - } - m2 = ((float *) (firstIndexableField(matrix1))); -l2: /* end loadArgumentMatrix: */; - /* begin loadArgumentMatrix: */ - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (2 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - matrix2 = null; - goto l5; - } - matrix2 = oop1; -l5: /* end stackObjectValue: */; - if (!successFlag) { - m1 = null; - goto l3; - } - if (!((((((unsigned) (longAt(matrix2))) >> 8) & 15) == 6) && ((slotSizeOf(matrix2)) == 6))) { - /* begin primitiveFail */ - successFlag = 0; - m1 = null; - goto l3; - } - m1 = ((float *) (firstIndexableField(matrix2))); -l3: /* end loadArgumentMatrix: */; - if (!successFlag) { - return null; - } - matrix2x3ComposeMatrixwithinto(m1, m2, m3); - /* begin pop: */ - stackPointer -= 3 * 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, result); - stackPointer = sp; -} - -EXPORT(int) m23PrimitiveInvertPoint(void) { - float * matrix; - int matrix1; - int object; - int sp; - int xValue; - int yValue; - int pointResult; - int oop; - - loadArgumentPoint(stackObjectValue(0)); - /* begin loadArgumentMatrix: */ - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (1 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - matrix1 = null; - goto l3; - } - matrix1 = oop; -l3: /* end stackObjectValue: */; - if (!successFlag) { - matrix = null; - goto l1; - } - if (!((((((unsigned) (longAt(matrix1))) >> 8) & 15) == 6) && ((slotSizeOf(matrix1)) == 6))) { - /* begin primitiveFail */ - successFlag = 0; - matrix = null; - goto l1; - } - matrix = ((float *) (firstIndexableField(matrix1))); -l1: /* end loadArgumentMatrix: */; - if (!successFlag) { - return null; - } - matrix2x3InvertPoint(matrix); - if (!(!successFlag)) { - /* begin roundAndStoreResultPoint: */ - m23ResultX += 0.5; - m23ResultY += 0.5; - if (!((m23ResultX >= (((double) -1073741824 ))) && (m23ResultX <= (((double) 1073741823 ))))) { - /* begin primitiveFail */ - successFlag = 0; - goto l2; - } - if (!((m23ResultY >= (((double) -1073741824 ))) && (m23ResultX <= (((double) 1073741823 ))))) { - /* begin primitiveFail */ - successFlag = 0; - goto l2; - } - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin push: */ - /* begin makePointwithxValue:yValue: */ - xValue = ((int) m23ResultX ); - yValue = ((int) m23ResultY ); - pointResult = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2)), 12, nilObj); - /* begin storePointer:ofObject:withValue: */ - if (pointResult < youngStart) { - possibleRootStoreIntovalue(pointResult, ((xValue << 1) | 1)); - } - longAtput(((((char *) pointResult)) + 4) + (0 << 2), ((xValue << 1) | 1)); - /* begin storePointer:ofObject:withValue: */ - if (pointResult < youngStart) { - possibleRootStoreIntovalue(pointResult, ((yValue << 1) | 1)); - } - longAtput(((((char *) pointResult)) + 4) + (1 << 2), ((yValue << 1) | 1)); - object = pointResult; - longAtput(sp = stackPointer + 4, object); - stackPointer = sp; - l2: /* end roundAndStoreResultPoint: */; - } -} - -EXPORT(int) m23PrimitiveInvertRectInto(void) { - double originX; - double originY; - float * matrix; - double cornerX; - double cornerY; - double minX; - int srcOop; - int dstOop; - double minY; - double maxX; - double maxY; - int sp; - int oop; - int oop1; - int matrix1; - int oop2; - - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - dstOop = null; - goto l1; - } - dstOop = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - srcOop = null; - goto l2; - } - srcOop = oop1; -l2: /* end stackObjectValue: */; - /* begin loadArgumentMatrix: */ - /* begin stackObjectValue: */ - oop2 = longAt(stackPointer - (2 * 4)); - if ((oop2 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - matrix1 = null; - goto l4; - } - matrix1 = oop2; -l4: /* end stackObjectValue: */; - if (!successFlag) { - matrix = null; - goto l3; - } - if (!((((((unsigned) (longAt(matrix1))) >> 8) & 15) == 6) && ((slotSizeOf(matrix1)) == 6))) { - /* begin primitiveFail */ - successFlag = 0; - matrix = null; - goto l3; - } - matrix = ((float *) (firstIndexableField(matrix1))); -l3: /* end loadArgumentMatrix: */; - if (!successFlag) { - return null; - } - if (!((fetchClassOf(srcOop)) == (fetchClassOf(dstOop)))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(((((unsigned) (longAt(srcOop))) >> 8) & 15) <= 4)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!((slotSizeOf(srcOop)) == 2)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - loadArgumentPoint(longAt(((((char *) srcOop)) + 4) + (0 << 2))); - if (!successFlag) { - return null; - } - originX = m23ArgX; - originY = m23ArgY; - matrix2x3InvertPoint(matrix); - minX = maxX = m23ResultX; - minY = maxY = m23ResultY; - loadArgumentPoint(longAt(((((char *) srcOop)) + 4) + (1 << 2))); - if (!successFlag) { - return null; - } - cornerX = m23ArgX; - cornerY = m23ArgY; - matrix2x3InvertPoint(matrix); - minX = ((minX < m23ResultX) ? minX : m23ResultX); - maxX = ((maxX < m23ResultX) ? m23ResultX : maxX); - minY = ((minY < m23ResultY) ? minY : m23ResultY); - maxY = ((maxY < m23ResultY) ? m23ResultY : maxY); - m23ArgX = cornerX; - m23ArgY = originY; - matrix2x3InvertPoint(matrix); - minX = ((minX < m23ResultX) ? minX : m23ResultX); - maxX = ((maxX < m23ResultX) ? m23ResultX : maxX); - minY = ((minY < m23ResultY) ? minY : m23ResultY); - maxY = ((maxY < m23ResultY) ? m23ResultY : maxY); - m23ArgX = originX; - m23ArgY = cornerY; - matrix2x3InvertPoint(matrix); - minX = ((minX < m23ResultX) ? minX : m23ResultX); - maxX = ((maxX < m23ResultX) ? m23ResultX : maxX); - minY = ((minY < m23ResultY) ? minY : m23ResultY); - maxY = ((maxY < m23ResultY) ? m23ResultY : maxY); - if (!(!successFlag)) { - dstOop = roundAndStoreResultRectx0y0x1y1(dstOop, minX, minY, maxX, maxY); - } - if (!(!successFlag)) { - /* begin pop: */ - stackPointer -= 3 * 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, dstOop); - stackPointer = sp; - } -} - -EXPORT(int) m23PrimitiveIsIdentity(void) { - float * matrix; - int sp; - int sp1; - int matrix1; - int oop; - - /* begin loadArgumentMatrix: */ - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - matrix1 = null; - goto l2; - } - matrix1 = oop; -l2: /* end stackObjectValue: */; - if (!successFlag) { - matrix = null; - goto l1; - } - if (!((((((unsigned) (longAt(matrix1))) >> 8) & 15) == 6) && ((slotSizeOf(matrix1)) == 6))) { - /* begin primitiveFail */ - successFlag = 0; - matrix = null; - goto l1; - } - matrix = ((float *) (firstIndexableField(matrix1))); -l1: /* end loadArgumentMatrix: */; - if (!successFlag) { - return null; - } - /* begin pop: */ - stackPointer -= 1 * 4; - /* begin pushBool: */ - if (((((((matrix[0]) == (((float) 1.0))) && ((matrix[1]) == (((float) 0.0)))) && ((matrix[2]) == (((float) 0.0)))) && ((matrix[3]) == (((float) 0.0)))) && ((matrix[4]) == (((float) 1.0)))) && ((matrix[5]) == (((float) 0.0)))) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } -} - -EXPORT(int) m23PrimitiveIsPureTranslation(void) { - float * matrix; - int sp; - int sp1; - int matrix1; - int oop; - - /* begin loadArgumentMatrix: */ - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - matrix1 = null; - goto l2; - } - matrix1 = oop; -l2: /* end stackObjectValue: */; - if (!successFlag) { - matrix = null; - goto l1; - } - if (!((((((unsigned) (longAt(matrix1))) >> 8) & 15) == 6) && ((slotSizeOf(matrix1)) == 6))) { - /* begin primitiveFail */ - successFlag = 0; - matrix = null; - goto l1; - } - matrix = ((float *) (firstIndexableField(matrix1))); -l1: /* end loadArgumentMatrix: */; - if (!successFlag) { - return null; - } - /* begin pop: */ - stackPointer -= 1 * 4; - /* begin pushBool: */ - if (((((matrix[0]) == (((float) 1.0))) && ((matrix[1]) == (((float) 0.0)))) && ((matrix[3]) == (((float) 0.0)))) && ((matrix[4]) == (((float) 1.0)))) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } -} - -EXPORT(int) m23PrimitiveTransformPoint(void) { - float * matrix; - int matrix1; - int object; - int sp; - int xValue; - int yValue; - int pointResult; - int oop; - - loadArgumentPoint(stackObjectValue(0)); - /* begin loadArgumentMatrix: */ - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (1 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - matrix1 = null; - goto l3; - } - matrix1 = oop; -l3: /* end stackObjectValue: */; - if (!successFlag) { - matrix = null; - goto l1; - } - if (!((((((unsigned) (longAt(matrix1))) >> 8) & 15) == 6) && ((slotSizeOf(matrix1)) == 6))) { - /* begin primitiveFail */ - successFlag = 0; - matrix = null; - goto l1; - } - matrix = ((float *) (firstIndexableField(matrix1))); -l1: /* end loadArgumentMatrix: */; - if (!successFlag) { - return null; - } - matrix2x3TransformPoint(matrix); - /* begin roundAndStoreResultPoint: */ - m23ResultX += 0.5; - m23ResultY += 0.5; - if (!((m23ResultX >= (((double) -1073741824 ))) && (m23ResultX <= (((double) 1073741823 ))))) { - /* begin primitiveFail */ - successFlag = 0; - goto l2; - } - if (!((m23ResultY >= (((double) -1073741824 ))) && (m23ResultX <= (((double) 1073741823 ))))) { - /* begin primitiveFail */ - successFlag = 0; - goto l2; - } - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin push: */ - /* begin makePointwithxValue:yValue: */ - xValue = ((int) m23ResultX ); - yValue = ((int) m23ResultY ); - pointResult = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2)), 12, nilObj); - /* begin storePointer:ofObject:withValue: */ - if (pointResult < youngStart) { - possibleRootStoreIntovalue(pointResult, ((xValue << 1) | 1)); - } - longAtput(((((char *) pointResult)) + 4) + (0 << 2), ((xValue << 1) | 1)); - /* begin storePointer:ofObject:withValue: */ - if (pointResult < youngStart) { - possibleRootStoreIntovalue(pointResult, ((yValue << 1) | 1)); - } - longAtput(((((char *) pointResult)) + 4) + (1 << 2), ((yValue << 1) | 1)); - object = pointResult; - longAtput(sp = stackPointer + 4, object); - stackPointer = sp; -l2: /* end roundAndStoreResultPoint: */; -} - -EXPORT(int) m23PrimitiveTransformRectInto(void) { - double originX; - double originY; - float * matrix; - double cornerX; - double cornerY; - double minX; - int srcOop; - int dstOop; - double minY; - double maxX; - double maxY; - int sp; - int oop; - int oop1; - int matrix1; - int oop2; - - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - dstOop = null; - goto l1; - } - dstOop = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - srcOop = null; - goto l2; - } - srcOop = oop1; -l2: /* end stackObjectValue: */; - /* begin loadArgumentMatrix: */ - /* begin stackObjectValue: */ - oop2 = longAt(stackPointer - (2 * 4)); - if ((oop2 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - matrix1 = null; - goto l4; - } - matrix1 = oop2; -l4: /* end stackObjectValue: */; - if (!successFlag) { - matrix = null; - goto l3; - } - if (!((((((unsigned) (longAt(matrix1))) >> 8) & 15) == 6) && ((slotSizeOf(matrix1)) == 6))) { - /* begin primitiveFail */ - successFlag = 0; - matrix = null; - goto l3; - } - matrix = ((float *) (firstIndexableField(matrix1))); -l3: /* end loadArgumentMatrix: */; - if (!successFlag) { - return null; - } - if (!((fetchClassOf(srcOop)) == (fetchClassOf(dstOop)))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!(((((unsigned) (longAt(srcOop))) >> 8) & 15) <= 4)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!((slotSizeOf(srcOop)) == 2)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - loadArgumentPoint(longAt(((((char *) srcOop)) + 4) + (0 << 2))); - if (!successFlag) { - return null; - } - originX = m23ArgX; - originY = m23ArgY; - matrix2x3TransformPoint(matrix); - minX = maxX = m23ResultX; - minY = maxY = m23ResultY; - loadArgumentPoint(longAt(((((char *) srcOop)) + 4) + (1 << 2))); - if (!successFlag) { - return null; - } - cornerX = m23ArgX; - cornerY = m23ArgY; - matrix2x3TransformPoint(matrix); - minX = ((minX < m23ResultX) ? minX : m23ResultX); - maxX = ((maxX < m23ResultX) ? m23ResultX : maxX); - minY = ((minY < m23ResultY) ? minY : m23ResultY); - maxY = ((maxY < m23ResultY) ? m23ResultY : maxY); - m23ArgX = cornerX; - m23ArgY = originY; - matrix2x3TransformPoint(matrix); - minX = ((minX < m23ResultX) ? minX : m23ResultX); - maxX = ((maxX < m23ResultX) ? m23ResultX : maxX); - minY = ((minY < m23ResultY) ? minY : m23ResultY); - maxY = ((maxY < m23ResultY) ? m23ResultY : maxY); - m23ArgX = originX; - m23ArgY = cornerY; - matrix2x3TransformPoint(matrix); - minX = ((minX < m23ResultX) ? minX : m23ResultX); - maxX = ((maxX < m23ResultX) ? m23ResultX : maxX); - minY = ((minY < m23ResultY) ? minY : m23ResultY); - maxY = ((maxY < m23ResultY) ? m23ResultY : maxY); - dstOop = roundAndStoreResultRectx0y0x1y1(dstOop, minX, minY, maxX, maxY); - if (!(!successFlag)) { - /* begin pop: */ - stackPointer -= 3 * 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, dstOop); - stackPointer = sp; - } -} - -int makeDirEntryNamesizecreateDatemodDateisDirfileSize(char *entryName, int entryNameSize, int createDate, int modifiedDate, int dirFlag, int fileSize) { - int modDateOop; - int i; - int nameString; - int createDateOop; - int results; - int valuePointer; - int valuePointer1; - int oop; - int oop1; - int oop2; - int oop3; - int oop4; - int oop5; - int oop6; - int oop7; - - /* begin pushRemappableOop: */ - oop = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)), 5); - remapBuffer[remapBufferCount += 1] = oop; - /* begin pushRemappableOop: */ - oop1 = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)), entryNameSize); - remapBuffer[remapBufferCount += 1] = oop1; - /* begin pushRemappableOop: */ - oop2 = positive32BitIntegerFor(createDate); - remapBuffer[remapBufferCount += 1] = oop2; - /* begin pushRemappableOop: */ - oop3 = positive32BitIntegerFor(modifiedDate); - remapBuffer[remapBufferCount += 1] = oop3; - /* begin popRemappableOop */ - oop4 = remapBuffer[remapBufferCount]; - remapBufferCount -= 1; - modDateOop = oop4; - /* begin popRemappableOop */ - oop5 = remapBuffer[remapBufferCount]; - remapBufferCount -= 1; - createDateOop = oop5; - /* begin popRemappableOop */ - oop6 = remapBuffer[remapBufferCount]; - remapBufferCount -= 1; - nameString = oop6; - /* begin popRemappableOop */ - oop7 = remapBuffer[remapBufferCount]; - remapBufferCount -= 1; - results = oop7; - for (i = 0; i <= (entryNameSize - 1); i += 1) { - byteAtput(((((char *) nameString)) + 4) + i, entryName[i]); - } - /* begin storePointer:ofObject:withValue: */ - if (results < youngStart) { - possibleRootStoreIntovalue(results, nameString); - } - longAtput(((((char *) results)) + 4) + (0 << 2), nameString); - /* begin storePointer:ofObject:withValue: */ - if (results < youngStart) { - possibleRootStoreIntovalue(results, createDateOop); - } - longAtput(((((char *) results)) + 4) + (1 << 2), createDateOop); - /* begin storePointer:ofObject:withValue: */ - if (results < youngStart) { - possibleRootStoreIntovalue(results, modDateOop); - } - longAtput(((((char *) results)) + 4) + (2 << 2), modDateOop); - if (dirFlag) { - /* begin storePointer:ofObject:withValue: */ - valuePointer = trueObj; - if (results < youngStart) { - possibleRootStoreIntovalue(results, valuePointer); - } - longAtput(((((char *) results)) + 4) + (3 << 2), valuePointer); - } else { - /* begin storePointer:ofObject:withValue: */ - valuePointer1 = falseObj; - if (results < youngStart) { - possibleRootStoreIntovalue(results, valuePointer1); - } - longAtput(((((char *) results)) + 4) + (3 << 2), valuePointer1); - } - /* begin storePointer:ofObject:withValue: */ - if (results < youngStart) { - possibleRootStoreIntovalue(results, ((fileSize << 1) | 1)); - } - longAtput(((((char *) results)) + 4) + (4 << 2), ((fileSize << 1) | 1)); - return results; -} - -int makePointwithxValueyValue(int xValue, int yValue) { - int pointResult; - - pointResult = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2)), 12, nilObj); - /* begin storePointer:ofObject:withValue: */ - if (pointResult < youngStart) { - possibleRootStoreIntovalue(pointResult, ((xValue << 1) | 1)); - } - longAtput(((((char *) pointResult)) + 4) + (0 << 2), ((xValue << 1) | 1)); - /* begin storePointer:ofObject:withValue: */ - if (pointResult < youngStart) { - possibleRootStoreIntovalue(pointResult, ((yValue << 1) | 1)); - } - longAtput(((((char *) pointResult)) + 4) + (1 << 2), ((yValue << 1) | 1)); - return pointResult; -} - -int mapPointersInObjectsFromto(int memStart, int memEnd) { - int oop; - int i; - int i2; - int oop1; - int i1; - int extra; - int type; - int extra1; - int fwdBlock; - int fieldOffset; - int fieldOop; - int newOop; - int fwdBlock1; - int header; - int header1; - int header2; - int methodHeader; - int size; - int fwdBlock2; - int fmt; - int header3; - int newClassOop; - int fwdBlock3; - int classHeader; - int classOop; - int newClassHeader; - int fwdBlock11; - int header4; - int header11; - int header21; - int fwdBlock4; - int fieldOffset1; - int fieldOop1; - int newOop1; - int fwdBlock12; - int header5; - int header12; - int header22; - int methodHeader1; - int size1; - int fwdBlock21; - int fmt1; - int header31; - int newClassOop1; - int fwdBlock31; - int classHeader1; - int classOop1; - int newClassHeader1; - int fwdBlock111; - int header41; - int header111; - int header211; - int sz; - int fwdBlock5; - int realHeader; - int header6; - int extra3; - int type2; - int extra12; - int sz1; - int extra2; - int header13; - int type1; - int extra11; - - /* begin compilerMapHookFrom:to: */ - if (compilerInitialized) { - compilerMapFromto(memStart, memEnd); - } - /* begin mapInterpreterOops */ - nilObj = remap(nilObj); - falseObj = remap(falseObj); - trueObj = remap(trueObj); - specialObjectsOop = remap(specialObjectsOop); - stackPointer -= activeContext; - activeContext = remap(activeContext); - stackPointer += activeContext; - theHomeContext = remap(theHomeContext); - instructionPointer -= method; - method = remap(method); - instructionPointer += method; - receiver = remap(receiver); - messageSelector = remap(messageSelector); - newMethod = remap(newMethod); - for (i2 = 1; i2 <= remapBufferCount; i2 += 1) { - oop1 = remapBuffer[i2]; - if (!((oop1 & 1))) { - remapBuffer[i2] = (remap(oop1)); - } - } - /* begin flushMethodCache */ - for (i1 = 1; i1 <= 2048; i1 += 1) { - methodCache[i1] = 0; - } - for (i1 = 1; i1 <= 64; i1 += 1) { - atCache[i1] = 0; - } - for (i = 1; i <= rootTableCount; i += 1) { - oop = rootTable[i]; - if ((oop < memStart) || (oop >= memEnd)) { - /* begin remapFieldsAndClassOf: */ - /* begin lastPointerWhileForwarding: */ - header3 = longAt(oop); - if ((header3 & 2147483648U) != 0) { - fwdBlock2 = (header3 & 2147483644) << 1; - ; - header3 = longAt(fwdBlock2 + 4); - } - fmt = (((unsigned) header3) >> 8) & 15; - if (fmt <= 4) { - if ((fmt == 3) && (isContextHeader(header3))) { - fieldOffset = (6 + (fetchStackPointerOf(oop))) * 4; - goto l1; - } - if ((header3 & 3) == 0) { - size = (longAt(oop - 8)) & 4294967292U; - } else { - size = header3 & 252; - } - fieldOffset = size - 4; - goto l1; - } - if (fmt < 12) { - fieldOffset = 0; - goto l1; - } - methodHeader = longAt(oop + 4); - fieldOffset = (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; - l1: /* end lastPointerWhileForwarding: */; - while (fieldOffset >= 4) { - fieldOop = longAt(oop + fieldOffset); - if (((fieldOop & 1) == 0) && (((longAt(fieldOop)) & 2147483648U) != 0)) { - fwdBlock = ((longAt(fieldOop)) & 2147483644) << 1; - ; - newOop = longAt(fwdBlock); - longAtput(oop + fieldOffset, newOop); - if ((oop < youngStart) && (newOop >= youngStart)) { - /* begin beRootWhileForwarding: */ - header = longAt(oop); - if ((header & 2147483648U) != 0) { - fwdBlock1 = (header & 2147483644) << 1; - ; - /* begin noteAsRoot:headerLoc: */ - header1 = longAt(fwdBlock1 + 4); - if ((header1 & 1073741824) == 0) { - if (rootTableCount < 2500) { - rootTableCount += 1; - rootTable[rootTableCount] = oop; - longAtput(fwdBlock1 + 4, header1 | 1073741824); - } - } - } else { - /* begin noteAsRoot:headerLoc: */ - header2 = longAt(oop); - if ((header2 & 1073741824) == 0) { - if (rootTableCount < 2500) { - rootTableCount += 1; - rootTable[rootTableCount] = oop; - longAtput(oop, header2 | 1073741824); - } - } - } - } - } - fieldOffset -= 4; - } - /* begin remapClassOf: */ - if (((longAt(oop)) & 3) == 3) { - goto l2; - } - classHeader = longAt(oop - 4); - classOop = classHeader & 4294967292U; - if (((classOop & 1) == 0) && (((longAt(classOop)) & 2147483648U) != 0)) { - fwdBlock3 = ((longAt(classOop)) & 2147483644) << 1; - ; - newClassOop = longAt(fwdBlock3); - newClassHeader = newClassOop | (classHeader & 3); - longAtput(oop - 4, newClassHeader); - if ((oop < youngStart) && (newClassOop >= youngStart)) { - /* begin beRootWhileForwarding: */ - header4 = longAt(oop); - if ((header4 & 2147483648U) != 0) { - fwdBlock11 = (header4 & 2147483644) << 1; - ; - /* begin noteAsRoot:headerLoc: */ - header11 = longAt(fwdBlock11 + 4); - if ((header11 & 1073741824) == 0) { - if (rootTableCount < 2500) { - rootTableCount += 1; - rootTable[rootTableCount] = oop; - longAtput(fwdBlock11 + 4, header11 | 1073741824); - } - } - } else { - /* begin noteAsRoot:headerLoc: */ - header21 = longAt(oop); - if ((header21 & 1073741824) == 0) { - if (rootTableCount < 2500) { - rootTableCount += 1; - rootTable[rootTableCount] = oop; - longAtput(oop, header21 | 1073741824); - } - } - } - } - } - l2: /* end remapClassOf: */; - } - } - /* begin oopFromChunk: */ - /* begin extraHeaderBytes: */ - type = (longAt(memStart)) & 3; - if (type > 1) { - extra1 = 0; - } else { - if (type == 1) { - extra1 = 4; - } else { - extra1 = 8; - } - } - extra = extra1; - oop = memStart + extra; - while (oop < memEnd) { - if (!(((longAt(oop)) & 3) == 2)) { - /* begin remapFieldsAndClassOf: */ - /* begin lastPointerWhileForwarding: */ - header31 = longAt(oop); - if ((header31 & 2147483648U) != 0) { - fwdBlock21 = (header31 & 2147483644) << 1; - ; - header31 = longAt(fwdBlock21 + 4); - } - fmt1 = (((unsigned) header31) >> 8) & 15; - if (fmt1 <= 4) { - if ((fmt1 == 3) && (isContextHeader(header31))) { - fieldOffset1 = (6 + (fetchStackPointerOf(oop))) * 4; - goto l3; - } - if ((header31 & 3) == 0) { - size1 = (longAt(oop - 8)) & 4294967292U; - } else { - size1 = header31 & 252; - } - fieldOffset1 = size1 - 4; - goto l3; - } - if (fmt1 < 12) { - fieldOffset1 = 0; - goto l3; - } - methodHeader1 = longAt(oop + 4); - fieldOffset1 = (((((unsigned) methodHeader1) >> 10) & 255) * 4) + 4; - l3: /* end lastPointerWhileForwarding: */; - while (fieldOffset1 >= 4) { - fieldOop1 = longAt(oop + fieldOffset1); - if (((fieldOop1 & 1) == 0) && (((longAt(fieldOop1)) & 2147483648U) != 0)) { - fwdBlock4 = ((longAt(fieldOop1)) & 2147483644) << 1; - ; - newOop1 = longAt(fwdBlock4); - longAtput(oop + fieldOffset1, newOop1); - if ((oop < youngStart) && (newOop1 >= youngStart)) { - /* begin beRootWhileForwarding: */ - header5 = longAt(oop); - if ((header5 & 2147483648U) != 0) { - fwdBlock12 = (header5 & 2147483644) << 1; - ; - /* begin noteAsRoot:headerLoc: */ - header12 = longAt(fwdBlock12 + 4); - if ((header12 & 1073741824) == 0) { - if (rootTableCount < 2500) { - rootTableCount += 1; - rootTable[rootTableCount] = oop; - longAtput(fwdBlock12 + 4, header12 | 1073741824); - } - } - } else { - /* begin noteAsRoot:headerLoc: */ - header22 = longAt(oop); - if ((header22 & 1073741824) == 0) { - if (rootTableCount < 2500) { - rootTableCount += 1; - rootTable[rootTableCount] = oop; - longAtput(oop, header22 | 1073741824); - } - } - } - } - } - fieldOffset1 -= 4; - } - /* begin remapClassOf: */ - if (((longAt(oop)) & 3) == 3) { - goto l4; - } - classHeader1 = longAt(oop - 4); - classOop1 = classHeader1 & 4294967292U; - if (((classOop1 & 1) == 0) && (((longAt(classOop1)) & 2147483648U) != 0)) { - fwdBlock31 = ((longAt(classOop1)) & 2147483644) << 1; - ; - newClassOop1 = longAt(fwdBlock31); - newClassHeader1 = newClassOop1 | (classHeader1 & 3); - longAtput(oop - 4, newClassHeader1); - if ((oop < youngStart) && (newClassOop1 >= youngStart)) { - /* begin beRootWhileForwarding: */ - header41 = longAt(oop); - if ((header41 & 2147483648U) != 0) { - fwdBlock111 = (header41 & 2147483644) << 1; - ; - /* begin noteAsRoot:headerLoc: */ - header111 = longAt(fwdBlock111 + 4); - if ((header111 & 1073741824) == 0) { - if (rootTableCount < 2500) { - rootTableCount += 1; - rootTable[rootTableCount] = oop; - longAtput(fwdBlock111 + 4, header111 | 1073741824); - } - } - } else { - /* begin noteAsRoot:headerLoc: */ - header211 = longAt(oop); - if ((header211 & 1073741824) == 0) { - if (rootTableCount < 2500) { - rootTableCount += 1; - rootTable[rootTableCount] = oop; - longAtput(oop, header211 | 1073741824); - } - } - } - } - } - l4: /* end remapClassOf: */; - } - /* begin objectAfterWhileForwarding: */ - header6 = longAt(oop); - if ((header6 & 2147483648U) == 0) { - /* begin objectAfter: */ - ; - if (((longAt(oop)) & 3) == 2) { - sz1 = (longAt(oop)) & 4294967292U; - } else { - /* begin sizeBitsOf: */ - header13 = longAt(oop); - if ((header13 & 3) == 0) { - sz1 = (longAt(oop - 8)) & 4294967292U; - goto l5; - } else { - sz1 = header13 & 252; - goto l5; - } - l5: /* end sizeBitsOf: */; - } - /* begin oopFromChunk: */ - /* begin extraHeaderBytes: */ - type1 = (longAt(oop + sz1)) & 3; - if (type1 > 1) { - extra11 = 0; - } else { - if (type1 == 1) { - extra11 = 4; - } else { - extra11 = 8; - } - } - extra2 = extra11; - oop = (oop + sz1) + extra2; - goto l6; - } - fwdBlock5 = (header6 & 2147483644) << 1; - ; - realHeader = longAt(fwdBlock5 + 4); - if ((realHeader & 3) == 0) { - sz = (longAt(oop - 8)) & 4294967292U; - } else { - sz = realHeader & 252; - } - /* begin oopFromChunk: */ - /* begin extraHeaderBytes: */ - type2 = (longAt(oop + sz)) & 3; - if (type2 > 1) { - extra12 = 0; - } else { - if (type2 == 1) { - extra12 = 4; - } else { - extra12 = 8; - } - } - extra3 = extra12; - oop = (oop + sz) + extra3; - l6: /* end objectAfterWhileForwarding: */; - } -} - -int markAndTrace(int oop) { - int action; - int lastFieldOffset; - int header; - int typeBits; - int childType; - int header1; - int type; - int methodHeader; - int sz; - int fmt; - int header2; - int header3; - int type1; - int oop1; - int lastFieldOffset1; - int header4; - int methodHeader1; - int sz1; - int fmt1; - int header11; - int header21; - int type2; - - header = longAt(oop); - if (!((header & 2147483648U) == 0)) { - return 0; - } - header = (header & 4294967292U) | 2; - if (oop >= youngStart) { - header = header | 2147483648U; - } - longAtput(oop, header); - parentField = 3; - child = oop; - /* begin lastPointerOf: */ - header2 = longAt(oop); - fmt = (((unsigned) header2) >> 8) & 15; - if (fmt <= 4) { - if ((fmt == 3) && (isContextHeader(header2))) { - lastFieldOffset = (6 + (fetchStackPointerOf(oop))) * 4; - goto l6; - } - /* begin sizeBitsOfSafe: */ - header3 = longAt(oop); - /* begin rightType: */ - if ((header3 & 252) == 0) { - type1 = 0; - goto l7; - } else { - if ((header3 & 126976) == 0) { - type1 = 1; - goto l7; - } else { - type1 = 3; - goto l7; - } - } - l7: /* end rightType: */; - if (type1 == 0) { - sz = (longAt(oop - 8)) & 4294967292U; - goto l8; - } else { - sz = header3 & 252; - goto l8; - } - l8: /* end sizeBitsOfSafe: */; - lastFieldOffset = sz - 4; - goto l6; - } - if (fmt < 12) { - lastFieldOffset = 0; - goto l6; - } - methodHeader = longAt(oop + 4); - lastFieldOffset = (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; -l6: /* end lastPointerOf: */; - field = oop + lastFieldOffset; - action = 1; - while (!(action == 4)) { - if (action == 1) { - /* begin startField */ - child = longAt(field); - typeBits = child & 3; - if ((typeBits & 1) == 1) { - field -= 4; - action = 1; - goto l1; - } - if (typeBits == 0) { - longAtput(field, parentField); - parentField = field; - action = 2; - goto l1; - } - if (typeBits == 2) { - if ((child & 126976) != 0) { - child = child & 4294967292U; - /* begin rightType: */ - if ((child & 252) == 0) { - childType = 0; - goto l3; - } else { - if ((child & 126976) == 0) { - childType = 1; - goto l3; - } else { - childType = 3; - goto l3; - } - } - l3: /* end rightType: */; - longAtput(field, child | childType); - action = 3; - goto l1; - } else { - child = longAt(field - 4); - child = child & 4294967292U; - longAtput(field - 4, parentField); - parentField = (field - 4) | 1; - action = 2; - goto l1; - } - } - l1: /* end startField */; - } - if (action == 2) { - /* begin startObj */ - oop1 = child; - if (oop1 < youngStart) { - field = oop1; - action = 3; - goto l12; - } - header4 = longAt(oop1); - if ((header4 & 2147483648U) == 0) { - if (((((unsigned) (longAt(oop1))) >> 8) & 15) == 4) { - lastFieldOffset1 = (nonWeakFieldsOf(oop1)) << 2; - } else { - /* begin lastPointerOf: */ - header11 = longAt(oop1); - fmt1 = (((unsigned) header11) >> 8) & 15; - if (fmt1 <= 4) { - if ((fmt1 == 3) && (isContextHeader(header11))) { - lastFieldOffset1 = (6 + (fetchStackPointerOf(oop1))) * 4; - goto l9; - } - /* begin sizeBitsOfSafe: */ - header21 = longAt(oop1); - /* begin rightType: */ - if ((header21 & 252) == 0) { - type2 = 0; - goto l10; - } else { - if ((header21 & 126976) == 0) { - type2 = 1; - goto l10; - } else { - type2 = 3; - goto l10; - } - } - l10: /* end rightType: */; - if (type2 == 0) { - sz1 = (longAt(oop1 - 8)) & 4294967292U; - goto l11; - } else { - sz1 = header21 & 252; - goto l11; - } - l11: /* end sizeBitsOfSafe: */; - lastFieldOffset1 = sz1 - 4; - goto l9; - } - if (fmt1 < 12) { - lastFieldOffset1 = 0; - goto l9; - } - methodHeader1 = longAt(oop1 + 4); - lastFieldOffset1 = (((((unsigned) methodHeader1) >> 10) & 255) * 4) + 4; - l9: /* end lastPointerOf: */; - } - header4 = header4 & 4294967292U; - header4 = (header4 | 2147483648U) | 2; - longAtput(oop1, header4); - field = oop1 + lastFieldOffset1; - action = 1; - goto l12; - } else { - field = oop1; - action = 3; - goto l12; - } - l12: /* end startObj */; - } - if (action == 3) { - /* begin upward */ - if ((parentField & 1) == 1) { - if (parentField == 3) { - header1 = (longAt(field)) & 4294967292U; - /* begin rightType: */ - if ((header1 & 252) == 0) { - type = 0; - goto l4; - } else { - if ((header1 & 126976) == 0) { - type = 1; - goto l4; - } else { - type = 3; - goto l4; - } - } - l4: /* end rightType: */; - longAtput(field, header1 + type); - action = 4; - goto l2; - } else { - child = field; - field = parentField - 1; - parentField = longAt(field); - header1 = longAt(field + 4); - /* begin rightType: */ - if ((header1 & 252) == 0) { - type = 0; - goto l5; - } else { - if ((header1 & 126976) == 0) { - type = 1; - goto l5; - } else { - type = 3; - goto l5; - } - } - l5: /* end rightType: */; - longAtput(field, child + type); - field += 4; - header1 = header1 & 4294967292U; - longAtput(field, header1 + type); - action = 3; - goto l2; - } - } else { - child = field; - field = parentField; - parentField = longAt(field); - longAtput(field, child); - field -= 4; - action = 1; - goto l2; - } - l2: /* end upward */; - } - } -} - -int markPhase(void) { - int oop; - int i; - int i1; - int oop1; - - freeContexts = 1; - /* begin markAndTraceInterpreterOops */ - /* begin compilerMarkHook */ - if (compilerInitialized) { - compilerMark(); - } - markAndTrace(specialObjectsOop); - markAndTrace(activeContext); - markAndTrace(messageSelector); - markAndTrace(newMethod); - for (i1 = 1; i1 <= remapBufferCount; i1 += 1) { - oop1 = remapBuffer[i1]; - if (!((oop1 & 1))) { - markAndTrace(oop1); - } - } - for (i = 1; i <= rootTableCount; i += 1) { - oop = rootTable[i]; - markAndTrace(oop); - } -} - -int matrix2x3ComposeMatrixwithinto(const float *m1, const float *m2, float *m3) { - double a21; - double a22; - double a23; - double a11; - double a12; - double a13; - - a11 = ((m1[0]) * (m2[0])) + ((m1[1]) * (m2[3])); - a12 = ((m1[0]) * (m2[1])) + ((m1[1]) * (m2[4])); - a13 = (((m1[0]) * (m2[2])) + ((m1[1]) * (m2[5]))) + (m1[2]); - a21 = ((m1[3]) * (m2[0])) + ((m1[4]) * (m2[3])); - a22 = ((m1[3]) * (m2[1])) + ((m1[4]) * (m2[4])); - a23 = (((m1[3]) * (m2[2])) + ((m1[4]) * (m2[5]))) + (m1[5]); - m3[0] = (((float) a11)); - m3[1] = (((float) a12)); - m3[2] = (((float) a13)); - m3[3] = (((float) a21)); - m3[4] = (((float) a22)); - m3[5] = (((float) a23)); -} - -int matrix2x3InvertPoint(float *m) { - double det; - double y; - double x; - double detX; - double detY; - - x = m23ArgX - (m[2]); - y = m23ArgY - (m[5]); - det = ((m[0]) * (m[4])) - ((m[1]) * (m[3])); - if (det == 0.0) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - det = 1.0 / det; - detX = (x * (m[4])) - ((m[1]) * y); - detY = ((m[0]) * y) - (x * (m[3])); - m23ResultX = detX * det; - m23ResultY = detY * det; -} - -int matrix2x3TransformPoint(float *m) { - m23ResultX = ((m23ArgX * (m[0])) + (m23ArgY * (m[1]))) + (m[2]); - m23ResultY = ((m23ArgX * (m[3])) + (m23ArgY * (m[4]))) + (m[5]); -} - -int mergewith(int sourceWord, int destinationWord) { - int (*mergeFnwith)(int, int); - - mergeFnwith = ((int (*)(int, int)) (opTable[combinationRule + 1])); - mergeFnwith; - return mergeFnwith(sourceWord, destinationWord); -} - -int methodArgumentCount(void) { - return argumentCount; -} - -int methodPrimitiveIndex(void) { - return primitiveIndex; -} - -int moveAETEntryFromedgex(int index, int edge, int xValue) { - int newIndex; - - newIndex = index; - while ((newIndex > 0) && ((objBuffer[(aetBuffer[newIndex - 1]) + 4]) > xValue)) { - aetBuffer[newIndex] = (aetBuffer[newIndex - 1]); - newIndex -= 1; - } - aetBuffer[newIndex] = edge; -} - -int needAvailableSpace(int nSlots) { - if (((((128 + objUsed) + (workBuffer[12])) + (workBuffer[14])) + nSlots) > (workBuffer[10])) { - /* begin stopBecauseOf: */ - workBuffer[64] = 1; - engineStopped = 1; - return 0; - } - return 1; -} - -int netAddressToInt(int oop) { - int sz; - int header; - int sz1; - int ccIndex; - int cl; - - /* begin assertClassOf:is: */ - if ((oop & 1)) { - successFlag = 0; - goto l2; - } - ccIndex = (((unsigned) (longAt(oop))) >> 12) & 31; - if (ccIndex == 0) { - cl = (longAt(oop - 4)) & 4294967292U; - } else { - cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - } - /* begin success: */ - successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (26 << 2)))) && successFlag; -l2: /* end assertClassOf:is: */; - if (successFlag) { - /* begin lengthOf: */ - header = longAt(oop); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz1 = (longAt(oop - 8)) & 4294967292U; - } else { - sz1 = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - sz = ((unsigned) (sz1 - 4)) >> 2; - goto l1; - } else { - sz = (sz1 - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l1; - } - l1: /* end lengthOf:baseHeader:format: */; - if (!(sz == 4)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - } - if (successFlag) { - return (((byteAt(((((char *) oop)) + 4) + 3)) + ((byteAt(((((char *) oop)) + 4) + 2)) << 8)) + ((byteAt(((((char *) oop)) + 4) + 1)) << 16)) + ((byteAt(((((char *) oop)) + 4) + 0)) << 24); - } -} - -int nilObject(void) { - return nilObj; -} - -int nonWeakFieldsOf(int oop) { - int classFormat; - int class; - int ccIndex; - - if (!(((((unsigned) (longAt(oop))) >> 8) & 15) == 4)) { - error("Called fixedFieldsOfWeak: with a non-weak oop"); - } - /* begin fetchClassOf: */ - if ((oop & 1)) { - class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l1; - } - ccIndex = (((unsigned) (longAt(oop))) >> 12) & 31; - if (ccIndex == 0) { - class = (longAt(oop - 4)) & 4294967292U; - goto l1; - } else { - class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l1; - } -l1: /* end fetchClassOf: */; - classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; - return (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; -} - -int nullCompilerHook(void) { - error("uninitialised compiler hook called"); - return 0; -} - -int objectAfter(int oop) { - int sz; - int extra; - int header; - int type; - int extra1; - - ; - if (((longAt(oop)) & 3) == 2) { - sz = (longAt(oop)) & 4294967292U; - } else { - /* begin sizeBitsOf: */ - header = longAt(oop); - if ((header & 3) == 0) { - sz = (longAt(oop - 8)) & 4294967292U; - goto l1; - } else { - sz = header & 252; - goto l1; - } - l1: /* end sizeBitsOf: */; - } - /* begin oopFromChunk: */ - /* begin extraHeaderBytes: */ - type = (longAt(oop + sz)) & 3; - if (type > 1) { - extra1 = 0; - } else { - if (type == 1) { - extra1 = 4; - } else { - extra1 = 8; - } - } - extra = extra1; - return (oop + sz) + extra; -} - -int okayFields(int oop) { - int i; - int fieldOop; - - if ((oop == null) || (oop == 0)) { - return 1; - } - if ((oop & 1)) { - return 1; - } - okayOop(oop); - oopHasOkayClass(oop); - if (!(((((unsigned) (longAt(oop))) >> 8) & 15) <= 4)) { - return 1; - } - i = (lengthOf(oop)) - 1; - while (i >= 0) { - fieldOop = longAt(((((char *) oop)) + 4) + (i << 2)); - if (!((fieldOop & 1))) { - okayOop(fieldOop); - oopHasOkayClass(fieldOop); - } - i -= 1; - } -} - -int okayOop(int oop) { - int sz; - int type; - int fmt; - int header; - - if ((oop & 1)) { - return 1; - } - if (!((0 < oop) && (oop < endOfMemory))) { - error("oop is not a valid address"); - } - if (!((oop % 4) == 0)) { - error("oop is not a word-aligned address"); - } - /* begin sizeBitsOf: */ - header = longAt(oop); - if ((header & 3) == 0) { - sz = (longAt(oop - 8)) & 4294967292U; - goto l1; - } else { - sz = header & 252; - goto l1; - } -l1: /* end sizeBitsOf: */; - if (!((oop + sz) < endOfMemory)) { - error("oop size would make it extend beyond the end of memory"); - } - type = (longAt(oop)) & 3; - if (type == 2) { - error("oop is a free chunk, not an object"); - } - if (type == 3) { - if (((((unsigned) (longAt(oop))) >> 12) & 31) == 0) { - error("cannot have zero compact class field in a short header"); - } - } - if (type == 1) { - if (!((oop >= 4) && (((longAt(oop - 4)) & 3) == type))) { - error("class header word has wrong type"); - } - } - if (type == 0) { - if (!((oop >= 8) && ((((longAt(oop - 8)) & 3) == type) && (((longAt(oop - 4)) & 3) == type)))) { - error("class header word has wrong type"); - } - } - fmt = (((unsigned) (longAt(oop))) >> 8) & 15; - if ((fmt == 5) || (fmt == 7)) { - error("oop has an unknown format type"); - } - if (!(((longAt(oop)) & 536870912) == 0)) { - error("unused header bit 30 is set; should be zero"); - } - if ((((longAt(oop)) & 1073741824) == 1) && (oop >= youngStart)) { - error("root bit is set in a young object"); - } - return 1; -} - -int oopFromChunk(int chunk) { - int extra; - int type; - int extra1; - - /* begin extraHeaderBytes: */ - type = (longAt(chunk)) & 3; - if (type > 1) { - extra1 = 0; - } else { - if (type == 1) { - extra1 = 4; - } else { - extra1 = 8; - } - } - extra = extra1; - return chunk + extra; -} - -int oopHasOKclass(int oop) { - int behaviorFormatBits; - int oopClass; - int formatMask; - int oopFormatBits; - int ccIndex; - - if ((oop & 1)) { - return 1; - } - if (!((0 < oop) && (oop < endOfMemory))) { - return 0; - } - if (!((oop % 4) == 0)) { - return 0; - } - if (!((oop + (sizeBitsOf(oop))) < endOfMemory)) { - return 0; - } - /* begin fetchClassOf: */ - if ((oop & 1)) { - oopClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l1; - } - ccIndex = (((unsigned) (longAt(oop))) >> 12) & 31; - if (ccIndex == 0) { - oopClass = (longAt(oop - 4)) & 4294967292U; - goto l1; - } else { - oopClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l1; - } -l1: /* end fetchClassOf: */; - if ((oopClass & 1)) { - return 0; - } - if (!((0 < oopClass) && (oopClass < endOfMemory))) { - return 0; - } - if (!((oopClass % 4) == 0)) { - return 0; - } - if (!((oopClass + (sizeBitsOf(oopClass))) < endOfMemory)) { - return 0; - } - if (!((((((unsigned) (longAt(oopClass))) >> 8) & 15) <= 4) && ((lengthOf(oopClass)) >= 3))) { - return 0; - } - if (((((unsigned) (longAt(oop))) >> 8) & 15) >= 8) { - formatMask = 3072; - } else { - formatMask = 3840; - } - behaviorFormatBits = ((longAt(((((char *) oopClass)) + 4) + (2 << 2))) - 1) & formatMask; - oopFormatBits = (longAt(oop)) & formatMask; - if (!(behaviorFormatBits == oopFormatBits)) { - return 0; - } - return 1; -} - -int oopHasOkayClass(int oop) { - int behaviorFormatBits; - int oopClass; - int formatMask; - int oopFormatBits; - int ccIndex; - - okayOop(oop); - /* begin fetchClassOf: */ - if ((oop & 1)) { - oopClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l1; - } - ccIndex = (((unsigned) (longAt(oop))) >> 12) & 31; - if (ccIndex == 0) { - oopClass = (longAt(oop - 4)) & 4294967292U; - goto l1; - } else { - oopClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l1; - } -l1: /* end fetchClassOf: */; - if ((oopClass & 1)) { - error("a SmallInteger is not a valid class or behavior"); - } - okayOop(oopClass); - if (!((((((unsigned) (longAt(oopClass))) >> 8) & 15) <= 4) && ((lengthOf(oopClass)) >= 3))) { - error("a class (behavior) must be a pointers object of size >= 3"); - } - if (((((unsigned) (longAt(oop))) >> 8) & 15) >= 8) { - formatMask = 3072; - } else { - formatMask = 3840; - } - behaviorFormatBits = ((longAt(((((char *) oopClass)) + 4) + (2 << 2))) - 1) & formatMask; - oopFormatBits = (longAt(oop)) & formatMask; - if (!(behaviorFormatBits == oopFormatBits)) { - error("object and its class (behavior) formats differ"); - } - return 1; -} - -int partitionedANDtonBitsnPartitions(int word1, int word2, int nBits, int nParts) { - int mask; - int i; - int result; - - mask = maskTable[nBits]; - result = 0; - for (i = 1; i <= nParts; i += 1) { - if ((word1 & mask) == mask) { - result = result | (word2 & mask); - } - mask = mask << nBits; - } - return result; -} - -int partitionedAddtonBitsnPartitions(int word1, int word2, int nBits, int nParts) { - int mask; - int sum; - int i; - int result; - - mask = maskTable[nBits]; - result = 0; - for (i = 1; i <= nParts; i += 1) { - sum = (word1 & mask) + (word2 & mask); - if (sum <= mask) { - result = result | sum; - } else { - result = result | mask; - } - mask = mask << nBits; - } - return result; -} - -int partitionedMaxwithnBitsnPartitions(int word1, int word2, int nBits, int nParts) { - int mask; - int i; - int result; - - mask = maskTable[nBits]; - result = 0; - for (i = 1; i <= nParts; i += 1) { - result = result | ((((word2 & mask) < (word1 & mask)) ? (word1 & mask) : (word2 & mask))); - mask = mask << nBits; - } - return result; -} - -int partitionedMinwithnBitsnPartitions(int word1, int word2, int nBits, int nParts) { - int mask; - int i; - int result; - - mask = maskTable[nBits]; - result = 0; - for (i = 1; i <= nParts; i += 1) { - result = result | ((((word2 & mask) < (word1 & mask)) ? (word2 & mask) : (word1 & mask))); - mask = mask << nBits; - } - return result; -} - -int partitionedSubfromnBitsnPartitions(int word1, int word2, int nBits, int nParts) { - int mask; - int i; - int p1; - int p2; - int result; - - mask = maskTable[nBits]; - result = 0; - for (i = 1; i <= nParts; i += 1) { - p1 = word1 & mask; - p2 = word2 & mask; - if (p1 < p2) { - result = result | (p2 - p1); - } else { - result = result | (p1 - p2); - } - mask = mask << nBits; - } - return result; -} - -int permuteData(void) { - int i; - int a; - int b; - int end; - float tmp; - - i = 0; - end = permTableSize; - while (i < end) { - a = (permTable[i]) - 1; - b = (permTable[i + 1]) - 1; - if (!((a < realDataSize) && (b < realDataSize))) { - /* begin success: */ - successFlag = 0 && successFlag; - return null; - } - tmp = realData[a]; - realData[a] = (realData[b]); - realData[b] = tmp; - tmp = imagData[a]; - imagData[a] = (imagData[b]); - imagData[b] = tmp; - i += 2; - } -} - -int pickSourcePixelssrcMaskdestMask(int nPix, int sourcePixMask, int destPixMask) { - int sourceWord; - int destWord; - int sourcePix; - int destPix; - int i; - - sourceWord = longAt(sourceIndex); - destWord = 0; - for (i = 1; i <= nPix; i += 1) { - sourcePix = (((unsigned) sourceWord) >> ((32 - sourcePixSize) - srcBitIndex)) & sourcePixMask; - destPix = (longAt(((((char *) colorMap)) + 4) + (sourcePix << 2))) & destPixMask; - if (destPixSize == 32) { - destWord = destPix; - } else { - destWord = (destWord << destPixSize) | destPix; - } - if ((srcBitIndex += sourcePixSize) > 31) { - srcBitIndex -= 32; - sourceIndex += 4; - sourceWord = longAt(sourceIndex); - } - } - return destWord; -} - -int pickSourcePixelsNullMapsrcMaskdestMask(int nPix, int sourcePixMask, int destPixMask) { - int sourceWord; - int destWord; - int sourcePix; - int i; - - sourceWord = longAt(sourceIndex); - destWord = 0; - for (i = 1; i <= nPix; i += 1) { - sourcePix = (((unsigned) sourceWord) >> ((32 - sourcePixSize) - srcBitIndex)) & sourcePixMask; - if (destPixSize == 32) { - destWord = sourcePix; - } else { - destWord = (destWord << destPixSize) | (sourcePix & destPixMask); - } - if ((srcBitIndex += sourcePixSize) > 31) { - srcBitIndex -= 32; - sourceIndex += 4; - sourceWord = longAt(sourceIndex); - } - } - return destWord; -} - -int pickSourcePixelsRGBnullMapsrcMaskdestMask(int nPix, int nullMap, int sourcePixMask, int destPixMask) { - int sourceWord; - int destWord; - int sourcePix; - int destPix; - int i; - int mask; - int srcPix; - int destPix1; - int d; - int mask3; - int srcPix1; - int destPix2; - int d1; - int mask4; - int srcPix2; - int destPix3; - int d2; - int mask5; - int srcPix3; - int destPix4; - int d3; - - sourceWord = longAt(sourceIndex); - destWord = 0; - for (i = 1; i <= nPix; i += 1) { - sourcePix = (((unsigned) sourceWord) >> ((32 - sourcePixSize) - srcBitIndex)) & sourcePixMask; - if (nullMap) { - if (sourcePixSize == 16) { - /* begin rgbMap:from:to: */ - if ((d = 8 - 5) > 0) { - mask = (1 << 5) - 1; - srcPix = sourcePix << d; - mask = mask << d; - destPix1 = srcPix & mask; - mask = mask << 8; - srcPix = srcPix << d; - destPix = (destPix1 + (srcPix & mask)) + ((srcPix << d) & (mask << 8)); - goto l1; - } else { - if (d == 0) { - if (5 == 5) { - destPix = sourcePix & 32767; - goto l1; - } - if (5 == 8) { - destPix = sourcePix & 16777215; - goto l1; - } - destPix = sourcePix; - goto l1; - } - if (sourcePix == 0) { - destPix = sourcePix; - goto l1; - } - d = 5 - 8; - mask = (1 << 8) - 1; - srcPix = ((unsigned) sourcePix) >> d; - destPix1 = srcPix & mask; - mask = mask << 8; - srcPix = ((unsigned) srcPix) >> d; - destPix1 = (destPix1 + (srcPix & mask)) + ((((unsigned) srcPix) >> d) & (mask << 8)); - if (destPix1 == 0) { - destPix = 1; - goto l1; - } - destPix = destPix1; - goto l1; - } - l1: /* end rgbMap:from:to: */; - } else { - /* begin rgbMap:from:to: */ - if ((d1 = 5 - 8) > 0) { - mask3 = (1 << 8) - 1; - srcPix1 = sourcePix << d1; - mask3 = mask3 << d1; - destPix2 = srcPix1 & mask3; - mask3 = mask3 << 5; - srcPix1 = srcPix1 << d1; - destPix = (destPix2 + (srcPix1 & mask3)) + ((srcPix1 << d1) & (mask3 << 5)); - goto l2; - } else { - if (d1 == 0) { - if (8 == 5) { - destPix = sourcePix & 32767; - goto l2; - } - if (8 == 8) { - destPix = sourcePix & 16777215; - goto l2; - } - destPix = sourcePix; - goto l2; - } - if (sourcePix == 0) { - destPix = sourcePix; - goto l2; - } - d1 = 8 - 5; - mask3 = (1 << 5) - 1; - srcPix1 = ((unsigned) sourcePix) >> d1; - destPix2 = srcPix1 & mask3; - mask3 = mask3 << 5; - srcPix1 = ((unsigned) srcPix1) >> d1; - destPix2 = (destPix2 + (srcPix1 & mask3)) + ((((unsigned) srcPix1) >> d1) & (mask3 << 5)); - if (destPix2 == 0) { - destPix = 1; - goto l2; - } - destPix = destPix2; - goto l2; - } - l2: /* end rgbMap:from:to: */; - } - } else { - if (sourcePixSize == 16) { - /* begin rgbMap:from:to: */ - if ((d2 = cmBitsPerColor - 5) > 0) { - mask4 = (1 << 5) - 1; - srcPix2 = sourcePix << d2; - mask4 = mask4 << d2; - destPix3 = srcPix2 & mask4; - mask4 = mask4 << cmBitsPerColor; - srcPix2 = srcPix2 << d2; - sourcePix = (destPix3 + (srcPix2 & mask4)) + ((srcPix2 << d2) & (mask4 << cmBitsPerColor)); - goto l3; - } else { - if (d2 == 0) { - if (5 == 5) { - sourcePix = sourcePix & 32767; - goto l3; - } - if (5 == 8) { - sourcePix = sourcePix & 16777215; - goto l3; - } - sourcePix = sourcePix; - goto l3; - } - if (sourcePix == 0) { - sourcePix = sourcePix; - goto l3; - } - d2 = 5 - cmBitsPerColor; - mask4 = (1 << cmBitsPerColor) - 1; - srcPix2 = ((unsigned) sourcePix) >> d2; - destPix3 = srcPix2 & mask4; - mask4 = mask4 << cmBitsPerColor; - srcPix2 = ((unsigned) srcPix2) >> d2; - destPix3 = (destPix3 + (srcPix2 & mask4)) + ((((unsigned) srcPix2) >> d2) & (mask4 << cmBitsPerColor)); - if (destPix3 == 0) { - sourcePix = 1; - goto l3; - } - sourcePix = destPix3; - goto l3; - } - l3: /* end rgbMap:from:to: */; - } else { - /* begin rgbMap:from:to: */ - if ((d3 = cmBitsPerColor - 8) > 0) { - mask5 = (1 << 8) - 1; - srcPix3 = sourcePix << d3; - mask5 = mask5 << d3; - destPix4 = srcPix3 & mask5; - mask5 = mask5 << cmBitsPerColor; - srcPix3 = srcPix3 << d3; - sourcePix = (destPix4 + (srcPix3 & mask5)) + ((srcPix3 << d3) & (mask5 << cmBitsPerColor)); - goto l4; - } else { - if (d3 == 0) { - if (8 == 5) { - sourcePix = sourcePix & 32767; - goto l4; - } - if (8 == 8) { - sourcePix = sourcePix & 16777215; - goto l4; - } - sourcePix = sourcePix; - goto l4; - } - if (sourcePix == 0) { - sourcePix = sourcePix; - goto l4; - } - d3 = 8 - cmBitsPerColor; - mask5 = (1 << cmBitsPerColor) - 1; - srcPix3 = ((unsigned) sourcePix) >> d3; - destPix4 = srcPix3 & mask5; - mask5 = mask5 << cmBitsPerColor; - srcPix3 = ((unsigned) srcPix3) >> d3; - destPix4 = (destPix4 + (srcPix3 & mask5)) + ((((unsigned) srcPix3) >> d3) & (mask5 << cmBitsPerColor)); - if (destPix4 == 0) { - sourcePix = 1; - goto l4; - } - sourcePix = destPix4; - goto l4; - } - l4: /* end rgbMap:from:to: */; - } - destPix = (longAt(((((char *) colorMap)) + 4) + (sourcePix << 2))) & destPixMask; - } - if (destPixSize == 32) { - destWord = destPix; - } else { - destWord = (destWord << destPixSize) | destPix; - } - if ((srcBitIndex += sourcePixSize) > 31) { - srcBitIndex -= 32; - sourceIndex += 4; - sourceWord = longAt(sourceIndex); - } - } - return destWord; -} - -int pixMaskwith(int sourceWord, int destinationWord) { - int mask; - int i; - int result; - - /* begin partitionedAND:to:nBits:nPartitions: */ - mask = maskTable[destPixSize]; - result = 0; - for (i = 1; i <= pixPerWord; i += 1) { - if (((~sourceWord) & mask) == mask) { - result = result | (destinationWord & mask); - } - mask = mask << destPixSize; - } - return result; -} - -int pixPaintwith(int sourceWord, int destinationWord) { - if (sourceWord == 0) { - return destinationWord; - } - return sourceWord | (partitionedANDtonBitsnPartitions(~sourceWord, destinationWord, destPixSize, pixPerWord)); -} - -int pop(int nItems) { - stackPointer -= nItems * 4; -} - -int popthenPush(int nItems, int oop) { - int sp; - - longAtput(sp = stackPointer - ((nItems - 1) * 4), oop); - stackPointer = sp; -} - -double popFloat(void) { - int top; - double result; - int top1; - int ccIndex; - int cl; - - /* begin popStack */ - top1 = longAt(stackPointer); - stackPointer -= 4; - top = top1; - /* begin assertClassOf:is: */ - if ((top & 1)) { - successFlag = 0; - goto l1; - } - ccIndex = (((unsigned) (longAt(top))) >> 12) & 31; - if (ccIndex == 0) { - cl = (longAt(top - 4)) & 4294967292U; - } else { - cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - } - /* begin success: */ - successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)))) && successFlag; -l1: /* end assertClassOf:is: */; - if (successFlag) { - ; - fetchFloatAtinto(top + 4, result); - } - return result; -} - -int popRemappableOop(void) { - int oop; - - oop = remapBuffer[remapBufferCount]; - remapBufferCount -= 1; - return oop; -} - -int popStack(void) { - int top; - - top = longAt(stackPointer); - stackPointer -= 4; - return top; -} - -int positive32BitIntegerFor(int integerValue) { - int newLargeInteger; - - if ((integerValue >= 0) && ((integerValue ^ (integerValue << 1)) >= 0)) { - return ((integerValue << 1) | 1); - } - newLargeInteger = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (13 << 2)), 8, 0); - byteAtput(((((char *) newLargeInteger)) + 4) + 3, (((unsigned) integerValue) >> 24) & 255); - byteAtput(((((char *) newLargeInteger)) + 4) + 2, (((unsigned) integerValue) >> 16) & 255); - byteAtput(((((char *) newLargeInteger)) + 4) + 1, (((unsigned) integerValue) >> 8) & 255); - byteAtput(((((char *) newLargeInteger)) + 4) + 0, integerValue & 255); - return newLargeInteger; -} - -int positive32BitValueOf(int oop) { - int sz; - int value; - int header; - int sz1; - int ccIndex; - int cl; - - if ((oop & 1)) { - value = (oop >> 1); - if (value < 0) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - return value; - } - /* begin assertClassOf:is: */ - if ((oop & 1)) { - successFlag = 0; - goto l2; - } - ccIndex = (((unsigned) (longAt(oop))) >> 12) & 31; - if (ccIndex == 0) { - cl = (longAt(oop - 4)) & 4294967292U; - } else { - cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - } - /* begin success: */ - successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (13 << 2)))) && successFlag; -l2: /* end assertClassOf:is: */; - if (successFlag) { - /* begin lengthOf: */ - header = longAt(oop); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz1 = (longAt(oop - 8)) & 4294967292U; - } else { - sz1 = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - sz = ((unsigned) (sz1 - 4)) >> 2; - goto l1; - } else { - sz = (sz1 - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l1; - } - l1: /* end lengthOf:baseHeader:format: */; - if (!(sz == 4)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - } - if (successFlag) { - return (((byteAt(((((char *) oop)) + 4) + 0)) + ((byteAt(((((char *) oop)) + 4) + 1)) << 8)) + ((byteAt(((((char *) oop)) + 4) + 2)) << 16)) + ((byteAt(((((char *) oop)) + 4) + 3)) << 24); - } -} - -int possibleRootStoreIntovalue(int oop, int valueObj) { - int header; - - if ((valueObj >= youngStart) && (!((valueObj & 1)))) { - /* begin noteAsRoot:headerLoc: */ - header = longAt(oop); - if ((header & 1073741824) == 0) { - if (rootTableCount < 2500) { - rootTableCount += 1; - rootTable[rootTableCount] = oop; - longAtput(oop, header | 1073741824); - } - } - } -} - -int postDisplayAction(void) { - if (((workBuffer[11]) >= (workBuffer[12])) && ((workBuffer[14]) == 0)) { - workBuffer[2] = 8; - } - if ((workBuffer[88]) >= (workBuffer[39])) { - workBuffer[2] = 8; - } -} - -int prepareForwardingTableForBecomingwithtwoWay(int array1, int array2, int twoWayFlag) { - int entriesAvailable; - int fwdBlock; - int fieldOffset; - int oop1; - int oop2; - int entriesNeeded; - int fwdBlkSize; - int originalHeader; - int originalHeaderType; - int originalHeader1; - int originalHeaderType1; - int methodHeader; - int sz; - int fmt; - int header; - int header1; - int type; - - entriesNeeded = ((int) (lastPointerOf(array1)) >> 2); - if (twoWayFlag) { - entriesNeeded = entriesNeeded * 2; - fwdBlkSize = 8; - } else { - fwdBlkSize = 16; - } - entriesAvailable = fwdTableInit(fwdBlkSize); - if (entriesAvailable < entriesNeeded) { - initializeMemoryFirstFree(freeBlock); - return 0; - } - /* begin lastPointerOf: */ - header = longAt(array1); - fmt = (((unsigned) header) >> 8) & 15; - if (fmt <= 4) { - if ((fmt == 3) && (isContextHeader(header))) { - fieldOffset = (6 + (fetchStackPointerOf(array1))) * 4; - goto l3; - } - /* begin sizeBitsOfSafe: */ - header1 = longAt(array1); - /* begin rightType: */ - if ((header1 & 252) == 0) { - type = 0; - goto l4; - } else { - if ((header1 & 126976) == 0) { - type = 1; - goto l4; - } else { - type = 3; - goto l4; - } - } - l4: /* end rightType: */; - if (type == 0) { - sz = (longAt(array1 - 8)) & 4294967292U; - goto l5; - } else { - sz = header1 & 252; - goto l5; - } - l5: /* end sizeBitsOfSafe: */; - fieldOffset = sz - 4; - goto l3; - } - if (fmt < 12) { - fieldOffset = 0; - goto l3; - } - methodHeader = longAt(array1 + 4); - fieldOffset = (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; -l3: /* end lastPointerOf: */; - while (fieldOffset >= 4) { - oop1 = longAt(array1 + fieldOffset); - oop2 = longAt(array2 + fieldOffset); - /* begin fwdBlockGet: */ - fwdTableNext += fwdBlkSize; - if (fwdTableNext <= fwdTableLast) { - fwdBlock = fwdTableNext; - goto l2; - } else { - fwdBlock = null; - goto l2; - } - l2: /* end fwdBlockGet: */; - /* begin initForwardBlock:mapping:to:withBackPtr: */ - originalHeader1 = longAt(oop1); - ; - originalHeaderType1 = originalHeader1 & 3; - longAtput(fwdBlock, oop2); - longAtput(fwdBlock + 4, originalHeader1); - if (!twoWayFlag) { - longAtput(fwdBlock + 8, oop1); - } - longAtput(oop1, (((unsigned) fwdBlock) >> 1) | (2147483648U | originalHeaderType1)); - if (twoWayFlag) { - /* begin fwdBlockGet: */ - fwdTableNext += fwdBlkSize; - if (fwdTableNext <= fwdTableLast) { - fwdBlock = fwdTableNext; - goto l1; - } else { - fwdBlock = null; - goto l1; - } - l1: /* end fwdBlockGet: */; - /* begin initForwardBlock:mapping:to:withBackPtr: */ - originalHeader = longAt(oop2); - ; - originalHeaderType = originalHeader & 3; - longAtput(fwdBlock, oop1); - longAtput(fwdBlock + 4, originalHeader); - if (!twoWayFlag) { - longAtput(fwdBlock + 8, oop2); - } - longAtput(oop2, (((unsigned) fwdBlock) >> 1) | (2147483648U | originalHeaderType)); - } - fieldOffset -= 4; - } - return 1; -} - -int primitiveAdd(void) { - int integerResult; - int sp; - - /* begin pop2AndPushIntegerIfOK: */ - integerResult = (stackIntegerValue(1)) + (stackIntegerValue(0)); - if (successFlag) { - if ((integerResult ^ (integerResult << 1)) >= 0) { - /* begin pop:thenPush: */ - longAtput(sp = stackPointer - ((2 - 1) * 4), ((integerResult << 1) | 1)); - stackPointer = sp; - } else { - successFlag = 0; - } - } -} - -int primitiveArctan(void) { - double rcvr; - - rcvr = popFloat(); - if (successFlag) { - pushFloat(atan(rcvr)); - } else { - /* begin unPop: */ - stackPointer += 1 * 4; - } -} - -int primitiveArrayBecome(void) { - int arg; - int rcvr; - int successValue; - int i; - - arg = longAt(stackPointer); - rcvr = longAt(stackPointer - (1 * 4)); - /* begin success: */ - successValue = becomewithtwoWay(rcvr, arg, 1); - successFlag = successValue && successFlag; - /* begin flushMethodCache */ - for (i = 1; i <= 2048; i += 1) { - methodCache[i] = 0; - } - for (i = 1; i <= 64; i += 1) { - atCache[i] = 0; - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 1 * 4; - } -} - -int primitiveArrayBecomeOneWay(void) { - int arg; - int rcvr; - int successValue; - int i; - - arg = longAt(stackPointer); - rcvr = longAt(stackPointer - (1 * 4)); - /* begin success: */ - successValue = becomewithtwoWay(rcvr, arg, 0); - successFlag = successValue && successFlag; - /* begin flushMethodCache */ - for (i = 1; i <= 2048; i += 1) { - methodCache[i] = 0; - } - for (i = 1; i <= 64; i += 1) { - atCache[i] = 0; - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 1 * 4; - } -} - -int primitiveAsFloat(void) { - int arg; - int integerPointer; - int top; - - /* begin popInteger */ - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - integerPointer = top; - if ((integerPointer & 1)) { - arg = (integerPointer >> 1); - goto l1; - } else { - successFlag = 0; - arg = 1; - goto l1; - } -l1: /* end popInteger */; - if (successFlag) { - pushFloat(((double) arg)); - } else { - /* begin unPop: */ - stackPointer += 1 * 4; - } -} - -int primitiveAsOop(void) { - int thisReceiver; - int sp; - int top; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - thisReceiver = top; - /* begin success: */ - successFlag = (!((thisReceiver & 1))) && successFlag; - if (successFlag) { - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, ((((((unsigned) (longAt(thisReceiver))) >> 17) & 4095) << 1) | 1)); - stackPointer = sp; - } else { - /* begin unPop: */ - stackPointer += 1 * 4; - } -} - -int primitiveAsyncFileClose(void) { - AsyncFile *f; - - f = asyncFileValueOf(longAt(stackPointer)); - if (successFlag) { - asyncFileClose(f); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 1 * 4; - } -} - -int primitiveAsyncFileOpen(void) { - AsyncFile *f; - int semaIndex; - int writeFlag; - int fileName; - int fmt; - int fileNameSize; - int fOop; - int sp; - int integerPointer; - int oop; - int successValue; - int header; - int sz; - - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - semaIndex = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - semaIndex = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - /* begin booleanValueOf: */ - if ((longAt(stackPointer - (1 * 4))) == trueObj) { - writeFlag = 1; - goto l2; - } - if ((longAt(stackPointer - (1 * 4))) == falseObj) { - writeFlag = 0; - goto l2; - } - successFlag = 0; - writeFlag = null; -l2: /* end booleanValueOf: */; - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (2 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - fileName = null; - goto l3; - } - fileName = oop; -l3: /* end stackObjectValue: */; - if (!(successFlag)) { - return null; - } - fmt = (((unsigned) (longAt(fileName))) >> 8) & 15; - /* begin success: */ - successValue = (fmt >= 8) && (fmt <= 11); - successFlag = successValue && successFlag; - /* begin lengthOf: */ - header = longAt(fileName); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(fileName - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - fileNameSize = ((unsigned) (sz - 4)) >> 2; - goto l4; - } else { - fileNameSize = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l4; - } -l4: /* end lengthOf:baseHeader:format: */; - if (successFlag) { - fOop = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (26 << 2)), sizeof(AsyncFile)); - f = asyncFileValueOf(fOop); - } - if (successFlag) { - asyncFileOpen(f, fileName + 4, fileNameSize, writeFlag, semaIndex); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 4 * 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, fOop); - stackPointer = sp; - } -} - -int primitiveAsyncFileReadResult(void) { - AsyncFile *f; - int startIndex; - int buffer; - int bufferPtr; - int bufferSize; - int count; - int fmt; - int r; - int sp; - int integerPointer; - int integerPointer1; - int oop; - int successValue; - int header; - int successValue1; - int sz; - - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - count = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - count = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - /* begin stackIntegerValue: */ - integerPointer1 = longAt(stackPointer - (1 * 4)); - if ((integerPointer1 & 1)) { - startIndex = (integerPointer1 >> 1); - goto l2; - } else { - /* begin primitiveFail */ - successFlag = 0; - startIndex = 0; - goto l2; - } -l2: /* end stackIntegerValue: */; - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (2 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - buffer = null; - goto l3; - } - buffer = oop; -l3: /* end stackObjectValue: */; - f = asyncFileValueOf(longAt(stackPointer - (3 * 4))); - if (!(successFlag)) { - return null; - } - fmt = (((unsigned) (longAt(buffer))) >> 8) & 15; - /* begin success: */ - successValue = (fmt == 6) || ((fmt >= 8) && (fmt <= 11)); - successFlag = successValue && successFlag; - /* begin lengthOf: */ - header = longAt(buffer); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(buffer - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - bufferSize = ((unsigned) (sz - 4)) >> 2; - goto l4; - } else { - bufferSize = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l4; - } -l4: /* end lengthOf:baseHeader:format: */; - if (fmt == 6) { - count = count * 4; - startIndex = ((startIndex - 1) * 4) + 1; - bufferSize = bufferSize * 4; - } - /* begin success: */ - successValue1 = (startIndex >= 1) && (((startIndex + count) - 1) <= bufferSize); - successFlag = successValue1 && successFlag; - bufferPtr = ((buffer + 4) + startIndex) - 1; - if (successFlag) { - r = asyncFileReadResult(f, bufferPtr, count); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 5 * 4; - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, ((r << 1) | 1)); - stackPointer = sp; - } -} - -int primitiveAsyncFileReadStart(void) { - AsyncFile *f; - int fPosition; - int count; - int integerPointer; - int integerPointer1; - - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - count = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - count = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - /* begin stackIntegerValue: */ - integerPointer1 = longAt(stackPointer - (1 * 4)); - if ((integerPointer1 & 1)) { - fPosition = (integerPointer1 >> 1); - goto l2; - } else { - /* begin primitiveFail */ - successFlag = 0; - fPosition = 0; - goto l2; - } -l2: /* end stackIntegerValue: */; - f = asyncFileValueOf(longAt(stackPointer - (2 * 4))); - if (successFlag) { - asyncFileReadStart(f, fPosition, count); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 3 * 4; - } -} - -int primitiveAsyncFileWriteResult(void) { - AsyncFile *f; - int r; - int sp; - - f = asyncFileValueOf(longAt(stackPointer)); - if (successFlag) { - r = asyncFileWriteResult(f); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, ((r << 1) | 1)); - stackPointer = sp; - } -} - -int primitiveAsyncFileWriteStart(void) { - AsyncFile *f; - int startIndex; - int buffer; - int bufferPtr; - int bufferSize; - int count; - int fPosition; - int fmt; - int integerPointer; - int integerPointer1; - int oop; - int integerPointer2; - int successValue; - int header; - int successValue1; - int sz; - - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - count = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - count = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - /* begin stackIntegerValue: */ - integerPointer1 = longAt(stackPointer - (1 * 4)); - if ((integerPointer1 & 1)) { - startIndex = (integerPointer1 >> 1); - goto l2; - } else { - /* begin primitiveFail */ - successFlag = 0; - startIndex = 0; - goto l2; - } -l2: /* end stackIntegerValue: */; - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (2 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - buffer = null; - goto l3; - } - buffer = oop; -l3: /* end stackObjectValue: */; - /* begin stackIntegerValue: */ - integerPointer2 = longAt(stackPointer - (3 * 4)); - if ((integerPointer2 & 1)) { - fPosition = (integerPointer2 >> 1); - goto l4; - } else { - /* begin primitiveFail */ - successFlag = 0; - fPosition = 0; - goto l4; - } -l4: /* end stackIntegerValue: */; - f = asyncFileValueOf(longAt(stackPointer - (4 * 4))); - if (!(successFlag)) { - return null; - } - fmt = (((unsigned) (longAt(buffer))) >> 8) & 15; - /* begin success: */ - successValue = (fmt == 6) || ((fmt >= 8) && (fmt <= 11)); - successFlag = successValue && successFlag; - /* begin lengthOf: */ - header = longAt(buffer); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(buffer - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - bufferSize = ((unsigned) (sz - 4)) >> 2; - goto l5; - } else { - bufferSize = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l5; - } -l5: /* end lengthOf:baseHeader:format: */; - if (fmt == 6) { - count = count * 4; - startIndex = ((startIndex - 1) * 4) + 1; - bufferSize = bufferSize * 4; - } - /* begin success: */ - successValue1 = (startIndex >= 1) && (((startIndex + count) - 1) <= bufferSize); - successFlag = successValue1 && successFlag; - bufferPtr = ((buffer + 4) + startIndex) - 1; - if (successFlag) { - asyncFileWriteStart(f, fPosition, bufferPtr, count); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 5 * 4; - } -} - -int primitiveAt(void) { - commonAt(0); -} - -int primitiveAtEnd(void) { - int stream; - int index; - int limit; - int sp; - int sp1; - int top; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - stream = top; - successFlag = (((((unsigned) (longAt(stream))) >> 8) & 15) <= 4) && ((lengthOf(stream)) >= (2 + 1)); - if (successFlag) { - index = fetchIntegerofObject(1, stream); - limit = fetchIntegerofObject(2, stream); - } - if (successFlag) { - /* begin pushBool: */ - if (index >= limit) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } - } else { - /* begin unPop: */ - stackPointer += 1 * 4; - } -} - -int primitiveAtPut(void) { - commonAtPut(0); -} - -int primitiveBeCursor(void) { - int maskObj; - int maskBitsIndex; - int depth; - int i; - int bitsObj; - int extentX; - int extentY; - int cursorObj; - int offsetObj; - int offsetX; - int offsetY; - int cursorBitsIndex; - int ourCursor; - int successValue; - int successValue1; - int successValue2; - int successValue3; - int successValue4; - int successValue5; - int successValue6; - int successValue7; - int successValue8; - - if (argumentCount == 0) { - cursorObj = longAt(stackPointer); - maskBitsIndex = null; - } - if (argumentCount == 1) { - cursorObj = longAt(stackPointer - (1 * 4)); - maskObj = longAt(stackPointer); - } - /* begin success: */ - successFlag = (argumentCount < 2) && successFlag; - /* begin success: */ - successValue7 = (((((unsigned) (longAt(cursorObj))) >> 8) & 15) <= 4) && ((lengthOf(cursorObj)) >= 5); - successFlag = successValue7 && successFlag; - if (successFlag) { - bitsObj = longAt(((((char *) cursorObj)) + 4) + (0 << 2)); - extentX = fetchIntegerofObject(1, cursorObj); - extentY = fetchIntegerofObject(2, cursorObj); - depth = fetchIntegerofObject(3, cursorObj); - offsetObj = longAt(((((char *) cursorObj)) + 4) + (4 << 2)); - } - /* begin success: */ - successValue8 = (((((unsigned) (longAt(offsetObj))) >> 8) & 15) <= 4) && ((lengthOf(offsetObj)) >= 2); - successFlag = successValue8 && successFlag; - if (successFlag) { - offsetX = fetchIntegerofObject(0, offsetObj); - offsetY = fetchIntegerofObject(1, offsetObj); - /* begin success: */ - successValue = (extentX == 16) && ((extentY == 16) && (depth == 1)); - successFlag = successValue && successFlag; - /* begin success: */ - successValue1 = (offsetX >= -16) && (offsetX <= 0); - successFlag = successValue1 && successFlag; - /* begin success: */ - successValue2 = (offsetY >= -16) && (offsetY <= 0); - successFlag = successValue2 && successFlag; - /* begin success: */ - successValue3 = (((((unsigned) (longAt(bitsObj))) >> 8) & 15) == 6) && ((lengthOf(bitsObj)) == 16); - successFlag = successValue3 && successFlag; - cursorBitsIndex = bitsObj + 4; - ; - } - if (argumentCount == 1) { - /* begin success: */ - successValue6 = (((((unsigned) (longAt(maskObj))) >> 8) & 15) <= 4) && ((lengthOf(maskObj)) >= 5); - successFlag = successValue6 && successFlag; - if (successFlag) { - bitsObj = longAt(((((char *) maskObj)) + 4) + (0 << 2)); - extentX = fetchIntegerofObject(1, maskObj); - extentY = fetchIntegerofObject(2, maskObj); - depth = fetchIntegerofObject(3, maskObj); - } - if (successFlag) { - /* begin success: */ - successValue4 = (extentX == 16) && ((extentY == 16) && (depth == 1)); - successFlag = successValue4 && successFlag; - /* begin success: */ - successValue5 = (((((unsigned) (longAt(bitsObj))) >> 8) & 15) == 6) && ((lengthOf(bitsObj)) == 16); - successFlag = successValue5 && successFlag; - maskBitsIndex = bitsObj + 4; - } - } - if (successFlag) { - if (argumentCount == 0) { - ioSetCursor(cursorBitsIndex, offsetX, offsetY); - } else { - ioSetCursorWithMask(cursorBitsIndex, maskBitsIndex, offsetX, offsetY); - } - /* begin pop: */ - stackPointer -= argumentCount * 4; - } -} - -int primitiveBeDisplay(void) { - int rcvr; - int oop; - int successValue; - - rcvr = longAt(stackPointer); - /* begin success: */ - successValue = (((((unsigned) (longAt(rcvr))) >> 8) & 15) <= 4) && ((lengthOf(rcvr)) >= 4); - successFlag = successValue && successFlag; - if (successFlag) { - /* begin storePointer:ofObject:withValue: */ - oop = specialObjectsOop; - if (oop < youngStart) { - possibleRootStoreIntovalue(oop, rcvr); - } - longAtput(((((char *) oop)) + 4) + (14 << 2), rcvr); - } -} - -int primitiveBeep(void) { - ioBeep(); -} - -int primitiveBitAnd(void) { - int integerReceiver; - int integerArgument; - int object; - int sp; - int top; - int top1; - int top2; - int top11; - - /* begin popPos32BitInteger */ - /* begin popStack */ - top1 = longAt(stackPointer); - stackPointer -= 4; - top = top1; - integerArgument = positive32BitValueOf(top); - /* begin popPos32BitInteger */ - /* begin popStack */ - top11 = longAt(stackPointer); - stackPointer -= 4; - top2 = top11; - integerReceiver = positive32BitValueOf(top2); - if (successFlag) { - /* begin push: */ - object = positive32BitIntegerFor(integerReceiver & integerArgument); - longAtput(sp = stackPointer + 4, object); - stackPointer = sp; - } else { - /* begin unPop: */ - stackPointer += 2 * 4; - } -} - -int primitiveBitOr(void) { - int integerReceiver; - int integerArgument; - int object; - int sp; - int top; - int top1; - int top2; - int top11; - - /* begin popPos32BitInteger */ - /* begin popStack */ - top1 = longAt(stackPointer); - stackPointer -= 4; - top = top1; - integerArgument = positive32BitValueOf(top); - /* begin popPos32BitInteger */ - /* begin popStack */ - top11 = longAt(stackPointer); - stackPointer -= 4; - top2 = top11; - integerReceiver = positive32BitValueOf(top2); - if (successFlag) { - /* begin push: */ - object = positive32BitIntegerFor(integerReceiver | integerArgument); - longAtput(sp = stackPointer + 4, object); - stackPointer = sp; - } else { - /* begin unPop: */ - stackPointer += 2 * 4; - } -} - -int primitiveBitShift(void) { - int shifted; - int integerReceiver; - int integerArgument; - int object; - int sp; - int integerPointer; - int top; - int top2; - int top1; - - /* begin popInteger */ - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - integerPointer = top; - if ((integerPointer & 1)) { - integerArgument = (integerPointer >> 1); - goto l1; - } else { - successFlag = 0; - integerArgument = 1; - goto l1; - } -l1: /* end popInteger */; - /* begin popPos32BitInteger */ - /* begin popStack */ - top1 = longAt(stackPointer); - stackPointer -= 4; - top2 = top1; - integerReceiver = positive32BitValueOf(top2); - if (successFlag) { - if (integerArgument >= 0) { - /* begin success: */ - successFlag = (integerArgument <= 31) && successFlag; - shifted = integerReceiver << integerArgument; - /* begin success: */ - successFlag = ((((unsigned) shifted) >> integerArgument) == integerReceiver) && successFlag; - } else { - /* begin success: */ - successFlag = (integerArgument >= -31) && successFlag; - shifted = ((integerArgument < 0) ? ((unsigned) integerReceiver >> -integerArgument) : ((unsigned) integerReceiver << integerArgument)); - } - } - if (successFlag) { - /* begin push: */ - object = positive32BitIntegerFor(shifted); - longAtput(sp = stackPointer + 4, object); - stackPointer = sp; - } else { - /* begin unPop: */ - stackPointer += 2 * 4; - } -} - -int primitiveBitXor(void) { - int integerReceiver; - int integerArgument; - int object; - int sp; - int top; - int top1; - int top2; - int top11; - - /* begin popPos32BitInteger */ - /* begin popStack */ - top1 = longAt(stackPointer); - stackPointer -= 4; - top = top1; - integerArgument = positive32BitValueOf(top); - /* begin popPos32BitInteger */ - /* begin popStack */ - top11 = longAt(stackPointer); - stackPointer -= 4; - top2 = top11; - integerReceiver = positive32BitValueOf(top2); - if (successFlag) { - /* begin push: */ - object = positive32BitIntegerFor(integerReceiver ^ integerArgument); - longAtput(sp = stackPointer + 4, object); - stackPointer = sp; - } else { - /* begin unPop: */ - stackPointer += 2 * 4; - } -} - -int primitiveBlockCopy(void) { - int methodContext; - int newContext; - int initialIP; - int context; - int contextSize; - int header; - int oop; - int sp; - - context = longAt(stackPointer - (1 * 4)); - if (((longAt(((((char *) context)) + 4) + (3 << 2))) & 1)) { - methodContext = longAt(((((char *) context)) + 4) + (5 << 2)); - } else { - methodContext = context; - } - /* begin sizeBitsOf: */ - header = longAt(methodContext); - if ((header & 3) == 0) { - contextSize = (longAt(methodContext - 8)) & 4294967292U; - goto l1; - } else { - contextSize = header & 252; - goto l1; - } -l1: /* end sizeBitsOf: */; - context = null; - /* begin pushRemappableOop: */ - remapBuffer[remapBufferCount += 1] = methodContext; - newContext = instantiateContextsizeInBytes(longAt(((((char *) specialObjectsOop)) + 4) + (11 << 2)), contextSize); - /* begin popRemappableOop */ - oop = remapBuffer[remapBufferCount]; - remapBufferCount -= 1; - methodContext = oop; - initialIP = (((instructionPointer - method) << 1) | 1); - longAtput(((((char *) newContext)) + 4) + (4 << 2), initialIP); - longAtput(((((char *) newContext)) + 4) + (1 << 2), initialIP); - /* begin storeStackPointerValue:inContext: */ - longAtput(((((char *) newContext)) + 4) + (2 << 2), ((0 << 1) | 1)); - longAtput(((((char *) newContext)) + 4) + (3 << 2), longAt(stackPointer - (0 * 4))); - longAtput(((((char *) newContext)) + 4) + (5 << 2), methodContext); - longAtput(((((char *) newContext)) + 4) + (0 << 2), nilObj); - /* begin pop:thenPush: */ - longAtput(sp = stackPointer - ((2 - 1) * 4), newContext); - stackPointer = sp; -} - -int primitiveBytesLeft(void) { - int sp; - - /* begin pop: */ - stackPointer -= 1 * 4; - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, ((((longAt(freeBlock)) & 4294967292U) << 1) | 1)); - stackPointer = sp; -} - -int primitiveClass(void) { - int instance; - int top; - int object; - int sp; - int ccIndex; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - instance = top; - /* begin push: */ - /* begin fetchClassOf: */ - if ((instance & 1)) { - object = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l1; - } - ccIndex = (((unsigned) (longAt(instance))) >> 12) & 31; - if (ccIndex == 0) { - object = (longAt(instance - 4)) & 4294967292U; - goto l1; - } else { - object = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l1; - } -l1: /* end fetchClassOf: */; - longAtput(sp = stackPointer + 4, object); - stackPointer = sp; -} - -int primitiveClipboardText(void) { - int sz; - int s; - int sp; - int hdr; - int totalLength; - int fmt; - int fixedFields; - int sp1; - int classFormat; - int class; - int sz1; - int ccIndex; - int ccIndex1; - int cl; - - if (argumentCount == 1) { - s = longAt(stackPointer); - /* begin assertClassOf:is: */ - if ((s & 1)) { - successFlag = 0; - goto l5; - } - ccIndex1 = (((unsigned) (longAt(s))) >> 12) & 31; - if (ccIndex1 == 0) { - cl = (longAt(s - 4)) & 4294967292U; - } else { - cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex1 - 1) << 2)); - } - /* begin success: */ - successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)))) && successFlag; - l5: /* end assertClassOf:is: */; - if (successFlag) { - /* begin stSizeOf: */ - hdr = longAt(s); - fmt = (((unsigned) hdr) >> 8) & 15; - /* begin lengthOf:baseHeader:format: */ - if ((hdr & 3) == 0) { - sz1 = (longAt(s - 8)) & 4294967292U; - } else { - sz1 = hdr & 252; - } - if (fmt < 8) { - totalLength = ((unsigned) (sz1 - 4)) >> 2; - goto l2; - } else { - totalLength = (sz1 - 4) - (fmt & 3); - goto l2; - } - l2: /* end lengthOf:baseHeader:format: */; - /* begin fixedFieldsOf:format:length: */ - if ((fmt > 4) || (fmt == 2)) { - fixedFields = 0; - goto l1; - } - if (fmt < 2) { - fixedFields = totalLength; - goto l1; - } - /* begin fetchClassOf: */ - if ((s & 1)) { - class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l3; - } - ccIndex = (((unsigned) (longAt(s))) >> 12) & 31; - if (ccIndex == 0) { - class = (longAt(s - 4)) & 4294967292U; - goto l3; - } else { - class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l3; - } - l3: /* end fetchClassOf: */; - classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; - fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; - l1: /* end fixedFieldsOf:format:length: */; - if ((fmt == 3) && (isContextHeader(hdr))) { - /* begin fetchStackPointerOf: */ - sp1 = longAt(((((char *) s)) + 4) + (2 << 2)); - if (!((sp1 & 1))) { - sz = 0; - goto l4; - } - sz = (sp1 >> 1); - goto l4; - } else { - sz = totalLength - fixedFields; - goto l4; - } - l4: /* end stSizeOf: */; - clipboardWriteFromAt(sz, s + 4, 0); - /* begin pop: */ - stackPointer -= 1 * 4; - } - } else { - sz = clipboardSize(); - s = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)), sz); - clipboardReadIntoAt(sz, s + 4, 0); - /* begin pop: */ - stackPointer -= 1 * 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, s); - stackPointer = sp; - } -} - -int primitiveClone(void) { - int newCopy; - int sp; - - newCopy = clone(longAt(stackPointer)); - /* begin pop:thenPush: */ - longAtput(sp = stackPointer - ((1 - 1) * 4), newCopy); - stackPointer = sp; -} - -int primitiveConstantFill(void) { - int i; - int end; - int fillValue; - int rcvr; - int rcvrIsBytes; - int successValue; - int successValue1; - int fmt; - - fillValue = positive32BitValueOf(longAt(stackPointer)); - rcvr = longAt(stackPointer - (1 * 4)); - /* begin success: */ - /* begin isWordsOrBytes: */ - fmt = (((unsigned) (longAt(rcvr))) >> 8) & 15; - successValue1 = (fmt == 6) || ((fmt >= 8) && (fmt <= 11)); - successFlag = successValue1 && successFlag; - rcvrIsBytes = ((((unsigned) (longAt(rcvr))) >> 8) & 15) >= 8; - if (rcvrIsBytes) { - /* begin success: */ - successValue = (fillValue >= 0) && (fillValue <= 255); - successFlag = successValue && successFlag; - } - if (successFlag) { - end = rcvr + (sizeBitsOf(rcvr)); - i = rcvr + 4; - if (rcvrIsBytes) { - while (i < end) { - byteAtput(i, fillValue); - i += 1; - } - } else { - while (i < end) { - longAtput(i, fillValue); - i += 4; - } - } - /* begin pop: */ - stackPointer -= 1 * 4; - } -} - -int primitiveCopyBits(void) { - int rcvr; - int successValue; - - rcvr = longAt(stackPointer - (argumentCount * 4)); - /* begin success: */ - successValue = loadBitBltFrom(rcvr); - successFlag = successValue && successFlag; - if (successFlag) { - copyBits(); - showDisplayBits(); - } -} - -int primitiveDeferDisplayUpdates(void) { - int flag; - - flag = longAt(stackPointer); - if (flag == trueObj) { - deferDisplayUpdates = 1; - } else { - if (flag == falseObj) { - deferDisplayUpdates = 0; - } else { - /* begin primitiveFail */ - successFlag = 0; - } - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 1 * 4; - } -} - -int primitiveDirectoryCreate(void) { - int dirName; - int dirNameIndex; - int dirNameSize; - int header; - int sz; - - dirName = longAt(stackPointer); - /* begin success: */ - successFlag = (((((unsigned) (longAt(dirName))) >> 8) & 15) >= 8) && successFlag; - if (successFlag) { - dirNameIndex = dirName + 4; - /* begin lengthOf: */ - header = longAt(dirName); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(dirName - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - dirNameSize = ((unsigned) (sz - 4)) >> 2; - goto l1; - } else { - dirNameSize = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l1; - } - l1: /* end lengthOf:baseHeader:format: */; - } - if (successFlag) { - /* begin success: */ - successFlag = (dir_Create((char *) dirNameIndex, dirNameSize)) && successFlag; - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 1 * 4; - } -} - -int primitiveDirectoryDelete(void) { - int dirName; - int dirNameIndex; - int dirNameSize; - int header; - int sz; - - dirName = longAt(stackPointer); - /* begin success: */ - successFlag = (((((unsigned) (longAt(dirName))) >> 8) & 15) >= 8) && successFlag; - if (successFlag) { - dirNameIndex = dirName + 4; - /* begin lengthOf: */ - header = longAt(dirName); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(dirName - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - dirNameSize = ((unsigned) (sz - 4)) >> 2; - goto l1; - } else { - dirNameSize = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l1; - } - l1: /* end lengthOf:baseHeader:format: */; - } - if (successFlag) { - /* begin success: */ - successFlag = (dir_Delete((char *) dirNameIndex, dirNameSize)) && successFlag; - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 1 * 4; - } -} - -int primitiveDirectoryDelimitor(void) { - int ascii; - int sp; - int successValue; - - ascii = asciiDirectoryDelimiter(); - /* begin success: */ - successValue = (ascii >= 0) && (ascii <= 255); - successFlag = successValue && successFlag; - if (successFlag) { - /* begin pop: */ - stackPointer -= 1 * 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (24 << 2))))) + 4) + (ascii << 2))); - stackPointer = sp; - } -} - -int primitiveDirectoryLookup(void) { - int dirFlag; - int pathName; - int pathNameIndex; - int pathNameSize; - int status; - int modifiedDate; - char entryName[256]; - int entryNameSize; - int index; - int createDate; - int fileSize; - int header; - int sz; - int sp; - int object; - int sp1; - int integerPointer; - - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - index = (integerPointer >> 1); - goto l2; - } else { - /* begin primitiveFail */ - successFlag = 0; - index = 0; - goto l2; - } -l2: /* end stackIntegerValue: */; - pathName = longAt(stackPointer - (1 * 4)); - /* begin success: */ - successFlag = (((((unsigned) (longAt(pathName))) >> 8) & 15) >= 8) && successFlag; - if (successFlag) { - pathNameIndex = pathName + 4; - /* begin lengthOf: */ - header = longAt(pathName); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(pathName - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - pathNameSize = ((unsigned) (sz - 4)) >> 2; - goto l1; - } else { - pathNameSize = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l1; - } - pathNameSize = null; - l1: /* end lengthOf: */; - } - if (successFlag) { - status = dir_Lookup( - (char *) pathNameIndex, pathNameSize, index, - entryName, &entryNameSize, &createDate, &modifiedDate, - &dirFlag, &fileSize); - if (status == 1) { - /* begin pop: */ - stackPointer -= 3 * 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, nilObj); - stackPointer = sp; - return null; - } - if (status == 2) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 3 * 4; - /* begin push: */ - object = makeDirEntryNamesizecreateDatemodDateisDirfileSize(entryName, entryNameSize, createDate, modifiedDate, dirFlag, fileSize); - longAtput(sp1 = stackPointer + 4, object); - stackPointer = sp1; - } -} - -int primitiveDirectorySetMacTypeAndCreator(void) { - int typeStringIndex; - int typeString; - int creatorString; - int fileName; - int creatorStringIndex; - int fileNameIndex; - int fileNameSize; - int header; - int sz; - int successValue; - int successValue1; - - creatorString = longAt(stackPointer); - typeString = longAt(stackPointer - (1 * 4)); - fileName = longAt(stackPointer - (2 * 4)); - /* begin success: */ - successValue = (((((unsigned) (longAt(creatorString))) >> 8) & 15) >= 8) && ((lengthOf(creatorString)) == 4); - successFlag = successValue && successFlag; - /* begin success: */ - successValue1 = (((((unsigned) (longAt(typeString))) >> 8) & 15) >= 8) && ((lengthOf(typeString)) == 4); - successFlag = successValue1 && successFlag; - /* begin success: */ - successFlag = (((((unsigned) (longAt(fileName))) >> 8) & 15) >= 8) && successFlag; - if (successFlag) { - creatorStringIndex = creatorString + 4; - typeStringIndex = typeString + 4; - fileNameIndex = fileName + 4; - /* begin lengthOf: */ - header = longAt(fileName); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(fileName - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - fileNameSize = ((unsigned) (sz - 4)) >> 2; - goto l1; - } else { - fileNameSize = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l1; - } - fileNameSize = null; - l1: /* end lengthOf: */; - } - if (successFlag) { - /* begin success: */ - successFlag = (dir_SetMacFileTypeAndCreator( - (char *) fileNameIndex, fileNameSize, - (char *) typeStringIndex, (char *) creatorStringIndex)) && successFlag; - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 3 * 4; - } -} - -int primitiveDiv(void) { - int quotient; - int sp; - - quotient = doPrimitiveDivby(longAt(stackPointer - (1 * 4)), longAt(stackPointer - (0 * 4))); - /* begin pop2AndPushIntegerIfOK: */ - if (successFlag) { - if ((quotient ^ (quotient << 1)) >= 0) { - /* begin pop:thenPush: */ - longAtput(sp = stackPointer - ((2 - 1) * 4), ((quotient << 1) | 1)); - stackPointer = sp; - } else { - successFlag = 0; - } - } -} - -int primitiveDivide(void) { - int integerReceiver; - int integerArgument; - int integerPointer; - int integerPointer1; - int sp; - - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (1 * 4)); - if ((integerPointer & 1)) { - integerReceiver = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - integerReceiver = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - /* begin stackIntegerValue: */ - integerPointer1 = longAt(stackPointer - (0 * 4)); - if ((integerPointer1 & 1)) { - integerArgument = (integerPointer1 >> 1); - goto l2; - } else { - /* begin primitiveFail */ - successFlag = 0; - integerArgument = 0; - goto l2; - } -l2: /* end stackIntegerValue: */; - if ((integerArgument != 0) && ((integerReceiver % integerArgument) == 0)) { - /* begin pop2AndPushIntegerIfOK: */ - if (successFlag) { - if (((integerReceiver / integerArgument) ^ ((integerReceiver / integerArgument) << 1)) >= 0) { - /* begin pop:thenPush: */ - longAtput(sp = stackPointer - ((2 - 1) * 4), (((integerReceiver / integerArgument) << 1) | 1)); - stackPointer = sp; - } else { - successFlag = 0; - } - } - } else { - /* begin primitiveFail */ - successFlag = 0; - } -} - -int primitiveDoPrimitiveWithArgs(void) { - int primIdx; - int argumentArray; - int arraySize; - int index; - int cntxSize; - int sp; - int sp1; - int sp2; - int sz; - int objectPointer; - int sz1; - int integerPointer; - int oop; - int header; - int header1; - int ccIndex; - int cl; - - argumentArray = longAt(stackPointer); - /* begin fetchWordLengthOf: */ - /* begin sizeBitsOf: */ - header = longAt(argumentArray); - if ((header & 3) == 0) { - sz = (longAt(argumentArray - 8)) & 4294967292U; - goto l2; - } else { - sz = header & 252; - goto l2; - } -l2: /* end sizeBitsOf: */; - arraySize = ((unsigned) (sz - 4)) >> 2; - /* begin fetchWordLengthOf: */ - objectPointer = activeContext; - /* begin sizeBitsOf: */ - header1 = longAt(objectPointer); - if ((header1 & 3) == 0) { - sz1 = (longAt(objectPointer - 8)) & 4294967292U; - goto l3; - } else { - sz1 = header1 & 252; - goto l3; - } -l3: /* end sizeBitsOf: */; - cntxSize = ((unsigned) (sz1 - 4)) >> 2; - /* begin success: */ - successFlag = (((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) + arraySize) < cntxSize) && successFlag; - /* begin assertClassOf:is: */ - if ((argumentArray & 1)) { - successFlag = 0; - goto l4; - } - ccIndex = (((unsigned) (longAt(argumentArray))) >> 12) & 31; - if (ccIndex == 0) { - cl = (longAt(argumentArray - 4)) & 4294967292U; - } else { - cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - } - /* begin success: */ - successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)))) && successFlag; -l4: /* end assertClassOf:is: */; - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (1 * 4)); - if ((integerPointer & 1)) { - primIdx = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - primIdx = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - if (!(successFlag)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin pop: */ - stackPointer -= 2 * 4; - primitiveIndex = primIdx; - argumentCount = arraySize; - index = 1; - while (index <= argumentCount) { - /* begin push: */ - longAtput(sp = stackPointer + 4, longAt(((((char *) argumentArray)) + 4) + ((index - 1) << 2))); - stackPointer = sp; - index += 1; - } - /* begin pushRemappableOop: */ - remapBuffer[remapBufferCount += 1] = argumentArray; - lkupClass = nilObj; - primitiveResponse(); - /* begin popRemappableOop */ - oop = remapBuffer[remapBufferCount]; - remapBufferCount -= 1; - argumentArray = oop; - if (!(successFlag)) { - /* begin pop: */ - stackPointer -= arraySize * 4; - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp1 = stackPointer + 4, ((primIdx << 1) | 1)); - stackPointer = sp1; - /* begin push: */ - longAtput(sp2 = stackPointer + 4, argumentArray); - stackPointer = sp2; - argumentCount = 2; - } -} - -int primitiveDrawLoop(void) { - int yDelta; - int rcvr; - int xDelta; - int affL; - int dx1; - int dy1; - int px; - int py; - int affR; - int affT; - int affB; - int i; - int P; - int integerPointer; - int integerPointer1; - int successValue; - - rcvr = longAt(stackPointer - (2 * 4)); - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (1 * 4)); - if ((integerPointer & 1)) { - xDelta = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - xDelta = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - /* begin stackIntegerValue: */ - integerPointer1 = longAt(stackPointer - (0 * 4)); - if ((integerPointer1 & 1)) { - yDelta = (integerPointer1 >> 1); - goto l2; - } else { - /* begin primitiveFail */ - successFlag = 0; - yDelta = 0; - goto l2; - } -l2: /* end stackIntegerValue: */; - /* begin success: */ - successValue = loadBitBltFrom(rcvr); - successFlag = successValue && successFlag; - if (successFlag) { - /* begin drawLoopX:Y: */ - if (xDelta > 0) { - dx1 = 1; - } else { - if (xDelta == 0) { - dx1 = 0; - } else { - dx1 = -1; - } - } - if (yDelta > 0) { - dy1 = 1; - } else { - if (yDelta == 0) { - dy1 = 0; - } else { - dy1 = -1; - } - } - px = abs(yDelta); - py = abs(xDelta); - affL = affT = 9999; - affR = affB = -9999; - if (py > px) { - P = ((int) py >> 1); - for (i = 1; i <= py; i += 1) { - destX += dx1; - if ((P -= px) < 0) { - destY += dy1; - P += py; - } - if (i < py) { - copyBits(); - if ((affectedL < affectedR) && (affectedT < affectedB)) { - affL = ((affL < affectedL) ? affL : affectedL); - affR = ((affR < affectedR) ? affectedR : affR); - affT = ((affT < affectedT) ? affT : affectedT); - affB = ((affB < affectedB) ? affectedB : affB); - if (((affR - affL) * (affB - affT)) > 4000) { - affectedL = affL; - affectedR = affR; - affectedT = affT; - affectedB = affB; - showDisplayBits(); - affL = affT = 9999; - affR = affB = -9999; - } - } - } - } - } else { - P = ((int) px >> 1); - for (i = 1; i <= px; i += 1) { - destY += dy1; - if ((P -= py) < 0) { - destX += dx1; - P += px; - } - if (i < px) { - copyBits(); - if ((affectedL < affectedR) && (affectedT < affectedB)) { - affL = ((affL < affectedL) ? affL : affectedL); - affR = ((affR < affectedR) ? affectedR : affR); - affT = ((affT < affectedT) ? affT : affectedT); - affB = ((affB < affectedB) ? affectedB : affB); - if (((affR - affL) * (affB - affT)) > 4000) { - affectedL = affL; - affectedR = affR; - affectedT = affT; - affectedB = affB; - showDisplayBits(); - affL = affT = 9999; - affR = affB = -9999; - } - } - } - } - } - affectedL = affL; - affectedR = affR; - affectedT = affT; - affectedB = affB; - /* begin storeInteger:ofObject:withValue: */ - if ((destX ^ (destX << 1)) >= 0) { - longAtput(((((char *) bitBltOop)) + 4) + (4 << 2), ((destX << 1) | 1)); - } else { - /* begin primitiveFail */ - successFlag = 0; - } - /* begin storeInteger:ofObject:withValue: */ - if ((destY ^ (destY << 1)) >= 0) { - longAtput(((((char *) bitBltOop)) + 4) + (5 << 2), ((destY << 1) | 1)); - } else { - /* begin primitiveFail */ - successFlag = 0; - } - showDisplayBits(); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 2 * 4; - } -} - -int primitiveEqual(void) { - int integerReceiver; - int integerArgument; - int result; - int top; - int top1; - int sp; - int sp1; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - integerArgument = top; - /* begin popStack */ - top1 = longAt(stackPointer); - stackPointer -= 4; - integerReceiver = top1; - /* begin compare31or32Bits:equal: */ - if (((integerReceiver & 1)) && ((integerArgument & 1))) { - result = integerReceiver == integerArgument; - goto l1; - } - result = (positive32BitValueOf(integerReceiver)) == (positive32BitValueOf(integerArgument)); -l1: /* end compare31or32Bits:equal: */; - /* begin checkBooleanResult: */ - if (successFlag) { - /* begin pushBool: */ - if (result) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } - } else { - /* begin unPop: */ - stackPointer += 2 * 4; - } -} - -int primitiveEquivalent(void) { - int thisObject; - int otherObject; - int sp; - int sp1; - int top; - int top1; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - otherObject = top; - /* begin popStack */ - top1 = longAt(stackPointer); - stackPointer -= 4; - thisObject = top1; - /* begin pushBool: */ - if (thisObject == otherObject) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } -} - -int primitiveExitToDebugger(void) { - error("Exit to debugger at user request"); -} - -int primitiveExp(void) { - double rcvr; - - rcvr = popFloat(); - if (successFlag) { - pushFloat(exp(rcvr)); - } else { - /* begin unPop: */ - stackPointer += 1 * 4; - } -} - -int primitiveExponent(void) { - int pwr; - double frac; - double rcvr; - int sp; - - rcvr = popFloat(); - if (successFlag) { - frac = frexp(rcvr, &pwr); - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, (((pwr - 1) << 1) | 1)); - stackPointer = sp; - } else { - /* begin unPop: */ - stackPointer += 1 * 4; - } -} - -int primitiveExternalCall(void) { - int addr; - int moduleName; - int moduleLength; - int session; - static int thisSession = 0; - int lit; - int functionAddress; - int functionName; - int functionLength; - int header; - int sz; - int oop; - int successValue; - int header1; - int sz1; - - if (thisSession == 0) { - thisSession = (ioMicroMSecs()) & 536870911; - if (thisSession == 0) { - thisSession = 1; - } - } - /* begin success: */ - successFlag = (((((unsigned) (longAt(((((char *) newMethod)) + 4) + (0 << 2)))) >> 10) & 255) > 0) && successFlag; - if (!(successFlag)) { - return null; - } - lit = longAt(((((char *) newMethod)) + 4) + ((0 + 1) << 2)); - /* begin success: */ - successValue = ((fetchClassOf(lit)) == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)))) && ((lengthOf(lit)) == 4); - successFlag = successValue && successFlag; - if (!(successFlag)) { - return null; - } - addr = positive32BitValueOf(longAt(((((char *) lit)) + 4) + (3 << 2))); - session = fetchIntegerofObject(2, lit); - if (successFlag && ((session == thisSession) && (addr != 0))) { - return ((int (*) (void)) addr) (); - } - /* begin storeInteger:ofObject:withValue: */ - if ((0 ^ (0 << 1)) >= 0) { - longAtput(((((char *) lit)) + 4) + (2 << 2), ((0 << 1) | 1)); - } else { - /* begin primitiveFail */ - successFlag = 0; - } - /* begin storeInteger:ofObject:withValue: */ - if ((0 ^ (0 << 1)) >= 0) { - longAtput(((((char *) lit)) + 4) + (3 << 2), ((0 << 1) | 1)); - } else { - /* begin primitiveFail */ - successFlag = 0; - } - moduleName = longAt(((((char *) lit)) + 4) + (0 << 2)); - if (moduleName == nilObj) { - moduleLength = 0; - } else { - /* begin success: */ - successFlag = (((((unsigned) (longAt(moduleName))) >> 8) & 15) >= 8) && successFlag; - /* begin lengthOf: */ - header = longAt(moduleName); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(moduleName - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - moduleLength = ((unsigned) (sz - 4)) >> 2; - goto l1; - } else { - moduleLength = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l1; - } - moduleLength = null; - l1: /* end lengthOf: */; - } - functionName = longAt(((((char *) lit)) + 4) + (1 << 2)); - /* begin success: */ - successFlag = (((((unsigned) (longAt(functionName))) >> 8) & 15) >= 8) && successFlag; - /* begin lengthOf: */ - header1 = longAt(functionName); - /* begin lengthOf:baseHeader:format: */ - if ((header1 & 3) == 0) { - sz1 = (longAt(functionName - 8)) & 4294967292U; - } else { - sz1 = header1 & 252; - } - if (((((unsigned) header1) >> 8) & 15) < 8) { - functionLength = ((unsigned) (sz1 - 4)) >> 2; - goto l2; - } else { - functionLength = (sz1 - 4) - (((((unsigned) header1) >> 8) & 15) & 3); - goto l2; - } - functionLength = null; -l2: /* end lengthOf: */; - if (!(successFlag)) { - return null; - } - addr = ioLoadExternalFunctionOfLengthFromModuleOfLength(functionName + 4, functionLength, moduleName + 4, moduleLength); - /* begin success: */ - successFlag = (addr != 0) && successFlag; - if (successFlag) { - /* begin storeInteger:ofObject:withValue: */ - if ((thisSession ^ (thisSession << 1)) >= 0) { - longAtput(((((char *) lit)) + 4) + (2 << 2), ((thisSession << 1) | 1)); - } else { - /* begin primitiveFail */ - successFlag = 0; - } - /* begin pushRemappableOop: */ - remapBuffer[remapBufferCount += 1] = lit; - functionAddress = positive32BitIntegerFor(addr); - /* begin popRemappableOop */ - oop = remapBuffer[remapBufferCount]; - remapBufferCount -= 1; - lit = oop; - /* begin storePointer:ofObject:withValue: */ - if (lit < youngStart) { - possibleRootStoreIntovalue(lit, functionAddress); - } - longAtput(((((char *) lit)) + 4) + (3 << 2), functionAddress); - if (successFlag && (addr != 0)) { - ((int (*) (void)) addr) (); - } - } -} - -EXPORT(int) primitiveFFTPermuteData(void) { - int rcvr; - int oop; - - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - rcvr = null; - goto l1; - } - rcvr = oop; -l1: /* end stackObjectValue: */; - if (!(loadFFTFrom(rcvr))) { - return null; - } - permuteData(); - if (!successFlag) { - permuteData(); - } -} - -EXPORT(int) primitiveFFTScaleData(void) { - int rcvr; - int oop; - - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - rcvr = null; - goto l1; - } - rcvr = oop; -l1: /* end stackObjectValue: */; - if (!(loadFFTFrom(rcvr))) { - return null; - } - scaleData(); -} - -EXPORT(int) primitiveFFTTransformData(void) { - int forward; - int rcvr; - int oop; - - /* begin booleanValueOf: */ - if ((longAt(stackPointer - (0 * 4))) == trueObj) { - forward = 1; - goto l1; - } - if ((longAt(stackPointer - (0 * 4))) == falseObj) { - forward = 0; - goto l1; - } - successFlag = 0; - forward = null; -l1: /* end booleanValueOf: */; - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (1 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - rcvr = null; - goto l2; - } - rcvr = oop; -l2: /* end stackObjectValue: */; - if (!(loadFFTFrom(rcvr))) { - return null; - } - /* begin transformData: */ - permuteData(); - if (!successFlag) { - permuteData(); - goto l3; - } - transformForward(forward); - if (!(forward)) { - scaleData(); - } -l3: /* end transformData: */; - if (!(!successFlag)) { - /* begin pop: */ - stackPointer -= 1 * 4; - } -} - -int primitiveFail(void) { - successFlag = 0; -} - -int primitiveFileAtEnd(void) { - int atEnd; - SQFile *file; - int sp; - int sp1; - - file = fileValueOf(longAt(stackPointer)); - if (successFlag) { - atEnd = sqFileAtEnd(file); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin pushBool: */ - if (atEnd) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } - } -} - -int primitiveFileClose(void) { - SQFile *file; - - file = fileValueOf(longAt(stackPointer)); - if (successFlag) { - sqFileClose(file); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 1 * 4; - } -} - -int primitiveFileDelete(void) { - int nameIndex; - int namePointer; - int nameSize; - int header; - int sz; - - namePointer = longAt(stackPointer); - /* begin success: */ - successFlag = (((((unsigned) (longAt(namePointer))) >> 8) & 15) >= 8) && successFlag; - if (successFlag) { - nameIndex = namePointer + 4; - /* begin lengthOf: */ - header = longAt(namePointer); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(namePointer - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - nameSize = ((unsigned) (sz - 4)) >> 2; - goto l1; - } else { - nameSize = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l1; - } - nameSize = null; - l1: /* end lengthOf: */; - } - if (successFlag) { - sqFileDeleteNameSize(nameIndex, nameSize); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 1 * 4; - } -} - -int primitiveFileGetPosition(void) { - int position; - SQFile *file; - int oop; - int sp; - - file = fileValueOf(longAt(stackPointer)); - if (successFlag) { - position = sqFileGetPosition(file); - } - if (successFlag) { - /* begin pop:thenPush: */ - oop = positive32BitIntegerFor(position); - longAtput(sp = stackPointer - ((2 - 1) * 4), oop); - stackPointer = sp; - } -} - -int primitiveFileOpen(void) { - int writeFlag; - int nameIndex; - int namePointer; - int nameSize; - int filePointer; - SQFile *file; - int header; - int sp; - int sz; - - /* begin booleanValueOf: */ - if ((longAt(stackPointer)) == trueObj) { - writeFlag = 1; - goto l1; - } - if ((longAt(stackPointer)) == falseObj) { - writeFlag = 0; - goto l1; - } - successFlag = 0; - writeFlag = null; -l1: /* end booleanValueOf: */; - namePointer = longAt(stackPointer - (1 * 4)); - /* begin success: */ - successFlag = (((((unsigned) (longAt(namePointer))) >> 8) & 15) >= 8) && successFlag; - if (successFlag) { - filePointer = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (26 << 2)), fileRecordSize()); - file = fileValueOf(filePointer); - nameIndex = namePointer + 4; - /* begin lengthOf: */ - header = longAt(namePointer); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(namePointer - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - nameSize = ((unsigned) (sz - 4)) >> 2; - goto l2; - } else { - nameSize = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l2; - } - l2: /* end lengthOf:baseHeader:format: */; - } - if (successFlag) { - sqFileOpen(file, nameIndex, nameSize, writeFlag); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 3 * 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, filePointer); - stackPointer = sp; - } -} - -int primitiveFileRead(void) { - int array; - int startIndex; - int arrayIndex; - int bytesRead; - int byteSize; - int count; - SQFile *file; - int sp; - int integerPointer; - int integerPointer1; - int successValue; - int successValue1; - int fmt; - - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - count = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - count = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - /* begin stackIntegerValue: */ - integerPointer1 = longAt(stackPointer - (1 * 4)); - if ((integerPointer1 & 1)) { - startIndex = (integerPointer1 >> 1); - goto l2; - } else { - /* begin primitiveFail */ - successFlag = 0; - startIndex = 0; - goto l2; - } -l2: /* end stackIntegerValue: */; - array = longAt(stackPointer - (2 * 4)); - file = fileValueOf(longAt(stackPointer - (3 * 4))); - /* begin success: */ - /* begin isWordsOrBytes: */ - fmt = (((unsigned) (longAt(array))) >> 8) & 15; - successValue = (fmt == 6) || ((fmt >= 8) && (fmt <= 11)); - successFlag = successValue && successFlag; - if (((((unsigned) (longAt(array))) >> 8) & 15) == 6) { - byteSize = 4; - } else { - byteSize = 1; - } - /* begin success: */ - successValue1 = (startIndex >= 1) && (((startIndex + count) - 1) <= (lengthOf(array))); - successFlag = successValue1 && successFlag; - if (successFlag) { - arrayIndex = array + 4; - bytesRead = sqFileReadIntoAt(file, count * byteSize, arrayIndex, (startIndex - 1) * byteSize); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 5 * 4; - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, (((bytesRead / byteSize) << 1) | 1)); - stackPointer = sp; - } -} - -int primitiveFileRename(void) { - int newNameIndex; - int newNamePointer; - int newNameSize; - int oldNamePointer; - int oldNameIndex; - int oldNameSize; - int header; - int header1; - int sz; - int sz1; - - newNamePointer = longAt(stackPointer); - oldNamePointer = longAt(stackPointer - (1 * 4)); - /* begin success: */ - successFlag = (((((unsigned) (longAt(newNamePointer))) >> 8) & 15) >= 8) && successFlag; - /* begin success: */ - successFlag = (((((unsigned) (longAt(oldNamePointer))) >> 8) & 15) >= 8) && successFlag; - if (successFlag) { - newNameIndex = newNamePointer + 4; - /* begin lengthOf: */ - header = longAt(newNamePointer); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(newNamePointer - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - newNameSize = ((unsigned) (sz - 4)) >> 2; - goto l1; - } else { - newNameSize = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l1; - } - l1: /* end lengthOf:baseHeader:format: */; - oldNameIndex = oldNamePointer + 4; - /* begin lengthOf: */ - header1 = longAt(oldNamePointer); - /* begin lengthOf:baseHeader:format: */ - if ((header1 & 3) == 0) { - sz1 = (longAt(oldNamePointer - 8)) & 4294967292U; - } else { - sz1 = header1 & 252; - } - if (((((unsigned) header1) >> 8) & 15) < 8) { - oldNameSize = ((unsigned) (sz1 - 4)) >> 2; - goto l2; - } else { - oldNameSize = (sz1 - 4) - (((((unsigned) header1) >> 8) & 15) & 3); - goto l2; - } - l2: /* end lengthOf:baseHeader:format: */; - } - if (successFlag) { - sqFileRenameOldSizeNewSize(oldNameIndex, oldNameSize, newNameIndex, newNameSize); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 2 * 4; - } -} - -int primitiveFileSetPosition(void) { - int newPosition; - SQFile *file; - - newPosition = positive32BitValueOf(longAt(stackPointer - (0 * 4))); - file = fileValueOf(longAt(stackPointer - (1 * 4))); - if (successFlag) { - sqFileSetPosition(file, newPosition); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 2 * 4; - } -} - -int primitiveFileSize(void) { - int size; - SQFile *file; - int oop; - int sp; - - file = fileValueOf(longAt(stackPointer)); - if (successFlag) { - size = sqFileSize(file); - } - if (successFlag) { - /* begin pop:thenPush: */ - oop = positive32BitIntegerFor(size); - longAtput(sp = stackPointer - ((2 - 1) * 4), oop); - stackPointer = sp; - } -} - -int primitiveFileWrite(void) { - int array; - int startIndex; - int arrayIndex; - int bytesWritten; - int byteSize; - int count; - SQFile *file; - int sp; - int integerPointer; - int integerPointer1; - int successValue; - int successValue1; - int fmt; - - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - count = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - count = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - /* begin stackIntegerValue: */ - integerPointer1 = longAt(stackPointer - (1 * 4)); - if ((integerPointer1 & 1)) { - startIndex = (integerPointer1 >> 1); - goto l2; - } else { - /* begin primitiveFail */ - successFlag = 0; - startIndex = 0; - goto l2; - } -l2: /* end stackIntegerValue: */; - array = longAt(stackPointer - (2 * 4)); - file = fileValueOf(longAt(stackPointer - (3 * 4))); - /* begin success: */ - /* begin isWordsOrBytes: */ - fmt = (((unsigned) (longAt(array))) >> 8) & 15; - successValue = (fmt == 6) || ((fmt >= 8) && (fmt <= 11)); - successFlag = successValue && successFlag; - if (((((unsigned) (longAt(array))) >> 8) & 15) == 6) { - byteSize = 4; - } else { - byteSize = 1; - } - /* begin success: */ - successValue1 = (startIndex >= 1) && (((startIndex + count) - 1) <= (lengthOf(array))); - successFlag = successValue1 && successFlag; - if (successFlag) { - arrayIndex = array + 4; - bytesWritten = sqFileWriteFromAt(file, count * byteSize, arrayIndex, (startIndex - 1) * byteSize); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 5 * 4; - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, (((bytesWritten / byteSize) << 1) | 1)); - stackPointer = sp; - } -} - -int primitiveFloatAddtoArg(int rcvrOop, int argOop) { - double arg; - double rcvr; - - rcvr = loadFloatOrIntFrom(rcvrOop); - arg = loadFloatOrIntFrom(argOop); - if (successFlag) { - /* begin pop: */ - stackPointer -= 2 * 4; - pushFloat(rcvr + arg); - } -} - -EXPORT(int) primitiveFloatArrayAddFloatArray(void) { - int arg; - int i; - float *argPtr; - int rcvr; - float *rcvrPtr; - int length; - int oop; - int oop1; - int successValue; - int hdr; - int totalLength; - int fmt; - int fixedFields; - int sp; - int classFormat; - int class; - int sz; - int ccIndex; - - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - arg = null; - goto l1; - } - arg = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - rcvr = null; - goto l2; - } - rcvr = oop1; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - /* begin success: */ - successFlag = (((((unsigned) (longAt(arg))) >> 8) & 15) == 6) && successFlag; - /* begin success: */ - successFlag = (((((unsigned) (longAt(rcvr))) >> 8) & 15) == 6) && successFlag; - if (!successFlag) { - return null; - } - /* begin stSizeOf: */ - hdr = longAt(arg); - fmt = (((unsigned) hdr) >> 8) & 15; - /* begin lengthOf:baseHeader:format: */ - if ((hdr & 3) == 0) { - sz = (longAt(arg - 8)) & 4294967292U; - } else { - sz = hdr & 252; - } - if (fmt < 8) { - totalLength = ((unsigned) (sz - 4)) >> 2; - goto l5; - } else { - totalLength = (sz - 4) - (fmt & 3); - goto l5; - } -l5: /* end lengthOf:baseHeader:format: */; - /* begin fixedFieldsOf:format:length: */ - if ((fmt > 4) || (fmt == 2)) { - fixedFields = 0; - goto l4; - } - if (fmt < 2) { - fixedFields = totalLength; - goto l4; - } - /* begin fetchClassOf: */ - if ((arg & 1)) { - class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l3; - } - ccIndex = (((unsigned) (longAt(arg))) >> 12) & 31; - if (ccIndex == 0) { - class = (longAt(arg - 4)) & 4294967292U; - goto l3; - } else { - class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l3; - } -l3: /* end fetchClassOf: */; - classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; - fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; -l4: /* end fixedFieldsOf:format:length: */; - if ((fmt == 3) && (isContextHeader(hdr))) { - /* begin fetchStackPointerOf: */ - sp = longAt(((((char *) arg)) + 4) + (2 << 2)); - if (!((sp & 1))) { - length = 0; - goto l6; - } - length = (sp >> 1); - goto l6; - } else { - length = totalLength - fixedFields; - goto l6; - } -l6: /* end stSizeOf: */; - /* begin success: */ - successValue = length == (stSizeOf(rcvr)); - successFlag = successValue && successFlag; - if (!successFlag) { - return null; - } - rcvrPtr = ((float *) (firstIndexableField(rcvr))); - argPtr = ((float *) (firstIndexableField(arg))); - for (i = 0; i <= (length - 1); i += 1) { - rcvrPtr[i] = ((rcvrPtr[i]) + (argPtr[i])); - } - /* begin pop: */ - stackPointer -= 1 * 4; -} - -EXPORT(int) primitiveFloatArrayAddScalar(void) { - int i; - double value; - int rcvr; - float *rcvrPtr; - int length; - int oop; - int hdr; - int totalLength; - int fmt; - int fixedFields; - int sp; - int classFormat; - int class; - int sz; - int ccIndex; - - value = stackFloatValue(0); - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (1 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - rcvr = null; - goto l1; - } - rcvr = oop; -l1: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - /* begin success: */ - successFlag = (((((unsigned) (longAt(rcvr))) >> 8) & 15) == 6) && successFlag; - if (!successFlag) { - return null; - } - /* begin stSizeOf: */ - hdr = longAt(rcvr); - fmt = (((unsigned) hdr) >> 8) & 15; - /* begin lengthOf:baseHeader:format: */ - if ((hdr & 3) == 0) { - sz = (longAt(rcvr - 8)) & 4294967292U; - } else { - sz = hdr & 252; - } - if (fmt < 8) { - totalLength = ((unsigned) (sz - 4)) >> 2; - goto l2; - } else { - totalLength = (sz - 4) - (fmt & 3); - goto l2; - } -l2: /* end lengthOf:baseHeader:format: */; - /* begin fixedFieldsOf:format:length: */ - if ((fmt > 4) || (fmt == 2)) { - fixedFields = 0; - goto l4; - } - if (fmt < 2) { - fixedFields = totalLength; - goto l4; - } - /* begin fetchClassOf: */ - if ((rcvr & 1)) { - class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l3; - } - ccIndex = (((unsigned) (longAt(rcvr))) >> 12) & 31; - if (ccIndex == 0) { - class = (longAt(rcvr - 4)) & 4294967292U; - goto l3; - } else { - class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l3; - } -l3: /* end fetchClassOf: */; - classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; - fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; -l4: /* end fixedFieldsOf:format:length: */; - if ((fmt == 3) && (isContextHeader(hdr))) { - /* begin fetchStackPointerOf: */ - sp = longAt(((((char *) rcvr)) + 4) + (2 << 2)); - if (!((sp & 1))) { - length = 0; - goto l5; - } - length = (sp >> 1); - goto l5; - } else { - length = totalLength - fixedFields; - goto l5; - } -l5: /* end stSizeOf: */; - rcvrPtr = ((float *) (firstIndexableField(rcvr))); - for (i = 0; i <= (length - 1); i += 1) { - rcvrPtr[i] = ((rcvrPtr[i]) + value); - } - /* begin pop: */ - stackPointer -= 1 * 4; -} - -EXPORT(int) primitiveFloatArrayAt(void) { - float *floatPtr; - double floatValue; - int rcvr; - int index; - int integerPointer; - int oop; - int successValue; - - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - index = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - index = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (1 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - rcvr = null; - goto l2; - } - rcvr = oop; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - /* begin success: */ - successFlag = (((((unsigned) (longAt(rcvr))) >> 8) & 15) == 6) && successFlag; - /* begin success: */ - successValue = (index > 0) && (index <= (slotSizeOf(rcvr))); - successFlag = successValue && successFlag; - if (!successFlag) { - return null; - } - floatPtr = firstIndexableField(rcvr); - floatValue = ((double) (floatPtr[index - 1]) ); - /* begin pop: */ - stackPointer -= 2 * 4; - pushFloat(floatValue); -} - -EXPORT(int) primitiveFloatArrayAtPut(void) { - float *floatPtr; - double floatValue; - int value; - int rcvr; - int index; - int sp; - int integerPointer; - int oop; - int successValue; - - value = longAt(stackPointer - (0 * 4)); - if ((value & 1)) { - floatValue = ((double) ((value >> 1)) ); - } else { - floatValue = floatValueOf(value); - } - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (1 * 4)); - if ((integerPointer & 1)) { - index = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - index = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (2 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - rcvr = null; - goto l2; - } - rcvr = oop; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - /* begin success: */ - successFlag = (((((unsigned) (longAt(rcvr))) >> 8) & 15) == 6) && successFlag; - /* begin success: */ - successValue = (index > 0) && (index <= (slotSizeOf(rcvr))); - successFlag = successValue && successFlag; - if (!successFlag) { - return null; - } - floatPtr = firstIndexableField(rcvr); - floatPtr[index - 1] = (((float) floatValue)); - if (!(!successFlag)) { - /* begin pop:thenPush: */ - longAtput(sp = stackPointer - ((3 - 1) * 4), value); - stackPointer = sp; - } -} - -EXPORT(int) primitiveFloatArrayDivFloatArray(void) { - int arg; - int i; - float *argPtr; - int rcvr; - float *rcvrPtr; - int length; - int oop; - int oop1; - int successValue; - int hdr; - int totalLength; - int fmt; - int fixedFields; - int sp; - int classFormat; - int class; - int sz; - int ccIndex; - - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - arg = null; - goto l1; - } - arg = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - rcvr = null; - goto l2; - } - rcvr = oop1; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - /* begin success: */ - successFlag = (((((unsigned) (longAt(arg))) >> 8) & 15) == 6) && successFlag; - /* begin success: */ - successFlag = (((((unsigned) (longAt(rcvr))) >> 8) & 15) == 6) && successFlag; - if (!successFlag) { - return null; - } - /* begin stSizeOf: */ - hdr = longAt(arg); - fmt = (((unsigned) hdr) >> 8) & 15; - /* begin lengthOf:baseHeader:format: */ - if ((hdr & 3) == 0) { - sz = (longAt(arg - 8)) & 4294967292U; - } else { - sz = hdr & 252; - } - if (fmt < 8) { - totalLength = ((unsigned) (sz - 4)) >> 2; - goto l5; - } else { - totalLength = (sz - 4) - (fmt & 3); - goto l5; - } -l5: /* end lengthOf:baseHeader:format: */; - /* begin fixedFieldsOf:format:length: */ - if ((fmt > 4) || (fmt == 2)) { - fixedFields = 0; - goto l4; - } - if (fmt < 2) { - fixedFields = totalLength; - goto l4; - } - /* begin fetchClassOf: */ - if ((arg & 1)) { - class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l3; - } - ccIndex = (((unsigned) (longAt(arg))) >> 12) & 31; - if (ccIndex == 0) { - class = (longAt(arg - 4)) & 4294967292U; - goto l3; - } else { - class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l3; - } -l3: /* end fetchClassOf: */; - classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; - fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; -l4: /* end fixedFieldsOf:format:length: */; - if ((fmt == 3) && (isContextHeader(hdr))) { - /* begin fetchStackPointerOf: */ - sp = longAt(((((char *) arg)) + 4) + (2 << 2)); - if (!((sp & 1))) { - length = 0; - goto l6; - } - length = (sp >> 1); - goto l6; - } else { - length = totalLength - fixedFields; - goto l6; - } -l6: /* end stSizeOf: */; - /* begin success: */ - successValue = length == (stSizeOf(rcvr)); - successFlag = successValue && successFlag; - if (!successFlag) { - return null; - } - rcvrPtr = ((float *) (firstIndexableField(rcvr))); - argPtr = ((float *) (firstIndexableField(arg))); - for (i = 0; i <= (length - 1); i += 1) { - if ((longAt(argPtr + i)) == 0) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - } - for (i = 0; i <= (length - 1); i += 1) { - rcvrPtr[i] = ((rcvrPtr[i]) / (argPtr[i])); - } - /* begin pop: */ - stackPointer -= 1 * 4; -} - -EXPORT(int) primitiveFloatArrayDivScalar(void) { - int length; - int i; - double value; - int rcvr; - float *rcvrPtr; - double inverse; - int oop; - int hdr; - int totalLength; - int fmt; - int fixedFields; - int sp; - int classFormat; - int class; - int sz; - int ccIndex; - - value = stackFloatValue(0); - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (1 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - rcvr = null; - goto l1; - } - rcvr = oop; -l1: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - if (value == 0.0) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - /* begin success: */ - successFlag = (((((unsigned) (longAt(rcvr))) >> 8) & 15) == 6) && successFlag; - if (!successFlag) { - return null; - } - /* begin stSizeOf: */ - hdr = longAt(rcvr); - fmt = (((unsigned) hdr) >> 8) & 15; - /* begin lengthOf:baseHeader:format: */ - if ((hdr & 3) == 0) { - sz = (longAt(rcvr - 8)) & 4294967292U; - } else { - sz = hdr & 252; - } - if (fmt < 8) { - totalLength = ((unsigned) (sz - 4)) >> 2; - goto l2; - } else { - totalLength = (sz - 4) - (fmt & 3); - goto l2; - } -l2: /* end lengthOf:baseHeader:format: */; - /* begin fixedFieldsOf:format:length: */ - if ((fmt > 4) || (fmt == 2)) { - fixedFields = 0; - goto l4; - } - if (fmt < 2) { - fixedFields = totalLength; - goto l4; - } - /* begin fetchClassOf: */ - if ((rcvr & 1)) { - class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l3; - } - ccIndex = (((unsigned) (longAt(rcvr))) >> 12) & 31; - if (ccIndex == 0) { - class = (longAt(rcvr - 4)) & 4294967292U; - goto l3; - } else { - class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l3; - } -l3: /* end fetchClassOf: */; - classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; - fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; -l4: /* end fixedFieldsOf:format:length: */; - if ((fmt == 3) && (isContextHeader(hdr))) { - /* begin fetchStackPointerOf: */ - sp = longAt(((((char *) rcvr)) + 4) + (2 << 2)); - if (!((sp & 1))) { - length = 0; - goto l5; - } - length = (sp >> 1); - goto l5; - } else { - length = totalLength - fixedFields; - goto l5; - } -l5: /* end stSizeOf: */; - rcvrPtr = ((float *) (firstIndexableField(rcvr))); - inverse = 1.0 / value; - for (i = 0; i <= (length - 1); i += 1) { - rcvrPtr[i] = ((rcvrPtr[i]) * inverse); - } - /* begin pop: */ - stackPointer -= 1 * 4; -} - -EXPORT(int) primitiveFloatArrayEqual(void) { - int arg; - int i; - float *argPtr; - int rcvr; - float *rcvrPtr; - int length; - int sp; - int sp1; - int sp2; - int sp11; - int oop; - int oop1; - int sp3; - int sp12; - int hdr; - int totalLength; - int fmt; - int fixedFields; - int sp4; - int classFormat; - int class; - int sz; - int ccIndex; - - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - arg = null; - goto l1; - } - arg = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - rcvr = null; - goto l2; - } - rcvr = oop1; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - /* begin success: */ - successFlag = (((((unsigned) (longAt(arg))) >> 8) & 15) == 6) && successFlag; - /* begin success: */ - successFlag = (((((unsigned) (longAt(rcvr))) >> 8) & 15) == 6) && successFlag; - if (!successFlag) { - return null; - } - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin stSizeOf: */ - hdr = longAt(arg); - fmt = (((unsigned) hdr) >> 8) & 15; - /* begin lengthOf:baseHeader:format: */ - if ((hdr & 3) == 0) { - sz = (longAt(arg - 8)) & 4294967292U; - } else { - sz = hdr & 252; - } - if (fmt < 8) { - totalLength = ((unsigned) (sz - 4)) >> 2; - goto l5; - } else { - totalLength = (sz - 4) - (fmt & 3); - goto l5; - } -l5: /* end lengthOf:baseHeader:format: */; - /* begin fixedFieldsOf:format:length: */ - if ((fmt > 4) || (fmt == 2)) { - fixedFields = 0; - goto l4; - } - if (fmt < 2) { - fixedFields = totalLength; - goto l4; - } - /* begin fetchClassOf: */ - if ((arg & 1)) { - class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l3; - } - ccIndex = (((unsigned) (longAt(arg))) >> 12) & 31; - if (ccIndex == 0) { - class = (longAt(arg - 4)) & 4294967292U; - goto l3; - } else { - class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l3; - } -l3: /* end fetchClassOf: */; - classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; - fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; -l4: /* end fixedFieldsOf:format:length: */; - if ((fmt == 3) && (isContextHeader(hdr))) { - /* begin fetchStackPointerOf: */ - sp4 = longAt(((((char *) arg)) + 4) + (2 << 2)); - if (!((sp4 & 1))) { - length = 0; - goto l6; - } - length = (sp4 >> 1); - goto l6; - } else { - length = totalLength - fixedFields; - goto l6; - } -l6: /* end stSizeOf: */; - if (!(length == (stSizeOf(rcvr)))) { - /* begin pushBool: */ - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; -; - return null; - } - rcvrPtr = ((float *) (firstIndexableField(rcvr))); - argPtr = ((float *) (firstIndexableField(arg))); - for (i = 0; i <= (length - 1); i += 1) { - if (!((rcvrPtr[i]) == (argPtr[i]))) { - /* begin pushBool: */ - /* begin push: */ - longAtput(sp11 = stackPointer + 4, falseObj); - stackPointer = sp11; -; - return null; - } - } - /* begin pushBool: */ - /* begin push: */ - longAtput(sp3 = stackPointer + 4, trueObj); - stackPointer = sp3; -; - return null; -} - -EXPORT(int) primitiveFloatArrayHash(void) { - int result; - int i; - int rcvr; - int *rcvrPtr; - int length; - int oop; - int sp; - int hdr; - int totalLength; - int fmt; - int fixedFields; - int sp1; - int classFormat; - int class; - int sz; - int ccIndex; - - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - rcvr = null; - goto l1; - } - rcvr = oop; -l1: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - /* begin success: */ - successFlag = (((((unsigned) (longAt(rcvr))) >> 8) & 15) == 6) && successFlag; - if (!successFlag) { - return null; - } - /* begin stSizeOf: */ - hdr = longAt(rcvr); - fmt = (((unsigned) hdr) >> 8) & 15; - /* begin lengthOf:baseHeader:format: */ - if ((hdr & 3) == 0) { - sz = (longAt(rcvr - 8)) & 4294967292U; - } else { - sz = hdr & 252; - } - if (fmt < 8) { - totalLength = ((unsigned) (sz - 4)) >> 2; - goto l2; - } else { - totalLength = (sz - 4) - (fmt & 3); - goto l2; - } -l2: /* end lengthOf:baseHeader:format: */; - /* begin fixedFieldsOf:format:length: */ - if ((fmt > 4) || (fmt == 2)) { - fixedFields = 0; - goto l4; - } - if (fmt < 2) { - fixedFields = totalLength; - goto l4; - } - /* begin fetchClassOf: */ - if ((rcvr & 1)) { - class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l3; - } - ccIndex = (((unsigned) (longAt(rcvr))) >> 12) & 31; - if (ccIndex == 0) { - class = (longAt(rcvr - 4)) & 4294967292U; - goto l3; - } else { - class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l3; - } -l3: /* end fetchClassOf: */; - classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; - fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; -l4: /* end fixedFieldsOf:format:length: */; - if ((fmt == 3) && (isContextHeader(hdr))) { - /* begin fetchStackPointerOf: */ - sp1 = longAt(((((char *) rcvr)) + 4) + (2 << 2)); - if (!((sp1 & 1))) { - length = 0; - goto l5; - } - length = (sp1 >> 1); - goto l5; - } else { - length = totalLength - fixedFields; - goto l5; - } -l5: /* end stSizeOf: */; - rcvrPtr = ((int *) (firstIndexableField(rcvr))); - result = 0; - for (i = 0; i <= (length - 1); i += 1) { - result += rcvrPtr[i]; - rcvrPtr += 4; - } - /* begin pop: */ - stackPointer -= 1 * 4; - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, (((result & 536870911) << 1) | 1)); - stackPointer = sp; - return null; -} - -EXPORT(int) primitiveFloatArrayMulFloatArray(void) { - int arg; - int i; - float *argPtr; - int rcvr; - float *rcvrPtr; - int length; - int oop; - int oop1; - int successValue; - int hdr; - int totalLength; - int fmt; - int fixedFields; - int sp; - int classFormat; - int class; - int sz; - int ccIndex; - - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - arg = null; - goto l1; - } - arg = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - rcvr = null; - goto l2; - } - rcvr = oop1; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - /* begin success: */ - successFlag = (((((unsigned) (longAt(arg))) >> 8) & 15) == 6) && successFlag; - /* begin success: */ - successFlag = (((((unsigned) (longAt(rcvr))) >> 8) & 15) == 6) && successFlag; - if (!successFlag) { - return null; - } - /* begin stSizeOf: */ - hdr = longAt(arg); - fmt = (((unsigned) hdr) >> 8) & 15; - /* begin lengthOf:baseHeader:format: */ - if ((hdr & 3) == 0) { - sz = (longAt(arg - 8)) & 4294967292U; - } else { - sz = hdr & 252; - } - if (fmt < 8) { - totalLength = ((unsigned) (sz - 4)) >> 2; - goto l5; - } else { - totalLength = (sz - 4) - (fmt & 3); - goto l5; - } -l5: /* end lengthOf:baseHeader:format: */; - /* begin fixedFieldsOf:format:length: */ - if ((fmt > 4) || (fmt == 2)) { - fixedFields = 0; - goto l4; - } - if (fmt < 2) { - fixedFields = totalLength; - goto l4; - } - /* begin fetchClassOf: */ - if ((arg & 1)) { - class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l3; - } - ccIndex = (((unsigned) (longAt(arg))) >> 12) & 31; - if (ccIndex == 0) { - class = (longAt(arg - 4)) & 4294967292U; - goto l3; - } else { - class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l3; - } -l3: /* end fetchClassOf: */; - classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; - fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; -l4: /* end fixedFieldsOf:format:length: */; - if ((fmt == 3) && (isContextHeader(hdr))) { - /* begin fetchStackPointerOf: */ - sp = longAt(((((char *) arg)) + 4) + (2 << 2)); - if (!((sp & 1))) { - length = 0; - goto l6; - } - length = (sp >> 1); - goto l6; - } else { - length = totalLength - fixedFields; - goto l6; - } -l6: /* end stSizeOf: */; - /* begin success: */ - successValue = length == (stSizeOf(rcvr)); - successFlag = successValue && successFlag; - if (!successFlag) { - return null; - } - rcvrPtr = ((float *) (firstIndexableField(rcvr))); - argPtr = ((float *) (firstIndexableField(arg))); - for (i = 0; i <= (length - 1); i += 1) { - rcvrPtr[i] = ((rcvrPtr[i]) * (argPtr[i])); - } - /* begin pop: */ - stackPointer -= 1 * 4; -} - -EXPORT(int) primitiveFloatArrayMulScalar(void) { - int i; - double value; - int rcvr; - float *rcvrPtr; - int length; - int oop; - int hdr; - int totalLength; - int fmt; - int fixedFields; - int sp; - int classFormat; - int class; - int sz; - int ccIndex; - - value = stackFloatValue(0); - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (1 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - rcvr = null; - goto l1; - } - rcvr = oop; -l1: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - /* begin success: */ - successFlag = (((((unsigned) (longAt(rcvr))) >> 8) & 15) == 6) && successFlag; - if (!successFlag) { - return null; - } - /* begin stSizeOf: */ - hdr = longAt(rcvr); - fmt = (((unsigned) hdr) >> 8) & 15; - /* begin lengthOf:baseHeader:format: */ - if ((hdr & 3) == 0) { - sz = (longAt(rcvr - 8)) & 4294967292U; - } else { - sz = hdr & 252; - } - if (fmt < 8) { - totalLength = ((unsigned) (sz - 4)) >> 2; - goto l2; - } else { - totalLength = (sz - 4) - (fmt & 3); - goto l2; - } -l2: /* end lengthOf:baseHeader:format: */; - /* begin fixedFieldsOf:format:length: */ - if ((fmt > 4) || (fmt == 2)) { - fixedFields = 0; - goto l4; - } - if (fmt < 2) { - fixedFields = totalLength; - goto l4; - } - /* begin fetchClassOf: */ - if ((rcvr & 1)) { - class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l3; - } - ccIndex = (((unsigned) (longAt(rcvr))) >> 12) & 31; - if (ccIndex == 0) { - class = (longAt(rcvr - 4)) & 4294967292U; - goto l3; - } else { - class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l3; - } -l3: /* end fetchClassOf: */; - classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; - fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; -l4: /* end fixedFieldsOf:format:length: */; - if ((fmt == 3) && (isContextHeader(hdr))) { - /* begin fetchStackPointerOf: */ - sp = longAt(((((char *) rcvr)) + 4) + (2 << 2)); - if (!((sp & 1))) { - length = 0; - goto l5; - } - length = (sp >> 1); - goto l5; - } else { - length = totalLength - fixedFields; - goto l5; - } -l5: /* end stSizeOf: */; - rcvrPtr = ((float *) (firstIndexableField(rcvr))); - for (i = 0; i <= (length - 1); i += 1) { - rcvrPtr[i] = ((rcvrPtr[i]) * value); - } - /* begin pop: */ - stackPointer -= 1 * 4; -} - -EXPORT(int) primitiveFloatArraySubFloatArray(void) { - int arg; - int i; - float *argPtr; - int rcvr; - float *rcvrPtr; - int length; - int oop; - int oop1; - int successValue; - int hdr; - int totalLength; - int fmt; - int fixedFields; - int sp; - int classFormat; - int class; - int sz; - int ccIndex; - - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (0 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - arg = null; - goto l1; - } - arg = oop; -l1: /* end stackObjectValue: */; - /* begin stackObjectValue: */ - oop1 = longAt(stackPointer - (1 * 4)); - if ((oop1 & 1)) { - /* begin primitiveFail */ - successFlag = 0; - rcvr = null; - goto l2; - } - rcvr = oop1; -l2: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - /* begin success: */ - successFlag = (((((unsigned) (longAt(arg))) >> 8) & 15) == 6) && successFlag; - /* begin success: */ - successFlag = (((((unsigned) (longAt(rcvr))) >> 8) & 15) == 6) && successFlag; - if (!successFlag) { - return null; - } - /* begin stSizeOf: */ - hdr = longAt(arg); - fmt = (((unsigned) hdr) >> 8) & 15; - /* begin lengthOf:baseHeader:format: */ - if ((hdr & 3) == 0) { - sz = (longAt(arg - 8)) & 4294967292U; - } else { - sz = hdr & 252; - } - if (fmt < 8) { - totalLength = ((unsigned) (sz - 4)) >> 2; - goto l5; - } else { - totalLength = (sz - 4) - (fmt & 3); - goto l5; - } -l5: /* end lengthOf:baseHeader:format: */; - /* begin fixedFieldsOf:format:length: */ - if ((fmt > 4) || (fmt == 2)) { - fixedFields = 0; - goto l4; - } - if (fmt < 2) { - fixedFields = totalLength; - goto l4; - } - /* begin fetchClassOf: */ - if ((arg & 1)) { - class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l3; - } - ccIndex = (((unsigned) (longAt(arg))) >> 12) & 31; - if (ccIndex == 0) { - class = (longAt(arg - 4)) & 4294967292U; - goto l3; - } else { - class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l3; - } -l3: /* end fetchClassOf: */; - classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; - fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; -l4: /* end fixedFieldsOf:format:length: */; - if ((fmt == 3) && (isContextHeader(hdr))) { - /* begin fetchStackPointerOf: */ - sp = longAt(((((char *) arg)) + 4) + (2 << 2)); - if (!((sp & 1))) { - length = 0; - goto l6; - } - length = (sp >> 1); - goto l6; - } else { - length = totalLength - fixedFields; - goto l6; - } -l6: /* end stSizeOf: */; - /* begin success: */ - successValue = length == (stSizeOf(rcvr)); - successFlag = successValue && successFlag; - if (!successFlag) { - return null; - } - rcvrPtr = ((float *) (firstIndexableField(rcvr))); - argPtr = ((float *) (firstIndexableField(arg))); - for (i = 0; i <= (length - 1); i += 1) { - rcvrPtr[i] = ((rcvrPtr[i]) - (argPtr[i])); - } - /* begin pop: */ - stackPointer -= 1 * 4; -} - -EXPORT(int) primitiveFloatArraySubScalar(void) { - int i; - double value; - int rcvr; - float *rcvrPtr; - int length; - int oop; - int hdr; - int totalLength; - int fmt; - int fixedFields; - int sp; - int classFormat; - int class; - int sz; - int ccIndex; - - value = stackFloatValue(0); - /* begin stackObjectValue: */ - oop = longAt(stackPointer - (1 * 4)); - if ((oop & 1)) { - /* begin primitiveFail */ - successFlag = 0; - rcvr = null; - goto l1; - } - rcvr = oop; -l1: /* end stackObjectValue: */; - if (!successFlag) { - return null; - } - /* begin success: */ - successFlag = (((((unsigned) (longAt(rcvr))) >> 8) & 15) == 6) && successFlag; - if (!successFlag) { - return null; - } - /* begin stSizeOf: */ - hdr = longAt(rcvr); - fmt = (((unsigned) hdr) >> 8) & 15; - /* begin lengthOf:baseHeader:format: */ - if ((hdr & 3) == 0) { - sz = (longAt(rcvr - 8)) & 4294967292U; - } else { - sz = hdr & 252; - } - if (fmt < 8) { - totalLength = ((unsigned) (sz - 4)) >> 2; - goto l2; - } else { - totalLength = (sz - 4) - (fmt & 3); - goto l2; - } -l2: /* end lengthOf:baseHeader:format: */; - /* begin fixedFieldsOf:format:length: */ - if ((fmt > 4) || (fmt == 2)) { - fixedFields = 0; - goto l4; - } - if (fmt < 2) { - fixedFields = totalLength; - goto l4; - } - /* begin fetchClassOf: */ - if ((rcvr & 1)) { - class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l3; - } - ccIndex = (((unsigned) (longAt(rcvr))) >> 12) & 31; - if (ccIndex == 0) { - class = (longAt(rcvr - 4)) & 4294967292U; - goto l3; - } else { - class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l3; - } -l3: /* end fetchClassOf: */; - classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; - fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; -l4: /* end fixedFieldsOf:format:length: */; - if ((fmt == 3) && (isContextHeader(hdr))) { - /* begin fetchStackPointerOf: */ - sp = longAt(((((char *) rcvr)) + 4) + (2 << 2)); - if (!((sp & 1))) { - length = 0; - goto l5; - } - length = (sp >> 1); - goto l5; - } else { - length = totalLength - fixedFields; - goto l5; - } -l5: /* end stSizeOf: */; - rcvrPtr = ((float *) (firstIndexableField(rcvr))); - for (i = 0; i <= (length - 1); i += 1) { - rcvrPtr[i] = ((rcvrPtr[i]) - value); - } - /* begin pop: */ - stackPointer -= 1 * 4; -} - -int primitiveFloatDividebyArg(int rcvrOop, int argOop) { - double arg; - double rcvr; - - rcvr = loadFloatOrIntFrom(rcvrOop); - arg = loadFloatOrIntFrom(argOop); - if (successFlag) { - /* begin success: */ - successFlag = (arg != 0.0) && successFlag; - if (successFlag) { - /* begin pop: */ - stackPointer -= 2 * 4; - pushFloat(rcvr / arg); - } - } -} - -int primitiveFloatEqual(void) { - int bool; - int sp; - int sp1; - - bool = primitiveFloatEqualtoArg(longAt(stackPointer - (1 * 4)), longAt(stackPointer)); - if (successFlag) { - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin pushBool: */ - if (bool) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } - } -} - -int primitiveFloatEqualtoArg(int rcvrOop, int argOop) { - double arg; - double rcvr; - - rcvr = loadFloatOrIntFrom(rcvrOop); - arg = loadFloatOrIntFrom(argOop); - if (successFlag) { - return rcvr == arg; - } -} - -int primitiveFloatGreaterthanArg(int rcvrOop, int argOop) { - double arg; - double rcvr; - - rcvr = loadFloatOrIntFrom(rcvrOop); - arg = loadFloatOrIntFrom(argOop); - if (successFlag) { - return rcvr > arg; - } -} - -int primitiveFloatGreaterOrEqual(void) { - int bool; - int sp; - int sp1; - - bool = primitiveFloatLessthanArg(longAt(stackPointer - (1 * 4)), longAt(stackPointer)); - if (successFlag) { - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin pushBool: */ - if (!bool) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } - } -} - -int primitiveFloatGreaterThan(void) { - int bool; - int sp; - int sp1; - - bool = primitiveFloatGreaterthanArg(longAt(stackPointer - (1 * 4)), longAt(stackPointer)); - if (successFlag) { - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin pushBool: */ - if (bool) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } - } -} - -int primitiveFloatLessthanArg(int rcvrOop, int argOop) { - double arg; - double rcvr; - - rcvr = loadFloatOrIntFrom(rcvrOop); - arg = loadFloatOrIntFrom(argOop); - if (successFlag) { - return rcvr < arg; - } -} - -int primitiveFloatLessOrEqual(void) { - int bool; - int sp; - int sp1; - - bool = primitiveFloatGreaterthanArg(longAt(stackPointer - (1 * 4)), longAt(stackPointer)); - if (successFlag) { - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin pushBool: */ - if (!bool) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } - } -} - -int primitiveFloatLessThan(void) { - int bool; - int sp; - int sp1; - - bool = primitiveFloatLessthanArg(longAt(stackPointer - (1 * 4)), longAt(stackPointer)); - if (successFlag) { - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin pushBool: */ - if (bool) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } - } -} - -int primitiveFloatMultiplybyArg(int rcvrOop, int argOop) { - double arg; - double rcvr; - - rcvr = loadFloatOrIntFrom(rcvrOop); - arg = loadFloatOrIntFrom(argOop); - if (successFlag) { - /* begin pop: */ - stackPointer -= 2 * 4; - pushFloat(rcvr * arg); - } -} - -int primitiveFloatNotEqual(void) { - int bool; - int sp; - int sp1; - - bool = primitiveFloatEqualtoArg(longAt(stackPointer - (1 * 4)), longAt(stackPointer)); - if (successFlag) { - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin pushBool: */ - if (!bool) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } - } -} - -int primitiveFloatSubtractfromArg(int rcvrOop, int argOop) { - double arg; - double rcvr; - - rcvr = loadFloatOrIntFrom(rcvrOop); - arg = loadFloatOrIntFrom(argOop); - if (successFlag) { - /* begin pop: */ - stackPointer -= 2 * 4; - pushFloat(rcvr - arg); - } -} - -int primitiveFlushCache(void) { - int i; - - /* begin flushMethodCache */ - for (i = 1; i <= 2048; i += 1) { - methodCache[i] = 0; - } - for (i = 1; i <= 64; i += 1) { - atCache[i] = 0; - } -} - -int primitiveFlushCacheByMethod(void) { - int probe; - int i; - int oldMethod; - - oldMethod = longAt(stackPointer); - probe = 0; - for (i = 1; i <= 512; i += 1) { - if ((methodCache[probe + 3]) == oldMethod) { - methodCache[probe + 1] = 0; - } - probe += 4; - } - /* begin compilerFlushCacheHook: */ - if (compilerInitialized) { - compilerFlushCache(oldMethod); - } -} - -int primitiveFlushCacheSelective(void) { - int probe; - int selector; - int i; - - selector = longAt(stackPointer); - probe = 0; - for (i = 1; i <= 512; i += 1) { - if ((methodCache[probe + 1]) == selector) { - methodCache[probe + 1] = 0; - } - probe += 4; - } -} - -int primitiveForceDisplayUpdate(void) { - ioForceDisplayUpdate(); -} - -int primitiveFormPrint(void) { - double vScale; - int depth; - int pixelsPerWord; - int bitsArray; - double hScale; - int wordsPerLine; - int h; - int w; - int bitsArraySize; - int landscapeFlag; - int rcvr; - int ok; - - /* begin booleanValueOf: */ - if ((longAt(stackPointer)) == trueObj) { - landscapeFlag = 1; - goto l1; - } - if ((longAt(stackPointer)) == falseObj) { - landscapeFlag = 0; - goto l1; - } - successFlag = 0; - landscapeFlag = null; -l1: /* end booleanValueOf: */; - vScale = floatValueOf(longAt(stackPointer - (1 * 4))); - hScale = floatValueOf(longAt(stackPointer - (2 * 4))); - rcvr = longAt(stackPointer - (3 * 4)); - if ((rcvr & 1)) { - /* begin success: */ - successFlag = 0 && successFlag; - } - if (successFlag) { - if (!((((((unsigned) (longAt(rcvr))) >> 8) & 15) <= 4) && ((lengthOf(rcvr)) >= 4))) { - /* begin success: */ - successFlag = 0 && successFlag; - } - } - if (successFlag) { - bitsArray = longAt(((((char *) rcvr)) + 4) + (0 << 2)); - w = fetchIntegerofObject(1, rcvr); - h = fetchIntegerofObject(2, rcvr); - depth = fetchIntegerofObject(3, rcvr); - if (!((w > 0) && (h > 0))) { - /* begin success: */ - successFlag = 0 && successFlag; - } - pixelsPerWord = 32 / depth; - wordsPerLine = (w + (pixelsPerWord - 1)) / pixelsPerWord; - if ((!((rcvr & 1))) && (isWordsOrBytes(bitsArray))) { - bitsArraySize = byteLengthOf(bitsArray); - /* begin success: */ - successFlag = (bitsArraySize == ((wordsPerLine * h) * 4)) && successFlag; - } else { - /* begin success: */ - successFlag = 0 && successFlag; - } - } - if (successFlag) { - ok = ioFormPrint(bitsArray + 4, w, h, depth, hScale, vScale, landscapeFlag); - /* begin success: */ - successFlag = ok && successFlag; - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 3 * 4; - } -} - -int primitiveFractionalPart(void) { - double trunc; - double frac; - double rcvr; - - rcvr = popFloat(); - if (successFlag) { - frac = modf(rcvr, &trunc); - pushFloat(frac); - } else { - /* begin unPop: */ - stackPointer += 1 * 4; - } -} - -int primitiveFullGC(void) { - int sp; - - /* begin pop: */ - stackPointer -= 1 * 4; - incrementalGC(); - fullGC(); - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, ((((longAt(freeBlock)) & 4294967292U) << 1) | 1)); - stackPointer = sp; -} - -int primitiveGetAttribute(void) { - int attr; - int sz; - int s; - int sp; - int integerPointer; - - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - attr = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - attr = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - if (successFlag) { - sz = attributeSize(attr); - } - if (successFlag) { - s = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)), sz); - getAttributeIntoLength(attr, s + 4, sz); - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, s); - stackPointer = sp; - } -} - -int primitiveGetTabletParameters(void) { - int cursorIndex; - int resultSize; - int result; - int sp; - int integerPointer; - - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - cursorIndex = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - cursorIndex = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - if (successFlag) { - resultSize = tabletResultSize(); - result = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (4 << 2)), resultSize); - /* begin success: */ - successFlag = (tabletGetParameters(cursorIndex, (int *) (result + 4))) && successFlag; - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, result); - stackPointer = sp; - } -} - -int primitiveGreaterOrEqual(void) { - int integerReceiver; - int integerArgument; - int integerPointer; - int top; - int integerPointer1; - int top1; - int sp; - int sp1; - - /* begin popInteger */ - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - integerPointer = top; - if ((integerPointer & 1)) { - integerArgument = (integerPointer >> 1); - goto l1; - } else { - successFlag = 0; - integerArgument = 1; - goto l1; - } -l1: /* end popInteger */; - /* begin popInteger */ - /* begin popStack */ - top1 = longAt(stackPointer); - stackPointer -= 4; - integerPointer1 = top1; - if ((integerPointer1 & 1)) { - integerReceiver = (integerPointer1 >> 1); - goto l2; - } else { - successFlag = 0; - integerReceiver = 1; - goto l2; - } -l2: /* end popInteger */; - /* begin checkBooleanResult: */ - if (successFlag) { - /* begin pushBool: */ - if (integerReceiver >= integerArgument) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } - } else { - /* begin unPop: */ - stackPointer += 2 * 4; - } -} - -int primitiveGreaterThan(void) { - int integerReceiver; - int integerArgument; - int integerPointer; - int top; - int integerPointer1; - int top1; - int sp; - int sp1; - - /* begin popInteger */ - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - integerPointer = top; - if ((integerPointer & 1)) { - integerArgument = (integerPointer >> 1); - goto l1; - } else { - successFlag = 0; - integerArgument = 1; - goto l1; - } -l1: /* end popInteger */; - /* begin popInteger */ - /* begin popStack */ - top1 = longAt(stackPointer); - stackPointer -= 4; - integerPointer1 = top1; - if ((integerPointer1 & 1)) { - integerReceiver = (integerPointer1 >> 1); - goto l2; - } else { - successFlag = 0; - integerReceiver = 1; - goto l2; - } -l2: /* end popInteger */; - /* begin checkBooleanResult: */ - if (successFlag) { - /* begin pushBool: */ - if (integerReceiver > integerArgument) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } - } else { - /* begin unPop: */ - stackPointer += 2 * 4; - } -} - -int primitiveImageName(void) { - int sz; - int s; - int sp; - int hdr; - int totalLength; - int fmt; - int fixedFields; - int sp1; - int classFormat; - int class; - int sz1; - int ccIndex; - int ccIndex1; - int cl; - - if (argumentCount == 1) { - s = longAt(stackPointer); - /* begin assertClassOf:is: */ - if ((s & 1)) { - successFlag = 0; - goto l5; - } - ccIndex1 = (((unsigned) (longAt(s))) >> 12) & 31; - if (ccIndex1 == 0) { - cl = (longAt(s - 4)) & 4294967292U; - } else { - cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex1 - 1) << 2)); - } - /* begin success: */ - successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)))) && successFlag; - l5: /* end assertClassOf:is: */; - if (successFlag) { - /* begin stSizeOf: */ - hdr = longAt(s); - fmt = (((unsigned) hdr) >> 8) & 15; - /* begin lengthOf:baseHeader:format: */ - if ((hdr & 3) == 0) { - sz1 = (longAt(s - 8)) & 4294967292U; - } else { - sz1 = hdr & 252; - } - if (fmt < 8) { - totalLength = ((unsigned) (sz1 - 4)) >> 2; - goto l2; - } else { - totalLength = (sz1 - 4) - (fmt & 3); - goto l2; - } - l2: /* end lengthOf:baseHeader:format: */; - /* begin fixedFieldsOf:format:length: */ - if ((fmt > 4) || (fmt == 2)) { - fixedFields = 0; - goto l1; - } - if (fmt < 2) { - fixedFields = totalLength; - goto l1; - } - /* begin fetchClassOf: */ - if ((s & 1)) { - class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l3; - } - ccIndex = (((unsigned) (longAt(s))) >> 12) & 31; - if (ccIndex == 0) { - class = (longAt(s - 4)) & 4294967292U; - goto l3; - } else { - class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l3; - } - l3: /* end fetchClassOf: */; - classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; - fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; - l1: /* end fixedFieldsOf:format:length: */; - if ((fmt == 3) && (isContextHeader(hdr))) { - /* begin fetchStackPointerOf: */ - sp1 = longAt(((((char *) s)) + 4) + (2 << 2)); - if (!((sp1 & 1))) { - sz = 0; - goto l4; - } - sz = (sp1 >> 1); - goto l4; - } else { - sz = totalLength - fixedFields; - goto l4; - } - l4: /* end stSizeOf: */; - imageNamePutLength(s + 4, sz); - /* begin pop: */ - stackPointer -= 1 * 4; - } - } else { - sz = imageNameSize(); - s = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)), sz); - imageNameGetLength(s + 4, sz); - /* begin pop: */ - stackPointer -= 1 * 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, s); - stackPointer = sp; - } -} - -int primitiveIncrementalGC(void) { - int sp; - - /* begin pop: */ - stackPointer -= 1 * 4; - incrementalGC(); - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, ((((longAt(freeBlock)) & 4294967292U) << 1) | 1)); - stackPointer = sp; -} - -int primitiveIndexOf(int methodPointer) { - int primBits; - - primBits = (((unsigned) (longAt(((((char *) methodPointer)) + 4) + (0 << 2)))) >> 1) & 805306879; - if (primBits > 511) { - return (primBits & 511) + (((unsigned) primBits) >> 19); - } else { - return primBits; - } -} - -int primitiveInitializeNetwork(void) { - int err; - int resolverSemaIndex; - int integerPointer; - - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - resolverSemaIndex = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - resolverSemaIndex = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - if (successFlag) { - err = sqNetworkInit(resolverSemaIndex); - /* begin success: */ - successFlag = (err == 0) && successFlag; - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 1 * 4; - } -} - -int primitiveInputSemaphore(void) { - int arg; - int oop; - int oop1; - int valuePointer; - int top; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - arg = top; - if ((fetchClassOf(arg)) == (longAt(((((char *) specialObjectsOop)) + 4) + (18 << 2)))) { - /* begin storePointer:ofObject:withValue: */ - oop = specialObjectsOop; - if (oop < youngStart) { - possibleRootStoreIntovalue(oop, arg); - } - longAtput(((((char *) oop)) + 4) + (22 << 2), arg); - } else { - /* begin storePointer:ofObject:withValue: */ - oop1 = specialObjectsOop; - valuePointer = nilObj; - if (oop1 < youngStart) { - possibleRootStoreIntovalue(oop1, valuePointer); - } - longAtput(((((char *) oop1)) + 4) + (22 << 2), valuePointer); - } -} - -int primitiveInputWord(void) { - int sp; - - /* begin pop: */ - stackPointer -= 1 * 4; - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, ((0 << 1) | 1)); - stackPointer = sp; -} - -int primitiveInstVarAt(void) { - int value; - int hdr; - int totalLength; - int index; - int rcvr; - int fmt; - int fixedFields; - int sp; - int top; - int sz; - int classFormat; - int class; - int integerPointer; - int top1; - int ccIndex; - - /* begin popInteger */ - /* begin popStack */ - top1 = longAt(stackPointer); - stackPointer -= 4; - integerPointer = top1; - if ((integerPointer & 1)) { - index = (integerPointer >> 1); - goto l4; - } else { - successFlag = 0; - index = 1; - goto l4; - } -l4: /* end popInteger */; - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - rcvr = top; - if (successFlag) { - hdr = longAt(rcvr); - fmt = (((unsigned) hdr) >> 8) & 15; - /* begin lengthOf:baseHeader:format: */ - if ((hdr & 3) == 0) { - sz = (longAt(rcvr - 8)) & 4294967292U; - } else { - sz = hdr & 252; - } - if (fmt < 8) { - totalLength = ((unsigned) (sz - 4)) >> 2; - goto l1; - } else { - totalLength = (sz - 4) - (fmt & 3); - goto l1; - } - l1: /* end lengthOf:baseHeader:format: */; - /* begin fixedFieldsOf:format:length: */ - if ((fmt > 4) || (fmt == 2)) { - fixedFields = 0; - goto l2; - } - if (fmt < 2) { - fixedFields = totalLength; - goto l2; - } - /* begin fetchClassOf: */ - if ((rcvr & 1)) { - class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l5; - } - ccIndex = (((unsigned) (longAt(rcvr))) >> 12) & 31; - if (ccIndex == 0) { - class = (longAt(rcvr - 4)) & 4294967292U; - goto l5; - } else { - class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l5; - } - l5: /* end fetchClassOf: */; - classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; - fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; - l2: /* end fixedFieldsOf:format:length: */; - if (!((index >= 1) && (index <= fixedFields))) { - successFlag = 0; - } - } - if (successFlag) { - /* begin subscript:with:format: */ - if (fmt <= 4) { - value = longAt(((((char *) rcvr)) + 4) + ((index - 1) << 2)); - goto l3; - } - if (fmt < 8) { - value = positive32BitIntegerFor(longAt(((((char *) rcvr)) + 4) + ((index - 1) << 2))); - goto l3; - } else { - value = (((byteAt(((((char *) rcvr)) + 4) + (index - 1))) << 1) | 1); - goto l3; - } - l3: /* end subscript:with:format: */; - } - if (successFlag) { - /* begin push: */ - longAtput(sp = stackPointer + 4, value); - stackPointer = sp; - } else { - /* begin unPop: */ - stackPointer += 2 * 4; - } -} - -int primitiveInstVarAtPut(void) { - int hdr; - int newValue; - int totalLength; - int index; - int rcvr; - int fmt; - int fixedFields; - int classFormat; - int class; - int sp; - int top; - int integerPointer; - int top1; - int top2; - int sz; - int ccIndex; - int valueToStore; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - newValue = top; - /* begin popInteger */ - /* begin popStack */ - top1 = longAt(stackPointer); - stackPointer -= 4; - integerPointer = top1; - if ((integerPointer & 1)) { - index = (integerPointer >> 1); - goto l2; - } else { - successFlag = 0; - index = 1; - goto l2; - } -l2: /* end popInteger */; - /* begin popStack */ - top2 = longAt(stackPointer); - stackPointer -= 4; - rcvr = top2; - if (successFlag) { - hdr = longAt(rcvr); - fmt = (((unsigned) hdr) >> 8) & 15; - /* begin lengthOf:baseHeader:format: */ - if ((hdr & 3) == 0) { - sz = (longAt(rcvr - 8)) & 4294967292U; - } else { - sz = hdr & 252; - } - if (fmt < 8) { - totalLength = ((unsigned) (sz - 4)) >> 2; - goto l3; - } else { - totalLength = (sz - 4) - (fmt & 3); - goto l3; - } - l3: /* end lengthOf:baseHeader:format: */; - /* begin fixedFieldsOf:format:length: */ - if ((fmt > 4) || (fmt == 2)) { - fixedFields = 0; - goto l1; - } - if (fmt < 2) { - fixedFields = totalLength; - goto l1; - } - /* begin fetchClassOf: */ - if ((rcvr & 1)) { - class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l4; - } - ccIndex = (((unsigned) (longAt(rcvr))) >> 12) & 31; - if (ccIndex == 0) { - class = (longAt(rcvr - 4)) & 4294967292U; - goto l4; - } else { - class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l4; - } - l4: /* end fetchClassOf: */; - classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; - fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; - l1: /* end fixedFieldsOf:format:length: */; - if (!((index >= 1) && (index <= fixedFields))) { - successFlag = 0; - } - } - if (successFlag) { - /* begin subscript:with:storing:format: */ - if (fmt <= 4) { - /* begin storePointer:ofObject:withValue: */ - if (rcvr < youngStart) { - possibleRootStoreIntovalue(rcvr, newValue); - } - longAtput(((((char *) rcvr)) + 4) + ((index - 1) << 2), newValue); - } else { - if (fmt < 8) { - valueToStore = positive32BitValueOf(newValue); - if (successFlag) { - longAtput(((((char *) rcvr)) + 4) + ((index - 1) << 2), valueToStore); - } - } else { - if (!((newValue & 1))) { - successFlag = 0; - } - valueToStore = (newValue >> 1); - if (!((valueToStore >= 0) && (valueToStore <= 255))) { - successFlag = 0; - } - if (successFlag) { - byteAtput(((((char *) rcvr)) + 4) + (index - 1), valueToStore); - } - } - } - } - if (successFlag) { - /* begin push: */ - longAtput(sp = stackPointer + 4, newValue); - stackPointer = sp; - } else { - /* begin unPop: */ - stackPointer += 3 * 4; - } -} - -int primitiveInstVarsPutFromStack(void) { - int i; - int rcvr; - int offsetBits; - - rcvr = longAt(stackPointer - (argumentCount * 4)); - if (rcvr < youngStart) { - beRootIfOld(rcvr); - } - for (i = 0; i <= (argumentCount - 1); i += 1) { - if ((i & 3) == 0) { - offsetBits = positive32BitValueOf(longAt(((((char *) newMethod)) + 4) + (((((int) i >> 2)) + 1) << 2))); - } - longAtput(((((char *) rcvr)) + 4) + ((offsetBits & 255) << 2), longAt(stackPointer - (i * 4))); - offsetBits = ((unsigned) offsetBits) >> 8; - } - /* begin pop: */ - stackPointer -= argumentCount * 4; -} - -int primitiveInterruptSemaphore(void) { - int arg; - int oop; - int oop1; - int valuePointer; - int top; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - arg = top; - if ((fetchClassOf(arg)) == (longAt(((((char *) specialObjectsOop)) + 4) + (18 << 2)))) { - /* begin storePointer:ofObject:withValue: */ - oop = specialObjectsOop; - if (oop < youngStart) { - possibleRootStoreIntovalue(oop, arg); - } - longAtput(((((char *) oop)) + 4) + (30 << 2), arg); - } else { - /* begin storePointer:ofObject:withValue: */ - oop1 = specialObjectsOop; - valuePointer = nilObj; - if (oop1 < youngStart) { - possibleRootStoreIntovalue(oop1, valuePointer); - } - longAtput(((((char *) oop1)) + 4) + (30 << 2), valuePointer); - } -} - -int primitiveKbdNext(void) { - int keystrokeWord; - int sp; - int sp1; - - /* begin pop: */ - stackPointer -= 1 * 4; - keystrokeWord = ioGetKeystroke(); - if (keystrokeWord >= 0) { - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp1 = stackPointer + 4, ((keystrokeWord << 1) | 1)); - stackPointer = sp1; - } else { - /* begin push: */ - longAtput(sp = stackPointer + 4, nilObj); - stackPointer = sp; - } -} - -int primitiveKbdPeek(void) { - int keystrokeWord; - int sp; - int sp1; - - /* begin pop: */ - stackPointer -= 1 * 4; - keystrokeWord = ioPeekKeystroke(); - if (keystrokeWord >= 0) { - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp1 = stackPointer + 4, ((keystrokeWord << 1) | 1)); - stackPointer = sp1; - } else { - /* begin push: */ - longAtput(sp = stackPointer + 4, nilObj); - stackPointer = sp; - } -} - -int primitiveLessOrEqual(void) { - int integerReceiver; - int integerArgument; - int integerPointer; - int top; - int integerPointer1; - int top1; - int sp; - int sp1; - - /* begin popInteger */ - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - integerPointer = top; - if ((integerPointer & 1)) { - integerArgument = (integerPointer >> 1); - goto l1; - } else { - successFlag = 0; - integerArgument = 1; - goto l1; - } -l1: /* end popInteger */; - /* begin popInteger */ - /* begin popStack */ - top1 = longAt(stackPointer); - stackPointer -= 4; - integerPointer1 = top1; - if ((integerPointer1 & 1)) { - integerReceiver = (integerPointer1 >> 1); - goto l2; - } else { - successFlag = 0; - integerReceiver = 1; - goto l2; - } -l2: /* end popInteger */; - /* begin checkBooleanResult: */ - if (successFlag) { - /* begin pushBool: */ - if (integerReceiver <= integerArgument) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } - } else { - /* begin unPop: */ - stackPointer += 2 * 4; - } -} - -int primitiveLessThan(void) { - int integerReceiver; - int integerArgument; - int integerPointer; - int top; - int integerPointer1; - int top1; - int sp; - int sp1; - - /* begin popInteger */ - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - integerPointer = top; - if ((integerPointer & 1)) { - integerArgument = (integerPointer >> 1); - goto l1; - } else { - successFlag = 0; - integerArgument = 1; - goto l1; - } -l1: /* end popInteger */; - /* begin popInteger */ - /* begin popStack */ - top1 = longAt(stackPointer); - stackPointer -= 4; - integerPointer1 = top1; - if ((integerPointer1 & 1)) { - integerReceiver = (integerPointer1 >> 1); - goto l2; - } else { - successFlag = 0; - integerReceiver = 1; - goto l2; - } -l2: /* end popInteger */; - /* begin checkBooleanResult: */ - if (successFlag) { - /* begin pushBool: */ - if (integerReceiver < integerArgument) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } - } else { - /* begin unPop: */ - stackPointer += 2 * 4; - } -} - -int primitiveLoadImageSegment(void) { - int outPtr; - int segmentWordArray; - int segOop; - int doingClass; - int mapOop; - int endSeg; - int header; - int hdrTypeBits; - int extraSize; - int outPointerArray; - int fieldPtr; - int fieldOop; - int lastPtr; - int lastOut; - int addr; - int addr1; - int extra; - int extra1; - int type; - int extra2; - int oop; - int sp; - int sz; - int extra3; - int header1; - int type1; - int extra11; - int sz1; - int extra4; - int header2; - int type2; - int extra12; - int type3; - int extra5; - int type4; - int extra6; - int extra7; - int type5; - int extra13; - - ; - outPointerArray = longAt(stackPointer - (0 * 4)); - lastOut = outPointerArray + (lastPointerOf(outPointerArray)); - segmentWordArray = longAt(stackPointer - (1 * 4)); - endSeg = (segmentWordArray + (sizeBitsOf(segmentWordArray))) - 4; - if (!((((((unsigned) (longAt(outPointerArray))) >> 8) & 15) == 2) && (((((unsigned) (longAt(segmentWordArray))) >> 8) & 15) == 6))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if (!((longAt(segmentWordArray + 4)) == 6502)) { - /* begin reverseBytesFrom:to: */ - addr1 = segmentWordArray + 4; - while (addr1 < (endSeg + 4)) { - longAtput(addr1, ((((((unsigned) (longAt(addr1)) >> 24)) & 255) + ((((unsigned) (longAt(addr1)) >> 8)) & 65280)) + ((((unsigned) (longAt(addr1)) << 8)) & 16711680)) + ((((unsigned) (longAt(addr1)) << 24)) & 4278190080U)); - addr1 += 4; - } - if (!((longAt(segmentWordArray + 4)) == 6502)) { - /* begin reverseBytesFrom:to: */ - addr = segmentWordArray + 4; - while (addr < (endSeg + 4)) { - longAtput(addr, ((((((unsigned) (longAt(addr)) >> 24)) & 255) + ((((unsigned) (longAt(addr)) >> 8)) & 65280)) + ((((unsigned) (longAt(addr)) << 8)) & 16711680)) + ((((unsigned) (longAt(addr)) << 24)) & 4278190080U)); - addr += 4; - } - ; - /* begin primitiveFail */ - successFlag = 0; - return null; - } - } - /* begin oopFromChunk: */ - /* begin extraHeaderBytes: */ - type3 = (longAt((segmentWordArray + 4) + 4)) & 3; - if (type3 > 1) { - extra5 = 0; - } else { - if (type3 == 1) { - extra5 = 4; - } else { - extra5 = 8; - } - } - extra = extra5; - segOop = ((segmentWordArray + 4) + 4) + extra; - while (segOop <= endSeg) { - if (((longAt(segOop)) & 3) <= 1) { - fieldPtr = segOop - 4; - doingClass = 1; - } else { - fieldPtr = segOop + 4; - doingClass = 0; - } - lastPtr = segOop + (lastPointerOf(segOop)); - if (lastPtr > endSeg) { - ; - /* begin primitiveFail */ - successFlag = 0; - return null; - } - while (!(fieldPtr > lastPtr)) { - fieldOop = longAt(fieldPtr); - if (doingClass) { - hdrTypeBits = (longAt(fieldPtr)) & 3; - fieldOop -= hdrTypeBits; - } - if ((fieldOop & 1)) { - fieldPtr += 4; - } else { - if (!((fieldOop & 3) == 0)) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - if ((fieldOop & 2147483648U) == 0) { - mapOop = fieldOop + segmentWordArray; - } else { - outPtr = outPointerArray + (fieldOop & 2147483647U); - if (outPtr > lastOut) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - mapOop = longAt(outPtr); - } - if (doingClass) { - longAtput(fieldPtr, mapOop + hdrTypeBits); - fieldPtr += 8; - doingClass = 0; - } else { - longAtput(fieldPtr, mapOop); - fieldPtr += 4; - } - } - } - /* begin objectAfter: */ - ; - if (((longAt(segOop)) & 3) == 2) { - sz = (longAt(segOop)) & 4294967292U; - } else { - /* begin sizeBitsOf: */ - header1 = longAt(segOop); - if ((header1 & 3) == 0) { - sz = (longAt(segOop - 8)) & 4294967292U; - goto l1; - } else { - sz = header1 & 252; - goto l1; - } - l1: /* end sizeBitsOf: */; - } - /* begin oopFromChunk: */ - /* begin extraHeaderBytes: */ - type1 = (longAt(segOop + sz)) & 3; - if (type1 > 1) { - extra11 = 0; - } else { - if (type1 == 1) { - extra11 = 4; - } else { - extra11 = 8; - } - } - extra3 = extra11; - segOop = (segOop + sz) + extra3; - } - /* begin oopFromChunk: */ - /* begin extraHeaderBytes: */ - type4 = (longAt((segmentWordArray + 4) + 4)) & 3; - if (type4 > 1) { - extra6 = 0; - } else { - if (type4 == 1) { - extra6 = 4; - } else { - extra6 = 8; - } - } - extra1 = extra6; - segOop = ((segmentWordArray + 4) + 4) + extra1; - while (segOop <= endSeg) { - if (!(oopHasOKclass(segOop))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - fieldPtr = segOop + 4; - lastPtr = segOop + (lastPointerOf(segOop)); - while (!(fieldPtr > lastPtr)) { - fieldOop = longAt(fieldPtr); - if (!(oopHasOKclass(fieldOop))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - fieldPtr += 4; - } - /* begin objectAfter: */ - ; - if (((longAt(segOop)) & 3) == 2) { - sz1 = (longAt(segOop)) & 4294967292U; - } else { - /* begin sizeBitsOf: */ - header2 = longAt(segOop); - if ((header2 & 3) == 0) { - sz1 = (longAt(segOop - 8)) & 4294967292U; - goto l2; - } else { - sz1 = header2 & 252; - goto l2; - } - l2: /* end sizeBitsOf: */; - } - /* begin oopFromChunk: */ - /* begin extraHeaderBytes: */ - type2 = (longAt(segOop + sz1)) & 3; - if (type2 > 1) { - extra12 = 0; - } else { - if (type2 == 1) { - extra12 = 4; - } else { - extra12 = 8; - } - } - extra4 = extra12; - segOop = (segOop + sz1) + extra4; - } - /* begin extraHeaderBytes: */ - type = (longAt(segmentWordArray)) & 3; - if (type > 1) { - extra2 = 0; - } else { - if (type == 1) { - extra2 = 4; - } else { - extra2 = 8; - } - } - extraSize = extra2; - hdrTypeBits = (longAt(segmentWordArray)) & 3; - if (extraSize == 8) { - longAtput(segmentWordArray - extraSize, (4 + 4) + hdrTypeBits); - } else { - header = longAt(segmentWordArray); - longAtput(segmentWordArray, ((header - (header & 252)) + 4) + 4); - } - ; - /* begin pop:thenPush: */ - /* begin oopFromChunk: */ - /* begin extraHeaderBytes: */ - type5 = (longAt((segmentWordArray + 4) + 4)) & 3; - if (type5 > 1) { - extra13 = 0; - } else { - if (type5 == 1) { - extra13 = 4; - } else { - extra13 = 8; - } - } - extra7 = extra13; - oop = ((segmentWordArray + 4) + 4) + extra7; - longAtput(sp = stackPointer - ((3 - 1) * 4), oop); - stackPointer = sp; -} - -int primitiveLoadInstVar(void) { - int thisReceiver; - int top; - int sp; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - thisReceiver = top; - /* begin push: */ - longAtput(sp = stackPointer + 4, longAt(((((char *) thisReceiver)) + 4) + ((primitiveIndex - 264) << 2))); - stackPointer = sp; -} - -int primitiveLogN(void) { - double rcvr; - - rcvr = popFloat(); - if (successFlag) { - pushFloat(log(rcvr)); - } else { - /* begin unPop: */ - stackPointer += 1 * 4; - } -} - -int primitiveLowSpaceSemaphore(void) { - int arg; - int oop; - int oop1; - int valuePointer; - int top; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - arg = top; - if ((fetchClassOf(arg)) == (longAt(((((char *) specialObjectsOop)) + 4) + (18 << 2)))) { - /* begin storePointer:ofObject:withValue: */ - oop = specialObjectsOop; - if (oop < youngStart) { - possibleRootStoreIntovalue(oop, arg); - } - longAtput(((((char *) oop)) + 4) + (17 << 2), arg); - } else { - /* begin storePointer:ofObject:withValue: */ - oop1 = specialObjectsOop; - valuePointer = nilObj; - if (oop1 < youngStart) { - possibleRootStoreIntovalue(oop1, valuePointer); - } - longAtput(((((char *) oop1)) + 4) + (17 << 2), valuePointer); - } -} - -int primitiveMIDIClosePort(void) { - int portNum; - int integerPointer; - - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - portNum = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - portNum = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - if (successFlag) { - sqMIDIClosePort(portNum); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 1 * 4; - } -} - -int primitiveMIDIGetClock(void) { - int clockValue; - int sp; - - clockValue = (sqMIDIGetClock()) & 536870911; - if (successFlag) { - /* begin pop: */ - stackPointer -= 1 * 4; - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, ((clockValue << 1) | 1)); - stackPointer = sp; - } -} - -int primitiveMIDIGetPortCount(void) { - int n; - int sp; - - n = sqMIDIGetPortCount(); - if (successFlag) { - /* begin pop: */ - stackPointer -= 1 * 4; - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, ((n << 1) | 1)); - stackPointer = sp; - } -} - -int primitiveMIDIGetPortDirectionality(void) { - int dir; - int portNum; - int integerPointer; - int sp; - - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - portNum = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - portNum = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - if (successFlag) { - dir = sqMIDIGetPortDirectionality(portNum); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, ((dir << 1) | 1)); - stackPointer = sp; - } -} - -int primitiveMIDIGetPortName(void) { - char portName[256]; - int portNum; - int sz; - int nameObj; - int namePtr; - int sp; - int integerPointer; - - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - portNum = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - portNum = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - if (successFlag) { - sz = sqMIDIGetPortName(portNum, (int) &portName, 255); - } - if (successFlag) { - nameObj = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)), sz); - namePtr = nameObj + 4; - memcpy((char *) namePtr, portName, sz); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, nameObj); - stackPointer = sp; - } -} - -int primitiveMIDIOpenPort(void) { - int semaIndex; - int portNum; - int clockRate; - int integerPointer; - int integerPointer1; - int integerPointer2; - - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - clockRate = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - clockRate = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - /* begin stackIntegerValue: */ - integerPointer1 = longAt(stackPointer - (1 * 4)); - if ((integerPointer1 & 1)) { - semaIndex = (integerPointer1 >> 1); - goto l2; - } else { - /* begin primitiveFail */ - successFlag = 0; - semaIndex = 0; - goto l2; - } -l2: /* end stackIntegerValue: */; - /* begin stackIntegerValue: */ - integerPointer2 = longAt(stackPointer - (2 * 4)); - if ((integerPointer2 & 1)) { - portNum = (integerPointer2 >> 1); - goto l3; - } else { - /* begin primitiveFail */ - successFlag = 0; - portNum = 0; - goto l3; - } -l3: /* end stackIntegerValue: */; - if (successFlag) { - sqMIDIOpenPort(portNum, semaIndex, clockRate); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 3 * 4; - } -} - -int primitiveMIDIParameterGetOrSet(void) { - int whichParameter; - int newValue; - int currentValue; - int integerPointer; - int integerPointer1; - int integerPointer2; - int sp; - - if (argumentCount == 1) { - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - whichParameter = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - whichParameter = 0; - goto l1; - } - l1: /* end stackIntegerValue: */; - if (!(successFlag)) { - return null; - } - currentValue = sqMIDIParameter(whichParameter, false, 0); - if (successFlag) { - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, ((currentValue << 1) | 1)); - stackPointer = sp; - } - return null; - } - if (argumentCount == 2) { - /* begin stackIntegerValue: */ - integerPointer1 = longAt(stackPointer - (0 * 4)); - if ((integerPointer1 & 1)) { - newValue = (integerPointer1 >> 1); - goto l2; - } else { - /* begin primitiveFail */ - successFlag = 0; - newValue = 0; - goto l2; - } - l2: /* end stackIntegerValue: */; - /* begin stackIntegerValue: */ - integerPointer2 = longAt(stackPointer - (1 * 4)); - if ((integerPointer2 & 1)) { - whichParameter = (integerPointer2 >> 1); - goto l3; - } else { - /* begin primitiveFail */ - successFlag = 0; - whichParameter = 0; - goto l3; - } - l3: /* end stackIntegerValue: */; - if (!(successFlag)) { - return null; - } - sqMIDIParameter(whichParameter, true, newValue); - if (successFlag) { - /* begin pop: */ - stackPointer -= 2 * 4; - } - return null; - } - /* begin primitiveFail */ - successFlag = 0; -} - -int primitiveMIDIRead(void) { - int array; - int portNum; - int arrayLength; - int bytesRead; - int fmt; - int header; - int sp; - int integerPointer; - int successValue; - int sz; - - array = longAt(stackPointer - (0 * 4)); - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (1 * 4)); - if ((integerPointer & 1)) { - portNum = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - portNum = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - fmt = (((unsigned) (longAt(array))) >> 8) & 15; - /* begin success: */ - successValue = (fmt >= 8) && (fmt <= 11); - successFlag = successValue && successFlag; - if (successFlag) { - /* begin lengthOf: */ - header = longAt(array); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(array - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - arrayLength = ((unsigned) (sz - 4)) >> 2; - goto l2; - } else { - arrayLength = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l2; - } - l2: /* end lengthOf:baseHeader:format: */; - bytesRead = sqMIDIPortReadInto(portNum, arrayLength, array + 4); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 3 * 4; - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, ((bytesRead << 1) | 1)); - stackPointer = sp; - } -} - -int primitiveMIDIWrite(void) { - int array; - int portNum; - int arrayLength; - int time; - int bytesWritten; - int fmt; - int header; - int sp; - int integerPointer; - int integerPointer1; - int successValue; - int sz; - - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - time = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - time = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - array = longAt(stackPointer - (1 * 4)); - /* begin stackIntegerValue: */ - integerPointer1 = longAt(stackPointer - (2 * 4)); - if ((integerPointer1 & 1)) { - portNum = (integerPointer1 >> 1); - goto l2; - } else { - /* begin primitiveFail */ - successFlag = 0; - portNum = 0; - goto l2; - } -l2: /* end stackIntegerValue: */; - fmt = (((unsigned) (longAt(array))) >> 8) & 15; - /* begin success: */ - successValue = (fmt >= 8) && (fmt <= 11); - successFlag = successValue && successFlag; - if (successFlag) { - /* begin lengthOf: */ - header = longAt(array); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz = (longAt(array - 8)) & 4294967292U; - } else { - sz = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - arrayLength = ((unsigned) (sz - 4)) >> 2; - goto l3; - } else { - arrayLength = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l3; - } - l3: /* end lengthOf:baseHeader:format: */; - bytesWritten = sqMIDIPortWriteFromAt(portNum, arrayLength, array + 4, time); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 4 * 4; - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, ((bytesWritten << 1) | 1)); - stackPointer = sp; - } -} - -int primitiveMakePoint(void) { - int argument; - int pt; - int rcvr; - int valuePointer; - int valuePointer1; - int valuePointer2; - int sp; - int pointResult; - int pointResult1; - int pointResult2; - - argument = longAt(stackPointer - (0 * 4)); - rcvr = longAt(stackPointer - (1 * 4)); - if ((rcvr & 1)) { - if ((argument & 1)) { - /* begin makePointwithxValue:yValue: */ - pointResult = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2)), 12, nilObj); - /* begin storePointer:ofObject:withValue: */ - if (pointResult < youngStart) { - possibleRootStoreIntovalue(pointResult, ((((rcvr >> 1)) << 1) | 1)); - } - longAtput(((((char *) pointResult)) + 4) + (0 << 2), ((((rcvr >> 1)) << 1) | 1)); - /* begin storePointer:ofObject:withValue: */ - if (pointResult < youngStart) { - possibleRootStoreIntovalue(pointResult, ((((argument >> 1)) << 1) | 1)); - } - longAtput(((((char *) pointResult)) + 4) + (1 << 2), ((((argument >> 1)) << 1) | 1)); - pt = pointResult; - } else { - /* begin makePointwithxValue:yValue: */ - pointResult1 = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2)), 12, nilObj); - /* begin storePointer:ofObject:withValue: */ - if (pointResult1 < youngStart) { - possibleRootStoreIntovalue(pointResult1, ((((rcvr >> 1)) << 1) | 1)); - } - longAtput(((((char *) pointResult1)) + 4) + (0 << 2), ((((rcvr >> 1)) << 1) | 1)); - /* begin storePointer:ofObject:withValue: */ - if (pointResult1 < youngStart) { - possibleRootStoreIntovalue(pointResult1, ((0 << 1) | 1)); - } - longAtput(((((char *) pointResult1)) + 4) + (1 << 2), ((0 << 1) | 1)); - pt = pointResult1; - /* begin storePointer:ofObject:withValue: */ - valuePointer = longAt(stackPointer - (0 * 4)); - if (pt < youngStart) { - possibleRootStoreIntovalue(pt, valuePointer); - } - longAtput(((((char *) pt)) + 4) + (1 << 2), valuePointer); - } - } else { - if (!((fetchClassOf(rcvr)) == (longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2))))) { - /* begin success: */ - successFlag = 0 && successFlag; - return null; - } - /* begin makePointwithxValue:yValue: */ - pointResult2 = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2)), 12, nilObj); - /* begin storePointer:ofObject:withValue: */ - if (pointResult2 < youngStart) { - possibleRootStoreIntovalue(pointResult2, ((0 << 1) | 1)); - } - longAtput(((((char *) pointResult2)) + 4) + (0 << 2), ((0 << 1) | 1)); - /* begin storePointer:ofObject:withValue: */ - if (pointResult2 < youngStart) { - possibleRootStoreIntovalue(pointResult2, ((0 << 1) | 1)); - } - longAtput(((((char *) pointResult2)) + 4) + (1 << 2), ((0 << 1) | 1)); - pt = pointResult2; - /* begin storePointer:ofObject:withValue: */ - valuePointer1 = longAt(stackPointer - (1 * 4)); - if (pt < youngStart) { - possibleRootStoreIntovalue(pt, valuePointer1); - } - longAtput(((((char *) pt)) + 4) + (0 << 2), valuePointer1); - /* begin storePointer:ofObject:withValue: */ - valuePointer2 = longAt(stackPointer - (0 * 4)); - if (pt < youngStart) { - possibleRootStoreIntovalue(pt, valuePointer2); - } - longAtput(((((char *) pt)) + 4) + (1 << 2), valuePointer2); - } - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, pt); - stackPointer = sp; -} - -int primitiveMillisecondClock(void) { - int object; - int sp; - - /* begin pop: */ - stackPointer -= 1 * 4; - /* begin push: */ - object = ((((ioMSecs()) & 536870911) << 1) | 1); - longAtput(sp = stackPointer + 4, object); - stackPointer = sp; -} - -int primitiveMod(void) { - int mod; - int sp; - - mod = doPrimitiveModby(longAt(stackPointer - (1 * 4)), longAt(stackPointer - (0 * 4))); - /* begin pop2AndPushIntegerIfOK: */ - if (successFlag) { - if ((mod ^ (mod << 1)) >= 0) { - /* begin pop:thenPush: */ - longAtput(sp = stackPointer - ((2 - 1) * 4), ((mod << 1) | 1)); - stackPointer = sp; - } else { - successFlag = 0; - } - } -} - -int primitiveMouseButtons(void) { - int buttonWord; - int sp; - - /* begin pop: */ - stackPointer -= 1 * 4; - buttonWord = ioGetButtonState(); - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp = stackPointer + 4, ((buttonWord << 1) | 1)); - stackPointer = sp; -} - -int primitiveMousePoint(void) { - int y; - int pointWord; - int x; - int object; - int sp; - int pointResult; - - /* begin pop: */ - stackPointer -= 1 * 4; - pointWord = ioMousePoint(); - /* begin signExtend16: */ - if ((((((unsigned) pointWord) >> 16) & 65535) & 32768) == 0) { - x = (((unsigned) pointWord) >> 16) & 65535; - goto l1; - } else { - x = ((((unsigned) pointWord) >> 16) & 65535) - 65536; - goto l1; - } -l1: /* end signExtend16: */; - /* begin signExtend16: */ - if (((pointWord & 65535) & 32768) == 0) { - y = pointWord & 65535; - goto l2; - } else { - y = (pointWord & 65535) - 65536; - goto l2; - } -l2: /* end signExtend16: */; - /* begin push: */ - /* begin makePointwithxValue:yValue: */ - pointResult = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2)), 12, nilObj); - /* begin storePointer:ofObject:withValue: */ - if (pointResult < youngStart) { - possibleRootStoreIntovalue(pointResult, ((x << 1) | 1)); - } - longAtput(((((char *) pointResult)) + 4) + (0 << 2), ((x << 1) | 1)); - /* begin storePointer:ofObject:withValue: */ - if (pointResult < youngStart) { - possibleRootStoreIntovalue(pointResult, ((y << 1) | 1)); - } - longAtput(((((char *) pointResult)) + 4) + (1 << 2), ((y << 1) | 1)); - object = pointResult; - longAtput(sp = stackPointer + 4, object); - stackPointer = sp; -} - -int primitiveMultiply(void) { - int integerRcvr; - int integerArg; - int integerResult; - int integerPointer; - int integerPointer1; - int sp; - - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (1 * 4)); - if ((integerPointer & 1)) { - integerRcvr = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - integerRcvr = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - /* begin stackIntegerValue: */ - integerPointer1 = longAt(stackPointer - (0 * 4)); - if ((integerPointer1 & 1)) { - integerArg = (integerPointer1 >> 1); - goto l2; - } else { - /* begin primitiveFail */ - successFlag = 0; - integerArg = 0; - goto l2; - } -l2: /* end stackIntegerValue: */; - if (successFlag) { - integerResult = integerRcvr * integerArg; - if ((integerArg == 0) || ((integerResult / integerArg) == integerRcvr)) { - /* begin pop2AndPushIntegerIfOK: */ - if (successFlag) { - if ((integerResult ^ (integerResult << 1)) >= 0) { - /* begin pop:thenPush: */ - longAtput(sp = stackPointer - ((2 - 1) * 4), ((integerResult << 1) | 1)); - stackPointer = sp; - } else { - successFlag = 0; - } - } - } else { - /* begin primitiveFail */ - successFlag = 0; - } - } -} - -int primitiveNew(void) { - int spaceOkay; - int class; - int object; - int sp; - int okay; - int format; - int minFree; - int minFree1; - - class = longAt(stackPointer - (0 * 4)); - /* begin sufficientSpaceToInstantiate:indexableSize: */ - format = (((unsigned) ((longAt(((((char *) class)) + 4) + (2 << 2))) - 1)) >> 8) & 15; - if (((((unsigned ) 0)) > 0) && (format < 2)) { - spaceOkay = 0; - goto l1; - } - if (format < 8) { - /* begin sufficientSpaceToAllocate: */ - minFree = (lowSpaceThreshold + (2500 + (0 * 4))) + 4; - if ((((unsigned ) ((longAt(freeBlock)) & 4294967292U))) >= (((unsigned ) minFree))) { - okay = 1; - goto l2; - } else { - okay = sufficientSpaceAfterGC(minFree); - goto l2; - } - l2: /* end sufficientSpaceToAllocate: */; - } else { - /* begin sufficientSpaceToAllocate: */ - minFree1 = (lowSpaceThreshold + (2500 + 0)) + 4; - if ((((unsigned ) ((longAt(freeBlock)) & 4294967292U))) >= (((unsigned ) minFree1))) { - okay = 1; - goto l3; - } else { - okay = sufficientSpaceAfterGC(minFree1); - goto l3; - } - l3: /* end sufficientSpaceToAllocate: */; - } - spaceOkay = okay; -l1: /* end sufficientSpaceToInstantiate:indexableSize: */; - /* begin success: */ - successFlag = spaceOkay && successFlag; - if (successFlag) { - /* begin push: */ - object = instantiateClassindexableSize(popStack(), 0); - longAtput(sp = stackPointer + 4, object); - stackPointer = sp; - } -} - -int primitiveNewMethod(void) { - int size; - int i; - int header; - int theMethod; - int bytecodeCount; - int class; - int literalCount; - int valuePointer; - int top; - int integerPointer; - int top1; - int top2; - int sp; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - header = top; - /* begin popInteger */ - /* begin popStack */ - top1 = longAt(stackPointer); - stackPointer -= 4; - integerPointer = top1; - if ((integerPointer & 1)) { - bytecodeCount = (integerPointer >> 1); - goto l1; - } else { - successFlag = 0; - bytecodeCount = 1; - goto l1; - } -l1: /* end popInteger */; - /* begin success: */ - successFlag = ((header & 1)) && successFlag; - if (!(successFlag)) { - /* begin unPop: */ - stackPointer += 2 * 4; - } - /* begin popStack */ - top2 = longAt(stackPointer); - stackPointer -= 4; - class = top2; - size = ((((((unsigned) header) >> 10) & 255) + 1) * 4) + bytecodeCount; - theMethod = instantiateClassindexableSize(class, size); - /* begin storePointer:ofObject:withValue: */ - if (theMethod < youngStart) { - possibleRootStoreIntovalue(theMethod, header); - } - longAtput(((((char *) theMethod)) + 4) + (0 << 2), header); - literalCount = (((unsigned) header) >> 10) & 255; - for (i = 1; i <= literalCount; i += 1) { - /* begin storePointer:ofObject:withValue: */ - valuePointer = nilObj; - if (theMethod < youngStart) { - possibleRootStoreIntovalue(theMethod, valuePointer); - } - longAtput(((((char *) theMethod)) + 4) + (i << 2), valuePointer); - } - /* begin push: */ - longAtput(sp = stackPointer + 4, theMethod); - stackPointer = sp; -} - -int primitiveNewWithArg(void) { - int spaceOkay; - int size; - int class; - int okay; - int format; - int oop; - int sp; - int minFree; - int minFree1; - - size = positive32BitValueOf(longAt(stackPointer - (0 * 4))); - class = longAt(stackPointer - (1 * 4)); - /* begin success: */ - successFlag = (size >= 0) && successFlag; - if (successFlag) { - /* begin sufficientSpaceToInstantiate:indexableSize: */ - format = (((unsigned) ((longAt(((((char *) class)) + 4) + (2 << 2))) - 1)) >> 8) & 15; - if (((((unsigned ) size)) > 0) && (format < 2)) { - spaceOkay = 0; - goto l1; - } - if (format < 8) { - /* begin sufficientSpaceToAllocate: */ - minFree = (lowSpaceThreshold + (2500 + (size * 4))) + 4; - if ((((unsigned ) ((longAt(freeBlock)) & 4294967292U))) >= (((unsigned ) minFree))) { - okay = 1; - goto l2; - } else { - okay = sufficientSpaceAfterGC(minFree); - goto l2; - } - l2: /* end sufficientSpaceToAllocate: */; - } else { - /* begin sufficientSpaceToAllocate: */ - minFree1 = (lowSpaceThreshold + (2500 + size)) + 4; - if ((((unsigned ) ((longAt(freeBlock)) & 4294967292U))) >= (((unsigned ) minFree1))) { - okay = 1; - goto l3; - } else { - okay = sufficientSpaceAfterGC(minFree1); - goto l3; - } - l3: /* end sufficientSpaceToAllocate: */; - } - spaceOkay = okay; - l1: /* end sufficientSpaceToInstantiate:indexableSize: */; - /* begin success: */ - successFlag = spaceOkay && successFlag; - class = longAt(stackPointer - (1 * 4)); - } - if (successFlag) { - /* begin pop:thenPush: */ - oop = instantiateClassindexableSize(class, size); - longAtput(sp = stackPointer - ((2 - 1) * 4), oop); - stackPointer = sp; - } -} - -int primitiveNext(void) { - int array; - int stream; - int index; - int limit; - int result; - int atIx; - int sp; - - stream = longAt(stackPointer); - if (!((((((unsigned) (longAt(stream))) >> 8) & 15) <= 4) && ((lengthOf(stream)) >= (2 + 1)))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - array = longAt(((((char *) stream)) + 4) + (0 << 2)); - index = fetchIntegerofObject(1, stream); - limit = fetchIntegerofObject(2, stream); - atIx = array & 28; - if (!((index < limit) && ((atCache[atIx + 1]) == array))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - index += 1; - result = commonVariableatcacheIndex(array, index, atIx); - if (successFlag) { - stream = longAt(stackPointer); - /* begin storeInteger:ofObject:withValue: */ - if ((index ^ (index << 1)) >= 0) { - longAtput(((((char *) stream)) + 4) + (1 << 2), ((index << 1) | 1)); - } else { - /* begin primitiveFail */ - successFlag = 0; - } - /* begin pop:thenPush: */ - longAtput(sp = stackPointer - ((1 - 1) * 4), result); - stackPointer = sp; - return null; - } -} - -int primitiveNextInstance(void) { - int object; - int instance; - int sp; - int top; - int thisClass; - int classPointer; - int thisObj; - int ccIndex; - int ccIndex1; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - object = top; - /* begin instanceAfter: */ - /* begin fetchClassOf: */ - if ((object & 1)) { - classPointer = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l3; - } - ccIndex1 = (((unsigned) (longAt(object))) >> 12) & 31; - if (ccIndex1 == 0) { - classPointer = (longAt(object - 4)) & 4294967292U; - goto l3; - } else { - classPointer = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex1 - 1) << 2)); - goto l3; - } -l3: /* end fetchClassOf: */; - thisObj = accessibleObjectAfter(object); - while (!(thisObj == null)) { - /* begin fetchClassOf: */ - if ((thisObj & 1)) { - thisClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l2; - } - ccIndex = (((unsigned) (longAt(thisObj))) >> 12) & 31; - if (ccIndex == 0) { - thisClass = (longAt(thisObj - 4)) & 4294967292U; - goto l2; - } else { - thisClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l2; - } - l2: /* end fetchClassOf: */; - if (thisClass == classPointer) { - instance = thisObj; - goto l1; - } - thisObj = accessibleObjectAfter(thisObj); - } - instance = nilObj; -l1: /* end instanceAfter: */; - if (instance == nilObj) { - /* begin unPop: */ - stackPointer += 1 * 4; - /* begin primitiveFail */ - successFlag = 0; - } else { - /* begin push: */ - longAtput(sp = stackPointer + 4, instance); - stackPointer = sp; - } -} - -int primitiveNextObject(void) { - int object; - int instance; - int sp; - int top; - int sp1; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - object = top; - instance = accessibleObjectAfter(object); - if (instance == null) { - /* begin pushInteger: */ - /* begin push: */ - longAtput(sp1 = stackPointer + 4, ((0 << 1) | 1)); - stackPointer = sp1; - } else { - /* begin push: */ - longAtput(sp = stackPointer + 4, instance); - stackPointer = sp; - } -} - -int primitiveNextPut(void) { - int array; - int stream; - int value; - int index; - int limit; - int atIx; - int sp; - int stSize; - int valToPut; - int fmt; - int fixedFields; - - value = longAt(stackPointer); - stream = longAt(stackPointer - (1 * 4)); - if (!((((((unsigned) (longAt(stream))) >> 8) & 15) <= 4) && ((lengthOf(stream)) >= (2 + 1)))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - array = longAt(((((char *) stream)) + 4) + (0 << 2)); - index = fetchIntegerofObject(1, stream); - limit = fetchIntegerofObject(2, stream); - atIx = (array & 28) + 32; - if (!((index < limit) && ((atCache[atIx + 1]) == array))) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - index += 1; - /* begin commonVariable:at:put:cacheIndex: */ - stSize = atCache[atIx + 2]; - if (((((unsigned ) index)) >= 1) && ((((unsigned ) index)) <= (((unsigned ) stSize)))) { - fmt = atCache[atIx + 3]; - if (fmt <= 4) { - fixedFields = atCache[atIx + 4]; - /* begin storePointer:ofObject:withValue: */ - if (array < youngStart) { - possibleRootStoreIntovalue(array, value); - } - longAtput(((((char *) array)) + 4) + (((index + fixedFields) - 1) << 2), value); - goto l1; - } - if (fmt < 8) { - valToPut = positive32BitValueOf(value); - if (successFlag) { - longAtput(((((char *) array)) + 4) + ((index - 1) << 2), valToPut); - } - goto l1; - } - if (fmt >= 16) { - valToPut = asciiOfCharacter(value); - if (!(successFlag)) { - goto l1; - } - } else { - valToPut = value; - } - if ((valToPut & 1)) { - byteAtput(((((char *) array)) + 4) + (index - 1), (valToPut >> 1)); - goto l1; - } - } - /* begin primitiveFail */ - successFlag = 0; -l1: /* end commonVariable:at:put:cacheIndex: */; - if (successFlag) { - /* begin storeInteger:ofObject:withValue: */ - if ((index ^ (index << 1)) >= 0) { - longAtput(((((char *) stream)) + 4) + (1 << 2), ((index << 1) | 1)); - } else { - /* begin primitiveFail */ - successFlag = 0; - } - /* begin pop:thenPush: */ - longAtput(sp = stackPointer - ((2 - 1) * 4), value); - stackPointer = sp; - return null; - } -} - -int primitiveNoop(void) { - /* begin pop: */ - stackPointer -= argumentCount * 4; -} - -int primitiveNotEqual(void) { - int integerReceiver; - int integerArgument; - int result; - int top; - int top1; - int sp; - int sp1; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - integerArgument = top; - /* begin popStack */ - top1 = longAt(stackPointer); - stackPointer -= 4; - integerReceiver = top1; - result = !(compare31or32Bitsequal(integerReceiver, integerArgument)); - /* begin checkBooleanResult: */ - if (successFlag) { - /* begin pushBool: */ - if (result) { - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; - } else { - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; - } - } else { - /* begin unPop: */ - stackPointer += 2 * 4; - } -} - -int primitiveObjectAt(void) { - int thisReceiver; - int index; - int sp; - int integerPointer; - int top; - int top1; - - /* begin popInteger */ - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - integerPointer = top; - if ((integerPointer & 1)) { - index = (integerPointer >> 1); - goto l1; - } else { - successFlag = 0; - index = 1; - goto l1; - } -l1: /* end popInteger */; - /* begin popStack */ - top1 = longAt(stackPointer); - stackPointer -= 4; - thisReceiver = top1; - /* begin success: */ - successFlag = (index > 0) && successFlag; - /* begin success: */ - successFlag = (index <= (((((unsigned) (longAt(((((char *) thisReceiver)) + 4) + (0 << 2)))) >> 10) & 255) + 1)) && successFlag; - if (successFlag) { - /* begin push: */ - longAtput(sp = stackPointer + 4, longAt(((((char *) thisReceiver)) + 4) + ((index - 1) << 2))); - stackPointer = sp; - } else { - /* begin unPop: */ - stackPointer += 2 * 4; - } -} - -int primitiveObjectAtPut(void) { - int thisReceiver; - int newValue; - int index; - int sp; - int top; - int integerPointer; - int top1; - int top2; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - newValue = top; - /* begin popInteger */ - /* begin popStack */ - top1 = longAt(stackPointer); - stackPointer -= 4; - integerPointer = top1; - if ((integerPointer & 1)) { - index = (integerPointer >> 1); - goto l1; - } else { - successFlag = 0; - index = 1; - goto l1; - } -l1: /* end popInteger */; - /* begin popStack */ - top2 = longAt(stackPointer); - stackPointer -= 4; - thisReceiver = top2; - /* begin success: */ - successFlag = (index > 0) && successFlag; - /* begin success: */ - successFlag = (index <= (((((unsigned) (longAt(((((char *) thisReceiver)) + 4) + (0 << 2)))) >> 10) & 255) + 1)) && successFlag; - if (successFlag) { - /* begin storePointer:ofObject:withValue: */ - if (thisReceiver < youngStart) { - possibleRootStoreIntovalue(thisReceiver, newValue); - } - longAtput(((((char *) thisReceiver)) + 4) + ((index - 1) << 2), newValue); - /* begin push: */ - longAtput(sp = stackPointer + 4, newValue); - stackPointer = sp; - } else { - /* begin unPop: */ - stackPointer += 3 * 4; - } -} - -int primitiveObjectPointsTo(void) { - int i; - int thang; - int rcvr; - int lastField; - int top; - int top1; - int sp; - int sp1; - int sp2; - int sp3; - int sp4; - int sp5; - int methodHeader; - int sz; - int fmt; - int header; - int header1; - int type; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - thang = top; - /* begin popStack */ - top1 = longAt(stackPointer); - stackPointer -= 4; - rcvr = top1; - if ((rcvr & 1)) { - /* begin pushBool: */ - /* begin push: */ - longAtput(sp1 = stackPointer + 4, falseObj); - stackPointer = sp1; -; - return null; - } - /* begin lastPointerOf: */ - header = longAt(rcvr); - fmt = (((unsigned) header) >> 8) & 15; - if (fmt <= 4) { - if ((fmt == 3) && (isContextHeader(header))) { - lastField = (6 + (fetchStackPointerOf(rcvr))) * 4; - goto l1; - } - /* begin sizeBitsOfSafe: */ - header1 = longAt(rcvr); - /* begin rightType: */ - if ((header1 & 252) == 0) { - type = 0; - goto l2; - } else { - if ((header1 & 126976) == 0) { - type = 1; - goto l2; - } else { - type = 3; - goto l2; - } - } - l2: /* end rightType: */; - if (type == 0) { - sz = (longAt(rcvr - 8)) & 4294967292U; - goto l3; - } else { - sz = header1 & 252; - goto l3; - } - l3: /* end sizeBitsOfSafe: */; - lastField = sz - 4; - goto l1; - } - if (fmt < 12) { - lastField = 0; - goto l1; - } - methodHeader = longAt(rcvr + 4); - lastField = (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; -l1: /* end lastPointerOf: */; - for (i = 4; i <= lastField; i += 4) { - if ((longAt(rcvr + i)) == thang) { - /* begin pushBool: */ - /* begin push: */ - longAtput(sp2 = stackPointer + 4, trueObj); - stackPointer = sp2; -; - return null; - } - } - /* begin pushBool: */ - /* begin push: */ - longAtput(sp5 = stackPointer + 4, falseObj); - stackPointer = sp5; -; -} - -int primitivePerform(void) { - int performSelector; - int selectorIndex; - int performMethod; - int i; - int newReceiver; - int lookupClass; - int fieldIndex; - int oop; - int valuePointer; - int oop1; - int valuePointer1; - int toIndex; - int fromIndex; - int lastFrom; - int ccIndex; - - performSelector = messageSelector; - performMethod = newMethod; - messageSelector = longAt(stackPointer - ((argumentCount - 1) * 4)); - newReceiver = longAt(stackPointer - (argumentCount * 4)); - argumentCount -= 1; - selectorIndex = (((unsigned) ((stackPointer - activeContext) - 4)) >> 2) - argumentCount; - /* begin transfer:fromIndex:ofObject:toIndex:ofObject: */ - fromIndex = activeContext + ((selectorIndex + 1) * 4); - toIndex = activeContext + (selectorIndex * 4); - lastFrom = fromIndex + (argumentCount * 4); - while (fromIndex < lastFrom) { - fromIndex += 4; - toIndex += 4; - longAtput(toIndex, longAt(fromIndex)); - } - /* begin pop: */ - stackPointer -= 1 * 4; - /* begin fetchClassOf: */ - if ((newReceiver & 1)) { - lookupClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l2; - } - ccIndex = (((unsigned) (longAt(newReceiver))) >> 12) & 31; - if (ccIndex == 0) { - lookupClass = (longAt(newReceiver - 4)) & 4294967292U; - goto l2; - } else { - lookupClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l2; - } -l2: /* end fetchClassOf: */; - findNewMethodInClass(lookupClass); - /* begin success: */ - successFlag = (((((unsigned) (longAt(((((char *) newMethod)) + 4) + (0 << 2)))) >> 25) & 15) == argumentCount) && successFlag; - if (successFlag) { - /* begin executeNewMethod */ - if (primitiveIndex > 0) { - primitiveResponse(); - if (successFlag) { - goto l1; - } - } - /* begin activateNewMethod */ - if (!(compilerInitialized && (compilerActivateMethod()))) { - bytecodeActivateNewMethod(); - } - /* begin quickCheckForInterrupts */ - if ((interruptCheckCounter -= 1) <= 0) { - checkForInterrupts(); - } - l1: /* end executeNewMethod */; - successFlag = 1; - } else { - for (i = 1; i <= argumentCount; i += 1) { - /* begin storePointer:ofObject:withValue: */ - fieldIndex = ((argumentCount - i) + 1) + selectorIndex; - oop = activeContext; - valuePointer = longAt(((((char *) activeContext)) + 4) + (((argumentCount - i) + selectorIndex) << 2)); - if (oop < youngStart) { - possibleRootStoreIntovalue(oop, valuePointer); - } - longAtput(((((char *) oop)) + 4) + (fieldIndex << 2), valuePointer); - } - /* begin unPop: */ - stackPointer += 1 * 4; - /* begin storePointer:ofObject:withValue: */ - oop1 = activeContext; - valuePointer1 = messageSelector; - if (oop1 < youngStart) { - possibleRootStoreIntovalue(oop1, valuePointer1); - } - longAtput(((((char *) oop1)) + 4) + (selectorIndex << 2), valuePointer1); - argumentCount += 1; - newMethod = performMethod; - messageSelector = performSelector; - } -} - -int primitivePerformAt(int lookupClass) { - int argumentArray; - int performSelector; - int arraySize; - int performMethod; - int performArgCount; - int index; - int cntxSize; - int sz; - int objectPointer; - int sz1; - int sp; - int sp1; - int sp2; - int top; - int top1; - int header; - int header1; - int ccIndex; - int cl; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - argumentArray = top; - /* begin assertClassOf:is: */ - if ((argumentArray & 1)) { - successFlag = 0; - goto l4; - } - ccIndex = (((unsigned) (longAt(argumentArray))) >> 12) & 31; - if (ccIndex == 0) { - cl = (longAt(argumentArray - 4)) & 4294967292U; - } else { - cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - } - /* begin success: */ - successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)))) && successFlag; -l4: /* end assertClassOf:is: */; - if (successFlag) { - /* begin fetchWordLengthOf: */ - /* begin sizeBitsOf: */ - header = longAt(argumentArray); - if ((header & 3) == 0) { - sz = (longAt(argumentArray - 8)) & 4294967292U; - goto l1; - } else { - sz = header & 252; - goto l1; - } - l1: /* end sizeBitsOf: */; - arraySize = ((unsigned) (sz - 4)) >> 2; - /* begin fetchWordLengthOf: */ - objectPointer = activeContext; - /* begin sizeBitsOf: */ - header1 = longAt(objectPointer); - if ((header1 & 3) == 0) { - sz1 = (longAt(objectPointer - 8)) & 4294967292U; - goto l2; - } else { - sz1 = header1 & 252; - goto l2; - } - l2: /* end sizeBitsOf: */; - cntxSize = ((unsigned) (sz1 - 4)) >> 2; - /* begin success: */ - successFlag = (((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) + arraySize) < cntxSize) && successFlag; - } - if (!(successFlag)) { - /* begin unPop: */ - stackPointer += 1 * 4; - return null; - } - performSelector = messageSelector; - performMethod = newMethod; - performArgCount = argumentCount; - /* begin popStack */ - top1 = longAt(stackPointer); - stackPointer -= 4; - messageSelector = top1; - index = 1; - while (index <= arraySize) { - /* begin push: */ - longAtput(sp = stackPointer + 4, longAt(((((char *) argumentArray)) + 4) + ((index - 1) << 2))); - stackPointer = sp; - index += 1; - } - argumentCount = arraySize; - findNewMethodInClass(lookupClass); - /* begin success: */ - successFlag = (((((unsigned) (longAt(((((char *) newMethod)) + 4) + (0 << 2)))) >> 25) & 15) == argumentCount) && successFlag; - if (successFlag) { - /* begin executeNewMethod */ - if (primitiveIndex > 0) { - primitiveResponse(); - if (successFlag) { - goto l3; - } - } - /* begin activateNewMethod */ - if (!(compilerInitialized && (compilerActivateMethod()))) { - bytecodeActivateNewMethod(); - } - /* begin quickCheckForInterrupts */ - if ((interruptCheckCounter -= 1) <= 0) { - checkForInterrupts(); - } - l3: /* end executeNewMethod */; - successFlag = 1; - } else { - /* begin pop: */ - stackPointer -= argumentCount * 4; - /* begin push: */ - longAtput(sp1 = stackPointer + 4, messageSelector); - stackPointer = sp1; - /* begin push: */ - longAtput(sp2 = stackPointer + 4, argumentArray); - stackPointer = sp2; - messageSelector = performSelector; - newMethod = performMethod; - argumentCount = performArgCount; - } -} - -int primitivePerformInSuperclass(void) { - int lookupClass; - int rcvr; - int currentClass; - int sp; - int top; - int ccIndex; - - lookupClass = longAt(stackPointer); - rcvr = longAt(stackPointer - (argumentCount * 4)); - /* begin fetchClassOf: */ - if ((rcvr & 1)) { - currentClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l1; - } - ccIndex = (((unsigned) (longAt(rcvr))) >> 12) & 31; - if (ccIndex == 0) { - currentClass = (longAt(rcvr - 4)) & 4294967292U; - goto l1; - } else { - currentClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l1; - } -l1: /* end fetchClassOf: */; - while (currentClass != lookupClass) { - currentClass = longAt(((((char *) currentClass)) + 4) + (0 << 2)); - if (currentClass == nilObj) { - /* begin primitiveFail */ - successFlag = 0; - return null; - } - } - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - primitivePerformAt(lookupClass); - if (!(successFlag)) { - /* begin push: */ - longAtput(sp = stackPointer + 4, lookupClass); - stackPointer = sp; - } -} - -int primitivePerformWithArgs(void) { - int lookupClass; - int rcvr; - int ccIndex; - - rcvr = longAt(stackPointer - (argumentCount * 4)); - /* begin fetchClassOf: */ - if ((rcvr & 1)) { - lookupClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); - goto l1; - } - ccIndex = (((unsigned) (longAt(rcvr))) >> 12) & 31; - if (ccIndex == 0) { - lookupClass = (longAt(rcvr - 4)) & 4294967292U; - goto l1; - } else { - lookupClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - goto l1; - } -l1: /* end fetchClassOf: */; - primitivePerformAt(lookupClass); -} - -int primitivePointX(void) { - int rcvr; - int sp; - int top; - int ccIndex; - int cl; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - rcvr = top; - /* begin assertClassOf:is: */ - if ((rcvr & 1)) { - successFlag = 0; - goto l1; - } - ccIndex = (((unsigned) (longAt(rcvr))) >> 12) & 31; - if (ccIndex == 0) { - cl = (longAt(rcvr - 4)) & 4294967292U; - } else { - cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - } - /* begin success: */ - successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2)))) && successFlag; -l1: /* end assertClassOf:is: */; - if (successFlag) { - /* begin push: */ - longAtput(sp = stackPointer + 4, longAt(((((char *) rcvr)) + 4) + (0 << 2))); - stackPointer = sp; - } else { - /* begin unPop: */ - stackPointer += 1 * 4; - } -} - -int primitivePointY(void) { - int rcvr; - int sp; - int top; - int ccIndex; - int cl; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - rcvr = top; - /* begin assertClassOf:is: */ - if ((rcvr & 1)) { - successFlag = 0; - goto l1; - } - ccIndex = (((unsigned) (longAt(rcvr))) >> 12) & 31; - if (ccIndex == 0) { - cl = (longAt(rcvr - 4)) & 4294967292U; - } else { - cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - } - /* begin success: */ - successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2)))) && successFlag; -l1: /* end assertClassOf:is: */; - if (successFlag) { - /* begin push: */ - longAtput(sp = stackPointer + 4, longAt(((((char *) rcvr)) + 4) + (1 << 2))); - stackPointer = sp; - } else { - /* begin unPop: */ - stackPointer += 1 * 4; - } -} - -int primitivePushFalse(void) { - int top; - int sp; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, falseObj); - stackPointer = sp; -} - -int primitivePushMinusOne(void) { - int top; - int sp; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, 4294967295U); - stackPointer = sp; -} - -int primitivePushNil(void) { - int top; - int sp; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, nilObj); - stackPointer = sp; -} - -int primitivePushOne(void) { - int top; - int sp; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, 3); - stackPointer = sp; -} - -int primitivePushSelf(void) { -} - -int primitivePushTrue(void) { - int top; - int sp; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, trueObj); - stackPointer = sp; -} - -int primitivePushTwo(void) { - int top; - int sp; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, 5); - stackPointer = sp; -} - -int primitivePushZero(void) { - int top; - int sp; - - /* begin popStack */ - top = longAt(stackPointer); - stackPointer -= 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, 1); - stackPointer = sp; -} - -int primitiveQuit(void) { - ioExit(); -} - -int primitiveQuo(void) { - int integerRcvr; - int integerArg; - int integerResult; - int integerPointer; - int integerPointer1; - int sp; - - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (1 * 4)); - if ((integerPointer & 1)) { - integerRcvr = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - integerRcvr = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - /* begin stackIntegerValue: */ - integerPointer1 = longAt(stackPointer - (0 * 4)); - if ((integerPointer1 & 1)) { - integerArg = (integerPointer1 >> 1); - goto l2; - } else { - /* begin primitiveFail */ - successFlag = 0; - integerArg = 0; - goto l2; - } -l2: /* end stackIntegerValue: */; - /* begin success: */ - successFlag = (integerArg != 0) && successFlag; - if (successFlag) { - if (integerRcvr > 0) { - if (integerArg > 0) { - integerResult = integerRcvr / integerArg; - } else { - integerResult = 0 - (integerRcvr / (0 - integerArg)); - } - } else { - if (integerArg > 0) { - integerResult = 0 - ((0 - integerRcvr) / integerArg); - } else { - integerResult = (0 - integerRcvr) / (0 - integerArg); - } - } - } - /* begin pop2AndPushIntegerIfOK: */ - if (successFlag) { - if ((integerResult ^ (integerResult << 1)) >= 0) { - /* begin pop:thenPush: */ - longAtput(sp = stackPointer - ((2 - 1) * 4), ((integerResult << 1) | 1)); - stackPointer = sp; - } else { - successFlag = 0; - } - } -} - -int primitiveReadJoystick(void) { - int index; - int object; - int sp; - int integerPointer; - - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - index = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - index = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - if (successFlag) { - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin push: */ - object = positive32BitIntegerFor(joystickRead(index)); - longAtput(sp = stackPointer + 4, object); - stackPointer = sp; - } -} - -int primitiveReadTablet(void) { - int cursorIndex; - int resultSize; - int result; - int sp; - int integerPointer; - - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - cursorIndex = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - cursorIndex = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - if (successFlag) { - resultSize = tabletResultSize(); - result = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (4 << 2)), resultSize); - /* begin success: */ - successFlag = (tabletRead(cursorIndex, (int *) (result + 4))) && successFlag; - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 2 * 4; - /* begin push: */ - longAtput(sp = stackPointer + 4, result); - stackPointer = sp; - } -} - -int primitiveRelinquishProcessor(void) { - int microSecs; - int integerPointer; - - /* begin stackIntegerValue: */ - integerPointer = longAt(stackPointer - (0 * 4)); - if ((integerPointer & 1)) { - microSecs = (integerPointer >> 1); - goto l1; - } else { - /* begin primitiveFail */ - successFlag = 0; - microSecs = 0; - goto l1; - } -l1: /* end stackIntegerValue: */; - if (successFlag) { - ioRelinquishProcessorForMicroseconds(microSecs); - /* begin pop: */ - stackPointer -= 1 * 4; - } -} - -int primitiveResolverAbortLookup(void) { - sqResolverAbort(); -} - -int primitiveResolverAddressLookupResult(void) { - int sz; - int s; - int sp; - - sz = sqResolverAddrLookupResultSize(); - if (successFlag) { - s = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)), sz); - sqResolverAddrLookupResult(((char *) (s + 4)), sz); - } - if (successFlag) { - /* begin pop:thenPush: */ - longAtput(sp = stackPointer - ((1 - 1) * 4), s); - stackPointer = sp; - } -} - -int primitiveResolverError(void) { - int err; - int sp; - - err = sqResolverError(); - if (successFlag) { - /* begin pop:thenPush: */ - longAtput(sp = stackPointer - ((1 - 1) * 4), ((err << 1) | 1)); - stackPointer = sp; - } -} - -int primitiveResolverLocalAddress(void) { - int addr; - int oop; - int sp; - - addr = sqResolverLocalAddress(); - if (successFlag) { - /* begin pop:thenPush: */ - oop = intToNetAddress(addr); - longAtput(sp = stackPointer - ((1 - 1) * 4), oop); - stackPointer = sp; - } -} - -int primitiveResolverNameLookupResult(void) { - int addr; - int oop; - int sp; - - addr = sqResolverNameLookupResult(); - if (successFlag) { - /* begin pop:thenPush: */ - oop = intToNetAddress(addr); - longAtput(sp = stackPointer - ((1 - 1) * 4), oop); - stackPointer = sp; - } -} - -int primitiveResolverStartAddressLookup(void) { - int addr; - - addr = netAddressToInt(longAt(stackPointer)); - if (successFlag) { - sqResolverStartAddrLookup(addr); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 1 * 4; - } -} - -int primitiveResolverStartNameLookup(void) { - int sz; - int name; - int header; - int sz1; - int ccIndex; - int cl; - - name = longAt(stackPointer); - /* begin assertClassOf:is: */ - if ((name & 1)) { - successFlag = 0; - goto l2; - } - ccIndex = (((unsigned) (longAt(name))) >> 12) & 31; - if (ccIndex == 0) { - cl = (longAt(name - 4)) & 4294967292U; - } else { - cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); - } - /* begin success: */ - successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)))) && successFlag; -l2: /* end assertClassOf:is: */; - if (successFlag) { - /* begin lengthOf: */ - header = longAt(name); - /* begin lengthOf:baseHeader:format: */ - if ((header & 3) == 0) { - sz1 = (longAt(name - 8)) & 4294967292U; - } else { - sz1 = header & 252; - } - if (((((unsigned) header) >> 8) & 15) < 8) { - sz = ((unsigned) (sz1 - 4)) >> 2; - goto l1; - } else { - sz = (sz1 - 4) - (((((unsigned) header) >> 8) & 15) & 3); - goto l1; - } - l1: /* end lengthOf:baseHeader:format: */; - sqResolverStartNameLookup(((char *) (name + 4)), sz); - } - if (successFlag) { - /* begin pop: */ - stackPointer -= 1 * 4; - } -} - -int primitiveResolverStatus(void) { - int status; - int sp; - - status = sqResolverStatus(); - if (successFlag) { - /* begin pop:thenPush: */ - longAtput(sp = stackPointer - ((1 - 1) * 4), ((status << 1) | 1)); - stackPointer = sp; - } -} - -int primitiveResponse(void) { - int startTime; - int timerPending; - - timerPending = nextWakeupTick != 0; - if (timerPending) { - startTime = ioLowResMSecs(); - } - successFlag = 1; - switch (primitiveIndex) { - case 0: - primitiveFail(); - break; - case 1: - primitiveAdd(); - break; - case 2: - primitiveSubtract(); - break; - case 3: - primitiveLessThan(); - break; - case 4: - primitiveGreaterThan(); - break; - case 5: - primitiveLessOrEqual(); - break; - case 6: - primitiveGreaterOrEqual(); - break; - case 7: - primitiveEqual(); - break; - case 8: - primitiveNotEqual(); - break; - case 9: - primitiveMultiply(); - break; - case 10: - primitiveDivide(); - break; - case 11: - primitiveMod(); - break; - case 12: - primitiveDiv(); - break; - case 13: - primitiveQuo(); - break; - case 14: - primitiveBitAnd(); - break; - case 15: - primitiveBitOr(); - break; - case 16: - primitiveBitXor(); - break; - case 17: - primitiveBitShift(); - break; - case 18: - primitiveMakePoint(); - break; - case 19: - case 20: - case 21: - case 22: - case 23: - case 24: - case 25: - case 26: - case 27: - case 28: - case 29: - case 30: - case 31: - case 32: - case 33: - case 34: - case 35: - case 36: - case 37: - case 38: - case 39: - primitiveFail(); - break; - case 40: - primitiveAsFloat(); - break; - case 41: - primitiveFloatAddtoArg(longAt(stackPointer - (1 * 4)), longAt(stackPointer)); - break; - case 42: - primitiveFloatSubtractfromArg(longAt(stackPointer - (1 * 4)), longAt(stackPointer)); - break; - case 43: - primitiveFloatLessThan(); - break; - case 44: - primitiveFloatGreaterThan(); - break; - case 45: - primitiveFloatLessOrEqual(); - break; - case 46: - primitiveFloatGreaterOrEqual(); - break; - case 47: - primitiveFloatEqual(); - break; - case 48: - primitiveFloatNotEqual(); - break; - case 49: - primitiveFloatMultiplybyArg(longAt(stackPointer - (1 * 4)), longAt(stackPointer)); - break; - case 50: - primitiveFloatDividebyArg(longAt(stackPointer - (1 * 4)), longAt(stackPointer)); - break; - case 51: - primitiveTruncated(); - break; - case 52: - primitiveFractionalPart(); - break; - case 53: - primitiveExponent(); - break; - case 54: - primitiveTimesTwoPower(); - break; - case 55: - primitiveSquareRoot(); - break; - case 56: - primitiveSine(); - break; - case 57: - primitiveArctan(); - break; - case 58: - primitiveLogN(); - break; - case 59: - primitiveExp(); - break; - case 60: - primitiveAt(); - break; - case 61: - primitiveAtPut(); - break; - case 62: - primitiveSize(); - break; - case 63: - primitiveStringAt(); - break; - case 64: - primitiveStringAtPut(); - break; - case 65: - primitiveNext(); - break; - case 66: - primitiveNextPut(); - break; - case 67: - primitiveAtEnd(); - break; - case 68: - primitiveObjectAt(); - break; - case 69: - primitiveObjectAtPut(); - break; - case 70: - primitiveNew(); - break; - case 71: - primitiveNewWithArg(); - break; - case 72: - primitiveArrayBecomeOneWay(); - break; - case 73: - primitiveInstVarAt(); - break; - case 74: - primitiveInstVarAtPut(); - break; - case 75: - primitiveAsOop(); - break; - case 76: - primitiveStoreStackp(); - break; - case 77: - primitiveSomeInstance(); - break; - case 78: - primitiveNextInstance(); - break; - case 79: - primitiveNewMethod(); - break; - case 80: - primitiveBlockCopy(); - break; - case 81: - primitiveValue(); - break; - case 82: - primitiveValueWithArgs(); - break; - case 83: - primitivePerform(); - break; - case 84: - primitivePerformWithArgs(); - break; - case 85: - primitiveSignal(); - break; - case 86: - primitiveWait(); - break; - case 87: - primitiveResume(); - break; - case 88: - primitiveSuspend(); - break; - case 89: - primitiveFlushCache(); - break; - case 90: - primitiveMousePoint(); - break; - case 91: - primitiveTestDisplayDepth(); - break; - case 92: - primitiveSetDisplayMode(); - break; - case 93: - primitiveInputSemaphore(); - break; - case 94: - primitiveFail(); - break; - case 95: - primitiveInputWord(); - break; - case 96: - primitiveCopyBits(); - break; - case 97: - primitiveSnapshot(); - break; - case 98: - primitiveStoreImageSegment(); - break; - case 99: - primitiveLoadImageSegment(); - break; - case 100: - primitivePerformInSuperclass(); - break; - case 101: - primitiveBeCursor(); - break; - case 102: - primitiveBeDisplay(); - break; - case 103: - primitiveScanCharacters(); - break; - case 104: - primitiveDrawLoop(); - break; - case 105: - primitiveStringReplace(); - break; - case 106: - primitiveScreenSize(); - break; - case 107: - primitiveMouseButtons(); - break; - case 108: - primitiveKbdNext(); - break; - case 109: - primitiveKbdPeek(); - break; - case 110: - primitiveEquivalent(); - break; - case 111: - primitiveClass(); - break; - case 112: - primitiveBytesLeft(); - break; - case 113: - primitiveQuit(); - break; - case 114: - primitiveExitToDebugger(); - break; - case 115: - primitiveFail(); - break; - case 116: - primitiveFlushCacheByMethod(); - break; - case 117: - primitiveExternalCall(); - break; - case 118: - primitiveDoPrimitiveWithArgs(); - break; - case 119: - primitiveFlushCacheSelective(); - break; - case 120: - primitiveFail(); - break; - case 121: - primitiveImageName(); - break; - case 122: - primitiveNoop(); - break; - case 123: - primitiveFail(); - break; - case 124: - primitiveLowSpaceSemaphore(); - break; - case 125: - primitiveSignalAtBytesLeft(); - break; - case 126: - primitiveDeferDisplayUpdates(); - break; - case 127: - primitiveShowDisplayRect(); - break; - case 128: - primitiveArrayBecome(); - break; - case 129: - primitiveSpecialObjectsOop(); - break; - case 130: - primitiveFullGC(); - break; - case 131: - primitiveIncrementalGC(); - break; - case 132: - primitiveObjectPointsTo(); - break; - case 133: - primitiveSetInterruptKey(); - break; - case 134: - primitiveInterruptSemaphore(); - break; - case 135: - primitiveMillisecondClock(); - break; - case 136: - primitiveSignalAtMilliseconds(); - break; - case 137: - primitiveSecondsClock(); - break; - case 138: - primitiveSomeObject(); - break; - case 139: - primitiveNextObject(); - break; - case 140: - primitiveBeep(); - break; - case 141: - primitiveClipboardText(); - break; - case 142: - primitiveVMPath(); - break; - case 143: - primitiveShortAt(); - break; - case 144: - primitiveShortAtPut(); - break; - case 145: - primitiveConstantFill(); - break; - case 146: - primitiveReadJoystick(); - break; - case 147: - primitiveWarpBits(); - break; - case 148: - primitiveClone(); - break; - case 149: - primitiveGetAttribute(); - break; - case 150: - primitiveFileAtEnd(); - break; - case 151: - primitiveFileClose(); - break; - case 152: - primitiveFileGetPosition(); - break; - case 153: - primitiveFileOpen(); - break; - case 154: - primitiveFileRead(); - break; - case 155: - primitiveFileSetPosition(); - break; - case 156: - primitiveFileDelete(); - break; - case 157: - primitiveFileSize(); - break; - case 158: - primitiveFileWrite(); - break; - case 159: - primitiveFileRename(); - break; - case 160: - primitiveDirectoryCreate(); - break; - case 161: - primitiveDirectoryDelimitor(); - break; - case 162: - primitiveDirectoryLookup(); - break; - case 163: - primitiveDirectoryDelete(); - break; - case 164: - case 165: - case 166: - case 167: - case 168: - primitiveFail(); - break; - case 169: - primitiveDirectorySetMacTypeAndCreator(); - break; - case 170: - primitiveSoundStart(); - break; - case 171: - primitiveSoundStartWithSemaphore(); - break; - case 172: - primitiveSoundStop(); - break; - case 173: - primitiveSoundAvailableSpace(); - break; - case 174: - primitiveSoundPlaySamples(); - break; - case 175: - primitiveSoundPlaySilence(); - break; - case 176: - primWaveTableSoundmixSampleCountintostartingAtpan(); - break; - case 177: - primFMSoundmixSampleCountintostartingAtpan(); - break; - case 178: - primPluckedSoundmixSampleCountintostartingAtpan(); - break; - case 179: - primSampledSoundmixSampleCountintostartingAtpan(); - break; - case 180: - primFMSoundmixSampleCountintostartingAtleftVolrightVol(); - break; - case 181: - primPluckedSoundmixSampleCountintostartingAtleftVolrightVol(); - break; - case 182: - oldprimSampledSoundmixSampleCountintostartingAtleftVolrightVol(); - break; - case 183: - primReverbSoundapplyReverbTostartingAtcount(); - break; - case 184: - primLoopedSampledSoundmixSampleCountintostartingAtleftVolrightVol(); - break; - case 185: - primSampledSoundmixSampleCountintostartingAtleftVolrightVol(); - break; - case 186: - case 187: - case 188: - primitiveFail(); - break; - case 189: - primitiveSoundInsertSamples(); - break; - case 190: - primitiveSoundStartRecording(); - break; - case 191: - primitiveSoundStopRecording(); - break; - case 192: - primitiveSoundGetRecordingSampleRate(); - break; - case 193: - primitiveSoundRecordSamples(); - break; - case 194: - primitiveSoundSetRecordLevel(); - break; - case 195: - case 196: - case 197: - case 198: - case 199: - primitiveFail(); - break; - case 200: - primitiveInitializeNetwork(); - break; - case 201: - primitiveResolverStartNameLookup(); - break; - case 202: - primitiveResolverNameLookupResult(); - break; - case 203: - primitiveResolverStartAddressLookup(); - break; - case 204: - primitiveResolverAddressLookupResult(); - break; - case 205: - primitiveResolverAbortLookup(); - break; - case 206: - primitiveResolverLocalAddress(); - break; - case 207: - primitiveResolverStatus(); - break; - case 208: - primitiveResolverError(); - break; - case 209: - primitiveSocketCreate(); - break; - case 210: - primitiveSocketDestroy(); - break; - case 211: - primitiveSocketConnectionStatus(); - break; - case 212: - primitiveSocketError(); - break; - case 213: - primitiveSocketLocalAddress(); - break; - case 214: - primitiveSocketLocalPort(); - break; - case 215: - primitiveSocketRemoteAddress(); - break; - case 216: - primitiveSocketRemotePort(); - break; - case 217: - primitiveSocketConnectToPort(); - break; - case 218: - primitiveSocketListenOnPort(); - break; - case 219: - primitiveSocketCloseConnection(); - break; - case 220: - primitiveSocketAbortConnection(); - break; - case 221: - primitiveSocketReceiveDataBufCount(); - break; - case 222: - primitiveSocketReceiveDataAvailable(); - break; - case 223: - primitiveSocketSendDataBufCount(); - break; - case 224: - primitiveSocketSendDone(); - break; - case 225: - primitiveSocketAccept(); - break; - case 226: - case 227: - case 228: - case 229: - primitiveFail(); - break; - case 230: - primitiveRelinquishProcessor(); - break; - case 231: - primitiveForceDisplayUpdate(); - break; - case 232: - primitiveFormPrint(); - break; - case 233: - primitiveSetFullScreen(); - break; - case 234: - primBitmapdecompressfromByteArrayat(); - break; - case 235: - primStringcomparewithcollated(); - break; - case 236: - primSampledSoundconvert8bitSignedFromto16Bit(); - break; - case 237: - primBitmapcompresstoByteArray(); - break; - case 238: - primitiveSerialPortOpen(); - break; - case 239: - primitiveSerialPortClose(); - break; - case 240: - primitiveSerialPortWrite(); - break; - case 241: - primitiveSerialPortRead(); - break; - case 242: - primitiveFail(); - break; - case 243: - primStringtranslatefromtotable(); - break; - case 244: - primStringfindFirstInStringinSetstartingAt(); - break; - case 245: - primStringindexOfAsciiinStringstartingAt(); - break; - case 246: - primStringfindSubstringinstartingAtmatchTable(); - break; - case 247: - case 248: - case 249: - primitiveFail(); - break; - case 250: - clearProfile(); - break; - case 251: - dumpProfile(); - break; - case 252: - startProfiling(); - break; - case 253: - stopProfiling(); - break; - case 254: - primitiveVMParameter(); - break; - case 255: - primitiveInstVarsPutFromStack(); - break; - case 256: - primitivePushSelf(); - break; - case 257: - primitivePushTrue(); - break; - case 258: - primitivePushFalse(); - break; - case 259: - primitivePushNil(); - break; - case 260: - primitivePushMinusOne(); - break; - case 261: - primitivePushZero(); - break; - case 262: - primitivePushOne(); - break; - case 263: - primitivePushTwo(); - break; - case 264: - case 265: - case 266: - case 267: - case 268: - case 269: - case 270: - case 271: - case 272: - case 273: - case 274: - case 275: - case 276: - case 277: - case 278: - case 279: - case 280: - case 281: - case 282: - case 283: - case 284: - case 285: - case 286: - case 287: - case 288: - case 289: - case 290: - case 291: - case 292: - case 293: - case 294: - case 295: - case 296: - case 297: - case 298: - case 299: - case 300: - case 301: - case 302: - case 303: - case 304: - case 305: - case 306: - case 307: - case 308: - case 309: - case 310: - case 311: - case 312: - case 313: - case 314: - case 315: - case 316: - case 317: - case 318: - case 319: - case 320: - case 321: - case 322: - case 323: - case 324: - case 325: - case 326: - case 327: - case 328: - case 329: - case 330: - case 331: - case 332: - case 333: - case 334: - case 335: - case 336: - case 337: - case 338: - case 339: - case 340: - case 341: - case 342: - case 343: - case 344: - case 345: - case 346: - case 347: - case 348: - case 349: - case 350: - case 351: - case 352: - case 353: - case 354: - case 355: - case 356: - case 357: - case 358: - case 359: - case 360: - case 361: - case 362: - case 363: - case 364: - case 365: - case 366: - case 367: - case 368: - case 369: - case 370: - case 371: - case 372: - case 373: - case 374: - case 375: - case 376: - case 377: - case 378: - case 379: - case 380: - case 381: - case 382: - case 383: - case 384: - case 385: - case 386: - case 387: - case 388: - case 389: - case 390: - case 391: - case 392: - case 393: - case 394: - case 395: - case 396: - case 397: - case 398: - case 399: - case 400: - case 401: - case 402: - case 403: - case 404: - case 405: - case 406: - case 407: - case 408: - case 409: - case 410: - case 411: - case 412: - case 413: - case 414: - case 415: - case 416: - case 417: - case 418: - case 419: - case 420: - case 421: - case 422: - case 423: - case 424: - case 425: - case 426: - case 427: - case 428: - case 429: - case 430: - case 431: - case 432: - case 433: - case 434: - case 435: - case 436: - case 437: - case 438: - case 439: - case 440: - case 441: - case 442: - case 443: - case 444: - case 445: - case 446: - case 447: - case 448: - case 449: - case 450: - case 451: - case 452: - case 453: - case 454: - case 455: - case 456: - case 457: - case 458: - case 459: - case 460: - case 461: - case 462: - case 463: - case 464: - case 465: - case 466: - case 467: - case 468: - case 469: - case 470: - case 471: - case 472: - case 473: - case 474: - case 475: - case 476: - case 477: - case 478: - case 479: - case 480: - case 481: - case 482: - case 483: - case 484: - case 485: - case 486: - case 487: - case 488: - case 489: - case 490: - case 491: - case 492: - case 493: - case 494: - case 495: - case 496: - case 497: - case 498: - case 499: - case 500: - case 501: - case 502: - case 503: - case 504: - case 505: - case 506: - case 507: - case 508: - case 509: - case 510: - case 511: - case 512: - case 513: - case 514: - case 515: - case 516: - case 517: - case 518: - case 519: - primitiveLoadInstVar(); - break; - case 520: - primitiveFail(); - break; - case 521: - primitiveMIDIClosePort(); - break; - case 522: - primitiveMIDIGetClock(); - break; - case 523: - primitiveMIDIGetPortCount(); - break; - case 524: - primitiveMIDIGetPortDirectionality(); - break; - case 525: - primitiveMIDIGetPortName(); - break; - case 526: - primitiveMIDIOpenPort(); - break; - case 527: - primitiveMIDIParameterGetOrSet(); - break; - case 528: - primitiveMIDIRead(); - break; - case 529: - primitiveMIDIWrite(); - break; - case 530: - case 531: - case 532: - case 533: - case 534: - case 535: - case 536: - case 537: - case 538: - case 539: - primitiveFail(); - break; - case 540: - primitiveAsyncFileClose(); - break; - case 541: - primitiveAsyncFileOpen(); - break; - case 542: - primitiveAsyncFileReadResult(); - break; - case 543: - primitiveAsyncFileReadStart(); - break; - case 544: - primitiveAsyncFileWriteResult(); - break; - case 545: - primitiveAsyncFileWriteStart(); - break; - case 546: - case 547: - primitiveFail(); - break; - case 548: - primitiveGetTabletParameters(); - break; - case 549: - primitiveReadTablet(); - break; - case 550: - primADPCMCodecprivateDecodeMono(); - break; - case 551: - primADPCMCodecprivateDecodeStereo(); - break; - case 552: - primADPCMCodecprivateEncodeMono(); - break; - case 553: - primADPCMCodecprivateEncodeStereo(); - break; - case 554: - case 555: - case 556: - case 557: - case 558: - case 559: - case 560: - case 561: - case 562: - case 563: - case 564: - case 565: - case 566: - case 567: - case 568: - case 569: - case 570: - case 571: - case 572: - case 573: - case 574: - case 575: - case 576: - case 577: - case 578: - case 579: - case 580: - case 581: - case 582: - case 583: - case 584: - case 585: - case 586: - case 587: - case 588: - case 589: - case 590: - case 591: - case 592: - case 593: - case 594: - case 595: - case 596: - case 597: - case 598: - case 599: - case 600: - case 601: - case 602: - case 603: - case 604: - case 605: - case 606: - case 607: - case 608: - case 609: - case 610: - case 611: - case 612: - case 613: - case 614: - case 615: - case 616: - case 617: - case 618: - case 619: - case 620: - case 621: - case 622: - case 623: - case 624: - case 625: - case 626: - case 627: - case 628: - case 629: - case 630: - case 631: - case 632: - case 633: - case 634: - case 635: - case 636: - case 637: - case 638: - case 639: - case 640: - case 641: - case 642: - case 643: - case 644: - case 645: - case 646: - case 647: - case 648: - case 649: - case 650: - case 651: - case 652: - case 653: - case 654: - case 655: - case 656: - case 657: - case 658: - case 659: - case 660: - case 661: - case 662: - case 663: - case 664: - case 665: - case 666: - case 667: - case 668: - case 669: - case 670: - case 671: - case 672: - case 673: - case 674: - case 675: - case 676: - case 677: - case 678: - case 679: - case 680: - case 681: - case 682: - case 683: - case 684: - case 685: - case 686: - case 687: - case 688: - case 689: - case 690: - case 691: - case 692: - case 693: - case 694: - case 695: - case 696: - case 697: - case 698: - case 699: - case 700: - primitiveFail(); - break; + ; + /* begin internalizeIPandSP */ + localIP = ((char *) instructionPointer); + localSP = ((char *) stackPointer); + localHomeContext = theHomeContext; + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + while (1) { + switch (currentBytecode) { + case 0: + /* pushReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushReceiverVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((0 & 15) << 2))); + break; + case 1: + /* pushReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushReceiverVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((1 & 15) << 2))); + break; + case 2: + /* pushReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushReceiverVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((2 & 15) << 2))); + break; + case 3: + /* pushReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushReceiverVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((3 & 15) << 2))); + break; + case 4: + /* pushReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushReceiverVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((4 & 15) << 2))); + break; + case 5: + /* pushReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushReceiverVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((5 & 15) << 2))); + break; + case 6: + /* pushReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushReceiverVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((6 & 15) << 2))); + break; + case 7: + /* pushReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushReceiverVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((7 & 15) << 2))); + break; + case 8: + /* pushReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushReceiverVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((8 & 15) << 2))); + break; + case 9: + /* pushReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushReceiverVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((9 & 15) << 2))); + break; + case 10: + /* pushReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushReceiverVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((10 & 15) << 2))); + break; + case 11: + /* pushReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushReceiverVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((11 & 15) << 2))); + break; + case 12: + /* pushReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushReceiverVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((12 & 15) << 2))); + break; + case 13: + /* pushReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushReceiverVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((13 & 15) << 2))); + break; + case 14: + /* pushReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushReceiverVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((14 & 15) << 2))); + break; + case 15: + /* pushReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushReceiverVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((15 & 15) << 2))); + break; + case 16: + /* pushTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushTemporaryVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((16 & 15) + 6) << 2))); + break; + case 17: + /* pushTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushTemporaryVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((17 & 15) + 6) << 2))); + break; + case 18: + /* pushTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushTemporaryVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((18 & 15) + 6) << 2))); + break; + case 19: + /* pushTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushTemporaryVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((19 & 15) + 6) << 2))); + break; + case 20: + /* pushTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushTemporaryVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((20 & 15) + 6) << 2))); + break; + case 21: + /* pushTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushTemporaryVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((21 & 15) + 6) << 2))); + break; + case 22: + /* pushTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushTemporaryVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((22 & 15) + 6) << 2))); + break; + case 23: + /* pushTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushTemporaryVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((23 & 15) + 6) << 2))); + break; + case 24: + /* pushTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushTemporaryVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((24 & 15) + 6) << 2))); + break; + case 25: + /* pushTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushTemporaryVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((25 & 15) + 6) << 2))); + break; + case 26: + /* pushTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushTemporaryVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((26 & 15) + 6) << 2))); + break; + case 27: + /* pushTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushTemporaryVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((27 & 15) + 6) << 2))); + break; + case 28: + /* pushTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushTemporaryVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((28 & 15) + 6) << 2))); + break; + case 29: + /* pushTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushTemporaryVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((29 & 15) + 6) << 2))); + break; + case 30: + /* pushTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushTemporaryVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((30 & 15) + 6) << 2))); + break; + case 31: + /* pushTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushTemporaryVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + (((31 & 15) + 6) << 2))); + break; + case 32: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((32 & 31) + 1) << 2))); + break; + case 33: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((33 & 31) + 1) << 2))); + break; + case 34: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((34 & 31) + 1) << 2))); + break; + case 35: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((35 & 31) + 1) << 2))); + break; + case 36: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((36 & 31) + 1) << 2))); + break; + case 37: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((37 & 31) + 1) << 2))); + break; + case 38: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((38 & 31) + 1) << 2))); + break; + case 39: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((39 & 31) + 1) << 2))); + break; + case 40: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((40 & 31) + 1) << 2))); + break; + case 41: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((41 & 31) + 1) << 2))); + break; + case 42: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((42 & 31) + 1) << 2))); + break; + case 43: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((43 & 31) + 1) << 2))); + break; + case 44: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((44 & 31) + 1) << 2))); + break; + case 45: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((45 & 31) + 1) << 2))); + break; + case 46: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((46 & 31) + 1) << 2))); + break; + case 47: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((47 & 31) + 1) << 2))); + break; + case 48: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((48 & 31) + 1) << 2))); + break; + case 49: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((49 & 31) + 1) << 2))); + break; + case 50: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((50 & 31) + 1) << 2))); + break; + case 51: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((51 & 31) + 1) << 2))); + break; + case 52: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((52 & 31) + 1) << 2))); + break; + case 53: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((53 & 31) + 1) << 2))); + break; + case 54: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((54 & 31) + 1) << 2))); + break; + case 55: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((55 & 31) + 1) << 2))); + break; + case 56: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((56 & 31) + 1) << 2))); + break; + case 57: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((57 & 31) + 1) << 2))); + break; + case 58: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((58 & 31) + 1) << 2))); + break; + case 59: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((59 & 31) + 1) << 2))); + break; + case 60: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((60 & 31) + 1) << 2))); + break; + case 61: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((61 & 31) + 1) << 2))); + break; + case 62: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((62 & 31) + 1) << 2))); + break; + case 63: + /* pushLiteralConstantBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((63 & 31) + 1) << 2))); + break; + case 64: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((64 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 65: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((65 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 66: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((66 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 67: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((67 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 68: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((68 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 69: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((69 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 70: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((70 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 71: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((71 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 72: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((72 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 73: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((73 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 74: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((74 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 75: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((75 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 76: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((76 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 77: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((77 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 78: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((78 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 79: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((79 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 80: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((80 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 81: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((81 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 82: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((82 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 83: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((83 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 84: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((84 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 85: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((85 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 86: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((86 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 87: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((87 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 88: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((88 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 89: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((89 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 90: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((90 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 91: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((91 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 92: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((92 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 93: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((93 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 94: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((94 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 95: + /* pushLiteralVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((95 & 31) + 1) << 2))))) + 4) + (1 << 2))); + break; + case 96: + /* storeAndPopReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + t2 = receiver; + t1 = longAt(localSP); + if (t2 < youngStart) { + possibleRootStoreIntovalue(t2, t1); + } + longAtput(((((char *) t2)) + 4) + ((96 & 7) << 2), t1); + /* begin internalPop: */ + localSP -= 1 * 4; + break; + case 97: + /* storeAndPopReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + t2 = receiver; + t1 = longAt(localSP); + if (t2 < youngStart) { + possibleRootStoreIntovalue(t2, t1); + } + longAtput(((((char *) t2)) + 4) + ((97 & 7) << 2), t1); + /* begin internalPop: */ + localSP -= 1 * 4; + break; + case 98: + /* storeAndPopReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + t2 = receiver; + t1 = longAt(localSP); + if (t2 < youngStart) { + possibleRootStoreIntovalue(t2, t1); + } + longAtput(((((char *) t2)) + 4) + ((98 & 7) << 2), t1); + /* begin internalPop: */ + localSP -= 1 * 4; + break; + case 99: + /* storeAndPopReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + t2 = receiver; + t1 = longAt(localSP); + if (t2 < youngStart) { + possibleRootStoreIntovalue(t2, t1); + } + longAtput(((((char *) t2)) + 4) + ((99 & 7) << 2), t1); + /* begin internalPop: */ + localSP -= 1 * 4; + break; + case 100: + /* storeAndPopReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + t2 = receiver; + t1 = longAt(localSP); + if (t2 < youngStart) { + possibleRootStoreIntovalue(t2, t1); + } + longAtput(((((char *) t2)) + 4) + ((100 & 7) << 2), t1); + /* begin internalPop: */ + localSP -= 1 * 4; + break; + case 101: + /* storeAndPopReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + t2 = receiver; + t1 = longAt(localSP); + if (t2 < youngStart) { + possibleRootStoreIntovalue(t2, t1); + } + longAtput(((((char *) t2)) + 4) + ((101 & 7) << 2), t1); + /* begin internalPop: */ + localSP -= 1 * 4; + break; + case 102: + /* storeAndPopReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + t2 = receiver; + t1 = longAt(localSP); + if (t2 < youngStart) { + possibleRootStoreIntovalue(t2, t1); + } + longAtput(((((char *) t2)) + 4) + ((102 & 7) << 2), t1); + /* begin internalPop: */ + localSP -= 1 * 4; + break; + case 103: + /* storeAndPopReceiverVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + t2 = receiver; + t1 = longAt(localSP); + if (t2 < youngStart) { + possibleRootStoreIntovalue(t2, t1); + } + longAtput(((((char *) t2)) + 4) + ((103 & 7) << 2), t1); + /* begin internalPop: */ + localSP -= 1 * 4; + break; + case 104: + /* storeAndPopTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + longAtput(((((char *) localHomeContext)) + 4) + (((104 & 7) + 6) << 2), longAt(localSP)); + /* begin internalPop: */ + localSP -= 1 * 4; + break; + case 105: + /* storeAndPopTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + longAtput(((((char *) localHomeContext)) + 4) + (((105 & 7) + 6) << 2), longAt(localSP)); + /* begin internalPop: */ + localSP -= 1 * 4; + break; + case 106: + /* storeAndPopTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + longAtput(((((char *) localHomeContext)) + 4) + (((106 & 7) + 6) << 2), longAt(localSP)); + /* begin internalPop: */ + localSP -= 1 * 4; + break; + case 107: + /* storeAndPopTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + longAtput(((((char *) localHomeContext)) + 4) + (((107 & 7) + 6) << 2), longAt(localSP)); + /* begin internalPop: */ + localSP -= 1 * 4; + break; + case 108: + /* storeAndPopTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + longAtput(((((char *) localHomeContext)) + 4) + (((108 & 7) + 6) << 2), longAt(localSP)); + /* begin internalPop: */ + localSP -= 1 * 4; + break; + case 109: + /* storeAndPopTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + longAtput(((((char *) localHomeContext)) + 4) + (((109 & 7) + 6) << 2), longAt(localSP)); + /* begin internalPop: */ + localSP -= 1 * 4; + break; + case 110: + /* storeAndPopTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + longAtput(((((char *) localHomeContext)) + 4) + (((110 & 7) + 6) << 2), longAt(localSP)); + /* begin internalPop: */ + localSP -= 1 * 4; + break; + case 111: + /* storeAndPopTemporaryVariableBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + longAtput(((((char *) localHomeContext)) + 4) + (((111 & 7) + 6) << 2), longAt(localSP)); + /* begin internalPop: */ + localSP -= 1 * 4; + break; + case 112: + /* pushReceiverBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin internalPush: */ + longAtput(localSP += 4, receiver); + break; + case 113: + /* pushConstantTrueBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin internalPush: */ + longAtput(localSP += 4, trueObj); + break; + case 114: + /* pushConstantFalseBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin internalPush: */ + longAtput(localSP += 4, falseObj); + break; + case 115: + /* pushConstantNilBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin internalPush: */ + longAtput(localSP += 4, nilObj); + break; + case 116: + /* pushConstantMinusOneBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin internalPush: */ + longAtput(localSP += 4, 4294967295U); + break; + case 117: + /* pushConstantZeroBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin internalPush: */ + longAtput(localSP += 4, 1); + break; + case 118: + /* pushConstantOneBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin internalPush: */ + longAtput(localSP += 4, 3); + break; + case 119: + /* pushConstantTwoBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin internalPush: */ + longAtput(localSP += 4, 5); + break; + case 120: + /* returnReceiver */ + t2 = longAt(((((char *) localHomeContext)) + 4) + (0 << 2)); + t1 = receiver; + /* begin returnValue:to: */ + commonReturn: /* */; + t5 = nilObj; + t4 = activeContext; + if ((t2 == t5) || ((longAt(((((char *) t2)) + 4) + (1 << 2))) == t5)) { + /* begin internalCannotReturn: */ + /* begin internalPush: */ + longAtput(localSP += 4, activeContext); + /* begin internalPush: */ + longAtput(localSP += 4, t1); + messageSelector = longAt(((((char *) specialObjectsOop)) + 4) + (21 << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l4: /* end fetchClassOf: */; + l2: /* end lookupInMethodCacheSel:class: */; + l3: /* end internalExecuteNewMethod */; + } + t4 = longAt(((((char *) activeContext)) + 4) + (0 << 2)); + while (!(t4 == t2)) { + if (t4 == nilObj) { + /* begin internalCannotReturn: */ + /* begin internalPush: */ + longAtput(localSP += 4, activeContext); + /* begin internalPush: */ + longAtput(localSP += 4, t1); + messageSelector = longAt(((((char *) specialObjectsOop)) + 4) + (21 << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l5: /* end fetchClassOf: */; + l6: /* end lookupInMethodCacheSel:class: */; + l7: /* end internalExecuteNewMethod */; + } + if (isUnwindMarked(t4)) { + /* begin internalAboutToReturn:through: */ + /* begin internalPush: */ + longAtput(localSP += 4, activeContext); + /* begin internalPush: */ + longAtput(localSP += 4, t1); + /* begin internalPush: */ + longAtput(localSP += 4, t4); + messageSelector = longAt(((((char *) specialObjectsOop)) + 4) + (48 << 2)); + argumentCount = 2; + /* begin normalSend */ + goto commonSend; + l8: /* end fetchClassOf: */; + l9: /* end lookupInMethodCacheSel:class: */; + l10: /* end internalExecuteNewMethod */; + } + t4 = longAt(((((char *) t4)) + 4) + (0 << 2)); + } + t4 = activeContext; + while (!(t4 == t2)) { + t3 = longAt(((((char *) t4)) + 4) + (0 << 2)); + longAtput(((((char *) t4)) + 4) + (0 << 2), t5); + longAtput(((((char *) t4)) + 4) + (1 << 2), t5); + if (reclaimableContextCount > 0) { + reclaimableContextCount -= 1; + /* begin recycleContextIfPossible: */ + if (t4 >= youngStart) { + t6 = longAt(t4); + if (((((unsigned) t6) >> 12) & 31) == 14) { + if ((t6 & 252) == 92) { + longAtput(((((char *) t4)) + 4) + (0 << 2), freeContexts); + freeContexts = t4; + } + if ((t6 & 252) == 252) { + longAtput(((((char *) t4)) + 4) + (0 << 2), freeLargeContexts); + freeLargeContexts = t4; + } + } + } + } + t4 = t3; + } + activeContext = t4; + if (t4 < youngStart) { + beRootIfOld(t4); + } + /* begin internalFetchContextRegisters: */ + t7 = longAt(((((char *) t4)) + 4) + (3 << 2)); + if ((t7 & 1)) { + t7 = longAt(((((char *) t4)) + 4) + (5 << 2)); + if (t7 < youngStart) { + beRootIfOld(t7); + } + } else { + t7 = t4; + } + localHomeContext = t7; + receiver = longAt(((((char *) t7)) + 4) + (5 << 2)); + method = longAt(((((char *) t7)) + 4) + (3 << 2)); + t7 = ((longAt(((((char *) t4)) + 4) + (1 << 2))) >> 1); + localIP = ((char *) (((method + t7) + 4) - 2)); + t7 = ((longAt(((((char *) t4)) + 4) + (2 << 2))) >> 1); + localSP = ((char *) ((t4 + 4) + (((6 + t7) - 1) * 4))); + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin internalPush: */ + longAtput(localSP += 4, t1); + l1: /* end returnValue:to: */; + break; + case 121: + /* returnTrue */ + t2 = longAt(((((char *) localHomeContext)) + 4) + (0 << 2)); + t1 = trueObj; + /* begin returnValue:to: */ + goto commonReturn; + l11: /* end returnValue:to: */; + break; + case 122: + /* returnFalse */ + t2 = longAt(((((char *) localHomeContext)) + 4) + (0 << 2)); + t1 = falseObj; + /* begin returnValue:to: */ + goto commonReturn; + l21: /* end returnValue:to: */; + break; + case 123: + /* returnNil */ + t2 = longAt(((((char *) localHomeContext)) + 4) + (0 << 2)); + t1 = nilObj; + /* begin returnValue:to: */ + goto commonReturn; + l31: /* end returnValue:to: */; + break; + case 124: + /* returnTopFromMethod */ + t2 = longAt(((((char *) localHomeContext)) + 4) + (0 << 2)); + t1 = longAt(localSP); + /* begin returnValue:to: */ + goto commonReturn; + l41: /* end returnValue:to: */; + break; + case 125: + /* returnTopFromBlock */ + t2 = longAt(((((char *) activeContext)) + 4) + (0 << 2)); + t1 = longAt(localSP); + /* begin returnValue:to: */ + goto commonReturn; + l51: /* end returnValue:to: */; + break; + case 126: + case 127: + /* unknownBytecode */ + error("Unknown bytecode"); + break; + case 128: + /* extendedPushBytecode */ + t1 = byteAt(++localIP); + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + t2 = (((unsigned) t1) >> 6) & 3; + t3 = t1 & 63; + if (t2 == 0) { + /* begin pushReceiverVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + (t3 << 2))); + goto l61; + } + if (t2 == 1) { + /* begin pushTemporaryVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) localHomeContext)) + 4) + ((t3 + 6) << 2))); + goto l61; + } + if (t2 == 2) { + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + ((t3 + 1) << 2))); + goto l61; + } + if (t2 == 3) { + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + ((t3 + 1) << 2))))) + 4) + (1 << 2))); + goto l61; + } + l61: /* end case */; + break; + case 129: + /* extendedStoreBytecode */ + t2 = byteAt(++localIP); + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + t3 = (((unsigned) t2) >> 6) & 3; + t4 = t2 & 63; + if (t3 == 0) { + /* begin storePointer:ofObject:withValue: */ + t5 = receiver; + t6 = longAt(localSP); + if (t5 < youngStart) { + possibleRootStoreIntovalue(t5, t6); + } + longAtput(((((char *) t5)) + 4) + (t4 << 2), t6); + goto l62; + } + if (t3 == 1) { + longAtput(((((char *) localHomeContext)) + 4) + ((t4 + 6) << 2), longAt(localSP)); + goto l62; + } + if (t3 == 2) { + error("illegal store"); + } + if (t3 == 3) { + t1 = longAt(((((char *) method)) + 4) + ((t4 + 1) << 2)); + /* begin storePointer:ofObject:withValue: */ + t7 = longAt(localSP); + if (t1 < youngStart) { + possibleRootStoreIntovalue(t1, t7); + } + longAtput(((((char *) t1)) + 4) + (1 << 2), t7); + goto l62; + } + l62: /* end case */; + break; + case 130: + /* extendedStoreAndPopBytecode */ + /* begin extendedStoreBytecode */ + t2 = byteAt(++localIP); + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + t3 = (((unsigned) t2) >> 6) & 3; + t4 = t2 & 63; + if (t3 == 0) { + /* begin storePointer:ofObject:withValue: */ + t5 = receiver; + t6 = longAt(localSP); + if (t5 < youngStart) { + possibleRootStoreIntovalue(t5, t6); + } + longAtput(((((char *) t5)) + 4) + (t4 << 2), t6); + goto l63; + } + if (t3 == 1) { + longAtput(((((char *) localHomeContext)) + 4) + ((t4 + 6) << 2), longAt(localSP)); + goto l63; + } + if (t3 == 2) { + error("illegal store"); + } + if (t3 == 3) { + t1 = longAt(((((char *) method)) + 4) + ((t4 + 1) << 2)); + /* begin storePointer:ofObject:withValue: */ + t7 = longAt(localSP); + if (t1 < youngStart) { + possibleRootStoreIntovalue(t1, t7); + } + longAtput(((((char *) t1)) + 4) + (1 << 2), t7); + goto l63; + } + l63: /* end extendedStoreBytecode */; + /* begin internalPop: */ + localSP -= 1 * 4; + break; + case 131: + /* singleExtendedSendBytecode */ + t1 = byteAt(++localIP); + messageSelector = longAt(((((char *) method)) + 4) + (((t1 & 31) + 1) << 2)); + argumentCount = ((unsigned) t1) >> 5; + /* begin normalSend */ + commonSend: /* */; + t2 = longAt(localSP - (argumentCount * 4)); + /* begin fetchClassOf: */ + if ((t2 & 1)) { + lkupClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); + goto l64; + } + t3 = (((unsigned) (longAt(t2))) >> 12) & 31; + if (t3 == 0) { + lkupClass = (longAt(t2 - 4)) & 4294967292U; + goto l64; + } else { + lkupClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((t3 - 1) << 2)); + goto l64; + } + l64: /* end fetchClassOf: */; + receiverClass = lkupClass; + commonLookup: /* */; + /* begin lookupInMethodCacheSel:class: */ + t5 = messageSelector ^ lkupClass; + t6 = t5 & 4088; + if (((methodCache[t6 + 1]) == messageSelector) && ((methodCache[t6 + 2]) == lkupClass)) { + newMethod = methodCache[t6 + 3]; + primitiveIndex = methodCache[t6 + 4]; + newNativeMethod = methodCache[t6 + 5]; + t4 = 1; + goto l65; + } + t6 = (((unsigned) t5) >> 1) & 4088; + if (((methodCache[t6 + 1]) == messageSelector) && ((methodCache[t6 + 2]) == lkupClass)) { + newMethod = methodCache[t6 + 3]; + primitiveIndex = methodCache[t6 + 4]; + newNativeMethod = methodCache[t6 + 5]; + t4 = 1; + goto l65; + } + t6 = (((unsigned) t5) >> 2) & 4088; + if (((methodCache[t6 + 1]) == messageSelector) && ((methodCache[t6 + 2]) == lkupClass)) { + newMethod = methodCache[t6 + 3]; + primitiveIndex = methodCache[t6 + 4]; + newNativeMethod = methodCache[t6 + 5]; + t4 = 1; + goto l65; + } + t4 = 0; + l65: /* end lookupInMethodCacheSel:class: */; + if (!(t4)) { + /* begin externalizeIPandSP */ + instructionPointer = ((int) localIP); + stackPointer = ((int) localSP); + theHomeContext = localHomeContext; + lookupMethodInClass(lkupClass); + /* begin internalizeIPandSP */ + localIP = ((char *) instructionPointer); + localSP = ((char *) stackPointer); + localHomeContext = theHomeContext; + addNewMethodToCache(); + } + /* begin internalExecuteNewMethod */ + t7 = primitiveIndex; + if (t7 > 0) { + if ((t7 > 255) && (t7 < 520)) { + if (t7 >= 264) { + /* begin internalPop:thenPush: */ + t8 = longAt(((((char *) (longAt(localSP)))) + 4) + ((t7 - 264) << 2)); + longAtput(localSP -= (1 - 1) * 4, t8); + goto l66; + } else { + if (t7 == 256) { + goto l66; + } + if (t7 == 257) { + /* begin internalPop:thenPush: */ + longAtput(localSP -= (1 - 1) * 4, trueObj); + goto l66; + } + if (t7 == 258) { + /* begin internalPop:thenPush: */ + longAtput(localSP -= (1 - 1) * 4, falseObj); + goto l66; + } + if (t7 == 259) { + /* begin internalPop:thenPush: */ + longAtput(localSP -= (1 - 1) * 4, nilObj); + goto l66; + } + /* begin internalPop:thenPush: */ + longAtput(localSP -= (1 - 1) * 4, (((t7 - 261) << 1) | 1)); + goto l66; + } + } else { + /* begin externalizeIPandSP */ + instructionPointer = ((int) localIP); + stackPointer = ((int) localSP); + theHomeContext = localHomeContext; + primitiveResponse(); + /* begin internalizeIPandSP */ + localIP = ((char *) instructionPointer); + localSP = ((char *) stackPointer); + localHomeContext = theHomeContext; + if (successFlag) { + ; + goto l66; + } + } + } + /* begin internalActivateNewMethod */ + t13 = longAt(((((char *) newMethod)) + 4) + (0 << 2)); + t10 = t13 & 262144; + if ((t10 == 0) && (freeContexts != 1)) { + t12 = freeContexts; + freeContexts = longAt(((((char *) t12)) + 4) + (0 << 2)); + } else { + /* begin externalizeIPandSP */ + instructionPointer = ((int) localIP); + stackPointer = ((int) localSP); + theHomeContext = localHomeContext; + t12 = allocateOrRecycleContext(t10); + /* begin internalizeIPandSP */ + localIP = ((char *) instructionPointer); + localSP = ((char *) stackPointer); + localHomeContext = theHomeContext; + } + t14 = (((unsigned) t13) >> 19) & 63; + longAtput(((((char *) t12)) + 4) + (0 << 2), activeContext); + longAtput(((((char *) t12)) + 4) + (1 << 2), (((((1 + ((((unsigned) t13) >> 10) & 255)) * 4) + 1) << 1) | 1)); + longAtput(((((char *) t12)) + 4) + (2 << 2), ((t14 << 1) | 1)); + longAtput(((((char *) t12)) + 4) + (3 << 2), newMethod); + t11 = argumentCount; + for (t9 = 0; t9 <= t11; t9 += 1) { + longAtput(((((char *) t12)) + 4) + ((5 + t9) << 2), longAt(localSP - ((t11 - t9) * 4))); + } + t13 = nilObj; + for (t9 = (t11 + 1); t9 <= t14; t9 += 1) { + longAtput(((((char *) t12)) + 4) + ((5 + t9) << 2), t13); + } + /* begin internalPop: */ + localSP -= (t11 + 1) * 4; + reclaimableContextCount += 1; + /* begin internalNewActiveContext: */ + /* begin internalStoreContextRegisters: */ + longAtput(((((char *) activeContext)) + 4) + (1 << 2), (((((((int) localIP )) + 2) - (method + 4)) << 1) | 1)); + longAtput(((((char *) activeContext)) + 4) + (2 << 2), (((((((unsigned) ((((int) localSP )) - (activeContext + 4))) >> 2) - 6) + 1) << 1) | 1)); + if (t12 < youngStart) { + beRootIfOld(t12); + } + activeContext = t12; + /* begin internalFetchContextRegisters: */ + t15 = longAt(((((char *) t12)) + 4) + (3 << 2)); + if ((t15 & 1)) { + t15 = longAt(((((char *) t12)) + 4) + (5 << 2)); + if (t15 < youngStart) { + beRootIfOld(t15); + } + } else { + t15 = t12; + } + localHomeContext = t15; + receiver = longAt(((((char *) t15)) + 4) + (5 << 2)); + method = longAt(((((char *) t15)) + 4) + (3 << 2)); + t15 = ((longAt(((((char *) t12)) + 4) + (1 << 2))) >> 1); + localIP = ((char *) (((method + t15) + 4) - 2)); + t15 = ((longAt(((((char *) t12)) + 4) + (2 << 2))) >> 1); + localSP = ((char *) ((t12 + 4) + (((6 + t15) - 1) * 4))); + /* begin internalQuickCheckForInterrupts */ + if ((interruptCheckCounter -= 1) <= 0) { + /* begin externalizeIPandSP */ + instructionPointer = ((int) localIP); + stackPointer = ((int) localSP); + theHomeContext = localHomeContext; + checkForInterrupts(); + ; + /* begin internalizeIPandSP */ + localIP = ((char *) instructionPointer); + localSP = ((char *) stackPointer); + localHomeContext = theHomeContext; + } + l66: /* end internalExecuteNewMethod */; + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + break; + case 132: + /* doubleExtendedDoAnythingBytecode */ + t4 = byteAt(++localIP); + t1 = byteAt(++localIP); + t2 = ((unsigned) t4) >> 5; + if (t2 == 0) { + messageSelector = longAt(((((char *) method)) + 4) + ((t1 + 1) << 2)); + argumentCount = t4 & 31; + /* begin normalSend */ + goto commonSend; + l71: /* end fetchClassOf: */; + l72: /* end lookupInMethodCacheSel:class: */; + l73: /* end internalExecuteNewMethod */; + } + if (t2 == 1) { + messageSelector = longAt(((((char *) method)) + 4) + ((t1 + 1) << 2)); + argumentCount = t4 & 31; + /* begin superclassSend */ + goto commonSupersend; + l68: /* end fetchClassOf: */; + l69: /* end lookupInMethodCacheSel:class: */; + l70: /* end internalExecuteNewMethod */; + } + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + if (t2 == 2) { + /* begin pushReceiverVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + (t1 << 2))); + goto l67; + } + if (t2 == 3) { + /* begin pushLiteralConstant: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) method)) + 4) + ((t1 + 1) << 2))); + goto l67; + } + if (t2 == 4) { + /* begin pushLiteralVariable: */ + /* begin internalPush: */ + longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + ((t1 + 1) << 2))))) + 4) + (1 << 2))); + goto l67; + } + if (t2 == 5) { + t3 = longAt(localSP); + /* begin storePointer:ofObject:withValue: */ + t5 = receiver; + if (t5 < youngStart) { + possibleRootStoreIntovalue(t5, t3); + } + longAtput(((((char *) t5)) + 4) + (t1 << 2), t3); + goto l67; + } + if (t2 == 6) { + t3 = longAt(localSP); + /* begin internalPop: */ + localSP -= 1 * 4; + /* begin storePointer:ofObject:withValue: */ + t6 = receiver; + if (t6 < youngStart) { + possibleRootStoreIntovalue(t6, t3); + } + longAtput(((((char *) t6)) + 4) + (t1 << 2), t3); + goto l67; + } + if (t2 == 7) { + t3 = longAt(localSP); + /* begin storePointer:ofObject:withValue: */ + t7 = longAt(((((char *) method)) + 4) + ((t1 + 1) << 2)); + if (t7 < youngStart) { + possibleRootStoreIntovalue(t7, t3); + } + longAtput(((((char *) t7)) + 4) + (1 << 2), t3); + goto l67; + } + l67: /* end case */; + break; + case 133: + /* singleExtendedSuperBytecode */ + t1 = byteAt(++localIP); + messageSelector = longAt(((((char *) method)) + 4) + (((t1 & 31) + 1) << 2)); + argumentCount = ((unsigned) t1) >> 5; + /* begin superclassSend */ + commonSupersend: /* */; + /* begin superclassOf: */ + t3 = longAt(((((char *) (longAt(((((char *) method)) + 4) + (((((((unsigned) (longAt(((((char *) method)) + 4) + (0 << 2)))) >> 10) & 255) - 1) + 1) << 2))))) + 4) + (1 << 2)); + lkupClass = longAt(((((char *) t3)) + 4) + (0 << 2)); + t2 = longAt(localSP - (argumentCount * 4)); + /* begin fetchClassOf: */ + if ((t2 & 1)) { + receiverClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); + goto l74; + } + t4 = (((unsigned) (longAt(t2))) >> 12) & 31; + if (t4 == 0) { + receiverClass = (longAt(t2 - 4)) & 4294967292U; + goto l74; + } else { + receiverClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((t4 - 1) << 2)); + goto l74; + } + l74: /* end fetchClassOf: */; + goto commonLookup; + l75: /* end lookupInMethodCacheSel:class: */; + l76: /* end internalExecuteNewMethod */; + break; + case 134: + /* secondExtendedSendBytecode */ + t1 = byteAt(++localIP); + messageSelector = longAt(((((char *) method)) + 4) + (((t1 & 63) + 1) << 2)); + argumentCount = ((unsigned) t1) >> 6; + /* begin normalSend */ + goto commonSend; + l77: /* end fetchClassOf: */; + l78: /* end lookupInMethodCacheSel:class: */; + l79: /* end internalExecuteNewMethod */; + break; + case 135: + /* popStackBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin internalPop: */ + localSP -= 1 * 4; + break; + case 136: + /* duplicateTopBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin internalPush: */ + t1 = longAt(localSP); + longAtput(localSP += 4, t1); + break; + case 137: + /* pushActiveContextBytecode */ + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + reclaimableContextCount = 0; + /* begin internalPush: */ + longAtput(localSP += 4, activeContext); + break; + case 138: + case 139: + case 140: + case 141: + case 142: + case 143: + /* experimentalBytecode */ + t8 = longAt(((((char *) localHomeContext)) + 4) + (((currentBytecode - 138) + 6) << 2)); + t6 = byteAt(localIP + 1); + t1 = byteAt(localIP + 2); + t7 = byteAt(localIP + 3); + if ((t8 & 1)) { + t2 = (t8 >> 1); + } else { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin internalPush: */ + longAtput(localSP += 4, t8); + goto l80; + } + if (t6 < 32) { + t4 = longAt(((((char *) localHomeContext)) + 4) + (((t6 & 15) + 6) << 2)); + if ((t4 & 1)) { + t4 = (t4 >> 1); + } else { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin internalPush: */ + longAtput(localSP += 4, t8); + goto l80; + } + } else { + if (t6 > 64) { + t4 = 1; + } else { + t4 = longAt(((((char *) method)) + 4) + (((t6 & 31) + 1) << 2)); + if ((t4 & 1)) { + t4 = (t4 >> 1); + } else { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin internalPush: */ + longAtput(localSP += 4, t8); + goto l80; + } + } + } + if (t1 < 178) { + t3 = t2 + t4; + if ((t3 ^ (t3 << 1)) >= 0) { + if ((t7 > 103) && (t7 < 112)) { + localIP += 3; + longAtput(((((char *) localHomeContext)) + 4) + (((t7 & 7) + 6) << 2), ((t3 << 1) | 1)); + } else { + localIP += 2; + /* begin internalPush: */ + longAtput(localSP += 4, ((t3 << 1) | 1)); + } + } else { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin internalPush: */ + longAtput(localSP += 4, t8); + goto l80; + } + } else { + t5 = byteAt(localIP + 4); + if (t2 <= t4) { + localIP = (localIP + 3) + 1; + } else { + localIP = ((localIP + 3) + 1) + t5; + } + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + } + l80: /* end case */; + break; + case 144: + /* shortUnconditionalJump */ + /* begin jump: */ + t1 = (144 & 7) + 1; + localIP = (localIP + t1) + 1; + currentBytecode = byteAt(localIP); + break; + case 145: + /* shortUnconditionalJump */ + /* begin jump: */ + t1 = (145 & 7) + 1; + localIP = (localIP + t1) + 1; + currentBytecode = byteAt(localIP); + break; + case 146: + /* shortUnconditionalJump */ + /* begin jump: */ + t1 = (146 & 7) + 1; + localIP = (localIP + t1) + 1; + currentBytecode = byteAt(localIP); + break; + case 147: + /* shortUnconditionalJump */ + /* begin jump: */ + t1 = (147 & 7) + 1; + localIP = (localIP + t1) + 1; + currentBytecode = byteAt(localIP); + break; + case 148: + /* shortUnconditionalJump */ + /* begin jump: */ + t1 = (148 & 7) + 1; + localIP = (localIP + t1) + 1; + currentBytecode = byteAt(localIP); + break; + case 149: + /* shortUnconditionalJump */ + /* begin jump: */ + t1 = (149 & 7) + 1; + localIP = (localIP + t1) + 1; + currentBytecode = byteAt(localIP); + break; + case 150: + /* shortUnconditionalJump */ + /* begin jump: */ + t1 = (150 & 7) + 1; + localIP = (localIP + t1) + 1; + currentBytecode = byteAt(localIP); + break; + case 151: + /* shortUnconditionalJump */ + /* begin jump: */ + t1 = (151 & 7) + 1; + localIP = (localIP + t1) + 1; + currentBytecode = byteAt(localIP); + break; + case 152: + case 153: + case 154: + case 155: + case 156: + case 157: + case 158: + case 159: + /* shortConditionalJump */ + /* begin jumplfFalseBy: */ + t1 = (currentBytecode & 7) + 1; + t2 = longAt(localSP); + if (t2 == falseObj) { + /* begin jump: */ + localIP = (localIP + t1) + 1; + currentBytecode = byteAt(localIP); + } else { + if (!(t2 == trueObj)) { + messageSelector = longAt(((((char *) specialObjectsOop)) + 4) + (25 << 2)); + argumentCount = 0; + /* begin normalSend */ + goto commonSend; + l82: /* end fetchClassOf: */; + l83: /* end lookupInMethodCacheSel:class: */; + l84: /* end internalExecuteNewMethod */; + } + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + } + /* begin internalPop: */ + localSP -= 1 * 4; + l81: /* end jumplfFalseBy: */; + break; + case 160: + case 161: + case 162: + case 163: + case 164: + case 165: + case 166: + case 167: + /* longUnconditionalJump */ + t1 = (((currentBytecode & 7) - 4) * 256) + (byteAt(++localIP)); + localIP += t1; + if (t1 < 0) { + /* begin internalQuickCheckForInterrupts */ + if ((interruptCheckCounter -= 1) <= 0) { + /* begin externalizeIPandSP */ + instructionPointer = ((int) localIP); + stackPointer = ((int) localSP); + theHomeContext = localHomeContext; + checkForInterrupts(); + ; + /* begin internalizeIPandSP */ + localIP = ((char *) instructionPointer); + localSP = ((char *) stackPointer); + localHomeContext = theHomeContext; + } + } + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + break; + case 168: + case 169: + case 170: + case 171: + /* longJumpIfTrue */ + /* begin jumplfTrueBy: */ + t1 = ((currentBytecode & 3) * 256) + (byteAt(++localIP)); + t2 = longAt(localSP); + if (t2 == trueObj) { + /* begin jump: */ + localIP = (localIP + t1) + 1; + currentBytecode = byteAt(localIP); + } else { + if (!(t2 == falseObj)) { + messageSelector = longAt(((((char *) specialObjectsOop)) + 4) + (25 << 2)); + argumentCount = 0; + /* begin normalSend */ + goto commonSend; + l86: /* end fetchClassOf: */; + l87: /* end lookupInMethodCacheSel:class: */; + l88: /* end internalExecuteNewMethod */; + } + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + } + /* begin internalPop: */ + localSP -= 1 * 4; + l85: /* end jumplfTrueBy: */; + break; + case 172: + case 173: + case 174: + case 175: + /* longJumpIfFalse */ + /* begin jumplfFalseBy: */ + t1 = ((currentBytecode & 3) * 256) + (byteAt(++localIP)); + t2 = longAt(localSP); + if (t2 == falseObj) { + /* begin jump: */ + localIP = (localIP + t1) + 1; + currentBytecode = byteAt(localIP); + } else { + if (!(t2 == trueObj)) { + messageSelector = longAt(((((char *) specialObjectsOop)) + 4) + (25 << 2)); + argumentCount = 0; + /* begin normalSend */ + goto commonSend; + l90: /* end fetchClassOf: */; + l91: /* end lookupInMethodCacheSel:class: */; + l92: /* end internalExecuteNewMethod */; + } + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + } + /* begin internalPop: */ + localSP -= 1 * 4; + l89: /* end jumplfFalseBy: */; + break; + case 176: + /* bytecodePrimAdd */ + t2 = longAt(localSP - (1 * 4)); + t3 = longAt(localSP - (0 * 4)); + if (((t2 & t3) & 1) != 0) { + t1 = ((t2 >> 1)) + ((t3 >> 1)); + if ((t1 ^ (t1 << 1)) >= 0) { + /* begin internalPop:thenPush: */ + longAtput(localSP -= (2 - 1) * 4, ((t1 << 1) | 1)); + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l93; + } + } else { + successFlag = 1; + /* begin externalizeIPandSP */ + instructionPointer = ((int) localIP); + stackPointer = ((int) localSP); + theHomeContext = localHomeContext; + primitiveFloatAddtoArg(t2, t3); + /* begin internalizeIPandSP */ + localIP = ((char *) instructionPointer); + localSP = ((char *) stackPointer); + localHomeContext = theHomeContext; + if (successFlag) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l93; + } + } + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((0 * 2) << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l94: /* end fetchClassOf: */; + l95: /* end lookupInMethodCacheSel:class: */; + l96: /* end internalExecuteNewMethod */; + l93: /* end case */; + break; + case 177: + /* bytecodePrimSubtract */ + t2 = longAt(localSP - (1 * 4)); + t3 = longAt(localSP - (0 * 4)); + if (((t2 & t3) & 1) != 0) { + t1 = ((t2 >> 1)) - ((t3 >> 1)); + if ((t1 ^ (t1 << 1)) >= 0) { + /* begin internalPop:thenPush: */ + longAtput(localSP -= (2 - 1) * 4, ((t1 << 1) | 1)); + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l97; + } + } else { + successFlag = 1; + /* begin externalizeIPandSP */ + instructionPointer = ((int) localIP); + stackPointer = ((int) localSP); + theHomeContext = localHomeContext; + primitiveFloatSubtractfromArg(t2, t3); + /* begin internalizeIPandSP */ + localIP = ((char *) instructionPointer); + localSP = ((char *) stackPointer); + localHomeContext = theHomeContext; + if (successFlag) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l97; + } + } + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((1 * 2) << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l98: /* end fetchClassOf: */; + l99: /* end lookupInMethodCacheSel:class: */; + l100: /* end internalExecuteNewMethod */; + l97: /* end case */; + break; + case 178: + /* bytecodePrimLessThan */ + t1 = longAt(localSP - (1 * 4)); + t3 = longAt(localSP - (0 * 4)); + if (((t1 & t3) & 1) != 0) { + ; + /* begin booleanCheat: */ + t6 = byteAt(++localIP); + /* begin internalPop: */ + localSP -= 2 * 4; + if ((t6 < 160) && (t6 > 151)) { + if (t1 < t3) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l101; + } else { + /* begin jump: */ + localIP = (localIP + (t6 - 151)) + 1; + currentBytecode = byteAt(localIP); + goto l101; + } + } + if (t6 == 172) { + t7 = byteAt(++localIP); + if (t1 < t3) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l101; + } else { + /* begin jump: */ + localIP = (localIP + t7) + 1; + currentBytecode = byteAt(localIP); + goto l101; + } + } + localIP -= 1; + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + if (t1 < t3) { + /* begin internalPush: */ + longAtput(localSP += 4, trueObj); + } else { + /* begin internalPush: */ + longAtput(localSP += 4, falseObj); + } + goto l101; + } + successFlag = 1; + t2 = primitiveFloatLessthanArg(t1, t3); + if (successFlag) { + /* begin booleanCheat: */ + t8 = byteAt(++localIP); + /* begin internalPop: */ + localSP -= 2 * 4; + if ((t8 < 160) && (t8 > 151)) { + if (t2) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l101; + } else { + /* begin jump: */ + localIP = (localIP + (t8 - 151)) + 1; + currentBytecode = byteAt(localIP); + goto l101; + } + } + if (t8 == 172) { + t9 = byteAt(++localIP); + if (t2) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l101; + } else { + /* begin jump: */ + localIP = (localIP + t9) + 1; + currentBytecode = byteAt(localIP); + goto l101; + } + } + localIP -= 1; + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + if (t2) { + /* begin internalPush: */ + longAtput(localSP += 4, trueObj); + } else { + /* begin internalPush: */ + longAtput(localSP += 4, falseObj); + } + goto l101; + } + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((2 * 2) << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l102: /* end fetchClassOf: */; + l103: /* end lookupInMethodCacheSel:class: */; + l104: /* end internalExecuteNewMethod */; + l101: /* end case */; + break; + case 179: + /* bytecodePrimGreaterThan */ + t1 = longAt(localSP - (1 * 4)); + t3 = longAt(localSP - (0 * 4)); + if (((t1 & t3) & 1) != 0) { + ; + /* begin booleanCheat: */ + t6 = byteAt(++localIP); + /* begin internalPop: */ + localSP -= 2 * 4; + if ((t6 < 160) && (t6 > 151)) { + if (t1 > t3) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l105; + } else { + /* begin jump: */ + localIP = (localIP + (t6 - 151)) + 1; + currentBytecode = byteAt(localIP); + goto l105; + } + } + if (t6 == 172) { + t7 = byteAt(++localIP); + if (t1 > t3) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l105; + } else { + /* begin jump: */ + localIP = (localIP + t7) + 1; + currentBytecode = byteAt(localIP); + goto l105; + } + } + localIP -= 1; + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + if (t1 > t3) { + /* begin internalPush: */ + longAtput(localSP += 4, trueObj); + } else { + /* begin internalPush: */ + longAtput(localSP += 4, falseObj); + } + goto l105; + } + successFlag = 1; + t2 = primitiveFloatGreaterthanArg(t1, t3); + if (successFlag) { + /* begin booleanCheat: */ + t8 = byteAt(++localIP); + /* begin internalPop: */ + localSP -= 2 * 4; + if ((t8 < 160) && (t8 > 151)) { + if (t2) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l105; + } else { + /* begin jump: */ + localIP = (localIP + (t8 - 151)) + 1; + currentBytecode = byteAt(localIP); + goto l105; + } + } + if (t8 == 172) { + t9 = byteAt(++localIP); + if (t2) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l105; + } else { + /* begin jump: */ + localIP = (localIP + t9) + 1; + currentBytecode = byteAt(localIP); + goto l105; + } + } + localIP -= 1; + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + if (t2) { + /* begin internalPush: */ + longAtput(localSP += 4, trueObj); + } else { + /* begin internalPush: */ + longAtput(localSP += 4, falseObj); + } + goto l105; + } + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((3 * 2) << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l106: /* end fetchClassOf: */; + l107: /* end lookupInMethodCacheSel:class: */; + l108: /* end internalExecuteNewMethod */; + l105: /* end case */; + break; + case 180: + /* bytecodePrimLessOrEqual */ + t1 = longAt(localSP - (1 * 4)); + t3 = longAt(localSP - (0 * 4)); + if (((t1 & t3) & 1) != 0) { + ; + /* begin booleanCheat: */ + t6 = byteAt(++localIP); + /* begin internalPop: */ + localSP -= 2 * 4; + if ((t6 < 160) && (t6 > 151)) { + if (t1 <= t3) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l109; + } else { + /* begin jump: */ + localIP = (localIP + (t6 - 151)) + 1; + currentBytecode = byteAt(localIP); + goto l109; + } + } + if (t6 == 172) { + t7 = byteAt(++localIP); + if (t1 <= t3) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l109; + } else { + /* begin jump: */ + localIP = (localIP + t7) + 1; + currentBytecode = byteAt(localIP); + goto l109; + } + } + localIP -= 1; + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + if (t1 <= t3) { + /* begin internalPush: */ + longAtput(localSP += 4, trueObj); + } else { + /* begin internalPush: */ + longAtput(localSP += 4, falseObj); + } + goto l109; + } + successFlag = 1; + t2 = primitiveFloatGreaterthanArg(t1, t3); + if (successFlag) { + /* begin booleanCheat: */ + t8 = byteAt(++localIP); + /* begin internalPop: */ + localSP -= 2 * 4; + if ((t8 < 160) && (t8 > 151)) { + if (!t2) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l109; + } else { + /* begin jump: */ + localIP = (localIP + (t8 - 151)) + 1; + currentBytecode = byteAt(localIP); + goto l109; + } + } + if (t8 == 172) { + t9 = byteAt(++localIP); + if (!t2) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l109; + } else { + /* begin jump: */ + localIP = (localIP + t9) + 1; + currentBytecode = byteAt(localIP); + goto l109; + } + } + localIP -= 1; + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + if (!t2) { + /* begin internalPush: */ + longAtput(localSP += 4, trueObj); + } else { + /* begin internalPush: */ + longAtput(localSP += 4, falseObj); + } + goto l109; + } + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((4 * 2) << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l110: /* end fetchClassOf: */; + l111: /* end lookupInMethodCacheSel:class: */; + l112: /* end internalExecuteNewMethod */; + l109: /* end case */; + break; + case 181: + /* bytecodePrimGreaterOrEqual */ + t1 = longAt(localSP - (1 * 4)); + t3 = longAt(localSP - (0 * 4)); + if (((t1 & t3) & 1) != 0) { + ; + /* begin booleanCheat: */ + t6 = byteAt(++localIP); + /* begin internalPop: */ + localSP -= 2 * 4; + if ((t6 < 160) && (t6 > 151)) { + if (t1 >= t3) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l113; + } else { + /* begin jump: */ + localIP = (localIP + (t6 - 151)) + 1; + currentBytecode = byteAt(localIP); + goto l113; + } + } + if (t6 == 172) { + t7 = byteAt(++localIP); + if (t1 >= t3) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l113; + } else { + /* begin jump: */ + localIP = (localIP + t7) + 1; + currentBytecode = byteAt(localIP); + goto l113; + } + } + localIP -= 1; + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + if (t1 >= t3) { + /* begin internalPush: */ + longAtput(localSP += 4, trueObj); + } else { + /* begin internalPush: */ + longAtput(localSP += 4, falseObj); + } + goto l113; + } + successFlag = 1; + t2 = primitiveFloatLessthanArg(t1, t3); + if (successFlag) { + /* begin booleanCheat: */ + t8 = byteAt(++localIP); + /* begin internalPop: */ + localSP -= 2 * 4; + if ((t8 < 160) && (t8 > 151)) { + if (!t2) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l113; + } else { + /* begin jump: */ + localIP = (localIP + (t8 - 151)) + 1; + currentBytecode = byteAt(localIP); + goto l113; + } + } + if (t8 == 172) { + t9 = byteAt(++localIP); + if (!t2) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l113; + } else { + /* begin jump: */ + localIP = (localIP + t9) + 1; + currentBytecode = byteAt(localIP); + goto l113; + } + } + localIP -= 1; + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + if (!t2) { + /* begin internalPush: */ + longAtput(localSP += 4, trueObj); + } else { + /* begin internalPush: */ + longAtput(localSP += 4, falseObj); + } + goto l113; + } + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((5 * 2) << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l114: /* end fetchClassOf: */; + l115: /* end lookupInMethodCacheSel:class: */; + l116: /* end internalExecuteNewMethod */; + l113: /* end case */; + break; + case 182: + /* bytecodePrimEqual */ + t1 = longAt(localSP - (1 * 4)); + t3 = longAt(localSP - (0 * 4)); + if (((t1 & t3) & 1) != 0) { + /* begin booleanCheat: */ + t4 = byteAt(++localIP); + /* begin internalPop: */ + localSP -= 2 * 4; + if ((t4 < 160) && (t4 > 151)) { + if (t1 == t3) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l117; + } else { + /* begin jump: */ + localIP = (localIP + (t4 - 151)) + 1; + currentBytecode = byteAt(localIP); + goto l117; + } + } + if (t4 == 172) { + t5 = byteAt(++localIP); + if (t1 == t3) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l117; + } else { + /* begin jump: */ + localIP = (localIP + t5) + 1; + currentBytecode = byteAt(localIP); + goto l117; + } + } + localIP -= 1; + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + if (t1 == t3) { + /* begin internalPush: */ + longAtput(localSP += 4, trueObj); + } else { + /* begin internalPush: */ + longAtput(localSP += 4, falseObj); + } + goto l117; + } + successFlag = 1; + t2 = primitiveFloatEqualtoArg(t1, t3); + if (successFlag) { + /* begin booleanCheat: */ + t6 = byteAt(++localIP); + /* begin internalPop: */ + localSP -= 2 * 4; + if ((t6 < 160) && (t6 > 151)) { + if (t2) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l117; + } else { + /* begin jump: */ + localIP = (localIP + (t6 - 151)) + 1; + currentBytecode = byteAt(localIP); + goto l117; + } + } + if (t6 == 172) { + t7 = byteAt(++localIP); + if (t2) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l117; + } else { + /* begin jump: */ + localIP = (localIP + t7) + 1; + currentBytecode = byteAt(localIP); + goto l117; + } + } + localIP -= 1; + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + if (t2) { + /* begin internalPush: */ + longAtput(localSP += 4, trueObj); + } else { + /* begin internalPush: */ + longAtput(localSP += 4, falseObj); + } + goto l117; + } + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((6 * 2) << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l118: /* end fetchClassOf: */; + l119: /* end lookupInMethodCacheSel:class: */; + l120: /* end internalExecuteNewMethod */; + l117: /* end case */; + break; + case 183: + /* bytecodePrimNotEqual */ + t1 = longAt(localSP - (1 * 4)); + t3 = longAt(localSP - (0 * 4)); + if (((t1 & t3) & 1) != 0) { + /* begin booleanCheat: */ + t4 = byteAt(++localIP); + /* begin internalPop: */ + localSP -= 2 * 4; + if ((t4 < 160) && (t4 > 151)) { + if (t1 != t3) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l121; + } else { + /* begin jump: */ + localIP = (localIP + (t4 - 151)) + 1; + currentBytecode = byteAt(localIP); + goto l121; + } + } + if (t4 == 172) { + t5 = byteAt(++localIP); + if (t1 != t3) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l121; + } else { + /* begin jump: */ + localIP = (localIP + t5) + 1; + currentBytecode = byteAt(localIP); + goto l121; + } + } + localIP -= 1; + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + if (t1 != t3) { + /* begin internalPush: */ + longAtput(localSP += 4, trueObj); + } else { + /* begin internalPush: */ + longAtput(localSP += 4, falseObj); + } + goto l121; + } + successFlag = 1; + t2 = primitiveFloatEqualtoArg(t1, t3); + if (successFlag) { + /* begin booleanCheat: */ + t6 = byteAt(++localIP); + /* begin internalPop: */ + localSP -= 2 * 4; + if ((t6 < 160) && (t6 > 151)) { + if (!t2) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l121; + } else { + /* begin jump: */ + localIP = (localIP + (t6 - 151)) + 1; + currentBytecode = byteAt(localIP); + goto l121; + } + } + if (t6 == 172) { + t7 = byteAt(++localIP); + if (!t2) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l121; + } else { + /* begin jump: */ + localIP = (localIP + t7) + 1; + currentBytecode = byteAt(localIP); + goto l121; + } + } + localIP -= 1; + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + if (!t2) { + /* begin internalPush: */ + longAtput(localSP += 4, trueObj); + } else { + /* begin internalPush: */ + longAtput(localSP += 4, falseObj); + } + goto l121; + } + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((7 * 2) << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l122: /* end fetchClassOf: */; + l123: /* end lookupInMethodCacheSel:class: */; + l124: /* end internalExecuteNewMethod */; + l121: /* end case */; + break; + case 184: + /* bytecodePrimMultiply */ + t2 = longAt(localSP - (1 * 4)); + t3 = longAt(localSP - (0 * 4)); + if (((t2 & t3) & 1) != 0) { + t2 = (t2 >> 1); + t3 = (t3 >> 1); + t1 = t2 * t3; + if (((t3 == 0) || ((t1 / t3) == t2)) && ((t1 ^ (t1 << 1)) >= 0)) { + /* begin internalPop:thenPush: */ + longAtput(localSP -= (2 - 1) * 4, ((t1 << 1) | 1)); + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l125; + } + } else { + successFlag = 1; + /* begin externalizeIPandSP */ + instructionPointer = ((int) localIP); + stackPointer = ((int) localSP); + theHomeContext = localHomeContext; + primitiveFloatMultiplybyArg(t2, t3); + /* begin internalizeIPandSP */ + localIP = ((char *) instructionPointer); + localSP = ((char *) stackPointer); + localHomeContext = theHomeContext; + if (successFlag) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l125; + } + } + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((8 * 2) << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l126: /* end fetchClassOf: */; + l127: /* end lookupInMethodCacheSel:class: */; + l128: /* end internalExecuteNewMethod */; + l125: /* end case */; + break; + case 185: + /* bytecodePrimDivide */ + t2 = longAt(localSP - (1 * 4)); + t3 = longAt(localSP - (0 * 4)); + if (((t2 & t3) & 1) != 0) { + t2 = (t2 >> 1); + t3 = (t3 >> 1); + if ((t3 != 0) && ((t2 % t3) == 0)) { + t1 = t2 / t3; + if ((t1 ^ (t1 << 1)) >= 0) { + /* begin internalPop:thenPush: */ + longAtput(localSP -= (2 - 1) * 4, ((t1 << 1) | 1)); + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l129; + } + } + } else { + successFlag = 1; + /* begin externalizeIPandSP */ + instructionPointer = ((int) localIP); + stackPointer = ((int) localSP); + theHomeContext = localHomeContext; + primitiveFloatDividebyArg(t2, t3); + /* begin internalizeIPandSP */ + localIP = ((char *) instructionPointer); + localSP = ((char *) stackPointer); + localHomeContext = theHomeContext; + if (successFlag) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l129; + } + } + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((9 * 2) << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l130: /* end fetchClassOf: */; + l131: /* end lookupInMethodCacheSel:class: */; + l132: /* end internalExecuteNewMethod */; + l129: /* end case */; + break; + case 186: + /* bytecodePrimMod */ + successFlag = 1; + t1 = doPrimitiveModby(longAt(localSP - (1 * 4)), longAt(localSP - (0 * 4))); + if (successFlag) { + /* begin internalPop:thenPush: */ + longAtput(localSP -= (2 - 1) * 4, ((t1 << 1) | 1)); + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l133; + } + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((10 * 2) << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l134: /* end fetchClassOf: */; + l135: /* end lookupInMethodCacheSel:class: */; + l136: /* end internalExecuteNewMethod */; + l133: /* end case */; + break; + case 187: + /* bytecodePrimMakePoint */ + successFlag = 1; + /* begin externalizeIPandSP */ + instructionPointer = ((int) localIP); + stackPointer = ((int) localSP); + theHomeContext = localHomeContext; + primitiveMakePoint(); + /* begin internalizeIPandSP */ + localIP = ((char *) instructionPointer); + localSP = ((char *) stackPointer); + localHomeContext = theHomeContext; + if (successFlag) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l137; + } + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((11 * 2) << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l138: /* end fetchClassOf: */; + l139: /* end lookupInMethodCacheSel:class: */; + l140: /* end internalExecuteNewMethod */; + l137: /* end case */; + break; + case 188: + /* bytecodePrimBitShift */ + successFlag = 1; + /* begin externalizeIPandSP */ + instructionPointer = ((int) localIP); + stackPointer = ((int) localSP); + theHomeContext = localHomeContext; + primitiveBitShift(); + /* begin internalizeIPandSP */ + localIP = ((char *) instructionPointer); + localSP = ((char *) stackPointer); + localHomeContext = theHomeContext; + if (successFlag) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l141; + } + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((12 * 2) << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l142: /* end fetchClassOf: */; + l143: /* end lookupInMethodCacheSel:class: */; + l144: /* end internalExecuteNewMethod */; + l141: /* end case */; + break; + case 189: + /* bytecodePrimDiv */ + successFlag = 1; + t1 = doPrimitiveDivby(longAt(localSP - (1 * 4)), longAt(localSP - (0 * 4))); + if (successFlag) { + /* begin internalPop:thenPush: */ + longAtput(localSP -= (2 - 1) * 4, ((t1 << 1) | 1)); + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l145; + } + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((13 * 2) << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l146: /* end fetchClassOf: */; + l147: /* end lookupInMethodCacheSel:class: */; + l148: /* end internalExecuteNewMethod */; + l145: /* end case */; + break; + case 190: + /* bytecodePrimBitAnd */ + successFlag = 1; + /* begin externalizeIPandSP */ + instructionPointer = ((int) localIP); + stackPointer = ((int) localSP); + theHomeContext = localHomeContext; + /* begin primitiveBitAnd */ + /* begin popPos32BitInteger */ + /* begin popStack */ + t6 = longAt(stackPointer); + stackPointer -= 4; + t5 = t6; + t1 = positive32BitValueOf(t5); + /* begin popPos32BitInteger */ + /* begin popStack */ + t8 = longAt(stackPointer); + stackPointer -= 4; + t7 = t8; + t2 = positive32BitValueOf(t7); + if (successFlag) { + /* begin push: */ + t3 = positive32BitIntegerFor(t2 & t1); + longAtput(t4 = stackPointer + 4, t3); + stackPointer = t4; + } else { + /* begin unPop: */ + stackPointer += 2 * 4; + } + /* begin internalizeIPandSP */ + localIP = ((char *) instructionPointer); + localSP = ((char *) stackPointer); + localHomeContext = theHomeContext; + if (successFlag) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l149; + } + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((14 * 2) << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l150: /* end fetchClassOf: */; + l151: /* end lookupInMethodCacheSel:class: */; + l152: /* end internalExecuteNewMethod */; + l149: /* end case */; + break; + case 191: + /* bytecodePrimBitOr */ + successFlag = 1; + /* begin externalizeIPandSP */ + instructionPointer = ((int) localIP); + stackPointer = ((int) localSP); + theHomeContext = localHomeContext; + /* begin primitiveBitOr */ + /* begin popPos32BitInteger */ + /* begin popStack */ + t6 = longAt(stackPointer); + stackPointer -= 4; + t5 = t6; + t1 = positive32BitValueOf(t5); + /* begin popPos32BitInteger */ + /* begin popStack */ + t8 = longAt(stackPointer); + stackPointer -= 4; + t7 = t8; + t2 = positive32BitValueOf(t7); + if (successFlag) { + /* begin push: */ + t3 = positive32BitIntegerFor(t2 | t1); + longAtput(t4 = stackPointer + 4, t3); + stackPointer = t4; + } else { + /* begin unPop: */ + stackPointer += 2 * 4; + } + /* begin internalizeIPandSP */ + localIP = ((char *) instructionPointer); + localSP = ((char *) stackPointer); + localHomeContext = theHomeContext; + if (successFlag) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l153; + } + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((15 * 2) << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l154: /* end fetchClassOf: */; + l155: /* end lookupInMethodCacheSel:class: */; + l156: /* end internalExecuteNewMethod */; + l153: /* end case */; + break; + case 192: + /* bytecodePrimAt */ + t4 = longAt(localSP); + t3 = longAt(localSP - (1 * 4)); + successFlag = (!((t3 & 1))) && ((t4 & 1)); + if (successFlag) { + t2 = t3 & 28; + if ((atCache[t2 + 1]) == t3) { + /* begin commonVariableInternal:at:cacheIndex: */ + t8 = atCache[t2 + 2]; + if (((((unsigned ) ((t4 >> 1)))) >= 1) && ((((unsigned ) ((t4 >> 1)))) <= (((unsigned ) t8)))) { + t7 = atCache[t2 + 3]; + if (t7 <= 4) { + t5 = atCache[t2 + 4]; + t1 = longAt(((((char *) t3)) + 4) + (((((t4 >> 1)) + t5) - 1) << 2)); + goto l158; + } + if (t7 < 8) { + t6 = longAt(((((char *) t3)) + 4) + ((((t4 >> 1)) - 1) << 2)); + /* begin externalizeIPandSP */ + instructionPointer = ((int) localIP); + stackPointer = ((int) localSP); + theHomeContext = localHomeContext; + t6 = positive32BitIntegerFor(t6); + /* begin internalizeIPandSP */ + localIP = ((char *) instructionPointer); + localSP = ((char *) stackPointer); + localHomeContext = theHomeContext; + t1 = t6; + goto l158; + } + if (t7 >= 16) { + t1 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (24 << 2))))) + 4) + ((byteAt(((((char *) t3)) + 4) + (((t4 >> 1)) - 1))) << 2)); + goto l158; + } else { + t1 = (((byteAt(((((char *) t3)) + 4) + (((t4 >> 1)) - 1))) << 1) | 1); + goto l158; + } + } + /* begin primitiveFail */ + successFlag = 0; + l158: /* end commonVariableInternal:at:cacheIndex: */; + if (successFlag) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin internalPop:thenPush: */ + longAtput(localSP -= (2 - 1) * 4, t1); + goto l157; + } + } + } + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((16 * 2) << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l159: /* end fetchClassOf: */; + l160: /* end lookupInMethodCacheSel:class: */; + l161: /* end internalExecuteNewMethod */; + l157: /* end case */; + break; + case 193: + /* bytecodePrimAtPut */ + t2 = longAt(localSP); + t4 = longAt(localSP - (1 * 4)); + t3 = longAt(localSP - (2 * 4)); + successFlag = (!((t3 & 1))) && ((t4 & 1)); + if (successFlag) { + t1 = (t3 & 28) + 32; + if ((atCache[t1 + 1]) == t3) { + /* begin commonVariable:at:put:cacheIndex: */ + t8 = atCache[t1 + 2]; + if (((((unsigned ) ((t4 >> 1)))) >= 1) && ((((unsigned ) ((t4 >> 1)))) <= (((unsigned ) t8)))) { + t6 = atCache[t1 + 3]; + if (t6 <= 4) { + t5 = atCache[t1 + 4]; + /* begin storePointer:ofObject:withValue: */ + if (t3 < youngStart) { + possibleRootStoreIntovalue(t3, t2); + } + longAtput(((((char *) t3)) + 4) + (((((t4 >> 1)) + t5) - 1) << 2), t2); + goto l163; + } + if (t6 < 8) { + t7 = positive32BitValueOf(t2); + if (successFlag) { + longAtput(((((char *) t3)) + 4) + ((((t4 >> 1)) - 1) << 2), t7); + } + goto l163; + } + if (t6 >= 16) { + t7 = asciiOfCharacter(t2); + if (!(successFlag)) { + goto l163; + } + } else { + t7 = t2; + } + if ((t7 & 1)) { + t7 = (t7 >> 1); + if (!((t7 >= 0) && (t7 <= 255))) { + /* begin primitiveFail */ + successFlag = 0; + goto l163; + } + byteAtput(((((char *) t3)) + 4) + (((t4 >> 1)) - 1), t7); + goto l163; + } + } + /* begin primitiveFail */ + successFlag = 0; + l163: /* end commonVariable:at:put:cacheIndex: */; + if (successFlag) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + /* begin internalPop:thenPush: */ + longAtput(localSP -= (3 - 1) * 4, t2); + goto l162; + } + } + } + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((17 * 2) << 2)); + argumentCount = 2; + /* begin normalSend */ + goto commonSend; + l164: /* end fetchClassOf: */; + l165: /* end lookupInMethodCacheSel:class: */; + l166: /* end internalExecuteNewMethod */; + l162: /* end case */; + break; + case 194: + /* bytecodePrimSize */ + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((18 * 2) << 2)); + argumentCount = 0; + /* begin normalSend */ + goto commonSend; + l167: /* end fetchClassOf: */; + l168: /* end lookupInMethodCacheSel:class: */; + l169: /* end internalExecuteNewMethod */; + break; + case 195: + /* bytecodePrimNext */ + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((19 * 2) << 2)); + argumentCount = 0; + /* begin normalSend */ + goto commonSend; + l170: /* end fetchClassOf: */; + l171: /* end lookupInMethodCacheSel:class: */; + l172: /* end internalExecuteNewMethod */; + break; + case 196: + /* bytecodePrimNextPut */ + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((20 * 2) << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l173: /* end fetchClassOf: */; + l174: /* end lookupInMethodCacheSel:class: */; + l175: /* end internalExecuteNewMethod */; + break; + case 197: + /* bytecodePrimAtEnd */ + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((21 * 2) << 2)); + argumentCount = 0; + /* begin normalSend */ + goto commonSend; + l176: /* end fetchClassOf: */; + l177: /* end lookupInMethodCacheSel:class: */; + l178: /* end internalExecuteNewMethod */; + break; + case 198: + /* bytecodePrimEquivalent */ + t1 = longAt(localSP - (1 * 4)); + t2 = longAt(localSP - (0 * 4)); + /* begin booleanCheat: */ + t3 = byteAt(++localIP); + /* begin internalPop: */ + localSP -= 2 * 4; + if ((t3 < 160) && (t3 > 151)) { + if (t1 == t2) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l179; + } else { + /* begin jump: */ + localIP = (localIP + (t3 - 151)) + 1; + currentBytecode = byteAt(localIP); + goto l179; + } + } + if (t3 == 172) { + t4 = byteAt(++localIP); + if (t1 == t2) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l179; + } else { + /* begin jump: */ + localIP = (localIP + t4) + 1; + currentBytecode = byteAt(localIP); + goto l179; + } + } + localIP -= 1; + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + if (t1 == t2) { + /* begin internalPush: */ + longAtput(localSP += 4, trueObj); + } else { + /* begin internalPush: */ + longAtput(localSP += 4, falseObj); + } + l179: /* end booleanCheat: */; + break; + case 199: + /* bytecodePrimClass */ + t1 = longAt(localSP); + /* begin internalPop:thenPush: */ + /* begin fetchClassOf: */ + if ((t1 & 1)) { + t2 = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); + goto l180; + } + t3 = (((unsigned) (longAt(t1))) >> 12) & 31; + if (t3 == 0) { + t2 = (longAt(t1 - 4)) & 4294967292U; + goto l180; + } else { + t2 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((t3 - 1) << 2)); + goto l180; + } + l180: /* end fetchClassOf: */; + longAtput(localSP -= (1 - 1) * 4, t2); + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + break; + case 200: + /* bytecodePrimBlockCopy */ + t2 = longAt(localSP - (1 * 4)); + successFlag = 1; + t1 = longAt(t2); + /* begin success: */ + /* begin isContextHeader: */ + t4 = (((unsigned) t1) >> 12) & 31; + t3 = (t4 == 13) || ((t4 == 14) || (t4 == 4)); + successFlag = t3 && successFlag; + if (successFlag) { + /* begin externalizeIPandSP */ + instructionPointer = ((int) localIP); + stackPointer = ((int) localSP); + theHomeContext = localHomeContext; + primitiveBlockCopy(); + /* begin internalizeIPandSP */ + localIP = ((char *) instructionPointer); + localSP = ((char *) stackPointer); + localHomeContext = theHomeContext; + } + if (!(successFlag)) { + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((24 * 2) << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l182: /* end fetchClassOf: */; + l183: /* end lookupInMethodCacheSel:class: */; + l184: /* end internalExecuteNewMethod */; + } + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + l181: /* end case */; + break; + case 201: + /* bytecodePrimValue */ + t1 = longAt(localSP); + successFlag = 1; + argumentCount = 0; + /* begin assertClassOf:is: */ + if ((t1 & 1)) { + successFlag = 0; + goto l186; + } + t3 = (((unsigned) (longAt(t1))) >> 12) & 31; + if (t3 == 0) { + t2 = (longAt(t1 - 4)) & 4294967292U; + } else { + t2 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((t3 - 1) << 2)); + } + /* begin success: */ + successFlag = (t2 == (longAt(((((char *) specialObjectsOop)) + 4) + (11 << 2)))) && successFlag; + l186: /* end assertClassOf:is: */; + if (successFlag) { + /* begin externalizeIPandSP */ + instructionPointer = ((int) localIP); + stackPointer = ((int) localSP); + theHomeContext = localHomeContext; + primitiveValue(); + /* begin internalizeIPandSP */ + localIP = ((char *) instructionPointer); + localSP = ((char *) stackPointer); + localHomeContext = theHomeContext; + } + if (!(successFlag)) { + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((25 * 2) << 2)); + argumentCount = 0; + /* begin normalSend */ + goto commonSend; + l187: /* end fetchClassOf: */; + l188: /* end lookupInMethodCacheSel:class: */; + l189: /* end internalExecuteNewMethod */; + } + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + l185: /* end case */; + break; + case 202: + /* bytecodePrimValueWithArg */ + t1 = longAt(localSP - (1 * 4)); + successFlag = 1; + argumentCount = 1; + /* begin assertClassOf:is: */ + if ((t1 & 1)) { + successFlag = 0; + goto l191; + } + t3 = (((unsigned) (longAt(t1))) >> 12) & 31; + if (t3 == 0) { + t2 = (longAt(t1 - 4)) & 4294967292U; + } else { + t2 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((t3 - 1) << 2)); + } + /* begin success: */ + successFlag = (t2 == (longAt(((((char *) specialObjectsOop)) + 4) + (11 << 2)))) && successFlag; + l191: /* end assertClassOf:is: */; + if (successFlag) { + /* begin externalizeIPandSP */ + instructionPointer = ((int) localIP); + stackPointer = ((int) localSP); + theHomeContext = localHomeContext; + primitiveValue(); + /* begin internalizeIPandSP */ + localIP = ((char *) instructionPointer); + localSP = ((char *) stackPointer); + localHomeContext = theHomeContext; + } + if (!(successFlag)) { + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((26 * 2) << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l192: /* end fetchClassOf: */; + l193: /* end lookupInMethodCacheSel:class: */; + l194: /* end internalExecuteNewMethod */; + } + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + l190: /* end case */; + break; + case 203: + /* bytecodePrimDo */ + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((27 * 2) << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l195: /* end fetchClassOf: */; + l196: /* end lookupInMethodCacheSel:class: */; + l197: /* end internalExecuteNewMethod */; + break; + case 204: + /* bytecodePrimNew */ + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((28 * 2) << 2)); + argumentCount = 0; + /* begin normalSend */ + goto commonSend; + l198: /* end fetchClassOf: */; + l199: /* end lookupInMethodCacheSel:class: */; + l200: /* end internalExecuteNewMethod */; + break; + case 205: + /* bytecodePrimNewWithArg */ + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((29 * 2) << 2)); + argumentCount = 1; + /* begin normalSend */ + goto commonSend; + l201: /* end fetchClassOf: */; + l202: /* end lookupInMethodCacheSel:class: */; + l203: /* end internalExecuteNewMethod */; + break; + case 206: + /* bytecodePrimPointX */ + successFlag = 1; + /* begin externalizeIPandSP */ + instructionPointer = ((int) localIP); + stackPointer = ((int) localSP); + theHomeContext = localHomeContext; + primitivePointX(); + /* begin internalizeIPandSP */ + localIP = ((char *) instructionPointer); + localSP = ((char *) stackPointer); + localHomeContext = theHomeContext; + if (successFlag) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l204; + } + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((30 * 2) << 2)); + argumentCount = 0; + /* begin normalSend */ + goto commonSend; + l205: /* end fetchClassOf: */; + l206: /* end lookupInMethodCacheSel:class: */; + l207: /* end internalExecuteNewMethod */; + l204: /* end case */; + break; + case 207: + /* bytecodePrimPointY */ + successFlag = 1; + /* begin externalizeIPandSP */ + instructionPointer = ((int) localIP); + stackPointer = ((int) localSP); + theHomeContext = localHomeContext; + primitivePointY(); + /* begin internalizeIPandSP */ + localIP = ((char *) instructionPointer); + localSP = ((char *) stackPointer); + localHomeContext = theHomeContext; + if (successFlag) { + /* begin fetchNextBytecode */ + currentBytecode = byteAt(++localIP); + goto l208; + } + messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((31 * 2) << 2)); + argumentCount = 0; + /* begin normalSend */ + goto commonSend; + l209: /* end fetchClassOf: */; + l210: /* end lookupInMethodCacheSel:class: */; + l211: /* end internalExecuteNewMethod */; + l208: /* end case */; + break; + case 208: + case 209: + case 210: + case 211: + case 212: + case 213: + case 214: + case 215: + case 216: + case 217: + case 218: + case 219: + case 220: + case 221: + case 222: + case 223: + case 224: + case 225: + case 226: + case 227: + case 228: + case 229: + case 230: + case 231: + case 232: + case 233: + case 234: + case 235: + case 236: + case 237: + case 238: + case 239: + case 240: + case 241: + case 242: + case 243: + case 244: + case 245: + case 246: + case 247: + case 248: + case 249: + case 250: + case 251: + case 252: + case 253: + case 254: + case 255: + /* sendLiteralSelectorBytecode */ + messageSelector = longAt(((((char *) method)) + 4) + (((currentBytecode & 15) + 1) << 2)); + argumentCount = ((((unsigned) currentBytecode) >> 4) & 3) - 1; + /* begin normalSend */ + goto commonSend; + l212: /* end fetchClassOf: */; + l213: /* end lookupInMethodCacheSel:class: */; + l214: /* end internalExecuteNewMethod */; + break; + } + } + + /* undo the pre-increment of IP before returning */ + + localIP -= 1; + /* begin externalizeIPandSP */ + instructionPointer = ((int) localIP); + stackPointer = ((int) localSP); + theHomeContext = localHomeContext; +} + + +/* Support for external primitives. */ + +int isKindOf(int oop, char *className) { + int oopClass; + int ccIndex; + + /* begin fetchClassOf: */ + if ((oop & 1)) { + oopClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); + goto l1; + } + ccIndex = (((unsigned) (longAt(oop))) >> 12) & 31; + if (ccIndex == 0) { + oopClass = (longAt(oop - 4)) & 4294967292U; + goto l1; + } else { + oopClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); + goto l1; + } +l1: /* end fetchClassOf: */; + while (!(oopClass == nilObj)) { + if (classNameOfIs(oopClass, className)) { + return 1; + } + oopClass = longAt(((((char *) oopClass)) + 4) + (0 << 2)); + } + return 0; +} + + +/* Support for external primitives */ + +int isMemberOf(int oop, char *className) { + int oopClass; + int ccIndex; + + /* begin fetchClassOf: */ + if ((oop & 1)) { + oopClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); + goto l1; + } + ccIndex = (((unsigned) (longAt(oop))) >> 12) & 31; + if (ccIndex == 0) { + oopClass = (longAt(oop - 4)) & 4294967292U; + goto l1; + } else { + oopClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); + goto l1; + } +l1: /* end fetchClassOf: */; + return classNameOfIs(oopClass, className); +} + + +/* Answer true if the argument contains indexable bytes. See comment in formatOf: */ +/* Note: Includes CompiledMethods. */ + +int isBytes(int oop) { + return ((((unsigned) (longAt(oop))) >> 8) & 15) >= 8; +} + +int isContextHeader(int aHeader) { + int ccIndex; + + ccIndex = (((unsigned) aHeader) >> 12) & 31; + return (ccIndex == 13) || ((ccIndex == 14) || (ccIndex == 4)); +} + +int isFloatObject(int oop) { + return (fetchClassOf(oop)) == (longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2))); +} + + +/* Is this a MethodContext whose meth has a primitive number of 199? */ +/* NB: the use of a primitive number for marking the method is pretty grungy, but it is simple to use for a test sytem, not too expensive and we don't actually have the two spare method header bits we need. We can probably obtain them when the method format is changed. + NB 2: actually, the jitter will probably implement the prim to actually mark the volatile frame by changing the return function pointer. */ + +int isHandlerMarked(int aContext) { + int header; + int pIndex; + int meth; + int primBits; + + header = longAt(aContext); + if (!(((((unsigned) header) >> 12) & 31) == 14)) { + return 0; + } + meth = longAt(((((char *) aContext)) + 4) + (3 << 2)); + /* begin primitiveIndexOf: */ + primBits = (((unsigned) (longAt(((((char *) meth)) + 4) + (0 << 2)))) >> 1) & 805306879; + if (primBits > 511) { + pIndex = (primBits & 511) + (((unsigned) primBits) >> 19); + goto l1; + } else { + pIndex = primBits; + goto l1; + } +l1: /* end primitiveIndexOf: */; + return pIndex == 199; +} + + +/* Return true if the given address is in ST object memory */ + +int isInMemory(int address) { + return (address >= (startOfMemory())) && (address < endOfMemory); +} + +int isIndexable(int oop) { + return ((((unsigned) (longAt(oop))) >> 8) & 15) >= 2; +} + +int isIntegerObject(int objectPointer) { + return (objectPointer & 1) > 0; +} + + +/* Return true if the given value can be represented as a Smalltalk integer value. */ +/* Details: This trick is from Tim Rowledge. Use a shift and XOR to set the sign bit if and only if the top two bits of the given value are the same, then test the sign bit. Note that the top two bits are equal for exactly those integers in the range that can be represented in 31-bits. */ + +int isIntegerValue(int intValue) { + return (intValue ^ (intValue << 1)) >= 0; +} + + +/* Answer true if the argument has only fields that can hold oops. See comment in formatOf: */ + +int isPointers(int oop) { + return ((((unsigned) (longAt(oop))) >> 8) & 15) <= 4; +} + + +/* Is this a MethodContext whose meth has a primitive number of 198? */ +/* NB: the use of a primitive number for marking the method is pretty grungy, but it is simple to use for a test sytem, not too expensive and we don't actually have the two spare method header bits we need. We can probably obtain them when the method format is changed + NB 2: actually, the jitter will probably implement the prim to actually mark the volatile frame by changing the return function pointer. */ + +int isUnwindMarked(int aContext) { + int header; + int pIndex; + int meth; + int primBits; + + header = longAt(aContext); + if (!(((((unsigned) header) >> 12) & 31) == 14)) { + return 0; + } + meth = longAt(((((char *) aContext)) + 4) + (3 << 2)); + /* begin primitiveIndexOf: */ + primBits = (((unsigned) (longAt(((((char *) meth)) + 4) + (0 << 2)))) >> 1) & 805306879; + if (primBits > 511) { + pIndex = (primBits & 511) + (((unsigned) primBits) >> 19); + goto l1; + } else { + pIndex = primBits; + goto l1; + } +l1: /* end primitiveIndexOf: */; + return pIndex == 198; +} + + +/* Answer true if the argument has only weak fields that can hold oops. See comment in formatOf: */ + +int isWeak(int oop) { + return ((((unsigned) (longAt(oop))) >> 8) & 15) == 4; +} + + +/* Answer true if the argument contains only indexable words (no oops). See comment in formatOf: */ + +int isWords(int oop) { + return ((((unsigned) (longAt(oop))) >> 8) & 15) == 6; +} + + +/* Answer true if the contains only indexable words or bytes (no oops). See comment in formatOf: */ +/* Note: Excludes CompiledMethods. */ + +int isWordsOrBytes(int oop) { + int fmt; + + fmt = (((unsigned) (longAt(oop))) >> 8) & 15; + return (fmt == 6) || ((fmt >= 8) && (fmt <= 11)); +} + + +/* Return the byte offset of the last pointer field of the given object. Works with CompiledMethods, as well as ordinary objects. Can be used even when the type bits are not correct. */ + +int lastPointerOf(int oop) { + int header; + int fmt; + int methodHeader; + int sz; + int header1; + int type; + + header = longAt(oop); + fmt = (((unsigned) header) >> 8) & 15; + if (fmt <= 4) { + if ((fmt == 3) && (isContextHeader(header))) { + return (6 + (fetchStackPointerOf(oop))) * 4; + } + /* begin sizeBitsOfSafe: */ + header1 = longAt(oop); + /* begin rightType: */ + if ((header1 & 252) == 0) { + type = 0; + goto l1; + } else { + if ((header1 & 126976) == 0) { + type = 1; + goto l1; + } else { + type = 3; + goto l1; + } + } + l1: /* end rightType: */; + if (type == 0) { + sz = (longAt(oop - 8)) & 4294967292U; + goto l2; + } else { + sz = header1 & 252; + goto l2; + } + l2: /* end sizeBitsOfSafe: */; + return sz - 4; + } + if (fmt < 12) { + return 0; + } + methodHeader = longAt(oop + 4); + return (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; +} + + +/* Return the number of indexable bytes or words in the given object. Assume the argument is not an integer. For a CompiledMethod, the size of the method header (in bytes) should be subtracted from the result. */ + +int lengthOf(int oop) { + int header; + int sz; + + header = longAt(oop); + /* begin lengthOf:baseHeader:format: */ + if ((header & 3) == 0) { + sz = (longAt(oop - 8)) & 4294967292U; + } else { + sz = header & 252; + } + if (((((unsigned) header) >> 8) & 15) < 8) { + return ((unsigned) (sz - 4)) >> 2; + } else { + return (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); + } + return null; +} + +int literalofMethod(int offset, int methodPointer) { + return longAt(((((char *) methodPointer)) + 4) + ((offset + 1) << 2)); +} + +int literalCountOf(int methodPointer) { + return (((unsigned) (longAt(((((char *) methodPointer)) + 4) + (0 << 2)))) >> 10) & 255; +} + + +/* This entry point needs to be implemented for the interpreter proxy. + Since BitBlt is now a plugin we need to look up BitBltPlugin_loadBitBltFrom + and call it. This entire mechanism should eventually go away and be + replaced with a dynamic lookup from BitBltPlugin itself but for backward + compatibility this stub is provided */ + +int loadBitBltFrom(int bb) { + int fn; + + fn = ioLoadFunctionFrom("loadBitBltFrom", "BitBltPlugin"); + if (fn == 0) { + /* begin primitiveFail */ + successFlag = 0; + return null; + } + return ((int (*) (int)) fn)(bb); +} + + +/* If floatOrInt is an integer, then convert it to a C double float and return it. + If it is a Float, then load its value and return it. + Otherwise fail -- ie return with successFlag set to false. */ + +double loadFloatOrIntFrom(int floatOrInt) { + if ((floatOrInt & 1)) { + return ((double) (floatOrInt >> 1)); + } + if ((fetchClassOfNonInt(floatOrInt)) == (longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)))) { + return floatValueOf(floatOrInt); + } + successFlag = 0; +} + +int loadInitialContext(void) { + int proc; + int sched; + int activeCntx; + int tmp; + + sched = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (3 << 2))))) + 4) + (1 << 2)); + proc = longAt(((((char *) sched)) + 4) + (1 << 2)); + activeContext = longAt(((((char *) proc)) + 4) + (1 << 2)); + if (activeContext < youngStart) { + beRootIfOld(activeContext); + } + /* begin fetchContextRegisters: */ + activeCntx = activeContext; + tmp = longAt(((((char *) activeCntx)) + 4) + (3 << 2)); + if ((tmp & 1)) { + tmp = longAt(((((char *) activeCntx)) + 4) + (5 << 2)); + if (tmp < youngStart) { + beRootIfOld(tmp); + } + } else { + tmp = activeCntx; + } + theHomeContext = tmp; + receiver = longAt(((((char *) tmp)) + 4) + (5 << 2)); + method = longAt(((((char *) tmp)) + 4) + (3 << 2)); + tmp = ((longAt(((((char *) activeCntx)) + 4) + (1 << 2))) >> 1); + instructionPointer = ((method + tmp) + 4) - 2; + tmp = ((longAt(((((char *) activeCntx)) + 4) + (2 << 2))) >> 1); + stackPointer = (activeCntx + 4) + (((6 + tmp) - 1) * 4); + reclaimableContextCount = 0; +} + +int lookupMethodInClass(int class) { + int currentClass; + int rclass; + int found; + int dictionary; + int oop; + int oop1; + int length; + int methodArray; + int wrapAround; + int mask; + int nextSelector; + int index; + int sz; + int primBits; + int header; + + currentClass = class; + while (currentClass != nilObj) { + dictionary = longAt(((((char *) currentClass)) + 4) + (1 << 2)); + if (dictionary == nilObj) { + /* begin pushRemappableOop: */ + remapBuffer[remapBufferCount += 1] = currentClass; + createActualMessageTo(class); + /* begin popRemappableOop */ + oop = remapBuffer[remapBufferCount]; + remapBufferCount -= 1; + currentClass = oop; + messageSelector = longAt(((((char *) specialObjectsOop)) + 4) + (34 << 2)); + return lookupMethodInClass(longAt(((((char *) currentClass)) + 4) + (0 << 2))); + } + /* begin lookupMethodInDictionary: */ + /* begin fetchWordLengthOf: */ + /* begin sizeBitsOf: */ + header = longAt(dictionary); + if ((header & 3) == 0) { + sz = (longAt(dictionary - 8)) & 4294967292U; + goto l2; + } else { + sz = header & 252; + goto l2; + } + l2: /* end sizeBitsOf: */; + length = ((unsigned) (sz - 4)) >> 2; + mask = (length - 2) - 1; + if ((messageSelector & 1)) { + index = (mask & ((messageSelector >> 1))) + 2; + } else { + index = (mask & ((((unsigned) (longAt(messageSelector))) >> 17) & 4095)) + 2; + } + wrapAround = 0; + while (1) { + nextSelector = longAt(((((char *) dictionary)) + 4) + (index << 2)); + if (nextSelector == nilObj) { + found = 0; + goto l3; + } + if (nextSelector == messageSelector) { + methodArray = longAt(((((char *) dictionary)) + 4) + (1 << 2)); + newMethod = longAt(((((char *) methodArray)) + 4) + ((index - 2) << 2)); + /* begin primitiveIndexOf: */ + primBits = (((unsigned) (longAt(((((char *) newMethod)) + 4) + (0 << 2)))) >> 1) & 805306879; + if (primBits > 511) { + primitiveIndex = (primBits & 511) + (((unsigned) primBits) >> 19); + goto l1; + } else { + primitiveIndex = primBits; + goto l1; + } + l1: /* end primitiveIndexOf: */; + if (primitiveIndex > 700) { + primitiveIndex = 0; + } + found = 1; + goto l3; + } + index += 1; + if (index == length) { + if (wrapAround) { + found = 0; + goto l3; + } + wrapAround = 1; + index = 2; + } + } + l3: /* end lookupMethodInDictionary: */; + if (found) { + return methodClass = currentClass; + } + currentClass = longAt(((((char *) currentClass)) + 4) + (0 << 2)); + } + if (messageSelector == (longAt(((((char *) specialObjectsOop)) + 4) + (20 << 2)))) { + error("Recursive not understood error encountered"); + } + /* begin pushRemappableOop: */ + remapBuffer[remapBufferCount += 1] = class; + createActualMessageTo(class); + /* begin popRemappableOop */ + oop1 = remapBuffer[remapBufferCount]; + remapBufferCount -= 1; + rclass = oop1; + messageSelector = longAt(((((char *) specialObjectsOop)) + 4) + (20 << 2)); + return lookupMethodInClass(rclass); +} + + +/* Return the first free block after the given chunk in memory. */ + +int lowestFreeAfter(int chunk) { + int oopHeader; + int oop; + int oopHeaderType; + int oopSize; + int extra; + int extra1; + int extra2; + int type; + int extra3; + int type1; + + /* begin oopFromChunk: */ + /* begin extraHeaderBytes: */ + type1 = (longAt(chunk)) & 3; + if (type1 > 1) { + extra3 = 0; + } else { + if (type1 == 1) { + extra3 = 4; + } else { + extra3 = 8; + } + } + extra1 = extra3; + oop = chunk + extra1; + while (oop < endOfMemory) { + oopHeader = longAt(oop); + oopHeaderType = oopHeader & 3; + if (oopHeaderType == 2) { + return oop; + } else { + if (oopHeaderType == 0) { + oopSize = (longAt(oop - 8)) & 4294967292U; + } else { + oopSize = oopHeader & 252; + } + } + /* begin oopFromChunk: */ + /* begin extraHeaderBytes: */ + type = (longAt(oop + oopSize)) & 3; + if (type > 1) { + extra2 = 0; + } else { + if (type == 1) { + extra2 = 4; + } else { + extra2 = 8; + } + } + extra = extra2; + oop = (oop + oopSize) + extra; + } + error("expected to find at least one free object"); +} + +int makePointwithxValueyValue(int xValue, int yValue) { + int pointResult; + + pointResult = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2)), 12, nilObj); + /* begin storePointer:ofObject:withValue: */ + if (pointResult < youngStart) { + possibleRootStoreIntovalue(pointResult, ((xValue << 1) | 1)); + } + longAtput(((((char *) pointResult)) + 4) + (0 << 2), ((xValue << 1) | 1)); + /* begin storePointer:ofObject:withValue: */ + if (pointResult < youngStart) { + possibleRootStoreIntovalue(pointResult, ((yValue << 1) | 1)); + } + longAtput(((((char *) pointResult)) + 4) + (1 << 2), ((yValue << 1) | 1)); + return pointResult; +} + + +/* Use the forwarding table to update the pointers of all non-free objects in the given range of memory. Also remap pointers in root objects which may contains pointers into the given memory range, and don't forget to flush the method cache based on the range */ + +int mapPointersInObjectsFromto(int memStart, int memEnd) { + int i; + int oop; + int i1; + int oop1; + int i2; + int probe; + int extra; + int extra1; + int type; + int header; + int sz; + int fwdBlock; + int realHeader; + int extra3; + int extra12; + int type2; + int sz1; + int extra2; + int header1; + int extra11; + int type1; + int newOop; + int fieldOop; + int fwdBlock4; + int fieldOffset; + int header5; + int fwdBlock1; + int header12; + int header2; + int header3; + int fmt; + int methodHeader; + int size; + int fwdBlock2; + int newClassHeader; + int classOop; + int newClassOop; + int fwdBlock3; + int classHeader; + int header4; + int fwdBlock11; + int header11; + int header21; + int newOop1; + int fieldOop1; + int fwdBlock5; + int fieldOffset1; + int header6; + int fwdBlock12; + int header13; + int header22; + int header31; + int fmt1; + int methodHeader1; + int size1; + int fwdBlock21; + int newClassHeader1; + int classOop1; + int newClassOop1; + int fwdBlock31; + int classHeader1; + int header41; + int fwdBlock111; + int header111; + int header211; + + /* begin compilerMapHookFrom:to: */ + if (compilerInitialized) { + compilerMapFromto(memStart, memEnd); + } + /* begin mapInterpreterOops */ + nilObj = remap(nilObj); + falseObj = remap(falseObj); + trueObj = remap(trueObj); + specialObjectsOop = remap(specialObjectsOop); + if (!(compilerInitialized)) { + stackPointer -= activeContext; + activeContext = remap(activeContext); + stackPointer += activeContext; + theHomeContext = remap(theHomeContext); + } + instructionPointer -= method; + method = remap(method); + instructionPointer += method; + receiver = remap(receiver); + messageSelector = remap(messageSelector); + newMethod = remap(newMethod); + methodClass = remap(methodClass); + lkupClass = remap(lkupClass); + receiverClass = remap(receiverClass); + for (i1 = 1; i1 <= remapBufferCount; i1 += 1) { + oop1 = remapBuffer[i1]; + if (!((oop1 & 1))) { + remapBuffer[i1] = (remap(oop1)); + } + } + /* begin flushMethodCacheFrom:to: */ + probe = 0; + for (i2 = 1; i2 <= 512; i2 += 1) { + if (!((methodCache[probe + 1]) == 0)) { + if ((((((methodCache[probe + 1]) >= memStart) && ((methodCache[probe + 1]) < memEnd)) || (((methodCache[probe + 2]) >= memStart) && ((methodCache[probe + 2]) < memEnd))) || (((methodCache[probe + 3]) >= memStart) && ((methodCache[probe + 3]) < memEnd))) || (((methodCache[probe + 5]) >= memStart) && ((methodCache[probe + 5]) < memEnd))) { + methodCache[probe + 1] = 0; + } + } + probe += 8; + } + for (i2 = 1; i2 <= 64; i2 += 1) { + atCache[i2] = 0; + } + for (i = 1; i <= rootTableCount; i += 1) { + oop = rootTable[i]; + if ((oop < memStart) || (oop >= memEnd)) { + /* begin remapFieldsAndClassOf: */ + /* begin lastPointerWhileForwarding: */ + header3 = longAt(oop); + if ((header3 & 2147483648U) != 0) { + fwdBlock2 = (header3 & 2147483644) << 1; + ; + header3 = longAt(fwdBlock2 + 4); + } + fmt = (((unsigned) header3) >> 8) & 15; + if (fmt <= 4) { + if ((fmt == 3) && (isContextHeader(header3))) { + fieldOffset = (6 + (fetchStackPointerOf(oop))) * 4; + goto l3; + } + if ((header3 & 3) == 0) { + size = (longAt(oop - 8)) & 4294967292U; + } else { + size = header3 & 252; + } + fieldOffset = size - 4; + goto l3; + } + if (fmt < 12) { + fieldOffset = 0; + goto l3; + } + methodHeader = longAt(oop + 4); + fieldOffset = (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; + l3: /* end lastPointerWhileForwarding: */; + while (fieldOffset >= 4) { + fieldOop = longAt(oop + fieldOffset); + if (((fieldOop & 1) == 0) && (((longAt(fieldOop)) & 2147483648U) != 0)) { + fwdBlock4 = ((longAt(fieldOop)) & 2147483644) << 1; + ; + newOop = longAt(fwdBlock4); + longAtput(oop + fieldOffset, newOop); + if ((oop < youngStart) && (newOop >= youngStart)) { + /* begin beRootWhileForwarding: */ + header5 = longAt(oop); + if ((header5 & 2147483648U) != 0) { + fwdBlock1 = (header5 & 2147483644) << 1; + ; + /* begin noteAsRoot:headerLoc: */ + header12 = longAt(fwdBlock1 + 4); + if ((header12 & 1073741824) == 0) { + if (rootTableCount < 2500) { + rootTableCount += 1; + rootTable[rootTableCount] = oop; + longAtput(fwdBlock1 + 4, header12 | 1073741824); + } + } + } else { + /* begin noteAsRoot:headerLoc: */ + header2 = longAt(oop); + if ((header2 & 1073741824) == 0) { + if (rootTableCount < 2500) { + rootTableCount += 1; + rootTable[rootTableCount] = oop; + longAtput(oop, header2 | 1073741824); + } + } + } + } + } + fieldOffset -= 4; + } + /* begin remapClassOf: */ + if (((longAt(oop)) & 3) == 3) { + goto l4; + } + classHeader = longAt(oop - 4); + classOop = classHeader & 4294967292U; + if (((classOop & 1) == 0) && (((longAt(classOop)) & 2147483648U) != 0)) { + fwdBlock3 = ((longAt(classOop)) & 2147483644) << 1; + ; + newClassOop = longAt(fwdBlock3); + newClassHeader = newClassOop | (classHeader & 3); + longAtput(oop - 4, newClassHeader); + if ((oop < youngStart) && (newClassOop >= youngStart)) { + /* begin beRootWhileForwarding: */ + header4 = longAt(oop); + if ((header4 & 2147483648U) != 0) { + fwdBlock11 = (header4 & 2147483644) << 1; + ; + /* begin noteAsRoot:headerLoc: */ + header11 = longAt(fwdBlock11 + 4); + if ((header11 & 1073741824) == 0) { + if (rootTableCount < 2500) { + rootTableCount += 1; + rootTable[rootTableCount] = oop; + longAtput(fwdBlock11 + 4, header11 | 1073741824); + } + } + } else { + /* begin noteAsRoot:headerLoc: */ + header21 = longAt(oop); + if ((header21 & 1073741824) == 0) { + if (rootTableCount < 2500) { + rootTableCount += 1; + rootTable[rootTableCount] = oop; + longAtput(oop, header21 | 1073741824); + } + } + } + } + } + l4: /* end remapClassOf: */; + } + } + /* begin oopFromChunk: */ + /* begin extraHeaderBytes: */ + type = (longAt(memStart)) & 3; + if (type > 1) { + extra1 = 0; + } else { + if (type == 1) { + extra1 = 4; + } else { + extra1 = 8; + } + } + extra = extra1; + oop = memStart + extra; + while (oop < memEnd) { + if (!(((longAt(oop)) & 3) == 2)) { + /* begin remapFieldsAndClassOf: */ + /* begin lastPointerWhileForwarding: */ + header31 = longAt(oop); + if ((header31 & 2147483648U) != 0) { + fwdBlock21 = (header31 & 2147483644) << 1; + ; + header31 = longAt(fwdBlock21 + 4); + } + fmt1 = (((unsigned) header31) >> 8) & 15; + if (fmt1 <= 4) { + if ((fmt1 == 3) && (isContextHeader(header31))) { + fieldOffset1 = (6 + (fetchStackPointerOf(oop))) * 4; + goto l5; + } + if ((header31 & 3) == 0) { + size1 = (longAt(oop - 8)) & 4294967292U; + } else { + size1 = header31 & 252; + } + fieldOffset1 = size1 - 4; + goto l5; + } + if (fmt1 < 12) { + fieldOffset1 = 0; + goto l5; + } + methodHeader1 = longAt(oop + 4); + fieldOffset1 = (((((unsigned) methodHeader1) >> 10) & 255) * 4) + 4; + l5: /* end lastPointerWhileForwarding: */; + while (fieldOffset1 >= 4) { + fieldOop1 = longAt(oop + fieldOffset1); + if (((fieldOop1 & 1) == 0) && (((longAt(fieldOop1)) & 2147483648U) != 0)) { + fwdBlock5 = ((longAt(fieldOop1)) & 2147483644) << 1; + ; + newOop1 = longAt(fwdBlock5); + longAtput(oop + fieldOffset1, newOop1); + if ((oop < youngStart) && (newOop1 >= youngStart)) { + /* begin beRootWhileForwarding: */ + header6 = longAt(oop); + if ((header6 & 2147483648U) != 0) { + fwdBlock12 = (header6 & 2147483644) << 1; + ; + /* begin noteAsRoot:headerLoc: */ + header13 = longAt(fwdBlock12 + 4); + if ((header13 & 1073741824) == 0) { + if (rootTableCount < 2500) { + rootTableCount += 1; + rootTable[rootTableCount] = oop; + longAtput(fwdBlock12 + 4, header13 | 1073741824); + } + } + } else { + /* begin noteAsRoot:headerLoc: */ + header22 = longAt(oop); + if ((header22 & 1073741824) == 0) { + if (rootTableCount < 2500) { + rootTableCount += 1; + rootTable[rootTableCount] = oop; + longAtput(oop, header22 | 1073741824); + } + } + } + } + } + fieldOffset1 -= 4; + } + /* begin remapClassOf: */ + if (((longAt(oop)) & 3) == 3) { + goto l6; + } + classHeader1 = longAt(oop - 4); + classOop1 = classHeader1 & 4294967292U; + if (((classOop1 & 1) == 0) && (((longAt(classOop1)) & 2147483648U) != 0)) { + fwdBlock31 = ((longAt(classOop1)) & 2147483644) << 1; + ; + newClassOop1 = longAt(fwdBlock31); + newClassHeader1 = newClassOop1 | (classHeader1 & 3); + longAtput(oop - 4, newClassHeader1); + if ((oop < youngStart) && (newClassOop1 >= youngStart)) { + /* begin beRootWhileForwarding: */ + header41 = longAt(oop); + if ((header41 & 2147483648U) != 0) { + fwdBlock111 = (header41 & 2147483644) << 1; + ; + /* begin noteAsRoot:headerLoc: */ + header111 = longAt(fwdBlock111 + 4); + if ((header111 & 1073741824) == 0) { + if (rootTableCount < 2500) { + rootTableCount += 1; + rootTable[rootTableCount] = oop; + longAtput(fwdBlock111 + 4, header111 | 1073741824); + } + } + } else { + /* begin noteAsRoot:headerLoc: */ + header211 = longAt(oop); + if ((header211 & 1073741824) == 0) { + if (rootTableCount < 2500) { + rootTableCount += 1; + rootTable[rootTableCount] = oop; + longAtput(oop, header211 | 1073741824); + } + } + } + } + } + l6: /* end remapClassOf: */; + } + /* begin objectAfterWhileForwarding: */ + header = longAt(oop); + if ((header & 2147483648U) == 0) { + /* begin objectAfter: */ + ; + if (((longAt(oop)) & 3) == 2) { + sz1 = (longAt(oop)) & 4294967292U; + } else { + /* begin sizeBitsOf: */ + header1 = longAt(oop); + if ((header1 & 3) == 0) { + sz1 = (longAt(oop - 8)) & 4294967292U; + goto l1; + } else { + sz1 = header1 & 252; + goto l1; + } + l1: /* end sizeBitsOf: */; + } + /* begin oopFromChunk: */ + /* begin extraHeaderBytes: */ + type1 = (longAt(oop + sz1)) & 3; + if (type1 > 1) { + extra11 = 0; + } else { + if (type1 == 1) { + extra11 = 4; + } else { + extra11 = 8; + } + } + extra2 = extra11; + oop = (oop + sz1) + extra2; + goto l2; + } + fwdBlock = (header & 2147483644) << 1; + ; + realHeader = longAt(fwdBlock + 4); + if ((realHeader & 3) == 0) { + sz = (longAt(oop - 8)) & 4294967292U; + } else { + sz = realHeader & 252; + } + /* begin oopFromChunk: */ + /* begin extraHeaderBytes: */ + type2 = (longAt(oop + sz)) & 3; + if (type2 > 1) { + extra12 = 0; + } else { + if (type2 == 1) { + extra12 = 4; + } else { + extra12 = 8; + } + } + extra3 = extra12; + oop = (oop + sz) + extra3; + l2: /* end objectAfterWhileForwarding: */; + } +} + + +/* Mark all objects reachable from the given one. + Trace from the given object even if it is old. + Do not trace if it is already marked. + Mark it only if it is a young object. */ +/* Tracer state variables: + child object being examined + field next field of child to examine + parentField field where child was stored in its referencing object */ + +int markAndTrace(int oop) { + int header; + int action; + int lastFieldOffset; + int typeBits; + int childType; + int header1; + int type; + int header2; + int fmt; + int methodHeader; + int sz; + int header3; + int type1; + int header4; + int oop1; + int lastFieldOffset1; + int header21; + int fmt1; + int methodHeader1; + int sz1; + int header11; + int type2; + + header = longAt(oop); + if (!((header & 2147483648U) == 0)) { + return 0; + } + header = (header & 4294967292U) | 2; + if (oop >= youngStart) { + header = header | 2147483648U; + } + longAtput(oop, header); + parentField = 3; + child = oop; + /* begin lastPointerOf: */ + header2 = longAt(oop); + fmt = (((unsigned) header2) >> 8) & 15; + if (fmt <= 4) { + if ((fmt == 3) && (isContextHeader(header2))) { + lastFieldOffset = (6 + (fetchStackPointerOf(oop))) * 4; + goto l6; + } + /* begin sizeBitsOfSafe: */ + header3 = longAt(oop); + /* begin rightType: */ + if ((header3 & 252) == 0) { + type1 = 0; + goto l7; + } else { + if ((header3 & 126976) == 0) { + type1 = 1; + goto l7; + } else { + type1 = 3; + goto l7; + } + } + l7: /* end rightType: */; + if (type1 == 0) { + sz = (longAt(oop - 8)) & 4294967292U; + goto l8; + } else { + sz = header3 & 252; + goto l8; + } + l8: /* end sizeBitsOfSafe: */; + lastFieldOffset = sz - 4; + goto l6; + } + if (fmt < 12) { + lastFieldOffset = 0; + goto l6; + } + methodHeader = longAt(oop + 4); + lastFieldOffset = (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; +l6: /* end lastPointerOf: */; + field = oop + lastFieldOffset; + + /* run the tracer state machine until all objects reachable from oop are marked */ + + action = 1; + while (!(action == 4)) { + if (action == 1) { + /* begin startField */ + child = longAt(field); + typeBits = child & 3; + if ((typeBits & 1) == 1) { + field -= 4; + action = 1; + goto l1; + } + if (typeBits == 0) { + longAtput(field, parentField); + parentField = field; + action = 2; + goto l1; + } + if (typeBits == 2) { + if ((child & 126976) != 0) { + child = child & 4294967292U; + /* begin rightType: */ + if ((child & 252) == 0) { + childType = 0; + goto l2; + } else { + if ((child & 126976) == 0) { + childType = 1; + goto l2; + } else { + childType = 3; + goto l2; + } + } + l2: /* end rightType: */; + longAtput(field, child | childType); + action = 3; + goto l1; + } else { + child = longAt(field - 4); + child = child & 4294967292U; + longAtput(field - 4, parentField); + parentField = (field - 4) | 1; + action = 2; + goto l1; + } + } + l1: /* end startField */; + } + if (action == 2) { + /* begin startObj */ + oop1 = child; + if (oop1 < youngStart) { + field = oop1; + action = 3; + goto l12; + } + header4 = longAt(oop1); + if ((header4 & 2147483648U) == 0) { + if (((((unsigned) (longAt(oop1))) >> 8) & 15) == 4) { + lastFieldOffset1 = (nonWeakFieldsOf(oop1)) << 2; + } else { + /* begin lastPointerOf: */ + header21 = longAt(oop1); + fmt1 = (((unsigned) header21) >> 8) & 15; + if (fmt1 <= 4) { + if ((fmt1 == 3) && (isContextHeader(header21))) { + lastFieldOffset1 = (6 + (fetchStackPointerOf(oop1))) * 4; + goto l11; + } + /* begin sizeBitsOfSafe: */ + header11 = longAt(oop1); + /* begin rightType: */ + if ((header11 & 252) == 0) { + type2 = 0; + goto l9; + } else { + if ((header11 & 126976) == 0) { + type2 = 1; + goto l9; + } else { + type2 = 3; + goto l9; + } + } + l9: /* end rightType: */; + if (type2 == 0) { + sz1 = (longAt(oop1 - 8)) & 4294967292U; + goto l10; + } else { + sz1 = header11 & 252; + goto l10; + } + l10: /* end sizeBitsOfSafe: */; + lastFieldOffset1 = sz1 - 4; + goto l11; + } + if (fmt1 < 12) { + lastFieldOffset1 = 0; + goto l11; + } + methodHeader1 = longAt(oop1 + 4); + lastFieldOffset1 = (((((unsigned) methodHeader1) >> 10) & 255) * 4) + 4; + l11: /* end lastPointerOf: */; + } + header4 = header4 & 4294967292U; + header4 = (header4 | 2147483648U) | 2; + longAtput(oop1, header4); + field = oop1 + lastFieldOffset1; + action = 1; + goto l12; + } else { + field = oop1; + action = 3; + goto l12; + } + l12: /* end startObj */; + } + if (action == 3) { + /* begin upward */ + if ((parentField & 1) == 1) { + if (parentField == 3) { + header1 = (longAt(field)) & 4294967292U; + /* begin rightType: */ + if ((header1 & 252) == 0) { + type = 0; + goto l3; + } else { + if ((header1 & 126976) == 0) { + type = 1; + goto l3; + } else { + type = 3; + goto l3; + } + } + l3: /* end rightType: */; + longAtput(field, header1 + type); + action = 4; + goto l5; + } else { + child = field; + field = parentField - 1; + parentField = longAt(field); + header1 = longAt(field + 4); + /* begin rightType: */ + if ((header1 & 252) == 0) { + type = 0; + goto l4; + } else { + if ((header1 & 126976) == 0) { + type = 1; + goto l4; + } else { + type = 3; + goto l4; + } + } + l4: /* end rightType: */; + longAtput(field, child + type); + field += 4; + header1 = header1 & 4294967292U; + longAtput(field, header1 + type); + action = 3; + goto l5; + } + } else { + child = field; + field = parentField; + parentField = longAt(field); + longAtput(field, child); + field -= 4; + action = 1; + goto l5; + } + l5: /* end upward */; + } + } +} + + +/* Mark and trace all oops in the interpreter's state. */ +/* Assume: All traced variables contain valid oops. */ + +int markAndTraceInterpreterOops(void) { + int i; + int oop; + + /* begin compilerMarkHook */ + if (compilerInitialized) { + compilerMark(); + } + markAndTrace(specialObjectsOop); + if (compilerInitialized) { + markAndTrace(receiver); + markAndTrace(method); + } else { + markAndTrace(activeContext); + } + markAndTrace(messageSelector); + markAndTrace(newMethod); + markAndTrace(methodClass); + markAndTrace(lkupClass); + markAndTrace(receiverClass); + for (i = 1; i <= remapBufferCount; i += 1) { + oop = remapBuffer[i]; + if (!((oop & 1))) { + markAndTrace(oop); + } + } +} + + +/* Mark phase of the mark and sweep garbage collector. Set the mark bits of all reachable objects. Free chunks are untouched by this process. */ +/* Assume: All non-free objects are initially unmarked. Root objects were unmarked when they were made roots. (Make sure this stays true!!). */ + +int markPhase(void) { + int i; + int oop; + + freeContexts = 1; + + /* trace the interpreter's objects, including the active stack and special objects array */ + + freeLargeContexts = 1; + markAndTraceInterpreterOops(); + for (i = 1; i <= rootTableCount; i += 1) { + oop = rootTable[i]; + markAndTrace(oop); + } +} + +int methodArgumentCount(void) { + return argumentCount; +} + +int methodPrimitiveIndex(void) { + return primitiveIndex; +} + + +/* The module with the given name was just unloaded. + Make sure we have no dangling references. */ + +EXPORT(int) moduleUnloaded(char * aModuleName) { + if ((strcmp(aModuleName, "SurfacePlugin")) == 0) { + showSurfaceFn = 0; + } +} + + +/* For access from BitBlt module */ + +int nilObject(void) { + return nilObj; +} + + +/* Return the number of non-weak fields in oop (i.e. the number of fixed fields). + Note: The following is copied from fixedFieldsOf:format:length: since we do know + the format of the oop (e.g. format = 4) and thus don't need the length. */ + +int nonWeakFieldsOf(int oop) { + int classFormat; + int class; + int ccIndex; + + if (!(((((unsigned) (longAt(oop))) >> 8) & 15) == 4)) { + error("Called fixedFieldsOfWeak: with a non-weak oop"); + } + /* begin fetchClassOf: */ + if ((oop & 1)) { + class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); + goto l1; + } + ccIndex = (((unsigned) (longAt(oop))) >> 12) & 31; + if (ccIndex == 0) { + class = (longAt(oop - 4)) & 4294967292U; + goto l1; + } else { + class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); + goto l1; + } +l1: /* end fetchClassOf: */; + classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; + return (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; +} + + +/* Record that the given oop in the old object area points to an object in the young area. + HeaderLoc is usually = oop, but may be an addr in a forwarding block. */ + +int noteAsRootheaderLoc(int oop, int headerLoc) { + int header; + + header = longAt(headerLoc); + if ((header & 1073741824) == 0) { + if (rootTableCount < 2500) { + rootTableCount += 1; + rootTable[rootTableCount] = oop; + longAtput(headerLoc, header | 1073741824); + } + } +} + + +/* This should never be called: either the compiler is uninitialised (in which case the hooks should never be reached) or the compiler initialisation should have replaced all the hook with their external implementations. */ + +int nullCompilerHook(void) { + error("uninitialised compiler hook called"); + return 0; +} + + +/* Return the object or free chunk immediately following the given object or free chunk in memory. Return endOfMemory when enumeration is complete. */ + +int objectAfter(int oop) { + int sz; + int extra; + int header; + int extra1; + int type; + + ; + if (((longAt(oop)) & 3) == 2) { + sz = (longAt(oop)) & 4294967292U; + } else { + /* begin sizeBitsOf: */ + header = longAt(oop); + if ((header & 3) == 0) { + sz = (longAt(oop - 8)) & 4294967292U; + goto l1; + } else { + sz = header & 252; + goto l1; + } + l1: /* end sizeBitsOf: */; + } + /* begin oopFromChunk: */ + /* begin extraHeaderBytes: */ + type = (longAt(oop + sz)) & 3; + if (type > 1) { + extra1 = 0; + } else { + if (type == 1) { + extra1 = 4; + } else { + extra1 = 8; + } + } + extra = extra1; + return (oop + sz) + extra; +} + + +/* If this is a pointers object, check that its fields are all okay oops. */ + +int okayFields(int oop) { + int i; + int fieldOop; + int c; + int ccIndex; + + if ((oop == null) || (oop == 0)) { + return 1; + } + if ((oop & 1)) { + return 1; + } + okayOop(oop); + oopHasOkayClass(oop); + if (!(((((unsigned) (longAt(oop))) >> 8) & 15) <= 4)) { + return 1; + } + /* begin fetchClassOf: */ + if ((oop & 1)) { + c = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); + goto l1; + } + ccIndex = (((unsigned) (longAt(oop))) >> 12) & 31; + if (ccIndex == 0) { + c = (longAt(oop - 4)) & 4294967292U; + goto l1; + } else { + c = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); + goto l1; + } +l1: /* end fetchClassOf: */; + if ((c == (longAt(((((char *) specialObjectsOop)) + 4) + (10 << 2)))) || (c == (longAt(((((char *) specialObjectsOop)) + 4) + (11 << 2))))) { + i = (6 + (fetchStackPointerOf(oop))) - 1; + } else { + i = (lengthOf(oop)) - 1; + } + while (i >= 0) { + fieldOop = longAt(((((char *) oop)) + 4) + (i << 2)); + if (!((fieldOop & 1))) { + okayOop(fieldOop); + oopHasOkayClass(fieldOop); + } + i -= 1; + } +} + + +/* Verify that the given oop is legitimate. Check address, header, and size but not class. */ +/* address and size checks */ + +int okayOop(int oop) { + int fmt; + int sz; + int type; + int header; + + if ((oop & 1)) { + return 1; + } + if (!((0 < oop) && (oop < endOfMemory))) { + error("oop is not a valid address"); + } + if (!((oop % 4) == 0)) { + error("oop is not a word-aligned address"); + } + /* begin sizeBitsOf: */ + header = longAt(oop); + if ((header & 3) == 0) { + sz = (longAt(oop - 8)) & 4294967292U; + goto l1; + } else { + sz = header & 252; + goto l1; + } +l1: /* end sizeBitsOf: */; + if (!((oop + sz) < endOfMemory)) { + error("oop size would make it extend beyond the end of memory"); + } + type = (longAt(oop)) & 3; + if (type == 2) { + error("oop is a free chunk, not an object"); + } + if (type == 3) { + if (((((unsigned) (longAt(oop))) >> 12) & 31) == 0) { + error("cannot have zero compact class field in a short header"); + } + } + if (type == 1) { + if (!((oop >= 4) && (((longAt(oop - 4)) & 3) == type))) { + error("class header word has wrong type"); + } + } + if (type == 0) { + if (!((oop >= 8) && ((((longAt(oop - 8)) & 3) == type) && (((longAt(oop - 4)) & 3) == type)))) { + error("class header word has wrong type"); + } + } + fmt = (((unsigned) (longAt(oop))) >> 8) & 15; + if ((fmt == 5) || (fmt == 7)) { + error("oop has an unknown format type"); + } + if (!(((longAt(oop)) & 536870912) == 0)) { + error("unused header bit 30 is set; should be zero"); + } + if ((((longAt(oop)) & 1073741824) == 1) && (oop >= youngStart)) { + error("root bit is set in a young object"); + } + return 1; +} + + +/* Compute the oop of this chunk by adding its extra header bytes. */ + +int oopFromChunk(int chunk) { + int extra; + int extra1; + int type; + + /* begin extraHeaderBytes: */ + type = (longAt(chunk)) & 3; + if (type > 1) { + extra1 = 0; + } else { + if (type == 1) { + extra1 = 4; + } else { + extra1 = 8; + } + } + extra = extra1; + return chunk + extra; +} + + +/* Similar to oopHasOkayClass:, except that it only returns true or false. */ + +int oopHasOKclass(int oop) { + int behaviorFormatBits; + int oopFormatBits; + int oopClass; + int formatMask; + int ccIndex; + + if ((oop & 1)) { + return 1; + } + if (!((0 < oop) && (oop < endOfMemory))) { + return 0; + } + if (!((oop % 4) == 0)) { + return 0; + } + if (!((oop + (sizeBitsOf(oop))) < endOfMemory)) { + return 0; + } + /* begin fetchClassOf: */ + if ((oop & 1)) { + oopClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); + goto l1; + } + ccIndex = (((unsigned) (longAt(oop))) >> 12) & 31; + if (ccIndex == 0) { + oopClass = (longAt(oop - 4)) & 4294967292U; + goto l1; + } else { + oopClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); + goto l1; + } +l1: /* end fetchClassOf: */; + if ((oopClass & 1)) { + return 0; + } + if (!((0 < oopClass) && (oopClass < endOfMemory))) { + return 0; + } + if (!((oopClass % 4) == 0)) { + return 0; + } + if (!((oopClass + (sizeBitsOf(oopClass))) < endOfMemory)) { + return 0; + } + if (!((((((unsigned) (longAt(oopClass))) >> 8) & 15) <= 4) && ((lengthOf(oopClass)) >= 3))) { + return 0; + } + if (((((unsigned) (longAt(oop))) >> 8) & 15) >= 8) { + + /* ignore extra bytes size bits */ + + formatMask = 3072; + } else { + formatMask = 3840; + } + behaviorFormatBits = ((longAt(((((char *) oopClass)) + 4) + (2 << 2))) - 1) & formatMask; + oopFormatBits = (longAt(oop)) & formatMask; + if (!(behaviorFormatBits == oopFormatBits)) { + return 0; + } + return 1; +} + + +/* Attempt to verify that the given oop has a reasonable behavior. The class must be a valid, non-integer oop and must not be nilObj. It must be a pointers object with three or more fields. Finally, the instance specification field of the behavior must match that of the instance. */ + +int oopHasOkayClass(int oop) { + int behaviorFormatBits; + int oopFormatBits; + int oopClass; + int formatMask; + int ccIndex; + + okayOop(oop); + /* begin fetchClassOf: */ + if ((oop & 1)) { + oopClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); + goto l1; + } + ccIndex = (((unsigned) (longAt(oop))) >> 12) & 31; + if (ccIndex == 0) { + oopClass = (longAt(oop - 4)) & 4294967292U; + goto l1; + } else { + oopClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); + goto l1; + } +l1: /* end fetchClassOf: */; + if ((oopClass & 1)) { + error("a SmallInteger is not a valid class or behavior"); + } + okayOop(oopClass); + if (!((((((unsigned) (longAt(oopClass))) >> 8) & 15) <= 4) && ((lengthOf(oopClass)) >= 3))) { + error("a class (behavior) must be a pointers object of size >= 3"); + } + if (((((unsigned) (longAt(oop))) >> 8) & 15) >= 8) { + + /* ignore extra bytes size bits */ + + formatMask = 3072; + } else { + formatMask = 3840; + } + behaviorFormatBits = ((longAt(((((char *) oopClass)) + 4) + (2 << 2))) - 1) & formatMask; + oopFormatBits = (longAt(oop)) & formatMask; + if (!(behaviorFormatBits == oopFormatBits)) { + error("object and its class (behavior) formats differ"); + } + return 1; +} + + +/* Note: May be called by translated primitive code. */ + +int pop(int nItems) { + stackPointer -= nItems * 4; +} + +int popthenPush(int nItems, int oop) { + int sp; + + longAtput(sp = stackPointer - ((nItems - 1) * 4), oop); + stackPointer = sp; +} + + +/* Note: May be called by translated primitive code. */ + +double popFloat(void) { + double result; + int top; + int top1; + int cl; + int ccIndex; + + /* begin popStack */ + top1 = longAt(stackPointer); + stackPointer -= 4; + top = top1; + /* begin assertClassOf:is: */ + if ((top & 1)) { + successFlag = 0; + goto l1; + } + ccIndex = (((unsigned) (longAt(top))) >> 12) & 31; + if (ccIndex == 0) { + cl = (longAt(top - 4)) & 4294967292U; + } else { + cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); + } + /* begin success: */ + successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)))) && successFlag; +l1: /* end assertClassOf:is: */; + if (successFlag) { + ; + fetchFloatAtinto(top + 4, result); + } + return result; +} + + +/* Pop and return the possibly remapped object from the remap buffer. */ + +int popRemappableOop(void) { + int oop; + + oop = remapBuffer[remapBufferCount]; + remapBufferCount -= 1; + return oop; +} + +int popStack(void) { + int top; + + top = longAt(stackPointer); + stackPointer -= 4; + return top; +} + + +/* Note - integerValue is interpreted as POSITIVE, eg, as the result of + Bitmap>at:, or integer>bitAnd:. */ + +int positive32BitIntegerFor(int integerValue) { + int newLargeInteger; + + if ((integerValue >= 0) && ((integerValue ^ (integerValue << 1)) >= 0)) { + return ((integerValue << 1) | 1); + } + newLargeInteger = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (13 << 2)), 8, 0); + byteAtput(((((char *) newLargeInteger)) + 4) + 3, (((unsigned) integerValue) >> 24) & 255); + byteAtput(((((char *) newLargeInteger)) + 4) + 2, (((unsigned) integerValue) >> 16) & 255); + byteAtput(((((char *) newLargeInteger)) + 4) + 1, (((unsigned) integerValue) >> 8) & 255); + byteAtput(((((char *) newLargeInteger)) + 4) + 0, integerValue & 255); + return newLargeInteger; +} + + +/* Convert the given object into an integer value. + The object may be either a positive ST integer or a four-byte LargePositiveInteger. */ + +int positive32BitValueOf(int oop) { + int value; + int sz; + int header; + int sz1; + int cl; + int ccIndex; + + if ((oop & 1)) { + value = (oop >> 1); + if (value < 0) { + /* begin primitiveFail */ + successFlag = 0; + return null; + } + return value; + } + /* begin assertClassOf:is: */ + if ((oop & 1)) { + successFlag = 0; + goto l2; + } + ccIndex = (((unsigned) (longAt(oop))) >> 12) & 31; + if (ccIndex == 0) { + cl = (longAt(oop - 4)) & 4294967292U; + } else { + cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); + } + /* begin success: */ + successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (13 << 2)))) && successFlag; +l2: /* end assertClassOf:is: */; + if (successFlag) { + /* begin lengthOf: */ + header = longAt(oop); + /* begin lengthOf:baseHeader:format: */ + if ((header & 3) == 0) { + sz1 = (longAt(oop - 8)) & 4294967292U; + } else { + sz1 = header & 252; + } + if (((((unsigned) header) >> 8) & 15) < 8) { + sz = ((unsigned) (sz1 - 4)) >> 2; + goto l1; + } else { + sz = (sz1 - 4) - (((((unsigned) header) >> 8) & 15) & 3); + goto l1; + } + sz = null; + l1: /* end lengthOf: */; + if (!(sz == 4)) { + /* begin primitiveFail */ + successFlag = 0; + return null; + } + } + if (successFlag) { + return (((byteAt(((((char *) oop)) + 4) + 0)) + ((byteAt(((((char *) oop)) + 4) + 1)) << 8)) + ((byteAt(((((char *) oop)) + 4) + 2)) << 16)) + ((byteAt(((((char *) oop)) + 4) + 3)) << 24); + } +} + + +/* Note - integerValue is interpreted as POSITIVE, eg, as the result of + Bitmap>at:, or integer>bitAnd:. */ + +int positive64BitIntegerFor(squeakInt64 integerValue) { + int i; + int check; + int value; + int newLargeInteger; + + if ((sizeof(integerValue)) == 4) { + return positive32BitIntegerFor(integerValue); + } + check = integerValue >> 32; + if (check == 0) { + return positive32BitIntegerFor(integerValue); + } + newLargeInteger = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (13 << 2)), 12, 0); + for (i = 0; i <= 7; i += 1) { + value = ( integerValue >> (i * 8)) & 255; + byteAtput(((((char *) newLargeInteger)) + 4) + i, value); + } + return newLargeInteger; +} + + +/* Convert the given object into an integer value. + The object may be either a positive ST integer or a eight-byte LargePositiveInteger. */ + +squeakInt64 positive64BitValueOf(int oop) { + int i; + squeakInt64 value; + int szsqueakInt64; + int sz; + int cl; + int ccIndex; + int header; + int sz1; + + if ((oop & 1)) { + value = (oop >> 1); + if (value < 0) { + /* begin primitiveFail */ + successFlag = 0; + return null; + } + return value; + } + /* begin assertClassOf:is: */ + if ((oop & 1)) { + successFlag = 0; + goto l1; + } + ccIndex = (((unsigned) (longAt(oop))) >> 12) & 31; + if (ccIndex == 0) { + cl = (longAt(oop - 4)) & 4294967292U; + } else { + cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); + } + /* begin success: */ + successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (13 << 2)))) && successFlag; +l1: /* end assertClassOf:is: */; + if (!(successFlag)) { + /* begin primitiveFail */ + successFlag = 0; + return null; + } + szsqueakInt64 = sizeof(squeakInt64); + /* begin lengthOf: */ + header = longAt(oop); + /* begin lengthOf:baseHeader:format: */ + if ((header & 3) == 0) { + sz1 = (longAt(oop - 8)) & 4294967292U; + } else { + sz1 = header & 252; + } + if (((((unsigned) header) >> 8) & 15) < 8) { + sz = ((unsigned) (sz1 - 4)) >> 2; + goto l2; + } else { + sz = (sz1 - 4) - (((((unsigned) header) >> 8) & 15) & 3); + goto l2; + } + sz = null; +l2: /* end lengthOf: */; + if (sz > szsqueakInt64) { + /* begin primitiveFail */ + successFlag = 0; + return null; + } + value = 0; + for (i = 0; i <= (sz - 1); i += 1) { + value += (((squeakInt64) (byteAt(((((char *) oop)) + 4) + i)))) << (i * 8); + } + return value; +} + + +/* oop is an old object. If valueObj is young, mark the object as a root. */ + +int possibleRootStoreIntovalue(int oop, int valueObj) { + int header; + + if ((valueObj >= youngStart) && (!((valueObj & 1)))) { + /* begin noteAsRoot:headerLoc: */ + header = longAt(oop); + if ((header & 1073741824) == 0) { + if (rootTableCount < 2500) { + rootTableCount += 1; + rootTable[rootTableCount] = oop; + longAtput(oop, header | 1073741824); + } + } + } +} + + +/* Ensure that there are enough forwarding blocks to accomodate this become, then prepare forwarding blocks for the pointer swap. Return true if successful. */ +/* Details: Doing a GC might generate enough space for forwarding blocks if we're short. However, this is an uncommon enough case that it is better handled by primitive fail code at the Smalltalk level. */ + +int prepareForwardingTableForBecomingwithtwoWay(int array1, int array2, int twoWayFlag) { + int entriesAvailable; + int fwdBlkSize; + int entriesNeeded; + int oop1; + int oop2; + int fwdBlock; + int fieldOffset; + int originalHeaderType; + int originalHeader; + int originalHeaderType1; + int originalHeader1; + int header; + int fmt; + int methodHeader; + int sz; + int header1; + int type; + + + /* need enough entries for all oops */ + + entriesNeeded = ((int) (lastPointerOf(array1)) >> 2); + if (twoWayFlag) { + entriesNeeded = entriesNeeded * 2; + + /* Note: Forward blocks must be quadword aligned. */ + + fwdBlkSize = 8; + } else { + + /* Note: Forward blocks must be quadword aligned. */ + + fwdBlkSize = 16; + } + entriesAvailable = fwdTableInit(fwdBlkSize); + if (entriesAvailable < entriesNeeded) { + initializeMemoryFirstFree(freeBlock); + return 0; + } + /* begin lastPointerOf: */ + header = longAt(array1); + fmt = (((unsigned) header) >> 8) & 15; + if (fmt <= 4) { + if ((fmt == 3) && (isContextHeader(header))) { + fieldOffset = (6 + (fetchStackPointerOf(array1))) * 4; + goto l3; + } + /* begin sizeBitsOfSafe: */ + header1 = longAt(array1); + /* begin rightType: */ + if ((header1 & 252) == 0) { + type = 0; + goto l4; + } else { + if ((header1 & 126976) == 0) { + type = 1; + goto l4; + } else { + type = 3; + goto l4; + } + } + l4: /* end rightType: */; + if (type == 0) { + sz = (longAt(array1 - 8)) & 4294967292U; + goto l5; + } else { + sz = header1 & 252; + goto l5; + } + l5: /* end sizeBitsOfSafe: */; + fieldOffset = sz - 4; + goto l3; + } + if (fmt < 12) { + fieldOffset = 0; + goto l3; + } + methodHeader = longAt(array1 + 4); + fieldOffset = (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; +l3: /* end lastPointerOf: */; + while (fieldOffset >= 4) { + oop1 = longAt(array1 + fieldOffset); + oop2 = longAt(array2 + fieldOffset); + /* begin fwdBlockGet: */ + fwdTableNext += fwdBlkSize; + if (fwdTableNext <= fwdTableLast) { + fwdBlock = fwdTableNext; + goto l2; + } else { + fwdBlock = null; + goto l2; + } + l2: /* end fwdBlockGet: */; + /* begin initForwardBlock:mapping:to:withBackPtr: */ + originalHeader1 = longAt(oop1); + ; + originalHeaderType1 = originalHeader1 & 3; + longAtput(fwdBlock, oop2); + longAtput(fwdBlock + 4, originalHeader1); + if (!twoWayFlag) { + longAtput(fwdBlock + 8, oop1); + } + longAtput(oop1, (((unsigned) fwdBlock) >> 1) | (2147483648U | originalHeaderType1)); + if (twoWayFlag) { + /* begin fwdBlockGet: */ + fwdTableNext += fwdBlkSize; + if (fwdTableNext <= fwdTableLast) { + fwdBlock = fwdTableNext; + goto l1; + } else { + fwdBlock = null; + goto l1; + } + l1: /* end fwdBlockGet: */; + /* begin initForwardBlock:mapping:to:withBackPtr: */ + originalHeader = longAt(oop2); + ; + originalHeaderType = originalHeader & 3; + longAtput(fwdBlock, oop1); + longAtput(fwdBlock + 4, originalHeader); + if (!twoWayFlag) { + longAtput(fwdBlock + 8, oop2); + } + longAtput(oop2, (((unsigned) fwdBlock) >> 1) | (2147483648U | originalHeaderType)); + } + fieldOffset -= 4; + } + return 1; +} + +int primitiveAdd(void) { + int integerResult; + int sp; + + /* begin pop2AndPushIntegerIfOK: */ + integerResult = (stackIntegerValue(1)) + (stackIntegerValue(0)); + if (successFlag) { + if ((integerResult ^ (integerResult << 1)) >= 0) { + /* begin pop:thenPush: */ + longAtput(sp = stackPointer - ((2 - 1) * 4), ((integerResult << 1) | 1)); + stackPointer = sp; + } else { + successFlag = 0; + } + } +} + +int primitiveArctan(void) { + double rcvr; + + rcvr = popFloat(); + if (successFlag) { + pushFloat(atan(rcvr)); + } else { + /* begin unPop: */ + stackPointer += 1 * 4; + } +} + + +/* We must flush the method cache here, to eliminate stale references + to mutated classes and/or selectors. */ + +int primitiveArrayBecome(void) { + int rcvr; + int arg; + int successValue; + + arg = longAt(stackPointer); + rcvr = longAt(stackPointer - (1 * 4)); + /* begin success: */ + successValue = becomewithtwoWay(rcvr, arg, 1); + successFlag = successValue && successFlag; + if (successFlag) { + /* begin pop: */ + stackPointer -= 1 * 4; + } +} + + +/* We must flush the method cache here, to eliminate stale references + to mutated classes and/or selectors. */ + +int primitiveArrayBecomeOneWay(void) { + int rcvr; + int arg; + int successValue; + + arg = longAt(stackPointer); + rcvr = longAt(stackPointer - (1 * 4)); + /* begin success: */ + successValue = becomewithtwoWay(rcvr, arg, 0); + successFlag = successValue && successFlag; + if (successFlag) { + /* begin pop: */ + stackPointer -= 1 * 4; + } +} + +int primitiveAsFloat(void) { + int arg; + int integerPointer; + int top; + + /* begin popInteger */ + /* begin popStack */ + top = longAt(stackPointer); + stackPointer -= 4; + integerPointer = top; + if ((integerPointer & 1)) { + arg = (integerPointer >> 1); + goto l1; + } else { + successFlag = 0; + arg = 1; + goto l1; + } +l1: /* end popInteger */; + if (successFlag) { + pushFloat(((double) arg)); + } else { + /* begin unPop: */ + stackPointer += 1 * 4; + } +} + +int primitiveAsOop(void) { + int thisReceiver; + int sp; + int top; + + /* begin popStack */ + top = longAt(stackPointer); + stackPointer -= 4; + thisReceiver = top; + /* begin success: */ + successFlag = (!((thisReceiver & 1))) && successFlag; + if (successFlag) { + /* begin pushInteger: */ + /* begin push: */ + longAtput(sp = stackPointer + 4, ((((((unsigned) (longAt(thisReceiver))) >> 17) & 4095) << 1) | 1)); + stackPointer = sp; + } else { + /* begin unPop: */ + stackPointer += 1 * 4; + } +} + +int primitiveAt(void) { + commonAt(0); +} + +int primitiveAtEnd(void) { + int limit; + int stream; + int index; + int sp; + int sp1; + int top; + + /* begin popStack */ + top = longAt(stackPointer); + stackPointer -= 4; + stream = top; + successFlag = (((((unsigned) (longAt(stream))) >> 8) & 15) <= 4) && ((lengthOf(stream)) >= (2 + 1)); + if (successFlag) { + index = fetchIntegerofObject(1, stream); + limit = fetchIntegerofObject(2, stream); + } + if (successFlag) { + /* begin pushBool: */ + if (index >= limit) { + /* begin push: */ + longAtput(sp = stackPointer + 4, trueObj); + stackPointer = sp; + } else { + /* begin push: */ + longAtput(sp1 = stackPointer + 4, falseObj); + stackPointer = sp1; + } + } else { + /* begin unPop: */ + stackPointer += 1 * 4; + } +} + +int primitiveAtPut(void) { + commonAtPut(0); +} + + +/* Set the cursor to the given shape. The Mac only supports 16x16 pixel cursors. Cursor offsets are handled by Smalltalk. */ + +int primitiveBeCursor(void) { + int maskBitsIndex; + int cursorObj; + int maskObj; + int i; + int bitsObj; + int ourCursor; + int extentX; + int offsetY; + int depth; + int cursorBitsIndex; + int offsetObj; + int offsetX; + int extentY; + int successValue; + int successValue1; + int successValue2; + int successValue3; + int successValue4; + int successValue5; + int successValue6; + int successValue7; + int successValue8; + + if (argumentCount == 0) { + cursorObj = longAt(stackPointer); + maskBitsIndex = null; + } + if (argumentCount == 1) { + cursorObj = longAt(stackPointer - (1 * 4)); + maskObj = longAt(stackPointer); + } + /* begin success: */ + successFlag = (argumentCount < 2) && successFlag; + /* begin success: */ + successValue7 = (((((unsigned) (longAt(cursorObj))) >> 8) & 15) <= 4) && ((lengthOf(cursorObj)) >= 5); + successFlag = successValue7 && successFlag; + if (successFlag) { + bitsObj = longAt(((((char *) cursorObj)) + 4) + (0 << 2)); + extentX = fetchIntegerofObject(1, cursorObj); + extentY = fetchIntegerofObject(2, cursorObj); + depth = fetchIntegerofObject(3, cursorObj); + offsetObj = longAt(((((char *) cursorObj)) + 4) + (4 << 2)); + } + /* begin success: */ + successValue8 = (((((unsigned) (longAt(offsetObj))) >> 8) & 15) <= 4) && ((lengthOf(offsetObj)) >= 2); + successFlag = successValue8 && successFlag; + if (successFlag) { + offsetX = fetchIntegerofObject(0, offsetObj); + offsetY = fetchIntegerofObject(1, offsetObj); + /* begin success: */ + successValue = (extentX == 16) && ((extentY == 16) && (depth == 1)); + successFlag = successValue && successFlag; + /* begin success: */ + successValue1 = (offsetX >= -16) && (offsetX <= 0); + successFlag = successValue1 && successFlag; + /* begin success: */ + successValue2 = (offsetY >= -16) && (offsetY <= 0); + successFlag = successValue2 && successFlag; + /* begin success: */ + successValue3 = (((((unsigned) (longAt(bitsObj))) >> 8) & 15) == 6) && ((lengthOf(bitsObj)) == 16); + successFlag = successValue3 && successFlag; + cursorBitsIndex = bitsObj + 4; + ; + } + if (argumentCount == 1) { + /* begin success: */ + successValue6 = (((((unsigned) (longAt(maskObj))) >> 8) & 15) <= 4) && ((lengthOf(maskObj)) >= 5); + successFlag = successValue6 && successFlag; + if (successFlag) { + bitsObj = longAt(((((char *) maskObj)) + 4) + (0 << 2)); + extentX = fetchIntegerofObject(1, maskObj); + extentY = fetchIntegerofObject(2, maskObj); + depth = fetchIntegerofObject(3, maskObj); + } + if (successFlag) { + /* begin success: */ + successValue4 = (extentX == 16) && ((extentY == 16) && (depth == 1)); + successFlag = successValue4 && successFlag; + /* begin success: */ + successValue5 = (((((unsigned) (longAt(bitsObj))) >> 8) & 15) == 6) && ((lengthOf(bitsObj)) == 16); + successFlag = successValue5 && successFlag; + maskBitsIndex = bitsObj + 4; + } + } + if (successFlag) { + if (argumentCount == 0) { + ioSetCursor(cursorBitsIndex, offsetX, offsetY); + } else { + ioSetCursorWithMask(cursorBitsIndex, maskBitsIndex, offsetX, offsetY); + } + /* begin pop: */ + stackPointer -= argumentCount * 4; + } +} + + +/* Record the system Display object. */ + +int primitiveBeDisplay(void) { + int rcvr; + int oop; + int successValue; + + rcvr = longAt(stackPointer); + /* begin success: */ + successValue = (((((unsigned) (longAt(rcvr))) >> 8) & 15) <= 4) && ((lengthOf(rcvr)) >= 4); + successFlag = successValue && successFlag; + if (successFlag) { + /* begin storePointer:ofObject:withValue: */ + oop = specialObjectsOop; + if (oop < youngStart) { + possibleRootStoreIntovalue(oop, rcvr); + } + longAtput(((((char *) oop)) + 4) + (14 << 2), rcvr); + } +} + +int primitiveBeep(void) { + ioBeep(); +} + +int primitiveBitAnd(void) { + int integerArgument; + int integerReceiver; + int object; + int sp; + int top; + int top1; + int top2; + int top11; + + /* begin popPos32BitInteger */ + /* begin popStack */ + top1 = longAt(stackPointer); + stackPointer -= 4; + top = top1; + integerArgument = positive32BitValueOf(top); + /* begin popPos32BitInteger */ + /* begin popStack */ + top11 = longAt(stackPointer); + stackPointer -= 4; + top2 = top11; + integerReceiver = positive32BitValueOf(top2); + if (successFlag) { + /* begin push: */ + object = positive32BitIntegerFor(integerReceiver & integerArgument); + longAtput(sp = stackPointer + 4, object); + stackPointer = sp; + } else { + /* begin unPop: */ + stackPointer += 2 * 4; + } +} + +int primitiveBitOr(void) { + int integerArgument; + int integerReceiver; + int object; + int sp; + int top; + int top1; + int top2; + int top11; + + /* begin popPos32BitInteger */ + /* begin popStack */ + top1 = longAt(stackPointer); + stackPointer -= 4; + top = top1; + integerArgument = positive32BitValueOf(top); + /* begin popPos32BitInteger */ + /* begin popStack */ + top11 = longAt(stackPointer); + stackPointer -= 4; + top2 = top11; + integerReceiver = positive32BitValueOf(top2); + if (successFlag) { + /* begin push: */ + object = positive32BitIntegerFor(integerReceiver | integerArgument); + longAtput(sp = stackPointer + 4, object); + stackPointer = sp; + } else { + /* begin unPop: */ + stackPointer += 2 * 4; + } +} + +int primitiveBitShift(void) { + int shifted; + int integerArgument; + int integerReceiver; + int integerPointer; + int object; + int sp; + int top; + int top2; + int top1; + + /* begin popInteger */ + /* begin popStack */ + top = longAt(stackPointer); + stackPointer -= 4; + integerPointer = top; + if ((integerPointer & 1)) { + integerArgument = (integerPointer >> 1); + goto l1; + } else { + successFlag = 0; + integerArgument = 1; + goto l1; + } +l1: /* end popInteger */; + /* begin popPos32BitInteger */ + /* begin popStack */ + top1 = longAt(stackPointer); + stackPointer -= 4; + top2 = top1; + integerReceiver = positive32BitValueOf(top2); + if (successFlag) { + if (integerArgument >= 0) { + /* begin success: */ + successFlag = (integerArgument <= 31) && successFlag; + shifted = integerReceiver << integerArgument; + /* begin success: */ + successFlag = ((((unsigned) shifted) >> integerArgument) == integerReceiver) && successFlag; + } else { + /* begin success: */ + successFlag = (integerArgument >= -31) && successFlag; + shifted = ((integerArgument < 0) ? ((unsigned) integerReceiver >> -integerArgument) : ((unsigned) integerReceiver << integerArgument)); + } + } + if (successFlag) { + /* begin push: */ + object = positive32BitIntegerFor(shifted); + longAtput(sp = stackPointer + 4, object); + stackPointer = sp; + } else { + /* begin unPop: */ + stackPointer += 2 * 4; + } +} + +int primitiveBitXor(void) { + int integerArgument; + int integerReceiver; + int object; + int sp; + int top; + int top1; + int top2; + int top11; + + /* begin popPos32BitInteger */ + /* begin popStack */ + top1 = longAt(stackPointer); + stackPointer -= 4; + top = top1; + integerArgument = positive32BitValueOf(top); + /* begin popPos32BitInteger */ + /* begin popStack */ + top11 = longAt(stackPointer); + stackPointer -= 4; + top2 = top11; + integerReceiver = positive32BitValueOf(top2); + if (successFlag) { + /* begin push: */ + object = positive32BitIntegerFor(integerReceiver ^ integerArgument); + longAtput(sp = stackPointer + 4, object); + stackPointer = sp; + } else { + /* begin unPop: */ + stackPointer += 2 * 4; + } +} + +int primitiveBlockCopy(void) { + int methodContext; + int context; + int contextSize; + int newContext; + int initialIP; + int header; + int oop; + int sp; + + context = longAt(stackPointer - (1 * 4)); + if (((longAt(((((char *) context)) + 4) + (3 << 2))) & 1)) { + methodContext = longAt(((((char *) context)) + 4) + (5 << 2)); + } else { + methodContext = context; + } + /* begin sizeBitsOf: */ + header = longAt(methodContext); + if ((header & 3) == 0) { + contextSize = (longAt(methodContext - 8)) & 4294967292U; + goto l1; + } else { + contextSize = header & 252; + goto l1; + } +l1: /* end sizeBitsOf: */; + + /* context is no longer needed and is not preserved across allocation */ + /* remap methodContext in case GC happens during allocation */ + + context = null; + /* begin pushRemappableOop: */ + remapBuffer[remapBufferCount += 1] = methodContext; + newContext = instantiateContextsizeInBytes(longAt(((((char *) specialObjectsOop)) + 4) + (11 << 2)), contextSize); + /* begin popRemappableOop */ + oop = remapBuffer[remapBufferCount]; + remapBufferCount -= 1; + methodContext = oop; + + /* Was instructionPointer + 3, but now it's greater by + methodOop + 4 (headerSize) and less by 1 due to preIncrement */ + /* Assume: have just allocated a new context; it must be young. + Thus, can use uncheck stores. See the comment in fetchContextRegisters. */ + + initialIP = (((instructionPointer - method) << 1) | 1); + longAtput(((((char *) newContext)) + 4) + (4 << 2), initialIP); + longAtput(((((char *) newContext)) + 4) + (1 << 2), initialIP); + /* begin storeStackPointerValue:inContext: */ + longAtput(((((char *) newContext)) + 4) + (2 << 2), ((0 << 1) | 1)); + longAtput(((((char *) newContext)) + 4) + (3 << 2), longAt(stackPointer - (0 * 4))); + longAtput(((((char *) newContext)) + 4) + (5 << 2), methodContext); + longAtput(((((char *) newContext)) + 4) + (0 << 2), nilObj); + /* begin pop:thenPush: */ + longAtput(sp = stackPointer - ((2 - 1) * 4), newContext); + stackPointer = sp; +} + + +/* Reports bytes available at this moment. For more meaningful results, calls to this primitive should be preceeded by a full or incremental garbage collection. */ + +int primitiveBytesLeft(void) { + int aBool; + int sp; + int integerValue; + int sp1; + + if (argumentCount == 0) { + /* begin pop: */ + stackPointer -= 1 * 4; + /* begin pushInteger: */ + /* begin push: */ + longAtput(sp = stackPointer + 4, ((((longAt(freeBlock)) & 4294967292U) << 1) | 1)); + stackPointer = sp; + return null; + } + if (argumentCount == 1) { + /* begin booleanValueOf: */ + if ((longAt(stackPointer)) == trueObj) { + aBool = 1; + goto l1; + } + if ((longAt(stackPointer)) == falseObj) { + aBool = 0; + goto l1; + } + successFlag = 0; + aBool = null; + l1: /* end booleanValueOf: */; + if (!(successFlag)) { + return null; + } + /* begin pop: */ + stackPointer -= 2 * 4; + /* begin pushInteger: */ + integerValue = ((longAt(freeBlock)) & 4294967292U) + (sqMemoryExtraBytesLeft(aBool)); + /* begin push: */ + longAtput(sp1 = stackPointer + 4, ((integerValue << 1) | 1)); + stackPointer = sp1; + return null; + } + /* begin primitiveFail */ + successFlag = 0; + return null; +} + + +/* Perform a function call to a foreign function. + Only invoked from method containing explicit external call spec. + Due to this we use the pluggable prim mechanism explicitly here + (the first literal of any FFI spec'ed method is an ExternalFunction + and not an array as used in the pluggable primitive mechanism). */ + +int primitiveCalloutToFFI(void) { + static char *moduleName = "SqueakFFIPrims"; + static char *functionName = "primitiveCallout"; + static int function = 0; + + if (function == 0) { + function = ioLoadExternalFunctionOfLengthFromModuleOfLength(((int) functionName), 16, ((int) moduleName), 14); + if (function == 0) { + /* begin primitiveFail */ + successFlag = 0; + return null; + } + } + return ((int (*) (void)) function) (); +} + + +/* Primitive. Change the class of the receiver into the class of the argument given that the format of the receiver matches the format of the argument's class. Fail if receiver or argument are SmallIntegers, or the receiver is an instance of a compact class and the argument isn't, or when the argument's class is compact and the receiver isn't, or when the format of the receiver is different from the format of the argument's class, or when the arguments class is fixed and the receiver's size differs from the size that an instance of the argument's class should have. */ + +int primitiveChangeClass(void) { + int byteSize; + int classHdr; + int rcvrFormat; + int rcvr; + int sizeHiBits; + int argClass; + int argFormat; + int ccIndex; + int arg; + int oop; + int oop1; + int i; + int ccIndex1; + + /* begin stackObjectValue: */ + oop = longAt(stackPointer - (0 * 4)); + if ((oop & 1)) { + /* begin primitiveFail */ + successFlag = 0; + arg = null; + goto l1; + } + arg = oop; +l1: /* end stackObjectValue: */; + /* begin stackObjectValue: */ + oop1 = longAt(stackPointer - (1 * 4)); + if ((oop1 & 1)) { + /* begin primitiveFail */ + successFlag = 0; + rcvr = null; + goto l2; + } + rcvr = oop1; +l2: /* end stackObjectValue: */; + if (!(successFlag)) { + return null; + } + /* begin fetchClassOf: */ + if ((arg & 1)) { + argClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); + goto l3; + } + ccIndex1 = (((unsigned) (longAt(arg))) >> 12) & 31; + if (ccIndex1 == 0) { + argClass = (longAt(arg - 4)) & 4294967292U; + goto l3; + } else { + argClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex1 - 1) << 2)); + goto l3; + } +l3: /* end fetchClassOf: */; + + /* Low 2 bits are 0 */ + /* Compute the size of instances of the class (used for fixed field classes only) */ + + classHdr = (longAt(((((char *) argClass)) + 4) + (2 << 2))) - 1; + sizeHiBits = ((unsigned) (classHdr & 393216)) >> 9; + classHdr = classHdr & 131071; + + /* size in bytes -- low 2 bits are 0 */ + /* Check the receiver's format against that of the class */ + + byteSize = (classHdr & 252) + sizeHiBits; + argFormat = (((unsigned) classHdr) >> 8) & 15; + rcvrFormat = (((unsigned) (longAt(rcvr))) >> 8) & 15; + if (!(argFormat == rcvrFormat)) { + /* begin success: */ + successFlag = 0 && successFlag; + return null; + } + if (argFormat < 2) { + if (!((byteSize - 4) == (byteSizeOf(rcvr)))) { + /* begin success: */ + successFlag = 0 && successFlag; + return null; + } + } + if (((longAt(rcvr)) & 3) == 3) { + ccIndex = classHdr & 126976; + if (ccIndex == 0) { + /* begin success: */ + successFlag = 0 && successFlag; + return null; + } + longAtput(rcvr, ((longAt(rcvr)) & (~126976)) | ccIndex); + } else { + longAtput(rcvr - 4, argClass | ((longAt(rcvr)) & 3)); + if (rcvr < youngStart) { + possibleRootStoreIntovalue(rcvr, argClass); + } + } + /* begin flushMethodCache */ + for (i = 1; i <= 4096; i += 1) { + methodCache[i] = 0; + } + for (i = 1; i <= 64; i += 1) { + atCache[i] = 0; + } + if (successFlag) { + /* begin pop: */ + stackPointer -= 1 * 4; + } +} + +int primitiveClass(void) { + int instance; + int top; + int object; + int sp; + int ccIndex; + + /* begin popStack */ + top = longAt(stackPointer); + stackPointer -= 4; + instance = top; + /* begin push: */ + /* begin fetchClassOf: */ + if ((instance & 1)) { + object = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); + goto l1; + } + ccIndex = (((unsigned) (longAt(instance))) >> 12) & 31; + if (ccIndex == 0) { + object = (longAt(instance - 4)) & 4294967292U; + goto l1; + } else { + object = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); + goto l1; + } +l1: /* end fetchClassOf: */; + longAtput(sp = stackPointer + 4, object); + stackPointer = sp; +} + + +/* When called with a single string argument, post the string to the clipboard. When called with zero arguments, return a string containing the current clipboard contents. */ + +int primitiveClipboardText(void) { + int s; + int sz; + int sp; + int cl; + int ccIndex; + int hdr; + int totalLength; + int fixedFields; + int fmt; + int sp1; + int sz1; + int classFormat; + int class; + int ccIndex1; + + if (argumentCount == 1) { + s = longAt(stackPointer); + /* begin assertClassOf:is: */ + if ((s & 1)) { + successFlag = 0; + goto l1; + } + ccIndex = (((unsigned) (longAt(s))) >> 12) & 31; + if (ccIndex == 0) { + cl = (longAt(s - 4)) & 4294967292U; + } else { + cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); + } + /* begin success: */ + successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)))) && successFlag; + l1: /* end assertClassOf:is: */; + if (successFlag) { + /* begin stSizeOf: */ + hdr = longAt(s); + fmt = (((unsigned) hdr) >> 8) & 15; + /* begin lengthOf:baseHeader:format: */ + if ((hdr & 3) == 0) { + sz1 = (longAt(s - 8)) & 4294967292U; + } else { + sz1 = hdr & 252; + } + if (fmt < 8) { + totalLength = ((unsigned) (sz1 - 4)) >> 2; + goto l4; + } else { + totalLength = (sz1 - 4) - (fmt & 3); + goto l4; + } + l4: /* end lengthOf:baseHeader:format: */; + /* begin fixedFieldsOf:format:length: */ + if ((fmt > 4) || (fmt == 2)) { + fixedFields = 0; + goto l2; + } + if (fmt < 2) { + fixedFields = totalLength; + goto l2; + } + /* begin fetchClassOf: */ + if ((s & 1)) { + class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); + goto l3; + } + ccIndex1 = (((unsigned) (longAt(s))) >> 12) & 31; + if (ccIndex1 == 0) { + class = (longAt(s - 4)) & 4294967292U; + goto l3; + } else { + class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex1 - 1) << 2)); + goto l3; + } + l3: /* end fetchClassOf: */; + classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; + fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; + l2: /* end fixedFieldsOf:format:length: */; + if ((fmt == 3) && (isContextHeader(hdr))) { + /* begin fetchStackPointerOf: */ + sp1 = longAt(((((char *) s)) + 4) + (2 << 2)); + if (!((sp1 & 1))) { + sz = 0; + goto l5; + } + sz = (sp1 >> 1); + goto l5; + } else { + sz = totalLength - fixedFields; + goto l5; + } + l5: /* end stSizeOf: */; + clipboardWriteFromAt(sz, s + 4, 0); + /* begin pop: */ + stackPointer -= 1 * 4; + } + } else { + sz = clipboardSize(); + s = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)), sz); + clipboardReadIntoAt(sz, s + 4, 0); + /* begin pop: */ + stackPointer -= 1 * 4; + /* begin push: */ + longAtput(sp = stackPointer + 4, s); + stackPointer = sp; + } +} + + +/* Return a shallow copy of the receiver. */ + +int primitiveClone(void) { + int newCopy; + int sp; + + newCopy = clone(longAt(stackPointer)); + /* begin pop:thenPush: */ + longAtput(sp = stackPointer - ((1 - 1) * 4), newCopy); + stackPointer = sp; +} + + +/* Fill the receiver, which must be an indexable bytes or words objects, with the given integer value. */ + +int primitiveConstantFill(void) { + int rcvrIsBytes; + int fillValue; + int i; + int end; + int rcvr; + int successValue; + int successValue1; + int fmt; + + fillValue = positive32BitValueOf(longAt(stackPointer)); + rcvr = longAt(stackPointer - (1 * 4)); + /* begin success: */ + /* begin isWordsOrBytes: */ + fmt = (((unsigned) (longAt(rcvr))) >> 8) & 15; + successValue1 = (fmt == 6) || ((fmt >= 8) && (fmt <= 11)); + successFlag = successValue1 && successFlag; + rcvrIsBytes = ((((unsigned) (longAt(rcvr))) >> 8) & 15) >= 8; + if (rcvrIsBytes) { + /* begin success: */ + successValue = (fillValue >= 0) && (fillValue <= 255); + successFlag = successValue && successFlag; + } + if (successFlag) { + end = rcvr + (sizeBitsOf(rcvr)); + i = rcvr + 4; + if (rcvrIsBytes) { + while (i < end) { + byteAtput(i, fillValue); + i += 1; + } + } else { + while (i < end) { + longAtput(i, fillValue); + i += 4; + } + } + /* begin pop: */ + stackPointer -= 1 * 4; + } +} + + +/* Set or clear the flag that controls whether modifications of the Display object are propagated to the underlying platform's screen. */ + +int primitiveDeferDisplayUpdates(void) { + int flag; + + flag = longAt(stackPointer); + if (flag == trueObj) { + deferDisplayUpdates = 1; + } else { + if (flag == falseObj) { + deferDisplayUpdates = 0; + } else { + /* begin primitiveFail */ + successFlag = 0; + } + } + if (successFlag) { + /* begin pop: */ + stackPointer -= 1 * 4; + } +} + + +/* Pass in a non-negative value to disable the architectures powermanager if any, zero to enable */ + +EXPORT(int) primitiveDisablePowerManager(void) { + int integer; + int integerPointer; + + /* begin stackIntegerValue: */ + integerPointer = longAt(stackPointer - (0 * 4)); + if ((integerPointer & 1)) { + integer = (integerPointer >> 1); + goto l1; + } else { + /* begin primitiveFail */ + successFlag = 0; + integer = 0; + goto l1; + } +l1: /* end stackIntegerValue: */; + if (successFlag) { + ioDisablePowerManager(integer); + /* begin pop: */ + stackPointer -= 1 * 4; + } +} + +int primitiveDiv(void) { + int quotient; + int sp; + + quotient = doPrimitiveDivby(longAt(stackPointer - (1 * 4)), longAt(stackPointer - (0 * 4))); + /* begin pop2AndPushIntegerIfOK: */ + if (successFlag) { + if ((quotient ^ (quotient << 1)) >= 0) { + /* begin pop:thenPush: */ + longAtput(sp = stackPointer - ((2 - 1) * 4), ((quotient << 1) | 1)); + stackPointer = sp; + } else { + successFlag = 0; + } + } +} + +int primitiveDivide(void) { + int integerArgument; + int integerReceiver; + int integerPointer; + int integerPointer1; + int sp; + + /* begin stackIntegerValue: */ + integerPointer = longAt(stackPointer - (1 * 4)); + if ((integerPointer & 1)) { + integerReceiver = (integerPointer >> 1); + goto l1; + } else { + /* begin primitiveFail */ + successFlag = 0; + integerReceiver = 0; + goto l1; + } +l1: /* end stackIntegerValue: */; + /* begin stackIntegerValue: */ + integerPointer1 = longAt(stackPointer - (0 * 4)); + if ((integerPointer1 & 1)) { + integerArgument = (integerPointer1 >> 1); + goto l2; + } else { + /* begin primitiveFail */ + successFlag = 0; + integerArgument = 0; + goto l2; + } +l2: /* end stackIntegerValue: */; + if ((integerArgument != 0) && ((integerReceiver % integerArgument) == 0)) { + /* begin pop2AndPushIntegerIfOK: */ + if (successFlag) { + if (((integerReceiver / integerArgument) ^ ((integerReceiver / integerArgument) << 1)) >= 0) { + /* begin pop:thenPush: */ + longAtput(sp = stackPointer - ((2 - 1) * 4), (((integerReceiver / integerArgument) << 1) | 1)); + stackPointer = sp; + } else { + successFlag = 0; + } + } + } else { + /* begin primitiveFail */ + successFlag = 0; + } +} + +int primitiveDoPrimitiveWithArgs(void) { + int argumentArray; + int arraySize; + int cntxSize; + int primIdx; + int index; + int sp; + int sp1; + int sp2; + int sz; + int objectPointer; + int sz1; + int integerPointer; + int oop; + int header; + int header1; + int cl; + int ccIndex; + + argumentArray = longAt(stackPointer); + /* begin fetchWordLengthOf: */ + /* begin sizeBitsOf: */ + header = longAt(argumentArray); + if ((header & 3) == 0) { + sz = (longAt(argumentArray - 8)) & 4294967292U; + goto l2; + } else { + sz = header & 252; + goto l2; + } +l2: /* end sizeBitsOf: */; + arraySize = ((unsigned) (sz - 4)) >> 2; + /* begin fetchWordLengthOf: */ + objectPointer = activeContext; + /* begin sizeBitsOf: */ + header1 = longAt(objectPointer); + if ((header1 & 3) == 0) { + sz1 = (longAt(objectPointer - 8)) & 4294967292U; + goto l3; + } else { + sz1 = header1 & 252; + goto l3; + } +l3: /* end sizeBitsOf: */; + cntxSize = ((unsigned) (sz1 - 4)) >> 2; + /* begin success: */ + successFlag = (((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) + arraySize) < cntxSize) && successFlag; + /* begin assertClassOf:is: */ + if ((argumentArray & 1)) { + successFlag = 0; + goto l4; + } + ccIndex = (((unsigned) (longAt(argumentArray))) >> 12) & 31; + if (ccIndex == 0) { + cl = (longAt(argumentArray - 4)) & 4294967292U; + } else { + cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); + } + /* begin success: */ + successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)))) && successFlag; +l4: /* end assertClassOf:is: */; + /* begin stackIntegerValue: */ + integerPointer = longAt(stackPointer - (1 * 4)); + if ((integerPointer & 1)) { + primIdx = (integerPointer >> 1); + goto l1; + } else { + /* begin primitiveFail */ + successFlag = 0; + primIdx = 0; + goto l1; + } +l1: /* end stackIntegerValue: */; + if (!(successFlag)) { + /* begin primitiveFail */ + successFlag = 0; + return null; + } + /* begin pop: */ + stackPointer -= 2 * 4; + primitiveIndex = primIdx; + argumentCount = arraySize; + index = 1; + while (index <= argumentCount) { + /* begin push: */ + longAtput(sp = stackPointer + 4, longAt(((((char *) argumentArray)) + 4) + ((index - 1) << 2))); + stackPointer = sp; + index += 1; + } + /* begin pushRemappableOop: */ + remapBuffer[remapBufferCount += 1] = argumentArray; + lkupClass = nilObj; + primitiveResponse(); + /* begin popRemappableOop */ + oop = remapBuffer[remapBufferCount]; + remapBufferCount -= 1; + argumentArray = oop; + if (!(successFlag)) { + /* begin pop: */ + stackPointer -= arraySize * 4; + /* begin pushInteger: */ + /* begin push: */ + longAtput(sp1 = stackPointer + 4, ((primIdx << 1) | 1)); + stackPointer = sp1; + /* begin push: */ + longAtput(sp2 = stackPointer + 4, argumentArray); + stackPointer = sp2; + argumentCount = 2; + } +} + +int primitiveEqual(void) { + int result; + int integerArgument; + int integerReceiver; + int top; + int top1; + int sp; + int sp1; + + /* begin popStack */ + top = longAt(stackPointer); + stackPointer -= 4; + integerArgument = top; + /* begin popStack */ + top1 = longAt(stackPointer); + stackPointer -= 4; + integerReceiver = top1; + /* begin compare31or32Bits:equal: */ + if (((integerReceiver & 1)) && ((integerArgument & 1))) { + result = integerReceiver == integerArgument; + goto l1; + } + result = (positive32BitValueOf(integerReceiver)) == (positive32BitValueOf(integerArgument)); +l1: /* end compare31or32Bits:equal: */; + /* begin checkBooleanResult: */ + if (successFlag) { + /* begin pushBool: */ + if (result) { + /* begin push: */ + longAtput(sp = stackPointer + 4, trueObj); + stackPointer = sp; + } else { + /* begin push: */ + longAtput(sp1 = stackPointer + 4, falseObj); + stackPointer = sp1; + } + } else { + /* begin unPop: */ + stackPointer += 2 * 4; + } +} + +int primitiveEquivalent(void) { + int otherObject; + int thisObject; + int top; + int top1; + int sp; + int sp1; + + /* begin popStack */ + top = longAt(stackPointer); + stackPointer -= 4; + otherObject = top; + /* begin popStack */ + top1 = longAt(stackPointer); + stackPointer -= 4; + thisObject = top1; + /* begin pushBool: */ + if (thisObject == otherObject) { + /* begin push: */ + longAtput(sp = stackPointer + 4, trueObj); + stackPointer = sp; + } else { + /* begin push: */ + longAtput(sp1 = stackPointer + 4, falseObj); + stackPointer = sp1; + } +} + +int primitiveExitToDebugger(void) { + error("Exit to debugger at user request"); +} + + +/* Computes E raised to the receiver power. */ + +int primitiveExp(void) { + double rcvr; + + rcvr = popFloat(); + if (successFlag) { + pushFloat(exp(rcvr)); + } else { + /* begin unPop: */ + stackPointer += 1 * 4; + } +} + + +/* Exponent part of this float. */ + +int primitiveExponent(void) { + double frac; + double rcvr; + int pwr; + int sp; + + rcvr = popFloat(); + if (successFlag) { + frac = frexp(rcvr, &pwr); + /* begin pushInteger: */ + /* begin push: */ + longAtput(sp = stackPointer + 4, (((pwr - 1) << 1) | 1)); + stackPointer = sp; + } else { + /* begin unPop: */ + stackPointer += 1 * 4; + } +} + + +/* Call an external primitive. The external primitive methods contain as first literal an array consisting of: + * The module name (String | Symbol) + * The function name (String | Symbol) + * The session ID (SmallInteger) [OBSOLETE] + * The function index (Integer) in the externalPrimitiveTable + For fast failures the primitive index of any method where the external prim is not found is rewritten in the method cache with zero. This allows for ultra fast responses as long as the method stays in the cache. + The fast failure response relies on lkupClass being properly set. This is done in #addToMethodCacheSel:class:method:primIndex: to compensate for execution of methods that are looked up in a superclass (such as in primitivePerformAt). + With the latest modifications (e.g., actually flushing the function addresses from the VM), the session ID is obsolete. But for backward compatibility it is still kept around. Also, a failed lookup is reported specially. If a method has been looked up and not been found, the function address is stored as -1 (e.g., the SmallInteger -1 to distinguish from 16rFFFFFFFF which may be returned from the lookup). + It is absolutely okay to remove the rewrite if we run into any problems later on. It has an approximate speed difference of 30% per failed primitive call which may be noticable but if, for any reasons, we run into problems (like with J3) we can always remove the rewrite. + */ + +int primitiveExternalCall(void) { + int moduleLength; + int delta; + int lit; + int moduleName; + int index; + int functionName; + int addr; + int functionLength; + int nArgs; + int header; + int sz; + int i; + int successValue; + int header1; + int sz1; + + ; + /* begin success: */ + successFlag = (((((unsigned) (longAt(((((char *) newMethod)) + 4) + (0 << 2)))) >> 10) & 255) > 0) && successFlag; + if (!(successFlag)) { + return null; + } + + /* Check if it's an array of length 4 */ + + lit = longAt(((((char *) newMethod)) + 4) + ((0 + 1) << 2)); + /* begin success: */ + successValue = ((fetchClassOf(lit)) == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)))) && ((lengthOf(lit)) == 4); + successFlag = successValue && successFlag; + if (!(successFlag)) { + return null; + } + index = longAt(((((char *) lit)) + 4) + (3 << 2)); + if (!((index & 1))) { + /* begin success: */ + successFlag = 0 && successFlag; + return null; + } + + /* Check if we have already looked up the function and failed. */ + + index = (index >> 1); + if (index < 0) { + rewriteMethodCacheSelclassprimIndex(messageSelector, lkupClass, 0); + /* begin success: */ + successFlag = 0 && successFlag; + return null; + } + if ((index > 0) && (index <= 4096)) { + addr = externalPrimitiveTable[index - 1]; + if (addr != 0) { + ((int (*) (void)) addr) (); + ; + return null; + } + /* begin success: */ + successFlag = 0 && successFlag; + return null; + } + /* begin storeInteger:ofObject:withValue: */ + if ((0 ^ (0 << 1)) >= 0) { + longAtput(((((char *) lit)) + 4) + (2 << 2), ((0 << 1) | 1)); + } else { + /* begin primitiveFail */ + successFlag = 0; + } + /* begin storeInteger:ofObject:withValue: */ + if ((0 ^ (0 << 1)) >= 0) { + longAtput(((((char *) lit)) + 4) + (3 << 2), ((0 << 1) | 1)); + } else { + /* begin primitiveFail */ + successFlag = 0; + } + moduleName = longAt(((((char *) lit)) + 4) + (0 << 2)); + if (moduleName == nilObj) { + moduleLength = 0; + } else { + /* begin success: */ + successFlag = (((((unsigned) (longAt(moduleName))) >> 8) & 15) >= 8) && successFlag; + /* begin lengthOf: */ + header = longAt(moduleName); + /* begin lengthOf:baseHeader:format: */ + if ((header & 3) == 0) { + sz = (longAt(moduleName - 8)) & 4294967292U; + } else { + sz = header & 252; + } + if (((((unsigned) header) >> 8) & 15) < 8) { + moduleLength = ((unsigned) (sz - 4)) >> 2; + goto l1; + } else { + moduleLength = (sz - 4) - (((((unsigned) header) >> 8) & 15) & 3); + goto l1; + } + moduleLength = null; + l1: /* end lengthOf: */; + } + functionName = longAt(((((char *) lit)) + 4) + (1 << 2)); + /* begin success: */ + successFlag = (((((unsigned) (longAt(functionName))) >> 8) & 15) >= 8) && successFlag; + /* begin lengthOf: */ + header1 = longAt(functionName); + /* begin lengthOf:baseHeader:format: */ + if ((header1 & 3) == 0) { + sz1 = (longAt(functionName - 8)) & 4294967292U; + } else { + sz1 = header1 & 252; + } + if (((((unsigned) header1) >> 8) & 15) < 8) { + functionLength = ((unsigned) (sz1 - 4)) >> 2; + goto l3; + } else { + functionLength = (sz1 - 4) - (((((unsigned) header1) >> 8) & 15) & 3); + goto l3; + } + functionLength = null; +l3: /* end lengthOf: */; + if (!(successFlag)) { + return null; + } + + /* Addr ~= 0 indicates we have a compat match later */ + + addr = 0; + if (moduleLength == 0) { + + /* The returned value is the index into the obsolete primitive table. + If the index is found, use the 'C-style' version of the lookup. */ + + index = findObsoleteNamedPrimitivelength(((char *) (functionName + 4)), functionLength); + if (!(index < 0)) { + addr = ioLoadFunctionFrom(((char*) ((obsoleteNamedPrimitiveTable[index])[2])), ((char*) ((obsoleteNamedPrimitiveTable[index])[1]))); + } + } + if (addr == 0) { + addr = ioLoadExternalFunctionOfLengthFromModuleOfLength(functionName + 4, functionLength, moduleName + 4, moduleLength); + } + if (addr == 0) { + index = -1; + } else { + /* begin addToExternalPrimitiveTable: */ + for (i = 0; i <= (4096 - 1); i += 1) { + if ((externalPrimitiveTable[i]) == 0) { + externalPrimitiveTable[i] = addr; + index = i + 1; + goto l2; + } + } + index = 0; + l2: /* end addToExternalPrimitiveTable: */; + } + /* begin success: */ + successFlag = (index >= 0) && successFlag; + /* begin storePointer:ofObject:withValue: */ + if (lit < youngStart) { + possibleRootStoreIntovalue(lit, ((index << 1) | 1)); + } + longAtput(((((char *) lit)) + 4) + (3 << 2), ((index << 1) | 1)); + if (successFlag && (addr != 0)) { + ((int (*) (void)) addr) (); + ; + } else { + rewriteMethodCacheSelclassprimIndex(messageSelector, lkupClass, 0); + } +} + +int primitiveFail(void) { + successFlag = 0; +} + + +/* Primitive. Search up the context stack for the next method context marked for exception handling starting at the receiver. Return nil if none found */ + +int primitiveFindHandlerContext(void) { + int thisCntx; + int nilOop; + int sp; + int top; + int sp1; + + /* begin popStack */ + top = longAt(stackPointer); + stackPointer -= 4; + thisCntx = top; + nilOop = nilObj; + do { + if (isHandlerMarked(thisCntx)) { + /* begin push: */ + longAtput(sp = stackPointer + 4, thisCntx); + stackPointer = sp; + return null; + } + thisCntx = longAt(((((char *) thisCntx)) + 4) + (0 << 2)); + } while(!(thisCntx == nilOop)); + /* begin push: */ + longAtput(sp1 = stackPointer + 4, nilObj); + stackPointer = sp1; + return null; +} + + +/* Primitive. Search up the context stack for the next method context marked for unwind handling from the receiver up to but not including the argument. Return nil if none found. */ + +int primitiveFindNextUnwindContext(void) { + int aContext; + int thisCntx; + int nilOop; + int sp; + int top; + int oop; + int sp1; + int top1; + + /* begin popStack */ + top = longAt(stackPointer); + stackPointer -= 4; + aContext = top; + /* begin fetchPointer:ofObject: */ + /* begin popStack */ + top1 = longAt(stackPointer); + stackPointer -= 4; + oop = top1; + thisCntx = longAt(((((char *) oop)) + 4) + (0 << 2)); + nilOop = nilObj; + while (!((thisCntx == aContext) || (thisCntx == nilOop))) { + if (isUnwindMarked(thisCntx)) { + /* begin push: */ + longAtput(sp = stackPointer + 4, thisCntx); + stackPointer = sp; + return null; + } + thisCntx = longAt(((((char *) thisCntx)) + 4) + (0 << 2)); + } + /* begin push: */ + longAtput(sp1 = stackPointer + 4, nilOop); + stackPointer = sp1; + return null; +} + +int primitiveFloatAdd(void) { + return primitiveFloatAddtoArg(longAt(stackPointer - (1 * 4)), longAt(stackPointer)); +} + +int primitiveFloatAddtoArg(int rcvrOop, int argOop) { + double rcvr; + double arg; + + rcvr = loadFloatOrIntFrom(rcvrOop); + arg = loadFloatOrIntFrom(argOop); + if (successFlag) { + /* begin pop: */ + stackPointer -= 2 * 4; + pushFloat(rcvr + arg); + } +} + +int primitiveFloatDivide(void) { + return primitiveFloatDividebyArg(longAt(stackPointer - (1 * 4)), longAt(stackPointer)); +} + +int primitiveFloatDividebyArg(int rcvrOop, int argOop) { + double rcvr; + double arg; + + rcvr = loadFloatOrIntFrom(rcvrOop); + arg = loadFloatOrIntFrom(argOop); + if (successFlag) { + /* begin success: */ + successFlag = (arg != 0.0) && successFlag; + if (successFlag) { + /* begin pop: */ + stackPointer -= 2 * 4; + pushFloat(rcvr / arg); + } + } +} + +int primitiveFloatEqual(void) { + int bool; + int sp; + int sp1; + + bool = primitiveFloatEqualtoArg(longAt(stackPointer - (1 * 4)), longAt(stackPointer)); + if (successFlag) { + /* begin pop: */ + stackPointer -= 2 * 4; + /* begin pushBool: */ + if (bool) { + /* begin push: */ + longAtput(sp = stackPointer + 4, trueObj); + stackPointer = sp; + } else { + /* begin push: */ + longAtput(sp1 = stackPointer + 4, falseObj); + stackPointer = sp1; + } + } +} + +int primitiveFloatEqualtoArg(int rcvrOop, int argOop) { + double rcvr; + double arg; + + rcvr = loadFloatOrIntFrom(rcvrOop); + arg = loadFloatOrIntFrom(argOop); + if (successFlag) { + return rcvr == arg; + } +} + +int primitiveFloatGreaterthanArg(int rcvrOop, int argOop) { + double rcvr; + double arg; + + rcvr = loadFloatOrIntFrom(rcvrOop); + arg = loadFloatOrIntFrom(argOop); + if (successFlag) { + return rcvr > arg; + } +} + +int primitiveFloatGreaterOrEqual(void) { + int bool; + int sp; + int sp1; + + bool = primitiveFloatLessthanArg(longAt(stackPointer - (1 * 4)), longAt(stackPointer)); + if (successFlag) { + /* begin pop: */ + stackPointer -= 2 * 4; + /* begin pushBool: */ + if (!bool) { + /* begin push: */ + longAtput(sp = stackPointer + 4, trueObj); + stackPointer = sp; + } else { + /* begin push: */ + longAtput(sp1 = stackPointer + 4, falseObj); + stackPointer = sp1; + } + } +} + +int primitiveFloatGreaterThan(void) { + int bool; + int sp; + int sp1; + + bool = primitiveFloatGreaterthanArg(longAt(stackPointer - (1 * 4)), longAt(stackPointer)); + if (successFlag) { + /* begin pop: */ + stackPointer -= 2 * 4; + /* begin pushBool: */ + if (bool) { + /* begin push: */ + longAtput(sp = stackPointer + 4, trueObj); + stackPointer = sp; + } else { + /* begin push: */ + longAtput(sp1 = stackPointer + 4, falseObj); + stackPointer = sp1; + } + } +} + +int primitiveFloatLessthanArg(int rcvrOop, int argOop) { + double rcvr; + double arg; + + rcvr = loadFloatOrIntFrom(rcvrOop); + arg = loadFloatOrIntFrom(argOop); + if (successFlag) { + return rcvr < arg; + } +} + +int primitiveFloatLessOrEqual(void) { + int bool; + int sp; + int sp1; + + bool = primitiveFloatGreaterthanArg(longAt(stackPointer - (1 * 4)), longAt(stackPointer)); + if (successFlag) { + /* begin pop: */ + stackPointer -= 2 * 4; + /* begin pushBool: */ + if (!bool) { + /* begin push: */ + longAtput(sp = stackPointer + 4, trueObj); + stackPointer = sp; + } else { + /* begin push: */ + longAtput(sp1 = stackPointer + 4, falseObj); + stackPointer = sp1; + } + } +} + +int primitiveFloatLessThan(void) { + int bool; + int sp; + int sp1; + + bool = primitiveFloatLessthanArg(longAt(stackPointer - (1 * 4)), longAt(stackPointer)); + if (successFlag) { + /* begin pop: */ + stackPointer -= 2 * 4; + /* begin pushBool: */ + if (bool) { + /* begin push: */ + longAtput(sp = stackPointer + 4, trueObj); + stackPointer = sp; + } else { + /* begin push: */ + longAtput(sp1 = stackPointer + 4, falseObj); + stackPointer = sp1; + } + } +} + +int primitiveFloatMultiply(void) { + return primitiveFloatMultiplybyArg(longAt(stackPointer - (1 * 4)), longAt(stackPointer)); +} + +int primitiveFloatMultiplybyArg(int rcvrOop, int argOop) { + double rcvr; + double arg; + + rcvr = loadFloatOrIntFrom(rcvrOop); + arg = loadFloatOrIntFrom(argOop); + if (successFlag) { + /* begin pop: */ + stackPointer -= 2 * 4; + pushFloat(rcvr * arg); + } +} + +int primitiveFloatNotEqual(void) { + int bool; + int sp; + int sp1; + + bool = primitiveFloatEqualtoArg(longAt(stackPointer - (1 * 4)), longAt(stackPointer)); + if (successFlag) { + /* begin pop: */ + stackPointer -= 2 * 4; + /* begin pushBool: */ + if (!bool) { + /* begin push: */ + longAtput(sp = stackPointer + 4, trueObj); + stackPointer = sp; + } else { + /* begin push: */ + longAtput(sp1 = stackPointer + 4, falseObj); + stackPointer = sp1; + } + } +} + +int primitiveFloatSubtract(void) { + return primitiveFloatSubtractfromArg(longAt(stackPointer - (1 * 4)), longAt(stackPointer)); +} + +int primitiveFloatSubtractfromArg(int rcvrOop, int argOop) { + double rcvr; + double arg; + + rcvr = loadFloatOrIntFrom(rcvrOop); + arg = loadFloatOrIntFrom(argOop); + if (successFlag) { + /* begin pop: */ + stackPointer -= 2 * 4; + pushFloat(rcvr - arg); + } +} + + +/* Clear the method lookup cache. This must be done after every programming change. */ + +int primitiveFlushCache(void) { + int i; + + /* begin flushMethodCache */ + for (i = 1; i <= 4096; i += 1) { + methodCache[i] = 0; + } + for (i = 1; i <= 64; i += 1) { + atCache[i] = 0; + } + /* begin compilerFlushCacheHook: */ + if (compilerInitialized) { + compilerFlushCache(null); + } +} + + +/* The receiver is a compiledMethod. Clear all entries in the method lookup cache that refer to this method, presumably because it has been redefined, overridden or removed. */ + +int primitiveFlushCacheByMethod(void) { + int i; + int probe; + int oldMethod; + + oldMethod = longAt(stackPointer); + probe = 0; + for (i = 1; i <= 512; i += 1) { + if ((methodCache[probe + 3]) == oldMethod) { + methodCache[probe + 1] = 0; + } + probe += 8; + } + /* begin compilerFlushCacheHook: */ + if (compilerInitialized) { + compilerFlushCache(oldMethod); + } +} + + +/* The receiver is a message selector. Clear all entries in the method lookup cache with this selector, presumably because an associated method has been redefined. */ + +int primitiveFlushCacheSelective(void) { + int i; + int probe; + int selector; + + selector = longAt(stackPointer); + probe = 0; + for (i = 1; i <= 512; i += 1) { + if ((methodCache[probe + 1]) == selector) { + methodCache[probe + 1] = 0; + } + probe += 8; + } +} + + +/* Primitive. Flush all the existing external primitives in the image thus forcing a reload on next invokation. */ + +int primitiveFlushExternalPrimitives(void) { + return flushExternalPrimitives(); +} + + +/* On some platforms, this primitive forces enqueued display updates to be processed immediately. On others, it does nothing. */ + +int primitiveForceDisplayUpdate(void) { + ioForceDisplayUpdate(); +} + + +/* On platforms that support it, this primitive prints the receiver, assumed to be a Form, to the default printer. */ + +int primitiveFormPrint(void) { + int landscapeFlag; + int depth; + int w; + int pixelsPerWord; + int wordsPerLine; + int h; + int bitsArraySize; + double vScale; + int ok; + int rcvr; + double hScale; + int bitsArray; + int header; + int fmt; + int sz; + + /* begin booleanValueOf: */ + if ((longAt(stackPointer)) == trueObj) { + landscapeFlag = 1; + goto l2; + } + if ((longAt(stackPointer)) == falseObj) { + landscapeFlag = 0; + goto l2; + } + successFlag = 0; + landscapeFlag = null; +l2: /* end booleanValueOf: */; + vScale = floatValueOf(longAt(stackPointer - (1 * 4))); + hScale = floatValueOf(longAt(stackPointer - (2 * 4))); + rcvr = longAt(stackPointer - (3 * 4)); + if ((rcvr & 1)) { + /* begin success: */ + successFlag = 0 && successFlag; + } + if (successFlag) { + if (!((((((unsigned) (longAt(rcvr))) >> 8) & 15) <= 4) && ((lengthOf(rcvr)) >= 4))) { + /* begin success: */ + successFlag = 0 && successFlag; + } + } + if (successFlag) { + bitsArray = longAt(((((char *) rcvr)) + 4) + (0 << 2)); + w = fetchIntegerofObject(1, rcvr); + h = fetchIntegerofObject(2, rcvr); + depth = fetchIntegerofObject(3, rcvr); + if (!((w > 0) && (h > 0))) { + /* begin success: */ + successFlag = 0 && successFlag; + } + pixelsPerWord = 32 / depth; + wordsPerLine = (w + (pixelsPerWord - 1)) / pixelsPerWord; + if ((!((rcvr & 1))) && (isWordsOrBytes(bitsArray))) { + /* begin byteLengthOf: */ + header = longAt(bitsArray); + if ((header & 3) == 0) { + sz = (longAt(bitsArray - 8)) & 4294967292U; + } else { + sz = header & 252; + } + fmt = (((unsigned) header) >> 8) & 15; + if (fmt < 8) { + bitsArraySize = sz - 4; + goto l1; + } else { + bitsArraySize = (sz - 4) - (fmt & 3); + goto l1; + } + l1: /* end byteLengthOf: */; + /* begin success: */ + successFlag = (bitsArraySize == ((wordsPerLine * h) * 4)) && successFlag; + } else { + /* begin success: */ + successFlag = 0 && successFlag; + } + } + if (successFlag) { + ok = ioFormPrint(bitsArray + 4, w, h, depth, hScale, vScale, landscapeFlag); + /* begin success: */ + successFlag = ok && successFlag; + } + if (successFlag) { + /* begin pop: */ + stackPointer -= 3 * 4; + } +} + +int primitiveFractionalPart(void) { + double frac; + double trunc; + double rcvr; + + rcvr = popFloat(); + if (successFlag) { + frac = modf(rcvr, &trunc); + pushFloat(frac); + } else { + /* begin unPop: */ + stackPointer += 1 * 4; + } +} + + +/* Do a quick, incremental garbage collection and return the number of bytes available (including swap space if dynamic memory management is supported). */ + +int primitiveFullGC(void) { + int integerValue; + int sp; + + /* begin pop: */ + stackPointer -= 1 * 4; + incrementalGC(); + fullGC(); + /* begin pushInteger: */ + integerValue = ((longAt(freeBlock)) & 4294967292U) + (sqMemoryExtraBytesLeft(1)); + /* begin push: */ + longAtput(sp = stackPointer + 4, ((integerValue << 1) | 1)); + stackPointer = sp; +} + + +/* Fetch the system attribute with the given integer ID. The result is a string, which will be empty if the attribute is not defined. */ + +int primitiveGetAttribute(void) { + int attr; + int s; + int sz; + int sp; + int integerPointer; + + /* begin stackIntegerValue: */ + integerPointer = longAt(stackPointer - (0 * 4)); + if ((integerPointer & 1)) { + attr = (integerPointer >> 1); + goto l1; + } else { + /* begin primitiveFail */ + successFlag = 0; + attr = 0; + goto l1; + } +l1: /* end stackIntegerValue: */; + if (successFlag) { + sz = attributeSize(attr); + } + if (successFlag) { + s = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)), sz); + getAttributeIntoLength(attr, s + 4, sz); + /* begin pop: */ + stackPointer -= 2 * 4; + /* begin push: */ + longAtput(sp = stackPointer + 4, s); + stackPointer = sp; + } +} + + +/* Primitive. Return the next input event from the OS event queue. */ + +int primitiveGetNextEvent(void) { + int evtBuf[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + int i; + int value; + int arg; + int oop; + + ; + arg = longAt(stackPointer - (0 * 4)); + if (!(((fetchClassOf(arg)) == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)))) && ((slotSizeOf(arg)) == 8))) { + /* begin primitiveFail */ + successFlag = 0; + return null; + } + ioGetNextEvent(((sqInputEvent*) evtBuf)); + if (!(successFlag)) { + return null; + } + /* begin storeInteger:ofObject:withValue: */ + if (((evtBuf[0]) ^ ((evtBuf[0]) << 1)) >= 0) { + longAtput(((((char *) arg)) + 4) + (0 << 2), (((evtBuf[0]) << 1) | 1)); + } else { + /* begin primitiveFail */ + successFlag = 0; + } + if (!(successFlag)) { + return null; + } + /* begin storeInteger:ofObject:withValue: */ + if ((((evtBuf[1]) & 536870911) ^ (((evtBuf[1]) & 536870911) << 1)) >= 0) { + longAtput(((((char *) arg)) + 4) + (1 << 2), ((((evtBuf[1]) & 536870911) << 1) | 1)); + } else { + /* begin primitiveFail */ + successFlag = 0; + } + if (!(successFlag)) { + return null; + } + for (i = 2; i <= 7; i += 1) { + value = evtBuf[i]; + if ((value ^ (value << 1)) >= 0) { + /* begin storeInteger:ofObject:withValue: */ + if ((value ^ (value << 1)) >= 0) { + longAtput(((((char *) arg)) + 4) + (i << 2), ((value << 1) | 1)); + } else { + /* begin primitiveFail */ + successFlag = 0; + } + } else { + /* begin pushRemappableOop: */ + remapBuffer[remapBufferCount += 1] = arg; + value = positive32BitIntegerFor(value); + /* begin popRemappableOop */ + oop = remapBuffer[remapBufferCount]; + remapBufferCount -= 1; + arg = oop; + /* begin storePointer:ofObject:withValue: */ + if (arg < youngStart) { + possibleRootStoreIntovalue(arg, value); + } + longAtput(((((char *) arg)) + 4) + (i << 2), value); + } + } + if (!(successFlag)) { + return null; + } + /* begin pop: */ + stackPointer -= 1 * 4; +} + +int primitiveGreaterOrEqual(void) { + int integerArgument; + int integerReceiver; + int integerPointer; + int integerPointer1; + int top; + int top1; + int sp; + int sp1; + + /* begin popInteger */ + /* begin popStack */ + top = longAt(stackPointer); + stackPointer -= 4; + integerPointer = top; + if ((integerPointer & 1)) { + integerArgument = (integerPointer >> 1); + goto l1; + } else { + successFlag = 0; + integerArgument = 1; + goto l1; + } +l1: /* end popInteger */; + /* begin popInteger */ + /* begin popStack */ + top1 = longAt(stackPointer); + stackPointer -= 4; + integerPointer1 = top1; + if ((integerPointer1 & 1)) { + integerReceiver = (integerPointer1 >> 1); + goto l2; + } else { + successFlag = 0; + integerReceiver = 1; + goto l2; + } +l2: /* end popInteger */; + /* begin checkBooleanResult: */ + if (successFlag) { + /* begin pushBool: */ + if (integerReceiver >= integerArgument) { + /* begin push: */ + longAtput(sp = stackPointer + 4, trueObj); + stackPointer = sp; + } else { + /* begin push: */ + longAtput(sp1 = stackPointer + 4, falseObj); + stackPointer = sp1; + } + } else { + /* begin unPop: */ + stackPointer += 2 * 4; + } +} + +int primitiveGreaterThan(void) { + int integerArgument; + int integerReceiver; + int integerPointer; + int integerPointer1; + int top; + int top1; + int sp; + int sp1; + + /* begin popInteger */ + /* begin popStack */ + top = longAt(stackPointer); + stackPointer -= 4; + integerPointer = top; + if ((integerPointer & 1)) { + integerArgument = (integerPointer >> 1); + goto l1; + } else { + successFlag = 0; + integerArgument = 1; + goto l1; + } +l1: /* end popInteger */; + /* begin popInteger */ + /* begin popStack */ + top1 = longAt(stackPointer); + stackPointer -= 4; + integerPointer1 = top1; + if ((integerPointer1 & 1)) { + integerReceiver = (integerPointer1 >> 1); + goto l2; + } else { + successFlag = 0; + integerReceiver = 1; + goto l2; + } +l2: /* end popInteger */; + /* begin checkBooleanResult: */ + if (successFlag) { + /* begin pushBool: */ + if (integerReceiver > integerArgument) { + /* begin push: */ + longAtput(sp = stackPointer + 4, trueObj); + stackPointer = sp; + } else { + /* begin push: */ + longAtput(sp1 = stackPointer + 4, falseObj); + stackPointer = sp1; + } + } else { + /* begin unPop: */ + stackPointer += 2 * 4; + } +} + + +/* When called with a single string argument, record the string as the current image file name. When called with zero arguments, return a string containing the current image file name. */ + +int primitiveImageName(void) { + int okToRename; + int s; + int sCRIfn; + int sz; + int sp; + int cl; + int ccIndex; + int hdr; + int totalLength; + int fixedFields; + int fmt; + int sp1; + int sz1; + int classFormat; + int class; + int ccIndex1; + + if (argumentCount == 1) { + sCRIfn = ioLoadFunctionFrom("secCanRenameImage", "SecurityPlugin"); + if (sCRIfn != 0) { + okToRename = ((int (*) (void)) sCRIfn)(); + if (!(okToRename)) { + /* begin primitiveFail */ + successFlag = 0; + return null; + } + } + s = longAt(stackPointer); + /* begin assertClassOf:is: */ + if ((s & 1)) { + successFlag = 0; + goto l1; + } + ccIndex = (((unsigned) (longAt(s))) >> 12) & 31; + if (ccIndex == 0) { + cl = (longAt(s - 4)) & 4294967292U; + } else { + cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); + } + /* begin success: */ + successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)))) && successFlag; + l1: /* end assertClassOf:is: */; + if (successFlag) { + /* begin stSizeOf: */ + hdr = longAt(s); + fmt = (((unsigned) hdr) >> 8) & 15; + /* begin lengthOf:baseHeader:format: */ + if ((hdr & 3) == 0) { + sz1 = (longAt(s - 8)) & 4294967292U; + } else { + sz1 = hdr & 252; + } + if (fmt < 8) { + totalLength = ((unsigned) (sz1 - 4)) >> 2; + goto l4; + } else { + totalLength = (sz1 - 4) - (fmt & 3); + goto l4; + } + l4: /* end lengthOf:baseHeader:format: */; + /* begin fixedFieldsOf:format:length: */ + if ((fmt > 4) || (fmt == 2)) { + fixedFields = 0; + goto l2; + } + if (fmt < 2) { + fixedFields = totalLength; + goto l2; + } + /* begin fetchClassOf: */ + if ((s & 1)) { + class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); + goto l3; + } + ccIndex1 = (((unsigned) (longAt(s))) >> 12) & 31; + if (ccIndex1 == 0) { + class = (longAt(s - 4)) & 4294967292U; + goto l3; + } else { + class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex1 - 1) << 2)); + goto l3; + } + l3: /* end fetchClassOf: */; + classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; + fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; + l2: /* end fixedFieldsOf:format:length: */; + if ((fmt == 3) && (isContextHeader(hdr))) { + /* begin fetchStackPointerOf: */ + sp1 = longAt(((((char *) s)) + 4) + (2 << 2)); + if (!((sp1 & 1))) { + sz = 0; + goto l5; + } + sz = (sp1 >> 1); + goto l5; + } else { + sz = totalLength - fixedFields; + goto l5; + } + l5: /* end stSizeOf: */; + imageNamePutLength(s + 4, sz); + /* begin pop: */ + stackPointer -= 1 * 4; + } + } else { + sz = imageNameSize(); + s = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)), sz); + imageNameGetLength(s + 4, sz); + /* begin pop: */ + stackPointer -= 1 * 4; + /* begin push: */ + longAtput(sp = stackPointer + 4, s); + stackPointer = sp; + } +} + + +/* Do a quick, incremental garbage collection and return the number of bytes immediately available. (Note: more space may be made available by doing a full garbage collection. */ + +int primitiveIncrementalGC(void) { + int integerValue; + int sp; + + /* begin pop: */ + stackPointer -= 1 * 4; + incrementalGC(); + /* begin pushInteger: */ + integerValue = ((longAt(freeBlock)) & 4294967292U) + (sqMemoryExtraBytesLeft(0)); + /* begin push: */ + longAtput(sp = stackPointer + 4, ((integerValue << 1) | 1)); + stackPointer = sp; +} + + +/* Note: We now have 11 bits of primitive index, but they are in two places + for temporary backward compatibility. The time to unpack is negligible, + since the reconstituted full index is stored in the method cache. */ + +int primitiveIndexOf(int methodPointer) { + int primBits; + + primBits = (((unsigned) (longAt(((((char *) methodPointer)) + 4) + (0 << 2)))) >> 1) & 805306879; + if (primBits > 511) { + return (primBits & 511) + (((unsigned) primBits) >> 19); + } else { + return primBits; + } +} + + +/* Register the input semaphore. If the argument is not a Semaphore, unregister the current input semaphore. */ + +int primitiveInputSemaphore(void) { + int arg; + int oop; + int oop1; + int valuePointer; + int top; + + arg = longAt(stackPointer - (0 * 4)); + if ((arg & 1)) { + ioSetInputSemaphore((arg >> 1)); + if (successFlag) { + /* begin pop: */ + stackPointer -= 1 * 4; + } + return null; + } + /* begin popStack */ + top = longAt(stackPointer); + stackPointer -= 4; + arg = top; + if ((fetchClassOf(arg)) == (longAt(((((char *) specialObjectsOop)) + 4) + (18 << 2)))) { + /* begin storePointer:ofObject:withValue: */ + oop = specialObjectsOop; + if (oop < youngStart) { + possibleRootStoreIntovalue(oop, arg); + } + longAtput(((((char *) oop)) + 4) + (22 << 2), arg); + } else { + /* begin storePointer:ofObject:withValue: */ + oop1 = specialObjectsOop; + valuePointer = nilObj; + if (oop1 < youngStart) { + possibleRootStoreIntovalue(oop1, valuePointer); + } + longAtput(((((char *) oop1)) + 4) + (22 << 2), valuePointer); + } +} + + +/* Return an integer indicating the reason for the most recent input interrupt. */ + +int primitiveInputWord(void) { + int sp; + + /* begin pop: */ + stackPointer -= 1 * 4; + /* begin pushInteger: */ + /* begin push: */ + longAtput(sp = stackPointer + 4, ((0 << 1) | 1)); + stackPointer = sp; +} + +int primitiveInstVarAt(void) { + int hdr; + int totalLength; + int fixedFields; + int value; + int fmt; + int rcvr; + int index; + int sp; + int integerPointer; + int top; + int top1; + int sz; + int classFormat; + int class; + int ccIndex; + + /* begin popInteger */ + /* begin popStack */ + top = longAt(stackPointer); + stackPointer -= 4; + integerPointer = top; + if ((integerPointer & 1)) { + index = (integerPointer >> 1); + goto l2; + } else { + successFlag = 0; + index = 1; + goto l2; + } +l2: /* end popInteger */; + /* begin popStack */ + top1 = longAt(stackPointer); + stackPointer -= 4; + rcvr = top1; + if (successFlag) { + hdr = longAt(rcvr); + fmt = (((unsigned) hdr) >> 8) & 15; + /* begin lengthOf:baseHeader:format: */ + if ((hdr & 3) == 0) { + sz = (longAt(rcvr - 8)) & 4294967292U; + } else { + sz = hdr & 252; + } + if (fmt < 8) { + totalLength = ((unsigned) (sz - 4)) >> 2; + goto l3; + } else { + totalLength = (sz - 4) - (fmt & 3); + goto l3; + } + l3: /* end lengthOf:baseHeader:format: */; + /* begin fixedFieldsOf:format:length: */ + if ((fmt > 4) || (fmt == 2)) { + fixedFields = 0; + goto l4; + } + if (fmt < 2) { + fixedFields = totalLength; + goto l4; + } + /* begin fetchClassOf: */ + if ((rcvr & 1)) { + class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); + goto l5; + } + ccIndex = (((unsigned) (longAt(rcvr))) >> 12) & 31; + if (ccIndex == 0) { + class = (longAt(rcvr - 4)) & 4294967292U; + goto l5; + } else { + class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); + goto l5; + } + l5: /* end fetchClassOf: */; + classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; + fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; + l4: /* end fixedFieldsOf:format:length: */; + if (!((index >= 1) && (index <= fixedFields))) { + successFlag = 0; + } + } + if (successFlag) { + /* begin subscript:with:format: */ + if (fmt <= 4) { + value = longAt(((((char *) rcvr)) + 4) + ((index - 1) << 2)); + goto l1; + } + if (fmt < 8) { + value = positive32BitIntegerFor(longAt(((((char *) rcvr)) + 4) + ((index - 1) << 2))); + goto l1; + } else { + value = (((byteAt(((((char *) rcvr)) + 4) + (index - 1))) << 1) | 1); + goto l1; + } + l1: /* end subscript:with:format: */; + } + if (successFlag) { + /* begin push: */ + longAtput(sp = stackPointer + 4, value); + stackPointer = sp; + } else { + /* begin unPop: */ + stackPointer += 2 * 4; + } +} + +int primitiveInstVarAtPut(void) { + int hdr; + int totalLength; + int fixedFields; + int fmt; + int rcvr; + int index; + int newValue; + int sp; + int top; + int integerPointer; + int top1; + int top2; + int sz; + int classFormat; + int class; + int valueToStore; + int ccIndex; + + /* begin popStack */ + top = longAt(stackPointer); + stackPointer -= 4; + newValue = top; + /* begin popInteger */ + /* begin popStack */ + top1 = longAt(stackPointer); + stackPointer -= 4; + integerPointer = top1; + if ((integerPointer & 1)) { + index = (integerPointer >> 1); + goto l1; + } else { + successFlag = 0; + index = 1; + goto l1; + } +l1: /* end popInteger */; + /* begin popStack */ + top2 = longAt(stackPointer); + stackPointer -= 4; + rcvr = top2; + if (successFlag) { + hdr = longAt(rcvr); + fmt = (((unsigned) hdr) >> 8) & 15; + /* begin lengthOf:baseHeader:format: */ + if ((hdr & 3) == 0) { + sz = (longAt(rcvr - 8)) & 4294967292U; + } else { + sz = hdr & 252; + } + if (fmt < 8) { + totalLength = ((unsigned) (sz - 4)) >> 2; + goto l2; + } else { + totalLength = (sz - 4) - (fmt & 3); + goto l2; + } + l2: /* end lengthOf:baseHeader:format: */; + /* begin fixedFieldsOf:format:length: */ + if ((fmt > 4) || (fmt == 2)) { + fixedFields = 0; + goto l3; + } + if (fmt < 2) { + fixedFields = totalLength; + goto l3; + } + /* begin fetchClassOf: */ + if ((rcvr & 1)) { + class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); + goto l4; + } + ccIndex = (((unsigned) (longAt(rcvr))) >> 12) & 31; + if (ccIndex == 0) { + class = (longAt(rcvr - 4)) & 4294967292U; + goto l4; + } else { + class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); + goto l4; + } + l4: /* end fetchClassOf: */; + classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; + fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; + l3: /* end fixedFieldsOf:format:length: */; + if (!((index >= 1) && (index <= fixedFields))) { + successFlag = 0; + } + } + if (successFlag) { + /* begin subscript:with:storing:format: */ + if (fmt <= 4) { + /* begin storePointer:ofObject:withValue: */ + if (rcvr < youngStart) { + possibleRootStoreIntovalue(rcvr, newValue); + } + longAtput(((((char *) rcvr)) + 4) + ((index - 1) << 2), newValue); + } else { + if (fmt < 8) { + valueToStore = positive32BitValueOf(newValue); + if (successFlag) { + longAtput(((((char *) rcvr)) + 4) + ((index - 1) << 2), valueToStore); + } + } else { + if (!((newValue & 1))) { + successFlag = 0; + } + valueToStore = (newValue >> 1); + if (!((valueToStore >= 0) && (valueToStore <= 255))) { + successFlag = 0; + } + if (successFlag) { + byteAtput(((((char *) rcvr)) + 4) + (index - 1), valueToStore); + } + } + } + } + if (successFlag) { + /* begin push: */ + longAtput(sp = stackPointer + 4, newValue); + stackPointer = sp; + } else { + /* begin unPop: */ + stackPointer += 3 * 4; + } +} + + +/* Note: this primitive has been decommissioned. It is only here for short-term compatibility with an internal 2.3beta-d image that used this. It did not save much time and it complicated several things. Plus Jitter will do it right anyway. */ + +int primitiveInstVarsPutFromStack(void) { + int i; + int offsetBits; + int rcvr; + + + /* Mark dirty so stores below can be unchecked */ + + rcvr = longAt(stackPointer - (argumentCount * 4)); + if (rcvr < youngStart) { + beRootIfOld(rcvr); + } + for (i = 0; i <= (argumentCount - 1); i += 1) { + if ((i & 3) == 0) { + offsetBits = positive32BitValueOf(longAt(((((char *) newMethod)) + 4) + (((((int) i >> 2)) + 1) << 2))); + } + longAtput(((((char *) rcvr)) + 4) + ((offsetBits & 255) << 2), longAt(stackPointer - (i * 4))); + offsetBits = ((unsigned) offsetBits) >> 8; + } + /* begin pop: */ + stackPointer -= argumentCount * 4; +} + + +/* Return the 32bit signed integer contents of a words receiver */ + +int primitiveIntegerAt(void) { + int value; + int rcvr; + int sz; + int index; + int addr; + int sp; + int object; + int sp1; + int integerPointer; + int successValue; + int header; + int sz1; + + /* begin stackIntegerValue: */ + integerPointer = longAt(stackPointer - (0 * 4)); + if ((integerPointer & 1)) { + index = (integerPointer >> 1); + goto l1; + } else { + /* begin primitiveFail */ + successFlag = 0; + index = 0; + goto l1; + } +l1: /* end stackIntegerValue: */; + rcvr = longAt(stackPointer - (1 * 4)); + if ((rcvr & 1)) { + /* begin success: */ + successFlag = 0 && successFlag; + return null; + } + if (!(((((unsigned) (longAt(rcvr))) >> 8) & 15) == 6)) { + /* begin success: */ + successFlag = 0 && successFlag; + return null; + } + /* begin lengthOf: */ + header = longAt(rcvr); + /* begin lengthOf:baseHeader:format: */ + if ((header & 3) == 0) { + sz1 = (longAt(rcvr - 8)) & 4294967292U; + } else { + sz1 = header & 252; + } + if (((((unsigned) header) >> 8) & 15) < 8) { + sz = ((unsigned) (sz1 - 4)) >> 2; + goto l2; + } else { + sz = (sz1 - 4) - (((((unsigned) header) >> 8) & 15) & 3); + goto l2; + } + sz = null; +l2: /* end lengthOf: */; + /* begin success: */ + successValue = (index >= 1) && (index <= sz); + successFlag = successValue && successFlag; + if (successFlag) { + + /* for zero indexing */ + + addr = ((rcvr + 4) - 4) + (index * 4); + value = *((int *) addr); + /* begin pop: */ + stackPointer -= 2 * 4; + if ((value ^ (value << 1)) >= 0) { + /* begin pushInteger: */ + /* begin push: */ + longAtput(sp = stackPointer + 4, ((value << 1) | 1)); + stackPointer = sp; + } else { + /* begin push: */ + object = signed32BitIntegerFor(value); + longAtput(sp1 = stackPointer + 4, object); + stackPointer = sp1; + } + } +} + + +/* Return the 32bit signed integer contents of a words receiver */ + +int primitiveIntegerAtPut(void) { + int value; + int rcvr; + int sz; + int index; + int addr; + int valueOop; + int sp; + int integerPointer; + int header; + int sz1; + + valueOop = longAt(stackPointer - (0 * 4)); + /* begin stackIntegerValue: */ + integerPointer = longAt(stackPointer - (1 * 4)); + if ((integerPointer & 1)) { + index = (integerPointer >> 1); + goto l1; + } else { + /* begin primitiveFail */ + successFlag = 0; + index = 0; + goto l1; + } +l1: /* end stackIntegerValue: */; + rcvr = longAt(stackPointer - (2 * 4)); + if ((rcvr & 1)) { + /* begin success: */ + successFlag = 0 && successFlag; + return null; + } + if (!(((((unsigned) (longAt(rcvr))) >> 8) & 15) == 6)) { + /* begin success: */ + successFlag = 0 && successFlag; + return null; + } + /* begin lengthOf: */ + header = longAt(rcvr); + /* begin lengthOf:baseHeader:format: */ + if ((header & 3) == 0) { + sz1 = (longAt(rcvr - 8)) & 4294967292U; + } else { + sz1 = header & 252; + } + if (((((unsigned) header) >> 8) & 15) < 8) { + sz = ((unsigned) (sz1 - 4)) >> 2; + goto l2; + } else { + sz = (sz1 - 4) - (((((unsigned) header) >> 8) & 15) & 3); + goto l2; + } + sz = null; +l2: /* end lengthOf: */; + if (!((index >= 1) && (index <= sz))) { + /* begin success: */ + successFlag = 0 && successFlag; + return null; + } + if ((valueOop & 1)) { + value = (valueOop >> 1); + } else { + value = signed32BitValueOf(valueOop); + } + if (successFlag) { + + /* for zero indexing */ + + addr = ((rcvr + 4) - 4) + (index * 4); + value = *((int *) addr) = value; + /* begin pop:thenPush: */ + longAtput(sp = stackPointer - ((3 - 1) * 4), valueOop); + stackPointer = sp; + } +} + + +/* Register the user interrupt semaphore. If the argument is not a Semaphore, unregister the current interrupt semaphore. */ + +int primitiveInterruptSemaphore(void) { + int arg; + int oop; + int oop1; + int valuePointer; + int top; + + /* begin popStack */ + top = longAt(stackPointer); + stackPointer -= 4; + arg = top; + if ((fetchClassOf(arg)) == (longAt(((((char *) specialObjectsOop)) + 4) + (18 << 2)))) { + /* begin storePointer:ofObject:withValue: */ + oop = specialObjectsOop; + if (oop < youngStart) { + possibleRootStoreIntovalue(oop, arg); + } + longAtput(((((char *) oop)) + 4) + (30 << 2), arg); + } else { + /* begin storePointer:ofObject:withValue: */ + oop1 = specialObjectsOop; + valuePointer = nilObj; + if (oop1 < youngStart) { + possibleRootStoreIntovalue(oop1, valuePointer); + } + longAtput(((((char *) oop1)) + 4) + (30 << 2), valuePointer); + } +} + + +/* Return the next keycode and remove it from the input buffer. The low byte is the 8-bit ISO character. The next four bits are the Smalltalk modifier bits