mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-05-31 00:21:35 +00:00
Move stack with limit utils to runner.rs
This commit is contained in:
parent
604374442d
commit
97b74ed10e
@ -139,7 +139,6 @@ mod memory;
|
|||||||
mod module;
|
mod module;
|
||||||
mod program;
|
mod program;
|
||||||
mod runner;
|
mod runner;
|
||||||
mod stack;
|
|
||||||
mod table;
|
mod table;
|
||||||
mod value;
|
mod value;
|
||||||
mod host;
|
mod host;
|
||||||
|
@ -1164,3 +1164,29 @@ pub fn prepare_function_args(function_type: &FunctionType, caller_stack: &mut St
|
|||||||
args.reverse();
|
args.reverse();
|
||||||
Ok(args)
|
Ok(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl StackWithLimit<RuntimeValue> {
|
||||||
|
fn pop_as<T>(&mut self) -> Result<T, Error>
|
||||||
|
where
|
||||||
|
RuntimeValue: TryInto<T, Error>,
|
||||||
|
{
|
||||||
|
let value = self.pop()?;
|
||||||
|
TryInto::try_into(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn pop_pair_as<T>(&mut self) -> Result<(T, T), Error>
|
||||||
|
where
|
||||||
|
RuntimeValue: TryInto<T, Error>,
|
||||||
|
{
|
||||||
|
let right = self.pop_as()?;
|
||||||
|
let left = self.pop_as()?;
|
||||||
|
Ok((left, right))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn pop_triple(&mut self) -> Result<(RuntimeValue, RuntimeValue, RuntimeValue), Error> {
|
||||||
|
let right = self.pop()?;
|
||||||
|
let mid = self.pop()?;
|
||||||
|
let left = self.pop()?;
|
||||||
|
Ok((left, mid, right))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
use interpreter::{Error as InterpreterError};
|
|
||||||
use interpreter::value::{RuntimeValue, TryInto};
|
|
||||||
use common::stack::StackWithLimit;
|
|
||||||
|
|
||||||
impl StackWithLimit<RuntimeValue> {
|
|
||||||
pub fn pop_as<T>(&mut self) -> Result<T, InterpreterError>
|
|
||||||
where
|
|
||||||
RuntimeValue: TryInto<T, InterpreterError>,
|
|
||||||
{
|
|
||||||
let value = self.pop()?;
|
|
||||||
TryInto::try_into(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn pop_pair_as<T>(&mut self) -> Result<(T, T), InterpreterError>
|
|
||||||
where
|
|
||||||
RuntimeValue: TryInto<T, InterpreterError>,
|
|
||||||
{
|
|
||||||
let right = self.pop_as()?;
|
|
||||||
let left = self.pop_as()?;
|
|
||||||
Ok((left, right))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn pop_triple(&mut self) -> Result<(RuntimeValue, RuntimeValue, RuntimeValue), InterpreterError> {
|
|
||||||
let right = self.pop()?;
|
|
||||||
let mid = self.pop()?;
|
|
||||||
let left = self.pop()?;
|
|
||||||
Ok((left, mid, right))
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user