php-parser/node/stmt/case.go
2017-12-29 17:53:13 +02:00

50 lines
734 B
Go

package stmt
import (
"github.com/z7zmey/php-parser/node"
)
type Case struct {
name string
attributes map[string]interface{}
cond node.Node
stmts []node.Node
}
func NewCase(cond node.Node, stmts []node.Node) node.Node {
return Case{
"Case",
map[string]interface{}{},
cond,
stmts,
}
}
func (n Case) Name() string {
return "Case"
}
func (n Case) Attributes() map[string]interface{} {
return n.attributes
}
func (n Case) Walk(v node.Visitor) {
if v.EnterNode(n) == false {
return
}
if n.cond != nil {
vv := v.GetChildrenVisitor("cond")
n.cond.Walk(vv)
}
if n.stmts != nil {
vv := v.GetChildrenVisitor("stmts")
for _, nn := range n.stmts {
nn.Walk(vv)
}
}
v.LeaveNode(n)
}