aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1994-11-18 17:46:21 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1994-11-18 17:46:21 -0200
commit333a4f13d084b99c3729414c9c2d66222a8a1fc7 (patch)
treef5ecc29ad2a9c3a86250708b30a9afcefae5cbe4
parent73664eb7399655e7cf65132c91a1aa16191a1667 (diff)
downloadlua-333a4f13d084b99c3729414c9c2d66222a8a1fc7.tar.gz
lua-333a4f13d084b99c3729414c9c2d66222a8a1fc7.tar.bz2
lua-333a4f13d084b99c3729414c9c2d66222a8a1fc7.zip
lua_lock receives its parameter via stack
-rw-r--r--fallback.c10
-rw-r--r--fallback.h3
-rw-r--r--mathlib.c4
3 files changed, 9 insertions, 8 deletions
diff --git a/fallback.c b/fallback.c
index 5690be64..f99fe63d 100644
--- a/fallback.c
+++ b/fallback.c
@@ -3,7 +3,7 @@
3** TecCGraf - PUC-Rio 3** TecCGraf - PUC-Rio
4*/ 4*/
5 5
6char *rcs_fallback="$Id: fallback.c,v 1.5 1994/11/10 17:36:54 roberto Exp roberto $"; 6char *rcs_fallback="$Id: fallback.c,v 1.6 1994/11/16 17:38:08 roberto Exp roberto $";
7 7
8#include <stdio.h> 8#include <stdio.h>
9 9
@@ -112,16 +112,16 @@ static void GDFB (void) { }
112static Object *lockArray = NULL; 112static Object *lockArray = NULL;
113static int lockSize = 0; 113static int lockSize = 0;
114 114
115int lua_lock (lua_Object object) 115int luaI_lock (Object *object)
116{ 116{
117 int i; 117 int i;
118 int oldSize; 118 int oldSize;
119 if (lua_isnil(object)) 119 if (tag(object) == LUA_T_NIL)
120 return -1; 120 return -1;
121 for (i=0; i<lockSize; i++) 121 for (i=0; i<lockSize; i++)
122 if (tag(&lockArray[i]) == LUA_T_NIL) 122 if (tag(&lockArray[i]) == LUA_T_NIL)
123 { 123 {
124 lockArray[i] = *luaI_Address(object); 124 lockArray[i] = *object;
125 return i; 125 return i;
126 } 126 }
127 /* no more empty spaces */ 127 /* no more empty spaces */
@@ -138,7 +138,7 @@ int lua_lock (lua_Object object)
138 } 138 }
139 for (i=oldSize; i<lockSize; i++) 139 for (i=oldSize; i<lockSize; i++)
140 tag(&lockArray[i]) = LUA_T_NIL; 140 tag(&lockArray[i]) = LUA_T_NIL;
141 lockArray[oldSize] = *luaI_Address(object); 141 lockArray[oldSize] = *object;
142 return oldSize; 142 return oldSize;
143} 143}
144 144
diff --git a/fallback.h b/fallback.h
index bde3c5ce..d447ce04 100644
--- a/fallback.h
+++ b/fallback.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: fallback.h,v 1.3 1994/11/10 17:11:52 roberto Exp roberto $ 2** $Id: fallback.h,v 1.4 1994/11/10 17:36:54 roberto Exp roberto $
3*/ 3*/
4 4
5#ifndef fallback_h 5#ifndef fallback_h
@@ -23,6 +23,7 @@ extern struct FB {
23#define FB_GC 8 23#define FB_GC 8
24 24
25void luaI_setfallback (void); 25void luaI_setfallback (void);
26int luaI_lock (Object *object);
26Object *luaI_getlocked (int ref); 27Object *luaI_getlocked (int ref);
27void luaI_travlock (void (*fn)(Object *)); 28void luaI_travlock (void (*fn)(Object *));
28 29
diff --git a/mathlib.c b/mathlib.c
index f0e84b98..4042834d 100644
--- a/mathlib.c
+++ b/mathlib.c
@@ -3,7 +3,7 @@
3** Mathematics library to LUA 3** Mathematics library to LUA
4*/ 4*/
5 5
6char *rcs_mathlib="$Id: mathlib.c,v 1.4 1994/10/11 13:06:47 celes Exp roberto $"; 6char *rcs_mathlib="$Id: mathlib.c,v 1.5 1994/11/17 19:43:34 roberto Exp roberto $";
7 7
8#include <stdio.h> /* NULL */ 8#include <stdio.h> /* NULL */
9#include <math.h> 9#include <math.h>
@@ -310,5 +310,5 @@ void mathlib_open (void)
310 lua_register ("exp", math_exp); 310 lua_register ("exp", math_exp);
311 lua_register ("deg", math_deg); 311 lua_register ("deg", math_deg);
312 lua_register ("rad", math_rad); 312 lua_register ("rad", math_rad);
313 old_pow = lua_lock(lua_setfallback("arith", math_pow)); 313 old_pow = lua_lockobject(lua_setfallback("arith", math_pow));
314} 314}