|
1 | 1 | #![allow(clippy::from_over_into)] |
2 | 2 |
|
3 | | -use { |
4 | | - wasm_encoder::{ |
5 | | - EntityType, ExportKind, GlobalType, HeapType, MemoryType, RefType, TableType, TagKind, |
6 | | - TagType, ValType, |
7 | | - }, |
8 | | - wasmparser::{ExternalKind, TypeRef}, |
| 3 | +use wasm_encoder::{ |
| 4 | + AbstractHeapType, EntityType, ExportKind, GlobalType, HeapType, MemoryType, RefType, TableType, |
| 5 | + TagKind, TagType, ValType, |
9 | 6 | }; |
10 | 7 |
|
11 | 8 | struct IntoHeapType(wasmparser::HeapType); |
12 | 9 |
|
13 | 10 | impl Into<HeapType> for IntoHeapType { |
14 | 11 | fn into(self) -> HeapType { |
15 | 12 | match self.0 { |
16 | | - wasmparser::HeapType::Func => HeapType::Func, |
17 | | - wasmparser::HeapType::Extern => HeapType::Extern, |
18 | 13 | wasmparser::HeapType::Concrete(_) => { |
19 | 14 | panic!("user-defined heap types not yet supported") |
20 | 15 | } |
21 | | - wasmparser::HeapType::Any => HeapType::Any, |
22 | | - wasmparser::HeapType::None => HeapType::None, |
23 | | - wasmparser::HeapType::NoExtern => HeapType::NoExtern, |
24 | | - wasmparser::HeapType::NoFunc => HeapType::NoFunc, |
25 | | - wasmparser::HeapType::Eq => HeapType::Eq, |
26 | | - wasmparser::HeapType::Struct => HeapType::Struct, |
27 | | - wasmparser::HeapType::Array => HeapType::Array, |
28 | | - wasmparser::HeapType::I31 => HeapType::I31, |
29 | | - wasmparser::HeapType::Exn => HeapType::Exn, |
| 16 | + wasmparser::HeapType::Abstract { ty, shared } => { |
| 17 | + let ty = match ty { |
| 18 | + wasmparser::AbstractHeapType::Func => AbstractHeapType::Func, |
| 19 | + wasmparser::AbstractHeapType::Extern => AbstractHeapType::Extern, |
| 20 | + wasmparser::AbstractHeapType::Any => AbstractHeapType::Any, |
| 21 | + wasmparser::AbstractHeapType::None => AbstractHeapType::None, |
| 22 | + wasmparser::AbstractHeapType::NoExtern => AbstractHeapType::NoExtern, |
| 23 | + wasmparser::AbstractHeapType::NoFunc => AbstractHeapType::NoFunc, |
| 24 | + wasmparser::AbstractHeapType::Eq => AbstractHeapType::Eq, |
| 25 | + wasmparser::AbstractHeapType::Struct => AbstractHeapType::Struct, |
| 26 | + wasmparser::AbstractHeapType::Array => AbstractHeapType::Array, |
| 27 | + wasmparser::AbstractHeapType::I31 => AbstractHeapType::I31, |
| 28 | + wasmparser::AbstractHeapType::Exn => AbstractHeapType::Exn, |
| 29 | + wasmparser::AbstractHeapType::NoExn => AbstractHeapType::NoExn, |
| 30 | + }; |
| 31 | + HeapType::Abstract { shared, ty } |
| 32 | + } |
30 | 33 | } |
31 | 34 | } |
32 | 35 | } |
@@ -67,45 +70,49 @@ impl Into<TagKind> for IntoTagKind { |
67 | 70 | } |
68 | 71 | } |
69 | 72 |
|
70 | | -pub struct IntoEntityType(pub TypeRef); |
| 73 | +pub struct IntoEntityType(pub wasmparser::TypeRef); |
71 | 74 |
|
72 | 75 | impl Into<EntityType> for IntoEntityType { |
73 | 76 | fn into(self) -> EntityType { |
74 | 77 | match self.0 { |
75 | | - TypeRef::Func(index) => EntityType::Function(index), |
76 | | - TypeRef::Table(ty) => EntityType::Table(TableType { |
| 78 | + wasmparser::TypeRef::Func(index) => EntityType::Function(index), |
| 79 | + wasmparser::TypeRef::Table(ty) => EntityType::Table(TableType { |
77 | 80 | element_type: IntoRefType(ty.element_type).into(), |
78 | 81 | minimum: ty.initial, |
79 | 82 | maximum: ty.maximum, |
| 83 | + table64: ty.table64, |
| 84 | + shared: ty.shared, |
80 | 85 | }), |
81 | | - TypeRef::Memory(ty) => EntityType::Memory(MemoryType { |
| 86 | + wasmparser::TypeRef::Memory(ty) => EntityType::Memory(MemoryType { |
82 | 87 | minimum: ty.initial, |
83 | 88 | maximum: ty.maximum, |
84 | 89 | memory64: ty.memory64, |
85 | 90 | shared: ty.shared, |
| 91 | + page_size_log2: ty.page_size_log2, |
86 | 92 | }), |
87 | | - TypeRef::Global(ty) => EntityType::Global(GlobalType { |
| 93 | + wasmparser::TypeRef::Global(ty) => EntityType::Global(GlobalType { |
88 | 94 | val_type: IntoValType(ty.content_type).into(), |
89 | 95 | mutable: ty.mutable, |
| 96 | + shared: ty.shared, |
90 | 97 | }), |
91 | | - TypeRef::Tag(ty) => EntityType::Tag(TagType { |
| 98 | + wasmparser::TypeRef::Tag(ty) => EntityType::Tag(TagType { |
92 | 99 | kind: IntoTagKind(ty.kind).into(), |
93 | 100 | func_type_idx: ty.func_type_idx, |
94 | 101 | }), |
95 | 102 | } |
96 | 103 | } |
97 | 104 | } |
98 | 105 |
|
99 | | -pub struct IntoExportKind(pub ExternalKind); |
| 106 | +pub struct IntoExportKind(pub wasmparser::ExternalKind); |
100 | 107 |
|
101 | 108 | impl Into<ExportKind> for IntoExportKind { |
102 | 109 | fn into(self) -> ExportKind { |
103 | 110 | match self.0 { |
104 | | - ExternalKind::Func => ExportKind::Func, |
105 | | - ExternalKind::Table => ExportKind::Table, |
106 | | - ExternalKind::Memory => ExportKind::Memory, |
107 | | - ExternalKind::Global => ExportKind::Global, |
108 | | - ExternalKind::Tag => ExportKind::Tag, |
| 111 | + wasmparser::ExternalKind::Func => ExportKind::Func, |
| 112 | + wasmparser::ExternalKind::Table => ExportKind::Table, |
| 113 | + wasmparser::ExternalKind::Memory => ExportKind::Memory, |
| 114 | + wasmparser::ExternalKind::Global => ExportKind::Global, |
| 115 | + wasmparser::ExternalKind::Tag => ExportKind::Tag, |
109 | 116 | } |
110 | 117 | } |
111 | 118 | } |
0 commit comments