nitg: add more info (for -v)
[nit.git] / src / scope.nit
index 95e4d4a..5197c19 100644 (file)
@@ -19,6 +19,19 @@ module scope
 
 import parser
 import toolcontext
+import phase
+
+import modelbuilder #FIXME useless
+
+redef class ToolContext
+       var scope_phase: Phase = new ScopePhase(self, null)
+end
+
+private class ScopePhase
+       super Phase
+       redef fun process_npropdef(npropdef) do npropdef.do_scope(toolcontext)
+end
+
 
 # A local variable (including parameters, automatic variables and self)
 class Variable
@@ -431,6 +444,20 @@ redef class AClosureCallExpr
        var variable: nullable ClosureVariable
 end
 
+redef class ASendExpr
+       # The escape mark used with the closures if any
+       var escapemark: nullable EscapeMark
+
+       redef fun accept_scope_visitor(v)
+       do
+               if self.n_closure_defs.length > 0 then
+                       var escapemark = v.make_escape_mark(self.n_closure_defs.last.n_label, true)
+                       self.escapemark = escapemark
+               end
+               super
+       end
+end
+
 redef class AClosureDef
        # The automatic variables in order
        var variables: nullable Array[Variable]
@@ -451,8 +478,7 @@ redef class AClosureDef
                        variables.add(va)
                end
 
-               var escapemark = v.make_escape_mark(n_label, true)
-               self.escapemark = escapemark
+               self.escapemark = self.parent.as(ASendExpr).escapemark
                v.enter_visit_block(self.n_expr, escapemark)
 
                v.scopes.shift