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

            Line data    Source code
       1              : /* valaunresolvedtype.vala
       2              :  *
       3              :  * Copyright (C) 2006-2008  Jürg Billeter, Raffaele Sandrini
       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              :  *      Raffaele Sandrini <raffaele@sandrini.ch>
      22              :  */
      23              : 
      24              : using GLib;
      25              : 
      26              : /**
      27              :  * An unresolved reference to a data type.
      28              :  */
      29     18322143 : public class Vala.UnresolvedType : DataType {
      30              :         /**
      31              :          * The unresolved reference to a type symbol.
      32              :          */
      33     69374410 :         public UnresolvedSymbol unresolved_symbol { get; set; }
      34              : 
      35      2959806 :         public UnresolvedType (SourceReference? source_reference = null) {
      36      1479903 :                 this.source_reference = source_reference;
      37              :         }
      38              : 
      39              :         /**
      40              :          * Creates a new type reference.
      41              :          *
      42              :          * @param symbol    unresolved type symbol
      43              :          * @param source    reference to source code
      44              :          * @return          newly created type reference
      45              :          */
      46     50498661 :         public UnresolvedType.from_symbol (UnresolvedSymbol symbol, SourceReference? source_reference = null) {
      47     16832887 :                 this.unresolved_symbol = symbol;
      48     16832887 :                 this.source_reference = source_reference;
      49              :         }
      50              : 
      51              :         /**
      52              :          * Creates a new type reference from a code expression.
      53              :          *
      54              :          * @param expr   member access expression
      55              :          * @return       newly created type reference
      56              :          */
      57        15630 :         public UnresolvedType.from_expression (MemberAccess expr) {
      58         7815 :                 unresolved_symbol = new UnresolvedSymbol.from_expression (expr);
      59         7815 :                 source_reference = expr.source_reference;
      60         7815 :                 value_owned = true;
      61              : 
      62         7823 :                 foreach (DataType arg in expr.get_type_arguments ()) {
      63            4 :                         add_type_argument (arg);
      64              :                 }
      65              :         }
      66              : 
      67      1446024 :         public override DataType copy () {
      68      1446024 :                 var result = new UnresolvedType (source_reference);
      69      1446024 :                 result.value_owned = value_owned;
      70      1446024 :                 result.nullable = nullable;
      71      1446024 :                 result.is_dynamic = is_dynamic;
      72      1446024 :                 result.unresolved_symbol = unresolved_symbol.copy ();
      73              : 
      74      1567562 :                 foreach (DataType arg in get_type_arguments ()) {
      75        60769 :                         result.add_type_argument (arg.copy ());
      76              :                 }
      77              : 
      78      1446024 :                 return result;
      79              :         }
      80              : 
      81          216 :         public override string to_qualified_string (Scope? scope) {
      82          216 :                 var s = unresolved_symbol.to_string ();
      83              : 
      84          216 :                 var type_args = get_type_arguments ();
      85          216 :                 if (type_args.size > 0) {
      86            0 :                         s += "<";
      87            0 :                         bool first = true;
      88            0 :                         foreach (DataType type_arg in type_args) {
      89            0 :                                 if (!first) {
      90            0 :                                         s += ",";
      91              :                                 } else {
      92              :                                         first = false;
      93              :                                 }
      94            0 :                                 if (type_arg.is_weak ()) {
      95            0 :                                         s += "weak ";
      96              :                                 }
      97            0 :                                 s += type_arg.to_qualified_string (scope);
      98              :                         }
      99            0 :                         s += ">";
     100              :                 }
     101          216 :                 if (nullable) {
     102            1 :                         s += "?";
     103              :                 }
     104              : 
     105          216 :                 return s;
     106              :         }
     107              : 
     108            0 :         public override bool is_disposable () {
     109            0 :                 return value_owned;
     110              :         }
     111              : }
        

Generated by: LCOV version 2.0-1