Use set[T] rather than HashSet[T] for enum sets

This commit is contained in:
Emery Hemingway 2022-07-09 08:08:52 -05:00
parent 895a8695d2
commit 8c0af37694
2 changed files with 12 additions and 2 deletions

View File

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

View File

@ -266,6 +266,12 @@ proc isSymbolEnum(scm: Schema; def: Definition): bool =
result = isSymbolEnum(scm, def.or)
else: discard
proc isSymbolEnum(scm: Schema; sp: SimplePattern): bool =
# HashSet
if sp.orKind == SimplepatternKind.`Ref` and sp.ref.module.len == 0:
result = isSymbolEnum(scm, deref(scm, sp.ref))
else: discard
proc isAny(scm: Schema; def: Definition): bool =
if def.orKind == DefinitionKind.Pattern:
if def.pattern.orKind == PatternKind.SimplePattern:
@ -295,7 +301,11 @@ proc typeIdent(scm: Schema; sp: SimplePattern): TypeSpec =
result.node = nn(nkBracketExpr, ident"seq", result.node)
of SimplepatternKind.`setof`:
result = typeIdent(scm, sp.setof.pattern)
result.node = nn(nkBracketExpr, ident"HashSet", result.node)
result.node =
if isSymbolEnum(scm, sp.setof.pattern):
nn(nkBracketExpr, ident"set", result.node)
else:
nn(nkBracketExpr, ident"HashSet", result.node)
of SimplepatternKind.`dictof`:
let
key = typeIdent(scm, sp.dictof.key)