Merge pull request #64 from status-im/push-experimental

Push experimental
This commit is contained in:
Yuriy Glukhov 2018-09-06 20:32:30 +03:00 committed by GitHub
commit cb442fa315
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 33 additions and 4 deletions

View File

@ -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 .. )
)

View File

@ -1 +0,0 @@
# --experimental:ForLoopMacros # Deactivated for CI - https://github.com/status-im/nimbus/pull/110#issuecomment-414326444

View File

@ -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":

View File

@ -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.}

View File

@ -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.}=

View File

@ -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

View File

@ -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.}=