2017-12-18 16:51:16 +00:00
|
|
|
package expr
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"github.com/z7zmey/php-parser/node"
|
|
|
|
)
|
|
|
|
|
2017-12-27 17:55:58 +00:00
|
|
|
func (n New) Name() string {
|
|
|
|
return "New"
|
|
|
|
}
|
|
|
|
|
2017-12-18 16:51:16 +00:00
|
|
|
type New struct {
|
2017-12-27 17:55:58 +00:00
|
|
|
name string
|
2017-12-18 16:51:16 +00:00
|
|
|
class node.Node
|
|
|
|
arguments []node.Node
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewNew(class node.Node, arguments []node.Node) node.Node {
|
|
|
|
return New{
|
2017-12-27 17:55:58 +00:00
|
|
|
"New",
|
2017-12-18 16:51:16 +00:00
|
|
|
class,
|
|
|
|
arguments,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n New) Print(out io.Writer, indent string) {
|
2017-12-27 17:55:58 +00:00
|
|
|
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
|
2017-12-18 16:51:16 +00:00
|
|
|
|
|
|
|
if n.class != nil {
|
|
|
|
fmt.Fprintf(out, "\n%vclass:", indent+" ")
|
|
|
|
n.class.Print(out, indent+" ")
|
|
|
|
}
|
|
|
|
|
|
|
|
if n.arguments != nil {
|
|
|
|
fmt.Fprintf(out, "\n%varguments:", indent+" ")
|
|
|
|
for _, nn := range n.arguments {
|
|
|
|
nn.Print(out, indent+" ")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|