Damien George
59a41e8fcd
py/qstr: Fix calc of qstr memory usage, due to new qstr chunk allocation.
2015-10-13 15:52:06 +01:00
Damien George
b8f9ac5411
py: Implement ptr32 load and store in viper emitter.
2015-10-13 00:50:17 +01:00
Damien George
3c9c3687d6
py: Add support to call __init__ from a builtin module on first import.
2015-10-12 13:46:01 +01:00
Paul Sokolovsky
408b74d74c
py: Allow to to build MicroPython as a static library.
...
The whole current port gets slurped into a static lib named
"libmicropython.a". Maybe that's not ideal, but at least something
to start with.
2015-10-12 15:32:06 +03:00
Damien George
fdfcee7b1e
py/parse: Make parser error handling cleaner, less spaghetti-like.
2015-10-12 12:59:18 +01:00
Damien George
64f2b213bb
py: Move constant folding from compiler to parser.
...
It makes much more sense to do constant folding in the parser while the
parse tree is being built. This eliminates the need to create parse
nodes that will just be folded away. The code is slightly simpler and a
bit smaller as well.
Constant folding now has a configuration option,
MICROPY_COMP_CONST_FOLDING, which is enabled by default.
2015-10-12 12:58:45 +01:00
Paul Sokolovsky
91fc075a33
py/objarray: Allow to create array of void pointers, as extension to CPython.
...
Using 'P' format specifier (matches struct module). This is another shortcut
for FFI, just as previously introduced "array of objects" ('O').
2015-10-12 10:13:51 +03:00
Paul Sokolovsky
1b586f3a73
py: Rename MP_BOOL() to mp_obj_new_bool() for consistency in naming.
2015-10-11 15:18:15 +03:00
Paul Sokolovsky
53ca6ae1f3
py/makeqstrdata.py: Catch and report case of empty input file.
...
The usual cause would be that a cross-compiler for a port is not in PATH.
2015-10-11 11:09:57 +03:00
Damien George
366239b8b9
py/parse: Factor logic when creating parse node from and-rule.
2015-10-08 23:13:18 +01:00
Damien George
b948de36fb
py: Don't generate unnecessary parse nodes for assignment or kwargs.
...
This patch eliminates the need for a nested parse node for assignments
and keyword arguments. It saves a little bit of RAM when parsing.
2015-10-08 14:26:01 +01:00
Damien George
9f5f156b9d
py/emitnative: Raise ViperTypeError for unsupported unary ops.
2015-10-08 13:08:59 +01:00
Damien George
7e12a601b8
py/compile: Fix edge case when constant-folding negation of integer.
...
Also adds tests specifically for testing constant folding.
2015-10-08 13:02:00 +01:00
Paul Sokolovsky
aaa8867d4a
modussl: SSL socket wrapper module based on axTLS.
2015-10-06 18:10:39 +03:00
Damien George
0496de26d3
py: Allow to enable inline assembler without native emitter.
2015-10-03 17:07:54 +01:00
Damien George
58e0f4ac50
py: Allocate parse nodes in chunks to reduce fragmentation and RAM use.
...
With this patch parse nodes are allocated sequentially in chunks. This
reduces fragmentation of the heap and prevents waste at the end of
individually allocated parse nodes.
Saves roughly 20% of RAM during parse stage.
2015-10-02 00:11:11 +01:00
Damien George
e5635f4ab3
py: Catch all cases of integer (big and small) division by zero.
2015-10-01 22:48:48 +01:00
Damien George
2065373f67
py/mpz: Fix bignum anding of large negative with smaller positive int.
2015-10-01 22:35:06 +01:00
Damien George
2f4e8511cd
py/mpz: Force rhs of mpz_shl_inpl/mpz_shr_inpl to be unsigned.
...
Python semantics are that rhs of shift must be non-negative, so there's
no need to handle negative values in the underlying mpz implementation.
2015-10-01 18:01:37 +01:00
Damien George
4c02e54298
py/mpz: Raise NotImplError instead of failing assertion.
2015-10-01 17:57:36 +01:00
Damien George
5f3c3ec5e6
py/parsenum: Provide detailed error for int parsing with escaped bytes.
...
This patch adds more fine grained error message control for errors when
parsing integers (now has terse, normal and detailed). When detailed is
enabled, the error now escapes bytes when printing them so they can be
more easily seen.
2015-10-01 17:18:12 +01:00
Tom Soulanille
f1a9923308
py/objrange: Bugfix for range_subscr() when index is a slice object.
2015-09-28 14:01:28 +00:00
Damien George
9d5e5c08ab
py/compile: Put compiler state on the C stack.
...
It's relatively small (between 44 and 56 bytes) and helps to reduce heap
pressure and fragmentation during compilation.
2015-09-24 13:15:57 +01:00
Damien George
fbcaf0ea18
py: Slightly simplify compile and emit of star/double-star arguments.
...
Saves a few bytes of code space and eliminates need for rot_two
bytecode (hence saving RAM and execution time, by a tiny bit).
2015-09-23 11:47:01 +01:00
Delio Brignoli
e6978a4e26
py: Fix call args when a stararg is followed by keyword args.
2015-09-23 11:37:00 +01:00
Alex March
bfb272b9e0
py/repl: Treat escaped quotes correctly in REPL continuation.
...
Escaped quotes are now recognised correctly in REPL when used
inside normal quotes.
Fixes : #1419
2015-09-19 14:06:23 +01:00
Tom Soulanille
661d9d1901
py/objslice: Fix indent.
2015-09-15 22:46:30 +01:00
Tom Soulanille
aeb62f9ae3
py/objslice: Make slice attributes (start/stop/step) readable.
...
Configurable with MICROPY_PY_BUILTINS_SLICE_ATTRS. Disabled by default.
2015-09-15 21:59:20 +01:00
Damien George
8b4fb4fe14
py/mpz: Fix calculation of max digit storage for mpz; fix sys.maxsize.
...
When creating constant mpz's, the length of the mpz must be exactly how
many digits are used (not allocated) otherwise these numbers are not
compatible with dynamically allocated numbers.
Addresses issue #1448 .
2015-09-15 16:15:57 +01:00
Damien George
0af73014cc
lib/mp-readline: Add auto-indent support.
...
4 spaces are added at start of line to match previous indent, and if
previous line ended in colon.
Backspace deletes 4 space if only spaces begin a line.
Configurable via MICROPY_REPL_AUTO_INDENT. Disabled by default.
2015-09-12 22:07:23 +01:00
Dave Hylands
9d6128acdc
stmhal: fix single precision float printing error
...
Fixes #1435 .
2015-09-11 23:09:50 +03:00
Damien George
2b000474d9
py/lexer: Properly classify floats that look like hex numbers.
...
Eg 0e0 almost looks like a hex number but in fact is a float.
2015-09-07 17:33:44 +01:00
Damien George
0be3c70cd8
py/lexer: Raise SyntaxError when unicode char point out of range.
2015-09-07 17:19:17 +01:00
Damien George
081f9325f5
py/lexer: Raise NotImplError for unicode name escape, instead of assert.
2015-09-07 17:08:49 +01:00
Damien George
558a016e2c
py/compile: Refine SyntaxError for repeated use of global/nonlocal.
2015-09-07 16:55:02 +01:00
Damien George
3a2171e406
py: Eliminate some cases which trigger unused parameter warnings.
2015-09-04 16:53:46 +01:00
Damien George
42cec5c893
py/objstr: Check for keyword args before checking for no posn args.
...
Otherwise something like bytes(abc=123) will succeed.
2015-09-04 16:51:55 +01:00
Damien George
55b11e6d38
py/objstr: For str.endswith(s, start) raise NotImpl instead of assert.
2015-09-04 16:49:56 +01:00
Damien George
0b7a66ab97
py/objbool: Simplify dispatch of bool binary op.
...
This optimises (in speed and code size) for the common case where the
binary op for the bool object is supported. Unsupported binary ops
still behave the same.
2015-09-04 16:46:15 +01:00
Damien George
ea5b59bfe6
py/compile: Only compile function annotations if really needed.
...
Function annotations are only needed when the native emitter is enabled
and when the current scope is emitted in viper mode. All other times
the annotations can be skipped completely.
2015-09-04 16:44:14 +01:00
Tony Abboud
8d8fdcb4be
stmhal: add option to query for the current usb mode
...
Fetch the current usb mode and return a string representation when
pyb.usb_mode() is called with no args. The possible string values are interned
as qstr's. None will be returned if an incorrect mode is set.
2015-09-03 23:30:43 +01:00
Damien George
821b7f22fe
py: Use mp_not_implemented consistently for not implemented features.
2015-09-03 23:14:06 +01:00
Damien George
e2aa117798
py/objstr: Simplify printing of bytes objects when unicode enabled.
2015-09-03 23:03:57 +01:00
Damien George
516982242d
py: Inline single use of mp_obj_str_get_len in mp_obj_len_maybe.
...
Gets rid of redundant double check for string type.
Also remove obsolete declaration of mp_obj_str_get_hash.
2015-09-03 23:01:07 +01:00
Paul Sokolovsky
8bf00084b6
py: Make "enumerate" qstr be conditional on MICROPY_PY_BUILTINS_ENUMERATE.
2015-09-03 19:35:52 +03:00
Damien George
81794fcd31
py/binary: Add support for array('q') and array('Q').
2015-09-01 16:31:48 +01:00
Damien George
22602cc37b
py/objstr: Make str.rsplit(None,n) raise NotImpl instead of assert(0).
2015-09-01 15:35:31 +01:00
Paul Sokolovsky
2ff2ea5f3b
vm: Handle "raise X from Y" statements the best way we can.
...
By issuing a warning that exception chaining is not supported, and ignoring
"from Y" argument.
2015-09-01 10:39:04 +03:00
Paul Sokolovsky
21ffa7c4ba
modbuiltins: Consistently use indentation for #if.
2015-08-31 00:22:11 +03:00
Damien George
000730ecaa
py/objstr: Simplify error handling for bad conversion specifier.
2015-08-30 12:43:21 +01:00