-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
224 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,118 @@ | ||
use super::{Action, EvalValue, Interpret, State}; | ||
use crate::inst::evm::*; | ||
|
||
impl Interpret for EvmUdiv { | ||
fn interpret(&self, state: &mut dyn State) -> EvalValue { | ||
state.set_action(Action::Continue); | ||
|
||
let lhs = state.lookup_val(*self.lhs()); | ||
let rhs = state.lookup_val(*self.rhs()); | ||
|
||
EvalValue::zip_with_imm( | ||
lhs, | ||
rhs, | ||
|lhs, rhs| { | ||
if rhs.is_zero() { | ||
rhs | ||
} else { | ||
lhs.udiv(rhs) | ||
} | ||
}, | ||
) | ||
} | ||
} | ||
|
||
impl Interpret for EvmSdiv { | ||
fn interpret(&self, state: &mut dyn State) -> EvalValue { | ||
state.set_action(Action::Continue); | ||
|
||
let lhs = state.lookup_val(*self.lhs()); | ||
let rhs = state.lookup_val(*self.rhs()); | ||
|
||
EvalValue::zip_with_imm( | ||
lhs, | ||
rhs, | ||
|lhs, rhs| { | ||
if rhs.is_zero() { | ||
rhs | ||
} else { | ||
lhs.sdiv(rhs) | ||
} | ||
}, | ||
) | ||
} | ||
} | ||
|
||
impl Interpret for EvmUmod { | ||
fn interpret(&self, state: &mut dyn State) -> EvalValue { | ||
state.set_action(Action::Continue); | ||
|
||
let lhs = state.lookup_val(*self.lhs()); | ||
let rhs = state.lookup_val(*self.rhs()); | ||
|
||
EvalValue::zip_with_imm( | ||
lhs, | ||
rhs, | ||
|lhs, rhs| { | ||
if rhs.is_zero() { | ||
rhs | ||
} else { | ||
lhs.urem(rhs) | ||
} | ||
}, | ||
) | ||
} | ||
} | ||
|
||
impl Interpret for EvmSmod { | ||
fn interpret(&self, state: &mut dyn State) -> EvalValue { | ||
state.set_action(Action::Continue); | ||
|
||
let lhs = state.lookup_val(*self.lhs()); | ||
let rhs = state.lookup_val(*self.rhs()); | ||
|
||
EvalValue::zip_with_imm( | ||
lhs, | ||
rhs, | ||
|lhs, rhs| { | ||
if rhs.is_zero() { | ||
rhs | ||
} else { | ||
lhs.srem(rhs) | ||
} | ||
}, | ||
) | ||
} | ||
} | ||
|
||
impl Interpret for EvmAddMod { | ||
fn interpret(&self, state: &mut dyn State) -> EvalValue { | ||
state.set_action(Action::Continue); | ||
let lhs = state.lookup_val(*self.lhs()); | ||
let rhs = state.lookup_val(*self.rhs()); | ||
|
||
EvalValue::zip_with_imm(lhs, rhs, |lhs, rhs| { | ||
if rhs.is_zero() { | ||
rhs | ||
} else { | ||
(lhs + rhs).urem(rhs) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
impl Interpret for EvmMulMod { | ||
fn interpret(&self, state: &mut dyn State) -> EvalValue { | ||
state.set_action(Action::Continue); | ||
let lhs = state.lookup_val(*self.lhs()); | ||
let rhs = state.lookup_val(*self.rhs()); | ||
|
||
EvalValue::zip_with_imm(lhs, rhs, |lhs, rhs| { | ||
if rhs.is_zero() { | ||
rhs | ||
} else { | ||
(lhs * rhs).urem(rhs) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters