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 {
|
|
|
|
return v.String()
|
|
|
|
}
|
|
|
|
|
|
|
|
return fmt.Sprintf("%s.%s", v.Module.String(), v.Variable.String())
|
|
|
|
}
|