assign_ref node

This commit is contained in:
z7zmey
2017-12-18 21:34:11 +02:00
parent 3ec45dc334
commit 2c6664bdc9
5 changed files with 30 additions and 30 deletions

View File

@@ -1,30 +1,19 @@
package assign_op
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
)
type Assign struct {
AssignOp
byRef bool
}
func NewAssign(variable node.Node, expression node.Node, byRef bool) node.Node {
func NewAssign(variable node.Node, expression node.Node) node.Node {
return Assign{
AssignOp{
node.SimpleNode{Name: "AssignAssign", Attributes: make(map[string]string)},
node.SimpleNode{Name: "Assign", Attributes: make(map[string]string)},
variable,
expression,
},
byRef,
}
}
func (n Assign) Print(out io.Writer, indent string) {
n.AssignOp.Print(out, indent)
fmt.Fprintf(out, "\n%vbyRef: %t", indent+" ", n.byRef)
}

View File

@@ -13,14 +13,6 @@ type AssignOp struct {
expression node.Node
}
func NewAssignOp(variable node.Node, expression node.Node) node.Node {
return AssignOp{
node.SimpleNode{Name: "AssignOp", Attributes: make(map[string]string)},
variable,
expression,
}
}
func (n AssignOp) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
@@ -28,7 +20,7 @@ func (n AssignOp) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%vvariable:", indent+" ")
n.variable.Print(out, indent+" ")
}
if n.expression != nil {
fmt.Fprintf(out, "\n%vexpression:", indent+" ")
n.expression.Print(out, indent+" ")

View File

@@ -0,0 +1,19 @@
package assign_op
import (
"github.com/z7zmey/php-parser/node"
)
type AssignRef struct {
AssignOp
}
func NewAssignRef(variable node.Node, expression node.Node) node.Node {
return AssignRef{
AssignOp{
node.SimpleNode{Name: "AssignRef", Attributes: make(map[string]string)},
variable,
expression,
},
}
}