David T. Lewis uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker-dtl.312.mcz ==================== Summary ==================== Name: VMMaker-dtl.312 Author: dtl Time: 23 March 2013, 11:37:27.659 pm UUID: 488d26b6-538b-40e3-b37a-9e84b2782b9b Ancestors: VMMaker-dtl.311 VMMaker 4.11.3 Merge from oscog: Identify generated sources using fileHeaderVersionStampForSourceClass: to specify the code generator, generated class, and Monticello source. Merge VMMaker-tpr.302 (misnamed package due to MC glitch), original commit was: Name: VMMaker-tpr.302 Author: tpr Time: 7 March 2013, 2:40:39.704 pm Ancestors: VMMaker-dtl.301 change HostWindowPlugin> primitiveShowHostWindow... to referto dispBits as ByteArray in order to have the C type be (char *) and not (unsigned *) as before. This reduces the compile errors for ioShowDisplayOnWindow() which is declared as (sqInt, unsigned char *..... =============== Diff against VMMaker-dtl.311 =============== Item was added: + ----- Method: CCodeGenerator class>>monticelloDescriptionFor: (in category 'C code generator') ----- + monticelloDescriptionFor: aClass + "Answer a suitable Monticello package stamp to include in the header." + | pkgInfo pkg uuid | + pkgInfo := PackageOrganizer default packageOfClass: aClass. + pkg := MCWorkingCopy allManagers detect: [:ea| ea packageName = pkgInfo packageName]. + pkg ancestry ancestors isEmpty ifFalse: + [uuid := pkg ancestry ancestors first id]. + ^aClass name, (pkg modified ifTrue: [' * '] ifFalse: [' ']), pkg ancestry ancestorString, ' uuid: ', uuid asString! Item was changed: ----- Method: CCodeGenerator>>addClass: (in category 'public') ----- addClass: aClass "Add the variables and methods of the given class to the code base." aClass prepareToBeAddedToCodeGenerator: self. self checkClassForNameConflicts: aClass. self addClassVarsFor: aClass. "ikp..." self addPoolVarsFor: aClass. variables addAll: aClass instVarNames. self retainMethods: aClass requiredMethodNames. + + "The identity of the translated class is kept in vmClass for use in identifying the + translated source. Unless otherwise overridden, the first class to be added to the + code generator will provide this identifier." + vmClass ifNil: [self vmClass: aClass]. - 'Adding Class ' , aClass name , '...' displayProgressAt: Sensor cursorPoint from: 0 to: aClass selectors size during: [:bar | + aClass selectors doWithIndex: [:sel :i | - aClass selectors doWithIndex: - [:sel :i | | source | bar value: i. self addMethodFor: aClass selector: sel]]. aClass declareCVarsIn: self! Item was changed: ----- Method: CCodeGenerator>>emitCHeaderForPrimitivesOn: (in category 'C code generator') ----- emitCHeaderForPrimitivesOn: aStream "Write a C file header for compiled primitives onto the given stream." aStream nextPutAll: '/* Automatically generated from Squeak ('; nextPutAll: VMMaker versionString; nextPutAll: ') on '. Time dateAndTimeNow do: [:e | aStream nextPutAll: e asString; nextPut: Character space]. aStream nextPutAll: '*/'; + cr; cr. + self fileHeaderVersionStampForSourceClass: vmClass. + aStream cr; cr; - cr; cr; nextPutAll: '#include "sq.h"'; cr; cr. "Additional header files" headerFiles do:[:hdr| aStream nextPutAll:'#include '; nextPutAll: hdr; cr]. aStream nextPutAll: ' #include "sqMemoryAccess.h" /*** Imported Functions/Variables ***/ extern sqInt stackValue(sqInt); extern sqInt stackIntegerValue(sqInt); extern sqInt successFlag; /* allows accessing Strings in both C and Smalltalk */ #define asciiValue(c) c '. aStream cr.! Item was changed: ----- Method: CCodeGenerator>>emitCHeaderOn: (in category 'C code generator') ----- emitCHeaderOn: aStream "Write a C file header onto the given stream." aStream nextPutAll: '/* '. aStream nextPutAll: VMMaker headerNotice. aStream nextPutAll: ' */'; cr. + self fileHeaderVersionStampForSourceClass: vmClass. + aStream cr; cr. self emitGlobalStructFlagOn: aStream. aStream nextPutAll: '#include "sq.h"'; cr. "Additional header files" headerFiles do:[:hdr| aStream nextPutAll:'#include '; nextPutAll: hdr; cr]. "Default definitions for optional functions, provided for backward compatibility" self emitDefaultMacrosOn: aStream. aStream nextPutAll: ' #include "sqMemoryAccess.h" sqInt printCallStack(void); void defaultErrorProc(char *s) { /* Print an error message and exit. */ static sqInt printingStack = false; printf("\n%s\n\n", s); if (!!printingStack) { /* flag prevents recursive error when trying to print a broken stack */ printingStack = true; printCallStack(); } exit(-1); } '. aStream cr.! Item was changed: ----- Method: CCodeGenerator>>fileHeaderVersionStampForSourceClass: (in category 'C code generator') ----- fileHeaderVersionStampForSourceClass: sourceClass + "Answer a suitable version stamp to include in the header." - "Answer a suitable versiomn stamp to include in the header." | exportBuildInfo slangDescription sourceDescription | [exportBuildInfo := sourceClass isInterpreterClass ifTrue: ['char *__interpBuildInfo = __buildInfo;'] ifFalse: [sourceClass isCogitClass + ifTrue: ['char *__cogitBuildInfo = __buildInfo;'] + ifFalse: + [sourceClass isPluginClass ifTrue: + [sourceClass exportBuildInfoOrNil]]]] - ifTrue: ['char *__cogitBuildInfo = __buildInfo;']]] on: MessageNotUnderstood do: [:ex| ex resume: false]. + [slangDescription := self class monticelloDescriptionFor: self class. - [slangDescription := self monticelloDescriptionFor: self class. sourceClass ifNotNil: + [sourceDescription := [sourceClass monticelloDescription] + on: MessageNotUnderstood + do: [:ex| self class monticelloDescriptionFor: sourceClass]]] - [sourceDescription := self monticelloDescriptionFor: sourceClass]] on: Error do: [:ex| | now | now := Time dateAndTimeNow printString. ^String streamContents: [:s| s nextPutAll: '/* Automatically generated from Squeak on '. s nextPutAll: now. s nextPutAll: ' */'; cr; cr. s nextPutAll: 'static char __buildInfo[] = "Generated on '. s nextPutAll: now. s nextPutAll: '. Compiled on "'. s nextPutAll: '__DATE__ ;'; cr. exportBuildInfo ifNotNil: [s nextPutAll: exportBuildInfo; cr]. s cr]]. ^String streamContents: [:s| + s nextPutAll: '/* Automatically generated by\ ' withCRs. - s nextPutAll: '/* Automatically generated by'. - s crtab. s nextPutAll: slangDescription. sourceDescription ifNotNil: + [s nextPutAll: '\ from\ ' withCRs; nextPutAll: (sourceDescription copyReplaceAll: '\' withCRs with: '\ ' withCRs)]. - [s cr; nextPutAll: ' from'; crtab; nextPutAll: sourceDescription]. s cr; nextPutAll: ' */'; cr. sourceDescription ifNotNil: [s nextPutAll: 'static char __buildInfo[] = "'. + s nextPutAll: (sourceDescription copyReplaceAll: '\' withCRs with: '\n\', '\' withCRs). - s nextPutAll: sourceDescription. s nextPutAll: ' " __DATE__ ;'; cr. exportBuildInfo ifNotNil: [s nextPutAll: exportBuildInfo; cr]. s cr]]! Item was removed: - ----- Method: CCodeGenerator>>monticelloDescriptionFor: (in category 'C code generator') ----- - monticelloDescriptionFor: aClass - "Answer a suitable Monticello package stamp to include in the header." - | pkgInfo pkg uuid | - pkgInfo := PackageOrganizer default packageOfClass: aClass. - pkg := MCWorkingCopy allManagers detect: [:ea| ea packageName = pkgInfo packageName]. - pkg ancestry ancestors isEmpty ifFalse: - [uuid := pkg ancestry ancestors first id]. - ^aClass name, (pkg modified ifTrue: [' * '] ifFalse: [' ']), pkg ancestry ancestorString, ' uuid: ', uuid asString! Item was changed: ----- Method: CCodeGenerator>>storeHeaderFor:onFile: (in category 'public') ----- storeHeaderFor: interpreterClassName onFile: fileName "Store C header code for this interpreter on the given file." | aStream | aStream := CrLfFileStream forceNewFileNamed: fileName. aStream ifNil: [Error signal: 'Could not open C header file: ', fileName]. aStream nextPutAll: '/* '; nextPutAll: VMMaker headerNotice; + nextPutAll: ' */'; cr; cr. + self fileHeaderVersionStampForSourceClass: vmClass. + aStream cr; cr; - nextPutAll: ' */'; cr; cr; nextPutAll: '#ifndef HAVE_INTERP_H'; cr; nextPutAll: '# define HAVE_INTERP_H'; cr; nextPutAll: '#endif'; cr; cr. self emitVmmVersionOn: aStream. (Smalltalk classNamed: interpreterClassName) emitInterpreterProxyVersionOn: aStream. self emitDefineBytesPerWordOn: aStream. self emitDefineMemoryAccessInImageOn: aStream. aStream cr. aStream close ! Item was changed: ----- Method: HostWindowPlugin>>primitiveShowHostWindow:bits:width:height:depth:left:right:top:bottom: (in category 'system primitives') ----- primitiveShowHostWindow: windowIndex bits: dispBits width: w height: h depth: d left: left right: right top: top bottom: bottom "Host window analogue of DisplayScreen> primShowRectLeft:right:top:bottom: (Interpreter>primitiveShowDisplayRect) which takes the window index, bitmap details and the rectangle bounds. Fail if the windowIndex is invalid or the platform routine returns false to indicate failure" |ok| self primitive: 'primitiveShowHostWindowRect' + parameters: #(SmallInteger ByteArray SmallInteger SmallInteger SmallInteger - parameters: #(SmallInteger WordArray SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger). "Tell the vm to copy pixel's from dispBits to the screen - this is just ioShowDisplay with the extra parameter of the windowIndex integer" ok := self cCode: 'ioShowDisplayOnWindow(dispBits, w, h, d, left, right, top, bottom, windowIndex)'. ok ifFalse:[interpreterProxy primitiveFail]! Item was added: + ----- Method: Interpreter class>>isInterpreterClass (in category 'translation') ----- + isInterpreterClass + ^true! Item was removed: - ----- Method: Interpreter class>>isTypePointerToStruct: (in category 'translation') ----- - isTypePointerToStruct: type "<String>" - ^false! Item was added: + ----- Method: Object class>>declareCVarsIn: (in category '*VMMaker-translation') ----- + declareCVarsIn: aCCodeGenerator + "Declare any additional variables and/or add type declarations for existing variables."! Item was added: + ----- Method: Object class>>isNonArgumentImplicitReceiverVariableName: (in category '*VMMaker-translation') ----- + isNonArgumentImplicitReceiverVariableName: aString + ^#('interpreterProxy' 'self') includes: aString + ! Item was added: + ----- Method: Object class>>isTypePointerToStruct: (in category '*VMMaker-translation') ----- + isTypePointerToStruct: type "<String>" + ^false! Item was added: + ----- Method: Object class>>requiredMethodNames (in category '*VMMaker-translation') ----- + requiredMethodNames + "Answer a list of method names that should be retained for export or other + support reasons. These are typically entry-points that unless explicitly noted + will be deleted by the code generator since it will assume these are not used." + ^#()! Item was added: + ----- Method: ObjectMemory class>>isNonArgumentImplicitReceiverVariableName: (in category 'translation') ----- + isNonArgumentImplicitReceiverVariableName: aString + ^#('self' 'interpreter' 'coInterpreter' 'heapMap') includes: aString! Item was added: + ----- Method: TMethod>>typeForSelf (in category 'utilities') ----- + typeForSelf + self assert: definingClass notNil. + ^[definingClass typeForSelf] + on: MessageNotUnderstood + do: [:ex| nil]! Item was removed: - ----- Method: VMClass class>>declareCVarsIn: (in category 'translation') ----- - declareCVarsIn: aCCodeGenerator - "Declare any additional variables and/or add type declarations for existing variables."! Item was added: + ----- Method: VMClass class>>isAccessor: (in category 'translation') ----- + isAccessor: aSelector + "Answer if aSelector is simply an accessor method for one of our fields. + Answer false by default. VMStructType classes redefine this appropriately." + ^false! Item was added: + ----- Method: VMClass class>>isCogitClass (in category 'translation') ----- + isCogitClass + "The various Cogit classes override this." + ^false! Item was added: + ----- Method: VMClass class>>isInterpreterClass (in category 'translation') ----- + isInterpreterClass + "The various Interpreter classes override this." + ^false! Item was added: + ----- Method: VMClass class>>isPluginClass (in category 'translation') ----- + isPluginClass + "InterpreterPlugin class override this." + ^false! Item was added: + ----- Method: VMClass class>>isStructClass (in category 'translation') ----- + isStructClass + "The various VMStructType classes override this." + ^false! Item was removed: - ----- Method: VMClass class>>requiredMethodNames (in category 'translation') ----- - requiredMethodNames - "Answer a list of method names that should be retained for export or other - support reasons. These are typically entry-points that unless explicitly noted - will be deleted by the code generator since it will assume these are not used." - ^#()! Item was added: + ----- Method: VMClass class>>typeForSelf (in category 'translation') ----- + typeForSelf + "Answer the type to give self if appropriate, or nil if not." + ^nil! Item was changed: ----- Method: VMMaker class>>headerNotice (in category 'version testing') ----- headerNotice "return a string to be put at the front of generated code files" ^String streamContents:[:strm| + strm nextPutAll: 'Smalltalk from '; + nextPutAll: Smalltalk version; + nextPutAll: ' with VMMaker '; + nextPutAll: self versionString; + nextPutAll: ' translated as C source on'. + Time dateAndTimeNow do: [:e | strm nextPut: Character space; nextPutAll: e asString]]! - strm nextPutAll: 'Automatically generated from Squeak on '. - Time dateAndTimeNow do: [:e | strm nextPutAll: e asString; nextPut: Character space]. - strm cr. - strm nextPutAll: ' by VMMaker '. - strm nextPutAll: self versionString. - strm cr]! Item was changed: ----- Method: VMMaker class>>useSinglePluginsDirectory: (in category 'initialisation') ----- useSinglePluginsDirectory: aBoolean "If true, all generated plugins will be in a common directory, otherwise the old directory structure is used in which internal and external plugins are generated to separate directories." + "VMMaker useSinglePluginsDirectory: true" + "VMMaker useSinglePluginsDirectory: false" + UseSinglePluginsDirectory := aBoolean! Item was changed: ----- Method: VMMaker class>>versionString (in category 'version testing') ----- versionString "VMMaker versionString" + ^'4.11.3'! - ^'4.11.2'! Item was changed: ----- Method: VMPluginCodeGenerator>>emitCHeaderOn: (in category 'C code generator') ----- emitCHeaderOn: aStream "Write a C file header onto the given stream." aStream nextPutAll: '/* '. aStream nextPutAll: VMMaker headerNotice. aStream nextPutAll: ' */';cr. + aStream nextPutAll: (self fileHeaderVersionStampForSourceClass: vmClass). + aStream cr; cr. aStream nextPutAll:' #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> /* 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 '. "Additional header files" headerFiles do:[:hdr| aStream nextPutAll:'#include '; nextPutAll: hdr; cr]. aStream nextPutAll: ' #include "sqMemoryAccess.h" '. aStream cr.! |
Free forum by Nabble | Edit this page |