gc:destructors: progress
This commit is contained in:
parent
9563be37d3
commit
728ff1004a
6 changed files with 85 additions and 2 deletions
|
|
@ -306,7 +306,9 @@ proc instantiateProcType(c: PContext, pt: TIdTable,
|
|||
|
||||
resetIdTable(cl.symMap)
|
||||
resetIdTable(cl.localCache)
|
||||
cl.isReturnType = true
|
||||
result.sons[0] = replaceTypeVarsT(cl, result.sons[0])
|
||||
cl.isReturnType = false
|
||||
result.n.sons[0] = originalParams[0].copyTree
|
||||
if result.sons[0] != nil:
|
||||
propagateToOwner(result, result.sons[0])
|
||||
|
|
|
|||
|
|
@ -481,6 +481,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
|
|||
if typ == nil: continue
|
||||
typeAllowedCheck(c.config, a.info, typ, symkind, if c.matchedConcept != nil: {taConcept} else: {})
|
||||
liftTypeBoundOps(c.graph, typ, a.info)
|
||||
instAllTypeBoundOp(c, a.info)
|
||||
var tup = skipTypes(typ, {tyGenericInst, tyAlias, tySink})
|
||||
if a.kind == nkVarTuple:
|
||||
if tup.kind != tyTuple:
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ type
|
|||
allowMetaTypes*: bool # allow types such as seq[Number]
|
||||
# i.e. the result contains unresolved generics
|
||||
skipTypedesc*: bool # wether we should skip typeDescs
|
||||
isReturnType*: bool
|
||||
owner*: PSym # where this instantiation comes from
|
||||
recursionLimit: int
|
||||
|
||||
|
|
@ -594,6 +595,21 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
|
|||
eraseVoidParams(result)
|
||||
skipIntLiteralParams(result)
|
||||
|
||||
of tySequence:
|
||||
if cl.isReturnType and cl.c.config.selectedGc == gcDestructors and result.destructor.isNil and
|
||||
result[0].kind != tyEmpty:
|
||||
let s = cl.c.graph.sysTypes[tySequence]
|
||||
var old = copyType(s, s.owner, keepId=false)
|
||||
# Remove the 'T' parameter from tySequence:
|
||||
old.sons.setLen 0
|
||||
old.n = nil
|
||||
old.flags = {tfHasAsgn}
|
||||
old.addSonSkipIntLit result[0]
|
||||
result.destructor = old.destructor
|
||||
result.assignment = old.assignment
|
||||
result.sink = old.sink
|
||||
cl.c.typesWithOps.add((result, old))
|
||||
|
||||
else: discard
|
||||
else:
|
||||
# If this type doesn't refer to a generic type we may still want to run it
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue