MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / raw_section

Method raw_section

crates/wizer/src/component/rewrite.rs:80–134  ·  view source on GitHub ↗
(
        &mut self,
        encoder: &mut wasm_encoder::Component,
        section: &wasm_encoder::RawSection,
    )

Source from the content-addressed store, hash-verified

78
79impl Reencoder<'_> {
80 fn raw_section(
81 &mut self,
82 encoder: &mut wasm_encoder::Component,
83 section: &wasm_encoder::RawSection,
84 ) {
85 match section.id {
86 // These can't define component functions so the sections are
87 // plumbed as-is.
88 id if id == wasm_encoder::ComponentSectionId::CoreCustom as u8
89 || id == wasm_encoder::ComponentSectionId::CoreInstance as u8
90 || id == wasm_encoder::ComponentSectionId::CoreType as u8
91 || id == wasm_encoder::ComponentSectionId::Component as u8
92 || id == wasm_encoder::ComponentSectionId::Type as u8 =>
93 {
94 encoder.section(section);
95 }
96
97 id if id == wasm_encoder::ComponentSectionId::CoreModule as u8 => {
98 panic!("should happen in caller");
99 }
100 id if id == wasm_encoder::ComponentSectionId::Start as u8 => {
101 // Component start sections aren't supported yet anyway
102 todo!()
103 }
104
105 // These sections all might affect or refer to component function
106 // indices so they're reencoded here, optionally updating function
107 // indices in case the index is higher than the one that we're
108 // removing.
109 id if id == wasm_encoder::ComponentSectionId::Instance as u8 => {
110 self.rewrite(
111 encoder,
112 section.data,
113 Self::parse_component_instance_section,
114 );
115 }
116 id if id == wasm_encoder::ComponentSectionId::Alias as u8 => {
117 self.rewrite(encoder, section.data, Self::parse_component_alias_section);
118 }
119 id if id == wasm_encoder::ComponentSectionId::CanonicalFunction as u8 => {
120 self.rewrite(
121 encoder,
122 section.data,
123 Self::parse_component_canonical_section,
124 );
125 }
126 id if id == wasm_encoder::ComponentSectionId::Import as u8 => {
127 self.rewrite(encoder, section.data, Self::parse_component_import_section);
128 }
129 id if id == wasm_encoder::ComponentSectionId::Export as u8 => {
130 self.rewrite(encoder, section.data, Self::parse_component_export_section);
131 }
132 other => panic!("unexpected component section id: {other}"),
133 }
134 }
135
136 fn rewrite<'a, T, S>(
137 &mut self,

Callers 1

rewrite_componentMethod · 0.80

Calls 2

sectionMethod · 0.80
rewriteMethod · 0.45

Tested by

no test coverage detected