This commit is contained in:
Araq 2012-10-19 13:24:42 +02:00
commit b20663ce19
4 changed files with 24 additions and 3 deletions

View file

@ -1036,6 +1036,9 @@ proc genOf(p: BProc, x: PNode, typ: PType, d: var TLoc) =
while (t.kind == tyObject) and (t.sons[0] != nil):
app(r, ".Sup")
t = skipTypes(t.sons[0], typedescInst)
if isObjLackingTypeField(t):
GlobalError(x.info, errGenerated,
"no 'of' operator available for pure objects")
if nilCheck != nil:
r = ropecg(p.module, "(($1) && #isObj($2.m_type, $3))",
[nilCheck, r, genTypeInfo(p.module, dest)])
@ -1597,7 +1600,7 @@ proc upConv(p: BProc, n: PNode, d: var TLoc) =
var a: TLoc
initLocExpr(p, n.sons[0], a)
var dest = skipTypes(n.typ, abstractPtrs)
if optObjCheck in p.options and not isPureObject(dest):
if optObjCheck in p.options and not isObjLackingTypeField(dest):
var r = rdLoc(a)
var nilCheck: PRope = nil
var t = skipTypes(a.t, abstractInst)

View file

@ -694,11 +694,14 @@ when false:
var tmp = getNimType(m)
appf(m.s[cfsTypeInit2], "$2 = &$1;$n", [tmp, name])
proc isObjLackingTypeField(typ: PType): bool {.inline.} =
result = (typ.kind == tyObject) and ((tfFinal in typ.flags) and
(typ.sons[0] == nil) or isPureObject(typ))
proc genTypeInfoAuxBase(m: BModule, typ: PType, name, base: PRope) =
var nimtypeKind: int
#allocMemTI(m, typ, name)
if (typ.kind == tyObject) and (tfFinal in typ.flags) and
(typ.sons[0] == nil):
if isObjLackingTypeField(typ):
nimtypeKind = ord(tyPureObject)
else:
nimtypeKind = ord(typ.kind)