Commit Graph

2209 Commits

Author SHA1 Message Date
Damien George
33ac0fd09f py: Don't try to optimise for+range when args are not simple expressions.
Addresses issue #1693.
2015-12-08 21:05:14 +00:00
Paul Sokolovsky
946f870e3c py/misc.h: Include stdint.h only once (unconditionally at the top). 2015-12-08 02:23:58 +02:00
Paul Sokolovsky
9f001b09a8 py/misc.h: Include stdint.h, as large share of code now depends on it. 2015-12-07 20:08:07 +02:00
pohmelie
c6ee273410 py: Add min/max "default" keyword argument 2015-12-07 18:56:25 +02:00
pohmelie
354e688d8e py: Add MICROPY_PY_BUILTINS_MIN_MAX, disable for minimal ports. 2015-12-07 18:56:25 +02:00
Paul Sokolovsky
2b7236d249 py: Make it easy to build without MICROPY_PY_BUILTINS_COMPLEX.
Automagically skip related modules.
2015-12-07 00:19:24 +02:00
Paul Sokolovsky
f2d532c404 py/modsys: Use MP_ROM_PTR() initializer for sys.modules.
Based on similar usage for sys.argv/sys.path.
2015-12-05 00:27:04 +02:00
Paul Sokolovsky
1a1d11fa32 py/modsys: Implement sys.modules.
This for example will allow people to reload modules which didn't load
successfully (e.g. due to syntax error).
2015-12-05 00:13:29 +02:00
Damien George
7a99639cff py: Fix function calls that have positional and a star-arg-with-iterator.
Addresses issue #1678.
2015-12-03 17:59:49 +00:00
Paul Sokolovsky
b4eccfd02d py/mpconfig: Actually allow to override MICROPY_BYTES_PER_GC_BLOCK. 2015-12-03 01:58:25 +02:00
Paul Sokolovsky
75feece208 py/gc: Make GC block size be configurable. 2015-12-03 01:40:52 +02:00
fabien.lementec
e042f485ed py/mpprint: Printing of doubles is now supported (by uPy own routine). 2015-12-02 14:21:36 +02:00
Damien George
b8cfb0d7b2 py: Add support for 64-bit NaN-boxing object model, on 32-bit machine.
To use, put the following in mpconfigport.h:

    #define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_D)
    #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)
    typedef int64_t mp_int_t;
    typedef uint64_t mp_uint_t;
    #define UINT_FMT "%llu"
    #define INT_FMT "%lld"

Currently does not work with native emitter enabled.
2015-11-29 14:25:36 +00:00
Damien George
999cedb90f py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR.
This allows the mp_obj_t type to be configured to something other than a
pointer-sized primitive type.

This patch also includes additional changes to allow the code to compile
when sizeof(mp_uint_t) != sizeof(void*), such as using size_t instead of
mp_uint_t, and various casts.
2015-11-29 14:25:35 +00:00
Damien George
cbf7674025 py: Add MP_ROM_* macros and mp_rom_* types and use them. 2015-11-29 14:25:04 +00:00
Damien George
94fe6e523d py/gc: Move away from using mp_uint_t, instead use uintptr_t and size_t.
The GC works with concrete pointers and so the types should reflect this.
2015-11-29 14:25:04 +00:00
Damien George
254cfa6c31 py: Use uintptr_t instead of mp_uint_t in MP_TAGPTR_* macros. 2015-11-29 14:25:04 +00:00
Damien George
9f6976b74e py: Make mp_setup_code_state take concrete pointer for func arg. 2015-11-29 14:25:04 +00:00
Damien George
5d66b427e2 py/emit: Change type of arg of load_const_obj from void* to mp_obj_t. 2015-11-29 14:25:04 +00:00
Damien George
c3f64d9799 py: Change qstr_* functions to use size_t as the type for str len arg. 2015-11-29 14:25:04 +00:00
Damien George
4e7107a572 py: Change mp_print_strn_t func type to use size_t for the str length. 2015-11-29 14:25:04 +00:00
Damien George
0786716c5a py/asmx86: Fix function definition to use int32_t instead of int. 2015-11-27 14:06:53 +00:00
Damien George
88a9103b3c py/binary: Make use of MP_ALIGN. 2015-11-27 12:05:11 +00:00
Paul Sokolovsky
f32020ef3d py/mpconfig.h: Allow to build without alloca() for ANSI C compliance.
Define MICROPY_NO_ALLOCA=1 and memory will be allocated from heap instead
and freed by garbage collection.
2015-11-25 23:24:51 +02:00
Paul Sokolovsky
f0fbab7ca7 extmod/fsusermount: Make configurable with MICROPY_FSUSERMOUNT. 2015-11-25 13:19:36 +02:00
Paul Sokolovsky
3a1bbcc2ef extmod: Move fsusermount.c from stmhal for cross-port reuse. 2015-11-25 13:19:36 +02:00
stijn
3baf6b5319 windows/py: Support 64bit mingw-w64 builds
- add mp_int_t/mp_uint_t typedefs in mpconfigport.h
- fix integer suffixes/formatting in mpconfig.h and mpz.h
- use MICROPY_NLR_SETJMP=1 in Makefile since the current nlrx64.S
  implementation causes segfaults in gc_free()
