summaryrefslogtreecommitdiffstatshomepage
path: root/tools
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-09-03 00:19:02 +1000
committerDamien George <damien.p.george@gmail.com>2016-09-03 00:19:02 +1000
commitc51c883cc84bb680dcc810a81e81dd1df879a07c (patch)
tree9e0a4fb651a33d187c438301d36092c3b0b574aa /tools
parent41ec22632da8f61ca5c841e13206258048d1be5b (diff)
downloadmicropython-c51c883cc84bb680dcc810a81e81dd1df879a07c.tar.gz
micropython-c51c883cc84bb680dcc810a81e81dd1df879a07c.zip
tools/mpy-tool.py: Support freezing of complex numbers.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/mpy-tool.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/mpy-tool.py b/tools/mpy-tool.py
index bfb2a5da79..bc8ac4fbd3 100755
--- a/tools/mpy-tool.py
+++ b/tools/mpy-tool.py
@@ -320,6 +320,9 @@ class RawCode:
print('STATIC const mp_obj_float_t %s = {{&mp_type_float}, %.16g};'
% (obj_name, obj))
print('#endif')
+ elif type(obj) is complex:
+ print('STATIC const mp_obj_complex_t %s = {{&mp_type_complex}, %.16g, %.16g};'
+ % (obj_name, obj.real, obj.imag))
else:
# TODO
raise FreezeError(self, 'freezing of object %r is not implemented' % (obj,))
@@ -485,6 +488,15 @@ def freeze_mpy(base_qstrs, raw_codes):
print('#endif')
print()
+ print('#if MICROPY_PY_BUILTINS_COMPLEX')
+ print('typedef struct _mp_obj_complex_t {')
+ print(' mp_obj_base_t base;')
+ print(' mp_float_t real;')
+ print(' mp_float_t imag;')
+ print('} mp_obj_complex_t;')
+ print('#endif')
+ print()
+
print('enum {')
for i in range(len(new)):
if i == 0: