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

            Line data    Source code
       1              : /* valadeletestatement.vala
       2              :  *
       3              :  * Copyright (C) 2008-2011  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              : /**
      24              :  * Represents a delete statement.
      25              :  *
      26              :  * {{{ delete foo; }}}
      27              :  */
      28           12 : public class Vala.DeleteStatement : CodeNode, Statement {
      29              :         /**
      30              :          * Expression representing the instance to be freed.
      31              :          */
      32              :         public Expression expression {
      33           35 :                 get { return _expression; }
      34            6 :                 private set {
      35            6 :                         _expression = value;
      36            6 :                         _expression.parent_node = this;
      37              :                 }
      38              :         }
      39              : 
      40            6 :         private Expression _expression;
      41              : 
      42           18 :         public DeleteStatement (Expression expression, SourceReference? source_reference = null) {
      43            6 :                 this.expression = expression;
      44            6 :                 this.source_reference = source_reference;
      45              :         }
      46              : 
      47           11 :         public override void accept (CodeVisitor visitor) {
      48           11 :                 visitor.visit_delete_statement (this);
      49              :         }
      50              : 
      51            6 :         public override void accept_children (CodeVisitor visitor) {
      52            6 :                 expression.accept (visitor);
      53              :         }
      54              : 
      55            0 :         public override void replace_expression (Expression old_node, Expression new_node) {
      56            0 :                 if (expression == old_node) {
      57            0 :                         expression = new_node;
      58              :                 }
      59              :         }
      60              : 
      61            6 :         public override bool check (CodeContext context) {
      62            6 :                 if (checked) {
      63            0 :                         return !error;
      64              :                 }
      65              : 
      66            6 :                 checked = true;
      67              : 
      68            6 :                 if (!expression.check (context)) {
      69              :                         // if there was an error in the inner expression, skip this check
      70            0 :                         error = true;
      71            0 :                         return false;
      72              :                 }
      73              : 
      74            6 :                 if (!(expression.value_type is PointerType) && !(expression.value_type is ArrayType)) {
      75            1 :                         error = true;
      76            1 :                         Report.error (source_reference, "delete operator not supported for `%s'", expression.value_type.to_string ());
      77              :                 }
      78              : 
      79            6 :                 return !error;
      80              :         }
      81              : 
      82            5 :         public override void emit (CodeGenerator codegen) {
      83            5 :                 expression.emit (codegen);
      84              : 
      85            5 :                 codegen.visit_delete_statement (this);
      86              :         }
      87              : }
        

Generated by: LCOV version 2.0-1