end
# Mark where break and continue will branch.
-# marks are either associated with a label of with a for_loop structure
+# Marks are either associated with a label of with a for_loop structure
class EscapeMark
# The name of the label (unless the mark is an anonymous loop mark)
var name: nullable String
# The tool context used to display errors
var toolcontext: ToolContext
+ var selfvariable: Variable = new Variable("self")
+
init(toolcontext: ToolContext)
do
self.toolcontext = toolcontext
end
end
+redef class ASelfExpr
+ # The variable associated with the self reciever
+ var variable: nullable Variable
+ redef fun accept_scope_visitor(v)
+ do
+ super
+ self.variable = v.selfvariable
+ end
+end
+
redef class AContinueExpr
# The escape mark associated with the continue
var escapemark: nullable EscapeMark
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]
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