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

            Line data    Source code
       1              : /* valatuple.vala
       2              :  *
       3              :  * Copyright (C) 2006-2010  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 a fixed-length sequence of expressions in the source code.
      27              :  */
      28            5 : public class Vala.Tuple : Expression {
      29            4 :         private List<Expression> expression_list = new ArrayList<Expression> ();
      30              : 
      31            4 :         public Tuple (SourceReference? source_reference = null) {
      32            2 :                 this.source_reference = source_reference;
      33              :         }
      34              : 
      35            2 :         public override void accept_children (CodeVisitor visitor) {
      36           10 :                 foreach (Expression expr in expression_list) {
      37            4 :                         expr.accept (visitor);
      38              :                 }
      39              :         }
      40              : 
      41            2 :         public override void accept (CodeVisitor visitor) {
      42            2 :                 visitor.visit_tuple (this);
      43              : 
      44            2 :                 visitor.visit_expression (this);
      45              :         }
      46              : 
      47            4 :         public void add_expression (Expression expr) {
      48            4 :                 expression_list.add (expr);
      49            4 :                 expr.parent_node = this;
      50              :         }
      51              : 
      52            2 :         public unowned List<Expression> get_expressions () {
      53            2 :                 return expression_list;
      54              :         }
      55              : 
      56            0 :         public override bool is_pure () {
      57            0 :                 return false;
      58              :         }
      59              : 
      60            0 :         public override void replace_expression (Expression old_node, Expression new_node) {
      61            0 :                 for (int i = 0; i < expression_list.size; i++) {
      62            0 :                         if (expression_list[i] == old_node) {
      63            0 :                                 expression_list[i] = new_node;
      64            0 :                                 new_node.parent_node = this;
      65              :                         }
      66              :                 }
      67              :         }
      68              : 
      69            0 :         public override bool check (CodeContext context) {
      70            0 :                 if (checked) {
      71            0 :                         return !error;
      72              :                 }
      73              : 
      74            0 :                 checked = true;
      75              : 
      76            0 :                 Report.error (source_reference, "tuples are not supported");
      77            0 :                 error = true;
      78            0 :                 return false;
      79              :         }
      80              : 
      81            0 :         public override void emit (CodeGenerator codegen) {
      82            0 :                 foreach (Expression expr in expression_list) {
      83            0 :                         expr.emit (codegen);
      84              :                 }
      85              : 
      86            0 :                 codegen.visit_tuple (this);
      87              : 
      88            0 :                 codegen.visit_expression (this);
      89              :         }
      90              : }
        

Generated by: LCOV version 2.0-1