Paul Sokolovsky
36c4499d36
Implement str() and repr() builtin functions.
2014-01-15 02:15:47 +02:00
Paul Sokolovsky
76d982ef34
type->print(): Distinguish str() and repr() variety by passing extra param.
2014-01-15 02:15:38 +02:00
Damien George
0f59203e37
Tidy up.
2014-01-14 23:18:35 +00:00
John R. Lenton
93451002f0
Merge remote-tracking branch 'upstream/master' into builtins
...
Conflicts:
py/builtin.c
py/builtin.h
py/runtime.c
2014-01-13 23:14:35 +00:00
John R. Lenton
88cb1e60e0
Made sorted() raise an exception instead of aborting when given no arguments; moved around some things in objfun.c as a consequence
2014-01-13 19:55:18 +00:00
John R. Lenton
2ded68db77
Cleaned up sorted() as per Damien's suggestions.
2014-01-13 19:52:28 +00:00
Damien George
2300537c79
Cleanup built-ins, and fix some compiler warnings/errors.
2014-01-13 19:39:01 +00:00
John R. Lenton
5c76839559
sorted
2014-01-13 05:12:50 +00:00
John R. Lenton
4bee76ebca
Added dict.fromkeys. Are we done with dict and #99 yet? I do think we are.
2014-01-10 11:25:03 +00:00
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.
2014-01-09 20:57:50 +00:00
Damien George
93a9b5b64d
py: Proper framework for built-in 'type'.
2014-01-08 18:48:12 +00:00
Damien George
6c73ca1e75
py: add variable argument exception constructor function.
...
Addresses issue #104 .
2014-01-08 18:11:23 +00:00
Damien George
38a2da68c2
py: Stuff qstr in object pointer; keys for mp_map_t are now always mp_obj_t.
2014-01-08 17:33:12 +00:00
Damien George
b97669ab94
py: Improve __build_class__.
2014-01-08 11:47:55 +00:00
Damien George
71c5181a8d
Convert Python types to proper Python type hierarchy.
...
Now much more inline with how CPython does types.
2014-01-04 20:21:15 +00:00
Damien George
eb7bfcb286
Split qstr into pools, and put initial pool in ROM.
...
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).
2014-01-04 15:57:35 +00:00
Damien George
66028ab6dc
Basic implementation of import.
...
import works for simple cases. Still work to do on finding the right
script, and setting globals/locals correctly when running an imported
function.
2014-01-03 14:03:48 +00:00
Damien George
40563d56bd
py: Add framework for built-in "type()" function.
2014-01-02 16:01:17 +00:00
Damien George
209d1b1835
py: add int() and float() built-ins, partially implemented.
2014-01-01 17:03:35 +00:00
Damien
dae7eb7226
py: add dict length function, and fix rt_store_set.
2013-12-29 22:32:51 +00:00
Damien
732407f1bf
Change memory allocation API to require size for free and realloc.
2013-12-29 19:33:23 +00:00
Damien
d9d6201b52
py: simplify __next__ method for generators.
2013-12-21 18:38:03 +00:00
Damien
d99b05282d
Change object representation from 1 big union to individual structs.
...
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).
2013-12-21 18:17:45 +00:00
Damien
a3dcd9e80c
py: add more Python built-in functions.
2013-12-17 21:35:38 +00:00
Damien
660365e14c
py: split runtime into map, obj, builtin.
2013-12-17 18:27:24 +00:00