Skip to content

Commit a8a489e

Browse files
committed
Remove ImportNameless bytecode
1 parent d287d1e commit a8a489e

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

crates/codegen/src/compile.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,20 +1351,17 @@ impl Compiler {
13511351
.collect()
13521352
};
13531353

1354-
let module_idx = module.as_ref().map(|s| self.name(s.as_str()));
1355-
13561354
// from .... import (*fromlist)
13571355
self.emit_load_const(ConstantData::Integer {
13581356
value: (*level).into(),
13591357
});
13601358
self.emit_load_const(ConstantData::Tuple {
13611359
elements: from_list,
13621360
});
1363-
if let Some(idx) = module_idx {
1364-
emit!(self, Instruction::ImportName { idx });
1365-
} else {
1366-
emit!(self, Instruction::ImportNameless);
1367-
}
1361+
1362+
let module_name = module.as_ref().map_or("", |s| s.as_str());
1363+
let module_idx = self.name(module_name);
1364+
emit!(self, Instruction::ImportName { idx: module_idx });
13681365

13691366
if import_star {
13701367
// from .... import *

crates/compiler-core/src/bytecode.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,6 @@ pub enum Instruction {
662662
ImportFrom {
663663
idx: Arg<NameIdx>,
664664
},
665-
/// Importing without name
666-
ImportNameless,
667665
/// Importing by name
668666
ImportName {
669667
idx: Arg<NameIdx>,
@@ -1607,7 +1605,7 @@ impl Instruction {
16071605
pub fn stack_effect(&self, arg: OpArg, jump: bool) -> i32 {
16081606
match self {
16091607
Nop => 0,
1610-
ImportName { .. } | ImportNameless => -1,
1608+
ImportName { .. } => -1,
16111609
ImportFrom { .. } => 1,
16121610
LoadFast(_) | LoadNameAny(_) | LoadGlobal(_) | LoadDeref(_) | LoadClassDeref(_) => 1,
16131611
StoreFast(_) | StoreLocal(_) | StoreGlobal(_) | StoreDeref(_) => -1,
@@ -1844,7 +1842,6 @@ impl Instruction {
18441842
GetIter => w!(GetIter),
18451843
GetLen => w!(GetLen),
18461844
ImportFrom { idx } => w!(ImportFrom, name = idx),
1847-
ImportNameless => w!(ImportNameless),
18481845
ImportName { idx } => w!(ImportName, name = idx),
18491846
IsOp(inv) => w!(IS_OP, ?inv),
18501847
JumpIfFalseOrPop { target } => w!(JumpIfFalseOrPop, target),

crates/vm/src/frame.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -939,10 +939,6 @@ impl ExecutingFrame<'_> {
939939
self.push_value(obj);
940940
Ok(None)
941941
}
942-
bytecode::Instruction::ImportNameless => {
943-
self.import(vm, None)?;
944-
Ok(None)
945-
}
946942
bytecode::Instruction::ImportName { idx } => {
947943
self.import(vm, Some(self.code.names[idx.get(arg) as usize]))?;
948944
Ok(None)

0 commit comments

Comments
 (0)