summaryrefslogtreecommitdiff
path: root/ltm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-12-23 16:19:57 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-12-23 16:19:57 -0200
commitb1b0c219f5255a0cd0921ebc0a77a81f99b72532 (patch)
tree7cb4d9cbbdb1309b94794eb75694b02f2b08f75a /ltm.c
parentbe3212de781786c0a68365dee1d3510407b5c325 (diff)
downloadlua-b1b0c219f5255a0cd0921ebc0a77a81f99b72532.tar.gz
lua-b1b0c219f5255a0cd0921ebc0a77a81f99b72532.tar.bz2
lua-b1b0c219f5255a0cd0921ebc0a77a81f99b72532.zip
new ttypes to distinguish between C closures and Lua closures.
Diffstat (limited to 'ltm.c')
-rw-r--r--ltm.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/ltm.c b/ltm.c
index 63d9f578..615cdfe4 100644
--- a/ltm.c
+++ b/ltm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltm.c,v 1.28 1999/10/04 17:51:04 roberto Exp roberto $ 2** $Id: ltm.c,v 1.29 1999/11/22 13:12:07 roberto Exp roberto $
3** Tag methods 3** Tag methods
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -42,7 +42,7 @@ static const char luaT_validevents[NUM_TAGS][IM_N] = {
42{1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1}, /* LUA_T_NUMBER */ 42{1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1}, /* LUA_T_NUMBER */
43{1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, /* LUA_T_STRING */ 43{1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, /* LUA_T_STRING */
44{0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1}, /* LUA_T_ARRAY */ 44{0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1}, /* LUA_T_ARRAY */
45{1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, /* LUA_T_PROTO */ 45{1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, /* LUA_T_LPROTO */
46{1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, /* LUA_T_CPROTO */ 46{1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, /* LUA_T_CPROTO */
47{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} /* LUA_T_NIL */ 47{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} /* LUA_T_NIL */
48}; 48};
@@ -104,23 +104,21 @@ int lua_copytagmethods (lua_State *L, int tagto, int tagfrom) {
104 104
105 105
106int luaT_effectivetag (const TObject *o) { 106int luaT_effectivetag (const TObject *o) {
107 static const int realtag[] = { /* ORDER LUA_T */
108 LUA_T_USERDATA, LUA_T_NUMBER, LUA_T_STRING, LUA_T_ARRAY,
109 LUA_T_LPROTO, LUA_T_CPROTO, LUA_T_NIL,
110 LUA_T_LPROTO, LUA_T_CPROTO, /* LUA_T_LCLOSURE, LUA_T_CCLOSURE */
111 LUA_T_LPROTO, LUA_T_CPROTO, /* LUA_T_LCLMARK, LUA_T_CCLMARK */
112 LUA_T_LPROTO, LUA_T_CPROTO /* LUA_T_LMARK, LUA_T_CMARK */
113 };
107 int t; 114 int t;
108 switch (t = ttype(o)) { 115 switch (t = ttype(o)) {
109 case LUA_T_ARRAY:
110 return o->value.a->htag;
111 case LUA_T_USERDATA: { 116 case LUA_T_USERDATA: {
112 int tag = o->value.ts->u.d.tag; 117 int tag = o->value.ts->u.d.tag;
113 return (tag >= 0) ? LUA_T_USERDATA : tag; 118 return (tag >= 0) ? LUA_T_USERDATA : tag; /* deprecated test */
114 } 119 }
115 case LUA_T_CLOSURE: 120 case LUA_T_ARRAY: return o->value.a->htag;
116 return o->value.cl->consts[0].ttype; 121 default: return realtag[-t];
117#ifdef DEBUG
118 case LUA_T_PMARK: case LUA_T_CMARK:
119 case LUA_T_CLMARK: case LUA_T_LINE:
120 LUA_INTERNALERROR(L, "invalid type");
121#endif
122 default:
123 return t;
124 } 122 }
125} 123}
126 124