From 722fa00fa3b88cfb9105a9329a36b3e3360a4243 Mon Sep 17 00:00:00 2001 From: vadim Date: Thu, 28 Dec 2017 13:36:27 +0200 Subject: [PATCH] walker: leave node event --- dumper.go | 8 ++++++-- node/argument.go | 6 ++++-- node/expr/array.go | 6 ++++-- node/expr/array_dim_fetch.go | 8 +++++--- node/expr/array_item.go | 8 +++++--- node/expr/assign_op/assign.go | 8 +++++--- node/expr/assign_op/assign_ref.go | 8 +++++--- node/expr/assign_op/bitwise_and.go | 8 +++++--- node/expr/assign_op/bitwise_or.go | 8 +++++--- node/expr/assign_op/bitwise_xor.go | 8 +++++--- node/expr/assign_op/concat.go | 8 +++++--- node/expr/assign_op/div.go | 8 +++++--- node/expr/assign_op/minus.go | 8 +++++--- node/expr/assign_op/mod.go | 8 +++++--- node/expr/assign_op/mul.go | 8 +++++--- node/expr/assign_op/plus.go | 8 +++++--- node/expr/assign_op/pow.go | 8 +++++--- node/expr/assign_op/shift_left.go | 8 +++++--- node/expr/assign_op/shift_right.go | 8 +++++--- node/expr/binary_op/bitwise_and.go | 8 +++++--- node/expr/binary_op/bitwise_or.go | 8 +++++--- node/expr/binary_op/bitwise_xor.go | 8 +++++--- node/expr/binary_op/boolean_and.go | 8 +++++--- node/expr/binary_op/boolean_or.go | 8 +++++--- node/expr/binary_op/coalesce.go | 8 +++++--- node/expr/binary_op/concat.go | 8 +++++--- node/expr/binary_op/div.go | 8 +++++--- node/expr/binary_op/equal.go | 8 +++++--- node/expr/binary_op/greater.go | 8 +++++--- node/expr/binary_op/greater_or_equal.go | 8 +++++--- node/expr/binary_op/identical.go | 8 +++++--- node/expr/binary_op/logical_and.go | 8 +++++--- node/expr/binary_op/logical_or.go | 8 +++++--- node/expr/binary_op/logical_xor.go | 8 +++++--- node/expr/binary_op/minus.go | 8 +++++--- node/expr/binary_op/mod.go | 8 +++++--- node/expr/binary_op/mul.go | 8 +++++--- node/expr/binary_op/not_equal.go | 8 +++++--- node/expr/binary_op/not_identical.go | 8 +++++--- node/expr/binary_op/plus.go | 8 +++++--- node/expr/binary_op/pow.go | 8 +++++--- node/expr/binary_op/shift_left.go | 8 +++++--- node/expr/binary_op/shift_right.go | 8 +++++--- node/expr/binary_op/smaller.go | 8 +++++--- node/expr/binary_op/smaller_or_equal.go | 8 +++++--- node/expr/binary_op/spaceship.go | 8 +++++--- node/expr/bitwise_not.go | 6 ++++-- node/expr/boolean_not.go | 6 ++++-- node/expr/cast/cast_array.go | 6 ++++-- node/expr/cast/cast_bool.go | 6 ++++-- node/expr/cast/cast_double.go | 6 ++++-- node/expr/cast/cast_int.go | 6 ++++-- node/expr/cast/cast_object.go | 6 ++++-- node/expr/cast/cast_string.go | 6 ++++-- node/expr/cast/cast_unset.go | 6 ++++-- node/expr/class_const_fetch.go | 6 ++++-- node/expr/clone.go | 6 ++++-- node/expr/closure.go | 12 +++++++----- node/expr/closure_use.go | 6 ++++-- node/expr/const_fetch.go | 6 ++++-- node/expr/empty.go | 6 ++++-- node/expr/error_suppress.go | 6 ++++-- node/expr/eval.go | 6 ++++-- node/expr/exit.go | 6 ++++-- node/expr/function_call.go | 8 +++++--- node/expr/include.go | 6 ++++-- node/expr/include_once.go | 6 ++++-- node/expr/instance_of.go | 8 +++++--- node/expr/isset.go | 6 ++++-- node/expr/list.go | 6 ++++-- node/expr/method_call.go | 10 ++++++---- node/expr/new.go | 8 +++++--- node/expr/post_dec.go | 6 ++++-- node/expr/post_inc.go | 6 ++++-- node/expr/pre_dec.go | 6 ++++-- node/expr/pre_inc.go | 6 ++++-- node/expr/print.go | 6 ++++-- node/expr/property_fetch.go | 8 +++++--- node/expr/require.go | 6 ++++-- node/expr/require_once.go | 6 ++++-- node/expr/shell_exec.go | 6 ++++-- node/expr/short_array.go | 6 ++++-- node/expr/short_list.go | 6 ++++-- node/expr/static_call.go | 10 ++++++---- node/expr/static_property_fetch.go | 8 +++++--- node/expr/ternary.go | 10 ++++++---- node/expr/unary_minus.go | 6 ++++-- node/expr/unary_plus.go | 6 ++++-- node/expr/variable.go | 6 ++++-- node/expr/yield.go | 8 +++++--- node/expr/yield_from.go | 6 ++++-- node/identifier.go | 4 +++- node/name/name.go | 4 ++-- node/name/name_part.go | 2 +- node/nullable.go | 6 ++++-- node/parameter.go | 10 ++++++---- node/scalar/dnumber.go | 2 +- node/scalar/encapsed.go | 4 ++-- node/scalar/encapsed_string_part.go | 2 +- node/scalar/lnumber.go | 2 +- node/scalar/magic_constant.go | 2 +- node/scalar/string.go | 2 +- node/stmt/alt_else.go | 6 ++++-- node/stmt/alt_else_if.go | 8 +++++--- node/stmt/alt_if.go | 12 +++++++----- node/stmt/break.go | 6 ++++-- node/stmt/case.go | 8 +++++--- node/stmt/catch.go | 8 +++++--- node/stmt/class.go | 14 ++++++++------ node/stmt/class_const_list.go | 8 +++++--- node/stmt/class_method.go | 12 +++++++----- node/stmt/const_list.go | 6 ++++-- node/stmt/constant.go | 6 ++++-- node/stmt/continue.go | 6 ++++-- node/stmt/declare.go | 8 +++++--- node/stmt/default.go | 6 ++++-- node/stmt/do.go | 8 +++++--- node/stmt/echo.go | 6 ++++-- node/stmt/else.go | 6 ++++-- node/stmt/else_if.go | 8 +++++--- node/stmt/expression.go | 6 ++++-- node/stmt/finally.go | 6 ++++-- node/stmt/for.go | 12 +++++++----- node/stmt/foreach.go | 12 +++++++----- node/stmt/function.go | 10 ++++++---- node/stmt/global.go | 6 ++++-- node/stmt/goto.go | 4 +++- node/stmt/group_use.go | 10 ++++++---- node/stmt/halt_compiler.go | 4 +++- node/stmt/if.go | 12 +++++++----- node/stmt/inline_html.go | 4 +++- node/stmt/interface.go | 8 +++++--- node/stmt/label.go | 4 +++- node/stmt/namespace.go | 8 +++++--- node/stmt/nop.go | 4 +++- node/stmt/property.go | 6 ++++-- node/stmt/property_list.go | 8 +++++--- node/stmt/return.go | 6 ++++-- node/stmt/static.go | 6 ++++-- node/stmt/static_var.go | 6 ++++-- node/stmt/stmt_list.go | 6 ++++-- node/stmt/switch.go | 8 +++++--- node/stmt/throw.go | 6 ++++-- node/stmt/trait.go | 6 ++++-- node/stmt/trait_method_ref.go | 6 ++++-- node/stmt/trait_use.go | 8 +++++--- node/stmt/trait_use_alias.go | 8 +++++--- node/stmt/trait_use_precedence.go | 8 +++++--- node/stmt/try.go | 10 ++++++---- node/stmt/unset.go | 6 ++++-- node/stmt/use.go | 8 +++++--- node/stmt/use_list.go | 8 +++++--- node/stmt/while.go | 8 +++++--- node/visitor.go | 5 +++-- 154 files changed, 691 insertions(+), 398 deletions(-) diff --git a/dumper.go b/dumper.go index 3e2ef65..9b94f3e 100644 --- a/dumper.go +++ b/dumper.go @@ -10,13 +10,13 @@ type dumper struct { indent string } -func (d dumper) Visit(n node.Node) bool { +func (d dumper) EnterNode(n node.Node) bool { fmt.Printf("%v[%v]:\n", d.indent, n.Name()) return true } -func (d dumper) Children(key string) node.Visitor { +func (d dumper) GetChildrenVisitor(key string) node.Visitor { fmt.Printf("%v%v:\n", d.indent+". ", key) return dumper{d.indent + ". . "} } @@ -24,3 +24,7 @@ func (d dumper) Children(key string) node.Visitor { func (d dumper) Scalar(key string, value interface{}) { fmt.Printf("%v%v: %v\n", d.indent+". ", key, value) } + +func (d dumper) LeaveNode(n node.Node) { + // do nothing +} diff --git a/node/argument.go b/node/argument.go index e50dc82..9c20f41 100644 --- a/node/argument.go +++ b/node/argument.go @@ -19,12 +19,14 @@ func NewArgument(expression Node, variadic bool) Node { } func (n Argument) Walk(v Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/array.go b/node/expr/array.go index 773de1d..439fd63 100644 --- a/node/expr/array.go +++ b/node/expr/array.go @@ -26,14 +26,16 @@ func NewArray(opentToken token.Token, closeToken token.Token, items []node.Node) } func (n Array) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.items != nil { - vv := v.Children("items") + vv := v.GetChildrenVisitor("items") for _, nn := range n.items { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/expr/array_dim_fetch.go b/node/expr/array_dim_fetch.go index 34d9dfc..bb126b2 100644 --- a/node/expr/array_dim_fetch.go +++ b/node/expr/array_dim_fetch.go @@ -23,17 +23,19 @@ func NewArrayDimFetch(variable node.Node, dim node.Node) node.Node { } func (n ArrayDimFetch) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } if n.dim != nil { - vv := v.Children("dim") + vv := v.GetChildrenVisitor("dim") n.dim.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/array_item.go b/node/expr/array_item.go index 9073be9..b71b0df 100644 --- a/node/expr/array_item.go +++ b/node/expr/array_item.go @@ -25,17 +25,19 @@ func NewArrayItem(key node.Node, val node.Node, byRef bool) node.Node { } func (n ArrayItem) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.key != nil { - vv := v.Children("key") + vv := v.GetChildrenVisitor("key") n.key.Walk(vv) } if n.val != nil { - vv := v.Children("val") + vv := v.GetChildrenVisitor("val") n.val.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/assign_op/assign.go b/node/expr/assign_op/assign.go index b8da9f1..8207d37 100644 --- a/node/expr/assign_op/assign.go +++ b/node/expr/assign_op/assign.go @@ -23,17 +23,19 @@ func NewAssign(variable node.Node, expression node.Node) node.Node { } func (n Assign) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } if n.expression != nil { - vv := v.Children("expression") + vv := v.GetChildrenVisitor("expression") n.expression.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/assign_op/assign_ref.go b/node/expr/assign_op/assign_ref.go index b1e7810..e17a463 100644 --- a/node/expr/assign_op/assign_ref.go +++ b/node/expr/assign_op/assign_ref.go @@ -23,17 +23,19 @@ func NewAssignRef(variable node.Node, expression node.Node) node.Node { } func (n AssignRef) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } if n.expression != nil { - vv := v.Children("expression") + vv := v.GetChildrenVisitor("expression") n.expression.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/assign_op/bitwise_and.go b/node/expr/assign_op/bitwise_and.go index 3878e58..9e3bf85 100644 --- a/node/expr/assign_op/bitwise_and.go +++ b/node/expr/assign_op/bitwise_and.go @@ -23,17 +23,19 @@ func NewBitwiseAnd(variable node.Node, expression node.Node) node.Node { } func (n BitwiseAnd) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } if n.expression != nil { - vv := v.Children("expression") + vv := v.GetChildrenVisitor("expression") n.expression.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/assign_op/bitwise_or.go b/node/expr/assign_op/bitwise_or.go index 55f3e59..3e93244 100644 --- a/node/expr/assign_op/bitwise_or.go +++ b/node/expr/assign_op/bitwise_or.go @@ -23,17 +23,19 @@ func NewBitwiseOr(variable node.Node, expression node.Node) node.Node { } func (n BitwiseOr) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } if n.expression != nil { - vv := v.Children("expression") + vv := v.GetChildrenVisitor("expression") n.expression.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/assign_op/bitwise_xor.go b/node/expr/assign_op/bitwise_xor.go index d0e1927..b213e46 100644 --- a/node/expr/assign_op/bitwise_xor.go +++ b/node/expr/assign_op/bitwise_xor.go @@ -23,17 +23,19 @@ func (n BitwiseXor) Name() string { } func (n BitwiseXor) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } if n.expression != nil { - vv := v.Children("expression") + vv := v.GetChildrenVisitor("expression") n.expression.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/assign_op/concat.go b/node/expr/assign_op/concat.go index bd9621e..54fdca8 100644 --- a/node/expr/assign_op/concat.go +++ b/node/expr/assign_op/concat.go @@ -23,17 +23,19 @@ func NewConcat(variable node.Node, expression node.Node) node.Node { } func (n Concat) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } if n.expression != nil { - vv := v.Children("expression") + vv := v.GetChildrenVisitor("expression") n.expression.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/assign_op/div.go b/node/expr/assign_op/div.go index b9b6716..bfdaed8 100644 --- a/node/expr/assign_op/div.go +++ b/node/expr/assign_op/div.go @@ -23,17 +23,19 @@ func NewDiv(variable node.Node, expression node.Node) node.Node { } func (n Div) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } if n.expression != nil { - vv := v.Children("expression") + vv := v.GetChildrenVisitor("expression") n.expression.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/assign_op/minus.go b/node/expr/assign_op/minus.go index 47b9ef8..0c30485 100644 --- a/node/expr/assign_op/minus.go +++ b/node/expr/assign_op/minus.go @@ -23,17 +23,19 @@ func NewMinus(variable node.Node, expression node.Node) node.Node { } func (n Minus) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } if n.expression != nil { - vv := v.Children("expression") + vv := v.GetChildrenVisitor("expression") n.expression.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/assign_op/mod.go b/node/expr/assign_op/mod.go index ab2163e..c0e60b3 100644 --- a/node/expr/assign_op/mod.go +++ b/node/expr/assign_op/mod.go @@ -23,17 +23,19 @@ func NewMod(variable node.Node, expression node.Node) node.Node { } func (n Mod) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } if n.expression != nil { - vv := v.Children("expression") + vv := v.GetChildrenVisitor("expression") n.expression.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/assign_op/mul.go b/node/expr/assign_op/mul.go index cd0b5d8..be7764a 100644 --- a/node/expr/assign_op/mul.go +++ b/node/expr/assign_op/mul.go @@ -23,17 +23,19 @@ func NewMul(variable node.Node, expression node.Node) node.Node { } func (n Mul) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } if n.expression != nil { - vv := v.Children("expression") + vv := v.GetChildrenVisitor("expression") n.expression.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/assign_op/plus.go b/node/expr/assign_op/plus.go index ca3375f..c576320 100644 --- a/node/expr/assign_op/plus.go +++ b/node/expr/assign_op/plus.go @@ -23,17 +23,19 @@ func NewPlus(variable node.Node, expression node.Node) node.Node { } func (n Plus) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } if n.expression != nil { - vv := v.Children("expression") + vv := v.GetChildrenVisitor("expression") n.expression.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/assign_op/pow.go b/node/expr/assign_op/pow.go index 790f359..9d44761 100644 --- a/node/expr/assign_op/pow.go +++ b/node/expr/assign_op/pow.go @@ -23,17 +23,19 @@ func NewPow(variable node.Node, expression node.Node) node.Node { } func (n Pow) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } if n.expression != nil { - vv := v.Children("expression") + vv := v.GetChildrenVisitor("expression") n.expression.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/assign_op/shift_left.go b/node/expr/assign_op/shift_left.go index 13a1aeb..8e40721 100644 --- a/node/expr/assign_op/shift_left.go +++ b/node/expr/assign_op/shift_left.go @@ -23,17 +23,19 @@ func NewShiftLeft(variable node.Node, expression node.Node) node.Node { } func (n ShiftLeft) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } if n.expression != nil { - vv := v.Children("expression") + vv := v.GetChildrenVisitor("expression") n.expression.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/assign_op/shift_right.go b/node/expr/assign_op/shift_right.go index 03b153b..ac507c2 100644 --- a/node/expr/assign_op/shift_right.go +++ b/node/expr/assign_op/shift_right.go @@ -23,17 +23,19 @@ func NewShiftRight(variable node.Node, expression node.Node) node.Node { } func (n ShiftRight) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } if n.expression != nil { - vv := v.Children("expression") + vv := v.GetChildrenVisitor("expression") n.expression.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/bitwise_and.go b/node/expr/binary_op/bitwise_and.go index bbeb817..25d3625 100644 --- a/node/expr/binary_op/bitwise_and.go +++ b/node/expr/binary_op/bitwise_and.go @@ -23,17 +23,19 @@ func NewBitwiseAnd(variable node.Node, expression node.Node) node.Node { } func (n BitwiseAnd) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/bitwise_or.go b/node/expr/binary_op/bitwise_or.go index 93650bf..56c7261 100644 --- a/node/expr/binary_op/bitwise_or.go +++ b/node/expr/binary_op/bitwise_or.go @@ -23,17 +23,19 @@ func (n BitwiseOr) Name() string { } func (n BitwiseOr) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/bitwise_xor.go b/node/expr/binary_op/bitwise_xor.go index 2d68ed7..d0dd8b8 100644 --- a/node/expr/binary_op/bitwise_xor.go +++ b/node/expr/binary_op/bitwise_xor.go @@ -23,17 +23,19 @@ func (n BitwiseXor) Name() string { } func (n BitwiseXor) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/boolean_and.go b/node/expr/binary_op/boolean_and.go index 422be6a..e15e031 100644 --- a/node/expr/binary_op/boolean_and.go +++ b/node/expr/binary_op/boolean_and.go @@ -23,17 +23,19 @@ func NewBooleanAnd(variable node.Node, expression node.Node) node.Node { } func (n BooleanAnd) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/boolean_or.go b/node/expr/binary_op/boolean_or.go index 35c56d6..3b2002c 100644 --- a/node/expr/binary_op/boolean_or.go +++ b/node/expr/binary_op/boolean_or.go @@ -23,17 +23,19 @@ func NewBooleanOr(variable node.Node, expression node.Node) node.Node { } func (n BooleanOr) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/coalesce.go b/node/expr/binary_op/coalesce.go index f0a2b4a..611f3ab 100644 --- a/node/expr/binary_op/coalesce.go +++ b/node/expr/binary_op/coalesce.go @@ -23,17 +23,19 @@ func NewCoalesce(variable node.Node, expression node.Node) node.Node { } func (n Coalesce) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/concat.go b/node/expr/binary_op/concat.go index ac1183d..cf0ad5c 100644 --- a/node/expr/binary_op/concat.go +++ b/node/expr/binary_op/concat.go @@ -23,17 +23,19 @@ func NewConcat(variable node.Node, expression node.Node) node.Node { } func (n Concat) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/div.go b/node/expr/binary_op/div.go index bec6627..13f8a31 100644 --- a/node/expr/binary_op/div.go +++ b/node/expr/binary_op/div.go @@ -23,17 +23,19 @@ func NewDiv(variable node.Node, expression node.Node) node.Node { } func (n Div) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/equal.go b/node/expr/binary_op/equal.go index cef0055..da77da4 100644 --- a/node/expr/binary_op/equal.go +++ b/node/expr/binary_op/equal.go @@ -23,17 +23,19 @@ func NewEqual(variable node.Node, expression node.Node) node.Node { } func (n Equal) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/greater.go b/node/expr/binary_op/greater.go index cd9ec50..f3f8352 100644 --- a/node/expr/binary_op/greater.go +++ b/node/expr/binary_op/greater.go @@ -23,17 +23,19 @@ func NewGreater(variable node.Node, expression node.Node) node.Node { } func (n Greater) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/greater_or_equal.go b/node/expr/binary_op/greater_or_equal.go index 8e7f52f..c267c63 100644 --- a/node/expr/binary_op/greater_or_equal.go +++ b/node/expr/binary_op/greater_or_equal.go @@ -23,17 +23,19 @@ func NewGreaterOrEqual(variable node.Node, expression node.Node) node.Node { } func (n GreaterOrEqual) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/identical.go b/node/expr/binary_op/identical.go index c5e5094..61e5ed4 100644 --- a/node/expr/binary_op/identical.go +++ b/node/expr/binary_op/identical.go @@ -23,17 +23,19 @@ func NewIdentical(variable node.Node, expression node.Node) node.Node { } func (n Identical) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/logical_and.go b/node/expr/binary_op/logical_and.go index 31edd78..e10075d 100644 --- a/node/expr/binary_op/logical_and.go +++ b/node/expr/binary_op/logical_and.go @@ -23,17 +23,19 @@ func NewLogicalAnd(variable node.Node, expression node.Node) node.Node { } func (n LogicalAnd) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/logical_or.go b/node/expr/binary_op/logical_or.go index 7be1e49..463f20d 100644 --- a/node/expr/binary_op/logical_or.go +++ b/node/expr/binary_op/logical_or.go @@ -23,17 +23,19 @@ func NewLogicalOr(variable node.Node, expression node.Node) node.Node { } func (n LogicalOr) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/logical_xor.go b/node/expr/binary_op/logical_xor.go index c1960b6..0fe06d3 100644 --- a/node/expr/binary_op/logical_xor.go +++ b/node/expr/binary_op/logical_xor.go @@ -23,17 +23,19 @@ func NewLogicalXor(variable node.Node, expression node.Node) node.Node { } func (n LogicalXor) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/minus.go b/node/expr/binary_op/minus.go index e7924b3..89be533 100644 --- a/node/expr/binary_op/minus.go +++ b/node/expr/binary_op/minus.go @@ -23,17 +23,19 @@ func NewMinus(variable node.Node, expression node.Node) node.Node { } func (n Minus) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/mod.go b/node/expr/binary_op/mod.go index da9da7c..6515806 100644 --- a/node/expr/binary_op/mod.go +++ b/node/expr/binary_op/mod.go @@ -23,17 +23,19 @@ func NewMod(variable node.Node, expression node.Node) node.Node { } func (n Mod) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/mul.go b/node/expr/binary_op/mul.go index e5ef893..257d1c3 100644 --- a/node/expr/binary_op/mul.go +++ b/node/expr/binary_op/mul.go @@ -23,17 +23,19 @@ func NewMul(variable node.Node, expression node.Node) node.Node { } func (n Mul) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/not_equal.go b/node/expr/binary_op/not_equal.go index fdee617..4b393df 100644 --- a/node/expr/binary_op/not_equal.go +++ b/node/expr/binary_op/not_equal.go @@ -23,17 +23,19 @@ func NewNotEqual(variable node.Node, expression node.Node) node.Node { } func (n NotEqual) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/not_identical.go b/node/expr/binary_op/not_identical.go index 6a2deb8..d351b72 100644 --- a/node/expr/binary_op/not_identical.go +++ b/node/expr/binary_op/not_identical.go @@ -23,17 +23,19 @@ func NewNotIdentical(variable node.Node, expression node.Node) node.Node { } func (n NotIdentical) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/plus.go b/node/expr/binary_op/plus.go index c7a805f..0c21d7d 100644 --- a/node/expr/binary_op/plus.go +++ b/node/expr/binary_op/plus.go @@ -23,17 +23,19 @@ func NewPlus(variable node.Node, expression node.Node) node.Node { } func (n Plus) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/pow.go b/node/expr/binary_op/pow.go index 5f28094..56cedc3 100644 --- a/node/expr/binary_op/pow.go +++ b/node/expr/binary_op/pow.go @@ -23,17 +23,19 @@ func NewPow(variable node.Node, expression node.Node) node.Node { } func (n Pow) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/shift_left.go b/node/expr/binary_op/shift_left.go index 7be8148..980c0da 100644 --- a/node/expr/binary_op/shift_left.go +++ b/node/expr/binary_op/shift_left.go @@ -23,17 +23,19 @@ func NewShiftLeft(variable node.Node, expression node.Node) node.Node { } func (n ShiftLeft) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/shift_right.go b/node/expr/binary_op/shift_right.go index 6110ddd..6b6e1b5 100644 --- a/node/expr/binary_op/shift_right.go +++ b/node/expr/binary_op/shift_right.go @@ -23,17 +23,19 @@ func NewShiftRight(variable node.Node, expression node.Node) node.Node { } func (n ShiftRight) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/smaller.go b/node/expr/binary_op/smaller.go index ee98050..f2d7f33 100644 --- a/node/expr/binary_op/smaller.go +++ b/node/expr/binary_op/smaller.go @@ -23,17 +23,19 @@ func NewSmaller(variable node.Node, expression node.Node) node.Node { } func (n Smaller) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/smaller_or_equal.go b/node/expr/binary_op/smaller_or_equal.go index 934d0e8..db7be1a 100644 --- a/node/expr/binary_op/smaller_or_equal.go +++ b/node/expr/binary_op/smaller_or_equal.go @@ -23,17 +23,19 @@ func NewSmallerOrEqual(variable node.Node, expression node.Node) node.Node { } func (n SmallerOrEqual) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/binary_op/spaceship.go b/node/expr/binary_op/spaceship.go index a2ff825..043204a 100644 --- a/node/expr/binary_op/spaceship.go +++ b/node/expr/binary_op/spaceship.go @@ -23,17 +23,19 @@ func NewSpaceship(variable node.Node, expression node.Node) node.Node { } func (n Spaceship) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.left != nil { - vv := v.Children("left") + vv := v.GetChildrenVisitor("left") n.left.Walk(vv) } if n.right != nil { - vv := v.Children("right") + vv := v.GetChildrenVisitor("right") n.right.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/bitwise_not.go b/node/expr/bitwise_not.go index ea7dcf5..06afcc5 100644 --- a/node/expr/bitwise_not.go +++ b/node/expr/bitwise_not.go @@ -21,12 +21,14 @@ func NewBitwiseNot(expression node.Node) node.Node { } func (n BitwiseNot) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/boolean_not.go b/node/expr/boolean_not.go index f6d2210..3b33e24 100644 --- a/node/expr/boolean_not.go +++ b/node/expr/boolean_not.go @@ -21,12 +21,14 @@ func NewBooleanNot(expression node.Node) node.Node { } func (n BooleanNot) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/cast/cast_array.go b/node/expr/cast/cast_array.go index 2ad6a65..69c29e0 100644 --- a/node/expr/cast/cast_array.go +++ b/node/expr/cast/cast_array.go @@ -22,12 +22,14 @@ func NewCastArray(expr node.Node) node.Node { } func (n CastArray) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/cast/cast_bool.go b/node/expr/cast/cast_bool.go index c5b47a3..f5191ea 100644 --- a/node/expr/cast/cast_bool.go +++ b/node/expr/cast/cast_bool.go @@ -22,12 +22,14 @@ func NewCastBool(expr node.Node) node.Node { } func (n CastBool) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/cast/cast_double.go b/node/expr/cast/cast_double.go index 2ec2a8e..dc98d5d 100644 --- a/node/expr/cast/cast_double.go +++ b/node/expr/cast/cast_double.go @@ -22,12 +22,14 @@ func NewCastDouble(expr node.Node) node.Node { } func (n CastDouble) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/cast/cast_int.go b/node/expr/cast/cast_int.go index 28495f0..3fc0cde 100644 --- a/node/expr/cast/cast_int.go +++ b/node/expr/cast/cast_int.go @@ -22,12 +22,14 @@ func NewCastInt(expr node.Node) node.Node { } func (n CastInt) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/cast/cast_object.go b/node/expr/cast/cast_object.go index 2985726..366cc15 100644 --- a/node/expr/cast/cast_object.go +++ b/node/expr/cast/cast_object.go @@ -22,12 +22,14 @@ func NewCastObject(expr node.Node) node.Node { } func (n CastObject) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/cast/cast_string.go b/node/expr/cast/cast_string.go index 993aa4d..a61003d 100644 --- a/node/expr/cast/cast_string.go +++ b/node/expr/cast/cast_string.go @@ -22,12 +22,14 @@ func NewCastString(expr node.Node) node.Node { } func (n CastString) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/cast/cast_unset.go b/node/expr/cast/cast_unset.go index b9359c7..97959dc 100644 --- a/node/expr/cast/cast_unset.go +++ b/node/expr/cast/cast_unset.go @@ -22,12 +22,14 @@ func NewCastUnset(expr node.Node) node.Node { } func (n CastUnset) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/class_const_fetch.go b/node/expr/class_const_fetch.go index 8926c37..8feb796 100644 --- a/node/expr/class_const_fetch.go +++ b/node/expr/class_const_fetch.go @@ -25,14 +25,16 @@ func NewClassConstFetch(class node.Node, constant token.Token) node.Node { } func (n ClassConstFetch) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } v.Scalar("constant", n.constant.Value) if n.class != nil { - vv := v.Children("class") + vv := v.GetChildrenVisitor("class") n.class.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/clone.go b/node/expr/clone.go index 21ec935..a5bdee8 100644 --- a/node/expr/clone.go +++ b/node/expr/clone.go @@ -21,12 +21,14 @@ func NewClone(expression node.Node) node.Node { } func (n Clone) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/closure.go b/node/expr/closure.go index 6d47ebe..75d1d4b 100644 --- a/node/expr/closure.go +++ b/node/expr/closure.go @@ -31,7 +31,7 @@ func NewClosure(params []node.Node, uses []node.Node, returnType node.Node, stmt } func (n Closure) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } @@ -39,28 +39,30 @@ func (n Closure) Walk(v node.Visitor) { v.Scalar("isReturnRef", n.isReturnRef) if n.params != nil { - vv := v.Children("params") + vv := v.GetChildrenVisitor("params") for _, nn := range n.params { nn.Walk(vv) } } if n.uses != nil { - vv := v.Children("uses") + vv := v.GetChildrenVisitor("uses") for _, nn := range n.uses { nn.Walk(vv) } } if n.returnType != nil { - vv := v.Children("returnType") + vv := v.GetChildrenVisitor("returnType") n.returnType.Walk(vv) } if n.stmts != nil { - vv := v.Children("stmts") + vv := v.GetChildrenVisitor("stmts") for _, nn := range n.stmts { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/expr/closure_use.go b/node/expr/closure_use.go index 4e48da6..302a8bf 100644 --- a/node/expr/closure_use.go +++ b/node/expr/closure_use.go @@ -23,14 +23,16 @@ func NewClusureUse(variable node.Node, byRef bool) node.Node { } func (n ClusureUse) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } v.Scalar("byRef", n.byRef) if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/const_fetch.go b/node/expr/const_fetch.go index 3607ba8..7385953 100644 --- a/node/expr/const_fetch.go +++ b/node/expr/const_fetch.go @@ -21,12 +21,14 @@ func NewConstFetch(constant node.Node) node.Node { } func (n ConstFetch) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.constant != nil { - vv := v.Children("constant") + vv := v.GetChildrenVisitor("constant") n.constant.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/empty.go b/node/expr/empty.go index 3546c99..19426b9 100644 --- a/node/expr/empty.go +++ b/node/expr/empty.go @@ -21,12 +21,14 @@ func NewEmpty(expression node.Node) node.Node { } func (n Empty) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/error_suppress.go b/node/expr/error_suppress.go index 4bbd76f..6346230 100644 --- a/node/expr/error_suppress.go +++ b/node/expr/error_suppress.go @@ -21,12 +21,14 @@ func NewErrorSuppress(expression node.Node) node.Node { } func (n ErrorSuppress) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/eval.go b/node/expr/eval.go index 08dcca3..2f40487 100644 --- a/node/expr/eval.go +++ b/node/expr/eval.go @@ -21,12 +21,14 @@ func NewEval(expression node.Node) node.Node { } func (n Eval) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/exit.go b/node/expr/exit.go index 50248df..b0a5d83 100644 --- a/node/expr/exit.go +++ b/node/expr/exit.go @@ -23,12 +23,14 @@ func NewExit(expr node.Node, isDie bool) node.Node { } func (n Exit) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/function_call.go b/node/expr/function_call.go index 90a8fe1..0b8ffed 100644 --- a/node/expr/function_call.go +++ b/node/expr/function_call.go @@ -23,19 +23,21 @@ func NewFunctionCall(function node.Node, arguments []node.Node) node.Node { } func (n FunctionCall) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.function != nil { - vv := v.Children("function") + vv := v.GetChildrenVisitor("function") n.function.Walk(vv) } if n.arguments != nil { - vv := v.Children("arguments") + vv := v.GetChildrenVisitor("arguments") for _, nn := range n.arguments { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/expr/include.go b/node/expr/include.go index 634e797..8cdd2c4 100644 --- a/node/expr/include.go +++ b/node/expr/include.go @@ -21,12 +21,14 @@ func NewInclude(expression node.Node) node.Node { } func (n Include) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/include_once.go b/node/expr/include_once.go index 8c564bb..78d56d3 100644 --- a/node/expr/include_once.go +++ b/node/expr/include_once.go @@ -21,12 +21,14 @@ func NewIncludeOnce(expression node.Node) node.Node { } func (n IncludeOnce) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/instance_of.go b/node/expr/instance_of.go index 94a1e27..dff3b90 100644 --- a/node/expr/instance_of.go +++ b/node/expr/instance_of.go @@ -23,17 +23,19 @@ func NewInstanceOf(expr node.Node, class node.Node) node.Node { } func (n InstanceOf) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } if n.class != nil { - vv := v.Children("class") + vv := v.GetChildrenVisitor("class") n.class.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/isset.go b/node/expr/isset.go index f17c74e..57f0a7b 100644 --- a/node/expr/isset.go +++ b/node/expr/isset.go @@ -21,14 +21,16 @@ func NewIsset(variables []node.Node) node.Node { } func (n Isset) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.variables != nil { - vv := v.Children("variables") + vv := v.GetChildrenVisitor("variables") for _, nn := range n.variables { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/expr/list.go b/node/expr/list.go index d9c9f34..8093e3e 100644 --- a/node/expr/list.go +++ b/node/expr/list.go @@ -21,14 +21,16 @@ func NewList(items []node.Node) node.Node { } func (n List) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.items != nil { - vv := v.Children("items") + vv := v.GetChildrenVisitor("items") for _, nn := range n.items { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/expr/method_call.go b/node/expr/method_call.go index 1cbb154..d9bcbaf 100644 --- a/node/expr/method_call.go +++ b/node/expr/method_call.go @@ -25,24 +25,26 @@ func NewMethodCall(variable node.Node, method node.Node, arguments []node.Node) } func (n MethodCall) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } if n.method != nil { - vv := v.Children("method") + vv := v.GetChildrenVisitor("method") n.method.Walk(vv) } if n.arguments != nil { - vv := v.Children("arguments") + vv := v.GetChildrenVisitor("arguments") for _, nn := range n.arguments { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/expr/new.go b/node/expr/new.go index 311cc17..625ea4d 100644 --- a/node/expr/new.go +++ b/node/expr/new.go @@ -23,19 +23,21 @@ func NewNew(class node.Node, arguments []node.Node) node.Node { } func (n New) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.class != nil { - vv := v.Children("class") + vv := v.GetChildrenVisitor("class") n.class.Walk(vv) } if n.arguments != nil { - vv := v.Children("arguments") + vv := v.GetChildrenVisitor("arguments") for _, nn := range n.arguments { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/expr/post_dec.go b/node/expr/post_dec.go index 25d9dc6..8f7454d 100644 --- a/node/expr/post_dec.go +++ b/node/expr/post_dec.go @@ -21,12 +21,14 @@ func NewPostDec(variableession node.Node) node.Node { } func (n PostDec) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/post_inc.go b/node/expr/post_inc.go index be9cccc..5da07e7 100644 --- a/node/expr/post_inc.go +++ b/node/expr/post_inc.go @@ -21,12 +21,14 @@ func NewPostInc(variableession node.Node) node.Node { } func (n PostInc) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/pre_dec.go b/node/expr/pre_dec.go index 2036ae6..6a10549 100644 --- a/node/expr/pre_dec.go +++ b/node/expr/pre_dec.go @@ -21,12 +21,14 @@ func NewPreDec(variableession node.Node) node.Node { } func (n PreDec) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/pre_inc.go b/node/expr/pre_inc.go index 3ddc59e..d94c28c 100644 --- a/node/expr/pre_inc.go +++ b/node/expr/pre_inc.go @@ -21,12 +21,14 @@ func NewPreInc(variableession node.Node) node.Node { } func (n PreInc) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/print.go b/node/expr/print.go index 6adcd5f..98623df 100644 --- a/node/expr/print.go +++ b/node/expr/print.go @@ -21,12 +21,14 @@ func NewPrint(expression node.Node) node.Node { } func (n Print) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/property_fetch.go b/node/expr/property_fetch.go index 6469ba4..f95efb0 100644 --- a/node/expr/property_fetch.go +++ b/node/expr/property_fetch.go @@ -23,17 +23,19 @@ func NewPropertyFetch(variable node.Node, property node.Node) node.Node { } func (n PropertyFetch) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } if n.property != nil { - vv := v.Children("property") + vv := v.GetChildrenVisitor("property") n.property.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/require.go b/node/expr/require.go index 0e6d7be..af115b7 100644 --- a/node/expr/require.go +++ b/node/expr/require.go @@ -21,12 +21,14 @@ func NewRequire(expression node.Node) node.Node { } func (n Require) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/require_once.go b/node/expr/require_once.go index 491fa54..3c49f34 100644 --- a/node/expr/require_once.go +++ b/node/expr/require_once.go @@ -21,12 +21,14 @@ func NewRequireOnce(expression node.Node) node.Node { } func (n RequireOnce) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/shell_exec.go b/node/expr/shell_exec.go index 4b7bb6a..92bfdac 100644 --- a/node/expr/shell_exec.go +++ b/node/expr/shell_exec.go @@ -21,14 +21,16 @@ func NewShellExec(parts []node.Node) node.Node { } func (n ShellExec) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.parts != nil { - vv := v.Children("parts") + vv := v.GetChildrenVisitor("parts") for _, nn := range n.parts { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/expr/short_array.go b/node/expr/short_array.go index 0f4b2e2..ab8b148 100644 --- a/node/expr/short_array.go +++ b/node/expr/short_array.go @@ -26,14 +26,16 @@ func NewShortArray(opentToken token.Token, closeToken token.Token, items []node. } func (n ShortArray) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.items != nil { - vv := v.Children("items") + vv := v.GetChildrenVisitor("items") for _, nn := range n.items { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/expr/short_list.go b/node/expr/short_list.go index d7c3ac3..f326507 100644 --- a/node/expr/short_list.go +++ b/node/expr/short_list.go @@ -21,14 +21,16 @@ func NewShortList(items []node.Node) node.Node { } func (n ShortList) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.items != nil { - vv := v.Children("items") + vv := v.GetChildrenVisitor("items") for _, nn := range n.items { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/expr/static_call.go b/node/expr/static_call.go index 41ddce1..d43cf8a 100644 --- a/node/expr/static_call.go +++ b/node/expr/static_call.go @@ -25,24 +25,26 @@ func NewStaticCall(class node.Node, call node.Node, arguments []node.Node) node. } func (n StaticCall) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.class != nil { - vv := v.Children("class") + vv := v.GetChildrenVisitor("class") n.class.Walk(vv) } if n.call != nil { - vv := v.Children("call") + vv := v.GetChildrenVisitor("call") n.call.Walk(vv) } if n.arguments != nil { - vv := v.Children("arguments") + vv := v.GetChildrenVisitor("arguments") for _, nn := range n.arguments { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/expr/static_property_fetch.go b/node/expr/static_property_fetch.go index 4a67fd4..12a9b62 100644 --- a/node/expr/static_property_fetch.go +++ b/node/expr/static_property_fetch.go @@ -23,17 +23,19 @@ func NewStaticPropertyFetch(class node.Node, property node.Node) node.Node { } func (n StaticPropertyFetch) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.class != nil { - vv := v.Children("class") + vv := v.GetChildrenVisitor("class") n.class.Walk(vv) } if n.property != nil { - vv := v.Children("property") + vv := v.GetChildrenVisitor("property") n.property.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/ternary.go b/node/expr/ternary.go index 9296c14..b56735b 100644 --- a/node/expr/ternary.go +++ b/node/expr/ternary.go @@ -25,22 +25,24 @@ func NewTernary(condition node.Node, ifTrue node.Node, ifFalse node.Node) node.N } func (n Ternary) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.condition != nil { - vv := v.Children("condition") + vv := v.GetChildrenVisitor("condition") n.condition.Walk(vv) } if n.ifTrue != nil { - vv := v.Children("ifTrue") + vv := v.GetChildrenVisitor("ifTrue") n.ifTrue.Walk(vv) } if n.ifFalse != nil { - vv := v.Children("ifFalse") + vv := v.GetChildrenVisitor("ifFalse") n.ifFalse.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/unary_minus.go b/node/expr/unary_minus.go index 4ecb90c..0c4260c 100644 --- a/node/expr/unary_minus.go +++ b/node/expr/unary_minus.go @@ -21,12 +21,14 @@ func NewUnaryMinus(expression node.Node) node.Node { } func (n UnaryMinus) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/unary_plus.go b/node/expr/unary_plus.go index c0bb60d..1e8578a 100644 --- a/node/expr/unary_plus.go +++ b/node/expr/unary_plus.go @@ -21,12 +21,14 @@ func NewUnaryPlus(expression node.Node) node.Node { } func (n UnaryPlus) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/variable.go b/node/expr/variable.go index 3d0e787..b1282ef 100644 --- a/node/expr/variable.go +++ b/node/expr/variable.go @@ -21,12 +21,14 @@ func NewVariable(varName node.Node) node.Node { } func (n Variable) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.varName != nil { - vv := v.Children("varName") + vv := v.GetChildrenVisitor("varName") n.varName.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/yield.go b/node/expr/yield.go index 470aceb..20f677e 100644 --- a/node/expr/yield.go +++ b/node/expr/yield.go @@ -23,17 +23,19 @@ func NewYield(key node.Node, value node.Node) node.Node { } func (n Yield) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.key != nil { - vv := v.Children("key") + vv := v.GetChildrenVisitor("key") n.key.Walk(vv) } if n.value != nil { - vv := v.Children("value") + vv := v.GetChildrenVisitor("value") n.value.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/expr/yield_from.go b/node/expr/yield_from.go index 78f6a7f..4a85d76 100644 --- a/node/expr/yield_from.go +++ b/node/expr/yield_from.go @@ -21,12 +21,14 @@ func NewYieldFrom(expression node.Node) node.Node { } func (n YieldFrom) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/identifier.go b/node/identifier.go index 4d38366..24ad694 100644 --- a/node/identifier.go +++ b/node/identifier.go @@ -21,9 +21,11 @@ func NewIdentifier(token token.Token) Node { } func (n Identifier) Walk(v Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } v.Scalar("token", n.token.Value) + + v.LeaveNode(n) } diff --git a/node/name/name.go b/node/name/name.go index 30c5eb6..4eb061a 100644 --- a/node/name/name.go +++ b/node/name/name.go @@ -21,12 +21,12 @@ func NewName(parts []node.Node) node.Node { } func (n NameNode) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.parts != nil { - vv := v.Children("parts") + vv := v.GetChildrenVisitor("parts") for _, nn := range n.parts { nn.Walk(vv) } diff --git a/node/name/name_part.go b/node/name/name_part.go index 56f35d8..37223b7 100644 --- a/node/name/name_part.go +++ b/node/name/name_part.go @@ -22,7 +22,7 @@ func NewNamePart(token token.Token) node.Node { } func (n NamePart) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } diff --git a/node/nullable.go b/node/nullable.go index da751c3..3ec57e6 100644 --- a/node/nullable.go +++ b/node/nullable.go @@ -17,12 +17,14 @@ func NewNullable(expression Node) Node { } func (n Nullable) Walk(v Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/parameter.go b/node/parameter.go index 90e35e1..39c340c 100644 --- a/node/parameter.go +++ b/node/parameter.go @@ -25,7 +25,7 @@ func NewParameter(variableType Node, variable Node, defaultValue Node, byRef boo } func (n Parameter) Walk(v Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } @@ -33,17 +33,19 @@ func (n Parameter) Walk(v Visitor) { v.Scalar("variadic", n.variadic) if n.variableType != nil { - vv := v.Children("variableType") + vv := v.GetChildrenVisitor("variableType") n.variableType.Walk(vv) } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } if n.defaultValue != nil { - vv := v.Children("defaultValue") + vv := v.GetChildrenVisitor("defaultValue") n.defaultValue.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/scalar/dnumber.go b/node/scalar/dnumber.go index 5c8bd96..5003e3b 100644 --- a/node/scalar/dnumber.go +++ b/node/scalar/dnumber.go @@ -22,7 +22,7 @@ func NewDnumber(token token.Token) node.Node { } func (n Dnumber) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } diff --git a/node/scalar/encapsed.go b/node/scalar/encapsed.go index 6ebeaf8..0367495 100644 --- a/node/scalar/encapsed.go +++ b/node/scalar/encapsed.go @@ -26,12 +26,12 @@ func NewEncapsed(startToken token.Token, parts []node.Node, endToken token.Token } func (n Encapsed) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.parts != nil { - vv := v.Children("parts") + vv := v.GetChildrenVisitor("parts") for _, nn := range n.parts { nn.Walk(vv) } diff --git a/node/scalar/encapsed_string_part.go b/node/scalar/encapsed_string_part.go index 41ea6cf..c20b739 100644 --- a/node/scalar/encapsed_string_part.go +++ b/node/scalar/encapsed_string_part.go @@ -22,7 +22,7 @@ func NewEncapsedStringPart(t token.Token) node.Node { } func (n EncapsedStringPart) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } diff --git a/node/scalar/lnumber.go b/node/scalar/lnumber.go index 68cb21d..0752ad7 100644 --- a/node/scalar/lnumber.go +++ b/node/scalar/lnumber.go @@ -22,7 +22,7 @@ func NewLnumber(token token.Token) node.Node { } func (n Lnumber) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } diff --git a/node/scalar/magic_constant.go b/node/scalar/magic_constant.go index 0993927..eda5ef7 100644 --- a/node/scalar/magic_constant.go +++ b/node/scalar/magic_constant.go @@ -22,7 +22,7 @@ func NewMagicConstant(token token.Token) node.Node { } func (n MagicConstant) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } diff --git a/node/scalar/string.go b/node/scalar/string.go index 82784e0..1798d1a 100644 --- a/node/scalar/string.go +++ b/node/scalar/string.go @@ -22,7 +22,7 @@ func NewString(token token.Token) node.Node { } func (n String) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } diff --git a/node/stmt/alt_else.go b/node/stmt/alt_else.go index 4e5d768..c64960d 100644 --- a/node/stmt/alt_else.go +++ b/node/stmt/alt_else.go @@ -24,12 +24,14 @@ func NewAltElse(token token.Token, stmt node.Node) node.Node { } func (n AltElse) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.stmt != nil { - vv := v.Children("stmt") + vv := v.GetChildrenVisitor("stmt") n.stmt.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/alt_else_if.go b/node/stmt/alt_else_if.go index c88cbfa..703d374 100644 --- a/node/stmt/alt_else_if.go +++ b/node/stmt/alt_else_if.go @@ -26,17 +26,19 @@ func NewAltElseIf(token token.Token, cond node.Node, stmt node.Node) node.Node { } func (n AltElseIf) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.cond != nil { - vv := v.Children("cond") + vv := v.GetChildrenVisitor("cond") n.cond.Walk(vv) } if n.stmt != nil { - vv := v.Children("stmt") + vv := v.GetChildrenVisitor("stmt") n.stmt.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/alt_if.go b/node/stmt/alt_if.go index 7deca96..0c77679 100644 --- a/node/stmt/alt_if.go +++ b/node/stmt/alt_if.go @@ -46,29 +46,31 @@ func (n AltIf) SetElse(_else node.Node) node.Node { } func (n AltIf) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.cond != nil { - vv := v.Children("cond") + vv := v.GetChildrenVisitor("cond") n.cond.Walk(vv) } if n.stmt != nil { - vv := v.Children("stmt") + vv := v.GetChildrenVisitor("stmt") n.stmt.Walk(vv) } if n.elseIf != nil { - vv := v.Children("elseIf") + vv := v.GetChildrenVisitor("elseIf") for _, nn := range n.elseIf { nn.Walk(vv) } } if n._else != nil { - vv := v.Children("else") + vv := v.GetChildrenVisitor("else") n._else.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/break.go b/node/stmt/break.go index 9749b15..3811725 100644 --- a/node/stmt/break.go +++ b/node/stmt/break.go @@ -24,12 +24,14 @@ func NewBreak(token token.Token, expr node.Node) node.Node { } func (n Break) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/case.go b/node/stmt/case.go index 05f9326..86ae459 100644 --- a/node/stmt/case.go +++ b/node/stmt/case.go @@ -26,19 +26,21 @@ func NewCase(token token.Token, cond node.Node, stmts []node.Node) node.Node { } func (n Case) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.cond != nil { - vv := v.Children("cond") + vv := v.GetChildrenVisitor("cond") n.cond.Walk(vv) } if n.stmts != nil { - vv := v.Children("stmts") + vv := v.GetChildrenVisitor("stmts") for _, nn := range n.stmts { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/stmt/catch.go b/node/stmt/catch.go index 1444786..b716a40 100644 --- a/node/stmt/catch.go +++ b/node/stmt/catch.go @@ -28,21 +28,23 @@ func NewCatch(token token.Token, types []node.Node, variable node.Node, stmts [] } func (n Catch) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.types != nil { - vv := v.Children("types") + vv := v.GetChildrenVisitor("types") for _, nn := range n.types { nn.Walk(vv) } } if n.stmts != nil { - vv := v.Children("stmts") + vv := v.GetChildrenVisitor("stmts") for _, nn := range n.stmts { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/stmt/class.go b/node/stmt/class.go index cf32ea8..f2e76b6 100644 --- a/node/stmt/class.go +++ b/node/stmt/class.go @@ -32,42 +32,44 @@ func NewClass(token token.Token, modifiers []node.Node, args []node.Node, extend } func (n Class) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } v.Scalar("token", n.token.Value) if n.modifiers != nil { - vv := v.Children("modifiers") + vv := v.GetChildrenVisitor("modifiers") for _, nn := range n.modifiers { nn.Walk(vv) } } if n.args != nil { - vv := v.Children("args") + vv := v.GetChildrenVisitor("args") for _, nn := range n.args { nn.Walk(vv) } } if n.extends != nil { - vv := v.Children("extends") + vv := v.GetChildrenVisitor("extends") n.extends.Walk(vv) } if n.implements != nil { - vv := v.Children("implements") + vv := v.GetChildrenVisitor("implements") for _, nn := range n.implements { nn.Walk(vv) } } if n.stmts != nil { - vv := v.Children("stmts") + vv := v.GetChildrenVisitor("stmts") for _, nn := range n.stmts { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/stmt/class_const_list.go b/node/stmt/class_const_list.go index 20e08f6..4329ff7 100644 --- a/node/stmt/class_const_list.go +++ b/node/stmt/class_const_list.go @@ -26,21 +26,23 @@ func NewClassConstList(token token.Token, modifiers []node.Node, consts []node.N } func (n ClassConstList) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.modifiers != nil { - vv := v.Children("modifiers") + vv := v.GetChildrenVisitor("modifiers") for _, nn := range n.modifiers { nn.Walk(vv) } } if n.consts != nil { - vv := v.Children("consts") + vv := v.GetChildrenVisitor("consts") for _, nn := range n.consts { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/stmt/class_method.go b/node/stmt/class_method.go index c3a429c..8af4213 100644 --- a/node/stmt/class_method.go +++ b/node/stmt/class_method.go @@ -32,7 +32,7 @@ func NewClassMethod(token token.Token, modifiers []node.Node, isReturnRef bool, } func (n ClassMethod) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } @@ -40,28 +40,30 @@ func (n ClassMethod) Walk(v node.Visitor) { v.Scalar("isReturnRef", n.isReturnRef) if n.modifiers != nil { - vv := v.Children("modifiers") + vv := v.GetChildrenVisitor("modifiers") for _, nn := range n.modifiers { nn.Walk(vv) } } if n.params != nil { - vv := v.Children("params") + vv := v.GetChildrenVisitor("params") for _, nn := range n.params { nn.Walk(vv) } } if n.returnType != nil { - vv := v.Children("returnType") + vv := v.GetChildrenVisitor("returnType") n.returnType.Walk(vv) } if n.stmts != nil { - vv := v.Children("stmts") + vv := v.GetChildrenVisitor("stmts") for _, nn := range n.stmts { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/stmt/const_list.go b/node/stmt/const_list.go index f27daff..b749c7c 100644 --- a/node/stmt/const_list.go +++ b/node/stmt/const_list.go @@ -24,14 +24,16 @@ func NewConstList(token token.Token, consts []node.Node) node.Node { } func (n ConstList) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.consts != nil { - vv := v.Children("consts") + vv := v.GetChildrenVisitor("consts") for _, nn := range n.consts { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/stmt/constant.go b/node/stmt/constant.go index 05bcb84..1211f2a 100644 --- a/node/stmt/constant.go +++ b/node/stmt/constant.go @@ -24,14 +24,16 @@ func NewConstant(token token.Token, expr node.Node) node.Node { } func (n Constant) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } v.Scalar("token", n.token.Value) if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/continue.go b/node/stmt/continue.go index d240bee..cdea152 100644 --- a/node/stmt/continue.go +++ b/node/stmt/continue.go @@ -24,12 +24,14 @@ func NewContinue(token token.Token, expr node.Node) node.Node { } func (n Continue) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/declare.go b/node/stmt/declare.go index 12c0a68..6e412f9 100644 --- a/node/stmt/declare.go +++ b/node/stmt/declare.go @@ -26,19 +26,21 @@ func NewDeclare(token token.Token, consts []node.Node, stmt node.Node) node.Node } func (n Declare) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.consts != nil { - vv := v.Children("consts") + vv := v.GetChildrenVisitor("consts") for _, nn := range n.consts { nn.Walk(vv) } } if n.stmt != nil { - vv := v.Children("stmt") + vv := v.GetChildrenVisitor("stmt") n.stmt.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/default.go b/node/stmt/default.go index f54bcae..da57757 100644 --- a/node/stmt/default.go +++ b/node/stmt/default.go @@ -24,14 +24,16 @@ func NewDefault(token token.Token, stmts []node.Node) node.Node { } func (n Default) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.stmts != nil { - vv := v.Children("stmts") + vv := v.GetChildrenVisitor("stmts") for _, nn := range n.stmts { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/stmt/do.go b/node/stmt/do.go index f9b6776..989e0d8 100644 --- a/node/stmt/do.go +++ b/node/stmt/do.go @@ -26,17 +26,19 @@ func NewDo(token token.Token, stmt node.Node, cond node.Node) node.Node { } func (n Do) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.cond != nil { - vv := v.Children("cond") + vv := v.GetChildrenVisitor("cond") n.cond.Walk(vv) } if n.stmt != nil { - vv := v.Children("stmt") + vv := v.GetChildrenVisitor("stmt") n.stmt.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/echo.go b/node/stmt/echo.go index 0912614..f4bca66 100644 --- a/node/stmt/echo.go +++ b/node/stmt/echo.go @@ -24,14 +24,16 @@ func NewEcho(token token.Token, exprs []node.Node) node.Node { } func (n Echo) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.exprs != nil { - vv := v.Children("exprs") + vv := v.GetChildrenVisitor("exprs") for _, nn := range n.exprs { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/stmt/else.go b/node/stmt/else.go index ab3f233..f97bed3 100644 --- a/node/stmt/else.go +++ b/node/stmt/else.go @@ -24,12 +24,14 @@ func NewElse(token token.Token, stmt node.Node) node.Node { } func (n Else) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.stmt != nil { - vv := v.Children("stmt") + vv := v.GetChildrenVisitor("stmt") n.stmt.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/else_if.go b/node/stmt/else_if.go index 3a1f87a..4c89d99 100644 --- a/node/stmt/else_if.go +++ b/node/stmt/else_if.go @@ -26,17 +26,19 @@ func NewElseIf(token token.Token, cond node.Node, stmt node.Node) node.Node { } func (n ElseIf) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.cond != nil { - vv := v.Children("cond") + vv := v.GetChildrenVisitor("cond") n.cond.Walk(vv) } if n.stmt != nil { - vv := v.Children("stmt") + vv := v.GetChildrenVisitor("stmt") n.stmt.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/expression.go b/node/stmt/expression.go index 410f8df..69b9614 100644 --- a/node/stmt/expression.go +++ b/node/stmt/expression.go @@ -21,12 +21,14 @@ func NewExpression(expr node.Node) node.Node { } func (n Expression) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/finally.go b/node/stmt/finally.go index 918fa99..e0c3042 100644 --- a/node/stmt/finally.go +++ b/node/stmt/finally.go @@ -24,14 +24,16 @@ func NewFinally(token token.Token, stmts []node.Node) node.Node { } func (n Finally) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.stmts != nil { - vv := v.Children("stmts") + vv := v.GetChildrenVisitor("stmts") for _, nn := range n.stmts { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/stmt/for.go b/node/stmt/for.go index 7458418..daf0b7a 100644 --- a/node/stmt/for.go +++ b/node/stmt/for.go @@ -30,33 +30,35 @@ func NewFor(token token.Token, init []node.Node, cond []node.Node, loop []node.N } func (n For) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.init != nil { - vv := v.Children("init") + vv := v.GetChildrenVisitor("init") for _, nn := range n.init { nn.Walk(vv) } } if n.cond != nil { - vv := v.Children("cond") + vv := v.GetChildrenVisitor("cond") for _, nn := range n.cond { nn.Walk(vv) } } if n.loop != nil { - vv := v.Children("loop") + vv := v.GetChildrenVisitor("loop") for _, nn := range n.loop { nn.Walk(vv) } } if n.stmt != nil { - vv := v.Children("stmt") + vv := v.GetChildrenVisitor("stmt") n.stmt.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/foreach.go b/node/stmt/foreach.go index aed5fc2..eeda925 100644 --- a/node/stmt/foreach.go +++ b/node/stmt/foreach.go @@ -32,27 +32,29 @@ func NewForeach(token token.Token, expr node.Node, key node.Node, variable node. } func (n Foreach) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } if n.key != nil { - vv := v.Children("key") + vv := v.GetChildrenVisitor("key") n.key.Walk(vv) } if n.variable != nil { - vv := v.Children("variable") + vv := v.GetChildrenVisitor("variable") n.variable.Walk(vv) } if n.stmt != nil { - vv := v.Children("stmt") + vv := v.GetChildrenVisitor("stmt") n.stmt.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/function.go b/node/stmt/function.go index 9400d86..82521b4 100644 --- a/node/stmt/function.go +++ b/node/stmt/function.go @@ -30,7 +30,7 @@ func NewFunction(token token.Token, isReturnRef bool, params []node.Node, return } func (n Function) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } @@ -38,21 +38,23 @@ func (n Function) Walk(v node.Visitor) { v.Scalar("isReturnRef", n.isReturnRef) if n.params != nil { - vv := v.Children("params") + vv := v.GetChildrenVisitor("params") for _, nn := range n.params { nn.Walk(vv) } } if n.returnType != nil { - vv := v.Children("returnType") + vv := v.GetChildrenVisitor("returnType") n.returnType.Walk(vv) } if n.stmts != nil { - vv := v.Children("stmts") + vv := v.GetChildrenVisitor("stmts") for _, nn := range n.stmts { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/stmt/global.go b/node/stmt/global.go index 50f11e8..9900139 100644 --- a/node/stmt/global.go +++ b/node/stmt/global.go @@ -24,14 +24,16 @@ func NewGlobal(token token.Token, vars []node.Node) node.Node { } func (n Global) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.vars != nil { - vv := v.Children("vars") + vv := v.GetChildrenVisitor("vars") for _, nn := range n.vars { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/stmt/goto.go b/node/stmt/goto.go index f66e84d..18840a8 100644 --- a/node/stmt/goto.go +++ b/node/stmt/goto.go @@ -25,9 +25,11 @@ func NewGoto(token token.Token, label token.Token) node.Node { } func (n Goto) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } v.Scalar("label", n.label.Value) + + v.LeaveNode(n) } diff --git a/node/stmt/group_use.go b/node/stmt/group_use.go index cc3918b..25f3e1d 100644 --- a/node/stmt/group_use.go +++ b/node/stmt/group_use.go @@ -39,24 +39,26 @@ func (n GroupUse) SetUseType(useType node.Node) node.Node { } func (n GroupUse) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.useType != nil { - vv := v.Children("useType") + vv := v.GetChildrenVisitor("useType") n.useType.Walk(vv) } if n.prefix != nil { - vv := v.Children("prefix") + vv := v.GetChildrenVisitor("prefix") n.prefix.Walk(vv) } if n.useList != nil { - vv := v.Children("useList") + vv := v.GetChildrenVisitor("useList") for _, nn := range n.useList { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/stmt/halt_compiler.go b/node/stmt/halt_compiler.go index 9e0f66a..e84cdbf 100644 --- a/node/stmt/halt_compiler.go +++ b/node/stmt/halt_compiler.go @@ -22,7 +22,9 @@ func NewHaltCompiler(token token.Token) node.Node { } func (n HaltCompiler) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } + + v.LeaveNode(n) } diff --git a/node/stmt/if.go b/node/stmt/if.go index 4ae2293..aafba63 100644 --- a/node/stmt/if.go +++ b/node/stmt/if.go @@ -46,29 +46,31 @@ func (n If) SetElse(_else node.Node) node.Node { } func (n If) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.cond != nil { - vv := v.Children("cond") + vv := v.GetChildrenVisitor("cond") n.cond.Walk(vv) } if n.stmt != nil { - vv := v.Children("stmt") + vv := v.GetChildrenVisitor("stmt") n.stmt.Walk(vv) } if n.elseIf != nil { - vv := v.Children("elseIf") + vv := v.GetChildrenVisitor("elseIf") for _, nn := range n.elseIf { nn.Walk(vv) } } if n._else != nil { - vv := v.Children("else") + vv := v.GetChildrenVisitor("else") n._else.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/inline_html.go b/node/stmt/inline_html.go index 2dd05c2..7c7993f 100644 --- a/node/stmt/inline_html.go +++ b/node/stmt/inline_html.go @@ -22,9 +22,11 @@ func NewInlineHtml(token token.Token) node.Node { } func (n InlineHtml) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } v.Scalar("token", n.token.Value) + + v.LeaveNode(n) } diff --git a/node/stmt/interface.go b/node/stmt/interface.go index e70b3d3..96f921d 100644 --- a/node/stmt/interface.go +++ b/node/stmt/interface.go @@ -28,23 +28,25 @@ func NewInterface(token token.Token, name token.Token, extends []node.Node, stmt } func (n Interface) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } v.Scalar("token", n.interfaceName.Value) if n.extends != nil { - vv := v.Children("extends") + vv := v.GetChildrenVisitor("extends") for _, nn := range n.extends { nn.Walk(vv) } } if n.stmts != nil { - vv := v.Children("stmts") + vv := v.GetChildrenVisitor("stmts") for _, nn := range n.stmts { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/stmt/label.go b/node/stmt/label.go index 08e966e..9bbbfbd 100644 --- a/node/stmt/label.go +++ b/node/stmt/label.go @@ -22,9 +22,11 @@ func NewLabel(token token.Token) node.Node { } func (n Label) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } v.Scalar("token", n.token.Value) + + v.LeaveNode(n) } diff --git a/node/stmt/namespace.go b/node/stmt/namespace.go index 17b55ec..4228a97 100644 --- a/node/stmt/namespace.go +++ b/node/stmt/namespace.go @@ -26,19 +26,21 @@ func NewNamespace(token token.Token, namespaceName node.Node, stmts []node.Node) } func (n Namespace) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.namespaceName != nil { - vv := v.Children("namespaceName") + vv := v.GetChildrenVisitor("namespaceName") n.namespaceName.Walk(vv) } if n.stmts != nil { - vv := v.Children("stmts") + vv := v.GetChildrenVisitor("stmts") for _, nn := range n.stmts { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/stmt/nop.go b/node/stmt/nop.go index 78bef7b..cc49ef0 100644 --- a/node/stmt/nop.go +++ b/node/stmt/nop.go @@ -29,9 +29,11 @@ func (n Nop) Print(out io.Writer, indent string) { } func (n Nop) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } v.Scalar("token", n.token.Value) + + v.LeaveNode(n) } diff --git a/node/stmt/property.go b/node/stmt/property.go index 577624a..099a5b6 100644 --- a/node/stmt/property.go +++ b/node/stmt/property.go @@ -24,14 +24,16 @@ func NewProperty(token token.Token, expr node.Node) node.Node { } func (n Property) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } v.Scalar("token", n.token.Value) if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/property_list.go b/node/stmt/property_list.go index 8c3d04f..224978c 100644 --- a/node/stmt/property_list.go +++ b/node/stmt/property_list.go @@ -23,21 +23,23 @@ func NewPropertyList(modifiers []node.Node, properties []node.Node) node.Node { } func (n PropertyList) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.modifiers != nil { - vv := v.Children("modifiers") + vv := v.GetChildrenVisitor("modifiers") for _, nn := range n.modifiers { nn.Walk(vv) } } if n.properties != nil { - vv := v.Children("properties") + vv := v.GetChildrenVisitor("properties") for _, nn := range n.properties { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/stmt/return.go b/node/stmt/return.go index 79fd167..a1166fb 100644 --- a/node/stmt/return.go +++ b/node/stmt/return.go @@ -24,12 +24,14 @@ func NewReturn(token token.Token, expr node.Node) node.Node { } func (n Return) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/static.go b/node/stmt/static.go index a33984d..1bb12ae 100644 --- a/node/stmt/static.go +++ b/node/stmt/static.go @@ -24,14 +24,16 @@ func NewStatic(token token.Token, vars []node.Node) node.Node { } func (n Static) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.vars != nil { - vv := v.Children("vars") + vv := v.GetChildrenVisitor("vars") for _, nn := range n.vars { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/stmt/static_var.go b/node/stmt/static_var.go index 15aa864..cd18ec1 100644 --- a/node/stmt/static_var.go +++ b/node/stmt/static_var.go @@ -24,12 +24,14 @@ func NewStaticVar(token token.Token, expr node.Node) node.Node { } func (n StaticVar) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/stmt_list.go b/node/stmt/stmt_list.go index ccbf237..fc77d91 100644 --- a/node/stmt/stmt_list.go +++ b/node/stmt/stmt_list.go @@ -21,14 +21,16 @@ func NewStmtList(stmts []node.Node) node.Node { } func (n StmtList) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.stmts != nil { - vv := v.Children("stmts") + vv := v.GetChildrenVisitor("stmts") for _, nn := range n.stmts { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/stmt/switch.go b/node/stmt/switch.go index 278d74f..227d6bb 100644 --- a/node/stmt/switch.go +++ b/node/stmt/switch.go @@ -26,19 +26,21 @@ func NewSwitch(token token.Token, cond node.Node, cases []node.Node) node.Node { } func (n Switch) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.cond != nil { - vv := v.Children("cond") + vv := v.GetChildrenVisitor("cond") n.cond.Walk(vv) } if n.cases != nil { - vv := v.Children("cases") + vv := v.GetChildrenVisitor("cases") for _, nn := range n.cases { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/stmt/throw.go b/node/stmt/throw.go index 05b8bd3..0e743d4 100644 --- a/node/stmt/throw.go +++ b/node/stmt/throw.go @@ -24,12 +24,14 @@ func NewThrow(token token.Token, expr node.Node) node.Node { } func (n Throw) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.expr != nil { - vv := v.Children("expr") + vv := v.GetChildrenVisitor("expr") n.expr.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/trait.go b/node/stmt/trait.go index fa96fc5..79a3f6f 100644 --- a/node/stmt/trait.go +++ b/node/stmt/trait.go @@ -25,16 +25,18 @@ func NewTrait(token token.Token, stmts []node.Node) node.Node { } func (n Trait) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } v.Scalar("token", n.token.Value) if n.stmts != nil { - vv := v.Children("stmts") + vv := v.GetChildrenVisitor("stmts") for _, nn := range n.stmts { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/stmt/trait_method_ref.go b/node/stmt/trait_method_ref.go index 8fc2efd..c80f9f3 100644 --- a/node/stmt/trait_method_ref.go +++ b/node/stmt/trait_method_ref.go @@ -25,14 +25,16 @@ func NewTraitMethodRef(trait node.Node, method token.Token) node.Node { } func (n TraitMethodRef) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } v.Scalar("method", n.method.Value) if n.trait != nil { - vv := v.Children("trait") + vv := v.GetChildrenVisitor("trait") n.trait.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/trait_use.go b/node/stmt/trait_use.go index d4ca5c6..2ba6f1d 100644 --- a/node/stmt/trait_use.go +++ b/node/stmt/trait_use.go @@ -27,21 +27,23 @@ func NewTraitUse(token token.Token, traits []node.Node, adaptations []node.Node) } func (n TraitUse) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.traits != nil { - vv := v.Children("traits") + vv := v.GetChildrenVisitor("traits") for _, nn := range n.traits { nn.Walk(vv) } } if n.adaptations != nil { - vv := v.Children("adaptations") + vv := v.GetChildrenVisitor("adaptations") for _, nn := range n.adaptations { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/stmt/trait_use_alias.go b/node/stmt/trait_use_alias.go index 137f848..f932feb 100644 --- a/node/stmt/trait_use_alias.go +++ b/node/stmt/trait_use_alias.go @@ -26,17 +26,19 @@ func NewTraitUseAlias(ref node.Node, modifier node.Node, alias token.TokenInterf } func (n TraitUseAlias) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.ref != nil { - vv := v.Children("ref") + vv := v.GetChildrenVisitor("ref") n.ref.Walk(vv) } if n.modifier != nil { - vv := v.Children("modifier") + vv := v.GetChildrenVisitor("modifier") n.modifier.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/trait_use_precedence.go b/node/stmt/trait_use_precedence.go index 5d1bf9e..462e895 100644 --- a/node/stmt/trait_use_precedence.go +++ b/node/stmt/trait_use_precedence.go @@ -23,17 +23,19 @@ func NewTraitUsePrecedence(ref node.Node, insteadof node.Node) node.Node { } func (n TraitUsePrecedence) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.ref != nil { - vv := v.Children("ref") + vv := v.GetChildrenVisitor("ref") n.ref.Walk(vv) } if n.insteadof != nil { - vv := v.Children("insteadof") + vv := v.GetChildrenVisitor("insteadof") n.insteadof.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/try.go b/node/stmt/try.go index b0c4c11..11de162 100644 --- a/node/stmt/try.go +++ b/node/stmt/try.go @@ -28,26 +28,28 @@ func NewTry(token token.Token, stmts []node.Node, catches []node.Node, finally n } func (n Try) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.stmts != nil { - vv := v.Children("stmts") + vv := v.GetChildrenVisitor("stmts") for _, nn := range n.stmts { nn.Walk(vv) } } if n.catches != nil { - vv := v.Children("catches") + vv := v.GetChildrenVisitor("catches") for _, nn := range n.catches { nn.Walk(vv) } } if n.finally != nil { - vv := v.Children("finally") + vv := v.GetChildrenVisitor("finally") n.finally.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/unset.go b/node/stmt/unset.go index 0035884..baa240d 100644 --- a/node/stmt/unset.go +++ b/node/stmt/unset.go @@ -24,14 +24,16 @@ func NewUnset(token token.Token, vars []node.Node) node.Node { } func (n Unset) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.vars != nil { - vv := v.Children("vars") + vv := v.GetChildrenVisitor("vars") for _, nn := range n.vars { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/stmt/use.go b/node/stmt/use.go index 479eea5..c5ced09 100644 --- a/node/stmt/use.go +++ b/node/stmt/use.go @@ -31,17 +31,19 @@ func (n Use) SetType(useType node.Node) node.Node { } func (n Use) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.useType != nil { - vv := v.Children("useType") + vv := v.GetChildrenVisitor("useType") n.useType.Walk(vv) } if n.use != nil { - vv := v.Children("use") + vv := v.GetChildrenVisitor("use") n.use.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/stmt/use_list.go b/node/stmt/use_list.go index 3621a62..0a54beb 100644 --- a/node/stmt/use_list.go +++ b/node/stmt/use_list.go @@ -26,19 +26,21 @@ func NewUseList(token token.Token, useType node.Node, uses []node.Node) node.Nod } func (n UseList) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.useType != nil { - vv := v.Children("useType") + vv := v.GetChildrenVisitor("useType") n.useType.Walk(vv) } if n.uses != nil { - vv := v.Children("uses") + vv := v.GetChildrenVisitor("uses") for _, nn := range n.uses { nn.Walk(vv) } } + + v.LeaveNode(n) } diff --git a/node/stmt/while.go b/node/stmt/while.go index c708b1d..4b521cc 100644 --- a/node/stmt/while.go +++ b/node/stmt/while.go @@ -26,17 +26,19 @@ func (n While) Name() string { } func (n While) Walk(v node.Visitor) { - if v.Visit(n) == false { + if v.EnterNode(n) == false { return } if n.cond != nil { - vv := v.Children("cond") + vv := v.GetChildrenVisitor("cond") n.cond.Walk(vv) } if n.stmt != nil { - vv := v.Children("stmt") + vv := v.GetChildrenVisitor("stmt") n.stmt.Walk(vv) } + + v.LeaveNode(n) } diff --git a/node/visitor.go b/node/visitor.go index 3659f03..63cdb28 100644 --- a/node/visitor.go +++ b/node/visitor.go @@ -1,7 +1,8 @@ package node type Visitor interface { - Visit(node Node) bool - Children(key string) Visitor + EnterNode(node Node) bool + GetChildrenVisitor(key string) Visitor Scalar(key string, value interface{}) + LeaveNode(node Node) }