commit 4039bf457db730caa9f3b3ceba391fa41b516def
parent 034de1fe73c24dcb75658b4c9ab16dd012ba3057
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Tue, 11 Mar 2003 09:30:15 -0300
^ operator is defined by global `__pow'
Diffstat:
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/lmathlib.c b/lmathlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lmathlib.c,v 1.54 2002/12/20 10:26:33 roberto Exp roberto $
+** $Id: lmathlib.c,v 1.55 2003/03/11 12:24:34 roberto Exp roberto $
** Standard mathematical library
** See Copyright Notice in lua.h
*/
@@ -240,7 +240,7 @@ LUALIB_API int luaopen_math (lua_State *L) {
lua_settable(L, -3);
lua_pushliteral(L, "__pow");
lua_pushcfunction(L, math_pow);
- lua_settable(L, LUA_REGISTRYINDEX);
+ lua_settable(L, LUA_GLOBALSINDEX);
return 1;
}
diff --git a/lvm.c b/lvm.c
@@ -1,5 +1,5 @@
/*
-** $Id: lvm.c,v 1.280 2003/03/06 19:37:42 roberto Exp roberto $
+** $Id: lvm.c,v 1.281 2003/03/07 13:21:31 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -357,11 +357,10 @@ static void Arith (lua_State *L, StkId ra,
case TM_MUL: setnvalue(ra, nvalue(b) * nvalue(c)); break;
case TM_DIV: setnvalue(ra, nvalue(b) / nvalue(c)); break;
case TM_POW: {
- const TObject *f = luaH_getstr(hvalue(registry(L)),
- G(L)->tmname[TM_POW]);
+ const TObject *f = luaH_getstr(hvalue(gt(L)), G(L)->tmname[TM_POW]);
ptrdiff_t res = savestack(L, ra);
if (!ttisfunction(f))
- luaG_runerror(L, "`pow' (for `^' operator) is not a function");
+ luaG_runerror(L, "`__pow' (`^' operator) is not a function");
callTMres(L, f, b, c);
ra = restorestack(L, res); /* previous call may change stack */
setobjs2s(ra, L->top);