John R. Lenton
9daa78943e
added enumerate()
2014-01-14 23:55:01 +00:00
Damien George
11cc694aa0
Merge pull request #173 from pfalcon/file-readall
...
Generic implementation if stream readall() method, immediately reused in unix io.FileIO implementation
2014-01-14 15:35:50 -08:00
Damien George
39eab8de96
Merge pull request #161 from pfalcon/exc-more-pythonic
...
Move towards Python-compliant interface of exceptions
2014-01-14 15:27:59 -08: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
0f59203e37
Tidy up.
2014-01-14 23:18:35 +00: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
Paul Sokolovsky
ddf2178d83
Refactor exception objects to have better impl of Python-side interface.
...
This implements internal args tuple of arguments, while still keeping
object useful for reporting C-side errors.
Further elaboration is needed.
2014-01-15 00:03:23 +02:00
Paul Sokolovsky
8eec8bcad9
Add objtuple.h to allow embedding of tuples inside other objects.
...
This is useful because tuple is closest analog of C static array.
2014-01-14 23:59:18 +02:00
xyb
82e61bdc24
support int(str, basbase)
2014-01-14 22:43:18 +08:00
xyb
c178ea471e
Implemented int(str) in UNIX
2014-01-14 21:39:05 +08: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
Paul Sokolovsky
5225450b9f
Add generic impl of stream .readall() method. Use one for unix io.FileIO.
2014-01-13 23:31:06 +02:00
Paul Sokolovsky
5d2499c638
Add "buffer management" and "shrink" API calls to vstr.
...
vstr is initially intended to deal with arbitrary-length strings. By
providing a bit lower-level API calls, it will be also useful to deal
with arbitrary-length I/O buffers (the difference from strings is that
buffers are filled from "outside", via I/O).
Another issue, especially aggravated by I/O buffer use, is alloc size
vs actual size length. If allocated 1Mb for buffer, but actually
read 1 byte, we don't want to keep rest of 1Mb be locked by this I/O
result, but rather return it to heap ASAP ("shrink" buffer before passing
it to qstr_from_str_take()).
2014-01-13 23:31:06 +02:00
Paul Sokolovsky
ca318bba0d
mp_obj_equal(): Compare small and long ints properly.
...
By dispatching to long int methods.
2014-01-13 22:41:16 +02:00
Paul Sokolovsky
76a90f2f60
Move mp_obj_int_t definition to objint.h, to reuse in long int impls.
2014-01-13 22:36:49 +02: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
f62d33aa1d
Consolidate rt_make_function_[0123] to rt_make_function_n.
2014-01-13 19:50:05 +00:00
Damien George
f88a72a88e
Merge pull request #168 from dhylands/add-strstr
...
Added public domain implementations of strchr and strstr.
2014-01-13 11:43:57 -08:00
Damien George
2300537c79
Cleanup built-ins, and fix some compiler warnings/errors.
2014-01-13 19:39:01 +00:00
Dave Hylands
44332ec9ea
Initialize is_kw for dynamically allocated mp_obj_fun_native_t ojects.
...
This should fix issue #171
2014-01-13 08:55:51 -08:00
Dave Hylands
c8effff937
Added public domain implementations of strchr and strstr.
2014-01-12 22:34:58 -08: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
189c8e1cc4
Fixed the merge so it worked and compiled and stuff
2014-01-13 00:52:06 +00:00
John R. Lenton
13e64f0660
Merge remote-tracking branch 'upstream/master' into containment
2014-01-13 00:41:12 +00:00
Damien George
34f813ee29
Merge pull request #162 from chipaca/str_find
...
Implement a basic str.find; fixes #67
2014-01-12 16:34:03 -08:00
Damien George
ec3e14e2af
Merge pull request #160 from pfalcon/elaborate-int
...
Elaborate small-int/long-int
2014-01-12 16:32:21 -08:00
John R. Lenton
7244a14439
oops, nasty off-by-one in set_copy
2014-01-12 23:37:45 +00:00
John R. Lenton
be790f94d5
Implemented set binary ops.
2014-01-12 23:09:10 +00:00
John R. Lenton
e820491f7a
Implement a basic str.find; fixes #67
2014-01-12 21:53:52 +00:00
Paul Sokolovsky
48b3572f7e
Add framework to support alternative implementations of long int Python type.
2014-01-12 22:04:21 +02:00
Paul Sokolovsky
80f60e1aee
Parse long Python ints properly.
...
Long int is something which doesn't fit into SMALL_INT partion of
machine_int_t. But it's also something which doesn't fit into
machine_int_t in the first place.
2014-01-12 22:04:21 +02: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
Paul Sokolovsky
c260bc58e6
Add WORD_MSBIT_HIGH define - machine_int_t with the highest bit set.
2014-01-12 22:04:21 +02:00
Paul Sokolovsky
fc5aac82cb
Move BITS_PER_BYTE, BITS_PER_WORD to mpconfig.h for reuse.
2014-01-12 22:04:20 +02:00
John R. Lenton
0de386bffe
Implemented set.update
2014-01-12 19:50:50 +00:00
John R. Lenton
ae00d334c6
Implemented set.remove
2014-01-12 19:16:59 +00:00
John R. Lenton
4a08067c0c
Implemented set.isdisjoint
2014-01-12 18:03:21 +00:00
John R. Lenton
f1ae6b48fb
Implemented set.intersection and set.intersection_update
2014-01-12 17:54:03 +00:00
John R. Lenton
032129f3b5
Implemented set.difference and set.difference_update
2014-01-12 17:07:17 +00:00
John R. Lenton
2a24172cdc
Implemented set.discard
2014-01-12 16:39:39 +00:00
John R. Lenton
3b0bd87906
Implemented set.copy
2014-01-12 15:56:25 +00:00
John R. Lenton
1d7fb2f21b
Implemented set.clear
2014-01-12 15:44:26 +00:00
John R. Lenton
19b14d3d8a
Implemented set.add
2014-01-12 15:29:11 +00:00
John R. Lenton
0ce03b48a0
make sets iterable
2014-01-12 15:17:42 +00:00
Damien George
69a818d418
py: Improve memory management for parser; add lexer error for bad line cont.
2014-01-12 13:55:24 +00:00
Damien George
97eb73cf84
Merge pull request #148 from pfalcon/list-cmp
...
Implement type virtual equality method support and implement comparisons for lists
2014-01-12 04:58:25 -08:00
Damien George
e5863d9301
py: AssertionError is loaded from global, to match CPython.
2014-01-12 12:35:08 +00:00
Damien George
c0876f7ca8
Merge pull request #146 from pfalcon/assert-exc
...
Add AssertionError.
2014-01-12 04:26:54 -08:00
Paul Sokolovsky
1945e60aeb
list: Implement comparison operators.
2014-01-12 03:34:04 +02:00
Paul Sokolovsky
cc57bd2663
mp_obj_equal(): For non-trivial types, call out to type's special method.
2014-01-12 03:33:56 +02: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
c698d266d1
list: Add extend() methods and += operator.
2014-01-12 00:54:10 +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
Damien George
bc1d36924d
py: Fix emitcpy and emitnative's binary_op.
2014-01-11 09:47:06 +00:00
Damien George
8d4ccc49ed
Merge branch 'master' of github.com:dpgeorge/micropython
2014-01-11 09:37:41 +00:00
Damien George
25042b19d2
py: Make arg to MP_BC_RAISE_VARARGS a byte.
2014-01-11 09:33:39 +00:00
John R. Lenton
b8698fca75
unified the bops
2014-01-11 00:58:59 +00:00
Damien George
ad97f2a49e
Merge pull request #136 from pfalcon/for-range-downto
...
compile_for_stmt_optimised_range(): Properly handle negative & unknown s...
2014-01-10 15:21:50 -08:00
Damien George
e9b4b7ac75
Merge pull request #135 from pfalcon/simple-raise
...
Crude attempt to implement RAISE_VARARGS (with args=1 so far only).
2014-01-10 15:20:08 -08:00
Damien George
46c9e97132
Merge pull request #134 from pfalcon/list-mul
...
list: Implement list multiplication.
2014-01-10 15:17:17 -08:00
Damien George
745ce4c2ad
Merge pull request #131 from chipaca/dict_fromkeys
...
Added dict.fromkeys.
2014-01-10 15:11:56 -08:00
Paul Sokolovsky
899c69f94c
compile_for_stmt_optimised_range(): Properly handle negative & unknown steps.
...
If step is not constant, in first approximation, we can't apply optimization,
(well, we could, but need a special case for this).
2014-01-11 01:00:21 +02:00
Paul Sokolovsky
5388a3c29a
Crude attempt to implement RAISE_VARARGS (with args=1 so far only).
2014-01-11 00:55:08 +02:00
Paul Sokolovsky
074d3b5f86
list: Implement list multiplication.
2014-01-11 00:49:19 +02:00
Paul Sokolovsky
bab5cfb34f
Unsupported operand types for binary operator: dump both args' types.
2014-01-11 00:14:48 +02:00
Paul Sokolovsky
d6f27fe317
mp_obj_equal(): Print which types' equality not implemented before assert().
2014-01-11 00:14:33 +02:00
Paul Sokolovsky
e06edce786
mp_repl_is_compound_stmt(): Thinko fix s/true/try/.
2014-01-11 00:12:06 +02:00
Paul Sokolovsky
4b919d0135
Dump few more bytecodes (based on attempt to run real-world code).
2014-01-11 00:10:49 +02: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
John R. Lenton
9ec3a87189
dict views now, refactoring later.
2014-01-10 01:00:20 +00:00
Damien George
2d45429122
Use memcpy instead of strncpy; add usart.status to stm.
2014-01-09 22:04:45 +00:00
Damien George
be842973b0
Merge pull request #123 from xbe/master
...
Implement str.strip
2014-01-09 13:55:55 -08: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
xbe
7b0f39f318
Implement str.strip
2014-01-08 14:23:45 -08:00
Damien George
1143e5e72a
Merge pull request #120 from dhylands/make-build-quieter
...
Make build output quieter.
2014-01-08 10:52:32 -08:00
Damien George
93a9b5b64d
py: Proper framework for built-in 'type'.
2014-01-08 18:48:12 +00:00
Dave Hylands
4646801181
Make build output quieter.
...
Use make V=1e make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
This should fix issue #117
2014-01-08 10:30:06 -08:00
Damien George
6c73ca1e75
py: add variable argument exception constructor function.
...
Addresses issue #104 .
2014-01-08 18:11:23 +00:00
Damien George
199b9e04eb
Merge pull request #114 from pfalcon/streams-bootstrap
...
Define buffer and stream protocols, and other starting bits of io.* framework, with io.FileIO-like implementation for Unix
2014-01-08 09:50:15 -08: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
Paul Sokolovsky
e98cf40c34
Add generic implementations of Python read()/write methods for streams.
...
These can be used for any object which implements stream protocol
(mp_stream_p_t).
2014-01-08 17:38:38 +02:00
Paul Sokolovsky
5b15daf6d1
Add support for stream and buffer protocols.
...
Stream protocol is abstraction of serial I/O. Buffer protocol is
abstraction of random-access I/O. These protocols are defined down
to C level, to allow generic, while still efficient algorithms
to be coded in C (like, buffered transfer between 2 stream objects,
saving/loading of buffer object to/from stream, etc). (Note that CPython
define buffer protocol on C level, but apparently not stream protocol).
2014-01-08 17:38:38 +02:00
Damien George
9193f89296
Move lexerstr to main py directory (everyone uses it).
2014-01-08 15:28:26 +00:00
Damien George
b97669ab94
py: Improve __build_class__.
2014-01-08 11:47:55 +00:00
Damien George
6d6bc9efc1
Merge pull request #108 from chipaca/dict_feats
...
Dictionary features that don't involve views or classmethods. First part of issue #99 .
2014-01-07 15:42:16 -08:00
Damien George
dfc0bac086
py: Small big fix to type declarations.
2014-01-07 23:18:54 +00:00
John R. Lenton
baa665406f
Moved dict methods out to a mp_method_t.
2014-01-07 23:18:25 +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
John R. Lenton
be8fe5be2e
Added dict.setdefault
2014-01-07 22:51:08 +00:00
John R. Lenton
f77dce8a5d
Added dict.popitem
2014-01-07 22:51:08 +00:00
John R. Lenton
0fcbaa442f
implemented dict.pop
2014-01-07 22:51:08 +00:00
John R. Lenton
cd0887352d
Added dict.get.
2014-01-07 22:51:08 +00:00
John R. Lenton
d90b19eca5
Added dict.copy
2014-01-07 22:51:08 +00:00
John R. Lenton
7d21d516d2
make dict_len use the map's used count
2014-01-07 22:51:08 +00:00
John R. Lenton
4ce6ceadca
Added dict.clear.
...
Added 0 to the list of primes. Funky primes, these.
2014-01-07 22:51:08 +00:00
John R. Lenton
a41fe31322
Added dict iterator.
2014-01-07 22:51:08 +00:00
Paul Sokolovsky
24507aff7d
Typo fix in comment.
2014-01-07 22:51:08 +00:00
Paul Sokolovsky
af61a1a492
Use constructor to create small int (avoid exposing mp_obj_t internals to VM).
2014-01-07 22:51:08 +00:00
Damien George
777575712b
Merge pull request #105 from chipaca/listsort
...
A more python-style list.sort. And keyword arguments.
2014-01-07 14:49:22 -08:00
Paul Sokolovsky
1e40840b3b
Add OSError, Python 3.3 generic I/O exception.
2014-01-07 20:16:54 +02:00
John R. Lenton
3391e19068
A bit of stylistic cleanup (chose the wrong side during conflict resolution).
2014-01-07 18:06:34 +00:00
John R. Lenton
270112f731
Merge remote-tracking branch 'upstream/master' into listsort. Lots of conflict fun.
...
Conflicts:
py/obj.h
py/objbool.c
py/objboundmeth.c
py/objcell.c
py/objclass.c
py/objclosure.c
py/objcomplex.c
py/objdict.c
py/objexcept.c
py/objfun.c
py/objgenerator.c
py/objinstance.c
py/objmodule.c
py/objrange.c
py/objset.c
py/objslice.c
2014-01-07 18:01:08 +00:00
John R. Lenton
c06763a020
This implements a better (more python-conformant) list.sort.
...
It's not really about that, though; it's about me figuring out a sane
way forward for keyword-argument functions (and function
metadata). But it's useful as is, and shouldn't break any existing
code, so here you have it; I'm going to park it in my mind for a bit
while sorting out the rest of the dict branch.
2014-01-07 17:29:16 +00:00
Damien George
7b21c2d8f0
py: Fix allocation of unique code blocks.
2014-01-07 16:54:58 +00:00
Damien George
97209d38e1
Merge branch 'cplusplus' of https://github.com/ian-v/micropython into ian-v-cplusplus
...
Conflicts:
py/objcomplex.c
2014-01-07 15:58:30 +00:00
Damien George
d3ebe4829d
Factor and simplify Makefile's and mpconfig, part 2.
2014-01-07 15:20:33 +00:00
Damien George
136f67523b
Factor and simplify Makefile's and mpconfig.
2014-01-07 14:54:15 +00:00
ian-v
a5a01df81d
Make list and str method tables static
2014-01-06 14:14:11 -08:00
Damien George
8b1b59c28e
Merge branch 'master' of github.com:dpgeorge/micropython
2014-01-06 22:13:45 +00:00
Damien George
e2e3d11e87
py: Fix up number operations and coercion.
2014-01-06 22:13:00 +00:00
ian-v
5fd8fd2c16
Revert MP_BOOL, etc. and use <stdbool.h> instead
2014-01-06 13:51:53 -08:00
ian-v
7a16fadbf8
Co-exist with C++ (issue #85 )
2014-01-06 09:52:29 -08:00
Paul Sokolovsky
fe039b4f4f
Typo fix in comment.
2014-01-06 17:54:34 +02:00
Paul Sokolovsky
e5ee1693ad
Use constructor to create small int (avoid exposing mp_obj_t internals to VM).
2014-01-06 17:54:16 +02:00
John R. Lenton
a10dba7509
Merge remote-tracking branch 'upstream/master' into list_reverse
2014-01-06 00:08:21 +00:00
Damien George
8137b004b0
Merge branch 'list_remove' of git://github.com/chipaca/micropython into chipaca-list_remove
2014-01-05 23:58:49 +00:00
Damien George
aa35fc60d7
Merge pull request #92 from chipaca/list_insert
...
List insert. Fixes issue #61 .
2014-01-05 15:59:00 -08:00
Damien George
17f4497d6d
Merge pull request #91 from chipaca/list_index
...
Fix off-by-one in non-default values of index's 2nd and 3rd arguments.
2014-01-05 15:55:55 -08:00
Damien George
73595feb75
Merge pull request #89 from pfalcon/c99-tagged-structs
...
Convert many object types structs to use C99 tagged initializer syntax.
2014-01-05 15:54:51 -08:00
John R. Lenton
ba3f87c947
Merge remote-tracking branch 'upstream/master' into list_reverse
2014-01-05 22:29:03 +00:00
John R. Lenton
d52a0318ce
Merge remote-tracking branch 'upstream/master' into list_remove
2014-01-05 22:27:11 +00:00
John R. Lenton
8428b8f3c9
Merge remote-tracking branch 'upstream/master' into list_insert
2014-01-05 22:11:01 +00:00
John R. Lenton
c553162ebc
Fix off-by-one in non-default values of index's 2nd and 3rd arguments.
2014-01-05 21:57:27 +00:00
Paul Sokolovsky
860ffb0a43
Convert many object types structs to use C99 tagged initializer syntax.
2014-01-05 22:34:09 +02:00
Dave Hylands
d986b582c0
Make qstr_init reinitialize last_pool.
...
This causes the pool to get reinitialized properly on a soft-reset.
2014-01-05 12:08:55 -08:00
Damien George
1703597c0b
Merge pull request #80 from xyb/striter
...
Implements str iterator
2014-01-05 05:53:31 -08:00
Damien George
f0691f4ed5
Fix qstr in objlist.c; add more tests for list.index.
...
list.index fails on an edge case.
2014-01-05 13:44:06 +00:00
xyb
8cfc9f07b9
Implements str iterator
2014-01-05 18:47:51 +08:00
John R. Lenton
7e73a8fd09
Merge remote-tracking branch 'upstream/master' into list_index
2014-01-05 01:57:54 +00:00
Damien George
45b43c21c4
Oops: add objint.c
2014-01-05 01:50:45 +00:00
Damien George
a494b29c73
Merge pull request #73 from mikaeleiman/apple-clang-fixes
...
Apple clang fixes
2014-01-04 12:29:34 -08: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
Mikael Eiman
d67091371d
OSX: fixes to make nlrx64.S with Apple's clang (switched to Apple-specific define instead of __llvm__)
2014-01-04 20:27:13 +01:00
Mikael Eiman
f53cdd947c
OSX: fixes to make nlrx64.S with Apple's clang (forgot a few places)
2014-01-04 20:19:19 +01:00
Mikael Eiman
5d02e2d6fa
OSX: fixes to make nlrx64.S with Apple's clang
2014-01-04 20:15:04 +01:00
Damien George
e9906ac3d7
Add ellipsis object.
2014-01-04 18:44:46 +00:00
Damien George
4d4bc9533e
Merge pull request #70 from chipaca/list_count
...
Implements list.count. Fixes isue #55 .
2014-01-04 10:09:40 -08: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
John R. Lenton
505dd00f07
Merge remote-tracking branch 'upstream/master' into list_count
2014-01-04 14:16:24 +00:00
Damien George
e67ed5d285
Improve configurability for native x64/thumb emitter.
...
With MICROPY_EMIT_X64 and MICROPY_EMIT_THUMB disabled, the respective
emitters and assemblers will not be included in the code. This can
significantly reduce binary size for unix version.
2014-01-04 13:55:24 +00:00
John R. Lenton
ff9a24f6f7
Merge remote-tracking branch 'upstream/master' into list_count
2014-01-04 12:52:07 +00:00
Damien George
0be78d44e5
Merge pull request #64 from pfalcon/str-slice-range-check
...
str slice: Trim slice indexes to be in range.
2014-01-04 04:28:57 -08:00
Damien George
597bb2f249
Merge pull request #60 from chipaca/list_copy
...
Implemented list.copy. Fixes issue #54 .
2014-01-04 04:25:46 -08:00
John R. Lenton
6e1e98f864
Implements list.reverse; fixes issue #66
2014-01-04 02:10:29 +00:00
John R. Lenton
49fb6e53b3
Implements list.remove (in terms of list.index and list.pop).
...
Fixes issue #63 .
2014-01-04 01:56:53 +00:00
Paul Sokolovsky
6ee1e383d6
str slice: Trim slice indexes to be in range.
2014-01-04 03:55:37 +02:00
John R. Lenton
f1c6ad46af
Merge remote-tracking branch 'upstream/master' into list_insert
2014-01-04 01:36:10 +00:00
John R. Lenton
a58cf679ee
Merge remote-tracking branch 'upstream/master' into list_count
2014-01-04 01:28:40 +00:00
John R. Lenton
45a8744617
Implements list.insert. Fixes issue #61 .
2014-01-04 01:15:01 +00:00
Damien George
c8d1384fc0
Fix int -> machine_int_t; add print to slice test.
2014-01-04 01:06:10 +00:00
Damien George
b95d90b2f3
Merge pull request #59 from pfalcon/slice
...
Implement basic slice object and string slicing
2014-01-03 17:03:19 -08:00
Damien George
9ba9589ef7
Merge pull request #58 from chipaca/list_clear
...
Added list.clear. Fixes issue #53 .
2014-01-03 16:54:30 -08:00
Paul Sokolovsky
f8b9d3c41a
str: Throw TypeError for invalid index type and clean up comments.
2014-01-04 02:35:49 +02:00
Paul Sokolovsky
e606cb6561
slice: Allow building with MICROPY_ENABLE_SLICE=0.
2014-01-04 02:35:49 +02:00
Paul Sokolovsky
decad08ef5
str: Handle non-positive slice indexes.
2014-01-04 02:35:48 +02:00
Paul Sokolovsky
59800afae9
slice: Implement special handling of omitted start/stop indexes.
2014-01-04 02:35:48 +02:00
Paul Sokolovsky
cd22627f78
Enable slice support in config.
2014-01-04 02:35:48 +02:00
Paul Sokolovsky
31ba60f836
str: Initial implementation of string slicing.
...
Only step=1 and non-negative indexes are supported so far.
2014-01-04 02:35:48 +02:00
Paul Sokolovsky
ded0a1efa5
Implement BUILD_SLICE opcode (2-arg version).
2014-01-04 02:35:48 +02:00
Paul Sokolovsky
1c6de11f77
Add basic implementation of slice object.
...
So far, only start and stop integer indexes are supported. Step is
not supported, as well as objects of arbitrary types.
2014-01-04 02:35:48 +02:00
John R. Lenton
5d4a821339
Implements list.index. Fixes issue #57 .
2014-01-04 00:26:30 +00:00
Damien George
98adccf7ac
Merge pull request #52 from chipaca/master
...
Tweaks to list.pop.
2014-01-03 16:22:19 -08:00
John R. Lenton
e241e8c169
Implemented list.count
2014-01-03 23:57:28 +00:00
Paul Sokolovsky
c90c0f68a2
Move INT_FMT, etc. declaration into global mpconfig.h .
...
This in particular makes it available for stm port.
2014-01-04 01:57:00 +02:00
John R. Lenton
26c211648b
Implemented list.copy. Fixes issue #54 .
2014-01-03 23:42:17 +00:00
John R. Lenton
069ded9514
Added list.clear. Fixes issue #53 .
2014-01-03 23:22:53 +00:00
John R. Lenton
97334c85d0
Merge remote-tracking branch 'upstream/master'
2014-01-03 22:55:16 +00:00
John R. Lenton
25f417c08c
Worked on list.pop:
...
* Fixes issue #51
* Adds a specific error message for when you try to pop an empty list.
* Releases some memory if the list has shurnk a lot.
2014-01-03 22:53:18 +00:00
Paul Sokolovsky
b372bfca21
Rename default config file to mpconfig.h, and port's to mpconfigport.h.
...
mpconfig.h will automatically pull mpconfigport.h.
2014-01-03 19:03:11 +02:00
Paul Sokolovsky
ef18102b9e
Make it possible to turn off collecting memory stats (MICROPY_MEM_STATS).
2014-01-03 18:55:24 +02:00
Paul Sokolovsky
780f555b2e
Add new alloc metric: peak_bytes_allocated.
...
This is just max value of current_bytes_allocated seen.
2014-01-03 18:55:23 +02:00
Paul Sokolovsky
02de0c57d2
Add new alloc metric: current_bytes_allocated.
...
Unlike total_bytes_allocated, this tracks m_free()'s too.
2014-01-03 18:55:23 +02:00
Paul Sokolovsky
43f1c8080a
m_realloc: Account only allocation size difference in total_bytes_allocated.
2014-01-03 18:55:23 +02:00
Damien George
4b57fac1c8
Merge pull request #43 from chipaca/master
...
Implement list addition.
2014-01-03 07:11:42 -08:00
Damien George
1fb031744f
Change mp_compile so that it returns a function object for the module.
2014-01-03 14:22:03 +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
John R. Lenton
9bc56d933f
Changed to use memcpy.
2014-01-03 10:13:38 +00:00
John R. Lenton
aeb16c36b0
Add a bit of whitespace.
2014-01-03 02:36:35 +00:00
John R. Lenton
81ad89c46e
untabified
2014-01-03 02:32:40 +00:00
John R. Lenton
4cb80582c4
Add list addition ( fixes : #39 )
2014-01-03 02:27:08 +00:00
Damien George
aae7847508
Change old use of module creation to new proper use.
2014-01-03 00:10:22 +00:00
Damien George
2870862601
Add module object, to be used eventually for import.
2014-01-02 21:30:26 +00:00
Damien George
0ff883904a
py: Fix generator where state array was incorrectly indexed.
...
Generator objects now allocate the object and the state in one malloc.
This improvement fixes Issue #38 .
2014-01-02 20:57:05 +00:00
Damien George
ebd2e8702d
py: __MACH__ also uses MAP_ANON.
2014-01-02 20:28:12 +00:00
Damien George
66327006fc
py: change negative array indices with array - 1.
2014-01-02 18:20:41 +00:00
Damien George
27bf5b829b
py: Add more bytecodes to showbc.c.
2014-01-02 18:15:33 +00:00
Paul Sokolovsky
bdf822b3d8
Add quick impl for MP_BC_LOAD_CONST_BYTES which just creates qstr so far.
...
This is based on the fact that qstr so far behaves more like byte string
than like Unicode string (for example, "012"[0] returns 48 (int)).
2014-01-02 18:51:19 +02:00
Damien George
fe8fb9165c
py: remove depedence on strcat and stpcpy.
...
This fixes Issue #29 , and means the core is no longer dependent on
string functions, except strlen.
2014-01-02 16:36:09 +00:00
Damien George
40563d56bd
py: Add framework for built-in "type()" function.
2014-01-02 16:01:17 +00:00
Edd Barrett
67ab5ee779
On OpenBSD MAP_ANONYMOUS is called MAP_ANON.
2014-01-01 23:16:27 +00:00
Damien George
df884fe4cc
py: change declaration of mp_map_t in obj.h (for issue #24 ).
2014-01-01 21:27:43 +00:00
Damien George
209d1b1835
py: add int() and float() built-ins, partially implemented.
2014-01-01 17:03:35 +00:00
Damien George
83c437cb0d
Merge pull request #12 from pfalcon/minor-fixes
...
Minor fixes
2013-12-30 14:43:21 -08:00
Damien George
6baf76e28b
py: make closures work.
2013-12-30 22:32:17 +00:00
Paul Sokolovsky
2efbc622cb
Typo fix in comment.
2013-12-30 21:03:41 +02:00
Damien George
8cc96a35e5
Put unicode functions in unicode.c, and tidy their names.
2013-12-30 18:23:50 +00:00
Damien George
212c296c0b
Make unix-cpy cross platform; remove dependency of asmx64 on mpconfig.
2013-12-30 12:52:32 +00:00
Damien George
cd340c44c2
Merge branch 'cross-plat' of https://github.com/pfalcon/micropython into pfalcon-cross-plat
2013-12-30 12:08:18 +00:00
Paul Sokolovsky
e85c38992d
Make "unix" target be crossplatform and support x86, x64, ARM hosts.
2013-12-30 03:38:32 +02: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
02a7c41e76
py: implement POP_BLOCK in VM.
2013-12-29 18:48:37 +00:00
Paul Sokolovsky
44d0f3cfa2
Handle return value of read() call.
2013-12-29 20:11:05 +02:00
Damien
de690d128b
Add unix-cpy, used to test Micro Python byte code against CPython.
2013-12-29 18:01:01 +00:00
Damien
b86e3f9293
py: implement some basic exception matching.
2013-12-29 17:17:43 +00:00
Damien
8f9e2ee157
Add code in VM to handle nested exceptions correctly.
2013-12-29 16:54:59 +00:00
Damien
dd12d1378f
Parse upper-case hex numbers correctly.
2013-12-29 13:03:49 +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
e2880aa2fd
Fix a few compiler warnings.
2013-12-20 14:22:59 +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
a1b2693161
py: remove further unnecessary emit_verbatim code.
2013-12-12 15:34:40 +00:00
Damien
e388f1034e
py: fix bug with doc string not recognised after first newline of file.
2013-12-12 15:24:38 +00:00
Damien
02f8941bf6
py: reduce use of emit_verbatim calls to minimum.
2013-12-12 15:13:36 +00:00
Damien
9ecbcfff99
py: work towards working closures.
2013-12-11 00:41:43 +00:00
Damien
318aec6ba9
py: emit correct id for closed over variables.
2013-12-10 18:28:17 +00:00
Damien
6332174ab4
py: compiler supports string juxtaposition=concatenation.
2013-12-10 17:41:49 +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
d79338969b
py: restrict further when for-range optimisation is done.
2013-11-28 19:12:18 +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
6f3e7fc505
py: add UNPACK_SEQUENCE and keyword methods to VM.
2013-11-26 15:15:50 +00:00
Damien
ff099f36d6
py: add more functionality to showbc.
2013-11-26 15:14:50 +00:00
Damien
d47f9d5a4f
py: add call to __init__ when instantiating class object.
2013-11-25 23:40:02 +00:00
Damien
c1075ddc8f
py: add some more opcodes to showbc.
2013-11-25 23:39:36 +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
6d4f3462c4
Viper: function calls now convert constant arguments to objects.
2013-11-16 20:44:39 +00:00
Damien
6b92d451b2
Add len and subscr (a hack) support for strings.
2013-11-09 20:13:55 +00:00
Damien
94658e2e25
Add JUMP_IF_x_OR_POP opcodes to VM.
2013-11-09 20:12:32 +00:00
Damien
f3822fc34c
Fix but with optimised range being 1 over.
2013-11-09 20:12:03 +00:00
Damien
f72fd0e875
Add optimisation for "for x in range".
2013-11-06 20:20:49 +00:00
Damien
5bf32c3b6b
Built-in print function supports variable number of arguments.
2013-11-06 17:16:35 +00:00
Damien
ae0bc08a37
Viper supports inplace add (trivial).
2013-11-06 17:11:07 +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
6addc89e55
Byte code for SMALL_INT uses 3 bytes for integer.
2013-11-04 23:04:50 +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
9b9e996df6
Support for for-loop in native thumb.
2013-11-03 14:25:43 +00:00
Damien
1a6633a74d
Implement more thumb branch instructions.
2013-11-03 13:58:19 +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
d2c1a732e5
Call gc_free in gc_realloc after allocating new block.
2013-10-23 21:03:27 +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
92c06561a3
Improve REPL compount statement detection.
2013-10-22 22:32:27 +01:00
Damien
bb5316b905
gc: reserve first block; lexer: free vstr.
2013-10-22 21:12:29 +01:00
Damien
fd8b6bcf55
Add gc_free function to force a block to be freed.
2013-10-22 20:26:36 +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
eefcc79022
Clear ATBs on gc_init; better gc_info.
2013-10-22 15:25:25 +01:00
Damien
dcced92c26
Add mark-sweep garbage collector.
2013-10-21 23:45:08 +01:00
Damien
fa2162bc77
Integrate new lexer stream with stm framework.
2013-10-20 17:42:00 +01:00
Damien
27fb45eb1c
Add local_num skeleton framework to deref/closure emit calls.
2013-10-20 15:07:49 +01:00
Damien
a5185f4bc8
Abstract out back-end stream functionality from lexer.
2013-10-20 14:41:27 +01:00
Damien
68f59a96e3
Add vstr and its functions.
2013-10-20 14:39:58 +01:00
Damien
df4b4f31ef
Make grammar rules const so the go in .text section.
2013-10-19 18:28:01 +01:00
Damien
4d7adce9c5
Remove obsolete emitthumb.c (now use emitnative.c).
2013-10-19 18:17:12 +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
7bbd110691
Remove line in emitbc.c to print code size.
2013-10-18 19:57:17 +01:00
Damien
3997be444c
Add single_input rule to grammar, for REPL.
2013-10-18 19:56:48 +01:00
Damien
9f770c658f
Fix up insertion of newline at end of lexer stream.
2013-10-18 19:54:31 +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
5fd09668b7
Add MAP_ADD opcode to VM.
2013-10-16 20:54:01 +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
152568bcb6
NLR and Python exceptions work on the board.
2013-10-16 00:46:39 +01:00
Damien
c9f91976e1
Crude try-except working.
2013-10-15 23:46:01 +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
0efb3a1b66
Tidy up SMALL_INT optimisations and CPython compatibility.
2013-10-12 16:16:56 +01:00
Damien
3a205179ea
Option in compile.c to emit compatible or not with CPython.
2013-10-12 15:01:56 +01:00
Damien
c025ebb2dc
Separate out mpy core and unix version.
2013-10-12 14:30:21 +01:00
Damien
a56f292626
Remove obsolete emitx64.c (now in emitnative.c).
2013-10-10 23:30:29 +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
5609cca2ce
Rename vm.h to bc.h.
2013-10-10 20:00:08 +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
91d387de7d
Improve indent/dedent error checking and reporting.
2013-10-09 15:09:52 +01:00
Damien
ff8ed77cc1
Improve push/pop and register usage for native emit.
2013-10-08 22:18:32 +01:00
Damien
13ed3a658d
Native Python and Viper support for x64 and thumb all together.
2013-10-08 09:05:10 +01:00
Damien
3410be8035
Merge viper types with standard native emitter.
2013-10-07 23:09:10 +01:00
Damien
acbf9a50d0
Rename r64->reg, i64->imm.
2013-10-07 21:52:14 +01:00
Damien
016f75f434
Add comments.
2013-10-07 21:22:39 +01:00
Damien
7af3d19a3c
Implement crude viper emit stage.
2013-10-07 00:02:49 +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
03d4124320
Add b_n opcode to inline thumb asm.
2013-10-06 00:36:05 +01:00
Damien
b14de21fc8
Optimise typedargslist_name to not create a node if just an id.
2013-10-06 00:28:28 +01:00
Damien
a2f2f7db1f
Almost supports arguments for inline asm functions.
2013-10-06 00:14:13 +01:00
Damien
5fa5ae40be
Make range of small int 24 bits.
2013-10-06 00:13:15 +01:00
Damien
39cf3285c7
Oops: add emitpass1.c for new factorised emit code.
2013-10-05 23:18:38 +01:00
Damien
826005c60b
Add support for inline thumb assembly.
2013-10-05 23:17:28 +01:00
Damien
5bfb759980
Incorporate emit_thumb into new emit framework.
2013-10-05 18:41:24 +01:00
Damien
6cdd3af601
Implement built-in decorators to select emit type.
2013-10-05 18:08:26 +01:00
Damien
4b03e77d4a
Factorise EMIT_COMMON calls, mostly into emit_pass1.
2013-10-05 14:17:09 +01:00
Damien
054848a1b8
Compiler computes labels and max_num_labels.
2013-10-05 13:44:41 +01:00
Damien
b05d707b23
Further factorise PASS_1 out of specific emit code.
2013-10-05 13:37:10 +01:00
Damien
415eb6f850
Restructure emit so it goes through a method table.
2013-10-05 12:19:06 +01:00
Damien
492d082455
Use macro EMIT_COMMON for emit_common calls.
2013-10-04 20:35:08 +01:00
Damien
d69adc19c7
Small fixes to Makefile.
2013-10-04 20:34:47 +01:00
Damien
429d71943d
Initial commit.
2013-10-04 19:53:11 +01:00