containerID is no longer needed for generics
This commit is contained in:
parent
a668b4ffb5
commit
0774af169b
6 changed files with 4 additions and 19 deletions
|
|
@ -675,7 +675,6 @@ type
|
||||||
size*: BiggestInt # the size of the type in bytes
|
size*: BiggestInt # the size of the type in bytes
|
||||||
# -1 means that the size is unkwown
|
# -1 means that the size is unkwown
|
||||||
align*: int # the type's alignment requirements
|
align*: int # the type's alignment requirements
|
||||||
containerID*: int # used for type checking of generics
|
|
||||||
loc*: TLoc
|
loc*: TLoc
|
||||||
|
|
||||||
TPair*{.final.} = object
|
TPair*{.final.} = object
|
||||||
|
|
@ -1012,7 +1011,6 @@ proc assignType(dest, src: PType) =
|
||||||
dest.n = src.n
|
dest.n = src.n
|
||||||
dest.size = src.size
|
dest.size = src.size
|
||||||
dest.align = src.align
|
dest.align = src.align
|
||||||
dest.containerID = src.containerID
|
|
||||||
dest.destructor = src.destructor
|
dest.destructor = src.destructor
|
||||||
# this fixes 'type TLock = TSysLock':
|
# this fixes 'type TLock = TSysLock':
|
||||||
if src.sym != nil:
|
if src.sym != nil:
|
||||||
|
|
|
||||||
|
|
@ -327,9 +327,6 @@ proc decodeType(r: PRodReader, info: TLineInfo): PType =
|
||||||
result.align = decodeVInt(r.s, r.pos)
|
result.align = decodeVInt(r.s, r.pos)
|
||||||
else:
|
else:
|
||||||
result.align = 2
|
result.align = 2
|
||||||
if r.s[r.pos] == '@':
|
|
||||||
inc(r.pos)
|
|
||||||
result.containerID = decodeVInt(r.s, r.pos)
|
|
||||||
decodeLoc(r, result.loc, info)
|
decodeLoc(r, result.loc, info)
|
||||||
while r.s[r.pos] == '^':
|
while r.s[r.pos] == '^':
|
||||||
inc(r.pos)
|
inc(r.pos)
|
||||||
|
|
|
||||||
|
|
@ -230,9 +230,6 @@ proc encodeType(w: PRodWriter, t: PType, result: var string) =
|
||||||
if t.align != 2:
|
if t.align != 2:
|
||||||
add(result, '=')
|
add(result, '=')
|
||||||
encodeVInt(t.align, result)
|
encodeVInt(t.align, result)
|
||||||
if t.containerID != 0:
|
|
||||||
add(result, '@')
|
|
||||||
encodeVInt(t.containerID, result)
|
|
||||||
encodeLoc(w, t.loc, result)
|
encodeLoc(w, t.loc, result)
|
||||||
for i in countup(0, sonsLen(t) - 1):
|
for i in countup(0, sonsLen(t) - 1):
|
||||||
if t.sons[i] == nil:
|
if t.sons[i] == nil:
|
||||||
|
|
|
||||||
|
|
@ -532,9 +532,6 @@ proc typeSectionRightSidePass(c: PContext, n: PNode) =
|
||||||
openScope(c.tab)
|
openScope(c.tab)
|
||||||
pushOwner(s)
|
pushOwner(s)
|
||||||
if s.magic == mNone: s.typ.kind = tyGenericBody
|
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
|
# XXX for generic type aliases this is not correct! We need the
|
||||||
# underlying Id really:
|
# underlying Id really:
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -769,9 +769,6 @@ proc semGeneric(c: PContext, n: PNode, s: PSym, prev: PType): PType =
|
||||||
return newOrPrevType(tyError, prev, c)
|
return newOrPrevType(tyError, prev, c)
|
||||||
elif s.typ.kind != tyGenericBody:
|
elif s.typ.kind != tyGenericBody:
|
||||||
isConcrete = false
|
isConcrete = false
|
||||||
elif s.typ.containerID == 0:
|
|
||||||
InternalError(n.info, "semtypes.semGeneric")
|
|
||||||
return newOrPrevType(tyError, prev, c)
|
|
||||||
elif sonsLen(n) != sonsLen(s.typ):
|
elif sonsLen(n) != sonsLen(s.typ):
|
||||||
LocalError(n.info, errWrongNumberOfArguments)
|
LocalError(n.info, errWrongNumberOfArguments)
|
||||||
return newOrPrevType(tyError, prev, c)
|
return newOrPrevType(tyError, prev, c)
|
||||||
|
|
|
||||||
|
|
@ -493,9 +493,8 @@ proc typeRel(c: var TCandidate, f, a: PType): TTypeRelation =
|
||||||
# simply no match for now:
|
# simply no match for now:
|
||||||
nil
|
nil
|
||||||
elif x.kind == tyGenericInst and
|
elif x.kind == tyGenericInst and
|
||||||
(f.sons[0].containerID == x.sons[0].containerID) and
|
(f.sons[0] == x.sons[0]) and
|
||||||
(sonsLen(x) - 1 == sonsLen(f)):
|
(sonsLen(x) - 1 == sonsLen(f)):
|
||||||
assert(x.sons[0].kind == tyGenericBody)
|
|
||||||
for i in countup(1, sonsLen(f) - 1):
|
for i in countup(1, sonsLen(f) - 1):
|
||||||
if x.sons[i].kind == tyGenericParam:
|
if x.sons[i].kind == tyGenericParam:
|
||||||
InternalError("wrong instantiated type!")
|
InternalError("wrong instantiated type!")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue