[refactoring] parameters: new node structure
This commit is contained in:
@@ -33,10 +33,18 @@ func (v *Dump) print(str string) {
|
||||
}
|
||||
|
||||
func (v *Dump) printIndent(indentDepth int) {
|
||||
if indentDepth < 0 {
|
||||
indentDepth = 0
|
||||
}
|
||||
|
||||
v.print(strings.Repeat("\t", indentDepth))
|
||||
}
|
||||
|
||||
func (v *Dump) printIndentIfNotSingle(indentDepth int) {
|
||||
if indentDepth < 0 {
|
||||
indentDepth = 0
|
||||
}
|
||||
|
||||
if !v.stack[v.depth-1].singleNode {
|
||||
v.print(strings.Repeat("\t", indentDepth))
|
||||
}
|
||||
@@ -173,20 +181,22 @@ func (v *Dump) Nullable(n *ast.Nullable) {
|
||||
v.printNode(n.GetNode())
|
||||
}
|
||||
|
||||
func (v *Dump) Reference(n *ast.Reference) {
|
||||
v.printIndentIfNotSingle(v.indent - 1)
|
||||
v.print("&ast.Reference{\n")
|
||||
v.printNode(n.GetNode())
|
||||
}
|
||||
|
||||
func (v *Dump) Variadic(n *ast.Variadic) {
|
||||
v.printIndentIfNotSingle(v.indent - 1)
|
||||
v.print("&ast.Variadic{\n")
|
||||
v.printNode(n.GetNode())
|
||||
}
|
||||
|
||||
func (v *Dump) Parameter(n *ast.Parameter) {
|
||||
v.printIndent(v.indent - 1)
|
||||
v.print("&ast.Parameter{\n")
|
||||
v.printNode(n.GetNode())
|
||||
|
||||
if n.ByRef {
|
||||
v.printIndent(v.indent)
|
||||
v.print("ByRef: true,\n")
|
||||
}
|
||||
|
||||
if n.Variadic {
|
||||
v.printIndent(v.indent)
|
||||
v.print("Variadic: true,\n")
|
||||
}
|
||||
}
|
||||
|
||||
func (v *Dump) Identifier(n *ast.Identifier) {
|
||||
|
||||
@@ -30,8 +30,7 @@ func ExampleDump() {
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.Identifier{},
|
||||
&ast.Parameter{
|
||||
Variadic: true,
|
||||
Var: &ast.ExprVariable{},
|
||||
Var: &ast.ExprVariable{},
|
||||
},
|
||||
&ast.StmtInlineHtml{
|
||||
Value: []byte("foo"),
|
||||
@@ -64,7 +63,6 @@ func ExampleDump() {
|
||||
// Value: []byte(""),
|
||||
// },
|
||||
// &ast.Parameter{
|
||||
// Variadic: true,
|
||||
// Var: &ast.ExprVariable{
|
||||
// },
|
||||
// },
|
||||
|
||||
@@ -502,10 +502,8 @@ func TestResolveFunctionName(t *testing.T) {
|
||||
FunctionName: &ast.Identifier{Value: []byte("A")},
|
||||
Params: []ast.Vertex{
|
||||
&ast.Parameter{
|
||||
ByRef: false,
|
||||
Variadic: false,
|
||||
Type: nameAB,
|
||||
Var: &ast.ExprVariable{VarName: &ast.Identifier{Value: []byte("foo")}},
|
||||
Type: nameAB,
|
||||
Var: &ast.ExprVariable{VarName: &ast.Identifier{Value: []byte("foo")}},
|
||||
},
|
||||
},
|
||||
ReturnType: &ast.Nullable{Expr: nameBC},
|
||||
@@ -540,10 +538,8 @@ func TestResolveMethodName(t *testing.T) {
|
||||
MethodName: &ast.Identifier{Value: []byte("A")},
|
||||
Params: []ast.Vertex{
|
||||
&ast.Parameter{
|
||||
ByRef: false,
|
||||
Variadic: false,
|
||||
Type: nameAB,
|
||||
Var: &ast.ExprVariable{VarName: &ast.Identifier{Value: []byte("foo")}},
|
||||
Type: nameAB,
|
||||
Var: &ast.ExprVariable{VarName: &ast.Identifier{Value: []byte("foo")}},
|
||||
},
|
||||
},
|
||||
ReturnType: &ast.Nullable{Expr: nameBC},
|
||||
@@ -573,10 +569,8 @@ func TestResolveClosureName(t *testing.T) {
|
||||
Static: false,
|
||||
Params: []ast.Vertex{
|
||||
&ast.Parameter{
|
||||
ByRef: false,
|
||||
Variadic: false,
|
||||
Type: nameAB,
|
||||
Var: &ast.ExprVariable{VarName: &ast.Identifier{Value: []byte("foo")}},
|
||||
Type: nameAB,
|
||||
Var: &ast.ExprVariable{VarName: &ast.Identifier{Value: []byte("foo")}},
|
||||
},
|
||||
},
|
||||
ClosureUse: nil,
|
||||
|
||||
@@ -30,6 +30,14 @@ func (v *Null) Nullable(_ *ast.Nullable) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (v *Null) Reference(_ *ast.Reference) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (v *Null) Variadic(_ *ast.Variadic) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (v *Null) Parameter(_ *ast.Parameter) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user