X-Git-Url: http://nitlanguage.org diff --git a/src/semantize/scope.nit b/src/semantize/scope.nit index e595b1c..3374951 100644 --- a/src/semantize/scope.nit +++ b/src/semantize/scope.nit @@ -18,6 +18,7 @@ module scope import phase +import modelbuilder redef class ToolContext # Run `APropdef::do_scope` on each propdef. @@ -70,6 +71,9 @@ private class ScopeVisitor # The tool context used to display errors var toolcontext: ToolContext + # The analysed property + var propdef: APropdef + var selfvariable = new Variable("self") init @@ -191,6 +195,7 @@ private class ScopeVisitor var res = search_label("") if res == null then self.error(nlabel, "Syntax Error: invalid anonymous label.") + node.is_broken = true return null end return res @@ -199,6 +204,7 @@ private class ScopeVisitor var res = search_label(name) if res == null then self.error(nlabel, "Syntax Error: invalid label `{name}`.") + node.is_broken = true return null end return res @@ -218,6 +224,7 @@ private class ScopeVisitor fun error(node: ANode, message: String) do self.toolcontext.error(node.hot_location, message) + node.is_broken = true end end @@ -244,10 +251,13 @@ redef class ANode end redef class APropdef + # The break escape mark associated with the return + var return_mark: nullable EscapeMark + # Entry point of the scope analysis fun do_scope(toolcontext: ToolContext) do - var v = new ScopeVisitor(toolcontext) + var v = new ScopeVisitor(toolcontext, self) v.enter_visit(self) v.shift_scope end @@ -322,6 +332,21 @@ redef class ABreakExpr end end +redef class AReturnExpr + redef fun accept_scope_visitor(v) + do + super + + var escapemark = v.propdef.return_mark + if escapemark == null then + escapemark = new EscapeMark + v.propdef.return_mark = escapemark + end + + escapemark.escapes.add(self) + self.escapemark = escapemark + end +end redef class ADoExpr # The break escape mark associated with the 'do' block @@ -331,6 +356,7 @@ redef class ADoExpr do self.break_mark = v.make_escape_mark(n_label, false) v.enter_visit_block(n_block, self.break_mark) + v.enter_visit_block(n_catch) end end