doc(deprecated) Document more API between the old and the new one.

This commit is contained in:
Ivan Enderlin
2020-07-03 15:54:31 +02:00
parent 9a7c8a7dd1
commit fe0ed40b5c
28 changed files with 215 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
struct ExportDescriptor {
name: String,
ty: ExternDescriptor,
}

View File

@@ -0,0 +1,7 @@
struct FuncSig {}
impl FuncSig {
fn new<Params, Returns>(params: Params, returns: Returns) -> Self;
fn params(&self) -> &[Type];
fn results(&self) -> &[Type];
}

View File

@@ -0,0 +1,4 @@
struct GlobalDescriptor {
mutable: bool,
ty: Type,
}

View File

@@ -0,0 +1,15 @@
enum GlobalInit {
I32Const(i32),
I64Const(i64),
F32Const(f32),
F64Const(f64),
V128Const(V128),
GetGlobal(GlobalIndex),
RefNullConst,
RefFunc(FunctionIndex),
}
impl GlobalInit {
fn from_value<T>(value: Value<T>) -> Self;
fn to_value<T>(&self) -> Value<T>;
}

View File

@@ -0,0 +1,3 @@
trait HostFunction<Args, Rets, Kind, T> {
fn function_body_ptr(self) -> *const VMFunctionBody;
}

View File

@@ -0,0 +1,5 @@
struct ImportDescriptor {
module: String,
name: String,
ty: ExternDescriptor,
}

View File

@@ -0,0 +1,5 @@
struct MemoryDescriptor {
minimum: Pages,
maximum: Option<Pages>,
shared: bool,
}

View File

@@ -0,0 +1,4 @@
enum MemoryType {
Dynamic,
Static { bound: Pages },
}

View File

@@ -0,0 +1,23 @@
struct ModuleInfo {
custom_sections: IndexMap<String, CustomSectionIndex>,
custom_sections_data: PrimaryMap<CustomSectionIndex, Arc<[u8]>>,
exports: IndexMap<String, ExportIndex>,
func_names: HashMap<FunctionIndex, String>,
functions: PrimaryMap<FunctionIndex, SignatureIndex>,
global_initializers: PrimaryMap<LocalGlobalIndex, GlobalInit>,
globals: PrimaryMap<GlobalIndex, GlobalType>,
id: ModuleId,
imports: IndexMap<(String, String, u32), ImportIndex>,
memories: PrimaryMap<MemoryIndex, MemoryType>,
name: Option<String>,
num_imported_funcs: usize,
num_imported_globals: usize,
num_imported_memories: usize,
num_imported_tables: usize,
passive_data: HashMap<DataIndex, Arc<[u8]>>,
passive_elements: HashMap<ElemIndex, Box<[FunctionIndex]>>,
signatures: PrimaryMap<SignatureIndex, FunctionType>,
start_func: Option<FunctionIndex>,
table_elements: Vec<TableElements>,
tables: PrimaryMap<TableIndex, TableType>,
}

View File

@@ -0,0 +1,10 @@
trait NativeWasmType {
type Abi: Copy + std::fmt::Debug;
const WASM_TYPE: Type;
fn from_binary(binary: i128) -> Self;
fn to_binary(self) -> i128;
fn into_abi(self) -> Self::Abi;
fn from_abi(abi: Self::Abi) -> Self;
fn to_value<T>(self) -> Value<T>;
}

View File

@@ -0,0 +1,10 @@
struct Table {}
impl Table {
fn new(desc: TableDescriptor, initial_value: Value) -> Result<Self, RuntimeError>;
fn descriptor(&self) -> TableDescriptor;
fn set(&self, index: u32, element: Value) -> Result<(), RuntimeError>;
fn get(&self, index: u32) -> Option<Value>;
fn size(&self) -> u32;
fn grow(&self, delta: u32, initial_value: Value) -> Result<u32, RuntimeError>;
}

View File

@@ -0,0 +1,9 @@
struct TableDescriptor {
ty: Type,
minimum: u32,
maximum: Option<u32>,
}
impl TableDescriptor {
fn new(ty: Type, minimum: u32, maximum: Option<u32>) -> Self;
}

View File

@@ -0,0 +1,6 @@
trait WasmExternType {
type Native: NativeWasmType;
fn from_native(native: Self::Native) -> Self;
fn to_native(self) -> Self::Native;
}

View File

