• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

henrythasler / rust-tiny-wasm / 22644633641

03 Mar 2026 09:58PM UTC coverage: 30.248% (-0.5%) from 30.717%
22644633641

push

github

henrythasler
fix formatting

91 of 340 new or added lines in 3 files covered. (26.76%)

28 existing lines in 1 file now uncovered.

513 of 1696 relevant lines covered (30.25%)

1.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

26.0
/src/loader/webassembly.rs
1
// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
2

3
#![allow(unused_imports)]
4
#![allow(non_snake_case)]
5
#![allow(non_camel_case_types)]
6
#![allow(irrefutable_let_patterns)]
7
#![allow(unused_comparisons)]
8

9
extern crate kaitai;
10
use super::vlq_base128_le::VlqBase128Le;
11
use kaitai::*;
12
use std::cell::{Cell, Ref, RefCell};
13
use std::convert::{TryFrom, TryInto};
14
use std::rc::{Rc, Weak};
15

16
/**
17
 * This document describes the binary format of a WebAssembly module
18
 * following the version 1.0 of the core WebAssembly standard.
19
 *
20
 * Repository: https://github.com/henrythasler/wasm-kaitai-struct
21
 *
22
 * * Naming of entities follows the official specification.
23
 * * All integers are encoded using the LEB128 variable-length integer encoding (see vlq_base128_le.ksy).
24
 * * The schema follows the KSY Style Guide
25
 * * Requires ks-version 0.9+ because of attribute value validation
26
 * * types appear in the order in which they are required
27
 * \sa * https://www.w3.org/TR/wasm-core-1/
28
 */
29

30
#[derive(Default, Debug, Clone)]
31
pub struct Webassembly {
32
    pub _root: SharedType<Webassembly>,
33
    pub _parent: SharedType<Webassembly>,
34
    pub _self: SharedType<Self>,
35
    magic: RefCell<Vec<u8>>,
36
    version: RefCell<u32>,
37
    sections: RefCell<Vec<OptRc<Webassembly_Section>>>,
38
    _io: RefCell<BytesReader>,
39
}
40
impl KStruct for Webassembly {
41
    type Root = Webassembly;
42
    type Parent = Webassembly;
43

44
    fn read<S: KStream>(
1✔
45
        self_rc: &OptRc<Self>,
1✔
46
        _io: &S,
1✔
47
        _root: SharedType<Self::Root>,
1✔
48
        _parent: SharedType<Self::Parent>,
1✔
49
    ) -> KResult<()> {
1✔
50
        *self_rc._io.borrow_mut() = _io.clone();
1✔
51
        self_rc._root.set(_root.get());
1✔
52
        self_rc._parent.set(_parent.get());
1✔
53
        self_rc._self.set(Ok(self_rc.clone()));
1✔
54
        let _rrc = self_rc._root.get_value().borrow().upgrade();
1✔
55
        let _prc = self_rc._parent.get_value().borrow().upgrade();
1✔
56
        let _r = _rrc.as_ref().unwrap();
1✔
57
        *self_rc.magic.borrow_mut() = _io.read_bytes(4 as usize)?.into();
1✔
58
        if !(*self_rc.magic() == vec![0x0u8, 0x61u8, 0x73u8, 0x6du8]) {
1✔
NEW
59
            return Err(KError::ValidationFailed(ValidationFailedError {
×
NEW
60
                kind: ValidationKind::NotEqual,
×
NEW
61
                src_path: "/seq/0".to_string(),
×
NEW
62
            }));
×
63
        }
1✔
64
        *self_rc.version.borrow_mut() = _io.read_u4le()?.into();
1✔
65
        *self_rc.sections.borrow_mut() = Vec::new();
1✔
66
        {
67
            let mut _i = 0;
1✔
68
            while !_io.is_eof() {
5✔
69
                let t = Self::read_into::<_, Webassembly_Section>(
4✔
70
                    &*_io,
4✔
71
                    Some(self_rc._root.clone()),
4✔
72
                    Some(self_rc._self.clone()),
4✔
NEW
73
                )?
×
74
                .into();
4✔
75
                self_rc.sections.borrow_mut().push(t);
4✔
76
                _i += 1;
4✔
77
            }
78
        }
79
        Ok(())
1✔
80
    }
1✔
81
}
82
impl Webassembly {}
83

84
/**
85
 * Magic number identifying the file as a WebAssembly module
86
 * \sa https://www.w3.org/TR/wasm-core-1/#binary-magic Source
87
 */
88
impl Webassembly {
89
    pub fn magic(&self) -> Ref<'_, Vec<u8>> {
1✔
90
        self.magic.borrow()
1✔
91
    }
1✔
92
}
93

94
/**
95
 * Version of the WebAssembly binary format
96
 * \sa https://www.w3.org/TR/wasm-core-1/#binary-version Source
97
 */
98
impl Webassembly {
99
    pub fn version(&self) -> Ref<'_, u32> {
×
100
        self.version.borrow()
×
101
    }
×
102
}
103

104
/**
105
 * A WebAssembly module is a set of sections
106
 * \sa https://www.w3.org/TR/wasm-core-1/#binary-module Source
107
 */
108
impl Webassembly {
109
    pub fn sections(&self) -> Ref<'_, Vec<OptRc<Webassembly_Section>>> {
×
110
        self.sections.borrow()
×
111
    }
×
112
}
113
impl Webassembly {
114
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
115
        self._io.borrow()
×
116
    }
×
117
}
118
#[derive(Debug, PartialEq, Clone)]
119
pub enum Webassembly_ExportTypes {
120
    FuncType,
121
    TableType,
122
    MemType,
123
    GlobalType,
124
    Unknown(i64),
125
}
126

127
impl TryFrom<i64> for Webassembly_ExportTypes {
128
    type Error = KError;
129
    fn try_from(flag: i64) -> KResult<Webassembly_ExportTypes> {
2✔
130
        match flag {
2✔
131
            0 => Ok(Webassembly_ExportTypes::FuncType),
2✔
132
            1 => Ok(Webassembly_ExportTypes::TableType),
×
133
            2 => Ok(Webassembly_ExportTypes::MemType),
×
134
            3 => Ok(Webassembly_ExportTypes::GlobalType),
×
135
            _ => Ok(Webassembly_ExportTypes::Unknown(flag)),
×
136
        }
137
    }
2✔
138
}
139

140
impl From<&Webassembly_ExportTypes> for i64 {
141
    fn from(v: &Webassembly_ExportTypes) -> Self {
×
142
        match *v {
×
143
            Webassembly_ExportTypes::FuncType => 0,
×
144
            Webassembly_ExportTypes::TableType => 1,
×
145
            Webassembly_ExportTypes::MemType => 2,
×
146
            Webassembly_ExportTypes::GlobalType => 3,
×
NEW
147
            Webassembly_ExportTypes::Unknown(v) => v,
×
148
        }
149
    }
×
150
}
151

152
impl Default for Webassembly_ExportTypes {
153
    fn default() -> Self {
2✔
154
        Webassembly_ExportTypes::Unknown(0)
2✔
155
    }
2✔
156
}
157

158
#[derive(Debug, PartialEq, Clone)]
159
pub enum Webassembly_ImportTypes {
160
    FuncType,
161
    TableType,
162
    MemType,
163
    GlobalType,
164
    Unknown(i64),
165
}
166

167
impl TryFrom<i64> for Webassembly_ImportTypes {
168
    type Error = KError;
169
    fn try_from(flag: i64) -> KResult<Webassembly_ImportTypes> {
×
170
        match flag {
×
171
            0 => Ok(Webassembly_ImportTypes::FuncType),
×
172
            1 => Ok(Webassembly_ImportTypes::TableType),
×
173
            2 => Ok(Webassembly_ImportTypes::MemType),
×
174
            3 => Ok(Webassembly_ImportTypes::GlobalType),
×
175
            _ => Ok(Webassembly_ImportTypes::Unknown(flag)),
×
176
        }
177
    }
×
178
}
179

180
impl From<&Webassembly_ImportTypes> for i64 {
181
    fn from(v: &Webassembly_ImportTypes) -> Self {
×
182
        match *v {
×
183
            Webassembly_ImportTypes::FuncType => 0,
×
184
            Webassembly_ImportTypes::TableType => 1,
×
185
            Webassembly_ImportTypes::MemType => 2,
×
186
            Webassembly_ImportTypes::GlobalType => 3,
×
NEW
187
            Webassembly_ImportTypes::Unknown(v) => v,
×
188
        }
189
    }
×
190
}
191

192
impl Default for Webassembly_ImportTypes {
NEW
193
    fn default() -> Self {
×
NEW
194
        Webassembly_ImportTypes::Unknown(0)
×
NEW
195
    }
×
196
}
197

198
#[derive(Debug, PartialEq, Clone)]
199
pub enum Webassembly_MutabilityTypes {
200
    Const,
201
    Var,
202
    Unknown(i64),
203
}
204

205
impl TryFrom<i64> for Webassembly_MutabilityTypes {
206
    type Error = KError;
207
    fn try_from(flag: i64) -> KResult<Webassembly_MutabilityTypes> {
×
208
        match flag {
×
209
            0 => Ok(Webassembly_MutabilityTypes::Const),
×
210
            1 => Ok(Webassembly_MutabilityTypes::Var),
×
211
            _ => Ok(Webassembly_MutabilityTypes::Unknown(flag)),
×
212
        }
213
    }
×
214
}
215

216
impl From<&Webassembly_MutabilityTypes> for i64 {
217
    fn from(v: &Webassembly_MutabilityTypes) -> Self {
×
218
        match *v {
×
219
            Webassembly_MutabilityTypes::Const => 0,
×
220
            Webassembly_MutabilityTypes::Var => 1,
×
NEW
221
            Webassembly_MutabilityTypes::Unknown(v) => v,
×
222
        }
223
    }
×
224
}
225

226
impl Default for Webassembly_MutabilityTypes {
NEW
227
    fn default() -> Self {
×
NEW
228
        Webassembly_MutabilityTypes::Unknown(0)
×
NEW
229
    }
×
230
}
231

232
#[derive(Debug, PartialEq, Clone)]
233
pub enum Webassembly_SectionId {
234
    CustomSection,
235
    TypeSection,
236
    ImportSection,
237
    FunctionSection,
238
    TableSection,
239
    MemorySection,
240
    GlobalSection,
241
    ExportSection,
242
    StartSection,
243
    ElementSection,
244
    CodeSection,
245
    DataSection,
246
    Unknown(i64),
247
}
248

249
impl TryFrom<i64> for Webassembly_SectionId {
250
    type Error = KError;
251
    fn try_from(flag: i64) -> KResult<Webassembly_SectionId> {
4✔
252
        match flag {
4✔
253
            0 => Ok(Webassembly_SectionId::CustomSection),
×
254
            1 => Ok(Webassembly_SectionId::TypeSection),
1✔
255
            2 => Ok(Webassembly_SectionId::ImportSection),
×
256
            3 => Ok(Webassembly_SectionId::FunctionSection),
1✔
257
            4 => Ok(Webassembly_SectionId::TableSection),
×
258
            5 => Ok(Webassembly_SectionId::MemorySection),
×
259
            6 => Ok(Webassembly_SectionId::GlobalSection),
×
260
            7 => Ok(Webassembly_SectionId::ExportSection),
1✔
261
            8 => Ok(Webassembly_SectionId::StartSection),
×
262
            9 => Ok(Webassembly_SectionId::ElementSection),
×
263
            10 => Ok(Webassembly_SectionId::CodeSection),
1✔
264
            11 => Ok(Webassembly_SectionId::DataSection),
×
265
            _ => Ok(Webassembly_SectionId::Unknown(flag)),
×
266
        }
267
    }
4✔
268
}
269

270
impl From<&Webassembly_SectionId> for i64 {
271
    fn from(v: &Webassembly_SectionId) -> Self {
×
272
        match *v {
×
273
            Webassembly_SectionId::CustomSection => 0,
×
274
            Webassembly_SectionId::TypeSection => 1,
×
275
            Webassembly_SectionId::ImportSection => 2,
×
276
            Webassembly_SectionId::FunctionSection => 3,
×
277
            Webassembly_SectionId::TableSection => 4,
×
278
            Webassembly_SectionId::MemorySection => 5,
×
279
            Webassembly_SectionId::GlobalSection => 6,
×
280
            Webassembly_SectionId::ExportSection => 7,
×
281
            Webassembly_SectionId::StartSection => 8,
×
282
            Webassembly_SectionId::ElementSection => 9,
×
283
            Webassembly_SectionId::CodeSection => 10,
×
284
            Webassembly_SectionId::DataSection => 11,
×
NEW
285
            Webassembly_SectionId::Unknown(v) => v,
×
286
        }
287
    }
×
288
}
289

290
impl Default for Webassembly_SectionId {
291
    fn default() -> Self {
4✔
292
        Webassembly_SectionId::Unknown(0)
4✔
293
    }
4✔
294
}
295

296
#[derive(Debug, PartialEq, Clone)]
297
pub enum Webassembly_Types {
298
    Function,
299
    Element,
300
    Unknown(i64),
301
}
302

303
impl TryFrom<i64> for Webassembly_Types {
304
    type Error = KError;
305
    fn try_from(flag: i64) -> KResult<Webassembly_Types> {
1✔
306
        match flag {
1✔
307
            96 => Ok(Webassembly_Types::Function),
1✔
308
            112 => Ok(Webassembly_Types::Element),
×
309
            _ => Ok(Webassembly_Types::Unknown(flag)),
×
310
        }
311
    }
1✔
312
}
313

314
impl From<&Webassembly_Types> for i64 {
315
    fn from(v: &Webassembly_Types) -> Self {
×
316
        match *v {
×
317
            Webassembly_Types::Function => 96,
×
318
            Webassembly_Types::Element => 112,
×
NEW
319
            Webassembly_Types::Unknown(v) => v,
×
320
        }
321
    }
×
322
}
323

324
impl Default for Webassembly_Types {
325
    fn default() -> Self {
1✔
326
        Webassembly_Types::Unknown(0)
1✔
327
    }
1✔
328
}
329

330
#[derive(Debug, PartialEq, Clone)]
331
pub enum Webassembly_ValTypes {
332
    F64,
333
    F32,
334
    I64,
335
    I32,
336
    Unknown(i64),
337
}
338

339
impl TryFrom<i64> for Webassembly_ValTypes {
340
    type Error = KError;
341
    fn try_from(flag: i64) -> KResult<Webassembly_ValTypes> {
×
342
        match flag {
×
343
            124 => Ok(Webassembly_ValTypes::F64),
×
344
            125 => Ok(Webassembly_ValTypes::F32),
×
345
            126 => Ok(Webassembly_ValTypes::I64),
×
346
            127 => Ok(Webassembly_ValTypes::I32),
×
347
            _ => Ok(Webassembly_ValTypes::Unknown(flag)),
×
348
        }
349
    }
×
350
}
351

352
impl From<&Webassembly_ValTypes> for i64 {
353
    fn from(v: &Webassembly_ValTypes) -> Self {
×
354
        match *v {
×
355
            Webassembly_ValTypes::F64 => 124,
×
356
            Webassembly_ValTypes::F32 => 125,
×
357
            Webassembly_ValTypes::I64 => 126,
×
358
            Webassembly_ValTypes::I32 => 127,
×
NEW
359
            Webassembly_ValTypes::Unknown(v) => v,
×
360
        }
361
    }
×
362
}
363

364
impl Default for Webassembly_ValTypes {
NEW
365
    fn default() -> Self {
×
NEW
366
        Webassembly_ValTypes::Unknown(0)
×
NEW
367
    }
×
368
}
369

