php-parser/node/stmt/do.go
2017-12-31 11:57:55 +02:00

56 lines
843 B
Go

package stmt
import (
"github.com/z7zmey/php-parser/node"
)
type Do struct {
name string
attributes map[string]interface{}
stmt node.Node
cond node.Node
}
func NewDo(stmt node.Node, cond node.Node) node.Node {
return Do{
"Do",
map[string]interface{}{},
stmt,
cond,
}
}
func (n Do) Name() string {
return "Do"
}
func (n Do) Attributes() map[string]interface{} {
return n.attributes
}
func (n Do) Attribute(key string) interface{} {
return n.attributes[key]
}
func (n Do) SetAttribute(key string, value interface{}) {
n.attributes[key] = value
}
func (n Do) Walk(v node.Visitor) {
if v.EnterNode(n) == false {
return
}
if n.cond != nil {
vv := v.GetChildrenVisitor("cond")
n.cond.Walk(vv)
}
if n.stmt != nil {
vv := v.GetChildrenVisitor("stmt")
n.stmt.Walk(vv)
}
v.LeaveNode(n)
}