Divide by zero, modulo by zero in Lua 5.1

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Divide by zero, modulo by zero in Lua 5.1

John D. Ramsdell-2
I'm trying to make it so when one changes LUA_NUMBER from double to
long, the interpreter handles divide by zero and modulo by zero
gracefully.  The macros luai_numdiv and luai_nummod are used in the VM
and the constant folding function.  In one context, struct lua_State
*L is defined, but not in the other.  This variable is used by the
error reporting routines, such as, luaG_runerror.  At this point, all
I can think to do is to introduce two macros for each operation, one
that makes use of L, which is available in the VM, and the other which
makes no provision for the second argument being zero.  Not very
satisfying.  Better ideas would be greatly appreciated.

John