summaryrefslogtreecommitdiffstatshomepage
path: root/py/builtin.c
Commit message (Collapse)AuthorAge
* py: Add MP_OBJ_STOP_ITERATION and make good use of it.Damien George2014-04-17
| | | | | Also make consistent use of MP_OBJ_NOT_SUPPORTED and MP_OBJ_NULL. This helps a lot in debugging and understanding of function API.
* py: Make built-in 'range' a class.Damien George2014-04-17
| | | | Addresses issue #487.
* py: Add builtin functions bin and oct, and some tests for them.Damien George2014-04-15
|
* py: Fix builtin hex to print prefix.Damien George2014-04-15
| | | | I was too hasty. Still a one-liner though.
* py: Add hex builtin function.Damien George2014-04-15
| | | | A one-liner, added especially for @pfalcon :)
* py: Revert mp_load_attr() to its previous state (not supporting default val).Paul Sokolovsky2014-04-06
| | | | | | | | 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).
* py: Optimize locals()/globals() implementation.Paul Sokolovsky2014-04-06
|
* py: Implement globals() and locals() builtins.Paul Sokolovsky2014-04-06
|
* py: Make globals and locals proper dictionary objects.Damien George2014-04-05
| | | | | | | | | | | 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.
* py: Change module globals from mp_map_t* to mp_obj_dict_t*.Damien George2014-04-05
| | | | | | Towards addressing issue #424. Had a small increase to ROM usage (order 60 bytes).
* py: Change nlr_jump to nlr_raise, to aid in debugging.Damien George2014-04-05
| | | | | | This does not affect code size or performance when debugging turned off. To address issue #420.
* py: Support 3-arg getattr() builtin (with default value).Paul Sokolovsky2014-04-05
|
* py: Remove mp_obj_less (use mp_binary_op(MP_BINARY_OP_LESS..) instead).Damien George2014-04-04
|
* py: Move to Python 3.4.0 compatibility.Damien George2014-04-02
| | | | | | | | | | | | | 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.
* py: Add support for sep and end keywords in print.Damien George2014-04-02
|
* py: Remove old "run time" functions that were 1 liners.Damien George2014-03-31
|
* Merge map.h into obj.h.Damien George2014-03-30
| | | | | | 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.
* Rename rt_* to mp_*.Damien George2014-03-30
| | | | | | | 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.
* py: Rename old const type objects to mp_type_* for consistency.Damien George2014-03-29
|
* Merge branch 'master' of github.com:micropython/micropythonDamien George2014-03-26
|\
| * py: Implement getattr() builtin.Paul Sokolovsky2014-03-27
| |
* | py: Improved builtin dir.Damien George2014-03-26
|/
* Remove mp_obj_type_t.methods entry and use .locals_dict instead.Damien George2014-03-26
| | | | | | | | | | | | | | | | | | | | | | 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.
* Change mp_method_t.name from const char * to qstr.Damien George2014-03-26
| | | | Addresses issue #377.
* py: Replace mp_const_stop_iteration object with MP_OBJ_NULL.Damien George2014-03-26
|
* py: Improve dir(): extract names from type->methods table.Damien George2014-03-23
|
* py: Make 'bytes' be a proper type, support standard constructor args.Paul Sokolovsky2014-03-22
|
* py: Make 'str' be a proper type, support standard constructor args.Paul Sokolovsky2014-03-22
|
* py: Clean up includes.xbe2014-03-17
| | | | Remove unnecessary includes. Add includes that improve portability.
* Implement ROMable modules. Add math module.Damien George2014-03-08
| | | | | | | | | | mp_module_obj_t can now be put in ROM. Configuration of float type is now similar to longint: can now choose none, float or double as the implementation. math module has basic math functions. For STM port, these are not yet implemented (they are just stub functions).
* Implement proper exception type hierarchy.Damien George2014-02-15
| | | | | | | | | | | | | | Each built-in exception is now a type, with base type BaseException. C exceptions are created by passing a pointer to the exception type to make an instance of. When raising an exception from the VM, an instance is created automatically if an exception type is raised (as opposed to an exception instance). Exception matching (RT_BINARY_OP_EXCEPTION_MATCH) is now proper. Handling of parse error changed to match new exceptions. mp_const_type renamed to mp_type_type for consistency.
* Replace global "static" -> "STATIC", to allow "analysis builds". Part 2.Paul Sokolovsky2014-02-12
|
* Make mp_obj_str_get_data return char* instead of byte*.Damien George2014-02-08
| | | | | Can't decide which is better for string type, char or byte pointer. Changing to char removes a few casts. Really need to do proper unicode.
* py: Add very basic implementation of dir() builtin.Damien George2014-02-02
| | | | Only works on modules and class instances.
* Change id to return signed integer.Damien George2014-02-02
|
* Implement and add tests for the id() builtin function.xbe2014-02-01
|
* Second stage of qstr revamp: uPy str object can be qstr or not.Damien George2014-01-22
|
* Merge branch 'master' of github.com:micropython/micropythonDamien George2014-01-21
|\ | | | | | | | | | | | | | | | | Conflicts: py/objstr.c py/py.mk py/stream.c unix/main.c unix/socket.c
| * Add dummy bytes() constructor.Paul Sokolovsky2014-01-20
| | | | | | | | | | | | Currently, MicroPython strings are mix between CPython byte and unicode strings. So, conversion is null so far. This dummy implementation is intended for compatibility with CPython (so, same code can run on both).
* | Revamp qstrs: they now include length and hash.Damien George2014-01-21
|/ | | | | Can now have null bytes in strings. Can define ROM qstrs per port using qstrdefsport.h
* Change int to uint for n_args in function with variable arguments.Damien George2014-01-19
|
* Make VM stack grow upwards, and so no reversed args arrays.Damien George2014-01-18
| | | | | | | | | | | | | | | Change state layout in VM so the stack starts at state[0] and grows upwards. Locals are at the top end of the state and number downwards. This cleans up a lot of the interface connecting the VM to C: now all functions that take an array of Micro Python objects are in order (ie no longer in reverse). Also clean up C API with keyword arguments (call_n and call_n_kw replaced with single call method that takes keyword arguments). And now make_new takes keyword arguments. emitnative.c has not yet been changed to comply with the new order of stack layout.
* Merge branch 'str-repr' of github.com:pfalcon/micropython into pfalcon-str-reprDamien George2014-01-15
|\ | | | | | | | | Conflicts: tests/basics/tests/exception1.py
| * Implement str() and repr() builtin functions.Paul Sokolovsky2014-01-15
| |
| * type->print(): Distinguish str() and repr() variety by passing extra param.Paul Sokolovsky2014-01-15
| |
* | Implement repr.Damien George2014-01-15
|/
* Tidy up.Damien George2014-01-14
|
* Merge remote-tracking branch 'upstream/master' into builtinsJohn R. Lenton2014-01-13
|\ | | | | | | | | | | | | Conflicts: py/builtin.c py/builtin.h py/runtime.c
| * Cleanup built-ins, and fix some compiler warnings/errors.Damien George2014-01-13
| |
* | Made sorted() raise an exception instead of aborting when given no ↵John R. Lenton2014-01-13
| | | | | | | | arguments; moved around some things in objfun.c as a consequence