Damien George
31101d91ce
py/lexer: Remove unnecessary code, and unreachable code.
...
Setting emit_dent=0 is unnecessary because arriving in that part of the
if-logic will guarantee that emit_dent is already zero.
The block to check indent_top(lex)>0 is unreachable because a newline is
always inserted an the end of the input stream, and hence dedents are
always processed before EOF.
2016-10-12 11:00:17 +11:00
Damien George
deaa57acf3
py/compile: Remove debugging code for compiler dispatch.
...
It was a relic from the days of developing the compiler and is no longer
needed, and it's impossible to trigger via a test.
2016-10-12 10:20:48 +11:00
Damien George
6dff3df501
py/objint: Use size_t for arguments that measure bytes/sizes.
2016-10-11 13:20:11 +11:00
Damien George
8bb7d958f1
py: Factor duplicated function to calculate size of formatted int.
2016-10-11 13:11:32 +11:00
Damien George
df3e5d2b2f
py/mpz: Use assert to verify mpz does not have a fixed digit buffer.
2016-10-11 13:00:56 +11:00
Damien George
48874942f0
py/mpz: In divmod, replace check for rhs!=0 with assert.
...
The check for division by zero is made by the caller of this function.
2016-10-11 13:00:01 +11:00
Damien George
e49153fb98
py/compile: Remove unreachable code.
2016-10-11 12:29:54 +11:00
Damien George
7dc2345715
py/modmicropython: Add micropython.opt_level([value]) function.
...
This allows to get/set at runtime the optimisation level of the compiler.
2016-10-11 10:56:22 +11:00
Paul Sokolovsky
d22a04d9c4
py/objstringio: Add readinto() method.
...
Also, drop deprecated (as for MicroPython) readall() method.
2016-10-09 11:56:11 +03:00
Damien George
3a0a771730
py: Add mp_raise_OSError(errno) helper function.
...
This is an often used code pattern, and its use reduces code size of the
core by about 100 bytes.
2016-10-07 13:31:59 +11:00
Damien George
dffa383b06
py/modstruct: Remove unreachable code, and add comment about CPy diff.
...
The deleted code is unreachable because calcsize_items guarantees that
num_items corresponds to how many items there are in fmt to unpack.
2016-10-07 12:54:14 +11:00
Damien George
8de270b4fc
py/objbool: Make a slight simplification of bool constructor.
...
Reduces code size for some archs.
2016-09-30 17:02:07 +10:00
Damien George
eca1408f16
py/objbool: Defer bool's unary op implementation to small int.
...
Similar to how binary op already works. Common unary operations already
have fast paths for bool so there's no need to have explicit handling of
ops in bool_unary_op, especially since they have the same behaviour as
integers.
2016-09-30 17:02:06 +10:00
Damien George
3be4f886ce
py/argcheck: Simplify if-chain so that the last one is the default.
2016-09-30 16:45:43 +10:00
Damien George
216a711cd4
py/compile: Fix typo when checking for parse-node kind.
2016-09-30 14:48:06 +10:00
Damien George
0d10517a45
py/scope: Factor common code to find locals and close over them.
...
Saves 50-100 bytes of code.
2016-09-30 13:53:00 +10:00
Damien George
d5495966ce
py/scope: Shrink scope_t struct by 1 machine word.
...
On 32-bit archs this makes the scope_t struct 48 bytes in size, which fits
in 3 GC blocks (previously it used 4 GC blocks). This will lead to some
savings when compiling scripts because there are usually quite a few scopes,
one for each function and class.
Note that qstrs will fit in 16 bits, this assumption is made in a few other
places.
2016-09-30 12:45:00 +10:00
Damien George
3dea8c9e92
py/scope: Use lookup-table to determine a scope's simple name.
...
Generates slightly smaller and more efficient code.
2016-09-30 12:34:05 +10:00
Damien George
b32c01b748
py/compile: Fix async-for/async-with to work with simpler exc on stack.
...
There is now just the exception instance on the stack when an exception is
raised, not the full (type, exc, traceback).
2016-09-28 11:52:13 +10:00
Damien George
2c7716fed0
py/objset: Ensure that use of frozenset.update raises an exception.
2016-09-28 11:06:18 +10:00
Damien George
dd4135aeaf
py/objset: Use mp_check_self() to check args of set/frozenset methods.
...
Following how other objects work, set/frozenset methods should use the
mp_check_self() macro to check the type of the self argument, because in
most cases this check can be a null operation.
Saves about 100-180 bytes of code for builds with set and frozenset
enabled.
2016-09-28 10:55:23 +10:00
Damien George
0c595fa094
py/objfun: Use if instead of switch to check return value of VM execute.
...
It's simpler and improves code coverage.
2016-09-27 23:08:10 +10:00
Damien George
c71edaed73
py/objfun: Remove unnecessary check for viper fun with 5 or more args.
...
The native emitter/compiler restricts viper functions to 4 args, so there
is no need for an extra check in the dynamic dispatch.
2016-09-27 23:05:51 +10:00
Damien George
7385b018ed
py/emitbc: Remove/refactor unreachable code, to improve coverage.
2016-09-27 15:46:50 +10:00
Damien George
897129a7ff
py/objstr: Remove unreachable function used only for terse error msgs.
2016-09-27 15:45:42 +10:00