summaryrefslogtreecommitdiffstatshomepage
path: root/py/objfun.c
Commit message (Collapse)AuthorAge
* 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 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.
* objfun: Add equality support.Paul Sokolovsky2014-04-05
|
* py: Disable dump_args function call entirely when not debugging.Damien George2014-03-31
| | | | | Yes, I know, a good compiler will optimise this away, but I feel this is neater.
* objgenerator: Handle default args to generator functions.Paul Sokolovsky2014-03-30
| | | | Addresses #397.
* 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
|
* py: Change mp_const_* objects to macros.Damien George2014-03-29
| | | | Addresses issue #388.
* py: Put n_state for bytecode in the bytecode prelude.Damien George2014-03-27
| | | | | | | | | | | 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.
* 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).
* py: Fix overriding of default arguments.Damien George2014-03-03
| | | | Addresses issue #327.
* py: Remove more var arg names fro macros with var args.Damien George2014-02-26
|
* py: Reduce size of mp_obj_fun_native_t struct by packing ints.Damien George2014-02-26
|
* py: Take out bitfield entries from their own structure.Damien George2014-02-26
| | | | | Don't need to wrap bitfields in their own struct. Compiler does the correct thing without it.
* Add pin mapping code.Dave Hylands2014-02-17
| | | | | | | | | | | | | | | | | | | | | | | This commit also introduces board directories and moves board specific config into the appropriate board directory. boards/stm32f4xx-af.csv was extracted from the STM32F4xx datasheet and hand-tweaked. make-pins.py takes boards/stm32f4xx-af.csv, boards/stm32f4xx-prefix.c, and boards/BOARD-NAME/pins.csv as input and generates the file build/pins_BOARD_NAME.c The generated pin file for PYBOARD4 looks like this: https://gist.github.com/dhylands/9063231 The generated pins file includes all of the supported alternate functions, and includes upsupported alternate functions as comments. See the commnet block at the top of stm/pin_map.c for details on how to use the pin mapper. I also went ahead and modified stm/gpio.c to use the pin mapper.
* Support passing positional args as keywords to bytecode functions.Paul Sokolovsky2014-02-16
| | | | | For this, record argument names along with each bytecode function. The code still includes extensive debug logging support so far.
* py: Pass keyword arguments to byte code.Damien George2014-02-16
|
* py: Implement *vargs support.Damien George2014-02-16
| | | | Addresses issue #295.
* py: VM never throws an exception, instead returns a status and value.Damien George2014-02-15
| | | | | Addresses issue #290, and hopefully sets up things to allow generators throwing exceptions, etc.
* 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.
* Change mp_obj_type_t.name from const char * to qstr.Damien George2014-02-15
| | | | | | Ultimately all static strings should be qstr. This entry in the type structure is only used for printing error messages (to tell the type of the bad argument), and printing objects that don't supply a .print method.
* Remove mp_obj_new_exception_msg_1_arg and _2_arg.Damien George2014-02-12
|
* Replace global "static" -> "STATIC", to allow "analysis builds". Part 1.Paul Sokolovsky2014-02-12
| | | | | | | | Some tools do not support local/static symbols (one example is GNU ld map file). Exposing all functions will allow to do detailed size comparisons, etc. Also, added bunch of statics where they were missing, and replaced few identity functions with global mp_identity().
* py: Pass keyword args to native functions by using the stack.Damien George2014-02-08
| | | | | | Passing keyword arguments to a native function now no longer requires heap memory. The kw_args map is created on the stack using the args array as the table.
* py: mp_execute_byte_code has 2 arg arrays, for more efficient default params.Damien George2014-02-01
|
* Implement default function arguments (for Python functions).Paul Sokolovsky2014-02-01
| | | | | | | | TODO: Decide if we really need separate bytecode for creating functions with default arguments - we would need same for closures, then there're keywords arguments too. Having all combinations is a small exponential explosion, likely we need just 2 cases - simplest (no defaults, no kw), and full - defaults & kw.
* Functions of fixed number of args are special-cased only for 3 or less args.Paul Sokolovsky2014-01-26
|
* Second stage of qstr revamp: uPy str object can be qstr or not.Damien George2014-01-22
|
* 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
* 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 remote-tracking branch 'upstream/master' into builtinsJohn R. Lenton2014-01-13
|\ | | | | | | | | | | | | Conflicts: py/builtin.c py/builtin.h py/runtime.c
| * Consolidate rt_make_function_[0123] to rt_make_function_n.Damien George2014-01-13
| |
| * Initialize is_kw for dynamically allocated mp_obj_fun_native_t ojects.Dave Hylands2014-01-13
| | | | | | | | This should fix issue #171
* | 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
* py: Stuff qstr in object pointer; keys for mp_map_t are now always mp_obj_t.Damien George2014-01-08
|
* Merge remote-tracking branch 'upstream/master' into listsort. Lots of ↵John R. Lenton2014-01-07
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | conflict fun. Conflicts: py/obj.h py/objbool.c py/objboundmeth.c py/objcell.c py/objclass.c py/objclosure.c py/objcomplex.c py/objdict.c py/objexcept.c py/objfun.c py/objgenerator.c py/objinstance.c py/objmodule.c py/objrange.c py/objset.c py/objslice.c
| * Merge branch 'cplusplus' of https://github.com/ian-v/micropython into ↵Damien George2014-01-07
| |\ | | | | | | | | | | | | | | | | | | ian-v-cplusplus Conflicts: py/objcomplex.c
| | * Co-exist with C++ (issue #85)ian-v2014-01-06
| |/
* / This implements a better (more python-conformant) list.sort.John R. Lenton2014-01-07
|/ | | | | | | | It's not really about that, though; it's about me figuring out a sane way forward for keyword-argument functions (and function metadata). But it's useful as is, and shouldn't break any existing code, so here you have it; I'm going to park it in my mind for a bit while sorting out the rest of the dict branch.
* Merge pull request #92 from chipaca/list_insertDamien George2014-01-05
|\ | | | | List insert. Fixes issue #61.
| * Merge remote-tracking branch 'upstream/master' into list_insertJohn R. Lenton2014-01-05
| |\
| * | Implements list.insert. Fixes issue #61.John R. Lenton2014-01-04
| | |
* | | Convert many object types structs to use C99 tagged initializer syntax.Paul Sokolovsky2014-01-05
| |/ |/|
* | Convert Python types to proper Python type hierarchy.Damien George2014-01-04
| | | | | | | | Now much more inline with how CPython does types.
* | Split qstr into pools, and put initial pool in ROM.Damien George2014-01-04
|/ | | | | | | | | | | | | | | | Qstr's are now split into a linked-list of qstr pools. This has 2 benefits: the first pool can be in ROM (huge benefit, since we no longer use RAM for the core qstrs), and subsequent pools use m_new for the next pool instead of m_renew (thus avoiding a huge single table for all the qstrs). Still would be better to use a hash table, but this scheme takes us part of the way (eventually convert the pools to hash tables). Also fixed bug with import. Also improved the way the module code is referenced (not magic number 1 anymore).
* Basic implementation of import.Damien George2014-01-03
| | | | | | import works for simple cases. Still work to do on finding the right script, and setting globals/locals correctly when running an imported function.
* Change memory allocation API to require size for free and realloc.Damien2013-12-29
|
* Change object representation from 1 big union to individual structs.Damien2013-12-21
A big change. Micro Python objects are allocated as individual structs with the first element being a pointer to the type information (which is itself an object). This scheme follows CPython. Much more flexible, not necessarily slower, uses same heap memory, and can allocate objects statically. Also change name prefix, from py_ to mp_ (mp for Micro Python).