Trim remaining expr/stmt from stdlib (#6742)
This commit is contained in:
parent
7f4248dc0c
commit
0ab373115c
9 changed files with 16 additions and 16 deletions
|
|
@ -400,7 +400,7 @@ proc quote*(bl: typed, op = "``"): NimNode {.magic: "QuoteAst", noSideEffect.}
|
||||||
##
|
##
|
||||||
## .. code-block:: nim
|
## .. code-block:: nim
|
||||||
##
|
##
|
||||||
## macro check(ex: expr): stmt =
|
## macro check(ex: untyped): typed =
|
||||||
## # this is a simplified version of the check macro from the
|
## # this is a simplified version of the check macro from the
|
||||||
## # unittest module.
|
## # unittest module.
|
||||||
##
|
##
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,12 @@ export nativesockets
|
||||||
|
|
||||||
{.warning: "rawsockets module is deprecated, use nativesockets instead".}
|
{.warning: "rawsockets module is deprecated, use nativesockets instead".}
|
||||||
|
|
||||||
template newRawSocket*(domain, sockType, protocol: cint): expr =
|
template newRawSocket*(domain, sockType, protocol: cint): untyped =
|
||||||
{.warning: "newRawSocket is deprecated, use newNativeSocket instead".}
|
{.warning: "newRawSocket is deprecated, use newNativeSocket instead".}
|
||||||
newNativeSocket(domain, sockType, protocol)
|
newNativeSocket(domain, sockType, protocol)
|
||||||
|
|
||||||
template newRawSocket*(domain: Domain = AF_INET,
|
template newRawSocket*(domain: Domain = AF_INET,
|
||||||
sockType: SockType = SOCK_STREAM,
|
sockType: SockType = SOCK_STREAM,
|
||||||
protocol: Protocol = IPPROTO_TCP): expr =
|
protocol: Protocol = IPPROTO_TCP): untyped =
|
||||||
{.warning: "newRawSocket is deprecated, use newNativeSocket instead".}
|
{.warning: "newRawSocket is deprecated, use newNativeSocket instead".}
|
||||||
newNativeSocket(domain, sockType, protocol)
|
newNativeSocket(domain, sockType, protocol)
|
||||||
|
|
|
||||||
|
|
@ -87,10 +87,10 @@ proc newSharedString*(s: string): SharedString =
|
||||||
result.len = len
|
result.len = len
|
||||||
|
|
||||||
when declared(atomicLoadN):
|
when declared(atomicLoadN):
|
||||||
template load(x): expr = atomicLoadN(addr x, ATOMIC_SEQ_CST)
|
template load(x): untyped = atomicLoadN(addr x, ATOMIC_SEQ_CST)
|
||||||
else:
|
else:
|
||||||
# XXX Fixme
|
# XXX Fixme
|
||||||
template load(x): expr = x
|
template load(x): untyped = x
|
||||||
|
|
||||||
proc add*(s: var SharedString; t: cstring; len: Natural) =
|
proc add*(s: var SharedString; t: cstring; len: Natural) =
|
||||||
if len == 0: return
|
if len == 0: return
|
||||||
|
|
|
||||||
|
|
@ -841,7 +841,7 @@ elif not defined(useNimRtl):
|
||||||
var attr: Tposix_spawnattr
|
var attr: Tposix_spawnattr
|
||||||
var fops: Tposix_spawn_file_actions
|
var fops: Tposix_spawn_file_actions
|
||||||
|
|
||||||
template chck(e: expr) =
|
template chck(e: untyped) =
|
||||||
if e != 0'i32: raiseOSError(osLastError())
|
if e != 0'i32: raiseOSError(osLastError())
|
||||||
|
|
||||||
chck posix_spawn_file_actions_init(fops)
|
chck posix_spawn_file_actions_init(fops)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ proc name*(t: typedesc): string {.magic: "TypeTrait".}
|
||||||
##
|
##
|
||||||
## proc `$`*(T: typedesc): string = name(T)
|
## proc `$`*(T: typedesc): string = name(T)
|
||||||
##
|
##
|
||||||
## template test(x): stmt =
|
## template test(x): typed =
|
||||||
## echo "type: ", type(x), ", value: ", x
|
## echo "type: ", type(x), ", value: ", x
|
||||||
##
|
##
|
||||||
## test 42
|
## test 42
|
||||||
|
|
|
||||||
|
|
@ -2763,9 +2763,9 @@ when defined(nimvarargstyped):
|
||||||
## pretends to be free of side effects, so that it can be used for debugging
|
## pretends to be free of side effects, so that it can be used for debugging
|
||||||
## routines marked as `noSideEffect <manual.html#pragmas-nosideeffect-pragma>`_.
|
## routines marked as `noSideEffect <manual.html#pragmas-nosideeffect-pragma>`_.
|
||||||
else:
|
else:
|
||||||
proc echo*(x: varargs[expr, `$`]) {.magic: "Echo", tags: [WriteIOEffect],
|
proc echo*(x: varargs[untyped, `$`]) {.magic: "Echo", tags: [WriteIOEffect],
|
||||||
benign, sideEffect.}
|
benign, sideEffect.}
|
||||||
proc debugEcho*(x: varargs[expr, `$`]) {.magic: "Echo", noSideEffect,
|
proc debugEcho*(x: varargs[untyped, `$`]) {.magic: "Echo", noSideEffect,
|
||||||
tags: [], raises: [].}
|
tags: [], raises: [].}
|
||||||
|
|
||||||
template newException*(exceptn: typedesc, message: string;
|
template newException*(exceptn: typedesc, message: string;
|
||||||
|
|
@ -3706,7 +3706,7 @@ proc instantiationInfo*(index = -1, fullPaths = false): tuple[
|
||||||
## .. code-block:: nim
|
## .. code-block:: nim
|
||||||
## import strutils
|
## import strutils
|
||||||
##
|
##
|
||||||
## template testException(exception, code: expr): stmt =
|
## template testException(exception, code: untyped): typed =
|
||||||
## try:
|
## try:
|
||||||
## let pos = instantiationInfo()
|
## let pos = instantiationInfo()
|
||||||
## discard(code)
|
## discard(code)
|
||||||
|
|
@ -3844,11 +3844,11 @@ type
|
||||||
{.deprecated: [PNimrodNode: NimNode].}
|
{.deprecated: [PNimrodNode: NimNode].}
|
||||||
|
|
||||||
when false:
|
when false:
|
||||||
template eval*(blk: stmt): stmt =
|
template eval*(blk: typed): typed =
|
||||||
## executes a block of code at compile time just as if it was a macro
|
## executes a block of code at compile time just as if it was a macro
|
||||||
## optionally, the block can return an AST tree that will replace the
|
## optionally, the block can return an AST tree that will replace the
|
||||||
## eval expression
|
## eval expression
|
||||||
macro payload: stmt {.gensym.} = blk
|
macro payload: typed {.gensym.} = blk
|
||||||
payload()
|
payload()
|
||||||
|
|
||||||
when hasAlloc:
|
when hasAlloc:
|
||||||
|
|
|
||||||
|
|
@ -370,7 +370,7 @@ proc commandPrompt() =
|
||||||
if dbgUser.len == 0: dbgUser.len = oldLen
|
if dbgUser.len == 0: dbgUser.len = oldLen
|
||||||
# now look what we have to do:
|
# now look what we have to do:
|
||||||
var i = scanWord(addr dbgUser.data, dbgTemp, 0)
|
var i = scanWord(addr dbgUser.data, dbgTemp, 0)
|
||||||
template `?`(x: expr): expr = dbgTemp == cstring(x)
|
template `?`(x: untyped): untyped = dbgTemp == cstring(x)
|
||||||
if ?"s" or ?"step":
|
if ?"s" or ?"step":
|
||||||
dbgState = dbStepInto
|
dbgState = dbStepInto
|
||||||
again = false
|
again = false
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ proc internRefcount(p: pointer): int {.exportc: "getRefcount".} =
|
||||||
when BitsPerPage mod (sizeof(int)*8) != 0:
|
when BitsPerPage mod (sizeof(int)*8) != 0:
|
||||||
{.error: "(BitsPerPage mod BitsPerUnit) should be zero!".}
|
{.error: "(BitsPerPage mod BitsPerUnit) should be zero!".}
|
||||||
|
|
||||||
template color(c): expr = c.refCount and colorMask
|
template color(c): untyped = c.refCount and colorMask
|
||||||
template setColor(c, col) =
|
template setColor(c, col) =
|
||||||
c.refcount = c.refcount and not colorMask or col
|
c.refcount = c.refcount and not colorMask or col
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -153,12 +153,12 @@ proc preferSpawn*(): bool =
|
||||||
## it is not necessary to call this directly; use 'spawnX' instead.
|
## it is not necessary to call this directly; use 'spawnX' instead.
|
||||||
result = gSomeReady.event
|
result = gSomeReady.event
|
||||||
|
|
||||||
proc spawn*(call: stmt) {.magic: "Spawn".}
|
proc spawn*(call: typed) {.magic: "Spawn".}
|
||||||
## always spawns a new task, so that the 'call' is never executed on
|
## always spawns a new task, so that the 'call' is never executed on
|
||||||
## the calling thread. 'call' has to be proc call 'p(...)' where 'p'
|
## the calling thread. 'call' has to be proc call 'p(...)' where 'p'
|
||||||
## is gcsafe and has 'void' as the return type.
|
## is gcsafe and has 'void' as the return type.
|
||||||
|
|
||||||
template spawnX*(call: stmt) =
|
template spawnX*(call: typed) =
|
||||||
## spawns a new task if a CPU core is ready, otherwise executes the
|
## spawns a new task if a CPU core is ready, otherwise executes the
|
||||||
## call in the calling thread. Usually it is advised to
|
## call in the calling thread. Usually it is advised to
|
||||||
## use 'spawn' in order to not block the producer for an unknown
|
## use 'spawn' in order to not block the producer for an unknown
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue