Fix gst_netaddress_*_ip6_address bindings, patch by Andrew Feren, fixes
[vala-lang.git] / vala / valaparenthesizedexpression.vala
blob2a29d933273a481037c73699f0a0437f4be234a2
1 /* valaparenthesizedexpression.vala
3 * Copyright (C) 2006-2008 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
19 * Author:
20 * Jürg Billeter <j@bitron.ch>
23 using Gee;
25 /**
26 * Represents a parenthesized expression in the source code.
28 public class Vala.ParenthesizedExpression : Expression {
29 /**
30 * The inner expression.
32 public Expression inner {
33 get {
34 return _inner;
36 set {
37 _inner = value;
38 _inner.parent_node = this;
42 private Expression _inner;
44 /**
45 * Creates a new parenthesized expression.
47 * @param inner an expression
48 * @param source reference to source code
49 * @return newly created parenthesized expression
51 public ParenthesizedExpression (Expression _inner, SourceReference? source) {
52 inner = _inner;
53 source_reference = source;
56 public override void accept (CodeVisitor visitor) {
57 visitor.visit_parenthesized_expression (this);
59 visitor.visit_expression (this);
62 public override void accept_children (CodeVisitor visitor) {
63 inner.accept (visitor);
66 public override void replace_expression (Expression old_node, Expression new_node) {
67 if (inner == old_node) {
68 inner = new_node;
72 public override bool is_pure () {
73 return inner.is_pure ();
76 public override bool check (SemanticAnalyzer analyzer) {
77 if (checked) {
78 return !error;
81 checked = true;
83 inner.target_type = target_type;
85 if (!inner.check (analyzer)) {
86 // ignore inner error
87 error = true;
88 return false;
91 if (inner.value_type == null) {
92 // static type may be null for method references
93 error = true;
94 Report.error (inner.source_reference, "Invalid expression type");
95 return false;
98 value_type = inner.value_type.copy ();
99 // don't call g_object_ref_sink on inner and outer expression
100 value_type.floating_reference = false;
102 // don't transform expression twice
103 inner.target_type = inner.value_type.copy ();
105 return !error;
108 public override void get_defined_variables (Collection<LocalVariable> collection) {
109 inner.get_defined_variables (collection);
112 public override void get_used_variables (Collection<LocalVariable> collection) {
113 inner.get_used_variables (collection);