LCOV - code coverage report
Current view: top level - ccode - valaccodeelementaccess.vala (source / functions) Coverage Total Hit
Test: vala 0.57.0.253-297e8 Lines: 100.0 % 20 20
Test Date: 2024-02-21 16:21:37 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         5178 : public class Vala.CCodeElementAccess : CCodeExpression {
      31              :         /**
      32              :          * Expression representing the container on which we want to access.
      33              :          */
      34         9830 :         public CCodeExpression container { get; set; }
      35              : 
      36              :         /**
      37              :          * Expression representing the index we want to access inside the
      38              :          * container.
      39              :          */
      40         9830 :         public List<CCodeExpression> indices { get; set; }
      41              : 
      42        14697 :         public CCodeElementAccess (CCodeExpression cont, CCodeExpression i) {
      43         4899 :                 container = cont;
      44         4899 :                 indices = new ArrayList<CCodeExpression> ();
      45         4899 :                 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         4996 :         public override void write (CCodeWriter writer) {
      54         4996 :                 container.write_inner (writer);
      55         4996 :                 writer.write_string ("[");
      56         4996 :                 bool first = true;
      57        15020 :                 foreach (var index in indices) {
      58         5012 :                         if (!first) {
      59           16 :                                 writer.write_string ("][");
      60              :                         }
      61         5012 :                         index.write (writer);
      62         5012 :                         first = false;
      63              :                 }
      64         4996 :                 writer.write_string ("]");
      65              :         }
      66              : }
        

Generated by: LCOV version 2.0-1