girparser: Guess virtual method wrapper variant when possible
[vala-lang.git] / vala / valatypeofexpression.vala
blob9efb1f55cb27e870e71405fe17e0c4f45db8d04f
1 /* valatypeofexpression.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 * Represents a typeof expression in the source code.
28 public class Vala.TypeofExpression : Expression {
29 /**
30 * The type to be retrieved.
32 public DataType type_reference {
33 get { return _data_type; }
34 set {
35 _data_type = value;
36 _data_type.parent_node = this;
40 private DataType _data_type;
42 /**
43 * Creates a new typeof expression.
45 * @param type a data type
46 * @param source reference to source code
47 * @return newly created typeof expression
49 public TypeofExpression (DataType type, SourceReference source) {
50 type_reference = type;
51 source_reference = source;
54 public override void accept (CodeVisitor visitor) {
55 visitor.visit_typeof_expression (this);
57 visitor.visit_expression (this);
60 public override void accept_children (CodeVisitor visitor) {
61 type_reference.accept (visitor);
64 public override bool is_pure () {
65 return true;
68 public override void replace_type (DataType old_type, DataType new_type) {
69 if (type_reference == old_type) {
70 type_reference = new_type;
74 public override bool check (CodeContext context) {
75 if (checked) {
76 return !error;
79 checked = true;
81 type_reference.check (context);
83 value_type = context.analyzer.type_type;
85 return !error;
88 public override void emit (CodeGenerator codegen) {
89 codegen.visit_typeof_expression (this);
91 codegen.visit_expression (this);