summaryrefslogtreecommitdiff
path: root/opcode.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-04-22 15:00:37 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-04-22 15:00:37 -0300
commit0ef5cf22891c9d34a88ccc5d89eb0ed82b004471 (patch)
tree1a095acefa978d5a41f32ff7d0fef58a642aa66c /opcode.c
parentfed9408ab51a4be5ff84450ad47d1e0cdaed97bc (diff)
downloadlua-github-0ef5cf22891c9d34a88ccc5d89eb0ed82b004471.tar.gz
lock mechanism seperseded by the REFERENCE mechanism.
Diffstat (limited to 'opcode.c')
-rw-r--r--opcode.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/opcode.c b/opcode.c
index ffa1c844..c2437a56 100644
--- a/opcode.c
+++ b/opcode.c
@@ -3,7 +3,7 @@
** TecCGraf - PUC-Rio
*/
-char *rcs_opcode="$Id: opcode.c,v 3.65 1996/03/21 18:55:02 roberto Exp roberto $";
+char *rcs_opcode="$Id: opcode.c,v 3.66 1996/03/22 19:12:15 roberto Exp roberto $";
#include <setjmp.h>
#include <stdio.h>
@@ -717,27 +717,31 @@ void *lua_getuserdata (lua_Object object)
}
-lua_Object lua_getlocked (int ref)
+lua_Object lua_getref (lua_Reference ref)
{
- adjustC(0);
- *top = *luaI_getlocked(ref);
- incr_top;
- CBase++; /* incorporate object in the stack */
- return Ref(top-1);
+ Object *o = luaI_getref(ref);
+ if (o == NULL)
+ return LUA_NOOBJECT;
+ adjustC(0);
+ luaI_pushobject(o);
+ CBase++; /* incorporate object in the stack */
+ return Ref(top-1);
}
-void lua_pushlocked (int ref)
+void lua_pushref (lua_Reference ref)
{
- *top = *luaI_getlocked(ref);
- incr_top;
+ Object *o = luaI_getref(ref);
+ if (o == NULL)
+ lua_error("access to invalid (possibly garbage collected) reference");
+ luaI_pushobject(o);
}
-int lua_lock (void)
+lua_Reference lua_ref (int lock)
{
adjustC(1);
- return luaI_lock(--top);
+ return luaI_ref(--top, lock);
}
@@ -812,27 +816,29 @@ void lua_pushcfunction (lua_CFunction fn)
*/
void lua_pushusertag (void *u, int tag)
{
- if (tag < LUA_T_USERDATA) return;
+ if (tag < LUA_T_USERDATA)
+ lua_error("invalid tag in `lua_pushusertag'");
tag(top) = tag; uvalue(top) = u;
incr_top;
}
/*
-** Push a lua_Object to stack.
+** Push an object on the stack.
*/
-void lua_pushobject (lua_Object o)
+void luaI_pushobject (Object *o)
{
- *top = *Address(o);
+ *top = *o;
incr_top;
}
/*
-** Push an object on the stack.
+** Push a lua_Object on stack.
*/
-void luaI_pushobject (Object *o)
+void lua_pushobject (lua_Object o)
{
- *top = *o;
- incr_top;
+ if (o == LUA_NOOBJECT)
+ lua_error("attempt to push a NOOBJECT");
+ luaI_pushobject(Address(o));
}
int lua_type (lua_Object o)