1 /* valayieldstatement.vala
3 * Copyright (C) 2008-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>
24 * Represents a yield statement in the source code.
26 public class Vala
.YieldStatement
: CodeNode
, Statement
{
28 * The expression to yield or the method call to yield to.
30 public Expression? yield_expression
{
31 get { return _yield_expression
; }
33 _yield_expression
= value
;
34 if (_yield_expression
!= null) {
35 _yield_expression
.parent_node
= this
;
40 private Expression _yield_expression
;
43 * Creates a new yield statement.
45 * @param yield_expression the yield expression
46 * @param source_reference reference to source code
47 * @return newly created yield statement
49 public YieldStatement (Expression? yield_expression
, SourceReference? source_reference
= null) {
50 this
.yield_expression
= yield_expression
;
51 this
.source_reference
= source_reference
;
54 public override void accept (CodeVisitor visitor
) {
55 visitor
.visit_yield_statement (this
);
58 public override void accept_children (CodeVisitor visitor
) {
59 if (yield_expression
!= null) {
60 yield_expression
.accept (visitor
);
62 visitor
.visit_end_full_expression (yield_expression
);
66 public override void replace_expression (Expression old_node
, Expression new_node
) {
67 if (yield_expression
== old_node
) {
68 yield_expression
= new_node
;
72 public override bool check (CodeContext context
) {
73 if (yield_expression
!= null) {
74 yield_expression
.check (context
);
75 error
= yield_expression
.error
;
81 public override void emit (CodeGenerator codegen
) {
82 if (yield_expression
!= null) {
83 yield_expression
.emit (codegen
);
85 codegen
.visit_end_full_expression (yield_expression
);
88 codegen
.visit_yield_statement (this
);