From: Luca Bruno Date: Sun, 2 Feb 2014 19:39:52 +0000 (+0100) Subject: Set the scope of the codebuilder block for symbol resolution X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0586aacdf7611cc69a85c4a9cce72f5b064cc49;p=thirdparty%2Fvala.git Set the scope of the codebuilder block for symbol resolution --- diff --git a/codegen/valaccodetransformer.vala b/codegen/valaccodetransformer.vala index 850cd4283..8504c489b 100644 --- a/codegen/valaccodetransformer.vala +++ b/codegen/valaccodetransformer.vala @@ -166,11 +166,12 @@ public class Vala.CCodeTransformer : CodeTransformer { public override void visit_while_statement (WhileStatement stmt) { // convert to simple loop push_builder (new CodeBuilder (context, stmt, stmt.source_reference)); - + Expression cond = null; if (!always_false (stmt.condition)) { b.open_loop (); if (!always_true (stmt.condition)) { - b.open_if (new UnaryExpression (UnaryOperator.LOGICAL_NEGATION, stmt.condition, stmt.condition.source_reference)); + cond = expression (@"!$(stmt.condition)"); + b.open_if (cond); b.add_break (); b.close (); } diff --git a/vala/valacodebuilder.vala b/vala/valacodebuilder.vala index 7a09f3b6e..2e52c8b6b 100644 --- a/vala/valacodebuilder.vala +++ b/vala/valacodebuilder.vala @@ -34,6 +34,7 @@ public class Vala.CodeBuilder { this.source_reference = source_reference; current_block = new Block (source_reference); + current_block.owner = context.analyzer.get_current_symbol (insert_statement).scope; insert_block = context.analyzer.get_current_block (insert_statement); insert_block.insert_before (insert_statement, current_block); this.insert_statement = current_block; diff --git a/vala/valacodetransformer.vala b/vala/valacodetransformer.vala index c70ce2073..5799ca2ef 100644 --- a/vala/valacodetransformer.vala +++ b/vala/valacodetransformer.vala @@ -133,6 +133,10 @@ public class Vala.CodeTransformer : CodeVisitor { } public void check (CodeNode node) { + var sym = context.analyzer.get_current_symbol (node); + if (sym != null) { + context.resolver.current_scope = sym.scope; + } node.accept (context.resolver); if (!node.check (context)) { return; diff --git a/vala/valasymbolresolver.vala b/vala/valasymbolresolver.vala index 1c0da5bcf..cf30a491e 100644 --- a/vala/valasymbolresolver.vala +++ b/vala/valasymbolresolver.vala @@ -29,7 +29,7 @@ using GLib; */ public class Vala.SymbolResolver : CodeVisitor { Symbol root_symbol; - Scope current_scope; + public Scope current_scope; /** * Resolve symbol names in the specified code context.