gc: destructors is beginning to work (#10483)
* kochdocs.nim: code cleanup * docgen: nicer indentation * parser.nim: code cleanup * fixes #10458 * make tests green again * make =destroy mixins * gc:destructors: produced C code is almost working * --gc:destructors simple program compiles (but leaks memory) * gc:destructors make examples compile in C++ mode * destructors: string implementation bugfixes * strs.nim: minor code cleanup * destructors: builtin seqs are beginning to work * remove debugging helpers
This commit is contained in:
parent
15422a3e5a
commit
dee8e6e98a
19 changed files with 162 additions and 101 deletions
|
|
@ -244,7 +244,10 @@ proc patchHead(n: PNode) =
|
|||
|
||||
proc patchHead(s: PSym) =
|
||||
if sfFromGeneric in s.flags:
|
||||
patchHead(s.ast[bodyPos])
|
||||
# do not patch the builtin type bound operators for seqs:
|
||||
let dest = s.typ.sons[1].skipTypes(abstractVar)
|
||||
if dest.kind != tySequence:
|
||||
patchHead(s.ast[bodyPos])
|
||||
|
||||
proc checkForErrorPragma(c: Con; t: PType; ri: PNode; opname: string) =
|
||||
var m = "'" & opname & "' is not available for type <" & typeToString(t) & ">"
|
||||
|
|
@ -267,7 +270,8 @@ template genOp(opr, opname, ri) =
|
|||
globalError(c.graph.config, dest.info, "internal error: '" & opname &
|
||||
"' operator not found for type " & typeToString(t))
|
||||
elif op.ast[genericParamsPos].kind != nkEmpty:
|
||||
globalError(c.graph.config, dest.info, "internal error: '" & opname & "' operator is generic")
|
||||
globalError(c.graph.config, dest.info, "internal error: '" & opname &
|
||||
"' operator is generic")
|
||||
patchHead op
|
||||
if sfError in op.flags: checkForErrorPragma(c, t, ri, opname)
|
||||
let addrExp = newNodeIT(nkHiddenAddr, dest.info, makePtrType(c, dest.typ))
|
||||
|
|
@ -275,6 +279,12 @@ template genOp(opr, opname, ri) =
|
|||
result = newTree(nkCall, newSymNode(op), addrExp)
|
||||
|
||||
proc genSink(c: Con; t: PType; dest, ri: PNode): PNode =
|
||||
when false:
|
||||
if t.kind != tyString:
|
||||
echo "this one ", c.graph.config$dest.info, " for ", typeToString(t, preferDesc)
|
||||
debug t.sink.typ.sons[2]
|
||||
echo t.sink.id, " owner ", t.id
|
||||
quit 1
|
||||
let t = t.skipTypes({tyGenericInst, tyAlias, tySink})
|
||||
genOp(if t.sink != nil: t.sink else: t.assignment, "=sink", ri)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue