summaryrefslogtreecommitdiff
path: root/vala/valacodenode.vala
diff options
context:
space:
mode:
authorLuca Bruno <lucabru@src.gnome.org>2011-08-07 12:44:41 +0200
committerRico Tzschichholz <ricotz@ubuntu.com>2018-10-23 18:45:45 +0200
commit6395a2efe8f166fe8b2595fc2ba08dc4bcc69216 (patch)
tree330e9fd04c476190b76ccc8710ca1d9dd8573fa8 /vala/valacodenode.vala
parent6c44fc72635e0a55f57bb9db526c4d83ddd551df (diff)
downloadvala-6395a2efe8f166fe8b2595fc2ba08dc4bcc69216.tar.gz
Collect error_types on demand to allow transformations
Diffstat (limited to 'vala/valacodenode.vala')
-rw-r--r--vala/valacodenode.vala46
1 files changed, 8 insertions, 38 deletions
diff --git a/vala/valacodenode.vala b/vala/valacodenode.vala
index e8ab35725..216b5604f 100644
--- a/vala/valacodenode.vala
+++ b/vala/valacodenode.vala
@@ -62,52 +62,19 @@ public abstract class Vala.CodeNode {
* Specifies that this node or a child node may throw an exception.
*/
public bool tree_can_fail {
- get { return _error_types != null && _error_types.size > 0; }
+ get {
+ var error_types = new ArrayList<DataType> ();
+ get_error_types (error_types);
+ return error_types.size > 0;
+ }
}
- private List<DataType> _error_types;
- private static List<DataType> _empty_type_list;
private AttributeCache[] attributes_cache;
static int last_temp_nr = 0;
static int next_attribute_cache_index = 0;
/**
- * Specifies the exceptions that can be thrown by this node or a child node
- */
- public List<DataType> get_error_types () {
- if (_error_types != null) {
- return _error_types;
- }
- if (_empty_type_list == null) {
- _empty_type_list = new ArrayList<DataType> ();
- }
- return _empty_type_list;
- }
-
- /**
- * Adds an error type to the exceptions that can be thrown by this node
- * or a child node
- */
- public void add_error_type (DataType error_type) {
- if (_error_types == null) {
- _error_types = new ArrayList<DataType> ();
- }
- _error_types.add (error_type);
- error_type.parent_node = this;
- }
-
- /**
- * Adds a collection of error types to the exceptions that can be thrown by this node
- * or a child node
- */
- public void add_error_types (List<DataType> error_types) {
- foreach (DataType error_type in error_types) {
- add_error_type (error_type);
- }
- }
-
- /**
* Visits this code node with the specified CodeVisitor.
*
* @param visitor the visitor to be called while traversing
@@ -377,6 +344,9 @@ public abstract class Vala.CodeNode {
public virtual void get_used_variables (Collection<Variable> collection) {
}
+ public virtual void get_error_types (Collection<DataType> collection, SourceReference? source_reference = null) {
+ }
+
public static string get_temp_name () {
return "." + (++last_temp_nr).to_string ();
}