2017-12-27 14:26:36 +00:00
|
|
|
package node
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Parameter struct {
|
2017-12-27 17:55:58 +00:00
|
|
|
name string
|
2017-12-27 14:26:36 +00:00
|
|
|
variableType Node
|
|
|
|
variable Node
|
|
|
|
defaultValue Node
|
|
|
|
byRef bool
|
|
|
|
variadic bool
|
|
|
|
}
|
|
|
|
|
2017-12-27 17:55:58 +00:00
|
|
|
func (n Parameter) Name() string {
|
|
|
|
return "Parameter"
|
|
|
|
}
|
|
|
|
|
2017-12-27 14:26:36 +00:00
|
|
|
func NewParameter(variableType Node, variable Node, defaultValue Node, byRef bool, variadic bool) Node {
|
|
|
|
return Parameter{
|
2017-12-27 17:55:58 +00:00
|
|
|
"Parameter",
|
2017-12-27 14:26:36 +00:00
|
|
|
variableType,
|
|
|
|
variable,
|
|
|
|
defaultValue,
|
|
|
|
byRef,
|
|
|
|
variadic,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n Parameter) 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-27 14:26:36 +00:00
|
|
|
fmt.Fprintf(out, "\n%vbyRef: %t", indent+" ", n.byRef)
|
|
|
|
fmt.Fprintf(out, "\n%vvariadic: %t", indent+" ", n.variadic)
|
|
|
|
|
|
|
|
if n.variableType != nil {
|
|
|
|
fmt.Fprintf(out, "\n%vvariableType:", indent+" ")
|
|
|
|
n.variableType.Print(out, indent+" ")
|
|
|
|
}
|
|
|
|
|
|
|
|
if n.variable != nil {
|
|
|
|
fmt.Fprintf(out, "\n%vvariable:", indent+" ")
|
|
|
|
n.variable.Print(out, indent+" ")
|
|
|
|
}
|
|
|
|
|
|
|
|
if n.defaultValue != nil {
|
|
|
|
fmt.Fprintf(out, "\n%vdefaultValue:", indent+" ")
|
|
|
|
n.defaultValue.Print(out, indent+" ")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|