glib-2.0: Fix g_variant_new_tuple binding
[vala-lang.git] / vala / valaexpression.vala
blobdd005afcaed59adfe358c13c0760c15690939ff2
1 /* valaexpression.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
19 * Author:
20 * Jürg Billeter <j@bitron.ch>
23 using GLib;
25 /**
26 * Base class for all code nodes that might be used as an expression.
28 public abstract class Vala.Expression : CodeNode {
29 /**
30 * The static type of the value of this expression.
32 * The semantic analyzer computes this value.
34 public DataType value_type { get; set; }
36 public DataType? formal_value_type { get; set; }
39 * The static type this expression is expected to have.
41 * The semantic analyzer computes this value, lambda expressions use it.
43 public DataType target_type { get; set; }
45 public DataType? formal_target_type { get; set; }
47 /**
48 * The symbol this expression refers to.
50 public weak Symbol symbol_reference { get; set; }
52 /**
53 * Specifies that this expression is used as lvalue, i.e. the
54 * left hand side of an assignment.
56 public bool lvalue { get; set; }
58 public TargetValue? target_value { get; set; }
60 /**
61 * Returns whether this expression is constant, i.e. whether this
62 * expression only consists of literals and other constants.
64 public virtual bool is_constant () {
65 return false;
68 /**
69 * Returns whether this expression is pure, i.e. whether this expression
70 * is free of side-effects.
72 public abstract bool is_pure ();
74 /**
75 * Returns whether this expression is guaranteed to be non-null.
77 public virtual bool is_non_null () {
78 return false;
81 public Statement? parent_statement {
82 get {
83 var expr = parent_node as Expression;
84 var stmt = parent_node as Statement;
85 var local = parent_node as LocalVariable;
86 if (stmt != null) {
87 return (Statement) parent_node;
88 } else if (expr != null) {
89 return expr.parent_statement;
90 } else if (local != null) {
91 return (Statement) local.parent_node;
92 } else {
93 return null;
98 public void insert_statement (Block block, Statement stmt) {
99 block.insert_before (parent_statement, stmt);