aboutsummaryrefslogtreecommitdiff
path: root/py/objfun.c
AgeCommit message (Collapse)Author
2014-05-10py: Tidy up returning NULL which should be MP_OBJ_NOT_SUPPORTED.Damien George
2014-05-10py: Combine native emitters to 1 glue function; distinguish viper.Damien George
This patch simplifies the glue between native emitter and runtime, and handles viper code like inline assember: return values are converted to Python objects. Fixes issue #531.
2014-05-10py: Rename byte_code to bytecode everywhere.Damien George
bytecode is the more widely used. See issue #590.
2014-05-03Add license header to (almost) all files.Damien George
Blanket wide to all .c and .h files. Some files originating from ST are difficult to deal with (license wise) so it was left out of those. Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
2014-05-03Merge pull request #552 from stinos/mingw-allocaPaul Sokolovsky
py: Use <alloca.h> for alloca()
2014-05-03objclosure, objcell: Print detailed representation if was requested.Paul Sokolovsky
Well, it is bound to "detailed error reporting", but that's closest what we have now without creating new entities.
2014-05-03py: Use <alloca.h> for alloca()stijn
alloca() is declared in alloca.h which als happens to be included by stdlib.h. On mingw however it resides in malloc.h only. So if we include alloca.h directly, and add an alloca.h for mingw in it's port directory we can get rid of the mingw-specific define to include malloc.h and the other ports are happy as well.
2014-05-02py, unix: Make "mpconfig.h" be first included, as other headers depend on it.Paul Sokolovsky
Specifically, nlr.h does.
2014-05-01objfun: More debug logging.Paul Sokolovsky
2014-05-01objgenerator: Fix check for too few args passed to gen function.Paul Sokolovsky
2014-05-01objgenerator: .print(): Output real underlying function name.Paul Sokolovsky
2014-05-01py: Add tentative scheme for error messages configuration.Paul Sokolovsky
2014-05-01objfun: Add function name accessor and .print slot method.Paul Sokolovsky
2014-04-30objfun: Factor out function to report positional args mismatch.Paul Sokolovsky
2014-04-27py: Implement keyword-only args.Damien George
Implements 'def f(*, a)' and 'def f(*a, b)', but not default keyword-only args, eg 'def f(*, a=1)'. Partially addresses issue #524.
2014-04-20py: Add win32-specific header for alloca().Paul Sokolovsky
2014-04-20py: Add arg checking helper functions.Damien George
These are to assist in writing native C functions that take positional and keyword arguments. mp_arg_check_num is for just checking the number of arguments is correct. mp_arg_parse_all is for parsing positional and keyword arguments with default values.
2014-04-18py: Allow to pass buffer protocol flags to get_buffer helper funcs.Damien George
2014-04-18py: Add typecode to buffer protocol.Damien George
When querying an object that supports the buffer protocol, that object must now return a typecode (as per binary.[ch]). This does not have to be honoured by the caller, but can be useful for determining element size.
2014-04-18py: Tidy up function argument error messages.Damien George
We are not as verbose as CPython, and maybe a bit too cryptic sometimes.
2014-04-17py: Simplify objfun/objgenerator connection, no need to call bc_get.Damien George
2014-04-17objfun: Add local header.Paul Sokolovsky
This follows pattern already used for objtuple, etc.: objfun.h's content is not public - each and every piece of code should not have access to it. It's not private either - with out architecture and implementation language (C) it doesn't make sense to keep implementation of each object strictly private and maintain cumbersome accessors. It's "local" - intended to be used by a small set of "friend" (in C++ terms) objects.
2014-04-13py: Fix mp_get_buffer, and use it in more places.Damien George
Must use mp_obj_get_type to get the type of an object. Can't assume mp_obj_t is castable to mp_obj_base_t.
2014-04-13py: Provide more details for too few and too much args for Python fun calls.Paul Sokolovsky
2014-04-13py: Big improvements to inline assembler.Damien George
Improved the Thumb assembler back end. Added many more Thumb instructions to the inline assembler. Improved parsing of assembler instructions and arguments. Assembler functions can now be passed the address of any object that supports the buffer protocol (to get the address of the buffer). Added an example of how to sum numbers from an array in assembler.
2014-04-11py: Change compile order for default positional and keyword args.Damien George
This simplifies the compiler a little, since now it can do 1 pass over a function declaration, to determine default arguments. I would have done this originally, but CPython 3.3 somehow had the default keyword args compiled before the default position args (even though they appear in the other order in the text of the script), and I thought it was important to have the same order of execution when evaluating default arguments. CPython 3.4 has changed the order to the more obvious one, so we can also change.
2014-04-10objfun: Fix default arguments filling loop, was broken in presense of kwargs.Paul Sokolovsky
2014-04-10objfun: More debug logging when calling a bytecode function.Paul Sokolovsky
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 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-05objfun: Add equality support.Paul Sokolovsky
2014-03-31py: Disable dump_args function call entirely when not debugging.Damien George
Yes, I know, a good compiler will optimise this away, but I feel this is neater.
2014-03-30objgenerator: Handle default args to generator functions.Paul Sokolovsky
Addresses #397.
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-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-17py: Clean up includes.xbe
Remove unnecessary includes. Add includes that improve portability.
2014-03-08Implement ROMable modules. Add math module.Damien George
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).
2014-03-03py: Fix overriding of default arguments.Damien George
Addresses issue #327.
2014-02-26py: Remove more var arg names fro macros with var args.Damien George
2014-02-26py: Reduce size of mp_obj_fun_native_t struct by packing ints.Damien George
2014-02-26py: Take out bitfield entries from their own structure.Damien George
Don't need to wrap bitfields in their own struct. Compiler does the correct thing without it.
2014-02-17Add pin mapping code.Dave Hylands
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.
2014-02-16Support passing positional args as keywords to bytecode functions.Paul Sokolovsky
For this, record argument names along with each bytecode function. The code still includes extensive debug logging support so far.
2014-02-16py: Pass keyword arguments to byte code.Damien George
2014-02-16py: Implement *vargs support.Damien George
Addresses issue #295.
2014-02-15py: VM never throws an exception, instead returns a status and value.Damien George
Addresses issue #290, and hopefully sets up things to allow generators throwing exceptions, etc.
2014-02-15Implement proper exception type hierarchy.Damien George
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.