newruntime: progress
This commit is contained in:
parent
8e5c1436ad
commit
ed878014be
2 changed files with 10 additions and 12 deletions
|
|
@ -731,8 +731,8 @@ proc injectDestructorCalls*(g: ModuleGraph; owner: PSym; n: PNode): PNode =
|
||||||
if param.typ.kind == tySink and hasDestructor(param.typ.sons[0]):
|
if param.typ.kind == tySink and hasDestructor(param.typ.sons[0]):
|
||||||
c.destroys.add genDestroy(c, param.typ.skipTypes({tyGenericInst, tyAlias, tySink}), params[i])
|
c.destroys.add genDestroy(c, param.typ.skipTypes({tyGenericInst, tyAlias, tySink}), params[i])
|
||||||
|
|
||||||
if optNimV2 in c.graph.config.globalOptions:
|
#if optNimV2 in c.graph.config.globalOptions:
|
||||||
injectDefaultCalls(n, c)
|
# injectDefaultCalls(n, c)
|
||||||
let body = p(n, c)
|
let body = p(n, c)
|
||||||
result = newNodeI(nkStmtList, n.info)
|
result = newNodeI(nkStmtList, n.info)
|
||||||
if c.topLevelVars.len > 0:
|
if c.topLevelVars.len > 0:
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,7 @@ proc addDestructorCall(c: var TLiftCtx; t: PType; body, x: PNode): bool =
|
||||||
if op == nil and useNoGc(c, t):
|
if op == nil and useNoGc(c, t):
|
||||||
op = liftBody(c.graph, t, attachedDestructor, c.info)
|
op = liftBody(c.graph, t, attachedDestructor, c.info)
|
||||||
doAssert op != nil
|
doAssert op != nil
|
||||||
|
doAssert op == t.destructor
|
||||||
|
|
||||||
if op != nil:
|
if op != nil:
|
||||||
markUsed(c.graph.config, c.info, op, c.graph.usageSym)
|
markUsed(c.graph.config, c.info, op, c.graph.usageSym)
|
||||||
|
|
@ -155,7 +156,7 @@ proc addDestructorCall(c: var TLiftCtx; t: PType; body, x: PNode): bool =
|
||||||
internalError(c.graph.config, c.info,
|
internalError(c.graph.config, c.info,
|
||||||
"type-bound operator could not be resolved")
|
"type-bound operator could not be resolved")
|
||||||
|
|
||||||
proc considerOverloadedOp(c: var TLiftCtx; t: PType; body, x, y: PNode): bool =
|
proc considerUserDefinedOp(c: var TLiftCtx; t: PType; body, x, y: PNode): bool =
|
||||||
case c.kind
|
case c.kind
|
||||||
of attachedDestructor:
|
of attachedDestructor:
|
||||||
result = addDestructorCall(c, t, body, x)
|
result = addDestructorCall(c, t, body, x)
|
||||||
|
|
@ -297,10 +298,10 @@ proc ownedRefOp(c: var TLiftCtx; t: PType; body, x, y: PNode) =
|
||||||
#var disposeCall = genBuiltin(c.graph, mDispose, "dispose", x)
|
#var disposeCall = genBuiltin(c.graph, mDispose, "dispose", x)
|
||||||
|
|
||||||
if isFinal(elemType):
|
if isFinal(elemType):
|
||||||
discard addDestructorCall(c, elemType, actions, x)
|
discard addDestructorCall(c, elemType, actions, genDeref(x))
|
||||||
actions.add callCodegenProc(c.graph, "nimRawDispose", c.info, x)
|
actions.add callCodegenProc(c.graph, "nimRawDispose", c.info, x)
|
||||||
else:
|
else:
|
||||||
discard addDestructorCall(c, elemType, newNodeI(nkStmtList, c.info), x)
|
discard addDestructorCall(c, elemType, newNodeI(nkStmtList, c.info), genDeref(x))
|
||||||
actions.add callCodegenProc(c.graph, "nimDestroyAndDispose", c.info, x)
|
actions.add callCodegenProc(c.graph, "nimDestroyAndDispose", c.info, x)
|
||||||
|
|
||||||
case c.kind
|
case c.kind
|
||||||
|
|
@ -369,7 +370,7 @@ proc liftBodyAux(c: var TLiftCtx; t: PType; body, x, y: PNode) =
|
||||||
elif c.graph.config.selectedGC == gcDestructors:
|
elif c.graph.config.selectedGC == gcDestructors:
|
||||||
# note that tfHasAsgn is propagated so we need the check on
|
# note that tfHasAsgn is propagated so we need the check on
|
||||||
# 'selectedGC' here to determine if we have the new runtime.
|
# 'selectedGC' here to determine if we have the new runtime.
|
||||||
discard considerOverloadedOp(c, t, body, x, y)
|
discard considerUserDefinedOp(c, t, body, x, y)
|
||||||
elif tfHasAsgn in t.flags:
|
elif tfHasAsgn in t.flags:
|
||||||
if c.kind != attachedDestructor:
|
if c.kind != attachedDestructor:
|
||||||
body.add newSeqCall(c.graph, x, y)
|
body.add newSeqCall(c.graph, x, y)
|
||||||
|
|
@ -380,14 +381,14 @@ proc liftBodyAux(c: var TLiftCtx; t: PType; body, x, y: PNode) =
|
||||||
if useNoGc(c, t):
|
if useNoGc(c, t):
|
||||||
strOp(c, t, body, x, y)
|
strOp(c, t, body, x, y)
|
||||||
elif tfHasAsgn in t.flags:
|
elif tfHasAsgn in t.flags:
|
||||||
discard considerOverloadedOp(c, t, body, x, y)
|
discard considerUserDefinedOp(c, t, body, x, y)
|
||||||
else:
|
else:
|
||||||
defaultOp(c, t, body, x, y)
|
defaultOp(c, t, body, x, y)
|
||||||
of tyObject:
|
of tyObject:
|
||||||
if not considerOverloadedOp(c, t, body, x, y):
|
if not considerUserDefinedOp(c, t, body, x, y):
|
||||||
liftBodyObj(c, t.n, body, x, y)
|
liftBodyObj(c, t.n, body, x, y)
|
||||||
of tyDistinct:
|
of tyDistinct:
|
||||||
if not considerOverloadedOp(c, t, body, x, y):
|
if not considerUserDefinedOp(c, t, body, x, y):
|
||||||
liftBodyAux(c, t.sons[0].skipTypes(skipPtrs), body, x, y)
|
liftBodyAux(c, t.sons[0].skipTypes(skipPtrs), body, x, y)
|
||||||
of tyTuple:
|
of tyTuple:
|
||||||
liftBodyTup(c, t, body, x, y)
|
liftBodyTup(c, t, body, x, y)
|
||||||
|
|
@ -533,6 +534,3 @@ proc liftTypeBoundOps*(g: ModuleGraph; typ: PType; info: TLineInfo) =
|
||||||
liftBody(g, typ, attachedAsgn, info)
|
liftBody(g, typ, attachedAsgn, info)
|
||||||
if typ.sink == nil:
|
if typ.sink == nil:
|
||||||
liftBody(g, typ, attachedSink, info)
|
liftBody(g, typ, attachedSink, info)
|
||||||
|
|
||||||
#proc patchResolvedTypeBoundOp*(g: ModuleGraph; n: PNode): PNode =
|
|
||||||
# if n.kind == nkCall and
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue