Merge branch 'master' into blockchain
This commit is contained in:
commit
18eb9ec3cc
@ -10,14 +10,6 @@ pub struct JitI256 {
|
|||||||
pub words: [u64; 4]
|
pub words: [u64; 4]
|
||||||
}
|
}
|
||||||
|
|
||||||
impl JitI256 {
|
|
||||||
pub fn new() -> JitI256 {
|
|
||||||
JitI256 {
|
|
||||||
words: [0; 4]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct JitRuntimeData {
|
pub struct JitRuntimeData {
|
||||||
pub gas: i64,
|
pub gas: i64,
|
||||||
@ -38,31 +30,8 @@ pub struct JitRuntimeData {
|
|||||||
pub code_hash: JitI256
|
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)]
|
#[repr(C)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub enum JitReturnCode {
|
pub enum JitReturnCode {
|
||||||
Stop = 0,
|
Stop = 0,
|
||||||
Return = 1,
|
Return = 1,
|
||||||
@ -74,22 +43,31 @@ pub enum JitReturnCode {
|
|||||||
UnexpectedError = -111
|
UnexpectedError = -111
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
pub enum JitContext {}
|
pub enum JitContext {}
|
||||||
|
|
||||||
#[link(name="evmjit")]
|
#[link(name="evmjit")]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn evmjit_create(data: JitRuntimeData, env: u8) -> JitContext;
|
pub fn evmjit_create_runtime_data() -> *mut JitRuntimeData;
|
||||||
pub fn evmjit_exec(context: JitContext) -> JitReturnCode;
|
pub fn evmjit_destroy_runtime_data(data: *mut JitRuntimeData);
|
||||||
pub fn evmjit_destroy(context: JitContext);
|
|
||||||
|
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]
|
#[test]
|
||||||
fn it_works() {
|
fn it_works() {
|
||||||
unsafe {
|
unsafe {
|
||||||
let context = evmjit_create(JitRuntimeData::new(), 0);
|
let data = evmjit_create_runtime_data();
|
||||||
let _result = evmjit_exec(context);
|
let context = evmjit_create_context(data, 0);
|
||||||
evmjit_destroy(context);
|
|
||||||
|
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