Damien George
7c9c667633
py: Implement iterator support for object that has __getitem__.
Addresses Issue #203 .
11 years ago
Paul Sokolovsky
c1d200ef74
rt_deinit(): Finalize some maps.
11 years ago
Paul Sokolovsky
91fb1c9b13
Add basic implementation of bytes type, piggybacking on str.
This reuses as much str implementation as possible, from this we
can make them more separate as needed.
11 years ago
Damien George
1e708fed18
py: Implement bool unary op; tidy up unary op dispatch.
11 years ago
Damien George
0d028743aa
py: Initialise loaded_module map in rt_init.
STM port crashes without this re-init. There should not be any state in
the core py/ code that relies on pre-initialised data.
11 years ago
Damien George
5fa93b6755
Second stage of qstr revamp: uPy str object can be qstr or not.
11 years ago
Damien George
55baff4c9b
Revamp qstrs: they now include length and hash.
Can now have null bytes in strings. Can define ROM qstrs per port using
qstrdefsport.h
11 years ago
Paul Sokolovsky
a80ff04fe7
Add dummy bytes() constructor.
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).
11 years ago
Damien George
91d457a277
py: Put micropython module init code in builtinmp.c.
11 years ago
Paul Sokolovsky
440cc3f028
Expose memory stats functions via "micropython" module.
These are micropython.mem_total(), .mem_current(), .mem_peak(). These are 3
individual functions with simple scalar return value to make sure that
calls to these functions themselves have minimal (hopefully zero) impact on
memory allocation.
11 years ago
Paul Sokolovsky
159c0f75da
Don't implicitly import "sys" module.
11 years ago
Paul Sokolovsky
f477bfbc75
Pre-create sys module.
11 years ago
Damien George
cbd2f7482c
py: Add module/function/class name to exceptions.
Exceptions know source file, line and block name.
Also tidy up some debug printing functions and provide a global
flag to enable/disable them.
11 years ago
Damien George
932bf1c48f
py: Fix VM/runtime unpack sequence bug, Issue #193 .
11 years ago
Damien George
f49ba1bd9c
Improve method lookup in mp_obj_class_lookup.
Now searches both locals_dict and methods. Partly addresses Issue #145 .
11 years ago
Paul Sokolovsky
427905cedd
Add skeleton implementation of array.array and bytearray.
So far, only storage, initialization, repr() and buffer protocol is
implemented - alredy suitable for passing binary data around.
11 years ago
Damien George
20006dbba9
Make VM stack grow upwards, and so no reversed args arrays.
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.
11 years ago
Paul Sokolovsky
6d8edf6acf
Add store_item() virtual method to type to implement container[index] = val.
11 years ago
Paul Sokolovsky
166bb40fb2
Add OverflowError and use it for small int overflow instead of assert.
11 years ago
Paul Sokolovsky
10744dd816
Add empty (false) value testing for strings, tuples, lists, dicts.
11 years ago
Paul Sokolovsky
dcac88095b
Add empty "micropython" module to allow more seamless CPython portability.
Implicit "micropython" module contains (at least) codegeneration decorators.
Make it explicit, so an app could have "import micropython". On MicroPython,
that will be no-op. On CPython, that will give a chance to have a module
with placeholder decorators.
11 years ago
Damien George
d02c6d8962
Implement eval.
11 years ago
Damien George
e2fb2baaa4
Implement repr.
11 years ago
John R. Lenton
fca456bc3c
added filter()
11 years ago
John R. Lenton
39b174e00a
Added map
11 years ago
Paul Sokolovsky
36c4499d36
Implement str() and repr() builtin functions.
11 years ago
John R. Lenton
9daa78943e
added enumerate()
11 years ago
Paul Sokolovsky
8bc96471f0
Implement "is" and "is not" operators.
So far, don't work for strings as expected.
11 years ago
Damien George
f62d33aa1d
Consolidate rt_make_function_[0123] to rt_make_function_n.
11 years ago
Damien George
2300537c79
Cleanup built-ins, and fix some compiler warnings/errors.
11 years ago
John R. Lenton
5c76839559
sorted
11 years ago
John R. Lenton
07205ec323
added zip()
11 years ago
Paul Sokolovsky
757ac81a69
Add proper checks for fits-in-small-int. Make it reusable.
We likely should make mp_obj_new_int() inline, and rely on its
encapsulated check rather than inline checks everywhere explicitly.
Also, parser for big small int values is still broken.
11 years ago
Paul Sokolovsky
729e9cce7b
rt_binary_op(): Don't fall thru in case small_int op result doesn't fit back.
Currently it would report "operation not supported" which is confusing. Overall,
this is thinko leading to undefined behavior.
11 years ago
Paul Sokolovsky
b81e1fdef7
Add AssertionError.
11 years ago
Damien George
eae16445d5
py: Implement staticmethod and classmethod (internally).
Still need to make built-ins by these names, and write tests.
11 years ago
John R. Lenton
c1bef21920
Implemented support for `in` and `not in` operators.
11 years ago
Damien George
bcbeea0a47
py: Fix bug where == and != not handled for small_ints.
11 years ago
John R. Lenton
b8698fca75
unified the bops
11 years ago
Paul Sokolovsky
bab5cfb34f
Unsupported operand types for binary operator: dump both args' types.
11 years ago
Damien George
004cdcebfe
py: Implement base class lookup, issubclass, isinstance.
11 years ago
Damien George
062478e66d
Improved type/class/instance code; mp_obj_type_t now has load_attr, store_attr.
Creating of classes (types) and instances is much more like CPython now.
You can use "type('name', (), {...})" to create classes.
11 years ago
Damien George
93a9b5b64d
py: Proper framework for built-in 'type'.
11 years ago
Damien George
6c73ca1e75
py: add variable argument exception constructor function.
Addresses issue #104 .
11 years ago
Damien George
38a2da68c2
py: Stuff qstr in object pointer; keys for mp_map_t are now always mp_obj_t.
11 years ago
Damien George
b97669ab94
py: Improve __build_class__.
11 years ago
John R. Lenton
9c83ec0eda
Merge remote-tracking branch 'upstream/master' into dict_feats
11 years ago
John R. Lenton
88f3043e0a
added a first pass of dict.update
11 years ago
Damien George
1a9951d5aa
py: Fix up number operations and coercion.
11 years ago
Paul Sokolovsky
1e40840b3b
Add OSError, Python 3.3 generic I/O exception.
11 years ago