summaryrefslogtreecommitdiffstatshomepage
path: root/py/compile.c
Commit message (Collapse)AuthorAge
* py: Rename byte_code to bytecode everywhere.Damien George2014-05-10
| | | | bytecode is the more widely used. See issue #590.
* py, compiler: Add basic support for A=const(123).Damien George2014-05-08
| | | | | | | | | | | 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.
* py, compiler: Improve passes; add an extra pass for native emitter.Damien George2014-05-07
|
* py, compiler: Start adding support for compile-time constants.Damien George2014-05-07
| | | | Just a start, no working code yet. As per issue #573.
* Add license header to (almost) all files.Damien George2014-05-03
| | | | | | | 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/.
* py: Add '*' qstr for 'import *'; use blank qstr for comprehension arg.Damien George2014-04-27
|
* py: Remove unnecessary LOAD_CONST_ID bytecode.Damien George2014-04-27
| | | | It's the same as LOAD_CONST_STR.
* py: Save some ROM by shortening compiler error messages.Damien George2014-04-27
| | | | Messages are still explanatory, while taking a little less ROM.
* py: Change the way function arguments are compiled.Damien George2014-04-27
| | | | | | | | 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.
* py: Implement keyword-only args.Damien George2014-04-27
| | | | | | | Implements 'def f(*, a)' and 'def f(*a, b)', but not default keyword-only args, eg 'def f(*, a=1)'. Partially addresses issue #524.
* Add ARRAY_SIZE macro, and use it where possible.Damien George2014-04-26
|
* py: Add MICROPY_ENABLE_DOC_STRING, disabled by default.Damien George2014-04-25
| | | | | | Also add a few STATIC's to some compile functions that should have them. Addresses issue #521.
* py: Add 'align' and 'data' meta-instructions to inline assembler.Damien George2014-04-21
|
* py: Making closures now passes pointer to stack, not a tuple for vars.Damien George2014-04-20
| | | | | | | 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.
* py: Merge BINARY_OP_SUBSCR and store_subscr (w/ delete) into subscr.Damien George2014-04-17
| | | | mp_obj_t->subscr now does load/store/delete.
* py: Remove unique_codes from emitglue.c. Replace with pointers.Damien George2014-04-13
| | | | | | | | | | | | | | | | 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.
* py: Improve inline assembler; improve compiler constant folding.Damien George2014-04-12
|
* py, compiler: Fix up creation of default positionals tuple.Damien George2014-04-12
| | | | | With new order of evaluation of defaults, creating the tuple was done in the wrong spot.
* py, compiler: Fix compiling of keyword args following named star.Damien George2014-04-11
|
* py: Change compile order for default positional and keyword args.Damien George2014-04-11
| | | | | | | | | | | 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.
* py, compiler: Allow lambda's to yield.Damien George2014-04-11
|
* py: Implement compiling of *-expr within parenthesis.Damien George2014-04-11
|
* py: Add simple way of looking up constants in compiler.Damien George2014-04-10
| | | | | | | | | | | | 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.
* py: Simplify stack get/set to become stack adjust in emitters.Damien George2014-04-10
| | | | Can do this now that the stack size calculation is improved.
* py, compiler: Improve stack depth counting.Damien George2014-04-10
| | | | Much less of a hack now. Hopefully it's correct!
* py: Make labels unsigned ints (converted from int).Damien George2014-04-10
| | | | | Labels should never be negative, and this modified type signature reflects that.
* py, compiler: Implement compiling of relative imports.Damien George2014-04-10
|
* py: Properly implement deletion of locals and derefs, and detect errors.Damien George2014-04-09
| | | | | Needed to reinstate 2 delete opcodes, to specifically check that a local is not deleted twice.
* py, compiler: Turn id_info_t.param into a set of flags.Damien George2014-04-09
| | | | So we can add more flags.
* py, compile: Simplify initialisation of compiler structure.Damien George2014-04-09
|
* py, compile: Reduce size of compiler structure.Damien George2014-04-09
|
* py, compile: Combine have_star_arg, have_dbl_star_arg into star_flags.Damien George2014-04-09
| | | | Small reduction in ROM, heap and stack usage.
* py, compiler: Clean up and compress scope/compile structures.Damien George2014-04-09
| | | | | Convert int types to uint where sensible, and then to uint8_t or uint16_t where possible to reduce RAM usage.
* py: implement UNPACK_EX byte code (for: a, *b, c = d)Damien George2014-04-08
|
* py: Improve compiler syntax errors; catch more errors.Damien George2014-04-08
|
* py: Implement more features in native emitter.Damien George2014-04-06
| | | | On x64, native emitter now passes 70 of the tests.
* py: Add option to compiler to specify default code emitter.Damien George2014-04-06
| | | | Also add command line option to unix port to select emitter.
* py: Enable optimisation of multiplying 2 small ints in compiler.Damien George2014-04-04
|
* py: This time, real proper overflow checking of small int power.Damien George2014-04-04
| | | | Previous overflow test was inadequate.
* py: Wrap compile_scope_inline_asm in #if; remove comment from misc.h.Damien George2014-04-02
|
* py: Enable a jump optimisation in the compiler.Damien George2014-04-02
|
* py: Move to Python 3.4.0 compatibility.Damien George2014-04-02
| | | | | | | | | | | | | Very little has changed. In Python 3.4 they removed the opcode STORE_LOCALS, but in Micro Python we only ever used this for CPython compatibility, so it was a trivial thing to remove. It also allowed to clean up some dead code (eg the 0xdeadbeef in class construction), and now class builders use 1 less stack word. Python 3.4.0 introduced the LOAD_CLASSDEREF opcode, which I have not yet understood. Still, all tests (apart from bytecode test) still pass. Bytecode tests needs some more attention, but they are not that important anymore.
* py: Fix bug in optimised for .. range.Damien George2014-03-31
| | | | | | Don't store final, failing value to the loop variable. This fix also makes for .. range a bit more efficient, as it uses less store/load pairs for the loop variable.
* py: Towards default keyword arguments.Damien George2014-03-31
| | | | These are default arguments after a bare *.
* Merge branch 'master' of github.com:micropython/micropythonDamien George2014-03-31
|\
| * compile: Don't try to constant-fold division by zero.Paul Sokolovsky2014-03-31
| | | | | | | | | | The way it is, just crashes app. And optimizing to "raise ZeroDivisionError" is probably too much.
* | py: Rename and reorder parameters in emit_make_function/closure.Damien George2014-03-31
|/ | | | In preparation for implementing default keyword arguments.
* py: Fix bug in compiler for empty class bases.Damien George2014-03-30
| | | | Eg class A(): pass would fail an assertion.
* Rename rt_* to mp_*.Damien George2014-03-30
| | | | | | | Mostly just a global search and replace. Except rt_is_true which becomes mp_obj_is_true. Still would like to tidy up some of the names, but this will do for now.
* compile: Print error messages on unimplemented relative imports.Paul Sokolovsky2014-03-30
|