@@ -432,15 +432,19 @@ impl InstructionMetadata for Instruction {
432432 }
433433 }
434434
435- fn unconditional_branch ( & self ) -> bool {
435+ fn is_unconditional_jump ( & self ) -> bool {
436436 matches ! (
437437 self ,
438438 Self :: JumpForward { .. }
439439 | Self :: JumpBackward { .. }
440440 | Self :: JumpBackwardNoInterrupt { .. }
441- | Self :: ReturnValue
442- | Self :: RaiseVarargs { .. }
443- | Self :: Reraise { .. }
441+ )
442+ }
443+
444+ fn is_scope_exit ( & self ) -> bool {
445+ matches ! (
446+ self ,
447+ Self :: ReturnValue | Self :: RaiseVarargs { .. } | Self :: Reraise { .. }
444448 )
445449 }
446450
@@ -997,7 +1001,11 @@ impl InstructionMetadata for PseudoInstruction {
9971001 }
9981002 }
9991003
1000- fn unconditional_branch ( & self ) -> bool {
1004+ fn is_scope_exit ( & self ) -> bool {
1005+ false
1006+ }
1007+
1008+ fn is_unconditional_jump ( & self ) -> bool {
10011009 matches ! ( self , Self :: Jump { .. } | Self :: JumpNoInterrupt { .. } )
10021010 }
10031011
@@ -1085,7 +1093,9 @@ macro_rules! inst_either {
10851093impl InstructionMetadata for AnyInstruction {
10861094 inst_either ! ( fn label_arg( & self ) -> Option <Arg <Label >>) ;
10871095
1088- inst_either ! ( fn unconditional_branch( & self ) -> bool ) ;
1096+ inst_either ! ( fn is_unconditional_jump( & self ) -> bool ) ;
1097+
1098+ inst_either ! ( fn is_scope_exit( & self ) -> bool ) ;
10891099
10901100 inst_either ! ( fn stack_effect( & self , arg: OpArg ) -> i32 ) ;
10911101
@@ -1142,16 +1152,9 @@ pub trait InstructionMetadata {
11421152 /// Gets the label stored inside this instruction, if it exists.
11431153 fn label_arg ( & self ) -> Option < Arg < Label > > ;
11441154
1145- /// Whether this is an unconditional branching.
1146- ///
1147- /// # Examples
1148- ///
1149- /// ```
1150- /// use rustpython_compiler_core::bytecode::{Arg, Instruction, InstructionMetadata};
1151- /// let jump_inst = Instruction::JumpForward { target: Arg::marker() };
1152- /// assert!(jump_inst.unconditional_branch())
1153- /// ```
1154- fn unconditional_branch ( & self ) -> bool ;
1155+ fn is_scope_exit ( & self ) -> bool ;
1156+
1157+ fn is_unconditional_jump ( & self ) -> bool ;
11551158
11561159 /// What effect this instruction has on the stack
11571160 ///
0 commit comments