aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-03-11 09:30:37 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-03-11 09:30:37 -0300
commit4039bf457db730caa9f3b3ceba391fa41b516def (patch)
tree8f291a0710390cb6885e126c56e30aa088d2f197
parent034de1fe73c24dcb75658b4c9ab16dd012ba3057 (diff)
downloadlua-4039bf457db730caa9f3b3ceba391fa41b516def.tar.gz
lua-4039bf457db730caa9f3b3ceba391fa41b516def.tar.bz2
lua-4039bf457db730caa9f3b3ceba391fa41b516def.zip
^ operator is defined by global `__pow'
-rw-r--r--lmathlib.c4
-rw-r--r--lvm.c7
2 files changed, 5 insertions, 6 deletions
diff --git a/lmathlib.c b/lmathlib.c
index b1a70959..a4fa618c 100644
--- a/lmathlib.c
+++ b/lmathlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmathlib.c,v 1.54 2002/12/20 10:26:33 roberto Exp roberto $ 2** $Id: lmathlib.c,v 1.55 2003/03/11 12:24:34 roberto Exp roberto $
3** Standard mathematical library 3** Standard mathematical library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -240,7 +240,7 @@ LUALIB_API int luaopen_math (lua_State *L) {
240 lua_settable(L, -3); 240 lua_settable(L, -3);
241 lua_pushliteral(L, "__pow"); 241 lua_pushliteral(L, "__pow");
242 lua_pushcfunction(L, math_pow); 242 lua_pushcfunction(L, math_pow);
243 lua_settable(L, LUA_REGISTRYINDEX); 243 lua_settable(L, LUA_GLOBALSINDEX);
244 return 1; 244 return 1;
245} 245}
246 246
diff --git a/lvm.c b/lvm.c
index a096ff37..bbdbea18 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.280 2003/03/06 19:37:42 roberto Exp roberto $ 2** $Id: lvm.c,v 1.281 2003/03/07 13:21:31 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -357,11 +357,10 @@ static void Arith (lua_State *L, StkId ra,
357 case TM_MUL: setnvalue(ra, nvalue(b) * nvalue(c)); break; 357 case TM_MUL: setnvalue(ra, nvalue(b) * nvalue(c)); break;
358 case TM_DIV: setnvalue(ra, nvalue(b) / nvalue(c)); break; 358 case TM_DIV: setnvalue(ra, nvalue(b) / nvalue(c)); break;
359 case TM_POW: { 359 case TM_POW: {
360 const TObject *f = luaH_getstr(hvalue(registry(L)), 360 const TObject *f = luaH_getstr(hvalue(gt(L)), G(L)->tmname[TM_POW]);
361 G(L)->tmname[TM_POW]);
362 ptrdiff_t res = savestack(L, ra); 361 ptrdiff_t res = savestack(L, ra);
363 if (!ttisfunction(f)) 362 if (!ttisfunction(f))
364 luaG_runerror(L, "`pow' (for `^' operator) is not a function"); 363 luaG_runerror(L, "`__pow' (`^' operator) is not a function");
365 callTMres(L, f, b, c); 364 callTMres(L, f, b, c);
366 ra = restorestack(L, res); /* previous call may change stack */ 365 ra = restorestack(L, res); /* previous call may change stack */
367 setobjs2s(ra, L->top); 366 setobjs2s(ra, L->top);