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

            Line data    Source code
       1              : /* valaccodememberaccess.vala
       2              :  *
       3              :  * Copyright (C) 2006  Raffaele Sandrini
       4              :  * Copyright (C) 2006-2008  Jürg Billeter
       5              :  *
       6              :  * This library is free software; you can redistribute it and/or
       7              :  * modify it under the terms of the GNU Lesser General Public
       8              :  * License as published by the Free Software Foundation; either
       9              :  * version 2.1 of the License, or (at your option) any later version.
      10              : 
      11              :  * This library is distributed in the hope that it will be useful,
      12              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      14              :  * Lesser General Public License for more details.
      15              : 
      16              :  * You should have received a copy of the GNU Lesser General Public
      17              :  * License along with this library; if not, write to the Free Software
      18              :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
      19              :  *
      20              :  * Author:
      21              :  *      Raffaele Sandrini <raffaele@sandrini.ch>
      22              :  *      Jürg Billeter <j@bitron.ch>
      23              :  */
      24              : 
      25              : using GLib;
      26              : 
      27              : /**
      28              :  * Represents an access to an array member in the C code.
      29              :  */
      30         5202 : public class Vala.CCodeElementAccess : CCodeExpression {
      31              :         /**
      32              :          * Expression representing the container on which we want to access.
      33              :          */
      34         9874 :         public CCodeExpression container { get; set; }
      35              : 
      36              :         /**
      37              :          * Expression representing the index we want to access inside the
      38              :          * container.
      39              :          */
      40         9874 :         public List<CCodeExpression> indices { get; set; }
      41              : 
      42        14763 :         public CCodeElementAccess (CCodeExpression cont, CCodeExpression i) {
      43         4921 :                 container = cont;
      44         4921 :                 indices = new ArrayList<CCodeExpression> ();
      45         4921 :                 indices.add (i);
      46              :         }
      47              : 
      48           48 :         public CCodeElementAccess.with_indices (CCodeExpression cont, List<CCodeExpression> i) {
      49           16 :                 container = cont;
      50           16 :                 indices = i;
      51              :         }
      52              : 
      53         5020 :         public override void write (CCodeWriter writer) {
      54         5020 :                 container.write_inner (writer);
      55         5020 :                 writer.write_string ("[");
      56         5020 :                 bool first = true;
      57        15092 :                 foreach (var index in indices) {
      58         5036 :                         if (!first) {
      59           16 :                                 writer.write_string ("][");
      60              :                         }
      61         5036 :                         index.write (writer);
      62         5036 :                         first = false;
      63              :                 }
      64         5020 :                 writer.write_string ("]");
      65              :         }
      66              : }
        

Generated by: LCOV version 2.0-1