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

Function typecheck

crates/wasmtime/src/runtime/instance.rs:1024–1042  ·  view source on GitHub ↗
(
    module: &Module,
    import_args: &[I],
    check: impl Fn(&matching::MatchCx<'_>, &EntityType, &I) -> Result<()>,
)

Source from the content-addressed store, hash-verified

1022}
1023
1024fn typecheck<I>(
1025 module: &Module,
1026 import_args: &[I],
1027 check: impl Fn(&matching::MatchCx<'_>, &EntityType, &I) -> Result<()>,
1028) -> Result<()> {
1029 let env_module = module.compiled_module().module();
1030 let expected_len = env_module.imports().count();
1031 let actual_len = import_args.len();
1032 if expected_len != actual_len {
1033 bail!("expected {expected_len} imports, found {actual_len}");
1034 }
1035 let cx = matching::MatchCx::new(module.engine());
1036 for ((name, field, expected_ty), actual) in env_module.imports().zip(import_args) {
1037 debug_assert!(expected_ty.is_canonicalized_for_runtime_usage());
1038 check(&cx, &expected_ty, actual)
1039 .with_context(|| format!("incompatible import type for `{name}::{field}`"))?;
1040 }
1041 Ok(())
1042}

Callers 15

typedMethod · 0.70
typecheck_externsMethod · 0.70
newMethod · 0.70
typecheckMethod · 0.50
typecheck_payloadFunction · 0.50
typecheckMethod · 0.50
typecheckMethod · 0.50
typecheckMethod · 0.50
lower_to_indexMethod · 0.50
lift_from_indexMethod · 0.50
typecheckMethod · 0.50

Calls 9

OkFunction · 0.85
compiled_moduleMethod · 0.80
with_contextMethod · 0.80
newFunction · 0.50
checkFunction · 0.50
moduleMethod · 0.45
importsMethod · 0.45
lenMethod · 0.45
engineMethod · 0.45

Tested by

no test coverage detected