370
#[derive(Default, Debug, Clone)]
371
pub struct Webassembly_Code {
372
    pub _root: SharedType<Webassembly>,
373
    pub _parent: SharedType<Webassembly_CodeSection>,
374
    pub _self: SharedType<Self>,
375
    len_func: RefCell<OptRc<VlqBase128Le>>,
376
    func: RefCell<OptRc<Webassembly_Func>>,
377
    _io: RefCell<BytesReader>,
378
    func_raw: RefCell<Vec<u8>>,
379
}
380
impl KStruct for Webassembly_Code {
381
    type Root = Webassembly;
382
    type Parent = Webassembly_CodeSection;
383

384
    fn read<S: KStream>(
2✔
385
        self_rc: &OptRc<Self>,
2✔
386
        _io: &S,
2✔
387
        _root: SharedType<Self::Root>,
2✔
388
        _parent: SharedType<Self::Parent>,
2✔
389
    ) -> KResult<()> {
2✔
390
        *self_rc._io.borrow_mut() = _io.clone();
2✔
391
        self_rc._root.set(_root.get());
2✔
392
        self_rc._parent.set(_parent.get());
2✔
393
        self_rc._self.set(Ok(self_rc.clone()));
2✔
394
        let _rrc = self_rc._root.get_value().borrow().upgrade();
2✔
395
        let _prc = self_rc._parent.get_value().borrow().upgrade();
2✔
396
        let _r = _rrc.as_ref().unwrap();
2✔
397
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
2✔
398
        *self_rc.len_func.borrow_mut() = t;
2✔
399
        *self_rc.func_raw.borrow_mut() = _io
2✔
400
            .read_bytes(*self_rc.len_func().value()? as usize)?
2✔
401
            .into();
2✔
402
        let func_raw = self_rc.func_raw.borrow();
2✔
403
        let _t_func_raw_io = BytesReader::from(func_raw.clone());
2✔
404
        let t = Self::read_into::<BytesReader, Webassembly_Func>(
2✔
405
            &_t_func_raw_io,
2✔
406
            Some(self_rc._root.clone()),
2✔
407
            Some(self_rc._self.clone()),
2✔
NEW
408
        )?
×
409
        .into();
2✔
410
        *self_rc.func.borrow_mut() = t;
2✔
411
        Ok(())
2✔
412
    }
2✔
413
}
414
impl Webassembly_Code {}
415
impl Webassembly_Code {
416
    pub fn len_func(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
2✔
417
        self.len_func.borrow()
2✔
418
    }
2✔
419
}
420
impl Webassembly_Code {
421
    pub fn func(&self) -> Ref<'_, OptRc<Webassembly_Func>> {
×
422
        self.func.borrow()
×
423
    }
×
424
}
425
impl Webassembly_Code {
426
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
427
        self._io.borrow()
×
428
    }
×
429
}
430
impl Webassembly_Code {
431
    pub fn func_raw(&self) -> Ref<'_, Vec<u8>> {
×
432
        self.func_raw.borrow()
×
433
    }
×
434
}
435

436
/**
437
 * (id 10) A vector of code entries
438
 * \sa https://www.w3.org/TR/wasm-core-1/#binary-codesec Source
439
 */
440

441
#[derive(Default, Debug, Clone)]
442
pub struct Webassembly_CodeSection {
443
    pub _root: SharedType<Webassembly>,
444
    pub _parent: SharedType<Webassembly_Section>,
445
    pub _self: SharedType<Self>,
446
    num_entries: RefCell<OptRc<VlqBase128Le>>,
447
    entries: RefCell<Vec<OptRc<Webassembly_Code>>>,
448
    _io: RefCell<BytesReader>,
449
}
450
impl KStruct for Webassembly_CodeSection {
451
    type Root = Webassembly;
452
    type Parent = Webassembly_Section;
453

454
    fn read<S: KStream>(
1✔
455
        self_rc: &OptRc<Self>,
1✔
456
        _io: &S,
1✔
457
        _root: SharedType<Self::Root>,
1✔
458
        _parent: SharedType<Self::Parent>,
1✔
459
    ) -> KResult<()> {
1✔
460
        *self_rc._io.borrow_mut() = _io.clone();
1✔
461
        self_rc._root.set(_root.get());
1✔
462
        self_rc._parent.set(_parent.get());
1✔
463
        self_rc._self.set(Ok(self_rc.clone()));
1✔
464
        let _rrc = self_rc._root.get_value().borrow().upgrade();
1✔
465
        let _prc = self_rc._parent.get_value().borrow().upgrade();
1✔
466
        let _r = _rrc.as_ref().unwrap();
1✔
467
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
1✔
468
        *self_rc.num_entries.borrow_mut() = t;
1✔
469
        *self_rc.entries.borrow_mut() = Vec::new();
1✔
470
        {
471
            let mut _i = 0;
1✔
472
            while !_io.is_eof() {
3✔
473
                let t = Self::read_into::<_, Webassembly_Code>(
2✔
474
                    &*_io,
2✔
475
                    Some(self_rc._root.clone()),
2✔
476
                    Some(self_rc._self.clone()),
2✔
NEW
477
                )?
×
478
                .into();
2✔
479
                self_rc.entries.borrow_mut().push(t);
2✔
480
                _i += 1;
2✔
481
            }
482
        }
483
        Ok(())
1✔
484
    }
1✔
485
}
486
impl Webassembly_CodeSection {}
487
impl Webassembly_CodeSection {
488
    pub fn num_entries(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
×
489
        self.num_entries.borrow()
×
490
    }
×
491
}
492
impl Webassembly_CodeSection {
493
    pub fn entries(&self) -> Ref<'_, Vec<OptRc<Webassembly_Code>>> {
×
494
        self.entries.borrow()
×
495
    }
×
496
}
497
impl Webassembly_CodeSection {
498
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
499
        self._io.borrow()
×
500
    }
×
501
}
502

503
/**
504
 * (id 0) - Custom section whose content is application-specific and not defined by the WebAssembly specification.
505
 * \sa https://www.w3.org/TR/wasm-core-1/#binary-customsec Source
506
 */
507

508
#[derive(Default, Debug, Clone)]
509
pub struct Webassembly_CustomSection {
510
    pub _root: SharedType<Webassembly>,
511
    pub _parent: SharedType<Webassembly_Section>,
512
    pub _self: SharedType<Self>,
513
    name: RefCell<OptRc<Webassembly_Name>>,
514
    data: RefCell<Vec<u8>>,
515
    _io: RefCell<BytesReader>,
516
}
517
impl KStruct for Webassembly_CustomSection {
518
    type Root = Webassembly;
519
    type Parent = Webassembly_Section;
520

521
    fn read<S: KStream>(
×
522
        self_rc: &OptRc<Self>,
×
523
        _io: &S,
×
524
        _root: SharedType<Self::Root>,
×
525
        _parent: SharedType<Self::Parent>,
×
526
    ) -> KResult<()> {
×
527
        *self_rc._io.borrow_mut() = _io.clone();
×
528
        self_rc._root.set(_root.get());
×
529
        self_rc._parent.set(_parent.get());
×
530
        self_rc._self.set(Ok(self_rc.clone()));
×
531
        let _rrc = self_rc._root.get_value().borrow().upgrade();
×
532
        let _prc = self_rc._parent.get_value().borrow().upgrade();
×
533
        let _r = _rrc.as_ref().unwrap();
×
NEW
534
        let t = Self::read_into::<_, Webassembly_Name>(&*_io, Some(self_rc._root.clone()), None)?
×
NEW
535
            .into();
×
536
        *self_rc.name.borrow_mut() = t;
×
537
        *self_rc.data.borrow_mut() = _io.read_bytes_full()?.into();
×
538
        Ok(())
×
539
    }
×
540
}
541
impl Webassembly_CustomSection {}
542
impl Webassembly_CustomSection {
543
    pub fn name(&self) -> Ref<'_, OptRc<Webassembly_Name>> {
×
544
        self.name.borrow()
×
545
    }
×
546
}
547

548
/**
549
 * Custom section data; out of scope for this schema
550
 */
551
impl Webassembly_CustomSection {
552
    pub fn data(&self) -> Ref<'_, Vec<u8>> {
×
553
        self.data.borrow()
×
554
    }
×
555
}
556
impl Webassembly_CustomSection {
557
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
558
        self._io.borrow()
×
559
    }
×
560
}
561

562
/**
563
 * (11) - Vector of data segments
564
 * \sa https://www.w3.org/TR/wasm-core-1/#binary-datasec Source
565
 */
566

567
#[derive(Default, Debug, Clone)]
568
pub struct Webassembly_DataSection {
569
    pub _root: SharedType<Webassembly>,
570
    pub _parent: SharedType<Webassembly_Section>,
571
    pub _self: SharedType<Self>,
572
    num_data: RefCell<OptRc<VlqBase128Le>>,
573
    data_segments: RefCell<Vec<OptRc<Webassembly_DataSegment>>>,
574
    _io: RefCell<BytesReader>,
575
}
576
impl KStruct for Webassembly_DataSection {
577
    type Root = Webassembly;
578
    type Parent = Webassembly_Section;
579

580
    fn read<S: KStream>(
×
581
        self_rc: &OptRc<Self>,
×
582
        _io: &S,
×
583
        _root: SharedType<Self::Root>,
×
584
        _parent: SharedType<Self::Parent>,
×
585
    ) -> KResult<()> {
×
586
        *self_rc._io.borrow_mut() = _io.clone();
×
587
        self_rc._root.set(_root.get());
×
588
        self_rc._parent.set(_parent.get());
×
589
        self_rc._self.set(Ok(self_rc.clone()));
×
590
        let _rrc = self_rc._root.get_value().borrow().upgrade();
×
591
        let _prc = self_rc._parent.get_value().borrow().upgrade();
×
592
        let _r = _rrc.as_ref().unwrap();
×
593
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
×
594
        *self_rc.num_data.borrow_mut() = t;
×
595
        *self_rc.data_segments.borrow_mut() = Vec::new();
×
596
        {
597
            let mut _i = 0;
×
598
            while !_io.is_eof() {
×
NEW
599
                let t = Self::read_into::<_, Webassembly_DataSegment>(
×
NEW
600
                    &*_io,
×
NEW
601
                    Some(self_rc._root.clone()),
×
NEW
602
                    Some(self_rc._self.clone()),
×
NEW
603
                )?
×
NEW
604
                .into();
×
605
                self_rc.data_segments.borrow_mut().push(t);
×
606
                _i += 1;
×
607
            }
608
        }
609
        Ok(())
×
610
    }
×
611
}
612
impl Webassembly_DataSection {}
613
impl Webassembly_DataSection {
614
    pub fn num_data(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
×
615
        self.num_data.borrow()
×
616
    }
×
617
}
618
impl Webassembly_DataSection {
619
    pub fn data_segments(&self) -> Ref<'_, Vec<OptRc<Webassembly_DataSegment>>> {
×
620
        self.data_segments.borrow()
×
621
    }
×
622
}
623
impl Webassembly_DataSection {
624
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
625
        self._io.borrow()
×
626
    }
×
627
}
628

629
#[derive(Default, Debug, Clone)]
630
pub struct Webassembly_DataSegment {
631
    pub _root: SharedType<Webassembly>,
632
    pub _parent: SharedType<Webassembly_DataSection>,
633
    pub _self: SharedType<Self>,
634
    data_memidx: RefCell<OptRc<VlqBase128Le>>,
635
    offset_expr: RefCell<OptRc<Webassembly_Expression>>,
636
    num_init: RefCell<OptRc<VlqBase128Le>>,
637
    init_vec: RefCell<Vec<u8>>,
638
    _io: RefCell<BytesReader>,
639
}
640
impl KStruct for Webassembly_DataSegment {
641
    type Root = Webassembly;
642
    type Parent = Webassembly_DataSection;
643

644
    fn read<S: KStream>(
×
645
        self_rc: &OptRc<Self>,
×
646
        _io: &S,
×
647
        _root: SharedType<Self::Root>,
×
648
        _parent: SharedType<Self::Parent>,
×
649
    ) -> KResult<()> {
×
650
        *self_rc._io.borrow_mut() = _io.clone();
×
651
        self_rc._root.set(_root.get());
×
652
        self_rc._parent.set(_parent.get());
×
653
        self_rc._self.set(Ok(self_rc.clone()));
×
654
        let _rrc = self_rc._root.get_value().borrow().upgrade();
×
655
        let _prc = self_rc._parent.get_value().borrow().upgrade();
×
656
        let _r = _rrc.as_ref().unwrap();
×
657
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
×
658
        *self_rc.data_memidx.borrow_mut() = t;
×
NEW
659
        let t =
×
NEW
660
            Self::read_into::<_, Webassembly_Expression>(&*_io, Some(self_rc._root.clone()), None)?
×
NEW
661
                .into();
×
662
        *self_rc.offset_expr.borrow_mut() = t;
×
663
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
×
664
        *self_rc.num_init.borrow_mut() = t;
×
NEW
665
        *self_rc.init_vec.borrow_mut() = _io
×
NEW
666
            .read_bytes(*self_rc.num_init().value()? as usize)?
×
NEW
667
            .into();
×
668
        Ok(())
×
669
    }
×
670
}
671
impl Webassembly_DataSegment {}
672
impl Webassembly_DataSegment {
673
    pub fn data_memidx(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
×
674
        self.data_memidx.borrow()
×
675
    }
×
676
}
677

678
/**
679
 * The offset is given by a constant expression that DOES NOT include an end marker
680
 * \sa https://www.w3.org/TR/wasm-core-1/#valid-constant Source
681
 */
682
impl Webassembly_DataSegment {
683
    pub fn offset_expr(&self) -> Ref<'_, OptRc<Webassembly_Expression>> {
×
684
        self.offset_expr.borrow()
×
685
    }
×
686
}
687
impl Webassembly_DataSegment {
688
    pub fn num_init(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
×
689
        self.num_init.borrow()
×
690
    }
×
691
}
692
impl Webassembly_DataSegment {
693
    pub fn init_vec(&self) -> Ref<'_, Vec<u8>> {
×
694
        self.init_vec.borrow()
×
695
    }
×
696
}
697
impl Webassembly_DataSegment {
698
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
699
        self._io.borrow()
×
700
    }
×
701
}
702

703
#[derive(Default, Debug, Clone)]
704
pub struct Webassembly_Element {
705
    pub _root: SharedType<Webassembly>,
706
    pub _parent: SharedType<Webassembly_ElementSection>,
707
    pub _self: SharedType<Self>,
708
    tableidx: RefCell<OptRc<VlqBase128Le>>,
709
    offset_expr: RefCell<OptRc<Webassembly_Expression>>,
710
    num_init: RefCell<OptRc<VlqBase128Le>>,
711
    init_vec: RefCell<Vec<OptRc<VlqBase128Le>>>,
712
    _io: RefCell<BytesReader>,
713
}
714
impl KStruct for Webassembly_Element {
715
    type Root = Webassembly;
716
    type Parent = Webassembly_ElementSection;
717

718
    fn read<S: KStream>(
×
719
        self_rc: &OptRc<Self>,
×
720
        _io: &S,
×
721
        _root: SharedType<Self::Root>,
×
722
        _parent: SharedType<Self::Parent>,
×
723
    ) -> KResult<()> {
×
724
        *self_rc._io.borrow_mut() = _io.clone();
×
725
        self_rc._root.set(_root.get());
×
726
        self_rc._parent.set(_parent.get());
×
727
        self_rc._self.set(Ok(self_rc.clone()));
×
728
        let _rrc = self_rc._root.get_value().borrow().upgrade();
×
729
        let _prc = self_rc._parent.get_value().borrow().upgrade();
×
730
        let _r = _rrc.as_ref().unwrap();
×
731
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
×
732
        *self_rc.tableidx.borrow_mut() = t;
×
NEW
733
        let t =
×
NEW
734
            Self::read_into::<_, Webassembly_Expression>(&*_io, Some(self_rc._root.clone()), None)?
×
NEW
735
                .into();
×
736
        *self_rc.offset_expr.borrow_mut() = t;
×
737
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
×
738
        *self_rc.num_init.borrow_mut() = t;
×
739
        *self_rc.init_vec.borrow_mut() = Vec::new();
×
740
        let l_init_vec = *self_rc.num_init().value()?;
×
741
        for _i in 0..l_init_vec {
×
742
            let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
×
743
            self_rc.init_vec.borrow_mut().push(t);
×
744
        }
745
        Ok(())
×
746
    }
×
747
}
748
impl Webassembly_Element {}
749
impl Webassembly_Element {
750
    pub fn tableidx(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
×
751
        self.tableidx.borrow()
×
752
    }
×
753
}
754

