Paul Sokolovsky
0f570cfccf
showbc: Decode MAP_ADD.
2014-05-11 20:51:31 +03:00
Damien George
3417bc2f25
py: Rename byte_code to bytecode everywhere.
...
bytecode is the more widely used. See issue #590 .
2014-05-10 10:36:38 +01:00
Paul Sokolovsky
4187068cad
showbc: Quote block name, so it was easily visible.
2014-05-04 22:42:11 +03:00
Damien George
04b9147e15
Add license header to (almost) all files.
...
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/.
2014-05-03 23:27:38 +01:00
Paul Sokolovsky
f54bcbf099
py, unix: Make "mpconfig.h" be first included, as other headers depend on it.
...
Specifically, nlr.h does.
2014-05-02 17:48:40 +03:00
Damien George
968bf34c4c
py: Remove unnecessary LOAD_CONST_ID bytecode.
...
It's the same as LOAD_CONST_STR.
2014-04-27 19:12:05 +01:00
Paul Sokolovsky
c5e32c6995
vm: Add rudimentary bytecode execution tracing capability.
2014-04-23 03:46:00 +03:00
Paul Sokolovsky
4c6b375960
showbc: MAKE_CLOSURE*: Update for new closed-over encoding.
2014-04-23 03:23:39 +03:00
Damien George
5f6a25fc50
py: Wrap #if's around emitter functions that are used only by emitcpy.
...
3 emitter functions are needed only for emitcpy, and so we can #if them
out when compiling with emitcpy support.
Also remove unused SETUP_LOOP bytecode.
2014-04-20 18:02:27 +01:00
Damien George
729f7b42d6
py: Merge BINARY_OP_SUBSCR and store_subscr (w/ delete) into subscr.
...
mp_obj_t->subscr now does load/store/delete.
2014-04-17 22:10:53 +01:00
Damien George
73496fbbe4
py: Fix up source-line calculation.
...
Should address issue #475 .
2014-04-13 14:51:56 +01:00
Damien George
3d484d9ad4
py: Update showbc to decode ptrs for MAKE_FUNCTION ops.
2014-04-13 11:22:44 +01:00
Damien George
6ce4277551
py: Make all LOAD_FAST ops check for unbound local.
...
This is necessary to catch all cases where locals are referenced before
assignment. We still keep the _0, _1, _2 versions of LOAD_FAST to help
reduced the byte code size in RAM.
Addresses issue #457 .
2014-04-12 18:20:40 +01:00
Paul Sokolovsky
faf84491ce
showbc: Add quotes around (some) string args, to show empty string properly.
2014-04-12 18:25:17 +03:00
Paul Sokolovsky
b9b1c00c8a
showbs: Dump LOAD_CONST_BYTES.
2014-04-12 00:39:55 +03:00
Paul Sokolovsky
00a9d138b2
showbc: Dump LOAD_NULL.
2014-04-12 00:39:55 +03:00
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
1d24ea5207
py: Finish implementation of all del opcodes.
...
At this point, all opcodes are now implemented!
Some del opcodes have been combined with store opcodes, with the value
to store being MP_OBJ_NULL.
2014-04-08 21:11:49 +01:00
Damien George
523b575039
py: Add LOAD_NULL bytecode and use it to simplify function calls.
...
Adding this bytecode allows to remove 4 others related to
function/method calls with * and ** support. Will also help with
bytecodes that make functions/closures with default positional and
keyword args.
2014-03-31 11:59:23 +01:00
Paul Sokolovsky
48bdb21332
showbc: Dump all CALL_FUNCTION_* and CALL_METHOD_* opcodes.
2014-03-30 17:40:45 +03:00
Damien George
440f041525
py: Fix bugs with debugging output.
...
show_bc now decodes the prelude correctly. Moved WRITE_FILE stuff from
runtime.c to emitglue.c.
Addresses issue #385 .
2014-03-28 18:38:20 +00:00
Paul Sokolovsky
182c31a208
showbc: Add few bytecodes related to "with".
2014-03-28 02:20:21 +02:00
Paul Sokolovsky
2447a5b582
py: Support closures with default args.
2014-03-26 23:17:44 +02:00
Paul Sokolovsky
da8d21e0dd
showbc: Dump YIELD_FROM.
2014-03-22 13:52:08 +02: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
0379b55ab0
py: Fix casting and printing of small int.
2014-02-22 17:34:09 +00:00
Paul Sokolovsky
1d30b11685
showbc: Update for recent int varlen storage refactor.
...
TODO: De-duplicate DECODE_UINT, etc. definitions.
2014-02-21 03:26:56 +02:00
Paul Sokolovsky
047cd40313
Bytecode int varlen encoding: support arbitrary values for signed ints too.
2014-02-19 15:53:41 +02:00
Paul Sokolovsky
da1ce93da8
Implement "from module import *" construct.
2014-02-14 00:30:36 +02:00
Damien George
ddaf6c112c
py: More output in showbc.
2014-02-06 20:31:32 +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
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
Paul Sokolovsky
7ee8e46878
Dump 4 more bytecodes (loop and finally ones).
2014-01-31 19:47:30 +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
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
2014-01-21 21:40:13 +00:00
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.
2014-01-19 11:48:48 +00:00
Damien George
e02b2d4391
py: Temporary fix for bug where not enough VM state is allocated.
2014-01-19 01:14:37 +00:00
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.
2014-01-18 23:24:36 +00:00
Damien George
20006dbba9
Make VM stack grow upwards, and so no reversed args arrays.
...
Change state layout in VM so the stack starts at state[0] and grows
upwards. Locals are at the top end of the state and number downwards.
This cleans up a lot of the interface connecting the VM to C: now all
functions that take an array of Micro Python objects are in order (ie no
longer in reverse).
Also clean up C API with keyword arguments (call_n and call_n_kw
replaced with single call method that takes keyword arguments). And now
make_new takes keyword arguments.
emitnative.c has not yet been changed to comply with the new order of
stack layout.
2014-01-18 14:10:48 +00:00
John R. Lenton
b8698fca75
unified the bops
2014-01-11 00:58:59 +00:00
Paul Sokolovsky
4b919d0135
Dump few more bytecodes (based on attempt to run real-world code).
2014-01-11 00:10:49 +02:00
Damien George
d3ebe4829d
Factor and simplify Makefile's and mpconfig, part 2.
2014-01-07 15:20:33 +00:00
Damien George
e9906ac3d7
Add ellipsis object.
2014-01-04 18:44:46 +00:00
Damien George
66028ab6dc
Basic implementation of import.
...
import works for simple cases. Still work to do on finding the right
script, and setting globals/locals correctly when running an imported
function.
2014-01-03 14:03:48 +00:00
Damien George
27bf5b829b
py: Add more bytecodes to showbc.c.
2014-01-02 18:15:33 +00:00
Damien George
6baf76e28b
py: make closures work.
2013-12-30 22:32:17 +00:00
Damien George
212c296c0b
Make unix-cpy cross platform; remove dependency of asmx64 on mpconfig.
2013-12-30 12:52:32 +00:00
Damien George
cd340c44c2
Merge branch 'cross-plat' of https://github.com/pfalcon/micropython into pfalcon-cross-plat
2013-12-30 12:08:18 +00:00
Paul Sokolovsky
e85c38992d
Make "unix" target be crossplatform and support x86, x64, ARM hosts.
2013-12-30 03:38:32 +02:00