schema: do not deref atomic types
This commit is contained in:
parent
0e3824fc5d
commit
96879da08c
|
@ -101,6 +101,11 @@ proc ident(np: NamedSimplePattern; fallback: string): PNode =
|
|||
proc isEmbedded(ts: TypeSpec): bool =
|
||||
embedded in ts.attrs
|
||||
|
||||
func isAtomic(r: Ref): bool =
|
||||
case r.name.string
|
||||
of "bool", "float", "double", "int", "string", "bytes", "symbol": true
|
||||
else: false
|
||||
|
||||
proc addAttrs(x: var TypeSpec; y: TypeSpec) =
|
||||
x.attrs = x.attrs + y.attrs
|
||||
|
||||
|
@ -111,7 +116,10 @@ proc dotExtend(result: var PNode; label: string) =
|
|||
|
||||
proc ident(`ref`: Ref): PNode =
|
||||
for m in `ref`.module: dotExtend(result, string m)
|
||||
dotExtend(result, `ref`.name.string.capitalizeAscii)
|
||||
if `ref`.isAtomic:
|
||||
dotExtend(result, `ref`.name.string)
|
||||
else:
|
||||
dotExtend(result, `ref`.name.string.capitalizeAscii)
|
||||
|
||||
proc deref(loc: Location; r: Ref): (Location, Definition) =
|
||||
result[0] = loc
|
||||
|
@ -174,6 +182,7 @@ proc attrs(loc: Location; sp: SimplePattern; seen: RefSet): Attributes =
|
|||
attrs(loc, sp.dictof.key, seen) + attrs(loc, sp.dictof.value, seen)
|
||||
of SimplepatternKind.Ref:
|
||||
if sp.ref in seen: {recursive}
|
||||
elif sp.ref.isAtomic: {}
|
||||
else:
|
||||
var
|
||||
(loc, def) = deref(loc, sp.ref)
|
||||
|
@ -245,7 +254,7 @@ proc isLiteral(loc: Location; pat: Pattern): bool {.gcsafe.}
|
|||
proc isLiteral(loc: Location; sp: SimplePattern): bool =
|
||||
case sp.orKind
|
||||
of SimplepatternKind.Ref:
|
||||
if sp.ref.module.len == 0:
|
||||
if sp.ref.module.len == 0 and not sp.ref.isAtomic:
|
||||
var (loc, def) = deref(loc, sp.ref)
|
||||
result = isLiteral(loc, def)
|
||||
of SimplepatternKind.lit:
|
||||
|
|
Loading…
Reference in New Issue