MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaO_rawarith

Function luaO_rawarith

third-party/lua-5.5.0/src/lobject.c:151–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149
150
151int luaO_rawarith (lua_State *L, int op, const TValue *p1, const TValue *p2,
152 TValue *res) {
153 switch (op) {
154 case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR:
155 case LUA_OPSHL: case LUA_OPSHR:
156 case LUA_OPBNOT: { /* operate only on integers */
157 lua_Integer i1; lua_Integer i2;
158 if (tointegerns(p1, &i1) && tointegerns(p2, &i2)) {
159 setivalue(res, intarith(L, op, i1, i2));
160 return 1;
161 }
162 else return 0; /* fail */
163 }
164 case LUA_OPDIV: case LUA_OPPOW: { /* operate only on floats */
165 lua_Number n1; lua_Number n2;
166 if (tonumberns(p1, n1) && tonumberns(p2, n2)) {
167 setfltvalue(res, numarith(L, op, n1, n2));
168 return 1;
169 }
170 else return 0; /* fail */
171 }
172 default: { /* other operations */
173 lua_Number n1; lua_Number n2;
174 if (ttisinteger(p1) && ttisinteger(p2)) {
175 setivalue(res, intarith(L, op, ivalue(p1), ivalue(p2)));
176 return 1;
177 }
178 else if (tonumberns(p1, n1) && tonumberns(p2, n2)) {
179 setfltvalue(res, numarith(L, op, n1, n2));
180 return 1;
181 }
182 else return 0; /* fail */
183 }
184 }
185}
186
187
188void luaO_arith (lua_State *L, int op, const TValue *p1, const TValue *p2,

Callers 2

luaO_arithFunction · 0.70
constfoldingFunction · 0.70

Calls 2

intarithFunction · 0.70
numarithFunction · 0.70

Tested by

no test coverage detected