755
/**
756
 * The offset is given by a constant expression that DOES NOT include an end marker
757
 * \sa https://www.w3.org/TR/wasm-core-1/#valid-constant Source
758
 */
759
impl Webassembly_Element {
760
    pub fn offset_expr(&self) -> Ref<'_, OptRc<Webassembly_Expression>> {
×
761
        self.offset_expr.borrow()
×
762
    }
×
763
}
764
impl Webassembly_Element {
765
    pub fn num_init(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
×
766
        self.num_init.borrow()
×
767
    }
×
768
}
769
impl Webassembly_Element {
770
    pub fn init_vec(&self) -> Ref<'_, Vec<OptRc<VlqBase128Le>>> {
×
771
        self.init_vec.borrow()
×
772
    }
×
773
}
774
impl Webassembly_Element {
775
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
776
        self._io.borrow()
×
777
    }
×
778
}
779

780
/**
781
 * (id 9) - Vector of element sections
782
 * \sa https://www.w3.org/TR/wasm-core-1/#binary-elemsec Source
783
 */
784

785
#[derive(Default, Debug, Clone)]
786
pub struct Webassembly_ElementSection {
787
    pub _root: SharedType<Webassembly>,
788
    pub _parent: SharedType<Webassembly_Section>,
789
    pub _self: SharedType<Self>,
790
    num_elements: RefCell<OptRc<VlqBase128Le>>,
791
    elements: RefCell<Vec<OptRc<Webassembly_Element>>>,
792
    _io: RefCell<BytesReader>,
793
}
794
impl KStruct for Webassembly_ElementSection {
795
    type Root = Webassembly;
796
    type Parent = Webassembly_Section;
797

798
    fn read<S: KStream>(
×
799
        self_rc: &OptRc<Self>,
×
800
        _io: &S,
×
801
        _root: SharedType<Self::Root>,
×
802
        _parent: SharedType<Self::Parent>,
×
803
    ) -> KResult<()> {
×
804
        *self_rc._io.borrow_mut() = _io.clone();
×
805
        self_rc._root.set(_root.get());
×
806
        self_rc._parent.set(_parent.get());
×
807
        self_rc._self.set(Ok(self_rc.clone()));
×
808
        let _rrc = self_rc._root.get_value().borrow().upgrade();
×
809
        let _prc = self_rc._parent.get_value().borrow().upgrade();
×
810
        let _r = _rrc.as_ref().unwrap();
×
811
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
×
812
        *self_rc.num_elements.borrow_mut() = t;
×
813
        *self_rc.elements.borrow_mut() = Vec::new();
×
814
        {
815
            let mut _i = 0;
×
816
            while !_io.is_eof() {
×
NEW
817
                let t = Self::read_into::<_, Webassembly_Element>(
×
NEW
818
                    &*_io,
×
NEW
819
                    Some(self_rc._root.clone()),
×
NEW
820
                    Some(self_rc._self.clone()),
×
NEW
821
                )?
×
NEW
822
                .into();
×
823
                self_rc.elements.borrow_mut().push(t);
×
824
                _i += 1;
×
825
            }
826
        }
827
        Ok(())
×
828
    }
×
829
}
830
impl Webassembly_ElementSection {}
831
impl Webassembly_ElementSection {
832
    pub fn num_elements(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
×
833
        self.num_elements.borrow()
×
834
    }
×
835
}
836
impl Webassembly_ElementSection {
837
    pub fn elements(&self) -> Ref<'_, Vec<OptRc<Webassembly_Element>>> {
×
838
        self.elements.borrow()
×
839
    }
×
840
}
841
impl Webassembly_ElementSection {
842
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
843
        self._io.borrow()
×
844
    }
×
845
}
846

847
#[derive(Default, Debug, Clone)]
848
pub struct Webassembly_Export {
849
    pub _root: SharedType<Webassembly>,
850
    pub _parent: SharedType<Webassembly_ExportSection>,
851
    pub _self: SharedType<Self>,
852
    name: RefCell<OptRc<Webassembly_Name>>,
853
    exportdesc: RefCell<Webassembly_ExportTypes>,
854
    idx: RefCell<OptRc<VlqBase128Le>>,
855
    _io: RefCell<BytesReader>,
856
}
857
impl KStruct for Webassembly_Export {
858
    type Root = Webassembly;
859
    type Parent = Webassembly_ExportSection;
860

861
    fn read<S: KStream>(
2✔
862
        self_rc: &OptRc<Self>,
2✔
863
        _io: &S,
2✔
864
        _root: SharedType<Self::Root>,
2✔
865
        _parent: SharedType<Self::Parent>,
2✔
866
    ) -> KResult<()> {
2✔
867
        *self_rc._io.borrow_mut() = _io.clone();
2✔
868
        self_rc._root.set(_root.get());
2✔
869
        self_rc._parent.set(_parent.get());
2✔
870
        self_rc._self.set(Ok(self_rc.clone()));
2✔
871
        let _rrc = self_rc._root.get_value().borrow().upgrade();
2✔
872
        let _prc = self_rc._parent.get_value().borrow().upgrade();
2✔
873
        let _r = _rrc.as_ref().unwrap();
2✔
874
        let t = Self::read_into::<_, Webassembly_Name>(&*_io, Some(self_rc._root.clone()), None)?
2✔
875
            .into();
2✔
876
        *self_rc.name.borrow_mut() = t;
2✔
877
        *self_rc.exportdesc.borrow_mut() = (_io.read_u1()? as i64).try_into()?;
2✔
878
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
2✔
879
        *self_rc.idx.borrow_mut() = t;
2✔
880
        Ok(())
2✔
881
    }
2✔
882
}
883
impl Webassembly_Export {}
884
impl Webassembly_Export {
885
    pub fn name(&self) -> Ref<'_, OptRc<Webassembly_Name>> {
×
886
        self.name.borrow()
×
887
    }
×
888
}
889
impl Webassembly_Export {
890
    pub fn exportdesc(&self) -> Ref<'_, Webassembly_ExportTypes> {
×
891
        self.exportdesc.borrow()
×
892
    }
×
893
}
894
impl Webassembly_Export {
895
    pub fn idx(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
×
896
        self.idx.borrow()
×
897
    }
×
898
}
899
impl Webassembly_Export {
900
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
901
        self._io.borrow()
×
902
    }
×
903
}
904

905
/**
906
 * (id 7) - Exported entities
907
 * \sa https://www.w3.org/TR/wasm-core-1/#binary-exportsec Source
908
 */
909

910
#[derive(Default, Debug, Clone)]
911
pub struct Webassembly_ExportSection {
912
    pub _root: SharedType<Webassembly>,
913
    pub _parent: SharedType<Webassembly_Section>,
914
    pub _self: SharedType<Self>,
915
    num_exports: RefCell<OptRc<VlqBase128Le>>,
916
    exports: RefCell<Vec<OptRc<Webassembly_Export>>>,
917
    _io: RefCell<BytesReader>,
918
}
919
impl KStruct for Webassembly_ExportSection {
920
    type Root = Webassembly;
921
    type Parent = Webassembly_Section;
922

923
    fn read<S: KStream>(
1✔
924
        self_rc: &OptRc<Self>,
1✔
925
        _io: &S,
1✔
926
        _root: SharedType<Self::Root>,
1✔
927
        _parent: SharedType<Self::Parent>,
1✔
928
    ) -> KResult<()> {
1✔
929
        *self_rc._io.borrow_mut() = _io.clone();
1✔
930
        self_rc._root.set(_root.get());
1✔
931
        self_rc._parent.set(_parent.get());
1✔
932
        self_rc._self.set(Ok(self_rc.clone()));
1✔
933
        let _rrc = self_rc._root.get_value().borrow().upgrade();
1✔
934
        let _prc = self_rc._parent.get_value().borrow().upgrade();
1✔
935
        let _r = _rrc.as_ref().unwrap();
1✔
936
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
1✔
937
        *self_rc.num_exports.borrow_mut() = t;
1✔
938
        *self_rc.exports.borrow_mut() = Vec::new();
1✔
939
        {
940
            let mut _i = 0;
1✔
941
            while !_io.is_eof() {
3✔
942
                let t = Self::read_into::<_, Webassembly_Export>(
2✔
943
                    &*_io,
2✔
944
                    Some(self_rc._root.clone()),
2✔
945
                    Some(self_rc._self.clone()),
2✔
NEW
946
                )?
×
947
                .into();
2✔
948
                self_rc.exports.borrow_mut().push(t);
2✔
949
                _i += 1;
2✔
950
            }
951
        }
952
        Ok(())
1✔
953
    }
1✔
954
}
955
impl Webassembly_ExportSection {}
956
impl Webassembly_ExportSection {
957
    pub fn num_exports(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
×
958
        self.num_exports.borrow()
×
959
    }
×
960
}
961
impl Webassembly_ExportSection {
962
    pub fn exports(&self) -> Ref<'_, Vec<OptRc<Webassembly_Export>>> {
×
963
        self.exports.borrow()
×
964
    }
×
965
}
966
impl Webassembly_ExportSection {
967
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
968
        self._io.borrow()
×
969
    }
×
970
}
971

972
#[derive(Default, Debug, Clone)]
973
pub struct Webassembly_Expression {
974
    pub _root: SharedType<Webassembly>,
975
    pub _parent: SharedType<KStructUnit>,
976
    pub _self: SharedType<Self>,
977
    bytes: RefCell<Vec<u8>>,
978
    _io: RefCell<BytesReader>,
979
}
980
impl KStruct for Webassembly_Expression {
981
    type Root = Webassembly;
982
    type Parent = KStructUnit;
983

984
    fn read<S: KStream>(
×
985
        self_rc: &OptRc<Self>,
×
986
        _io: &S,
×
987
        _root: SharedType<Self::Root>,
×
988
        _parent: SharedType<Self::Parent>,
×
989
    ) -> KResult<()> {
×
990
        *self_rc._io.borrow_mut() = _io.clone();
×
991
        self_rc._root.set(_root.get());
×
992
        self_rc._parent.set(_parent.get());
×
993
        self_rc._self.set(Ok(self_rc.clone()));
×
994
        let _rrc = self_rc._root.get_value().borrow().upgrade();
×
995
        let _prc = self_rc._parent.get_value().borrow().upgrade();
×
996
        let _r = _rrc.as_ref().unwrap();
×
997
        *self_rc.bytes.borrow_mut() = Vec::new();
×
998
        {
999
            let mut _i = 0;
×
1000
            while {
1001
                self_rc.bytes.borrow_mut().push(_io.read_u1()?.into());
×
1002
                let _t_bytes = self_rc.bytes.borrow();
×
1003
                let _tmpa = *_t_bytes.last().unwrap();
×
1004
                _i += 1;
×
NEW
1005
                let x = !(((self_rc.bytes()[((self_rc.bytes().len() as i32) - (1 as i32)) as usize]
×
NEW
1006
                    as u8)
×
NEW
1007
                    == (11 as u8))
×
NEW
1008
                    && (((self_rc.bytes().len() as i32) == (1 as i32))
×
NEW
1009
                        || (self_rc.bytes()
×
NEW
1010
                            [((self_rc.bytes().len() as i32) - (2 as i32)) as usize]
×
NEW
1011
                            < 128)));
×
1012
                x
×
1013
            } {}
×
1014
        }
1015
        Ok(())
×
1016
    }
×
1017
}
1018
impl Webassembly_Expression {}
1019
impl Webassembly_Expression {
1020
    pub fn bytes(&self) -> Ref<'_, Vec<u8>> {
×
1021
        self.bytes.borrow()
×
1022
    }
×
1023
}
1024
impl Webassembly_Expression {
1025
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
1026
        self._io.borrow()
×
1027
    }
×
1028
}
1029

1030
#[derive(Default, Debug, Clone)]
1031
pub struct Webassembly_Func {
1032
    pub _root: SharedType<Webassembly>,
1033
    pub _parent: SharedType<Webassembly_Code>,
1034
    pub _self: SharedType<Self>,
1035
    num_locals: RefCell<OptRc<VlqBase128Le>>,
1036
    locals: RefCell<Vec<OptRc<Webassembly_Local>>>,
1037
    expr: RefCell<Vec<u8>>,
1038
    _io: RefCell<BytesReader>,
1039
}
1040
impl KStruct for Webassembly_Func {
1041
    type Root = Webassembly;
1042
    type Parent = Webassembly_Code;
1043

1044
    fn read<S: KStream>(
2✔
1045
        self_rc: &OptRc<Self>,
2✔
1046
        _io: &S,
2✔
1047
        _root: SharedType<Self::Root>,
2✔
1048
        _parent: SharedType<Self::Parent>,
2✔
1049
    ) -> KResult<()> {
2✔
1050
        *self_rc._io.borrow_mut() = _io.clone();
2✔
1051
        self_rc._root.set(_root.get());
2✔
1052
        self_rc._parent.set(_parent.get());
2✔
1053
        self_rc._self.set(Ok(self_rc.clone()));
2✔
1054
        let _rrc = self_rc._root.get_value().borrow().upgrade();
2✔
1055
        let _prc = self_rc._parent.get_value().borrow().upgrade();
2✔
1056
        let _r = _rrc.as_ref().unwrap();
2✔
1057
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
2✔
1058
        *self_rc.num_locals.borrow_mut() = t;
2✔
1059
        *self_rc.locals.borrow_mut() = Vec::new();
2✔
1060
        let l_locals = *self_rc.num_locals().value()?;
2✔
1061
        for _i in 0..l_locals {
2✔
NEW
1062
            let t = Self::read_into::<_, Webassembly_Local>(
×
NEW
1063
                &*_io,
×
NEW
1064
                Some(self_rc._root.clone()),
×
NEW
1065
                Some(self_rc._self.clone()),
×
NEW
1066
            )?
×
NEW
1067
            .into();
×
UNCOV
1068
            self_rc.locals.borrow_mut().push(t);
×
1069
        }
1070
        *self_rc.expr.borrow_mut() = _io.read_bytes_full()?.into();
2✔
1071
        Ok(())
2✔
1072
    }
2✔
1073
}
1074
impl Webassembly_Func {}
1075
impl Webassembly_Func {
1076
    pub fn num_locals(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
2✔
1077
        self.num_locals.borrow()
2✔
1078
    }
2✔
1079
}
1080
impl Webassembly_Func {
1081
    pub fn locals(&self) -> Ref<'_, Vec<OptRc<Webassembly_Local>>> {
×
1082
        self.locals.borrow()
×
1083
    }
×
1084
}
1085
impl Webassembly_Func {
1086
    pub fn expr(&self) -> Ref<'_, Vec<u8>> {
×
1087
        self.expr.borrow()
×
1088
    }
