Less identifier mangling

This commit is contained in:
Emery Hemingway 2021-09-06 18:33:49 +02:00
parent 41675a2daf
commit 00bb9de55f
1 changed files with 6 additions and 6 deletions

View File

@ -39,7 +39,7 @@ proc ident(sn: SchemaNode): PNode =
var s: string
case sn.kind
of snkAlt:
s = sn.altLabel.toLower.nimIdentNormalize
s = sn.altLabel.nimIdentNormalize
of snkLiteral: s = $sn.value
of snkRecord:
s = $sn.nodes[0]
@ -67,7 +67,7 @@ proc typeIdent(sn: SchemaNode): PNode =
of snkRef:
var id = ident sn.refPath[sn.refPath.high]
for i in countDown(sn.refPath.high.pred, 0):
id = nn(nkDotExpr, ident(sn.refPath[i].toLowerAscii), id)
id = nn(nkDotExpr, ident(sn.refPath[i]), id)
id
else:
ident"Preserve"
@ -397,7 +397,7 @@ proc collectRefImports(imports: PNode; sn: SchemaNode) =
imports.add ident"std/tables"
of snkRef:
if sn.refPath.len > 1:
imports.add ident(sn.refPath[0].toLowerAscii)
imports.add ident(sn.refPath[0])
else:
for child in sn.items:
collectRefImports(imports, child)
@ -405,7 +405,7 @@ proc collectRefImports(imports: PNode; sn: SchemaNode) =
proc collectRefImports(imports: PNode; scm: Schema) =
if scm.embeddedType.contains {'.'}:
let m = split(scm.embeddedType, '.', 1 )[0]
imports.add ident(m.toLowerAscii)
imports.add ident(m)
for _, def in scm.definitions:
collectRefImports(imports, def)
@ -413,7 +413,7 @@ proc moduleScopedIdent(s: string): PNode =
var id: string
let items = split(s, {'.'})
for i in 0..<items.high:
id.add items[i].toLowerAscii
id.add items[i]
id.add '.'
id.add items[items.high]
ident(id)
@ -432,7 +432,7 @@ proc generateNimFile*(scm: Schema; path: string) =
typeSection.add nn(nkTypeDef,
ident"EmbeddedType",
newEmpty(),
scm.embeddedType.moduleScopedIdent)
scm.embeddedType.ident)
typeSection.add nn(nkTypeDef,
ident"Preserve",
newEmpty(),