containerID is no longer needed for generics

This commit is contained in:
Zahary Karadjov
2013-03-01 12:12:53 +02:00
parent a668b4ffb5
commit 0774af169b
6 changed files with 4 additions and 19 deletions

View File

@@ -675,7 +675,6 @@ type
size*: BiggestInt # the size of the type in bytes
# -1 means that the size is unkwown
align*: int # the type's alignment requirements
containerID*: int # used for type checking of generics
loc*: TLoc
TPair*{.final.} = object
@@ -1012,7 +1011,6 @@ proc assignType(dest, src: PType) =
dest.n = src.n
dest.size = src.size
dest.align = src.align
dest.containerID = src.containerID
dest.destructor = src.destructor
# this fixes 'type TLock = TSysLock':
if src.sym != nil:

View File

@@ -327,9 +327,6 @@ proc decodeType(r: PRodReader, info: TLineInfo): PType =
result.align = decodeVInt(r.s, r.pos)
else:
result.align = 2
if r.s[r.pos] == '@':
inc(r.pos)
result.containerID = decodeVInt(r.s, r.pos)
decodeLoc(r, result.loc, info)
while r.s[r.pos] == '^':
inc(r.pos)

View File

@@ -230,9 +230,6 @@ proc encodeType(w: PRodWriter, t: PType, result: var string) =
if t.align != 2:
add(result, '=')
encodeVInt(t.align, result)
if t.containerID != 0:
add(result, '@')
encodeVInt(t.containerID, result)
encodeLoc(w, t.loc, result)
for i in countup(0, sonsLen(t) - 1):
if t.sons[i] == nil:

View File

@@ -532,9 +532,6 @@ proc typeSectionRightSidePass(c: PContext, n: PNode) =
openScope(c.tab)
pushOwner(s)
if s.magic == mNone: s.typ.kind = tyGenericBody
if s.typ.containerID != 0:
InternalError(a.info, "semTypeSection: containerID")
s.typ.containerID = s.typ.id
# XXX for generic type aliases this is not correct! We need the
# underlying Id really:
#

View File

@@ -769,9 +769,6 @@ proc semGeneric(c: PContext, n: PNode, s: PSym, prev: PType): PType =
return newOrPrevType(tyError, prev, c)
elif s.typ.kind != tyGenericBody:
isConcrete = false
elif s.typ.containerID == 0:
InternalError(n.info, "semtypes.semGeneric")
return newOrPrevType(tyError, prev, c)
elif sonsLen(n) != sonsLen(s.typ):
LocalError(n.info, errWrongNumberOfArguments)
return newOrPrevType(tyError, prev, c)

View File

@@ -493,11 +493,10 @@ proc typeRel(c: var TCandidate, f, a: PType): TTypeRelation =
# simply no match for now:
nil
elif x.kind == tyGenericInst and
(f.sons[0].containerID == x.sons[0].containerID) and
(sonsLen(x) - 1 == sonsLen(f)):
assert(x.sons[0].kind == tyGenericBody)
for i in countup(1, sonsLen(f) - 1):
if x.sons[i].kind == tyGenericParam:
(f.sons[0] == x.sons[0]) and
(sonsLen(x) - 1 == sonsLen(f)):
for i in countup(1, sonsLen(f) - 1):
if x.sons[i].kind == tyGenericParam:
InternalError("wrong instantiated type!")
elif typeRel(c, f.sons[i], x.sons[i]) <= isSubtype: return
result = isGeneric