×
1089
}
1090
impl Webassembly_Func {
1091
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
1092
        self._io.borrow()
×
1093
    }
×
1094
}
1095

1096
/**
1097
 * (id 3) - Vector of type indices (see `Type Section`) for all functions in the `Code Section`
1098
 * \sa https://www.w3.org/TR/wasm-core-1/#binary-funcsec Source
1099
 */
1100

1101
#[derive(Default, Debug, Clone)]
1102
pub struct Webassembly_FunctionSection {
1103
    pub _root: SharedType<Webassembly>,
1104
    pub _parent: SharedType<Webassembly_Section>,
1105
    pub _self: SharedType<Self>,
1106
    num_typeidx: RefCell<OptRc<VlqBase128Le>>,
1107
    typeidx: RefCell<Vec<OptRc<VlqBase128Le>>>,
1108
    _io: RefCell<BytesReader>,
1109
}
1110
impl KStruct for Webassembly_FunctionSection {
1111
    type Root = Webassembly;
1112
    type Parent = Webassembly_Section;
1113

1114
    fn read<S: KStream>(
1✔
1115
        self_rc: &OptRc<Self>,
1✔
1116
        _io: &S,
1✔
1117
        _root: SharedType<Self::Root>,
1✔
1118
        _parent: SharedType<Self::Parent>,
1✔
1119
    ) -> KResult<()> {
1✔
1120
        *self_rc._io.borrow_mut() = _io.clone();
1✔
1121
        self_rc._root.set(_root.get());
1✔
1122
        self_rc._parent.set(_parent.get());
1✔
1123
        self_rc._self.set(Ok(self_rc.clone()));
1✔
1124
        let _rrc = self_rc._root.get_value().borrow().upgrade();
1✔
1125
        let _prc = self_rc._parent.get_value().borrow().upgrade();
1✔
1126
        let _r = _rrc.as_ref().unwrap();
1✔
1127
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
1✔
1128
        *self_rc.num_typeidx.borrow_mut() = t;
1✔
1129
        *self_rc.typeidx.borrow_mut() = Vec::new();
1✔
1130
        {
1131
            let mut _i = 0;
1✔
1132
            while !_io.is_eof() {
3✔
1133
                let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
2✔
1134
                self_rc.typeidx.borrow_mut().push(t);
2✔
1135
                _i += 1;
2✔
1136
            }
1137
        }
1138
        Ok(())
1✔
1139
    }
1✔
1140
}
1141
impl Webassembly_FunctionSection {}
1142
impl Webassembly_FunctionSection {
1143
    pub fn num_typeidx(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
×
1144
        self.num_typeidx.borrow()
×
1145
    }
×
1146
}
1147
impl Webassembly_FunctionSection {
1148
    pub fn typeidx(&self) -> Ref<'_, Vec<OptRc<VlqBase128Le>>> {
×
1149
        self.typeidx.borrow()
×
1150
    }
×
1151
}
1152
impl Webassembly_FunctionSection {
1153
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
1154
        self._io.borrow()
×
1155
    }
×
1156
}
1157

1158
/**
1159
 * Byte `0x60` followed by a vector of parameters and results
1160
 * \sa https://www.w3.org/TR/wasm-core-1/#binary-functype Source
1161
 */
1162

1163
#[derive(Default, Debug, Clone)]
1164
pub struct Webassembly_Functype {
1165
    pub _root: SharedType<Webassembly>,
1166
    pub _parent: SharedType<Webassembly_TypeSection>,
1167
    pub _self: SharedType<Self>,
1168
    functype: RefCell<Webassembly_Types>,
1169
    parameters: RefCell<OptRc<Webassembly_VecValtype>>,
1170
    results: RefCell<OptRc<Webassembly_VecValtype>>,
1171
    _io: RefCell<BytesReader>,
1172
}
1173
impl KStruct for Webassembly_Functype {
1174
    type Root = Webassembly;
1175
    type Parent = Webassembly_TypeSection;
1176

1177
    fn read<S: KStream>(
1✔
1178
        self_rc: &OptRc<Self>,
1✔
1179
        _io: &S,
1✔
1180
        _root: SharedType<Self::Root>,
1✔
1181
        _parent: SharedType<Self::Parent>,
1✔
1182
    ) -> KResult<()> {
1✔
1183
        *self_rc._io.borrow_mut() = _io.clone();
1✔
1184
        self_rc._root.set(_root.get());
1✔
1185
        self_rc._parent.set(_parent.get());
1✔
1186
        self_rc._self.set(Ok(self_rc.clone()));
1✔
1187
        let _rrc = self_rc._root.get_value().borrow().upgrade();
1✔
1188
        let _prc = self_rc._parent.get_value().borrow().upgrade();
1✔
1189
        let _r = _rrc.as_ref().unwrap();
1✔
1190
        *self_rc.functype.borrow_mut() = (_io.read_u1()? as i64).try_into()?;
1✔
1191
        if !(*self_rc.functype() == Webassembly_Types::Function) {
1✔
NEW
1192
            return Err(KError::ValidationFailed(ValidationFailedError {
×
NEW
1193
                kind: ValidationKind::NotEqual,
×
NEW
1194
                src_path: "/types/functype/seq/0".to_string(),
×
NEW
1195
            }));
×
1196
        }
1✔
1197
        let t = Self::read_into::<_, Webassembly_VecValtype>(
1✔
1198
            &*_io,
1✔
1199
            Some(self_rc._root.clone()),
1✔
1200
            Some(self_rc._self.clone()),
1✔
NEW
1201
        )?
×
1202
        .into();
1✔
1203
        *self_rc.parameters.borrow_mut() = t;
1✔
1204
        let t = Self::read_into::<_, Webassembly_VecValtype>(
1✔
1205
            &*_io,
1✔
1206
            Some(self_rc._root.clone()),
1✔
1207
            Some(self_rc._self.clone()),
1✔
NEW
1208
        )?
×
1209
        .into();
1✔
1210
        *self_rc.results.borrow_mut() = t;
1✔
1211
        Ok(())
1✔
1212
    }
1✔
1213
}
1214
impl Webassembly_Functype {}
1215
impl Webassembly_Functype {
1216
    pub fn functype(&self) -> Ref<'_, Webassembly_Types> {
1✔
1217
        self.functype.borrow()
1✔
1218
    }
1✔
1219
}
1220
impl Webassembly_Functype {
1221
    pub fn parameters(&self) -> Ref<'_, OptRc<Webassembly_VecValtype>> {
×
1222
        self.parameters.borrow()
×
1223
    }
×
1224
}
1225
impl Webassembly_Functype {
1226
    pub fn results(&self) -> Ref<'_, OptRc<Webassembly_VecValtype>> {
×
1227
        self.results.borrow()
×
1228
    }
×
1229
}
1230
impl Webassembly_Functype {
1231
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
1232
        self._io.borrow()
×
1233
    }
×
1234
}
1235

1236
#[derive(Default, Debug, Clone)]
1237
pub struct Webassembly_Global {
1238
    pub _root: SharedType<Webassembly>,
1239
    pub _parent: SharedType<Webassembly_GlobalSection>,
1240
    pub _self: SharedType<Self>,
1241
    valtype: RefCell<Webassembly_ValTypes>,
1242
    mutability: RefCell<Webassembly_MutabilityTypes>,
1243
    init_expr: RefCell<OptRc<Webassembly_Expression>>,
1244
    _io: RefCell<BytesReader>,
1245
}
1246
impl KStruct for Webassembly_Global {
1247
    type Root = Webassembly;
1248
    type Parent = Webassembly_GlobalSection;
1249

1250
    fn read<S: KStream>(
×
1251
        self_rc: &OptRc<Self>,
×
1252
        _io: &S,
×
1253
        _root: SharedType<Self::Root>,
×
1254
        _parent: SharedType<Self::Parent>,
×
1255
    ) -> KResult<()> {
×
1256
        *self_rc._io.borrow_mut() = _io.clone();
×
1257
        self_rc._root.set(_root.get());
×
1258
        self_rc._parent.set(_parent.get());
×
1259
        self_rc._self.set(Ok(self_rc.clone()));
×
1260
        let _rrc = self_rc._root.get_value().borrow().upgrade();
×
1261
        let _prc = self_rc._parent.get_value().borrow().upgrade();
×
1262
        let _r = _rrc.as_ref().unwrap();
×
1263
        *self_rc.valtype.borrow_mut() = (_io.read_u1()? as i64).try_into()?;
×
1264
        *self_rc.mutability.borrow_mut() = (_io.read_u1()? as i64).try_into()?;
×
NEW
1265
        if !((*self_rc.mutability() == Webassembly_MutabilityTypes::Const)
×
NEW
1266
            || (*self_rc.mutability() == Webassembly_MutabilityTypes::Var))
×
1267
        {
NEW
1268
            return Err(KError::ValidationFailed(ValidationFailedError {
×
NEW
1269
                kind: ValidationKind::NotAnyOf,
×
NEW
1270
                src_path: "/types/global/seq/1".to_string(),
×
NEW
1271
            }));
×
1272
        }
×
NEW
1273
        let t =
×
NEW
1274
            Self::read_into::<_, Webassembly_Expression>(&*_io, Some(self_rc._root.clone()), None)?
×
NEW
1275
                .into();
×
1276
        *self_rc.init_expr.borrow_mut() = t;
×
1277
        Ok(())
×
1278
    }
×
1279
}
1280
impl Webassembly_Global {}
1281
impl Webassembly_Global {
1282
    pub fn valtype(&self) -> Ref<'_, Webassembly_ValTypes> {
×
1283
        self.valtype.borrow()
×
1284
    }
×
1285
}
1286
impl Webassembly_Global {
1287
    pub fn mutability(&self) -> Ref<'_, Webassembly_MutabilityTypes> {
×
1288
        self.mutability.borrow()
×
1289
    }
×
1290
}
1291
impl Webassembly_Global {
1292
    pub fn init_expr(&self) -> Ref<'_, OptRc<Webassembly_Expression>> {
×
1293
        self.init_expr.borrow()
×
1294
    }
×
1295
}
1296
impl Webassembly_Global {
1297
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
1298
        self._io.borrow()
×
1299
    }
×
1300
}
1301

1302
#[derive(Default, Debug, Clone)]
1303
pub struct Webassembly_GlobalImport {
1304
    pub _root: SharedType<Webassembly>,
1305
    pub _parent: SharedType<Webassembly_Import>,
1306
    pub _self: SharedType<Self>,
1307
    valtype: RefCell<Webassembly_ValTypes>,
1308
    mutability: RefCell<Webassembly_MutabilityTypes>,
1309
    _io: RefCell<BytesReader>,
1310
}
1311
impl KStruct for Webassembly_GlobalImport {
1312
    type Root = Webassembly;
1313
    type Parent = Webassembly_Import;
1314

1315
    fn read<S: KStream>(
×
1316
        self_rc: &OptRc<Self>,
×
1317
        _io: &S,
×
1318
        _root: SharedType<Self::Root>,
×
1319
        _parent: SharedType<Self::Parent>,
×
1320
    ) -> KResult<()> {
×
1321
        *self_rc._io.borrow_mut() = _io.clone();
×
1322
        self_rc._root.set(_root.get());
×
1323
        self_rc._parent.set(_parent.get());
×
1324
        self_rc._self.set(Ok(self_rc.clone()));
×
1325
        let _rrc = self_rc._root.get_value().borrow().upgrade();
×
1326
        let _prc = self_rc._parent.get_value().borrow().upgrade();
×
1327
        let _r = _rrc.as_ref().unwrap();
×
1328
        *self_rc.valtype.borrow_mut() = (_io.read_u1()? as i64).try_into()?;
×
1329
        *self_rc.mutability.borrow_mut() = (_io.read_u1()? as i64).try_into()?;
×
NEW
1330
        if !((*self_rc.mutability() == Webassembly_MutabilityTypes::Const)
×
NEW
1331
            || (*self_rc.mutability() == Webassembly_MutabilityTypes::Var))
×
1332
        {
NEW
1333
            return Err(KError::ValidationFailed(ValidationFailedError {
×
NEW
1334
                kind: ValidationKind::NotAnyOf,
×
NEW
1335
                src_path: "/types/global_import/seq/1".to_string(),
×
NEW
1336
            }));
×
1337
        }
×
1338
        Ok(())
×
1339
    }
×
1340
}
1341
impl Webassembly_GlobalImport {}
1342
impl Webassembly_GlobalImport {
1343
    pub fn valtype(&self) -> Ref<'_, Webassembly_ValTypes> {
×
1344
        self.valtype.borrow()
×
1345
    }
×
1346
}
1347
impl Webassembly_GlobalImport {
1348
    pub fn mutability(&self) -> Ref<'_, Webassembly_MutabilityTypes> {
×
1349
        self.mutability.borrow()
×
1350
    }
×
1351
}
1352
impl Webassembly_GlobalImport {
1353
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
1354
        self._io.borrow()
×
1355
    }
×
1356
}
1357

1358
/**
1359
 * (id 6) Vector of globals
1360
 * \sa https://www.w3.org/TR/wasm-core-1/#binary-memsec Source
1361
 */
1362

1363
#[derive(Default, Debug, Clone)]
1364
pub struct Webassembly_GlobalSection {
1365
    pub _root: SharedType<Webassembly>,
1366
    pub _parent: SharedType<Webassembly_Section>,
1367
    pub _self: SharedType<Self>,
1368
    num_globals: RefCell<OptRc<VlqBase128Le>>,
1369
    globals: RefCell<Vec<OptRc<Webassembly_Global>>>,
1370
    _io: RefCell<BytesReader>,
1371
}
1372
impl KStruct for Webassembly_GlobalSection {
1373
    type Root = Webassembly;
1374
    type Parent = Webassembly_Section;
1375

1376
    fn read<S: KStream>(
×
1377
        self_rc: &OptRc<Self>,
×
1378
        _io: &S,
×
1379
        _root: SharedType<Self::Root>,
×
1380
        _parent: SharedType<Self::Parent>,
×
1381
    ) -> KResult<()> {
×
1382
        *self_rc._io.borrow_mut() = _io.clone();
×
1383
        self_rc._root.set(_root.get());
×
1384
        self_rc._parent.set(_parent.get());
×
1385
        self_rc._self.set(Ok(self_rc.clone()));
×
1386
        let _rrc = self_rc._root.get_value().borrow().upgrade();
×
1387
        let _prc = self_rc._parent.get_value().borrow().upgrade();
×
1388
        let _r = _rrc.as_ref().unwrap();
×
1389
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
×
1390
        *self_rc.num_globals.borrow_mut() = t;
×
1391
        *self_rc.globals.borrow_mut() = Vec::new();
×
1392
        {
1393
            let mut _i = 0;
×
1394
            while !_io.is_eof() {
×
NEW
1395
                let t = Self::read_into::<_, Webassembly_Global>(
×
NEW
1396
                    &*_io,
×
NEW
1397
                    Some(self_rc._root.clone()),
×
NEW
1398
                    Some(self_rc._self.clone()),
×
NEW
1399
                )?
×
NEW
1400
                .into();
×
1401
                self_rc.globals.borrow_mut().push(t);
×
1402
                _i += 1;
×
1403
            }
1404
        }
1405
        Ok(())
×
1406
    }
×
1407
}
1408
impl Webassembly_GlobalSection {}
1409
impl Webassembly_GlobalSection {
1410
    pub fn num_globals(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
×
1411
        self.num_globals.borrow()
×
1412
    }
×
1413
}
1414
impl Webassembly_GlobalSection {
1415
    pub fn globals(&self) -> Ref<'_, Vec<OptRc<Webassembly_Global>>> {
×
1416
        self.globals.borrow()
×
1417
    }
