Commit Graph

289 Commits

Author SHA1 Message Date
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
Damien George db12891918 py: Eliminate 'op' variable in VM dispatch loop.
Remembering the last op is rarely needed, and when it is, can simply use
*save_ip.
2014-04-27 18:19:06 +01:00
Damien George c0dc7c3dfa py, vm: Fix recent bug where state is freed too early. 2014-04-24 15:42:05 +01:00
Damien George d5e8482c4a py, vm: Free heap-allocated state if it was allocated on the heap. 2014-04-24 13:52:06 +01:00
Paul Sokolovsky c5e32c6995 vm: Add rudimentary bytecode execution tracing capability. 2014-04-23 03:46:00 +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 3558f62fb5 py: Making closures now passes pointer to stack, not a tuple for vars.
Closed over variables are now passed on the stack, instead of creating a
tuple and passing that.  This way memory for the closed over variables
can be allocated within the closure object itself.  See issue #510 for
background.
2014-04-20 17:50:40 +01:00
Damien George 5b65f0c7d3 py: Rename USE_COMPUTED_GOTOS to USE_COMPUTED_GOTO and enable on stmhal.
On stmhal, computed gotos make the binary about 1k bigger, but makes it
run faster, and we have the room, so why not.  All tests pass on
pyboard using computed gotos.
2014-04-17 23:24:13 +01:00
Damien George ea8d06c39d py: Add MP_OBJ_STOP_ITERATION and make good use of it.
Also make consistent use of MP_OBJ_NOT_SUPPORTED and MP_OBJ_NULL.
This helps a lot in debugging and understanding of function API.
2014-04-17 23:19:36 +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 66ae8c9f49 py: Tidy up variables in VM, probably fixes subtle bugs.
Things get tricky when using the nlr code to catch exceptions.  Need to
ensure that the variables (stack layout) in the exception handler are
the same as in the bit protected by the exception handler.

Prior to this patch there were a few bugs.  1) The constant
mp_const_MemoryError_obj was being preloaded to a specific location on
the stack at the start of the function.  But this location on the stack
was being overwritten in the opcode loop (since it didn't think that
variable would ever be referenced again), and so when an exception
occurred, the variable holding the address of MemoryError was corrupt.
2) The FOR_ITER opcode detection in the exception handler used sp, which
may or may not contain the right value coming out of the main opcode
loop.

With this patch there is a clear separation of variables used in the
opcode loop and in the exception handler (should fix issue (2) above).
Furthermore, nlr_raise is no longer used in the opcode loop.  Instead,
it jumps directly into the exception handler.  This tells the C compiler
more about the possible code flow, and means that it should have the
same stack layout for the exception handler.  This should fix issue (1)
above.  Indeed, the generated (ARM) assembler has been checked explicitly,
and with 'goto exception_handler', the problem with &MemoryError is
fixed.

This may now fix problems with rge-sm, and probably many other subtle
bugs yet to show themselves.  Incidentally, rge-sm now passes on
pyboard (with a reduced range of integration)!

Main lesson: nlr is tricky.  Don't use nlr_push unless you know what you
are doing!  Luckily, it's not used in many places.  Using nlr_raise/jump
is fine.
2014-04-17 16:50:23 +01:00
AZ Huang 9413ca02fb Rename header file. 2014-04-15 21:29:08 +08:00
AZ Huang 9309d9982f Move entry_table to separated header file. 2014-04-15 17:08:42 +08:00
Damien George 3bb8bd899b Make USE_COMPUTED_GOTO a config option in mpconfig.h.
Disabled by default.  Enabled in unix port.
2014-04-14 21:20:30 +01:00
AZ Huang b1f692e82e Use computed goto instead of switching op-codes. 2014-04-15 02:40:28 +08:00
Damien George df8127a17e py: Remove unique_codes from emitglue.c. Replace with pointers.
Attempt to address issue #386.  unique_code_id's have been removed and
replaced with a pointer to the "raw code" information.  This pointer is
stored in the actual byte code (aligned, so the GC can trace it), so
that raw code (ie byte code, native code and inline assembler) is kept
only for as long as it is needed.  In memory it's now like a tree: the
outer module's byte code points directly to its children's raw code.  So
when the outer code gets freed, if there are no remaining functions that
need the raw code, then the children's code gets freed as well.

