Commit Graph

650 Commits

Author SHA1 Message Date
Markus Siemens
242856cfbf Fixed problems with nlx86.S on Linux
Fixed '#ifdef's so Linux would compile again and added
.scl and .type for Windows.
2014-01-28 19:52:04 +01:00
Markus Siemens
19ccc6bdc7 Added Windows port (see #233) 2014-01-28 18:21:05 +01:00
Paul Sokolovsky
1801421f6d bytearray: Print objects properly. 2014-01-28 03:40:48 +02:00
Paul Sokolovsky
0b7e29c025 Factor out quoted string print function for reuse (mp_str_print_quoted()). 2014-01-28 03:40:06 +02:00
Paul Sokolovsky
7e652af242 array: CPython prints empty arrays inconsistently (only typecode, no []). 2014-01-28 03:19:13 +02:00
Paul Sokolovsky
0dd0467a97 Don't pre-import array module. 2014-01-28 03:18:30 +02:00
Paul Sokolovsky
11973b48b5 array.array: Allow to create empty arrays. 2014-01-28 03:18:30 +02:00
Damien George
c674f02d5c Merge pull request #231 from iabdalkader/master
Fix implicit double conversion warning
2014-01-27 15:54:44 -08:00
Damien George
c7aa9fcae5 Merge branch 'master' of github.com:micropython/micropython 2014-01-27 23:16:20 +00:00
Damien George
4e8dc8c41b py: Add unary op not for NoneType, bool, tuple, list, dict; fix for int. 2014-01-27 23:15:32 +00:00
Paul Sokolovsky
9b00dad7bb long int: Implement more operations. 2014-01-27 12:25:23 +02:00
mux
00a4da93e8 Fix implicit double conversion warning 2014-01-27 10:21:42 +02:00
Paul Sokolovsky
ddf1aa9223 list.pop(): Don't allow ->alloc drop to zero, which causes unexpected behavior. 2014-01-27 01:07:58 +02:00
Paul Sokolovsky
14d28be344 gen.send(): Throw StopIteration. Also, explicitly shutdown finished gen.
Otherwise, some generator statements still may be spuriously executed on
subsequent calls to next()/send().
2014-01-27 01:07:58 +02:00
Paul Sokolovsky
bf38e2a03a Implement send() method for generators. 2014-01-26 20:56:08 +02:00
Paul Sokolovsky
9d95a2b21d Functions of fixed number of args are special-cased only for 3 or less args. 2014-01-26 02:03:07 +02:00
Paul Sokolovsky
2ca84aa01e Add MP_OBJ_IS_INT(), for symmetry with MP_OBJ_IS_STR(). 2014-01-26 02:03:07 +02:00
Damien George
8fcf7b858d Merge pull request #225 from dhylands/fix-make-dep
Fixed dependency problem for qstrdefs.generated.h
2014-01-25 09:34:23 -08:00
Dave Hylands
1a3b0d5fed Fixed dependency problem for qstrdefs.generated.h
The problem manifests itself in make 4.0

I also fixed the LINK message when linking the final executable for unix and unix-cpy.
2014-01-25 08:55:31 -08:00
Damien George
b829b5caec Implement mp_parse_node_free; print properly repr(string). 2014-01-25 13:51:19 +00:00
Damien George
e0722ee9d9 Merge branch 'free-parse-tree' of github.com:pfalcon/micropython into pfalcon-free-parse-tree 2014-01-25 11:54:46 +00:00
Damien George
28eb57786d py: Optimise generated code for working out line numbers. 2014-01-25 11:43:20 +00:00
Damien George
2259e62c37 Remove obsoleted comment. 2014-01-25 00:25:32 +00:00
Damien George
0f5e8b151f Merge branch 'master' of github.com:micropython/micropython 2014-01-25 00:18:30 +00:00
Damien George
7c9c667633 py: Implement iterator support for object that has __getitem__.
Addresses Issue #203.
2014-01-25 00:17:36 +00:00
Paul Sokolovsky
aee2ba70de Add parse_node_free_struct() and use it to free parse tree after compilation.
TODO: Check lexer/parse/compile error path for leaks too.
2014-01-25 02:11:59 +02:00
Paul Sokolovsky
c1d200ef74 rt_deinit(): Finalize some maps. 2014-01-25 02:04:07 +02:00
Paul Sokolovsky
9a24a0465f Add mp_map_deinit() & mp_map_free() to finalize maps.
mp_map_deinit() finalizes static map, mp_map_free() - dynamic.
2014-01-25 02:04:01 +02:00
Damien George
fcd4ae8271 Merge pull request #221 from pfalcon/basic-bytes
Add basic implementation of bytes type, piggybacking on str.
2014-01-24 15:15:47 -08:00
Damien George
58b8a6202a Merge pull request #219 from dhylands/add-deps
Rework makefiles. Add proper dependency checking.
2014-01-24 15:03:39 -08:00
Damien George
0004a84ec0 Revert "Move gc_collect to py/gc.c"
This reverts commit a215b09c0d.
2014-01-24 22:54:09 +00:00
Damien George
baba08bff9 Merge pull request #218 from iabdalkader/master
Move file obj to separate module
2014-01-24 14:48:06 -08:00
Damien George
41d02b654e py: Improve freeing of emitters in mp_compile.
There can be multiple emitters allocated during compile (eg byte code
and native).
2014-01-24 22:42:28 +00:00
Damien George
ceb87835fe Merge pull request #217 from pfalcon/free-emitter
Add support for freeing code emitter objects at the end of compilation.
2014-01-24 14:32:40 -08:00
Damien George
1976baeeb7 Retain file order of qstr definitions.
Want common qstrs to be first in the list so they have the lowest ids,
so that in the byte code they take up the least room.
2014-01-24 22:22:00 +00:00
Damien George
60aca4810f Merge pull request #215 from pfalcon/qstr-special-chars
Allow qstr's with non-ident chars, construct good identifier for them.
2014-01-24 14:14:44 -08:00
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.
2014-01-24 22:56:26 +02:00
mux
a215b09c0d Move gc_collect to py/gc.c
* Move gc_collect from main to py/gc.c
* Define GC's memory boundaries in linker script
* Issue #220
2014-01-24 21:33:19 +02:00
Dave Hylands
c89c681a9f Rework makefiles. Add proper dependency checking. 2014-01-24 08:46:48 -08:00
Paul Sokolovsky
f46d87a30d Add support for freeing code emitter objects at the end of compilation. 2014-01-24 16:31:20 +02:00
Paul Sokolovsky
39763c6cb0 lexerstr: Free mp_lexer_str_buf_t structure itself. 2014-01-24 02:57:50 +02:00
Paul Sokolovsky
ab5d08280b Allow qstr's with non-ident chars, construct good identifier for them.
Also, add qstr's for string appearing in unix REPL loop, gross effect
being less allocations for each command run.
2014-01-24 02:34:22 +02:00
Paul Sokolovsky
fd31358505 mp_compile(): Properly free module_scope and all nested scopes. 2014-01-23 23:16:18 +02:00
Paul Sokolovsky
624ed5d563 mp_lexer_free(): Free lex->indent_level array. 2014-01-23 23:16:18 +02:00
Damien George
1e708fed18 py: Implement bool unary op; tidy up unary op dispatch. 2014-01-23 18:27:51 +00:00
Damien George
b051e7d167 py: Simpler implementation of mp_obj_callable. 2014-01-23 18:13:53 +00:00
Paul Sokolovsky
c3e72a8cc8 mp_obj_is_callable(): Only object types can be callable.
Fixes segfault on callable("string").
2014-01-23 03:37:21 +02:00
Paul Sokolovsky
1eacefe5bc Implement simplest case of str.startswith(). 2014-01-23 02:47:10 +02:00
Damien George
b979122dfb py: Use C99 way of variable macro arguments.
Addresses Issue #207.
2014-01-23 00:34:21 +00:00
Damien George
00208ce194 py: Change macro var args in parser to be C99 compliant. 2014-01-23 00:00:53 +00:00
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.
2014-01-22 23:59:20 +00:00
Damien George
f64086f80f Fix 1 warning and 1 bug. 2014-01-22 23:18:50 +00:00
Paul Sokolovsky
0b7184dcb8 Implement octal and hex escapes in strings. 2014-01-22 22:48:25 +02:00
Paul Sokolovsky
0914371faf file.readline(): Use mp_obj_str_get_data() and fix off-by-one error on EOF. 2014-01-22 19:17:58 +02:00
Damien George
5fa93b6755 Second stage of qstr revamp: uPy str object can be qstr or not. 2014-01-22 14:35:10 +00:00
Damien George
e6a4ab4be1 py: Remove implicit conversion of float to int in mp_obj_get_int().
Addresses Issue #199.
2014-01-22 00:21:47 +00:00
Damien George
2843b8e3a7 Merge branch 'master' of github.com:micropython/micropython 2014-01-21 23:49:44 +00:00
Damien George
600ae734cf py: Implement break and continue byte codes, and add tests.
Also fixes a bug in the for-in-range optimiser.

I hope to remove break and continue byte codes in the future and just
use jump (if possible).
2014-01-21 23:48:04 +00:00
Dave Hylands
7a996b1f65 Fix malformed generated file when using python 2.7 2014-01-21 15:28:27 -08:00
Paul Sokolovsky
09ce05996a array: Implement iterator. 2014-01-21 23:59:50 +02:00
Paul Sokolovsky
33996685df Add len() support for arrays. 2014-01-21 23:59:50 +02:00
Damien George
12eaccacda Merge branch 'master' of github.com:micropython/micropython
Conflicts:
	py/objstr.c
	py/py.mk
	py/stream.c
	unix/main.c
	unix/socket.c
2014-01-21 21:54:15 +00:00
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
2014-01-21 21:40:13 +00:00
Paul Sokolovsky
4c316552c1 Implement str.split(None).
Note that splitting by explicit string is not implemented so far.
2014-01-21 05:01:21 +02:00
Paul Sokolovsky
7380a83780 str: Implement proper string (instead of byte string) indexing.
Also, support negative indexes.
2014-01-21 02:25:59 +02:00
Paul Sokolovsky
545591a696 Implement string multiplication. 2014-01-21 00:39:12 +02:00
Paul Sokolovsky
439542f70c sequence.c: Start to refactor sequence operations for reuse among types. 2014-01-21 00:39:12 +02:00
Paul Sokolovsky
8965a5eb1e objstr: More support for MP_OBJ_QSTR. 2014-01-20 23:34:17 +02:00
Paul Sokolovsky
e6da0df6d1 mp_obj_get_type_str(): Handle MP_OBJ_QSTR. 2014-01-20 23:01:06 +02:00
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).
2014-01-20 20:37:01 +02:00
Paul Sokolovsky
ff3bdea49d stream_read(): Shrink memory block to actual read size. 2014-01-20 20:37:01 +02:00
Paul Sokolovsky
d54bef7692 stream: Add generic unbuffered iternext method.
Uses stream_unbuffered_readline underline.
2014-01-20 18:42:08 +02:00
Paul Sokolovsky
dff3f896d7 mp_identity(): Add generic identity function.
Useful as getiter method for objects which are their own iterators, etc.
2014-01-20 18:42:08 +02:00
Paul Sokolovsky
3754c4a040 mp_obj_get_qstr(): Handle MP_OBJ_QSTR. 2014-01-20 18:23:38 +02:00
Damien George
91d457a277 py: Put micropython module init code in builtinmp.c. 2014-01-20 10:30:24 +00:00
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.
2014-01-20 02:20:40 +02:00
Paul Sokolovsky
159c0f75da Don't implicitly import "sys" module. 2014-01-20 01:57:20 +02:00
Paul Sokolovsky
f477bfbc75 Pre-create sys module. 2014-01-20 01:00:28 +02:00
Paul Sokolovsky
bb33cc66fb Properly print MP_OBJ_QSTR objects. 2014-01-20 01:00:28 +02:00
Paul Sokolovsky
d720ab5236 Implement modules as singletons Python semantics.
In Python, importing module several times returns same underlying module
object. This also fixes import statement handling for builtin modules.

