The Trunk: Collections-eem.678.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Collections-eem.678.mcz

commits-2
Eliot Miranda uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-eem.678.mcz

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

Name: Collections-eem.678
Author: eem
Time: 22 February 2016, 9:39:42.620109 am
UUID: 5f42102e-7dd0-4fc7-b437-5ba06a88240d
Ancestors: Collections-ul.677

Make ByteArray>>unsignedLong[64]At:bigEndian: 64-bit aware.

=============== Diff against Collections-ul.677 ===============

Item was changed:
  ----- Method: ByteArray>>unsignedLong64At:bigEndian: (in category 'platform independent access') -----
  unsignedLong64At: index bigEndian: bigEndian
  "Return a 64-bit unsigned integer quantity starting from the given byte index. Use #normalize where necessary to ensure compatibility with non-30-bit SmallIntegers."
 
+ | byte |
+ SmallInteger maxVal >  1073741823 ifTrue:
+ [bigEndian
+ ifTrue: "64-bit SmallIntegers have a 3 bit tag and a sign bit, so the most positive value has 16rF as its top byte."
+ [(byte := self at: index) <= 16rF ifTrue:
+ [^((((((((byte bitShift: 8) + (self at: index + 1) bitShift: 8) + (self at: index + 2) bitShift: 8) + (self at: index + 3)) bitShift: 8)
+ + (self at: index + 4) bitShift: 8) + (self at: index + 5) bitShift: 8) + (self at: index + 6) bitShift: 8) + (self at: index + 7)]]
+ ifFalse:
+ [(byte := self at: index + 7) <= 16rF ifTrue:
+ [^((((((((byte bitShift: 8) + (self at: index + 6) bitShift: 8) + (self at: index + 5) bitShift: 8) + (self at: index + 4)) bitShift: 8)
+ + (self at: index + 3) bitShift: 8) + (self at: index + 2) bitShift: 8) + (self at: index + 1) bitShift: 8) + (self at: index)]]].
- | v |
  bigEndian ifFalse: [
+ (byte := self at: index + 7) = 0 ifFalse: [
- (v := self at: index + 7) = 0 ifFalse: [
  ^(LargePositiveInteger new: 8)
+ replaceFrom: 1 to: 8 with: self startingAt: index;
- replaceFrom: 1
- to: 8
- with: self
- startingAt: index;
  normalize ].
+ (byte := self at: index + 6) = 0 ifFalse: [
- (v := self at: index + 6) = 0 ifFalse: [
  ^(LargePositiveInteger new: 7)
+ replaceFrom: 1 to: 7 with: self startingAt: index;
- replaceFrom: 1
- to: 7
- with: self
- startingAt: index;
  normalize ].
+ (byte := self at: index + 5) = 0 ifFalse: [
- (v := self at: index + 5) = 0 ifFalse: [
  ^(LargePositiveInteger new: 6)
+ replaceFrom: 1 to: 6 with: self startingAt: index;
- replaceFrom: 1
- to: 6
- with: self
- startingAt: index;
  normalize ].
+ (byte := self at: index + 4) = 0 ifFalse: [
- (v := self at: index + 4) = 0 ifFalse: [
  ^(LargePositiveInteger new: 5)
+ replaceFrom: 1 to: 5 with: self startingAt: index;
- replaceFrom: 1
- to: 5
- with: self
- startingAt: index;
  normalize ].
+ (byte := self at: index + 3) <= 16r3F ifFalse: [
- (v := self at: index + 3) <= 16r3F ifFalse: [
  ^(LargePositiveInteger new: 4)
+ replaceFrom: 1 to: 4 with: self startingAt: index;
- replaceFrom: 1
- to: 4
- with: self
- startingAt: index;
  normalize ].
+ ^(((byte bitShift: 8) + (self at: index + 2) bitShift: 8) + (self at: index + 1) bitShift: 8) + (self at: index) ].
+ (byte := self at: index) = 0 ifFalse: [
- ^(((v bitShift: 8) + (self at: index + 2) bitShift: 8) + (self at: index + 1) bitShift: 8) + (self at: index) ].
- (v := self at: index) = 0 ifFalse: [
  ^(LargePositiveInteger new: 8)
  digitAt: 1 put: (self at: index + 7);
  digitAt: 2 put: (self at: index + 6);
  digitAt: 3 put: (self at: index + 5);
  digitAt: 4 put: (self at: index + 4);
  digitAt: 5 put: (self at: index + 3);
  digitAt: 6 put: (self at: index + 2);
  digitAt: 7 put: (self at: index + 1);
+ digitAt: 8 put: byte;
- digitAt: 8 put: v;
  normalize ].
+ (byte := self at: index + 1) = 0 ifFalse: [
- (v := self at: index + 1) = 0 ifFalse: [
  ^(LargePositiveInteger new: 7)
  digitAt: 1 put: (self at: index + 7);
  digitAt: 2 put: (self at: index + 6);
  digitAt: 3 put: (self at: index + 5);
  digitAt: 4 put: (self at: index + 4);
  digitAt: 5 put: (self at: index + 3);
  digitAt: 6 put: (self at: index + 2);
+ digitAt: 7 put: byte;
- digitAt: 7 put: v;
  normalize ].
+ (byte := self at: index + 2) = 0 ifFalse: [
- (v := self at: index + 2) = 0 ifFalse: [
  ^(LargePositiveInteger new: 6)
  digitAt: 1 put: (self at: index + 7);
  digitAt: 2 put: (self at: index + 6);
  digitAt: 3 put: (self at: index + 5);
  digitAt: 4 put: (self at: index + 4);
  digitAt: 5 put: (self at: index + 3);
+ digitAt: 6 put: byte;
- digitAt: 6 put: v;
  normalize ].
+ (byte := self at: index + 3) = 0 ifFalse: [
- (v := self at: index + 3) = 0 ifFalse: [
  ^(LargePositiveInteger new: 5)
  digitAt: 1 put: (self at: index + 7);
  digitAt: 2 put: (self at: index + 6);
  digitAt: 3 put: (self at: index + 5);
  digitAt: 4 put: (self at: index + 4);
+ digitAt: 5 put: byte;
- digitAt: 5 put: v;
  normalize ].
+ (byte := self at: index + 4) <= 16r3F ifFalse: [
- (v := self at: index + 4) <= 16r3F ifFalse: [
  ^(LargePositiveInteger new: 4)
  digitAt: 1 put: (self at: index + 7);
  digitAt: 2 put: (self at: index + 6);
  digitAt: 3 put: (self at: index + 5);
+ digitAt: 4 put: byte;
- digitAt: 4 put: v;
  normalize ].
+ ^(((byte bitShift: 8) + (self at: index + 5) bitShift: 8) + (self at: index + 6) bitShift: 8) + (self at: index + 7)!
- ^(((v bitShift: 8) + (self at: index + 5) bitShift: 8) + (self at: index + 6) bitShift: 8) + (self at: index + 7)!

Item was changed:
  ----- Method: ByteArray>>unsignedLongAt:bigEndian: (in category 'platform independent access') -----
  unsignedLongAt: index bigEndian: bigEndian
  "Return a 32-bit unsigned integer quantity starting from the given byte index. Use #normalize where necessary to ensure compatibility with non-30-bit SmallIntegers."
-
  | byte |
+ bigEndian ifTrue:
+ [((byte := self at: index) <= 16r3F
+ or: [SmallInteger maxVal >  1073741823]) ifTrue:
+ [^(((byte bitShift: 8) + (self at: index + 1) bitShift: 8) + (self at: index + 2) bitShift: 8) + (self at: index + 3)].
- bigEndian ifTrue: [
- (byte := self at: index) <= 16r3F ifTrue: [
- ^(((byte bitShift: 8) + (self at: index + 1) bitShift: 8) + (self at: index + 2) bitShift: 8) + (self at: index + 3) ].
  ^(LargePositiveInteger new: 4)
  digitAt: 1 put: (self at: index + 3);
  digitAt: 2 put: (self at: index + 2);
  digitAt: 3 put: (self at: index + 1);
  digitAt: 4 put: byte;
+ normalize].
+ ((byte := self at: index + 3) <= 16r3F
+ or: [SmallInteger maxVal >  1073741823]) ifTrue:
+ [^(((byte bitShift: 8) + (self at: index + 2) bitShift: 8) + (self at: index + 1) bitShift: 8) + (self at: index)].
- normalize ].
- (byte := self at: index + 3) <= 16r3F ifTrue: [
- ^(((byte bitShift: 8) + (self at: index + 2) bitShift: 8) + (self at: index + 1) bitShift: 8) + (self at: index) ].
  ^(LargePositiveInteger new: 4)
+ replaceFrom: 1 to: 4 with: self startingAt: index;
+ normalize!
- replaceFrom: 1
- to: 4
- with: self
- startingAt: index;
- normalize
- !