[vala/wip/transform: 332/373] 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: 332/373] Added TraverseVisitor for traversing the tree with a callback
- Date: Mon, 22 Oct 2018 15:00:00 +0000 (UTC)
commit 4a9126c4e1e87bb01bd5b1dbbd761fe44ff20eca
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 fec06f1bd..02510ebb2 100644
--- a/vala/Makefile.am
+++ b/vala/Makefile.am
@@ -159,6 +159,7 @@ libvala_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 a1d2f0971..118bd660d 100644
--- a/vala/valaassignment.vala
+++ b/vala/valaassignment.vala
@@ -514,18 +514,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 eb2f11d10..bd6b816a8 100644
--- a/vala/valabinaryexpression.vala
+++ b/vala/valabinaryexpression.vala
@@ -434,11 +434,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 4bed12c86..35ac2f52c 100644
--- a/vala/valacastexpression.vala
+++ b/vala/valacastexpression.vala
@@ -202,10 +202,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 dd50676cf..da64d6d85 100644
--- a/vala/valacatchclause.vala
+++ b/vala/valacatchclause.vala
@@ -153,10 +153,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 216b5604f..41e2042a8 100644
--- a/vala/valacodenode.vala
+++ b/vala/valacodenode.vala
@@ -338,7 +338,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 e26efda6a..6345524ae 100644
--- a/vala/valaconditionalexpression.vala
+++ b/vala/valaconditionalexpression.vala
@@ -110,12 +110,6 @@ public class Vala.ConditionalExpression : Expression {
false_expression.get_error_types (collection, source_reference);
}
- 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 1fea1cfbb..de58207e1 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 dec200795..027e2c39d 100644
--- a/vala/valaelementaccess.vala
+++ b/vala/valaelementaccess.vala
@@ -261,13 +261,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 736c6b7fe..82d18f828 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 ab8f49431..17070cc97 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 43e0b68d8..492ddd659 100644
--- a/vala/valamemberaccess.vala
+++ b/vala/valamemberaccess.vala
@@ -917,12 +917,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 5a79d18de..1787611ea 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -1137,14 +1137,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 b36b1b490..fab99161c 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -633,14 +633,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 4c3e23b33..5b57c1306 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 71ec28910..d792ad3e5 100644
--- a/vala/valaobjectcreationexpression.vala
+++ b/vala/valaobjectcreationexpression.vala
@@ -509,12 +509,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 87ee8a86b..05304cba0 100644
--- a/vala/valapointerindirection.vala
+++ b/vala/valapointerindirection.vala
@@ -115,10 +115,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 156ffecf0..cfee09175 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 9362bbd1c..6fdfdfa87 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 931e5d073..1335968ab 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 6621b41d8..591e2fafb 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 5061a2c0d..b7bb08b24 100644
--- a/vala/valathrowstatement.vala
+++ b/vala/valathrowstatement.vala
@@ -129,10 +129,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 000000000..37c85ece5
--- /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 5ef22965a..4cc7ea1b7 100644
--- a/vala/valaunaryexpression.vala
+++ b/vala/valaunaryexpression.vala
@@ -254,20 +254,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]