This is pretty much like CPython does it, except that CPython stores
indexes in the byte code rather than machine pointers.  These indices
index the per-function constant table in order to find the relevant
code.
2014-04-13 11:04:33 +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
Damien George 69b89d21b2 py: Change compile order for default positional and keyword args.
This simplifies the compiler a little, since now it can do 1 pass over
a function declaration, to determine default arguments.  I would have
done this originally, but CPython 3.3 somehow had the default keyword
args compiled before the default position args (even though they appear
in the other order in the text of the script), and I thought it was
important to have the same order of execution when evaluating default
arguments.  CPython 3.4 has changed the order to the more obvious one,
so we can also change.
2014-04-11 13:38:30 +00:00
Damien George a1ef441d18 py: Fix VM stack overflow detection. 2014-04-10 16:59:44 +00:00
Damien George e90be0ddf5 py: Add option to VM to detect stack overflow. 2014-04-10 16:21:34 +00:00
Damien George d99944acdd py: Clear state to MP_OBJ_NULL before executing byte code. 2014-04-09 19:53:31 +01: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 f4c9b33abf py: Remove DELETE_SUBSCR opcode, combine with STORE_SUBSCR.
This makes the runtime and object APIs more consistent.  mp_store_subscr
functionality now moved into objects (ie list and dict store_item).
2014-04-08 21:32:29 +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 495d781a36 py: implement UNPACK_EX byte code (for: a, *b, c = d) 2014-04-08 17:51:47 +01:00
Damien George e753d916c0 py: Raise exception for unimplemented byte codes. 2014-04-08 16:49:28 +01:00
Damien George cdd96dff2c py: Implement more features in native emitter.
On x64, native emitter now passes 70 of the tests.
2014-04-06 12:58:40 +01:00
Damien George ea13f407a3 py: Change nlr_jump to nlr_raise, to aid in debugging.
This does not affect code size or performance when debugging turned off.

To address issue #420.
2014-04-05 18:32:08 +01:00
Damien George 09a4d8305d py: Fix bug in DELETE_SUBSCR bytecode, decreasing sp too much. 2014-04-05 13:47:41 +01:00
Damien George 66edc5d899 py: Implement DELETE_SUBSCR bytecode; implement mp_obj_dict_delete. 2014-04-05 13:25:13 +01:00
Damien George 6902eeda25 py: Add m_malloc_fail function to handle memory allocation error.
A malloc/realloc fail now throws MemoryError.
2014-04-04 10:52:59 +00:00
Damien George 43e92cfb52 Merge branch 'master' of github.com:micropython/micropython 2014-03-31 16:28:58 +01:00
Damien George 15d18069c5 py: Remove old "run time" functions that were 1 liners. 2014-03-31 16:28:13 +01:00
Paul Sokolovsky 7da0660516 mp_resume: Dare to pass send_value of NULL.
There was thinkos that either send_value or throw_value is specified, but
there were cases with both. Note that send_value is pushed onto generator's
stack - but that's probably only good, because if we throw exception into
gen, it should not ever use send_value, and that will be just extra "assert".
2014-03-31 17:22:37 +03:00
Damien George e337f1ef5e py: Towards default keyword arguments.
These are default arguments after a bare *.
2014-03-31 15:18:37 +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 f39d3b93da py: Implement support for generalized generator protocol.
Iterators and ducktype objects can now be arguments of yield from.
2014-03-30 23:30:16 +03:00
Damien George 230fec77d7 py: Implement positional and keyword args via * and **.
Extends previous implementation with * for function calls to * and **
for both function and method calls.
2014-03-30 21:21:24 +01:00
Damien George f6a820903a Merge pull request #396 from pfalcon/call-star
vm: Implement CALL_FUNCTION_VAR opcode (foo(*(1, 2, 3))).
2014-03-30 19:09:16 +01:00
Paul Sokolovsky 14b8203a99 vm: Implement DELETE_FAST_N bytecode. 2014-03-30 17:49:56 +03:00
Paul Sokolovsky 55ca075cab vm: Implement CALL_FUNCTION_VAR opcode (foo(*(1, 2, 3))). 2014-03-30 17:47:16 +03:00
Damien George d17926db71 Rename rt_* to mp_*.
Mostly just a global search and replace.  Except rt_is_true which
becomes mp_obj_is_true.