×
1418
}
1419
impl Webassembly_GlobalSection {
1420
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
1421
        self._io.borrow()
×
1422
    }
×
1423
}
1424

1425
/**
1426
 * An element of the import section
1427
 */
1428

1429
#[derive(Default, Debug, Clone)]
1430
pub struct Webassembly_Import {
1431
    pub _root: SharedType<Webassembly>,
1432
    pub _parent: SharedType<Webassembly_ImportSection>,
1433
    pub _self: SharedType<Self>,
1434
    module: RefCell<OptRc<Webassembly_Name>>,
1435
    name: RefCell<OptRc<Webassembly_Name>>,
1436
    import_type: RefCell<Webassembly_ImportTypes>,
1437
    importdesc: RefCell<Option<Webassembly_Import_Importdesc>>,
1438
    _io: RefCell<BytesReader>,
1439
}
1440
#[derive(Debug, Clone)]
1441
pub enum Webassembly_Import_Importdesc {
1442
    VlqBase128Le(OptRc<VlqBase128Le>),
1443
    Webassembly_GlobalImport(OptRc<Webassembly_GlobalImport>),
1444
    Webassembly_Memory(OptRc<Webassembly_Memory>),
1445
    Webassembly_Table(OptRc<Webassembly_Table>),
1446
}
1447
impl From<&Webassembly_Import_Importdesc> for OptRc<VlqBase128Le> {
1448
    fn from(v: &Webassembly_Import_Importdesc) -> Self {
×
1449
        if let Webassembly_Import_Importdesc::VlqBase128Le(x) = v {
×
1450
            return x.clone();
×
1451
        }
×
NEW
1452
        panic!(
×
1453
            "expected Webassembly_Import_Importdesc::VlqBase128Le, got {:?}",
1454
            v
1455
        )
UNCOV
1456
    }
×
1457
}
1458
impl From<OptRc<VlqBase128Le>> for Webassembly_Import_Importdesc {
1459
    fn from(v: OptRc<VlqBase128Le>) -> Self {
×
1460
        Self::VlqBase128Le(v)
×
1461
    }
×
1462
}
1463
impl From<&Webassembly_Import_Importdesc> for OptRc<Webassembly_GlobalImport> {
1464
    fn from(v: &Webassembly_Import_Importdesc) -> Self {
×
1465
        if let Webassembly_Import_Importdesc::Webassembly_GlobalImport(x) = v {
×
1466
            return x.clone();
×
1467
        }
×
NEW
1468
        panic!(
×
1469
            "expected Webassembly_Import_Importdesc::Webassembly_GlobalImport, got {:?}",
1470
            v
1471
        )
UNCOV
1472
    }
×
1473
}
1474
impl From<OptRc<Webassembly_GlobalImport>> for Webassembly_Import_Importdesc {
1475
    fn from(v: OptRc<Webassembly_GlobalImport>) -> Self {
×
1476
        Self::Webassembly_GlobalImport(v)
×
1477
    }
×
1478
}
1479
impl From<&Webassembly_Import_Importdesc> for OptRc<Webassembly_Memory> {
1480
    fn from(v: &Webassembly_Import_Importdesc) -> Self {
×
1481
        if let Webassembly_Import_Importdesc::Webassembly_Memory(x) = v {
×
1482
            return x.clone();
×
1483
        }
×
NEW
1484
        panic!(
×
1485
            "expected Webassembly_Import_Importdesc::Webassembly_Memory, got {:?}",
1486
            v
1487
        )
UNCOV
1488
    }
×
1489
}
1490
impl From<OptRc<Webassembly_Memory>> for Webassembly_Import_Importdesc {
1491
    fn from(v: OptRc<Webassembly_Memory>) -> Self {
×
1492
        Self::Webassembly_Memory(v)
×
1493
    }
×
1494
}
1495
impl From<&Webassembly_Import_Importdesc> for OptRc<Webassembly_Table> {
1496
    fn from(v: &Webassembly_Import_Importdesc) -> Self {
×
1497
        if let Webassembly_Import_Importdesc::Webassembly_Table(x) = v {
×
1498
            return x.clone();
×
1499
        }
×
NEW
1500
        panic!(
×
1501
            "expected Webassembly_Import_Importdesc::Webassembly_Table, got {:?}",
1502
            v
1503
        )
UNCOV
1504
    }
×
1505
}
1506
impl From<OptRc<Webassembly_Table>> for Webassembly_Import_Importdesc {
1507
    fn from(v: OptRc<Webassembly_Table>) -> Self {
×
1508
        Self::Webassembly_Table(v)
×
1509
    }
×
1510
}
1511
impl KStruct for Webassembly_Import {
1512
    type Root = Webassembly;
1513
    type Parent = Webassembly_ImportSection;
1514

1515
    fn read<S: KStream>(
×
1516
        self_rc: &OptRc<Self>,
×
1517
        _io: &S,
×
1518
        _root: SharedType<Self::Root>,
×
1519
        _parent: SharedType<Self::Parent>,
×
1520
    ) -> KResult<()> {
×
1521
        *self_rc._io.borrow_mut() = _io.clone();
×
1522
        self_rc._root.set(_root.get());
×
1523
        self_rc._parent.set(_parent.get());
×
1524
        self_rc._self.set(Ok(self_rc.clone()));
×
1525
        let _rrc = self_rc._root.get_value().borrow().upgrade();
×
1526
        let _prc = self_rc._parent.get_value().borrow().upgrade();
×
1527
        let _r = _rrc.as_ref().unwrap();
×
NEW
1528
        let t = Self::read_into::<_, Webassembly_Name>(&*_io, Some(self_rc._root.clone()), None)?
×
NEW
1529
            .into();
×
1530
        *self_rc.module.borrow_mut() = t;
×
NEW
1531
        let t = Self::read_into::<_, Webassembly_Name>(&*_io, Some(self_rc._root.clone()), None)?
×
NEW
1532
            .into();
×
1533
        *self_rc.name.borrow_mut() = t;
×
1534
        *self_rc.import_type.borrow_mut() = (_io.read_u1()? as i64).try_into()?;
×
1535
        match *self_rc.import_type() {
×
1536
            Webassembly_ImportTypes::FuncType => {
1537
                let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
×
1538
                *self_rc.importdesc.borrow_mut() = Some(t);
×
1539
            }
1540
            Webassembly_ImportTypes::GlobalType => {
NEW
1541
                let t = Self::read_into::<_, Webassembly_GlobalImport>(
×
NEW
1542
                    &*_io,
×
NEW
1543
                    Some(self_rc._root.clone()),
×
NEW
1544
                    Some(self_rc._self.clone()),
×
NEW
1545
                )?
×
NEW
1546
                .into();
×
UNCOV
1547
                *self_rc.importdesc.borrow_mut() = Some(t);
×
1548
            }
1549
            Webassembly_ImportTypes::MemType => {
NEW
1550
                let t = Self::read_into::<_, Webassembly_Memory>(
×
NEW
1551
                    &*_io,
×
NEW
1552
                    Some(self_rc._root.clone()),
×
NEW
1553
                    None,
×
NEW
1554
                )?
×
NEW
1555
                .into();
×
UNCOV
1556
                *self_rc.importdesc.borrow_mut() = Some(t);
×
1557
            }
1558
            Webassembly_ImportTypes::TableType => {
NEW
1559
                let t = Self::read_into::<_, Webassembly_Table>(
×
NEW
1560
                    &*_io,
×
NEW
1561
                    Some(self_rc._root.clone()),
×
NEW
1562
                    None,
×
NEW
1563
                )?
×
NEW
1564
                .into();
×
UNCOV
1565
                *self_rc.importdesc.borrow_mut() = Some(t);
×
1566
            }
1567
            _ => {}
×
1568
        }
1569
        Ok(())
×
1570
    }
×
1571
}
1572
impl Webassembly_Import {}
1573
impl Webassembly_Import {
1574
    pub fn module(&self) -> Ref<'_, OptRc<Webassembly_Name>> {
×
1575
        self.module.borrow()
×
1576
    }
×
1577
}
1578
impl Webassembly_Import {
1579
    pub fn name(&self) -> Ref<'_, OptRc<Webassembly_Name>> {
×
1580
        self.name.borrow()
×
1581
    }
×
1582
}
1583
impl Webassembly_Import {
1584
    pub fn import_type(&self) -> Ref<'_, Webassembly_ImportTypes> {
×
1585
        self.import_type.borrow()
×
1586
    }
×
1587
}
1588
impl Webassembly_Import {
1589
    pub fn importdesc(&self) -> Ref<'_, Option<Webassembly_Import_Importdesc>> {
×
1590
        self.importdesc.borrow()
×
1591
    }
×
1592
}
1593
impl Webassembly_Import {
1594
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
1595
        self._io.borrow()
×
1596
    }
×
1597
}
1598

1599
/**
1600
 * (id 2) - Imported components
1601
 * \sa https://www.w3.org/TR/wasm-core-1/#binary-importsec Source
1602
 */
1603

1604
#[derive(Default, Debug, Clone)]
1605
pub struct Webassembly_ImportSection {
1606
    pub _root: SharedType<Webassembly>,
1607
    pub _parent: SharedType<Webassembly_Section>,
1608
    pub _self: SharedType<Self>,
1609
    num_imports: RefCell<OptRc<VlqBase128Le>>,
1610
    imports: RefCell<Vec<OptRc<Webassembly_Import>>>,
1611
    _io: RefCell<BytesReader>,
1612
}
1613
impl KStruct for Webassembly_ImportSection {
1614
    type Root = Webassembly;
1615
    type Parent = Webassembly_Section;
1616

1617
    fn read<S: KStream>(
×
1618
        self_rc: &OptRc<Self>,
×
1619
        _io: &S,
×
1620
        _root: SharedType<Self::Root>,
×
1621
        _parent: SharedType<Self::Parent>,
×
1622
    ) -> KResult<()> {
×
1623
        *self_rc._io.borrow_mut() = _io.clone();
×
1624
        self_rc._root.set(_root.get());
×
1625
        self_rc._parent.set(_parent.get());
×
1626
        self_rc._self.set(Ok(self_rc.clone()));
×
1627
        let _rrc = self_rc._root.get_value().borrow().upgrade();
×
1628
        let _prc = self_rc._parent.get_value().borrow().upgrade();
×
1629
        let _r = _rrc.as_ref().unwrap();
×
1630
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
×
1631
        *self_rc.num_imports.borrow_mut() = t;
×
1632
        *self_rc.imports.borrow_mut() = Vec::new();
×
1633
        {
1634
            let mut _i = 0;
×
1635
            while !_io.is_eof() {
×
NEW
1636
                let t = Self::read_into::<_, Webassembly_Import>(
×
NEW
1637
                    &*_io,
×
NEW
1638
                    Some(self_rc._root.clone()),
×
NEW
1639
                    Some(self_rc._self.clone()),
×
NEW
1640
                )?
×
NEW
1641
                .into();
×
1642
                self_rc.imports.borrow_mut().push(t);
×
1643
                _i += 1;
×
1644
            }
1645
        }
1646
        Ok(())
×
1647
    }
×
1648
}
1649
impl Webassembly_ImportSection {}
1650
impl Webassembly_ImportSection {
1651
    pub fn num_imports(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
×
1652
        self.num_imports.borrow()
×
1653
    }
×
1654
}
1655
impl Webassembly_ImportSection {
1656
    pub fn imports(&self) -> Ref<'_, Vec<OptRc<Webassembly_Import>>> {
×
1657
        self.imports.borrow()
×
1658
    }
×
1659
}
1660
impl Webassembly_ImportSection {
1661
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
1662
        self._io.borrow()
×
1663
    }
×
1664
}
1665

1666
#[derive(Default, Debug, Clone)]
1667
pub struct Webassembly_Limits {
1668
    pub _root: SharedType<Webassembly>,
1669
    pub _parent: SharedType<KStructUnit>,
1670
    pub _self: SharedType<Self>,
1671
    flags: RefCell<u8>,
1672
    min: RefCell<OptRc<VlqBase128Le>>,
1673
    max: RefCell<OptRc<VlqBase128Le>>,
1674
    _io: RefCell<BytesReader>,
1675
}
1676
impl KStruct for Webassembly_Limits {
1677
    type Root = Webassembly;
1678
    type Parent = KStructUnit;
1679

1680
    fn read<S: KStream>(
×
1681
        self_rc: &OptRc<Self>,
×
1682
        _io: &S,
×
1683
        _root: SharedType<Self::Root>,
×
1684
        _parent: SharedType<Self::Parent>,
×
1685
    ) -> KResult<()> {
×
1686
        *self_rc._io.borrow_mut() = _io.clone();
×
1687
        self_rc._root.set(_root.get());
×
1688
        self_rc._parent.set(_parent.get());
×
1689
        self_rc._self.set(Ok(self_rc.clone()));
×
1690
        let _rrc = self_rc._root.get_value().borrow().upgrade();
×
1691
        let _prc = self_rc._parent.get_value().borrow().upgrade();
×
1692
        let _r = _rrc.as_ref().unwrap();
×
1693
        *self_rc.flags.borrow_mut() = _io.read_u1()?.into();
×
NEW
1694
        if !(((*self_rc.flags() as u8) == (0 as u8)) || ((*self_rc.flags() as u8) == (1 as u8))) {
×
NEW
1695
            return Err(KError::ValidationFailed(ValidationFailedError {
×
NEW
1696
                kind: ValidationKind::NotAnyOf,
×
NEW
1697
                src_path: "/types/limits/seq/0".to_string(),
×
NEW
1698
            }));
×
1699
        }
×
1700
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
×
1701
        *self_rc.min.borrow_mut() = t;
×
NEW
1702
        if (*self_rc.flags() as u8) == (1 as u8) {
×
1703
            let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
×
1704
            *self_rc.max.borrow_mut() = t;
×
1705
        }
×
1706
        Ok(())
×
1707
    }
×
1708
}
1709
impl Webassembly_Limits {}
1710
impl Webassembly_Limits {
1711
    pub fn flags(&self) -> Ref<'_, u8> {
×
1712
        self.flags.borrow()
×
1713
    }
×
1714
}
1715
impl Webassembly_Limits {
1716
    pub fn min(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
×
1717
        self.min.borrow()
×
1718
    }
×
1719
}
1720
impl Webassembly_Limits {
1721
    pub fn max(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
×
1722
        self.max.borrow()
×
1723
    }
×
1724
}
1725
impl Webassembly_Limits {
1726
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
1727
        self._io.borrow()
×
1728
    }
×
1729
}
1730

1731
#[derive(Default, Debug, Clone)]
1732
pub struct Webassembly_Local {
1733
    pub _root: SharedType<Webassembly>,
1734
    pub _parent: SharedType<Webassembly_Func>,
1735
    pub _self: SharedType<Self>,
1736
    num_valtype: RefCell<OptRc<VlqBase128Le>>,
1737
    valtype: RefCell<Webassembly_ValTypes>,
1738
    _io: RefCell<BytesReader>,
1739
}
1740
impl KStruct for Webassembly_Local {
1741
    type Root = Webassembly;
1742
    type Parent = Webassembly_Func;
1743

1744
    fn read<S: KStream>(
×
1745
        self_rc: &OptRc<Self>,
×
1746
        _io: &S,
×
1747
        _root: SharedType<Self::Root>,
×
1748
        _parent: SharedType<Self::Parent>,
×
1749
    ) -> KResult<()> {
×
1750
        *self_rc._io.borrow_mut() = _io.clone();
×
1751
        self_rc._root.set(_root.get());
×
1752
        self_rc._parent.set(_parent.get());
×
1753
        self_rc._self.set(Ok(self_rc.clone()));
×
1754
        let _rrc = self_rc._root.get_value().borrow().upgrade();
×
1755
        let _prc = self_rc._parent.get_value().borrow().upgrade();
×
1756
        let _r = _rrc.as_ref().unwrap();
×
1757
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
×
1758
        *self_rc.num_valtype.borrow_mut() = t;
×
1759
        *self_rc.valtype.borrow_mut() = (_io.read_u1()? as i64).try_into()?;
×
1760
        Ok(())
×
1761
    }
×
1762
}
1763
impl Webassembly_Local {}
1764
impl Webassembly_Local {
1765
    pub fn num_valtype(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
×
1766
        self.num_valtype.borrow()
×
1767
    }
×
1768
}
1769
impl Webassembly_Local {
1770
    pub fn valtype(&self) -> Ref<'_, Webassembly_ValTypes> {
×
1771
        self.valtype.borrow()
×
1772
    }
