@@ -299,14 +299,12 @@ STATIC void c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if, int la
299299 if (jump_if == false) {
300300 EMIT_ARG (jump , label );
301301 }
302- } else if (MP_PARSE_NODE_IS_STRUCT_KIND (pns -> nodes [0 ], PN_testlist_comp )) {
302+ } else {
303+ assert (MP_PARSE_NODE_IS_STRUCT_KIND (pns -> nodes [0 ], PN_testlist_comp ));
303304 // non-empty tuple, acts as true for the condition
304305 if (jump_if == true) {
305306 EMIT_ARG (jump , label );
306307 }
307- } else {
308- // parenthesis around 1 item, is just that item
309- c_if_cond (comp , pns -> nodes [0 ], jump_if , label );
310308 }
311309 return ;
312310 }
@@ -420,7 +418,6 @@ STATIC void c_assign_tuple(compiler_t *comp, mp_parse_node_t node_head, uint num
420418
421419// assigns top of stack to pn
422420STATIC void c_assign (compiler_t * comp , mp_parse_node_t pn , assign_kind_t assign_kind ) {
423- tail_recursion :
424421 assert (!MP_PARSE_NODE_IS_NULL (pn ));
425422 if (MP_PARSE_NODE_IS_LEAF (pn )) {
426423 if (MP_PARSE_NODE_IS_ID (pn )) {
@@ -462,16 +459,13 @@ STATIC void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t assign_
462459 if (MP_PARSE_NODE_IS_NULL (pns -> nodes [0 ])) {
463460 // empty tuple
464461 goto cannot_assign ;
465- } else if (MP_PARSE_NODE_IS_STRUCT_KIND (pns -> nodes [0 ], PN_testlist_comp )) {
462+ } else {
463+ assert (MP_PARSE_NODE_IS_STRUCT_KIND (pns -> nodes [0 ], PN_testlist_comp ));
466464 if (assign_kind != ASSIGN_STORE ) {
467465 goto bad_aug ;
468466 }
469467 pns = (mp_parse_node_struct_t * )pns -> nodes [0 ];
470468 goto testlist_comp ;
471- } else {
472- // parenthesis around 1 item, is just that item
473- pn = pns -> nodes [0 ];
474- goto tail_recursion ;
475469 }
476470 break ;
477471
@@ -885,7 +879,10 @@ STATIC void c_del_stmt(compiler_t *comp, mp_parse_node_t pn) {
885879 }
886880 } else if (MP_PARSE_NODE_IS_STRUCT_KIND (pn , PN_atom_paren )) {
887881 pn = ((mp_parse_node_struct_t * )pn )-> nodes [0 ];
888- if (MP_PARSE_NODE_IS_STRUCT_KIND (pn , PN_testlist_comp )) {
882+ if (MP_PARSE_NODE_IS_NULL (pn )) {
883+ goto cannot_delete ;
884+ } else {
885+ assert (MP_PARSE_NODE_IS_STRUCT_KIND (pn , PN_testlist_comp ));
889886 mp_parse_node_struct_t * pns = (mp_parse_node_struct_t * )pn ;
890887 // TODO perhaps factorise testlist_comp code with other uses of PN_testlist_comp
891888
@@ -915,12 +912,9 @@ STATIC void c_del_stmt(compiler_t *comp, mp_parse_node_t pn) {
915912 c_del_stmt (comp , pns -> nodes [0 ]);
916913 c_del_stmt (comp , pns -> nodes [1 ]);
917914 }
918- } else {
919- // tuple with 1 element
920- c_del_stmt (comp , pn );
921915 }
922916 } else {
923- // TODO is there anything else to implement?
917+ // some arbitrary statment that we can't delete (eg del 1)
924918 goto cannot_delete ;
925919 }
926920
@@ -2185,7 +2179,8 @@ STATIC void compile_atom_paren(compiler_t *comp, mp_parse_node_struct_t *pns) {
21852179 if (MP_PARSE_NODE_IS_NULL (pns -> nodes [0 ])) {
21862180 // an empty tuple
21872181 c_tuple (comp , MP_PARSE_NODE_NULL , NULL );
2188- } else if (MP_PARSE_NODE_IS_STRUCT_KIND (pns -> nodes [0 ], PN_testlist_comp )) {
2182+ } else {
2183+ assert (MP_PARSE_NODE_IS_STRUCT_KIND (pns -> nodes [0 ], PN_testlist_comp ));
21892184 pns = (mp_parse_node_struct_t * )pns -> nodes [0 ];
21902185 assert (!MP_PARSE_NODE_IS_NULL (pns -> nodes [1 ]));
21912186 if (MP_PARSE_NODE_IS_STRUCT (pns -> nodes [1 ])) {
@@ -2209,9 +2204,6 @@ STATIC void compile_atom_paren(compiler_t *comp, mp_parse_node_struct_t *pns) {
22092204 tuple_with_2_items :
22102205 c_tuple (comp , MP_PARSE_NODE_NULL , pns );
22112206 }
2212- } else {
2213- // parenthesis around a single item, is just that item
2214- compile_node (comp , pns -> nodes [0 ]);
22152207 }
22162208}
22172209
0 commit comments