mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-14 00:25:17 +00:00
Fix max_stacksize DEBUG to use const
This commit is contained in:
parent
6760d21399
commit
c3b1400240
1 changed files with 10 additions and 4 deletions
14
src/ir.rs
14
src/ir.rs
|
@ -167,19 +167,22 @@ impl CodeInfo {
|
|||
let mut startdepths = vec![u32::MAX; self.blocks.len()];
|
||||
startdepths[0] = 0;
|
||||
stack.push(Label(0));
|
||||
let debug = false;
|
||||
const DEBUG: bool = false;
|
||||
'process_blocks: while let Some(block) = stack.pop() {
|
||||
let mut depth = startdepths[block.0 as usize];
|
||||
if debug {
|
||||
if DEBUG {
|
||||
eprintln!("===BLOCK {}===", block.0);
|
||||
}
|
||||
let block = &self.blocks[block.0 as usize];
|
||||
for i in &block.instructions {
|
||||
let instr = &i.instr;
|
||||
let effect = instr.stack_effect(false);
|
||||
if DEBUG {
|
||||
eprint!("{instr:?}: {depth} {effect:+} => ");
|
||||
}
|
||||
let new_depth = add_ui(depth, effect);
|
||||
if debug {
|
||||
eprintln!("{:?}: {:+}, {:+} = {}", instr, effect, depth, new_depth);
|
||||
if DEBUG {
|
||||
eprintln!("{new_depth}");
|
||||
}
|
||||
if new_depth > maxdepth {
|
||||
maxdepth = new_depth
|
||||
|
@ -205,6 +208,9 @@ impl CodeInfo {
|
|||
}
|
||||
stackdepth_push(&mut stack, &mut startdepths, block.next, depth);
|
||||
}
|
||||
if DEBUG {
|
||||
eprintln!("DONE: {maxdepth}");
|
||||
}
|
||||
maxdepth
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue