Commit Graph

786 Commits (9ed5435061cc6ae85cd9d8556d934c0e638ffadd)

Author SHA1 Message Date
Paul Sokolovsky 9ed5435061 Implement slicing for tuples. 2014-02-02 03:42:07 +02:00
Paul Sokolovsky 13cfabd1b2 Implement slicing for lists. 2014-02-02 03:32:55 +02:00
Paul Sokolovsky 7364af2d8c Factor out m_seq_get_fast_slice_indexes() fucntions as sequence helper.
Takes slice object and sequence length and computes subsequence indexes
for case of slice step=1.
2014-02-02 02:38:22 +02:00
Paul Sokolovsky a9459bc723 unix: Add basic time module (with time() and clock() functions).
Both return int so far (single-precision float doesn't have enough
bits to represent int32 precisely).
2014-02-02 01:34:11 +02:00
Paul Sokolovsky 513e6567b1 Add testcase for sequence unpacking. 2014-02-02 01:34:11 +02:00
Paul Sokolovsky edbdf71f5c rt_unpack_sequence(): Support generic iterables. 2014-02-02 01:34:11 +02:00
Damien George 48697f1dd2 Tidy up some comments. 2014-02-01 23:32:29 +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 7e5fb24e3b py: Reduce code size of compiler by a bit. 2014-02-01 22:18:47 +00:00
Damien George e24b563796 py: Fix emitcpy so continue is compatible with CPython. 2014-02-01 21:56:25 +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 a908202d60 unix: libffi include path now found using pkg-config.
Hopefully this works for other people as well :)
2014-02-01 18:48:19 +00:00
Damien George 6fcaea6ca8 Merge pull request #254 from pfalcon/config-modules
Add mpconfigport.mk file to configure which modules to include into build
2014-02-01 10:44:17 -08: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
Paul Sokolovsky ed1239fce6 Add mpconfigport.mk file to configure which modules to include into build.
Proof of concept, controls "ffi" module as one which requires external
dependencies.
2014-02-01 20:09:45 +02: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
Damien George 382b3d00ed Merge pull request #251 from pfalcon/return_unwind
Add exception stack unwind support for RETURN_VALUE.
2014-02-01 09:10:47 -08:00
Damien George d71cd86dc1 Merge branch 'iabdalkader-master'
Conflicts:
	stm/usb.c
	stm/usb.h
2014-02-01 16:17:06 +00:00
Damien George 01156d510c stm: Add support for ctrl-C to interrupt running Python.
Using PendSV interrupt at lowest priority, code can now raise an
exception during an interrupt by calling pendsv_nlr_jump.  The exception
will be raised when all interrupts are finished.  This is used to trap
ctrl-C from the USB VCP to break out of running Python code.
2014-02-01 16:04:34 +00:00
mux 565fdccfd2 Add usb_vcp_connected prototype to usb.h 2014-02-01 15:49:16 +02: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
mux b2269b610e Detect VCP line state.
* Detect VCP line state, based on SET_CONTROL_LINE_STATE request
2014-02-01 13:28:29 +02:00
Damien George 532f2c30f6 Merge pull request #246 from pfalcon/exc_stack_entry
vm: Introduce structure for exception stack entry, record entry type.
2014-01-31 15:51:20 -08:00
Damien George 8b56beb1a1 py: Simplified rt_call_function_n_kw. 2014-01-31 23:49:49 +00:00
Damien George f3b05449cc Merge branch 'fix_str_call' of github.com:msiemens/micropython into msiemens-fix_str_call 2014-01-31 23:47:52 +00:00
Damien George 94f68300f9 py: Make str.replace do 2 passes over the string. 2014-01-31 23:45:12 +00:00
Damien George 1aa1c511dd Merge branch 'master' of github.com:xbe/micropython into xbe-master 2014-01-31 23:29:57 +00:00
Markus Siemens 2c2a124e16 Fix SIGSEV when running "a"()
rt_call_function_n_kw did check for integers but not for strings
being called. Added a check so running "a"() won't SIGSEV but
throw an exception.
2014-01-31 22:16:23 +01:00
Paul Sokolovsky c9887cbbe2 Add basic try-finally testcase.
It's mildly suprising these work without further changes to exception
handling code (the only change required was to handle SETUP_FINALLY).
2014-01-31 21:33:07 +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 7ee8e46878 Dump 4 more bytecodes (loop and finally ones). 2014-01-31 19:47:30 +02:00
Paul Sokolovsky 027594e1a7 Typo fixes in comments. 2014-01-31 19:47:23 +02:00
Paul Sokolovsky c92a56dc93 Add testcase with exception handler spread across functions. 2014-01-31 17:06:15 +02:00
xbe 480c15afb5 Implement str.replace and add tests for it. 2014-01-30 22:17:30 -08:00
xbe 65365778fd Add tests for str.strip 2014-01-30 22:16:47 -08:00
Damien George 3f759b71c6 py: Add MICROPY_ENABLE_FLOAT around a float specific piece of code. 2014-01-31 00:42:12 +00:00
Damien George 28f93fbb48 Merge pull request #239 from pfalcon/end_finally
vm: Add basic implementation of END_FINALLY opcode.
2014-01-30 14:30:41 -08:00
Damien George 65ae601665 Merge pull request #240 from msiemens/windows_fix
windows: Make windows/main.c independent from unix/main.c
2014-01-30 14:28:38 -08:00
Damien George 39631bc312 Fix Makefiles: -O3 option was not being applied; mkdir for STM. 2014-01-30 22:16:51 +00:00
Markus Siemens 7e0dee0cbf windows: Make windows/main.c independent from unix/main.c
Up to know changes unix/main.c were able to break the windows
build because windows/main.c simply included unix/main.c.

Now windows/main.c stands on it's own and won't break if
unix/main.c changes.
2014-01-30 17:13:16 +01: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 09a0c64bce py: Improve __bool__ and __len__ dispatch; add slots for them. 2014-01-30 10:05:33 +00:00
Damien George b25711ea8f Merge pull request #238 from pfalcon/bool_len
Implement __bool__ and __len__ via unary_op virtual method for all types.
2014-01-30 01:29:32 -08:00
Paul Sokolovsky c1d9bbc345 Implement __bool__ and __len__ via unary_op virtual method for all types.
__bool__() and __len__() are just the same as __neg__() or __invert__(),
and require efficient dispatching implementation (not requiring search/lookup).
type->unary_op() is just the right choice for this short of adding
standalone virtual method(s) to already big mp_obj_type_t structure.
2014-01-30 04:37:19 +02:00
Paul Sokolovsky cdd2c62e07 realloc(): Log original memory ptr too.
To alloc complete memory alloc flow tracing.
2014-01-30 03:58:17 +02:00
Damien George 4a74d31e70 run-tests can handle segfault. 2014-01-29 22:32:23 +00:00
Damien George 14b929f1d9 Merge branch 'master' of github.com:msiemens/micropython into msiemens-master 2014-01-29 22:24:35 +00:00
Damien George 62ad189a65 py: Add compile option to enable/disable source line numbers. 2014-01-29 21:51:51 +00:00