summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2019-06-12 08:27:02 +0200
committerAraq <rumpf_a@web.de>2019-06-12 08:45:47 +0200
commitc07973e313cb701a076bffb890c0777a555ffa16 (patch)
tree9839d475eb3dacbe940ad59c318b2019b65fd611
parent549d8cc0c694528d44e012e72924d4c171322fb0 (diff)
downloadNim-c07973e313cb701a076bffb890c0777a555ffa16.tar.gz
[refactoring] liftdestructors is now a module of its own
-rw-r--r--compiler/liftdestructors.nim19
-rw-r--r--compiler/semexprs.nim10
-rw-r--r--compiler/sempass2.nim2
-rw-r--r--compiler/semstmts.nim2
4 files changed, 16 insertions, 17 deletions
diff --git a/compiler/liftdestructors.nim b/compiler/liftdestructors.nim
index 18f967465..7e4f26e4e 100644
--- a/compiler/liftdestructors.nim
+++ b/compiler/liftdestructors.nim
@@ -10,12 +10,11 @@
 ## This module implements lifting for type-bound operations
 ## (``=sink``, ``=``, ``=destroy``, ``=deepCopy``).
 
-# included from sempass2.nim
-
 # Todo:
 # - use openArray instead of array to avoid over-specializations
 
-import sighashes
+import modulegraphs, lineinfos, idents, ast, astalgo, renderer, semdata,
+  sighashes, lowerings, options, types, msgs, magicsys, tables
 
 type
   TLiftCtx = object
@@ -135,8 +134,8 @@ proc considerAsgnOrSink(c: var TLiftCtx; t: PType; body, x, y: PNode;
     if field != nil and sfOverriden in field.flags:
       if sfError in op.flags:
         incl c.fn.flags, sfError
-      else:
-        markUsed(c.graph.config, c.info, op, c.graph.usageSym)
+      #else:
+      #  markUsed(c.graph.config, c.info, op, c.graph.usageSym)
       onUse(c.info, op)
       body.add newAsgnCall(c.graph, op, x, y)
       result = true
@@ -155,8 +154,8 @@ proc considerAsgnOrSink(c: var TLiftCtx; t: PType; body, x, y: PNode;
         op = produceSym(c.c, t, c.kind, c.info)
     if sfError in op.flags:
       incl c.fn.flags, sfError
-    else:
-      markUsed(c.graph.config, c.info, op, c.graph.usageSym)
+    #else:
+    #  markUsed(c.graph.config, c.info, op, c.graph.usageSym)
     onUse(c.info, op)
     # We also now do generic instantiations in the destructor lifting pass:
     if op.ast[genericParamsPos].kind != nkEmpty:
@@ -179,7 +178,7 @@ proc addDestructorCall(c: var TLiftCtx; t: PType; body, x: PNode) =
     doAssert op == t.destructor
 
   if op != nil:
-    markUsed(c.graph.config, c.info, op, c.graph.usageSym)
+    #markUsed(c.graph.config, c.info, op, c.graph.usageSym)
     onUse(c.info, op)
     body.add destructorCall(c.graph, op, x)
   elif useNoGc(c, t):
@@ -198,7 +197,7 @@ proc considerUserDefinedOp(c: var TLiftCtx; t: PType; body, x, y: PNode): bool =
         op = c.c.instTypeBoundOp(c.c, op, t.typeInst, c.info, attachedAsgn, 1)
         t.attachedOps[attachedDestructor] = op
 
-      markUsed(c.graph.config, c.info, op, c.graph.usageSym)
+      #markUsed(c.graph.config, c.info, op, c.graph.usageSym)
       onUse(c.info, op)
       body.add destructorCall(c.graph, op, x)
       result = true
@@ -210,7 +209,7 @@ proc considerUserDefinedOp(c: var TLiftCtx; t: PType; body, x, y: PNode): bool =
   of attachedDeepCopy:
     let op = t.attachedOps[attachedDeepCopy]
     if op != nil:
-      markUsed(c.graph.config, c.info, op, c.graph.usageSym)
+      #markUsed(c.graph.config, c.info, op, c.graph.usageSym)
       onUse(c.info, op)
       body.add newDeepCopyCall(op, x, y)
       result = true
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 52c6815b2..f53bda0ea 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -844,9 +844,10 @@ proc afterCallActions(c: PContext; n, orig: PNode, flags: TExprFlags): PNode =
     analyseIfAddressTakenInCall(c, result)
     if callee.magic != mNone:
       result = magicsAfterOverloadResolution(c, result, flags)
-    if result.typ != nil and
-        not (result.typ.kind == tySequence and result.typ.sons[0].kind == tyEmpty):
-      liftTypeBoundOps(c, result.typ, n.info)
+    when false:
+      if result.typ != nil and
+          not (result.typ.kind == tySequence and result.typ.sons[0].kind == tyEmpty):
+        liftTypeBoundOps(c, result.typ, n.info)
     #result = patchResolvedTypeBoundOp(c, result)
   if c.matchedConcept == nil:
     result = evalAtCompileTime(c, result)
@@ -1689,8 +1690,7 @@ proc semAsgn(c: PContext, n: PNode; mode=asgnNormal): PNode =
     borrowCheck(c, n, lhs, rhs)
 
     n.sons[1] = fitNode(c, le, rhs, goodLineInfo(n[1]))
-    liftTypeBoundOps(c, lhs.typ, lhs.info)
-    #liftTypeBoundOps(c, n.sons[0].typ, n.sons[0].info)
+    when false: liftTypeBoundOps(c, lhs.typ, lhs.info)
 
     fixAbstractType(c, n)
     asgnToResultVar(c, n, n.sons[0], n.sons[1])
diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim
index 217482d95..32d749bb4 100644
--- a/compiler/sempass2.nim
+++ b/compiler/sempass2.nim
@@ -18,7 +18,7 @@ when not defined(leanCompiler):
 when defined(useDfa):
   import dfa
 
-include liftdestructors
+import liftdestructors
 
 #[ Second semantic checking pass over the AST. Necessary because the old
    way had some inherent problems. Performs:
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 525de63e8..5a876a6ea 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -493,7 +493,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
     # this can only happen for errornous var statements:
     if typ == nil: continue
     typeAllowedCheck(c.config, a.info, typ, symkind, if c.matchedConcept != nil: {taConcept} else: {})
-    liftTypeBoundOps(c, typ, a.info)
+    when false: liftTypeBoundOps(c, typ, a.info)
     instAllTypeBoundOp(c, a.info)
     var tup = skipTypes(typ, {tyGenericInst, tyAlias, tySink})
     if a.kind == nkVarTuple: