LCOV - code coverage report
Current view: top level - ccode - valaccodebinaryexpression.vala (source / functions) Coverage Total Hit
Test: vala 0.57.0.253-297e8 Lines: 97.1 % 35 34
Test Date: 2024-02-21 16:21:37 Functions: - 0 0

            Line data    Source code
       1              : /* valaccodebinaryexpression.vala
       2              :  *
       3              :  * Copyright (C) 2006-2008  Jürg Billeter
       4              :  *
       5              :  * This library is free software; you can redistribute it and/or
       6              :  * modify it under the terms of the GNU Lesser General Public
       7              :  * License as published by the Free Software Foundation; either
       8              :  * version 2.1 of the License, or (at your option) any later version.
       9              : 
      10              :  * This library is distributed in the hope that it will be useful,
      11              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      12              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13              :  * Lesser General Public License for more details.
      14              : 
      15              :  * You should have received a copy of the GNU Lesser General Public
      16              :  * License along with this library; if not, write to the Free Software
      17              :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
      18              :  *
      19              :  * Author:
      20              :  *      Jürg Billeter <j@bitron.ch>
      21              :  */
      22              : 
      23              : using GLib;
      24              : 
      25              : /**
      26              :  * Represents an expression with two operands in C code.
      27              :  */
      28        22233 : public class Vala.CCodeBinaryExpression : CCodeExpression {
      29              :         /**
      30              :          * The binary operator.
      31              :          */
      32        23225 :         public CCodeBinaryOperator operator { get; set; }
      33              : 
      34              :         /**
      35              :          * The left operand.
      36              :          */
      37        66165 :         public CCodeExpression left { get; set; }
      38              : 
      39              :         /**
      40              :          * The right operand.
      41              :          */
      42        66198 :         public CCodeExpression right { get; set; }
      43              : 
      44        62603 :         public CCodeBinaryExpression (CCodeBinaryOperator op, CCodeExpression l, CCodeExpression r) {
      45        21457 :                 operator = op;
      46        21457 :                 left = l;
      47        21457 :                 right = r;
      48              :         }
      49              : 
      50        18015 :         public override void write (CCodeWriter writer) {
      51        18015 :                 left.write_inner (writer);
      52              : 
      53        18015 :                 switch (operator) {
      54         1895 :                 case CCodeBinaryOperator.PLUS: writer.write_string (" + "); break;
      55          366 :                 case CCodeBinaryOperator.MINUS: writer.write_string (" - "); break;
      56          435 :                 case CCodeBinaryOperator.MUL: writer.write_string (" * "); break;
      57           57 :                 case CCodeBinaryOperator.DIV: writer.write_string (" / "); break;
      58           11 :                 case CCodeBinaryOperator.MOD: writer.write_string (" % "); break;
      59           26 :                 case CCodeBinaryOperator.SHIFT_LEFT: writer.write_string (" << "); break;
      60            3 :                 case CCodeBinaryOperator.SHIFT_RIGHT: writer.write_string (" >> "); break;
      61          787 :                 case CCodeBinaryOperator.LESS_THAN: writer.write_string (" < "); break;
      62          267 :                 case CCodeBinaryOperator.GREATER_THAN: writer.write_string (" > "); break;
      63           91 :                 case CCodeBinaryOperator.LESS_THAN_OR_EQUAL: writer.write_string (" <= "); break;
      64          201 :                 case CCodeBinaryOperator.GREATER_THAN_OR_EQUAL: writer.write_string (" >= "); break;
      65         6920 :                 case CCodeBinaryOperator.EQUALITY: writer.write_string (" == "); break;
      66         6336 :                 case CCodeBinaryOperator.INEQUALITY: writer.write_string (" != "); break;
      67          260 :                 case CCodeBinaryOperator.BITWISE_AND: writer.write_string (" & "); break;
      68           28 :                 case CCodeBinaryOperator.BITWISE_OR: writer.write_string (" | "); break;
      69            6 :                 case CCodeBinaryOperator.BITWISE_XOR: writer.write_string (" ^ "); break;
      70          223 :                 case CCodeBinaryOperator.AND: writer.write_string (" && "); break;
      71          103 :                 case CCodeBinaryOperator.OR: writer.write_string (" || "); break;
      72            0 :                 default: assert_not_reached ();
      73              :                 }
      74              : 
      75        18015 :                 right.write_inner (writer);
      76              :         }
      77              : 
      78         3183 :         public override void write_inner (CCodeWriter writer) {
      79         3183 :                 writer.write_string ("(");
      80         3183 :                 this.write (writer);
      81         3183 :                 writer.write_string (")");
      82              :         }
      83              : }
      84              : 
      85              : public enum Vala.CCodeBinaryOperator {
      86              :         PLUS,
      87              :         MINUS,
      88              :         MUL,
      89              :         DIV,
      90              :         MOD,
      91              :         SHIFT_LEFT,
      92              :         SHIFT_RIGHT,
      93              :         LESS_THAN,
      94              :         GREATER_THAN,
      95              :         LESS_THAN_OR_EQUAL,
      96              :         GREATER_THAN_OR_EQUAL,
      97              :         EQUALITY,
      98              :         INEQUALITY,
      99              :         BITWISE_AND,
     100              :         BITWISE_OR,
     101              :         BITWISE_XOR,
     102              :         AND,
     103              :         OR
     104              : }
        

Generated by: LCOV version 2.0-1