summaryrefslogtreecommitdiffstatshomepage
path: root/py/objgenerator.c
Commit message (Collapse)AuthorAge
* py: Comment exc_state member from mp_obj_gen_instance_t as it gives troublestijn2014-05-05
| | | | | | | ...to some compilers who can't process 2 zero-sized arrays in structs. It's never referenced directly anyway. See disussion on #568 as well.
* Add license header to (almost) all files.Damien George2014-05-03
| | | | | | | 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/.
* py, unix: Make "mpconfig.h" be first included, as other headers depend on it.Paul Sokolovsky2014-05-02
| | | | Specifically, nlr.h does.
* objgenerator: .print(): Output real underlying function name.Paul Sokolovsky2014-05-01
|
* 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: Simplify objfun/objgenerator connection, no need to call bc_get.Damien George2014-04-17
|
* objgenerator: Generator must execute in its defining lexical context.Paul Sokolovsky2014-04-17
| | | | | I.e. with its own globals. So, just as for functions, we need to switch globals when resuming a generator.
* py: Clear state to MP_OBJ_NULL before executing byte code.Damien George2014-04-09
|
* py: Generators can have their locals closed over.Damien George2014-04-09
|
* 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.
* objgenerator.throw(GeneratorExit) is not equivalent to .close().Paul Sokolovsky2014-03-31
| | | | | | | | | .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.
* objgenerator: Another obscure case of propagating MP_OBJ_NULL optimization.Paul Sokolovsky2014-03-31
|
* py: Don't wrap necessary function calls in assert.Damien George2014-03-30
|
* Merge pull request #399 from pfalcon/gen-defargsDamien George2014-03-30
|\ | | | | objgenerator: Handle default args to generator functions.
| * objgenerator: Handle default args to generator functions.Paul Sokolovsky2014-03-30
| | | | | | | | Addresses #397.
* | py: Implement support for generalized generator protocol.Paul Sokolovsky2014-03-30
|/ | | | Iterators and ducktype objects can now be arguments of yield from.
* 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.
* objgenerator.throw: Instantiate if exception type passed, just as "raise".Paul Sokolovsky2014-03-30
| | | | Caught by CPython test_pep380.py.
* objgenerator.throw(): Throwing GeneratorExit is equivalent to .close().Paul Sokolovsky2014-03-30
| | | | According to PEP380 and caught by CPython test_pep380.py .
* objgenerator: Store proper code_info pointer.Paul Sokolovsky2014-03-30
|
* objgenerator: mp_obj_gen_resume() suitable only for generators.Paul Sokolovsky2014-03-30
|
* py: Rename mp_exc_stack to mp_exc_stack_t.Damien George2014-03-30
|
* 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.
* objgenerator: close(): Throw instance of GeneratorExit (not type).Paul Sokolovsky2014-03-28
| | | | | To comply with Python semantics and allow use of mp_obj_is_subclass_fast() for exception matching.
* 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: Calculate maximum exception stack size in compiler.Damien George2014-03-27
|
* 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: Swap around the double return value of mp_obj_gen_resume.Damien George2014-03-26
| | | | Just to keep things consistent :)
* py: Replace mp_const_stop_iteration object with MP_OBJ_NULL.Damien George2014-03-26
|
* py: Use _is_subclass_fast instead of _exception_match.Damien George2014-03-26
|
* objgenerator: Implement return with value and .close() method.Paul Sokolovsky2014-03-26
| | | | | | Return with value gets converted to StopIteration(value). Implementation keeps optimizing against creating of possibly unneeded exception objects, so there're considerable refactoring to implement these features.
* objgenerator: Add comments for latest mp_obj_gen_instance_t refactors.Paul Sokolovsky2014-03-22
|
* objgenerator: Implement .throw() method to throw exceptions into generator.Paul Sokolovsky2014-03-22
|
* objgenerator: Implement throwing exceptions out of generator.Paul Sokolovsky2014-03-22
|
* objgenerator: Keep exception stack within generator object, like value stack.Paul Sokolovsky2014-03-22
| | | | This is required to properly handle exceptions across yields.
* py: Clean up includes.xbe2014-03-17
| | | | Remove unnecessary includes. Add includes that improve portability.
* 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: Simplify fastn in VM; reduce size of unique code struct.Damien George2014-01-29
| | | | | | | | | | We still have FAST_[0,1,2] byte codes, but they now just access the fastn array (before they had special local variables). It's now simpler, a bit faster, and uses a bit less stack space (on STM at least, which is most important). The only reason now to keep FAST_[0,1,2] byte codes is for compressed byte code size.
* gen.send(): Throw StopIteration. Also, explicitly shutdown finished gen.Paul Sokolovsky2014-01-27
| | | | | Otherwise, some generator statements still may be spuriously executed on subsequent calls to next()/send().
* Implement send() method for generators.Paul Sokolovsky2014-01-26
|
* 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
* Add source file name and line number to error messages.Damien George2014-01-18
| | | | | Byte code has a map from byte-code offset to source-code line number, used to give better error messages.
* 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.