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

Method typecheck

crates/wasmtime/src/runtime/component/linker.rs:167–190  ·  view source on GitHub ↗
(&'a self, component: &'a Component)

Source from the content-addressed store, hash-verified

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`].

Callers 2

instantiate_preMethod · 0.45

Calls 8

OkFunction · 0.85
env_componentMethod · 0.80
with_contextMethod · 0.80
newFunction · 0.50
typesMethod · 0.45
iterMethod · 0.45
getMethod · 0.45
definitionMethod · 0.45

Tested by

no test coverage detected