2018-03-30 21:58:57 -05:00
|
|
|
package addrs
|
|
|
|
|
2018-04-30 12:06:05 -05:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2018-03-30 21:58:57 -05:00
|
|
|
// InputVariable is the address of an input variable.
|
|
|
|
type InputVariable struct {
|
|
|
|
referenceable
|
|
|
|
Name string
|
|
|
|
}
|
2018-04-03 20:03:47 -05:00
|
|
|
|
|
|
|
func (v InputVariable) String() string {
|
|
|
|
return "var." + v.Name
|
|
|
|
}
|
2018-04-30 12:06:05 -05:00
|
|
|
|
|
|
|
// AbsInputVariableInstance is the address of an input variable within a
|
|
|
|
// particular module instance.
|
|
|
|
type AbsInputVariableInstance struct {
|
|
|
|
Module ModuleInstance
|
|
|
|
Variable InputVariable
|
|
|
|
}
|
|
|
|
|
|
|
|
// InputVariable returns the absolute address of the input variable of the
|
|
|
|
// given name inside the receiving module instance.
|
|
|
|
func (m ModuleInstance) InputVariable(name string) AbsInputVariableInstance {
|
|
|
|
return AbsInputVariableInstance{
|
|
|
|
Module: m,
|
|
|
|
Variable: InputVariable{
|
|
|
|
Name: name,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v AbsInputVariableInstance) String() string {
|
|
|
|
if len(v.Module) == 0 {
|
|
|
|
return v.String()
|
|
|
|
}
|
|
|
|
|
|
|
|
return fmt.Sprintf("%s.%s", v.Module.String(), v.Variable.String())
|
|
|
|
}
|