expr assign binary and cast nodes

This commit is contained in:
z7zmey
2017-12-12 23:26:00 +02:00
parent ddf72d4b4f
commit d7a593ef3b
52 changed files with 1584 additions and 580 deletions

View File

@@ -0,0 +1,30 @@
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 {
return Assign{
AssignOp{
node.SimpleNode{Name: "AssignAssign", 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

@@ -0,0 +1,36 @@
package assign_op
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
)
type AssignOp struct {
node.SimpleNode
variable node.Node
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)
if n.variable != nil {
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 BitwiseAnd struct {
AssignOp
}
func NewBitwiseAnd(variable node.Node, expression node.Node) node.Node {
return BitwiseAnd{
AssignOp{
node.SimpleNode{Name: "AssignBitwiseAnd", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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