Damien George
f49ba1bd9c
Improve method lookup in mp_obj_class_lookup.
...
Now searches both locals_dict and methods. Partly addresses Issue #145 .
2014-01-18 17:52:41 +00:00
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.
2014-01-18 19:27:38 +02:00
Damien George
0c4e909e76
Merge pull request #191 from pfalcon/store-item
...
Add store_item() virtual method to type to implement container[index] = val
2014-01-18 06:57:47 -08:00
Damien George
632cf5710c
Merge branch 'master' of github.com:dpgeorge/micropython
2014-01-18 14:15:48 +00:00
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.
2014-01-18 14:10:48 +00:00
Paul Sokolovsky
6d8edf6acf
Add store_item() virtual method to type to implement container[index] = val.
2014-01-18 13:11:59 +02:00
Paul Sokolovsky
166bb40fb2
Add OverflowError and use it for small int overflow instead of assert.
2014-01-18 12:46:43 +02:00
Paul Sokolovsky
10744dd816
Add empty (false) value testing for strings, tuples, lists, dicts.
2014-01-16 23:54:17 +02:00
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.
2014-01-16 19:29:11 +02:00
Damien George
4899ff9470
Merge branch 'str-repr' of github.com:pfalcon/micropython into pfalcon-str-repr
...
Conflicts:
tests/basics/tests/exception1.py
2014-01-15 22:39:03 +00:00
Damien George
7a9d0c4540
Merge branch 'builtins' of github.com:chipaca/micropython into chipaca-builtins
...
Added some checks for number of arguments.
Conflicts:
py/mpqstrraw.h
2014-01-15 22:27:16 +00:00
Damien George
d02c6d8962
Implement eval.
2014-01-15 22:14:03 +00:00
Damien George
e2fb2baaa4
Implement repr.
2014-01-15 21:40:48 +00:00
John R. Lenton
fca456bc3c
added filter()
2014-01-15 01:37:08 +00:00
John R. Lenton
39b174e00a
Added map
2014-01-15 01:10:09 +00:00
Paul Sokolovsky
36c4499d36
Implement str() and repr() builtin functions.
2014-01-15 02:15:47 +02:00
John R. Lenton
ff8007c7d6
Merge remote-tracking branch 'upstream/master' into builtins
2014-01-14 23:58:05 +00:00
John R. Lenton
9daa78943e
added enumerate()
2014-01-14 23:55:01 +00:00
Damien George
66a5bf681d
Merge pull request #142 from chipaca/containment
...
Implemented support for `in` and `not in` operators.
2014-01-14 15:23:09 -08:00
Damien George
6c2401e935
Merge pull request #165 from chipaca/builtins
...
added zip()
2014-01-14 15:13:40 -08:00
Paul Sokolovsky
8bc96471f0
Implement "is" and "is not" operators.
...
So far, don't work for strings as expected.
2014-01-15 00:32:09 +02: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
f5a0a7d2b3
Merge remote-tracking branch 'upstream/master' into containment
2014-01-13 23:09:04 +00:00
Damien George
f62d33aa1d
Consolidate rt_make_function_[0123] to rt_make_function_n.
2014-01-13 19:50:05 +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
07205ec323
added zip()
2014-01-13 02:31:00 +00:00
John R. Lenton
13e64f0660
Merge remote-tracking branch 'upstream/master' into containment
2014-01-13 00:41:12 +00:00
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.
2014-01-12 22:04:21 +02:00
Damien George
c0876f7ca8
Merge pull request #146 from pfalcon/assert-exc
...
Add AssertionError.
2014-01-12 04:26:54 -08:00
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.
2014-01-12 03:33:01 +02:00
Paul Sokolovsky
b81e1fdef7
Add AssertionError.
2014-01-12 00:20:49 +02:00
Damien George
eae16445d5
py: Implement staticmethod and classmethod (internally).
...
Still need to make built-ins by these names, and write tests.
2014-01-11 19:22:29 +00:00
John R. Lenton
813edf63a3
Merge remote-tracking branch 'upstream/master' into containment
...
Conflicts:
py/runtime.c
2014-01-11 16:34:56 +00:00
John R. Lenton
c1bef21920
Implemented support for in
and not in
operators.
2014-01-11 12:39:33 +00:00
Damien George
bcbeea0a47
py: Fix bug where == and != not handled for small_ints.
2014-01-11 10:47:22 +00:00
John R. Lenton
b8698fca75
unified the bops
2014-01-11 00:58:59 +00:00
Paul Sokolovsky
bab5cfb34f
Unsupported operand types for binary operator: dump both args' types.
2014-01-11 00:14:48 +02:00
Damien George
004cdcebfe
py: Implement base class lookup, issubclass, isinstance.
2014-01-09 21:43:51 +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
John R. Lenton
9c83ec0eda
Merge remote-tracking branch 'upstream/master' into dict_feats
2014-01-07 23:06:46 +00:00
John R. Lenton
88f3043e0a
added a first pass of dict.update
2014-01-07 22:51:08 +00:00
Damien George
1a9951d5aa
py: Fix up number operations and coercion.
2014-01-07 22:51:08 +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
e9906ac3d7
Add ellipsis object.
2014-01-04 18:44:46 +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
14f945c2ca
Add note about implementing inplace operators.
2014-01-03 14:09:31 +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
2870862601
Add module object, to be used eventually for import.
2014-01-02 21:30:26 +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 George
6baf76e28b
py: make closures work.
2013-12-30 22:32:17 +00:00
Damien George
8cc96a35e5
Put unicode functions in unicode.c, and tidy their names.
2013-12-30 18:23:50 +00:00
Damien
dae7eb7226
py: add dict length function, and fix rt_store_set.
2013-12-29 22:32:51 +00:00
Damien
b86e3f9293
py: implement some basic exception matching.
2013-12-29 17:17:43 +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
Damien
9ecbcfff99
py: work towards working closures.
2013-12-11 00:41:43 +00:00
Damien
db4c361f1c
py: add skeletal import functionality.
2013-12-10 17:27:24 +00:00
Damien
033d17a633
py: built-in range now accepts variable number of arguments.
2013-11-28 19:22:56 +00:00
Damien
86c7fc7dd9
py: add list pop and sort, unpack_sequence, and keywords in method_call.
2013-11-26 15:16:41 +00:00
Damien
d47f9d5a4f
py: add call to __init__ when instantiating class object.
2013-11-25 23:40:02 +00:00
Damien
f03001f8a6
Add function to decode and show byte code.
2013-11-17 13:19:33 +00:00
Damien
0446a0d76d
Change some debugging/output messages for native code generation.
2013-11-17 13:16:36 +00:00
Damien
6b92d451b2
Add len and subscr (a hack) support for strings.
2013-11-09 20:13:55 +00:00
Damien
5bf32c3b6b
Built-in print function supports variable number of arguments.
2013-11-06 17:16:35 +00:00
Damien
40fdfe3000
Improve allocation of stack for byte code.
2013-11-05 22:16:22 +00:00
Damien
03c9cfb015
Make byte code jumps relative.
2013-11-05 22:06:08 +00:00
Damien
96a0addb18
Fixup include of stdarg and va_list definition.
2013-11-03 18:30:10 +00:00
Damien
2f06c57f8a
Add simple var-arg functions; add simple string.format.
2013-11-03 18:20:56 +00:00
Damien
33af3bf028
Change Py API names, py_get_* -> py_obj_get_*.
2013-11-03 14:39:47 +00:00
Damien
d57eba51e5
Add user object to runtime.
2013-11-02 23:58:14 +00:00
Damien
6ba1314265
Fix bug: emit native didn't clear last_was_return in label_assign.
2013-11-02 20:34:54 +00:00
Damien
7410e440ab
Add basic complex number support.
2013-11-02 19:47:57 +00:00
Damien
e0b1864337
Small hack to temporarily fix allocation of unique_code slots.
2013-11-02 16:41:24 +00:00
Damien
ccfc9c51ba
Py runtime: list.append returns None.
2013-11-02 15:10:37 +00:00
Damien
4ebb32fb95
Implement: str.join, more float support, ROT_TWO in VM.
2013-11-02 14:33:10 +00:00
Damien
2839168340
Add py_get_array_fixed_n function.
2013-10-25 00:40:38 +01:00
Damien
6f08f8ce51
Add working MMA support.
2013-10-23 22:17:26 +01:00
Damien
8b3a7c2237
Fix func decls with no arguments: () -> (void).
2013-10-23 20:20:17 +01:00
Damien
9fc7933ff2
Add py_get_qstr.
2013-10-23 00:01:10 +01:00
Damien
ec63cce470
Add simple support for C modules.
2013-10-22 22:58:17 +01:00
Damien
7b2d3f38ce
Implement some more operators, mostly for small ints.
2013-10-22 16:53:02 +01:00
Damien
f086ecf57c
Shrink py_obj_base_t size to 4 machine words.
2013-10-22 16:05:11 +01:00
Damien
df4b4f31ef
Make grammar rules const so the go in .text section.
2013-10-19 18:28:01 +01:00
Damien
1595f3257e
Make rt_fun_table const, so it goes in .text section.
2013-10-19 15:09:32 +01:00
Damien
5ac1b2efbd
Implement REPL.
2013-10-18 19:58:12 +01:00
Damien
d2755ec538
Add iterators and comprehension to emitnative.
2013-10-16 23:58:48 +01:00
Damien
c12aa468a1
Add SET_ADD opcode to VM.
2013-10-16 20:57:49 +01:00
Damien
bd25445a82
Implement BC & runtime support for generator/yielding.
2013-10-16 20:39:12 +01:00
Damien
c226dca1f7
Support tuples and list comprehension, albeit crude.
2013-10-16 16:12:52 +01:00
Damien
ce89a21ea4
Implement basic exception framework, and simple for loop.
2013-10-15 22:25:17 +01:00
Damien
3ef4abb446
Change ifdef/if defined to simple if's.
2013-10-12 16:53:13 +01:00
Damien
c025ebb2dc
Separate out mpy core and unix version.
2013-10-12 14:30:21 +01:00
Damien
a1ddfcc213
Wrap out-native code in preprocessor declarations.
2013-10-10 23:25:50 +01:00
Damien
eb19efb27e
Simplify and improve function & method calling.
2013-10-10 22:06:54 +01:00
Damien
7f5dacf345
Implement basic class/object in native code.
2013-10-10 11:24:39 +01:00
Damien
a397776d6b
Implement basic class/object functionality in runtime.
2013-10-09 23:10:10 +01:00
Damien
13ed3a658d
Native Python and Viper support for x64 and thumb all together.
2013-10-08 09:05:10 +01:00
Damien
e4af64f307
Functions to convert values to/from inline asm.
2013-10-06 12:04:13 +01:00
Damien
dc83382903
Make runtime able to call inline asm with 1 argument.
2013-10-06 01:01:01 +01:00
Damien
826005c60b
Add support for inline thumb assembly.
2013-10-05 23:17:28 +01:00
Damien
6cdd3af601
Implement built-in decorators to select emit type.
2013-10-05 18:08:26 +01:00
Damien
b05d707b23
Further factorise PASS_1 out of specific emit code.
2013-10-05 13:37:10 +01:00
Damien
429d71943d
Initial commit.
2013-10-04 19:53:11 +01:00