mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
Trim remaining expr/stmt from stdlib (#6742)
This commit is contained in:
committed by
Andreas Rumpf
parent
7f4248dc0c
commit
0ab373115c
@@ -400,7 +400,7 @@ proc quote*(bl: typed, op = "``"): NimNode {.magic: "QuoteAst", noSideEffect.}
|
||||
##
|
||||
## .. code-block:: nim
|
||||
##
|
||||
## macro check(ex: expr): stmt =
|
||||
## macro check(ex: untyped): typed =
|
||||
## # this is a simplified version of the check macro from the
|
||||
## # unittest module.
|
||||
##
|
||||
|
||||
@@ -3,12 +3,12 @@ export nativesockets
|
||||
|
||||
{.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".}
|
||||
newNativeSocket(domain, sockType, protocol)
|
||||
|
||||
template newRawSocket*(domain: Domain = AF_INET,
|
||||
sockType: SockType = SOCK_STREAM,
|
||||
protocol: Protocol = IPPROTO_TCP): expr =
|
||||
protocol: Protocol = IPPROTO_TCP): untyped =
|
||||
{.warning: "newRawSocket is deprecated, use newNativeSocket instead".}
|
||||
newNativeSocket(domain, sockType, protocol)
|
||||
|
||||
@@ -87,10 +87,10 @@ proc newSharedString*(s: string): SharedString =
|
||||
result.len = len
|
||||
|
||||
when declared(atomicLoadN):
|
||||
template load(x): expr = atomicLoadN(addr x, ATOMIC_SEQ_CST)
|
||||
template load(x): untyped = atomicLoadN(addr x, ATOMIC_SEQ_CST)
|
||||
else:
|
||||
# XXX Fixme
|
||||
template load(x): expr = x
|
||||
template load(x): untyped = x
|
||||
|
||||
proc add*(s: var SharedString; t: cstring; len: Natural) =
|
||||
if len == 0: return
|
||||
|
||||
@@ -841,7 +841,7 @@ elif not defined(useNimRtl):
|
||||
var attr: Tposix_spawnattr
|
||||
var fops: Tposix_spawn_file_actions
|
||||
|
||||
template chck(e: expr) =
|
||||
template chck(e: untyped) =
|
||||
if e != 0'i32: raiseOSError(osLastError())
|
||||
|
||||
chck posix_spawn_file_actions_init(fops)
|
||||
|
||||
@@ -21,7 +21,7 @@ proc name*(t: typedesc): string {.magic: "TypeTrait".}
|
||||
##
|
||||
## proc `$`*(T: typedesc): string = name(T)
|
||||
##
|
||||
## template test(x): stmt =
|
||||
## template test(x): typed =
|
||||
## echo "type: ", type(x), ", value: ", x
|
||||
##
|
||||
## test 42
|
||||
|
||||
@@ -2763,9 +2763,9 @@ when defined(nimvarargstyped):
|
||||
## pretends to be free of side effects, so that it can be used for debugging
|
||||
## routines marked as `noSideEffect <manual.html#pragmas-nosideeffect-pragma>`_.
|
||||
else:
|
||||
proc echo*(x: varargs[expr, `$`]) {.magic: "Echo", tags: [WriteIOEffect],
|
||||
proc echo*(x: varargs[untyped, `$`]) {.magic: "Echo", tags: [WriteIOEffect],
|
||||
benign, sideEffect.}
|
||||
proc debugEcho*(x: varargs[expr, `$`]) {.magic: "Echo", noSideEffect,
|
||||
proc debugEcho*(x: varargs[untyped, `$`]) {.magic: "Echo", noSideEffect,
|
||||
tags: [], raises: [].}
|
||||
|
||||
template newException*(exceptn: typedesc, message: string;
|
||||
@@ -3706,7 +3706,7 @@ proc instantiationInfo*(index = -1, fullPaths = false): tuple[
|
||||
## .. code-block:: nim
|
||||
## import strutils
|
||||
##
|
||||
## template testException(exception, code: expr): stmt =
|
||||
## template testException(exception, code: untyped): typed =
|
||||
## try:
|
||||
## let pos = instantiationInfo()
|
||||
## discard(code)
|
||||
@@ -3844,11 +3844,11 @@ type
|
||||
{.deprecated: [PNimrodNode: NimNode].}
|
||||
|
||||
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
|
||||
## optionally, the block can return an AST tree that will replace the
|
||||
## eval expression
|
||||
macro payload: stmt {.gensym.} = blk
|
||||
macro payload: typed {.gensym.} = blk
|
||||
payload()
|
||||
|
||||
when hasAlloc:
|
||||
|
||||
@@ -370,7 +370,7 @@ proc commandPrompt() =
|
||||
if dbgUser.len == 0: dbgUser.len = oldLen
|
||||
# now look what we have to do:
|
||||
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":
|
||||
dbgState = dbStepInto
|
||||
again = false
|
||||
|
||||
@@ -173,7 +173,7 @@ proc internRefcount(p: pointer): int {.exportc: "getRefcount".} =
|
||||
when BitsPerPage mod (sizeof(int)*8) != 0:
|
||||
{.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) =
|
||||
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.
|
||||
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
|
||||
## the calling thread. 'call' has to be proc call 'p(...)' where 'p'
|
||||
## 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
|
||||
## call in the calling thread. Usually it is advised to
|
||||
## use 'spawn' in order to not block the producer for an unknown
|
||||
|
||||
Reference in New Issue
Block a user