@@ -984,15 +984,14 @@ impl<O: OutputStream> Compiler<O> {
984984 Ok ( ( ) )
985985 }
986986
987- fn option_stmt_to_bool ( & mut self , stmts : & Option < ast:: Suite > ) -> bool {
988- match & stmts {
989- Some ( stmts) => self . find_ann ( stmts) ,
990- None => false ,
991- }
992- }
993-
994- fn find_ann ( & mut self , body : & [ ast:: Statement ] ) -> bool {
987+ fn find_ann ( & self , body : & [ ast:: Statement ] ) -> bool {
995988 use ast:: StatementType :: * ;
989+ let option_stmt_to_bool = |suit : & Option < ast:: Suite > | -> bool {
990+ match suit {
991+ Some ( stmts) => self . find_ann ( stmts) ,
992+ None => false ,
993+ }
994+ } ;
996995
997996 for statement in body {
998997 let res = match & statement. node {
@@ -1007,17 +1006,17 @@ impl<O: OutputStream> Compiler<O> {
10071006 iter : _,
10081007 body,
10091008 orelse,
1010- } => self . find_ann ( body) || self . option_stmt_to_bool ( orelse) ,
1009+ } => self . find_ann ( body) || option_stmt_to_bool ( orelse) ,
10111010 If {
10121011 test : _,
10131012 body,
10141013 orelse,
1015- } => self . find_ann ( body) || self . option_stmt_to_bool ( orelse) ,
1014+ } => self . find_ann ( body) || option_stmt_to_bool ( orelse) ,
10161015 While {
10171016 test : _,
10181017 body,
10191018 orelse,
1020- } => self . find_ann ( body) || self . option_stmt_to_bool ( orelse) ,
1019+ } => self . find_ann ( body) || option_stmt_to_bool ( orelse) ,
10211020 With {
10221021 is_async : _,
10231022 items : _,
@@ -1029,9 +1028,9 @@ impl<O: OutputStream> Compiler<O> {
10291028 orelse,
10301029 finalbody,
10311030 } => {
1032- self . find_ann ( body)
1033- || self . option_stmt_to_bool ( orelse)
1034- || self . option_stmt_to_bool ( finalbody)
1031+ self . find_ann ( & body)
1032+ || option_stmt_to_bool ( orelse)
1033+ || option_stmt_to_bool ( finalbody)
10351034 }
10361035 _ => false ,
10371036 } ;
@@ -1097,15 +1096,7 @@ impl<O: OutputStream> Compiler<O> {
10971096 } ) ;
10981097 // setup annotations
10991098 if self . find_ann ( body) {
1100- self . emit ( Instruction :: BuildMap {
1101- size : 0 ,
1102- unpack : false ,
1103- for_call : false ,
1104- } ) ;
1105- self . emit ( Instruction :: StoreName {
1106- name : "__annotations__" . to_owned ( ) ,
1107- scope : bytecode:: NameScope :: Free ,
1108- } ) ;
1099+ self . emit ( Instruction :: SetupAnnotation ) ;
11091100 }
11101101 self . compile_statements ( new_body) ?;
11111102 self . emit ( Instruction :: LoadConst {
0 commit comments