summaryrefslogtreecommitdiff
path: root/py/compile.c
AgeCommit message (Collapse)Author
2014-07-03Rename machine_(u)int_t to mp_(u)int_t.Damien George
See discussion in issue #50.
2014-06-30py: Improvements to native emitter.Damien George
Native emitter can now compile try/except blocks using nlr_push/nlr_pop. It probably only works for 1 level of exception handling. It doesn't work on Thumb (only x64). Native emitter can also handle some additional op codes. With this patch, 198 tests now pass using "-X emit=native" option to micropython.
2014-06-21py: Include mpconfig.h before all other includes.Paul Sokolovsky
It defines types used by all other headers. Fixes #691.
2014-06-19Prefix ARRAY_SIZE with micropython prefix MP_Emmanuel Blot
2014-06-07py: Implement default keyword only args.Damien George
Should finish addressing issue #524.
2014-05-31py: Fix stack underflow with optimised for loop.Damien George
2014-05-30py: Fix break from within a for loop.Damien George
Needed to pop the iterator object when breaking out of a for loop. Need also to be careful to unwind exception handler before popping iterator. Addresses issue #635.
2014-05-28py: Fix check of small-int overflow when parsing ints.Damien George
Also unifies use of SMALL_INT_FITS macro across parser and runtime.
2014-05-25py: Don't automatically intern strings in parser.Damien George
This completes non-automatic interning of strings in the parser, so that doc strings don't take up RAM. It complicates the parser and compiler, and bloats stmhal by about 300 bytes. It's complicated because now there are 2 kinds of parse-nodes that can be strings: interned leaves and non-interned structs.
2014-05-21Tidy up some configuration options.Damien George
MP_ALLOC_* -> MICROPY_ALLOC_* MICROPY_PATH_MAX -> MICROPY_ALLOC_PATH_MAX MICROPY_ENABLE_REPL_HELPERS -> MICROPY_HELPER_REPL MICROPY_ENABLE_LEXER_UNIX -> MICROPY_HELPER_LEXER_UNIX MICROPY_EXTRA_* -> MICROPY_PORT_* See issue #35.
2014-05-12py: Rename BYTE_CODE to BYTECODE (this was missed in previous rename).Damien George
2014-05-10py: Rename byte_code to bytecode everywhere.Damien George
bytecode is the more widely used. See issue #590.
2014-05-08py, compiler: Add basic support for A=const(123).Damien George
You can now do: X = const(123) Y = const(456 + X) and the compiler will replace X and Y with their values. See discussion in issue #266 and issue #573.
2014-05-07py, compiler: Improve passes; add an extra pass for native emitter.Damien George
2014-05-07py, compiler: Start adding support for compile-time constants.Damien George
Just a start, no working code yet. As per issue #573.
2014-05-03Add license header to (almost) all files.Damien George
Blanket wide to all .c and .h files. Some files originating from ST are difficult to deal with (license wise) so it was left out of those. Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
2014-04-27py: Add '*' qstr for 'import *'; use blank qstr for comprehension arg.Damien George
2014-04-27py: Remove unnecessary LOAD_CONST_ID bytecode.Damien George
It's the same as LOAD_CONST_STR.
2014-04-27py: Save some ROM by shortening compiler error messages.Damien George
Messages are still explanatory, while taking a little less ROM.
2014-04-27py: Change the way function arguments are compiled.Damien George
New way uses slightly less ROM and RAM, should be slightly faster, and, most importantly, allows to catch the error "non-keyword arg following keyword arg". Addresses issue #466.
2014-04-27py: Implement keyword-only args.Damien George
Implements 'def f(*, a)' and 'def f(*a, b)', but not default keyword-only args, eg 'def f(*, a=1)'. Partially addresses issue #524.
2014-04-26Add ARRAY_SIZE macro, and use it where possible.Damien George
2014-04-25py: Add MICROPY_ENABLE_DOC_STRING, disabled by default.Damien George
Also add a few STATIC's to some compile functions that should have them. Addresses issue #521.
2014-04-21py: Add 'align' and 'data' meta-instructions to inline assembler.Damien George
2014-04-20py: Making closures now passes pointer to stack, not a tuple for vars.Damien George
Closed over variables are now passed on the stack, instead of creating a tuple and passing that. This way memory for the closed over variables can be allocated within the closure object itself. See issue #510 for background.
2014-04-17py: Merge BINARY_OP_SUBSCR and store_subscr (w/ delete) into subscr.Damien George
mp_obj_t->subscr now does load/store/delete.
2014-04-13py: Remove unique_codes from emitglue.c. Replace with pointers.Damien George
Attempt to address issue #386. unique_code_id's have been removed and replaced with a pointer to the "raw code" information. This pointer is stored in the actual byte code (aligned, so the GC can trace it), so that raw code (ie byte code, native code and inline assembler) is kept only for as long as it is needed. In memory it's now like a tree: the outer module's byte code points directly to its children's raw code. So when the outer code gets freed, if there are no remaining functions that need the raw code, then the children's code gets freed as well. This is pretty much like CPython does it, except that CPython stores indexes in the byte code rather than machine pointers. These indices index the per-function constant table in order to find the relevant code.
2014-04-12py: Improve inline assembler; improve compiler constant folding.Damien George
2014-04-12py, compiler: Fix up creation of default positionals tuple.Damien George
With new order of evaluation of defaults, creating the tuple was done in the wrong spot.
2014-04-11py, compiler: Fix compiling of keyword args following named star.Damien George
2014-04-11py: Change compile order for default positional and keyword args.Damien George
This simplifies the compiler a little, since now it can do 1 pass over a function declaration, to determine default arguments. I would have done this originally, but CPython 3.3 somehow had the default keyword args compiled before the default position args (even though they appear in the other order in the text of the script), and I thought it was important to have the same order of execution when evaluating default arguments. CPython 3.4 has changed the order to the more obvious one, so we can also change.
2014-04-11py, compiler: Allow lambda's to yield.Damien George
2014-04-11py: Implement compiling of *-expr within parenthesis.Damien George
2014-04-10py: Add simple way of looking up constants in compiler.Damien George
Working towards trying to support compile-time constants (see discussion in issue #227), this patch allows the compiler to look inside arbitrary uPy objects at compile time. The objects to search are given by the macro MICROPY_EXTRA_CONSTANTS (so they must be constant/ROM objects), and the constant folding occures on forms base.attr (both base and attr must be id's). It works, but it breaks strict CPython compatibility, since the lookup will succeed even without importing the namespace.
2014-04-10py: Simplify stack get/set to become stack adjust in emitters.Damien George
Can do this now that the stack size calculation is improved.
2014-04-10py, compiler: Improve stack depth counting.Damien George
Much less of a hack now. Hopefully it's correct!
2014-04-10py: Make labels unsigned ints (converted from int).Damien George
Labels should never be negative, and this modified type signature reflects that.
2014-04-10py, compiler: Implement compiling of relative imports.Damien George
2014-04-09py: Properly implement deletion of locals and derefs, and detect errors.Damien George
Needed to reinstate 2 delete opcodes, to specifically check that a local is not deleted twice.
2014-04-09py, compiler: Turn id_info_t.param into a set of flags.Damien George
So we can add more flags.
2014-04-09py, compile: Simplify initialisation of compiler structure.Damien George
2014-04-09py, compile: Reduce size of compiler structure.Damien George
2014-04-09py, compile: Combine have_star_arg, have_dbl_star_arg into star_flags.Damien George
Small reduction in ROM, heap and stack usage.
2014-04-09py, compiler: Clean up and compress scope/compile structures.Damien George
Convert int types to uint where sensible, and then to uint8_t or uint16_t where possible to reduce RAM usage.
2014-04-08py: implement UNPACK_EX byte code (for: a, *b, c = d)Damien George
2014-04-08py: Improve compiler syntax errors; catch more errors.Damien George
2014-04-06py: Implement more features in native emitter.Damien George
On x64, native emitter now passes 70 of the tests.
2014-04-06py: Add option to compiler to specify default code emitter.Damien George
Also add command line option to unix port to select emitter.
2014-04-04py: Enable optimisation of multiplying 2 small ints in compiler.Damien George
2014-04-04py: This time, real proper overflow checking of small int power.Damien George
Previous overflow test was inadequate.