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

            Line data    Source code
       1              : /* valavaluetype.vala
       2              :  *
       3              :  * Copyright (C) 2007-2009  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              :  * A value type, i.e. a struct or an enum type.
      27              :  */
      28         1537 : public abstract class Vala.ValueType : DataType {
      29     25597104 :         protected ValueType (TypeSymbol type_symbol, SourceReference? source_reference = null) {
      30     12798552 :                 base.with_symbol (type_symbol, source_reference);
      31              :         }
      32              : 
      33       576881 :         public override bool is_disposable () {
      34       576881 :                 if (!value_owned) {
      35       288969 :                         return false;
      36              :                 }
      37              : 
      38              :                 // nullable structs are heap allocated
      39       302464 :                 if (nullable) {
      40       576881 :                         return true;
      41              :                 }
      42              : 
      43       301684 :                 unowned Struct? st = type_symbol as Struct;
      44       287133 :                 if (st != null && !st.error) {
      45       287132 :                         return st.is_disposable ();
      46              :                 }
      47              : 
      48       576881 :                 return false;
      49              :         }
      50              : 
      51     13936864 :         public override bool check (CodeContext context) {
      52     13936864 :                 if (!type_symbol.check (context)) {
      53            2 :                         error = true;
      54            2 :                         return false;
      55              :                 }
      56              : 
      57              :                 // check whether there is the expected amount of type-arguments
      58     13936862 :                 if (!check_type_arguments (context, true)) {
      59            0 :                         error = true;
      60            0 :                         return false;
      61              :                 }
      62              : 
      63     13936864 :                 return true;
      64              :         }
      65              : }
        

Generated by: LCOV version 2.0-1