Skip to content

Commit 8adcd36

Browse files
committed
Adjust frame.rs
1 parent 7179e0d commit 8adcd36

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

crates/vm/src/frame.rs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ impl ExecutingFrame<'_> {
554554
Ok(None)
555555
}
556556
bytecode::Instruction::BinaryOp { op } => self.execute_bin_op(vm, op.get(arg)),
557-
bytecode::Instruction::BinarySubscript => {
557+
bytecode::Instruction::BinarySubscr => {
558558
let key = self.pop_value();
559559
let container = self.pop_value();
560560
self.state
@@ -697,7 +697,30 @@ impl ExecutingFrame<'_> {
697697
self.push_value(matched);
698698
Ok(None)
699699
}
700-
bytecode::Instruction::CompareOperation { op } => self.execute_compare(vm, op.get(arg)),
700+
bytecode::Instruction::CheckExcMatch(target) => {
701+
let b = self.pop_value();
702+
let a = self.pop_value();
703+
if let Some(tuple_of_exceptions) = b.downcast_ref::<PyTuple>() {
704+
for exception in tuple_of_exceptions {
705+
if !exception
706+
.is_subclass(vm.ctx.exceptions.base_exception_type.into(), vm)?
707+
{
708+
return Err(vm.new_type_error(
709+
"catching classes that do not inherit from BaseException is not allowed",
710+
));
711+
}
712+
}
713+
} else if !b.is_subclass(vm.ctx.exceptions.base_exception_type.into(), vm)? {
714+
return Err(vm.new_type_error(
715+
"catching classes that do not inherit from BaseException is not allowed",
716+
));
717+
}
718+
719+
let value = a.is_instance(&b, vm)?;
720+
self.push_value(vm.ctx.new_bool(value).into());
721+
self.pop_jump_if(vm, target.get(arg), false)
722+
}
723+
bytecode::Instruction::CompareOp { op } => self.execute_compare(vm, op.get(arg)),
701724
bytecode::Instruction::ContainsOp(invert) => {
702725
let b = self.pop_value();
703726
let a = self.pop_value();
@@ -765,7 +788,7 @@ impl ExecutingFrame<'_> {
765788
}
766789
Ok(None)
767790
}
768-
bytecode::Instruction::DeleteLocal(idx) => {
791+
bytecode::Instruction::DeleteName(idx) => {
769792
let name = self.code.names[idx.get(arg) as usize];
770793
let res = self.locals.mapping().ass_subscript(name, None, vm);
771794

@@ -778,7 +801,7 @@ impl ExecutingFrame<'_> {
778801
}
779802
Ok(None)
780803
}
781-
bytecode::Instruction::DeleteSubscript => self.execute_delete_subscript(vm),
804+
bytecode::Instruction::DeleteSubscr => self.execute_delete_subscript(vm),
782805
bytecode::Instruction::DictUpdate { index } => {
783806
// Stack before: [..., dict, ..., source] (source at TOS)
784807
// Stack after: [..., dict, ...] (source consumed)
@@ -990,29 +1013,6 @@ impl ExecutingFrame<'_> {
9901013
bytecode::Instruction::JumpIfFalseOrPop { target } => {
9911014
self.jump_if_or_pop(vm, target.get(arg), false)
9921015
}
993-
bytecode::Instruction::JumpIfNotExcMatch(target) => {
994-
let b = self.pop_value();
995-
let a = self.pop_value();
996-
if let Some(tuple_of_exceptions) = b.downcast_ref::<PyTuple>() {
997-
for exception in tuple_of_exceptions {
998-
if !exception
999-
.is_subclass(vm.ctx.exceptions.base_exception_type.into(), vm)?
1000-
{
1001-
return Err(vm.new_type_error(
1002-
"catching classes that do not inherit from BaseException is not allowed",
1003-
));
1004-
}
1005-
}
1006-
} else if !b.is_subclass(vm.ctx.exceptions.base_exception_type.into(), vm)? {
1007-
return Err(vm.new_type_error(
1008-
"catching classes that do not inherit from BaseException is not allowed",
1009-
));
1010-
}
1011-
1012-
let value = a.is_instance(&b, vm)?;
1013-
self.push_value(vm.ctx.new_bool(value).into());
1014-
self.pop_jump_if(vm, target.get(arg), false)
1015-
}
10161016
bytecode::Instruction::JumpIfTrueOrPop { target } => {
10171017
self.jump_if_or_pop(vm, target.get(arg), true)
10181018
}
@@ -1347,7 +1347,7 @@ impl ExecutingFrame<'_> {
13471347
self.pop_block();
13481348
Ok(None)
13491349
}
1350-
bytecode::Instruction::PopException => {
1350+
bytecode::Instruction::PopExcept => {
13511351
let block = self.pop_block();
13521352
if let BlockType::ExceptHandler { prev_exc } = block.typ {
13531353
vm.set_exception(prev_exc);
@@ -1367,7 +1367,7 @@ impl ExecutingFrame<'_> {
13671367
self.pop_value();
13681368
Ok(None)
13691369
}
1370-
bytecode::Instruction::Raise { kind } => self.execute_raise(vm, kind.get(arg)),
1370+
bytecode::Instruction::RaiseVarargs { kind } => self.execute_raise(vm, kind.get(arg)),
13711371
bytecode::Instruction::Resume { arg: resume_arg } => {
13721372
// Resume execution after yield, await, or at function start
13731373
// In CPython, this checks instrumentation and eval breaker
@@ -1415,7 +1415,7 @@ impl ExecutingFrame<'_> {
14151415
bytecode::Instruction::SetFunctionAttribute { attr } => {
14161416
self.execute_set_function_attribute(vm, attr.get(arg))
14171417
}
1418-
bytecode::Instruction::SetupAnnotation => self.setup_annotations(vm),
1418+
bytecode::Instruction::SetupAnnotations => self.setup_annotations(vm),
14191419
bytecode::Instruction::SetupAsyncWith { end } => {
14201420
let enter_res = self.pop_value();
14211421
self.push_block(BlockType::Finally {
@@ -1484,13 +1484,13 @@ impl ExecutingFrame<'_> {
14841484
.set_item(self.code.names[idx.get(arg) as usize], value, vm)?;
14851485
Ok(None)
14861486
}
1487-
bytecode::Instruction::StoreLocal(idx) => {
1487+
bytecode::Instruction::StoreName(idx) => {
14881488
let name = self.code.names[idx.get(arg) as usize];
14891489
let value = self.pop_value();
14901490
self.locals.mapping().ass_subscript(name, Some(value), vm)?;
14911491
Ok(None)
14921492
}
1493-
bytecode::Instruction::StoreSubscript => self.execute_store_subscript(vm),
1493+
bytecode::Instruction::StoreSubscr => self.execute_store_subscript(vm),
14941494
bytecode::Instruction::Subscript => self.execute_subscript(vm),
14951495
bytecode::Instruction::Swap { index } => {
14961496
let len = self.state.stack.len();

0 commit comments

Comments
 (0)