mirror of
https://github.com/guilhermewerner/machine
synced 2025-06-16 13:14:18 +00:00
Split Payload and PayloadType
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
use crate::Machine;
|
||||
use crate::Payload::PayloadType;
|
||||
use crate::Types::Byte;
|
||||
use crate::{Machine, PayloadType};
|
||||
|
||||
pub struct Instruction {
|
||||
pub code: Byte,
|
||||
@ -13,7 +12,12 @@ pub type InstructionFunction = fn(machine: &mut Machine) -> bool;
|
||||
|
||||
impl Instruction {
|
||||
#[inline]
|
||||
pub fn New(code: Byte, name: &str, payload: PayloadType, function: InstructionFunction) -> Self {
|
||||
pub fn New(
|
||||
code: Byte,
|
||||
name: &str,
|
||||
payload: PayloadType,
|
||||
function: InstructionFunction,
|
||||
) -> Self {
|
||||
Self {
|
||||
code,
|
||||
name: name.to_string(),
|
||||
|
@ -1,8 +1,7 @@
|
||||
use crate::Instruction;
|
||||
use crate::Instructions::*;
|
||||
use crate::Operations::*;
|
||||
use crate::Payload::PayloadType;
|
||||
use crate::Types::Byte;
|
||||
use crate::{Instruction, PayloadType};
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub struct InstructionTable {
|
||||
@ -19,6 +18,7 @@ impl Default for InstructionTable {
|
||||
|
||||
impl InstructionTable {
|
||||
#[inline]
|
||||
#[rustfmt::skip]
|
||||
pub fn New() -> Self {
|
||||
let mut table = InstructionTable::default();
|
||||
|
||||
|
@ -8,16 +8,6 @@ pub type TwoRegisters = (Byte, Byte);
|
||||
pub type ThreeRegisters = (Byte, Byte, Byte);
|
||||
pub type FourRegisters = (Byte, Byte, Byte, Byte);
|
||||
|
||||
pub enum PayloadType {
|
||||
Nothing,
|
||||
Register,
|
||||
RegisterAddress,
|
||||
AddressRegister,
|
||||
TwoRegisters,
|
||||
ThreeRegisters,
|
||||
FourRegisters,
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn GetRegister(vm: &mut Machine) -> Register {
|
||||
vm.ReadByte(None)
|
||||
|
10
Source/PayloadType.rs
Normal file
10
Source/PayloadType.rs
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
pub enum PayloadType {
|
||||
Nothing,
|
||||
Register,
|
||||
RegisterAddress,
|
||||
AddressRegister,
|
||||
TwoRegisters,
|
||||
ThreeRegisters,
|
||||
FourRegisters,
|
||||
}
|
@ -23,6 +23,10 @@ pub use self::_Limits::*;
|
||||
mod _Machine;
|
||||
pub use self::_Machine::*;
|
||||
|
||||
#[path = "PayloadType.rs"]
|
||||
mod _PayloadType;
|
||||
pub use self::_PayloadType::*;
|
||||
|
||||
#[path = "Registry.rs"]
|
||||
mod _Registry;
|
||||
pub use self::_Registry::*;
|
||||
|
Reference in New Issue
Block a user