Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed May 14, 2021
1 parent 7c33dbd commit e2bdcc1
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 34 deletions.
1 change: 0 additions & 1 deletion compiler/builddeps.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 1 addition & 3 deletions compiler/ic/replayer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions compiler/pragmas.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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},
Expand Down
1 change: 1 addition & 0 deletions compiler/semdata.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 2 additions & 15 deletions compiler/semmagic.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
11 changes: 7 additions & 4 deletions lib/std/private/dependency_utils.nim
Original file line number Diff line number Diff line change
@@ -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
3 changes: 0 additions & 3 deletions lib/std/strfloats.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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.} =
Expand Down

0 comments on commit e2bdcc1

Please sign in to comment.