[Vm-dev] VM Maker: VMMaker-dtl.308.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Mar 20 00:01:23 UTC 2013


David T. Lewis uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker-dtl.308.mcz

==================== Summary ====================

Name: VMMaker-dtl.308
Author: dtl
Time: 19 March 2013, 7:39:10.89 pm
UUID: 8b89cb23-28fd-47a1-8bdd-3a66296d2d75
Ancestors: VMMaker-eem.307

VMMaker 4.11.1

Comment out five unimplemented translation selectors in SmartSyntaxPluginCodeGenerator>>initializeCTranslationDictionary and fix the presumptive selectors for four of these. Leave as comments to reflect original author intent.

Remove redundant class SlangTestSupportSmartSyntaxInterpreterPlugin and move its test method #declareInt:wordPointer: to SlangTestSupportSSIP.

SlangTest should not depend on SlangBrowser package, so break the dependency. Create code generators in the support classes, caching to initialize once per test method, and add asCString instance methods to these classes distinct from class side methods used by SlangBrowser caching. Change all tests to use these code generators.

Ensure that SlangTestSupportPlugin and SlangTestSupportSSIP are not included in VMMaker code generation, as these are intended only as support classes for SlangTest and may contain methods that connot be compiled.

=============== Diff against VMMaker-eem.307 ===============