×
1773
}
1774
impl Webassembly_Local {
1775
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
1776
        self._io.borrow()
×
1777
    }
×
1778
}
1779

1780
#[derive(Default, Debug, Clone)]
1781
pub struct Webassembly_Memory {
1782
    pub _root: SharedType<Webassembly>,
1783
    pub _parent: SharedType<KStructUnit>,
1784
    pub _self: SharedType<Self>,
1785
    limits: RefCell<OptRc<Webassembly_Limits>>,
1786
    _io: RefCell<BytesReader>,
1787
}
1788
impl KStruct for Webassembly_Memory {
1789
    type Root = Webassembly;
1790
    type Parent = KStructUnit;
1791

1792
    fn read<S: KStream>(
×
1793
        self_rc: &OptRc<Self>,
×
1794
        _io: &S,
×
1795
        _root: SharedType<Self::Root>,
×
1796
        _parent: SharedType<Self::Parent>,
×
1797
    ) -> KResult<()> {
×
1798
        *self_rc._io.borrow_mut() = _io.clone();
×
1799
        self_rc._root.set(_root.get());
×
1800
        self_rc._parent.set(_parent.get());
×
1801
        self_rc._self.set(Ok(self_rc.clone()));
×
1802
        let _rrc = self_rc._root.get_value().borrow().upgrade();
×
1803
        let _prc = self_rc._parent.get_value().borrow().upgrade();
×
1804
        let _r = _rrc.as_ref().unwrap();
×
NEW
1805
        let t = Self::read_into::<_, Webassembly_Limits>(&*_io, Some(self_rc._root.clone()), None)?
×
NEW
1806
            .into();
×
1807
        *self_rc.limits.borrow_mut() = t;
×
1808
        Ok(())
×
1809
    }
×
1810
}
1811
impl Webassembly_Memory {}
1812
impl Webassembly_Memory {
1813
    pub fn limits(&self) -> Ref<'_, OptRc<Webassembly_Limits>> {
×
1814
        self.limits.borrow()
×
1815
    }
×
1816
}
1817
impl Webassembly_Memory {
1818
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
1819
        self._io.borrow()
×
1820
    }
×
1821
}
1822

1823
/**
1824
 * (id 5) Vector of memories
1825
 * \sa https://www.w3.org/TR/wasm-core-1/#binary-memsec Source
1826
 */
1827

1828
#[derive(Default, Debug, Clone)]
1829
pub struct Webassembly_MemorySection {
1830
    pub _root: SharedType<Webassembly>,
1831
    pub _parent: SharedType<Webassembly_Section>,
1832
    pub _self: SharedType<Self>,
1833
    num_memories: RefCell<OptRc<VlqBase128Le>>,
1834
    memories: RefCell<Vec<OptRc<Webassembly_Memory>>>,
1835
    _io: RefCell<BytesReader>,
1836
}
1837
impl KStruct for Webassembly_MemorySection {
1838
    type Root = Webassembly;
1839
    type Parent = Webassembly_Section;
1840

1841
    fn read<S: KStream>(
×
1842
        self_rc: &OptRc<Self>,
×
1843
        _io: &S,
×
1844
        _root: SharedType<Self::Root>,
×
1845
        _parent: SharedType<Self::Parent>,
×
1846
    ) -> KResult<()> {
×
1847
        *self_rc._io.borrow_mut() = _io.clone();
×
1848
        self_rc._root.set(_root.get());
×
1849
        self_rc._parent.set(_parent.get());
×
1850
        self_rc._self.set(Ok(self_rc.clone()));
×
1851
        let _rrc = self_rc._root.get_value().borrow().upgrade();
×
1852
        let _prc = self_rc._parent.get_value().borrow().upgrade();
×
1853
        let _r = _rrc.as_ref().unwrap();
×
1854
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
×
1855
        *self_rc.num_memories.borrow_mut() = t;
×
1856
        *self_rc.memories.borrow_mut() = Vec::new();
×
1857
        {
1858
            let mut _i = 0;
×
1859
            while !_io.is_eof() {
×
NEW
1860
                let t = Self::read_into::<_, Webassembly_Memory>(
×
NEW
1861
                    &*_io,
×
NEW
1862
                    Some(self_rc._root.clone()),
×
NEW
1863
                    None,
×
NEW
1864
                )?
×
NEW
1865
                .into();
×
1866
                self_rc.memories.borrow_mut().push(t);
×
1867
                _i += 1;
×
1868
            }
1869
        }
1870
        Ok(())
×
1871
    }
×
1872
}
1873
impl Webassembly_MemorySection {}
1874
impl Webassembly_MemorySection {
1875
    pub fn num_memories(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
×
1876
        self.num_memories.borrow()
×
1877
    }
×
1878
}
1879
impl Webassembly_MemorySection {
1880
    pub fn memories(&self) -> Ref<'_, Vec<OptRc<Webassembly_Memory>>> {
×
1881
        self.memories.borrow()
×
1882
    }
×
1883
}
1884
impl Webassembly_MemorySection {
1885
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
1886
        self._io.borrow()
×
1887
    }
×
1888
}
1889

1890
/**
1891
 * UTF-8 encoded character sequence
1892
 * \sa https://www.w3.org/TR/wasm-core-1/#binary-name Source
1893
 */
1894

1895
#[derive(Default, Debug, Clone)]
1896
pub struct Webassembly_Name {
1897
    pub _root: SharedType<Webassembly>,
1898
    pub _parent: SharedType<KStructUnit>,
1899
    pub _self: SharedType<Self>,
1900
    length: RefCell<OptRc<VlqBase128Le>>,
1901
    value: RefCell<String>,
1902
    _io: RefCell<BytesReader>,
1903
}
1904
impl KStruct for Webassembly_Name {
1905
    type Root = Webassembly;
1906
    type Parent = KStructUnit;
1907

1908
    fn read<S: KStream>(
2✔
1909
        self_rc: &OptRc<Self>,
2✔
1910
        _io: &S,
2✔
1911
        _root: SharedType<Self::Root>,
2✔
1912
        _parent: SharedType<Self::Parent>,
2✔
1913
    ) -> KResult<()> {
2✔
1914
        *self_rc._io.borrow_mut() = _io.clone();
2✔
1915
        self_rc._root.set(_root.get());
2✔
1916
        self_rc._parent.set(_parent.get());
2✔
1917
        self_rc._self.set(Ok(self_rc.clone()));
2✔
1918
        let _rrc = self_rc._root.get_value().borrow().upgrade();
2✔
1919
        let _prc = self_rc._parent.get_value().borrow().upgrade();
2✔
1920
        let _r = _rrc.as_ref().unwrap();
2✔
1921
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
2✔
1922
        *self_rc.length.borrow_mut() = t;
2✔
1923
        *self_rc.value.borrow_mut() = bytes_to_str(
2✔
1924
            &_io.read_bytes(*self_rc.length().value()? as usize)?.into(),
2✔
1925
            "UTF-8",
2✔
NEW
1926
        )?;
×
1927
        Ok(())
2✔
1928
    }
2✔
1929
}
1930
impl Webassembly_Name {}
1931
impl Webassembly_Name {
1932
    pub fn length(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
2✔
1933
        self.length.borrow()
2✔
1934
    }
2✔
1935
}
1936
impl Webassembly_Name {
1937
    pub fn value(&self) -> Ref<'_, String> {
×
1938
        self.value.borrow()
×
1939
    }
×
1940
}
1941
impl Webassembly_Name {
1942
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
1943
        self._io.borrow()
×
1944
    }
×
1945
}
1946

1947
/**
1948
 * A specific section as part of a module
1949
 * \sa https://www.w3.org/TR/wasm-core-1/#binary-section Source
1950
 */
1951

