cycle breaker (#13593)
* cycle breaking as an alternative to cycle detection
This commit is contained in:
parent
705e283fef
commit
35fb38629f
10 changed files with 298 additions and 41 deletions
|
|
@ -1606,10 +1606,33 @@ proc genRepr(p: BProc, e: PNode, d: var TLoc) =
|
|||
a.storage)
|
||||
gcUsage(p.config, e)
|
||||
|
||||
proc rdMType(p: BProc; a: TLoc; nilCheck: var Rope): Rope =
|
||||
result = rdLoc(a)
|
||||
var t = skipTypes(a.t, abstractInst)
|
||||
while t.kind in {tyVar, tyLent, tyPtr, tyRef}:
|
||||
if t.kind notin {tyVar, tyLent}: nilCheck = result
|
||||
if t.kind notin {tyVar, tyLent} or not p.module.compileToCpp:
|
||||
result = "(*$1)" % [result]
|
||||
t = skipTypes(t.lastSon, abstractInst)
|
||||
discard getTypeDesc(p.module, t)
|
||||
if not p.module.compileToCpp:
|
||||
while t.kind == tyObject and t[0] != nil:
|
||||
result.add(".Sup")
|
||||
t = skipTypes(t[0], skipPtrs)
|
||||
result.add ".m_type"
|
||||
|
||||
proc genGetTypeInfo(p: BProc, e: PNode, d: var TLoc) =
|
||||
discard cgsym(p.module, "TNimType")
|
||||
let t = e[1].typ
|
||||
putIntoDest(p, d, e, genTypeInfo(p.module, t, e.info))
|
||||
if isFinal(t) or e[0].sym.name.s != "getDynamicTypeInfo":
|
||||
# ordinary static type information
|
||||
putIntoDest(p, d, e, genTypeInfo(p.module, t, e.info))
|
||||
else:
|
||||
var a: TLoc
|
||||
initLocExpr(p, e[1], a)
|
||||
var nilCheck = Rope(nil)
|
||||
# use the dynamic type stored at offset 0:
|
||||
putIntoDest(p, d, e, rdMType(p, a, nilCheck))
|
||||
|
||||
template genDollar(p: BProc, n: PNode, d: var TLoc, frmt: string) =
|
||||
var a: TLoc
|
||||
|
|
@ -2113,21 +2136,6 @@ proc genEnumToStr(p: BProc, e: PNode, d: var TLoc) =
|
|||
n[0] = newSymNode(toStrProc)
|
||||
expr(p, n, d)
|
||||
|
||||
proc rdMType(p: BProc; a: TLoc; nilCheck: var Rope): Rope =
|
||||
result = rdLoc(a)
|
||||
var t = skipTypes(a.t, abstractInst)
|
||||
while t.kind in {tyVar, tyLent, tyPtr, tyRef}:
|
||||
if t.kind notin {tyVar, tyLent}: nilCheck = result
|
||||
if t.kind notin {tyVar, tyLent} or not p.module.compileToCpp:
|
||||
result = "(*$1)" % [result]
|
||||
t = skipTypes(t.lastSon, abstractInst)
|
||||
discard getTypeDesc(p.module, t)
|
||||
if not p.module.compileToCpp:
|
||||
while t.kind == tyObject and t[0] != nil:
|
||||
result.add(".Sup")
|
||||
t = skipTypes(t[0], skipPtrs)
|
||||
result.add ".m_type"
|
||||
|
||||
proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
|
||||
case op
|
||||
of mOr, mAnd: genAndOr(p, e, d, op)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue