[Vm-dev] VM Maker: VMMaker-dtl.424.mcz
commits at source.squeak.org
commits at source.squeak.org
Mon Apr 5 20:11:36 UTC 2021
David T. Lewis uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker-dtl.424.mcz
==================== Summary ====================
Name: VMMaker-dtl.424
Author: dtl
Time: 5 April 2021, 4:11:26.362 pm
UUID: 4bdf5efb-f2f2-47b9-a80f-93e9c910412b
Ancestors: VMMaker-dtl.423
VMMaker 4.19.7
Fix unit tests and C code generation for #cppIf:ifTrue:ifFalse: #cppIf:ifTrue: oscog compatibility methods. Tests were incorrectly written to specify #ifdef generation instead of the intended #if directives.
=============== Diff against VMMaker-dtl.423 ===============
Item was changed:
----- Method: CCodeGenerator>>generateOscogInlineCppIf:on:indent: (in category 'C translation') -----
generateOscogInlineCppIf: msgNode on: aStream indent: level
"Generate the C code for this message onto the given stream."
+ "Translate cppIf:ifTrue: as if it was isDefinedTrueExpression:inSmalltalk:comment:ifTrue:ifFalse:
- "Translate cppIf:ifTrue: as if it was isDefined:inSmalltalk:comment:ifTrue:
by adding nil argument entries for the comment node and the Smalltalk
expression node. Compatibility for externally maintained plugins."
msgNode args size = 2
+ ifTrue: [| newArgs emptyStatementList |
- ifTrue: [| newArgs |
"Expand the arguments array to match that of cppIf:ifTrue:ifFalse: "
+ emptyStatementList := TStmtListNode
+ readFrom: '(TStmtListNode basicNew instVarAt: 1 put: nil; instVarAt: 2 put: #(); instVarAt: 3 put: ((OrderedCollection new)); yourself)'.
+ newArgs := Array new: 5.
- newArgs := Array new: 4.
newArgs at: 1 put: (msgNode args at: 1).
newArgs at: 4 put: (msgNode args at: 2).
+ newArgs at: 5 put: emptyStatementList. "empty #else clause"
msgNode
setSelector: msgNode selector
receiver: msgNode receiver
arguments: newArgs].
self
+ generateInlineCppIfElse: msgNode
- generateInlineCppIfDef: msgNode
on: aStream
indent: level
!
Item was changed:
----- Method: CCodeGenerator>>generateOscogInlineCppIfElse:on:indent: (in category 'C translation') -----
generateOscogInlineCppIfElse: msgNode on: aStream indent: level
"Generate the C code for this message onto the given stream."
+ "Translate cppIf:ifTrue:ifFalse: as if it was isDefinedTrueExpression:inSmalltalk:comment:ifTrue:ifFalse:
+ by adding dummy or nil argument entries for the comment node and the Smalltalk
- "Translate cppIf:ifTrue:ifFalse: as if it was isDefined:inSmalltalk:comment:ifTrue:ifFalse:
- by adding nil argument entries for the comment node and the Smalltalk
expression node. Compatibility for externally maintained plugins."
msgNode args size = 3
ifTrue: [| newArgs |
"Expand the arguments array to match that of cppIf:ifTrue:ifFalse: "
newArgs := Array new: 5.
newArgs at: 1 put: (msgNode args at: 1).
newArgs at: 4 put: (msgNode args at: 2).
newArgs at: 5 put: (msgNode args at: 3).
msgNode
setSelector: msgNode selector
receiver: msgNode receiver
arguments: newArgs].
self
+ generateInlineCppIfElse: msgNode
- generateInlineCppIfDefElse: msgNode
on: aStream
indent: level
!
Item was changed:
----- Method: SlangTest>>testCppIfIfTrue (in category 'testing preprocessor directives - oscog compatibility') -----
testCppIfIfTrue
"Test the oscog variant of isDefined:inSmalltalk:comment:ifTrue:
Same as isDefined:inSmalltalk:comment:ifTrue: but does not support the
comment and Smalltalk block."
"(SlangTest selector: #testCppIfIfTrue) run"
| stssi cString stringWithoutWhiteSpace lines expected |
stssi := SlangTestSupportInterpreter inline: false.
"verify that the default Smalltalk block that is evaluated in simulation"
self assert: stssi ifdefElseEndif = #defaultBlockForSimulation.
"verify generated C string"
cString := stssi asCString: #cppIfIfTrue.
lines := (cString findTokens: Character cr) select: [:e |
{
+ '# if (HAVE_FOO)' .
- '# ifdef HAVE_FOO' .
' return 1;' .
'# else' .
' return 0;' .
'# endif // HAVE_FOO'
} includes: e ].
self should: lines size = 3.
self should: ('*return 1*' match: lines second).
"check the rest of the method, ignoring whitespace and ignoring the leading method comment"
stringWithoutWhiteSpace := cString reject: [:e | e isSeparator].
+ expected := 'sqIntcppIfIfTrue(void){#if(HAVE_FOO)return1;#endif//HAVE_FOOreturnnull;}'.
- expected := 'sqIntcppIfIfTrue(void){#ifdefHAVE_FOOreturn1;#endif//HAVE_FOOreturnnull;}'.
self should: expected = (stringWithoutWhiteSpace last: expected size).
!
Item was changed:
----- Method: SlangTest>>testCppIfIfTrueIfFalse (in category 'testing preprocessor directives - oscog compatibility') -----
testCppIfIfTrueIfFalse
"Test the oscog variant of isDefined:inSmalltalk:comment:ifTrue:ifFalse:
Same as isDefined:inSmalltalk:comment:ifTrue:ifFalse: but does not support
the comment and Smalltalk block."
"(SlangTest selector: #testCppIfIfTrueIfFalse) run"
| stssi cString stringWithoutWhiteSpace lines expected |
stssi := SlangTestSupportInterpreter inline: false.
"verify that the default Smalltalk block that is evaluated in simulation"
self assert: stssi ifdefElseEndif = #defaultBlockForSimulation.
"verify generated C string"
cString := stssi asCString: #cppIfIfTrueIfFalse.
lines := (cString findTokens: Character cr) select: [:e |
{
+ '# if (HAVE_FOO)' .
- '# ifdef HAVE_FOO' .
' return 1;' .
'# else' .
' return 0;' .
'# endif // HAVE_FOO'
} includes: e ].
self should: lines size = 5.
self should: ('*return 1*' match: lines second).
self should: ('*return 0*' match: lines fourth).
"check the rest of the method, ignoring whitespace and ignoring the leading method comment"
stringWithoutWhiteSpace := cString reject: [:e | e isSeparator].
+ expected := 'sqIntcppIfIfTrueIfFalse(void){#if(HAVE_FOO)return1;#elsereturn0;#endif//HAVE_FOOreturnnull;}'.
- expected := 'sqIntcppIfIfTrueIfFalse(void){#ifdefHAVE_FOOreturn1;#elsereturn0;#endif//HAVE_FOOreturnnull;}'.
self should: expected = (stringWithoutWhiteSpace last: expected size).
!
Item was changed:
----- Method: VMMaker class>>versionString (in category 'version testing') -----
versionString
"VMMaker versionString"
+ ^'4.19.7'!
- ^'4.19.6'!
More information about the Vm-dev
mailing list