Commit Graph

1327 Commits

Author SHA1 Message Date
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.
2014-03-31 02:23:57 +03:00
Paul Sokolovsky a8e60c1fde objfloat: Missing default: caused incorrect results for unimplemented ops. 2014-03-31 02:23:56 +03:00
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.
2014-03-31 02:23:56 +03:00
Damien George e0f2979aed py: Add equality test for None object. 2014-03-30 23:16:42 +01:00
Damien George 6433bd927a py: Add explicit conversion from float to int via int(). 2014-03-30 23:13:16 +01:00
Damien George 804760bfca py: Fix bug in compiler for empty class bases.
Eg class A(): pass would fail an assertion.
2014-03-30 23:06:37 +01:00
Damien George 0997af932f py: Don't wrap necessary function calls in assert. 2014-03-30 21:55:28 +01:00
Damien George 0aa4379543 Merge pull request #399 from pfalcon/gen-defargs
objgenerator: Handle default args to generator functions.
2014-03-30 21:51:49 +01:00
Paul Sokolovsky f7eaf605c0 py: Fix "TypeError: 'iterator' object is not iterable", doh. 2014-03-30 23:37:24 +03: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
Paul Sokolovsky a30cf9f3af objzip: Use mp_identity(). 2014-03-30 23:30:15 +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 7fafb28f6d objgenerator: Handle default args to generator functions.
Addresses #397.
2014-03-30 20:25:19 +03: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
Paul Sokolovsky 48bdb21332 showbc: Dump all CALL_FUNCTION_* and CALL_METHOD_* opcodes. 2014-03-30 17:40:45 +03:00
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.
2014-03-30 13:54:02 +01: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 09d207785c stmhal: Unify naming of HW config; make SD detect configurable.
All board config macros now begin with MICROPY_HW_.

Renamed PYBv10 to PYBV10, since macros should be all uppercase.

Made SDCARD_DETECT configurable in mpconfigport.h, so that the SD
detect pin can be easily configured.
2014-03-30 12:30:35 +01:00
Paul Sokolovsky 24a140a444 objexcept: Fix another place missing proper args tuple initialization. 2014-03-30 13:29:33 +03:00
Paul Sokolovsky ee5ecc9de2 objgenerator.throw: Instantiate if exception type passed, just as "raise".
Caught by CPython test_pep380.py.
2014-03-30 13:21:11 +03:00
Paul Sokolovsky 9a54a22318 objgenerator.throw(): Throwing GeneratorExit is equivalent to .close().
According to PEP380 and caught by CPython test_pep380.py .
2014-03-30 13:21:11 +03:00
Paul Sokolovsky 6ae237d2bd objgenerator: Store proper code_info pointer. 2014-03-30 04:16:58 +03:00
Paul Sokolovsky aaff716189 objgenerator: mp_obj_gen_resume() suitable only for generators. 2014-03-30 04:16:43 +03:00
Paul Sokolovsky 8d9cc2e669 compile: Print error messages on unimplemented relative imports. 2014-03-30 04:16:35 +03:00
Paul Sokolovsky 0ae518fb9e mp_obj_print_exception(): Assert that traceback has sane number of entries. 2014-03-30 04:16:24 +03: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
Damien George 010043caaf Add "tracing" to try-reraise2.py test. It now fails. 2014-03-30 00:39:15 +00:00
Damien George f8ff700de8 Merge pull request #390 from pfalcon/reraise-recursive
vm: Save current active exception on opening new try block.
2014-03-30 00:09:35 +00:00
Damien George d54b8a4789 Merge branch 'master' of github.com:micropython/micropython 2014-03-30 00:03:41 +00:00
Damien George 038df43183 stmhal: Implement selector for USB device mode; improve boot up.
Can now choose at boot up whether the USB device is CDC+MSC or CDC+HID.
Choice is made by an option in boot.py, with default being CDC+MSC.
HID+MSC is not currently supported, but should be easy to implement.

Boot up now has ability to change the reset mode: hold down USR switch
while booting and LEDs will count from 1 to 7 to indicate the boot mode.
Release USR when correct mode is selected.  Current modes are 1 (normal
boot), 2 (safe mode), 3 (reset FS mode).
2014-03-30 00:00:15 +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
Damien George d40d8f1e16 Merge branch 'master' of github.com:micropython/micropython 2014-03-29 21:58:36 +00:00
Damien George 64563e39b3 stmhal: Add CDC+HID USB device.
The HID device must appear before the CDC in order for both to work at
the same time.

Whilst the code is working, it's not currently used.
2014-03-29 21:57:30 +00: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
Damien George f4417a1f95 stmhal: Add Windows .inf file for USB CDC device. 2014-03-29 17:43:02 +00:00
Damien George 2bce0bd750 Merge branch 'master' of github.com:micropython/micropython 2014-03-29 17:28:59 +00:00
Damien George 0aa5d51cf1 py: Support mpz -op- float, mpz -op- complex, and complex -op- mpz. 2014-03-29 17:28:20 +00:00
Paul Sokolovsky 40d6d29af6 vm: Elaborate comments for WITH_CLEANUP, other cosmetic fixes. 2014-03-29 18:46:04 +02:00
Damien George c9fd6645b0 stmhal: Factor out stdio and readline to separate files.
Adds readline_init() to clear readline history on soft reset.  Addresses
issue #387.
2014-03-29 14:20:05 +00: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 918638ec6e unix: Fix ffi.c to compile with latest changes to API. 2014-03-29 13:48:32 +00:00
Damien George 3e1a5c10c5 py: Rename old const type objects to mp_type_* for consistency. 2014-03-29 13:43:38 +00:00
Damien George 07ddab529c py: Change mp_const_* objects to macros.
Addresses issue #388.
2014-03-29 13:15:08 +00:00