Skip to content

Commit

Permalink
chore(interface-types) Move the instruction.rs module in `instructi…
Browse files Browse the repository at this point in the history
…ons/mod.rs`.
  • Loading branch information
Hywan committed Mar 26, 2020
1 parent 734795c commit 3c02c50
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 131 deletions.
125 changes: 0 additions & 125 deletions lib/interface-types/src/interpreter/instruction.rs

This file was deleted.

129 changes: 125 additions & 4 deletions lib/interface-types/src/interpreter/instructions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,138 @@ mod strings;

use crate::{
errors::{InstructionError, InstructionErrorKind, InstructionResult, WasmValueNativeCastError},
interpreter::{
wasm::values::{InterfaceValue, NativeType},
Instruction,
},
interpreter::wasm::values::{InterfaceValue, NativeType},
};
pub(crate) use argument_get::argument_get;
pub(crate) use call_core::call_core;
pub(crate) use numbers::*;
use std::convert::TryFrom;
pub(crate) use strings::*;

/// Represents all the possible WIT instructions.
#[derive(PartialEq, Debug, Clone, Copy)]
pub enum Instruction {
/// The `arg.get` instruction.
ArgumentGet {
/// The argument index.
index: u32,
},

/// The `call-core` instruction.
CallCore {
/// The function index.
function_index: usize,
},

/// The `s8.from_i32` instruction.
S8FromI32,

/// The `s8.from_i64` instruction.
S8FromI64,

/// The `s16.from_i32` instruction.
S16FromI32,

/// The `s16.from_i64` instruction.
S16FromI64,

/// The `s32.from_i32` instruction.
S32FromI32,

/// The `s32.from_i64` instruction.
S32FromI64,

/// The `s64.from_i32` instruction.
S64FromI32,

/// The `s64.from_i64` instruction.
S64FromI64,

/// The `i32.from_s8` instruction.
I32FromS8,

/// The `i32.from_s16` instruction.
I32FromS16,

/// The `i32.from_s32` instruction.
I32FromS32,

/// The `i32.from_s64` instruction.
I32FromS64,

/// The `i64.from_s8` instruction.
I64FromS8,

/// The `i64.from_s16` instruction.
I64FromS16,

/// The `i64.from_s32` instruction.
I64FromS32,

/// The `i64.from_s64` instruction.
I64FromS64,

/// The `u8.from_i32` instruction.
U8FromI32,

/// The `u8.from_i64` instruction.
U8FromI64,

/// The `u16.from_i32` instruction.
U16FromI32,

/// The `u16.from_i64` instruction.
U16FromI64,

/// The `u32.from_i32` instruction.
U32FromI32,

/// The `u32.from_i64` instruction.
U32FromI64,

/// The `u64.from_i32` instruction.
U64FromI32,

/// The `u64.from_i64` instruction.
U64FromI64,

/// The `i32.from_u8` instruction.
I32FromU8,

/// The `i32.from_u16` instruction.
I32FromU16,

/// The `i32.from_u32` instruction.
I32FromU32,

/// The `i32.from_u64` instruction.
I32FromU64,

/// The `i64.from_u8` instruction.
I64FromU8,

/// The `i64.from_u16` instruction.
I64FromU16,

/// The `i64.from_u32` instruction.
I64FromU32,

/// The `i64.from_u64` instruction.
I64FromU64,

/// The `string.lift_memory` instruction.
StringLiftMemory,

/// The `string.lower_memory` instruction.
StringLowerMemory {
/// The allocator function index.
allocator_index: u32,
},

/// The `string.size` instruction.
StringSize,
}

/// Just a short helper to map the error of a cast from an
/// `InterfaceValue` to a native value.
pub(crate) fn to_native<'a, T>(
Expand Down
3 changes: 1 addition & 2 deletions lib/interface-types/src/interpreter/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
//! A stack-based interpreter to execute instructions of WIT adapters.
mod instruction;
mod instructions;
pub mod stack;
pub mod wasm;

use crate::errors::{InstructionResult, InterpreterResult};
pub use instruction::Instruction;
pub use instructions::Instruction;
use stack::Stack;
use std::{convert::TryFrom, marker::PhantomData};
use wasm::values::InterfaceValue;
Expand Down

0 comments on commit 3c02c50

Please sign in to comment.