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.
11 years ago
Damien George
804760bfca
py: Fix bug in compiler for empty class bases.
Eg class A(): pass would fail an assertion.
11 years ago
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.
11 years ago
Paul Sokolovsky
8d9cc2e669
compile: Print error messages on unimplemented relative imports.
11 years ago
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).
11 years ago
Paul Sokolovsky
44307d5ef8
vm: Implement "with" statement (SETUP_WITH and WITH_CLEANUP bytecodes).
11 years ago
Damien George
2326d52d20
py: Factor out code from runtime.c to emitglue.c.
11 years ago
Damien George
8dcc0c7924
py: Calculate maximum exception stack size in compiler.
11 years ago
Damien George
bdcbf0fcd1
py: Restore CPython compatibility in compiler for closures with def args.
11 years ago
Paul Sokolovsky
2447a5b582
py: Support closures with default args.
11 years ago
Rachel Dowdall
2d15deebdc
Fixed floor division on mp ints and small ints. Added a floordivide test case.
11 years ago
Rachel Dowdall
56402796d8
Fixed floor division on mp ints and small ints. Added a floordivide test case.
11 years ago
Rachel Dowdall
cde8631f15
Fixed modulo operator on ints and mp ints to agree with python. Added intdivmod.c and tests/basics/modulo.py.
11 years ago
xbe
efe3422394
py: Clean up includes.
Remove unnecessary includes. Add includes that improve portability.
11 years ago
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 .
11 years ago
Damien George
1dc76af7bf
py: Remove name of var arg from macros with var args.
11 years ago
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
11 years ago
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().
11 years ago
Paul Sokolovsky
a1aba36feb
compile: Add comments ergarding non-implemented relative imports.
11 years ago
Damien George
8725f8f7de
py: Pass all scope flags through to runtime.
11 years ago
Paul Sokolovsky
520e2f58a5
Replace global "static" -> "STATIC", to allow "analysis builds". Part 2.
11 years ago
Paul Sokolovsky
2f0b026a44
Clean up handling of function return type annotation.
11 years ago
Damien George
bbcd49a496
py: Fix compile of class with keyword arguments in bases.
11 years ago
Damien George
35e2a4e6bb
py: Add built-in super.
11 years ago
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.
11 years ago
Damien George
7e5fb24e3b
py: Reduce code size of compiler by a bit.
11 years ago
Damien George
cbddb279bb
py: Implement break/continue from an exception with finally.
Still todo: break/continue from within the finally block itself.
11 years ago
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.
11 years ago
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.
11 years ago
Damien George
e4b6a079b3
py: Implement 'not' in compiler, and improve rt_is_true.
11 years ago
Damien George
41d02b654e
py: Improve freeing of emitters in mp_compile.
There can be multiple emitters allocated during compile (eg byte code
and native).
11 years ago
Paul Sokolovsky
f46d87a30d
Add support for freeing code emitter objects at the end of compilation.
11 years ago
Paul Sokolovsky
fd31358505
mp_compile(): Properly free module_scope and all nested scopes.
11 years ago
Damien George
b979122dfb
py: Use C99 way of variable macro arguments.
Addresses Issue #207 .
11 years ago
Damien George
00208ce194
py: Change macro var args in parser to be C99 compliant.
11 years ago
Damien George
600ae734cf
py: Implement break and continue byte codes, and add tests.
Also fixes a bug in the for-in-range optimiser.
I hope to remove break and continue byte codes in the future and just
use jump (if possible).
11 years ago
Damien George
55baff4c9b
Revamp qstrs: they now include length and hash.
Can now have null bytes in strings. Can define ROM qstrs per port using
qstrdefsport.h
11 years ago
Damien George
cbd2f7482c
py: Add module/function/class name to exceptions.
Exceptions know source file, line and block name.
Also tidy up some debug printing functions and provide a global
flag to enable/disable them.
11 years ago
Damien George
08335004cf
Add source file name and line number to error messages.
Byte code has a map from byte-code offset to source-code line number,
used to give better error messages.
11 years ago
Damien George
d02c6d8962
Implement eval.
11 years ago
Damien George
e5863d9301
py: AssertionError is loaded from global, to match CPython.
11 years ago
John R. Lenton
b8698fca75
unified the bops
11 years ago
Paul Sokolovsky
899c69f94c
compile_for_stmt_optimised_range(): Properly handle negative & unknown steps.
If step is not constant, in first approximation, we can't apply optimization,
(well, we could, but need a special case for this).
11 years ago
ian-v
5fd8fd2c16
Revert MP_BOOL, etc. and use <stdbool.h> instead
11 years ago
ian-v
7a16fadbf8
Co-exist with C++ (issue #85 )
11 years ago
Damien George
71c5181a8d
Convert Python types to proper Python type hierarchy.
Now much more inline with how CPython does types.
11 years ago
Damien George
eb7bfcb286
Split qstr into pools, and put initial pool in ROM.
Qstr's are now split into a linked-list of qstr pools. This has 2
benefits: the first pool can be in ROM (huge benefit, since we no longer
use RAM for the core qstrs), and subsequent pools use m_new for the next
pool instead of m_renew (thus avoiding a huge single table for all the
qstrs).
Still would be better to use a hash table, but this scheme takes us part
of the way (eventually convert the pools to hash tables).
Also fixed bug with import.
Also improved the way the module code is referenced (not magic number 1
anymore).
11 years ago
Damien George
e67ed5d285
Improve configurability for native x64/thumb emitter.
With MICROPY_EMIT_X64 and MICROPY_EMIT_THUMB disabled, the respective
emitters and assemblers will not be included in the code. This can
significantly reduce binary size for unix version.
11 years ago
Damien George
1fb031744f
Change mp_compile so that it returns a function object for the module.
11 years ago
Damien George
fe8fb9165c
py: remove depedence on strcat and stpcpy.
This fixes Issue #29 , and means the core is no longer dependent on
string functions, except strlen.
11 years ago