parent
6be8a66833
commit
0d194cdbf9
2 changed files with 74 additions and 25 deletions
|
|
@ -416,7 +416,6 @@ proc allRoots(n: PNode; result: var seq[(PSym, int)]; level: int) =
|
||||||
proc destMightOwn(c: var Partitions; dest: var VarIndex; n: PNode) =
|
proc destMightOwn(c: var Partitions; dest: var VarIndex; n: PNode) =
|
||||||
## Analyse if 'n' is an expression that owns the data, if so mark 'dest'
|
## Analyse if 'n' is an expression that owns the data, if so mark 'dest'
|
||||||
## with 'ownsData'.
|
## with 'ownsData'.
|
||||||
if n.typ == nil: return
|
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkEmpty, nkCharLit..nkNilLit:
|
of nkEmpty, nkCharLit..nkNilLit:
|
||||||
# primitive literals including the empty are harmless:
|
# primitive literals including the empty are harmless:
|
||||||
|
|
@ -475,6 +474,7 @@ proc destMightOwn(c: var Partitions; dest: var VarIndex; n: PNode) =
|
||||||
destMightOwn(c, dest, n[0])
|
destMightOwn(c, dest, n[0])
|
||||||
|
|
||||||
of nkCallKinds:
|
of nkCallKinds:
|
||||||
|
if n.typ != nil:
|
||||||
if hasDestructor(n.typ):
|
if hasDestructor(n.typ):
|
||||||
# calls do construct, what we construct must be destroyed,
|
# calls do construct, what we construct must be destroyed,
|
||||||
# so dest cannot be a cursor:
|
# so dest cannot be a cursor:
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ doing shady stuff...
|
||||||
192.168.0.1
|
192.168.0.1
|
||||||
192.168.0.1
|
192.168.0.1
|
||||||
192.168.0.1'''
|
192.168.0.1'''
|
||||||
cmd: '''nim c --gc:arc --expandArc:newTarget --expandArc:delete --expandArc:p1 --expandArc:tt --hint:Performance:off --assertions:off --expandArc:extractConfig --expandArc:mergeShadowScope $file'''
|
cmd: '''nim c --gc:arc --expandArc:newTarget --expandArc:delete --expandArc:p1 --expandArc:tt --hint:Performance:off --assertions:off --expandArc:extractConfig --expandArc:mergeShadowScope --expandArc:check $file'''
|
||||||
nimout: '''--expandArc: newTarget
|
nimout: '''--expandArc: newTarget
|
||||||
|
|
||||||
var
|
var
|
||||||
|
|
@ -127,6 +127,36 @@ block :tmp:
|
||||||
:tmpD
|
:tmpD
|
||||||
inc(i, 1)
|
inc(i, 1)
|
||||||
`=destroy`(shadowScope)
|
`=destroy`(shadowScope)
|
||||||
|
-- end of expandArc ------------------------
|
||||||
|
--expandArc: check
|
||||||
|
|
||||||
|
var par
|
||||||
|
this.isValid = fileExists(this.value)
|
||||||
|
if dirExists(this.value):
|
||||||
|
var :tmpD
|
||||||
|
par = (dir:
|
||||||
|
wasMoved(:tmpD)
|
||||||
|
`=copy`(:tmpD, this.value)
|
||||||
|
:tmpD, front: "") else:
|
||||||
|
var
|
||||||
|
:tmpD_1
|
||||||
|
:tmpD_2
|
||||||
|
:tmpD_3
|
||||||
|
par = (dir_1: parentDir(this.value), front_1:
|
||||||
|
wasMoved(:tmpD_1)
|
||||||
|
`=copy`(:tmpD_1,
|
||||||
|
:tmpD_3 = splitPath do:
|
||||||
|
wasMoved(:tmpD_2)
|
||||||
|
`=copy`(:tmpD_2, this.value)
|
||||||
|
:tmpD_2
|
||||||
|
:tmpD_3.tail)
|
||||||
|
:tmpD_1)
|
||||||
|
`=destroy`(:tmpD_3)
|
||||||
|
if dirExists(par.dir):
|
||||||
|
`=sink`(this.matchDirs, getSubDirs(par.dir, par.front))
|
||||||
|
else:
|
||||||
|
`=sink`(this.matchDirs, [])
|
||||||
|
`=destroy`(par)
|
||||||
-- end of expandArc ------------------------'''
|
-- end of expandArc ------------------------'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -322,3 +352,22 @@ proc mergeShadowScope*(c: PContext) =
|
||||||
c.addInterfaceDecl(sym)
|
c.addInterfaceDecl(sym)
|
||||||
|
|
||||||
mergeShadowScope(PContext(currentScope: Scope(parent: Scope())))
|
mergeShadowScope(PContext(currentScope: Scope(parent: Scope())))
|
||||||
|
|
||||||
|
type
|
||||||
|
Foo = ref object
|
||||||
|
isValid*: bool
|
||||||
|
value*: string
|
||||||
|
matchDirs*: seq[string]
|
||||||
|
|
||||||
|
proc getSubDirs(parent, front: string): seq[string] = @[]
|
||||||
|
|
||||||
|
method check(this: Foo) {.base.} =
|
||||||
|
this.isValid = fileExists(this.value)
|
||||||
|
let par = if dirExists(this.value): (dir: this.value, front: "")
|
||||||
|
else: (dir: parentDir(this.value), front: splitPath(this.value).tail)
|
||||||
|
if dirExists(par.dir):
|
||||||
|
this.matchDirs = getSubDirs(par.dir, par.front)
|
||||||
|
else:
|
||||||
|
this.matchDirs = @[]
|
||||||
|
|
||||||
|
check(Foo())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue