resurgence 0.1.4

A VM backend library that makes developing interpreters easy. Can be used either as an entire backend, or to create a backend
Documentation
use super::register::{Register, RegisterReference};

/// `Bytecode`: Represents instructions the built in Resurgence VM can use (this can be reused for any VM)
/// 
/// Possible Values: 
/// * `Alloc(u32)`: Preallocates memory in the vector stored in a `StackFrame` object 
/// * `Free(u32)`: Pops n amount of `StackFrame` objects
/// * `Jump(i64)`: Jumps n amount of operations
/// * `Call(u64)`: Jumps to index n by doing a recursive call of the execute_butecode function
/// * `CCall(String)`: Calls a C API function
/// * `Mov(Register, RegisterReference, Register, RegisterReference)`: Moves from one register to another
/// * `Cpy(Register, RegisterReference, Register, RegisterReference)`: Copies a value from one register to another
/// * `Ref(Register, RegisterReference, Register, RegisterReference)`: Stores the address of a register to another
/// * `Add(Register, Register, Register)`: Adds 2 registers and stores it in the output
/// * `Sub(Register, Register, Register)`: Subtracts 2 registers and stores it in the output
/// * `Mul(Register, Register, Register)`: Multiples 2 registers and stores it in the output
/// * `Div(Register, Register, Register)`: Divides 2 registers and stores it in the output
/// * `Equal(Register, Register)`: Checks if 2 registers are equal and jumps one operation if the condition is `true`
/// * `NotEqual(Register, Register)`: Checks if 2 registers are not equal and jumps one operation if the condition is `true`
/// * `Greater(Register, Register)`: Checks if one register is greater then another and jumps one operation if the condition is `true`
/// * `Less(Register, Register)`: Checks if one register is less then another and jumps one operation if the condition is `true`
/// * `GreaterEqual(Register, Register)`: Checks if one register is greater than or equal to another and jumps one operation if the condition is `true`
/// * `LessEqual(Register, Register)`: Checks if one register is less than or equal to another and jumps one operation if the condition is `true`
pub enum ByteCode {
    Alloc(u32),
    Free(u32),
    Jump(i64),
    Call(u64),
    CCall(String),

    Mov(Register, RegisterReference, Register, RegisterReference),
    Cpy(Register, RegisterReference, Register, RegisterReference),
    Ref(Register, RegisterReference, Register, RegisterReference),

    StackPush(Register, RegisterReference),
    StackPop,

    Add(Register, Register, Register),
    Sub(Register, Register, Register),
    Mul(Register, Register, Register),
    Div(Register, Register, Register),

    Equal(Register, Register),
    NotEqual(Register, Register),
    Greater(Register, Register),
    Less(Register, Register),
    GreaterEqual(Register, Register),
    LessEqual(Register, Register),
}