mirror of
https://github.com/guilhermewerner/machine
synced 2025-06-16 13:14:18 +00:00
Working...
This commit is contained in:
24
Source/Instruction.rs
Normal file
24
Source/Instruction.rs
Normal file
@ -0,0 +1,24 @@
|
||||
use crate::Machine;
|
||||
use crate::Payload::PayloadType;
|
||||
use crate::Types::Byte;
|
||||
|
||||
pub struct Instruction {
|
||||
pub code: Byte,
|
||||
pub name: String,
|
||||
pub payload: PayloadType,
|
||||
pub function: InstructionFunction,
|
||||
}
|
||||
|
||||
pub type InstructionFunction = fn(machine: &mut Machine) -> bool;
|
||||
|
||||
impl Instruction {
|
||||
#[inline]
|
||||
pub fn New(code: Byte, name: &str, payload: PayloadType, function: InstructionFunction) -> Self {
|
||||
Self {
|
||||
code,
|
||||
name: name.to_string(),
|
||||
payload,
|
||||
function,
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user