fixes in evmjit bridge
This commit is contained in:
parent
74368663db
commit
1c10f073f3
@ -10,14 +10,6 @@ pub struct JitI256 {
|
||||
pub words: [u64; 4]
|
||||
}
|
||||
|
||||
impl JitI256 {
|
||||
pub fn new() -> JitI256 {
|
||||
JitI256 {
|
||||
words: [0; 4]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct JitRuntimeData {
|
||||
pub gas: i64,
|
||||
@ -38,31 +30,8 @@ pub struct JitRuntimeData {
|
||||
pub code_hash: JitI256
|
||||
}
|
||||
|
||||
impl JitRuntimeData {
|
||||
pub fn new() -> JitRuntimeData {
|
||||
JitRuntimeData {
|
||||
gas: 0,
|
||||
gas_price: 0,
|
||||
call_data: ptr::null(),
|
||||
call_data_size: 0,
|
||||
address: JitI256::new(),
|
||||
caller: JitI256::new(),
|
||||
origin: JitI256::new(),
|
||||
call_value: JitI256::new(),
|
||||
coinbase: JitI256::new(),
|
||||
difficulty: JitI256::new(),
|
||||
gas_limit: JitI256::new(),
|
||||
number: 0,
|
||||
timestamp: 0,
|
||||
code: ptr::null(),
|
||||
code_size: 0,
|
||||
code_hash: JitI256::new()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
pub enum JitReturnCode {
|
||||
Stop = 0,
|
||||
Return = 1,
|
||||
@ -74,22 +43,31 @@ pub enum JitReturnCode {
|
||||
UnexpectedError = -111
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum JitContext {}
|
||||
|
||||
#[link(name="evmjit")]
|
||||
extern "C" {
|
||||
pub fn evmjit_create(data: JitRuntimeData, env: u8) -> JitContext;
|
||||
pub fn evmjit_exec(context: JitContext) -> JitReturnCode;
|
||||
pub fn evmjit_destroy(context: JitContext);
|
||||
pub fn evmjit_create_runtime_data() -> *mut JitRuntimeData;
|
||||
pub fn evmjit_destroy_runtime_data(data: *mut JitRuntimeData);
|
||||
|
||||
pub fn evmjit_create_context(data: *mut JitRuntimeData, env: u8) -> *mut JitContext;
|
||||
pub fn evmjit_destroy_context(context: *mut JitContext);
|
||||
|
||||
pub fn evmjit_exec(context: *mut JitContext) -> JitReturnCode;
|
||||
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
unsafe {
|
||||
let context = evmjit_create(JitRuntimeData::new(), 0);
|
||||
let _result = evmjit_exec(context);
|
||||
evmjit_destroy(context);
|
||||
let data = evmjit_create_runtime_data();
|
||||
let context = evmjit_create_context(data, 0);
|
||||
|
||||
let code = evmjit_exec(context);
|
||||
assert_eq!(code, JitReturnCode::Stop);
|
||||
|
||||
evmjit_destroy_runtime_data(data);
|
||||
evmjit_destroy_context(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user