]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Set the scope of the codebuilder block for symbol resolution
authorLuca Bruno <lucabru@src.gnome.org>
Sun, 2 Feb 2014 19:39:52 +0000 (20:39 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 11 Mar 2019 12:52:38 +0000 (13:52 +0100)
codegen/valaccodetransformer.vala
vala/valacodebuilder.vala
vala/valacodetransformer.vala
vala/valasymbolresolver.vala

index 850cd4283ae0c70da7f7f9b66ed7468e23f58669..8504c489b46eeb89f48c5a3c293751c1ad9a8091 100644 (file)
@@ -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 ();
                        }
index 7a09f3b6eb80a171f2969acef2dd51e1a48ce0b7..2e52c8b6b3f561deb7390b159b3e6270c762bb9d 100644 (file)
@@ -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;
index c70ce207303442c397de11d52e03cd8340696fb1..5799ca2effda3c47095fbba3f412e0f3921a74a5 100644 (file)
@@ -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;
index 1c0da5bcf60056dce66ab55c1ff743d395bfa77c..cf30a491ec5327a5c2237fbd65c3d9e2f6e75386 100644 (file)
@@ -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.