- update README
2015-11-24 17:34:14 +02:00
stijn
bf1570cb25 nlr: Use single preprocessor symbol to check if building on Windows 2015-11-24 17:34:14 +02:00
Damien George
9a56912ad1 py/compile: Do proper checking of * and ** in function definition.
This patch checks that there is only one *, and that ** is last in the
arg list.
2015-11-23 16:50:42 +00:00
Damien George
0e3f29cc99 py: Check that second argument to hasattr is actually a string.
Fixes issue #1623.
2015-11-23 15:57:00 +00:00
Damien George
44e6e348d6 py/emitglue: Implement persistent saving and loading of const objects. 2015-11-23 11:54:12 +00:00
Damien George
39a8deb95f py/emitglue: Add feature-flag header to .mpy to detect bytecode compat.
Loading .mpy files will now check to make sure that the target VM can
support the bytecode.
2015-11-23 10:58:16 +00:00
Paul Sokolovsky
b3be4710aa py/mpz: Normalize (remove leading zeros) xor operation result. 2015-11-22 22:03:18 +02:00
Paul Sokolovsky
3d6240ba1b py/formatfloat: Handle calculation of integer digit for %f format properly.
%f prints true integer digit, so its calculation should happen before any
exponential scaling.
2015-11-22 20:05:08 +02:00
Paul Sokolovsky
3c4c069802 py/formatfloat: Workaround (fix?) incorrect rounding for %f format. 2015-11-22 18:09:28 +02:00
Paul Sokolovsky
9aaccd4735 py/formatfloat: Convert to fully portable implementation.
This takes previous IEEE-754 single precision float implementation, and
converts it to fully portable parametrizable implementation using C99
functions like signbit(), isnan(), isinf(). As long as those functions
are available (they can be defined in adhoc manner of course), and
compiler can perform standard arithmetic and comparison operations on a
float type, this implementation will work with any underlying float type
(including types whose mantissa is larger than available intergral integer
type).
2015-11-22 17:54:05 +02:00
Paul Sokolovsky
295ea12411 py/emitglue: Host definition of mp_verbose_flag.
This may not seem like the ideal place, but is actually the only place
in py/ where it gets referenced, so is just right.
2015-11-21 16:54:15 +02:00
Paul Sokolovsky
72bd172b30 py/modsys: Consistently use indented #if's. 2015-11-21 16:03:37 +02:00
Damien George
83229d3ffe py: Use MP_OBJ_NULL instead of NULL when appropriate. 2015-11-20 14:09:20 +00:00
Damien George
b5b1f2c527 py/emitglue: Add mp_raw_code_load_mem to load raw-code from memory. 2015-11-20 12:44:20 +00:00
Damien George
f148727b78 py/emitglue: Only compile raw-code fatfs loader when on thumb2 platform.
Here we are assuming that a thumb2 port will have fatfs, which is only
roughly true.  We need a better way of enabling specific raw-code file
readers.
2015-11-20 12:42:26 +00:00
Damien George
d4dba88236 py/compile: Add mp_compile_to_raw_code() to return raw code object.
This can then be passed to mp_raw_code_save_file to save a .mpy file.
2015-11-20 12:30:37 +00:00
Igor Gatis
f5c554dfe3 py: Added Cygwin support to py/nlrx86.S. 2015-11-19 20:23:43 +02:00
Damien George
593faf14c4 py/map: Store key/value in earliest possible slot in hash table.
This change makes the code behave how it was supposed to work when first
written.  The avail_slot variable is set to the first free slot when
looking for a key (which would come from deleting an entry).  So it's
more efficient (for subsequent lookups) to insert a new key into such a
slot, rather than the very last slot that was searched.
2015-11-19 01:27:28 +00:00
Damien George
994ff738c8 py/mpstate: Make mp_pending_exception volatile.
It can change asynchronously.
2015-11-17 14:27:21 +00:00
Damien George
a24eafacc9 py/modmath: Make log2, log10 and hyperbolic funcs be SPECIAL_FUNCTIONS.
Will be included only when MICROPY_PY_MATH_SPECIAL_FUNCTIONS is enabled.

Also covers cmath module (but only log10 is there at the moment).
2015-11-17 14:10:13 +00:00
Damien George
2c83894257 py: Implement default and star args for lambdas. 2015-11-17 14:00:14 +00:00
Damien George
cbd9ae5256 py/compile: Don't unnecessarily save state when compiling param list.
Parameter lists can't be nested so there is no need to save the global
state when compiling them.
2015-11-17 12:37:02 +00:00
Paul Sokolovsky
863d4cd862 py/modmath: Don't create symbol entry for expm1() if not needed. 2015-11-14 00:55:54 +02:00
Paul Sokolovsky
0d6116d86b py/modmath: Make expm1() be in MICROPY_PY_MATH_SPECIAL_FUNCTIONS. 2015-11-14 00:46:52 +02:00