component-model icon indicating copy to clipboard operation
component-model copied to clipboard

How instantiate, argument and namespace interactive?

Open dannypsnl opened this issue 7 months ago • 4 comments

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

  1. instantiation argument's name is given to correspond to imports in the component 0
  2. the kind is Type means instantiate the component 0 with a type (in the component should have a type import)
  3. index 25 is the index of type

Since they seems all wrong, I'm not sure how these interactive now.

dannypsnl avatar Mar 27 '25 07:03 dannypsnl