7 // ModuleCall is the address of a call from the current module to a child
10 // There is no "Abs" version of ModuleCall because an absolute module path
11 // is represented by ModuleInstance.
12 type ModuleCall struct {
17 func (c ModuleCall) String() string {
18 return "module." + c.Name
21 // Instance returns the address of an instance of the receiver identified by
23 func (c ModuleCall) Instance(key InstanceKey) ModuleCallInstance {
24 return ModuleCallInstance{
30 // ModuleCallInstance is the address of one instance of a module created from
31 // a module call, which might create multiple instances using "count" or
32 // "for_each" arguments.
33 type ModuleCallInstance struct {
39 func (c ModuleCallInstance) String() string {
41 return c.Call.String()
43 return fmt.Sprintf("module.%s%s", c.Call.Name, c.Key)
46 // ModuleInstance returns the address of the module instance that corresponds
47 // to the receiving call instance when resolved in the given calling module.
48 // In other words, it returns the child module instance that the receving
49 // call instance creates.
50 func (c ModuleCallInstance) ModuleInstance(caller ModuleInstance) ModuleInstance {
51 return caller.Child(c.Call.Name, c.Key)
54 // Output returns the address of an output of the receiver identified by its
56 func (c ModuleCallInstance) Output(name string) ModuleCallOutput {
57 return ModuleCallOutput{
63 // ModuleCallOutput is the address of a particular named output produced by
64 // an instance of a module call.
65 type ModuleCallOutput struct {
67 Call ModuleCallInstance
71 func (co ModuleCallOutput) String() string {
72 return fmt.Sprintf("%s.%s", co.Call.String(), co.Name)
75 // AbsOutputValue returns the absolute output value address that corresponds
76 // to the receving module call output address, once resolved in the given
78 func (co ModuleCallOutput) AbsOutputValue(caller ModuleInstance) AbsOutputValue {
79 moduleAddr := co.Call.ModuleInstance(caller)
80 return moduleAddr.OutputValue(co.Name)