diff options
author | Zahary Karadjov <zahary@gmail.com> | 2017-06-10 17:39:34 +0300 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-06-20 11:29:42 +0200 |
commit | dea6d8dd94e474012ad6595f20ece11ea77ee260 (patch) | |
tree | bc27e901c5ba226d8185d712b213ae54e2508350 | |
parent | 268b918150212d89c61bd16f3444f45cf4327181 (diff) | |
download | Nim-dea6d8dd94e474012ad6595f20ece11ea77ee260.tar.gz |
add a useful helper for debugging typeRel problems
-rw-r--r-- | compiler/sigmatch.nim | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 5280c27a1..6a1352508 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -302,8 +302,30 @@ proc describeArgs*(c: PContext, n: PNode, startIdx = 1; add(result, argTypeToString(arg, prefer)) if i != sonsLen(n) - 1: add(result, ", ") -proc typeRel*(c: var TCandidate, f, aOrig: PType, - flags: TTypeRelFlags = {}): TTypeRelation +proc typeRelImpl*(c: var TCandidate, f, aOrig: PType, + flags: TTypeRelFlags = {}): TTypeRelation + +var nextTypeRel = 0 + +template typeRel*(c: var TCandidate, f, aOrig: PType, + flags: TTypeRelFlags = {}): TTypeRelation = + const traceTypeRel = false + + when traceTypeRel: + var enteringAt = nextTypeRel + if mdbg: + inc nextTypeRel + echo "----- TYPE REL ", enteringAt + debug f + debug aOrig + + let r = typeRelImpl(c, f, aOrig, flags) + + when traceTypeRel: + if enteringAt != nextTypeRel: + echo "----- TYPE REL ", enteringAt, " RESULT: ", r + + r proc concreteType(c: TCandidate, t: PType): PType = case t.kind @@ -871,8 +893,8 @@ proc isCovariantPtr(c: var TCandidate, f, a: PType): bool = else: return false -proc typeRel(c: var TCandidate, f, aOrig: PType, - flags: TTypeRelFlags = {}): TTypeRelation = +proc typeRelImpl(c: var TCandidate, f, aOrig: PType, + flags: TTypeRelFlags = {}): TTypeRelation = # typeRel can be used to establish various relationships between types: # # 1) When used with concrete types, it will check for type equivalence |