[vala/wip/transform: 85/106] Set the scope of the codebuilder block for symbol resolution
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/transform: 85/106] Set the scope of the codebuilder block for symbol resolution
- Date: Mon, 4 Feb 2019 09:27:08 +0000 (UTC)
commit 8032a4f83e3f859a8aabd96467f989b897089603
Author: Luca Bruno <lucabru src gnome org>
Date: Sun Feb 2 20:39:52 2014 +0100
Set the scope of the codebuilder block for symbol resolution
codegen/valaccodetransformer.vala | 5 +++--
vala/valacodebuilder.vala | 1 +
vala/valacodetransformer.vala | 4 ++++
vala/valasymbolresolver.vala | 2 +-
4 files changed, 9 insertions(+), 3 deletions(-)
---
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.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]