Numbers. (but completely different)

Alan Grimes alangrimes at starpower.net
Fri Apr 9 16:42:35 UTC 2004


Tim Rowledge wrote:

>>^obj << 1 + 1.
>>    
>>
>Which is exactly what we've been doing since the first version. See
>CCodeGenerator>generateIntegerObjectOf:on:indent:
>  
>

URK!

Maybe it would be better to put this in Interpreter Simulator and simply 
put a stub in Object Memory that says "this is overriden". The comment 
in the existing function should be ammended to make it clear that it 
means _C_ translator.

################################
ObjectMemory >>> integerValueOf: objectPointer

    "Translator produces 'objectPointer >> 1'"

    ((objectPointer bitAnd: 16r80000000) ~= 0)
        ifTrue: ["negative"
                ^ ((objectPointer bitAnd: 16r7FFFFFFF) >> 1)
                    - 16r3FFFFFFF - 1  "Faster than -16r40000000 (a LgInt)"]
        ifFalse: ["positive"
                ^ objectPointer >> 1]
############################

In the CCode Generator the story wasn't any nicer, I found:
################################
generateIntegerValueOf: msgNode on: aStream indent: level
    "Generate the C code for this message onto the given stream."

    aStream nextPutAll: '('.
    self emitCExpression: msgNode args first on: aStream.
    aStream nextPutAll: ' >> 1)'.
##########################

Which doesn't appear to preserve the sign bit....

lemme recompile it with the /2 operation and see what happens.........



More information about the Squeak-dev mailing list