Damien George
f78b6df192
py: Disable dump_args function call entirely when not debugging.
Yes, I know, a good compiler will optimise this away, but I feel this is
neater.
11 years ago
Damien George
e337f1ef5e
py: Towards default keyword arguments.
These are default arguments after a bare *.
11 years ago
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.
11 years ago
Damien George
3056509e00
py: Rename and reorder parameters in emit_make_function/closure.
In preparation for implementing default keyword arguments.
11 years ago
Paul Sokolovsky
6ded55a61f
py: Properly implement divide-by-zero handling.
"1/0" is sacred idiom, the shortest way to break program execution
(sys.exit() is too long).
11 years ago
Paul Sokolovsky
96ed213320
objfloat: Quick&dirty implementation of float floor division.
TODO: Likely doesn't match Python semantics for negative numbers.
11 years ago
Paul Sokolovsky
96eec4f8a6
compile: Don't try to constant-fold division by zero.
The way it is, just crashes app. And optimizing to
"raise ZeroDivisionError" is probably too much.
11 years ago
Paul Sokolovsky
864038dab7
objfloat: Make sure that floats always have dot (for C "double" type case).
This matches CPython behavior and hopefully can be treated as general
Python semantics.
11 years ago
Paul Sokolovsky
a8e60c1fde
objfloat: Missing default: caused incorrect results for unimplemented ops.
11 years ago
Paul Sokolovsky
a96d3d0840
objexcept: No more magic messages in exceptions, only exception arguments.
One of the reason for separate "message" (besides still unfulfilled desire to
optimize memory usage) was apparent special handling of exception with
messages by CPython. Well, the message is still just an exception argument,
it just printed specially. Implement that with PRINT_EXC printing format.
11 years ago
Damien George
e0f2979aed
py: Add equality test for None object.
11 years ago
Damien George
6433bd927a
py: Add explicit conversion from float to int via int().
11 years ago
Damien George
804760bfca
py: Fix bug in compiler for empty class bases.
Eg class A(): pass would fail an assertion.
11 years ago
Damien George
0997af932f
py: Don't wrap necessary function calls in assert.
11 years ago
Paul Sokolovsky
f7eaf605c0
py: Fix "TypeError: 'iterator' object is not iterable", doh.
11 years ago
Paul Sokolovsky
f39d3b93da
py: Implement support for generalized generator protocol.
Iterators and ducktype objects can now be arguments of yield from.
11 years ago
Paul Sokolovsky
a30cf9f3af
objzip: Use mp_identity().
11 years ago
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.
11 years ago
Paul Sokolovsky
7fafb28f6d
objgenerator: Handle default args to generator functions.
Addresses #397 .
11 years ago
Paul Sokolovsky
14b8203a99
vm: Implement DELETE_FAST_N bytecode.
11 years ago
Paul Sokolovsky
55ca075cab
vm: Implement CALL_FUNCTION_VAR opcode (foo(*(1, 2, 3))).
11 years ago
Paul Sokolovsky
48bdb21332
showbc: Dump all CALL_FUNCTION_* and CALL_METHOD_* opcodes.
11 years ago
Damien George
df6567e634
Merge map.h into obj.h.
Pretty much everyone needs to include map.h, since it's such an integral
part of the Micro Python object implementation. Thus, the definitions
are now in obj.h instead. map.h is removed.
11 years ago
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.
11 years ago
Paul Sokolovsky
24a140a444
objexcept: Fix another place missing proper args tuple initialization.
11 years ago
Paul Sokolovsky
ee5ecc9de2
objgenerator.throw: Instantiate if exception type passed, just as "raise".
Caught by CPython test_pep380.py.
11 years ago
Paul Sokolovsky
9a54a22318
objgenerator.throw(): Throwing GeneratorExit is equivalent to .close().
According to PEP380 and caught by CPython test_pep380.py .
11 years ago
Paul Sokolovsky
6ae237d2bd
objgenerator: Store proper code_info pointer.
11 years ago
Paul Sokolovsky
aaff716189
objgenerator: mp_obj_gen_resume() suitable only for generators.
11 years ago
Paul Sokolovsky
8d9cc2e669
compile: Print error messages on unimplemented relative imports.
11 years ago
Paul Sokolovsky
0ae518fb9e
mp_obj_print_exception(): Assert that traceback has sane number of entries.
11 years ago
Damien George
89f94b51ab
py: Rename mp_exc_stack to mp_exc_stack_t.
11 years ago
Damien George
d7592a1c3f
py: Fix reraise logic.
11 years ago
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.
11 years ago
Paul Sokolovsky
69975df3ff
vm: WITH_CLEANUP: use POP_EXC_BLOCK().
11 years ago
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.
11 years ago
Paul Sokolovsky
d109676ec0
py: Reraising exception possible only in except block.
11 years ago
Damien George
0aa5d51cf1
py: Support mpz -op- float, mpz -op- complex, and complex -op- mpz.
11 years ago
Paul Sokolovsky
40d6d29af6
vm: Elaborate comments for WITH_CLEANUP, other cosmetic fixes.
11 years ago
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.
11 years ago
Damien George
b04be056fe
py: Fix regress with GeneratorExit object becoming truly const.
11 years ago
Damien George
3e1a5c10c5
py: Rename old const type objects to mp_type_* for consistency.
11 years ago
Damien George
07ddab529c
py: Change mp_const_* objects to macros.
Addresses issue #388 .
11 years ago
Damien George
6e54fcfd12
py: Fix typo printing complex numbers that are purely imaginary.
11 years ago
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).
11 years ago
Paul Sokolovsky
44307d5ef8
vm: Implement "with" statement (SETUP_WITH and WITH_CLEANUP bytecodes).
11 years ago
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.
11 years ago
Paul Sokolovsky
4fff26a35c
vm: Factor out exception block setup to a macro.
Will be reused in WITH bytecodes.
11 years ago
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 .
11 years ago
Paul Sokolovsky
55234f4617
py: yield from: Elaborate GeneratorExit (gen.close()) handling.
Handling of GeneratorExit is really peculiar - it subverts normal exception
propagation rules.
11 years ago