[vala/wip/transform: 85/99] Set the scope of the codebuilder block for symbol resolution
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/transform: 85/99] Set the scope of the codebuilder block for symbol resolution
- Date: Sun, 9 Feb 2014 22:45:27 +0000 (UTC)
commit 8d1dca1882eb273299fa21db6ebf03fa3d19afe0
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/valaassignment.vala | 2 +-
vala/valacodebuilder.vala | 1 +
vala/valacodetransformer.vala | 4 ++++
vala/valamemberaccess.vala | 2 +-
vala/valamethodcall.vala | 2 +-
vala/valapointerindirection.vala | 4 ++++
vala/valareferencetransferexpression.vala | 4 ++++
vala/valasymbolresolver.vala | 2 +-
vala/valatypecheck.vala | 4 ++++
10 files changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/codegen/valaccodetransformer.vala b/codegen/valaccodetransformer.vala
index 1bfc968..cf514bb 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/valaassignment.vala b/vala/valaassignment.vala
index 5784fa9..6086948 100644
--- a/vala/valaassignment.vala
+++ b/vala/valaassignment.vala
@@ -102,7 +102,7 @@ public class Vala.Assignment : Expression {
}
public override string to_string () {
- return left.to_string () + get_operator_string () + right.to_string ();
+ return "("+left.to_string () + get_operator_string () + right.to_string ()+")";
}
public override void replace_expression (Expression old_node, Expression new_node) {
diff --git a/vala/valacodebuilder.vala b/vala/valacodebuilder.vala
index 1c2c03e..866556e 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 cffeb99..7c379bf 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/valamemberaccess.vala b/vala/valamemberaccess.vala
index 253eab2..4fd337f 100644
--- a/vala/valamemberaccess.vala
+++ b/vala/valamemberaccess.vala
@@ -136,7 +136,7 @@ public class Vala.MemberAccess : Expression {
if (inner == null) {
return member_name;
} else {
- return "%s.%s".printf (inner.to_string (), member_name);
+ return "%s%s%s".printf (inner.to_string (), pointer_member_access ? "->" :
".", member_name);
}
} else {
// ensure to always use fully-qualified name
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index ea0dfdb..6b86486 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -770,7 +770,7 @@ public class Vala.MethodCall : Expression {
b.append (", ");
}
b.append (expr.to_string ());
- first = true;
+ first = false;
}
b.append ("))");
diff --git a/vala/valapointerindirection.vala b/vala/valapointerindirection.vala
index 4cefaf1..ec5d6cc 100644
--- a/vala/valapointerindirection.vala
+++ b/vala/valapointerindirection.vala
@@ -106,4 +106,8 @@ public class Vala.PointerIndirection : Expression {
codegen.visit_expression (this);
}
+
+ public override string to_string () {
+ return "(*"+inner.to_string()+")";
+ }
}
diff --git a/vala/valareferencetransferexpression.vala b/vala/valareferencetransferexpression.vala
index 441ad4e..c870b81 100644
--- a/vala/valareferencetransferexpression.vala
+++ b/vala/valareferencetransferexpression.vala
@@ -116,4 +116,8 @@ public class Vala.ReferenceTransferExpression : Expression {
codegen.visit_expression (this);
}
+
+ public override string to_string () {
+ return "(owned) "+inner.to_string ();
+ }
}
diff --git a/vala/valasymbolresolver.vala b/vala/valasymbolresolver.vala
index 608e262..3bb974e 100644
--- a/vala/valasymbolresolver.vala
+++ b/vala/valasymbolresolver.vala
@@ -30,7 +30,7 @@ using GLib;
public class Vala.SymbolResolver : CodeVisitor {
CodeContext context;
Symbol root_symbol;
- Scope current_scope;
+ public Scope current_scope;
/**
* Resolve symbol names in the specified code context.
diff --git a/vala/valatypecheck.vala b/vala/valatypecheck.vala
index 4a49f5b..ed024b3 100644
--- a/vala/valatypecheck.vala
+++ b/vala/valatypecheck.vala
@@ -132,4 +132,8 @@ public class Vala.TypeCheck : Expression {
codegen.visit_expression (this);
}
+
+ public override string to_string () {
+ return @"($expression is $type_reference)";
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]