nu_protocol::ir

Enum Instruction

Source
pub enum Instruction {
Show 52 variants Unreachable, LoadLiteral { dst: RegId, lit: Literal, }, LoadValue { dst: RegId, val: Box<Value>, }, Move { dst: RegId, src: RegId, }, Clone { dst: RegId, src: RegId, }, Collect { src_dst: RegId, }, Span { src_dst: RegId, }, Drop { src: RegId, }, Drain { src: RegId, }, DrainIfEnd { src: RegId, }, LoadVariable { dst: RegId, var_id: VarId, }, StoreVariable { var_id: VarId, src: RegId, }, DropVariable { var_id: VarId, }, LoadEnv { dst: RegId, key: DataSlice, }, LoadEnvOpt { dst: RegId, key: DataSlice, }, StoreEnv { key: DataSlice, src: RegId, }, PushPositional { src: RegId, }, AppendRest { src: RegId, }, PushFlag { name: DataSlice, }, PushShortFlag { short: DataSlice, }, PushNamed { name: DataSlice, src: RegId, }, PushShortNamed { short: DataSlice, src: RegId, }, PushParserInfo { name: DataSlice, info: Box<Expression>, }, RedirectOut { mode: RedirectMode, }, RedirectErr { mode: RedirectMode, }, CheckErrRedirected { src: RegId, }, OpenFile { file_num: u32, path: RegId, append: bool, }, WriteFile { file_num: u32, src: RegId, }, CloseFile { file_num: u32, }, Call { decl_id: DeclId, src_dst: RegId, }, StringAppend { src_dst: RegId, val: RegId, }, GlobFrom { src_dst: RegId, no_expand: bool, }, ListPush { src_dst: RegId, item: RegId, }, ListSpread { src_dst: RegId, items: RegId, }, RecordInsert { src_dst: RegId, key: RegId, val: RegId, }, RecordSpread { src_dst: RegId, items: RegId, }, Not { src_dst: RegId, }, BinaryOp { lhs_dst: RegId, op: Operator, rhs: RegId, }, FollowCellPath { src_dst: RegId, path: RegId, }, CloneCellPath { dst: RegId, src: RegId, path: RegId, }, UpsertCellPath { src_dst: RegId, path: RegId, new_value: RegId, }, Jump { index: usize, }, BranchIf { cond: RegId, index: usize, }, BranchIfEmpty { src: RegId, index: usize, }, Match { pattern: Box<Pattern>, src: RegId, index: usize, }, CheckMatchGuard { src: RegId, }, Iterate { dst: RegId, stream: RegId, end_index: usize, }, OnError { index: usize, }, OnErrorInto { index: usize, dst: RegId, }, PopErrorHandler, ReturnEarly { src: RegId, }, Return { src: RegId, },
}

Variants§

§

Unreachable

Unreachable code path (error)

§

LoadLiteral

Load a literal value into the dst register

Fields

§dst: RegId
§

LoadValue

Load a clone of a boxed value into the dst register (e.g. from const evaluation)

Fields

§dst: RegId
§val: Box<Value>
§

Move

Move a register. Value is taken from src (used by this instruction).

Fields

§dst: RegId
§src: RegId
§

Clone

Copy a register (must be a collected value). Value is still in src after this instruction.

Fields

§dst: RegId
§src: RegId
§

Collect

Collect a stream in a register to a value

Fields

§src_dst: RegId
§

Span

Change the span of the contents of a register to the span of this instruction.

Fields

§src_dst: RegId
§

Drop

Drop the value/stream in a register, without draining

Fields

§src: RegId
§

Drain

Drain the value/stream in a register and discard (e.g. semicolon).

If passed a stream from an external command, sets $env.LAST_EXIT_CODE to the resulting exit code, and invokes any available error handler with Empty, or if not available, returns an exit-code-only stream, leaving the block.

Fields

§src: RegId
§

DrainIfEnd

Drain the value/stream in a register and discard only if this is the last pipeline element.

Fields

§src: RegId
§

LoadVariable

Load the value of a variable into the dst register

Fields

§dst: RegId
§var_id: VarId
§

StoreVariable

Store the value of a variable from the src register

Fields

§var_id: VarId
§src: RegId
§

DropVariable

Remove a variable from the stack, freeing up whatever resources were associated with it

Fields

§var_id: VarId
§

LoadEnv

Load the value of an environment variable into the dst register

Fields

§dst: RegId
§

LoadEnvOpt

Load the value of an environment variable into the dst register, or Nothing if it doesn’t exist

Fields

§dst: RegId
§

StoreEnv

Store the value of an environment variable from the src register

Fields

§src: RegId
§

PushPositional

Add a positional arg to the next (internal) call.

Fields

§src: RegId
§

AppendRest

Add a list of args to the next (internal) call (spread/rest).

Fields

§src: RegId
§

PushFlag

Add a named arg with no value to the next (internal) call.

Fields

§

PushShortFlag

Add a short named arg with no value to the next (internal) call.

Fields

§

PushNamed

Add a named arg with a value to the next (internal) call.

Fields

§src: RegId
§

PushShortNamed

Add a short named arg with a value to the next (internal) call.

Fields

§src: RegId
§

PushParserInfo

Add parser info to the next (internal) call.

Fields

§

RedirectOut

Set the redirection for stdout for the next call (only).

The register for a file redirection is not consumed.

Fields

§

RedirectErr

Set the redirection for stderr for the next call (only).

The register for a file redirection is not consumed.

Fields

§

CheckErrRedirected

Throw an error if stderr wasn’t redirected in the given stream. src is preserved.

Fields

§src: RegId
§

OpenFile

Open a file for redirection, pushing it onto the file stack.

Fields

§file_num: u32
§path: RegId
§append: bool
§

WriteFile

Write data from the register to a file. This is done to finish a file redirection, in case an internal command or expression was evaluated rather than an external one.

Fields

§file_num: u32
§src: RegId
§

CloseFile

Pop a file used for redirection from the file stack.

Fields

§file_num: u32
§

Call

Make a call. The input is taken from src_dst, and the output is placed in src_dst, overwriting it. The argument stack is used implicitly and cleared when the call ends.

Fields

§decl_id: DeclId
§src_dst: RegId
§

StringAppend

Append a value onto the end of a string. Uses to_expanded_string(", ", ...) on the value. Used for string interpolation literals. Not the same thing as the ++ operator.

Fields

§src_dst: RegId
§val: RegId
§

GlobFrom

Convert a string into a glob. Used for glob interpolation and setting glob variables. If the value is already a glob, it won’t be modified (no_expand will have no effect).

Fields

§src_dst: RegId
§no_expand: bool
§

ListPush

Push a value onto the end of a list. Used to construct list literals.

Fields

§src_dst: RegId
§item: RegId
§

ListSpread

Spread a value onto the end of a list. Used to construct list literals.

Fields

§src_dst: RegId
§items: RegId
§

RecordInsert

Insert a key-value pair into a record. Used to construct record literals. Raises an error if the key already existed in the record.

Fields

§src_dst: RegId
§key: RegId
§val: RegId
§

RecordSpread

Spread a record onto a record. Used to construct record literals. Any existing value for the key is overwritten.

Fields

§src_dst: RegId
§items: RegId
§

Not

Negate a boolean.

Fields

§src_dst: RegId
§

BinaryOp

Do a binary operation on lhs_dst (left) and rhs (right) and write the result to lhs_dst.

Fields

§lhs_dst: RegId
§rhs: RegId
§

FollowCellPath

Follow a cell path on the value in src_dst, storing the result back to src_dst

Fields

§src_dst: RegId
§path: RegId
§

CloneCellPath

Clone the value at a cell path in src, storing the result to dst. The original value remains in src. Must be a collected value.

Fields

§dst: RegId
§src: RegId
§path: RegId
§

UpsertCellPath

Update/insert a cell path to new_value on the value in src_dst, storing the modified value back to src_dst

Fields

§src_dst: RegId
§path: RegId
§new_value: RegId
§

Jump

Jump to an offset in this block

Fields

§index: usize
§

BranchIf

Branch to an offset in this block if the value of the cond register is a true boolean, otherwise continue execution

Fields

§cond: RegId
§index: usize
§

BranchIfEmpty

Branch to an offset in this block if the value of the src register is Empty or Nothing, otherwise continue execution. The original value in src is preserved.

Fields

§src: RegId
§index: usize
§

Match

Match a pattern on src. If the pattern matches, branch to index after having set any variables captured by the pattern. If the pattern doesn’t match, continue execution. The original value is preserved in src through this instruction.

Fields

§pattern: Box<Pattern>
§src: RegId
§index: usize
§

CheckMatchGuard

Check that a match guard is a boolean, throwing MatchGuardNotBool if it isn’t. Preserves src.

Fields

§src: RegId
§

Iterate

Iterate on register stream, putting the next value in dst if present, or jumping to end_index if the iterator is finished

Fields

§dst: RegId
§stream: RegId
§end_index: usize
§

OnError

Push an error handler, without capturing the error value

Fields

§index: usize
§

OnErrorInto

Push an error handler, capturing the error value into dst. If the error handler is not called, the register should be freed manually.

Fields

§index: usize
§dst: RegId
§

PopErrorHandler

Pop an error handler. This is not necessary when control flow is directed to the error handler due to an error.

§

ReturnEarly

Return early from the block, raising a ShellError::Return instead.

Collecting the value is unavoidable.

Fields

§src: RegId
§

Return

Return from the block with the value in the register

Fields

§src: RegId

Implementations§

Source§

impl Instruction

Source

pub fn display<'a>( &'a self, engine_state: &'a EngineState, data: &'a [u8], ) -> FmtInstruction<'a>

Returns a value that can be formatted with Display to show a detailed listing of the instruction.

Source

pub fn output_register(&self) -> Option<RegId>

Get the output register, for instructions that produce some kind of immediate result.

Source

pub fn branch_target(&self) -> Option<usize>

Returns the branch target index of the instruction if this is a branching instruction.

Source

pub fn set_branch_target(&mut self, target_index: usize) -> Result<(), usize>

Sets the branch target of the instruction if this is a branching instruction.

Returns Err(target_index) if it isn’t a branching instruction.

Trait Implementations§

Source§

impl Clone for Instruction

Source§

fn clone(&self) -> Instruction

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Instruction

Source§

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

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

impl<'de> Deserialize<'de> for Instruction

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Instruction

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoSpanned for T

Source§

fn into_spanned(self, span: Span) -> Spanned<T>

Wrap items together with a span into Spanned. Read more
Source§

impl<D> OwoColorize for D

Source§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
Source§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
Source§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
Source§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
Source§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
Source§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
Source§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
Source§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
Source§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
Source§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
Source§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
Source§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
Source§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
Source§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
Source§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
Source§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
Source§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
Source§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
Source§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
Source§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
Source§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
Source§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
Source§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
Source§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
Source§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
Source§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
Source§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
Source§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
Source§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
Source§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
Source§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
Source§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
Source§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
Source§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
Source§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
Source§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
Source§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
Source§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
Source§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
Source§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
Source§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
Source§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
Source§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
Source§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
Source§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
Source§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
Source§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
Source§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
Source§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
Source§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
Source§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
Source§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
Source§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
Source§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,