[vala/wip/transform: 83/99] Use _ctmp%d_ for compiler variables since they are globally mapped. Fix templates
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/transform: 83/99] Use _ctmp%d_ for compiler variables since they are globally mapped. Fix templates
- Date: Sun, 25 Sep 2016 19:23:22 +0000 (UTC)
commit 063372d6358009deac43d34c58222708c8d427f4
Author: Luca Bruno <lucabru src gnome org>
Date: Sat Feb 1 18:26:35 2014 +0100
Use _ctmp%d_ for compiler variables since they are globally mapped. Fix templates
codegen/valaccodebasemodule.vala | 2 +-
codegen/valaccodetransformer.vala | 6 +++---
vala/valaelementaccess.vala | 2 +-
vala/valamethodcall.vala | 2 +-
vala/valaobjectcreationexpression.vala | 2 +-
vala/valatemplate.vala | 19 +++++++++++++++++++
6 files changed, 26 insertions(+), 7 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 9f06906..704b1d6 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2267,7 +2267,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
// compiler-internal variable
if (!variable_name_map.contains (name)) {
- variable_name_map.set (name, "_tmp%d_".printf (next_temp_var_id));
+ variable_name_map.set (name, "_ctmp%d_".printf (next_temp_var_id));
next_temp_var_id++;
}
return variable_name_map.get (name);
diff --git a/codegen/valaccodetransformer.vala b/codegen/valaccodetransformer.vala
index d8c4675..795e4f7 100644
--- a/codegen/valaccodetransformer.vala
+++ b/codegen/valaccodetransformer.vala
@@ -73,7 +73,7 @@ public class Vala.CCodeTransformer : CodeTransformer {
if (m.body == null) {
return;
}
-
+
m.accept_children (this);
}
@@ -530,7 +530,7 @@ public class Vala.CCodeTransformer : CodeTransformer {
if (expr.value_type.data_type != null && expr.value_type.data_type.is_subtype_of
(context.analyzer.string_type.data_type)) {
return expr;
} else {
- return expression (@"($expr).to_string ()");
+ return expression (@"$expr.to_string ()");
}
}
@@ -545,7 +545,7 @@ public class Vala.CCodeTransformer : CodeTransformer {
} else {
replacement = stringify (expression_list[0]);
if (expression_list.size > 1) {
- var concat = (MethodCall) expression (@"($replacement).concat()");
+ var concat = (MethodCall) expression (@"$replacement.concat()");
for (int i = 1; i < expression_list.size; i++) {
concat.add_argument (stringify (expression_list[i]));
}
diff --git a/vala/valaelementaccess.vala b/vala/valaelementaccess.vala
index dedfc04..8d67998 100644
--- a/vala/valaelementaccess.vala
+++ b/vala/valaelementaccess.vala
@@ -95,7 +95,7 @@ public class Vala.ElementAccess : Expression {
}
int index = indices.index_of (old_node);
- if (index >= 0 && new_node.parent_node == null) {
+ if (index >= 0) {
indices[index] = new_node;
new_node.parent_node = this;
}
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index 76f49a1..4dd0117 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -101,7 +101,7 @@ public class Vala.MethodCall : Expression {
}
int index = argument_list.index_of (old_node);
- if (index >= 0 && new_node.parent_node == null) {
+ if (index >= 0) {
argument_list[index] = new_node;
new_node.parent_node = this;
}
diff --git a/vala/valaobjectcreationexpression.vala b/vala/valaobjectcreationexpression.vala
index 26e1076..4cd5b3f 100644
--- a/vala/valaobjectcreationexpression.vala
+++ b/vala/valaobjectcreationexpression.vala
@@ -138,7 +138,7 @@ public class Vala.ObjectCreationExpression : Expression {
public override void replace_expression (Expression old_node, Expression new_node) {
int index = argument_list.index_of (old_node);
- if (index >= 0 && new_node.parent_node == null) {
+ if (index >= 0) {
argument_list[index] = new_node;
new_node.parent_node = this;
}
diff --git a/vala/valatemplate.vala b/vala/valatemplate.vala
index 3a35562..8d446d1 100644
--- a/vala/valatemplate.vala
+++ b/vala/valatemplate.vala
@@ -51,6 +51,25 @@ public class Vala.Template : Expression {
return false;
}
+ public override string to_string () {
+ var b = new StringBuilder ();
+ b.append ("@\"");
+
+ foreach (var expr in expression_list) {
+ if (expr is StringLiteral) {
+ unowned string value = ((StringLiteral) expr).value;
+ b.append (value.substring (1, (uint) (value.length - 2)));
+ } else {
+ b.append ("$(");
+ b.append (expr.to_string ());
+ b.append_c (')');
+ }
+ }
+
+ b.append_c ('"');
+ return b.str;
+ }
+
public override bool check (CodeContext context) {
if (checked) {
return !error;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]