Skip to content

Commit

Permalink
cursor and mutation tracking fixes (#15113)
Browse files Browse the repository at this point in the history
* fixes #15110
* fixes #15096

* prepare varpartitions for cursor inference
* new cursor inference begins to work
* make tests green
  • Loading branch information
Araq authored Jul 30, 2020
1 parent 32c6146 commit d130175
Show file tree
Hide file tree
Showing 8 changed files with 311 additions and 368 deletions.
9 changes: 9 additions & 0 deletions compiler/ast.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1841,6 +1841,11 @@ proc isImportedException*(t: PType; conf: ConfigRef): bool =
proc isInfixAs*(n: PNode): bool =
return n.kind == nkInfix and n[0].kind == nkIdent and n[0].ident.s == "as"

proc skipColon*(n: PNode): PNode =
result = n
if n.kind == nkExprColonExpr:
result = n[1]

proc findUnresolvedStatic*(n: PNode): PNode =
# n.typ == nil: see issue #14802
if n.kind == nkSym and n.typ != nil and n.typ.kind == tyStatic and n.typ.n == nil:
Expand All @@ -1860,6 +1865,10 @@ when false:
if n[i].containsNil: return true

template hasDestructor*(t: PType): bool = {tfHasAsgn, tfHasOwned} * t.flags != {}

proc hasDisabledAsgn*(t: PType): bool =
t.attachedOps[attachedAsgn] != nil and sfError in t.attachedOps[attachedAsgn].flags

template incompleteType*(t: PType): bool =
t.sym != nil and {sfForward, sfNoForward} * t.sym.flags == {sfForward}

Expand Down
300 changes: 0 additions & 300 deletions compiler/cursor_inference.nim

This file was deleted.

4 changes: 2 additions & 2 deletions compiler/injectdestructors.nim
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import
intsets, strtabs, ast, astalgo, msgs, renderer, magicsys, types, idents,
strutils, options, dfa, lowerings, tables, modulegraphs, msgs,
lineinfos, parampatterns, sighashes, liftdestructors, optimizer,
cursor_inference
varpartitions

from trees import exprStructuralEquivalent, getRoot

Expand Down Expand Up @@ -1002,7 +1002,7 @@ proc injectDestructorCalls*(g: ModuleGraph; owner: PSym; n: PNode): PNode =
echoCfg(c.g)
echo n

computeCursors(n, g.config)
computeCursors(owner, n, g.config)

var scope: Scope
let body = p(n, c, scope, normal)
Expand Down
2 changes: 2 additions & 0 deletions compiler/sempass2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,8 @@ proc trackCall(tracked: PEffects; n: PNode) =
case op[i].kind
of tySink:
checkForSink(tracked.config, tracked.owner, n[i])
of tyVar:
tracked.hasDangerousAssign = true
#of tyOut:
# consider this case: p(out x, x); we want to remark that 'x' is not
# initialized until after the call. Since we do this after we analysed the
Expand Down
Loading

0 comments on commit d130175

Please sign in to comment.