use crate::{
interpreter_types::{Immediates, InterpreterTypes, Jumps, RuntimeFlag, StackTr},
InstructionResult,
};
use primitives::U256;
use crate::InstructionContext;
pub fn pop<WIRE: InterpreterTypes, H: ?Sized>(context: InstructionContext<'_, H, WIRE>) {
popn!([_i], context.interpreter);
}
pub fn push0<WIRE: InterpreterTypes, H: ?Sized>(context: InstructionContext<'_, H, WIRE>) {
check!(context.interpreter, SHANGHAI);
push!(context.interpreter, U256::ZERO);
}
pub fn push<const N: usize, WIRE: InterpreterTypes, H: ?Sized>(
context: InstructionContext<'_, H, WIRE>,
) {
let slice = context.interpreter.bytecode.read_slice(N);
if !context.interpreter.stack.push_slice(slice) {
context.interpreter.halt(InstructionResult::StackOverflow);
return;
}
context.interpreter.bytecode.relative_jump(N as isize);
}
pub fn dup<const N: usize, WIRE: InterpreterTypes, H: ?Sized>(
context: InstructionContext<'_, H, WIRE>,
) {
if !context.interpreter.stack.dup(N) {
context.interpreter.halt(InstructionResult::StackOverflow);
}
}
pub fn swap<const N: usize, WIRE: InterpreterTypes, H: ?Sized>(
context: InstructionContext<'_, H, WIRE>,
) {
assert!(N != 0);
if !context.interpreter.stack.exchange(0, N) {
context.interpreter.halt(InstructionResult::StackOverflow);
}
}