'From Squeak3.0 of 4 February 2001 [latest update: #3414] on 5 February 2001 at 9:21:39 pm'! "Change Set: CodeGenFix-ar Date: 5 February 2001 Author: Andreas Raab A fix for translating #primitiveFail() correctly."! !PluggableCodeGenerator methodsFor: 'C code generator' stamp: 'ar 2/5/2001 21:20'! emitCHeaderForPrimitivesOn: aStream "Write a C file header for compiled primitives onto the given stream." aStream nextPutAll: '/* Automatically generated from Squeak on '. aStream nextPutAll: Time dateAndTimeNow printString. aStream nextPutAll: ' */'; cr; cr. aStream nextPutAll: '#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 */ '; cr; cr. "Additional header files" headerFiles do:[:hdr| aStream nextPutAll:'#include '; nextPutAll: hdr; cr]. aStream nextPutAll: ' /* 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 '. aStream cr.! !