Fix export translation for components. (#6108)
* Fix export translation for components. Exports in the component model cause a new index to be added to the index space of the item being exported. This commit updates component translation so that translation of component export sections properly updates internal lists representing those index spaces. * Code review feedback.
This commit is contained in:
@@ -622,8 +622,31 @@ impl<'a, 'data> Translator<'a, 'data> {
|
||||
self.result
|
||||
.initializers
|
||||
.push(LocalInitializer::Export(item));
|
||||
if let ComponentItem::Type(ty) = item {
|
||||
self.types.push_component_typedef(ty);
|
||||
|
||||
// Exports create a new index, so push the item onto the
|
||||
// appropriate list.
|
||||
match item {
|
||||
ComponentItem::Func(idx) => {
|
||||
self.result
|
||||
.component_funcs
|
||||
.push(self.result.component_funcs[idx]);
|
||||
}
|
||||
ComponentItem::Module(_idx) => {
|
||||
// We don't need to do anything here for modules as
|
||||
// the type information isn't tracked in the initial
|
||||
// translation pass.
|
||||
}
|
||||
ComponentItem::Component(idx) => {
|
||||
self.result.components.push(self.result.components[idx]);
|
||||
}
|
||||
ComponentItem::ComponentInstance(idx) => {
|
||||
self.result
|
||||
.component_instances
|
||||
.push(self.result.component_instances[idx]);
|
||||
}
|
||||
ComponentItem::Type(ty) => {
|
||||
self.types.push_component_typedef(ty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user