7 // OutputValue is the address of an output value, in the context of the module
8 // that is defining it.
10 // This is related to but separate from ModuleCallOutput, which represents
11 // a module output from the perspective of its parent module. Since output
12 // values cannot be represented from the module where they are defined,
13 // OutputValue is not Referenceable, while ModuleCallOutput is.
14 type OutputValue struct {
18 func (v OutputValue) String() string {
19 return "output." + v.Name
22 // Absolute converts the receiver into an absolute address within the given
24 func (v OutputValue) Absolute(m ModuleInstance) AbsOutputValue {
25 return AbsOutputValue{
31 // AbsOutputValue is the absolute address of an output value within a module instance.
33 // This represents an output globally within the namespace of a particular
34 // configuration. It is related to but separate from ModuleCallOutput, which
35 // represents a module output from the perspective of its parent module.
36 type AbsOutputValue struct {
38 OutputValue OutputValue
41 // OutputValue returns the absolute address of an output value of the given
42 // name within the receiving module instance.
43 func (m ModuleInstance) OutputValue(name string) AbsOutputValue {
44 return AbsOutputValue{
46 OutputValue: OutputValue{
52 func (v AbsOutputValue) String() string {
53 if v.Module.IsRoot() {
54 return v.OutputValue.String()
56 return fmt.Sprintf("%s.%s", v.Module.String(), v.OutputValue.String())
59 // ModuleCallOutput converts an AbsModuleOutput into a ModuleCallOutput,
60 // returning also the module instance that the ModuleCallOutput is relative
63 // The root module does not have a call, and so this method cannot be used
64 // with outputs in the root module, and will panic in that case.
65 func (v AbsOutputValue) ModuleCallOutput() (ModuleInstance, ModuleCallOutput) {
66 if v.Module.IsRoot() {
67 panic("ReferenceFromCall used with root module output")
70 caller, call := v.Module.CallInstance()
71 return caller, ModuleCallOutput{
73 Name: v.OutputValue.Name,