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
Damien
dae7eb7226
py: add dict length function, and fix rt_store_set.
2013-12-29 22:32:51 +00:00
Damien
8f9e2ee157
Add code in VM to handle nested exceptions correctly.
2013-12-29 16:54:59 +00:00
Damien
d99b05282d
Change object representation from 1 big union to individual structs.
...
A big change. Micro Python objects are allocated as individual structs
with the first element being a pointer to the type information (which
is itself an object). This scheme follows CPython. Much more flexible,
not necessarily slower, uses same heap memory, and can allocate objects
statically.
Also change name prefix, from py_ to mp_ (mp for Micro Python).
2013-12-21 18:17:45 +00:00
Damien
ff099f36d6
py: add more functionality to showbc.
2013-11-26 15:14:50 +00:00
Damien
c1075ddc8f
py: add some more opcodes to showbc.
2013-11-25 23:39:36 +00:00
Damien
f03001f8a6
Add function to decode and show byte code.
2013-11-17 13:19:33 +00:00