pub enum Intent {
Show 43 variants
PrintLast,
ReturnLast,
ContinueLast,
BreakLast,
ImportLastAsModule {
module_name: String,
descope: usize,
},
TickCurrentBlock,
SetVar {
vname: Identifier,
access_kind: VarAccessMode,
},
DefVar {
vname: Identifier,
access_kind: VarAccessMode,
is_const: bool,
},
BuildDynamicGetter {
path: Rc<AccessPath>,
dynamic_key_count: usize,
pending_exprs: Vec<Rc<Sequence>>,
override_print: bool,
prefer_function: bool,
fallback: Option<Rc<Sequence>>,
},
GetValue {
path: Rc<AccessPath>,
dynamic_key_count: usize,
override_print: bool,
prefer_function: bool,
fallback: Option<Rc<Sequence>>,
},
BuildDynamicSetter {
path: Rc<AccessPath>,
write_mode: VarWriteMode,
expr_count: usize,
pending_exprs: Vec<Rc<Sequence>>,
val_source: SetterValueSource,
},
SetValue {
path: Rc<AccessPath>,
write_mode: VarWriteMode,
expr_count: usize,
},
Invoke {
arg_exprs: Rc<Vec<ArgumentExpr>>,
arg_eval_count: usize,
is_temporal: bool,
},
InvokePipeStep {
steps: Rc<Vec<FunctionCall>>,
step_index: usize,
state: InvokePipeStepState,
pipeval: Option<RantValue>,
assignment_pipe: Option<Rc<AssignmentPipeTarget>>,
},
CreateDefaultArgs {
context: RantFunctionHandle,
default_arg_exprs: Vec<(Rc<Sequence>, usize)>,
eval_index: usize,
},
Call {
argc: usize,
override_print: bool,
},
CallOperand {
sequence: Rc<Sequence>,
},
CallTemporal {
func: RantFunctionHandle,
arg_exprs: Rc<Vec<ArgumentExpr>>,
args: Rc<Vec<RantValue>>,
temporal_state: TemporalSpreadState,
},
BuildList {
init: Rc<Vec<Rc<Sequence>>>,
index: usize,
list: RantList,
},
BuildTuple {
init: Rc<Vec<Rc<Sequence>>>,
index: usize,
items: Vec<RantValue>,
},
BuildMap {
init: Rc<Vec<(MapKeyExpr, Rc<Sequence>)>>,
pair_index: usize,
map: RantMap,
},
BuildWeightedBlock {
block: Rc<Block>,
weights: Weights,
pop_next_weight: bool,
},
RuntimeCall {
function: Box<dyn FnOnce(&mut VM<'_>) -> RuntimeResult<()>>,
interrupt: bool,
},
DropStaleUnwinds,
Add,
Subtract,
Multiply,
Divide,
Modulo,
Power,
LogicNot,
Negate,
LogicShortCircuit {
on_truthiness: bool,
short_circuit_result: LogicShortCircuitHandling,
gen_op_intent: Box<dyn FnOnce() -> Intent>,
rhs: Rc<Sequence>,
},
LogicAnd,
LogicOr,
LogicXor,
Equals,
NotEquals,
Greater,
GreaterOrEqual,
Less,
LessOrEqual,
CheckCondition {
conditions: Rc<Vec<(Rc<Sequence>, Rc<Block>)>>,
fallback: Option<Rc<Block>>,
index: usize,
},
}
Expand description
Actions that can be queued on a stack frame that are performed before the frame runs.
“Call” or “Invoke”?
In the context of Rant runtime intents, “calling” and “invoking” have specific meanings:
- “Invoke” means that argument expressions potentially need to be evaluated before the call can proceed;
- “Call” means that all argument values are already known (either in the intent or on the value stack).
Variants
PrintLast
Pops a value off the value stack and print it to the current frame’s output.
ReturnLast
Pops a value off the value stack and returns it from the current function.
ContinueLast
Pops a value off the value stack and continues to the next repeater iteration with it.
BreakLast
Pops a value off the value stack and breaks from the current repeater with it.
ImportLastAsModule
Pops a map off the stack and loads it as a module with the specified name.
TickCurrentBlock
Check if the current block is finished and either continue the block or pop the state from the stack
SetVar
Pops a value off the stack and assign it to an existing variable.
DefVar
Pops a value off the stack and assign it to a new variable.
BuildDynamicGetter
Pops a block from pending_exprs
and evaluate it. If there are no expressions left, switch intent to GetValue
.
GetValue
Pops dynamic key values off the stack and runs a getter. If the getter fails, evaluates the fallback.
BuildDynamicSetter
Used to evaluate a setter path with dynamic keys.
Pops a block from pending_exprs
and evaluate it. If there are no expressions left, switch intent to SetValue
.
SetValue
Pops expr_count
values off the stack and uses them for expression fields in a setter.
Invoke
Evaluates arg_exprs
in order, then pops the argument values off the stack, pops a function off the stack, and passes the arguments to the function.
InvokePipeStep
Fields
step_index: usize
The current step being executed
state: InvokePipeStepState
Current state of the intent.
Invokes a single function in a piped function call chain.
CreateDefaultArgs
Evaluates each sequence in default_arg_exprs
in order and assigns their results to local constants with their associated Identifier
.
Call
Pops argc
args off the stack, then pops a function off the stack and calls it with the args.
CallOperand
Fields
sequence: Rc<Sequence>
Calls a sequence without an inner variable scope, then pushes its output to the value stack.
CallTemporal
Fields
func: RantFunctionHandle
Calls a function for every variant of a temporal argument set and increments the provided temporal state.
BuildList
Pops value from stack and adds it to a list. If index
is out of range, prints the list.
BuildTuple
Pops a value from the stack and adds it to items
. If index
is out of range, produces a tuple from items
and prints it.
BuildMap
Pops a value and optional key from stack and adds them to map
. If pair_index
is out of range, prints map
.
BuildWeightedBlock
Evaluates expressions in weights
and then runs the block with the computed element weights.
RuntimeCall
Calls a function that accepts a mutable reference to the current runtime. Optionally interrupts the intent loop to force another tick.
DropStaleUnwinds
Drops all unwind states that are no longer within the call stack.
Add
Pops two values (RHS, LHS), performs addition, and pushes the result.
Subtract
Pops two values (RHS, LHS), performs subtraction, and pushes the result.
Multiply
Pops two values (RHS, LHS), performs multiplication, and pushes the result.
Divide
Pops two values (RHS, LHS), performs division, and pushes the result.
Modulo
Pops two values (RHS, LHS), performs modulo, and pushes the result.
Power
Pops two values (RHS, LHS), performs exponentiation, and pushes the result.
LogicNot
Pops a value, performs logical NOT, and pushes the result.
Negate
Pops a value, performs negation, and pushes the result.
LogicShortCircuit
Pops a value off the value stack and compares its truthiness against on_truthiness
, and re-pushes the value.
If they match, do nothing and continue.
If they don’t match, calls gen_op_intent
and pushes the returned intent onto the current frame, then evaluates rhs
using the CallOperand
intent.
LogicAnd
Pops two values, performs logical AND, and pushes the result.
LogicOr
Pops two values, performs logical OR, and pushes the result.
LogicXor
Pops two values (RHS, LHS), performs logical XOR, and pushes the result.
Equals
Pops two values (RHS, LHS), calculates LHS == RHS
, and pushes the result.
NotEquals
Pops two values (RHS, LHS), calculates LHS != RHS
, and pushes the result.
Greater
Pops two values (RHS, LHS), calculates LHS > RHS
, and pushes the result.
GreaterOrEqual
Pops two values (RHS, LHS), calculates LHS >= RHS
, and pushes the result.
Less
Pops two values (RHS, LHS), calculates LHS < RHS
, and pushes the result.
LessOrEqual
Pops two values (RHS, LHS), calculates LHS <= RHS
, and pushes the result.
CheckCondition
If index
is nonzero, pops a value off the value stack and checks its truthiness.
If it’s falsy, pushes the next condition (or fallback) to the call stack and re-pushes this intent with index = index + 1
.
If it’s truthy, pushes it to the value stack and exits.
Auto Trait Implementations
impl !RefUnwindSafe for Intent
impl !Send for Intent
impl !Sync for Intent
impl Unpin for Intent
impl !UnwindSafe for Intent
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more