Tidy up isOrdinalType

This commit is contained in:
Matthew Baulch
2016-08-11 21:09:34 +10:00
parent e56da28bcf
commit 623e0763c2

View File

@@ -148,10 +148,11 @@ proc skipGeneric(t: PType): PType =
proc isOrdinalType(t: PType): bool =
assert(t != nil)
# caution: uint, uint64 are no ordinal types!
result = t.kind in {tyChar,tyInt..tyInt64,tyUInt8..tyUInt32,tyBool,tyEnum} or
(t.kind in {tyRange, tyOrdinal, tyConst, tyMutable, tyGenericInst}) and
isOrdinalType(t.sons[0])
const
# caution: uint, uint64 are no ordinal types!
baseKinds = {tyChar,tyInt..tyInt64,tyUInt8..tyUInt32,tyBool,tyEnum}
parentKinds = {tyRange, tyOrdinal, tyConst, tyMutable, tyGenericInst}
t.kind in baseKinds or (t.kind in parentKinds and isOrdinalType(t.sons[0]))
proc enumHasHoles(t: PType): bool =
var b = t