Item was changed:
  ----- Method: SlangTest>>setUp (in category 'running') -----
  setUp
  
  	"Some of the test may be long running when SlangTestSupport is a subclass
  	of ObjectMemory."
  	(self respondsTo: #timeout: ) "Recent Squeak images with test case timeout"
  		ifTrue: [self perform: #timeout: with: 30].
+ !
- 	VMMaker clearCacheEntriesFor: SlangTestSupportInterpreter.
- 	VMMaker clearCacheEntriesFor: SlangTestSupportPlugin.
- 	VMMaker clearCacheEntriesFor: SlangTestSupportSSIP!

Item was removed:
- ----- Method: SlangTest>>testASlangBrowserInstalled (in category 'slang browser dependency') -----
- testASlangBrowserInstalled
- 	"The SlangBrowser package must be installed in order for these tests
- 	to run"
- 
- 	self assert: (SlangTestSupportPlugin respondsTo: #asCString)!

Item was changed:
  ----- Method: SlangTest>>testIfElseEndif (in category 'testing preprocessor directives') -----
  testIfElseEndif
  	"Test isDefinedTrueExpression:inSmalltalk:comment:ifTrue:ifFalse: "
  
  	"(SlangTest selector: #testIfElseEndif) run"
  
+ 	| stssi cString stringWithoutWhiteSpace lines |
+ 	stssi := SlangTestSupportInterpreter inline: false.
+ 
- 	| cString stringWithoutWhiteSpace lines |
  	"verify that the default Smalltalk block that is evaluated in simulation"
+ 	self assert: stssi ifDefinedTrueElseEndif = 4.
- 	self assert: SlangTestSupportInterpreter new ifDefinedTrueElseEndif = 4.
  
  	"verify generated C string"
+ 	cString := stssi asCString: #ifDefinedTrueElseEndif.
- 	cString := SlangTestSupportInterpreter asCString: #ifDefinedTrueElseEndif.
  	lines := (cString findTokens: Character cr) select: [:e |
  		{
  			'# if (SIZE == 8)  // SIZE may be 4 or 8' .
  			'	return 8;' .
  			'# else' .
  			'	return 4;' .
  			'# endif  // SIZE == 8'
  		} includes: e ].
  	self should: lines size = 5.
  	self should: ('*return 8*' match: lines second).
  	self should: ('*return 4*' match: lines fourth).
  
  	"check the rest of the method, ignoring whitespace"
+ 	cString := stssi asCString: #ifDefinedTrueElseEndif.
- 	cString := SlangTestSupportInterpreter asCString: #ifDefinedTrueElseEndif.
  	stringWithoutWhiteSpace := cString reject: [:e | e isSeparator].
  	self should: stringWithoutWhiteSpace =
  		'sqIntifDefinedTrueElseEndif(void){#if(SIZE==8)//SIZEmaybe4or8return8;#elsereturn4;#endif//SIZE==8returnnull;}'.
  
  "
  sqInt ifDefinedTrueElseEndif(void) {
  	
  # if (SIZE == 8)  // SIZE may be 4 or 8
  	return 8;
  # else
  	return 4;
  # endif  // SIZE == 8
  	
  	return null;
  }
  "!

Item was changed:
  ----- Method: SlangTest>>testIfdefElseEndif (in category 'testing preprocessor directives') -----
  testIfdefElseEndif
  	"Test isDefined:inSmalltalk:comment:ifTrue:ifFalse: "
  
  	"(SlangTest selector: #testIfdefElseEndif) run"
  
+ 	| stssi cString stringWithoutWhiteSpace lines |
- 	| cString stringWithoutWhiteSpace lines |
  	self flag: #FIXME. "See redundant implementation in oscog #cppIf:ifTrue:ifFalse:"
  
+ 	stssi := SlangTestSupportInterpreter inline: false.
+ 
  	"verify that the default Smalltalk block that is evaluated in simulation"
+ 	self assert: stssi ifdefElseEndif = #defaultBlockForSimulation.
- 	self assert: SlangTestSupportInterpreter new ifdefElseEndif = #defaultBlockForSimulation.
  
  	"verify generated C string"
+ 	cString := stssi asCString: #ifdefElseEndif.
- 	cString := SlangTestSupportInterpreter asCString: #ifdefElseEndif.
  	lines := (cString findTokens: Character cr) select: [:e |
  		{
  			'# ifdef HAVE_FOO  // some platforms do not support foo properly' .
  			'	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"
  	stringWithoutWhiteSpace := cString reject: [:e | e isSeparator].
  	self should: stringWithoutWhiteSpace =
  		'sqIntifdefElseEndif(void){#ifdefHAVE_FOO//someplatformsdonotsupportfooproperlyreturn1;#elsereturn0;#endif//HAVE_FOOreturnnull;}'.
  
  "
  sqInt ifdefElseEndif(void) {
  	
  # ifdef HAVE_FOO  // some platforms do not support foo properly
  	return 1;
  # else
  	return 0;
  # endif  // HAVE_FOO
  	
  	return null;
  }
  "!

Item was changed:
  ----- Method: SlangTest>>testIfdefEndif (in category 'testing preprocessor directives') -----
  testIfdefEndif
  	"Test isDefined:inSmalltalk:comment:ifTrue: "
  
  	"(SlangTest selector: #testIfdefEndif) run"
  
+ 	| stssi cString stringWithoutWhiteSpace lines |
- 	| cString stringWithoutWhiteSpace lines |
  	self flag: #FIXME. "See redundant implementation in oscog #cppIf:ifTrue:"
  
+ 	stssi := SlangTestSupportInterpreter inline: false.
+ 
  	"verify that the default Smalltalk block that is evaluated in simulation"
+ 	self assert: stssi ifdefEndif = #defaultBlockForSimulation.
- 	self assert: SlangTestSupportInterpreter new ifdefEndif = #defaultBlockForSimulation.
  
  	"verify generated C string"
+ 	cString := stssi asCString: #ifdefEndif.
- 	cString := SlangTestSupportInterpreter asCString: #ifdefEndif.
  	lines := (cString findTokens: Character cr) select: [:e |
  		{
  			'# ifdef HAVE_FOO  // some platforms do not support foo properly' .
  			'	return 1;' .
  			'# endif  // HAVE_FOO'
  		} includes: e ].
  	self should: lines size = 3.
  
  	"check the rest of the method, ignoring whitespace"
+ 	cString := stssi asCString: #ifdefEndif.
- 	cString := SlangTestSupportInterpreter asCString: #ifdefEndif.
  	stringWithoutWhiteSpace := cString reject: [:e | e isSeparator].
  	self should: stringWithoutWhiteSpace =
  		'sqIntifdefEndif(void){#ifdefHAVE_FOO//someplatformsdonotsupportfooproperlyreturn1;#endif//HAVE_FOOreturn0;}'.
  
  "
  sqInt ifdefEndif(void) {
  	
  # ifdef HAVE_FOO  // some platforms do not support foo properly
  	return 1;
  # endif  // HAVE_FOO
  	
  	return 0;
  }
  "!

Item was changed:
  ----- Method: SlangTest>>testInterpDeclareExport (in category 'testing interpreter') -----
  testInterpDeclareExport
  	"Pragma declarations should generate the same C source code as the
  	traditional method send declarations"
  
+ 	| stssi m p |
+ 	stssi := SlangTestSupportInterpreter inline: false.
+ 	m := (stssi asCString: #declareExportTrueByMethod)
- 	| m p |
- 	m := (SlangTestSupportInterpreter asCString: #declareExportTrueByMethod)
  			copyReplaceAll: 'declareExportTrueByMethod'
  			with: 'methodName'.
+ 	p := (stssi asCString: #declareExportTrueByPragma)
- 	p := (SlangTestSupportInterpreter asCString: #declareExportTrueByPragma)
  			copyReplaceAll: 'declareExportTrueByPragma'
  			with: 'methodName'.
  	self assert: m = p.
  
+ 	m := (stssi asCString: #declareExportFalseByMethod)
- 	m := (SlangTestSupportInterpreter asCString: #declareExportFalseByMethod)
  			copyReplaceAll: 'declareExportFalseByMethod'
  			with: 'methodName'.
+ 	p := (stssi asCString: #declareExportFalseByPragma)
- 	p := (SlangTestSupportInterpreter asCString: #declareExportFalseByPragma)
  			copyReplaceAll: 'declareExportFalseByPragma'
  			with: 'methodName'.
  	self assert: m = p.!

Item was changed:
  ----- Method: SlangTest>>testInterpDeclareInline (in category 'testing interpreter') -----
  testInterpDeclareInline
  	"Pragma declarations should generate the same C source code as the
  	traditional method send declarations"
  
+ 	| stssi m p |
+ 	stssi := SlangTestSupportInterpreter inline: true.
+ 	m := ((stssi asCString: #inlineByMethod)
- 	| m p |
- 	m := ((SlangTestSupportInterpreter asInlinedCString: #inlineByMethod)
  			copyReplaceAll: 'inlineByMethod'
  			with: 'methodName')
  				copyReplaceAll: 'methodThatShouldNotBeInlinedByMethod'
  				with: 'calledMethodName'.
+ 	p := ((stssi asCString: #inlineByPragma)
- 	p := ((SlangTestSupportInterpreter asInlinedCString: #inlineByPragma)
  			copyReplaceAll: 'inlineByPragma'
  			with: 'methodName')
  				copyReplaceAll: 'methodThatShouldNotBeInlinedByPragma'
  				with: 'calledMethodName'.
  	self assert: m = p!

Item was changed:
  ----- Method: SlangTest>>testInterpDeclareStatic (in category 'testing interpreter') -----
  testInterpDeclareStatic
  	"A static directive should cause the generated function to be declared static."
  
+ 	| stssi m1 p1 m2 p2 |
+ 	stssi := SlangTestSupportInterpreter inline: false.
+ 	m1 := (stssi asCString: #declareStaticTrueByMethod)
- 	| m1 p1 m2 p2 |
- 	m1 := (SlangTestSupportInterpreter asCString: #declareStaticTrueByMethod)
  			copyReplaceAll: 'declareStaticTrueByMethod'
  			with: 'methodName'.
+ 	p1 := (stssi asCString: #declareStaticTrueByPragma)
- 	p1 := (SlangTestSupportInterpreter asCString: #declareStaticTrueByPragma)
  			copyReplaceAll: 'declareStaticTrueByPragma'
  			with: 'methodName'.
  	self assert: m1 = p1.
  
+ 	m2 := (stssi asCString: #declareStaticFalseByMethod)
- 	m2 := (SlangTestSupportInterpreter asCString: #declareStaticFalseByMethod)
  			copyReplaceAll: 'declareStaticFalseByMethod'
  			with: 'methodName'.
+ 	p2 := (stssi asCString: #declareStaticFalseByPragma)
- 	p2 := (SlangTestSupportInterpreter asCString: #declareStaticFalseByPragma)
  			copyReplaceAll: 'declareStaticFalseByPragma'
  			with: 'methodName'.
  	self assert: m2 = p2.
  
  	"verify that the keyword 'static appears in the generated C source"
  	self assert: (m1 includesSubString: 'static').
  	self assert: (p1 includesSubString: 'static').
  	self deny: (m2 includesSubString: 'static').
  	self deny: (p2 includesSubString: 'static')
  !

Item was changed:
  ----- Method: SlangTest>>testInterpDoNotdoNotGenerateByMethod (in category 'testing interpreter') -----
  testInterpDoNotdoNotGenerateByMethod
  	"A doNotdoNotGenerate statement should prevent code generation"
  
+ 	"(SlangTest selector: #testInterpDoNotdoNotGenerateByMethod) debug"
+ 
+ 	| stssi m |
+ 	stssi := SlangTestSupportInterpreter inline: false.
- 	| m |
  	self assert: (SlangTestSupportInterpreter canUnderstand: #doNotGenerateByMethod).
+ 	m := stssi asCString: #doNotGenerateByMethod.
- 	m := SlangTestSupportInterpreter asCString: #doNotGenerateByMethod.
  	self assert: (m includesSubString: 'No source has been generated').
+ 	self deny: (stssi asCString includesSubString: 'doNotGenerateByMethod').
+ 	self assert: (stssi doNotGenerateByMethod = 4)
- 	self deny: (SlangTestSupportInterpreter asCString includesSubString: 'doNotGenerateByMethod').
- 	self assert: (SlangTestSupportInterpreter new doNotGenerateByMethod = 4)
  
  !

Item was changed:
  ----- Method: SlangTest>>testInterpDoNotdoNotGenerateByPragma (in category 'testing interpreter') -----
  testInterpDoNotdoNotGenerateByPragma
  	"A <doNotdoNotGenerate> declaration should prevent code generation"
  
+ 	| stssi m |
+ 	stssi := SlangTestSupportInterpreter inline: false.
- 	| m |
  	self assert: (SlangTestSupportInterpreter canUnderstand: #doNotGenerateByPragma).
+ 	m := stssi asCString: #doNotGenerateByPragma.
- 	m := SlangTestSupportInterpreter asCString: #doNotGenerateByPragma.
  	self assert: (m includesSubString: 'No source has been generated').
+ 	self deny: (stssi asCString includesSubString: 'doNotGenerateByPragma').
+ 	self assert: (stssi doNotGenerateByPragma = 4)
- 	self deny: (SlangTestSupportInterpreter asCString includesSubString: 'doNotGenerateByPragma').
- 	self assert: (SlangTestSupportInterpreter new doNotGenerateByPragma = 4)
  !

Item was changed:
  ----- Method: SlangTest>>testInterpDoNotdoNotGenerateSubclassResponsibility (in category 'testing interpreter') -----
  testInterpDoNotdoNotGenerateSubclassResponsibility
  	"If a method contains self subclassResponsibility, assume it is not meant for translation."
  
+ 	| stssi m |
+ 	stssi := SlangTestSupportInterpreter inline: false.
- 	| m |
  	self assert: (SlangTestSupportInterpreter canUnderstand: #anAbstractMethod).
+ 	m := stssi asCString: #anAbstractMethod.
- 	m := SlangTestSupportInterpreter asCString: #anAbstractMethod.
  	self assert: (m includesSubString: 'No source has been generated').
+ 	self deny: (stssi asCString includesSubString: 'anAbstractMethod').
+ 	self should: [stssi anAbstractMethod]
- 	self deny: (SlangTestSupportInterpreter asCString includesSubString: 'anAbstractMethod').
- 	self should: [SlangTestSupportInterpreter new anAbstractMethod]
  		raise: Error
  
  !

Item was changed:
  ----- Method: SlangTest>>testInterpMixedMethodAndPragmaDeclarations (in category 'testing interpreter') -----
  testInterpMixedMethodAndPragmaDeclarations
  	"Pragmas and method declarations should coexist"
  
+ 	| stssi s |
+ 	stssi := SlangTestSupportInterpreter inline: false.
+ 	s := (stssi asCString: #varDefByMethodAndPragma)
- 	| s |
- 	s := (SlangTestSupportInterpreter asCString: #varDefByMethodAndPragma)
  			copyReplaceAll: 'varDefByMethod'
  			with: 'methodName'.
  	self assert: (s includesSubString: 'unsigned int * bar').
  	self assert: (s includesSubString: 'char *foo').
  	self assert: (s includesSubString: 'float baz').
  	self assert: (s includesSubString: 'double fum').
  !

Item was changed:
  ----- Method: SlangTest>>testInterpReturnTypeC (in category 'testing interpreter') -----
  testInterpReturnTypeC
  	"Pragma declarations should generate the same C source code as the
  	traditional method send declarations"
  
+ 	| stssi m p |
+ 	stssi := SlangTestSupportInterpreter inline: false.
+ 	m := (stssi asCString: #returnTypeByMethod)
- 	| m p |
- 	m := (SlangTestSupportInterpreter asCString: #returnTypeByMethod)
  			copyReplaceAll: 'returnTypeByMethod'
  			with: 'methodName'.
+ 	p := (stssi asCString: #returnTypeByPragma)
- 	p := (SlangTestSupportInterpreter asCString: #returnTypeByPragma)
  			copyReplaceAll: 'returnTypeByPragma'
  			with: 'methodName'.
  	self assert: m = p!

Item was changed:
  ----- Method: SlangTest>>testInterpTypeDeclarations (in category 'testing interpreter') -----
  testInterpTypeDeclarations
  	"Pragma declarations should generate the same C source code as the
  	traditional method send declarations"
  
+ 	| stssi m p |
+ 	stssi := SlangTestSupportInterpreter inline: false.
+ 	m := (stssi asCString: #varDefByMethod)
- 	| m p |
- 	m := (SlangTestSupportInterpreter asCString: #varDefByMethod)
  			copyReplaceAll: 'varDefByMethod'
  			with: 'methodName'.
+ 	p := (stssi asCString: #varDefByPragma)
- 	p := (SlangTestSupportInterpreter asCString: #varDefByPragma)
  			copyReplaceAll: 'varDefByPragma'
  			with: 'methodName'.
  	self assert: m = p!

Item was changed:
  ----- Method: SlangTest>>testIvarShouldNotBeRedeclaredAsLocal (in category 'testing variable declaration') -----
  testIvarShouldNotBeRedeclaredAsLocal
  	"Document a bug in some versions of the code generator. If an instance variable is
  	referenced in the generated code, that variable should not be declared as a local
  	in the function."
  
+ 	| stssi s |
+ 	stssi := SlangTestSupportInterpreter inline: false.
+ 	s := stssi asCString: #setBreakSelector: .
- 	| s |
- 	s := SlangTestSupportInterpreter asCString: #setBreakSelector: .
  	self deny: (s includesSubString: 'sqInt breakSelector;')
  !

Item was changed:
  ----- Method: SlangTest>>testLocalizeGlobalVariables (in category 'testing variable declaration') -----
  testLocalizeGlobalVariables
  	"CCodeGenerator>>localizeGlobalVariables performs an optimization
  	that may be misleading when introducing a new method. This test
  	documents that optimization.
  	
  	If a method makes reference to an instance variable, and if this is the
  	only method containing a reference to that variable, then the C translator
  	will produce a local variable declaration in the generated function, and no
  	global declaration will appear in the generated source file. This optimization
  	is applied after inlining has been performed, so there are legitimate cases
  	where a variable must be an instance variable referenced by two methods,
  	but can be made local if those methods are inlined into a single method
  	and only one method reference to the variable remains. See
  	ObjectMemory>>markAndSweep: for an example."
  
+ 	| stssi s |
+ 	stssi := SlangTestSupportInterpreter inline: false.
+ 	s := stssi asCString: #methodWithReferenceToVariables .
- 	| s |
- 	s := SlangTestSupportInterpreter asCString: #methodWithReferenceToVariables .
  	"variable with one method reference is promoted to a local method variable"
  	self assert: (s includesSubString: 'sqInt aVarWithOneReference;').
  	"normal expected behavior, the variable is global in the generated source module."
  	self deny: (s includesSubString: 'sqInt aVarWithTwoReferences;')
  !

Item was changed:
  ----- Method: SlangTest>>testPluginDeclareExport (in category 'testing base plugins') -----
  testPluginDeclareExport
  	"Pragma declarations should generate the same C source code as the
  	traditional method send declarations"
  
+ 	| stsp m p |
+ 	stsp := SlangTestSupportPlugin inline: false.
+ 	m := (stsp asCString: #declareExportTrueByMethod)
- 	| m p |
- 	m := (SlangTestSupportPlugin asCString: #declareExportTrueByMethod)
  			copyReplaceAll: 'declareExportTrueByMethod'
  			with: 'methodName'.
+ 	p := (stsp asCString: #declareExportTrueByPragma)
- 	p := (SlangTestSupportPlugin asCString: #declareExportTrueByPragma)
  			copyReplaceAll: 'declareExportTrueByPragma'
  			with: 'methodName'.
  	self assert: m = p.
  
+ 	m := (stsp asCString: #declareExportFalseByMethod)
- 	m := (SlangTestSupportPlugin asCString: #declareExportFalseByMethod)
  			copyReplaceAll: 'declareExportFalseByMethod'
  			with: 'methodName'.
+ 	p := (stsp asCString: #declareExportFalseByPragma)
- 	p := (SlangTestSupportPlugin asCString: #declareExportFalseByPragma)
  			copyReplaceAll: 'declareExportFalseByPragma'
  			with: 'methodName'.
  	self assert: m = p.!

Item was changed:
  ----- Method: SlangTest>>testPluginDeclareInline (in category 'testing base plugins') -----
  testPluginDeclareInline
  	"Pragma declarations should generate the same C source code as the
  	traditional method send declarations"
  
+ 	| stsp m p |
+ 	stsp := SlangTestSupportPlugin inline: true.
+ 	m := ((stsp asCString: #inlineByMethod)
- 	| m p |
- 	m := ((SlangTestSupportPlugin asInlinedCString: #inlineByMethod)
  			copyReplaceAll: 'inlineByMethod'
  			with: 'methodName')
  				copyReplaceAll: 'methodThatShouldNotBeInlinedByMethod'
  				with: 'calledMethodName'.
+ 	p := ((stsp asCString: #inlineByPragma)
- 	p := ((SlangTestSupportPlugin asInlinedCString: #inlineByPragma)
  			copyReplaceAll: 'inlineByPragma'
  			with: 'methodName')
  				copyReplaceAll: 'methodThatShouldNotBeInlinedByPragma'
  				with: 'calledMethodName'.
  	self assert: m = p!

Item was changed:
  ----- Method: SlangTest>>testPluginDeclareStatic (in category 'testing base plugins') -----
  testPluginDeclareStatic
  	"A static directive should cause the generated function to be declared static."
  
+ 	| stsp m1 p1 m2 p2 |
+ 	stsp := SlangTestSupportPlugin inline: false.
+ 	m1 := (stsp asCString: #declareStaticTrueByMethod)
- 	| m1 p1 m2 p2 |
- 	m1 := (SlangTestSupportPlugin asCString: #declareStaticTrueByMethod)
  			copyReplaceAll: 'declareStaticTrueByMethod'
  			with: 'methodName'.
+ 	p1 := (stsp asCString: #declareStaticTrueByPragma)
- 	p1 := (SlangTestSupportPlugin asCString: #declareStaticTrueByPragma)
  			copyReplaceAll: 'declareStaticTrueByPragma'
  			with: 'methodName'.
  	self assert: m1 = p1.
  
+ 	m2 := (stsp asCString: #declareStaticFalseByMethod)
- 	m2 := (SlangTestSupportPlugin asCString: #declareStaticFalseByMethod)
  			copyReplaceAll: 'declareStaticFalseByMethod'
  			with: 'methodName'.
+ 	p2 := (stsp asCString: #declareStaticFalseByPragma)
- 	p2 := (SlangTestSupportPlugin asCString: #declareStaticFalseByPragma)
  			copyReplaceAll: 'declareStaticFalseByPragma'
  			with: 'methodName'.
  	self assert: m2 = p2.
  
  	"verify that the keyword 'static appears in the generated C source"
  	self assert: (m1 includesSubString: 'static').
  	self assert: (p1 includesSubString: 'static').
  	self deny: (m2 includesSubString: 'static').
  	self deny: (p2 includesSubString: 'static')
  !

Item was changed:
  ----- Method: SlangTest>>testPluginDoNotGenerateByMethod (in category 'testing base plugins') -----
  testPluginDoNotGenerateByMethod
  	"A doNotdoNotGenerate statement should prevent code generation"
  
+ 	| stsp m |
+ 	stsp := SlangTestSupportPlugin inline: false.
- 	| m |
  	self assert: (SlangTestSupportPlugin canUnderstand: #doNotGenerateByMethod).
+ 	m := stsp asCString: #doNotGenerateByMethod.
- 	m := SlangTestSupportPlugin asCString: #doNotGenerateByMethod.
  	self assert: (m includesSubString: 'No source has been generated').
+ 	self deny: (stsp asCString includesSubString: 'doNotGenerateByMethod').
+ 	self assert: (stsp doNotGenerateByMethod = 4)
- 	self deny: (SlangTestSupportPlugin asCString includesSubString: 'doNotGenerateByMethod').
- 	self assert: (SlangTestSupportPlugin new doNotGenerateByMethod = 4)
  !

Item was changed:
  ----- Method: SlangTest>>testPluginDoNotGenerateByPragma (in category 'testing base plugins') -----
  testPluginDoNotGenerateByPragma
  	"A <doNotdoNotGenerate> declaration should prevent code generation"
  
+ 	| stsp m |
+ 	stsp := SlangTestSupportPlugin inline: false.
- 	| m |
  	self assert: (SlangTestSupportPlugin canUnderstand: #doNotGenerateByPragma).
+ 	m := stsp asCString: #doNotGenerateByPragma.
- 	m := SlangTestSupportPlugin asCString: #doNotGenerateByPragma.
  	self assert: (m includesSubString: 'No source has been generated').
+ 	self deny: (stsp asCString includesSubString: 'doNotGenerateByPragma').
+ 	self assert: (stsp doNotGenerateByPragma = 4)
- 	self deny: (SlangTestSupportPlugin asCString includesSubString: 'doNotGenerateByPragma').
- 	self assert: (SlangTestSupportPlugin new doNotGenerateByPragma = 4)
  !

Item was changed:
  ----- Method: SlangTest>>testPluginDoNotGenerateSubclassResponsibility (in category 'testing base plugins') -----
  testPluginDoNotGenerateSubclassResponsibility
  	"If a method contains self subclassResponsibility, assume it is not meant for translation."
  
+ 	| stsp m |
+ 	stsp := SlangTestSupportPlugin inline: false.
- 	| m |
  	self assert: (SlangTestSupportPlugin canUnderstand: #anAbstractMethod).
+ 	m := stsp asCString: #anAbstractMethod.
- 	m := SlangTestSupportPlugin asCString: #anAbstractMethod.
  	self assert: (m includesSubString: 'No source has been generated').
+ 	self deny: (stsp asCString includesSubString: 'anAbstractMethod').
+ 	self should: [stsp anAbstractMethod]
- 	self deny: (SlangTestSupportPlugin asCString includesSubString: 'anAbstractMethod').
- 	self should: [SlangTestSupportPlugin new anAbstractMethod]
  		raise: Error
  !

Item was changed:
  ----- Method: SlangTest>>testPluginMixedMethodAndPragmaDeclarations (in category 'testing base plugins') -----
  testPluginMixedMethodAndPragmaDeclarations
  	"Pragmas and method declarations should coexist"
  
+ 	| stsp s |
+ 	stsp := SlangTestSupportPlugin inline: false.
+ 	s := (stsp asCString: #varDefByMethodAndPragma)
- 	| s |
- 	s := (SlangTestSupportPlugin asCString: #varDefByMethodAndPragma)
  			copyReplaceAll: 'varDefByMethod'
  			with: 'methodName'.
  	self assert: (s includesSubString: 'unsigned int * bar').
  	self assert: (s includesSubString: 'char *foo').
  	self assert: (s includesSubString: 'float baz').
  	self assert: (s includesSubString: 'double fum').
  !

Item was changed:
  ----- Method: SlangTest>>testPluginReturnTypeC (in category 'testing base plugins') -----
  testPluginReturnTypeC
  	"Pragma declarations should generate the same C source code as the
  	traditional method send declarations"
  
+ 	| stsp m p |
+ 	stsp := SlangTestSupportPlugin inline: false.
+ 	m := (stsp asCString: #returnTypeByMethod)
- 	| m p |
- 	m := (SlangTestSupportPlugin asCString: #returnTypeByMethod)
  			copyReplaceAll: 'returnTypeByMethod'
  			with: 'methodName'.
+ 	p := (stsp asCString: #returnTypeByPragma)
- 	p := (SlangTestSupportPlugin asCString: #returnTypeByPragma)
  			copyReplaceAll: 'returnTypeByPragma'
  			with: 'methodName'.
  	self assert: m = p!

Item was changed:
  ----- Method: SlangTest>>testPluginTypeDeclarations (in category 'testing base plugins') -----
  testPluginTypeDeclarations
  	"Pragma declarations should generate the same C source code as the
  	traditional method send declarations"
  
+ 	| stsp m p |
+ 	stsp := SlangTestSupportPlugin inline: false.
+ 	m := (stsp asCString: #varDefByMethod)
- 	| m p |
- 	m := (SlangTestSupportPlugin asCString: #varDefByMethod)
  			copyReplaceAll: 'varDefByMethod'
  			with: 'methodName'.
+ 	p := (stsp asCString: #varDefByPragma)
- 	p := (SlangTestSupportPlugin asCString: #varDefByPragma)
  			copyReplaceAll: 'varDefByPragma'
  			with: 'methodName'.
  	self assert: m = p!

Item was changed:
  ----- Method: SlangTest>>testPreprocessorExpression (in category 'testing preprocessor directives') -----
  testPreprocessorExpression
  	"Test preprocessorExpression: "
  
  	"(SlangTest selector: #testPreprocessorExpression) run"
  
+ 	| stssi cString |
- 	| cString |
  	self flag: #FIXME. "See redundant implementation in oscog #cPreprocessorDirective: "
  
+ 	stssi := SlangTestSupportInterpreter inline: false.
+ 	cString := stssi asCString: #preprocessorExpression.
- 	cString := SlangTestSupportInterpreter asCString: #preprocessorExpression.
  	self should: ('*# define FOO bar*' match: cString).
  	self should: ((cString findTokens: Character cr) select: [:e | e = '# define FOO bar' ]) size = 1.
  	self should: ((cString findTokens: Character cr) select: [:e | e = '## define FOO bar' ]) size = 0.
  !

Item was changed:
  ----- Method: SlangTest>>testSSIPDeclareExport (in category 'testing ssip plugins') -----
  testSSIPDeclareExport
  	"Pragma declarations should generate the same C source code as the
  	traditional method send declarations"
  
+ 	| stss m p |
+ 	stss := SlangTestSupportSSIP inline: false.
+ 	m := (stss asCString: #declareExportTrueByMethod)
- 	| m p |
- 	m := (SlangTestSupportSSIP asCString: #declareExportTrueByMethod)
  			copyReplaceAll: 'declareExportTrueByMethod'
  			with: 'methodName'.
+ 	p := (stss asCString: #declareExportTrueByPragma)
- 	p := (SlangTestSupportSSIP asCString: #declareExportTrueByPragma)
  			copyReplaceAll: 'declareExportTrueByPragma'
  			with: 'methodName'.
  	self assert: m = p.
  
+ 	m := (stss asCString: #declareExportFalseByMethod)
- 	m := (SlangTestSupportSSIP asCString: #declareExportFalseByMethod)
  			copyReplaceAll: 'declareExportFalseByMethod'
  			with: 'methodName'.
+ 	p := (stss asCString: #declareExportFalseByPragma)
- 	p := (SlangTestSupportSSIP asCString: #declareExportFalseByPragma)
  			copyReplaceAll: 'declareExportFalseByPragma'
  			with: 'methodName'.
  	self assert: m = p.!

Item was changed:
  ----- Method: SlangTest>>testSSIPDeclareInline (in category 'testing ssip plugins') -----
  testSSIPDeclareInline
  	"Pragma declarations should generate the same C source code as the
  	traditional method send declarations"
  
+ 	| stss m p |
+ 	stss := SlangTestSupportSSIP inline: true.
+ 	m := ((stss asCString: #inlineByMethod)
- 	| m p |
- 	m := ((SlangTestSupportSSIP asInlinedCString: #inlineByMethod)
  			copyReplaceAll: 'inlineByMethod'
  			with: 'methodName')
  				copyReplaceAll: 'methodThatShouldNotBeInlinedByMethod'
  				with: 'calledMethodName'.
+ 	p := ((stss asCString: #inlineByPragma)
- 	p := ((SlangTestSupportSSIP asInlinedCString: #inlineByPragma)
  			copyReplaceAll: 'inlineByPragma'
  			with: 'methodName')
  				copyReplaceAll: 'methodThatShouldNotBeInlinedByPragma'
  				with: 'calledMethodName'.
  	self assert: m = p!

Item was changed:
  ----- Method: SlangTest>>testSSIPDeclareStatic (in category 'testing ssip plugins') -----
  testSSIPDeclareStatic
  	"A static directive should cause the generated function to be declared static."
  
+ 	| stss m1 p1 m2 p2 |
+ 	stss := SlangTestSupportSSIP inline: false.
+ 	m1 := (stss asCString: #declareStaticTrueByMethod)
- 	| m1 p1 m2 p2 |
- 	m1 := (SlangTestSupportSSIP asCString: #declareStaticTrueByMethod)
  			copyReplaceAll: 'declareStaticTrueByMethod'
  			with: 'methodName'.
+ 	p1 := (stss asCString: #declareStaticTrueByPragma)
- 	p1 := (SlangTestSupportSSIP asCString: #declareStaticTrueByPragma)
  			copyReplaceAll: 'declareStaticTrueByPragma'
  			with: 'methodName'.
  	self assert: m1 = p1.
  
+ 	m2 := (stss asCString: #declareStaticFalseByMethod)
- 	m2 := (SlangTestSupportSSIP asCString: #declareStaticFalseByMethod)
  			copyReplaceAll: 'declareStaticFalseByMethod'
  			with: 'methodName'.
+ 	p2 := (stss asCString: #declareStaticFalseByPragma)
- 	p2 := (SlangTestSupportSSIP asCString: #declareStaticFalseByPragma)
  			copyReplaceAll: 'declareStaticFalseByPragma'
  			with: 'methodName'.
  	self assert: m2 = p2.
  
  	"verify that the keyword 'static appears in the generated C source"
  	self assert: (m1 includesSubString: 'static').
  	self assert: (p1 includesSubString: 'static').
  	self deny: (m2 includesSubString: 'static').
  	self deny: (p2 includesSubString: 'static')
  !

Item was changed:
  ----- Method: SlangTest>>testSSIPDoNotGenerateByMethod (in category 'testing ssip plugins') -----
  testSSIPDoNotGenerateByMethod
  	"A doNotdoNotGenerate statement should prevent code generation"
  
+ 	| stss m |
+ 	stss := SlangTestSupportSSIP inline: false.
- 	| m |
  	self assert: (SlangTestSupportSSIP canUnderstand: #doNotGenerateByMethod).
+ 	m := stss asCString: #doNotGenerateByMethod.
- 	m := SlangTestSupportSSIP asCString: #doNotGenerateByMethod.
  	self assert: (m includesSubString: 'No source has been generated').
+ 	self deny: (stss asCString includesSubString: 'doNotGenerateByMethod').
+ 	self assert: (stss doNotGenerateByMethod = 4)!
- 	self deny: (SlangTestSupportSSIP asCString includesSubString: 'doNotGenerateByMethod').
- 	self assert: (SlangTestSupportSSIP new doNotGenerateByMethod = 4)!

Item was changed:
  ----- Method: SlangTest>>testSSIPDoNotGenerateByPragma (in category 'testing ssip plugins') -----
  testSSIPDoNotGenerateByPragma
  	"A <doNotdoNotGenerate> declaration should prevent code generation"
  
+ 	| stss m |
+ 	stss := SlangTestSupportSSIP inline: false.
- 	| m |
  	self assert: (SlangTestSupportSSIP canUnderstand: #doNotGenerateByPragma).
+ 	m := stss asCString: #doNotGenerateByPragma.
- 	m := SlangTestSupportSSIP asCString: #doNotGenerateByPragma.
  	self assert: (m includesSubString: 'No source has been generated').
+ 	self deny: (stss asCString includesSubString: 'doNotGenerateByPragma').
+ 	self assert: (stss doNotGenerateByPragma = 4)
- 	self deny: (SlangTestSupportSSIP asCString includesSubString: 'doNotGenerateByPragma').
- 	self assert: (SlangTestSupportSSIP new doNotGenerateByPragma = 4)
  !

Item was changed:
  ----- Method: SlangTest>>testSSIPDoNotGenerateSubclassResponsibility (in category 'testing ssip plugins') -----
  testSSIPDoNotGenerateSubclassResponsibility
  	"If a method contains self subclassResponsibility, assume it is not meant for translation."
  
+ 	| stss m |
+ 	stss := SlangTestSupportSSIP inline: false.
- 	| m |
  	self assert: (SlangTestSupportSSIP canUnderstand: #anAbstractMethod).
+ 	m := stss asCString: #anAbstractMethod.
- 	m := SlangTestSupportSSIP asCString: #anAbstractMethod.
  	self assert: (m includesSubString: 'No source has been generated').
+ 	self deny: (stss asCString includesSubString: 'anAbstractMethod').
+ 	self should: [stss anAbstractMethod]
- 	self deny: (SlangTestSupportSSIP asCString includesSubString: 'anAbstractMethod').
- 	self should: [SlangTestSupportSSIP new anAbstractMethod]
  		raise: Error
  !

Item was changed:
  ----- Method: SlangTest>>testSSIPMixedMethodAndPragmaDeclarations (in category 'testing ssip plugins') -----
  testSSIPMixedMethodAndPragmaDeclarations
  	"Pragmas and method declarations should coexist"
  
+ 	| stss s |
+ 	stss := SlangTestSupportSSIP inline: false.
+ 	s := (stss asCString: #varDefByMethodAndPragma)
- 	| s |
- 	s := (SlangTestSupportSSIP asCString: #varDefByMethodAndPragma)
  			copyReplaceAll: 'varDefByMethod'
  			with: 'methodName'.
  	self assert: (s includesSubString: 'unsigned int * bar').
  	self assert: (s includesSubString: 'char *foo').
  	self assert: (s includesSubString: 'float baz').
  	self assert: (s includesSubString: 'double fum').
  !

Item was changed:
  ----- Method: SlangTest>>testSSIPReturnTypeC (in category 'testing ssip plugins') -----
  testSSIPReturnTypeC
  	"Pragma declarations should generate the same C source code as the
  	traditional method send declarations"
  
+ 	| stss m p |
+ 	stss := SlangTestSupportSSIP inline: false.
+ 	m := (stss asCString: #returnTypeByMethod)
- 	| m p |
- 	m := (SlangTestSupportSSIP asCString: #returnTypeByMethod)
  			copyReplaceAll: 'returnTypeByMethod'
  			with: 'methodName'.
+ 	p := (stss asCString: #returnTypeByPragma)
- 	p := (SlangTestSupportSSIP asCString: #returnTypeByPragma)
  			copyReplaceAll: 'returnTypeByPragma'
  			with: 'methodName'.
  	self assert: m = p!

Item was changed:
  ----- Method: SlangTest>>testSSIPTypeDeclarations (in category 'testing ssip plugins') -----
  testSSIPTypeDeclarations
  	"Pragma declarations should generate the same C source code as the
  	traditional method send declarations"
  
+ 	| stss m p |
+ 	stss := SlangTestSupportSSIP inline: false.
+ 	m := (stss asCString: #varDefByMethod)
- 	| m p |
- 	m := (SlangTestSupportSSIP asCString: #varDefByMethod)
  			copyReplaceAll: 'varDefByMethod'
  			with: 'methodName'.
+ 	p := (stss asCString: #varDefByPragma)
- 	p := (SlangTestSupportSSIP asCString: #varDefByPragma)
  			copyReplaceAll: 'varDefByPragma'
  			with: 'methodName'.
  	self assert: m = p!

Item was changed:
  ----- Method: SlangTest>>testSetInstanceVariableWithAnAccessorMethod (in category 'testing intermediate variable removal') -----
  testSetInstanceVariableWithAnAccessorMethod
  	"Intermediate variable from parameter of accessor method should be removed.
  	This is an existing limitation of the inliner, and could be improved for better code
  	generation. It is not a bug."
  
+ 	| stssi s |
+ 	stssi := SlangTestSupportInterpreter inline: false.
+ 	s := (stssi asInlinedCString: #setInstanceVariableWithAnAccessorMethod)
- 	| s |
- 	s := (SlangTestSupportInterpreter asInlinedCString: #setInstanceVariableWithAnAccessorMethod)
  			copyReplaceAll: 'setInstanceVariableWithAnAccessorMethod'
  			with: 'methodName'.
  	self assert: (s includesSubString: 'aVariable = remap(objectMemory, nilObj);').
  
  	"Should be translated like this:
  		aVariable = remap(objectMemory, nilObj);
  
  	Not like this:
  		oop = remap(objectMemory, nilObj);
  		aVariable = oop;"
  !

Item was changed:
  ----- Method: SlangTest>>testSmartSyntaxParameterDeclaration (in category 'testing smart syntax') -----
  testSmartSyntaxParameterDeclaration
  	"(SlangTest selector: #testSmartSyntaxParameterDeclaration) run"
  
  	| s |
+ 	s := (SlangTestSupportSSIP
- 	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' "
  !

Item was changed:
  ObjectMemory subclass: #SlangTestSupportInterpreter
+ 	instanceVariableNames: 'cg inlineFlag primFailCode aVarWithOneReference aVarWithTwoReferences objectMemory aVariable breakSelector'
- 	instanceVariableNames: 'primFailCode aVarWithOneReference aVarWithTwoReferences objectMemory aVariable breakSelector'
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'VMMaker-Tests'!
  
  !SlangTestSupportInterpreter commentStamp: 'dtl 9/19/2010 21:36' prior: 0!
  SlangTestSupport implements translatable methods for use in SlangTest unit tests.
  
  	"VMMaker clearCacheEntriesFor: SlangTestSupportInterpreter.
  	SlangTestSupportInterpreter asCString"!

Item was added:
+ ----- Method: SlangTestSupportInterpreter class>>buildCodeGeneratorInlined: (in category 'translation') -----
+ buildCodeGeneratorInlined: doInlining
+ 	"Build a CCodeGenerator for this class."
+ 
+ 	 | cg |
+ 	cg := CCodeGeneratorGlobalStructure new initialize.
+ 	cg declareMethodsStatic: false.
+ 	cg permitMethodPruning: true.
+ 	cg uncheckedAbstractMethods addAll: self abstractSelectors.
+ 	^self initializeCodeGenerator: cg
+ 
+ !

Item was added:
+ ----- Method: SlangTestSupportInterpreter class>>inline: (in category 'instance creation') -----
+ inline: flag
+ 
+ 	"Transcript show: (self inline: true) asCString"
+ 
+ 	^self new inline: flag!

Item was added:
+ ----- Method: SlangTestSupportInterpreter>>asCString (in category 'translation') -----
+ asCString
+ 
+ 	| stream |
+ 	stream := ReadWriteStream on: String new.
+ 	self cg emitCCodeOn: stream doAssertions: true.
+ 	^ stream contents
+ !

Item was added:
+ ----- Method: SlangTestSupportInterpreter>>asCString: (in category 'translation') -----
+ asCString: selector
+ 
+ 	| method stream |
+ 	method := self cg methodNamed: selector.
+ 	method ifNil: [^ 'No source has been generated'].
+ 	stream := ReadWriteStream on: String new.
+ 	method emitCCodeOn: stream generator: cg.
+ 	^ stream contents
+ !

Item was added:
+ ----- Method: SlangTestSupportInterpreter>>cg (in category 'translation') -----
+ cg
+ 	"Lazy initialize, once per test"
+ 
+ 	cg ifNil: [ObjectMemory initialize; initializeConstants.
+ 		cg := self class buildCodeGeneratorInlined: inlineFlag = true.
+ 		cg prepareMethodsInlined: inlineFlag = true doAssertions: true].
+ 	^ cg!

Item was added:
+ ----- Method: SlangTestSupportInterpreter>>inline: (in category 'initialize') -----
+ inline: flag
+ 	inlineFlag := flag!

Item was changed:
  InterpreterPlugin subclass: #SlangTestSupportPlugin
+ 	instanceVariableNames: 'cg inlineFlag'
- 	instanceVariableNames: ''
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'VMMaker-Tests'!
  
  !SlangTestSupportPlugin commentStamp: 'dtl 9/19/2010 21:36' prior: 0!
  SlangTestSupport implements translatable methods for use in SlangTest unit tests.
  This is a subclass of InterpreterPlugin, which provides coverage of slang translation
  for base plugins.
  
  	"VMMaker clearCacheEntriesFor: SlangTestSupportPlugin.
  	SlangTestSupportPlugin asCString"!

Item was added:
+ ----- Method: SlangTestSupportPlugin class>>buildCodeGeneratorInlined: (in category 'translation') -----
+ buildCodeGeneratorInlined: doInlining
+ 	"Build a CCodeGenerator for this class."
+ 
+ 	 | cg |
+ 	cg := VMPluginCodeGenerator new initialize.
+ 	cg declareMethodsStatic: false.
+ 	cg permitMethodPruning: true.
+ 	cg uncheckedAbstractMethods addAll: self abstractSelectors.
+ 	^self initializeCodeGenerator: cg
+ 
+ !

Item was added:
+ ----- Method: SlangTestSupportPlugin class>>inline: (in category 'instance creation') -----
+ inline: flag
+ 
+ 	"Transcript show: (self inline: true) asCString"
+ 
+ 	^self new inline: flag!

Item was added:
+ ----- Method: SlangTestSupportPlugin class>>shouldBeTranslated (in category 'translation') -----
+ shouldBeTranslated
+ 	"Translated only for unit test support. The generated C module is not expected
+ 	to be compiled."
+ 	^false!

Item was added:
+ ----- Method: SlangTestSupportPlugin>>asCString (in category 'translation') -----
+ asCString
+ 
+ 	| stream |
+ 	stream := ReadWriteStream on: String new.
+ 	self cg emitCCodeOn: stream doAssertions: true.
+ 	^ stream contents
+ !

Item was added:
+ ----- Method: SlangTestSupportPlugin>>asCString: (in category 'translation') -----
+ asCString: selector
+ 
+ 	| method stream |
+ 	method := self cg methodNamed: selector.
+ 	method ifNil: [^ 'No source has been generated'].
+ 	stream := ReadWriteStream on: String new.
+ 	method emitCCodeOn: stream generator: cg.
+ 	^ stream contents
+ !

Item was added:
+ ----- Method: SlangTestSupportPlugin>>cg (in category 'translation') -----
+ cg
+ 	"Lazy initialize, once per test"
+ 
+ 	cg ifNil: [ObjectMemory initialize; initializeConstants.
+ 		cg := self class buildCodeGeneratorInlined: inlineFlag = true.
+ 		cg prepareMethodsInlined: inlineFlag = true doAssertions: true].
+ 	^ cg!

Item was added:
+ ----- Method: SlangTestSupportPlugin>>inline: (in category 'initialize') -----
+ inline: flag
+ 	inlineFlag := flag!

Item was changed:
  SmartSyntaxInterpreterPlugin subclass: #SlangTestSupportSSIP
+ 	instanceVariableNames: 'cg inlineFlag'
- 	instanceVariableNames: ''
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'VMMaker-Tests'!
  
  !SlangTestSupportSSIP commentStamp: 'dtl 9/19/2010 11:38' prior: 0!
  SlangTestSupportSSIP implements translatable methods for use in SlangTest unit tests.
  It is a subclass of SmartSyntaxInterpreterPlugin, which requires additional
  test coverage.
  
  	"VMMaker clearCacheEntriesFor: SlangTestSupportSSIP.
  	SlangTestSupportSSIP asCString"!

Item was added:
+ ----- Method: SlangTestSupportSSIP class>>buildCodeGeneratorInlined: (in category 'translation') -----
+ buildCodeGeneratorInlined: doInlining
+ 	"Build a CCodeGenerator for this class."
+ 
+ 	 | cg |
+ 	cg := SmartSyntaxPluginCodeGenerator new initialize.
+ 	cg declareMethodsStatic: false.
+ 	cg permitMethodPruning: true.
+ 	cg uncheckedAbstractMethods addAll: self abstractSelectors.
+ 	^self initializeCodeGenerator: cg
+ 
+ !

Item was added:
+ ----- Method: SlangTestSupportSSIP class>>inline: (in category 'instance creation') -----
+ inline: flag
+ 
+ 	"Transcript show: (self inline: true) asCString"
+ 
+ 	^self new inline: flag!

Item was added:
+ ----- Method: SlangTestSupportSSIP class>>shouldBeTranslated (in category 'translation') -----
+ shouldBeTranslated
+ 	"Translated only for unit test support. The generated C module is not expected
+ 	to be compiled."
+ 	^false!

Item was added:
+ ----- Method: SlangTestSupportSSIP>>asCString (in category 'translation') -----
+ asCString
+ 
+ 	| stream |
+ 	stream := ReadWriteStream on: String new.
+ 	self cg emitCCodeOn: stream doAssertions: true.
+ 	^ stream contents
+ !

Item was added:
+ ----- Method: SlangTestSupportSSIP>>asCString: (in category 'translation') -----
+ asCString: selector
+ 
+ 	| method stream |
+ 	method := self cg methodNamed: selector.
+ 	method ifNil: [^ 'No source has been generated'].
+ 	stream := ReadWriteStream on: String new.
+ 	method emitCCodeOn: stream generator: cg.
+ 	^ stream contents
+ !

Item was added:
+ ----- Method: SlangTestSupportSSIP>>cg (in category 'translation') -----
+ cg
+ 	"Lazy initialize, once per test"
+ 
+ 	cg ifNil: [ObjectMemory initialize; initializeConstants.
+ 		cg := self class buildCodeGeneratorInlined: inlineFlag = true.
+ 		cg prepareMethodsInlined: inlineFlag = true doAssertions: true].
+ 	^ cg!

Item was added:
+ ----- Method: SlangTestSupportSSIP>>declareInt:wordPointer: (in category 'parameter declarations') -----
+ 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;
+ }
+ "!

Item was added:
+ ----- Method: SlangTestSupportSSIP>>inline: (in category 'initialize') -----
+ inline: flag
+ 	inlineFlag := flag!

Item was removed:
- SmartSyntaxInterpreterPlugin subclass: #SlangTestSupportSmartSyntaxInterpreterPlugin
- 	instanceVariableNames: ''
- 	classVariableNames: ''
- 	poolDictionaries: ''
- 	category: 'VMMaker-Tests'!

Item was removed:
- ----- Method: SlangTestSupportSmartSyntaxInterpreterPlugin>>declareInt:wordPointer: (in category 'parameter declarations') -----
- 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;
- }
- "!

Item was changed:
  ----- Method: SmartSyntaxPluginCodeGenerator>>initializeCTranslationDictionary (in category 'translating builtins') -----
  initializeCTranslationDictionary 
  	"Initialize the dictionary mapping message names to actions for C code generation."
  
  	| pairs |
  	super initializeCTranslationDictionary.
  	pairs := #(
  		#asCInt						#generateAsCInt:on:indent:
  		#asCUnsigned				#generateAsCUnsigned:on:indent:
  		#asCBoolean					#generateAsCBoolean:on:indent:
  		#asCDouble					#generateAsCDouble:on:indent:
  
  		#asSmallIntegerObj			#generateAsSmallIntegerObj:on:indent:
  		#asPositiveIntegerObj		#generateAsPositiveIntegerObj:on:indent:
  		#asBooleanObj				#generateAsBooleanObj:on:indent:
  		#asFloatObj					#generateAsFloatObj:on:indent:
  
  		#asIf:var:					#generateAsIfVar:on:indent:
  		#asIf:var:asValue:			#generateAsIfVarAsValue:on:indent:
  		#asIf:var:put:				#generateAsIfVarPut:on:indent:
  		#field:						#generateField:on:indent:
  		#field:put:					#generateFieldPut:on:indent:
  		
  		#class						#generateClass:on:indent:
  
  		#stSize						#generateStSize:on:indent:
  		#stAt:						#generateStAt:on:indent:
  		#stAt:put:					#generateStAtPut:on:indent:
  
  		#asCharPtr					#generateAsCharPtr:on:indent:
  		#asIntPtr					#generateAsIntPtr:on:indent:
  		#cPtrAsOop					#generateCPtrAsOop:on:indent:
  		#next						#generateNext:on:indent:
  
  		#asOop:						#generateAsOop:on:indent:
  		#asValue:					#generateAsValue:on:indent:
  
  		#isFloat						#generateIsFloat:on:indent:
  		#isIndexable					#generateIsIndexable:on:indent:
  		#isIntegerOop				#generateIsIntegerOop:on:indent:
  		#isIntegerValue				#generateIsIntegerValue:on:indent:
+ 		"#FloatOop					#generateIsFloatValue:on:indent:"		"unused, never implemented"
- 		#FloatOop					#generateIsFloatValue:on:indent:
  		#isWords					#generateIsWords:on:indent:
  		#isWordsOrBytes				#generateIsWordsOrBytes:on:indent:
  		#isPointers					#generateIsPointers:on:indent:
  		#isNil						#generateIsNil:on:indent:
  		#isMemberOf:				#generateIsMemberOf:on:indent:
  		#isKindOf:					#generateIsKindOf:on:indent:
  
  		#fromStack:					#generateFromStack:on:indent:
+ 		"#clone						#generateClone:on:indent:"				"unused, never implemented"
+ 		"#new						#generateNew:on:indent:"				"unused, never implemented"
+ 		"#new:						#generateNewSize:on:indent:"			"unused, never implemented"
+ 		"#superclass					#generateSuperclass:on:indent:"	"unused, never implemented"
- 		#clone						#generateClone:on:indent
- 		#new						#generateNew:on:indent
- 		#new:						#generateNewSize:on:indent
- 		#superclass					#generateSuperclass:on:indent:
  		#remapOop:in:				#generateRemapOopIn:on:indent:
  		#debugCode:					#generateDebugCode:on:indent:
  	).
  
  	1 to: pairs size by: 2 do: [:i |
  		translationDict at: (pairs at: i) put: (pairs at: i + 1)].
  !

Item was changed:
  ----- Method: VMMaker class>>versionString (in category 'version testing') -----
  versionString
  
  	"VMMaker versionString"
  
+ 	^'4.11.1'!
- 	^'4.10.14'!



More information about the Vm-dev mailing list