[squeak-dev] The Trunk: System-eem.801.mcz

Eliot Miranda eliot.miranda at gmail.com
Sun Feb 21 18:06:24 UTC 2016


Hi David,

    since WordArray is defined as a sequence of 32-bit integer slots, a one element WordArray has its first element in the first four bytes on both big and little endianness 64-bit and 32-bit platforms and so two elements are not necessary.  I could add this to the comment.  And yes, this is possible because there are no compact classes to prevent a more general adoptInstance:.

_,,,^..^,,,_ (phone)

> On Feb 21, 2016, at 8:50 AM, David T. Lewis <lewis at mail.msen.com> wrote:
> 
>> On Sun, Feb 21, 2016 at 07:40:22AM +0000, commits at source.squeak.org wrote:
>> Eliot Miranda uploaded a new version of System to project The Trunk:
>> http://source.squeak.org/trunk/System-eem.801.mcz
>> 
>> ==================== Summary ====================
>> 
>> Name: System-eem.801
>> Author: eem
>> Time: 20 February 2016, 11:40:02.089874 pm
>> UUID: cb00963a-1c90-40c0-9539-04c88c0afa5f
>> Ancestors: System-mt.800
>> 
>> In Spur calcEndianness can be a lot simpler.
> 
> This works in Spur because ByteArray can now adopt an instance of WordArray,
> is that right?
> 
> Does the test work on big endian 64-bit? I think that it will, but if there
> is any doubt it might be safer to use a two element WordArray:
> 
>    WordArray with: 16r01020304 with: 16r01020304
> 
> The method comment describes the old String implementation, so it would be
> good to update that.
> 
> Dave
> 
> 
> 
>> =============== Diff against System-mt.800 ===============
>> 
>> Item was changed:
>>  ----- Method: SmalltalkImage>>calcEndianness (in category 'system attributes') -----
>>  calcEndianness
>> -    | bytes word blt |
>>      "What endian-ness is the current hardware?  The String '1234' will be stored into a machine word.  On BigEndian machines (the Mac), $1 will be the high byte if the word.  On LittleEndian machines (the PC), $4 will be the high byte."
>>      "Smalltalk endianness"
>> +    | wordThenBytes |
>> +    wordThenBytes := WordArray with: 16r01020304.
>> +    ByteArray adoptInstance: wordThenBytes.
>> +    wordThenBytes first = 1 ifTrue: [^#big].
>> +    wordThenBytes first = 4 ifTrue: [^#little].
>> +    self error: 'The author is confused'!
>> - 
>> -    bytes := ByteArray withAll: #(0 0 0 0).  "(1 2 3 4) or (4 3 2 1)"
>> -    word := WordArray with: 16r01020304.
>> -    blt := (BitBlt toForm: (Form new hackBits: bytes)) 
>> -                sourceForm: (Form new hackBits: word).
>> -    blt combinationRule: Form over.  "store"
>> -    blt sourceY: 0; destY: 0; height: 1; width: 4.
>> -    blt sourceX: 0; destX: 0.
>> -    blt copyBits.  "paste the word into the bytes"
>> -    bytes first = 1 ifTrue: [^ #big].
>> -    bytes first = 4 ifTrue: [^ #little].
>> -    self error: 'Ted is confused'.!
> 


More information about the Squeak-dev mailing list