Line data Source code
1 : /* valaloop.vala
2 : *
3 : * Copyright (C) 2021 Rico Tzschichholz
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 : * Rico Tzschichholz <ricotz@ubuntu.com>
21 : */
22 :
23 : /**
24 : * Base class for all loop statements.
25 : */
26 29709 : public abstract class Vala.Loop : CodeNode {
27 : /**
28 : * Specifies the loop condition.
29 : */
30 : public Expression? condition {
31 143571 : get {
32 143571 : return _condition;
33 : }
34 28172 : private set {
35 56344 : _condition = value;
36 28172 : if (_condition != null) {
37 28171 : _condition.parent_node = this;
38 : }
39 : }
40 : }
41 :
42 : /**
43 : * Specifies the loop body.
44 : */
45 : public Block body {
46 86199 : get {
47 86199 : return _body;
48 : }
49 28172 : private set {
50 56344 : _body = value;
51 28172 : _body.parent_node = this;
52 : }
53 : }
54 :
55 28172 : Expression _condition;
56 28172 : Block _body;
57 :
58 56344 : protected Loop (Expression? condition, Block body, SourceReference? source_reference = null) {
59 28172 : this.condition = condition;
60 28172 : this.body = body;
61 28172 : this.source_reference = source_reference;
62 : }
63 :
64 0 : public override void replace_expression (Expression old_node, Expression new_node) {
65 0 : if (condition == old_node) {
66 0 : condition = new_node;
67 : }
68 : }
69 : }
|