Merge: new `with` statement
[nit.git] / src / semantize / flow.nit
index 733e3d3..8dad3b7 100644 (file)
@@ -20,6 +20,7 @@ module flow
 import scope
 
 redef class ToolContext
+       # Run `APropdef::do_flow` on each propdef
        var flow_phase: Phase = new FlowPhase(self, [scope_phase])
 end
 
@@ -33,19 +34,17 @@ end
 private class FlowVisitor
        super Visitor
 
-       var current_flow_context: FlowContext
+       var current_flow_context = new FlowContext
 
        var toolcontext: ToolContext
 
-       init(toolcontext: ToolContext)
+       init
        do
-               self.toolcontext = toolcontext
-               current_flow_context = new FlowContext
                flows.add(current_flow_context)
                current_flow_context.is_start = true
        end
 
-       var first: nullable ANode
+       var first: nullable ANode = null
 
        redef fun visit(node)
        do
@@ -78,7 +77,7 @@ private class FlowVisitor
 
        fun printflow
        do
-               var file = new OFStream.open("flow.dot")
+               var file = new FileWriter.open("flow.dot")
                file.write("digraph \{\n")
                for f in flows do
                        var s = ""
@@ -439,6 +438,14 @@ redef class AForExpr
        end
 end
 
+redef class AWithExpr
+       redef fun accept_flow_visitor(v)
+       do
+               super
+               v.merge_breaks(self.break_mark)
+       end
+end
+
 redef class AAssertExpr
        redef fun accept_flow_visitor(v)
        do
@@ -538,7 +545,15 @@ redef class AIsaExpr
        end
 end
 
-redef class AProxyExpr
+redef class AParExpr
+       redef fun accept_flow_visitor(v)
+       do
+               var after_expr = v.visit_expr(self.n_expr)
+               v.current_flow_context = after_expr
+       end
+end
+
+redef class AOnceExpr
        redef fun accept_flow_visitor(v)
        do
                var after_expr = v.visit_expr(self.n_expr)