mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-21 06:45:27 +00:00
Show that a variable is cursor in --expandArc (#15002)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user