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