@@ -0,0 +1,12 @@
trait WasmTypeList {
type CStruct;
type Array: AsMut<[i128]>;
fn from_array(array: Self::Array) -> Self;
fn empty_array(self) -> Self::Array;
fn from_c_struct(c_struct: Self::CStruct) -> Self;
fn into_c_struct(self) -> Self::CStruct;
fn wasm_types() -> &'static [Type];
fn from_slice(slice: &[i128]) -> Result<Self, TryFromSliceError>;
fn into_array(self) -> Self::Array;
}

View File

@@ -0,0 +1,4 @@
struct ExportDescriptor<'a> {
name: &'a str,
ty: ExternDescriptor,
}

View File

@@ -0,0 +1,8 @@
struct FuncSig {}
impl FuncSig {
fn new<Params, Returns>(params: Params, returns: Returns) -> Self;
fn params(&self) -> &[Type];
fn returns(&self) -> &[Type];
fn check_param_value_types(&self, params: &[Value]) -> bool;
}

View File

@@ -0,0 +1,4 @@
struct GlobalDescriptor {
mutable: bool,
ty: Type,
}

View File

@@ -0,0 +1,4 @@
struct GlobalInit {
desc: GlobalDescriptor,
init: Initializer,
}

View File

@@ -0,0 +1,3 @@
trait HostFunction<Kind, Args, Rets> {
fn to_raw(self) -> (NonNull<Func>, Option<NonNull<FuncEnv>>);
}

View File

@@ -0,0 +1,5 @@
struct ImportDescriptor {
namespace: String,
name: String,
ty: ExternDescriptor,
}

View File

@@ -0,0 +1,6 @@
struct MemoryDescriptor {
minimum: Pages,
maximum: Option<Pages>,
shared: bool,
memory_type: MemoryType,
}

View File

@@ -0,0 +1,5 @@
enum MemoryType {
Dynamic,
Static,
SharedStatic,
}

View File

@@ -0,0 +1,21 @@
struct ModuleInfo {
backend: String,
custom_sections: HashMap<String, Vec<Vec<u8>>>,
data_initializers: Vec<DataInitializer>,
elem_initializers: Vec<TableInitializer>,
em_symbol_map: Option<HashMap<u32, String>>,
exports: IndexMap<String, ExportIndex>,
func_assoc: Map<FuncIndex, SigIndex>,
generate_debug_info: bool,
globals: Map<LocalGlobalIndex, GlobalInit>,
imported_functions: Map<ImportedFuncIndex, ImportName>,
imported_globals: Map<ImportedGlobalIndex, (ImportName, GlobalDescriptor)>,
imported_memories: Map<ImportedMemoryIndex, (ImportName, MemoryDescriptor)>,
imported_tables: Map<ImportedTableIndex, (ImportName, TableDescriptor)>,
memories: Map<LocalMemoryIndex, MemoryDescripto>,
name_table: StringTable<NameIndex>,
namespace_table: StringTable<NamespaceIndex>,
signatures: Map<SigIndex, FuncSig>,
start_func: Option<FuncIndex>,
tables: Map<LocalTableIndex, TableDescriptor>,
}

View File

@@ -0,0 +1,6 @@
trait NativeWasmType {
const TYPE: Type;
fn from_binary(bits: u64) -> Self;
fn to_binary(self) -> u64;
}

View File

@@ -0,0 +1,10 @@
struct Table {}
impl Table {
fn new(desc: TableDescriptor) -> Result<Self, CreationError>;
fn descriptor(&self) -> TableDescriptor;
fn set<T: StorableInTable>(&self, index: u32, element: T) -> Result<(), TableAccessError>;
fn size(&self) -> u32;
fn grow(&self, delta: u32) -> Result<u32, GrowError>;
fn vm_local_table(&mut self) -> *mut LocalTable;
}

View File

@@ -0,0 +1,5 @@
struct TableDescriptor {
element: ElementType,
minimum: u32,
maximum: Option<u32>,
}

View File

@@ -0,0 +1,6 @@
trait WasmExternType {
type Native: NativeWasmType;
fn from_native(native: Self::Native) -> Self;
fn to_native(self) -> Self::Native;
}

View File

@@ -0,0 +1,11 @@
trait WasmTypeList {
type CStruct;
type RetArray: AsMut<[u64]>;
fn from_ret_array(array: Self::RetArray) -> Self;
fn empty_ret_array() -> Self::RetArray;
fn from_c_struct(c_struct: Self::CStruct) -> Self;
fn into_c_struct(self) -> Self::CStruct;
fn types() -> &'static [Type];
fn call<Rets>(self, f: NonNull<Func>, wasm: Wasm, ctx: *mut Ctx) -> Result<Rets, RuntimeError>;
}