Skip to content

Commit 65086a3

Browse files
committed
Fix merge
1 parent 672a95e commit 65086a3

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

crates/compiler-core/src/bytecode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use num_complex::Complex64;
1515
use rustpython_wtf8::{Wtf8, Wtf8Buf};
1616

1717
pub use crate::bytecode::{
18-
instruction::{Arg, Instruction},
18+
instruction::{Arg, Instruction, encode_load_super_attr_arg},
1919
oparg::{
2020
BinaryOperator, BuildSliceArgCount, ComparisonOperator, ConvertValueOparg,
2121
IntrinsicFunction1, IntrinsicFunction2, Invert, Label, MakeFunctionFlags, NameIdx, OpArg,

crates/compiler-core/src/bytecode/instruction.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,3 +917,18 @@ impl<T: OpArgType> fmt::Debug for Arg<T> {
917917
write!(f, "Arg<{}>", core::any::type_name::<T>())
918918
}
919919
}
920+
921+
/// Encode LOAD_SUPER_ATTR oparg: bit 0 = load_method, bit 1 = has_class, bits 2+ = name index.
922+
#[inline]
923+
pub const fn encode_load_super_attr_arg(name_idx: u32, load_method: bool, has_class: bool) -> u32 {
924+
(name_idx << 2) | ((has_class as u32) << 1) | (load_method as u32)
925+
}
926+
927+
/// Decode LOAD_SUPER_ATTR oparg: returns (name_idx, load_method, has_class).
928+
#[inline]
929+
const fn decode_load_super_attr_arg(oparg: u32) -> (u32, bool, bool) {
930+
let load_method = (oparg & 1) == 1;
931+
let has_class = (oparg & 2) == 2;
932+
let name_idx = oparg >> 2;
933+
(name_idx, load_method, has_class)
934+
}

0 commit comments

Comments
 (0)