File tree Expand file tree Collapse file tree 5 files changed +25
-11
lines changed Expand file tree Collapse file tree 5 files changed +25
-11
lines changed Original file line number Diff line number Diff line change @@ -43,8 +43,6 @@ proc splitNifSym(s: string): SplittedNifSym =
4343proc fromNif (c: var DecodeContext ; n: var Cursor ): PNode
4444proc fromNifType (c: var DecodeContext ; n: var Cursor ): PType
4545
46- include nifdecodertypes
47-
4846proc fromNifSymbol (c: var DecodeContext ; n: var Cursor ): PSym =
4947 result = c.nifSymToPSym[n.symId]
5048 inc n
@@ -56,6 +54,7 @@ proc fromNifSymDef(c: var DecodeContext; n: var Cursor; kind: TNodeKind): PNode
5654 of nkVarSection: skVar
5755 of nkLetSection: skLet
5856 of nkImportStmt: skModule
57+ of nkEnumTy: skEnumField
5958 else : skConst
6059 inc n
6160 assert n.kind == SymbolDef
@@ -99,6 +98,8 @@ proc fromNifSymDef(c: var DecodeContext; n: var Cursor; kind: TNodeKind): PNode
9998 assert n.kind == ParRi
10099 inc n
101100
101+ include nifdecodertypes
102+
102103proc fromNifLocal (c: var DecodeContext ; n: var Cursor ; kind: TNodeKind ): PNode =
103104 result = newNodeI (kind, unknownLineInfo, 1 )
104105 inc n
Original file line number Diff line number Diff line change @@ -77,7 +77,14 @@ proc readTypeKind(n: var Cursor; tag: string): TTypeKind =
7777
7878proc fromNifTypeImpl (c: var DecodeContext ; n: var Cursor ; kind: TTypeKind ; res: PType ) =
7979 case kind
80- of tyFromExpr, tyEnum:
80+ of tyEnum:
81+ res.n = newNode (nkEnumTy)
82+ while n.kind != ParRi :
83+ var sym = fromNifSymDef (c, n, nkEnumTy)
84+ sym.sym.typ = res
85+ res.n.add sym
86+ expect n, ParRi
87+ of tyFromExpr:
8188 res.n = fromNif (c, n)
8289 of tyStatic:
8390 res.addAllowNil fromNifType (c, n)
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ proc addFloatLit(b: var Builder; f: float; suffix: string) =
3030 addStrLit (b, suffix)
3131
3232proc toNif (c: var EncodeContext ; n: PNode )
33- proc toNif (c: var EncodeContext ; t: PType )
33+ proc toNif (c: var EncodeContext ; t: PType ; isTypeSection = false )
3434
3535proc toNifSym (c: var EncodeContext ; sym: PSym ): string =
3636 result = sym.name.s & '.' & $ sym.disamb
@@ -115,9 +115,9 @@ proc toNifTypeSection(c: var EncodeContext; n: PNode) =
115115 let last = n[2 ]
116116 if name.kind == nkSym:
117117 if last.kind == nkEmpty and name.sym.typ != nil :
118- toNif c, name.sym.typ
118+ toNif c, name.sym.typ, true
119119 elif name.sym.typ != nil and name.sym.typ.kind in {tyEnum, tyObject} and name.sym.typ.n != nil :
120- toNif c, name.sym.typ
120+ toNif c, name.sym.typ, true
121121 else :
122122 toNif c, last
123123 else :
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ template typeHead(c: var EncodeContext; t: PType; body: untyped) =
3535 writeTypeFlags (c, t)
3636 body
3737
38- proc toNif (c: var EncodeContext ; t: PType ) =
38+ proc toNif (c: var EncodeContext ; t: PType ; isTypeSection = false ) =
3939 if t == nil :
4040 c.b.addKeyw " missing"
4141 return
@@ -91,11 +91,12 @@ proc toNif(c: var EncodeContext; t: PType) =
9191 c.typeHead t:
9292 for _, son in t.ikids: toNif c, son
9393 of tyDistinct, tyEnum:
94- if t.sym != nil :
95- symToNif c, t.sym
96- else :
94+ if isTypeSection:
9795 c.typeHead t:
98- for _, son in t.ikids: toNif c, son
96+ for son in t.n:
97+ symdefToNif c, son
98+ else :
99+ symToNif c, t.sym
99100 of tyPtr:
100101 if isNominalRef (t):
101102 symToNif c, t.sym
Original file line number Diff line number Diff line change 11type
22 TestInt = int
3+ TestEnum = enum
4+ X
5+ Y
36
47var x: TestInt
8+ var testEnum: TestEnum
9+ var testEnum1 = X
You can’t perform that action at this time.
0 commit comments