Damien George
a68c754688
py/lexer: Move check for keyword to name-tokenising block.
...
Keywords only needs to be searched for if the token is a MP_TOKEN_NAME, so
we can move the seach to the part of the code that does the tokenising for
MP_TOKEN_NAME.
2017-02-17 10:59:57 +11:00
Damien George
98b3072da5
py/lexer: Simplify handling of indenting of very first token.
2017-02-17 10:56:06 +11:00
Damien George
b0599de48e
minimal: Update frozentest.mpy file for new .mpy version.
2017-02-17 10:27:47 +11:00
Damien George
30f3bcdd29
gitattributes: Remove obsolete lines.
2017-02-17 10:27:34 +11:00
Damien George
9214e39b3c
gitattributes: Add .mpy files to list of binary files.
2017-02-17 10:23:14 +11:00
Glenn Ruben Bakke
7ce31444a0
nrf5: Adding target to flash bluetooth stack when using pyocd-flashtool.
2017-02-16 23:18:07 +01:00
Glenn Ruben Bakke
2fd55feb0c
nrf5/modules: Guarding callback to python event handler before issue the call in case it is not set.
2017-02-16 18:49:47 +01:00
Damien George
6a11048af1
py/persistentcode: Bump .mpy version due to change in bytecode.
2017-02-17 00:19:34 +11:00
Damien George
c264414746
py/lexer: Don't generate string representation for period or ellipsis.
...
It's not needed.
2017-02-16 20:23:41 +11:00
Damien George
0ec957d7c5
tests/cmdline: Update cmd_parsetree test for changes to grammar order.
2017-02-16 19:45:07 +11:00
Damien George
71019ae4f5
py/grammar: Group no-compile grammar rules together to shrink tables.
...
Grammar rules have 2 variants: ones that are attached to a specific
compile function which is called to compile that grammar node, and ones
that don't have a compile function and are instead just inspected to see
what form they take.
In the compiler there is a table of all grammar rules, with each entry
having a pointer to the associated compile function. Those rules with no
compile function have a null pointer. There are 120 such rules, so that's
120 words of essentially wasted code space.
By grouping together the compile vs no-compile rules we can put all the
no-compile rules at the end of the list of rules, and then we don't need
to store the null pointers. We just have a truncated table and it's
guaranteed that when indexing this table we only index the first half,
the half with populated pointers.
This patch implements such a grouping by having a specific macro for the
compile vs no-compile grammar rules (DEF_RULE vs DEF_RULE_NC). It saves
around 460 bytes of code on 32-bit archs.
2017-02-16 19:45:06 +11:00
Damien George
7839b8b827
tests/micropython/heapalloc_iter: Add tests for contains and unpack.
2017-02-16 19:11:34 +11:00
Damien George
e6003f466e
py: De-optimise some uses of mp_getiter, so they don't use the C stack.
...
In these cases the heap is anyway used to create a new object so no real
need to use the C stack for iterating. It saves a few bytes of code size.
2017-02-16 19:11:34 +11:00
Damien George
019048a6dc
tests/micropython: Add test for iterating with the heap locked.
2017-02-16 19:11:34 +11:00
Damien George
86b3db9cd0
tests/cmdline/cmd_showbc: Update to work with recent changes.
2017-02-16 18:38:07 +11:00
Damien George
4d2bab1444
py/compile: Optimise list/dict/set comprehensions to use stack iter.
2017-02-16 18:38:07 +11:00
Damien George
861b001783
tests/cmdline: Update tests to pass with latest changes to bytecode.
2017-02-16 18:38:07 +11:00
Damien George
cb6300697c
py/runtime: Optimise case of identity iterator so it doesn't alloc RAM.
2017-02-16 18:38:06 +11:00
Damien George
30b42dd72d
py: Remove unused "use_stack" argument from for_iter_end emit function.
2017-02-16 18:38:06 +11:00
Damien George
088740ecc4
py: Optimise storage of iterator so it takes only 4 slots on Py stack.
2017-02-16 18:38:06 +11:00
Damien George
6e769da0da
py: Make FOR_ITER opcode pop 1+4 slots from the stack when finished.
...
The extra 4 slots correspond to the iterator object stored on the stack.
2017-02-16 18:38:06 +11:00
Damien George
f4df3aaa72
py: Allow bytecode/native to put iter_buf on stack for simple for loops.
...
So that the "for x in it: ..." statement can now work without using the
heap (so long as the iterator argument fits in an iter_buf structure).
2017-02-16 18:38:06 +11:00
Damien George
ae8d867586
py: Add iter_buf to getiter type method.
...
Allows to iterate over the following without allocating on the heap:
- tuple
- list
- string, bytes
- bytearray, array
- dict (not dict.keys, dict.values, dict.items)
- set, frozenset
Allows to call the following without heap memory:
- all, any, min, max, sum
TODO: still need to allocate stack memory in bytecode for iter_buf.
2017-02-16 18:38:06 +11:00
Damien George
101886f529
py/vm: Convert mp_uint_t to size_t where appropriate.
2017-02-16 16:51:17 +11:00
Damien George
da36f5232d
py/objint: Convert mp_uint_t to size_t where appropriate.
2017-02-16 16:51:17 +11:00
Damien George
fa5a591757
py/objexcept: Convert mp_uint_t to size_t where appropriate.
2017-02-16 16:51:17 +11:00
Damien George
efa629028a
py/objclosure: Convert mp_uint_t to size_t where appropriate.
2017-02-16 16:51:17 +11:00
Damien George
dbcdb9f8d8
py/objfun: Convert mp_uint_t to size_t where appropriate.
2017-02-16 16:51:16 +11:00
Damien George
ccc5254224
py/objarray: Convert mp_uint_t to size_t where appropriate.
2017-02-16 16:51:16 +11:00
Damien George
c0d9500eee
py/objstr: Convert mp_uint_t to size_t (and use int) where appropriate.
2017-02-16 16:51:16 +11:00
Damien George
68cd3a93f0
py/objset: Convert mp_uint_t to size_t where appropriate.
2017-02-16 16:51:16 +11:00
Damien George
1ea2f7a8ce
py/objdict: Convert mp_uint_t to size_t where appropriate.
2017-02-16 16:51:16 +11:00
Damien George
58d9eeb8d9
py/objlist: Convert mp_uint_t to size_t where appropriate.
2017-02-16 16:51:16 +11:00
Damien George
229823942c
py/objtuple: Convert mp_uint_t to size_t where appropriate.
2017-02-16 16:51:16 +11:00
Damien George
891dc5c62c
py/persistentcode: Replace mp_uint_t with size_t where appropriate.
2017-02-16 16:51:16 +11:00
Damien George
6ed77bedbd
py/mpz: Change type of "base" args from mp_uint_t to unsigned int.
2017-02-16 16:51:16 +11:00
Damien George
eb90edb5c0
py/mpz: Remove obsolete declaration of mpz_as_str_size.
2017-02-16 16:51:16 +11:00
Damien George
dcdcc43dad
py/mpz: Convert mp_uint_t to size_t where appropriate.
2017-02-16 16:51:13 +11:00
Damien George
4e3bac2e42
py/runtime: Convert mp_uint_t to size_t where appropriate.
2017-02-16 16:51:13 +11:00
Glenn Ruben Bakke
18365135f7
nrf5/modules: Updating ubluepy example to turn led2 on and off when receiving connected and disconnect bluetooth event.
2017-02-15 23:58:23 +01:00
Glenn Ruben Bakke
d88320b5b3
nrf5/sdk: Updating bluetooth driver to have configurable logs.
2017-02-15 23:57:23 +01:00
Glenn Ruben Bakke
832a7ffd14
nrf5/modules: updating ubluepy and bluetooth driver to support python created event handler. Added registration of callback from ubluepy against the bluetooth driver and dispatching of events to the user supplied python function.
2017-02-15 23:32:42 +01:00
Glenn Ruben Bakke
d29539a395
nrf5/modules: Splitting includes to be inside or outside of the compile guard in ubluepy. This way, all micropython specific includes will be outside, and internal will be inside. This way, there will not be any dependency towards ubluepy headers if not compiled in.
2017-02-15 19:33:11 +01:00
Glenn Ruben Bakke
db75b5535c
nrf5/modules: Adding two new functions to ubluepy peripheral class to set specific handlers for notificaitons and connection related events.
2017-02-15 19:30:45 +01:00
Glenn Ruben Bakke
ec517a37f6
nrf5: Set ubluepy to disabled by default in mpconfigport.h if not configured.
2017-02-15 19:13:55 +01:00
Paul Sokolovsky
a937750ceb
extmod/modlwip: Add my copyright.
...
Per:
$ git log modlwip.c |grep ^Auth | sort | uniq -c
9 Author: Damien George
2 Author: Galen Hazelwood
43 Author: Paul Sokolovsky
2017-02-15 19:20:46 +03:00
Paul Sokolovsky
f980c70997
tests/basic/: Make various tests skippable.
...
To run the testsuite on small ports.
2017-02-15 18:11:16 +03:00
Paul Sokolovsky
b737c9cbc8
tests/gen_yield_from_close: Use range() instead of reversed().
...
As a "more basic" builtin iterator, present even in smaller ports.
2017-02-15 17:05:27 +03:00
Paul Sokolovsky
eb101a2701
examples/embedding/README: Convert to markdown, grammar and clarity fixes.
2017-02-15 13:27:24 +03:00
Damien George
e5cc681cb1
stmhal: Use generic interrupt char code.
2017-02-15 16:39:30 +11:00