Update the wasm-tools family of crates (#5310)

Most of the changes here are the updates to the component model which
includes optional URL fields in imports/exports.
This commit is contained in:
Alex Crichton
2022-11-21 15:37:16 -06:00
committed by GitHub
parent c74706aa59
commit b305f251fb
21 changed files with 331 additions and 127 deletions

View File

@@ -840,14 +840,16 @@ impl<'a, 'data> Translator<'a, 'data> {
// An imported component instance is being aliased, so the type of
// the aliased item is directly available from the instance type.
ComponentInstanceType::Index(ty) => {
self.result.push_typedef(self.types[ty].exports[name])
let (_url, ty) = &self.types[ty].exports[name];
self.result.push_typedef(*ty);
}
// An imported component was instantiated so the type of the aliased
// export is available through the type of the export on the
// original component.
ComponentInstanceType::InstantiatedIndex(ty) => {
self.result.push_typedef(self.types[ty].exports[name])
let (_, ty) = self.types[ty].exports[name];
self.result.push_typedef(ty);
}
// A static nested component was instantiated which means that the

View File

@@ -668,7 +668,7 @@ impl<'a> Inliner<'a> {
ComponentInstanceDef::Import(path, ty) => {
let mut path = path.clone();
path.path.push(name);
match self.types[*ty].exports[*name] {
match self.types[*ty].exports[*name].1 {
TypeDef::ComponentFunc(_) => {
frame.component_funcs.push(ComponentFuncDef::Import(path));
}
@@ -909,7 +909,7 @@ impl<'a> Inliner<'a> {
// Note that for now this would only work with
// module-exporting instances.
ComponentInstanceDef::Import(path, ty) => {
for (name, ty) in self.types[ty].exports.iter() {
for (name, (_url, ty)) in self.types[ty].exports.iter() {
let mut path = path.clone();
path.path.push(name);
let def = ComponentItemDef::from_import(path, *ty)?;

View File

@@ -553,13 +553,17 @@ impl ComponentTypesBuilder {
ComponentTypeDeclaration::Type(ty) => self.type_declaration_type(ty)?,
ComponentTypeDeclaration::CoreType(ty) => self.type_declaration_core_type(ty)?,
ComponentTypeDeclaration::Alias(alias) => self.type_declaration_alias(alias)?,
ComponentTypeDeclaration::Export { name, ty } => {
ComponentTypeDeclaration::Export { name, url, ty } => {
let ty = self.component_type_ref(ty);
result.exports.insert(name.to_string(), ty);
result
.exports
.insert(name.to_string(), (url.to_string(), ty));
}
ComponentTypeDeclaration::Import(import) => {
let ty = self.component_type_ref(&import.ty);
result.imports.insert(import.name.to_string(), ty);
result
.imports
.insert(import.name.to_string(), (import.url.to_string(), ty));
}
}
}
@@ -581,9 +585,11 @@ impl ComponentTypesBuilder {
InstanceTypeDeclaration::Type(ty) => self.type_declaration_type(ty)?,
InstanceTypeDeclaration::CoreType(ty) => self.type_declaration_core_type(ty)?,
InstanceTypeDeclaration::Alias(alias) => self.type_declaration_alias(alias)?,
InstanceTypeDeclaration::Export { name, ty } => {
InstanceTypeDeclaration::Export { name, url, ty } => {
let ty = self.component_type_ref(ty);
result.exports.insert(name.to_string(), ty);
result
.exports
.insert(name.to_string(), (url.to_string(), ty));
}
}
}
@@ -971,9 +977,9 @@ pub struct TypeModule {
#[derive(Serialize, Deserialize, Default)]
pub struct TypeComponent {
/// The named values that this component imports.
pub imports: IndexMap<String, TypeDef>,
pub imports: IndexMap<String, (String, TypeDef)>,
/// The named values that this component exports.
pub exports: IndexMap<String, TypeDef>,
pub exports: IndexMap<String, (String, TypeDef)>,
}
/// The type of a component instance in the component model, or an instantiated
@@ -983,7 +989,7 @@ pub struct TypeComponent {
#[derive(Serialize, Deserialize, Default)]
pub struct TypeComponentInstance {
/// The list of exports that this component has along with their types.
pub exports: IndexMap<String, TypeDef>,
pub exports: IndexMap<String, (String, TypeDef)>,
}
/// A component function type in the component model.