[Vm-dev] VM Maker: VMMaker-dtl.302.mcz
David T. Lewis
lewis at mail.msen.com
Sat Mar 9 15:40:04 UTC 2013
On Sat, Mar 09, 2013 at 03:06:23PM +0000, commits at source.squeak.org wrote:
>
> David T. Lewis uploaded a new version of VMMaker to project VM Maker:
> http://source.squeak.org/VMMaker/VMMaker-dtl.302.mcz
>
@Tim: This fixes the parameter declaration in HostWindowPlugin slang:
unsigned *dispBits;
@Eliot: This is a one line patch to WordArray that can go into the oscog
branch also. I also made a test for it, change set attached.
Dave
-------------- next part --------------
'From Squeak4.3 of 22 December 2011 [latest update: #11860] on 8 March 2013 at 9:01:43 pm'!
"Change Set: SmartSyntaxParameterBugFix-dtl
Date: 8 March 2013
Author: David T. Lewis
A WordArray parameter in the parameter list of a primitive declaration should be declared as (unsigned *) not (usqInt *) in the generated C code. Fix code generation and provide a unit test.
Also remove redundant type declaration in HostWindowPlugin>>primitiveShowHostWindow:bits:width:height:depth:left:right:top:bottom: which was an ineffective attempt to work around the code generation bug."!
SmartSyntaxInterpreterPlugin subclass: #SlangTestSupportSmartSyntaxInterpreterPlugin
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'VMMaker-Tests'!
!HostWindowPlugin methodsFor: 'system primitives' stamp: 'dtl 3/8/2013 20:57'!
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 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]! !
!SlangTest methodsFor: 'testing smart syntax' stamp: 'dtl 3/8/2013 20:36'!
testSmartSyntaxParameterDeclaration
"(SlangTest selector: #testSmartSyntaxParameterDeclaration) run"
| s |
s := (SlangTestSupportSmartSyntaxInterpreterPlugin
asInlinedCString: #declareInt:wordPointer: ).
"parameter taken from the stack should be cast to (unsigned *)"
self should: ['*pointerToWords = ((unsigned **) (interpreterProxy->firstIndexableField(interpreterProxy->stackValue(0))));*' match: s].
"local variable declaration should match the data type as in the cast"
self shouldnt: ['*usqInt **pointerToWords*' match: s]. "the buggy code generator renders it as 'usqInt *pointerToWords' "
self should: ['*unsigned **pointerToWords*' match: s]. "it should be rendered as 'unsigned *pointerToWords' "
! !
!SlangTestSupportSmartSyntaxInterpreterPlugin methodsFor: 'parameter declarations' stamp: 'dtl 3/8/2013 19:40'!
declareInt: anInt wordPointer: pointerToWords
"The pointerToWords parameter should be (unsigned *) as a result of the WordArray
declaration in primitive:parameters: and the local declaration for pointerToWords should
match this data type. For buggy code generator this is not the case."
self var: #pointerToWords type: 'unsigned char * '. "intentional red herring, no effect"
self primitive: 'primitiveShowHostWindowRect' parameters: #(SmallInteger WordArray).
"Incorrect output, demonstrating code generator bug:
EXPORT(sqInt) primitiveShowHostWindowRect(void) {
sqInt anInt;
usqInt *pointerToWords;
anInt = interpreterProxy->stackIntegerValue(1);
interpreterProxy->success(interpreterProxy->isWords(interpreterProxy->stackValue(0)));
pointerToWords = ((unsigned *) (interpreterProxy->firstIndexableField(interpreterProxy->stackValue(0))));
if (interpreterProxy->failed()) {
return null;
}
if (interpreterProxy->failed()) {
return null;
}
interpreterProxy->pop(2);
return null;
}
"! !
!VMMaker class methodsFor: 'version testing' stamp: 'dtl 3/8/2013 20:50'!
versionString
"VMMaker versionString"
^'4.10.13'! !
!WordArray class methodsFor: '*VMMaker-plugin generation' stamp: 'dtl 3/8/2013 20:36'!
ccgDeclareCForVar: aSymbolOrString
"Address of an unsigned 32 bit value, regardless of Smalltalk wordSize"
^'unsigned *', aSymbolOrString! !
More information about the Vm-dev
mailing list