wasmparser
behaviour in case of Nested Components
#1698
-
In the case of this nested component: (alias export 2 "incoming-request" (type (;45;)))
(alias export 2 "response-outparam" (type (;46;)))
(component (;0;)
(import "import-type-incoming-request" (type (;0;) (sub resource)))
(import "import-type-response-outparam" (type (;1;) (sub resource)))
(import "import-type-incoming-request0" (type (;2;) (eq 0)))
(type (;3;) (own 2))
(import "import-type-response-outparam0" (type (;4;) (eq 1)))
(type (;5;) (own 4))
(type (;6;) (func (param "request" 3) (param "response-out" 5)))
(import "import-func-handle" (func (;0;) (type 6)))
(export (;7;) "incoming-request" (type 0))
(export (;8;) "response-outparam" (type 1))
(type (;9;) (own 7))
(type (;10;) (own 8))
(type (;11;) (func (param "request" 9) (param "response-out" 10)))
(export (;1;) "handle" (func 0) (func (type 11)))
)
(instance (;14;) (instantiate 0
(with "import-func-handle" (func 39))
(with "import-type-incoming-request" (type 45))
(with "import-type-response-outparam" (type 46))
(with "import-type-incoming-request0" (type 40))
(with "import-type-response-outparam0" (type 42))
)
)
(export (;15;) "wasi:http/incoming-handler@0.2.0-rc-2023-10-18" (instance 14)) I see that Payload::ComponentSection {
parser: comp_parser,
unchecked_range,
} => {
let cmp =
Component::parse_comp(&wasm[unchecked_range], enable_multi_memory, comp_parser)?;
components.push(cmp.clone());
Self::add_to_sections(&mut sections, Section::Component, &mut num_sections, 1);
} This is where my entire I also see that I'm doing the same thing for a module: Payload::ModuleSection {
parser,
unchecked_range,
} => {
modules.push(Module::parse(
&wasm[unchecked_range],
enable_multi_memory,
parser,
)?);
Self::add_to_sections(&mut sections, Section::Module, &mut num_sections, 1);
} it works fine in this case. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I've also recreated the issue on this smaller binary: (component
(core type (;0;)
(module)
)
(import "i1" (core module (;0;) (type 0)))
(core module (;1;))
(core module (;2;))
(core module (;3;))
(component (;1;)
(type (;0;) (func (param "p" string)))
(import "a" (func (;0;) (type 0)))
)
(export (;4;) "x" (core module 3))
) Gives output: (component
(core type (;0;)
(module)
)
(import "i1" (core module (;0;) (type 0)))
(core module (;1;))
(core module (;2;))
(core module (;3;))
(component (;0;)
(type (;0;) (func (param "p" string)))
(import "a" (func (;0;) (type 0)))
)
(type (;0;) (func (param "p" string)))
(import "a" (func (;0;) (type 0)))
(export (;4;) "x" (core module 3))
) Because the outer parser does not jump to |
Beta Was this translation helpful? Give feedback.
-
Ah when using the |
Beta Was this translation helpful? Give feedback.
Ah when using the
parse_all
helper there's no need to switch to the parsers that are given since theparse_all
helper handles that for you. You'll want to instead track the depth of which you're processing a component at yourself when theVersion
andEnd
markers are seen.