mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-06-12 06:21:40 +00:00
Cleaning
This commit is contained in:
@ -1,14 +1,6 @@
|
||||
use elements::{InitExpr, Opcode, Type, FunctionType, Internal, External, ResizableLimits, Local, ValueType, BlockType};
|
||||
use elements::ResizableLimits;
|
||||
use interpreter::Error;
|
||||
use interpreter::runner::{FunctionContext};
|
||||
use interpreter::VariableType;
|
||||
use interpreter::RuntimeValue;
|
||||
use common::stack::StackWithLimit;
|
||||
|
||||
/// Maximum number of entries in value stack.
|
||||
const DEFAULT_VALUE_STACK_LIMIT: usize = 16384;
|
||||
/// Maximum number of entries in frame stack.
|
||||
const DEFAULT_FRAME_STACK_LIMIT: usize = 1024;
|
||||
|
||||
/// Execution context.
|
||||
pub struct ExecutionParams<'a, St: 'static> {
|
||||
@ -36,36 +28,6 @@ pub enum ItemIndex {
|
||||
External(u32),
|
||||
}
|
||||
|
||||
/// Caller context.
|
||||
pub struct CallerContext<'a> {
|
||||
/// Value stack limit
|
||||
pub value_stack_limit: usize,
|
||||
/// Frame stack limit
|
||||
pub frame_stack_limit: usize,
|
||||
/// Stack of the input parameters
|
||||
pub value_stack: &'a mut StackWithLimit<RuntimeValue>,
|
||||
}
|
||||
|
||||
impl<'a> CallerContext<'a> {
|
||||
/// Top most args
|
||||
pub fn topmost(args: &'a mut StackWithLimit<RuntimeValue>) -> Self {
|
||||
CallerContext {
|
||||
value_stack_limit: DEFAULT_VALUE_STACK_LIMIT,
|
||||
frame_stack_limit: DEFAULT_FRAME_STACK_LIMIT,
|
||||
value_stack: args,
|
||||
}
|
||||
}
|
||||
|
||||
/// Nested context
|
||||
pub fn nested(outer: &'a mut FunctionContext) -> Self {
|
||||
CallerContext {
|
||||
value_stack_limit: outer.value_stack().limit() - outer.value_stack().len(),
|
||||
frame_stack_limit: outer.frame_stack().limit() - outer.frame_stack().len(),
|
||||
value_stack: &mut outer.value_stack,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check_limits(limits: &ResizableLimits) -> Result<(), Error> {
|
||||
if let Some(maximum) = limits.maximum() {
|
||||
if maximum < limits.initial() {
|
||||
|
Reference in New Issue
Block a user