aboutsummaryrefslogtreecommitdiff
path: root/py/vm.c
AgeCommit message (Collapse)Author
2014-02-20py: Fix type of integer in decoding int.Damien George
2014-02-19Bytecode int varlen encoding: support arbitrary values for signed ints too.Paul Sokolovsky
2014-02-19Bytecode uint varlen encoding: support arbitrary values.Paul Sokolovsky
2014-02-15py: VM never throws an exception, instead returns a status and value.Damien George
Addresses issue #290, and hopefully sets up things to allow generators throwing exceptions, etc.
2014-02-15Implement proper exception type hierarchy.Damien George
Each built-in exception is now a type, with base type BaseException. C exceptions are created by passing a pointer to the exception type to make an instance of. When raising an exception from the VM, an instance is created automatically if an exception type is raised (as opposed to an exception instance). Exception matching (RT_BINARY_OP_EXCEPTION_MATCH) is now proper. Handling of parse error changed to match new exceptions. mp_const_type renamed to mp_type_type for consistency.
2014-02-14py: Fix IMPORT_STAR, needs to pop the stack.Damien George
2014-02-14Implement "from module import *" construct.Paul Sokolovsky
2014-02-01py: Tidy up BINARY_OPs; negation done by special NOT bytecode.Damien George
IS_NOT and NOT_IN are now compiled to IS + NOT and IN + NOT, with a new special NOT bytecode.
2014-02-01py: Implement break/continue from an exception with finally.Damien George
Still todo: break/continue from within the finally block itself.
2014-02-01py: mp_execute_byte_code has 2 arg arrays, for more efficient default params.Damien George
2014-02-01Merge branch 'fun-defargs' of github.com:pfalcon/micropython into ↵Damien George
pfalcon-fun-defargs
2014-02-01Implement default function arguments (for Python functions).Paul Sokolovsky
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-01Add exception stack unwind support for RETURN_VALUE.Paul Sokolovsky
This properly implements return from try/finally block(s). TODO: Consider if we need to do any value stack unwinding for RETURN_VALUE case. Intuitively, this is "success" return, so value stack should be in good shape, and unwinding shouldn't be required.
2014-01-31Update VM stacks comments.Paul Sokolovsky
2014-01-31vm: Introduce structure for exception stack entry, record entry type.Paul Sokolovsky
Also, handle SETUP_FINALLY opcode.
2014-01-30vm: Add basic implementation of END_FINALLY opcode.Paul Sokolovsky
Allows to have nested try blocks with except filters. TODO: Don't add END_FINALLY's exception re-raise points to traceback.
2014-01-29py: Simplify fastn in VM; reduce size of unique code struct.Damien George
We still have FAST_[0,1,2] byte codes, but they now just access the fastn array (before they had special local variables). It's now simpler, a bit faster, and uses a bit less stack space (on STM at least, which is most important). The only reason now to keep FAST_[0,1,2] byte codes is for compressed byte code size.
2014-01-29py: Fix bug with LOAD_METHOD; fix int->machine_int_t for small int.Damien George
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-26Implement send() method for generators.Paul Sokolovsky
2014-01-25py: Optimise generated code for working out line numbers.Damien George
2014-01-24Add basic implementation of bytes type, piggybacking on str.Paul Sokolovsky
This reuses as much str implementation as possible, from this we can make them more separate as needed.
2014-01-21py: Implement break and continue byte codes, and add tests.Damien George
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).
2014-01-21Revamp qstrs: they now include length and hash.Damien George
Can now have null bytes in strings. Can define ROM qstrs per port using qstrdefsport.h
2014-01-19py: Add full traceback to exception printing.Damien George
2014-01-19py: Add module/function/class name to exceptions.Damien George
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-19py: Temporary fix for bug where not enough VM state is allocated.Damien George
2014-01-18py: Fix VM/runtime unpack sequence bug, Issue #193.Damien George
2014-01-18Add source file name and line number to error messages.Damien George
Byte code has a map from byte-code offset to source-code line number, used to give better error messages.
2014-01-18Make VM stack grow upwards, and so no reversed args arrays.Damien George
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-17Implement LOAD_CONST_INT (by dispatching to int object implementation).Paul Sokolovsky
2014-01-13sortedJohn R. Lenton
2014-01-11Merge branch 'master' of github.com:dpgeorge/micropythonDamien George
2014-01-11py: Make arg to MP_BC_RAISE_VARARGS a byte.Damien George
2014-01-11unified the bopsJohn R. Lenton
2014-01-11Crude attempt to implement RAISE_VARARGS (with args=1 so far only).Paul Sokolovsky
2014-01-06Use constructor to create small int (avoid exposing mp_obj_t internals to VM).Paul Sokolovsky
2014-01-04Add ellipsis object.Damien George
2014-01-04slice: Allow building with MICROPY_ENABLE_SLICE=0.Paul Sokolovsky
2014-01-04Implement BUILD_SLICE opcode (2-arg version).Paul Sokolovsky
2014-01-02py: change negative array indices with array - 1.Damien George
2014-01-02Add quick impl for MP_BC_LOAD_CONST_BYTES which just creates qstr so far.Paul Sokolovsky
This is based on the fact that qstr so far behaves more like byte string than like Unicode string (for example, "012"[0] returns 48 (int)).
2013-12-30py: make closures work.Damien George
2013-12-29py: implement POP_BLOCK in VM.Damien
2013-12-29py: implement some basic exception matching.Damien
2013-12-29Add code in VM to handle nested exceptions correctly.Damien
2013-12-21Change object representation from 1 big union to individual structs.Damien
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-17py: split runtime into map, obj, builtin.Damien
2013-12-11py: work towards working closures.Damien
2013-12-10py: add skeletal import functionality.Damien
2013-11-26py: add UNPACK_SEQUENCE and keyword methods to VM.Damien