Fix spellings (#12277) [backport]
This commit is contained in:
parent
9dd297f613
commit
39290cf88c
110 changed files with 166 additions and 166 deletions
|
|
@ -71,7 +71,7 @@ iterator parseTableCells*(s: string, delim = '\t'): Cell =
|
||||||
proc alignTable*(s: string, delim = '\t', fill = ' ', sep = " "): string =
|
proc alignTable*(s: string, delim = '\t', fill = ' ', sep = " "): string =
|
||||||
## formats a `delim`-delimited `s` representing a table; each cell is aligned
|
## formats a `delim`-delimited `s` representing a table; each cell is aligned
|
||||||
## to a width that's computed for each column; consecutive columns are
|
## to a width that's computed for each column; consecutive columns are
|
||||||
## delimted by `sep`, and alignment space is filled using `fill`.
|
## delimited by `sep`, and alignment space is filled using `fill`.
|
||||||
## More customized formatting can be done by calling `parseTableCells` directly.
|
## More customized formatting can be done by calling `parseTableCells` directly.
|
||||||
for cell in parseTableCells(s, delim):
|
for cell in parseTableCells(s, delim):
|
||||||
result.add cell.text
|
result.add cell.text
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ type
|
||||||
nkStmtListExpr, # a statement list followed by an expr; this is used
|
nkStmtListExpr, # a statement list followed by an expr; this is used
|
||||||
# to allow powerful multi-line templates
|
# to allow powerful multi-line templates
|
||||||
nkBlockExpr, # a statement block ending in an expr; this is used
|
nkBlockExpr, # a statement block ending in an expr; this is used
|
||||||
# to allowe powerful multi-line templates that open a
|
# to allow powerful multi-line templates that open a
|
||||||
# temporary scope
|
# temporary scope
|
||||||
nkStmtListType, # a statement list ending in a type; for macros
|
nkStmtListType, # a statement list ending in a type; for macros
|
||||||
nkBlockType, # a statement block ending in a type; for macros
|
nkBlockType, # a statement block ending in a type; for macros
|
||||||
|
|
@ -272,7 +272,7 @@ type
|
||||||
sfNamedParamCall, # symbol needs named parameter call syntax in target
|
sfNamedParamCall, # symbol needs named parameter call syntax in target
|
||||||
# language; for interfacing with Objective C
|
# language; for interfacing with Objective C
|
||||||
sfDiscardable, # returned value may be discarded implicitly
|
sfDiscardable, # returned value may be discarded implicitly
|
||||||
sfOverriden, # proc is overriden
|
sfOverriden, # proc is overridden
|
||||||
sfCallsite # A flag for template symbols to tell the
|
sfCallsite # A flag for template symbols to tell the
|
||||||
# compiler it should use line information from
|
# compiler it should use line information from
|
||||||
# the calling side of the macro, not from the
|
# the calling side of the macro, not from the
|
||||||
|
|
@ -535,8 +535,8 @@ type
|
||||||
tfTriggersCompileTime # uses the NimNode type which make the proc
|
tfTriggersCompileTime # uses the NimNode type which make the proc
|
||||||
# implicitly '.compiletime'
|
# implicitly '.compiletime'
|
||||||
tfRefsAnonObj # used for 'ref object' and 'ptr object'
|
tfRefsAnonObj # used for 'ref object' and 'ptr object'
|
||||||
tfCovariant # covariant generic param mimicing a ptr type
|
tfCovariant # covariant generic param mimicking a ptr type
|
||||||
tfWeakCovariant # covariant generic param mimicing a seq/array type
|
tfWeakCovariant # covariant generic param mimicking a seq/array type
|
||||||
tfContravariant # contravariant generic param
|
tfContravariant # contravariant generic param
|
||||||
tfCheckedForDestructor # type was checked for having a destructor.
|
tfCheckedForDestructor # type was checked for having a destructor.
|
||||||
# If it has one, t.destructor is not nil.
|
# If it has one, t.destructor is not nil.
|
||||||
|
|
@ -1250,7 +1250,7 @@ proc skipTypes*(t: PType, kinds: TTypeKinds): PType =
|
||||||
|
|
||||||
proc newIntTypeNode*(intVal: BiggestInt, typ: PType): PNode =
|
proc newIntTypeNode*(intVal: BiggestInt, typ: PType): PNode =
|
||||||
|
|
||||||
# this is dirty. abstractVarRange isn't defined yet and therefor it
|
# this is dirty. abstractVarRange isn't defined yet and therefore it
|
||||||
# is duplicated here.
|
# is duplicated here.
|
||||||
const abstractVarRange = {tyGenericInst, tyRange, tyVar, tyDistinct, tyOrdinal,
|
const abstractVarRange = {tyGenericInst, tyRange, tyVar, tyDistinct, tyOrdinal,
|
||||||
tyTypeDesc, tyAlias, tyInferred, tySink, tyOwned}
|
tyTypeDesc, tyAlias, tyInferred, tySink, tyOwned}
|
||||||
|
|
|
||||||
|
|
@ -1027,7 +1027,7 @@ proc genAndOr(p: BProc, e: PNode, d: var TLoc, m: TMagic) =
|
||||||
dec p.splitDecls
|
dec p.splitDecls
|
||||||
|
|
||||||
proc genEcho(p: BProc, n: PNode) =
|
proc genEcho(p: BProc, n: PNode) =
|
||||||
# this unusal way of implementing it ensures that e.g. ``echo("hallo", 45)``
|
# this unusual way of implementing it ensures that e.g. ``echo("hallo", 45)``
|
||||||
# is threadsafe.
|
# is threadsafe.
|
||||||
internalAssert p.config, n.kind == nkBracket
|
internalAssert p.config, n.kind == nkBracket
|
||||||
if p.config.target.targetOS == osGenode:
|
if p.config.target.targetOS == osGenode:
|
||||||
|
|
|
||||||
|
|
@ -784,7 +784,7 @@ proc genStringCase(p: BProc, t: PNode, d: var TLoc) =
|
||||||
var branches: seq[Rope]
|
var branches: seq[Rope]
|
||||||
newSeq(branches, bitMask + 1)
|
newSeq(branches, bitMask + 1)
|
||||||
var a: TLoc
|
var a: TLoc
|
||||||
initLocExpr(p, t.sons[0], a) # fist pass: gnerate ifs+goto:
|
initLocExpr(p, t.sons[0], a) # fist pass: generate ifs+goto:
|
||||||
var labId = p.labels
|
var labId = p.labels
|
||||||
for i in 1 ..< len(t):
|
for i in 1 ..< len(t):
|
||||||
inc(p.labels)
|
inc(p.labels)
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ proc mangleParamName(m: BModule; s: PSym): Rope =
|
||||||
var res = s.name.s.mangle
|
var res = s.name.s.mangle
|
||||||
# Take into account if HCR is on because of the following scenario:
|
# Take into account if HCR is on because of the following scenario:
|
||||||
# if a module gets imported and it has some more importc symbols in it,
|
# if a module gets imported and it has some more importc symbols in it,
|
||||||
# some param names might recieve the "_0" suffix to distinguish from what
|
# some param names might receive the "_0" suffix to distinguish from what
|
||||||
# is newly available. That might lead to changes in the C code in nimcache
|
# is newly available. That might lead to changes in the C code in nimcache
|
||||||
# that contain only a parameter name change, but that is enough to mandate
|
# that contain only a parameter name change, but that is enough to mandate
|
||||||
# recompilation of that source file and thus a new shared object will be
|
# recompilation of that source file and thus a new shared object will be
|
||||||
|
|
|
||||||
|
|
@ -1255,7 +1255,7 @@ proc hcrGetProcLoadCode(m: BModule, sym, prefix, handle, getProcFunc: string): R
|
||||||
|
|
||||||
proc genMainProc(m: BModule) =
|
proc genMainProc(m: BModule) =
|
||||||
## this function is called in cgenWriteModules after all modules are closed,
|
## this function is called in cgenWriteModules after all modules are closed,
|
||||||
## it means raising dependency on the symbols is too late as it will not propogate
|
## it means raising dependency on the symbols is too late as it will not propagate
|
||||||
## into other modules, only simple rope manipulations are allowed
|
## into other modules, only simple rope manipulations are allowed
|
||||||
|
|
||||||
var preMainCode: Rope
|
var preMainCode: Rope
|
||||||
|
|
@ -1514,7 +1514,7 @@ proc registerModuleToMain(g: BModuleList; m: BModule) =
|
||||||
|
|
||||||
proc genDatInitCode(m: BModule) =
|
proc genDatInitCode(m: BModule) =
|
||||||
## this function is called in cgenWriteModules after all modules are closed,
|
## this function is called in cgenWriteModules after all modules are closed,
|
||||||
## it means raising dependency on the symbols is too late as it will not propogate
|
## it means raising dependency on the symbols is too late as it will not propagate
|
||||||
## into other modules, only simple rope manipulations are allowed
|
## into other modules, only simple rope manipulations are allowed
|
||||||
|
|
||||||
var moduleDatInitRequired = m.hcrOn
|
var moduleDatInitRequired = m.hcrOn
|
||||||
|
|
@ -1558,7 +1558,7 @@ proc hcrGetProcLoadCode(m: BModule, sym, prefix, handle, getProcFunc: string): R
|
||||||
|
|
||||||
proc genInitCode(m: BModule) =
|
proc genInitCode(m: BModule) =
|
||||||
## this function is called in cgenWriteModules after all modules are closed,
|
## this function is called in cgenWriteModules after all modules are closed,
|
||||||
## it means raising dependency on the symbols is too late as it will not propogate
|
## it means raising dependency on the symbols is too late as it will not propagate
|
||||||
## into other modules, only simple rope manipulations are allowed
|
## into other modules, only simple rope manipulations are allowed
|
||||||
var moduleInitRequired = m.hcrOn
|
var moduleInitRequired = m.hcrOn
|
||||||
let initname = getInitName(m)
|
let initname = getInitName(m)
|
||||||
|
|
@ -1746,7 +1746,7 @@ proc rawNewModule(g: BModuleList; module: PSym, filename: AbsoluteFile): BModule
|
||||||
result.typeNodesName = getTempName(result)
|
result.typeNodesName = getTempName(result)
|
||||||
result.nimTypesName = getTempName(result)
|
result.nimTypesName = getTempName(result)
|
||||||
# no line tracing for the init sections of the system module so that we
|
# no line tracing for the init sections of the system module so that we
|
||||||
# don't generate a TFrame which can confuse the stack botton initialization:
|
# don't generate a TFrame which can confuse the stack bottom initialization:
|
||||||
if sfSystemModule in module.flags:
|
if sfSystemModule in module.flags:
|
||||||
incl result.flags, preventStackTrace
|
incl result.flags, preventStackTrace
|
||||||
excl(result.preInitProc.options, optStackTrace)
|
excl(result.preInitProc.options, optStackTrace)
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ type
|
||||||
id*: int # the ID of the label; positive means that it
|
id*: int # the ID of the label; positive means that it
|
||||||
label*: Rope # generated text for the label
|
label*: Rope # generated text for the label
|
||||||
# nil if label is not used
|
# nil if label is not used
|
||||||
sections*: TCProcSections # the code beloging
|
sections*: TCProcSections # the code belonging
|
||||||
isLoop*: bool # whether block is a loop
|
isLoop*: bool # whether block is a loop
|
||||||
nestedTryStmts*: int16 # how many try statements is it nested into
|
nestedTryStmts*: int16 # how many try statements is it nested into
|
||||||
nestedExceptStmts*: int16 # how many except statements is it nested into
|
nestedExceptStmts*: int16 # how many except statements is it nested into
|
||||||
|
|
@ -150,7 +150,7 @@ type
|
||||||
initProc*: BProc # code for init procedure
|
initProc*: BProc # code for init procedure
|
||||||
preInitProc*: BProc # code executed before the init proc
|
preInitProc*: BProc # code executed before the init proc
|
||||||
hcrCreateTypeInfosProc*: Rope # type info globals are in here when HCR=on
|
hcrCreateTypeInfosProc*: Rope # type info globals are in here when HCR=on
|
||||||
inHcrInitGuard*: bool # We are currently withing a HCR reloading guard.
|
inHcrInitGuard*: bool # We are currently within a HCR reloading guard.
|
||||||
typeStack*: TTypeSeq # used for type generation
|
typeStack*: TTypeSeq # used for type generation
|
||||||
dataCache*: TNodeTable
|
dataCache*: TNodeTable
|
||||||
typeNodes*, nimTypes*: int # used for type info generation
|
typeNodes*, nimTypes*: int # used for type info generation
|
||||||
|
|
|
||||||
|
|
@ -1288,7 +1288,7 @@ proc transformClosureIterator*(g: ModuleGraph; fn: PSym, n: PNode): PNode =
|
||||||
if getEnvParam(fn).isNil:
|
if getEnvParam(fn).isNil:
|
||||||
# Lambda lifting was not done yet. Use temporary :state sym, which will
|
# Lambda lifting was not done yet. Use temporary :state sym, which will
|
||||||
# be handled specially by lambda lifting. Local temp vars (if needed)
|
# be handled specially by lambda lifting. Local temp vars (if needed)
|
||||||
# should folllow the same logic.
|
# should follow the same logic.
|
||||||
ctx.stateVarSym = newSym(skVar, getIdent(ctx.g.cache, ":state"), fn, fn.info)
|
ctx.stateVarSym = newSym(skVar, getIdent(ctx.g.cache, ":state"), fn, fn.info)
|
||||||
ctx.stateVarSym.typ = g.createClosureIterStateType(fn)
|
ctx.stateVarSym.typ = g.createClosureIterStateType(fn)
|
||||||
ctx.stateLoopLabel = newSym(skLabel, getIdent(ctx.g.cache, ":stateLoop"), fn, fn.info)
|
ctx.stateLoopLabel = newSym(skLabel, getIdent(ctx.g.cache, ":stateLoop"), fn, fn.info)
|
||||||
|
|
@ -1309,7 +1309,7 @@ proc transformClosureIterator*(g: ModuleGraph; fn: PSym, n: PNode): PNode =
|
||||||
# Optimize empty states away
|
# Optimize empty states away
|
||||||
ctx.deleteEmptyStates()
|
ctx.deleteEmptyStates()
|
||||||
|
|
||||||
# Make new body by concating the list of states
|
# Make new body by concatenating the list of states
|
||||||
result = newNodeI(nkStmtList, n.info)
|
result = newNodeI(nkStmtList, n.info)
|
||||||
for s in ctx.states:
|
for s in ctx.states:
|
||||||
assert(s.len == 2)
|
assert(s.len == 2)
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ proc loadConfigsAndRunMainCommand*(self: NimProg, cache: IdentCache; conf: Confi
|
||||||
discard
|
discard
|
||||||
|
|
||||||
# now process command line arguments again, because some options in the
|
# now process command line arguments again, because some options in the
|
||||||
# command line can overwite the config file's settings
|
# command line can overwrite the config file's settings
|
||||||
extccomp.initVars(conf)
|
extccomp.initVars(conf)
|
||||||
self.processCmdLine(passCmd2, "", conf)
|
self.processCmdLine(passCmd2, "", conf)
|
||||||
if conf.command == "":
|
if conf.command == "":
|
||||||
|
|
|
||||||
|
|
@ -513,7 +513,7 @@ proc genTry(c: var Con; n: PNode) =
|
||||||
let f = c.tryStmtFixups[i]
|
let f = c.tryStmtFixups[i]
|
||||||
c.patch(f)
|
c.patch(f)
|
||||||
# we also need to produce join instructions
|
# we also need to produce join instructions
|
||||||
# for the 'fork' that might preceed the goto instruction
|
# for the 'fork' that might precede the goto instruction
|
||||||
if f.int-1 >= 0 and c.code[f.int-1].kind == fork:
|
if f.int-1 >= 0 and c.code[f.int-1].kind == fork:
|
||||||
c.joinI(TPosition(f.int-1), n)
|
c.joinI(TPosition(f.int-1), n)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ proc evalTemplateArgs(n: PNode, s: PSym; conf: ConfigRef; fromHlo: bool): PNode
|
||||||
else:
|
else:
|
||||||
addSon(result, default.copyTree)
|
addSon(result, default.copyTree)
|
||||||
|
|
||||||
# add any generic paramaters
|
# add any generic parameters
|
||||||
for i in 1 .. genericParams:
|
for i in 1 .. genericParams:
|
||||||
result.addSon n.sons[givenRegularParams + i]
|
result.addSon n.sons[givenRegularParams + i]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -404,7 +404,7 @@ proc getConfigVar(conf: ConfigRef; c: TSystemCC, suffix: string): string =
|
||||||
CC[c].name & fullSuffix
|
CC[c].name & fullSuffix
|
||||||
result = getConfigVar(conf, fullCCname)
|
result = getConfigVar(conf, fullCCname)
|
||||||
if result.len == 0:
|
if result.len == 0:
|
||||||
# not overriden for this cross compilation setting?
|
# not overridden for this cross compilation setting?
|
||||||
result = getConfigVar(conf, CC[c].name & fullSuffix)
|
result = getConfigVar(conf, CC[c].name & fullSuffix)
|
||||||
else:
|
else:
|
||||||
result = getConfigVar(conf, CC[c].name & fullSuffix)
|
result = getConfigVar(conf, CC[c].name & fullSuffix)
|
||||||
|
|
@ -757,7 +757,7 @@ proc getLinkCmd(conf: ConfigRef; output: AbsoluteFile,
|
||||||
# way of being able to debug and rebuild the program at the same time. This
|
# way of being able to debug and rebuild the program at the same time. This
|
||||||
# is accomplished using the /PDB:<filename> flag (there also exists the
|
# is accomplished using the /PDB:<filename> flag (there also exists the
|
||||||
# /PDBALTPATH:<filename> flag). The only downside is that the .pdb files are
|
# /PDBALTPATH:<filename> flag). The only downside is that the .pdb files are
|
||||||
# atleast 300kb big (when linking statically to the runtime - or else 5mb+)
|
# at least 300kb big (when linking statically to the runtime - or else 5mb+)
|
||||||
# and will quickly accumulate. There is a hacky solution: we could try to
|
# and will quickly accumulate. There is a hacky solution: we could try to
|
||||||
# delete all .pdb files with a pattern and swallow exceptions.
|
# delete all .pdb files with a pattern and swallow exceptions.
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ type
|
||||||
info: TLineInfo
|
info: TLineInfo
|
||||||
indent, emitPar: int
|
indent, emitPar: int
|
||||||
x: string # the current input line
|
x: string # the current input line
|
||||||
outp: PLLStream # the ouput will be parsed by pnimsyn
|
outp: PLLStream # the output will be parsed by pnimsyn
|
||||||
subsChar, nimDirective: char
|
subsChar, nimDirective: char
|
||||||
emit, conc, toStr: string
|
emit, conc, toStr: string
|
||||||
curly, bracket, par: int
|
curly, bracket, par: int
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ proc hlo(c: PContext, n: PNode): PNode
|
||||||
proc evalPattern(c: PContext, n, orig: PNode): PNode =
|
proc evalPattern(c: PContext, n, orig: PNode): PNode =
|
||||||
internalAssert c.config, n.kind == nkCall and n.sons[0].kind == nkSym
|
internalAssert c.config, n.kind == nkCall and n.sons[0].kind == nkSym
|
||||||
# we need to ensure that the resulting AST is semchecked. However, it's
|
# we need to ensure that the resulting AST is semchecked. However, it's
|
||||||
# aweful to semcheck before macro invocation, so we don't and treat
|
# awful to semcheck before macro invocation, so we don't and treat
|
||||||
# templates and macros as immediate in this context.
|
# templates and macros as immediate in this context.
|
||||||
var rule: string
|
var rule: string
|
||||||
if optHints in c.config.options and hintPattern in c.config.notes:
|
if optHints in c.config.options and hintPattern in c.config.notes:
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ proc importPureEnumField*(c: PContext; s: PSym) =
|
||||||
if checkB == nil:
|
if checkB == nil:
|
||||||
strTableAdd(c.pureEnumFields, s)
|
strTableAdd(c.pureEnumFields, s)
|
||||||
else:
|
else:
|
||||||
# mark as ambigous:
|
# mark as ambiguous:
|
||||||
incl(c.ambiguousSymbols, checkB.id)
|
incl(c.ambiguousSymbols, checkB.id)
|
||||||
incl(c.ambiguousSymbols, s.id)
|
incl(c.ambiguousSymbols, s.id)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -256,7 +256,7 @@ proc isLastRead(n: PNode; c: var Con): bool =
|
||||||
|
|
||||||
proc initialized(code: ControlFlowGraph; pc: int,
|
proc initialized(code: ControlFlowGraph; pc: int,
|
||||||
init, uninit: var IntSet; comesFrom: int): int =
|
init, uninit: var IntSet; comesFrom: int): int =
|
||||||
## Computes the set of definitely initialized variables accross all code paths
|
## Computes the set of definitely initialized variables across all code paths
|
||||||
## as an IntSet of IDs.
|
## as an IntSet of IDs.
|
||||||
var pc = pc
|
var pc = pc
|
||||||
while pc < code.len:
|
while pc < code.len:
|
||||||
|
|
@ -492,7 +492,7 @@ proc pArg(arg: PNode; c: var Con; isSink: bool): PNode =
|
||||||
result.add pArg(arg[i], c, i < L and isSinkTypeForParam(parameters[i]))
|
result.add pArg(arg[i], c, i < L and isSinkTypeForParam(parameters[i]))
|
||||||
elif arg.containsConstSeq:
|
elif arg.containsConstSeq:
|
||||||
# const sequences are not mutable and so we need to pass a copy to the
|
# const sequences are not mutable and so we need to pass a copy to the
|
||||||
# sink parameter (bug #11524). Note that the string implemenation is
|
# sink parameter (bug #11524). Note that the string implementation is
|
||||||
# different and can deal with 'const string sunk into var'.
|
# different and can deal with 'const string sunk into var'.
|
||||||
result = passCopyToSink(arg, c)
|
result = passCopyToSink(arg, c)
|
||||||
elif arg.kind in {nkBracket, nkObjConstr, nkTupleConstr, nkCharLit..nkTripleStrLit}:
|
elif arg.kind in {nkBracket, nkObjConstr, nkTupleConstr, nkCharLit..nkTripleStrLit}:
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ type
|
||||||
TErrorHandler* = proc (conf: ConfigRef; info: TLineInfo; msg: TMsgKind; arg: string)
|
TErrorHandler* = proc (conf: ConfigRef; info: TLineInfo; msg: TMsgKind; arg: string)
|
||||||
TLexer* = object of TBaseLexer
|
TLexer* = object of TBaseLexer
|
||||||
fileIdx*: FileIndex
|
fileIdx*: FileIndex
|
||||||
indentAhead*: int # if > 0 an indendation has already been read
|
indentAhead*: int # if > 0 an indentation has already been read
|
||||||
# this is needed because scanning comments
|
# this is needed because scanning comments
|
||||||
# needs so much look-ahead
|
# needs so much look-ahead
|
||||||
currLineIndent*: int
|
currLineIndent*: int
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,7 @@ proc addInterfaceOverloadableSymAt*(c: PContext, scope: PScope, sym: PSym) =
|
||||||
addInterfaceDeclAux(c, sym)
|
addInterfaceDeclAux(c, sym)
|
||||||
|
|
||||||
when defined(nimfix):
|
when defined(nimfix):
|
||||||
# when we cannot find the identifier, retry with a changed identifer:
|
# when we cannot find the identifier, retry with a changed identifier:
|
||||||
proc altSpelling(x: PIdent): PIdent =
|
proc altSpelling(x: PIdent): PIdent =
|
||||||
case x.s[0]
|
case x.s[0]
|
||||||
of 'A'..'Z': result = getIdent(toLowerAscii(x.s[0]) & x.s.substr(1))
|
of 'A'..'Z': result = getIdent(toLowerAscii(x.s[0]) & x.s.substr(1))
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ type
|
||||||
importModuleCallback*: proc (graph: ModuleGraph; m: PSym, fileIdx: FileIndex): PSym {.nimcall.}
|
importModuleCallback*: proc (graph: ModuleGraph; m: PSym, fileIdx: FileIndex): PSym {.nimcall.}
|
||||||
includeFileCallback*: proc (graph: ModuleGraph; m: PSym, fileIdx: FileIndex): PNode {.nimcall.}
|
includeFileCallback*: proc (graph: ModuleGraph; m: PSym, fileIdx: FileIndex): PNode {.nimcall.}
|
||||||
recordStmt*: proc (graph: ModuleGraph; m: PSym; n: PNode) {.nimcall.}
|
recordStmt*: proc (graph: ModuleGraph; m: PSym; n: PNode) {.nimcall.}
|
||||||
cacheSeqs*: Table[string, PNode] # state that is shared to suppor the 'macrocache' API
|
cacheSeqs*: Table[string, PNode] # state that is shared to support the 'macrocache' API
|
||||||
cacheCounters*: Table[string, BiggestInt]
|
cacheCounters*: Table[string, BiggestInt]
|
||||||
cacheTables*: Table[string, BTree[string, PNode]]
|
cacheTables*: Table[string, BTree[string, PNode]]
|
||||||
passes*: seq[TPass]
|
passes*: seq[TPass]
|
||||||
|
|
@ -215,7 +215,7 @@ proc addDep*(g: ModuleGraph; m: PSym, dep: FileIndex) =
|
||||||
addModuleDep(g.incr, g.config, m.info.fileIndex, dep, isIncludeFile = false)
|
addModuleDep(g.incr, g.config, m.info.fileIndex, dep, isIncludeFile = false)
|
||||||
if g.suggestMode:
|
if g.suggestMode:
|
||||||
g.deps.incl m.position.dependsOn(dep.int)
|
g.deps.incl m.position.dependsOn(dep.int)
|
||||||
# we compute the transitive closure later when quering the graph lazily.
|
# we compute the transitive closure later when querying the graph lazily.
|
||||||
# this improves efficiency quite a lot:
|
# this improves efficiency quite a lot:
|
||||||
#invalidTransitiveClosure = true
|
#invalidTransitiveClosure = true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ proc selectUniqueSymbol*(i: Interpreter; name: string;
|
||||||
s = nextIdentIter(it, i.mainModule.tab)
|
s = nextIdentIter(it, i.mainModule.tab)
|
||||||
|
|
||||||
proc selectRoutine*(i: Interpreter; name: string): PSym =
|
proc selectRoutine*(i: Interpreter; name: string): PSym =
|
||||||
## Selects a declared rountine (proc/func/etc) from the main module.
|
## Selects a declared routine (proc/func/etc) from the main module.
|
||||||
## The routine needs to have the export marker ``*``. The only matching
|
## The routine needs to have the export marker ``*``. The only matching
|
||||||
## routine is returned and ``nil`` if it is overloaded.
|
## routine is returned and ``nil`` if it is overloaded.
|
||||||
result = selectUniqueSymbol(i, name, {skTemplate, skMacro, skFunc,
|
result = selectUniqueSymbol(i, name, {skTemplate, skMacro, skFunc,
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ proc handleCmdLine(config: ConfigRef) =
|
||||||
gProjectPath = getCurrentDir()
|
gProjectPath = getCurrentDir()
|
||||||
loadConfigs(DefaultConfig, config) # load all config files
|
loadConfigs(DefaultConfig, config) # load all config files
|
||||||
# now process command line arguments again, because some options in the
|
# now process command line arguments again, because some options in the
|
||||||
# command line can overwite the config file's settings
|
# command line can overwrite the config file's settings
|
||||||
extccomp.initVars()
|
extccomp.initVars()
|
||||||
processCmdLine(passCmd2, "", config)
|
processCmdLine(passCmd2, "", config)
|
||||||
mainCommand()
|
mainCommand()
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,6 @@ const
|
||||||
VersionAsString* = system.NimVersion
|
VersionAsString* = system.NimVersion
|
||||||
RodFileVersion* = "1223" # modify this if the rod-format changes!
|
RodFileVersion* = "1223" # modify this if the rod-format changes!
|
||||||
|
|
||||||
NimCompilerApiVersion* = 3 ## Check for the existance of this before accessing it
|
NimCompilerApiVersion* = 3 ## Check for the existence of this before accessing it
|
||||||
## as older versions of the compiler API do not
|
## as older versions of the compiler API do not
|
||||||
## declare this.
|
## declare this.
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ type
|
||||||
LegacyFeature* = enum
|
LegacyFeature* = enum
|
||||||
allowSemcheckedAstModification,
|
allowSemcheckedAstModification,
|
||||||
## Allows to modify a NimNode where the type has already been
|
## Allows to modify a NimNode where the type has already been
|
||||||
## flaged with nfSem. If you actually do this, it will cause
|
## flagged with nfSem. If you actually do this, it will cause
|
||||||
## bugs.
|
## bugs.
|
||||||
|
|
||||||
SymbolFilesOption* = enum
|
SymbolFilesOption* = enum
|
||||||
|
|
|
||||||
|
|
@ -710,7 +710,7 @@ proc identOrLiteral(p: var TParser, mode: TPrimaryMode): PNode =
|
||||||
result = parseCast(p)
|
result = parseCast(p)
|
||||||
else:
|
else:
|
||||||
parMessage(p, errExprExpected, p.tok)
|
parMessage(p, errExprExpected, p.tok)
|
||||||
getTok(p) # we must consume a token here to prevend endless loops!
|
getTok(p) # we must consume a token here to prevent endless loops!
|
||||||
result = p.emptyNode
|
result = p.emptyNode
|
||||||
|
|
||||||
proc namedParams(p: var TParser, callee: PNode,
|
proc namedParams(p: var TParser, callee: PNode,
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ proc equalGenericParams(procA, procB: PNode): bool =
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
proc searchForProcOld*(c: PContext, scope: PScope, fn: PSym): PSym =
|
proc searchForProcOld*(c: PContext, scope: PScope, fn: PSym): PSym =
|
||||||
# Searchs for a forward declaration or a "twin" symbol of fn
|
# Searches for a forward declaration or a "twin" symbol of fn
|
||||||
# in the symbol table. If the parameter lists are exactly
|
# in the symbol table. If the parameter lists are exactly
|
||||||
# the same the sym in the symbol table is returned, else nil.
|
# the same the sym in the symbol table is returned, else nil.
|
||||||
var it: TIdentIter
|
var it: TIdentIter
|
||||||
|
|
@ -108,7 +108,7 @@ when false:
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
proc searchForBorrowProc*(c: PContext, startScope: PScope, fn: PSym): PSym =
|
proc searchForBorrowProc*(c: PContext, startScope: PScope, fn: PSym): PSym =
|
||||||
# Searchs for the fn in the symbol table. If the parameter lists are suitable
|
# Searches for the fn in the symbol table. If the parameter lists are suitable
|
||||||
# for borrowing the sym in the symbol table is returned, else nil.
|
# for borrowing the sym in the symbol table is returned, else nil.
|
||||||
var it: TIdentIter
|
var it: TIdentIter
|
||||||
for scope in walkScopes(startScope):
|
for scope in walkScopes(startScope):
|
||||||
|
|
|
||||||
|
|
@ -640,7 +640,7 @@ proc explicitGenericInstantiation(c: PContext, n: PNode, s: PSym): PNode =
|
||||||
result = explicitGenericInstError(c, n)
|
result = explicitGenericInstError(c, n)
|
||||||
|
|
||||||
proc searchForBorrowProc(c: PContext, startScope: PScope, fn: PSym): PSym =
|
proc searchForBorrowProc(c: PContext, startScope: PScope, fn: PSym): PSym =
|
||||||
# Searchs for the fn in the symbol table. If the parameter lists are suitable
|
# Searches for the fn in the symbol table. If the parameter lists are suitable
|
||||||
# for borrowing the sym in the symbol table is returned, else nil.
|
# for borrowing the sym in the symbol table is returned, else nil.
|
||||||
# New approach: generate fn(x, y, z) where x, y, z have the proper types
|
# New approach: generate fn(x, y, z) where x, y, z have the proper types
|
||||||
# and use the overloading resolution mechanism:
|
# and use the overloading resolution mechanism:
|
||||||
|
|
|
||||||
|
|
@ -2038,7 +2038,7 @@ proc tryExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||||
let oldErrorMax = c.config.errorMax
|
let oldErrorMax = c.config.errorMax
|
||||||
let oldCompilesId = c.compilesContextId
|
let oldCompilesId = c.compilesContextId
|
||||||
# if this is a nested 'when compiles', do not increase the ID so that
|
# if this is a nested 'when compiles', do not increase the ID so that
|
||||||
# generic instantations can still be cached for this level.
|
# generic instantiations can still be cached for this level.
|
||||||
if c.compilesContextId == 0:
|
if c.compilesContextId == 0:
|
||||||
inc c.compilesContextIdGenerator
|
inc c.compilesContextIdGenerator
|
||||||
c.compilesContextId = c.compilesContextIdGenerator
|
c.compilesContextId = c.compilesContextIdGenerator
|
||||||
|
|
|
||||||
|
|
@ -211,7 +211,7 @@ proc instGenericContainer(c: PContext, info: TLineInfo, header: PType,
|
||||||
param.typ = makeTypeDesc(c, header[i+1])
|
param.typ = makeTypeDesc(c, header[i+1])
|
||||||
|
|
||||||
# this scope was not created by the user,
|
# this scope was not created by the user,
|
||||||
# unused params shoudn't be reported.
|
# unused params shouldn't be reported.
|
||||||
param.flags.incl sfUsed
|
param.flags.incl sfUsed
|
||||||
addDecl(c, param)
|
addDecl(c, param)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -279,7 +279,7 @@ proc semDynamicBindSym(c: PContext, n: PNode): PNode =
|
||||||
a.setResult opBindSym(c, scope, a.getNode(0), a.getInt(1).int, a.getNode(2))
|
a.setResult opBindSym(c, scope, a.getNode(0), a.getInt(1).int, a.getNode(2))
|
||||||
|
|
||||||
let
|
let
|
||||||
# altough we use VM callback here, it is not
|
# although we use VM callback here, it is not
|
||||||
# executed like 'normal' VM callback
|
# executed like 'normal' VM callback
|
||||||
idx = vm.registerCallback("bindSymImpl", bindSymWrapper)
|
idx = vm.registerCallback("bindSymImpl", bindSymWrapper)
|
||||||
# dummy node to carry idx information to VM
|
# dummy node to carry idx information to VM
|
||||||
|
|
|
||||||
|
|
@ -339,7 +339,7 @@ proc semConstructFields(c: PContext, recNode: PNode,
|
||||||
result = initPartial
|
result = initPartial
|
||||||
if discriminatorVal.kind == nkIntLit:
|
if discriminatorVal.kind == nkIntLit:
|
||||||
# When the discriminator is a compile-time value, we also know
|
# When the discriminator is a compile-time value, we also know
|
||||||
# which brach will be selected:
|
# which branch will be selected:
|
||||||
let matchedBranch = recNode.pickCaseBranch discriminatorVal
|
let matchedBranch = recNode.pickCaseBranch discriminatorVal
|
||||||
if matchedBranch != nil: checkMissingFields matchedBranch
|
if matchedBranch != nil: checkMissingFields matchedBranch
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -575,7 +575,7 @@ proc trackOperand(tracked: PEffects, n: PNode, paramType: PType; caller: PNode)
|
||||||
notNilCheck(tracked, n, paramType)
|
notNilCheck(tracked, n, paramType)
|
||||||
|
|
||||||
proc breaksBlock(n: PNode): bool =
|
proc breaksBlock(n: PNode): bool =
|
||||||
# sematic check doesn't allow statements after raise, break, return or
|
# semantic check doesn't allow statements after raise, break, return or
|
||||||
# call to noreturn proc, so it is safe to check just the last statements
|
# call to noreturn proc, so it is safe to check just the last statements
|
||||||
var it = n
|
var it = n
|
||||||
while it.kind in {nkStmtList, nkStmtListExpr} and it.len > 0:
|
while it.kind in {nkStmtList, nkStmtListExpr} and it.len > 0:
|
||||||
|
|
|
||||||
|
|
@ -76,13 +76,13 @@ type
|
||||||
c*: PContext
|
c*: PContext
|
||||||
typeMap*: ptr LayeredIdTable # map PType to PType
|
typeMap*: ptr LayeredIdTable # map PType to PType
|
||||||
symMap*: TIdTable # map PSym to PSym
|
symMap*: TIdTable # map PSym to PSym
|
||||||
localCache*: TIdTable # local cache for remembering alraedy replaced
|
localCache*: TIdTable # local cache for remembering already replaced
|
||||||
# types during instantiation of meta types
|
# types during instantiation of meta types
|
||||||
# (they are not stored in the global cache)
|
# (they are not stored in the global cache)
|
||||||
info*: TLineInfo
|
info*: TLineInfo
|
||||||
allowMetaTypes*: bool # allow types such as seq[Number]
|
allowMetaTypes*: bool # allow types such as seq[Number]
|
||||||
# i.e. the result contains unresolved generics
|
# i.e. the result contains unresolved generics
|
||||||
skipTypedesc*: bool # wether we should skip typeDescs
|
skipTypedesc*: bool # whether we should skip typeDescs
|
||||||
isReturnType*: bool
|
isReturnType*: bool
|
||||||
owner*: PSym # where this instantiation comes from
|
owner*: PSym # where this instantiation comes from
|
||||||
recursionLimit: int
|
recursionLimit: int
|
||||||
|
|
@ -249,7 +249,7 @@ proc replaceTypeVarsS(cl: var TReplTypeVars, s: PSym): PSym =
|
||||||
return s
|
return s
|
||||||
|
|
||||||
# XXX: Bound symbols in default parameter expressions may reach here.
|
# XXX: Bound symbols in default parameter expressions may reach here.
|
||||||
# We cannot process them, becase `sym.n` may point to a proc body with
|
# We cannot process them, because `sym.n` may point to a proc body with
|
||||||
# cyclic references that will lead to an infinite recursion.
|
# cyclic references that will lead to an infinite recursion.
|
||||||
# Perhaps we should not use a black-list here, but a whitelist instead
|
# Perhaps we should not use a black-list here, but a whitelist instead
|
||||||
# (e.g. skGenericParam and skType).
|
# (e.g. skGenericParam and skType).
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ proc align(address, alignment: int): int =
|
||||||
result = (address + (alignment - 1)) and not (alignment - 1)
|
result = (address + (alignment - 1)) and not (alignment - 1)
|
||||||
|
|
||||||
const
|
const
|
||||||
## a size is concidered "unknown" when it is an imported type from C
|
## a size is considered "unknown" when it is an imported type from C
|
||||||
## or C++.
|
## or C++.
|
||||||
szUnknownSize* = -3
|
szUnknownSize* = -3
|
||||||
szIllegalRecursion* = -2
|
szIllegalRecursion* = -2
|
||||||
|
|
|
||||||
|
|
@ -877,7 +877,7 @@ proc hoistParamsUsedInDefault(c: PTransf, call, letSection, defExpr: PNode): PNo
|
||||||
# The recursion may confuse you. It performs two duties:
|
# The recursion may confuse you. It performs two duties:
|
||||||
#
|
#
|
||||||
# 1) extracting all referenced params from default expressions
|
# 1) extracting all referenced params from default expressions
|
||||||
# into a let section preceeding the call
|
# into a let section preceding the call
|
||||||
#
|
#
|
||||||
# 2) replacing the "references" within the default expression
|
# 2) replacing the "references" within the default expression
|
||||||
# with these extracted skLet symbols.
|
# with these extracted skLet symbols.
|
||||||
|
|
@ -1140,7 +1140,7 @@ proc transformBody*(g: ModuleGraph, prc: PSym, cache = true;
|
||||||
|
|
||||||
let cache = cache or prc.typ.callConv == ccInline
|
let cache = cache or prc.typ.callConv == ccInline
|
||||||
if cache:
|
if cache:
|
||||||
# genProc for inline procs will be called multiple times from diffrent modules,
|
# genProc for inline procs will be called multiple times from different modules,
|
||||||
# it is important to transform exactly once to get sym ids and locations right
|
# it is important to transform exactly once to get sym ids and locations right
|
||||||
prc.transformedBody = result
|
prc.transformedBody = result
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -303,7 +303,7 @@ proc analyseObjectWithTypeFieldAux(t: PType,
|
||||||
|
|
||||||
proc analyseObjectWithTypeField*(t: PType): TTypeFieldResult =
|
proc analyseObjectWithTypeField*(t: PType): TTypeFieldResult =
|
||||||
# this does a complex analysis whether a call to ``objectInit`` needs to be
|
# this does a complex analysis whether a call to ``objectInit`` needs to be
|
||||||
# made or intializing of the type field suffices or if there is no type field
|
# made or initializing of the type field suffices or if there is no type field
|
||||||
# at all in this type.
|
# at all in this type.
|
||||||
var marker = initIntSet()
|
var marker = initIntSet()
|
||||||
result = analyseObjectWithTypeFieldAux(t, marker)
|
result = analyseObjectWithTypeFieldAux(t, marker)
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ proc createStrKeepNode(x: var TFullReg; keepNode=true) =
|
||||||
x.node = newNode(nkStrLit)
|
x.node = newNode(nkStrLit)
|
||||||
# It not only hackey, it is also wrong for tgentemplate. The primary
|
# It not only hackey, it is also wrong for tgentemplate. The primary
|
||||||
# cause of bugs like these is that the VM does not properly distinguish
|
# cause of bugs like these is that the VM does not properly distinguish
|
||||||
# between variable defintions (var foo = e) and variable updates (foo = e).
|
# between variable definitions (var foo = e) and variable updates (foo = e).
|
||||||
|
|
||||||
include vmhooks
|
include vmhooks
|
||||||
|
|
||||||
|
|
@ -357,7 +357,7 @@ proc cleanUpOnReturn(c: PCtx; f: PStackFrame): int =
|
||||||
result = -1
|
result = -1
|
||||||
|
|
||||||
# Traverse the stack starting from the end in order to execute the blocks in
|
# Traverse the stack starting from the end in order to execute the blocks in
|
||||||
# the inteded order
|
# the intended order
|
||||||
for i in 1 .. f.safePoints.len:
|
for i in 1 .. f.safePoints.len:
|
||||||
var pc = f.safePoints[^i]
|
var pc = f.safePoints[^i]
|
||||||
# Skip the `except` blocks
|
# Skip the `except` blocks
|
||||||
|
|
@ -1189,7 +1189,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
tos.pushSafePoint(pc + rbx)
|
tos.pushSafePoint(pc + rbx)
|
||||||
assert c.code[pc+rbx].opcode in {opcExcept, opcFinally}
|
assert c.code[pc+rbx].opcode in {opcExcept, opcFinally}
|
||||||
of opcExcept:
|
of opcExcept:
|
||||||
# This opcode is never executed, it only holds informations for the
|
# This opcode is never executed, it only holds information for the
|
||||||
# exception handling routines.
|
# exception handling routines.
|
||||||
doAssert(false)
|
doAssert(false)
|
||||||
of opcFinally:
|
of opcFinally:
|
||||||
|
|
@ -1275,7 +1275,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
regs[ra].node = getNullValue(typ, c.debug[pc], c.config)
|
regs[ra].node = getNullValue(typ, c.debug[pc], c.config)
|
||||||
# opcLdNull really is the gist of the VM's problems: should it load
|
# opcLdNull really is the gist of the VM's problems: should it load
|
||||||
# a fresh null to regs[ra].node or to regs[ra].node[]? This really
|
# a fresh null to regs[ra].node or to regs[ra].node[]? This really
|
||||||
# depends on whether regs[ra] represents the variable itself or wether
|
# depends on whether regs[ra] represents the variable itself or whether
|
||||||
# it holds the indirection! Due to the way registers are re-used we cannot
|
# it holds the indirection! Due to the way registers are re-used we cannot
|
||||||
# say for sure here! --> The codegen has to deal with it
|
# say for sure here! --> The codegen has to deal with it
|
||||||
# via 'genAsgnPatch'.
|
# via 'genAsgnPatch'.
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ proc gABC(ctx: PCtx; n: PNode; opc: TOpcode; a, b, c: TRegister = 0) =
|
||||||
ctx.debug.add(n.info)
|
ctx.debug.add(n.info)
|
||||||
|
|
||||||
proc gABI(c: PCtx; n: PNode; opc: TOpcode; a, b: TRegister; imm: BiggestInt) =
|
proc gABI(c: PCtx; n: PNode; opc: TOpcode; a, b: TRegister; imm: BiggestInt) =
|
||||||
# Takes the `b` register and the immediate `imm`, appies the operation `opc`,
|
# Takes the `b` register and the immediate `imm`, applies the operation `opc`,
|
||||||
# and stores the output value into `a`.
|
# and stores the output value into `a`.
|
||||||
# `imm` is signed and must be within [-128, 127]
|
# `imm` is signed and must be within [-128, 127]
|
||||||
if imm >= -128 and imm <= 127:
|
if imm >= -128 and imm <= 127:
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
#
|
#
|
||||||
|
|
||||||
# Unforunately this cannot be a module yet:
|
# Unfortunately this cannot be a module yet:
|
||||||
#import vmdeps, vm
|
#import vmdeps, vm
|
||||||
from math import sqrt, ln, log10, log2, exp, round, arccos, arcsin,
|
from math import sqrt, ln, log10, log2, exp, round, arccos, arcsin,
|
||||||
arctan, arctan2, cos, cosh, hypot, sinh, sin, tan, tanh, pow, trunc,
|
arctan, arctan2, cos, cosh, hypot, sinh, sin, tan, tanh, pow, trunc,
|
||||||
|
|
|
||||||
|
|
@ -364,7 +364,7 @@ when defined(nimHasSignatureHashInMacro):
|
||||||
|
|
||||||
proc symBodyHash*(s: NimNode): string {.noSideEffect.} =
|
proc symBodyHash*(s: NimNode): string {.noSideEffect.} =
|
||||||
## Returns a stable digest for symbols derived not only from type signature
|
## Returns a stable digest for symbols derived not only from type signature
|
||||||
## and owning module, but also implementation body. All procs/varibles used in
|
## and owning module, but also implementation body. All procs/variables used in
|
||||||
## the implementation of this symbol are hashed recursively as well, including
|
## the implementation of this symbol are hashed recursively as well, including
|
||||||
## magics from system module.
|
## magics from system module.
|
||||||
discard
|
discard
|
||||||
|
|
|
||||||
|
|
@ -391,7 +391,7 @@ proc setVal[K, V](table: var PConcTable[K, V], key: int, val: int,
|
||||||
# Done spinning for a new slot
|
# Done spinning for a new slot
|
||||||
var oldVal = atomic_load_n(table[idx].value.addr, ATOMIC_RELAXED)
|
var oldVal = atomic_load_n(table[idx].value.addr, ATOMIC_RELAXED)
|
||||||
if val == oldVal:
|
if val == oldVal:
|
||||||
#echo("this val is alredy in the slot")
|
#echo("this val is already in the slot")
|
||||||
return oldVal
|
return oldVal
|
||||||
nextTable = atomic_load_n(table.next.addr, ATOMIC_SEQ_CST)
|
nextTable = atomic_load_n(table.next.addr, ATOMIC_SEQ_CST)
|
||||||
if nextTable == nil and
|
if nextTable == nil and
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ type
|
||||||
## the option was given a value
|
## the option was given a value
|
||||||
|
|
||||||
proc initOptParser*(cmdline: seq[string]): OptParser {.rtl.} =
|
proc initOptParser*(cmdline: seq[string]): OptParser {.rtl.} =
|
||||||
## Initalizes option parses with cmdline. cmdline should not contain
|
## Initializes option parses with cmdline. cmdline should not contain
|
||||||
## argument 0 - program name.
|
## argument 0 - program name.
|
||||||
## If cmdline.len == 0 default to current command line arguments.
|
## If cmdline.len == 0 default to current command line arguments.
|
||||||
result.remainingShortOptions = ""
|
result.remainingShortOptions = ""
|
||||||
|
|
|
||||||
|
|
@ -275,9 +275,9 @@ proc createDiffs(dataA, dataB: DiffData): seq[Item] =
|
||||||
proc diffInt*(arrayA, arrayB: openArray[int]): seq[Item] =
|
proc diffInt*(arrayA, arrayB: openArray[int]): seq[Item] =
|
||||||
## Find the difference in 2 arrays of integers.
|
## Find the difference in 2 arrays of integers.
|
||||||
##
|
##
|
||||||
## ``arrayA`` A-version of the numbers (usualy the old one)
|
## ``arrayA`` A-version of the numbers (usually the old one)
|
||||||
##
|
##
|
||||||
## ``arrayB`` B-version of the numbers (usualy the new one)
|
## ``arrayB`` B-version of the numbers (usually the new one)
|
||||||
##
|
##
|
||||||
## Returns a sequence of Items that describe the differences.
|
## Returns a sequence of Items that describe the differences.
|
||||||
|
|
||||||
|
|
@ -301,7 +301,7 @@ proc diffText*(textA, textB: string): seq[Item] =
|
||||||
##
|
##
|
||||||
## The algorithm itself is comparing 2 arrays of numbers so when comparing 2 text documents
|
## The algorithm itself is comparing 2 arrays of numbers so when comparing 2 text documents
|
||||||
## each line is converted into a (hash) number. This hash-value is computed by storing all
|
## each line is converted into a (hash) number. This hash-value is computed by storing all
|
||||||
## textlines into a common hashtable so i can find dublicates in there, and generating a
|
## textlines into a common hashtable so i can find duplicates in there, and generating a
|
||||||
## new number each time a new textline is inserted.
|
## new number each time a new textline is inserted.
|
||||||
##
|
##
|
||||||
## ``textA`` A-version of the text (usually the old one)
|
## ``textA`` A-version of the text (usually the old one)
|
||||||
|
|
|
||||||
|
|
@ -303,7 +303,7 @@ iterator instantRows*(db: var DbConn, query: SqlQuery,
|
||||||
args: varargs[string, `$`]): InstantRow
|
args: varargs[string, `$`]): InstantRow
|
||||||
{.tags: [ReadDbEffect, WriteDbEffect].} =
|
{.tags: [ReadDbEffect, WriteDbEffect].} =
|
||||||
## Same as fastRows but returns a handle that can be used to get column text
|
## Same as fastRows but returns a handle that can be used to get column text
|
||||||
## on demand using []. Returned handle is valid only within the interator body.
|
## on demand using []. Returned handle is valid only within the iterator body.
|
||||||
var
|
var
|
||||||
rowRes: Row = @[]
|
rowRes: Row = @[]
|
||||||
sz: TSqlInteger = 0
|
sz: TSqlInteger = 0
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,7 @@ proc setRow(res: PPGresult, r: var Row, line, cols: int32) =
|
||||||
iterator fastRows*(db: DbConn, query: SqlQuery,
|
iterator fastRows*(db: DbConn, query: SqlQuery,
|
||||||
args: varargs[string, `$`]): Row {.tags: [ReadDbEffect].} =
|
args: varargs[string, `$`]): Row {.tags: [ReadDbEffect].} =
|
||||||
## executes the query and iterates over the result dataset. This is very
|
## executes the query and iterates over the result dataset. This is very
|
||||||
## fast, but potenially dangerous: If the for-loop-body executes another
|
## fast, but potentially dangerous: If the for-loop-body executes another
|
||||||
## query, the results can be undefined. For Postgres it is safe though.
|
## query, the results can be undefined. For Postgres it is safe though.
|
||||||
var res = setupQuery(db, query, args)
|
var res = setupQuery(db, query, args)
|
||||||
var L = pqnfields(res)
|
var L = pqnfields(res)
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ type
|
||||||
## into PCRE flags. These include ``NEVER_UTF``, ``ANCHORED``,
|
## into PCRE flags. These include ``NEVER_UTF``, ``ANCHORED``,
|
||||||
## ``DOLLAR_ENDONLY``, ``FIRSTLINE``, ``NO_AUTO_CAPTURE``,
|
## ``DOLLAR_ENDONLY``, ``FIRSTLINE``, ``NO_AUTO_CAPTURE``,
|
||||||
## ``JAVASCRIPT_COMPAT``, ``U``, ``NO_STUDY``. In other PCRE wrappers, you
|
## ``JAVASCRIPT_COMPAT``, ``U``, ``NO_STUDY``. In other PCRE wrappers, you
|
||||||
## will need to pass these as seperate flags to PCRE.
|
## will need to pass these as separate flags to PCRE.
|
||||||
pattern*: string ## not nil
|
pattern*: string ## not nil
|
||||||
pcreObj: ptr pcre.Pcre ## not nil
|
pcreObj: ptr pcre.Pcre ## not nil
|
||||||
pcreExtra: ptr pcre.ExtraData ## nil
|
pcreExtra: ptr pcre.ExtraData ## nil
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ proc initRstGenerator*(g: var RstGenerator, target: OutputTarget,
|
||||||
## index hyperlinks to the file, but you can pass an empty string here if you
|
## index hyperlinks to the file, but you can pass an empty string here if you
|
||||||
## are parsing a stream in memory. If `filename` ends with the ``.nim``
|
## are parsing a stream in memory. If `filename` ends with the ``.nim``
|
||||||
## extension, the title for the document will be set by default to ``Module
|
## extension, the title for the document will be set by default to ``Module
|
||||||
## filename``. This default title can be overriden by the embedded rst, but
|
## filename``. This default title can be overridden by the embedded rst, but
|
||||||
## it helps to prettify the generated index if no title is found.
|
## it helps to prettify the generated index if no title is found.
|
||||||
##
|
##
|
||||||
## The ``RstParseOptions``, ``FindFileHandler`` and ``MsgHandler`` types
|
## The ``RstParseOptions``, ``FindFileHandler`` and ``MsgHandler`` types
|
||||||
|
|
@ -350,7 +350,7 @@ proc hash(n: PRstNode): int =
|
||||||
proc renderIndexTerm*(d: PDoc, n: PRstNode, result: var string) =
|
proc renderIndexTerm*(d: PDoc, n: PRstNode, result: var string) =
|
||||||
## Renders the string decorated within \`foobar\`\:idx\: markers.
|
## Renders the string decorated within \`foobar\`\:idx\: markers.
|
||||||
##
|
##
|
||||||
## Additionally adds the encosed text to the index as a term. Since we are
|
## Additionally adds the enclosed text to the index as a term. Since we are
|
||||||
## interested in different instances of the same term to have different
|
## interested in different instances of the same term to have different
|
||||||
## entries, a table is used to keep track of the amount of times a term has
|
## entries, a table is used to keep track of the amount of times a term has
|
||||||
## previously appeared to give a different identifier value for each.
|
## previously appeared to give a different identifier value for each.
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
# Dead code elimination ensures that we don't accidentally generate #includes
|
# Dead code elimination ensures that we don't accidentally generate #includes
|
||||||
# for files that might not exist on a specific platform! The user will get an
|
# for files that might not exist on a specific platform! The user will get an
|
||||||
# error only if they actualy try to use the missing declaration
|
# error only if they actually try to use the missing declaration
|
||||||
{.deadCodeElim: on.} # dce option deprecated
|
{.deadCodeElim: on.} # dce option deprecated
|
||||||
|
|
||||||
when defined(nimHasStyleChecks):
|
when defined(nimHasStyleChecks):
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ proc sendSignal*(pid: Pid, signal: int) =
|
||||||
proc mkstemp*(prefix: string): (string, File) =
|
proc mkstemp*(prefix: string): (string, File) =
|
||||||
## Creates a unique temporary file from a prefix string. Adds a six chars suffix.
|
## Creates a unique temporary file from a prefix string. Adds a six chars suffix.
|
||||||
## The file is created with perms 0600.
|
## The file is created with perms 0600.
|
||||||
## Returs the filename and a file opened in r/w mode.
|
## Returns the filename and a file opened in r/w mode.
|
||||||
var tmpl = cstring(prefix & "XXXXXX")
|
var tmpl = cstring(prefix & "XXXXXX")
|
||||||
let fd = mkstemp(tmpl)
|
let fd = mkstemp(tmpl)
|
||||||
var f: File
|
var f: File
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,7 @@ proc processTimers(
|
||||||
dec count
|
dec count
|
||||||
didSomeWork = true
|
didSomeWork = true
|
||||||
|
|
||||||
# Return the number of miliseconds in which the next timer will expire.
|
# Return the number of milliseconds in which the next timer will expire.
|
||||||
if p.timers.len == 0: return
|
if p.timers.len == 0: return
|
||||||
|
|
||||||
let millisecs = (p.timers[0].finishAt - getMonoTime()).inMilliseconds
|
let millisecs = (p.timers[0].finishAt - getMonoTime()).inMilliseconds
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ proc write*[T](future: FutureStream[T], value: T): Future[void] =
|
||||||
result.fail(newException(ValueError, msg))
|
result.fail(newException(ValueError, msg))
|
||||||
return
|
return
|
||||||
# TODO: Implement limiting of the streams storage to prevent it growing
|
# TODO: Implement limiting of the streams storage to prevent it growing
|
||||||
# infinitely when no reads are occuring.
|
# infinitely when no reads are occurring.
|
||||||
future.queue.addLast(value)
|
future.queue.addLast(value)
|
||||||
if not future.cb.isNil: future.cb()
|
if not future.cb.isNil: future.cb()
|
||||||
result.complete()
|
result.complete()
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
## to force predictable behaviour for all input, causing a small performance hit.
|
## to force predictable behaviour for all input, causing a small performance hit.
|
||||||
##
|
##
|
||||||
## At this time only `fastLog2`, `firstSetBit, `countLeadingZeroBits`, `countTrailingZeroBits`
|
## At this time only `fastLog2`, `firstSetBit, `countLeadingZeroBits`, `countTrailingZeroBits`
|
||||||
## may return undefined and/or platform dependant value if given invalid input.
|
## may return undefined and/or platform dependent value if given invalid input.
|
||||||
|
|
||||||
proc bitnot*[T: SomeInteger](x: T): T {.magic: "BitnotI", noSideEffect.}
|
proc bitnot*[T: SomeInteger](x: T): T {.magic: "BitnotI", noSideEffect.}
|
||||||
## Computes the `bitwise complement` of the integer `x`.
|
## Computes the `bitwise complement` of the integer `x`.
|
||||||
|
|
|
||||||
|
|
@ -848,7 +848,7 @@ template mapIt*(s: typed, op: untyped): untyped =
|
||||||
result
|
result
|
||||||
|
|
||||||
template mapIt*(s, typ, op: untyped): untyped {.error:
|
template mapIt*(s, typ, op: untyped): untyped {.error:
|
||||||
"Deprecated since v0.12; Use 'mapIt(seq1, op)' - without specifying the type of the returned seqence".} =
|
"Deprecated since v0.12; Use 'mapIt(seq1, op)' - without specifying the type of the returned sequence".} =
|
||||||
var result: seq[typ] = @[]
|
var result: seq[typ] = @[]
|
||||||
for it {.inject.} in items(s):
|
for it {.inject.} in items(s):
|
||||||
result.add(op)
|
result.add(op)
|
||||||
|
|
@ -883,7 +883,7 @@ template newSeqWith*(len: int, init: untyped): untyped =
|
||||||
## or to populate fields of the created sequence.
|
## or to populate fields of the created sequence.
|
||||||
##
|
##
|
||||||
runnableExamples:
|
runnableExamples:
|
||||||
## Creates a seqence containing 5 bool sequences, each of length of 3.
|
## Creates a sequence containing 5 bool sequences, each of length of 3.
|
||||||
var seq2D = newSeqWith(5, newSeq[bool](3))
|
var seq2D = newSeqWith(5, newSeq[bool](3))
|
||||||
assert seq2D.len == 5
|
assert seq2D.len == 5
|
||||||
assert seq2D[0].len == 3
|
assert seq2D[0].len == 3
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ when defined(cpp) or defined(nimdoc):
|
||||||
## Behaves like Acquire when applied to load, like Release when
|
## Behaves like Acquire when applied to load, like Release when
|
||||||
## applied to a store and like AcquireRelease when applied to a
|
## applied to a store and like AcquireRelease when applied to a
|
||||||
## read-modify-write operation.
|
## read-modify-write operation.
|
||||||
## Also garantees that all threads observe the same total ordering
|
## Also guarantees that all threads observe the same total ordering
|
||||||
## with other moSequentiallyConsistent operations.
|
## with other moSequentiallyConsistent operations.
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ when defined(haiku):
|
||||||
header: "<OS.h>".}
|
header: "<OS.h>".}
|
||||||
|
|
||||||
proc countProcessors*(): int {.rtl, extern: "ncpi$1".} =
|
proc countProcessors*(): int {.rtl, extern: "ncpi$1".} =
|
||||||
## returns the numer of the processors/cores the machine has.
|
## returns the number of the processors/cores the machine has.
|
||||||
## Returns 0 if it cannot be detected.
|
## Returns 0 if it cannot be detected.
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
type
|
type
|
||||||
|
|
|
||||||
|
|
@ -2025,7 +2025,7 @@ proc parseHtml*(s: Stream, filename: string,
|
||||||
#if x.kind != xmlEof:
|
#if x.kind != xmlEof:
|
||||||
# adderr(errorMsg(x, "EOF expected"))
|
# adderr(errorMsg(x, "EOF expected"))
|
||||||
while x.kind != xmlEof:
|
while x.kind != xmlEof:
|
||||||
var oldPos = x.bufpos # little hack to see if we made any progess
|
var oldPos = x.bufpos # little hack to see if we made any progress
|
||||||
result.addNode(parse(x, errors))
|
result.addNode(parse(x, errors))
|
||||||
if x.bufpos == oldPos:
|
if x.bufpos == oldPos:
|
||||||
# force progress!
|
# force progress!
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
## ``JNull``. You check the kind of this object variant by using the ``kind``
|
## ``JNull``. You check the kind of this object variant by using the ``kind``
|
||||||
## accessor.
|
## accessor.
|
||||||
##
|
##
|
||||||
## For a ``JsonNode`` who's kind is ``JObject``, you can acess its fields using
|
## For a ``JsonNode`` who's kind is ``JObject``, you can access its fields using
|
||||||
## the ``[]`` operator. The following example shows how to do this:
|
## the ``[]`` operator. The following example shows how to do this:
|
||||||
##
|
##
|
||||||
## .. code-block:: Nim
|
## .. code-block:: Nim
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
## which work for mixed float/int operands.
|
## which work for mixed float/int operands.
|
||||||
## All operations convert the integer operand into the
|
## All operations convert the integer operand into the
|
||||||
## type of the float operand. For numerical expressions, the return
|
## type of the float operand. For numerical expressions, the return
|
||||||
## type is always the type of the float involved in the expresssion,
|
## type is always the type of the float involved in the expression,
|
||||||
## i.e., there is no auto conversion from float32 to float64.
|
## i.e., there is no auto conversion from float32 to float64.
|
||||||
##
|
##
|
||||||
## Note: In general, auto-converting from int to float loses
|
## Note: In general, auto-converting from int to float loses
|
||||||
|
|
|
||||||
|
|
@ -303,7 +303,7 @@ when defined(posix) or defined(nimdoc):
|
||||||
## resize and re-map the file underlying an ``allowRemap MemFile``.
|
## resize and re-map the file underlying an ``allowRemap MemFile``.
|
||||||
## **Note**: this assumes the entire file is mapped read-write at offset zero.
|
## **Note**: this assumes the entire file is mapped read-write at offset zero.
|
||||||
## Also, the value of ``.mem`` will probably change.
|
## Also, the value of ``.mem`` will probably change.
|
||||||
## **Note**: This is not (yet) avaiable on Windows.
|
## **Note**: This is not (yet) available on Windows.
|
||||||
when defined(posix):
|
when defined(posix):
|
||||||
if f.handle == -1:
|
if f.handle == -1:
|
||||||
raise newException(IOError,
|
raise newException(IOError,
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,7 @@ proc newSocket*(domain: Domain = AF_INET, sockType: SockType = SOCK_STREAM,
|
||||||
result = newSocket(fd, domain, sockType, protocol, buffered)
|
result = newSocket(fd, domain, sockType, protocol, buffered)
|
||||||
|
|
||||||
proc parseIPv4Address(addressStr: string): IpAddress =
|
proc parseIPv4Address(addressStr: string): IpAddress =
|
||||||
## Parses IPv4 adresses
|
## Parses IPv4 addresses
|
||||||
## Raises ValueError on errors
|
## Raises ValueError on errors
|
||||||
var
|
var
|
||||||
byteCount = 0
|
byteCount = 0
|
||||||
|
|
@ -264,7 +264,7 @@ proc parseIPv4Address(addressStr: string): IpAddress =
|
||||||
result.address_v4[byteCount] = cast[uint8](currentByte)
|
result.address_v4[byteCount] = cast[uint8](currentByte)
|
||||||
|
|
||||||
proc parseIPv6Address(addressStr: string): IpAddress =
|
proc parseIPv6Address(addressStr: string): IpAddress =
|
||||||
## Parses IPv6 adresses
|
## Parses IPv6 addresses
|
||||||
## Raises ValueError on errors
|
## Raises ValueError on errors
|
||||||
result = IpAddress(family: IpAddressFamily.IPv6)
|
result = IpAddress(family: IpAddressFamily.IPv6)
|
||||||
if addressStr.len < 2:
|
if addressStr.len < 2:
|
||||||
|
|
@ -1657,7 +1657,7 @@ proc connect*(socket: Socket, address: string, port = Port(0),
|
||||||
timeout: int) {.tags: [ReadIOEffect, WriteIOEffect].} =
|
timeout: int) {.tags: [ReadIOEffect, WriteIOEffect].} =
|
||||||
## Connects to server as specified by ``address`` on port specified by ``port``.
|
## Connects to server as specified by ``address`` on port specified by ``port``.
|
||||||
##
|
##
|
||||||
## The ``timeout`` paremeter specifies the time in milliseconds to allow for
|
## The ``timeout`` parameter specifies the time in milliseconds to allow for
|
||||||
## the connection to the server to be made.
|
## the connection to the server to be made.
|
||||||
socket.fd.setBlocking(false)
|
socket.fd.setBlocking(false)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -382,7 +382,7 @@ iterator parentDirs*(path: string, fromRoot=false, inclusive=true): string =
|
||||||
## Walks over all parent directories of a given `path`.
|
## Walks over all parent directories of a given `path`.
|
||||||
##
|
##
|
||||||
## If `fromRoot` is true (default: false), the traversal will start from
|
## If `fromRoot` is true (default: false), the traversal will start from
|
||||||
## the file system root diretory.
|
## the file system root directory.
|
||||||
## If `inclusive` is true (default), the original argument will be included
|
## If `inclusive` is true (default), the original argument will be included
|
||||||
## in the traversal.
|
## in the traversal.
|
||||||
##
|
##
|
||||||
|
|
@ -781,7 +781,7 @@ proc getTempDir*(): string {.rtl, extern: "nos$1",
|
||||||
## **Please do not use this**: On Android, it currently
|
## **Please do not use this**: On Android, it currently
|
||||||
## returns ``getHomeDir()``, and on other Unix based systems it can cause
|
## returns ``getHomeDir()``, and on other Unix based systems it can cause
|
||||||
## security problems too. That said, you can override this implementation
|
## security problems too. That said, you can override this implementation
|
||||||
## by adding ``-d:tempDir=mytempname`` to your compiler invokation.
|
## by adding ``-d:tempDir=mytempname`` to your compiler invocation.
|
||||||
##
|
##
|
||||||
## See also:
|
## See also:
|
||||||
## * `getHomeDir proc <#getHomeDir>`_
|
## * `getHomeDir proc <#getHomeDir>`_
|
||||||
|
|
@ -1868,7 +1868,7 @@ type
|
||||||
proc getCurrentCompilerExe*(): string {.compileTime.} = discard
|
proc getCurrentCompilerExe*(): string {.compileTime.} = discard
|
||||||
## This is `getAppFilename() <#getAppFilename>`_ at compile time.
|
## This is `getAppFilename() <#getAppFilename>`_ at compile time.
|
||||||
##
|
##
|
||||||
## Can be used to retrive the currently executing
|
## Can be used to retrieve the currently executing
|
||||||
## Nim compiler from a Nim or nimscript program, or the nimble binary
|
## Nim compiler from a Nim or nimscript program, or the nimble binary
|
||||||
## inside a nimble program (likewise with other binaries built from
|
## inside a nimble program (likewise with other binaries built from
|
||||||
## compiler API).
|
## compiler API).
|
||||||
|
|
@ -2475,7 +2475,7 @@ when defined(nimdoc):
|
||||||
##
|
##
|
||||||
## Unlike `argc`:idx: in C, if your binary was called without parameters this
|
## Unlike `argc`:idx: in C, if your binary was called without parameters this
|
||||||
## will return zero.
|
## will return zero.
|
||||||
## You can query each individual paramater with `paramStr proc <#paramStr,int>`_
|
## You can query each individual parameter with `paramStr proc <#paramStr,int>`_
|
||||||
## or retrieve all of them in one go with `commandLineParams proc
|
## or retrieve all of them in one go with `commandLineParams proc
|
||||||
## <#commandLineParams>`_.
|
## <#commandLineParams>`_.
|
||||||
##
|
##
|
||||||
|
|
|
||||||
|
|
@ -318,7 +318,7 @@ proc readHeaderRow*(my: var CsvParser) =
|
||||||
my.headers = my.row
|
my.headers = my.row
|
||||||
|
|
||||||
proc rowEntry*(my: var CsvParser, entry: string): var string =
|
proc rowEntry*(my: var CsvParser, entry: string): var string =
|
||||||
## Acceses a specified `entry` from the current row.
|
## Accesses a specified `entry` from the current row.
|
||||||
##
|
##
|
||||||
## Assumes that `readHeaderRow <#readHeaderRow,CsvParser>`_ has already been
|
## Assumes that `readHeaderRow <#readHeaderRow,CsvParser>`_ has already been
|
||||||
## called.
|
## called.
|
||||||
|
|
|
||||||
|
|
@ -711,7 +711,7 @@ proc identOrLiteral(p: var SqlParser): SqlNode =
|
||||||
getTok(p)
|
getTok(p)
|
||||||
else:
|
else:
|
||||||
sqlError(p, "expression expected")
|
sqlError(p, "expression expected")
|
||||||
getTok(p) # we must consume a token here to prevend endless loops!
|
getTok(p) # we must consume a token here to prevent endless loops!
|
||||||
|
|
||||||
proc primary(p: var SqlParser): SqlNode =
|
proc primary(p: var SqlParser): SqlNode =
|
||||||
if (p.tok.kind == tkOperator and (p.tok.literal == "+" or p.tok.literal == "-")) or isKeyw(p, "not"):
|
if (p.tok.kind == tkOperator and (p.tok.literal == "+" or p.tok.literal == "-")) or isKeyw(p, "not"):
|
||||||
|
|
|
||||||
|
|
@ -634,7 +634,7 @@ iterator interpolatedFragments*(s: string): tuple[kind: InterpolatedKind,
|
||||||
kind = ikDollar
|
kind = ikDollar
|
||||||
else:
|
else:
|
||||||
raise newException(ValueError,
|
raise newException(ValueError,
|
||||||
"Unable to parse a varible name at " & substr(s, i, s.high))
|
"Unable to parse a variable name at " & substr(s, i, s.high))
|
||||||
else:
|
else:
|
||||||
while j < s.len and s[j] != '$': inc j
|
while j < s.len and s[j] != '$': inc j
|
||||||
kind = ikStr
|
kind = ikStr
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ import
|
||||||
# xmlElementCloseEnd, ## ``/>``
|
# xmlElementCloseEnd, ## ``/>``
|
||||||
|
|
||||||
type
|
type
|
||||||
XmlEventKind* = enum ## enumation of all events that may occur when parsing
|
XmlEventKind* = enum ## enumeration of all events that may occur when parsing
|
||||||
xmlError, ## an error occurred during parsing
|
xmlError, ## an error occurred during parsing
|
||||||
xmlEof, ## end of file reached
|
xmlEof, ## end of file reached
|
||||||
xmlCharData, ## character data
|
xmlCharData, ## character data
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ when defined(nimdoc):
|
||||||
proc setData*[T](s: Selector[T], fd: SocketHandle|int, data: var T): bool =
|
proc setData*[T](s: Selector[T], fd: SocketHandle|int, data: var T): bool =
|
||||||
## Associate application-defined ``data`` with descriptor ``fd``.
|
## Associate application-defined ``data`` with descriptor ``fd``.
|
||||||
##
|
##
|
||||||
## Returns ``true``, if data was succesfully updated, ``false`` otherwise.
|
## Returns ``true``, if data was successfully updated, ``false`` otherwise.
|
||||||
|
|
||||||
template isEmpty*[T](s: Selector[T]): bool = # TODO: Why is this a template?
|
template isEmpty*[T](s: Selector[T]): bool = # TODO: Why is this a template?
|
||||||
## Returns ``true``, if there are no registered events or descriptors
|
## Returns ``true``, if there are no registered events or descriptors
|
||||||
|
|
@ -316,7 +316,7 @@ else:
|
||||||
|
|
||||||
proc verifySelectParams(timeout: int) =
|
proc verifySelectParams(timeout: int) =
|
||||||
# Timeout of -1 means: wait forever
|
# Timeout of -1 means: wait forever
|
||||||
# Anything higher is the time to wait in miliseconds.
|
# Anything higher is the time to wait in milliseconds.
|
||||||
doAssert(timeout >= -1, "Cannot select with a negative value, got " & $timeout)
|
doAssert(timeout >= -1, "Cannot select with a negative value, got " & $timeout)
|
||||||
|
|
||||||
when defined(linux):
|
when defined(linux):
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ proc auth*(smtp: Smtp | AsyncSmtp, username, password: string) {.multisync.} =
|
||||||
await smtp.checkReply("334") # TODO: Same as above, only "Password:" (I think?)
|
await smtp.checkReply("334") # TODO: Same as above, only "Password:" (I think?)
|
||||||
|
|
||||||
await smtp.debugSend(encode(password) & "\c\L")
|
await smtp.debugSend(encode(password) & "\c\L")
|
||||||
await smtp.checkReply("235") # Check whether the authentification was successful.
|
await smtp.checkReply("235") # Check whether the authentication was successful.
|
||||||
|
|
||||||
proc sendMail*(smtp: Smtp | AsyncSmtp, fromAddr: string,
|
proc sendMail*(smtp: Smtp | AsyncSmtp, fromAddr: string,
|
||||||
toAddrs: seq[string], msg: string) {.multisync.} =
|
toAddrs: seq[string], msg: string) {.multisync.} =
|
||||||
|
|
|
||||||
|
|
@ -299,7 +299,7 @@ type
|
||||||
alternateForm*: bool ## Whether to prefix binary, octal and hex numbers
|
alternateForm*: bool ## Whether to prefix binary, octal and hex numbers
|
||||||
## with ``0b``, ``0o``, ``0x``.
|
## with ``0b``, ``0o``, ``0x``.
|
||||||
padWithZero*: bool ## Whether to pad with zeros rather than spaces.
|
padWithZero*: bool ## Whether to pad with zeros rather than spaces.
|
||||||
minimumWidth*, precision*: int ## Desired minium width and precision.
|
minimumWidth*, precision*: int ## Desired minimum width and precision.
|
||||||
typ*: char ## Type like 'f', 'g' or 'd'.
|
typ*: char ## Type like 'f', 'g' or 'd'.
|
||||||
endPosition*: int ## End position in the format specifier after
|
endPosition*: int ## End position in the format specifier after
|
||||||
## ``parseStandardFormatSpecifier`` returned.
|
## ``parseStandardFormatSpecifier`` returned.
|
||||||
|
|
@ -617,7 +617,7 @@ when isMainModule:
|
||||||
check &"{1f:.3f}", "1.000"
|
check &"{1f:.3f}", "1.000"
|
||||||
check &"Hello, {s}!", "Hello, string!"
|
check &"Hello, {s}!", "Hello, string!"
|
||||||
|
|
||||||
# Tests for identifers without parenthesis
|
# Tests for identifiers without parenthesis
|
||||||
check &"{s} works{s}", "string worksstring"
|
check &"{s} works{s}", "string worksstring"
|
||||||
check &"{s:>7}", " string"
|
check &"{s:>7}", " string"
|
||||||
doAssert(not compiles(&"{s_works}")) # parsed as identifier `s_works`
|
doAssert(not compiles(&"{s_works}")) # parsed as identifier `s_works`
|
||||||
|
|
|
||||||
|
|
@ -326,7 +326,7 @@ proc del*(t: StringTableRef, key: string) =
|
||||||
## Removes `key` from `t`.
|
## Removes `key` from `t`.
|
||||||
##
|
##
|
||||||
## See also:
|
## See also:
|
||||||
## * `clear proc <#clear,StringTableRef,StringTableMode>`_ for reseting a
|
## * `clear proc <#clear,StringTableRef,StringTableMode>`_ for resetting a
|
||||||
## table to be empty
|
## table to be empty
|
||||||
## * `[]= proc <#[]=,StringTableRef,string,string>`_ for inserting a new
|
## * `[]= proc <#[]=,StringTableRef,string,string>`_ for inserting a new
|
||||||
## (key, value) pair in the table
|
## (key, value) pair in the table
|
||||||
|
|
|
||||||
|
|
@ -2017,7 +2017,7 @@ proc countLines*(s: string): int {.noSideEffect,
|
||||||
## `character literal <manual.html#lexical-analysis-character-literals>`_
|
## `character literal <manual.html#lexical-analysis-character-literals>`_
|
||||||
## newline combination (CR, LF, CR-LF) is supported.
|
## newline combination (CR, LF, CR-LF) is supported.
|
||||||
##
|
##
|
||||||
## In this context, a line is any string seperated by a newline combination.
|
## In this context, a line is any string separated by a newline combination.
|
||||||
## A line can be an empty string.
|
## A line can be an empty string.
|
||||||
##
|
##
|
||||||
## See also:
|
## See also:
|
||||||
|
|
@ -2145,7 +2145,7 @@ proc multiReplace*(s: string, replacements: varargs[(string, string)]): string {
|
||||||
## pass through the input string.
|
## pass through the input string.
|
||||||
##
|
##
|
||||||
## `multiReplace` performs all replacements in a single pass, this means it
|
## `multiReplace` performs all replacements in a single pass, this means it
|
||||||
## can be used to swap the occurences of "a" and "b", for instance.
|
## can be used to swap the occurrences of "a" and "b", for instance.
|
||||||
##
|
##
|
||||||
## If the resulting string is not longer than the original input string,
|
## If the resulting string is not longer than the original input string,
|
||||||
## only a single memory allocation is required.
|
## only a single memory allocation is required.
|
||||||
|
|
@ -2280,14 +2280,14 @@ proc validIdentifier*(s: string): bool {.noSideEffect,
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
||||||
# floating point formating:
|
# floating point formatting:
|
||||||
when not defined(js):
|
when not defined(js):
|
||||||
proc c_sprintf(buf, frmt: cstring): cint {.header: "<stdio.h>",
|
proc c_sprintf(buf, frmt: cstring): cint {.header: "<stdio.h>",
|
||||||
importc: "sprintf", varargs, noSideEffect.}
|
importc: "sprintf", varargs, noSideEffect.}
|
||||||
|
|
||||||
type
|
type
|
||||||
FloatFormatMode* = enum
|
FloatFormatMode* = enum
|
||||||
## the different modes of floating point formating
|
## the different modes of floating point formatting
|
||||||
ffDefault, ## use the shorter floating point notation
|
ffDefault, ## use the shorter floating point notation
|
||||||
ffDecimal, ## use decimal floating point notation
|
ffDecimal, ## use decimal floating point notation
|
||||||
ffScientific ## use scientific notation (using ``e`` character)
|
ffScientific ## use scientific notation (using ``e`` character)
|
||||||
|
|
@ -2892,7 +2892,7 @@ proc editDistance*(a, b: string): int {.noSideEffect,
|
||||||
inc(len1)
|
inc(len1)
|
||||||
inc(len2)
|
inc(len2)
|
||||||
var half = len1 shr 1
|
var half = len1 shr 1
|
||||||
# initalize first row:
|
# initialize first row:
|
||||||
#var row = cast[ptr array[0..high(int) div 8, int]](alloc(len2*sizeof(int)))
|
#var row = cast[ptr array[0..high(int) div 8, int]](alloc(len2*sizeof(int)))
|
||||||
var row: seq[int]
|
var row: seq[int]
|
||||||
newSeq(row, len2)
|
newSeq(row, len2)
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@
|
||||||
The ``times`` module exports two similar types that are both used to
|
The ``times`` module exports two similar types that are both used to
|
||||||
represent some amount of time: `Duration <#Duration>`_ and
|
represent some amount of time: `Duration <#Duration>`_ and
|
||||||
`TimeInterval <#TimeInterval>`_.
|
`TimeInterval <#TimeInterval>`_.
|
||||||
This section explains how they differ and when one should be prefered over the
|
This section explains how they differ and when one should be preferred over the
|
||||||
other (short answer: use ``Duration`` unless support for months and years is
|
other (short answer: use ``Duration`` unless support for months and years is
|
||||||
needed).
|
needed).
|
||||||
|
|
||||||
|
|
@ -152,7 +152,7 @@
|
||||||
A ``TimeInterval`` represents an amount of time expressed in calendar
|
A ``TimeInterval`` represents an amount of time expressed in calendar
|
||||||
units, for example "1 year and 2 days". Since some units cannot be
|
units, for example "1 year and 2 days". Since some units cannot be
|
||||||
normalized (the length of a year is different for leap years for example),
|
normalized (the length of a year is different for leap years for example),
|
||||||
the ``TimeInterval`` type uses seperate fields for every unit. The
|
the ``TimeInterval`` type uses separate fields for every unit. The
|
||||||
``TimeInterval``'s returned from this module generally don't normalize
|
``TimeInterval``'s returned from this module generally don't normalize
|
||||||
**anything**, so even units that could be normalized (like seconds,
|
**anything**, so even units that could be normalized (like seconds,
|
||||||
milliseconds and so on) are left untouched.
|
milliseconds and so on) are left untouched.
|
||||||
|
|
@ -393,7 +393,7 @@ type
|
||||||
years*: int ## The number of years
|
years*: int ## The number of years
|
||||||
|
|
||||||
Timezone* = ref object ## \
|
Timezone* = ref object ## \
|
||||||
## Timezone interface for supporting `DateTime <#DateTime>`_\s of arbritary
|
## Timezone interface for supporting `DateTime <#DateTime>`_\s of arbitrary
|
||||||
## timezones. The ``times`` module only supplies implementations for the
|
## timezones. The ``times`` module only supplies implementations for the
|
||||||
## systems local time and UTC.
|
## systems local time and UTC.
|
||||||
zonedTimeFromTimeImpl: proc (x: Time): ZonedTime
|
zonedTimeFromTimeImpl: proc (x: Time): ZonedTime
|
||||||
|
|
@ -2526,7 +2526,7 @@ when not defined(JS):
|
||||||
## because sub-second resolution is likely to be supported (depending
|
## because sub-second resolution is likely to be supported (depending
|
||||||
## on the hardware/OS).
|
## on the hardware/OS).
|
||||||
##
|
##
|
||||||
## ``getTime`` should generally be prefered over this proc.
|
## ``getTime`` should generally be preferred over this proc.
|
||||||
when defined(macosx):
|
when defined(macosx):
|
||||||
var a: Timeval
|
var a: Timeval
|
||||||
gettimeofday(a)
|
gettimeofday(a)
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ type
|
||||||
## non-js target to true or false respectively.
|
## non-js target to true or false respectively.
|
||||||
## The deprecated environment variable
|
## The deprecated environment variable
|
||||||
## ``NIMTEST_NO_COLOR``, when set,
|
## ``NIMTEST_NO_COLOR``, when set,
|
||||||
## changes the defualt to true, if
|
## changes the default to true, if
|
||||||
## ``NIMTEST_COLOR`` is undefined.
|
## ``NIMTEST_COLOR`` is undefined.
|
||||||
outputLevel: OutputLevel
|
outputLevel: OutputLevel
|
||||||
## Set the verbosity of test results.
|
## Set the verbosity of test results.
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,7 @@ proc editDistanceAscii*(a, b: string): int {.noSideEffect.} =
|
||||||
inc(len1)
|
inc(len1)
|
||||||
inc(len2)
|
inc(len2)
|
||||||
var half = len1 shr 1
|
var half = len1 shr 1
|
||||||
# initalize first row:
|
# initialize first row:
|
||||||
#var row = cast[ptr array[0..high(int) div 8, int]](alloc(len2*sizeof(int)))
|
#var row = cast[ptr array[0..high(int) div 8, int]](alloc(len2*sizeof(int)))
|
||||||
var row: seq[int]
|
var row: seq[int]
|
||||||
newSeq(row, len2)
|
newSeq(row, len2)
|
||||||
|
|
|
||||||
|
|
@ -477,14 +477,14 @@ when defined(nimArrIdx):
|
||||||
x: S) {.noSideEffect, magic: "ArrPut".}
|
x: S) {.noSideEffect, magic: "ArrPut".}
|
||||||
|
|
||||||
proc `=destroy`*[T](x: var T) {.inline, magic: "Destroy".} =
|
proc `=destroy`*[T](x: var T) {.inline, magic: "Destroy".} =
|
||||||
## Generic `destructor`:idx: implementation that can be overriden.
|
## Generic `destructor`:idx: implementation that can be overridden.
|
||||||
discard
|
discard
|
||||||
proc `=sink`*[T](x: var T; y: T) {.inline, magic: "Asgn".} =
|
proc `=sink`*[T](x: var T; y: T) {.inline, magic: "Asgn".} =
|
||||||
## Generic `sink`:idx: implementation that can be overriden.
|
## Generic `sink`:idx: implementation that can be overridden.
|
||||||
shallowCopy(x, y)
|
shallowCopy(x, y)
|
||||||
|
|
||||||
type
|
type
|
||||||
HSlice*[T, U] = object ## "Heterogenous" slice type.
|
HSlice*[T, U] = object ## "Heterogeneous" slice type.
|
||||||
a*: T ## The lower bound (inclusive).
|
a*: T ## The lower bound (inclusive).
|
||||||
b*: U ## The upper bound (inclusive).
|
b*: U ## The upper bound (inclusive).
|
||||||
Slice*[T] = HSlice[T, T] ## An alias for ``HSlice[T, T]``.
|
Slice*[T] = HSlice[T, T] ## An alias for ``HSlice[T, T]``.
|
||||||
|
|
@ -2314,7 +2314,7 @@ proc addQuitProc*(quitProc: proc() {.noconv.}) {.
|
||||||
## registered.
|
## registered.
|
||||||
|
|
||||||
# Support for addQuitProc() is done by Ansi C's facilities here.
|
# Support for addQuitProc() is done by Ansi C's facilities here.
|
||||||
# In case of an unhandled exeption the exit handlers should
|
# In case of an unhandled exception the exit handlers should
|
||||||
# not be called explicitly! The user may decide to do this manually though.
|
# not be called explicitly! The user may decide to do this manually though.
|
||||||
|
|
||||||
when not defined(nimscript) and not defined(JS):
|
when not defined(nimscript) and not defined(JS):
|
||||||
|
|
@ -3974,7 +3974,7 @@ proc `[]=`*[Idx, T, U, V](a: var array[Idx, T], x: HSlice[U, V], b: openArray[T]
|
||||||
if L == b.len:
|
if L == b.len:
|
||||||
for i in 0..<L: a[Idx(i + xa)] = b[i]
|
for i in 0..<L: a[Idx(i + xa)] = b[i]
|
||||||
else:
|
else:
|
||||||
sysFatal(RangeError, "diferent lengths for slice assignment")
|
sysFatal(RangeError, "different lengths for slice assignment")
|
||||||
|
|
||||||
proc `[]`*[T, U, V](s: openArray[T], x: HSlice[U, V]): seq[T] =
|
proc `[]`*[T, U, V](s: openArray[T], x: HSlice[U, V]): seq[T] =
|
||||||
## Slice operation for sequences.
|
## Slice operation for sequences.
|
||||||
|
|
@ -4224,7 +4224,7 @@ proc addEscapedChar*(s: var string, c: char) {.noSideEffect, inline.} =
|
||||||
## by ``\xHH`` where ``HH`` is its hexadecimal value.
|
## by ``\xHH`` where ``HH`` is its hexadecimal value.
|
||||||
##
|
##
|
||||||
## The procedure has been designed so that its output is usable for many
|
## The procedure has been designed so that its output is usable for many
|
||||||
## diferent common syntaxes.
|
## different common syntaxes.
|
||||||
##
|
##
|
||||||
## **Note**: This is **not correct** for producing Ansi C code!
|
## **Note**: This is **not correct** for producing Ansi C code!
|
||||||
case c
|
case c
|
||||||
|
|
@ -4254,7 +4254,7 @@ proc addQuoted*[T](s: var string, x: T) =
|
||||||
## See `addEscapedChar <#addEscapedChar,string,char>`_
|
## See `addEscapedChar <#addEscapedChar,string,char>`_
|
||||||
## for the escaping scheme. When `x` is a string, characters in the
|
## for the escaping scheme. When `x` is a string, characters in the
|
||||||
## range ``{\128..\255}`` are never escaped so that multibyte UTF-8
|
## range ``{\128..\255}`` are never escaped so that multibyte UTF-8
|
||||||
## characters are untouched (note that this behavior is diferent from
|
## characters are untouched (note that this behavior is different from
|
||||||
## ``addEscapedChar``).
|
## ``addEscapedChar``).
|
||||||
##
|
##
|
||||||
## The Nim standard library uses this function on the elements of
|
## The Nim standard library uses this function on the elements of
|
||||||
|
|
@ -4315,7 +4315,7 @@ when hasAlloc:
|
||||||
x.add(y)
|
x.add(y)
|
||||||
|
|
||||||
proc safeAdd*(x: var string, y: string) {.noSideEffect, deprecated.} =
|
proc safeAdd*(x: var string, y: string) {.noSideEffect, deprecated.} =
|
||||||
## Adds ``y`` to ``x`` unless ``x`` is not yet initalized; in that
|
## Adds ``y`` to ``x`` unless ``x`` is not yet initialized; in that
|
||||||
## case, ``x`` becomes ``y``.
|
## case, ``x`` becomes ``y``.
|
||||||
when defined(nimNoNilSeqs):
|
when defined(nimNoNilSeqs):
|
||||||
x.add(y)
|
x.add(y)
|
||||||
|
|
|
||||||
|
|
@ -244,7 +244,7 @@ proc asgnRefNoCycle(dest: PPointer, src: pointer) {.compilerproc, inline,
|
||||||
|
|
||||||
proc unsureAsgnRef(dest: PPointer, src: pointer) {.compilerproc.} =
|
proc unsureAsgnRef(dest: PPointer, src: pointer) {.compilerproc.} =
|
||||||
# unsureAsgnRef updates the reference counters only if dest is not on the
|
# unsureAsgnRef updates the reference counters only if dest is not on the
|
||||||
# stack. It is used by the code generator if it cannot decide wether a
|
# stack. It is used by the code generator if it cannot decide whether a
|
||||||
# reference is in the stack or not (this can happen for var parameters).
|
# reference is in the stack or not (this can happen for var parameters).
|
||||||
if not isOnStack(dest):
|
if not isOnStack(dest):
|
||||||
if src != nil: incRef(usrToCell(src))
|
if src != nil: incRef(usrToCell(src))
|
||||||
|
|
|
||||||
|
|
@ -240,7 +240,7 @@ proc asgnRefNoCycle(dest: PPointer, src: pointer) {.compilerproc, inline,
|
||||||
|
|
||||||
proc unsureAsgnRef(dest: PPointer, src: pointer) {.compilerproc.} =
|
proc unsureAsgnRef(dest: PPointer, src: pointer) {.compilerproc.} =
|
||||||
# unsureAsgnRef marks 'src' as grey only if dest is not on the
|
# unsureAsgnRef marks 'src' as grey only if dest is not on the
|
||||||
# stack. It is used by the code generator if it cannot decide wether a
|
# stack. It is used by the code generator if it cannot decide whether a
|
||||||
# reference is in the stack or not (this can happen for var parameters).
|
# reference is in the stack or not (this can happen for var parameters).
|
||||||
if src != nil:
|
if src != nil:
|
||||||
let s = usrToCell(src)
|
let s = usrToCell(src)
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ type
|
||||||
# CPU this needs to be changed:
|
# CPU this needs to be changed:
|
||||||
const
|
const
|
||||||
PageShift = when defined(cpu16): 8 else: 12 # \
|
PageShift = when defined(cpu16): 8 else: 12 # \
|
||||||
# my tests showed no improvments for using larger page sizes.
|
# my tests showed no improvements for using larger page sizes.
|
||||||
PageSize = 1 shl PageShift
|
PageSize = 1 shl PageShift
|
||||||
PageMask = PageSize-1
|
PageMask = PageSize-1
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ const
|
||||||
SQLITE_EMPTY* = 16 # Database is empty
|
SQLITE_EMPTY* = 16 # Database is empty
|
||||||
SQLITE_SCHEMA* = 17 # The database schema changed
|
SQLITE_SCHEMA* = 17 # The database schema changed
|
||||||
SQLITE_TOOBIG* = 18 # Too much data for one row of a table
|
SQLITE_TOOBIG* = 18 # Too much data for one row of a table
|
||||||
SQLITE_CONSTRAINT* = 19 # Abort due to contraint violation
|
SQLITE_CONSTRAINT* = 19 # Abort due to constraint violation
|
||||||
SQLITE_MISMATCH* = 20 # Data type mismatch
|
SQLITE_MISMATCH* = 20 # Data type mismatch
|
||||||
SQLITE_MISUSE* = 21 # Library used incorrectly
|
SQLITE_MISUSE* = 21 # Library used incorrectly
|
||||||
SQLITE_NOLFS* = 22 # Uses OS features not supported on host
|
SQLITE_NOLFS* = 22 # Uses OS features not supported on host
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ type
|
||||||
ccInline, # proc should be inlined
|
ccInline, # proc should be inlined
|
||||||
ccNoInline, # proc should not be inlined
|
ccNoInline, # proc should not be inlined
|
||||||
#
|
#
|
||||||
# continueing here
|
# continuing here
|
||||||
ccFastCall, # fastcall (pass parameters in registers)
|
ccFastCall, # fastcall (pass parameters in registers)
|
||||||
ccClosure, # proc has a closure
|
ccClosure, # proc has a closure
|
||||||
ccNoConvention # needed for generating proper C procs sometimes
|
ccNoConvention # needed for generating proper C procs sometimes
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ type
|
||||||
ccInline, # proc should be inlined
|
ccInline, # proc should be inlined
|
||||||
ccNoInline, # proc should not be inlined
|
ccNoInline, # proc should not be inlined
|
||||||
#
|
#
|
||||||
# continueing here
|
# continuing here
|
||||||
ccFastCall, # fastcall (pass parameters in registers)
|
ccFastCall, # fastcall (pass parameters in registers)
|
||||||
ccClosure, # proc has a closure
|
ccClosure, # proc has a closure
|
||||||
ccNoConvention # needed for generating proper C procs sometimes
|
ccNoConvention # needed for generating proper C procs sometimes
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ when not defined(nimcore):
|
||||||
{.error: "nimcore MUST be defined for Nim's core tooling".}
|
{.error: "nimcore MUST be defined for Nim's core tooling".}
|
||||||
|
|
||||||
import strutils, os, parseopt, parseutils, sequtils, net, rdstdin, sexp
|
import strutils, os, parseopt, parseutils, sequtils, net, rdstdin, sexp
|
||||||
# Do NOT import suggest. It will lead to wierd bugs with
|
# Do NOT import suggest. It will lead to weird bugs with
|
||||||
# suggestionResultHook, because suggest.nim is included by sigmatch.
|
# suggestionResultHook, because suggest.nim is included by sigmatch.
|
||||||
# So we import that one instead.
|
# So we import that one instead.
|
||||||
import compiler / [options, commands, modules, sem,
|
import compiler / [options, commands, modules, sem,
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ proc runCmd(cmd, dest: string): bool =
|
||||||
of "!del":
|
of "!del":
|
||||||
del(x)
|
del(x)
|
||||||
else:
|
else:
|
||||||
quit "unkown command: " & cmd
|
quit "unknown command: " & cmd
|
||||||
|
|
||||||
proc smartCompare(pattern, x: string): bool =
|
proc smartCompare(pattern, x: string): bool =
|
||||||
if pattern.contains('*'):
|
if pattern.contains('*'):
|
||||||
|
|
|
||||||
|
|
@ -569,7 +569,7 @@ proc quoted(a: string): string =
|
||||||
result.addQuoted(a)
|
result.addQuoted(a)
|
||||||
|
|
||||||
proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) =
|
proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) =
|
||||||
## returs a list of tests that have problems
|
## returns a list of tests that have problems
|
||||||
var specs: seq[TSpec] = @[]
|
var specs: seq[TSpec] = @[]
|
||||||
for kind, dir in walkDir(testsDir):
|
for kind, dir in walkDir(testsDir):
|
||||||
assert testsDir.startsWith(testsDir)
|
assert testsDir.startsWith(testsDir)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ type
|
||||||
|
|
||||||
echo("")
|
echo("")
|
||||||
|
|
||||||
# NOTE: when entering newlines, adjust `expectedEnd` ouptuts
|
# NOTE: when entering newlines, adjust `expectedEnd` outputs
|
||||||
|
|
||||||
try:
|
try:
|
||||||
doAssert(false, "msg1") # doAssert test
|
doAssert(false, "msg1") # doAssert test
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ discard """
|
||||||
action: compile
|
action: compile
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# this test should ensure that the AST doesn't change slighly without it getting noticed.
|
# this test should ensure that the AST doesn't change slightly without it getting noticed.
|
||||||
|
|
||||||
import ../ast_pattern_matching
|
import ../ast_pattern_matching
|
||||||
|
|
||||||
|
|
@ -12,7 +12,7 @@ template expectNimNode(arg: untyped): NimNode = arg
|
||||||
## type `NimNode`.
|
## type `NimNode`.
|
||||||
|
|
||||||
proc substitudeComments(symbols, values, n: NimNode): NimNode =
|
proc substitudeComments(symbols, values, n: NimNode): NimNode =
|
||||||
## substitudes all nodes of kind nnkCommentStmt to parameter
|
## substitutes all nodes of kind nnkCommentStmt to parameter
|
||||||
## symbols. Consumes the argument `n`.
|
## symbols. Consumes the argument `n`.
|
||||||
if n.kind == nnkCommentStmt:
|
if n.kind == nnkCommentStmt:
|
||||||
values.add newCall(bindSym"newCommentStmtNode", newLit(n.strVal))
|
values.add newCall(bindSym"newCommentStmtNode", newLit(n.strVal))
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import
|
||||||
nativesockets, os, asyncdispatch
|
nativesockets, os, asyncdispatch
|
||||||
|
|
||||||
proc setupServerSocket(hostname: string, port: Port, domain: Domain): AsyncFD =
|
proc setupServerSocket(hostname: string, port: Port, domain: Domain): AsyncFD =
|
||||||
## Creates a socket, binds it to the specified address, and starts listening for connecitons.
|
## Creates a socket, binds it to the specified address, and starts listening for connections.
|
||||||
## Registers the descriptor with the dispatcher of the current thread
|
## Registers the descriptor with the dispatcher of the current thread
|
||||||
## Raises OSError in case of an error.
|
## Raises OSError in case of an error.
|
||||||
let fd = newNativeSocket(domain)
|
let fd = newNativeSocket(domain)
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ block tcasestm:
|
||||||
of "N": false
|
of "N": false
|
||||||
else:
|
else:
|
||||||
echo "no good"
|
echo "no good"
|
||||||
quit("quiting")
|
quit("quitting")
|
||||||
|
|
||||||
proc toBool(s: string): bool =
|
proc toBool(s: string): bool =
|
||||||
case s:
|
case s:
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
|
|
||||||
proc addFloats*(x, y, z: float): float =
|
proc addFloats*(x, y, z: float): float =
|
||||||
discard "implementation overriden by tcompilerapi.nim"
|
discard "implementation overridden by tcompilerapi.nim"
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ for j, y in stepIt(2.0, -0.0375 * 4, 107 div 4):
|
||||||
errors += 1
|
errors += 1
|
||||||
row.add(c)
|
row.add(c)
|
||||||
|
|
||||||
# Printing aparently makes the test fail when joined.
|
# Printing apparently makes the test fail when joined.
|
||||||
# echo row
|
# echo row
|
||||||
|
|
||||||
doAssert errors < 10, "total errors: " & $errors
|
doAssert errors < 10, "total errors: " & $errors
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@ vcat.x = "cat value"
|
||||||
reject:
|
reject:
|
||||||
vcat = vdog
|
vcat = vdog
|
||||||
|
|
||||||
# XXX: The next two cases seem incosistent, perhaps we should change the rules
|
# XXX: The next two cases seem inconsistent, perhaps we should change the rules
|
||||||
accept:
|
accept:
|
||||||
# truncating copies are allowed
|
# truncating copies are allowed
|
||||||
var vanimal: Animal = vdog
|
var vanimal: Animal = vdog
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ test:
|
||||||
|
|
||||||
macro test2*(a: untyped): untyped =
|
macro test2*(a: untyped): untyped =
|
||||||
proc testproc(recurse: int) =
|
proc testproc(recurse: int) =
|
||||||
echo "Thats weird"
|
echo "That's weird"
|
||||||
var o : NimNode = nil
|
var o : NimNode = nil
|
||||||
echo " no its not!"
|
echo " no its not!"
|
||||||
o = newNimNode(nnkNone)
|
o = newNimNode(nnkNone)
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ template overloadedTemplate(x: string) =
|
||||||
"""
|
"""
|
||||||
|
|
||||||
inspectUntyped bindSym("overloadedTemplate"), """bindSym("overloadedTemplate")"""
|
inspectUntyped bindSym("overloadedTemplate"), """bindSym("overloadedTemplate")"""
|
||||||
# binSym is active only in the presense of `typed` params.
|
# binSym is active only in the presence of `typed` params.
|
||||||
# `untyped` params still get the raw AST
|
# `untyped` params still get the raw AST
|
||||||
|
|
||||||
inspectSymbol normalProc, """
|
inspectSymbol normalProc, """
|
||||||
|
|
|
||||||
|
|
@ -455,7 +455,7 @@ proc removeCollisionHandler*(space: PSpace; a: TCollisionType;
|
||||||
#/ If the shape is attached to a static body, it will be added as a static shape.
|
#/ If the shape is attached to a static body, it will be added as a static shape.
|
||||||
proc addShape*(space: PSpace; shape: PShape): PShape{.
|
proc addShape*(space: PSpace; shape: PShape): PShape{.
|
||||||
cdecl, importc: "cpSpaceAddShape", dynlib: Lib.}
|
cdecl, importc: "cpSpaceAddShape", dynlib: Lib.}
|
||||||
#/ Explicity add a shape as a static shape to the simulation.
|
#/ Explicitly add a shape as a static shape to the simulation.
|
||||||
proc addStaticShape*(space: PSpace; shape: PShape): PShape{.
|
proc addStaticShape*(space: PSpace; shape: PShape): PShape{.
|
||||||
cdecl, importc: "cpSpaceAddStaticShape", dynlib: Lib.}
|
cdecl, importc: "cpSpaceAddStaticShape", dynlib: Lib.}
|
||||||
#/ Add a rigid body to the simulation.
|
#/ Add a rigid body to the simulation.
|
||||||
|
|
@ -1028,12 +1028,12 @@ proc getCircleRadius*(shape: PShape): CpFloat {.
|
||||||
proc allocPolyShape*(): PPolyShape {.
|
proc allocPolyShape*(): PPolyShape {.
|
||||||
cdecl, importc: "cpPolyShapeAlloc", dynlib: Lib.}
|
cdecl, importc: "cpPolyShapeAlloc", dynlib: Lib.}
|
||||||
#/ Initialize a polygon shape.
|
#/ Initialize a polygon shape.
|
||||||
#/ A convex hull will be created from the vertexes.
|
#/ A convex hull will be created from the vertices.
|
||||||
proc init*(poly: PPolyShape; body: PBody, numVerts: cint;
|
proc init*(poly: PPolyShape; body: PBody, numVerts: cint;
|
||||||
verts: ptr TVector; offset: TVector): PPolyShape {.
|
verts: ptr TVector; offset: TVector): PPolyShape {.
|
||||||
cdecl, importc: "cpPolyShapeInit", dynlib: Lib.}
|
cdecl, importc: "cpPolyShapeInit", dynlib: Lib.}
|
||||||
#/ Allocate and initialize a polygon shape.
|
#/ Allocate and initialize a polygon shape.
|
||||||
#/ A convex hull will be created from the vertexes.
|
#/ A convex hull will be created from the vertices.
|
||||||
proc newPolyShape*(body: PBody; numVerts: cint; verts: ptr TVector;
|
proc newPolyShape*(body: PBody; numVerts: cint; verts: ptr TVector;
|
||||||
offset: TVector): PShape {.
|
offset: TVector): PShape {.
|
||||||
cdecl, importc: "cpPolyShapeNew", dynlib: Lib.}
|
cdecl, importc: "cpPolyShapeNew", dynlib: Lib.}
|
||||||
|
|
@ -1050,7 +1050,7 @@ proc newBoxShape*(body: PBody; width, height: CpFloat): PShape {.
|
||||||
proc newBoxShape*(body: PBody; box: TBB): PShape {.
|
proc newBoxShape*(body: PBody; box: TBB): PShape {.
|
||||||
cdecl, importc: "cpBoxShapeNew2", dynlib: Lib.}
|
cdecl, importc: "cpBoxShapeNew2", dynlib: Lib.}
|
||||||
|
|
||||||
#/ Check that a set of vertexes is convex and has a clockwise winding.
|
#/ Check that a set of vertices is convex and has a clockwise winding.
|
||||||
#/ NOTE: Due to floating point precision issues, hulls created with cpQuickHull() are not guaranteed to validate!
|
#/ NOTE: Due to floating point precision issues, hulls created with cpQuickHull() are not guaranteed to validate!
|
||||||
proc validatePoly*(verts: ptr TVector; numVerts: cint): bool {.
|
proc validatePoly*(verts: ptr TVector; numVerts: cint): bool {.
|
||||||
cdecl, importc: "cpPolyValidate", dynlib: Lib.}
|
cdecl, importc: "cpPolyValidate", dynlib: Lib.}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ proc setConnected(state: bool) =
|
||||||
for b in connectionButtons: disable(b)
|
for b in connectionButtons: disable(b)
|
||||||
|
|
||||||
proc setActiveZone(ind: int; zone: ScZoneRecord) =
|
proc setActiveZone(ind: int; zone: ScZoneRecord) =
|
||||||
#hilight it or something
|
#highlight it or something
|
||||||
dispmessage("Selected " & zone.name)
|
dispmessage("Selected " & zone.name)
|
||||||
connectZone(zone.ip, zone.port)
|
connectZone(zone.ip, zone.port)
|
||||||
playBtn.enable()
|
playBtn.enable()
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ proc t6*(x: type(t3(0))): type(t1(0)) =
|
||||||
proc t7*(x: int): type($x) =
|
proc t7*(x: int): type($x) =
|
||||||
result = "test"
|
result = "test"
|
||||||
|
|
||||||
# This is a more compicated example involving a type
|
# This is a more complicated example involving a type
|
||||||
# selection through a macro:
|
# selection through a macro:
|
||||||
# https://github.com/nim-lang/Nim/issues/7230
|
# https://github.com/nim-lang/Nim/issues/7230
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ proc `+!!`(p: pointer, size: int): pointer {.inline.} =
|
||||||
|
|
||||||
const
|
const
|
||||||
PageShift = when defined(cpu16): 8 else: 12 # \
|
PageShift = when defined(cpu16): 8 else: 12 # \
|
||||||
# my tests showed no improvments for using larger page sizes.
|
# my tests showed no improvements for using larger page sizes.
|
||||||
PageSize = 1 shl PageShift
|
PageSize = 1 shl PageShift
|
||||||
|
|
||||||
var p = osAllocPages(3 * PageSize)
|
var p = osAllocPages(3 * PageSize)
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,6 @@ type
|
||||||
foo: ref int
|
foo: ref int
|
||||||
bar: ref int not nil
|
bar: ref int not nil
|
||||||
var x: ref int = new(int)
|
var x: ref int = new(int)
|
||||||
# Create instance without initializaing the `bar` field
|
# Create instance without initializing the `bar` field
|
||||||
var f = Foo(foo: x)
|
var f = Foo(foo: x)
|
||||||
echo f.bar.isNil # true
|
echo f.bar.isNil # true
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ TFoo
|
||||||
'''
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
## XXX this output needs to be adapated for VCC which produces different results.
|
## XXX this output needs to be adapted for VCC which produces different results.
|
||||||
|
|
||||||
# It turned out that it's hard to generate correct for these two test cases at
|
# It turned out that it's hard to generate correct for these two test cases at
|
||||||
# the same time.
|
# the same time.
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import os, strutils
|
||||||
# 8 - Handle : Invalid Handle
|
# 8 - Handle : Invalid Handle
|
||||||
|
|
||||||
proc genBadFileName(limit = 100): string =
|
proc genBadFileName(limit = 100): string =
|
||||||
## Generates a filename of a nonexistant file.
|
## Generates a filename of a nonexistent file.
|
||||||
## Returns "" if generation fails.
|
## Returns "" if generation fails.
|
||||||
result = "a"
|
result = "a"
|
||||||
var hitLimit = true
|
var hitLimit = true
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ when true:
|
||||||
doAssert result.other == node["other"].getBiggestInt()
|
doAssert result.other == node["other"].getBiggestInt()
|
||||||
|
|
||||||
# TODO: Test object variant with set in of branch.
|
# TODO: Test object variant with set in of branch.
|
||||||
# TODO: Should we support heterogenous arrays?
|
# TODO: Should we support heterogeneous arrays?
|
||||||
|
|
||||||
# Tests that verify the error messages for invalid data.
|
# Tests that verify the error messages for invalid data.
|
||||||
block:
|
block:
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ when defined(case_testfile): # compiled test file for child process
|
||||||
# failed. The shell (and lldb debugger) solves that by inserting a
|
# failed. The shell (and lldb debugger) solves that by inserting a
|
||||||
# helpful msg: `segmentation fault` when it detects a signal killed
|
# helpful msg: `segmentation fault` when it detects a signal killed
|
||||||
# the child.
|
# the child.
|
||||||
# todo: expose an API that will show more diagnostic, returing
|
# todo: expose an API that will show more diagnostic, returning
|
||||||
# (exitCode, signal) instead of just `shellExitCode`.
|
# (exitCode, signal) instead of just `shellExitCode`.
|
||||||
if true: quit(139)
|
if true: quit(139)
|
||||||
of "exit_recursion": # stack overflow by infinite recursion
|
of "exit_recursion": # stack overflow by infinite recursion
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue