2017-12-16 20:14:26 +00:00
|
|
|
package expr
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/z7zmey/php-parser/node"
|
|
|
|
"github.com/z7zmey/php-parser/token"
|
|
|
|
)
|
|
|
|
|
2017-12-27 17:55:58 +00:00
|
|
|
func (n ClassConstFetch) Name() string {
|
|
|
|
return "ClassConstFetch"
|
|
|
|
}
|
|
|
|
|
2017-12-16 20:14:26 +00:00
|
|
|
type ClassConstFetch struct {
|
2017-12-27 17:55:58 +00:00
|
|
|
name string
|
|
|
|
class node.Node
|
|
|
|
constant token.Token
|
2017-12-16 20:14:26 +00:00
|
|
|
}
|
|
|
|
|
2017-12-27 23:23:32 +00:00
|
|
|
// TODO: constant must be identifier
|
2017-12-27 17:55:58 +00:00
|
|
|
func NewClassConstFetch(class node.Node, constant token.Token) node.Node {
|
2017-12-16 20:14:26 +00:00
|
|
|
return ClassConstFetch{
|
2017-12-27 17:55:58 +00:00
|
|
|
"ClassConstFetch",
|
2017-12-16 20:14:26 +00:00
|
|
|
class,
|
2017-12-27 17:55:58 +00:00
|
|
|
constant,
|
2017-12-16 20:14:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-27 23:23:32 +00:00
|
|
|
func (n ClassConstFetch) Walk(v node.Visitor) {
|
|
|
|
if v.Visit(n) == false {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
v.Scalar("constant", n.constant.Value)
|
2017-12-16 20:14:26 +00:00
|
|
|
|
|
|
|
if n.class != nil {
|
2017-12-27 23:23:32 +00:00
|
|
|
vv := v.Children("class")
|
|
|
|
n.class.Walk(vv)
|
2017-12-16 20:14:26 +00:00
|
|
|
}
|
|
|
|
}
|