support binary expressions in default arguments
authorJuerg Billeter <j@bitron.ch>
Fri, 29 Feb 2008 21:41:44 +0000 (21:41 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Fri, 29 Feb 2008 21:41:44 +0000 (21:41 +0000)
2008-02-29  Juerg Billeter  <j@bitron.ch>

* vala/valabinaryexpression.vala, vala/valaunaryexpression.vala:
  support binary expressions in default arguments

svn path=/trunk/; revision=1067

ChangeLog
vala/valabinaryexpression.vala
vala/valaunaryexpression.vala

index 87e4477..495dc1c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2008-02-29  Jürg Billeter  <j@bitron.ch>
 
+       * vala/valabinaryexpression.vala, vala/valaunaryexpression.vala:
+         support binary expressions in default arguments
+
+2008-02-29  Jürg Billeter  <j@bitron.ch>
+
        * gobject/valaccodegeneratorinterface.vala,
          gobject/valaccodegeneratorsignal.vala: support GLib.Error as
          signal parameter type, fixes bug 519415
index 7a7665d..e60acc4 100644 (file)
@@ -1,6 +1,6 @@
 /* valabinaryexpression.vala
  *
- * Copyright (C) 2006-2007  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
@@ -94,6 +94,36 @@ public class Vala.BinaryExpression : Expression {
                }
        }
 
+       private string! get_operator_string () {
+               switch (_operator) {
+               case BinaryOperator.PLUS: return "+";
+               case BinaryOperator.MINUS: return "-";
+               case BinaryOperator.MUL: return "*";
+               case BinaryOperator.DIV: return "/";
+               case BinaryOperator.MOD: return "%";
+               case BinaryOperator.SHIFT_LEFT: return "<<";
+               case BinaryOperator.SHIFT_RIGHT: return ">>";
+               case BinaryOperator.LESS_THAN: return "<";
+               case BinaryOperator.GREATER_THAN: return ">";
+               case BinaryOperator.LESS_THAN_OR_EQUAL: return "<=";
+               case BinaryOperator.GREATER_THAN_OR_EQUAL: return ">=";
+               case BinaryOperator.EQUALITY: return "==";
+               case BinaryOperator.INEQUALITY: return "!+";
+               case BinaryOperator.BITWISE_AND: return "&";
+               case BinaryOperator.BITWISE_OR: return "|";
+               case BinaryOperator.BITWISE_XOR: return "^";
+               case BinaryOperator.AND: return "&&";
+               case BinaryOperator.OR: return "||";
+               case BinaryOperator.IN: return "in";
+               }
+
+               assert_not_reached ();
+       }
+
+       public override string! to_string () {
+               return _left.to_string () + get_operator_string () + _right.to_string ();
+       }
+
        public override bool is_pure () {
                return left.is_pure () && right.is_pure ();
        }
index c4653c2..5b34458 100644 (file)
@@ -1,6 +1,6 @@
 /* valaunaryexpression.vala
  *
- * Copyright (C) 2006-2007  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
@@ -74,25 +74,23 @@ public class Vala.UnaryExpression : Expression {
                }
        }
 
-       public string! operator_string {
-               get {
-                       switch (_operator) {
-                               case UnaryOperator.PLUS: return "+";
-                               case UnaryOperator.MINUS: return "-";
-                               case UnaryOperator.LOGICAL_NEGATION: return "!";
-                               case UnaryOperator.BITWISE_COMPLEMENT: return "~";
-                               case UnaryOperator.INCREMENT: return "++";
-                               case UnaryOperator.DECREMENT: return "--";
-                               case UnaryOperator.REF: return "ref ";
-                               case UnaryOperator.OUT: return "out ";
-                       }
-
-                       assert_not_reached ();
+       private string! get_operator_string () {
+               switch (_operator) {
+               case UnaryOperator.PLUS: return "+";
+               case UnaryOperator.MINUS: return "-";
+               case UnaryOperator.LOGICAL_NEGATION: return "!";
+               case UnaryOperator.BITWISE_COMPLEMENT: return "~";
+               case UnaryOperator.INCREMENT: return "++";
+               case UnaryOperator.DECREMENT: return "--";
+               case UnaryOperator.REF: return "ref ";
+               case UnaryOperator.OUT: return "out ";
                }
+
+               assert_not_reached ();
        }
 
        public override string! to_string () {
-               return operator_string + _inner.to_string ();
+               return get_operator_string () + _inner.to_string ();
        }
 
        public override bool is_pure () {