diff --git a/compiler/builddeps.nim b/compiler/builddeps.nim index 63f9a9780661c..b6426e16b712a 100644 --- a/compiler/builddeps.nim +++ b/compiler/builddeps.nim @@ -14,7 +14,6 @@ import msgs, options, ast, lineinfos, extccomp, pathutils const prefix = "__" # prevent clashing with user files proc addDependency*(conf: ConfigRef, name: string, info: TLineInfo) = - echo "D20210513T231239" case name of "dragonbox": if name notin conf.dependencies: diff --git a/compiler/ic/replayer.nim b/compiler/ic/replayer.nim index 6d0e61af777b7..0e7db9463f41d 100644 --- a/compiler/ic/replayer.nim +++ b/compiler/ic/replayer.nim @@ -32,9 +32,7 @@ proc replayStateChanges*(module: PSym; g: ModuleGraph) = of "hint": message(g.config, n.info, hintUser, n[1].strVal) of "warning": message(g.config, n.info, warnUser, n[1].strVal) of "error": localError(g.config, n.info, errUser, n[1].strVal) - of "addDependency": - echo ("in replayer", n[1].strVal) - addDependency(g.config, n[1].strVal, n.info) + of "addDependency": addDependency(g.config, n[1].strVal, n.info) of "compile": internalAssert g.config, n.len == 4 and n[2].kind == nkStrLit let cname = AbsoluteFile n[1].strVal diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 667637348f342..e81e7e0d6f7fb 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -96,12 +96,6 @@ proc getPragmaVal*(procAst: PNode; name: TSpecialWord): PNode = proc pragma*(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords; isStatement: bool = false) -# proc recordPragma(c: PContext; n: PNode; args: varargs[string]) = -# var recorded = newNodeI(nkReplayAction, n.info) -# for i in 0..args.high: -# recorded.add newStrNode(args[i], n.info) -# addPragmaComputation(c, recorded) - const errStringLiteralExpected = "string literal expected" errIntLiteralExpected = "integer literal expected" @@ -494,8 +488,6 @@ proc relativeFile(c: PContext; n: PNode; ext=""): AbsoluteFile = if result.isEmpty: result = AbsoluteFile s proc processCompile(c: PContext, n: PNode) = - # echo (filename, found, "D20210513T234512", conf.toCompile) - echo ("processCompile", "D20210513T234512", n.renderTree) proc docompile(c: PContext; it: PNode; src, dest: AbsoluteFile; customArgs: string) = var cf = Cfile(nimname: splitFile(src).name, cname: src, obj: dest, flags: {CfileFlag.External}, diff --git a/compiler/semdata.nim b/compiler/semdata.nim index 20c25e677f797..b4a419a735d70 100644 --- a/compiler/semdata.nim +++ b/compiler/semdata.nim @@ -333,6 +333,7 @@ proc addPragmaComputation*(c: PContext; n: PNode) = addPragmaComputation(c.encoder, c.packedRepr, n) proc recordPragma*(c: PContext; n: PNode; args: varargs[string]) = + # xxx rename to `recordAction`, since it can record things other than pragmas var recorded = newNodeI(nkReplayAction, n.info) for i in 0..args.high: recorded.add newStrNode(args[i], n.info) diff --git a/compiler/semmagic.nim b/compiler/semmagic.nim index 41ef0d4c6ce5b..1ce8bd052cf60 100644 --- a/compiler/semmagic.nim +++ b/compiler/semmagic.nim @@ -576,22 +576,9 @@ proc magicsAfterOverloadResolution(c: PContext, n: PNode, of mAddDependency: let x = c.semConstExpr(c, n[1]) case x.kind - of nkStrKinds: - addDependency(c.config, x.strVal, n.info) - else: - localError(c.config, n.info, "cannot evaluate at compile time") - echo ("addPragmaComputation", n.renderTree) - # proc recordPragma(c: PContext; n: PNode; args: varargs[string]) = - # var recorded = newNodeI(nkReplayAction, n.info) - # for i in 0..args.high: - # recorded.add newStrNode(args[i], n.info) - # addPragmaComputation(c, recorded) - # addPragmaComputation(c, n) + of nkStrKinds: addDependency(c.config, x.strVal, n.info) + else: localError(c.config, n.info, "cannot evaluate at compile time") recordPragma(c, n, "addDependency", x.strVal) - # var recorded = newNodeI(nkReplayAction, n.info) - # for i in 0..args.high: - # recorded.add newStrNode(args[i], n.info) - # addPragmaComputation(c, recorded) result = newNodeIT(nkEmpty, n.info, getSysType(c.graph, n.info, tyVoid)) of mPrivateAccess: var t = n[1].typ[0] diff --git a/lib/std/private/dependency_utils.nim b/lib/std/private/dependency_utils.nim index efd7f7d89b080..5fa2bf6f22916 100644 --- a/lib/std/private/dependency_utils.nim +++ b/lib/std/private/dependency_utils.nim @@ -1,5 +1,8 @@ -proc addDependency*(name: string) {.magic: "AddDependency".} = - ## TODO: doc comment +##[ +Experimental, subject to change +]## -# proc addDependency*(name: string) {.compileTime.} = -# ## TODO +proc addDependency*(name: string) {.magic: "AddDependency".} = + ## Adds a dependency on `name`; currently only `dragonbox` is supported. + # a pragma would be possible but cause more boilerplate, and also would be less flexible + # in case we want to also return something about the depenedncy diff --git a/lib/std/strfloats.nim b/lib/std/strfloats.nim index a9cccd9f9b8f6..3960b3191261c 100644 --- a/lib/std/strfloats.nim +++ b/lib/std/strfloats.nim @@ -74,10 +74,7 @@ proc toStringSprintf*(buf: var array[strFloatBufLen, char]; value: BiggestFloat) when useDragonbox: import private/dependency_utils - # static: addDependency("dragonbox") - static: echo "D20210513T234052.1" addDependency("dragonbox") - static: echo "D20210513T234052.2" proc dragonboxToString(buf: ptr char, value: cdouble): ptr char {.importc: "nim_dragonbox_Dtoa".} proc toStringDragonbox*(buf: var array[strFloatBufLen, char]; value: BiggestFloat): int {.inline.} =