MCPcopy Create free account
hub / github.com/Tencent/sluaunreal / validop

Function validop

Plugins/slua_unreal/External/lua/lcode.cpp:958–969  ·  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

956** operations cannot have 0 as divisor.
957*/
958static int validop (int op, TValue *v1, TValue *v2) {
959 switch (op) {
960 case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR:
961 case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */
962 lua_Integer i;
963 return (tointeger(v1, &i) && tointeger(v2, &i));
964 }
965 case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */
966 return (nvalue(v2) != 0);
967 default: return 1; /* everything else is valid */
968 }
969}
970
971
972/*

Callers 1

constfoldingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected