Wykres commitów

952 Commity (be019ce0636398d1cbdee007d5238160dce8eda7)

Autor SHA1 Wiadomość Data
Damien George 8123a3339d Merge pull request #425 from iabdalkader/del
Implement del
2014-04-05 18:49:39 +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 efccbf6f27 Merge pull request #436 from dhylands/pfenv-print-int
Change pfenv_print_int to take machine_uint_t rather than unsinged in
2014-04-05 18:11:02 +01:00
Damien George 327a3e2faa Merge pull request #435 from dhylands/str-modulo-float
Allow floating point arguments with %d,i,u,o,x,X formats
2014-04-05 18:10:11 +01:00
Damien George 23419a2f8a Merge pull request #433 from pfalcon/getattr-3arg
py: Support 3-arg getattr() builtin (with default value).
2014-04-05 18:00:04 +01:00
Dave Hylands 64ef5d7f4e Change pfenv_print_int to take machine_uint_t rather than unsinged in
With this change, the following works:

>>> print('%#x' % 0x1234567890abcdef)
0x1234567890abcdef
2014-04-05 09:42:20 -07:00
Damien George 6d508666ea Merge branch 'master' of github.com:micropython/micropython 2014-04-05 17:19:03 +01:00
Damien George 95004e5114 py: Fix delete operation on map/dict and set objects.
Hash table can now be completely full (ie now NULL entry) before a
resize is triggered.  Use sentinel value to indicate delete entry in the
table.
2014-04-05 17:17:19 +01:00
Dave Hylands f81a49e464 Allow floating point arguments with %d,i,u,o,x,X formats 2014-04-05 08:26:51 -07:00
Paul Sokolovsky e99841be69 mp_obj_get_int(): Add warning against adding implicit float->int conversion. 2014-04-05 17:46:47 +03:00
mux cc849f70f4 Move del to locals 2014-04-05 15:49:03 +02: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 3c8aecf62c Merge pull request #431 from pfalcon/unbreak-map-remove
map: When removing a key, don't NULL the entry, but mark as deleted.
2014-04-05 12:09:09 +01:00
Paul Sokolovsky 586bfce10d objfun: Add equality support. 2014-04-05 13:53:39 +03:00
Paul Sokolovsky bfb7d6a26d py: Support 3-arg getattr() builtin (with default value). 2014-04-05 13:34:02 +03:00
Paul Sokolovsky 438d504e27 objtype: Add equality test for type types. 2014-04-05 13:10:56 +03:00
Paul Sokolovsky 91cbe6033a py: Allow types to be hashable.
Quite natural to have d[int] = handle_int .
2014-04-05 12:51:58 +03:00
Paul Sokolovsky c6813d92db py: Put default namespace into module __main__.
That's how CPython has it, in particular, "import __main__" should work.
2014-04-05 12:29:15 +03:00
Paul Sokolovsky 4a088f4b61 map: When removing a key, don't NULL the entry, but mark as deleted.
When searching next time, such entry should be just skipped, not terminate
the search. It's known that marking techique is not efficient at the presense
of many removes, but namespace usage should not require many deletes, and
as for user dictionaries - well, open addressing map table with linear
rehashing and load factor of ~1 is not particularly efficient at all ;-).
TODO: May consider "shift other entries in cluster" approach as an
alternative.
2014-04-05 05:11:12 +03:00
Paul Sokolovsky a0d32991ed mp_load_name(): Optimize for outer scope where locals == globals. 2014-04-05 05:10:12 +03:00
Paul Sokolovsky e3f58c8380 map: Add mp_map_dump() (#ifdef'ed) to be handy when debugging maps. 2014-04-05 05:10:02 +03:00
Damien George 6582a4170d Merge pull request #421 from dhylands/git-version
Add the git version and build-date to the banner
2014-04-04 16:09:29 +01:00
Damien George e8208a7f02 py: Make False and True act like 0 and 1 for integer arithmetic. 2014-04-04 15:08:23 +01:00
Damien George d7aadcfe1b py: Allow dict constructor to take keyword arguments. 2014-04-04 15:08:00 +01:00
Damien George 36f0ee1a54 py: Remove mp_obj_less (use mp_binary_op(MP_BINARY_OP_LESS..) instead). 2014-04-04 15:07:17 +01:00
Damien George 9b1599c663 Merge pull request #422 from dhylands/str-modulo
Str modulo
2014-04-04 12:37:52 +01:00
Damien George af27259439 py: Enable optimisation of multiplying 2 small ints in compiler. 2014-04-04 11:21:58 +00:00
Damien George ecf5b77123 py: This time, real proper overflow checking of small int power.
Previous overflow test was inadequate.
2014-04-04 11:13:51 +00: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
Dave Hylands 6756a37a77 Implements most of str.modulo
The alternate form for floating point doesn't work yet.
The %(name)s form doesn't work yet.
2014-04-03 23:55:02 -07:00
Dave Hylands bf7d690e36 Add the git version to the banner 2014-04-03 16:55:15 -07:00
Damien George 5bf565e353 py: Handle small int power overflow correctly. 2014-04-04 00:16:32 +01:00
Damien George 4b34c76fd6 Changes to get unix/ port compiling on Cygwin. 2014-04-03 23:51:16 +01:00
mux 4f7e9f5c44 Implement del 2014-04-03 23:55:12 +02:00
Paul Sokolovsky 98a627dc03 py: Add "io" module.
So far just includes "open" function, which should be supplied by a port.

TODO: Make the module #ifdef'ed.
2014-04-03 22:08:57 +03:00
Damien George 8270e3853d py: More robust int conversion and overflow checking. 2014-04-03 11:00:54 +00:00
Damien George cc7085c1ce Merge branch 'fix-format-int' of github.com:dhylands/micropython into dhylands-fix-format-int
Conflicts:
	py/objstr.c
2014-04-02 20:37:05 +01:00
Dave Hylands 22fe4d7344 Fix str.format to work with {:f/g/e} and ints
Also fix objstr.c to compile when floats disabled.
2014-04-02 12:10:18 -07:00
Damien George c322c5f07f py: Fix regress for printing of floats and #if.
Also change formating modifier in test script (it still passes with
original format though).
2014-04-02 20:04:15 +01:00
Paul Sokolovsky e807fa8d60 gc: Uses uint defined in misc.h. 2014-04-02 20:36:32 +03:00
Damien George 094d450003 py: Wrap compile_scope_inline_asm in #if; remove comment from misc.h. 2014-04-02 17:31:27 +01:00
Damien George 70f33cde48 py: Fix up so that it can compile without float. 2014-04-02 17:06:05 +01:00
Damien George af6edc61bd py: Enable a jump optimisation in the compiler. 2014-04-02 16:12:28 +01:00
Damien George 882b363564 py: Move to Python 3.4.0 compatibility.
Very little has changed.  In Python 3.4 they removed the opcode
STORE_LOCALS, but in Micro Python we only ever used this for CPython
compatibility, so it was a trivial thing to remove.  It also allowed to
clean up some dead code (eg the 0xdeadbeef in class construction), and
now class builders use 1 less stack word.

Python 3.4.0 introduced the LOAD_CLASSDEREF opcode, which I have not
yet understood.  Still, all tests (apart from bytecode test) still pass.
Bytecode tests needs some more attention, but they are not that
important anymore.
2014-04-02 15:56:31 +01:00
Damien George 93b7faa29a py: Factor out static/class method unwrapping code; add tests. 2014-04-02 14:13:26 +01:00
Damien George b23fbb3126 py: Implement floating point power binop. 2014-04-02 12:26:49 +01:00
Damien George 660aef67c4 py: Allow multiple of str/list/tuple on left by an integer. 2014-04-02 12:22:07 +01:00
Damien George 4881566874 py: Add support for sep and end keywords in print. 2014-04-02 10:34:44 +01:00
Damien George 084ef373fb py: Fix math.{ceil,floor,trunc} to return int. 2014-04-01 21:21:50 +01:00
Damien George e3e0500296 py: Make pfenv.c conform to code conventions. 2014-04-01 21:15:03 +01:00
Dave Hylands 1c6b4b2e24 Reduce stack usage of pfenv_print_strn 2014-04-01 11:59:31 -07:00
Dave Hylands 80359aa96e Fix INT_BUF_SIZE to work with 32-bit and 64-bit 2014-04-01 11:03:44 -07:00
Damien George e09320adb5 py: Remove implicit conversion from int to float. 2014-04-01 10:56:07 +01:00
Dave Hylands baf6f14deb Enhance str.format support
This adds support for almost everything (the comma isn't currently
supported).

The "unspecified" type with floats also doesn't behave exactly like
python.

Tested under unix with float and double
Spot tested on stmhal
2014-04-01 01:17:33 -07:00
Damien George e44d26ae0c py: Implement __getattr__.
It's not completely satisfactory, because a failed call to __getattr__
should not raise an exception.

__setattr__ could be implemented, but it would slow down all stores to a
user created object.  Need to implement some caching system.
2014-03-31 22:57:56 +01:00
Paul Sokolovsky 4db727afea objstr: Very basic implementation of % string formatting operator. 2014-03-31 21:20:52 +03:00
Paul Sokolovsky 6ce78c4fae py: Wrap .__class__ handling in MICROPY_CPYTHON_COMPAT.
Because it's superfluos in the presence of type(), a remenant from Python's
"old classes".
2014-03-31 20:40:31 +03:00
Paul Sokolovsky b509f73982 objtype: Wrap .__name__ handling in MICROPY_CPYTHON_COMPAT.
Because it's runtime reflection feature, not required for many apps.
Rant time:
Python could really use better str() vs repr() distinction, for example,
repr(type) could be "<class 'foo'>" (as it is now), and str(type) just
"foo". But alas, getting straight name requires adhoc attribute.
2014-03-31 20:40:31 +03:00
Damien George 3ff2d03891 py: Fix bug in optimised for .. range.
Don't store final, failing value to the loop variable.  This fix also
makes for .. range a bit more efficient, as it uses less store/load
pairs for the loop variable.
2014-03-31 18:02:22 +01:00
Damien George 8cd72bdf92 py: Fix vstr_init for case that alloc = 0. 2014-03-31 17:10:59 +01: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
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.
2014-03-31 15:59:25 +01:00
Paul Sokolovsky e566670153 objtype: Add virtual __name__ attribute.
It's virtual because it's not shown in dir(...). (That's also how CPython
has it).
2014-03-31 17:22:38 +03: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
Paul Sokolovsky a2109d9321 mp_resume: Elaborate handling of .throw() for objects which lack it.
In this case, the exception is just re-thrown - the ideas is that object
doesn't handle this exception specially, so it will propagated per Python
semantics.
2014-03-31 17:22:37 +03:00
Paul Sokolovsky 817e76a1a5 objgenerator.throw(GeneratorExit) is not equivalent to .close().
.throw() propagates any exceptions, and .close() swallows them. Yielding
in reponse to .throw(GeneratorExit) is still fatal, and we need to
handle it for .throw() case separately (previously it was handled only
for .close() case).

Obscure corner cases due to test_pep380.py.
2014-03-31 17:22:37 +03:00
Paul Sokolovsky 1eac05d541 objgenerator: Another obscure case of propagating MP_OBJ_NULL optimization. 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 1aa2c10263 Merge branch 'master' of github.com:micropython/micropython 2014-03-31 12:01:09 +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
Damien George 3056509e00 py: Rename and reorder parameters in emit_make_function/closure.
In preparation for implementing default keyword arguments.
2014-03-31 11:30:17 +01:00
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).
2014-03-31 02:23:57 +03:00
Paul Sokolovsky 96ed213320 objfloat: Quick&dirty implementation of float floor division.
TODO: Likely doesn't match Python semantics for negative numbers.
2014-03-31 02:23:57 +03:00
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.
2014-03-31 02:23:57 +03:00
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
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
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
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 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 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
Damien George da51a399cf Merge pull request #383 from pfalcon/yield-from
Implement "yield from"
2014-03-29 12:18:14 +00:00
Damien George 6e54fcfd12 py: Fix typo printing complex numbers that are purely imaginary. 2014-03-29 11:41:38 +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
Damien George 1d7553311c Merge pull request #382 from pfalcon/genexit-inst
objgenerator: close(): Throw instance of GeneratorExit (not type).
2014-03-29 01:25:05 +00:00
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.
2014-03-28 18:38:20 +00: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
Paul Sokolovsky c4d589e2bb objgenerator: close(): Throw instance of GeneratorExit (not type).
To comply with Python semantics and allow use of mp_obj_is_subclass_fast()
for exception matching.
2014-03-28 02:40:26 +02:00
Paul Sokolovsky 182c31a208 showbc: Add few bytecodes related to "with". 2014-03-28 02:20:21 +02:00
Damien George c63f984647 py: Thin out predefined exceptions.
Only exceptions that are actually used are left prefedined.  Hierarchy
is still there, and removed exceptions are just commented out.
2014-03-27 23:49:06 +00:00
Damien George 01b877d16d py: Fix typo printing complex numbers. 2014-03-27 23:35:31 +00:00
Damien George ce8f07adcd py: Rename emit_pre so they have globally unique names. 2014-03-27 23:30:26 +00:00
Damien George 2326d52d20 py: Factor out code from runtime.c to emitglue.c. 2014-03-27 23:26:35 +00:00
Damien George 8767d0710e py: complex_print uses format_float if single precision fp used. 2014-03-27 22:17:49 +00: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
Damien George 945a01c4e3 py: Fix bug in type_store_attr, trying to store to ROM. 2014-03-27 09:32:26 +00:00
Damien George bdcbf0fcd1 py: Restore CPython compatibility in compiler for closures with def args. 2014-03-26 23:15:35 +00:00
Damien George d6f9434091 Merge pull request #381 from pfalcon/closure-defargs
py: Support closures with default args.
2014-03-26 23:09:14 +00:00
Damien George f61a072f68 Merge branch 'master' of github.com:micropython/micropython 2014-03-26 22:36:43 +00:00
Damien George c3f1126ee8 py: Fix logic bugs in object attribute/method extraction. 2014-03-26 22:35:10 +00:00
Damien George 6022d9d478 py: Improved builtin dir. 2014-03-26 22:35:00 +00:00
Paul Sokolovsky e9137b94f2 py: Implement getattr() builtin. 2014-03-27 00:11:36 +02:00
Damien George 9b196cddab Remove mp_obj_type_t.methods entry and use .locals_dict instead.
Originally, .methods was used for methods in a ROM class, and
locals_dict for methods in a user-created class.  That distinction is
unnecessary, and we can use locals_dict for ROM classes now that we have
ROMable maps.

This removes an entry in the bloated mp_obj_type_t struct, saving a word
for each ROM object and each RAM object.  ROM objects that have a
methods table (now a locals_dict) need an extra word in total (removed
the methods pointer (1 word), no longer need the sentinel (2 words), but
now need an mp_obj_dict_t wrapper (4 words)).  But RAM objects save a
word because they never used the methods entry.

Overall the ROM usage is down by a few hundred bytes, and RAM usage is
down 1 word per user-defined type/class.

There is less code (no need to check 2 tables), and now consistent with
the way ROM modules have their tables initialised.

Efficiency is very close to equivaluent.
2014-03-26 21:47:19 +00:00
Paul Sokolovsky 2447a5b582 py: Support closures with default args. 2014-03-26 23:17:44 +02:00
Damien George c12b2213c1 Change mp_method_t.name from const char * to qstr.
Addresses issue #377.
2014-03-26 20:15:40 +00:00
Damien George 69b3ba0df3 py: Swap around the double return value of mp_obj_gen_resume.
Just to keep things consistent :)
2014-03-26 19:33:23 +00: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 9c817b9465 Merge branch 'master' of github.com:micropython/micropython 2014-03-26 18:56:02 +00:00
Damien George 548e76cfd6 py: Use _is_subclass_fast instead of _exception_match. 2014-03-26 18:55:29 +00:00