mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
Refactor block stack unwinding to enable finally execution.
This commit is contained in:
1 parent
9168455b12
commit
86fc18ec6c
3 files changed
+174
-131
No files matched your search
@@ -178,6 +178,22 @@ pub enum Instruction {
|
||||
start: Label,
|
||||
end: Label,
|
||||
},
|
||||
|
||||
/// Setup a finally handler, which will be called whenever one of this events occurs:
|
||||
/// - the block is popped
|
||||
/// - the function returns
|
||||
/// - an exception is returned
|
||||
SetupFinally {
|
||||
handler: Label,
|
||||
},
|
||||
|
||||
/// Marker bytecode for the end of a finally sequence.
|
||||
/// When this bytecode is executed, the eval loop does one of those things:
|
||||
/// - Continue at a certain bytecode position
|
||||
/// - Propagate the exception
|
||||
/// - Return from a function
|
||||
EndFinally,
|
||||
|
||||
SetupExcept {
|
||||
handler: Label,
|
||||
},
|
||||
@@ -475,7 +491,9 @@ impl Instruction {
|
||||
YieldValue => w!(YieldValue),
|
||||
YieldFrom => w!(YieldFrom),
|
||||
SetupLoop { start, end } => w!(SetupLoop, label_map[start], label_map[end]),
|
||||
SetupExcept { handler } => w!(SetupExcept, handler),
|
||||
SetupExcept { handler } => w!(SetupExcept, label_map[handler]),
|
||||
SetupFinally { handler } => w!(SetupFinally, label_map[handler]),
|
||||
EndFinally => w!(EndFinally),
|
||||
SetupWith { end } => w!(SetupWith, end),
|
||||
CleanupWith { end } => w!(CleanupWith, end),
|
||||
PopBlock => w!(PopBlock),
|
||||
|
||||
Reference in new issue
Block a user