component-model
component-model copied to clipboard
How instantiate, argument and namespace interactive?
Below text is the binary built from https://github.com/sunfishcode/hello-wasi-http/tree/29205a0749835bd65be65841640af913be9be794 and use wasm-tools dump *.wasm to get.
[instance 6] Instantiate { component_index: 0, args: [ComponentInstantiationArg { name: "import-func-handle", kind: Func, index: 11 }, Compon
entInstantiationArg { name: "import-type-incoming-request", kind: Type, index: 25 }, ComponentInstantiationArg { name: "import-type-response-outparam", kind: Type, ind
ex: 26 }, ComponentInstantiationArg { name: "import-type-incoming-request0", kind: Type, index: 20 }, ComponentInstantiationArg { name: "import-type-response-outparam0
", kind: Type, index: 22 }] }
I stuck in this case, this part is trying to instantiate the component 0 with some arguments. The particular argument import-type-incoming-request has index 25, I thought that is the index of a component instance, and found that's wrong guess.
Indeed, there is a type 25:
alias [type 25] InstanceExport { kind: Type, instance_index: 5, name: "incoming-request" }
This confuse me because I think
- instantiation argument's name is given to correspond to imports in the component
0 - the kind is
Typemeans instantiate the component0with a type (in the component should have a type import) - index 25 is the index of type
Since they seems all wrong, I'm not sure how these interactive now.
Could you clarify what you feel is wrong here? This is indeed instantiating a component with a type, and it's because the component being instantiated should import a type and that needs to be satisfied. You say that everything seems all wrong, but can you be more specific?
Because I thought the meaning of
[type 0] ComponentImport { name: ComponentImportName("import-type-incoming-request"), ty: Type(SubResource) }
was
- import something named
import-type-incoming-request - check its type is a subtype of resource
- assign it to DBI space, in this case is
0
Sorry I'm a bit confused, the snippet you pasted in response isn't present above, so this looks like it's new questions about a new line. Your understanding of that line in isolation seems correct enough, but I still don't really know what you feel is wrong and/or what you're asking here (maybe I'll let others resond....)
Because argument import-type-incoming-request is a type, but in component, the import import-type-incoming-request should be an instance (to have a type that is a subtype of resource).