Portability: Inlined #asLegalSelector since Smalltalk/X does not support it
authorJan Vrany <jan.vrany@fit.cvut.cz>
Fri, 01 May 2015 14:39:47 +0200
changeset 445 eb33780df2f9
parent 444 a3657ab0ca6b
child 446 c2ad34a08856
Portability: Inlined #asLegalSelector since Smalltalk/X does not support it
compiler/PPCCompiler.st
--- a/compiler/PPCCompiler.st	Fri May 01 14:34:58 2015 +0200
+++ b/compiler/PPCCompiler.st	Fri May 01 14:39:47 2015 +0200
@@ -256,23 +256,30 @@
 !
 
 idFor: object prefixed: prefix suffixed: suffix effect: effect
-	| name id |
-	^ ids at: object ifAbsentPut: [ 
-		((object isKindOf: PPCNode) and: [object name isNotNil]) ifTrue: [ 
-			"Do not use prefix, if there is a name"
-			name := object name asLegalSelector.
-			id := (name, suffix) asSymbol.
-			
-			"Make sure, that the generated ID is uniqe!!"
-			(ids includes: id) ifTrue: [ 
-				(id, '_', ids size asString) asSymbol 
-			] ifFalse: [ 
-				id
-			]
-		] ifFalse: [ 
-			(prefix, '_', (ids size asString), suffix) asSymbol
-		]
-	]
+        | name id |
+        ^ ids at: object ifAbsentPut: [ 
+                ((object isKindOf: PPCNode) and: [object name isNotNil]) ifTrue: [ 
+                        "Do not use prefix, if there is a name"
+                        name := object name.
+                        "Selector sanitizing inlined here as Smalltalk/X does not
+                         support asLegalSelector"
+                        name := name select: [:char | char isAlphaNumeric].
+                        (name isEmpty or: [ name first isLetter not ])
+                            ifTrue: [ name := 'v', name ].
+                        id := (name, suffix) asSymbol.
+                        
+                        "Make sure, that the generated ID is uniqe!!"
+                        (ids includes: id) ifTrue: [ 
+                                (id, '_', ids size asString) asSymbol 
+                        ] ifFalse: [ 
+                                id
+                        ]
+                ] ifFalse: [ 
+                        (prefix, '_', (ids size asString), suffix) asSymbol
+                ]
+        ]
+
+    "Modified: / 01-05-2015 / 14:38:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !PPCCompiler methodsFor:'code generation - support'!