[vala/wip/transform: 57/95] Added TraverseVisitor for traversing the tree with a callback
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/transform: 57/95] Added TraverseVisitor for traversing the tree with a callback
- Date: Mon, 20 Mar 2017 14:33:17 +0000 (UTC)
commit 17e3f340b7fdcb041cc3beeae6f5ce39d862b593
Author: Luca Bruno <lucabru src gnome org>
Date: Sat Oct 27 17:11:40 2012 +0200
Added TraverseVisitor for traversing the tree with a callback
This will allow cleaning up virtual methods of code nodes
and more stateful to stateless code conversion.
vala/Makefile.am | 1 +
vala/valaassignment.vala | 12 -
vala/valabinaryexpression.vala | 5 -
vala/valacastexpression.vala | 4 -
vala/valacatchclause.vala | 6 -
vala/valacodenode.vala | 73 ++++++-
vala/valaconditionalexpression.vala | 6 -
vala/valadeclarationstatement.vala | 13 --
vala/valaelementaccess.vala | 7 -
vala/valaexpressionstatement.vala | 4 -
vala/valaforeachstatement.vala | 4 -
vala/valamemberaccess.vala | 6 -
vala/valamethod.vala | 8 -
vala/valamethodcall.vala | 8 -
vala/valanamedargument.vala | 4 -
vala/valaobjectcreationexpression.vala | 6 -
vala/valapointerindirection.vala | 4 -
vala/valapostfixexpression.vala | 11 -
vala/valareferencetransferexpression.vala | 11 -
vala/valareturnstatement.vala | 6 -
vala/valasliceexpression.vala | 6 -
vala/valathrowstatement.vala | 4 -
vala/valatraversevisitor.vala | 333 +++++++++++++++++++++++++++++
vala/valaunaryexpression.vala | 14 --
24 files changed, 406 insertions(+), 150 deletions(-)
---
diff --git a/vala/Makefile.am b/vala/Makefile.am
index e905efd..4d12e4a 100644
--- a/vala/Makefile.am
+++ b/vala/Makefile.am
@@ -150,6 +150,7 @@ libvalacore_la_VALASOURCES = \
valatemplate.vala \
valathrowstatement.vala \
valatokentype.vala \
+ valatraversevisitor.vala \
valatrystatement.vala \
valatuple.vala \
valatypecheck.vala \
diff --git a/vala/valaassignment.vala b/vala/valaassignment.vala
index 9fc966d..04c49cd 100644
--- a/vala/valaassignment.vala
+++ b/vala/valaassignment.vala
@@ -575,18 +575,6 @@ public class Vala.Assignment : Expression {
codegen.visit_expression (this);
}
- public override void get_defined_variables (Collection<Variable> collection) {
- right.get_defined_variables (collection);
- left.get_defined_variables (collection);
- var local = left.symbol_reference as LocalVariable;
- var param = left.symbol_reference as Parameter;
- if (local != null) {
- collection.add (local);
- } else if (param != null && param.direction == ParameterDirection.OUT) {
- collection.add (param);
- }
- }
-
public override void get_used_variables (Collection<Variable> collection) {
var ma = left as MemberAccess;
var ea = left as ElementAccess;
diff --git a/vala/valabinaryexpression.vala b/vala/valabinaryexpression.vala
index f9500e0..f95c74b 100644
--- a/vala/valabinaryexpression.vala
+++ b/vala/valabinaryexpression.vala
@@ -402,11 +402,6 @@ public class Vala.BinaryExpression : Expression {
codegen.visit_expression (this);
}
- public override void get_defined_variables (Collection<Variable> collection) {
- left.get_defined_variables (collection);
- right.get_defined_variables (collection);
- }
-
public override void get_used_variables (Collection<Variable> collection) {
left.get_used_variables (collection);
right.get_used_variables (collection);
diff --git a/vala/valacastexpression.vala b/vala/valacastexpression.vala
index 76bef3c..2d5509a 100644
--- a/vala/valacastexpression.vala
+++ b/vala/valacastexpression.vala
@@ -188,10 +188,6 @@ public class Vala.CastExpression : Expression {
codegen.visit_expression (this);
}
- public override void get_defined_variables (Collection<Variable> collection) {
- inner.get_defined_variables (collection);
- }
-
public override void get_used_variables (Collection<Variable> collection) {
inner.get_used_variables (collection);
}
diff --git a/vala/valacatchclause.vala b/vala/valacatchclause.vala
index e3efd58..9816891 100644
--- a/vala/valacatchclause.vala
+++ b/vala/valacatchclause.vala
@@ -147,10 +147,4 @@ public class Vala.CatchClause : CodeNode {
codegen.visit_catch_clause (this);
}
-
- public override void get_defined_variables (Collection<Variable> collection) {
- if (error_variable != null) {
- collection.add (error_variable);
- }
- }
}
diff --git a/vala/valacodenode.vala b/vala/valacodenode.vala
index a4a85e5..efce32b 100644
--- a/vala/valacodenode.vala
+++ b/vala/valacodenode.vala
@@ -344,7 +344,78 @@ public abstract class Vala.CodeNode {
return str.append (" */").str;
}
- public virtual void get_defined_variables (Collection<Variable> collection) {
+ public void get_defined_variables (Collection<Variable> collection) {
+ var traverse = new TraverseVisitor ((n) => {
+ if (n is Assignment) {
+ var a = (Assignment) n;
+ var local = a.left.symbol_reference as LocalVariable;
+ var param = a.left.symbol_reference as Parameter;
+ if (local != null) {
+ collection.add (local);
+ } else if (param != null && param.direction ==
ParameterDirection.OUT) {
+ collection.add (param);
+ }
+ } else if (n is CatchClause) {
+ var clause = (CatchClause) n;
+ if (clause.error_variable != null) {
+ collection.add (clause.error_variable);
+ }
+ return TraverseStatus.STOP;
+ } else if (n is DeclarationStatement) {
+ var stmt = (DeclarationStatement) n;
+ var local = stmt.declaration as LocalVariable;
+ if (local != null) {
+ var array_type = local.variable_type as ArrayType;
+ if (local.initializer != null || (array_type != null &&
array_type.fixed_length)) {
+ collection.add (local);
+ }
+ }
+ } else if (n is ForeachStatement) {
+ var stmt = (ForeachStatement) n;
+ collection.add (stmt.element_variable);
+ return TraverseStatus.STOP;
+ } else if (n is Method) {
+ var m = (Method) n;
+ // capturing variables is only supported if they are initialized
+ // therefore assume that captured variables are initialized
+ if (m.closure) {
+ m.get_captured_variables ((Collection<LocalVariable>)
collection);
+ }
+ return TraverseStatus.STOP;
+ } else if (n is PostfixExpression) {
+ var expr = (PostfixExpression) n;
+ var local = expr.inner.symbol_reference as LocalVariable;
+ var param = expr.inner.symbol_reference as Parameter;
+ if (local != null) {
+ collection.add (local);
+ } else if (param != null && param.direction ==
ParameterDirection.OUT) {
+ collection.add (param);
+ }
+ } else if (n is ReferenceTransferExpression) {
+ var expr = (ReferenceTransferExpression) n;
+ var local = expr.inner.symbol_reference as LocalVariable;
+ var param = expr.inner.symbol_reference as Parameter;
+ if (local != null) {
+ collection.add (local);
+ } else if (param != null && param.direction ==
ParameterDirection.OUT) {
+ collection.add (param);
+ }
+ } else if (n is UnaryExpression) {
+ var expr = (UnaryExpression) n;
+ if (expr.operator == UnaryOperator.OUT || expr.operator ==
UnaryOperator.REF) {
+ var local = expr.inner.symbol_reference as LocalVariable;
+ var param = expr.inner.symbol_reference as Parameter;
+ if (local != null) {
+ collection.add (local);
+ }
+ if (param != null && param.direction ==
ParameterDirection.OUT) {
+ collection.add (param);
+ }
+ }
+ }
+ return TraverseStatus.CONTINUE;
+ });
+ accept (traverse);
}
public virtual void get_used_variables (Collection<Variable> collection) {
diff --git a/vala/valaconditionalexpression.vala b/vala/valaconditionalexpression.vala
index 968e040..0e0918a 100644
--- a/vala/valaconditionalexpression.vala
+++ b/vala/valaconditionalexpression.vala
@@ -104,12 +104,6 @@ public class Vala.ConditionalExpression : Expression {
return condition.is_accessible (sym) && true_expression.is_accessible (sym) &&
false_expression.is_accessible (sym);
}
- public override void get_defined_variables (Collection<Variable> collection) {
- condition.get_defined_variables (collection);
- true_expression.get_defined_variables (collection);
- false_expression.get_defined_variables (collection);
- }
-
public override void get_used_variables (Collection<Variable> collection) {
condition.get_used_variables (collection);
true_expression.get_used_variables (collection);
diff --git a/vala/valadeclarationstatement.vala b/vala/valadeclarationstatement.vala
index 1fea1cf..de58207 100644
--- a/vala/valadeclarationstatement.vala
+++ b/vala/valadeclarationstatement.vala
@@ -88,19 +88,6 @@ public class Vala.DeclarationStatement : BaseStatement {
codegen.visit_declaration_statement (this);
}
- public override void get_defined_variables (Collection<Variable> collection) {
- var local = declaration as LocalVariable;
- if (local != null) {
- var array_type = local.variable_type as ArrayType;
- if (local.initializer != null) {
- local.initializer.get_defined_variables (collection);
- collection.add (local);
- } else if (array_type != null && array_type.fixed_length) {
- collection.add (local);
- }
- }
- }
-
public override void get_used_variables (Collection<Variable> collection) {
var local = declaration as LocalVariable;
if (local != null && local.initializer != null) {
diff --git a/vala/valaelementaccess.vala b/vala/valaelementaccess.vala
index 2fe4b87..2e5ee1b 100644
--- a/vala/valaelementaccess.vala
+++ b/vala/valaelementaccess.vala
@@ -245,13 +245,6 @@ public class Vala.ElementAccess : Expression {
codegen.visit_expression (this);
}
- public override void get_defined_variables (Collection<Variable> collection) {
- container.get_defined_variables (collection);
- foreach (Expression index in indices) {
- index.get_defined_variables (collection);
- }
- }
-
public override void get_used_variables (Collection<Variable> collection) {
container.get_used_variables (collection);
foreach (Expression index in indices) {
diff --git a/vala/valaexpressionstatement.vala b/vala/valaexpressionstatement.vala
index 736c6b7..82d18f8 100644
--- a/vala/valaexpressionstatement.vala
+++ b/vala/valaexpressionstatement.vala
@@ -93,10 +93,6 @@ public class Vala.ExpressionStatement : BaseStatement {
codegen.visit_expression_statement (this);
}
- public override void get_defined_variables (Collection<Variable> collection) {
- expression.get_defined_variables (collection);
- }
-
public override void get_used_variables (Collection<Variable> collection) {
expression.get_used_variables (collection);
}
diff --git a/vala/valaforeachstatement.vala b/vala/valaforeachstatement.vala
index a412527..aa3dcf8 100644
--- a/vala/valaforeachstatement.vala
+++ b/vala/valaforeachstatement.vala
@@ -329,10 +329,6 @@ public class Vala.ForeachStatement : BaseStatement {
codegen.visit_foreach_statement (this);
}
-
- public override void get_defined_variables (Collection<Variable> collection) {
- collection.add (element_variable);
- }
}
public enum Vala.ForeachIteration {
diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala
index 80a593b..2bcc381 100644
--- a/vala/valamemberaccess.vala
+++ b/vala/valamemberaccess.vala
@@ -900,12 +900,6 @@ public class Vala.MemberAccess : Expression {
codegen.visit_expression (this);
}
- public override void get_defined_variables (Collection<Variable> collection) {
- if (inner != null) {
- inner.get_defined_variables (collection);
- }
- }
-
public override void get_used_variables (Collection<Variable> collection) {
if (inner != null) {
inner.get_used_variables (collection);
diff --git a/vala/valamethod.vala b/vala/valamethod.vala
index 025486f..d546a6e 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -1070,14 +1070,6 @@ public class Vala.Method : Subroutine, Callable {
}
}
- public override void get_defined_variables (Collection<Variable> collection) {
- // capturing variables is only supported if they are initialized
- // therefore assume that captured variables are initialized
- if (closure) {
- get_captured_variables ((Collection<LocalVariable>) collection);
- }
- }
-
public int get_format_arg_index () {
for (int i = 0; i < parameters.size; i++) {
if (parameters[i].format_arg) {
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index 1079441..8d4550b 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -617,14 +617,6 @@ public class Vala.MethodCall : Expression {
codegen.visit_expression (this);
}
- public override void get_defined_variables (Collection<Variable> collection) {
- call.get_defined_variables (collection);
-
- foreach (Expression arg in argument_list) {
- arg.get_defined_variables (collection);
- }
- }
-
public override void get_used_variables (Collection<Variable> collection) {
call.get_used_variables (collection);
diff --git a/vala/valanamedargument.vala b/vala/valanamedargument.vala
index 4c3e23b..5b57c13 100644
--- a/vala/valanamedargument.vala
+++ b/vala/valanamedargument.vala
@@ -89,10 +89,6 @@ public class Vala.NamedArgument : Expression {
codegen.visit_expression (this);
}
- public override void get_defined_variables (Collection<Variable> collection) {
- inner.get_defined_variables (collection);
- }
-
public override void get_used_variables (Collection<Variable> collection) {
inner.get_used_variables (collection);
}
diff --git a/vala/valaobjectcreationexpression.vala b/vala/valaobjectcreationexpression.vala
index 7bd62ef..1c48f3d 100644
--- a/vala/valaobjectcreationexpression.vala
+++ b/vala/valaobjectcreationexpression.vala
@@ -504,12 +504,6 @@ public class Vala.ObjectCreationExpression : Expression {
codegen.visit_expression (this);
}
- public override void get_defined_variables (Collection<Variable> collection) {
- foreach (Expression arg in argument_list) {
- arg.get_defined_variables (collection);
- }
- }
-
public override void get_used_variables (Collection<Variable> collection) {
foreach (Expression arg in argument_list) {
arg.get_used_variables (collection);
diff --git a/vala/valapointerindirection.vala b/vala/valapointerindirection.vala
index 52ee238..077c451 100644
--- a/vala/valapointerindirection.vala
+++ b/vala/valapointerindirection.vala
@@ -111,10 +111,6 @@ public class Vala.PointerIndirection : Expression {
codegen.visit_expression (this);
}
- public override void get_defined_variables (Collection<Variable> collection) {
- inner.get_defined_variables (collection);
- }
-
public override void get_used_variables (Collection<Variable> collection) {
inner.get_used_variables (collection);
}
diff --git a/vala/valapostfixexpression.vala b/vala/valapostfixexpression.vala
index dd6e351..471d813 100644
--- a/vala/valapostfixexpression.vala
+++ b/vala/valapostfixexpression.vala
@@ -76,17 +76,6 @@ public class Vala.PostfixExpression : Expression {
return inner.is_accessible (sym);
}
- public override void get_defined_variables (Collection<Variable> collection) {
- inner.get_defined_variables (collection);
- var local = inner.symbol_reference as LocalVariable;
- var param = inner.symbol_reference as Parameter;
- if (local != null) {
- collection.add (local);
- } else if (param != null && param.direction == ParameterDirection.OUT) {
- collection.add (param);
- }
- }
-
public override void get_used_variables (Collection<Variable> collection) {
inner.get_used_variables (collection);
}
diff --git a/vala/valareferencetransferexpression.vala b/vala/valareferencetransferexpression.vala
index ceb51a2..524d139 100644
--- a/vala/valareferencetransferexpression.vala
+++ b/vala/valareferencetransferexpression.vala
@@ -121,17 +121,6 @@ public class Vala.ReferenceTransferExpression : Expression {
codegen.visit_expression (this);
}
- public override void get_defined_variables (Collection<Variable> collection) {
- inner.get_defined_variables (collection);
- var local = inner.symbol_reference as LocalVariable;
- var param = inner.symbol_reference as Parameter;
- if (local != null) {
- collection.add (local);
- } else if (param != null && param.direction == ParameterDirection.OUT) {
- collection.add (param);
- }
- }
-
public override void get_used_variables (Collection<Variable> collection) {
inner.get_used_variables (collection);
var local = inner.symbol_reference as LocalVariable;
diff --git a/vala/valareturnstatement.vala b/vala/valareturnstatement.vala
index 219f6d9..59236e7 100644
--- a/vala/valareturnstatement.vala
+++ b/vala/valareturnstatement.vala
@@ -159,12 +159,6 @@ public class Vala.ReturnStatement : BaseStatement {
codegen.visit_return_statement (this);
}
- public override void get_defined_variables (Collection<Variable> collection) {
- if (return_expression != null) {
- return_expression.get_defined_variables (collection);
- }
- }
-
public override void get_used_variables (Collection<Variable> collection) {
if (return_expression != null) {
return_expression.get_used_variables (collection);
diff --git a/vala/valasliceexpression.vala b/vala/valasliceexpression.vala
index 6621b41..591e2fa 100644
--- a/vala/valasliceexpression.vala
+++ b/vala/valasliceexpression.vala
@@ -183,12 +183,6 @@ public class Vala.SliceExpression : Expression {
codegen.visit_expression (this);
}
- public override void get_defined_variables (Collection<Variable> collection) {
- container.get_defined_variables (collection);
- start.get_defined_variables (collection);
- stop.get_defined_variables (collection);
- }
-
public override void get_used_variables (Collection<Variable> collection) {
container.get_used_variables (collection);
start.get_used_variables (collection);
diff --git a/vala/valathrowstatement.vala b/vala/valathrowstatement.vala
index 32275f3..ab0328c 100644
--- a/vala/valathrowstatement.vala
+++ b/vala/valathrowstatement.vala
@@ -123,10 +123,6 @@ public class Vala.ThrowStatement : BaseStatement {
codegen.visit_throw_statement (this);
}
- public override void get_defined_variables (Collection<Variable> collection) {
- error_expression.get_defined_variables (collection);
- }
-
public override void get_used_variables (Collection<Variable> collection) {
error_expression.get_used_variables (collection);
}
diff --git a/vala/valatraversevisitor.vala b/vala/valatraversevisitor.vala
new file mode 100644
index 0000000..37c85ec
--- /dev/null
+++ b/vala/valatraversevisitor.vala
@@ -0,0 +1,333 @@
+/* valatraversevisitor.vala
+ *
+ * Copyright (C) 2012 Luca Bruno
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Luca Bruno <lucabru src gnome org>
+ */
+
+/**
+ * Code visitor for traversing the tree with a simple callback
+ */
+public class Vala.TraverseVisitor : CodeVisitor {
+ private TraverseFunc func;
+
+ public TraverseVisitor (owned TraverseFunc func) {
+ this.func = (owned) func;
+ }
+
+ public override void visit_namespace (Namespace ns) {
+ if (func (ns) == TraverseStatus.CONTINUE) {
+ ns.accept_children (this);
+ }
+ }
+
+ public override void visit_class (Class cl) {
+ if (func (cl) == TraverseStatus.CONTINUE) {
+ cl.accept_children (this);
+ }
+ }
+
+ public override void visit_struct (Struct st) {
+ if (func (st) == TraverseStatus.CONTINUE) {
+ st.accept_children (this);
+ }
+ }
+
+ public override void visit_interface (Interface iface) {
+ if (func (iface) == TraverseStatus.CONTINUE) {
+ iface.accept_children (this);
+ }
+ }
+
+ public override void visit_enum (Enum en) {
+ if (func (en) == TraverseStatus.CONTINUE) {
+ en.accept_children (this);
+ }
+ }
+
+ public override void visit_enum_value (EnumValue ev) {
+ if (func (ev) == TraverseStatus.CONTINUE) {
+ ev.accept_children (this);
+ }
+ }
+
+ public override void visit_error_domain (ErrorDomain edomain) {
+ if (func (edomain) == TraverseStatus.CONTINUE) {
+ edomain.accept_children (this);
+ }
+ }
+
+ public override void visit_error_code (ErrorCode ecode) {
+ if (func (ecode) == TraverseStatus.CONTINUE) {
+ ecode.accept_children (this);
+ }
+ }
+
+ public override void visit_delegate (Delegate d) {
+ if (func (d) == TraverseStatus.CONTINUE) {
+ d.accept_children (this);
+ }
+ }
+
+ public override void visit_constant (Constant c) {
+ if (func (c) == TraverseStatus.CONTINUE) {
+ c.accept_children (this);
+ }
+ }
+
+ public override void visit_field (Field f) {
+ if (func (f) == TraverseStatus.CONTINUE) {
+ f.accept_children (this);
+ }
+ }
+
+ public override void visit_method (Method m) {
+ if (func (m) == TraverseStatus.CONTINUE) {
+ m.accept_children (this);
+ }
+ }
+
+ public override void visit_creation_method (CreationMethod m) {
+ if (func (m) == TraverseStatus.CONTINUE) {
+ m.accept_children (this);
+ }
+ }
+
+ public override void visit_formal_parameter (Parameter p) {
+ if (func (p) == TraverseStatus.CONTINUE) {
+ p.accept_children (this);
+ }
+ }
+
+ public override void visit_property (Property prop) {
+ if (func (prop) == TraverseStatus.CONTINUE) {
+ prop.accept_children (this);
+ }
+ }
+
+ public override void visit_property_accessor (PropertyAccessor acc) {
+ if (func (acc) == TraverseStatus.CONTINUE) {
+ acc.accept_children (this);
+ }
+ }
+
+ public override void visit_signal (Signal sig) {
+ if (func (sig) == TraverseStatus.CONTINUE) {
+ sig.accept_children (this);
+ }
+ }
+
+ public override void visit_constructor (Constructor c) {
+ if (func (c) == TraverseStatus.CONTINUE) {
+ c.accept_children (this);
+ }
+ }
+
+ public override void visit_destructor (Destructor d) {
+ if (func (d) == TraverseStatus.CONTINUE) {
+ d.accept_children (this);
+ }
+ }
+
+ public override void visit_block (Block b) {
+ if (func (b) == TraverseStatus.CONTINUE) {
+ b.accept_children (this);
+ }
+ }
+
+ public override void visit_declaration_statement (DeclarationStatement stmt) {
+ if (func (stmt) == TraverseStatus.CONTINUE) {
+ stmt.accept_children (this);
+ }
+ }
+
+ public override void visit_local_variable (LocalVariable local) {
+ if (func (local) == TraverseStatus.CONTINUE) {
+ local.accept_children (this);
+ }
+ }
+
+ public override void visit_initializer_list (InitializerList list) {
+ if (func (list) == TraverseStatus.CONTINUE) {
+ list.accept_children (this);
+ }
+ }
+
+ public override void visit_expression_statement (ExpressionStatement stmt) {
+ if (func (stmt) == TraverseStatus.CONTINUE) {
+ stmt.accept_children (this);
+ }
+ }
+
+ public override void visit_if_statement (IfStatement stmt) {
+ if (func (stmt) == TraverseStatus.CONTINUE) {
+ stmt.accept_children (this);
+ }
+ }
+
+ public override void visit_switch_statement (SwitchStatement stmt) {
+ if (func (stmt) == TraverseStatus.CONTINUE) {
+ stmt.accept_children (this);
+ }
+ }
+
+ public override void visit_switch_section (SwitchSection section) {
+ if (func (section) == TraverseStatus.CONTINUE) {
+ section.accept_children (this);
+ }
+ }
+
+ public override void visit_switch_label (SwitchLabel label) {
+ if (func (label) == TraverseStatus.CONTINUE) {
+ label.accept_children (this);
+ }
+ }
+
+ public override void visit_loop (Loop loop) {
+ if (func (loop) == TraverseStatus.CONTINUE) {
+ loop.accept_children (this);
+ }
+ }
+
+ public override void visit_while_statement (WhileStatement stmt) {
+ if (func (stmt) == TraverseStatus.CONTINUE) {
+ stmt.accept_children (this);
+ }
+ }
+
+ public override void visit_do_statement (DoStatement stmt) {
+ if (func (stmt) == TraverseStatus.CONTINUE) {
+ stmt.accept_children (this);
+ }
+ }
+
+ public override void visit_for_statement (ForStatement stmt) {
+ if (func (stmt) == TraverseStatus.CONTINUE) {
+ stmt.accept_children (this);
+ }
+ }
+
+ public override void visit_foreach_statement (ForeachStatement stmt) {
+ if (func (stmt) == TraverseStatus.CONTINUE) {
+ stmt.accept_children (this);
+ }
+ }
+
+ public override void visit_break_statement (BreakStatement stmt) {
+ if (func (stmt) == TraverseStatus.CONTINUE) {
+ stmt.accept_children (this);
+ }
+ }
+
+ public override void visit_continue_statement (ContinueStatement stmt) {
+ if (func (stmt) == TraverseStatus.CONTINUE) {
+ stmt.accept_children (this);
+ }
+ }
+
+ public override void visit_return_statement (ReturnStatement stmt) {
+ if (func (stmt) == TraverseStatus.CONTINUE) {
+ stmt.accept_children (this);
+ }
+ }
+
+ public override void visit_yield_statement (YieldStatement stmt) {
+ if (func (stmt) == TraverseStatus.CONTINUE) {
+ stmt.accept_children (this);
+ }
+ }
+
+ public override void visit_throw_statement (ThrowStatement stmt) {
+ if (func (stmt) == TraverseStatus.CONTINUE) {
+ stmt.accept_children (this);
+ }
+ }
+
+ public override void visit_try_statement (TryStatement stmt) {
+ if (func (stmt) == TraverseStatus.CONTINUE) {
+ stmt.accept_children (this);
+ }
+ }
+
+ public override void visit_catch_clause (CatchClause clause) {
+ if (func (clause) == TraverseStatus.CONTINUE) {
+ clause.accept_children (this);
+ }
+ }
+
+ public override void visit_lock_statement (LockStatement stmt) {
+ if (func (stmt) == TraverseStatus.CONTINUE) {
+ stmt.accept_children (this);
+ }
+ }
+
+ public override void visit_unlock_statement (UnlockStatement stmt) {
+ if (func (stmt) == TraverseStatus.CONTINUE) {
+ stmt.accept_children (this);
+ }
+ }
+
+ public override void visit_delete_statement (DeleteStatement stmt) {
+ if (func (stmt) == TraverseStatus.CONTINUE) {
+ stmt.accept_children (this);
+ }
+ }
+
+ public override void visit_expression (Expression expr) {
+ if (func (expr) == TraverseStatus.CONTINUE) {
+ expr.accept_children (this);
+ }
+ }
+
+ public override void visit_method_call (MethodCall expr) {
+ if (func (expr) == TraverseStatus.CONTINUE) {
+ expr.accept_children (this);
+ }
+ }
+
+ public override void visit_conditional_expression (ConditionalExpression expr) {
+ if (func (expr) == TraverseStatus.CONTINUE) {
+ expr.accept_children (this);
+ }
+ }
+
+ public override void visit_binary_expression (BinaryExpression expr) {
+ if (func (expr) == TraverseStatus.CONTINUE) {
+ expr.accept_children (this);
+ }
+ }
+
+ public override void visit_unary_expression (UnaryExpression expr) {
+ if (func (expr) == TraverseStatus.CONTINUE) {
+ expr.accept_children (this);
+ }
+ }
+
+ public override void visit_object_creation_expression (ObjectCreationExpression expr) {
+ if (func (expr) == TraverseStatus.CONTINUE) {
+ expr.accept_children (this);
+ }
+ }
+}
+
+public enum Vala.TraverseStatus {
+ STOP,
+ CONTINUE
+}
+
+public delegate Vala.TraverseStatus Vala.TraverseFunc (CodeNode node);
diff --git a/vala/valaunaryexpression.vala b/vala/valaunaryexpression.vala
index 1118930..0994387 100644
--- a/vala/valaunaryexpression.vala
+++ b/vala/valaunaryexpression.vala
@@ -250,20 +250,6 @@ public class Vala.UnaryExpression : Expression {
codegen.visit_expression (this);
}
- public override void get_defined_variables (Collection<Variable> collection) {
- inner.get_defined_variables (collection);
- if (operator == UnaryOperator.OUT || operator == UnaryOperator.REF) {
- var local = inner.symbol_reference as LocalVariable;
- var param = inner.symbol_reference as Parameter;
- if (local != null) {
- collection.add (local);
- }
- if (param != null && param.direction == ParameterDirection.OUT) {
- collection.add (param);
- }
- }
- }
-
public override void get_used_variables (Collection<Variable> collection) {
if (operator != UnaryOperator.OUT) {
inner.get_used_variables (collection);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]