Skip to content

Commit e498caf

Browse files
authored
maps nkNilLit to nil tag (#1503)
Maps `nkNilLit` to `nil` tag and maps `mNil` to `nilm` tag so that they don't conflict. Generated `enum2nif.nim` is used in nim-lang/Nim#25201.
1 parent b874020 commit e498caf

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/gear2/enum2nif.nim

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by enumgen.nim. DO NOT EDIT!
1+
# Generated by gear2/generator/enumgen.nim in Nimony repo. DO NOT EDIT!
22

33
import compiler / [ast, options]
44

@@ -27,7 +27,7 @@ proc toNifTag*(s: TNodeKind): string =
2727
of nkStrLit: "strlit"
2828
of nkRStrLit: "rstrlit"
2929
of nkTripleStrLit: "triplestrlit"
30-
of nkNilLit: "nillit"
30+
of nkNilLit: "nil"
3131
of nkComesFrom: "comesfrom"
3232
of nkDotCall: "dotcall"
3333
of nkCommand: "cmd"
@@ -197,7 +197,7 @@ proc parseNodeKind*(s: string): TNodeKind =
197197
of "strlit": nkStrLit
198198
of "rstrlit": nkRStrLit
199199
of "triplestrlit": nkTripleStrLit
200-
of "nillit": nkNilLit
200+
of "nil": nkNilLit
201201
of "comesfrom": nkComesFrom
202202
of "dotcall": nkDotCall
203203
of "cmd": nkCommand
@@ -744,6 +744,7 @@ proc toNifTag*(s: TMagic): string =
744744
of mExit: "exit"
745745
of mSetLengthStr: "setlenstr"
746746
of mSetLengthSeq: "setlenseq"
747+
of mSetLengthSeqUninit: "setlensequninit"
747748
of mIsPartOf: "ispartof"
748749
of mAstToStr: "asttostr"
749750
of mParallel: "parallel"
@@ -799,7 +800,7 @@ proc toNifTag*(s: TMagic): string =
799800
of mString: "string"
800801
of mCstring: "cstring"
801802
of mPointer: "pointer"
802-
of mNil: "nil"
803+
of mNil: "nilm"
803804
of mExpr: "exprm"
804805
of mStmt: "stmtm"
805806
of mTypeDesc: "typedesc"
@@ -1025,6 +1026,7 @@ proc parseMagic*(s: string): TMagic =
10251026
of "exit": mExit
10261027
of "setlenstr": mSetLengthStr
10271028
of "setlenseq": mSetLengthSeq
1029+
of "setlensequninit": mSetLengthSeqUninit
10281030
of "ispartof": mIsPartOf
10291031
of "asttostr": mAstToStr
10301032
of "parallel": mParallel
@@ -1080,7 +1082,7 @@ proc parseMagic*(s: string): TMagic =
10801082
of "string": mString
10811083
of "cstring": mCstring
10821084
of "pointer": mPointer
1083-
of "nil": mNil
1085+
of "nilm": mNil
10841086
of "exprm": mExpr
10851087
of "stmtm": mStmt
10861088
of "typedesc": mTypeDesc

src/gear2/generator/enumgen.nim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const
3939
("nkBreakStmt", "brk"),
4040
("nkStmtListExpr", "expr"),
4141
("nkEnumFieldDef", "efld"),
42+
("nkNilLit", "nil"),
4243
("ccNoConvention", "noconv"),
4344
("mExpr", "exprm"),
4445
("mStmt", "stmtm"),
@@ -53,6 +54,7 @@ const
5354
("mRange", "rangem"),
5455
("mVar", "varm"),
5556
("mInSet", "contains"),
57+
("mNil", "nilm"),
5658
("tyBuiltInTypeClass", "bconcept"),
5759
("tyUserTypeClass", "uconcept"),
5860
("tyUserTypeClassInst", "uconceptinst"),
@@ -222,7 +224,7 @@ proc genFlags[E](f: var File; enumName: string; prefixLen = 2) =
222224
f.write code
223225

224226
var f = open("src/gear2/enum2nif.nim", fmWrite)
225-
f.write "# Generated by enumgen.nim. DO NOT EDIT!\n\n"
227+
f.write "# Generated by gear2/generator/enumgen.nim in Nimony repo. DO NOT EDIT!\n\n"
226228
f.write "import compiler / [ast, options]\n\n"
227229
# use the same mapping for TNodeKind and TMagic so that we can detect conflicts!
228230
var nodeTags = initOrderedTable[string, bool]()

0 commit comments

Comments
 (0)