[vala/wip/transform: 39/124] Add ConditionalExpression.replace_expression plus other fixes
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/transform: 39/124] Add ConditionalExpression.replace_expression plus other fixes
- Date: Wed, 26 Apr 2017 20:21:11 +0000 (UTC)
commit 8caca5374ef363ab861e0a923d39ff4745d1a454
Author: Luca Bruno <lucabru src gnome org>
Date: Thu Dec 29 12:39:15 2011 +0100
Add ConditionalExpression.replace_expression plus other fixes
codegen/valagvarianttransformer.vala | 2 ++
vala/valacodetransformer.vala | 6 ++++++
vala/valaconditionalexpression.vala | 18 ++++++++++++++----
3 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/codegen/valagvarianttransformer.vala b/codegen/valagvarianttransformer.vala
index 3ead018..a0be0e8 100644
--- a/codegen/valagvarianttransformer.vala
+++ b/codegen/valagvarianttransformer.vala
@@ -244,6 +244,8 @@ public class Vala.GVariantTransformer : CodeTransformer {
}
public override void visit_expression (Expression expr) {
+ base.visit_expression (expr);
+
if (!(context.profile == Profile.GOBJECT && expr.target_type != null &&
expr.target_type.data_type == context.analyzer.gvariant_type.data_type && !(expr.value_type is NullType) &&
expr.value_type.data_type != context.analyzer.gvariant_type.data_type)) {
// no implicit gvariant boxing
return;
diff --git a/vala/valacodetransformer.vala b/vala/valacodetransformer.vala
index 9eefee8..8583c10 100644
--- a/vala/valacodetransformer.vala
+++ b/vala/valacodetransformer.vala
@@ -200,6 +200,7 @@ public class Vala.CodeTransformer : CodeVisitor {
var loop = new Loop (stmt.body, stmt.source_reference);
var parent_block = (Block) stmt.parent_node;
+ context.analyzer.replaced_nodes.add (stmt);
parent_block.replace_statement (stmt, loop);
stmt.body.checked = false;
@@ -214,6 +215,7 @@ public class Vala.CodeTransformer : CodeVisitor {
var loop = new Loop (stmt.body, stmt.source_reference);
var parent_block = (Block) stmt.parent_node;
+ context.analyzer.replaced_nodes.add (stmt);
parent_block.replace_statement (stmt, loop);
check (loop);
@@ -241,6 +243,7 @@ public class Vala.CodeTransformer : CodeVisitor {
block.add_statement (new Loop (stmt.body, stmt.source_reference));
var parent_block = (Block) stmt.parent_node;
+ context.analyzer.replaced_nodes.add (stmt);
parent_block.replace_statement (stmt, block);
stmt.body.checked = false;
@@ -287,6 +290,7 @@ public class Vala.CodeTransformer : CodeVisitor {
block.add_statement (new Loop (stmt.body, stmt.source_reference));
var parent_block = (Block) stmt.parent_node;
+ context.analyzer.replaced_nodes.add (stmt);
parent_block.replace_statement (stmt, block);
stmt.body.checked = false;
@@ -370,6 +374,7 @@ public class Vala.CodeTransformer : CodeVisitor {
block.remove_local_variable (local);
context.analyzer.get_insert_block (expr).add_local_variable (local);
+ context.analyzer.replaced_nodes.add (expr);
old_parent_node.replace_expression (expr, temp_access);
check (temp_access);
}
@@ -400,6 +405,7 @@ public class Vala.CodeTransformer : CodeVisitor {
ma.formal_target_type = expr.formal_target_type;
ma.target_type = expr.target_type;
+ context.analyzer.replaced_nodes.add (expr);
expr.parent_node.replace_expression (expr, ma);
check (ma);
}
diff --git a/vala/valaconditionalexpression.vala b/vala/valaconditionalexpression.vala
index dfaefa4..480d37c 100644
--- a/vala/valaconditionalexpression.vala
+++ b/vala/valaconditionalexpression.vala
@@ -85,11 +85,9 @@ public class Vala.ConditionalExpression : Expression {
}
public override void accept (CodeVisitor visitor) {
- // FIXME: temporary workaround to keep alive the object
- var self = this;
- visitor.visit_conditional_expression (self);
+ visitor.visit_conditional_expression (this);
- visitor.visit_expression (self);
+ visitor.visit_expression (this);
}
public override void accept_children (CodeVisitor visitor) {
@@ -124,6 +122,18 @@ public class Vala.ConditionalExpression : Expression {
false_expression.get_used_variables (collection);
}
+ public override void replace_expression (Expression old_node, Expression new_node) {
+ if (condition == old_node) {
+ condition = new_node;
+ }
+ if (true_expression == old_node) {
+ true_expression = new_node;
+ }
+ if (false_expression == old_node) {
+ false_expression = new_node;
+ }
+ }
+
public override bool check (CodeContext context) {
if (checked) {
return !error;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]