addrs: ModuleInstance.ChildCall method

This allows us to concisely construct AbsModuleCall address values by
method chaining from module instance addresses.
This commit is contained in:
Martin Atkins 2021-07-28 10:59:07 -07:00
parent 5a6d11e375
commit 57d36c1d9d
1 changed files with 9 additions and 0 deletions

View File

@ -237,6 +237,15 @@ func (m ModuleInstance) Child(name string, key InstanceKey) ModuleInstance {
}) })
} }
// ChildCall returns the address of a module call within the receiver,
// identified by the given name.
func (m ModuleInstance) ChildCall(name string) AbsModuleCall {
return AbsModuleCall{
Module: m,
Call: ModuleCall{Name: name},
}
}
// Parent returns the address of the parent module instance of the receiver, or // Parent returns the address of the parent module instance of the receiver, or
// the receiver itself if there is no parent (if it's the root module address). // the receiver itself if there is no parent (if it's the root module address).
func (m ModuleInstance) Parent() ModuleInstance { func (m ModuleInstance) Parent() ModuleInstance {