[vala/wip/transform: 74/97] 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: 74/97] Use _ctmp%d_ for compiler variables since they are globally mapped. Fix templates
- Date: Mon, 21 Jan 2019 18:44:52 +0000 (UTC)
commit b5968071d26df8987316b9a218a930f4e77f0dd0
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 | 4 ++--
vala/valatemplate.vala | 19 +++++++++++++++++++
3 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index d4e43424b..5f4b40f27 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2387,7 +2387,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 413b64a1a..4b8c68a0d 100644
--- a/codegen/valaccodetransformer.vala
+++ b/codegen/valaccodetransformer.vala
@@ -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/valatemplate.vala b/vala/valatemplate.vala
index cf45522cf..7921d30f6 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 void replace_expression (Expression old_node, Expression new_node) {
int index = expression_list.index_of (old_node);
if (index >= 0) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]