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

            Line data    Source code
       1              : /* valadestructor.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 class or instance destructor.
      27              :  */
      28           44 : public class Vala.Destructor : Subroutine {
      29              :         /**
      30              :          * Specifies the generated `this` parameter for instance methods.
      31              :          */
      32          166 :         public Parameter? this_parameter { get; set; }
      33              : 
      34              :         /**
      35              :          * Specifies whether this is an instance or a class destructor.
      36              :          */
      37          134 :         public MemberBinding binding { get; set; default = MemberBinding.INSTANCE; }
      38              : 
      39              :         public override bool has_result {
      40            0 :                 get { return false; }
      41              :         }
      42              : 
      43              :         /**
      44              :          * Creates a new destructor.
      45              :          *
      46              :          * @param source_reference reference to source code
      47              :          * @return                 newly created destructor
      48              :          */
      49           26 :         public Destructor (SourceReference? source_reference = null) {
      50           26 :                 base (null, source_reference);
      51              :         }
      52              : 
      53           69 :         public override void accept (CodeVisitor visitor) {
      54           69 :                 visitor.visit_destructor (this);
      55              :         }
      56              : 
      57           17 :         public override void accept_children (CodeVisitor visitor) {
      58           17 :                 if (body != null) {
      59           17 :                         body.accept (visitor);
      60              :                 }
      61              :         }
      62              : 
      63           17 :         public override bool check (CodeContext context) {
      64           17 :                 if (checked) {
      65            0 :                         return !error;
      66              :                 }
      67              : 
      68           17 :                 checked = true;
      69              : 
      70           17 :                 if (this_parameter != null) {
      71           16 :                         this_parameter.check (context);
      72              :                 }
      73              : 
      74           17 :                 var old_symbol = context.analyzer.current_symbol;
      75           17 :                 context.analyzer.current_symbol = this;
      76              : 
      77           17 :                 if (body != null) {
      78           17 :                         body.check (context);
      79              :                 }
      80              : 
      81           34 :                 if (body != null && !body.error) {
      82           17 :                         var body_errors = new ArrayList<DataType> ();
      83           17 :                         body.get_error_types (body_errors);
      84           21 :                         foreach (DataType body_error_type in body_errors) {
      85            2 :                                 if (!((ErrorType) body_error_type).dynamic_error) {
      86            2 :                                         Report.warning (body_error_type.source_reference, "unhandled error `%s'", body_error_type.to_string());
      87              :                                 }
      88              :                         }
      89              :                 }
      90              : 
      91           17 :                 context.analyzer.current_symbol = old_symbol;
      92              : 
      93           17 :                 return !error;
      94              :         }
      95              : }
        

Generated by: LCOV version 2.0-1