From aef38a9abc5a8b2e9adc7a3a5ad0a205b53d63b2 Mon Sep 17 00:00:00 2001 From: Tomusdrw Date: Sat, 16 Jan 2016 02:25:08 +0100 Subject: [PATCH] Fixing code compilation --- src/evm/interpreter.rs | 15 ++++++++------- src/evm/tests.rs | 2 +- src/executive.rs | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/evm/interpreter.rs b/src/evm/interpreter.rs index 99194a3f9..c5a0941dc 100644 --- a/src/evm/interpreter.rs +++ b/src/evm/interpreter.rs @@ -215,7 +215,7 @@ pub struct Interpreter; impl evm::Evm for Interpreter { fn exec(&self, params: &ActionParams, ext: &mut evm::Ext) -> evm::Result { - let code = ¶ms.code; + let code = ¶ms.code.clone().unwrap(); let valid_jump_destinations = self.find_jump_destinations(&code); let mut current_gas = params.gas.clone(); @@ -653,9 +653,10 @@ impl Interpreter { let big_id = stack.pop_back(); let id = big_id.low_u64() as usize; let max = id.wrapping_add(32); - let bound = cmp::min(params.data.len(), max); - if id < bound && big_id < U256::from(params.data.len()) { - let mut v = params.data[id..bound].to_vec(); + let data = params.data.clone().unwrap(); + let bound = cmp::min(data.len(), max); + if id < bound && big_id < U256::from(data.len()) { + let mut v = data[id..bound].to_vec(); v.resize(32, 0); stack.push(U256::from(&v[..])) } else { @@ -663,7 +664,7 @@ impl Interpreter { } }, instructions::CALLDATASIZE => { - stack.push(U256::from(params.data.len())); + stack.push(U256::from(params.data.clone().unwrap().len())); }, instructions::CODESIZE => { stack.push(U256::from(code.len())); @@ -674,10 +675,10 @@ impl Interpreter { stack.push(U256::from(len)); }, instructions::CALLDATACOPY => { - self.copy_data_to_memory(mem, stack, ¶ms.data); + self.copy_data_to_memory(mem, stack, ¶ms.data.clone().unwrap()); }, instructions::CODECOPY => { - self.copy_data_to_memory(mem, stack, ¶ms.code); + self.copy_data_to_memory(mem, stack, ¶ms.code.clone().unwrap()); }, instructions::EXTCODECOPY => { let address = u256_to_address(&stack.pop_back()); diff --git a/src/evm/tests.rs b/src/evm/tests.rs index 5ec8af21d..b682d42c2 100644 --- a/src/evm/tests.rs +++ b/src/evm/tests.rs @@ -103,7 +103,7 @@ fn test_stack_underflow() { let mut params = ActionParams::new(); params.address = address.clone(); params.gas = U256::from(100_000); - params.code = code; + params.code = Some(code); let mut ext = FakeExt::new(); let err = { diff --git a/src/executive.rs b/src/executive.rs index 29e054520..f88705989 100644 --- a/src/executive.rs +++ b/src/executive.rs @@ -784,7 +784,7 @@ mod tests { params.sender = sender.clone(); params.origin = sender.clone(); params.gas = U256::from(0x0186a0); - params.code = code.clone(); + params.code = Some(code.clone()); params.value = U256::from_str("0de0b6b3a7640000").unwrap(); let mut state = State::new_temp(); state.add_balance(&sender, &U256::from_str("152d02c7e14af6800000").unwrap());