diff --git a/src/futhark.nim b/src/futhark.nim index c5516cd..64691da 100644 --- a/src/futhark.nim +++ b/src/futhark.nim @@ -20,10 +20,23 @@ const "shl", "shr", "static", "template", "try", "tuple", "type", "using", - "var", "void", + "var", "when", "while", "xor", "yield"] + # The following list is generated by running `jq '.entries[] | select (.type == "skType").name'` on the output of `nim jsondoc system.nim` + systemTypes = ["int", "int8", "int16", "int32", "int64", "uint", "uint8", + "uint16", "uint32", "uint64", "float", "float32", "float64", "char", + "string", "cstring", "pointer", "typedesc", "`ptr`", "`ref`", "void", + "auto", "any", "untyped", "typed", "bool", "SomeSignedInt", + "SomeUnsignedInt", "SomeInteger", "SomeFloat", "SomeNumber", "SomeOrdinal", + "`static`", "`type`", "TypeOfMode", "iterable", "Ordinal", "range", + "array", "openArray", "varargs", "seq", "set", "UncheckedArray", "sink", + "lent", "HSlice", "Slice", "byte", "Natural", "Positive", "RootObj", + "RootRef", "RootEffect", "StackTraceEntry", "Exception", "Defect", + "CatchableError", "JsRoot", "owned", "Endianness", "TaintedString", + "csize", "AllocStats", "GC_Strategy", "PFrame", "TFrame", "ForeignCell", + "Channel", "BackwardsIndex", "NimNode", "ForLoopStmt"] syspaths {.strdefine.} = "" nodeclguards = defined(nodeclguards) noopaquetypes = defined(noopaquetypes) @@ -204,11 +217,11 @@ proc sanitizeName(usedNames: var HashSet[string], origName: string, kind: string var normalizedName = result.nimIdentNormalize() renamed = false - if usedNames.contains(normalizedName) or result in builtins: + if usedNames.contains(normalizedName) or normalizedName in builtins or normalizedName in systemTypes: result.add "_" & kind normalizedName.add kind renamed = true - if usedNames.contains(normalizedName) or result in builtins: + if usedNames.contains(normalizedName) or normalizedName in builtins or normalizedName in systemTypes: let uniqueTail = hash(origName).uint32.toHex result.add "_" & uniqueTail normalizedName.add uniqueTail @@ -294,7 +307,7 @@ proc addEntity(state: var State, name: string, entity: JsonNode) = state.opaqueTypes.excl name proc addOpaque(state: var State, opaque: string) = - if not state.entities.hasKey(opaque) and opaque notin builtins: + if not state.entities.hasKey(opaque) and opaque notin builtins and opaque notin systemTypes: state.opaqueTypes.incl opaque proc toNimType(json: JsonNode, state: var State): NimNode =