tools/mpy-tool.py: Support freezing of complex numbers.
This commit is contained in:
parent
41ec22632d
commit
c51c883cc8
@ -320,6 +320,9 @@ class RawCode:
|
|||||||
print('STATIC const mp_obj_float_t %s = {{&mp_type_float}, %.16g};'
|
print('STATIC const mp_obj_float_t %s = {{&mp_type_float}, %.16g};'
|
||||||
% (obj_name, obj))
|
% (obj_name, obj))
|
||||||
print('#endif')
|
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:
|
else:
|
||||||
# TODO
|
# TODO
|
||||||
raise FreezeError(self, 'freezing of object %r is not implemented' % (obj,))
|
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('#endif')
|
||||||
print()
|
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 {')
|
print('enum {')
|
||||||
for i in range(len(new)):
|
for i in range(len(new)):
|
||||||
if i == 0:
|
if i == 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user