(
validator: FuncValidator<impl WasmModuleResources>,
body: FunctionBody<'_>,
local_addr_map: Vec<u16>,
allocs: OperatorsReaderAllocations,
)
| 76 | } |
| 77 | |
| 78 | pub(crate) fn process_operators_and_validate( |
| 79 | validator: FuncValidator<impl WasmModuleResources>, |
| 80 | body: FunctionBody<'_>, |
| 81 | local_addr_map: Vec<u16>, |
| 82 | allocs: OperatorsReaderAllocations, |
| 83 | ) -> Result<(Vec<Instruction>, WasmFunctionData, FuncValidatorAllocations, OperatorsReaderAllocations)> { |
| 84 | let reader = body.get_binary_reader_for_operators()?; |
| 85 | let mut reader = OperatorsReader::new_with_allocs(reader, allocs); |
| 86 | let mut builder = FunctionBuilder::new(validator, local_addr_map); |
| 87 | |
| 88 | while !reader.eof() { |
| 89 | builder.position = reader.original_position(); |
| 90 | if let Err(e) = reader.visit_operator(&mut ValidateThenVisit(&mut builder)) { |
| 91 | cold_path(); |
| 92 | return Err(crate::ParseError::ParseError { message: e.to_string(), offset: builder.position }); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | reader.finish()?; |
| 97 | |
| 98 | if let Some(error) = builder.error { |
| 99 | return Err(error); |
| 100 | } |
| 101 | |
| 102 | Ok((builder.instructions, builder.data.finish(), builder.validator.into_allocations(), reader.into_allocations())) |
| 103 | } |
| 104 | |
| 105 | pub(crate) struct FunctionBuilder<R> { |
| 106 | validator: FuncValidator<R>, |
no test coverage detected