MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / validop

Function validop

libraries/AP_Scripting/lua/src/lcode.c:967–978  ·  view source on GitHub ↗

** Return false if folding can raise an error. ** Bitwise operations need operands convertible to integers; division ** operations cannot have 0 as divisor. */

Source from the content-addressed store, hash-verified

965** operations cannot have 0 as divisor.
966*/
967static int validop (int op, TValue *v1, TValue *v2) {
968 switch (op) {
969 case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR:
970 case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */
971 lua_Integer i;
972 return (tointeger(v1, &i) && tointeger(v2, &i));
973 }
974 case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */
975 return (nvalue(v2) != 0);
976 default: return 1; /* everything else is valid */
977 }
978}
979
980
981/*

Callers 1

constfoldingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected