| 1 | use craterust-analyzer cargo wasmparser 0.239.0 crate/::preluderust-analyzer cargo wasmparser 0.239.0 prelude/::*; |
| 2 | use craterust-analyzer cargo wasmparser 0.239.0 crate/::{BinaryReaderrust-analyzer cargo wasmparser 0.239.0 binary_reader/BinaryReader#, Resultrust-analyzer cargo wasmparser 0.239.0 binary_reader/Result#, Subsectionrust-analyzer cargo wasmparser 0.239.0 readers/Subsection#, Subsectionsrust-analyzer cargo wasmparser 0.239.0 readers/Subsections#, SymbolFlagsrust-analyzer cargo wasmparser 0.239.0 readers/core/linking/SymbolFlags#}; |
| 3 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#; |
| 4 | |
| 5 | /// Parser for the dynamic linking `dylink.0` custom section. |
| 6 | /// |
| 7 | /// This format is currently defined upstream at |
| 8 | /// <https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md>. |
| 9 | pub type Dylink0SectionReaderrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/Dylink0SectionReader#<'a> = Subsectionsrust-analyzer cargo wasmparser 0.239.0 readers/Subsections#<'a, Dylink0Subsectionrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/Dylink0Subsection#<'a>>; |
| 10 | |
| 11 | const WASM_DYLINK_MEM_INFOrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/WASM_DYLINK_MEM_INFO.: u8 = 1; |
| 12 | const WASM_DYLINK_NEEDEDrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/WASM_DYLINK_NEEDED.: u8 = 2; |
| 13 | const WASM_DYLINK_EXPORT_INFOrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/WASM_DYLINK_EXPORT_INFO.: u8 = 3; |
| 14 | const WASM_DYLINK_IMPORT_INFOrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/WASM_DYLINK_IMPORT_INFO.: u8 = 4; |
| 15 | const WASM_DYLINK_RUNTIME_PATHrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/WASM_DYLINK_RUNTIME_PATH.: u8 = 5; |
| 16 | |
| 17 | /// Represents a `WASM_DYLINK_MEM_INFO` field |
| 18 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 19 | pub struct MemInforust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/MemInfo# { |
| 20 | /// Size of the memory area the loader should reserve for the module, which |
| 21 | /// will begin at `env.__memory_base`. |
| 22 | pub memory_sizerust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/MemInfo#memory_size.: u32, |
| 23 | |
| 24 | /// The required alignment of the memory area, in bytes, encoded as a power |
| 25 | /// of 2. |
| 26 | pub memory_alignmentrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/MemInfo#memory_alignment.: u32, |
| 27 | |
| 28 | /// Size of the table area the loader should reserve for the module, which |
| 29 | /// will begin at `env.__table_base`. |
| 30 | pub table_sizerust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/MemInfo#table_size.: u32, |
| 31 | |
| 32 | /// The required alignment of the table area, in elements, encoded as a |
| 33 | /// power of 2. |
| 34 | pub table_alignmentrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/MemInfo#table_alignment.: u32, |
| 35 | } |
| 36 | |
| 37 | #[allow(missing_docs)] |
| 38 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 39 | pub struct ExportInforust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/ExportInfo#<'a> { |
| 40 | pub namerust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/ExportInfo#name.: &'a str, |
| 41 | pub flagsrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/ExportInfo#flags.: SymbolFlagsrust-analyzer cargo wasmparser 0.239.0 readers/core/linking/SymbolFlags#, |
| 42 | } |
| 43 | |
| 44 | #[allow(missing_docs)] |
| 45 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 46 | pub struct ImportInforust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/ImportInfo#<'a> { |
| 47 | pub modulerust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/ImportInfo#module.: &'a str, |
| 48 | pub fieldrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/ImportInfo#field.: &'a str, |
| 49 | pub flagsrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/ImportInfo#flags.: SymbolFlagsrust-analyzer cargo wasmparser 0.239.0 readers/core/linking/SymbolFlags#, |
| 50 | } |
| 51 | |
| 52 | /// Possible subsections of the `dylink.0` custom section. |
| 53 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 54 | #[allow(missing_docs)] |
| 55 | pub enum Dylink0Subsectionrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/Dylink0Subsection#<'a> { |
| 56 | MemInforust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/Dylink0Subsection#MemInfo#(MemInforust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/MemInfo#), |
| 57 | Neededrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/Dylink0Subsection#Needed#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&'a str>), |
| 58 | ExportInforust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/Dylink0Subsection#ExportInfo#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<ExportInforust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/ExportInfo#<'a>>), |
| 59 | ImportInforust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/Dylink0Subsection#ImportInfo#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<ImportInforust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/ImportInfo#<'a>>), |
| 60 | RuntimePathrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/Dylink0Subsection#RuntimePath#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&'a str>), |
| 61 | Unknownrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/Dylink0Subsection#Unknown# { |
| 62 | tyrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/Dylink0Subsection#Unknown#ty.: u8, |
| 63 | datarust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/Dylink0Subsection#Unknown#data.: &'a [u8], |
| 64 | rangerust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/Dylink0Subsection#Unknown#range.: Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>, |
| 65 | }, |
| 66 | } |
| 67 | |
| 68 | impl<'a> Subsectionrust-analyzer cargo wasmparser 0.239.0 readers/Subsection#<'a> for Dylink0Subsectionrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/Dylink0Subsection#<'a> { |
| 69 | fn from_readerrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/impl#[`Dylink0Subsection<'a>`][`Subsection<'a>`]from_reader().(id: u8, mut reader: BinaryReaderrust-analyzer cargo wasmparser 0.239.0 binary_reader/BinaryReader#<'a>) -> Resultrust-analyzer cargo wasmparser 0.239.0 binary_reader/Result#<Selfrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/impl#[`Dylink0Subsection<'a>`][`Subsection<'a>`]> { |
| 70 | let data = reader.remaining_bufferrust-analyzer cargo wasmparser 0.239.0 binary_reader/impl#[`BinaryReader<'a>`]remaining_buffer().(); |
| 71 | let offset = reader.original_positionrust-analyzer cargo wasmparser 0.239.0 binary_reader/impl#[`BinaryReader<'a>`]original_position().(); |
| 72 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(match id { |
| 73 | WASM_DYLINK_MEM_INFOrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/WASM_DYLINK_MEM_INFO. => Selfrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/impl#[`Dylink0Subsection<'a>`][`Subsection<'a>`]::MemInforust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/Dylink0Subsection#MemInfo#(MemInforust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/MemInfo# { |
| 74 | memory_sizerust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/MemInfo#memory_size.: reader.read_var_u32rust-analyzer cargo wasmparser 0.239.0 binary_reader/impl#[`BinaryReader<'a>`]read_var_u32().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 75 | memory_alignmentrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/MemInfo#memory_alignment.: reader.read_var_u32rust-analyzer cargo wasmparser 0.239.0 binary_reader/impl#[`BinaryReader<'a>`]read_var_u32().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 76 | table_sizerust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/MemInfo#table_size.: reader.read_var_u32rust-analyzer cargo wasmparser 0.239.0 binary_reader/impl#[`BinaryReader<'a>`]read_var_u32().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 77 | table_alignmentrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/MemInfo#table_alignment.: reader.read_var_u32rust-analyzer cargo wasmparser 0.239.0 binary_reader/impl#[`BinaryReader<'a>`]read_var_u32().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 78 | }), |
| 79 | WASM_DYLINK_NEEDEDrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/WASM_DYLINK_NEEDED. => Selfrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/impl#[`Dylink0Subsection<'a>`][`Subsection<'a>`]::Neededrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/Dylink0Subsection#Needed#( |
| 80 | (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#reader.read_var_u32rust-analyzer cargo wasmparser 0.239.0 binary_reader/impl#[`BinaryReader<'a>`]read_var_u32().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().) |
| 81 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|_| reader.read_stringrust-analyzer cargo wasmparser 0.239.0 binary_reader/impl#[`BinaryReader<'a>`]read_string().()) |
| 82 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Resultrust-analyzer cargo wasmparser 0.239.0 binary_reader/Result#<_, _>>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 83 | ), |
| 84 | WASM_DYLINK_EXPORT_INFOrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/WASM_DYLINK_EXPORT_INFO. => Selfrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/impl#[`Dylink0Subsection<'a>`][`Subsection<'a>`]::ExportInforust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/Dylink0Subsection#ExportInfo#( |
| 85 | (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#reader.read_var_u32rust-analyzer cargo wasmparser 0.239.0 binary_reader/impl#[`BinaryReader<'a>`]read_var_u32().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().) |
| 86 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|_| { |
| 87 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ExportInforust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/ExportInfo# { |
| 88 | namerust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/ExportInfo#name.: reader.read_stringrust-analyzer cargo wasmparser 0.239.0 binary_reader/impl#[`BinaryReader<'a>`]read_string().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 89 | flagsrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/ExportInfo#flags.: reader.readrust-analyzer cargo wasmparser 0.239.0 binary_reader/impl#[`BinaryReader<'a>`]read().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 90 | }) |
| 91 | }) |
| 92 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Resultrust-analyzer cargo wasmparser 0.239.0 binary_reader/Result#<_, _>>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/try_trait/Try#branch()., |
| 93 | ), |
| 94 | WASM_DYLINK_IMPORT_INFOrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/WASM_DYLINK_IMPORT_INFO. => Selfrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/impl#[`Dylink0Subsection<'a>`][`Subsection<'a>`]::ImportInforust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/Dylink0Subsection#ImportInfo#( |
| 95 | (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#reader.read_var_u32rust-analyzer cargo wasmparser 0.239.0 binary_reader/impl#[`BinaryReader<'a>`]read_var_u32().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().) |
| 96 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|_| { |
| 97 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ImportInforust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/ImportInfo# { |
| 98 | modulerust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/ImportInfo#module.: reader.read_stringrust-analyzer cargo wasmparser 0.239.0 binary_reader/impl#[`BinaryReader<'a>`]read_string().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 99 | fieldrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/ImportInfo#field.: reader.read_stringrust-analyzer cargo wasmparser 0.239.0 binary_reader/impl#[`BinaryReader<'a>`]read_string().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 100 | flagsrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/ImportInfo#flags.: reader.readrust-analyzer cargo wasmparser 0.239.0 binary_reader/impl#[`BinaryReader<'a>`]read().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 101 | }) |
| 102 | }) |
| 103 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Resultrust-analyzer cargo wasmparser 0.239.0 binary_reader/Result#<_, _>>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/try_trait/Try#branch()., |
| 104 | ), |
| 105 | WASM_DYLINK_RUNTIME_PATHrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/WASM_DYLINK_RUNTIME_PATH. => Selfrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/impl#[`Dylink0Subsection<'a>`][`Subsection<'a>`]::RuntimePathrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/Dylink0Subsection#RuntimePath#( |
| 106 | (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#reader.read_var_u32rust-analyzer cargo wasmparser 0.239.0 binary_reader/impl#[`BinaryReader<'a>`]read_var_u32().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().) |
| 107 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|_| reader.read_stringrust-analyzer cargo wasmparser 0.239.0 binary_reader/impl#[`BinaryReader<'a>`]read_string().()) |
| 108 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Resultrust-analyzer cargo wasmparser 0.239.0 binary_reader/Result#<_, _>>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 109 | ), |
| 110 | ty => Selfrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/impl#[`Dylink0Subsection<'a>`][`Subsection<'a>`]::Unknownrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/Dylink0Subsection#Unknown# { |
| 111 | tyrust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/Dylink0Subsection#Unknown#ty., |
| 112 | datarust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/Dylink0Subsection#Unknown#data., |
| 113 | rangerust-analyzer cargo wasmparser 0.239.0 readers/core/dylink0/Dylink0Subsection#Unknown#range.: offset..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), |
| 114 | }, |
| 115 | }) |
| 116 | } |
| 117 | } |