2018-03-31 04:58:57 +02:00
|
|
|
package addrs
|
|
|
|
|
2018-04-30 19:06:05 +02:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2018-03-31 04:58:57 +02:00
|
|
|
// InputVariable is the address of an input variable.
|
|
|
|
type InputVariable struct {
|
|
|
|
referenceable
|
|
|
|
Name string
|
|
|
|
}
|
2018-04-04 03:03:47 +02:00
|
|
|
|
|
|
|
func (v InputVariable) String() string {
|
|
|
|
return "var." + v.Name
|
|
|
|
}
|
2018-04-30 19:06:05 +02: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-04 02:43:55 +01:00
|
|
|
return v.Variable.String()
|
2018-04-30 19:06:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return fmt.Sprintf("%s.%s", v.Module.String(), v.Variable.String())
|
|
|
|
}
|