Skip to main content

Opcode

Enum Opcode 

Source
pub enum Opcode {
Show 96 variants PushInt(i32), PushFloat(f32), PushBool(bool), PushString(u16), PushList(u16), PushDivertTarget(DefinitionId), PushNull, Pop, Duplicate, Add, Subtract, Multiply, Divide, Modulo, Negate, Equal, NotEqual, Greater, GreaterOrEqual, Less, LessOrEqual, Not, And, Or, GetGlobal(DefinitionId), SetGlobal(DefinitionId), DeclareTemp(u16), GetTemp(u16), SetTemp(u16), GetTempRaw(u16), PushVarPointer(DefinitionId), PushTempPointer(u16), Jump(i32), JumpIfFalse(i32), Goto(DefinitionId), GotoIf(DefinitionId), GotoVariable, EnterContainer(DefinitionId), ExitContainer, Call(DefinitionId), Return, TunnelCall(DefinitionId), TunnelReturn, TunnelCallVariable, CallVariable, ThreadCall(DefinitionId), ThreadStart, ThreadDone, EmitLine(u16, u8), EmitValue, EmitNewline, Spring, Glue, BeginTag, EndTag, EvalLine(u16, u8), BeginFragment, EndFragment, BeginChoice(ChoiceFlags, DefinitionId), EndChoice, Sequence(SequenceKind, u8), SequenceBranch(i32), VisitCount, CurrentVisitCount, TurnsSince, TurnIndex, ChoiceCount, Random, SeedRandom, CastToInt, CastToFloat, Floor, Ceiling, Pow, Min, Max, CallExternal(DefinitionId, u8), ListContains, ListNotContains, ListIntersect, ListAll, ListInvert, ListCount, ListMin, ListMax, ListValue, ListRange, ListFromInt, ListRandom, Done, Yield, End, Nop, BeginStringEval, EndStringEval, SourceLocation(u32, u32),
}
Expand description

A single VM instruction with its operands.

Variants§

§

PushInt(i32)

§

PushFloat(f32)

§

PushBool(bool)

§

PushString(u16)

§

PushList(u16)

§

PushDivertTarget(DefinitionId)

§

PushNull

§

Pop

§

Duplicate

§

Add

§

Subtract

§

Multiply

§

Divide

§

Modulo

§

Negate

§

Equal

§

NotEqual

§

Greater

§

GreaterOrEqual

§

Less

§

LessOrEqual

§

Not

§

And

§

Or

§

GetGlobal(DefinitionId)

§

SetGlobal(DefinitionId)

§

DeclareTemp(u16)

§

GetTemp(u16)

§

SetTemp(u16)

§

GetTempRaw(u16)

Get a temp’s raw value without auto-dereference (for passing a ref onward).

§

PushVarPointer(DefinitionId)

Push a pointer to a global variable onto the eval stack.

§

PushTempPointer(u16)

Push a pointer to a temp variable onto the eval stack.

§

Jump(i32)

§

JumpIfFalse(i32)

§

Goto(DefinitionId)

§

GotoIf(DefinitionId)

§

GotoVariable

§

EnterContainer(DefinitionId)

§

ExitContainer

§

Call(DefinitionId)

§

Return

§

TunnelCall(DefinitionId)

§

TunnelReturn

§

TunnelCallVariable

§

CallVariable

§

ThreadCall(DefinitionId)

§

ThreadStart

§

ThreadDone

§

EmitLine(u16, u8)

§

EmitValue

§

EmitNewline

§

Spring

Word break — renders as a single space between content parts.

§

Glue

§

BeginTag

§

EndTag

§

EvalLine(u16, u8)

§

BeginFragment

Begin capturing output into a fragment (structural preservation).

§

EndFragment

End fragment capture — store parts and push Value::FragmentRef.

§

BeginChoice(ChoiceFlags, DefinitionId)

§

EndChoice

§

Sequence(SequenceKind, u8)

§

SequenceBranch(i32)

§

VisitCount

Pop a DivertTarget from the stack, push its visit count.

§

CurrentVisitCount

Push the visit count of the current container (no stack input).

§

TurnsSince

§

TurnIndex

§

ChoiceCount

§

Random

§

SeedRandom

§

CastToInt

§

CastToFloat

§

Floor

§

Ceiling

§

Pow

§

Min

§

Max

§

CallExternal(DefinitionId, u8)

§

ListContains

§

ListNotContains

§

ListIntersect

§

ListAll

§

ListInvert

§

ListCount

§

ListMin

§

ListMax

§

ListValue

§

ListRange

§

ListFromInt

§

ListRandom

§

Done

§

Yield

Pause for choice presentation. Like Done but does NOT set did_safe_exit — if no choices are pending, the story ran out of content rather than reaching an explicit -> DONE.

§

End

§

Nop

§

BeginStringEval

§

EndStringEval

§

SourceLocation(u32, u32)

Implementations§

Source§

impl Opcode

Source

pub fn encode(&self, buf: &mut Vec<u8>)

Encode this instruction into the byte buffer.

Source

pub fn decode(buf: &[u8], offset: &mut usize) -> Result<Self, DecodeError>

Decode a single instruction from buf starting at *offset.

On success, *offset is advanced past the consumed bytes.

Trait Implementations§

Source§

impl Clone for Opcode

Source§

fn clone(&self) -> Opcode

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 Opcode

Source§

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

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

impl PartialEq for Opcode

Source§

fn eq(&self, other: &Opcode) -> 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 StructuralPartialEq for Opcode

Auto Trait Implementations§

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.