aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-10-03 11:27:44 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-10-03 11:27:44 -0300
commitd68209e822c21d3678cc53f1e02ba1c9dd26e23e (patch)
tree76feb02bb882d8b40fd3b969017b811e39389dff
parent1088cde03c5551bab90e211e979b11278d666cd5 (diff)
downloadlua-d68209e822c21d3678cc53f1e02ba1c9dd26e23e.tar.gz
lua-d68209e822c21d3678cc53f1e02ba1c9dd26e23e.tar.bz2
lua-d68209e822c21d3678cc53f1e02ba1c9dd26e23e.zip
details.
-rw-r--r--lapi.c12
-rw-r--r--ltm.c15
-rw-r--r--ltm.h6
-rw-r--r--lvm.c4
4 files changed, 23 insertions, 14 deletions
diff --git a/lapi.c b/lapi.c
index 48488d3a..7715c5a2 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.102 2000/10/02 14:47:43 roberto Exp roberto $ 2** $Id: lapi.c,v 1.103 2000/10/02 20:10:55 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -141,10 +141,14 @@ int lua_isstring (lua_State *L, int index) {
141 return (t == LUA_TSTRING || t == LUA_TNUMBER); 141 return (t == LUA_TSTRING || t == LUA_TNUMBER);
142} 142}
143 143
144
145static int auxtag (const TObject *o) {
146return ((ttype(o) == TAG_USERDATA) ? tsvalue(o)->u.d.tag :
147 (ttype(o) == TAG_TABLE) ? hvalue(o)->htag : (int)ttype(o));
148}
149
144int lua_tag (lua_State *L, int index) { 150int lua_tag (lua_State *L, int index) {
145 btest(L, index, 151 btest(L, index, auxtag(o), LUA_NOTAG);
146 ((ttype(o) == TAG_USERDATA) ? tsvalue(o)->u.d.tag :
147 luaT_effectivetag(L, o)), LUA_NOTAG);
148} 152}
149 153
150int lua_equal (lua_State *L, int index1, int index2) { 154int lua_equal (lua_State *L, int index1, int index2) {
diff --git a/ltm.c b/ltm.c
index 524b4fb2..b009e8b4 100644
--- a/ltm.c
+++ b/ltm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltm.c,v 1.50 2000/09/29 12:42:13 roberto Exp roberto $ 2** $Id: ltm.c,v 1.51 2000/10/02 20:10:55 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*/
@@ -117,15 +117,20 @@ int lua_copytagmethods (lua_State *L, int tagto, int tagfrom) {
117} 117}
118 118
119 119
120int luaT_effectivetag (lua_State *L, const TObject *o) { 120const TObject *luaT_gettagmethods (lua_State *L, const TObject *o) {
121 lua_Tag t = ttype(o); 121 lua_Tag t = ttype(o);
122 switch (t) { 122 switch (t) {
123 case TAG_USERDATA: { 123 case TAG_USERDATA: {
124 int tag = tsvalue(o)->u.d.tag; 124 int tag = tsvalue(o)->u.d.tag;
125 return (tag > L->last_tag) ? TAG_USERDATA : tag; /* deprecated test */ 125 if (tag > L->last_tag)
126 return L->IMtable[TAG_USERDATA].int_method;
127 else
128 return L->IMtable[tag].int_method;
126 } 129 }
127 case TAG_TABLE: return hvalue(o)->htag; 130 case TAG_TABLE:
128 default: return t; 131 return L->IMtable[hvalue(o)->htag].int_method;
132 default:
133 return L->IMtable[(int)t].int_method;;
129 } 134 }
130} 135}
131 136
diff --git a/ltm.h b/ltm.h
index 2d15b3ef..22974dc5 100644
--- a/ltm.h
+++ b/ltm.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltm.h,v 1.14 2000/08/07 20:21:34 roberto Exp roberto $ 2** $Id: ltm.h,v 1.15 2000/09/05 19:33:32 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,14 +42,14 @@ struct IM {
42 42
43 43
44#define luaT_getim(L,tag,event) (&L->IMtable[tag].int_method[event]) 44#define luaT_getim(L,tag,event) (&L->IMtable[tag].int_method[event])
45#define luaT_getimbyObj(L,o,e) (luaT_getim(L, luaT_effectivetag(L, o),(e))) 45#define luaT_getimbyObj(L,o,e) (&luaT_gettagmethods((L),(o))[e])
46 46
47extern const char *const luaT_eventname[]; 47extern const char *const luaT_eventname[];
48 48
49 49
50void luaT_init (lua_State *L); 50void luaT_init (lua_State *L);
51void luaT_realtag (lua_State *L, int tag); 51void luaT_realtag (lua_State *L, int tag);
52int luaT_effectivetag (lua_State *L, const TObject *o); 52const TObject *luaT_gettagmethods (lua_State *L, const TObject *o);
53int luaT_validevent (int t, int e); /* used by compatibility module */ 53int luaT_validevent (int t, int e); /* used by compatibility module */
54 54
55 55
diff --git a/lvm.c b/lvm.c
index f405b802..53bc7821 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.139 2000/10/02 20:10:55 roberto Exp roberto $ 2** $Id: lvm.c,v 1.140 2000/10/03 14:03:21 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*/
@@ -174,7 +174,7 @@ void luaV_settable (lua_State *L, StkId t, StkId key) {
174 174
175const TObject *luaV_getglobal (lua_State *L, TString *s) { 175const TObject *luaV_getglobal (lua_State *L, TString *s) {
176 const TObject *value = luaH_getstr(L->gt, s); 176 const TObject *value = luaH_getstr(L->gt, s);
177 TObject *im = luaT_getimbyObj(L, value, IM_GETGLOBAL); 177 const TObject *im = luaT_getimbyObj(L, value, IM_GETGLOBAL);
178 if (ttype(im) == TAG_NIL) /* is there a tag method? */ 178 if (ttype(im) == TAG_NIL) /* is there a tag method? */
179 return value; /* default behavior */ 179 return value; /* default behavior */
180 else { /* tag method */ 180 else { /* tag method */