Nicolas Cellier uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-nice.2911.mcz==================== Summary ====================
Name: VMMaker.oscog-nice.2911
Author: nice
Time: 27 December 2020, 3:28:06.697857 pm
UUID: 5c1ef787-4a6b-4b99-9298-d4823eca470e
Ancestors: VMMaker.oscog-nice.2910
Simplify the rule for generating hex literal constants when more intellegible than decimal.
This is useful for having a chance to decipher generated code for bit tricks.
=============== Diff against VMMaker.oscog-nice.2910 ===============
Item was changed:
----- Method: CCodeGenerator>>cLiteralFor: (in category 'C code generator') -----
cLiteralFor: anObject
"Return a string representing the C literal value for the given object."
anObject isNumber
ifTrue:
[anObject isInteger ifTrue:
[| hex |
+ hex := (anObject > 255 and: [(anObject hex asSet size * 3) <= (anObject printString asSet size * 2)]).
- hex := (anObject > 0
- and: [(anObject >> anObject lowBit + 1) isPowerOfTwo
- and: [(anObject highBit = anObject lowBit and: [anObject > 65536])
- or: [anObject highBit - anObject lowBit >= 4]]]).
^self cLiteralForInteger: anObject hex: hex].
anObject isFloat ifTrue:
[^anObject printString]]
ifFalse:
[anObject isSymbol ifTrue:
[^self cFunctionNameFor: anObject].
anObject isString ifTrue:
[^'"', (anObject copyReplaceAll: (String with: Character cr) with: '\n') , '"'].
anObject == nil ifTrue: [^ 'null' ].
anObject == true ifTrue: [^ '1' ].
anObject == false ifTrue: [^ '0' ].
anObject isCharacter ifTrue:
[^anObject == $'
ifTrue: ['''\'''''] "i.e. '\''"
ifFalse: [anObject asString printString]]].
self error: 'Warning: A Smalltalk literal could not be translated into a C constant: ', anObject printString.
^'"XXX UNTRANSLATABLE CONSTANT XXX"'!