Still would like to tidy up some of the names, but this will do for now.
2014-03-30 13:35:08 +01:00
Damien George 89f94b51ab py: Rename mp_exc_stack to mp_exc_stack_t. 2014-03-30 00:57:09 +00:00
Damien George d7592a1c3f py: Fix reraise logic. 2014-03-30 00:54:48 +00:00
Paul Sokolovsky 0c904df8e6 vm: Save current active exception on opening new try block.
Required to reraise correct exceptions in except block, regardless if more
try blocks with active exceptions happen in the same except block.

P.S. This "automagic reraise" appears to be quite wasteful feature of Python
- we need to save pending exception just in case it *might* be reraised.
Instead, programmer could explcitly capture exception to a variable using
"except ... as var", and reraise that. So, consider disabling argless raise
support as an optimization.
2014-03-30 01:01:35 +02:00
Paul Sokolovsky 69975df3ff vm: WITH_CLEANUP: use POP_EXC_BLOCK(). 2014-03-30 01:00:51 +02:00
Paul Sokolovsky a0ad77ba08 vm: Establish macros PUSH_EXC_BLOCK & POP_EXC_BLOCK to deal with exc stack.
E.g. to handle currently_in_except_block restoring properly.
2014-03-29 23:18:59 +02:00
Paul Sokolovsky d109676ec0 py: Reraising exception possible only in except block. 2014-03-29 23:18:59 +02:00
Paul Sokolovsky 40d6d29af6 vm: Elaborate comments for WITH_CLEANUP, other cosmetic fixes. 2014-03-29 18:46:04 +02:00
Damien George c689c19471 py: Make MP_BC_SETUP_WITH use the bytecode stack for load_method.
The compiler allocates 7 entries on the stack for a with statement
(following CPython, but probably can be reduced).  This is enough for
the method load and call in SETUP_WITH.
2014-03-29 14:06:14 +00:00
Damien George 21a07dc50f Merge pull request #389 from pfalcon/with-statement
With statement implementation
2014-03-29 14:00:03 +00:00
Damien George b04be056fe py: Fix regress with GeneratorExit object becoming truly const. 2014-03-29 13:52:51 +00:00
Damien George 07ddab529c py: Change mp_const_* objects to macros.
Addresses issue #388.
2014-03-29 13:15:08 +00:00
Damien George da51a399cf Merge pull request #383 from pfalcon/yield-from
Implement "yield from"
2014-03-29 12:18:14 +00:00
Damien George d1e443d0bc py: Free unique_code slot for outer module.
Partly (very partly!) addresses issue #386.  Most importantly, at the
REPL command line, each invocation does not now lead to increased memory
usage (unless you define a function/lambda).
2014-03-29 11:39:36 +00:00
Paul Sokolovsky 44307d5ef8 vm: Implement "with" statement (SETUP_WITH and WITH_CLEANUP bytecodes). 2014-03-29 04:39:24 +02:00
Paul Sokolovsky 682f9e639d vm: Make sure that exception triple is <type, instance, traceback>.
This reduntant triple is one of the ugliest parts of Python, which they
chickened out to fix in Python3. We really should consider passing just
as single exception instance (without breaking Python-level APIs of course),
but until we do, let's follow CPython layout.
2014-03-29 04:35:36 +02:00
Paul Sokolovsky 4fff26a35c vm: Factor out exception block setup to a macro.
Will be reused in WITH bytecodes.
2014-03-29 04:35:23 +02:00
Paul Sokolovsky 55234f4617 py: yield from: Elaborate GeneratorExit (gen.close()) handling.
Handling of GeneratorExit is really peculiar - it subverts normal exception
propagation rules.
2014-03-28 02:50:56 +02:00
Paul Sokolovsky cf21a4e7f4 py: Core "yield from" implementation. 2014-03-28 02:50:56 +02:00
Damien George bee17b00e3 py: Put n_state for bytecode in the bytecode prelude.
Rationale: setting up the stack (state for locals and exceptions) is
really part of the "code", it's the prelude of the function.  For
example, native code adjusts the stack pointer on entry to the function.
Native code doesn't need to know n_state for any other reason.  So
putting the state size in the bytecode prelude is sensible.

