```
pub enum OpCode {
```## Show 51 variants

OpConstant(ConstantIdx),
OpPop,
OpInvert,
OpNegate,
OpAdd,
OpSub,
OpMul,
OpDiv,
OpEqual,
OpLess,
OpLessOrEq,
OpMore,
OpMoreOrEq,
OpJump(JumpOffset),
OpJumpIfTrue(JumpOffset),
OpJumpIfFalse(JumpOffset),
OpJumpIfCatchable(JumpOffset),
OpJumpIfNotFound(JumpOffset),
OpJumpIfNoFinaliseRequest(JumpOffset),
OpAttrs(Count),
OpAttrsUpdate,
OpAttrsSelect,
OpAttrsTrySelect,
OpHasAttr,
OpValidateClosedFormals,
OpPushWith(StackIdx),
OpPopWith,
OpResolveWith,
OpList(Count),
OpConcat,
OpInterpolate(Count),
OpCoerceToString(CoercionKind),
OpFindFile,
OpResolveHomePath,
OpAssertBool,
OpAssertAttrs,
OpGetLocal(StackIdx),
OpCloseScope(Count),
OpAssertFail,
OpCall,
OpGetUpvalue(UpvalueIdx),
OpClosure(ConstantIdx),
OpThunkClosure(ConstantIdx),
OpThunkSuspended(ConstantIdx),
OpForce,
OpFinalise(StackIdx),
OpReturn,
DataStackIdx(StackIdx),
DataDeferredLocal(StackIdx),
DataUpvalueIdx(UpvalueIdx),
DataCaptureWith,
}

## Expand description

All variants of this enum carry a bounded amount of data to ensure that no heap allocations are needed for an Opcode.

In documentation comments, stack positions are referred to by
indices written in `{}`

as such, where required:

```
--- top of the stack
/
v
[ ... | 3 | 2 | 1 | 0 ]
^
/
2 values deep ---
```

Unless otherwise specified, operations leave their result at the top of the stack.

## Variants§

### OpConstant(ConstantIdx)

Push a constant onto the stack.

### OpPop

Discard a value from the stack.

### OpInvert

Invert the boolean at the top of the stack.

### OpNegate

Invert the sign of the number at the top of the stack.

### OpAdd

Sum up the two numbers at the top of the stack.

### OpSub

Subtract the number at {1} from the number at {2}.

### OpMul

Multiply the two numbers at the top of the stack.

### OpDiv

Divide the two numbers at the top of the stack.

### OpEqual

Check the two values at the top of the stack for Nix-equality.

### OpLess

Check whether the value at {2} is less than {1}.

### OpLessOrEq

Check whether the value at {2} is less than or equal to {1}.

### OpMore

Check whether the value at {2} is greater than {1}.

### OpMoreOrEq

Check whether the value at {2} is greater than or equal to {1}.

### OpJump(JumpOffset)

Jump forward in the bytecode specified by the number of instructions in its usize operand.

### OpJumpIfTrue(JumpOffset)

Jump forward in the bytecode specified by the number of
instructions in its usize operand, *if* the value at the top
of the stack is `true`

.

### OpJumpIfFalse(JumpOffset)

Jump forward in the bytecode specified by the number of
instructions in its usize operand, *if* the value at the top
of the stack is `false`

.

### OpJumpIfCatchable(JumpOffset)

Pop one stack item and jump forward in the bytecode
specified by the number of instructions in its usize
operand, *if* the value at the top of the stack is a
Value::Catchable.

### OpJumpIfNotFound(JumpOffset)

Jump forward in the bytecode specified by the number of
instructions in its usize operand, *if* the value at the top
of the stack is the internal value representing a missing
attribute set key.

### OpJumpIfNoFinaliseRequest(JumpOffset)

Jump forward in the bytecode specified by the number of
instructions in its usize operand, *if* the value at the top
of the stack is *not* the internal value requesting a
stack value finalisation.

### OpAttrs(Count)

Construct an attribute set from the given number of key-value pairs on the top of the stack

Note that this takes the count of *pairs*, not the number of *stack values* - the actual
number of values popped off the stack will be twice the argument to this op

### OpAttrsUpdate

