[Vm-dev] VM Maker: Cog-eem.441.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Sep 10 00:38:48 UTC 2021


Eliot Miranda uploaded a new version of Cog to project VM Maker:
http://source.squeak.org/VMMaker/Cog-eem.441.mcz

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

Name: Cog-eem.441
Author: eem
Time: 9 September 2021, 5:38:46.405784 pm
UUID: 298e5969-20b7-4ed9-bc9a-f18ed98be9d3
Ancestors: Cog-eem.440

Add a source cleanup script to use string for variable names and symbols for types in typed variable declarations, etc.

=============== Diff against Cog-eem.440 ===============

Item was added:
+ ----- Method: CogScripts class>>cleanUpVariableAndTypeDeclarationsIn: (in category 'plugin scripts') -----
+ cleanUpVariableAndTypeDeclarationsIn: aClass
+ 	"Three cleanups"
+ 	"CogScripts cleanUpVariableAndTypeDeclarationsIn: aClass"
+ 	"make sure var: foo uses a string for foo"
+ 	aClass selectorsAndMethodsDo:
+ 		[:s :m| | osrc src |
+ 		src := osrc := m getSourceFromFile asString.
+ 		(src indicesOfSubCollection: '<var: #') reverseDo:
+ 			[:i| | j |
+ 			(src at: i + 7) = $'
+ 				ifTrue: [src := src copyReplaceFrom: i + 6 to: i + 6 with: '']
+ 				ifFalse:
+ 					[src := (src first: i + 5),
+ 							'''',
+ 							(src copyFrom: i + 7 to: (j := src indexOf: Character space startingAt: i + 8) - 1),
+ 							'''',
+ 							(src copyFrom: j to: src size)]].
+ 		src ~= osrc ifTrue:
+ 			[aClass compile: src classified: (aClass whichCategoryIncludesSelector: s)]].
+ 
+ 	"make sure symbols are used for type in <var: 'foo' type: #type>"
+ 	aClass selectorsAndMethodsDo:
+ 		[:s :m| | osrc src |
+ 		src := osrc := m getSourceFromFile asString.
+ 		(src indicesOfSubCollection: ' type:') reverseDo:
+ 			[:i| | j k type |
+ 			((src at: (j := i + 6)) = $'
+ 			or: [(src at: i + 6) isSeparator and: [(src at: (j := i + 7)) = $']]) ifTrue:
+ 				[k := src indexOf: $' startingAt: j + 1.
+ 				type := (src copyFrom: j + 1 to: k - 1) withBlanksTrimmed.
+ 				(type includes: Character space)
+ 					ifTrue: [type := '#''', type, '''']
+ 					ifFalse: [type := '#', type].
+ 				 j = (i + 6) ifTrue:
+ 					[type := ' ', type].
+ 				 src := src copyReplaceFrom: j to: k with: type]].
+ 		src ~= osrc ifTrue:
+ 			[aClass compile: src classified: (aClass whichCategoryIncludesSelector: s)]].
+ 
+ 	"Make sure symbols are used for types in cCoerce: foo to: type"
+ 	aClass selectorsAndMethodsDo:
+ 		[:s :m| | osrc src |
+ 		src := osrc := m getSourceFromFile asString.
+ 		(src indicesOfSubCollection: ' to:') reverseDo:
+ 			[:i| | j k type |
+ 			((src at: (j := i + 4)) = $'
+ 			or: [(src at: i + 4) isSeparator and: [(src at: (j := i + 5)) = $']]) ifTrue:
+ 				[k := src indexOf: $' startingAt: j + 1.
+ 				type := (src copyFrom: j + 1 to: k - 1) withBlanksTrimmed.
+ 				(type includes: Character space)
+ 					ifTrue: [type := '#''', type, '''']
+ 					ifFalse: [type := '#', type].
+ 				 j = (i + 4) ifTrue:
+ 					[type := ' ', type].
+ 				 src := src copyReplaceFrom: j to: k with: type]].
+ 		src ~= osrc ifTrue:
+ 			[aClass compile: src classified: (aClass whichCategoryIncludesSelector: s)]]
+ 
+ 	"and this is for emergencies... (spaces missing from #'foo *' types)
+ 
+ 	[:class|
+ 	 class selectorsAndMethodsDo:
+ 		[:s :m| | osrc src |
+ 		src := osrc := m getSourceFromFile asString.
+ 		(src indicesOfSubCollection: '''int*''') reverseDo:
+ 			[:i|
+ 			src := (src first: i - 1), '''int *''', (src copyFrom: i + 6 to: src size)].
+ 		src ~= osrc ifTrue:
+ 			[class compile: src classified: (class whichCategoryIncludesSelector: s)]]] value: BalloonEnginePlugin."!



More information about the Vm-dev mailing list