aboutsummaryrefslogtreecommitdiff
path: root/py/runtime.c
AgeCommit message (Collapse)Author
2014-04-06py: Implement more features in native emitter.Damien George
On x64, native emitter now passes 70 of the tests.
2014-04-06py: Revert mp_load_attr() to its previous state (not supporting default val).Paul Sokolovsky
Based on the discussion in #433. mp_load_attr() is critical-path function, so any extra check will slowdown any script. As supporting default val required only for getattr() builtin, move correspending implementation there (still as a separate function due to concerns of maintainability of such almost-duplicated code instances).
2014-04-05py: Make globals and locals proper dictionary objects.Damien George
Finishes addressing issue #424. In the end this was a very neat refactor that now makes things a lot more consistent across the py code base. It allowed some simplifications in certain places, now that everything is a dict object. Also converted builtins tables to dictionaries. This will be useful when we need to turn builtins into a proper module.
2014-04-05py: Change module globals from mp_map_t* to mp_obj_dict_t*.Damien George
Towards addressing issue #424. Had a small increase to ROM usage (order 60 bytes).
2014-04-05py: Change nlr_jump to nlr_raise, to aid in debugging.Damien George
This does not affect code size or performance when debugging turned off. To address issue #420.
2014-04-05Merge pull request #433 from pfalcon/getattr-3argDamien George
py: Support 3-arg getattr() builtin (with default value).
2014-04-05py: Implement DELETE_SUBSCR bytecode; implement mp_obj_dict_delete.Damien George
2014-04-05py: Support 3-arg getattr() builtin (with default value).Paul Sokolovsky
2014-04-05py: Put default namespace into module __main__.Paul Sokolovsky
That's how CPython has it, in particular, "import __main__" should work.
2014-04-05mp_load_name(): Optimize for outer scope where locals == globals.Paul Sokolovsky
2014-04-04py: This time, real proper overflow checking of small int power.Damien George
Previous overflow test was inadequate.
2014-04-04py: Add m_malloc_fail function to handle memory allocation error.Damien George
A malloc/realloc fail now throws MemoryError.
2014-04-04py: Handle small int power overflow correctly.Damien George
2014-04-02py: Fix up so that it can compile without float.Damien George
2014-03-31py: Implement __getattr__.Damien George
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-31py: Wrap .__class__ handling in MICROPY_CPYTHON_COMPAT.Paul Sokolovsky
Because it's superfluos in the presence of type(), a remenant from Python's "old classes".
2014-03-31Merge branch 'master' of github.com:micropython/micropythonDamien George
2014-03-31py: Remove old "run time" functions that were 1 liners.Damien George
2014-03-31mp_resume: Dare to pass send_value of NULL.Paul Sokolovsky
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-31mp_resume: Elaborate handling of .throw() for objects which lack it.Paul Sokolovsky
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-31Merge branch 'master' of github.com:micropython/micropythonDamien George
2014-03-31py: Add LOAD_NULL bytecode and use it to simplify function calls.Damien George
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-31py: Properly implement divide-by-zero handling.Paul Sokolovsky
"1/0" is sacred idiom, the shortest way to break program execution (sys.exit() is too long).
2014-03-30py: Implement support for generalized generator protocol.Paul Sokolovsky
Iterators and ducktype objects can now be arguments of yield from.
2014-03-30py: Implement positional and keyword args via * and **.Damien George
Extends previous implementation with * for function calls to * and ** for both function and method calls.
2014-03-30Merge map.h into obj.h.Damien George
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-30Rename rt_* to mp_*.Damien George
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-29py: Rename old const type objects to mp_type_* for consistency.Damien George
2014-03-29py: Change mp_const_* objects to macros.Damien George
Addresses issue #388.
2014-03-28py: Fix bugs with debugging output.Damien George
show_bc now decodes the prelude correctly. Moved WRITE_FILE stuff from runtime.c to emitglue.c. Addresses issue #385.
2014-03-27py: Factor out code from runtime.c to emitglue.c.Damien George
2014-03-27py: Put n_state for bytecode in the bytecode prelude.Damien George
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-26Merge pull request #381 from pfalcon/closure-defargsDamien George
py: Support closures with default args.
2014-03-26py: Fix logic bugs in object attribute/method extraction.Damien George
2014-03-26Remove mp_obj_type_t.methods entry and use .locals_dict instead.Damien George
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-26py: Support closures with default args.Paul Sokolovsky
2014-03-26Change mp_method_t.name from const char * to qstr.Damien George
Addresses issue #377.
2014-03-26py: Replace mp_const_stop_iteration object with MP_OBJ_NULL.Damien George
2014-03-26py: Add support for user-defined iterators via __iter__, __next__.Damien George
2014-03-25Proper support for registering builtin modules in ROM.Damien George
Comes with some refactoring of code and renaming of files. All modules are now named mod*.[ch].
2014-03-25rt_load_method(): Add missing qstr_str() when getting type name.Paul Sokolovsky
2014-03-23py: Implement support for "except Exception as var" clause.Paul Sokolovsky
For this, needed to implement DELETE_NAME bytecode (because var bound in except clause is automatically deleted at its end). http://docs.python.org/3/reference/compound_stmts.html#except : "When an exception has been assigned using as target, it is cleared at the end of the except clause."
2014-03-23runtime: RT_BINARY_OP_EXCEPTION_MATCH: don't fall thru in case of wrong types.Paul Sokolovsky
2014-03-22py: Remove some unnecessary exception objects.Damien George
2014-03-22py: Add 'object' object.Damien George
2014-03-22Fixed floor division on mp ints and small ints. Added a floordivide test case.Rachel Dowdall
2014-03-22Fixed modulo operator on ints and mp ints to agree with python. Added ↵Rachel Dowdall
intdivmod.c and tests/basics/modulo.py.
2014-03-22Added exception hierarchy except for OSError and UnicodeError (requires ↵Rachel Dowdall
arguments). Comment out the errors that aren't needed if memory becomes an issue.
2014-03-22Merge remote-tracking branch 'upstream/master'Rachel Dowdall
2014-03-22py: Make 'bytes' be a proper type, support standard constructor args.Paul Sokolovsky