Damien George
2bf7c09222
py: Properly implement deletion of locals and derefs, and detect errors.
...
Needed to reinstate 2 delete opcodes, to specifically check that a local
is not deleted twice.
2014-04-09 15:26:46 +01:00
Damien George
11d8cd54c9
py, compiler: Turn id_info_t.param into a set of flags.
...
So we can add more flags.
2014-04-09 14:42:51 +01:00
Damien George
b140bff877
py, compile: Simplify initialisation of compiler structure.
2014-04-09 12:54:21 +01:00
Damien George
02a4c05c5f
py, compile: Reduce size of compiler structure.
2014-04-09 12:50:58 +01:00
Damien George
922ddd6415
py, compile: Combine have_star_arg, have_dbl_star_arg into star_flags.
...
Small reduction in ROM, heap and stack usage.
2014-04-09 12:43:17 +01:00
Damien George
78035b995f
py, compiler: Clean up and compress scope/compile structures.
...
Convert int types to uint where sensible, and then to uint8_t or
uint16_t where possible to reduce RAM usage.
2014-04-09 12:27:39 +01:00
Damien George
495d781a36
py: implement UNPACK_EX byte code (for: a, *b, c = d)
2014-04-08 17:51:47 +01:00
Damien George
b7ffdcc1c7
py: Improve compiler syntax errors; catch more errors.
2014-04-08 16:41:02 +01:00
Damien George
cdd96dff2c
py: Implement more features in native emitter.
...
On x64, native emitter now passes 70 of the tests.
2014-04-06 12:58:40 +01:00
Damien George
65cad12d38
py: Add option to compiler to specify default code emitter.
...
Also add command line option to unix port to select emitter.
2014-04-06 11:48:15 +01:00
Damien George
af27259439
py: Enable optimisation of multiplying 2 small ints in compiler.
2014-04-04 11:21:58 +00:00
Damien George
ecf5b77123
py: This time, real proper overflow checking of small int power.
...
Previous overflow test was inadequate.
2014-04-04 11:13:51 +00:00
Damien George
094d450003
py: Wrap compile_scope_inline_asm in #if; remove comment from misc.h.
2014-04-02 17:31:27 +01:00
Damien George
af6edc61bd
py: Enable a jump optimisation in the compiler.
2014-04-02 16:12:28 +01:00
Damien George
882b363564
py: Move to Python 3.4.0 compatibility.
...
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.
2014-04-02 15:56:31 +01:00
Damien George
3ff2d03891
py: Fix bug in optimised for .. range.
...
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.
2014-03-31 18:02:22 +01:00
Damien George
e337f1ef5e
py: Towards default keyword arguments.
...
These are default arguments after a bare *.
2014-03-31 15:18:37 +01:00
Damien George
1aa2c10263
Merge branch 'master' of github.com:micropython/micropython
2014-03-31 12:01:09 +01:00
Damien George
3056509e00
py: Rename and reorder parameters in emit_make_function/closure.
...
In preparation for implementing default keyword arguments.
2014-03-31 11:30:17 +01:00
Paul Sokolovsky
96eec4f8a6
compile: Don't try to constant-fold division by zero.
...
The way it is, just crashes app. And optimizing to
"raise ZeroDivisionError" is probably too much.
2014-03-31 02:23:57 +03:00
Damien George
804760bfca
py: Fix bug in compiler for empty class bases.
...
Eg class A(): pass would fail an assertion.
2014-03-30 23:06:37 +01:00
Damien George
d17926db71
Rename rt_* to mp_*.
...
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.
2014-03-30 13:35:08 +01:00
Paul Sokolovsky
8d9cc2e669
compile: Print error messages on unimplemented relative imports.
2014-03-30 04:16:35 +03:00
Damien George
21a07dc50f
Merge pull request #389 from pfalcon/with-statement
...
With statement implementation
2014-03-29 14:00:03 +00:00
Damien George
d1e443d0bc
py: Free unique_code slot for outer module.
...
Partly (very partly!) addresses issue #386 . Most importantly, at the
REPL command line, each invocation does not now lead to increased memory
usage (unless you define a function/lambda).
2014-03-29 11:39:36 +00:00
Paul Sokolovsky
44307d5ef8
vm: Implement "with" statement (SETUP_WITH and WITH_CLEANUP bytecodes).
2014-03-29 04:39:24 +02:00
Damien George
2326d52d20
py: Factor out code from runtime.c to emitglue.c.
2014-03-27 23:26:35 +00:00
Damien George
8dcc0c7924
py: Calculate maximum exception stack size in compiler.
2014-03-27 10:55:21 +00:00
Damien George
bdcbf0fcd1
py: Restore CPython compatibility in compiler for closures with def args.
2014-03-26 23:15:35 +00:00
Paul Sokolovsky
2447a5b582
py: Support closures with default args.
2014-03-26 23:17:44 +02:00
Rachel Dowdall
56402796d8
Fixed floor division on mp ints and small ints. Added a floordivide test case.
2014-03-22 20:19:24 +00:00
Rachel Dowdall
cde8631f15
Fixed modulo operator on ints and mp ints to agree with python. Added intdivmod.c and tests/basics/modulo.py.
2014-03-22 17:29:27 +00:00
xbe
efe3422394
py: Clean up includes.
...
Remove unnecessary includes. Add includes that improve portability.
2014-03-17 02:43:40 -07:00
Damien George
f41fdd05b0
py: Unify syntax error handling in compiler; check defualt arg syntax.
...
Checks for non-default args following default args, and errors out.
Addresses issue #328 .
2014-03-03 23:19:11 +00:00
Damien George
1dc76af7bf
py: Remove name of var arg from macros with var args.
2014-02-26 16:57:08 +00:00
Paul Sokolovsky
56e5ef203b
parse: Refactor parse node encoding to support full range of small ints.
...
Based on suggestion by @dpgeorge at
https://github.com/micropython/micropython/pull/313
2014-02-22 16:39:45 +02:00
Paul Sokolovsky
bbf0e2fe12
parse: Note that fact that parser's small ints are different than VM small int.
...
Specifically, VM's small ints are 31 bit, while parser's only 28. There's already
MP_OBJ_FITS_SMALL_INT(), so, for clarity, rename MP_FIT_SMALL_INT() to
MP_PARSE_FITS_SMALL_INT().
2014-02-21 03:27:09 +02:00
Paul Sokolovsky
a1aba36feb
compile: Add comments ergarding non-implemented relative imports.
2014-02-20 13:22:28 +02:00
Damien George
8725f8f7de
py: Pass all scope flags through to runtime.
2014-02-15 19:33:11 +00:00
Paul Sokolovsky
520e2f58a5
Replace global "static" -> "STATIC", to allow "analysis builds". Part 2.
2014-02-12 18:31:30 +02:00
Paul Sokolovsky
2f0b026a44
Clean up handling of function return type annotation.
2014-02-10 02:04:26 +02:00
Damien George
bbcd49a496
py: Fix compile of class with keyword arguments in bases.
2014-02-06 20:30:16 +00:00
Damien George
35e2a4e6bb
py: Add built-in super.
2014-02-05 00:51:47 +00:00
Damien George
9aa2a527b5
py: Tidy up BINARY_OPs; negation done by special NOT bytecode.
...
IS_NOT and NOT_IN are now compiled to IS + NOT and IN + NOT, with a new
special NOT bytecode.
2014-02-01 23:04:09 +00:00
Damien George
7e5fb24e3b
py: Reduce code size of compiler by a bit.
2014-02-01 22:18:47 +00:00
Damien George
cbddb279bb
py: Implement break/continue from an exception with finally.
...
Still todo: break/continue from within the finally block itself.
2014-02-01 20:08:18 +00:00
Paul Sokolovsky
90750029df
Implement default function arguments (for Python functions).
...
TODO: Decide if we really need separate bytecode for creating functions
with default arguments - we would need same for closures, then there're
keywords arguments too. Having all combinations is a small exponential
explosion, likely we need just 2 cases - simplest (no defaults, no kw),
and full - defaults & kw.
2014-02-01 15:38:22 +02:00
Damien George
08d075592f
py: Fix bug with LOAD_METHOD; fix int->machine_int_t for small int.
...
LOAD_METHOD bug was: emitbc did not correctly calculate the amount of
stack usage for a LOAD_METHOD operation.
small int bug was: int was being used to pass small ints, when it should
have been machine_int_t.
2014-01-29 18:58:52 +00:00
Damien George
e4b6a079b3
py: Implement 'not' in compiler, and improve rt_is_true.
2014-01-28 23:27:35 +00:00
Damien George
41d02b654e
py: Improve freeing of emitters in mp_compile.
...
There can be multiple emitters allocated during compile (eg byte code
and native).
2014-01-24 22:42:28 +00:00