cleanup destructor building for arrays; still doesn't work

This commit is contained in:
Araq 2015-08-18 13:57:37 +02:00
commit d634da775d
3 changed files with 15 additions and 27 deletions

View file

@ -190,7 +190,6 @@ proc resetMemory =
resetRopeCache()
resetSysTypes()
gOwners = @[]
rangeDestructorProc = nil
for i in low(buckets)..high(buckets):
buckets[i] = nil
idAnon = nil
@ -237,7 +236,7 @@ proc mainCommand* =
when SimulateCaasMemReset:
gGlobalOptions.incl(optCaasEnabled)
# In "nimrod serve" scenario, each command must reset the registered passes
# In "nim serve" scenario, each command must reset the registered passes
clearPasses()
gLastCmdTime = epochTime()
appendStr(searchPaths, options.libpath)

View file

@ -24,7 +24,6 @@ var
destructorName = getIdent"destroy_"
destructorParam = getIdent"this_"
destructorPragma = newIdentNode(getIdent"destructor", unknownLineInfo())
rangeDestructorProc*: PSym
proc instantiateDestructor(c: PContext, typ: PType): PType
@ -141,9 +140,7 @@ proc instantiateDestructor(c: PContext, typ: PType): PType =
case t.kind
of tySequence, tyArray, tyArrayConstr, tyOpenArray, tyVarargs:
if instantiateDestructor(c, t.sons[0]) != nil:
if rangeDestructorProc == nil:
rangeDestructorProc = searchInScopes(c, getIdent"nimDestroyRange")
t.destructor = rangeDestructorProc
t.destructor = getCompilerProc"nimDestroyRange"
return t
else:
return nil

View file

@ -173,18 +173,10 @@ proc objectInit(dest: pointer, typ: PNimType) =
# ---------------------- assign zero -----------------------------------------
when not defined(nimmixin):
proc destroy(x: int) = discard
proc nimDestroyRange*[T](r: T) =
# internal proc used for destroying sequences and arrays
for i in countup(0, r.len - 1): destroy(r[i])
else:
# XXX Why is this exported and no compilerproc? -> compilerprocs cannot be
# generic for now
proc nimDestroyRange*[T](r: T) =
# internal proc used for destroying sequences and arrays
mixin destroy
for i in countup(0, r.len - 1): destroy(r[i])
proc nimDestroyRange[T](r: T) {.compilerProc.} =
# internal proc used for destroying sequences and arrays
mixin `=destroy`
for i in countup(0, r.len - 1): `=destroy`(r[i])
proc genericReset(dest: pointer, mt: PNimType) {.compilerProc, benign.}
proc genericResetAux(dest: pointer, n: ptr TNimNode) =