1952
#[derive(Default, Debug, Clone)]
1953
pub struct Webassembly_Section {
1954
    pub _root: SharedType<Webassembly>,
1955
    pub _parent: SharedType<Webassembly>,
1956
    pub _self: SharedType<Self>,
1957
    id: RefCell<Webassembly_SectionId>,
1958
    len_content: RefCell<OptRc<VlqBase128Le>>,
1959
    content: RefCell<Option<Webassembly_Section_Content>>,
1960
    _io: RefCell<BytesReader>,
1961
    content_raw: RefCell<Vec<u8>>,
1962
}
1963
#[derive(Debug, Clone)]
1964
pub enum Webassembly_Section_Content {
1965
    Webassembly_GlobalSection(OptRc<Webassembly_GlobalSection>),
1966
    Webassembly_CustomSection(OptRc<Webassembly_CustomSection>),
1967
    Webassembly_MemorySection(OptRc<Webassembly_MemorySection>),
1968
    Webassembly_ElementSection(OptRc<Webassembly_ElementSection>),
1969
    Webassembly_TableSection(OptRc<Webassembly_TableSection>),
1970
    Webassembly_FunctionSection(OptRc<Webassembly_FunctionSection>),
1971
    Webassembly_ExportSection(OptRc<Webassembly_ExportSection>),
1972
    Bytes(Vec<u8>),
1973
    Webassembly_CodeSection(OptRc<Webassembly_CodeSection>),
1974
    Webassembly_ImportSection(OptRc<Webassembly_ImportSection>),
1975
    Webassembly_TypeSection(OptRc<Webassembly_TypeSection>),
1976
    Webassembly_StartSection(OptRc<Webassembly_StartSection>),
1977
    Webassembly_DataSection(OptRc<Webassembly_DataSection>),
1978
}
1979
impl From<&Webassembly_Section_Content> for OptRc<Webassembly_GlobalSection> {
1980
    fn from(v: &Webassembly_Section_Content) -> Self {
×
1981
        if let Webassembly_Section_Content::Webassembly_GlobalSection(x) = v {
×
1982
            return x.clone();
×
1983
        }
×
NEW
1984
        panic!(
×
1985
            "expected Webassembly_Section_Content::Webassembly_GlobalSection, got {:?}",
1986
            v
1987
        )
UNCOV
1988
    }
×
1989
}
1990
impl From<OptRc<Webassembly_GlobalSection>> for Webassembly_Section_Content {
1991
    fn from(v: OptRc<Webassembly_GlobalSection>) -> Self {
×
1992
        Self::Webassembly_GlobalSection(v)
×
1993
    }
×
1994
}
1995
impl From<&Webassembly_Section_Content> for OptRc<Webassembly_CustomSection> {
1996
    fn from(v: &Webassembly_Section_Content) -> Self {
×
1997
        if let Webassembly_Section_Content::Webassembly_CustomSection(x) = v {
×
1998
            return x.clone();
×
1999
        }
×
NEW
2000
        panic!(
×
2001
            "expected Webassembly_Section_Content::Webassembly_CustomSection, got {:?}",
2002
            v
2003
        )
UNCOV
2004
    }
×
2005
}
2006
impl From<OptRc<Webassembly_CustomSection>> for Webassembly_Section_Content {
2007
    fn from(v: OptRc<Webassembly_CustomSection>) -> Self {
×
2008
        Self::Webassembly_CustomSection(v)
×
2009
    }
×
2010
}
2011
impl From<&Webassembly_Section_Content> for OptRc<Webassembly_MemorySection> {
2012
    fn from(v: &Webassembly_Section_Content) -> Self {
×
2013
        if let Webassembly_Section_Content::Webassembly_MemorySection(x) = v {
×
2014
            return x.clone();
×
2015
        }
×
NEW
2016
        panic!(
×
2017
            "expected Webassembly_Section_Content::Webassembly_MemorySection, got {:?}",
2018
            v
2019
        )
UNCOV
2020
    }
×
2021
}
2022
impl From<OptRc<Webassembly_MemorySection>> for Webassembly_Section_Content {
2023
    fn from(v: OptRc<Webassembly_MemorySection>) -> Self {
×
2024
        Self::Webassembly_MemorySection(v)
×
2025
    }
×
2026
}
2027
impl From<&Webassembly_Section_Content> for OptRc<Webassembly_ElementSection> {
2028
    fn from(v: &Webassembly_Section_Content) -> Self {
×
2029
        if let Webassembly_Section_Content::Webassembly_ElementSection(x) = v {
×
2030
            return x.clone();
×
2031
        }
×
NEW
2032
        panic!(
×
2033
            "expected Webassembly_Section_Content::Webassembly_ElementSection, got {:?}",
2034
            v
2035
        )
UNCOV
2036
    }
×
2037
}
2038
impl From<OptRc<Webassembly_ElementSection>> for Webassembly_Section_Content {
2039
    fn from(v: OptRc<Webassembly_ElementSection>) -> Self {
×
2040
        Self::Webassembly_ElementSection(v)
×
2041
    }
×
2042
}
2043
impl From<&Webassembly_Section_Content> for OptRc<Webassembly_TableSection> {
2044
    fn from(v: &Webassembly_Section_Content) -> Self {
×
2045
        if let Webassembly_Section_Content::Webassembly_TableSection(x) = v {
×
2046
            return x.clone();
×
2047
        }
×
NEW
2048
        panic!(
×
2049
            "expected Webassembly_Section_Content::Webassembly_TableSection, got {:?}",
2050
            v
2051
        )
UNCOV
2052
    }
×
2053
}
2054
impl From<OptRc<Webassembly_TableSection>> for Webassembly_Section_Content {
2055
    fn from(v: OptRc<Webassembly_TableSection>) -> Self {
×
2056
        Self::Webassembly_TableSection(v)
×
2057
    }
×
2058
}
2059
impl From<&Webassembly_Section_Content> for OptRc<Webassembly_FunctionSection> {
2060
    fn from(v: &Webassembly_Section_Content) -> Self {
×
2061
        if let Webassembly_Section_Content::Webassembly_FunctionSection(x) = v {
×
2062
            return x.clone();
×
2063
        }
×
NEW
2064
        panic!(
×
2065
            "expected Webassembly_Section_Content::Webassembly_FunctionSection, got {:?}",
2066
            v
2067
        )
UNCOV
2068
    }
×
2069
}
2070
impl From<OptRc<Webassembly_FunctionSection>> for Webassembly_Section_Content {
2071
    fn from(v: OptRc<Webassembly_FunctionSection>) -> Self {
1✔
2072
        Self::Webassembly_FunctionSection(v)
1✔
2073
    }
1✔
2074
}
2075
impl From<&Webassembly_Section_Content> for OptRc<Webassembly_ExportSection> {
2076
    fn from(v: &Webassembly_Section_Content) -> Self {
×
2077
        if let Webassembly_Section_Content::Webassembly_ExportSection(x) = v {
×
2078
            return x.clone();
×
2079
        }
×
NEW
2080
        panic!(
×
2081
            "expected Webassembly_Section_Content::Webassembly_ExportSection, got {:?}",
2082
            v
2083
        )
UNCOV
2084
    }
×
2085
}
2086
impl From<OptRc<Webassembly_ExportSection>> for Webassembly_Section_Content {
2087
    fn from(v: OptRc<Webassembly_ExportSection>) -> Self {
1✔
2088
        Self::Webassembly_ExportSection(v)
1✔
2089
    }
1✔
2090
}
2091
impl From<&Webassembly_Section_Content> for Vec<u8> {
2092
    fn from(v: &Webassembly_Section_Content) -> Self {
×
2093
        if let Webassembly_Section_Content::Bytes(x) = v {
×
2094
            return x.clone();
×
2095
        }
×
2096
        panic!("expected Webassembly_Section_Content::Bytes, got {:?}", v)
×
2097
    }
×
2098
}
2099
impl From<Vec<u8>> for Webassembly_Section_Content {
2100
    fn from(v: Vec<u8>) -> Self {
×
2101
        Self::Bytes(v)
×
2102
    }
×
2103
}
2104
impl From<&Webassembly_Section_Content> for OptRc<Webassembly_CodeSection> {
2105
    fn from(v: &Webassembly_Section_Content) -> Self {
×
2106
        if let Webassembly_Section_Content::Webassembly_CodeSection(x) = v {
×
2107
            return x.clone();
×
2108
        }
×
NEW
2109
        panic!(
×
2110
            "expected Webassembly_Section_Content::Webassembly_CodeSection, got {:?}",
2111
            v
2112
        )
UNCOV
2113
    }
×
2114
}
2115
impl From<OptRc<Webassembly_CodeSection>> for Webassembly_Section_Content {
2116
    fn from(v: OptRc<Webassembly_CodeSection>) -> Self {
1✔
2117
        Self::Webassembly_CodeSection(v)
1✔
2118
    }
1✔
2119
}
2120
impl From<&Webassembly_Section_Content> for OptRc<Webassembly_ImportSection> {
2121
    fn from(v: &Webassembly_Section_Content) -> Self {
×
2122
        if let Webassembly_Section_Content::Webassembly_ImportSection(x) = v {
×
2123
            return x.clone();
×
2124
        }
×
NEW
2125
        panic!(
×
2126
            "expected Webassembly_Section_Content::Webassembly_ImportSection, got {:?}",
2127
            v
2128
        )
UNCOV
2129
    }
×
2130
}
2131
impl From<OptRc<Webassembly_ImportSection>> for Webassembly_Section_Content {
2132
    fn from(v: OptRc<Webassembly_ImportSection>) -> Self {
×
2133
        Self::Webassembly_ImportSection(v)
×
2134
    }
×
2135
}
2136
impl From<&Webassembly_Section_Content> for OptRc<Webassembly_TypeSection> {
2137
    fn from(v: &Webassembly_Section_Content) -> Self {
×
2138
        if let Webassembly_Section_Content::Webassembly_TypeSection(x) = v {
×
2139
            return x.clone();
×
2140
        }
×
NEW
2141
        panic!(
×
2142
            "expected Webassembly_Section_Content::Webassembly_TypeSection, got {:?}",
2143
            v
2144
        )
UNCOV
2145
    }
×
2146
}
2147
impl From<OptRc<Webassembly_TypeSection>> for Webassembly_Section_Content {
2148
    fn from(v: OptRc<Webassembly_TypeSection>) -> Self {
1✔
2149
        Self::Webassembly_TypeSection(v)
1✔
2150
    }
1✔
2151
}
2152
impl From<&Webassembly_Section_Content> for OptRc<Webassembly_StartSection> {
2153
    fn from(v: &Webassembly_Section_Content) -> Self {
×
2154
        if let Webassembly_Section_Content::Webassembly_StartSection(x) = v {
×
2155
            return x.clone();
×
2156
        }
×
NEW
2157
        panic!(
×
2158
            "expected Webassembly_Section_Content::Webassembly_StartSection, got {:?}",
2159
            v
2160
        )
UNCOV
2161
    }
×
2162
}
2163
impl From<OptRc<Webassembly_StartSection>> for Webassembly_Section_Content {
2164
    fn from(v: OptRc<Webassembly_StartSection>) -> Self {
×
2165
        Self::Webassembly_StartSection(v)
×
2166
    }
×
2167
}
2168
impl From<&Webassembly_Section_Content> for OptRc<Webassembly_DataSection> {
2169
    fn from(v: &Webassembly_Section_Content) -> Self {
×
2170
        if let Webassembly_Section_Content::Webassembly_DataSection(x) = v {
×
2171
            return x.clone();
×
2172
        }
×
NEW
2173
        panic!(
×
2174
            "expected Webassembly_Section_Content::Webassembly_DataSection, got {:?}",
2175
            v
2176
        )
UNCOV
2177
    }
×
2178
}
2179
impl From<OptRc<Webassembly_DataSection>> for Webassembly_Section_Content {
2180
    fn from(v: OptRc<Webassembly_DataSection>) -> Self {
×
2181
        Self::Webassembly_DataSection(v)
×
2182
    }
×
2183
}
2184
impl KStruct for Webassembly_Section {
2185
    type Root = Webassembly;
2186
    type Parent = Webassembly;
2187

2188
    fn read<S: KStream>(
4✔
2189
        self_rc: &OptRc<Self>,
4✔
2190
        _io: &S,
4✔
2191
        _root: SharedType<Self::Root>,
4✔
2192
        _parent: SharedType<Self::Parent>,
4✔
2193
    ) -> KResult<()> {
4✔
2194
        *self_rc._io.borrow_mut() = _io.clone();
4✔
2195
        self_rc._root.set(_root.get());
4✔
2196
        self_rc._parent.set(_parent.get());
4✔
2197
        self_rc._self.set(Ok(self_rc.clone()));
4✔
2198
        let _rrc = self_rc._root.get_value().borrow().upgrade();
4✔
2199
        let _prc = self_rc._parent.get_value().borrow().upgrade();
4✔
2200
        let _r = _rrc.as_ref().unwrap();
4✔
2201
        *self_rc.id.borrow_mut() = (_io.read_u1()? as i64).try_into()?;
4✔
2202
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
4✔
2203
        *self_rc.len_content.borrow_mut() = t;
4✔
2204
        match *self_rc.id() {
4✔
2205
            Webassembly_SectionId::CodeSection => {
2206
                *self_rc.content_raw.borrow_mut() = _io
1✔
2207
                    .read_bytes(*self_rc.len_content().value()? as usize)?
1✔
2208
                    .into();
1✔
2209
                let content_raw = self_rc.content_raw.borrow();
1✔
2210
                let _t_content_raw_io = BytesReader::from(content_raw.clone());
1✔
2211
                let t = Self::read_into::<BytesReader, Webassembly_CodeSection>(
1✔
2212
                    &_t_content_raw_io,
1✔
2213
                    Some(self_rc._root.clone()),
1✔
2214
                    Some(self_rc._self.clone()),
1✔
NEW
2215
                )?
×
2216
                .into();
1✔
2217
                *self_rc.content.borrow_mut() = Some(t);
1✔
2218
            }
2219
            Webassembly_SectionId::CustomSection => {
NEW
2220
                *self_rc.content_raw.borrow_mut() = _io
×
NEW
2221
                    .read_bytes(*self_rc.len_content().value()? as usize)?
×
NEW
2222
                    .into();
×
2223
                let content_raw = self_rc.content_raw.borrow();
×
2224
                let _t_content_raw_io = BytesReader::from(content_raw.clone());
×
NEW
2225
                let t = Self::read_into::<BytesReader, Webassembly_CustomSection>(
×
NEW
2226
                    &_t_content_raw_io,
×
NEW
2227
                    Some(self_rc._root.clone()),
×
NEW
2228
                    Some(self_rc._self.clone()),
×
NEW
2229
                )?
×
NEW
2230
                .into();
×
UNCOV
2231
                *self_rc.content.borrow_mut() = Some(t);
×
2232
            }
2233
            Webassembly_SectionId::DataSection => {
NEW
2234
                *self_rc.content_raw.borrow_mut() = _io
×
NEW
2235
                    .read_bytes(*self_rc.len_content().value()? as usize)?
×
NEW
2236
                    .into();
×
2237
                let content_raw = self_rc.content_raw.borrow();
×
2238
                let _t_content_raw_io = BytesReader::from(content_raw.clone());
×
NEW
2239
                let t = Self::read_into::<BytesReader, Webassembly_DataSection>(
×
NEW
2240
                    &_t_content_raw_io,
×
NEW
2241
                    Some(self_rc._root.clone()),
×
NEW
2242
                    Some(self_rc._self.clone()),
×
NEW
2243
                )?
×
NEW
2244
                .into();
×
UNCOV
2245
                *self_rc.content.borrow_mut() = Some(t);
×
2246
            }
2247
            Webassembly_SectionId::ElementSection => {
NEW
2248
                *self_rc.content_raw.borrow_mut() = _io
×
NEW
2249
                    .read_bytes(*self_rc.len_content().value()? as usize)?
×
NEW
2250
                    .into();
×
2251
                let content_raw = self_rc.content_raw.borrow();
×
2252
                let _t_content_raw_io = BytesReader::from(content_raw.clone());
×
NEW
2253
                let t = Self::read_into::<BytesReader, Webassembly_ElementSection>(
×
NEW
2254
                    &_t_content_raw_io,
×
NEW
2255
                    Some(self_rc._root.clone()),
×
NEW
2256
                    Some(self_rc._self.clone()),
×
NEW
2257
                )?
×
NEW
2258
                .into();
×
UNCOV
2259
                *self_rc.content.borrow_mut() = Some(t);
×
2260
            }
2261
            Webassembly_SectionId::ExportSection => {
2262
                *self_rc.content_raw.borrow_mut() = _io
1✔
2263
                    .read_bytes(*self_rc.len_content().value()? as usize)?
1✔
2264
                    .into();
1✔
2265
                let content_raw = self_rc.content_raw.borrow();
1✔
2266
                let _t_content_raw_io = BytesReader::from(content_raw.clone());
1✔
2267
                let t = Self::read_into::<BytesReader, Webassembly_ExportSection>(
1✔
2268
                    &_t_content_raw_io,
1✔
2269
                    Some(self_rc._root.clone()),
1✔
2270
                    Some(self_rc._self.clone()),
1✔
NEW
2271
                )?
×
2272
                .into();
1✔
2273
                *self_rc.content.borrow_mut() = Some(t);
1✔
2274
            }
2275
            Webassembly_SectionId::FunctionSection => {
2276
                *self_rc.content_raw.borrow_mut() = _io
1✔
2277
                    .read_bytes(*self_rc.len_content().value()? as usize)?
1✔
2278
                    .into();
1✔
2279
                let content_raw = self_rc.content_raw.borrow();
1✔
2280
                let _t_content_raw_io = BytesReader::from(content_raw.clone());
1✔
2281
                let t = Self::read_into::<BytesReader, Webassembly_FunctionSection>(
1✔
2282
                    &_t_content_raw_io,
1✔
2283
                    Some(self_rc._root.clone()),
1✔
2284
                    Some(self_rc._self.clone()),
1✔
NEW
2285
                )?
×
2286
                .into();
1✔
2287
                *self_rc.content.borrow_mut() = Some(t);
1✔
2288
            }
2289
            Webassembly_SectionId::GlobalSection => {
NEW
2290
                *self_rc.content_raw.borrow_mut() = _io
×
NEW
2291
                    .read_bytes(*self_rc.len_content().value()? as usize)?
×
NEW
2292
                    .into();
×
2293
                let content_raw = self_rc.content_raw.borrow();
×
2294
                let _t_content_raw_io = BytesReader::from(content_raw.clone());
×
NEW
2295
                let t = Self::read_into::<BytesReader, Webassembly_GlobalSection>(
×
NEW
2296
                    &_t_content_raw_io,
×
NEW
2297
                    Some(self_rc._root.clone()),
×
NEW
2298
                    Some(self_rc._self.clone()),
×
NEW
2299
                )?
×
NEW
2300
                .into();
×
UNCOV
2301
                *self_rc.content.borrow_mut() = Some(t);
×
2302
            }
2303
            Webassembly_SectionId::ImportSection => {
NEW
2304
                *self_rc.content_raw.borrow_mut() = _io
×
NEW
2305
                    .read_bytes(*self_rc.len_content().value()? as usize)?
×
NEW
2306
                    .into();
×
2307
                let content_raw = self_rc.content_raw.borrow();
×
2308
                let _t_content_raw_io = BytesReader::from(content_raw.clone());
×
NEW
2309
                let t = Self::read_into::<BytesReader, Webassembly_ImportSection>(
×
NEW
2310
                    &_t_content_raw_io,
×
NEW
2311
                    Some(self_rc._root.clone()),
×
NEW
2312
                    Some(self_rc._self.clone()),
×
NEW
2313
                )?
×
NEW
2314
                .into();
×
UNCOV
2315
                *self_rc.content.borrow_mut() = Some(t);
×
2316
            }
2317
            Webassembly_SectionId::MemorySection => {
NEW
2318
                *self_rc.content_raw.borrow_mut() = _io
×
NEW
2319
                    .read_bytes(*self_rc.len_content().value()? as usize)?
×
NEW
2320
                    .into();
×
2321
                let content_raw = self_rc.content_raw.borrow();
×
2322
                let _t_content_raw_io = BytesReader::from(content_raw.clone());
×
NEW
2323
                let t = Self::read_into::<BytesReader, Webassembly_MemorySection>(
×
NEW
2324
                    &_t_content_raw_io,
×
NEW
2325
                    Some(self_rc._root.clone()),
×
NEW
2326
                    Some(self_rc._self.clone()),
×
NEW
2327
                )?
×
NEW
2328
                .into();
×
UNCOV
2329
                *self_rc.content.borrow_mut() = Some(t);
×
2330
            }
2331
            Webassembly_SectionId::StartSection => {
NEW
2332
                *self_rc.content_raw.borrow_mut() = _io
×
NEW
2333
                    .read_bytes(*self_rc.len_content().value()? as usize)?
×
NEW
2334
                    .into();
×
2335
                let content_raw = self_rc.content_raw.borrow();
×
2336
                let _t_content_raw_io = BytesReader::from(content_raw.clone());
×
NEW
2337
                let t = Self::read_into::<BytesReader, Webassembly_StartSection>(
×
NEW
2338
                    &_t_content_raw_io,
×
NEW
2339
                    Some(self_rc._root.clone()),
×
NEW
2340
                    Some(self_rc._self.clone()),
×
NEW
2341
                )?
×
NEW
2342
                .into();
×
UNCOV
2343
                *self_rc.content.borrow_mut() = Some(t);
×
2344
            }
2345
            Webassembly_SectionId::TableSection => {
NEW
2346
                *self_rc.content_raw.borrow_mut() = _io
×
NEW
2347
                    .read_bytes(*self_rc.len_content().value()? as usize)?
×
NEW
2348
                    .into();
×
2349
                let content_raw = self_rc.content_raw.borrow();
×
2350
                let _t_content_raw_io = BytesReader::from(content_raw.clone());
×
NEW
2351
                let t = Self::read_into::<BytesReader, Webassembly_TableSection>(
×
NEW
2352
                    &_t_content_raw_io,
×
NEW
2353
                    Some(self_rc._root.clone()),
×
NEW
2354
                    Some(self_rc._self.clone()),
×
NEW
2355
                )?
×
NEW
2356
                .into();
×
UNCOV
2357
                *self_rc.content.borrow_mut() = Some(t);
×
2358
            }
2359
            Webassembly_SectionId::TypeSection => {
2360
                *self_rc.content_raw.borrow_mut() = _io
1✔
2361
                    .read_bytes(*self_rc.len_content().value()? as usize)?
1✔
2362
                    .into();
1✔
2363
                let content_raw = self_rc.content_raw.borrow();
1✔
2364
                let _t_content_raw_io = BytesReader::from(content_raw.clone());
1✔
2365
                let t = Self::read_into::<BytesReader, Webassembly_TypeSection>(
1✔
2366
                    &_t_content_raw_io,
1✔
2367
                    Some(self_rc._root.clone()),
1✔
2368
                    Some(self_rc._self.clone()),
1✔
NEW
2369
                )?
×
2370
                .into();
1✔
2371
                *self_rc.content.borrow_mut() = Some(t);
1✔
2372
            }
2373
            _ => {
NEW
2374
                *self_rc.content.borrow_mut() = Some(
×
NEW
2375
                    _io.read_bytes(*self_rc.len_content().value()? as usize)?
×
NEW
2376
                        .into(),
×
2377
                );
2378
            }
2379
        }
2380
        Ok(())
4✔
2381
    }
4✔
2382
}
2383
impl Webassembly_Section {}
2384

