LCOV - code coverage report
Current view: top level - ccode - valaccodebinarycompareexpression.vala (source / functions) Coverage Total Hit
Test: vala 0.57.0.298-a8cae1 Lines: 95.7 % 23 22
Test Date: 2024-04-25 11:34:36 Functions: - 0 0

            Line data    Source code
       1              : /* valaccodebinarycompareexpression.vala
       2              :  *
       3              :  * Copyright (C) 2022  Rico Tzschichholz
       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              :  *      Rico Tzschichholz <ricotz@ubuntu.com>
      21              :  */
      22              : 
      23              : /**
      24              :  * Represents an expression comparing two operands checking against a non-boolean result in C code.
      25              :  */
      26         1993 : public class Vala.CCodeBinaryCompareExpression : CCodeBinaryExpression {
      27              :         /**
      28              :          * The compare function.
      29              :          */
      30         5316 :         public CCodeExpression call { get; set; }
      31              : 
      32              :         /**
      33              :          * The expected result.
      34              :          */
      35         5316 :         public CCodeExpression result { get; set; }
      36              : 
      37         5316 :         public CCodeBinaryCompareExpression (CCodeExpression cmp, CCodeBinaryOperator op, CCodeExpression l, CCodeExpression r, CCodeExpression res) {
      38         1772 :                 base (op, l, r);
      39         1772 :                 call = cmp;
      40         1772 :                 result = res;
      41              :         }
      42              : 
      43         1772 :         public override void write (CCodeWriter writer) {
      44         1772 :                 call.write_inner (writer);
      45         1772 :                 writer.write_string (" (");
      46         1772 :                 left.write (writer);
      47         1772 :                 writer.write_string (", ");
      48         1772 :                 right.write (writer);
      49         1772 :                 writer.write_string (")");
      50              : 
      51         1772 :                 switch (operator) {
      52            5 :                 case CCodeBinaryOperator.LESS_THAN: writer.write_string (" < "); break;
      53            5 :                 case CCodeBinaryOperator.GREATER_THAN: writer.write_string (" > "); break;
      54            6 :                 case CCodeBinaryOperator.LESS_THAN_OR_EQUAL: writer.write_string (" <= "); break;
      55            4 :                 case CCodeBinaryOperator.GREATER_THAN_OR_EQUAL: writer.write_string (" >= "); break;
      56         1664 :                 case CCodeBinaryOperator.EQUALITY: writer.write_string (" == "); break;
      57           88 :                 case CCodeBinaryOperator.INEQUALITY: writer.write_string (" != "); break;
      58            0 :                 default: assert_not_reached ();
      59              :                 }
      60              : 
      61         1772 :                 result.write_inner (writer);
      62              :         }
      63              : }
        

Generated by: LCOV version 2.0-1