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 =
|
proc isEmbedded(ts: TypeSpec): bool =
|
||||||
embedded in ts.attrs
|
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) =
|
proc addAttrs(x: var TypeSpec; y: TypeSpec) =
|
||||||
x.attrs = x.attrs + y.attrs
|
x.attrs = x.attrs + y.attrs
|
||||||
|
|
||||||
|
@ -111,7 +116,10 @@ proc dotExtend(result: var PNode; label: string) =
|
||||||
|
|
||||||
proc ident(`ref`: Ref): PNode =
|
proc ident(`ref`: Ref): PNode =
|
||||||
for m in `ref`.module: dotExtend(result, string m)
|
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) =
|
proc deref(loc: Location; r: Ref): (Location, Definition) =
|
||||||
result[0] = loc
|
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)
|
attrs(loc, sp.dictof.key, seen) + attrs(loc, sp.dictof.value, seen)
|
||||||
of SimplepatternKind.Ref:
|
of SimplepatternKind.Ref:
|
||||||
if sp.ref in seen: {recursive}
|
if sp.ref in seen: {recursive}
|
||||||
|
elif sp.ref.isAtomic: {}
|
||||||
else:
|
else:
|
||||||
var
|
var
|
||||||
(loc, def) = deref(loc, sp.ref)
|
(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 =
|
proc isLiteral(loc: Location; sp: SimplePattern): bool =
|
||||||
case sp.orKind
|
case sp.orKind
|
||||||
of SimplepatternKind.Ref:
|
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)
|
var (loc, def) = deref(loc, sp.ref)
|
||||||
result = isLiteral(loc, def)
|
result = isLiteral(loc, def)
|
||||||
of SimplepatternKind.lit:
|
of SimplepatternKind.lit:
|
||||||
|
|
Loading…
Reference in New Issue