2385
/**
2386
 * Section identifier
2387
 */
2388
impl Webassembly_Section {
2389
    pub fn id(&self) -> Ref<'_, Webassembly_SectionId> {
4✔
2390
        self.id.borrow()
4✔
2391
    }
4✔
2392
}
2393

2394
/**
2395
 * Length of the section content in bytes
2396
 */
2397
impl Webassembly_Section {
2398
    pub fn len_content(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
4✔
2399
        self.len_content.borrow()
4✔
2400
    }
4✔
2401
}
2402

2403
/**
2404
 * Section content
2405
 */
2406
impl Webassembly_Section {
2407
    pub fn content(&self) -> Ref<'_, Option<Webassembly_Section_Content>> {
×
2408
        self.content.borrow()
×
2409
    }
×
2410
}
2411
impl Webassembly_Section {
2412
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
2413
        self._io.borrow()
×
2414
    }
×
2415
}
2416
impl Webassembly_Section {
2417
    pub fn content_raw(&self) -> Ref<'_, Vec<u8>> {
×
2418
        self.content_raw.borrow()
×
2419
    }
×
2420
}
2421

2422
/**
2423
 * (id 8) - Start-function or -component of the module
2424
 * \sa https://www.w3.org/TR/wasm-core-1/#binary-startsec Source
2425
 */
2426

2427
#[derive(Default, Debug, Clone)]
2428
pub struct Webassembly_StartSection {
2429
    pub _root: SharedType<Webassembly>,
2430
    pub _parent: SharedType<Webassembly_Section>,
2431
    pub _self: SharedType<Self>,
2432
    start: RefCell<OptRc<VlqBase128Le>>,
2433
    _io: RefCell<BytesReader>,
2434
}
2435
impl KStruct for Webassembly_StartSection {
2436
    type Root = Webassembly;
2437
    type Parent = Webassembly_Section;
2438

2439
    fn read<S: KStream>(
×
2440
        self_rc: &OptRc<Self>,
×
2441
        _io: &S,
×
2442
        _root: SharedType<Self::Root>,
×
2443
        _parent: SharedType<Self::Parent>,
×
2444
    ) -> KResult<()> {
×
2445
        *self_rc._io.borrow_mut() = _io.clone();
×
2446
        self_rc._root.set(_root.get());
×
2447
        self_rc._parent.set(_parent.get());
×
2448
        self_rc._self.set(Ok(self_rc.clone()));
×
2449
        let _rrc = self_rc._root.get_value().borrow().upgrade();
×
2450
        let _prc = self_rc._parent.get_value().borrow().upgrade();
×
2451
        let _r = _rrc.as_ref().unwrap();
×
2452
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
×
2453
        *self_rc.start.borrow_mut() = t;
×
2454
        Ok(())
×
2455
    }
×
2456
}
2457
impl Webassembly_StartSection {}
2458

2459
/**
2460
 * function index of the start-function
2461
 */
2462
impl Webassembly_StartSection {
2463
    pub fn start(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
×
2464
        self.start.borrow()
×
2465
    }
×
2466
}
2467
impl Webassembly_StartSection {
2468
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
2469
        self._io.borrow()
×
2470
    }
×
2471
}
2472

2473
#[derive(Default, Debug, Clone)]
2474
pub struct Webassembly_Table {
2475
    pub _root: SharedType<Webassembly>,
2476
    pub _parent: SharedType<KStructUnit>,
2477
    pub _self: SharedType<Self>,
2478
    elemtype: RefCell<Webassembly_Types>,
2479
    limits: RefCell<OptRc<Webassembly_Limits>>,
2480
    _io: RefCell<BytesReader>,
2481
}
2482
impl KStruct for Webassembly_Table {
2483
    type Root = Webassembly;
2484
    type Parent = KStructUnit;
2485

2486
    fn read<S: KStream>(
×
2487
        self_rc: &OptRc<Self>,
×
2488
        _io: &S,
×
2489
        _root: SharedType<Self::Root>,
×
2490
        _parent: SharedType<Self::Parent>,
×
2491
    ) -> KResult<()> {
×
2492
        *self_rc._io.borrow_mut() = _io.clone();
×
2493
        self_rc._root.set(_root.get());
×
2494
        self_rc._parent.set(_parent.get());
×
2495
        self_rc._self.set(Ok(self_rc.clone()));
×
2496
        let _rrc = self_rc._root.get_value().borrow().upgrade();
×
2497
        let _prc = self_rc._parent.get_value().borrow().upgrade();
×
2498
        let _r = _rrc.as_ref().unwrap();
×
2499
        *self_rc.elemtype.borrow_mut() = (_io.read_u1()? as i64).try_into()?;
×
2500
        if !(*self_rc.elemtype() == Webassembly_Types::Element) {
×
NEW
2501
            return Err(KError::ValidationFailed(ValidationFailedError {
×
NEW
2502
                kind: ValidationKind::NotEqual,
×
NEW
2503
                src_path: "/types/table/seq/0".to_string(),
×
NEW
2504
            }));
×
2505
        }
×
NEW
2506
        let t = Self::read_into::<_, Webassembly_Limits>(&*_io, Some(self_rc._root.clone()), None)?
×
NEW
2507
            .into();
×
2508
        *self_rc.limits.borrow_mut() = t;
×
2509
        Ok(())
×
2510
    }
×
2511
}
2512
impl Webassembly_Table {}
2513
impl Webassembly_Table {
2514
    pub fn elemtype(&self) -> Ref<'_, Webassembly_Types> {
×
2515
        self.elemtype.borrow()
×
2516
    }
×
2517
}
2518
impl Webassembly_Table {
2519
    pub fn limits(&self) -> Ref<'_, OptRc<Webassembly_Limits>> {
×
2520
        self.limits.borrow()
×
2521
    }
×
2522
}
2523
impl Webassembly_Table {
2524
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
2525
        self._io.borrow()
×
2526
    }
×
2527
}
2528

2529
/**
2530
 * (id 4) Vector of tables
2531
 * \sa https://www.w3.org/TR/wasm-core-1/#binary-tablesec Source
2532
 */
2533

2534
#[derive(Default, Debug, Clone)]
2535
pub struct Webassembly_TableSection {
2536
    pub _root: SharedType<Webassembly>,
2537
    pub _parent: SharedType<Webassembly_Section>,
2538
    pub _self: SharedType<Self>,
2539
    num_tables: RefCell<OptRc<VlqBase128Le>>,
2540
    tables: RefCell<Vec<OptRc<Webassembly_Table>>>,
2541
    _io: RefCell<BytesReader>,
2542
}
2543
impl KStruct for Webassembly_TableSection {
2544
    type Root = Webassembly;
2545
    type Parent = Webassembly_Section;
2546

2547
    fn read<S: KStream>(
×
2548
        self_rc: &OptRc<Self>,
×
2549
        _io: &S,
×
2550
        _root: SharedType<Self::Root>,
×
2551
        _parent: SharedType<Self::Parent>,
×
2552
    ) -> KResult<()> {
×
2553
        *self_rc._io.borrow_mut() = _io.clone();
×
2554
        self_rc._root.set(_root.get());
×
2555
        self_rc._parent.set(_parent.get());
×
2556
        self_rc._self.set(Ok(self_rc.clone()));
×
2557
        let _rrc = self_rc._root.get_value().borrow().upgrade();
×
2558
        let _prc = self_rc._parent.get_value().borrow().upgrade();
×
2559
        let _r = _rrc.as_ref().unwrap();
×
2560
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
×
2561
        *self_rc.num_tables.borrow_mut() = t;
×
2562
        *self_rc.tables.borrow_mut() = Vec::new();
×
2563
        {
2564
            let mut _i = 0;
×
2565
            while !_io.is_eof() {
×
NEW
2566
                let t = Self::read_into::<_, Webassembly_Table>(
×
NEW
2567
                    &*_io,
×
NEW
2568
                    Some(self_rc._root.clone()),
×
NEW
2569
                    None,
×
NEW
2570
                )?
×
NEW
2571
                .into();
×
2572
                self_rc.tables.borrow_mut().push(t);
×
2573
                _i += 1;
×
2574
            }
2575
        }
2576
        Ok(())
×
2577
    }
×
2578
}
2579
impl Webassembly_TableSection {}
2580
impl Webassembly_TableSection {
2581
    pub fn num_tables(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
×
2582
        self.num_tables.borrow()
×
2583
    }
×
2584
}
2585
impl Webassembly_TableSection {
2586
    pub fn tables(&self) -> Ref<'_, Vec<OptRc<Webassembly_Table>>> {
×
2587
        self.tables.borrow()
×
2588
    }
×
2589
}
2590
impl Webassembly_TableSection {
2591
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
2592
        self._io.borrow()
×
2593
    }
×
2594
}
2595

2596
/**
2597
 * (id 1) - A vector of function types
2598
 * \sa https://www.w3.org/TR/wasm-core-1/#binary-typesec Source
2599
 */
2600

2601
#[derive(Default, Debug, Clone)]
2602
pub struct Webassembly_TypeSection {
2603
    pub _root: SharedType<Webassembly>,
2604
    pub _parent: SharedType<Webassembly_Section>,
2605
    pub _self: SharedType<Self>,
2606
    num_functypes: RefCell<OptRc<VlqBase128Le>>,
2607
    functypes: RefCell<Vec<OptRc<Webassembly_Functype>>>,
2608
    _io: RefCell<BytesReader>,
2609
}
2610
impl KStruct for Webassembly_TypeSection {
2611
    type Root = Webassembly;
2612
    type Parent = Webassembly_Section;
2613

2614
    fn read<S: KStream>(
1✔
2615
        self_rc: &OptRc<Self>,
1✔
2616
        _io: &S,
1✔
2617
        _root: SharedType<Self::Root>,
1✔
2618
        _parent: SharedType<Self::Parent>,
1✔
2619
    ) -> KResult<()> {
1✔
2620
        *self_rc._io.borrow_mut() = _io.clone();
1✔
2621
        self_rc._root.set(_root.get());
1✔
2622
        self_rc._parent.set(_parent.get());
1✔
2623
        self_rc._self.set(Ok(self_rc.clone()));
1✔
2624
        let _rrc = self_rc._root.get_value().borrow().upgrade();
1✔
2625
        let _prc = self_rc._parent.get_value().borrow().upgrade();
1✔
2626
        let _r = _rrc.as_ref().unwrap();
1✔
2627
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
1✔
2628
        *self_rc.num_functypes.borrow_mut() = t;
1✔
2629
        *self_rc.functypes.borrow_mut() = Vec::new();
1✔
2630
        {
2631
            let mut _i = 0;
1✔
2632
            while !_io.is_eof() {
2✔
2633
                let t = Self::read_into::<_, Webassembly_Functype>(
1✔
2634
                    &*_io,
1✔
2635
                    Some(self_rc._root.clone()),
1✔
2636
                    Some(self_rc._self.clone()),
1✔
NEW
2637
                )?
×
2638
                .into();
1✔
2639
                self_rc.functypes.borrow_mut().push(t);
1✔
2640
                _i += 1;
1✔
2641
            }
2642
        }
2643
        Ok(())
1✔
2644
    }
1✔
2645
}
2646
impl Webassembly_TypeSection {}
2647
impl Webassembly_TypeSection {
2648
    pub fn num_functypes(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
×
2649
        self.num_functypes.borrow()
×
2650
    }
×
2651
}
2652
impl Webassembly_TypeSection {
2653
    pub fn functypes(&self) -> Ref<'_, Vec<OptRc<Webassembly_Functype>>> {
×
2654
        self.functypes.borrow()
×
2655
    }
×
2656
}
2657
impl Webassembly_TypeSection {
2658
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
2659
        self._io.borrow()
×
2660
    }
×
2661
}
2662

2663
#[derive(Default, Debug, Clone)]
2664
pub struct Webassembly_VecValtype {
2665
    pub _root: SharedType<Webassembly>,
2666
    pub _parent: SharedType<Webassembly_Functype>,
2667
    pub _self: SharedType<Self>,
2668
    num_types: RefCell<OptRc<VlqBase128Le>>,
2669
    valtype: RefCell<Vec<Webassembly_ValTypes>>,
2670
    _io: RefCell<BytesReader>,
2671
}
2672
impl KStruct for Webassembly_VecValtype {
2673
    type Root = Webassembly;
2674
    type Parent = Webassembly_Functype;
2675

2676
    fn read<S: KStream>(
2✔
2677
        self_rc: &OptRc<Self>,
2✔
2678
        _io: &S,
2✔
2679
        _root: SharedType<Self::Root>,
2✔
2680
        _parent: SharedType<Self::Parent>,
2✔
2681
    ) -> KResult<()> {
2✔
2682
        *self_rc._io.borrow_mut() = _io.clone();
2✔
2683
        self_rc._root.set(_root.get());
2✔
2684
        self_rc._parent.set(_parent.get());
2✔
2685
        self_rc._self.set(Ok(self_rc.clone()));
2✔
2686
        let _rrc = self_rc._root.get_value().borrow().upgrade();
2✔
2687
        let _prc = self_rc._parent.get_value().borrow().upgrade();
2✔
2688
        let _r = _rrc.as_ref().unwrap();
2✔
2689
        let t = Self::read_into::<_, VlqBase128Le>(&*_io, None, None)?.into();
2✔
2690
        *self_rc.num_types.borrow_mut() = t;
2✔
2691
        *self_rc.valtype.borrow_mut() = Vec::new();
2✔
2692
        let l_valtype = *self_rc.num_types().value()?;
2✔
2693
        for _i in 0..l_valtype {
2✔
NEW
2694
            self_rc
×
NEW
2695
                .valtype
×
NEW
2696
                .borrow_mut()
×
NEW
2697
                .push((_io.read_u1()? as i64).try_into()?);
×
2698
        }
2699
        Ok(())
2✔
2700
    }
2✔
2701
}
2702
impl Webassembly_VecValtype {}
2703
impl Webassembly_VecValtype {
2704
    pub fn num_types(&self) -> Ref<'_, OptRc<VlqBase128Le>> {
2✔
2705
        self.num_types.borrow()
2✔
2706
    }
2✔
2707
}
2708

2709
/**
2710
 * Value Types
2711
 * \sa https://www.w3.org/TR/wasm-core-1/#binary-valtype Source
2712
 */
2713
impl Webassembly_VecValtype {
2714
    pub fn valtype(&self) -> Ref<'_, Vec<Webassembly_ValTypes>> {
×
2715
        self.valtype.borrow()
×
2716
    }
×
2717
}
2718
impl Webassembly_VecValtype {
2719
    pub fn _io(&self) -> Ref<'_, BytesReader> {
×
2720
        self._io.borrow()
×
2721
    }
×
2722
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc