#[repr(u8)]
pub enum Instruction {
Show 94 variants ImportName { idx: Arg<NameIdx>, }, ImportNameless, ImportStar, ImportFrom { idx: Arg<NameIdx>, }, LoadFast(Arg<NameIdx>), LoadNameAny(Arg<NameIdx>), LoadGlobal(Arg<NameIdx>), LoadDeref(Arg<NameIdx>), LoadClassDeref(Arg<NameIdx>), StoreFast(Arg<NameIdx>), StoreLocal(Arg<NameIdx>), StoreGlobal(Arg<NameIdx>), StoreDeref(Arg<NameIdx>), DeleteFast(Arg<NameIdx>), DeleteLocal(Arg<NameIdx>), DeleteGlobal(Arg<NameIdx>), DeleteDeref(Arg<NameIdx>), LoadClosure(Arg<NameIdx>), Subscript, StoreSubscript, DeleteSubscript, StoreAttr { idx: Arg<NameIdx>, }, DeleteAttr { idx: Arg<NameIdx>, }, LoadConst { idx: Arg<u32>, }, UnaryOperation { op: Arg<UnaryOperator>, }, BinaryOperation { op: Arg<BinaryOperator>, }, BinaryOperationInplace { op: Arg<BinaryOperator>, }, LoadAttr { idx: Arg<NameIdx>, }, TestOperation { op: Arg<TestOperator>, }, CompareOperation { op: Arg<ComparisonOperator>, }, Pop, Rotate2, Rotate3, Duplicate, Duplicate2, GetIter, Continue { target: Arg<Label>, }, Break { target: Arg<Label>, }, Jump { target: Arg<Label>, }, JumpIfTrue { target: Arg<Label>, }, JumpIfFalse { target: Arg<Label>, }, JumpIfTrueOrPop { target: Arg<Label>, }, JumpIfFalseOrPop { target: Arg<Label>, }, MakeFunction(Arg<MakeFunctionFlags>), CallFunctionPositional { nargs: Arg<u32>, }, CallFunctionKeyword { nargs: Arg<u32>, }, CallFunctionEx { has_kwargs: Arg<bool>, }, LoadMethod { idx: Arg<NameIdx>, }, CallMethodPositional { nargs: Arg<u32>, }, CallMethodKeyword { nargs: Arg<u32>, }, CallMethodEx { has_kwargs: Arg<bool>, }, ForIter { target: Arg<Label>, }, ReturnValue, YieldValue, YieldFrom, SetupAnnotation, SetupLoop, SetupFinally { handler: Arg<Label>, }, EnterFinally, EndFinally, SetupExcept { handler: Arg<Label>, }, SetupWith { end: Arg<Label>, }, WithCleanupStart, WithCleanupFinish, PopBlock, Raise { kind: Arg<RaiseKind>, }, BuildString { size: Arg<u32>, }, BuildTuple { size: Arg<u32>, }, BuildTupleUnpack { size: Arg<u32>, }, BuildList { size: Arg<u32>, }, BuildListUnpack { size: Arg<u32>, }, BuildSet { size: Arg<u32>, }, BuildSetUnpack { size: Arg<u32>, }, BuildMap { size: Arg<u32>, }, BuildMapForCall { size: Arg<u32>, }, DictUpdate, BuildSlice { step: Arg<bool>, }, ListAppend { i: Arg<u32>, }, SetAdd { i: Arg<u32>, }, MapAdd { i: Arg<u32>, }, PrintExpr, LoadBuildClass, UnpackSequence { size: Arg<u32>, }, UnpackEx { args: Arg<UnpackExArgs>, }, FormatValue { conversion: Arg<ConversionFlag>, }, PopException, Reverse { amount: Arg<u32>, }, GetAwaitable, BeforeAsyncWith, SetupAsyncWith { end: Arg<Label>, }, GetAIter, GetANext, EndAsyncFor, ExtendedArg,
}
Expand description

A Single bytecode instruction.

Variants§

§

ImportName

Importing by name

Fields

§

ImportNameless

Importing without name

§

ImportStar

Import *

§

ImportFrom

from … import …

Fields

§

LoadFast(Arg<NameIdx>)

§

LoadNameAny(Arg<NameIdx>)

§

LoadGlobal(Arg<NameIdx>)

§

LoadDeref(Arg<NameIdx>)

§

LoadClassDeref(Arg<NameIdx>)

§

StoreFast(Arg<NameIdx>)

§

StoreLocal(Arg<NameIdx>)

§

StoreGlobal(Arg<NameIdx>)

§

StoreDeref(Arg<NameIdx>)

§

DeleteFast(Arg<NameIdx>)

§

DeleteLocal(Arg<NameIdx>)

§

DeleteGlobal(Arg<NameIdx>)

§

DeleteDeref(Arg<NameIdx>)

§

LoadClosure(Arg<NameIdx>)

§

Subscript

§

StoreSubscript

§

DeleteSubscript

§

StoreAttr

Fields

§

DeleteAttr

Fields

§

LoadConst

Fields

§idx: Arg<u32>

index into constants vec

§

UnaryOperation

Fields

§

BinaryOperation

§

BinaryOperationInplace

§

LoadAttr

Fields

§

TestOperation

Fields

§

CompareOperation

§

Pop

§

Rotate2

§

Rotate3

§

Duplicate

§

Duplicate2

§

GetIter

§

Continue

Fields

§target: Arg<Label>
§

Break

Fields

§target: Arg<Label>
§

Jump

Fields

§target: Arg<Label>
§

JumpIfTrue

Pop the top of the stack, and jump if this value is true.

Fields

§target: Arg<Label>
§

JumpIfFalse

Pop the top of the stack, and jump if this value is false.

Fields

§target: Arg<Label>
§

JumpIfTrueOrPop

Peek at the top of the stack, and jump if this value is true. Otherwise, pop top of stack.

Fields

§target: Arg<Label>
§

JumpIfFalseOrPop

Peek at the top of the stack, and jump if this value is false. Otherwise, pop top of stack.

Fields

§target: Arg<Label>
§

MakeFunction(Arg<MakeFunctionFlags>)

§

CallFunctionPositional

Fields

§nargs: Arg<u32>
§

CallFunctionKeyword

Fields

§nargs: Arg<u32>
§

CallFunctionEx

Fields

§has_kwargs: Arg<bool>
§

LoadMethod

Fields

§

CallMethodPositional

Fields

§nargs: Arg<u32>
§

CallMethodKeyword

Fields

§nargs: Arg<u32>
§

CallMethodEx

Fields

§has_kwargs: Arg<bool>
§

ForIter

Fields

§target: Arg<Label>
§

ReturnValue

§

YieldValue

§

YieldFrom

§

SetupAnnotation

§

SetupLoop

§

SetupFinally

Setup a finally handler, which will be called whenever one of this events occurs:

  • the block is popped
  • the function returns
  • an exception is returned

Fields

§handler: Arg<Label>
§

EnterFinally

Enter a finally block, without returning, excepting, just because we are there.

§

EndFinally

Marker bytecode for the end of a finally sequence. When this bytecode is executed, the eval loop does one of those things:

  • Continue at a certain bytecode position
  • Propagate the exception
  • Return from a function
  • Do nothing at all, just continue
§

SetupExcept

Fields

§handler: Arg<Label>
§

SetupWith

Fields

§end: Arg<Label>
§

WithCleanupStart

§

WithCleanupFinish

§

PopBlock

§

Raise

Fields

§

BuildString

Fields

§size: Arg<u32>
§

BuildTuple

Fields

§size: Arg<u32>
§

BuildTupleUnpack

Fields

§size: Arg<u32>
§

BuildList

Fields

§size: Arg<u32>
§

BuildListUnpack

Fields

§size: Arg<u32>
§

BuildSet

Fields

§size: Arg<u32>
§

BuildSetUnpack

Fields

§size: Arg<u32>
§

BuildMap

Fields

§size: Arg<u32>
§

BuildMapForCall

Fields

§size: Arg<u32>
§

DictUpdate

§

BuildSlice

Fields

§step: Arg<bool>

whether build a slice with a third step argument

§

ListAppend

Fields

§

SetAdd

Fields

§

MapAdd

Fields

§

PrintExpr

§

LoadBuildClass

§

UnpackSequence

Fields

§size: Arg<u32>
§

UnpackEx

Fields

§

FormatValue

Fields

§conversion: Arg<ConversionFlag>
§

PopException

§

Reverse

Fields

§amount: Arg<u32>
§

GetAwaitable

§

BeforeAsyncWith

§

SetupAsyncWith

Fields

§end: Arg<Label>
§

GetAIter

§

GetANext

§

EndAsyncFor

§

ExtendedArg

Implementations§

source§

impl Instruction

source

pub fn label_arg(&self) -> Option<Arg<Label>>

Gets the label stored inside this instruction, if it exists

source

pub fn unconditional_branch(&self) -> bool

Whether this is an unconditional branching

§Examples
use rustpython_compiler_core::bytecode::{Arg, Instruction};
let jump_inst = Instruction::Jump { target: Arg::marker() };
assert!(jump_inst.unconditional_branch())
source

pub fn stack_effect(&self, arg: OpArg, jump: bool) -> i32

What effect this instruction has on the stack

§Examples
use rustpython_compiler_core::bytecode::{Arg, Instruction, Label, UnaryOperator};
let (target, jump_arg) = Arg::new(Label(0xF));
let jump_instruction = Instruction::Jump { target };
let (op, invert_arg) = Arg::new(UnaryOperator::Invert);
let invert_instruction = Instruction::UnaryOperation { op };
assert_eq!(jump_instruction.stack_effect(jump_arg, true), 0);
assert_eq!(invert_instruction.stack_effect(invert_arg, false), 0);
source

pub fn display<'a>( &'a self, arg: OpArg, ctx: &'a impl InstrDisplayContext ) -> impl Display + 'a

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 From<Instruction> for u8

source§

fn from(ins: Instruction) -> u8

Converts to this type from the input type.
source§

impl PartialEq for Instruction

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<u8> for Instruction

§

type Error = MarshalError

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

fn try_from(value: u8) -> Result<Self, MarshalError>

Performs the conversion.
source§

impl Copy for Instruction

source§

impl Eq for Instruction

source§

impl StructuralPartialEq for Instruction

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

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

source§

fn exact_from(value: T) -> U

source§

impl<T, U> ExactInto<U> for T
where U: ExactFrom<T>,

source§

fn exact_into(self) -> U

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> OverflowingInto<U> for T
where U: OverflowingFrom<T>,

source§

impl<T, U> RoundingInto<U> for T
where U: RoundingFrom<T>,

source§

impl<T, U> SaturatingInto<U> for T
where U: SaturatingFrom<T>,

source§

impl<T> ToDebugString for T
where T: Debug,

source§

fn to_debug_string(&self) -> String

Returns the String produced by Ts Debug implementation.

§Examples
use malachite_base::strings::ToDebugString;

assert_eq!([1, 2, 3].to_debug_string(), "[1, 2, 3]");
assert_eq!(
    [vec![2, 3], vec![], vec![4]].to_debug_string(),
    "[[2, 3], [], [4]]"
);
assert_eq!(Some(5).to_debug_string(), "Some(5)");
source§

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

§

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>,

§

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>,

§

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, U> WrappingInto<U> for T
where U: WrappingFrom<T>,

source§

fn wrapping_into(self) -> U