Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use macros to reduce eval_log* boilerplate code #283

Merged
merged 1 commit into from
May 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 14 additions & 42 deletions interpreter/src/eval/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,50 +669,22 @@ pub fn eval_gas<S: GasState, H: RuntimeEnvironment + RuntimeBackend, Tr>(
self::system::gas(machine, handle)
}

pub fn eval_log0<S: AsRef<RuntimeState>, H: RuntimeEnvironment + RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
_position: usize,
) -> Control<Tr> {
self::system::log(machine, 0, handle)
}

pub fn eval_log1<S: AsRef<RuntimeState>, H: RuntimeEnvironment + RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
_position: usize,
) -> Control<Tr> {
self::system::log(machine, 1, handle)
}

pub fn eval_log2<S: AsRef<RuntimeState>, H: RuntimeEnvironment + RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
_position: usize,
) -> Control<Tr> {
self::system::log(machine, 2, handle)
}

pub fn eval_log3<S: AsRef<RuntimeState>, H: RuntimeEnvironment + RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
_position: usize,
) -> Control<Tr> {
self::system::log(machine, 3, handle)
macro_rules! eval_log {
($($num:expr),*) => {
$(paste::paste! {
pub fn [<eval_log $num>]<S: AsRef<RuntimeState>, H: RuntimeEnvironment + RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
_position: usize,
) -> Control<Tr> {
self::system::log(machine, $num, handle)
}
})*
};
}

pub fn eval_log4<S: AsRef<RuntimeState>, H: RuntimeEnvironment + RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
_position: usize,
) -> Control<Tr> {
self::system::log(machine, 4, handle)
}
eval_log! { 0, 1, 2, 3, 4 }

pub fn eval_suicide<S: AsRef<RuntimeState>, H: RuntimeEnvironment + RuntimeBackend, Tr>(
machine: &mut Machine<S>,
Expand Down