1 /* valadovacontrolflowmodule.vala
3 * Copyright (C) 2006-2010 Jürg Billeter
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.
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.
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
20 * Jürg Billeter <j@bitron.ch>
23 public abstract class Vala
.DovaControlFlowModule
: DovaMethodModule
{
24 public override void visit_if_statement (IfStatement stmt
) {
25 ccode
.open_if (get_cvalue (stmt
.condition
));
27 stmt
.true_statement
.emit (this
);
29 if (stmt
.false_statement
!= null) {
31 stmt
.false_statement
.emit (this
);
37 public override void visit_switch_statement (SwitchStatement stmt
) {
38 ccode
.open_switch (get_cvalue (stmt
.expression
));
40 foreach (SwitchSection section
in stmt
.get_sections ()) {
41 if (section
.has_default_label ()) {
50 public override void visit_switch_label (SwitchLabel label
) {
51 if (label
.expression
!= null) {
52 label
.expression
.emit (this
);
54 visit_end_full_expression (label
.expression
);
56 ccode
.add_case (get_cvalue (label
.expression
));
60 public override void visit_loop (Loop stmt
) {
61 ccode
.open_while (new
CCodeConstant ("true"));
63 stmt
.body
.emit (this
);
68 public override void visit_break_statement (BreakStatement stmt
) {
69 append_local_free (current_symbol
, true);
74 public override void visit_continue_statement (ContinueStatement stmt
) {
75 append_local_free (current_symbol
, true);
77 ccode
.add_continue ();