[other] make typeAllowed easier to debug by using structured programming
This commit is contained in:
parent
572b7c37a5
commit
549d8cc0c6
1 changed files with 33 additions and 26 deletions
|
|
@ -1204,13 +1204,16 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind,
|
||||||
# if we have already checked the type, return true, because we stop the
|
# if we have already checked the type, return true, because we stop the
|
||||||
# evaluation if something is wrong:
|
# evaluation if something is wrong:
|
||||||
result = nil
|
result = nil
|
||||||
if typ == nil: return
|
if typ == nil: return nil
|
||||||
if containsOrIncl(marker, typ.id): return
|
if containsOrIncl(marker, typ.id): return nil
|
||||||
var t = skipTypes(typ, abstractInst-{tyTypeDesc})
|
var t = skipTypes(typ, abstractInst-{tyTypeDesc})
|
||||||
case t.kind
|
case t.kind
|
||||||
of tyVar, tyLent:
|
of tyVar, tyLent:
|
||||||
if kind in {skProc, skFunc, skConst}: return t
|
if kind in {skProc, skFunc, skConst}:
|
||||||
elif t.kind == tyLent and kind != skResult: return t
|
result = t
|
||||||
|
elif t.kind == tyLent and kind != skResult:
|
||||||
|
result = t
|
||||||
|
else:
|
||||||
var t2 = skipTypes(t.sons[0], abstractInst-{tyTypeDesc})
|
var t2 = skipTypes(t.sons[0], abstractInst-{tyTypeDesc})
|
||||||
case t2.kind
|
case t2.kind
|
||||||
of tyVar, tyLent:
|
of tyVar, tyLent:
|
||||||
|
|
@ -1222,7 +1225,9 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind,
|
||||||
if kind notin {skParam, skResult}: result = t
|
if kind notin {skParam, skResult}: result = t
|
||||||
else: result = typeAllowedAux(marker, t2, kind, flags)
|
else: result = typeAllowedAux(marker, t2, kind, flags)
|
||||||
of tyProc:
|
of tyProc:
|
||||||
if kind == skConst and t.callConv == ccClosure: return t
|
if kind == skConst and t.callConv == ccClosure:
|
||||||
|
result = t
|
||||||
|
else:
|
||||||
for i in 1 ..< sonsLen(t):
|
for i in 1 ..< sonsLen(t):
|
||||||
result = typeAllowedAux(marker, t.sons[i], skParam, flags)
|
result = typeAllowedAux(marker, t.sons[i], skParam, flags)
|
||||||
if result != nil: break
|
if result != nil: break
|
||||||
|
|
@ -1287,7 +1292,9 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind,
|
||||||
if result != nil: break
|
if result != nil: break
|
||||||
of tyObject, tyTuple:
|
of tyObject, tyTuple:
|
||||||
if kind in {skProc, skFunc, skConst} and
|
if kind in {skProc, skFunc, skConst} and
|
||||||
t.kind == tyObject and t.sons[0] != nil: return t
|
t.kind == tyObject and t.sons[0] != nil:
|
||||||
|
result = t
|
||||||
|
else:
|
||||||
let flags = flags+{taField}
|
let flags = flags+{taField}
|
||||||
for i in 0 ..< sonsLen(t):
|
for i in 0 ..< sonsLen(t):
|
||||||
result = typeAllowedAux(marker, t.sons[i], kind, flags)
|
result = typeAllowedAux(marker, t.sons[i], kind, flags)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue