Schema: do not overload `$` or encode for Preserve types
This commit is contained in:
parent
5250707f0e
commit
b6275a241b
|
@ -197,7 +197,7 @@ proc isEmbeddable(scm: Schema; orDef: DefinitionOr; seen: RefSet): bool =
|
||||||
isEmbeddable(scm, na.pattern, seen)
|
isEmbeddable(scm, na.pattern, seen)
|
||||||
isEmbeddable(orDef.data.pattern0) or
|
isEmbeddable(orDef.data.pattern0) or
|
||||||
isEmbeddable(orDef.data.pattern1) or
|
isEmbeddable(orDef.data.pattern1) or
|
||||||
any(orDef.data.patternN, isEmbeddable)
|
sequtils.any(orDef.data.patternN, isEmbeddable)
|
||||||
|
|
||||||
proc isEmbeddable(scm: Schema; def: Definition; seen: RefSet): bool =
|
proc isEmbeddable(scm: Schema; def: Definition; seen: RefSet): bool =
|
||||||
case def.orKind
|
case def.orKind
|
||||||
|
@ -266,6 +266,16 @@ proc isSymbolEnum(scm: Schema; def: Definition): bool =
|
||||||
result = isSymbolEnum(scm, def.or)
|
result = isSymbolEnum(scm, def.or)
|
||||||
else: discard
|
else: discard
|
||||||
|
|
||||||
|
proc isAny(scm: Schema; def: Definition): bool =
|
||||||
|
if def.orKind == DefinitionKind.Pattern:
|
||||||
|
if def.pattern.orKind == PatternKind.SimplePattern:
|
||||||
|
case def.pattern.simplePattern.orKind
|
||||||
|
of SimplePatternKind.Ref:
|
||||||
|
result = isAny(scm, deref(scm, def.pattern.simplePattern.`ref`))
|
||||||
|
of SimplePatternKind.any:
|
||||||
|
result = true
|
||||||
|
else: discard
|
||||||
|
|
||||||
proc typeIdent(atom: AtomKind): PNode =
|
proc typeIdent(atom: AtomKind): PNode =
|
||||||
case atom
|
case atom
|
||||||
of AtomKind.`Boolean`: ident"bool"
|
of AtomKind.`Boolean`: ident"bool"
|
||||||
|
@ -705,7 +715,7 @@ proc renderNimModule*(scm: Schema): string =
|
||||||
var name = name
|
var name = name
|
||||||
name[0] = name[0].toUpperAscii
|
name[0] = name[0].toUpperAscii
|
||||||
var defIdent = parameterize(ident(name), isEmbeddable(scm, def))
|
var defIdent = parameterize(ident(name), isEmbeddable(scm, def))
|
||||||
if not isSymbolEnum(scm, def):
|
if not isSymbolEnum(scm, def) and not isAny(scm, def):
|
||||||
if isEmbeddable(scm, def):
|
if isEmbeddable(scm, def):
|
||||||
mergeType(embeddableType, defIdent)
|
mergeType(embeddableType, defIdent)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue