Skip to main content

ScriptOperation

Enum ScriptOperation 

Source
pub enum ScriptOperation<'a, SE: ScriptExpression> {
Show 14 variants None, Expression { expression: SE, }, DefineRegister { query: TypeQuery<'a>, }, DropRegister { index: usize, }, PushFromRegister { index: usize, }, PopToRegister { index: usize, }, MoveRegister { from: usize, to: usize, }, CallFunction { query: FunctionQuery<'a>, }, BranchScope { scope_success: ScriptHandle<'a, SE>, scope_failure: Option<ScriptHandle<'a, SE>>, }, LoopScope { scope: ScriptHandle<'a, SE>, }, PushScope { scope: ScriptHandle<'a, SE>, }, PopScope, ContinueScopeConditionally, Suspend,
}
Expand description

One instruction of a script.

See the module docs for why the set is this small.

Variants§

§

None

Does nothing.

§

Expression

Runs a frontend-defined operation. See ScriptExpression.

Fields

§expression: SE
§

DefineRegister

Allocates a register of the queried type.

A register has to be defined before it is used, and is dropped when the scope that defined it ends.

Fields

§query: TypeQuery<'a>
§

DropRegister

Destroys the value in a register, leaving it empty.

Fields

§index: usize
§

PushFromRegister

Moves a register’s value onto the stack, leaving the register empty.

Fields

§index: usize
§

PopToRegister

Moves the top stack value into a register.

Fields

§index: usize
§

MoveRegister

Moves a value from one register to another.

Fields

§from: usize
§

CallFunction

Finds a function in the registry and invokes it.

Fields

§query: FunctionQuery<'a>
§

BranchScope

Takes a bool off the stack and runs one of two scopes.

The failure scope is optional, in which case a false does nothing.

Fields

§scope_success: ScriptHandle<'a, SE>
§scope_failure: Option<ScriptHandle<'a, SE>>
§

LoopScope

Repeats a scope while a bool taken off the stack is true.

The scope must leave a fresh bool on the stack before it ends, otherwise the next round reads whatever happens to be there.

Fields

§scope: ScriptHandle<'a, SE>
§

PushScope

Runs a nested scope and comes back when it ends.

Fields

§scope: ScriptHandle<'a, SE>
§

PopScope

Ends the current scope early, the way return does.

§

ContinueScopeConditionally

Takes a bool off the stack and ends the current scope when it is false.

§

Suspend

Stops stepping and reports back to the caller without finishing.

For frontends building coroutines or futures. Anything to yield has to be left on the stack for the host to take.

Implementations§

Source§

impl<SE: ScriptExpression> ScriptOperation<'_, SE>

Source

pub fn label(&self) -> &str

Returns the operation’s name, for debugging and tooling.

Trait Implementations§

Source§

impl<'a, SE: Debug + ScriptExpression> Debug for ScriptOperation<'a, SE>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, SE> Freeze for ScriptOperation<'a, SE>
where SE: Freeze, Arc<Vec<ScriptOperation<'a, SE>>>: Freeze, Option<Arc<Vec<ScriptOperation<'a, SE>>>>: Freeze,

§

impl<'a, SE> RefUnwindSafe for ScriptOperation<'a, SE>

§

impl<'a, SE> Send for ScriptOperation<'a, SE>
where Arc<Vec<ScriptOperation<'a, SE>>>: Send, Option<Arc<Vec<ScriptOperation<'a, SE>>>>: Send,

§

impl<'a, SE> Sync for ScriptOperation<'a, SE>
where Arc<Vec<ScriptOperation<'a, SE>>>: Sync, Option<Arc<Vec<ScriptOperation<'a, SE>>>>: Sync,

§

impl<'a, SE> Unpin for ScriptOperation<'a, SE>
where SE: Unpin, Arc<Vec<ScriptOperation<'a, SE>>>: Unpin, Option<Arc<Vec<ScriptOperation<'a, SE>>>>: Unpin,

§

impl<'a, SE> UnsafeUnpin for ScriptOperation<'a, SE>

§

impl<'a, SE> UnwindSafe for ScriptOperation<'a, SE>

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> Finalize for T

Source§

unsafe fn finalize_raw(data: *mut ())

Drops the value stored at data in place. 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.