Merge the attribute set at {2} into the attribute set at {1}, and leave the new set at the top of the stack.

### OpAttrsSelect

Select the attribute with the name at {1} from the set at {2}.

### OpAttrsTrySelect

Select the attribute with the name at {1} from the set at {2}, but leave
a `Value::AttrNotFound`

in the stack instead of failing if it is
missing.

### OpHasAttr

Check for the presence of the attribute with the name at {1} in the set at {2}.

### OpValidateClosedFormals

Throw an error if the attribute set at the top of the stack has any attributes other than those listed in the formals of the current lambda

Panics if the current frame is not a lambda with formals

### OpPushWith(StackIdx)

Push a value onto the runtime `with`

-stack to enable dynamic identifier
resolution. The absolute stack index of the value is supplied as a usize
operand.

### OpPopWith

Pop the last runtime `with`

-stack element.

### OpResolveWith

Dynamically resolve an identifier with the name at {1} from the runtime
`with`

-stack.

### OpList(Count)

Construct a list from the given number of values at the top of the stack.

### OpConcat

Concatenate the lists at {2} and {1}.

### OpInterpolate(Count)

Interpolate the given number of string fragments into a single string.

### OpCoerceToString(CoercionKind)

Force the Value on the stack and coerce it to a string

### OpFindFile

Attempt to resolve the Value on the stack using the configured `NixSearchPath`

### OpResolveHomePath

Attempt to resolve a path literal relative to the home dir

### OpAssertBool

Assert that the value at {1} is a boolean, and fail with a runtime error otherwise.

### OpAssertAttrs

### OpGetLocal(StackIdx)

Access local identifiers with statically known positions.

### OpCloseScope(Count)

Close scopes while leaving their expression value around.

### OpAssertFail

Return an error indicating that an `assert`

failed

### OpCall

Call the value at {1} in a new VM callframe

### OpGetUpvalue(UpvalueIdx)

Retrieve the upvalue at the given index from the closure or thunk currently under evaluation.

### OpClosure(ConstantIdx)

Construct a closure which has upvalues but no self-references

### OpThunkClosure(ConstantIdx)

Construct a closure which has self-references (direct or via upvalues)

### OpThunkSuspended(ConstantIdx)

Construct a suspended thunk, used to delay a computation for laziness.

### OpForce

Force the value at {1} until it is a `Thunk::Evaluated`

.

### OpFinalise(StackIdx)

Finalise initialisation of the upvalues of the value in the given stack index (which must be a Value::Thunk) after the scope is fully bound.

### OpReturn

Final instruction emitted in a chunk. Does not have an inherent effect, but can simplify VM logic as a marker in some cases.

Can be thought of as “returning” the value to the parent frame, hence the name.

### DataStackIdx(StackIdx)

Populate a static upvalue by copying from the stack immediately.

### DataDeferredLocal(StackIdx)

Populate a static upvalue of a thunk by copying it the stack, but do when the thunk is finalised (by OpFinalise) rather than immediately.

### DataUpvalueIdx(UpvalueIdx)

Populate a static upvalue by copying it from the upvalues of an enclosing scope.

### DataCaptureWith

Populate dynamic upvalues by saving a copy of the with-stack.

## Trait Implementations§

source§### impl PartialEq for OpCode

### impl PartialEq for OpCode

### impl Copy for OpCode

### impl Eq for OpCode

### impl StructuralPartialEq for OpCode

## Auto Trait Implementations§

### impl RefUnwindSafe for OpCode

### impl Send for OpCode

### impl Sync for OpCode

### impl Unpin for OpCode

### impl UnwindSafe for OpCode

## Blanket Implementations§

source§### impl<T> BorrowMut<T> for Twhere
T: ?Sized,

### impl<T> BorrowMut<T> for Twhere
T: ?Sized,

source§#### fn borrow_mut(&mut self) -> &mut T

#### fn borrow_mut(&mut self) -> &mut T

source§### impl<Q, K> Equivalent<K> for Q

### impl<Q, K> Equivalent<K> for Q

source§### impl<Q, K> Equivalent<K> for Q

### impl<Q, K> Equivalent<K> for Q

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

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

`key`

and return `true`

if they are equal.