@@ -197,48 +197,74 @@ impl CodeInfo {
197197 . filter ( |b| b. next != BlockIdx :: NULL || !b. instructions . is_empty ( ) )
198198 {
199199 for info in & mut block. instructions {
200- match info. instr {
200+ // Special case for:
201+ // - `RealInstruction::LoadAttr`
202+ // - `RealInstruction::LoadSuperAttr`
203+
204+ if let Some ( instr) = info. instr . real ( ) {
205+ match instr {
206+ // LOAD_ATTR → encode with method flag=0
207+ RealInstruction :: LoadAttr { idx } => {
208+ let encoded = encode_load_attr_arg ( idx. get ( info. arg ) , false ) ;
209+ info. arg = OpArg ( encoded) ;
210+ info. instr = RealInstruction :: LoadAttr { idx : Arg :: marker ( ) } . into ( ) ;
211+ }
212+ // LOAD_SUPER_ATTR → encode with flags=0b10 (method=0, class=1)
213+ RealInstruction :: LoadSuperAttr { arg : idx } => {
214+ let encoded =
215+ encode_load_super_attr_arg ( idx. get ( info. arg ) , false , true ) ;
216+ info. arg = OpArg ( encoded) ;
217+ info. instr =
218+ RealInstruction :: LoadSuperAttr { arg : Arg :: marker ( ) } . into ( ) ;
219+ }
220+ _ => { }
221+ }
222+
223+ continue ;
224+ }
225+
226+ let instr = info. instr . expect_pseudo ( ) ;
227+
228+ match instr {
201229 // LOAD_ATTR_METHOD pseudo → LOAD_ATTR (with method flag=1)
202- Instruction :: Pseudo ( PseudoInstruction :: LoadAttrMethod { idx } ) => {
230+ PseudoInstruction :: LoadAttrMethod { idx } => {
203231 let encoded = encode_load_attr_arg ( idx. get ( info. arg ) , true ) ;
204232 info. arg = OpArg ( encoded) ;
205233 info. instr = RealInstruction :: LoadAttr { idx : Arg :: marker ( ) } . into ( ) ;
206234 }
207- // LOAD_ATTR → encode with method flag=0
208- Instruction :: Real ( RealInstruction :: LoadAttr { idx } ) => {
209- let encoded = encode_load_attr_arg ( idx. get ( info. arg ) , false ) ;
210- info. arg = OpArg ( encoded) ;
211- info. instr = RealInstruction :: LoadAttr { idx : Arg :: marker ( ) } . into ( ) ;
212- }
213235 // POP_BLOCK pseudo → NOP
214- Instruction :: Pseudo ( PseudoInstruction :: PopBlock ) => {
236+ PseudoInstruction :: PopBlock => {
215237 info. instr = RealInstruction :: Nop . into ( ) ;
216238 }
217239 // LOAD_SUPER_METHOD pseudo → LOAD_SUPER_ATTR (flags=0b11: method=1, class=1)
218- Instruction :: Pseudo ( PseudoInstruction :: LoadSuperMethod { idx } ) => {
240+ PseudoInstruction :: LoadSuperMethod { idx } => {
219241 let encoded = encode_load_super_attr_arg ( idx. get ( info. arg ) , true , true ) ;
220242 info. arg = OpArg ( encoded) ;
221243 info. instr = RealInstruction :: LoadSuperAttr { arg : Arg :: marker ( ) } . into ( ) ;
222244 }
223245 // LOAD_ZERO_SUPER_ATTR pseudo → LOAD_SUPER_ATTR (flags=0b00: method=0, class=0)
224- Instruction :: Pseudo ( PseudoInstruction :: LoadZeroSuperAttr { idx } ) => {
246+ PseudoInstruction :: LoadZeroSuperAttr { idx } => {
225247 let encoded = encode_load_super_attr_arg ( idx. get ( info. arg ) , false , false ) ;
226248 info. arg = OpArg ( encoded) ;
227249 info. instr = RealInstruction :: LoadSuperAttr { arg : Arg :: marker ( ) } . into ( ) ;
228250 }
229251 // LOAD_ZERO_SUPER_METHOD pseudo → LOAD_SUPER_ATTR (flags=0b01: method=1, class=0)
230- Instruction :: Pseudo ( PseudoInstruction :: LoadZeroSuperMethod { idx } ) => {
252+ PseudoInstruction :: LoadZeroSuperMethod { idx } => {
231253 let encoded = encode_load_super_attr_arg ( idx. get ( info. arg ) , true , false ) ;
232254 info. arg = OpArg ( encoded) ;
233255 info. instr = RealInstruction :: LoadSuperAttr { arg : Arg :: marker ( ) } . into ( ) ;
234256 }
235- // LOAD_SUPER_ATTR → encode with flags=0b10 (method=0, class=1)
236- Instruction :: Real ( RealInstruction :: LoadSuperAttr { arg : idx } ) => {
237- let encoded = encode_load_super_attr_arg ( idx. get ( info. arg ) , false , true ) ;
238- info. arg = OpArg ( encoded) ;
239- info. instr = RealInstruction :: LoadSuperAttr { arg : Arg :: marker ( ) } . into ( ) ;
257+ PseudoInstruction :: Jump { .. } => {
258+ // PseudoInstruction::Jump instructions are handled later
259+ }
260+ PseudoInstruction :: JumpNoInterrupt { .. }
261+ | PseudoInstruction :: Reserved258
262+ | PseudoInstruction :: SetupCleanup
263+ | PseudoInstruction :: SetupFinally
264+ | PseudoInstruction :: SetupWith
265+ | PseudoInstruction :: StoreFastMaybeNull => {
266+ unimplemented ! ( "Got a placeholder pseudo instruction ({instr:?})" )
240267 }
241- _ => { }
242268 }
243269 }
244270 }
0 commit comments