There're still issues:
1. CPython exposes set of loaded modules as sys.modules, we may want to
do that either.
2. Builtin modules are implicitly imported, which is not really correct.
We should separate registering a (builtin) module and importing a module.
CPython keeps builtin module names in sys.builtin_module_names .
2014-01-20 00:38:39 +02:00
Damien George
a11ceca807 Change int to uint for n_args in function with variable arguments. 2014-01-19 16:02:09 +00:00
Damien George
136b149e41 py: Add full traceback to exception printing. 2014-01-19 12:38:49 +00:00
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.
2014-01-19 11:48:48 +00:00
Damien George
e02b2d4391 py: Temporary fix for bug where not enough VM state is allocated. 2014-01-19 01:14:37 +00:00
Damien George
ebde0b8a09 Tiny optimisation in objlist.c; a new test for inheritance. 2014-01-19 00:47:40 +00:00
Damien George
2025e82cbf Merge branch 'master' of github.com:micropython/micropython 2014-01-18 23:43:31 +00:00
Damien George
932bf1c48f py: Fix VM/runtime unpack sequence bug, Issue #193. 2014-01-18 23:42:49 +00:00
Paul Sokolovsky
a2715c05c6 Add objarray.h . 2014-01-19 01:40:47 +02:00
Damien George
6b21538e91 Merge pull request #192 from pfalcon/arrays
Add skeleton implementation of array.array and bytearray.
2014-01-18 15:31:57 -08:00
Damien George
08335004cf Add source file name and line number to error messages.
Byte code has a map from byte-code offset to source-code line number,
used to give better error messages.
2014-01-18 23:24:36 +00:00
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
1d6fc94c16 Implement framework for class-defined built-in operators.
Now working for class-defined methods: __getitem__, __setitem__,
__add__, __sub__.  Easy to add others.
2014-01-18 15:31:13 +00: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
Paul Sokolovsky
d26b379eec int: Add value accessors: mp_obj_int_get() & mp_obj_int_get_checked().
mp_obj_int_get() can be used when just full resolution of C machine_int_t
is required (returns truncated value of long int). mp_obj_int_get_checked()
will throw exception if Python int value not representable in machine_int_t.
2014-01-18 16:12:12 +02: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
a9f5abd48c Implement LOAD_CONST_INT (by dispatching to int object implementation). 2014-01-17 20:05:10 +02:00
Paul Sokolovsky
966879cf59 Add long int implementation using C long long type, enable for unix port. 2014-01-17 20:05:02 +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
Paul Sokolovsky
a671f891dd Make file.read() and file.read(-1) call out to file.readall().
Per Python3 io module semantics.
2014-01-16 12:58:36 +02:00
Paul Sokolovsky
323c09e881 Do not assume that vstr buf is the same after it was extended. 2014-01-16 12:58:18 +02:00
Paul Sokolovsky
f2b796e7c7 str.format: Don't assume that '}' immediately follows '{', skip insides.
That at least makes stuff like "{:x}".format(1) to produce not completely
broken output.
2014-01-16 03:46:01 +02:00
Damien George
b99d9ea258 Add errno=0 before call. 2014-01-15 23:08:33 +00:00
Damien George
613eb25545 stm: Fix print methods with new kind argument. 2014-01-15 23:02:53 +00:00
Damien George
5573f9f150 Merge branch 'str2int' of github.com:xyb/micropython into xyb-str2int
Conflicts:
	py/objint.c
	unix-cpy/Makefile
	unix/Makefile
2014-01-15 22:58:39 +00: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
11507f4074 Merge branch 'master' of github.com:dpgeorge/micropython 2014-01-15 22:14:18 +00:00
Damien George
d02c6d8962 Implement eval. 2014-01-15 22:14:03 +00:00
Paul Sokolovsky
9953ca432b Add unbuffered readline() implementation for Raw I/O files. 2014-01-15 23:43:25 +02:00
Damien George
e2fb2baaa4 Implement repr. 2014-01-15 21:40:48 +00:00
Damien George
9528cd66d7 Convert parse errors to exceptions.
Parser no longer prints an error, but instead returns an exception ID
and message.
2014-01-15 21:23:31 +00:00
xyb
3e4ed25138 add more tests and remove debug code 2014-01-15 20:37:17 +08:00
xyb
3270fb4be6 int() test passed 2014-01-15 19:58:11 +08: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
Paul Sokolovsky
76d982ef34 type->print(): Distinguish str() and repr() variety by passing extra param. 2014-01-15 02:15:38 +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
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