preserves_schema_nim: emit Perserve type for And composites

This commit is contained in:
Emery Hemingway 2023-02-28 22:03:19 -06:00
parent 66a653a775
commit 70655a959b
2 changed files with 7 additions and 3 deletions

View File

@ -1,6 +1,6 @@
# Package
version = "20221213"
version = "20230228"
author = "Emery Hemingway"
description = "data model and serialization format"
license = "Unlicense"

View File

@ -493,7 +493,10 @@ proc typeDef(loc: Location; name: string; def: Definition; ty: PNode): PNode =
embeddingParams(loc.schema, isEmbedded(loc, def)),
ty)
of DefinitionKind.and:
raiseAssert "And variants not suported"
nn(nkTypeDef,
name.ident.toExport,
embeddingParams(loc.schema, isEmbedded(loc, def)),
preserveIdent(loc.schema))
of DefinitionKind.Pattern:
typeDef(loc, name, def.pattern, ty)
@ -675,7 +678,8 @@ proc nimTypeOf(loc: Location; known: var TypeTable; def: Definition; name: strin
case def.orKind
of DefinitionKind.or:
nimTypeOf(loc, known, def.or, name)
of DefinitionKind.and: raiseAssert """"And" definitions are unsupported"""
of DefinitionKind.and:
TypeSpec(node: preserveIdent(loc.schema))
of DefinitionKind.Pattern:
nimTypeOf(loc, known, def.pattern, name)