Skip to main content

Op

Enum Op 

Source
pub enum Op {
Show 31 variants Const(f32), Load(u16), Store(u16), Pop, Neg, Add, Sub, Mul, Div, Mod, Pow, Above, Below, AboveEq, BelowEq, Equal, NotEqual, Not, BitAnd, BitOr, Fn1(Unary), Fn2(Binary), MemLoad(Mem), MemStore(Mem), Jump(u32), JumpIfZero(u32), JumpIfNotZero(u32), LoopBegin(u32), LoopEnd(u32), WhileBegin(u32), WhileEnd(u32),
}
Expand description

One bytecode instruction.

A stack machine, not a register one, and deliberately: EEL2 is an expression language whose statements are expressions, so a stack matches its shape and the codegen is a post-order walk with no allocation. The named variables are registers (Op::Load / Op::Store); the stack is only the arithmetic’s scratch.

Variants§

§

Const(f32)

Push a literal.

§

Load(u16)

Push register n.

§

Store(u16)

Pop, store into register n, and push the value back — EEL2’s assignment is an expression that yields what it assigned.

§

Pop

Discard the top of the stack. Emitted between the statements of a sequence, whose value is its last statement’s.

§

Neg

Arithmetic negation.

§

Add

Addition.

§

Sub

Subtraction.

§

Mul

Multiplication.

§

Div

Division. Total: a zero divisor yields 0, which is EEL2’s own behaviour and what keeps the VM panic-free (Plan 0100 Phase 2).

§

Mod

Remainder, on the integer parts, EEL2’s %. Total the same way.

§

Pow

EEL2’s ^, which is exponentiation rather than xor. EEL2’s pow.

§

Above

> — pushes 1 or 0.

§

Below

<.

§

AboveEq

>=.

§

BelowEq

<=.

§

Equal

==, against EEL2’s comparison epsilon.

§

NotEqual

!=, against the same epsilon.

§

Not

!1 when the operand is zero, else 0.

§

BitAnd

EEL2’s &bitwise and on the truncated integer parts, not a logical one. band is the logical operator, and the two are different functions: 3 & 4 is 0 where band(3, 4) is 1.

§

BitOr

EEL2’s | — bitwise or, the counterpart of Op::BitAnd.

§

Fn1(Unary)

One-argument builtin.

§

Fn2(Binary)

Two-argument builtin.

§

MemLoad(Mem)

Pop an index, push that slot.

§

MemStore(Mem)

Pop a value and an index (value on top), store, and push the value back.

§

Jump(u32)

Unconditional jump to an absolute instruction index.

§

JumpIfZero(u32)

Pop; jump when the value is zero.

§

JumpIfNotZero(u32)

Pop; jump when the value is non-zero.

§

LoopBegin(u32)

Pop a count, open a loop frame, and jump past Op::LoopEnd when the count rounds to less than one. The count is clamped to Budget::loops.

§

LoopEnd(u32)

Close a loop iteration: discard the body’s value, decrement, and jump back to the operand while iterations remain. Pushes 0 when the loop ends, because a loop is an expression.

§

WhileBegin(u32)

Open a while frame with Budget::loops iterations, jumping past its Op::WhileEnd never — the test is at the end, because EEL2’s while(body) runs the body first.

§

WhileEnd(u32)

Close a while iteration: pop the body’s value, decrement, and jump back to the operand while it is non-zero and iterations remain. Pushes 0 when the loop ends.

Trait Implementations§

Source§

impl Clone for Op

Source§

fn clone(&self) -> Op

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Op

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Op

Source§

fn eq(&self, other: &Op) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Op

Source§

impl StructuralPartialEq for Op

Auto Trait Implementations§

§

impl Freeze for Op

§

impl RefUnwindSafe for Op

§

impl Send for Op

§

impl Sync for Op

§

impl Unpin for Op

§

impl UnsafeUnpin for Op

§

impl UnwindSafe for Op

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,