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

Function validate_signature_params

cranelift/interpreter/src/step.rs:21–35  ·  view source on GitHub ↗

Ensures that all types in args are the same as expected by the signature

(sig: &[AbiParam], args: &[DataValue])

Source from the content-addressed store, hash-verified

19
20/// Ensures that all types in args are the same as expected by the signature
21fn validate_signature_params(sig: &[AbiParam], args: &[DataValue]) -> bool {
22 args.iter()
23 .map(|r| r.ty())
24 .zip(sig.iter().map(|r| r.value_type))
25 .all(|(a, b)| match (a, b) {
26 // For these two cases we don't have precise type information for `a`.
27 // We don't distinguish between different bool types, or different vector types
28 // The actual error is in `Value::ty` that returns default types for some values
29 // but we don't have enough information there either.
30 //
31 // Ideally the user has run the verifier and caught this properly...
32 (a, b) if a.is_vector() && b.is_vector() => true,
33 (a, b) => a == b,
34 })
35}
36
37// Helper for summing a sequence of values.
38fn sum_unsigned(head: DataValue, tail: SmallVec<[DataValue; 1]>) -> ValueResult<u128> {

Callers 1

stepFunction · 0.85

Calls 5

allMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
tyMethod · 0.45
is_vectorMethod · 0.45

Tested by

no test coverage detected