made compiler more robust for idetools; implemented idetools.usages
This commit is contained in:
parent
b0c11d3efb
commit
674c05f426
11 changed files with 96 additions and 47 deletions
|
|
@ -228,24 +228,25 @@ proc minRel(a, b: TTypeRelation): TTypeRelation =
|
|||
if a <= b: result = a
|
||||
else: result = b
|
||||
|
||||
proc tupleRel(c: var TCandidate, f, a: PType): TTypeRelation =
|
||||
proc tupleRel(c: var TCandidate, f, a: PType): TTypeRelation =
|
||||
result = isNone
|
||||
if sameType(f, a):
|
||||
result = isEqual
|
||||
elif sonsLen(a) == sonsLen(f):
|
||||
elif sonsLen(a) == sonsLen(f):
|
||||
result = isEqual
|
||||
for i in countup(0, sonsLen(f) - 1):
|
||||
for i in countup(0, sonsLen(f) - 1):
|
||||
var m = typeRel(c, f.sons[i], a.sons[i])
|
||||
if m < isSubtype: return isNone
|
||||
result = minRel(result, m)
|
||||
if f.n != nil and a.n != nil:
|
||||
for i in countup(0, sonsLen(f.n) - 1):
|
||||
if f.n != nil and a.n != nil:
|
||||
for i in countup(0, sonsLen(f.n) - 1):
|
||||
# check field names:
|
||||
if f.n.sons[i].kind != nkSym: InternalError(f.n.info, "tupleRel")
|
||||
if a.n.sons[i].kind != nkSym: InternalError(a.n.info, "tupleRel")
|
||||
var x = f.n.sons[i].sym
|
||||
var y = a.n.sons[i].sym
|
||||
if x.name.id != y.name.id: return isNone
|
||||
elif a.n.sons[i].kind != nkSym: InternalError(a.n.info, "tupleRel")
|
||||
else:
|
||||
var x = f.n.sons[i].sym
|
||||
var y = a.n.sons[i].sym
|
||||
if x.name.id != y.name.id: return isNone
|
||||
|
||||
proc matchTypeClass(c: var TCandidate, f, a: PType): TTypeRelation =
|
||||
for i in countup(0, f.sonsLen - 1):
|
||||
|
|
@ -501,7 +502,7 @@ proc typeRel(c: var TCandidate, f, a: PType): TTypeRelation =
|
|||
for i in countup(1, sonsLen(f) - 1):
|
||||
if a.sons[i].kind == tyGenericParam:
|
||||
InternalError("wrong instantiated type!")
|
||||
if typeRel(c, f.sons[i], a.sons[i]) <= isSubtype: return
|
||||
elif typeRel(c, f.sons[i], a.sons[i]) <= isSubtype: return
|
||||
result = isGeneric
|
||||
else:
|
||||
result = typeRel(c, f.sons[0], a)
|
||||
|
|
@ -539,7 +540,7 @@ proc typeRel(c: var TCandidate, f, a: PType): TTypeRelation =
|
|||
result = isNone
|
||||
of tyExpr, tyStmt:
|
||||
result = isGeneric
|
||||
else: internalError("typeRel(" & $f.kind & ')')
|
||||
else: internalError("typeRel: " & $f.kind)
|
||||
|
||||
proc cmpTypes*(f, a: PType): TTypeRelation =
|
||||
var c: TCandidate
|
||||
|
|
@ -551,7 +552,9 @@ proc getInstantiatedType(c: PContext, arg: PNode, m: TCandidate,
|
|||
result = PType(idTableGet(m.bindings, f))
|
||||
if result == nil:
|
||||
result = generateTypeInstance(c, m.bindings, arg, f)
|
||||
if result == nil: InternalError(arg.info, "getInstantiatedType")
|
||||
if result == nil:
|
||||
InternalError(arg.info, "getInstantiatedType")
|
||||
result = errorType(c)
|
||||
|
||||
proc implicitConv(kind: TNodeKind, f: PType, arg: PNode, m: TCandidate,
|
||||
c: PContext): PNode =
|
||||
|
|
@ -794,6 +797,7 @@ proc matchesAux*(c: PContext, n, nOrig: PNode,
|
|||
else:
|
||||
if m.callee.n.sons[f].kind != nkSym:
|
||||
InternalError(n.sons[a].info, "matches")
|
||||
return
|
||||
formal = m.callee.n.sons[f].sym
|
||||
if ContainsOrIncl(marker, formal.position):
|
||||
# already in namedParams:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue