mirror of
https://github.com/pezkuwichain/wasm-instrument.git
synced 2026-04-28 14:28:01 +00:00
refactored rust runtime
This commit is contained in:
@@ -10,9 +10,11 @@ extern crate wasm_utils;
|
||||
mod alloc;
|
||||
mod storage;
|
||||
mod call_args;
|
||||
mod runtime;
|
||||
mod gas_counter;
|
||||
|
||||
use std::env;
|
||||
use parity_wasm::interpreter::{self, ModuleInstanceInterface, RuntimeValue};
|
||||
use parity_wasm::interpreter::{self, ModuleInstanceInterface};
|
||||
|
||||
pub const DEFAULT_MEMORY_INDEX: interpreter::ItemIndex = interpreter::ItemIndex::Internal(0);
|
||||
pub type WasmMemoryPtr = i32;
|
||||
@@ -36,12 +38,13 @@ fn main() {
|
||||
let module_instance = program.add_module("contract", module).expect("Module to be added successfully");
|
||||
|
||||
// Create allocator
|
||||
let mut allocator = alloc::Arena::new(5*1024*1024);
|
||||
let runtime = runtime::Runtime::default();
|
||||
runtime.allocator().alloc(5*1024*1024).expect("to allocate 5mb successfully"); // reserve stack space
|
||||
|
||||
// Initialize call descriptor
|
||||
let descriptor = call_args::init(
|
||||
&*program.module("env").expect("env module to exist"),
|
||||
&mut allocator,
|
||||
&runtime,
|
||||
&[],
|
||||
&[0u8; 128],
|
||||
).expect("call descriptor initialization to succeed");
|
||||
|
||||
Reference in New Issue
Block a user