Damien George
42495392da
py: Implement "it" instruction for inline Thumb assembler.
2015-02-16 17:46:49 +00:00
Damien George
3d7bf5d4b1
py: More robust checking in inline assembler compiler.
2015-02-16 17:46:28 +00:00
Paul Sokolovsky
9e6c82960e
builtinimport: Revamp&refactor handling of relative imports.
...
Relative imports are based of a package, so we're currently at a module
within a package, we should get to package first.
Also, factor out path travsering operation, but this broke testing for
boundary errors with relative imports. TODO: reintroduce them, together
with proper tests.
2015-02-16 12:11:34 +02:00
Paul Sokolovsky
078172dcab
builtinimport: Improve debugging output.
2015-02-16 12:11:03 +02:00
Paul Sokolovsky
e8432b3c72
stackctrl: Encode "recursion depth exceeded" message as qstr.
...
So corresponding exception can be thrown even under tight memory conditions.
2015-02-15 22:41:14 +03:00
Paul Sokolovsky
fa3b895145
objexcept: Optimize traceback allocation for exception.
...
Traceback allocation for exception will now never lead to recursive
MemoryError exception - if there's no memory for traceback, it simply
won't be created.
2015-02-15 22:41:14 +03:00
Paul Sokolovsky
29c4f92e13
objexcept: Optimize using messages without formatting substitutions.
...
They are directly cast to str object, skipping allocation of formatting
buffer.
2015-02-15 22:41:14 +03:00
Paul Sokolovsky
3077fbff26
nlr: Add even more optional debugging logging.
...
Has to be enabled by manual editing, but at least it's there, as debugging
NLR issues may be weird.
2015-02-15 20:28:18 +03:00
Paul Sokolovsky
e89cc13e5c
nlr: If DEBUG, guard against recursive nlr_push().
...
Pushing same NLR record twice would lead to "infinite loop" in nlr_jump
(but more realistically, it will crash as soon as NLR record on stack is
overwritten).
2015-02-15 20:23:52 +03:00
Paul Sokolovsky
53e5e0fa28
py: Make old_globals part of mp_code_state structure.
...
Conceptually it is part of code state, so let it be allocated in the same way
as the rest of state.
2015-02-15 19:24:15 +03:00
Damien George
e5039c6ff8
py: Use TextIOWrapper only if PY_IO_FILEIO def'd; cast size_t for print.
2015-02-15 13:17:11 +00:00
Damien George
f6532bb9e0
py: Simplify and remove redundant code for __iter__ method lookup.
2015-02-15 01:10:13 +00:00
Damien George
d1c3788375
py: Fix loading of immediate pointer in Thumb assembler.
...
Addresses issue #1117 .
2015-02-15 00:45:28 +00:00
Damien George
0868942e77
py: Check for valid file when creating lexer for execfile.
...
Addresses issue #1119 .
2015-02-15 00:02:27 +00:00
stijn
1b8e76b8e6
py: Cleanup duplication in instance_is_callable/instance_call.
2015-02-14 23:49:04 +00:00
stijn
c1832fd206
py: Add setattr builtin.
2015-02-14 23:35:00 +00:00
Paul Sokolovsky
089c3f321e
py/asm*.c: Typo fixes in comments.
2015-02-14 02:20:35 +08:00
Damien George
192d536fe4
py: Implement clz and rbit for inline Thumb assembler.
2015-02-13 11:06:23 +00:00
Damien George
32f0b7942c
py: Implement sdiv/udiv for inline Thumb assembler.
2015-02-13 10:43:05 +00:00
Damien George
0d967b8ae4
py: Implement push/pop for inline Thumb assembler.
2015-02-13 02:30:35 +00:00
Damien George
dfe944c3e5
py: Expose compile.c:list_get as mp_parse_node_extract_list.
2015-02-13 02:29:46 +00:00
Damien George
8dfbd2d589
py: Make inline assembler raise proper SyntaxError exception on error.
...
Also gives line number of location of error. Very useful!
2015-02-13 01:00:51 +00:00
Damien George
1bf5a022fe
py: Add ldrex and strex to thumb2 inline assembler.
...
These are useful for implementing atomic lock operations.
2015-02-12 22:52:42 +00:00
Damien George
596f41da04
py: Reuse value stack in VM WITH_CLEANUP opcode to reduce C-stack size.
...
Saves 8 bytes C-stack on stmhal and 16 bytes on unix x86.
2015-02-10 13:21:42 +00:00
Damien George
ea0461dcd3
py: Add option to micropython.qstr_info() to dump actual qstrs.
2015-02-10 11:02:28 +00:00
Damien George
d0df10b2c6
py: Don't unnecessarily create a bound method.
2015-02-09 16:59:15 +00:00
Damien George
48244044a2
py: Allow subclass of native object to delegate to the native buffer_p.
...
Addresses issue #1109 .
2015-02-09 15:08:00 +00:00
Damien George
1a6721fefd
py: Remove obsolete MP_F_LOAD_CONST_{INT,DEC} from emitnative.c.
2015-02-09 14:53:16 +00:00
Paul Sokolovsky
194117a066
objstr: Fix bytes creation from array of long ints.
2015-02-09 12:11:49 +08:00
Damien George
28631537bd
py: Add MICROPY_OBJ_BASE_ALIGNMENT to help with 16-bit ports.
2015-02-08 13:42:00 +00:00
Damien George
f804833a97
py: Initialise variables in mp_parse correctly, to satisfy gcc warning.
2015-02-08 13:40:20 +00:00
Damien George
7d414a1b52
py: Parse big-int/float/imag constants directly in parser.
...
Previous to this patch, a big-int, float or imag constant was interned
(made into a qstr) and then parsed at runtime to create an object each
time it was needed. This is wasteful in RAM and not efficient. Now,
these constants are parsed straight away in the parser and turned into
objects. This allows constants with large numbers of digits (so
addresses issue #1103 ) and takes us a step closer to #722 .
2015-02-08 01:57:40 +00:00
Damien George
5f97aaeca4
py: Fix instance lookup, since object is not a real type.
2015-02-08 00:42:13 +00:00
Damien George
0bfc7638ba
py: Protect mp_parse and mp_compile with nlr push/pop block.
...
To enable parsing constants more efficiently, mp_parse should be allowed
to raise an exception, and mp_compile can already raise a MemoryError.
So these functions need to be protected by an nlr push/pop block.
This patch adds that feature in all places. This allows to simplify how
mp_parse and mp_compile are called: they now raise an exception if they
have an error and so explicit checking is not needed anymore.
2015-02-07 18:33:58 +00:00
Damien George
e1e359ff59
py: Put mp_sys_path, mp_sys_argv and gc_collected in mp_state_ctx_t.
...
Without mp_sys_path and mp_sys_argv in the root pointer section of the
state, their memory was being incorrectly collected by GC.
2015-02-07 17:24:10 +00:00
Damien George
744e767458
py: Make list.sort keep stack usage within O(log(N)) bound.
...
Also fix list.sort so it works with user-defined types, and parse the
keyword arguments properly.
Addresses issue #338 .
2015-02-02 15:14:22 +00:00
Damien George
f49782f005
py: Fix cmath.log10; fix printing of complex number with negative imag.
2015-02-02 12:52:14 +00:00
Paul Sokolovsky
98c4bc3fac
py: Add MICROPY_PY_ALL_SPECIAL_METHODS and __iadd__ special method under it.
2015-01-31 00:35:56 +02:00
Damien George
32bade19d9
py: Convert CR to LF and CR LF to LF in lexer.
...
Only noticeable difference is how newlines are encoded in triple-quoted
strings. The behaviour now matches CPython3.
2015-01-30 00:27:46 +00:00
Damien George
3da677e658
py: Implement Ellipsis object in native emitter.
2015-01-29 15:13:40 +00:00
Damien George
827b0f747b
py: Change vstr_null_terminate -> vstr_null_terminated_str, returns str.
2015-01-29 13:57:23 +00:00
Damien George
81e70a88a7
py: Make REPL printing function print repr of object, not str.
...
Addresses issue #1014 .
2015-01-28 23:53:13 +00:00
Damien George
0d3cb6726d
py: Change vstr so that it doesn't null terminate buffer by default.
...
This cleans up vstr so that it's a pure "variable buffer", and the user
can decide whether they need to add a terminating null byte. In most
places where vstr is used, the vstr did not need to be null terminated
and so this patch saves code size, a tiny bit of RAM, and makes vstr
usage more efficient. When null termination is needed it must be
done explicitly using vstr_null_terminate.
2015-01-28 23:43:01 +00:00
Paul Sokolovsky
bbd9251bac
py: bytes(): Make sure we add values as bytes, not as chars.
2015-01-28 22:29:07 +02:00
Damien George
98e3a64694
py: Remove duplicated mp_obj_str_make_new function from objstrunicode.c.
2015-01-28 14:14:57 +00:00
Damien George
16677ce311
py: Be more precise about unicode type and disabled unicode behaviour.
2015-01-28 14:07:11 +00:00
David Steinberg
0b3014ce3a
py: Add support for floats in mp_binary_{get,set}_val()
...
- This then provides support for floats in the struct package
2015-01-27 22:49:01 +02:00
Damien George
a5efcd4745
py: Specify unary/binary op name in TypeError error message.
...
Eg, "() + 1" now tells you that __add__ is not supported for tuple and
int types (before it just said the generic "binary operator"). We reuse
the table of names for slot lookup because it would be a waste of code
space to store the pretty name for each operator.
2015-01-27 18:02:25 +00:00
Damien George
a9dc9b8f6d
py: Fix comparison of minus-zero long int.
2015-01-27 17:47:38 +00:00
Damien George
8788b131ec
py: Check for NDEBUG using #ifdef rather than #if.
...
Defining NDEBUG (to any value, even 0) disables debugging. Otherwise,
if it's not defined, debugging is enabled.
2015-01-25 18:35:54 +00:00