vala r1847 - in trunk: . gobject vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1847 - in trunk: . gobject vala
- Date: Fri, 17 Oct 2008 11:42:40 +0000 (UTC)
Author: juergbi
Date: Fri Oct 17 11:42:40 2008
New Revision: 1847
URL: http://svn.gnome.org/viewvc/vala?rev=1847&view=rev
Log:
2008-10-17 JÃrg Billeter <j bitron ch>
* vala/valasemanticanalyzer.vala:
* gobject/valaccodegenerator.vala:
Move C-specific string concatenation from semantic analyzer to
code generator, patch by Andrea Del Signore
Modified:
trunk/ChangeLog
trunk/gobject/valaccodegenerator.vala
trunk/vala/valasemanticanalyzer.vala
Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala (original)
+++ trunk/gobject/valaccodegenerator.vala Fri Oct 17 11:42:40 2008
@@ -3663,19 +3663,28 @@
if (!(expr.left.value_type is NullType)
&& expr.left.value_type.compatible (string_type)
&& !(expr.right.value_type is NullType)
- && expr.right.value_type.compatible (string_type)
- && (expr.operator == BinaryOperator.EQUALITY
- || expr.operator == BinaryOperator.INEQUALITY
- || expr.operator == BinaryOperator.LESS_THAN
- || expr.operator == BinaryOperator.GREATER_THAN
- || expr.operator == BinaryOperator.LESS_THAN_OR_EQUAL
- || expr.operator == BinaryOperator.GREATER_THAN_OR_EQUAL)) {
- requires_strcmp0 = true;
- var ccall = new CCodeFunctionCall (new CCodeIdentifier ("_vala_strcmp0"));
- ccall.add_argument (cleft);
- ccall.add_argument (cright);
- cleft = ccall;
- cright = new CCodeConstant ("0");
+ && expr.right.value_type.compatible (string_type)) {
+ if (expr.operator == BinaryOperator.PLUS) {
+ /* string concatenation: convert to g_strconcat (a, b, NULL) */
+ var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_strconcat"));
+ ccall.add_argument (cleft);
+ ccall.add_argument (cright);
+ ccall.add_argument (new CCodeConstant("NULL"));
+ expr.ccodenode = ccall;
+ return;
+ } else if (expr.operator == BinaryOperator.EQUALITY
+ || expr.operator == BinaryOperator.INEQUALITY
+ || expr.operator == BinaryOperator.LESS_THAN
+ || expr.operator == BinaryOperator.GREATER_THAN
+ || expr.operator == BinaryOperator.LESS_THAN_OR_EQUAL
+ || expr.operator == BinaryOperator.GREATER_THAN_OR_EQUAL) {
+ requires_strcmp0 = true;
+ var ccall = new CCodeFunctionCall (new CCodeIdentifier ("_vala_strcmp0"));
+ ccall.add_argument (cleft);
+ ccall.add_argument (cright);
+ cleft = ccall;
+ cright = new CCodeConstant ("0");
+ }
}
expr.ccodenode = new CCodeBinaryExpression (op, cleft, cright);
Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala (original)
+++ trunk/vala/valasemanticanalyzer.vala Fri Oct 17 11:42:40 2008
@@ -3147,22 +3147,16 @@
if (expr.left.value_type.data_type == string_type.data_type
&& expr.operator == BinaryOperator.PLUS) {
+ // string concatenation
+
if (expr.right.value_type == null || expr.right.value_type.data_type != string_type.data_type) {
expr.error = true;
Report.error (expr.source_reference, "Operands must be strings");
return;
}
- /* string concatenation: convert to a.concat (b) */
-
- var concat_call = new InvocationExpression (new MemberAccess (expr.left, "concat"));
- concat_call.add_argument (expr.right);
- concat_call.target_type = expr.target_type;
-
- replaced_nodes.add (expr);
- expr.parent_node.replace_expression (expr, concat_call);
-
- concat_call.accept (this);
+ expr.value_type = string_type.copy ();
+ expr.value_type.value_owned = true;
} else if (expr.operator == BinaryOperator.PLUS
|| expr.operator == BinaryOperator.MINUS
|| expr.operator == BinaryOperator.MUL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]