vala r2092 - in trunk: . ccode gobject
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r2092 - in trunk: . ccode gobject
- Date: Sun, 30 Nov 2008 08:51:08 +0000 (UTC)
Author: juergbi
Date: Sun Nov 30 08:51:08 2008
New Revision: 2092
URL: http://svn.gnome.org/viewvc/vala?rev=2092&view=rev
Log:
2008-11-30 JÃrg Billeter <j bitron ch>
* ccode/valaccodeassignment.vala:
* ccode/valaccodeconditionalexpression.vala:
* gobject/valaccodearraymodule.vala:
* gobject/valaccodeassignmentmodule.vala:
* gobject/valaccodebasemodule.vala:
* gobject/valaccodecontrolflowmodule.vala:
* gobject/valaccodedelegatemodule.vala:
* gobject/valaccodemethodcallmodule.vala:
More parenthesis improvements
Modified:
trunk/ChangeLog
trunk/ccode/valaccodeassignment.vala
trunk/ccode/valaccodeconditionalexpression.vala
trunk/gobject/valaccodearraymodule.vala
trunk/gobject/valaccodeassignmentmodule.vala
trunk/gobject/valaccodebasemodule.vala
trunk/gobject/valaccodecontrolflowmodule.vala
trunk/gobject/valaccodedelegatemodule.vala
trunk/gobject/valaccodemethodcallmodule.vala
Modified: trunk/ccode/valaccodeassignment.vala
==============================================================================
--- trunk/ccode/valaccodeassignment.vala (original)
+++ trunk/ccode/valaccodeassignment.vala Sun Nov 30 08:51:08 2008
@@ -78,6 +78,12 @@
right.write (writer);
}
+
+ public override void write_inner (CCodeWriter writer) {
+ writer.write_string ("(");
+ this.write (writer);
+ writer.write_string (")");
+ }
}
public enum Vala.CCodeAssignmentOperator {
Modified: trunk/ccode/valaccodeconditionalexpression.vala
==============================================================================
--- trunk/ccode/valaccodeconditionalexpression.vala (original)
+++ trunk/ccode/valaccodeconditionalexpression.vala Sun Nov 30 08:51:08 2008
@@ -1,6 +1,6 @@
/* valaccodeconditionalexpression.vala
*
- * Copyright (C) 2006 JÃrg Billeter
+ * Copyright (C) 2006-2008 JÃrg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -48,12 +48,16 @@
}
public override void write (CCodeWriter writer) {
- writer.write_string ("(");
- condition.write (writer);
+ condition.write_inner (writer);
writer.write_string (" ? ");
- true_expression.write (writer);
+ true_expression.write_inner (writer);
writer.write_string (" : ");
- false_expression.write (writer);
+ false_expression.write_inner (writer);
+ }
+
+ public override void write_inner (CCodeWriter writer) {
+ writer.write_string ("(");
+ this.write (writer);
writer.write_string (")");
}
}
Modified: trunk/gobject/valaccodearraymodule.vala
==============================================================================
--- trunk/gobject/valaccodearraymodule.vala (original)
+++ trunk/gobject/valaccodearraymodule.vala Sun Nov 30 08:51:08 2008
@@ -53,7 +53,7 @@
temp_vars.insert (0, temp_var);
- csize = new CCodeParenthesizedExpression (new CCodeAssignment (name_cnode, csize));
+ csize = new CCodeAssignment (name_cnode, csize);
}
if (first) {
@@ -147,7 +147,7 @@
CCodeExpression length_expr = new CCodeIdentifier (get_array_length_cname (param.name, dim));
if (param.direction != ParameterDirection.IN) {
// accessing argument of out/ref param
- length_expr = new CCodeParenthesizedExpression (new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, length_expr));
+ length_expr = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, length_expr);
}
if (is_out) {
// passing array as out/ref
@@ -283,8 +283,8 @@
} else {
// access to element in an array
for (int i = 1; i < rank; i++) {
- var cmul = new CCodeBinaryExpression (CCodeBinaryOperator.MUL, new CCodeParenthesizedExpression (cindex), head.get_array_length_cexpression (expr.container, i + 1));
- cindex = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, cmul, new CCodeParenthesizedExpression ((CCodeExpression) indices[i].ccodenode));
+ var cmul = new CCodeBinaryExpression (CCodeBinaryOperator.MUL, cindex, head.get_array_length_cexpression (expr.container, i + 1));
+ cindex = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, cmul, (CCodeExpression) indices[i].ccodenode);
}
expr.ccodenode = new CCodeElementAccess (ccontainer, cindex);
}
@@ -368,7 +368,7 @@
var dest = new CCodeIdentifier ("dest");
var src_address = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, array, new CCodeBinaryExpression (CCodeBinaryOperator.MUL, src, element_size));
var dest_address = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, array, new CCodeBinaryExpression (CCodeBinaryOperator.MUL, dest, element_size));
- var dest_end_address = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, array, new CCodeBinaryExpression (CCodeBinaryOperator.MUL, new CCodeParenthesizedExpression (new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, dest, length)), element_size));
+ var dest_end_address = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, array, new CCodeBinaryExpression (CCodeBinaryOperator.MUL, new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, dest, length), element_size));
fun.block = new CCodeBlock ();
@@ -381,14 +381,14 @@
var czero1 = new CCodeFunctionCall (new CCodeIdentifier ("memset"));
czero1.add_argument (src_address);
czero1.add_argument (new CCodeConstant ("0"));
- czero1.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.MUL, new CCodeParenthesizedExpression (new CCodeBinaryExpression (CCodeBinaryOperator.MINUS, dest, src)), element_size));
+ czero1.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.MUL, new CCodeBinaryExpression (CCodeBinaryOperator.MINUS, dest, src), element_size));
var czeroblock1 = new CCodeBlock ();
czeroblock1.add_statement (new CCodeExpressionStatement (czero1));
var czero2 = new CCodeFunctionCall (new CCodeIdentifier ("memset"));
czero2.add_argument (dest_end_address);
czero2.add_argument (new CCodeConstant ("0"));
- czero2.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.MUL, new CCodeParenthesizedExpression (new CCodeBinaryExpression (CCodeBinaryOperator.MINUS, src, dest)), element_size));
+ czero2.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.MUL, new CCodeBinaryExpression (CCodeBinaryOperator.MINUS, src, dest), element_size));
var czeroblock2 = new CCodeBlock ();
czeroblock2.add_statement (new CCodeExpressionStatement (czero2));
Modified: trunk/gobject/valaccodeassignmentmodule.vala
==============================================================================
--- trunk/gobject/valaccodeassignmentmodule.vala (original)
+++ trunk/gobject/valaccodeassignmentmodule.vala Sun Nov 30 08:51:08 2008
@@ -73,7 +73,7 @@
} else {
assert_not_reached ();
}
- cexpr = new CCodeBinaryExpression (cop, (CCodeExpression) get_ccodenode (assignment.left), new CCodeParenthesizedExpression (cexpr));
+ cexpr = new CCodeBinaryExpression (cop, (CCodeExpression) get_ccodenode (assignment.left), cexpr);
}
var ccall = get_property_set_call (prop, ma, cexpr);
Modified: trunk/gobject/valaccodebasemodule.vala
==============================================================================
--- trunk/gobject/valaccodebasemodule.vala (original)
+++ trunk/gobject/valaccodebasemodule.vala Sun Nov 30 08:51:08 2008
@@ -231,7 +231,7 @@
source_type_member_declaration.append (fun.copy ());
// (str1 != str2)
- var cineq = new CCodeParenthesizedExpression (new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, new CCodeIdentifier ("str1"), new CCodeIdentifier ("str2")));
+ var cineq = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, new CCodeIdentifier ("str1"), new CCodeIdentifier ("str2"));
fun.block = new CCodeBlock ();
@@ -1721,10 +1721,10 @@
bool uses_gfree = (type.data_type != null && !type.data_type.is_reference_counting () && type.data_type.get_free_function () == "g_free");
uses_gfree = uses_gfree || type is ArrayType;
if (uses_gfree) {
- return new CCodeParenthesizedExpression (cassign);
+ return cassign;
}
- return new CCodeConditionalExpression (cisnull, new CCodeConstant ("NULL"), new CCodeParenthesizedExpression (cassign));
+ return new CCodeConditionalExpression (cisnull, new CCodeConstant ("NULL"), cassign);
}
public override void visit_end_full_expression (Expression expr) {
@@ -2782,7 +2782,7 @@
} else if (expr.operator == BinaryOperator.OR) {
op = CCodeBinaryOperator.OR;
} else if (expr.operator == BinaryOperator.IN) {
- expr.ccodenode = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, new CCodeParenthesizedExpression (new CCodeBinaryExpression (CCodeBinaryOperator.BITWISE_AND, new CCodeParenthesizedExpression (cright), new CCodeParenthesizedExpression (cleft))), new CCodeParenthesizedExpression (cleft));
+ expr.ccodenode = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, new CCodeBinaryExpression (CCodeBinaryOperator.BITWISE_AND, cright, cleft), cleft);
return;
} else {
assert_not_reached ();
@@ -2986,7 +2986,7 @@
var decl = get_temp_variable (expression_type, true, expression_type);
temp_vars.insert (0, decl);
temp_ref_vars.insert (0, decl);
- cexpr = new CCodeParenthesizedExpression (new CCodeAssignment (new CCodeIdentifier (get_variable_cname (decl.name)), cexpr));
+ cexpr = new CCodeAssignment (new CCodeIdentifier (get_variable_cname (decl.name)), cexpr);
if (expression_type is ArrayType && expr != null) {
var array_type = (ArrayType) expression_type;
Modified: trunk/gobject/valaccodecontrolflowmodule.vala
==============================================================================
--- trunk/gobject/valaccodecontrolflowmodule.vala (original)
+++ trunk/gobject/valaccodecontrolflowmodule.vala Sun Nov 30 08:51:08 2008
@@ -113,7 +113,7 @@
var cname = new CCodeIdentifier ("%s_label%d".printf (temp_var.name, label_count++));
var ccond = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, czero, cname);
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_quark_from_static_string"));
- var cinit = new CCodeParenthesizedExpression (new CCodeAssignment (cname, ccall));
+ var cinit = new CCodeAssignment (cname, ccall);
ccall.add_argument (cexpr);
@@ -391,7 +391,7 @@
var ccond_term2 = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, new CCodeElementAccess (new CCodeIdentifier (collection_backup.name), new CCodeIdentifier (it_name)), new CCodeConstant ("NULL"));
var ccond_term = new CCodeBinaryExpression (CCodeBinaryOperator.AND, ccond_term1, ccond_term2);
- ccond = new CCodeBinaryExpression (CCodeBinaryOperator.OR, new CCodeParenthesizedExpression (ccond_ind), new CCodeParenthesizedExpression (ccond_term));
+ ccond = new CCodeBinaryExpression (CCodeBinaryOperator.OR, ccond_ind, ccond_term);
} else {
/* assert when trying to iterate over value-type arrays of unknown length */
var cassert = new CCodeFunctionCall (new CCodeIdentifier ("g_assert"));
Modified: trunk/gobject/valaccodedelegatemodule.vala
==============================================================================
--- trunk/gobject/valaccodedelegatemodule.vala (original)
+++ trunk/gobject/valaccodedelegatemodule.vala Sun Nov 30 08:51:08 2008
@@ -97,7 +97,7 @@
CCodeExpression target_expr = new CCodeIdentifier (get_delegate_target_cname (param.name));
if (param.direction != ParameterDirection.IN) {
// accessing argument of out/ref param
- target_expr = new CCodeParenthesizedExpression (new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, target_expr));
+ target_expr = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, target_expr);
}
if (is_out) {
// passing array as out/ref
Modified: trunk/gobject/valaccodemethodcallmodule.vala
==============================================================================
--- trunk/gobject/valaccodemethodcallmodule.vala (original)
+++ trunk/gobject/valaccodemethodcallmodule.vala Sun Nov 30 08:51:08 2008
@@ -447,7 +447,7 @@
var celems = (CCodeExpression) ma.inner.ccodenode;
var array_type = (ArrayType) ma.inner.value_type;
var csizeof = new CCodeIdentifier ("sizeof (%s)".printf (array_type.element_type.get_cname ()));
- var cdelta = new CCodeParenthesizedExpression (new CCodeBinaryExpression (CCodeBinaryOperator.MINUS, temp_ref, clen));
+ var cdelta = new CCodeBinaryExpression (CCodeBinaryOperator.MINUS, temp_ref, clen);
var ccheck = new CCodeBinaryExpression (CCodeBinaryOperator.GREATER_THAN, temp_ref, clen);
var czero = new CCodeFunctionCall (new CCodeIdentifier ("memset"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]