Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
c51c883c
Commit
c51c883c
authored
Sep 03, 2016
by
Damien George
Browse files
tools/mpy-tool.py: Support freezing of complex numbers.
parent
41ec2263
Changes
1
Hide whitespace changes
Inline
Side-by-side
tools/mpy-tool.py
View file @
c51c883c
...
...
@@ -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
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment