(&'a self, component: &'a Component)
| 165 | } |
| 166 | |
| 167 | fn typecheck<'a>(&'a self, component: &'a Component) -> Result<TypeChecker<'a>> { |
| 168 | let mut cx = TypeChecker { |
| 169 | engine: &self.engine, |
| 170 | types: component.types(), |
| 171 | strings: &self.strings, |
| 172 | imported_resources: try_new::<Arc<_>>(TryPrimaryMap::new())?, |
| 173 | }; |
| 174 | |
| 175 | // Walk over the component's list of import names and use that to lookup |
| 176 | // the definition within this linker that it corresponds to. When found |
| 177 | // perform a typecheck against the component's expected type. |
| 178 | let env_component = component.env_component(); |
| 179 | for (_idx, (name, ty)) in env_component.import_types.iter() { |
| 180 | let import = self.map.get(name, &self.strings); |
| 181 | cx.definition(&ty.ty, import).with_context(|| { |
| 182 | format!( |
| 183 | "component imports {desc} `{name}`, but \ |
| 184 | a matching implementation was not found in the linker", |
| 185 | desc = ty.ty.desc() |
| 186 | ) |
| 187 | })?; |
| 188 | } |
| 189 | Ok(cx) |
| 190 | } |
| 191 | |
| 192 | /// Returns the [`types::Component`] corresponding to `component` with resource |
| 193 | /// types imported by it replaced using imports present in [`Self`]. |
no test coverage detected