Merge pull request #64 from status-im/push-experimental
Push experimental
This commit is contained in:
commit
cb442fa315
|
@ -55,8 +55,7 @@ install:
|
|||
) ELSE (
|
||||
( CD Nim ) &
|
||||
( git rev-parse HEAD > ..\\cur_ver.txt ) &
|
||||
( fc ver.txt ..\\cur_ver.txt > nul ) &
|
||||
( IF NOT ERRORLEVEL == 0 SET NEED_REBUILD=1 ) &
|
||||
( fc ver.txt ..\\cur_ver.txt || SET NEED_REBUILD=1 ) &
|
||||
( cd .. )
|
||||
)
|
||||
|
||||
|
|
1
nim.cfg
1
nim.cfg
|
@ -1 +0,0 @@
|
|||
# --experimental:ForLoopMacros # Deactivated for CI - https://github.com/status-im/nimbus/pull/110#issuecomment-414326444
|
|
@ -17,7 +17,6 @@ proc test(name: string, lang: string = "c") =
|
|||
--run
|
||||
--nimcache: "nimcache"
|
||||
switch("out", ("./build/" & name))
|
||||
switch("experimental", "ForLoopMacros")
|
||||
setCommand lang, "tests/" & name & ".nim"
|
||||
|
||||
task test_internal_debug, "Run tests for internal procs - test implementation (StUint[64] = 2x uint32":
|
||||
|
|
|
@ -11,20 +11,28 @@ import ./datatypes, ./as_words
|
|||
|
||||
func `not`*(x: IntImpl): IntImpl {.inline.}=
|
||||
## Bitwise complement of unsigned integer x
|
||||
{.push experimental: "forLoopMacros".}
|
||||
for wr, wx in asWords(result, x):
|
||||
wr = not wx
|
||||
{.pop.}
|
||||
|
||||
func `or`*(x, y: IntImpl): IntImpl {.inline.}=
|
||||
## `Bitwise or` of numbers x and y
|
||||
{.push experimental: "forLoopMacros".}
|
||||
for wr, wx, wy in asWords(result, x, y):
|
||||
wr = wx or wy
|
||||
{.pop.}
|
||||
|
||||
func `and`*(x, y: IntImpl): IntImpl {.inline.}=
|
||||
## `Bitwise and` of numbers x and y
|
||||
{.push experimental: "forLoopMacros".}
|
||||
for wr, wx, wy in asWords(result, x, y):
|
||||
wr = wx and wy
|
||||
{.pop.}
|
||||
|
||||
func `xor`*(x, y: IntImpl): IntImpl {.inline.}=
|
||||
## `Bitwise xor` of numbers x and y
|
||||
{.push experimental: "forLoopMacros".}
|
||||
for wr, wx, wy in asWords(result, x, y):
|
||||
wr = wx xor wy
|
||||
{.pop.}
|
||||
|
|
|
@ -14,9 +14,11 @@ func isZero*(n: SomeSignedInt): bool {.inline.} =
|
|||
n == 0
|
||||
|
||||
func isZero*(n: IntImpl): bool {.inline.} =
|
||||
{.push experimental: "forLoopMacros".}
|
||||
for word in asWords(n):
|
||||
if word != 0:
|
||||
return false
|
||||
{.pop.}
|
||||
return true
|
||||
|
||||
func isNegative*(n: IntImpl): bool {.inline.} =
|
||||
|
@ -25,23 +27,29 @@ func isNegative*(n: IntImpl): bool {.inline.} =
|
|||
|
||||
func `<`*(x, y: IntImpl): bool {.inline.}=
|
||||
# Lower comparison for multi-precision integers
|
||||
{.push experimental: "forLoopMacros".}
|
||||
for wx, wy in asSignedWords(x, y):
|
||||
if wx != wy:
|
||||
return wx < wy
|
||||
{.pop.}
|
||||
return false # they're equal
|
||||
|
||||
func `==`*(x, y: IntImpl): bool {.inline.}=
|
||||
# Equal comparison for multi-precision integers
|
||||
{.push experimental: "forLoopMacros".}
|
||||
for wx, wy in asWords(x, y):
|
||||
if wx != wy:
|
||||
return false
|
||||
{.pop.}
|
||||
return true # they're equal
|
||||
|
||||
func `<=`*(x, y: IntImpl): bool {.inline.}=
|
||||
# Lower or equal comparison for multi-precision integers
|
||||
{.push experimental: "forLoopMacros".}
|
||||
for wx, wy in asSignedWords(x, y):
|
||||
if wx != wy:
|
||||
return wx < wy
|
||||
{.pop.}
|
||||
return true # they're equal
|
||||
|
||||
func isOdd*(x: IntImpl): bool {.inline.}=
|
||||
|
|
|
@ -11,23 +11,31 @@ import ./datatypes, ./as_words
|
|||
|
||||
func `not`*(x: UintImpl): UintImpl {.inline.}=
|
||||
## Bitwise complement of unsigned integer x
|
||||
{.push experimental: "forLoopMacros".}
|
||||
for wr, wx in asWords(result, x):
|
||||
wr = not wx
|
||||
{.pop.}
|
||||
|
||||
func `or`*(x, y: UintImpl): UintImpl {.inline.}=
|
||||
## `Bitwise or` of numbers x and y
|
||||
{.push experimental: "forLoopMacros".}
|
||||
for wr, wx, wy in asWords(result, x, y):
|
||||
wr = wx or wy
|
||||
{.pop.}
|
||||
|
||||
func `and`*(x, y: UintImpl): UintImpl {.inline.}=
|
||||
## `Bitwise and` of numbers x and y
|
||||
{.push experimental: "forLoopMacros".}
|
||||
for wr, wx, wy in asWords(result, x, y):
|
||||
wr = wx and wy
|
||||
{.pop.}
|
||||
|
||||
func `xor`*(x, y: UintImpl): UintImpl {.inline.}=
|
||||
## `Bitwise xor` of numbers x and y
|
||||
{.push experimental: "forLoopMacros".}
|
||||
for wr, wx, wy in asWords(result, x, y):
|
||||
wr = wx xor wy
|
||||
{.pop.}
|
||||
|
||||
func `shr`*(x: UintImpl, y: SomeInteger): UintImpl {.inline.}
|
||||
# Forward declaration
|
||||
|
|
|
@ -13,30 +13,38 @@ func isZero*(n: SomeUnsignedInt): bool {.inline.} =
|
|||
n == 0
|
||||
|
||||
func isZero*(n: UintImpl): bool {.inline.} =
|
||||
{.push experimental: "forLoopMacros".}
|
||||
for word in asWords(n):
|
||||
if word != 0:
|
||||
return false
|
||||
{.pop.}
|
||||
return true
|
||||
|
||||
func `<`*(x, y: UintImpl): bool {.inline.}=
|
||||
# Lower comparison for multi-precision integers
|
||||
{.push experimental: "forLoopMacros".}
|
||||
for wx, wy in asWords(x, y):
|
||||
if wx != wy:
|
||||
return wx < wy
|
||||
{.pop.}
|
||||
return false # they're equal
|
||||
|
||||
func `==`*(x, y: UintImpl): bool {.inline.}=
|
||||
# Equal comparison for multi-precision integers
|
||||
{.push experimental: "forLoopMacros".}
|
||||
for wx, wy in asWords(x, y):
|
||||
if wx != wy:
|
||||
return false
|
||||
{.pop.}
|
||||
return true # they're equal
|
||||
|
||||
func `<=`*(x, y: UintImpl): bool {.inline.}=
|
||||
# Lower or equal comparison for multi-precision integers
|
||||
{.push experimental: "forLoopMacros".}
|
||||
for wx, wy in asWords(x, y):
|
||||
if wx != wy:
|
||||
return wx < wy
|
||||
{.pop.}
|
||||
return true # they're equal
|
||||
|
||||
func isOdd*(x: UintImpl): bool {.inline.}=
|
||||
|
|
Loading…
Reference in New Issue