remove obsolete ref modifier and callback keyword
[vala-lang.git] / vala / valacodenode.vala
blob1cdaeb751b1e90a436bf823024d055b6f71b656a
1 /* valacodenode.vala
3 * Copyright (C) 2006-2007 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 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 part of the parsed source code.
28 * Code nodes get created by the parser and are used throughout the whole
29 * compilation process.
31 public abstract class Vala.CodeNode {
32 /**
33 * Parent of this code node.
35 public CodeNode parent_node { get; set; }
37 /**
38 * Symbol that corresponds to this code node.
40 public Symbol symbol { get; set; }
42 /**
43 * References the location in the source file where this code node has
44 * been written.
46 public SourceReference source_reference { get; set construct; }
48 /**
49 * Contains all attributes that have been specified for this code node.
51 public List<Attribute> attributes;
53 /**
54 * Generated CCodeNode that corresponds to this code node.
56 public CCodeNode ccodenode {
57 get {
58 return _ccodenode;
60 set {
61 if (source_reference != null) {
62 value.line = new CCodeLineDirective (
63 source_reference.file.filename,
64 source_reference.first_line);
67 _ccodenode = value;
71 /**
72 * Specifies whether a fatal error has been detected in this code node.
74 public bool error { get; set; }
76 /**
77 * Visits this code node with the specified CodeVisitor.
79 * @param visitor the visitor to be called while traversing
81 public virtual void accept (CodeVisitor! visitor) {
84 /**
85 * Visits all children of this code node with the specified CodeVisitor.
87 * @param visitor the visitor to be called while traversing
89 public virtual void accept_children (CodeVisitor! visitor) {
92 public virtual void replace (CodeNode! old_node, CodeNode! new_node) {
95 /**
96 * Returns the specified attribute.
98 * @param name attribute name
99 * @return attribute
101 public Attribute get_attribute (string! name) {
102 // FIXME: use hash table
103 foreach (Attribute a in attributes) {
104 if (a.name == name) {
105 return a;
109 return null;
112 private CCodeNode _ccodenode;
115 * Returns a string that represents this code node.
117 * @return a string representation
119 public virtual string! to_string () {
120 if (source_reference != null) {
121 return source_reference.to_string ();
123 return "(unknown)";