It reduced ROM usage on STM by about 30 bytes :)  And makes it easier to
pass information about the bytecode between functions.
2014-03-27 11:07:04 +00:00
Damien George 8dcc0c7924 py: Calculate maximum exception stack size in compiler. 2014-03-27 10:55:21 +00:00
Paul Sokolovsky 2447a5b582 py: Support closures with default args. 2014-03-26 23:17:44 +02:00
Damien George 66eaf84b8c py: Replace mp_const_stop_iteration object with MP_OBJ_NULL. 2014-03-26 19:27:58 +00:00
Damien George 688e220d26 Merge pull request #379 from pfalcon/reraise
vm: Implement raise statement w/o args (reraising last exception).
2014-03-26 18:59:15 +00:00
Damien George 9e6e935df0 py: Add support for user-defined iterators via __iter__, __next__. 2014-03-26 18:37:06 +00:00
Paul Sokolovsky c403076ef8 vm: Implement raise statement w/o args (reraising last exception). 2014-03-26 17:32:02 +02:00
Paul Sokolovsky f909034400 py: Implement support for "except Exception as var" clause.
For this, needed to implement DELETE_NAME bytecode (because var bound
in except clause is automatically deleted at its end).
http://docs.python.org/3/reference/compound_stmts.html#except :
"When an exception has been assigned using as target, it is cleared at
the end of the except clause."
2014-03-23 22:00:04 +02:00
Paul Sokolovsky 1673420053 vm: Abstract working with tagged pointers in VM using macro accessors.
Based on issues raised during recent review and inconsistency of different
implementations.
2014-03-23 21:41:29 +02:00
Damien George ffa37db5c5 py: Fix int -> machine_uint_t. 2014-03-22 20:43:45 +00:00
Paul Sokolovsky 48caa09a9d objgenerator: Implement .throw() method to throw exceptions into generator. 2014-03-22 17:55:42 +02:00
Paul Sokolovsky c0abc28aa1 objgenerator: Keep exception stack within generator object, like value stack.
This is required to properly handle exceptions across yields.
2014-03-22 17:55:42 +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 4d79d5dd7c py: Fix type of integer in decoding int. 2014-02-20 00:00:04 +00: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 0f96ec8268 Bytecode uint varlen encoding: support arbitrary values. 2014-02-19 15:52:57 +02:00
Damien George c8f78bc280 py: VM never throws an exception, instead returns a status and value.
Addresses issue #290, and hopefully sets up things to allow generators
throwing exceptions, etc.
2014-02-15 22:55:00 +00:00
Damien George c5966128c7 Implement proper exception type hierarchy.
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-15 16:10:44 +00:00
Damien George aa9b74fead py: Fix IMPORT_STAR, needs to pop the stack. 2014-02-14 23:06:33 +00:00
Paul Sokolovsky da1ce93da8 Implement "from module import *" construct. 2014-02-14 00:30:36 +02: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
Damien George fb083ea986 py: mp_execute_byte_code has 2 arg arrays, for more efficient default params. 2014-02-01 18:29:40 +00:00
Damien George 87413a4d0c Merge branch 'fun-defargs' of github.com:pfalcon/micropython into pfalcon-fun-defargs 2014-02-01 17:51:47 +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 6472dea146 Add exception stack unwind support for RETURN_VALUE.
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-02-01 15:23:03 +02:00
Paul Sokolovsky 8519342c1a Update VM stacks comments. 2014-01-31 19:48:53 +02:00
Paul Sokolovsky c7a0b14df9 vm: Introduce structure for exception stack entry, record entry type.
Also, handle SETUP_FINALLY opcode.
2014-01-31 19:48:53 +02:00
Paul Sokolovsky 382e8eeea2 vm: Add basic implementation of END_FINALLY opcode.
Allows to have nested try blocks with except filters.

