py/makeqstrdata.py: Ensure that scope names get low qstr values.

Originally implemented in a patch file provided by @ironss-iotec.

Fixes issue #14093.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
Jim Mussared
2024-03-26 15:23:21 +11:00
committed by Damien George
parent 57de9da352
commit d694ac6e1b
4 changed files with 19 additions and 6 deletions

View File

@@ -370,6 +370,8 @@ static mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_arg
// Qstrs for special methods are guaranteed to have a small value, so we use byte
// type to represent them.
// The (unescaped) names appear in `unsorted_str_list` in the QSTR
// generator script py/makeqstrdata.py to ensure they are assigned low numbers.
const byte mp_unary_op_method_name[MP_UNARY_OP_NUM_RUNTIME] = {
[MP_UNARY_OP_BOOL] = MP_QSTR___bool__,
[MP_UNARY_OP_LEN] = MP_QSTR___len__,
@@ -468,6 +470,8 @@ static mp_obj_t instance_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
// fail). They can be added at the expense of code size for the qstr.
// Qstrs for special methods are guaranteed to have a small value, so we use byte
// type to represent them.
// The (unescaped) names appear in `unsorted_str_list` in the QSTR
// generator script py/makeqstrdata.py to ensure they are assigned low numbers.
const byte mp_binary_op_method_name[MP_BINARY_OP_NUM_RUNTIME] = {
[MP_BINARY_OP_LESS] = MP_QSTR___lt__,
[MP_BINARY_OP_MORE] = MP_QSTR___gt__,