Damien George
a32c1e41cc
py: Improve native emitter; now supports more opcodes.
11 years ago
Damien George
04b9147e15
Add license header to (almost) all files.
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/.
11 years ago
Paul Sokolovsky
418aca976c
objclosure, objcell: Print detailed representation if was requested.
Well, it is bound to "detailed error reporting", but that's closest what we
have now without creating new entities.
11 years ago
Paul Sokolovsky
d8351ca8a0
objtype: .print() Exception instances in adhoc way.
This is ugly, just as expected.
11 years ago
Paul Sokolovsky
c3103b55c1
objgenerator: .print(): Output real underlying function name.
11 years ago
Paul Sokolovsky
a224067846
py: Clear allocated, but unused memory in containers.
Also, clear up freed slots in containers.
As a follow up to 32bef315be
.
11 years ago
Damien George
2827d62e8b
py: Implement keyword-only args.
Implements 'def f(*, a)' and 'def f(*a, b)', but not default
keyword-only args, eg 'def f(*, a=1)'.
Partially addresses issue #524 .
11 years ago
Paul Sokolovsky
cb9dc086a3
modio: Implement io.StringIO class.
11 years ago
Paul Sokolovsky
dec31bb872
objexcept: Add mp_obj_new_exception_arg1() convenience function.
11 years ago
Damien George
3558f62fb5
py: Making closures now passes pointer to stack, not a tuple for vars.
Closed over variables are now passed on the stack, instead of creating a
tuple and passing that. This way memory for the closed over variables
can be allocated within the closure object itself. See issue #510 for
background.
11 years ago
Paul Sokolovsky
4602b9a79f
obj.h: Typo fix in comment.
11 years ago
Damien George
b11b85adaa
py: Allow to pass buffer protocol flags to get_buffer helper funcs.
11 years ago
Damien George
57a4b4f178
py: Add typecode to buffer protocol.
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.
11 years ago
Damien George
ea8d06c39d
py: Add MP_OBJ_STOP_ITERATION and make good use of it.
Also make consistent use of MP_OBJ_NOT_SUPPORTED and MP_OBJ_NULL.
This helps a lot in debugging and understanding of function API.
11 years ago
Damien George
729f7b42d6
py: Merge BINARY_OP_SUBSCR and store_subscr (w/ delete) into subscr.
mp_obj_t->subscr now does load/store/delete.
11 years ago
Damien George
de7c425139
py: Simplify objfun/objgenerator connection, no need to call bc_get.
11 years ago
Damien George
71d3112f7e
py: Make built-in 'range' a class.
Addresses issue #487 .
11 years ago
Damien George
777b0f32f4
py: Add property object, with basic functionality.
Enabled by MICROPY_ENABLE_PROPERTY.
11 years ago
Paul Sokolovsky
18bef25a0c
objlist: Add support for statically allocated lists.
Similar to similar support for lists.
11 years ago
Damien George
2813cb6043
py: Add 'static' to inline function MP_BOOL; remove category_t.
Small fixes to get it compiling with ARMCC. I have no idea why
category_t was in the enum definition for qstrs...
11 years ago
Damien George
db049c2e00
py: Change inline to static inline for 2 functions.
11 years ago
Damien George
1184094839
py: Revert some inline functions back to macros, since they bloat stmhal.
11 years ago
Damien George
a5c82a8187
py: Convert some macros to inline functions (in obj.h).
Also convert mp_obj_is_integer to an inline function.
Overall this decreased code size (at least on 32-bit x86 machine).
11 years ago
Damien George
ae491055fa
py: Fix float/complex binop returning NULL; implement complex power.
11 years ago
Damien George
b5fbd0ba87
py: Add mp_obj_is_integer; make mp_get_index check for long int.
mp_obj_is_integer should be used to check if an object is of integral
type. It returns true for bool, small int and long int.
11 years ago
Paul Sokolovsky
3aa8ee7c9e
py: Add mp_get_buffer(), mp_get_buffer_raise() convenience functions to API.
11 years ago
Damien George
f4c9b33abf
py: Remove DELETE_SUBSCR opcode, combine with STORE_SUBSCR.
This makes the runtime and object APIs more consistent. mp_store_subscr
functionality now moved into objects (ie list and dict store_item).
11 years ago
Damien George
1d24ea5207
py: Finish implementation of all del opcodes.
At this point, all opcodes are now implemented!
Some del opcodes have been combined with store opcodes, with the value
to store being MP_OBJ_NULL.
11 years ago
Paul Sokolovsky
4dcb605ac4
py: Make bytearray a proper type.
11 years ago
Damien George
495d781a36
py: implement UNPACK_EX byte code (for: a, *b, c = d)
11 years ago
Damien George
27e735fd18
py: Replace stream_p with *stream_p in mp_obj_type_t.
This is to reduce ROM usage. stream_p is used in file and socket types
only (at the moment), so seems a good idea to make the protocol
functions a pointer instead of the actual structure.
It saves 308 bytes of ROM in the stmhal/ port, 928 in unix/.
11 years ago
Damien George
8b0535e23f
py: Change module globals from mp_map_t* to mp_obj_dict_t*.
Towards addressing issue #424 .
Had a small increase to ROM usage (order 60 bytes).
11 years ago
Damien George
95004e5114
py: Fix delete operation on map/dict and set objects.
Hash table can now be completely full (ie now NULL entry) before a
resize is triggered. Use sentinel value to indicate delete entry in the
table.
11 years ago
mux
cc849f70f4
Move del to locals
11 years ago
Damien George
66edc5d899
py: Implement DELETE_SUBSCR bytecode; implement mp_obj_dict_delete.
11 years ago
Paul Sokolovsky
e3f58c8380
map: Add mp_map_dump() (#ifdef'ed) to be handy when debugging maps.
11 years ago
Damien George
36f0ee1a54
py: Remove mp_obj_less (use mp_binary_op(MP_BINARY_OP_LESS..) instead).
11 years ago
Damien George
6902eeda25
py: Add m_malloc_fail function to handle memory allocation error.
A malloc/realloc fail now throws MemoryError.
11 years ago
mux
4f7e9f5c44
Implement del
11 years ago
Damien George
8270e3853d
py: More robust int conversion and overflow checking.
11 years ago
Paul Sokolovsky
a96d3d0840
objexcept: No more magic messages in exceptions, only exception arguments.
One of the reason for separate "message" (besides still unfulfilled desire to
optimize memory usage) was apparent special handling of exception with
messages by CPython. Well, the message is still just an exception argument,
it just printed specially. Implement that with PRINT_EXC printing format.
11 years ago
Paul Sokolovsky
7fafb28f6d
objgenerator: Handle default args to generator functions.
Addresses #397 .
11 years ago
Paul Sokolovsky
55ca075cab
vm: Implement CALL_FUNCTION_VAR opcode (foo(*(1, 2, 3))).
11 years ago
Damien George
df6567e634
Merge map.h into obj.h.
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.
11 years ago
Damien George
d17926db71
Rename rt_* to mp_*.
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.
11 years ago
Damien George
3e1a5c10c5
py: Rename old const type objects to mp_type_* for consistency.
11 years ago
Damien George
07ddab529c
py: Change mp_const_* objects to macros.
Addresses issue #388 .
11 years ago
Paul Sokolovsky
c4d589e2bb
objgenerator: close(): Throw instance of GeneratorExit (not type).
To comply with Python semantics and allow use of mp_obj_is_subclass_fast()
for exception matching.
11 years ago
Damien George
c63f984647
py: Thin out predefined exceptions.
Only exceptions that are actually used are left prefedined. Hierarchy
is still there, and removed exceptions are just commented out.
11 years ago
Damien George
bee17b00e3
py: Put n_state for bytecode in the bytecode prelude.
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.
11 years ago