@@ -556,22 +556,18 @@ void mp_emit_bc_load_null(emit_t *emit) {
556556 emit_write_bytecode_byte (emit , MP_BC_LOAD_NULL );
557557}
558558
559- void mp_emit_bc_load_fast (emit_t * emit , qstr qst , mp_uint_t local_num ) {
559+ void mp_emit_bc_load_local (emit_t * emit , qstr qst , mp_uint_t local_num , int kind ) {
560+ MP_STATIC_ASSERT (MP_BC_LOAD_FAST_N + MP_EMIT_IDOP_LOCAL_FAST == MP_BC_LOAD_FAST_N );
561+ MP_STATIC_ASSERT (MP_BC_LOAD_FAST_N + MP_EMIT_IDOP_LOCAL_DEREF == MP_BC_LOAD_DEREF );
560562 (void )qst ;
561563 emit_bc_pre (emit , 1 );
562- if (local_num <= 15 ) {
564+ if (kind == MP_EMIT_IDOP_LOCAL_FAST && local_num <= 15 ) {
563565 emit_write_bytecode_byte (emit , MP_BC_LOAD_FAST_MULTI + local_num );
564566 } else {
565- emit_write_bytecode_byte_uint (emit , MP_BC_LOAD_FAST_N , local_num );
567+ emit_write_bytecode_byte_uint (emit , MP_BC_LOAD_FAST_N + kind , local_num );
566568 }
567569}
568570
569- void mp_emit_bc_load_deref (emit_t * emit , qstr qst , mp_uint_t local_num ) {
570- (void )qst ;
571- emit_bc_pre (emit , 1 );
572- emit_write_bytecode_byte_uint (emit , MP_BC_LOAD_DEREF , local_num );
573- }
574-
575571void mp_emit_bc_load_name (emit_t * emit , qstr qst ) {
576572 (void )qst ;
577573 emit_bc_pre (emit , 1 );
@@ -613,22 +609,18 @@ void mp_emit_bc_load_subscr(emit_t *emit) {
613609 emit_write_bytecode_byte (emit , MP_BC_LOAD_SUBSCR );
614610}
615611
616- void mp_emit_bc_store_fast (emit_t * emit , qstr qst , mp_uint_t local_num ) {
612+ void mp_emit_bc_store_local (emit_t * emit , qstr qst , mp_uint_t local_num , int kind ) {
613+ MP_STATIC_ASSERT (MP_BC_STORE_FAST_N + MP_EMIT_IDOP_LOCAL_FAST == MP_BC_STORE_FAST_N );
614+ MP_STATIC_ASSERT (MP_BC_STORE_FAST_N + MP_EMIT_IDOP_LOCAL_DEREF == MP_BC_STORE_DEREF );
617615 (void )qst ;
618616 emit_bc_pre (emit , -1 );
619- if (local_num <= 15 ) {
617+ if (kind == MP_EMIT_IDOP_LOCAL_FAST && local_num <= 15 ) {
620618 emit_write_bytecode_byte (emit , MP_BC_STORE_FAST_MULTI + local_num );
621619 } else {
622- emit_write_bytecode_byte_uint (emit , MP_BC_STORE_FAST_N , local_num );
620+ emit_write_bytecode_byte_uint (emit , MP_BC_STORE_FAST_N + kind , local_num );
623621 }
624622}
625623
626- void mp_emit_bc_store_deref (emit_t * emit , qstr qst , mp_uint_t local_num ) {
627- (void )qst ;
628- emit_bc_pre (emit , -1 );
629- emit_write_bytecode_byte_uint (emit , MP_BC_STORE_DEREF , local_num );
630- }
631-
632624void mp_emit_bc_store_name (emit_t * emit , qstr qst ) {
633625 emit_bc_pre (emit , -1 );
634626 emit_write_bytecode_byte_qstr (emit , MP_BC_STORE_NAME , qst );
@@ -652,14 +644,11 @@ void mp_emit_bc_store_subscr(emit_t *emit) {
652644 emit_write_bytecode_byte (emit , MP_BC_STORE_SUBSCR );
653645}
654646
655- void mp_emit_bc_delete_fast (emit_t * emit , qstr qst , mp_uint_t local_num ) {
656- (void )qst ;
657- emit_write_bytecode_byte_uint (emit , MP_BC_DELETE_FAST , local_num );
658- }
659-
660- void mp_emit_bc_delete_deref (emit_t * emit , qstr qst , mp_uint_t local_num ) {
647+ void mp_emit_bc_delete_local (emit_t * emit , qstr qst , mp_uint_t local_num , int kind ) {
648+ MP_STATIC_ASSERT (MP_BC_DELETE_FAST + MP_EMIT_IDOP_LOCAL_FAST == MP_BC_DELETE_FAST );
649+ MP_STATIC_ASSERT (MP_BC_DELETE_FAST + MP_EMIT_IDOP_LOCAL_DEREF == MP_BC_DELETE_DEREF );
661650 (void )qst ;
662- emit_write_bytecode_byte_uint (emit , MP_BC_DELETE_DEREF , local_num );
651+ emit_write_bytecode_byte_uint (emit , MP_BC_DELETE_FAST + kind , local_num );
663652}
664653
665654void mp_emit_bc_delete_name (emit_t * emit , qstr qst ) {
@@ -972,20 +961,17 @@ const emit_method_table_t emit_bc_method_table = {
972961 mp_emit_bc_set_source_line ,
973962
974963 {
975- mp_emit_bc_load_fast ,
976- mp_emit_bc_load_deref ,
964+ mp_emit_bc_load_local ,
977965 mp_emit_bc_load_name ,
978966 mp_emit_bc_load_global ,
979967 },
980968 {
981- mp_emit_bc_store_fast ,
982- mp_emit_bc_store_deref ,
969+ mp_emit_bc_store_local ,
983970 mp_emit_bc_store_name ,
984971 mp_emit_bc_store_global ,
985972 },
986973 {
987- mp_emit_bc_delete_fast ,
988- mp_emit_bc_delete_deref ,
974+ mp_emit_bc_delete_local ,
989975 mp_emit_bc_delete_name ,
990976 mp_emit_bc_delete_global ,
991977 },
@@ -1056,22 +1042,19 @@ const emit_method_table_t emit_bc_method_table = {
10561042};
10571043#else
10581044const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops = {
1059- mp_emit_bc_load_fast ,
1060- mp_emit_bc_load_deref ,
1045+ mp_emit_bc_load_local ,
10611046 mp_emit_bc_load_name ,
10621047 mp_emit_bc_load_global ,
10631048};
10641049
10651050const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops = {
1066- mp_emit_bc_store_fast ,
1067- mp_emit_bc_store_deref ,
1051+ mp_emit_bc_store_local ,
10681052 mp_emit_bc_store_name ,
10691053 mp_emit_bc_store_global ,
10701054};
10711055
10721056const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_delete_id_ops = {
1073- mp_emit_bc_delete_fast ,
1074- mp_emit_bc_delete_deref ,
1057+ mp_emit_bc_delete_local ,
10751058 mp_emit_bc_delete_name ,
10761059 mp_emit_bc_delete_global ,
10771060};
0 commit comments