]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Add BinaryOperator.to_string()
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 15 Nov 2018 09:57:06 +0000 (10:57 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 15 Nov 2018 09:57:06 +0000 (10:57 +0100)
vala/valabinaryexpression.vala

index 62c1014e895aad3c031b1ef6a5278e40c55ef1a5..95491d3520c7aa11053475d2471ff004f0c02e8b 100644 (file)
@@ -108,34 +108,8 @@ public class Vala.BinaryExpression : Expression {
                }
        }
 
-       private unowned 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";
-               case BinaryOperator.COALESCE: return "??";
-               default: assert_not_reached ();
-               }
-       }
-
        public override string to_string () {
-               return "(%s %s %s)".printf (_left.to_string (), get_operator_string (), _right.to_string ());
+               return "(%s %s %s)".printf (_left.to_string (), operator.to_string (), _right.to_string ());
        }
 
        public override bool is_constant () {
@@ -598,5 +572,31 @@ public enum Vala.BinaryOperator {
        AND,
        OR,
        IN,
-       COALESCE
+       COALESCE;
+
+       public unowned string to_string () {
+               switch (this) {
+               case PLUS: return "+";
+               case MINUS: return "-";
+               case MUL: return "*";
+               case DIV: return "/";
+               case MOD: return "%";
+               case SHIFT_LEFT: return "<<";
+               case SHIFT_RIGHT: return ">>";
+               case LESS_THAN: return "<";
+               case GREATER_THAN: return ">";
+               case LESS_THAN_OR_EQUAL: return "<=";
+               case GREATER_THAN_OR_EQUAL: return ">=";
+               case EQUALITY: return "==";
+               case INEQUALITY: return "!=";
+               case BITWISE_AND: return "&";
+               case BITWISE_OR: return "|";
+               case BITWISE_XOR: return "^";
+               case AND: return "&&";
+               case OR: return "||";
+               case IN: return "in";
+               case COALESCE: return "??";
+               default: assert_not_reached ();
+               }
+       }
 }