MCPcopy Index your code
hub / github.com/explodingcamera/tinywasm / process_operators_and_validate

Function process_operators_and_validate

crates/parser/src/visit.rs:78–103  ·  view source on GitHub ↗
(
    validator: FuncValidator<impl WasmModuleResources>,
    body: FunctionBody<'_>,
    local_addr_map: Vec<u16>,
    allocs: OperatorsReaderAllocations,
)

Source from the content-addressed store, hash-verified

76}
77
78pub(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
105pub(crate) struct FunctionBuilder<R> {
106 validator: FuncValidator<R>,

Callers 1

convert_module_codeFunction · 0.85

Calls 2

ValidateThenVisitClass · 0.85
finishMethod · 0.80

Tested by

no test coverage detected