File tree Expand file tree Collapse file tree 3 files changed +5
-15
lines changed
Expand file tree Collapse file tree 3 files changed +5
-15
lines changed Original file line number Diff line number Diff line change @@ -1352,20 +1352,17 @@ impl Compiler {
13521352 . collect ( )
13531353 } ;
13541354
1355- let module_idx = module. as_ref ( ) . map ( |s| self . name ( s. as_str ( ) ) ) ;
1356-
13571355 // from .... import (*fromlist)
13581356 self . emit_load_const ( ConstantData :: Integer {
13591357 value : ( * level) . into ( ) ,
13601358 } ) ;
13611359 self . emit_load_const ( ConstantData :: Tuple {
13621360 elements : from_list,
13631361 } ) ;
1364- if let Some ( idx) = module_idx {
1365- emit ! ( self , Instruction :: ImportName { idx } ) ;
1366- } else {
1367- emit ! ( self , Instruction :: ImportNameless ) ;
1368- }
1362+
1363+ let module_name = module. as_ref ( ) . map_or ( "" , |s| s. as_str ( ) ) ;
1364+ let module_idx = self . name ( module_name) ;
1365+ emit ! ( self , Instruction :: ImportName { idx: module_idx } ) ;
13691366
13701367 if import_star {
13711368 // from .... import *
Original file line number Diff line number Diff line change @@ -730,8 +730,6 @@ pub enum Instruction {
730730 ImportFrom {
731731 idx : Arg < NameIdx > ,
732732 } ,
733- /// Importing without name
734- ImportNameless ,
735733 /// Importing by name
736734 ImportName {
737735 idx : Arg < NameIdx > ,
@@ -1671,7 +1669,7 @@ impl Instruction {
16711669 pub fn stack_effect ( & self , arg : OpArg , jump : bool ) -> i32 {
16721670 match self {
16731671 Nop => 0 ,
1674- ImportName { .. } | ImportNameless => -1 ,
1672+ ImportName { .. } => -1 ,
16751673 ImportFrom { .. } => 1 ,
16761674 LoadFast ( _) | LoadNameAny ( _) | LoadGlobal ( _) | LoadDeref ( _) | LoadClassDeref ( _) => 1 ,
16771675 StoreFast ( _) | StoreLocal ( _) | StoreGlobal ( _) | StoreDeref ( _) => -1 ,
@@ -1912,7 +1910,6 @@ impl Instruction {
19121910 GetIter => w ! ( GetIter ) ,
19131911 GetLen => w ! ( GetLen ) ,
19141912 ImportFrom { idx } => w ! ( ImportFrom , name = idx) ,
1915- ImportNameless => w ! ( ImportNameless ) ,
19161913 ImportName { idx } => w ! ( ImportName , name = idx) ,
19171914 IsOp ( inv) => w ! ( IS_OP , ?inv) ,
19181915 JumpIfFalseOrPop { target } => w ! ( JumpIfFalseOrPop , target) ,
Original file line number Diff line number Diff line change @@ -955,10 +955,6 @@ impl ExecutingFrame<'_> {
955955 self . push_value ( obj) ;
956956 Ok ( None )
957957 }
958- bytecode:: Instruction :: ImportNameless => {
959- self . import ( vm, None ) ?;
960- Ok ( None )
961- }
962958 bytecode:: Instruction :: ImportName { idx } => {
963959 self . import ( vm, Some ( self . code . names [ idx. get ( arg) as usize ] ) ) ?;
964960 Ok ( None )
You can’t perform that action at this time.
0 commit comments