2017-12-27 14:26:36 +00:00
|
|
|
package node
|
|
|
|
|
|
|
|
type Parameter struct {
|
2017-12-27 17:55:58 +00:00
|
|
|
name string
|
2017-12-29 15:20:24 +00:00
|
|
|
attributes map[string]interface{}
|
2017-12-31 10:59:22 +00:00
|
|
|
position *Position
|
2017-12-27 14:26:36 +00:00
|
|
|
variableType Node
|
|
|
|
variable Node
|
|
|
|
defaultValue Node
|
2017-12-27 17:55:58 +00:00
|
|
|
}
|
|
|
|
|
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-29 15:20:24 +00:00
|
|
|
map[string]interface{}{
|
|
|
|
"byRef": byRef,
|
|
|
|
"variadic": variadic,
|
|
|
|
},
|
2017-12-31 10:59:22 +00:00
|
|
|
nil,
|
2017-12-27 14:26:36 +00:00
|
|
|
variableType,
|
|
|
|
variable,
|
|
|
|
defaultValue,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-29 15:20:24 +00:00
|
|
|
func (n Parameter) Name() string {
|
|
|
|
return "Parameter"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n Parameter) Attributes() map[string]interface{} {
|
|
|
|
return n.attributes
|
|
|
|
}
|
|
|
|
|
2017-12-31 09:57:55 +00:00
|
|
|
func (n Parameter) Attribute(key string) interface{} {
|
|
|
|
return n.attributes[key]
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n Parameter) SetAttribute(key string, value interface{}) {
|
|
|
|
n.attributes[key] = value
|
|
|
|
}
|
|
|
|
|
2017-12-31 10:59:22 +00:00
|
|
|
func (n Parameter) Position() *Position {
|
|
|
|
return n.position
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n Parameter) SetPosition(p *Position) Node {
|
|
|
|
n.position = p
|
|
|
|
return n
|
|
|
|
}
|
|
|
|
|
2017-12-27 23:23:32 +00:00
|
|
|
func (n Parameter) Walk(v Visitor) {
|
2017-12-28 11:36:27 +00:00
|
|
|
if v.EnterNode(n) == false {
|
2017-12-27 23:23:32 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-12-27 14:26:36 +00:00
|
|
|
if n.variableType != nil {
|
2017-12-28 11:36:27 +00:00
|
|
|
vv := v.GetChildrenVisitor("variableType")
|
2017-12-27 23:23:32 +00:00
|
|
|
n.variableType.Walk(vv)
|
2017-12-27 14:26:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if n.variable != nil {
|
2017-12-28 11:36:27 +00:00
|
|
|
vv := v.GetChildrenVisitor("variable")
|
2017-12-27 23:23:32 +00:00
|
|
|
n.variable.Walk(vv)
|
2017-12-27 14:26:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if n.defaultValue != nil {
|
2017-12-28 11:36:27 +00:00
|
|
|
vv := v.GetChildrenVisitor("defaultValue")
|
2017-12-27 23:23:32 +00:00
|
|
|
n.defaultValue.Walk(vv)
|
2017-12-27 14:26:36 +00:00
|
|
|
}
|
2017-12-28 11:36:27 +00:00
|
|
|
|
|
|
|
v.LeaveNode(n)
|
2017-12-27 14:26:36 +00:00
|
|
|
}
|