TODO: Don't add END_FINALLY's exception re-raise points to traceback.
2014-01-30 13:49:18 +02:00
Damien George d0691ccaec py: Simplify fastn in VM; reduce size of unique code struct.
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-29 20:30:52 +00: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
Paul Sokolovsky bf38e2a03a Implement send() method for generators. 2014-01-26 20:56:08 +02:00
Damien George 28eb57786d py: Optimise generated code for working out line numbers. 2014-01-25 11:43:20 +00:00
Paul Sokolovsky 91fb1c9b13 Add basic implementation of bytes type, piggybacking on str.
This reuses as much str implementation as possible, from this we
can make them more separate as needed.
2014-01-24 22:56:26 +02:00
Damien George 600ae734cf py: Implement break and continue byte codes, and add tests.
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-21 23:48:04 +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 136b149e41 py: Add full traceback to exception printing. 2014-01-19 12:38:49 +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 932bf1c48f py: Fix VM/runtime unpack sequence bug, Issue #193. 2014-01-18 23:42:49 +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
Paul Sokolovsky a9f5abd48c Implement LOAD_CONST_INT (by dispatching to int object implementation). 2014-01-17 20:05:10 +02:00
John R. Lenton 5c76839559 sorted 2014-01-13 05:12:50 +00:00
Damien George 8d4ccc49ed Merge branch 'master' of github.com:dpgeorge/micropython 2014-01-11 09:37:41 +00:00
Damien George 25042b19d2 py: Make arg to MP_BC_RAISE_VARARGS a byte. 2014-01-11 09:33:39 +00:00
John R. Lenton b8698fca75 unified the bops 2014-01-11 00:58:59 +00:00
Paul Sokolovsky 5388a3c29a Crude attempt to implement RAISE_VARARGS (with args=1 so far only). 2014-01-11 00:55:08 +02:00
Paul Sokolovsky e5ee1693ad Use constructor to create small int (avoid exposing mp_obj_t internals to VM). 2014-01-06 17:54:16 +02:00
Damien George e9906ac3d7 Add ellipsis object. 2014-01-04 18:44:46 +00:00
Paul Sokolovsky e606cb6561 slice: Allow building with MICROPY_ENABLE_SLICE=0. 2014-01-04 02:35:49 +02:00
Paul Sokolovsky ded0a1efa5 Implement BUILD_SLICE opcode (2-arg version). 2014-01-04 02:35:48 +02:00
Damien George 66327006fc py: change negative array indices with array - 1. 2014-01-02 18:20:41 +00:00
Paul Sokolovsky bdf822b3d8 Add quick impl for MP_BC_LOAD_CONST_BYTES which just creates qstr so far.
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)).
2014-01-02 18:51:19 +02:00
Damien George 6baf76e28b py: make closures work. 2013-12-30 22:32:17 +00:00
Damien 02a7c41e76 py: implement POP_BLOCK in VM. 2013-12-29 18:48:37 +00:00
Damien b86e3f9293 py: implement some basic exception matching. 2013-12-29 17:17:43 +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 660365e14c py: split runtime into map, obj, builtin. 2013-12-17 18:27:24 +00:00
Damien 9ecbcfff99 py: work towards working closures. 2013-12-11 00:41:43 +00:00
Damien db4c361f1c py: add skeletal import functionality. 2013-12-10 17:27:24 +00:00
Damien 6f3e7fc505 py: add UNPACK_SEQUENCE and keyword methods to VM. 2013-11-26 15:15:50 +00:00
Damien 94658e2e25 Add JUMP_IF_x_OR_POP opcodes to VM. 2013-11-09 20:12:32 +00:00
Damien 40fdfe3000 Improve allocation of stack for byte code. 2013-11-05 22:16:22 +00:00
Damien 03c9cfb015 Make byte code jumps relative. 2013-11-05 22:06:08 +00:00
Damien 6addc89e55 Byte code for SMALL_INT uses 3 bytes for integer. 2013-11-04 23:04:50 +00:00
Damien 7410e440ab Add basic complex number support. 2013-11-02 19:47:57 +00:00
Damien 4ebb32fb95 Implement: str.join, more float support, ROT_TWO in VM. 2013-11-02 14:33:10 +00:00
Damien c12aa468a1 Add SET_ADD opcode to VM. 2013-10-16 20:57:49 +01:00
Damien 5fd09668b7 Add MAP_ADD opcode to VM. 2013-10-16 20:54:01 +01:00
Damien bd25445a82 Implement BC & runtime support for generator/yielding. 2013-10-16 20:39:12 +01:00
Damien c226dca1f7 Support tuples and list comprehension, albeit crude. 2013-10-16 16:12:52 +01:00
Damien c9f91976e1 Crude try-except working. 2013-10-15 23:46:01 +01:00
Damien ce89a21ea4 Implement basic exception framework, and simple for loop. 2013-10-15 22:25:17 +01:00
Damien c025ebb2dc Separate out mpy core and unix version. 2013-10-12 14:30:21 +01:00
Damien eb19efb27e Simplify and improve function & method calling. 2013-10-10 22:06:54 +01:00
Damien a397776d6b Implement basic class/object functionality in runtime. 2013-10-09 23:10:10 +01:00
Damien b05d707b23 Further factorise PASS_1 out of specific emit code. 2013-10-05 13:37:10 +01:00