2017-12-16 19:08:39 +00:00
|
|
|
package expr
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/z7zmey/php-parser/node"
|
|
|
|
)
|
|
|
|
|
2017-12-27 17:55:58 +00:00
|
|
|
func (n ArrayItem) Name() string {
|
|
|
|
return "ArrayItem"
|
|
|
|
}
|
|
|
|
|
2017-12-16 19:08:39 +00:00
|
|
|
type ArrayItem struct {
|
2017-12-27 17:55:58 +00:00
|
|
|
name string
|
|
|
|
key node.Node
|
|
|
|
val node.Node
|
2017-12-16 19:08:39 +00:00
|
|
|
byRef bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewArrayItem(key node.Node, val node.Node, byRef bool) node.Node {
|
|
|
|
return ArrayItem{
|
2017-12-27 17:55:58 +00:00
|
|
|
"ArrayItem",
|
2017-12-16 19:08:39 +00:00
|
|
|
key,
|
|
|
|
val,
|
|
|
|
byRef,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-27 23:23:32 +00:00
|
|
|
func (n ArrayItem) Walk(v node.Visitor) {
|
|
|
|
if v.Visit(n) == false {
|
|
|
|
return
|
|
|
|
}
|
2017-12-16 19:08:39 +00:00
|
|
|
|
|
|
|
if n.key != nil {
|
2017-12-27 23:23:32 +00:00
|
|
|
vv := v.Children("key")
|
|
|
|
n.key.Walk(vv)
|
2017-12-16 19:08:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if n.val != nil {
|
2017-12-27 23:23:32 +00:00
|
|
|
vv := v.Children("val")
|
|
|
|
n.val.Walk(vv)
|
2017-12-16 19:08:39 +00:00
|
|
|
}
|
|
|
|
}
|