diff options
author | Damien George <damien@micropython.org> | 2024-02-09 17:38:25 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-02-16 12:48:02 +1100 |
commit | 5e3006f1172d0eabbbefeb3268dfb942ec7cf9cd (patch) | |
tree | 9ad4455beb4711980134e44acd0d2bdf798b74b4 /tools/mpy-tool.py | |
parent | 416465d81e911b088836f4e7c37fac2bc0f67917 (diff) |
py/emitglue: Simplify mp_raw_code_t's kind and scope_flags members.
To simplify their access and reduce code size.
The `scope_flags` member is only ever used to determine if a function is a
generator or not, so make it reflect that fact as a bool type.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tools/mpy-tool.py')
-rwxr-xr-x | tools/mpy-tool.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/mpy-tool.py b/tools/mpy-tool.py index 9b824099e..744800c67 100755 --- a/tools/mpy-tool.py +++ b/tools/mpy-tool.py @@ -126,6 +126,7 @@ MP_PERSISTENT_OBJ_FLOAT = 8 MP_PERSISTENT_OBJ_COMPLEX = 9 MP_PERSISTENT_OBJ_TUPLE = 10 +MP_SCOPE_FLAG_GENERATOR = 0x01 MP_SCOPE_FLAG_VIPERRELOC = 0x10 MP_SCOPE_FLAG_VIPERRODATA = 0x20 MP_SCOPE_FLAG_VIPERBSS = 0x40 @@ -912,7 +913,7 @@ class RawCode(object): raw_code_type = "mp_raw_code_truncated_t" print("static const %s raw_code_%s = {" % (raw_code_type, self.escaped_name)) print(" .kind = %s," % RawCode.code_kind_str[self.code_kind]) - print(" .scope_flags = 0x%02x," % self.scope_flags) + print(" .is_generator = %d," % bool(self.scope_flags & MP_SCOPE_FLAG_GENERATOR)) print(" .fun_data = fun_data_%s," % self.escaped_name) if len(self.children): print(" .children = (void *)&children_%s," % self.escaped_name) |