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.
11 years ago
Paul Sokolovsky
edbdf71f5c
rt_unpack_sequence(): Support generic iterables.
11 years ago
Damien George
48697f1dd2
Tidy up some comments.
11 years ago
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.
11 years ago
Damien George
7e5fb24e3b
py: Reduce code size of compiler by a bit.
11 years ago
Damien George
e24b563796
py: Fix emitcpy so continue is compatible with CPython.
11 years ago
Damien George
cbddb279bb
py: Implement break/continue from an exception with finally.
Still todo: break/continue from within the finally block itself.
11 years ago
Damien George
fb083ea986
py: mp_execute_byte_code has 2 arg arrays, for more efficient default params.
11 years ago
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.
11 years ago
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.
11 years ago
Damien George
8b56beb1a1
py: Simplified rt_call_function_n_kw.
11 years ago
Damien George
94f68300f9
py: Make str.replace do 2 passes over the string.
11 years ago
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.
11 years ago
Paul Sokolovsky
8519342c1a
Update VM stacks comments.
11 years ago
Paul Sokolovsky
c7a0b14df9
vm: Introduce structure for exception stack entry, record entry type.
Also, handle SETUP_FINALLY opcode.
11 years ago
Paul Sokolovsky
7ee8e46878
Dump 4 more bytecodes (loop and finally ones).
11 years ago
Paul Sokolovsky
027594e1a7
Typo fixes in comments.
11 years ago
xbe
480c15afb5
Implement str.replace and add tests for it.
11 years ago
Damien George
3f759b71c6
py: Add MICROPY_ENABLE_FLOAT around a float specific piece of code.
11 years ago
Damien George
39631bc312
Fix Makefiles: -O3 option was not being applied; mkdir for STM.
11 years ago
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.
11 years ago
Damien George
09a0c64bce
py: Improve __bool__ and __len__ dispatch; add slots for them.
11 years ago
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.
11 years ago
Paul Sokolovsky
cdd2c62e07
realloc(): Log original memory ptr too.
To alloc complete memory alloc flow tracing.
11 years ago
Damien George
62ad189a65
py: Add compile option to enable/disable source line numbers.
11 years ago
Damien George
2d15c1216d
stm: Add optional memory debugging output.
11 years ago
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.
11 years ago
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.
11 years ago
Damien George
1ba1facaaa
py: Msg in exception is no longer interned.
11 years ago
Damien George
4d5b28cd08
Add qstr_info() function and bindings for unix port.
11 years ago
Damien George
e4b6a079b3
py: Implement 'not' in compiler, and improve rt_is_true.
11 years ago
Paul Sokolovsky
7f11c794a5
mp_obj_new_bytearray_by_ref(): Allow to create array by reference.
This is special feature for FFI.
11 years ago
Markus Siemens
242856cfbf
Fixed problems with nlx86.S on Linux
Fixed '#ifdef's so Linux would compile again and added
.scl and .type for Windows.
11 years ago
Markus Siemens
19ccc6bdc7
Added Windows port (see #233 )
11 years ago
Paul Sokolovsky
1801421f6d
bytearray: Print objects properly.
11 years ago
Paul Sokolovsky
0b7e29c025
Factor out quoted string print function for reuse (mp_str_print_quoted()).
11 years ago
Paul Sokolovsky
7e652af242
array: CPython prints empty arrays inconsistently (only typecode, no []).
11 years ago
Paul Sokolovsky
0dd0467a97
Don't pre-import array module.
11 years ago
Paul Sokolovsky
11973b48b5
array.array: Allow to create empty arrays.
11 years ago
Damien George
4e8dc8c41b
py: Add unary op not for NoneType, bool, tuple, list, dict; fix for int.
11 years ago
Paul Sokolovsky
9b00dad7bb
long int: Implement more operations.
11 years ago
mux
00a4da93e8
Fix implicit double conversion warning
11 years ago
Paul Sokolovsky
ddf1aa9223
list.pop(): Don't allow ->alloc drop to zero, which causes unexpected behavior.
11 years ago
Paul Sokolovsky
14d28be344
gen.send(): Throw StopIteration. Also, explicitly shutdown finished gen.
Otherwise, some generator statements still may be spuriously executed on
subsequent calls to next()/send().
11 years ago
Paul Sokolovsky
bf38e2a03a
Implement send() method for generators.
11 years ago
Paul Sokolovsky
9d95a2b21d
Functions of fixed number of args are special-cased only for 3 or less args.
11 years ago
Paul Sokolovsky
2ca84aa01e
Add MP_OBJ_IS_INT(), for symmetry with MP_OBJ_IS_STR().
11 years ago
Dave Hylands
1a3b0d5fed
Fixed dependency problem for qstrdefs.generated.h
The problem manifests itself in make 4.0
I also fixed the LINK message when linking the final executable for unix and unix-cpy.
11 years ago
Damien George
b829b5caec
Implement mp_parse_node_free; print properly repr(string).
11 years ago
Damien George
28eb57786d
py: Optimise generated code for working out line numbers.
11 years ago