mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-07 04:14:19 +00:00
newruntime: progress
This commit is contained in:
@@ -731,8 +731,8 @@ proc injectDestructorCalls*(g: ModuleGraph; owner: PSym; n: PNode): PNode =
|
||||
if param.typ.kind == tySink and hasDestructor(param.typ.sons[0]):
|
||||
c.destroys.add genDestroy(c, param.typ.skipTypes({tyGenericInst, tyAlias, tySink}), params[i])
|
||||
|
||||
if optNimV2 in c.graph.config.globalOptions:
|
||||
injectDefaultCalls(n, c)
|
||||
#if optNimV2 in c.graph.config.globalOptions:
|
||||
# injectDefaultCalls(n, c)
|
||||
let body = p(n, c)
|
||||
result = newNodeI(nkStmtList, n.info)
|
||||
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):
|
||||
op = liftBody(c.graph, t, attachedDestructor, c.info)
|
||||
doAssert op != nil
|
||||
doAssert op == t.destructor
|
||||
|
||||
if op != nil:
|
||||
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,
|
||||
"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
|
||||
of attachedDestructor:
|
||||
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)
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
case c.kind
|
||||
@@ -369,7 +370,7 @@ proc liftBodyAux(c: var TLiftCtx; t: PType; body, x, y: PNode) =
|
||||
elif c.graph.config.selectedGC == gcDestructors:
|
||||
# note that tfHasAsgn is propagated so we need the check on
|
||||
# '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:
|
||||
if c.kind != attachedDestructor:
|
||||
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):
|
||||
strOp(c, t, body, x, y)
|
||||
elif tfHasAsgn in t.flags:
|
||||
discard considerOverloadedOp(c, t, body, x, y)
|
||||
discard considerUserDefinedOp(c, t, body, x, y)
|
||||
else:
|
||||
defaultOp(c, t, body, x, y)
|
||||
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)
|
||||
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)
|
||||
of tyTuple:
|
||||
liftBodyTup(c, t, body, x, y)
|
||||
@@ -533,6 +534,3 @@ proc liftTypeBoundOps*(g: ModuleGraph; typ: PType; info: TLineInfo) =
|
||||
liftBody(g, typ, attachedAsgn, info)
|
||||
if typ.sink == nil:
|
||||
liftBody(g, typ, attachedSink, info)
|
||||
|
||||
#proc patchResolvedTypeBoundOp*(g: ModuleGraph; n: PNode): PNode =
|
||||
# if n.kind == nkCall and
|
||||
|
||||
Reference in New Issue
Block a user