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
|
|
|
|
2020-02-24 16:42:32 -06:00
|
|
|
// Absolute converts the receiver into an absolute address within the given
|
|
|
|
// module instance.
|
|
|
|
func (v InputVariable) Absolute(m ModuleInstance) AbsInputVariableInstance {
|
|
|
|
return AbsInputVariableInstance{
|
|
|
|
Module: m,
|
|
|
|
Variable: v,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 {
|
2020-01-03 19:43:55 -06:00
|
|
|
return v.Variable.String()
|
2018-04-30 12:06:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return fmt.Sprintf("%s.%s", v.Module.String(), v.Variable.String())
|
|
|
|
}
|