micropython/tests/cmdline
Angus Gratton 25ff5b52d9 py/parse: Allow const types other than int to optimise as true/false.
Allows optimisation of cases like:

    import micropython
    _DEBUG = micropython.const(False)
    if _DEBUG:
        print('Debugging info')

Previously the 'if' statement was only optimised out if the type of the
const() argument was integer.

The change is implemented in a way that makes the compiler slightly smaller
(-16 bytes on PYBV11) but compilation will also be very slightly slower.

As a bonus, if const support is enabled then the compiler can now optimise
const truthy/falsey expressions of other types, like:

    while "something":
        pass

... unclear if that is useful, but perhaps it could be.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2022-09-23 16:04:13 +10:00
..
cmd_optimise.py
cmd_optimise.py.exp
cmd_parsetree.py
cmd_parsetree.py.exp py/compile: Allow new qstrs to be allocated at all compiler passes. 2022-05-17 23:39:22 +10:00
cmd_showbc.py py/emit: Suppress unreachable bytecode/native code that follows jump. 2022-06-20 22:28:18 +10:00
cmd_showbc.py.exp py/emit: Suppress unreachable bytecode/native code that follows jump. 2022-06-20 22:28:18 +10:00
cmd_showbc_const.py py/parse: Allow const types other than int to optimise as true/false. 2022-09-23 16:04:13 +10:00
cmd_showbc_const.py.exp py/parse: Allow const types other than int to optimise as true/false. 2022-09-23 16:04:13 +10:00
cmd_showbc_opt.py py/emit: Suppress unreachable bytecode/native code that follows jump. 2022-06-20 22:28:18 +10:00
cmd_showbc_opt.py.exp py/emit: Suppress unreachable bytecode/native code that follows jump. 2022-06-20 22:28:18 +10:00
cmd_verbose.py
cmd_verbose.py.exp
repl_autocomplete.py
repl_autocomplete.py.exp
repl_autoindent.py
repl_autoindent.py.exp
repl_basic.py
repl_basic.py.exp
repl_cont.py
repl_cont.py.exp
repl_emacs_keys.py
repl_emacs_keys.py.exp
repl_inspect.py
repl_inspect.py.exp
repl_micropyinspect
repl_micropyinspect.py
repl_micropyinspect.py.exp
repl_sys_ps1_ps2.py
repl_sys_ps1_ps2.py.exp
repl_words_move.py
repl_words_move.py.exp