circuitpython/py
Damien George bdbe8c9ae2 py: Make UNARY_OP_NOT a first-class op, to agree with Py not semantics.
Fixes #1684 and makes "not" match Python semantics.  The code is also
simplified (the separate MP_BC_NOT opcode is removed) and the patch saves
68 bytes for bare-arm/ and 52 bytes for minimal/.

Previously "not x" was implemented as !mp_unary_op(x, MP_UNARY_OP_BOOL),
so any given object only needs to implement MP_UNARY_OP_BOOL (and the VM
had a special opcode to do the ! bit).

With this patch "not x" is implemented as mp_unary_op(x, MP_UNARY_OP_NOT),
but this operation is caught at the start of mp_unary_op and dispatched as
!mp_obj_is_true(x).  mp_obj_is_true has special logic to test for
truthness, and is the correct way to handle the not operation.
2015-12-10 22:19:48 +00:00
..
argcheck.c py: Use mp_not_implemented consistently for not implemented features. 2015-09-03 23:14:06 +01:00
asmarm.c py: Implement native multiply operation in viper emitter. 2015-06-04 14:00:29 +00:00
asmarm.h py: Implement native multiply operation in viper emitter. 2015-06-04 14:00:29 +00:00
asmthumb.c py/asmthumb: Allow to compile with -Wsign-compare and -Wunused-parameter. 2015-11-09 14:11:21 +00:00
asmthumb.h py: Add lsl/lsr/asr opcode support to inline Thumb2 assembler. 2015-10-19 14:26:19 +01:00
asmx64.c py: Implement ptr32 load and store in viper emitter. 2015-10-13 00:50:17 +01:00
asmx64.h py: Implement ptr32 load and store in viper emitter. 2015-10-13 00:50:17 +01:00
asmx86.c py/asmx86: Fix function definition to use int32_t instead of int. 2015-11-27 14:06:53 +00:00
asmx86.h py: Implement native multiply operation in viper emitter. 2015-06-04 14:00:29 +00:00
bc0.h py: Make UNARY_OP_NOT a first-class op, to agree with Py not semantics. 2015-12-10 22:19:48 +00:00
bc.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
bc.h py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
binary.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
binary.h py/binary: Make return type of mp_binary_get_size size_t instead of int. 2015-05-17 18:12:19 +01:00
builtin.h extmod: Move fsusermount.c from stmhal for cross-port reuse. 2015-11-25 13:19:36 +02:00
builtinevex.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
builtinimport.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
compile.c py: Don't try to optimise for+range when args are not simple expressions. 2015-12-08 21:05:14 +00:00
compile.h py/compile: Add mp_compile_to_raw_code() to return raw code object. 2015-11-20 12:30:37 +00:00
emit.h py/emit: Change type of arg of load_const_obj from void* to mp_obj_t. 2015-11-29 14:25:04 +00:00
emitbc.c py: Make UNARY_OP_NOT a first-class op, to agree with Py not semantics. 2015-12-10 22:19:48 +00:00
emitcommon.c unix-cpy: Remove unix-cpy. It's no longer needed. 2015-08-17 12:51:26 +01:00
emitglue.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
emitglue.h py/emitglue: Add mp_raw_code_load_mem to load raw-code from memory. 2015-11-20 12:44:20 +00:00
emitinlinethumb.c py/emitinlinethumb: Add support for MRS instruction. 2015-12-10 17:32:54 +00:00
emitnative.c py: Make UNARY_OP_NOT a first-class op, to agree with Py not semantics. 2015-12-10 22:19:48 +00:00
formatfloat.c py/formatfloat: Handle calculation of integer digit for %f format properly. 2015-11-22 20:05:08 +02:00
formatfloat.h py: Implement mp_format_float for doubles and use where appropriate 2015-05-17 21:47:11 +01:00
frozenmod.c frozenmod: Include header with function prototypes. 2015-05-31 23:02:04 +03:00
frozenmod.h py: Implement very simple frozen modules support. 2015-01-20 11:52:12 +02:00
gc.c py/gc: Make GC block size be configurable. 2015-12-03 01:40:52 +02:00
gc.h py/gc: Move away from using mp_uint_t, instead use uintptr_t and size_t. 2015-11-29 14:25:04 +00:00
grammar.h py/compile: Do proper checking of * and ** in function definition. 2015-11-23 16:50:42 +00:00
lexer.c py/lexer: Properly classify floats that look like hex numbers. 2015-09-07 17:33:44 +01:00
lexer.h unix: Allow to cat a script into stdin from the command line. 2015-06-04 23:42:45 +01:00
lexerstr.c py: Use m_{new,renew,del} consistently. 2015-02-27 09:34:51 +00:00
lexerunix.c unix: Allow to cat a script into stdin from the command line. 2015-06-04 23:42:45 +01:00
makeqstrdata.py py/makeqstrdata.py: Catch and report case of empty input file. 2015-10-11 11:09:57 +03:00
makeversionhdr.py py/makeversionhdr.py: Work with backslashes in paths. 2015-10-30 11:34:53 +03:00
malloc.c py: Improve allocation policy of qstr data. 2015-07-14 22:56:32 +01:00
map.c py: Use MP_OBJ_NULL instead of NULL when appropriate. 2015-11-20 14:09:20 +00:00
misc.h py/misc.h: Include stdint.h only once (unconditionally at the top). 2015-12-08 02:23:58 +02:00
mkenv.mk py: Allow to to build MicroPython as a static library. 2015-10-12 15:32:06 +03:00
mkrules.mk py/mkrules.mk: Don't pass COPT to linker. 2015-12-10 00:49:25 +02:00
modarray.c py: Add MP_ROM_* macros and mp_rom_* types and use them. 2015-11-29 14:25:04 +00:00
modbuiltins.c py: Add min/max "default" keyword argument 2015-12-07 18:56:25 +02:00
modcmath.c py: Make it easy to build without MICROPY_PY_BUILTINS_COMPLEX. 2015-12-07 00:19:24 +02:00
modcollections.c py: Add MP_ROM_* macros and mp_rom_* types and use them. 2015-11-29 14:25:04 +00:00
modgc.c py: Add MP_ROM_* macros and mp_rom_* types and use them. 2015-11-29 14:25:04 +00:00
modio.c py: Add MP_ROM_* macros and mp_rom_* types and use them. 2015-11-29 14:25:04 +00:00
modmath.c py: Add MP_ROM_* macros and mp_rom_* types and use them. 2015-11-29 14:25:04 +00:00
modmicropython.c py: Add MP_ROM_* macros and mp_rom_* types and use them. 2015-11-29 14:25:04 +00:00
modstruct.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
modsys.c py/modsys: Use MP_ROM_PTR() initializer for sys.modules. 2015-12-05 00:27:04 +02:00
mpconfig.h py: Add MICROPY_PY_BUILTINS_MIN_MAX, disable for minimal ports. 2015-12-07 18:56:25 +02:00
mphal.h all: Add py/mphal.h and use it in all ports. 2015-10-31 19:14:30 +03:00
mpprint.c py/mpprint: Printing of doubles is now supported (by uPy own routine). 2015-12-02 14:21:36 +02:00
mpprint.h py: Change mp_print_strn_t func type to use size_t for the str length. 2015-11-29 14:25:04 +00:00
mpstate.c py: Put all global state together in state structures. 2015-01-07 20:33:00 +00:00
mpstate.h py/modsys: Implement sys.modules. 2015-12-05 00:13:29 +02:00
mpz.c py/mpz: Normalize (remove leading zeros) xor operation result. 2015-11-22 22:03:18 +02:00
mpz.h windows/py: Support 64bit mingw-w64 builds 2015-11-24 17:34:14 +02:00
nativeglue.c py: Rename MP_BOOL() to mp_obj_new_bool() for consistency in naming. 2015-10-11 15:18:15 +03:00
nlr.h py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
nlrsetjmp.c py: Put all global state together in state structures. 2015-01-07 20:33:00 +00:00
nlrthumb.S py/nlrthumb: Make compatible with Cortex-M0 (ARMv6M instr set). 2015-10-20 13:26:34 +01:00
nlrx64.S nlr: Use single preprocessor symbol to check if building on Windows 2015-11-24 17:34:14 +02:00
nlrx86.S nlr: Use single preprocessor symbol to check if building on Windows 2015-11-24 17:34:14 +02:00
nlrxtensa.S py: Put all global state together in state structures. 2015-01-07 20:33:00 +00:00
obj.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
obj.h py: Add support for 64-bit NaN-boxing object model, on 32-bit machine. 2015-11-29 14:25:36 +00:00
objarray.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objattrtuple.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objbool.c py: Make UNARY_OP_NOT a first-class op, to agree with Py not semantics. 2015-12-10 22:19:48 +00:00
objboundmeth.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objcell.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objclosure.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objcomplex.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objdict.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objenumerate.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objexcept.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objexcept.h py: Fix adding of traceback so that it appends to existing info. 2015-02-27 00:36:39 +00:00
objfilter.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objfloat.c py: Add support for 64-bit NaN-boxing object model, on 32-bit machine. 2015-11-29 14:25:36 +00:00
objfun.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objfun.h py: Add constant table to bytecode. 2015-11-13 12:49:18 +00:00
objgenerator.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objgenerator.h py: Move to guarded includes, everywhere in py/ core. 2015-01-01 20:32:09 +00:00
objgetitemiter.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objint_longlong.c py/objint_longlong: Instead of assert, throw OverflowError. 2015-11-09 01:34:56 +02:00
objint_mpz.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objint.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objint.h py: Support conversion of bignum to bytes. 2015-04-25 23:16:39 +01:00
objlist.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objlist.h py: Fix adding of traceback so that it appends to existing info. 2015-02-27 00:36:39 +00:00
objmap.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objmodule.c py: Make it easy to build without MICROPY_PY_BUILTINS_COMPLEX. 2015-12-07 00:19:24 +02:00
objmodule.h py: Move to guarded includes, everywhere in py/ core. 2015-01-01 20:32:09 +00:00
objnamedtuple.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objnone.c py: Convert hash API to use MP_UNARY_OP_HASH instead of ad-hoc function. 2015-05-12 22:46:02 +01:00
objobject.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objproperty.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objrange.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objreversed.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objset.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objsingleton.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objslice.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objstr.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objstr.h py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objstringio.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objstrunicode.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objtuple.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objtuple.h py: Add MP_ROM_* macros and mp_rom_* types and use them. 2015-11-29 14:25:04 +00:00
objtype.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
objtype.h py: Check that arg to object.__new__ is a user-defined type. 2015-05-04 11:08:40 +01:00
objzip.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
opmethods.c py: Move to guarded includes, everywhere in py/ core. 2015-01-01 20:32:09 +00:00
parse.c py: Add support for 64-bit NaN-boxing object model, on 32-bit machine. 2015-11-29 14:25:36 +00:00
parse.h py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
parsenum.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
parsenum.h py: Parse big-int/float/imag constants directly in parser. 2015-02-08 01:57:40 +00:00
parsenumbase.c py: Parse big-int/float/imag constants directly in parser. 2015-02-08 01:57:40 +00:00
parsenumbase.h py: Move to guarded includes, everywhere in py/ core. 2015-01-01 20:32:09 +00:00
py.mk extmod: Move fsusermount.c from stmhal for cross-port reuse. 2015-11-25 13:19:36 +02:00
qstr.c py: Change qstr_* functions to use size_t as the type for str len arg. 2015-11-29 14:25:04 +00:00
qstr.h py: Change qstr_* functions to use size_t as the type for str len arg. 2015-11-29 14:25:04 +00:00
qstrdefs.h py: Add min/max "default" keyword argument 2015-12-07 18:56:25 +02:00
repl.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
repl.h py, readline: Add tab autocompletion for REPL. 2015-04-29 00:46:26 +01:00
runtime0.h py: Make UNARY_OP_NOT a first-class op, to agree with Py not semantics. 2015-12-10 22:19:48 +00:00
runtime.c py: Make UNARY_OP_NOT a first-class op, to agree with Py not semantics. 2015-12-10 22:19:48 +00:00
runtime.h py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
scope.c unix-cpy: Remove unix-cpy. It's no longer needed. 2015-08-17 12:51:26 +01:00
scope.h py: Put all bytecode state (arg count, etc) in bytecode. 2015-11-13 12:49:18 +00:00
sequence.c py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. 2015-11-29 14:25:35 +00:00
showbc.c py: Make UNARY_OP_NOT a first-class op, to agree with Py not semantics. 2015-12-10 22:19:48 +00:00
smallint.c py: Move to guarded includes, everywhere in py/ core. 2015-01-01 20:32:09 +00:00
smallint.h py: Add support for 64-bit NaN-boxing object model, on 32-bit machine. 2015-11-29 14:25:36 +00:00
stackctrl.c vm: Support strict stackless mode, with proper exception reporting. 2015-04-03 00:26:47 +03:00
stackctrl.h py: Move to guarded includes, everywhere in py/ core. 2015-01-01 20:32:09 +00:00
stream.c py: Add mp_get_stream_raise to factor out check for stream methods. 2015-12-09 18:47:43 +00:00
stream.h py: Add mp_get_stream_raise to factor out check for stream methods. 2015-12-09 18:47:43 +00:00
unicode.c py: Minor improvement to unichar_isxdigit 2015-05-20 09:31:22 +01:00
unicode.h py: Move to guarded includes, everywhere in py/ core. 2015-01-01 20:32:09 +00:00
vm.c py: Make UNARY_OP_NOT a first-class op, to agree with Py not semantics. 2015-12-10 22:19:48 +00:00
vmentrytable.h py: Make UNARY_OP_NOT a first-class op, to agree with Py not semantics. 2015-12-10 22:19:48 +00:00
vstr.c py: Prevent many extra vstr allocations. 2015-07-06 17:29:27 +01:00
warning.c py: Convert occurrences of non-debug printf to mp_printf. 2015-04-16 14:30:16 +00:00