diff options
author | Clyybber <darkmine956@gmail.com> | 2020-07-17 10:56:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-17 10:56:17 +0200 |
commit | 1355b461aa70cd1e17b2f07085aa6c97cb54283f (patch) | |
tree | 493f236f32668e5379a1c6dfa61a846ffbaa90d2 /compiler | |
parent | 9fb7467fda597957634b17782745a7f25d83296f (diff) | |
download | Nim-1355b461aa70cd1e17b2f07085aa6c97cb54283f.tar.gz |
Show that a variable is cursor in --expandArc (#15002)
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/cursor_inference.nim | 9 | ||||
-rw-r--r-- | compiler/injectdestructors.nim | 11 | ||||
-rw-r--r-- | compiler/renderer.nim | 2 |
3 files changed, 11 insertions, 11 deletions
diff --git a/compiler/cursor_inference.nim b/compiler/cursor_inference.nim index 224131270..94b06ac79 100644 --- a/compiler/cursor_inference.nim +++ b/compiler/cursor_inference.nim @@ -73,7 +73,7 @@ proc cursorId(c: Con; x: PSym): int = if c.cursors[i].s == x: return i return -1 -proc getCursors(c: Con): IntSet = +proc getCursors(c: Con) = #[ Question: if x depends on y and y depends on z then also y depends on z. @@ -86,7 +86,6 @@ proc getCursors(c: Con): IntSet = y.s = "mutate" ]# - result = initIntSet() for cur in c.cursors: if not c.mayOwnData.contains(cur.s.id) and cur.s.typ.skipTypes({tyGenericInst, tyAlias}).kind != tyOwned: @@ -97,7 +96,7 @@ proc getCursors(c: Con): IntSet = #echo "bah, not a cursor ", cur.s, " bad dependency ", d break doAdd when true: - result.incl cur.s.id + cur.s.flags.incl sfCursor when false: echo "computed as a cursor ", cur.s, " ", cur.deps, " ", c.config $ cur.s.info @@ -294,7 +293,7 @@ proc analyse(c: var Con; n: PNode) = else: for child in n: analyse(c, child) -proc computeCursors*(n: PNode; config: ConfigRef): IntSet = +proc computeCursors*(n: PNode; config: ConfigRef) = var c = Con(config: config) analyse(c, n) - result = getCursors c + getCursors c diff --git a/compiler/injectdestructors.nim b/compiler/injectdestructors.nim index 556d098f4..99eefca57 100644 --- a/compiler/injectdestructors.nim +++ b/compiler/injectdestructors.nim @@ -35,7 +35,6 @@ type Con = object owner: PSym g: ControlFlowGraph - cursors: IntSet graph: ModuleGraph otherRead: PNode inLoop, inSpawn: int @@ -152,13 +151,13 @@ proc isLastRead(location: PNode; cfg: ControlFlowGraph; otherRead: var PNode; pc proc isCursor(n: PNode; c: Con): bool = case n.kind of nkSym: - result = sfCursor in n.sym.flags or c.cursors.contains(n.sym.id) + sfCursor in n.sym.flags of nkDotExpr: - result = sfCursor in n[1].sym.flags + isCursor(n[1], c) of nkCheckedFieldExpr: - result = isCursor(n[0], c) + isCursor(n[0], c) else: - result = false + false proc isLastRead(n: PNode; c: var Con): bool = # first we need to search for the instruction that belongs to 'n': @@ -1043,7 +1042,7 @@ proc injectDestructorCalls*(g: ModuleGraph; owner: PSym; n: PNode): PNode = echoCfg(c.g) echo n - c.cursors = computeCursors(n, g.config) + computeCursors(n, g.config) var scope: Scope let body = p(n, c, scope, normal) diff --git a/compiler/renderer.nim b/compiler/renderer.nim index 3cd532e15..f600d58bf 100644 --- a/compiler/renderer.nim +++ b/compiler/renderer.nim @@ -865,6 +865,8 @@ proc gident(g: var TSrcGen, n: PNode) = if localId != 0 and n.sym.magic == mNone: s.add '_' s.addInt localId + if sfCursor in n.sym.flags: + s.add "_cursor" elif n.kind == nkSym and (renderIds in g.flags or sfGenSym in n.sym.flags or n.sym.kind == skTemp): s.add '_' s.addInt n.sym.id |