FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Newtype for `[ir::Block]` (#8142) · RustPython/RustPython@6533a78 · GitHub

Repository navigation

Commit 6533a78

Browse files
authored
Newtype for [ir::Block] (#8142)
1 parent c95b48c commit 6533a78

2 files changed

Lines changed: 310 additions & 245 deletions

File tree

‎crates/codegen/src/compile.rs‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use crate::{
1313
IndexMap, IndexSet, ToPythonName,
1414
error::{CodegenError, CodegenErrorType, InternalError, PatternUnreachableReason},
15-
ir::{self, BlockIdx},
15+
ir::{self, Block, BlockIdx, Blocks},
1616
preprocess,
1717
symboltable::{self, CompilerScope, Symbol, SymbolFlags, SymbolScope, SymbolTable},
1818
unparse::UnparseExpr,
@@ -470,7 +470,7 @@ impl Compiler {
470470
flags: CodeFlags::empty(),
471471
source_path: source_file.name().to_owned(),
472472
private: None,
473-
blocks: vec![ir::Block::default()],
473+
blocks: Blocks::from([Block::default()]),
474474
current_block: BlockIdx::new(0),
475475
instr_sequence: ir::InstructionSequence::new(),
476476
instr_sequence_label_map: ir::InstructionSequenceLabelMap::new(),
@@ -547,8 +547,9 @@ impl Compiler {
547547
saved_annotations_instr_sequence,
548548
) = {
549549
let code = self.current_code_info();
550+
550551
(
551-
mem::replace(&mut code.blocks, vec![ir::Block::default()]),
552+
mem::replace(&mut code.blocks, Blocks::from([Block::default()])),
552553
mem::replace(&mut code.current_block, BlockIdx::new(0)),
553554
mem::replace(&mut code.instr_sequence, ir::InstructionSequence::new()),
554555
mem::replace(
@@ -1348,7 +1349,7 @@ impl Compiler {
13481349
flags,
13491350
source_path,
13501351
private,
1351-
blocks: vec![ir::Block::default()],
1352+
blocks: Blocks::from([Block::default()]),
13521353
current_block: BlockIdx::new(0),
13531354
instr_sequence: ir::InstructionSequence::new(),
13541355
instr_sequence_label_map: ir::InstructionSequenceLabelMap::new(),
@@ -10983,7 +10984,7 @@ impl Compiler {
1098310984
unwrap_internal(self, result);
1098410985
let code = self.current_code_info();
1098510986
let idx = BlockIdx::new(code.blocks.len().to_u32());
10986-
code.blocks.push(ir::Block::default());
10987+
code.blocks.push(Block::default());
1098710988
let result = code.push_unmapped_instr_sequence_label();
1098810989
unwrap_internal(self, result);
1098910990
idx
@@ -10998,7 +10999,7 @@ impl Compiler {
1099810999
unwrap_internal(self, result);
1099911000
let code = self.current_code_info();
1100011001
let idx = BlockIdx::new(code.blocks.len().to_u32());
11001-
code.blocks.push(ir::Block::default());
11002+
code.blocks.push(Block::default());
1100211003
let result = code.push_unlabeled_instr_sequence_block();
1100311004
unwrap_internal(self, result);
1100411005
idx

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL