the is operator now uses exactly the same algorithm as proc signature matching
This commit is contained in:
parent
3f71b7f1f6
commit
5a6030a16b
3 changed files with 11 additions and 22 deletions
|
|
@ -322,24 +322,13 @@ proc isOpImpl(c: PContext, n: PNode): PNode =
|
||||||
t.callConv == ccClosure and
|
t.callConv == ccClosure and
|
||||||
tfIterator in t.flags))
|
tfIterator in t.flags))
|
||||||
else:
|
else:
|
||||||
var match: bool
|
var t2 = n[2].typ.skipTypes({tyTypeDesc})
|
||||||
let t2 = n[2].typ.skipTypes({tyTypeDesc})
|
let lifted = liftParamType(c, skType, newNodeI(nkArgList, n.info),
|
||||||
case t2.kind
|
t2, ":anon", n.info)
|
||||||
of tyTypeClasses:
|
if lifted != nil: t2 = lifted
|
||||||
var m: TCandidate
|
var m: TCandidate
|
||||||
initCandidate(c, m, t2)
|
initCandidate(c, m, t2)
|
||||||
match = typeRel(m, t2, t1) != isNone
|
let match = typeRel(m, t2, t1) != isNone
|
||||||
of tyOrdinal:
|
|
||||||
var m: TCandidate
|
|
||||||
initCandidate(c, m, t2)
|
|
||||||
match = isOrdinalType(t1)
|
|
||||||
of tySequence, tyArray, tySet:
|
|
||||||
var m: TCandidate
|
|
||||||
initCandidate(c, m, t2)
|
|
||||||
match = typeRel(m, t2, t1) != isNone
|
|
||||||
else:
|
|
||||||
match = sameType(t1, t2)
|
|
||||||
|
|
||||||
result = newIntNode(nkIntLit, ord(match))
|
result = newIntNode(nkIntLit, ord(match))
|
||||||
|
|
||||||
result.typ = n.typ
|
result.typ = n.typ
|
||||||
|
|
|
||||||
|
|
@ -820,7 +820,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
|
||||||
else:
|
else:
|
||||||
return isNone
|
return isNone
|
||||||
|
|
||||||
of tyUserTypeClassInst:
|
of tyUserTypeClass, tyUserTypeClassInst:
|
||||||
considerPreviousT:
|
considerPreviousT:
|
||||||
result = matchUserTypeClass(c.c, c, f, a)
|
result = matchUserTypeClass(c.c, c, f, a)
|
||||||
if result == isGeneric:
|
if result == isGeneric:
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,7 @@ when defined(Posix):
|
||||||
of AF_UNIX: result = posix.AF_UNIX
|
of AF_UNIX: result = posix.AF_UNIX
|
||||||
of AF_INET: result = posix.AF_INET
|
of AF_INET: result = posix.AF_INET
|
||||||
of AF_INET6: result = posix.AF_INET6
|
of AF_INET6: result = posix.AF_INET6
|
||||||
else: nil
|
else: discard
|
||||||
|
|
||||||
proc toInt(typ: TType): cint =
|
proc toInt(typ: TType): cint =
|
||||||
case typ
|
case typ
|
||||||
|
|
@ -200,7 +200,7 @@ when defined(Posix):
|
||||||
of SOCK_DGRAM: result = posix.SOCK_DGRAM
|
of SOCK_DGRAM: result = posix.SOCK_DGRAM
|
||||||
of SOCK_SEQPACKET: result = posix.SOCK_SEQPACKET
|
of SOCK_SEQPACKET: result = posix.SOCK_SEQPACKET
|
||||||
of SOCK_RAW: result = posix.SOCK_RAW
|
of SOCK_RAW: result = posix.SOCK_RAW
|
||||||
else: nil
|
else: discard
|
||||||
|
|
||||||
proc toInt(p: TProtocol): cint =
|
proc toInt(p: TProtocol): cint =
|
||||||
case p
|
case p
|
||||||
|
|
@ -210,7 +210,7 @@ when defined(Posix):
|
||||||
of IPPROTO_IPV6: result = posix.IPPROTO_IPV6
|
of IPPROTO_IPV6: result = posix.IPPROTO_IPV6
|
||||||
of IPPROTO_RAW: result = posix.IPPROTO_RAW
|
of IPPROTO_RAW: result = posix.IPPROTO_RAW
|
||||||
of IPPROTO_ICMP: result = posix.IPPROTO_ICMP
|
of IPPROTO_ICMP: result = posix.IPPROTO_ICMP
|
||||||
else: nil
|
else: discard
|
||||||
|
|
||||||
else:
|
else:
|
||||||
proc toInt(domain: TDomain): cint =
|
proc toInt(domain: TDomain): cint =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue