system.nim: don't use deprecated symbols/constructs

This commit is contained in:
Araq
2017-02-08 14:55:30 +01:00
parent 794d36cf31
commit 346ea6d171
8 changed files with 33 additions and 32 deletions

View File

@@ -98,7 +98,7 @@ type
SomeNumber* = SomeInteger|SomeReal
## type class matching all number types
proc defined*(x: expr): bool {.magic: "Defined", noSideEffect, compileTime.}
proc defined*(x: untyped): bool {.magic: "Defined", noSideEffect, compileTime.}
## Special compile-time procedure that checks whether `x` is
## defined.
## `x` is an external symbol introduced through the compiler's
@@ -119,7 +119,7 @@ when defined(nimalias):
TNumber: SomeNumber,
TOrdinal: SomeOrdinal].}
proc declared*(x: expr): bool {.magic: "Defined", noSideEffect, compileTime.}
proc declared*(x: untyped): bool {.magic: "Defined", noSideEffect, compileTime.}
## Special compile-time procedure that checks whether `x` is
## declared. `x` has to be an identifier or a qualified identifier.
## This can be used to check whether a library provides a certain
@@ -133,11 +133,11 @@ proc declared*(x: expr): bool {.magic: "Defined", noSideEffect, compileTime.}
when defined(useNimRtl):
{.deadCodeElim: on.}
proc definedInScope*(x: expr): bool {.
proc definedInScope*(x: untyped): bool {.
magic: "DefinedInScope", noSideEffect, deprecated, compileTime.}
## **Deprecated since version 0.9.6**: Use ``declaredInScope`` instead.
proc declaredInScope*(x: expr): bool {.
proc declaredInScope*(x: untyped): bool {.
magic: "DefinedInScope", noSideEffect, compileTime.}
## Special compile-time procedure that checks whether `x` is
## declared in the current scope. `x` has to be an identifier.
@@ -160,7 +160,7 @@ proc unsafeAddr*[T](x: T): ptr T {.magic: "Addr", noSideEffect.} =
## Cannot be overloaded.
discard
proc `type`*(x: expr): typeDesc {.magic: "TypeOf", noSideEffect, compileTime.} =
proc `type`*(x: untyped): typeDesc {.magic: "TypeOf", noSideEffect, compileTime.} =
## Builtin 'type' operator for accessing the type of an expression.
## Cannot be overloaded.
discard
@@ -2257,7 +2257,7 @@ iterator fields*[T: tuple|object](x: T): RootObj {.
## iterates over every field of `x`. Warning: This really transforms
## the 'for' and unrolls the loop. The current implementation also has a bug
## that affects symbol binding in the loop body.
iterator fields*[S:tuple|object, T:tuple|object](x: S, y: T): tuple[a,b: expr] {.
iterator fields*[S:tuple|object, T:tuple|object](x: S, y: T): tuple[a,b: untyped] {.
magic: "Fields", noSideEffect.}
## iterates over every field of `x` and `y`.
## Warning: This is really transforms the 'for' and unrolls the loop.
@@ -2298,7 +2298,7 @@ iterator fieldPairs*[T: tuple|object](x: T): RootObj {.
## current implementation also has a bug that affects symbol binding in the
## loop body.
iterator fieldPairs*[S: tuple|object, T: tuple|object](x: S, y: T): tuple[
a, b: expr] {.
a, b: untyped] {.
magic: "FieldPairs", noSideEffect.}
## iterates over every field of `x` and `y`.
## Warning: This really transforms the 'for' and unrolls the loop.
@@ -2443,7 +2443,7 @@ when not defined(nimscript) and hasAlloc:
proc GC_unref*(x: string) {.magic: "GCunref", benign.}
## see the documentation of `GC_ref`.
template accumulateResult*(iter: expr) =
template accumulateResult*(iter: untyped) =
## helps to convert an iterator to a proc.
result = @[]
for x in iter: add(result, x)
@@ -2558,7 +2558,8 @@ else:
proc debugEcho*(x: varargs[expr, `$`]) {.magic: "Echo", noSideEffect,
tags: [], raises: [].}
template newException*(exceptn: typedesc, message: string; parentException: ref Exception = nil): expr =
template newException*(exceptn: typedesc, message: string;
parentException: ref Exception = nil): untyped =
## creates an exception object of type ``exceptn`` and sets its ``msg`` field
## to `message`. Returns the new exception object.
var
@@ -3607,7 +3608,7 @@ when hasAlloc:
x[j+i] = item[j]
inc(j)
proc compiles*(x: expr): bool {.magic: "Compiles", noSideEffect, compileTime.} =
proc compiles*(x: untyped): bool {.magic: "Compiles", noSideEffect, compileTime.} =
## Special compile-time procedure that checks whether `x` can be compiled
## without any semantic error.
## This can be used to check whether a type supports some operation:
@@ -3671,7 +3672,7 @@ when hasAlloc and not defined(nimscript) and not defined(JS):
include "system/deepcopy"
proc procCall*(x: expr) {.magic: "ProcCall", compileTime.} =
proc procCall*(x: untyped) {.magic: "ProcCall", compileTime.} =
## special magic to prohibit dynamic binding for `method`:idx: calls.
## This is similar to `super`:idx: in ordinary OO languages.
##

View File

@@ -748,7 +748,7 @@ proc getOccupiedMem(a: MemRegion): int {.inline.} =
# ---------------------- thread memory region -------------------------------
template instantiateForRegion(allocator: expr) =
template instantiateForRegion(allocator: untyped) =
when defined(fulldebug):
proc interiorAllocatedPtr*(p: pointer): pointer =
result = interiorAllocatedPtr(allocator, p)

View File

@@ -324,7 +324,7 @@ when defined(endb):
when not defined(noSignalHandler):
proc signalHandler(sign: cint) {.exportc: "signalHandler", noconv.} =
template processSignal(s, action: expr) {.immediate, dirty.} =
template processSignal(s, action: untyped) {.dirty.} =
if s == SIGINT: action("SIGINT: Interrupted by Ctrl-C.\n")
elif s == SIGSEGV:
action("SIGSEGV: Illegal storage access. (Attempt to read from nil?)\n")

View File

@@ -144,7 +144,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) =
when col == rcBlack:
c.refcount = c.refcount and not colorMask
@@ -167,7 +167,7 @@ proc writeCell(msg: cstring, c: PCell) =
c_fprintf(stdout, "[GC] %s: %p %d %s rc=%ld; color=%ld\n",
msg, c, kind, typName, c.refcount shr rcShift, c.color)
template gcTrace(cell, state: expr): stmt {.immediate.} =
template gcTrace(cell, state: untyped) =
when traceGC: traceCell(cell, state)
# forward declarations:
@@ -179,13 +179,13 @@ proc forAllChildrenAux(dest: pointer, mt: PNimType, op: WalkOp) {.benign.}
# we need the prototype here for debugging purposes
when hasThreadSupport and hasSharedHeap:
template `--`(x: expr): expr = atomicDec(x, rcIncrement) <% rcIncrement
template `++`(x: expr): stmt = discard atomicInc(x, rcIncrement)
template `--`(x: untyped): untyped = atomicDec(x, rcIncrement) <% rcIncrement
template `++`(x: untyped) = discard atomicInc(x, rcIncrement)
else:
template `--`(x: expr): expr =
template `--`(x: untyped): untyped =
dec(x, rcIncrement)
x <% rcIncrement
template `++`(x: expr): stmt = inc(x, rcIncrement)
template `++`(x: untyped) = inc(x, rcIncrement)
proc incRef(c: PCell) {.inline.} =
gcAssert(isAllocatedPtr(gch.region, c), "incRef: interiorPtr")
@@ -419,7 +419,7 @@ proc addNewObjToZCT(res: PCell, gch: var GcHeap) {.inline.} =
var d = gch.zct.d
when true:
# loop unrolled for performance:
template replaceZctEntry(i: expr) =
template replaceZctEntry(i: untyped) =
c = d[i]
if c.refcount >=% rcIncrement:
c.refcount = c.refcount and not ZctFlag

View File

@@ -150,7 +150,7 @@ when allowForeignThreadGc:
setStackBottom(addr(stackTop))
initGC()
else:
template setupForeignThreadGc*(): stmt =
template setupForeignThreadGc*() =
{.error: "setupForeignThreadGc is available only when ``--threads:on`` and ``--tlsEmulation:off`` are used".}
# ----------------- stack management --------------------------------------
@@ -197,7 +197,7 @@ when defined(sparc): # For SPARC architecture.
var x = cast[ByteAddress](p)
result = a <=% x and x <=% b
template forEachStackSlot(gch, gcMark: expr) {.immediate, dirty.} =
template forEachStackSlot(gch, gcMark: untyped) {.dirty.} =
when defined(sparcv9):
asm """"flushw \n" """
else:
@@ -235,7 +235,7 @@ elif stackIncreases:
# a little hack to get the size of a JmpBuf in the generated C code
# in a platform independent way
template forEachStackSlot(gch, gcMark: expr) {.immediate, dirty.} =
template forEachStackSlot(gch, gcMark: untyped) {.dirty.} =
var registers {.noinit.}: C_JmpBuf
if c_setjmp(registers) == 0'i32: # To fill the C stack with registers.
var max = cast[ByteAddress](gch.stackBottom)
@@ -261,7 +261,7 @@ else:
if a <=% x and x <=% b:
return true
template forEachStackSlot(gch, gcMark: expr) {.immediate, dirty.} =
template forEachStackSlot(gch, gcMark: untyped) {.dirty.} =
# We use a jmp_buf buffer that is in the C stack.
# Used to traverse the stack and registers assuming
# that 'setjmp' will save registers in the C stack.
@@ -299,7 +299,7 @@ else:
var x = cast[ByteAddress](p)
result = a <=% x and x <=% b
template forEachStackSlot(gch, gcMark: expr) {.immediate, dirty.} =
template forEachStackSlot(gch, gcMark: untyped) {.dirty.} =
# We use a jmp_buf buffer that is in the C stack.
# Used to traverse the stack and registers assuming
# that 'setjmp' will save registers in the C stack.

View File

@@ -24,7 +24,7 @@ const
rcGrey = 1 # unused
rcBlack = 2
template mulThreshold(x): expr {.immediate.} = x * 2
template mulThreshold(x): untyped = x * 2
when defined(memProfiler):
proc nimProfile(requestedSize: int)

View File

@@ -33,16 +33,16 @@ proc eqStrings(a, b: NimString): bool {.inline, compilerProc.} =
equalMem(addr(a.data), addr(b.data), a.len)
when declared(allocAtomic):
template allocStr(size: expr): expr =
template allocStr(size: untyped): untyped =
cast[NimString](allocAtomic(size))
template allocStrNoInit(size: expr): expr =
template allocStrNoInit(size: untyped): untyped =
cast[NimString](boehmAllocAtomic(size))
else:
template allocStr(size: expr): expr =
template allocStr(size: untyped): untyped =
cast[NimString](newObj(addr(strDesc), size))
template allocStrNoInit(size: expr): expr =
template allocStrNoInit(size: untyped): untyped =
cast[NimString](newObjNoInit(addr(strDesc), size))
proc rawNewStringNoInit(space: int): NimString {.compilerProc.} =

View File

@@ -39,9 +39,9 @@ const
UNI_SUR_LOW_START = 0xDC00
UNI_SUR_LOW_END = 0xDFFF
template ones(n: expr): expr = ((1 shl n)-1)
template ones(n: untyped): untyped = ((1 shl n)-1)
template fastRuneAt(s: cstring, i: int, result: expr, doInc = true) =
template fastRuneAt(s: cstring, i: int, result: untyped, doInc = true) =
## Returns the unicode character ``s[i]`` in `result`. If ``doInc == true``
## `i` is incremented by the number of bytes that have been processed.
bind ones