right shift is now by default sign preserving (#11322)

* right shift is now by default sign preserving
* fix hashString and semfold
* enable arithmetic shift right globally for CI
* fix typo
* remove xxx
* use oldShiftRight as flag
* apply feedback
* add changelog entry
This commit is contained in:
Arne Döring 2019-05-29 16:48:00 +02:00 • committed by Andreas Rumpf
commit 88b5dd3362
18 changed files with 211 additions and 187 deletions

View file

@ -31,13 +31,13 @@ test(`or`, 0xf0f0'i16, 0x0d0d'i16, 0xfdfd'i16)
test(`and`, 0xf0f0'i16, 0xfdfd'i16, 0xf0f0'i16)
when not defined(js):
test(`shr`, 0xffffffffffffffff'i64, 0x4'i64, 0x0fffffffffffffff'i64)
test(`shr`, 0xffff'i16, 0x4'i16, 0x0fff'i16)
test(`shr`, 0xff'i8, 0x4'i8, 0x0f'i8)
test(`shr`, 0xffffffffffffffff'i64, 0x4'i64, 0xffffffffffffffff'i64)
test(`shr`, 0xffff'i16, 0x4'i16, 0xffff'i16)
test(`shr`, 0xff'i8, 0x4'i8, 0xff'i8)
when not defined(js):
test(`shr`, 0xffffffff'i64, 0x4'i64, 0x0fffffff'i64)
test(`shr`, 0xffffffff'i32, 0x4'i32, 0x0fffffff'i32)
test(`shr`, 0xffffffff'i32, 0x4'i32, 0xffffffff'i32)
when not defined(js):
test(`shl`, 0xffffffffffffffff'i64, 0x4'i64, 0xfffffffffffffff0'i64)

View file

@ -22,7 +22,7 @@ proc toVarNum(x: int32, b: var TBuffer) =
a = abs(x)
# first 6 bits:
b[0] = toU8(ord(a >% 63'i32) shl 7 or (ord(x < 0'i32) shl 6) or (int(a) and 63))
a = a shr 6'i32 # skip first 6 bits
a = (a shr 6'i32) and 0x03ffffff # skip first 6 bits
var i = 1
while a != 0'i32:
b[i] = toU8(ord(a >% 127'i32) shl 7 or (int(a) and 127))
@ -42,7 +42,7 @@ proc toVarNum64(x: int64, b: var TBuffer) =
a = abs(x)
# first 6 bits:
b[0] = toU8(ord(a >% 63'i64) shl 7 or (ord(x < 0'i64) shl 6) or int(a and 63))
a = a shr 6 # skip first 6 bits
a = (a shr 6) and 0x03ffffffffffffff # skip first 6 bits
var i = 1
while a != 0'i64:
b[i] = toU8(ord(a >% 127'i64) shl 7 or int(a and 127))