interpreter: interpret `with` statement
[nit.git] / src / semantize / scope.nit
index 00702d0..749bb9e 100644 (file)
@@ -20,6 +20,7 @@ module scope
 import phase
 
 redef class ToolContext
+       # Run `APropdef::do_scope` on each propdef.
        var scope_phase: Phase = new ScopePhase(self, null)
 end
 
@@ -71,9 +72,8 @@ private class ScopeVisitor
 
        var selfvariable = new Variable("self")
 
-       init(toolcontext: ToolContext)
+       init
        do
-               self.toolcontext = toolcontext
                scopes.add(new Scope)
        end
 
@@ -411,6 +411,24 @@ redef class AForExpr
        end
 end
 
+redef class AWithExpr
+       # The break escape mark associated with the 'with'
+       var break_mark: nullable EscapeMark
+
+       redef fun accept_scope_visitor(v)
+       do
+               v.scopes.unshift(new Scope)
+
+               var escapemark = v.make_escape_mark(n_label, true)
+               self.break_mark = escapemark
+
+               v.enter_visit(n_expr)
+               v.enter_visit_block(n_block, escapemark)
+
+               v.shift_scope
+       end
+end
+
 redef class AVarFormExpr
        # The associated variable
        var variable: nullable Variable