a better bugfix
This commit is contained in:
parent
767bd57289
commit
6152eb3be3
2 changed files with 36 additions and 33 deletions
|
|
@ -2876,19 +2876,20 @@ proc genBracedInit(p: BProc, n: PNode; isConst: bool): Rope =
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkHiddenStdConv, nkHiddenSubConv:
|
of nkHiddenStdConv, nkHiddenSubConv:
|
||||||
result = genBracedInit(p, n[1], isConst)
|
result = genBracedInit(p, n[1], isConst)
|
||||||
of nkCurly:
|
else:
|
||||||
|
var t = skipTypes(n.typ, abstractInstOwned)
|
||||||
|
case t.kind
|
||||||
|
of tySet:
|
||||||
var cs: TBitSet
|
var cs: TBitSet
|
||||||
toBitSet(p.config, n, cs)
|
toBitSet(p.config, n, cs)
|
||||||
result = genRawSetData(cs, int(getSize(p.config, n.typ)))
|
result = genRawSetData(cs, int(getSize(p.config, n.typ)))
|
||||||
of nkBracket, nkPar, nkTupleConstr, nkClosure:
|
of tySequence:
|
||||||
var t = skipTypes(n.typ, abstractInstOwned)
|
|
||||||
if t.kind == tySequence:
|
|
||||||
if optSeqDestructors in p.config.globalOptions:
|
if optSeqDestructors in p.config.globalOptions:
|
||||||
result = genConstSeqV2(p, n, n.typ, isConst)
|
result = genConstSeqV2(p, n, n.typ, isConst)
|
||||||
else:
|
else:
|
||||||
result = genConstSeq(p, n, n.typ, isConst)
|
result = genConstSeq(p, n, n.typ, isConst)
|
||||||
elif t.kind == tyProc and t.callConv == ccClosure and n.len > 1 and
|
of tyProc:
|
||||||
n[1].kind == nkNilLit:
|
if t.callConv == ccClosure and n.len > 1 and n[1].kind == nkNilLit:
|
||||||
# Conversion: nimcall -> closure.
|
# Conversion: nimcall -> closure.
|
||||||
# this hack fixes issue that nkNilLit is expanded to {NIM_NIL,NIM_NIL}
|
# this hack fixes issue that nkNilLit is expanded to {NIM_NIL,NIM_NIL}
|
||||||
# this behaviour is needed since closure_var = nil must be
|
# this behaviour is needed since closure_var = nil must be
|
||||||
|
|
@ -2903,11 +2904,13 @@ proc genBracedInit(p: BProc, n: PNode; isConst: bool): Rope =
|
||||||
initLocExpr(p, n[0], d)
|
initLocExpr(p, n[0], d)
|
||||||
result = "{(($1) $2),NIM_NIL}" % [getClosureType(p.module, t, clHalfWithEnv), rdLoc(d)]
|
result = "{(($1) $2),NIM_NIL}" % [getClosureType(p.module, t, clHalfWithEnv), rdLoc(d)]
|
||||||
else:
|
else:
|
||||||
|
result = ~"NIM_NIL"
|
||||||
|
of tyArray, tyTuple, tyOpenArray, tyVarargs:
|
||||||
result = genConstSimpleList(p, n, isConst)
|
result = genConstSimpleList(p, n, isConst)
|
||||||
of nkObjConstr:
|
of tyObject:
|
||||||
result = genConstObjConstr(p, n, isConst)
|
result = genConstObjConstr(p, n, isConst)
|
||||||
of nkStrLit..nkTripleStrLit:
|
of tyString, tyCString:
|
||||||
if optSeqDestructors in p.config.globalOptions:
|
if optSeqDestructors in p.config.globalOptions and n.kind != nkNilLit:
|
||||||
result = genStringLiteralV2Const(p.module, n, isConst)
|
result = genStringLiteralV2Const(p.module, n, isConst)
|
||||||
else:
|
else:
|
||||||
var d: TLoc
|
var d: TLoc
|
||||||
|
|
|
||||||
|
|
@ -362,13 +362,13 @@ proc genObjectInit(p: BProc, section: TCProcSection, t: PType, a: var TLoc,
|
||||||
linefmt(p, section, "$1.m_type = $2;$n", [r, genTypeInfo(p.module, t, a.lode.info)])
|
linefmt(p, section, "$1.m_type = $2;$n", [r, genTypeInfo(p.module, t, a.lode.info)])
|
||||||
of frEmbedded:
|
of frEmbedded:
|
||||||
if optTinyRtti in p.config.globalOptions:
|
if optTinyRtti in p.config.globalOptions:
|
||||||
|
if mode == constructRefObj:
|
||||||
var n = newNodeIT(nkObjConstr, a.lode.info, t)
|
var n = newNodeIT(nkObjConstr, a.lode.info, t)
|
||||||
n.add newNodeIT(nkType, a.lode.info, t)
|
n.add newNodeIT(nkType, a.lode.info, t)
|
||||||
if mode == constructRefObj:
|
|
||||||
genObjConstr(p, n, a)
|
genObjConstr(p, n, a)
|
||||||
else:
|
else:
|
||||||
var tmp: TLoc
|
var tmp: TLoc
|
||||||
rawConstExpr(p, n, tmp)
|
rawConstExpr(p, newNodeIT(nkType, a.lode.info, t), tmp)
|
||||||
genAssignment(p, a, tmp, {})
|
genAssignment(p, a, tmp, {})
|
||||||
else:
|
else:
|
||||||
# worst case for performance:
|
# worst case for performance:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue