fix the error "only proc headers can feature pragmas" when compiling in JS mode
This commit is contained in:
parent
9dec669b94
commit
3c840102bc
3 changed files with 33 additions and 33 deletions
|
|
@ -447,38 +447,38 @@ proc chr*(u: range[0..255]): char {.magic: "Chr", noSideEffect.}
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# built-in operators
|
# built-in operators
|
||||||
|
|
||||||
proc ze*(x: int8): int {.magic: "Ze8ToI", noSideEffect.}
|
when not defined(JS):
|
||||||
## zero extends a smaller integer type to ``int``. This treats `x` as
|
proc ze*(x: int8): int {.magic: "Ze8ToI", noSideEffect.}
|
||||||
## unsigned.
|
## zero extends a smaller integer type to ``int``. This treats `x` as
|
||||||
proc ze*(x: int16): int {.magic: "Ze16ToI", noSideEffect.}
|
## unsigned.
|
||||||
## zero extends a smaller integer type to ``int``. This treats `x` as
|
proc ze*(x: int16): int {.magic: "Ze16ToI", noSideEffect.}
|
||||||
## unsigned.
|
## zero extends a smaller integer type to ``int``. This treats `x` as
|
||||||
|
## unsigned.
|
||||||
|
|
||||||
proc ze64*(x: int8): int64 {.magic: "Ze8ToI64", noSideEffect.}
|
proc ze64*(x: int8): int64 {.magic: "Ze8ToI64", noSideEffect.}
|
||||||
## zero extends a smaller integer type to ``int64``. This treats `x` as
|
## zero extends a smaller integer type to ``int64``. This treats `x` as
|
||||||
## unsigned.
|
## unsigned.
|
||||||
proc ze64*(x: int16): int64 {.magic: "Ze16ToI64", noSideEffect.}
|
proc ze64*(x: int16): int64 {.magic: "Ze16ToI64", noSideEffect.}
|
||||||
## zero extends a smaller integer type to ``int64``. This treats `x` as
|
## zero extends a smaller integer type to ``int64``. This treats `x` as
|
||||||
## unsigned.
|
## unsigned.
|
||||||
|
|
||||||
proc ze64*(x: int32): int64 {.magic: "Ze32ToI64", noSideEffect.}
|
proc ze64*(x: int32): int64 {.magic: "Ze32ToI64", noSideEffect.}
|
||||||
## zero extends a smaller integer type to ``int64``. This treats `x` as
|
## zero extends a smaller integer type to ``int64``. This treats `x` as
|
||||||
## unsigned.
|
## unsigned.
|
||||||
proc ze64*(x: int): int64 {.magic: "ZeIToI64", noSideEffect.}
|
proc ze64*(x: int): int64 {.magic: "ZeIToI64", noSideEffect.}
|
||||||
## zero extends a smaller integer type to ``int64``. This treats `x` as
|
## zero extends a smaller integer type to ``int64``. This treats `x` as
|
||||||
## unsigned. Does nothing if the size of an ``int`` is the same as ``int64``.
|
## unsigned. Does nothing if the size of an ``int`` is the same as ``int64``.
|
||||||
## (This is the case on 64 bit processors.)
|
## (This is the case on 64 bit processors.)
|
||||||
|
|
||||||
proc toU8*(x: int): int8 {.magic: "ToU8", noSideEffect.}
|
|
||||||
## treats `x` as unsigned and converts it to a byte by taking the last 8 bits
|
|
||||||
## from `x`.
|
|
||||||
proc toU16*(x: int): int16 {.magic: "ToU16", noSideEffect.}
|
|
||||||
## treats `x` as unsigned and converts it to an ``int16`` by taking the last
|
|
||||||
## 16 bits from `x`.
|
|
||||||
proc toU32*(x: int64): int32 {.magic: "ToU32", noSideEffect.}
|
|
||||||
## treats `x` as unsigned and converts it to an ``int32`` by taking the
|
|
||||||
## last 32 bits from `x`.
|
|
||||||
|
|
||||||
|
proc toU8*(x: int): int8 {.magic: "ToU8", noSideEffect.}
|
||||||
|
## treats `x` as unsigned and converts it to a byte by taking the last 8 bits
|
||||||
|
## from `x`.
|
||||||
|
proc toU16*(x: int): int16 {.magic: "ToU16", noSideEffect.}
|
||||||
|
## treats `x` as unsigned and converts it to an ``int16`` by taking the last
|
||||||
|
## 16 bits from `x`.
|
||||||
|
proc toU32*(x: int64): int32 {.magic: "ToU32", noSideEffect.}
|
||||||
|
## treats `x` as unsigned and converts it to an ``int32`` by taking the
|
||||||
|
## last 32 bits from `x`.
|
||||||
|
|
||||||
# integer calculations:
|
# integer calculations:
|
||||||
proc `+` *(x: int): int {.magic: "UnaryPlusI", noSideEffect.}
|
proc `+` *(x: int): int {.magic: "UnaryPlusI", noSideEffect.}
|
||||||
|
|
|
||||||
|
|
@ -472,17 +472,17 @@ proc Ze(a: int): int {.compilerproc.} =
|
||||||
proc Ze64(a: int64): int64 {.compilerproc.} =
|
proc Ze64(a: int64): int64 {.compilerproc.} =
|
||||||
result = a
|
result = a
|
||||||
|
|
||||||
proc toU8(a: int): int8 {.noStackFrame, compilerproc.} =
|
proc ToU8(a: int): int8 {.noStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
return `a`;
|
return `a`;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc toU16(a: int): int16 {.noStackFrame, compilerproc.} =
|
proc ToU16(a: int): int16 {.noStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
return `a`;
|
return `a`;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc toU32(a: int): int32 {.noStackFrame, compilerproc.} =
|
proc ToU32(a: int): int32 {.noStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
return `a`;
|
return `a`;
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ discard """
|
||||||
WARNING: false first asseertion from bar
|
WARNING: false first asseertion from bar
|
||||||
ERROR: false second assertion from bar
|
ERROR: false second assertion from bar
|
||||||
-1
|
-1
|
||||||
tests/run/tfailedassert.nim:27 false assertion from foo
|
tests/assert/tfailedassert.nim:27 false assertion from foo
|
||||||
'''
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue