Damien George
a2e383820d
py: Clean up and comment out unused functions in mpz.
2015-03-02 12:58:06 +00:00
Damien George
62a3a287d9
py: Set compiler scope before folding constants so error messages work.
...
Addresses issue #1140 .
2015-03-01 12:04:05 +00:00
Damien George
7711afbb4a
py: Combine complie functions for or_test/and_test to reduce code size.
...
Saves around 60 bytes code on Thumb2 archs.
2015-02-28 15:10:18 +00:00
Damien George
63f3832e81
py: Combine emit functions for jump true/false to reduce code size.
...
Saves 116 bytes for stmhal and 56 bytes for cc3200 port.
2015-02-28 15:04:06 +00:00
Damien George
0b2fd91890
py: Combine logic for compiling and/or tests, to reduce code size.
...
Reduces code size by 72 bytes on Thumb2 archs.
2015-02-28 14:37:54 +00:00
Paul Sokolovsky
cefcbb22b2
objarray: Implement array slice assignment.
...
This is rarely used feature which takes enough code to implement, so is
controlled by MICROPY_PY_ARRAY_SLICE_ASSIGN config setting, default off.
But otherwise it may be useful, as allows to update arbitrary-sized data
buffers in-place.
Slice is yet to implement, and actually, slice assignment implemented in
such a way that RHS of assignment should be array of the exact same item
typecode as LHS. CPython has it more relaxed, where RHS can be any sequence
of compatible types (e.g. it's possible to assign list of int's to a
bytearray slice).
Overall, when all "slice write" features are implemented, it may cost ~1KB
of code.
2015-02-27 22:17:15 +02:00
Damien George
0bb971370b
py: Transform assert logic in compiler to save code space.
...
Saves about 250 code bytes for Thumb2 archs.
2015-02-27 14:25:47 +00:00
Damien George
4d77e1a034
py: Use m_{new,renew,del} consistently.
...
This is so all memory requests go through the same interface.
2015-02-27 09:34:51 +00:00
Damien George
4852e09c79
py: Fix adding of traceback so that it appends to existing info.
...
This makes exception traceback info self contained (ie doesn't rely on
list object, which was a bit of a hack), reduces code size, and reduces
RAM footprint of exception by eliminating the list object.
Addresses part of issue #1126 .
2015-02-27 00:36:39 +00:00
Damien George
12d6d777e1
py: Small optimisation of logic flow in BC_WITH_CLEANUP bytecode.
...
Slightly smaller code, and does not need to use C stack to save
temporaries.
2015-02-26 17:54:50 +00:00
Damien George
534574348e
py: Make inline assembler raise exception when branch not in range.
...
Addresses issue #1132 .
2015-02-25 15:45:55 +00:00
Damien George
993f067fa2
py: In inline assembler, add return statement to fix flow logic.
2015-02-24 22:43:01 +00:00
Damien George
e5315f7ffd
py: Factor some code in inline thumb assembler to reduce code size.
2015-02-24 16:35:37 +00:00
Damien George
e41b21c01e
py: Make more asmthumb functions inline to reduce code size.
2015-02-24 16:32:52 +00:00
Damien George
8f7976ba0d
py: Reduce code size of inline thumb assembler by using static tables.
...
Reduces stmhal by about 300 bytes ROM.
2015-02-24 16:10:58 +00:00
nhtshot
5d323defe4
py: Update parse.c&mpconfig.h to reflect rename of mp_lexer_show_token.
...
This function is only used when DEBUG_PRINTERS and USE_RULE_NAME are
enabled.
2015-02-23 21:36:05 +00:00
Paul Sokolovsky
71ebd4b7f0
py: Implement UnicodeError.
...
Still too shy to implement UnicodeEncodeError which was really needed for
micropython-lib case.
2015-02-23 23:20:16 +02:00
Damien George
5cbeacebdb
py: Make math special functions configurable and disabled by default.
...
The implementation of these functions is very large (order 4k) and they
are rarely used, so we don't enable them by default.
They are however enabled in stmhal and unix, since we have the room.
2015-02-22 14:48:18 +00:00
Paul Sokolovsky
e06cf89f04
py: Add few more special methods.
2015-02-22 01:21:08 +02:00
Damien George
eff359e114
py: Expose mp_obj_list_remove as a public function.
2015-02-21 14:47:02 +00:00
Paul Sokolovsky
8c705233f3
py: Fix mp_obj_print() to work when Python streams are not used.
2015-02-17 00:32:18 +02:00
Paul Sokolovsky
1f91e92cc6
py: Revamp mp_obj_print() to use Python streams.
...
Most of printing infrastructure now uses streams, but mp_obj_print() used
libc's printf(), which led to weird buffering issues in output. So, switch
mp_obj_print() to streams too, even though it may make sense to move it to
a separate file, as it is purely a debugging function now.
2015-02-17 00:13:01 +02:00
Damien George
eff10f66a6
py: Implement bl/bx instructions for inline Thumb assembler.
2015-02-16 18:17:07 +00:00
Damien George
42495392da
py: Implement "it" instruction for inline Thumb assembler.
2015-02-16 17:46:49 +00:00
Damien George
3d7bf5d4b1
py: More robust checking in inline assembler compiler.
2015-02-16 17:46:28 +00:00
Paul Sokolovsky
9e6c82960e
builtinimport: Revamp&refactor handling of relative imports.
...
Relative imports are based of a package, so we're currently at a module
within a package, we should get to package first.
Also, factor out path travsering operation, but this broke testing for
boundary errors with relative imports. TODO: reintroduce them, together
with proper tests.
2015-02-16 12:11:34 +02:00
Paul Sokolovsky
078172dcab
builtinimport: Improve debugging output.
2015-02-16 12:11:03 +02:00
Paul Sokolovsky
e8432b3c72
stackctrl: Encode "recursion depth exceeded" message as qstr.
...
So corresponding exception can be thrown even under tight memory conditions.
2015-02-15 22:41:14 +03:00
Paul Sokolovsky
fa3b895145
objexcept: Optimize traceback allocation for exception.
...
Traceback allocation for exception will now never lead to recursive
MemoryError exception - if there's no memory for traceback, it simply
won't be created.
2015-02-15 22:41:14 +03:00
Paul Sokolovsky
29c4f92e13
objexcept: Optimize using messages without formatting substitutions.
...
They are directly cast to str object, skipping allocation of formatting
buffer.
2015-02-15 22:41:14 +03:00
Paul Sokolovsky
3077fbff26
nlr: Add even more optional debugging logging.
...
Has to be enabled by manual editing, but at least it's there, as debugging
NLR issues may be weird.
2015-02-15 20:28:18 +03:00
Paul Sokolovsky
e89cc13e5c
nlr: If DEBUG, guard against recursive nlr_push().
...
Pushing same NLR record twice would lead to "infinite loop" in nlr_jump
(but more realistically, it will crash as soon as NLR record on stack is
overwritten).
2015-02-15 20:23:52 +03:00
Paul Sokolovsky
53e5e0fa28
py: Make old_globals part of mp_code_state structure.
...
Conceptually it is part of code state, so let it be allocated in the same way
as the rest of state.
2015-02-15 19:24:15 +03:00
Damien George
e5039c6ff8
py: Use TextIOWrapper only if PY_IO_FILEIO def'd; cast size_t for print.
2015-02-15 13:17:11 +00:00
Damien George
f6532bb9e0
py: Simplify and remove redundant code for __iter__ method lookup.
2015-02-15 01:10:13 +00:00
Damien George
d1c3788375
py: Fix loading of immediate pointer in Thumb assembler.
...
Addresses issue #1117 .
2015-02-15 00:45:28 +00:00
Damien George
0868942e77
py: Check for valid file when creating lexer for execfile.
...
Addresses issue #1119 .
2015-02-15 00:02:27 +00:00
stijn
1b8e76b8e6
py: Cleanup duplication in instance_is_callable/instance_call.
2015-02-14 23:49:04 +00:00
stijn
c1832fd206
py: Add setattr builtin.
2015-02-14 23:35:00 +00:00
Paul Sokolovsky
089c3f321e
py/asm*.c: Typo fixes in comments.
2015-02-14 02:20:35 +08:00
Damien George
192d536fe4
py: Implement clz and rbit for inline Thumb assembler.
2015-02-13 11:06:23 +00:00
Damien George
32f0b7942c
py: Implement sdiv/udiv for inline Thumb assembler.
2015-02-13 10:43:05 +00:00
Damien George
0d967b8ae4
py: Implement push/pop for inline Thumb assembler.
2015-02-13 02:30:35 +00:00
Damien George
dfe944c3e5
py: Expose compile.c:list_get as mp_parse_node_extract_list.
2015-02-13 02:29:46 +00:00
Damien George
8dfbd2d589
py: Make inline assembler raise proper SyntaxError exception on error.
...
Also gives line number of location of error. Very useful!
2015-02-13 01:00:51 +00:00
Damien George
1bf5a022fe
py: Add ldrex and strex to thumb2 inline assembler.
...
These are useful for implementing atomic lock operations.
2015-02-12 22:52:42 +00:00
Damien George
596f41da04
py: Reuse value stack in VM WITH_CLEANUP opcode to reduce C-stack size.
...
Saves 8 bytes C-stack on stmhal and 16 bytes on unix x86.
2015-02-10 13:21:42 +00:00
Damien George
ea0461dcd3
py: Add option to micropython.qstr_info() to dump actual qstrs.
2015-02-10 11:02:28 +00:00
Damien George
d0df10b2c6
py: Don't unnecessarily create a bound method.
2015-02-09 16:59:15 +00:00
Damien George
48244044a2
py: Allow subclass of native object to delegate to the native buffer_p.
...
Addresses issue #1109 .
2015-02-09 15:08:00 +00:00