styleCheck: make the compiler and large parts of the stdlib compatible with --styleCheck:error
This commit is contained in:
parent
96523cdd3e
commit
c94647aeca
90 changed files with 680 additions and 652 deletions
|
|
@ -499,7 +499,7 @@ type
|
|||
filename*: string
|
||||
line*,column*: int
|
||||
|
||||
proc `$`*(arg: Lineinfo): string =
|
||||
proc `$`*(arg: LineInfo): string =
|
||||
# BUG: without `result = `, gives compile error
|
||||
result = arg.filename & "(" & $arg.line & ", " & $arg.column & ")"
|
||||
|
||||
|
|
@ -988,16 +988,16 @@ proc newBlockStmt*(label, body: NimNode): NimNode {.compileTime.} =
|
|||
## Create a new block statement with label
|
||||
return newNimNode(nnkBlockStmt).add(label, body)
|
||||
|
||||
proc newBlockStmt*(body: NimNode): NimNode {.compiletime.} =
|
||||
proc newBlockStmt*(body: NimNode): NimNode {.compileTime.} =
|
||||
## Create a new block: stmt
|
||||
return newNimNode(nnkBlockStmt).add(newEmptyNode(), body)
|
||||
|
||||
proc newVarStmt*(name, value: NimNode): NimNode {.compiletime.} =
|
||||
proc newVarStmt*(name, value: NimNode): NimNode {.compileTime.} =
|
||||
## Create a new var stmt
|
||||
return newNimNode(nnkVarSection).add(
|
||||
newNimNode(nnkIdentDefs).add(name, newNimNode(nnkEmpty), value))
|
||||
|
||||
proc newLetStmt*(name, value: NimNode): NimNode {.compiletime.} =
|
||||
proc newLetStmt*(name, value: NimNode): NimNode {.compileTime.} =
|
||||
## Create a new let stmt
|
||||
return newNimNode(nnkLetSection).add(
|
||||
newNimNode(nnkIdentDefs).add(name, newNimNode(nnkEmpty), value))
|
||||
|
|
@ -1095,7 +1095,7 @@ proc newProc*(name = newEmptyNode();
|
|||
body)
|
||||
|
||||
proc newIfStmt*(branches: varargs[tuple[cond, body: NimNode]]):
|
||||
NimNode {.compiletime.} =
|
||||
NimNode {.compileTime.} =
|
||||
## Constructor for ``if`` statements.
|
||||
##
|
||||
## .. code-block:: nim
|
||||
|
|
@ -1233,7 +1233,7 @@ proc `body=`*(someProc: NimNode, val: NimNode) {.compileTime.} =
|
|||
else:
|
||||
badNodeKind someProc, "body="
|
||||
|
||||
proc basename*(a: NimNode): NimNode {.compiletime, benign.}
|
||||
proc basename*(a: NimNode): NimNode {.compileTime, benign.}
|
||||
|
||||
proc `$`*(node: NimNode): string {.compileTime.} =
|
||||
## Get the string of an identifier node
|
||||
|
|
@ -1396,7 +1396,7 @@ else:
|
|||
else:
|
||||
result = false
|
||||
|
||||
proc hasArgOfName*(params: NimNode; name: string): bool {.compiletime.}=
|
||||
proc hasArgOfName*(params: NimNode; name: string): bool {.compileTime.}=
|
||||
## Search nnkFormalParams for an argument.
|
||||
expectKind(params, nnkFormalParams)
|
||||
for i in 1 ..< params.len:
|
||||
|
|
@ -1404,7 +1404,7 @@ proc hasArgOfName*(params: NimNode; name: string): bool {.compiletime.}=
|
|||
if name.eqIdent( $ node[0]):
|
||||
return true
|
||||
|
||||
proc addIdentIfAbsent*(dest: NimNode, ident: string) {.compiletime.} =
|
||||
proc addIdentIfAbsent*(dest: NimNode, ident: string) {.compileTime.} =
|
||||
## Add ident to dest if it is not present. This is intended for use
|
||||
## with pragmas.
|
||||
for node in dest.children:
|
||||
|
|
|
|||
|
|
@ -170,14 +170,14 @@ proc add*[T](x: var seq[T]; value: sink T) {.magic: "AppendSeqElem", noSideEffec
|
|||
proc setLen[T](s: var seq[T], newlen: Natural) =
|
||||
{.noSideEffect.}:
|
||||
if newlen < s.len:
|
||||
shrink(s, newLen)
|
||||
shrink(s, newlen)
|
||||
else:
|
||||
let oldLen = s.len
|
||||
if newLen <= oldLen: return
|
||||
if newlen <= oldLen: return
|
||||
var xu = cast[ptr NimSeqV2[T]](addr s)
|
||||
if xu.p == nil or xu.p.cap < newLen:
|
||||
xu.p = cast[typeof(xu.p)](prepareSeqAdd(oldLen, xu.p, newLen - oldLen, sizeof(T)))
|
||||
xu.len = newLen
|
||||
if xu.p == nil or xu.p.cap < newlen:
|
||||
xu.p = cast[typeof(xu.p)](prepareSeqAdd(oldLen, xu.p, newlen - oldLen, sizeof(T)))
|
||||
xu.len = newlen
|
||||
|
||||
when false:
|
||||
proc resize[T](s: var NimSeqV2[T]) =
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@
|
|||
when false:
|
||||
# these are to be implemented or changed in the code generator.
|
||||
|
||||
#proc rawNewStringNoInit(space: int): NimString {.compilerProc.}
|
||||
#proc rawNewStringNoInit(space: int): NimString {.compilerproc.}
|
||||
# seems to be unused.
|
||||
proc copyDeepString(src: NimString): NimString {.inline.}
|
||||
# ----------------- sequences ----------------------------------------------
|
||||
|
||||
proc incrSeqV3(s: PGenericSeq, typ: PNimType): PGenericSeq {.compilerProc.}
|
||||
proc incrSeqV3(s: PGenericSeq, typ: PNimType): PGenericSeq {.compilerproc.}
|
||||
proc setLengthSeqV2(s: PGenericSeq, typ: PNimType, newLen: int): PGenericSeq {.
|
||||
compilerRtl.}
|
||||
proc newSeq(typ: PNimType, len: int): pointer {.compilerRtl.}
|
||||
|
|
@ -109,7 +109,7 @@ proc nimAddCharV1(s: var NimStringV2; c: char) {.compilerRtl.} =
|
|||
s.p.data[s.len+1] = '\0'
|
||||
inc s.len
|
||||
|
||||
proc toNimStr(str: cstring, len: int): NimStringV2 {.compilerProc.} =
|
||||
proc toNimStr(str: cstring, len: int): NimStringV2 {.compilerproc.} =
|
||||
if len <= 0:
|
||||
result = NimStringV2(len: 0, p: nil)
|
||||
else:
|
||||
|
|
@ -126,7 +126,7 @@ proc cstrToNimstr(str: cstring): NimStringV2 {.compilerRtl.} =
|
|||
if str == nil: toNimStr(str, 0)
|
||||
else: toNimStr(str, str.len)
|
||||
|
||||
proc nimToCStringConv(s: NimStringV2): cstring {.compilerProc, nonReloadable, inline.} =
|
||||
proc nimToCStringConv(s: NimStringV2): cstring {.compilerproc, nonReloadable, inline.} =
|
||||
if s.len == 0: result = cstring""
|
||||
else: result = cstring(unsafeAddr s.p.data)
|
||||
|
||||
|
|
@ -141,7 +141,7 @@ proc appendChar(dest: var NimStringV2; c: char) {.compilerproc, inline.} =
|
|||
dest.p.data[dest.len+1] = '\0'
|
||||
inc dest.len
|
||||
|
||||
proc rawNewString(space: int): NimStringV2 {.compilerProc.} =
|
||||
proc rawNewString(space: int): NimStringV2 {.compilerproc.} =
|
||||
# this is also 'system.newStringOfCap'.
|
||||
if space <= 0:
|
||||
result = NimStringV2(len: 0, p: nil)
|
||||
|
|
@ -152,7 +152,7 @@ proc rawNewString(space: int): NimStringV2 {.compilerProc.} =
|
|||
p.cap = space
|
||||
result = NimStringV2(len: 0, p: p)
|
||||
|
||||
proc mnewString(len: int): NimStringV2 {.compilerProc.} =
|
||||
proc mnewString(len: int): NimStringV2 {.compilerproc.} =
|
||||
if len <= 0:
|
||||
result = NimStringV2(len: 0, p: nil)
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue