Skip to content

Commit 26cf717

Browse files
committed
clean up code
1 parent 9a1ab95 commit 26cf717

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
lines changed

compiler/icnif/nifdecoder.nim

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,6 @@ proc nodeKind(n: Cursor): TNodeKind {.inline.} =
1717
assert n.kind == ParLe
1818
pool.tags[n.tagId].parseNodeKind()
1919

20-
const SysTypeKinds = {tyBool, tyChar, tyString, tyInt .. tyUInt64}
21-
22-
proc getSysTypeSym(c: var DecodeContext; typeKind: TTypeKind): PSym =
23-
assert typeKind in SysTypeKinds
24-
if typeKind in c.sysTypes:
25-
result = c.sysTypes[typeKind]
26-
else:
27-
let ident = c.graph.cache.getIdent(toNifTag typeKind)
28-
result = newSym(skType, ident, c.idgen, c.owner, unknownLineInfo)
29-
var typ = newType(typeKind, c.idgen, nil)
30-
typ.sym = result
31-
result.typ = typ
32-
c.sysTypes[typeKind] = result
33-
34-
proc getSysType(c: var DecodeContext; typeKind: TTypeKind): PType =
35-
# This will be replaced with magicsys.getSysType
36-
assert typeKind in SysTypeKinds
37-
getSysTypeSym(c, typeKind).typ
38-
3920
type
4021
SplittedNifSym = object
4122
name: string

compiler/icnif/nifdecodertypes.nim

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,25 @@ proc expect(n: var Cursor; k: NifKind) =
88
writeStackTrace()
99
quit "[NIF decoder] expected: " & $k & " but got: " & $n.kind & toString n
1010

11+
const SysTypeKinds = {tyBool, tyChar, tyString, tyInt .. tyUInt64}
12+
13+
proc getSysTypeSym(c: var DecodeContext; typeKind: TTypeKind): PSym =
14+
assert typeKind in SysTypeKinds
15+
if typeKind in c.sysTypes:
16+
result = c.sysTypes[typeKind]
17+
else:
18+
let ident = c.graph.cache.getIdent(toNifTag typeKind)
19+
result = newSym(skType, ident, c.idgen, c.owner, unknownLineInfo)
20+
var typ = newType(typeKind, c.idgen, nil)
21+
typ.sym = result
22+
result.typ = typ
23+
c.sysTypes[typeKind] = result
24+
25+
proc getSysType(c: var DecodeContext; typeKind: TTypeKind): PType =
26+
# This will be replaced with magicsys.getSysType
27+
assert typeKind in SysTypeKinds
28+
getSysTypeSym(c, typeKind).typ
29+
1130
proc readTypeKind(n: var Cursor; tag: string): TTypeKind =
1231
if tag.len == 1:
1332
case tag[0]

compiler/icnif/nifencoder.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ proc toNifTypeSection(c: var EncodeContext; n: PNode) =
8383
assert n.len == 3
8484

8585
var name: PNode
86-
var visibility: PNode
87-
var pragma: PNode
86+
var visibility: PNode = nil
87+
var pragma: PNode = nil
8888
if n[0].kind == nkPragmaExpr:
8989
pragma = n[0][1]
9090
if n[0][0].kind == nkPostfix:

compiler/icnif/nifencodertypes.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ proc toNif(c: var EncodeContext; t: PType) =
4141
return
4242

4343
case t.kind
44-
of tyNone: atom c, t
45-
of tyBool: atom c, t
44+
of tyNone: atom c, t
45+
of tyBool: atom c, t
4646
of tyChar: atom c, t, "c +8"
4747
of tyEmpty: c.b.addEmpty
4848
of tyInt: atom c, t, "i -1"

tests/icnif/tencode_node2node.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ proc newConfigRefForTest(): ConfigRef =
1414
excl(conf.notes, hintProcessing)
1515
excl(conf.mainPackageNotes, hintProcessing)
1616
result = conf
17-
17+
1818
proc newModuleGraphForSem(cache: IdentCache; conf: ConfigRef): ModuleGraph =
1919
var graph = newModuleGraph(cache, conf)
2020
graph.setPipeLinePass(SemPass)

0 commit comments

Comments
 (0)