diff options
Diffstat (limited to 'ltm.c')
-rw-r--r-- | ltm.c | 38 |
1 files changed, 17 insertions, 21 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltm.c,v 1.6 1997/11/04 15:27:53 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 1.7 1997/11/10 17:47:01 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 | */ |
@@ -9,9 +9,9 @@ | |||
9 | #include <string.h> | 9 | #include <string.h> |
10 | 10 | ||
11 | #include "lauxlib.h" | 11 | #include "lauxlib.h" |
12 | #include "ldo.h" | ||
13 | #include "lmem.h" | 12 | #include "lmem.h" |
14 | #include "lobject.h" | 13 | #include "lobject.h" |
14 | #include "lstate.h" | ||
15 | #include "ltm.h" | 15 | #include "ltm.h" |
16 | 16 | ||
17 | 17 | ||
@@ -31,10 +31,6 @@ static int luaI_checkevent (char *name, char *list[]) | |||
31 | } | 31 | } |
32 | 32 | ||
33 | 33 | ||
34 | struct IM *luaT_IMtable; | ||
35 | static int IMtable_size; | ||
36 | static int last_tag; | ||
37 | |||
38 | 34 | ||
39 | /* events in LUA_T_NIL are all allowed, since this is used as a | 35 | /* events in LUA_T_NIL are all allowed, since this is used as a |
40 | * 'placeholder' for "default" fallbacks | 36 | * 'placeholder' for "default" fallbacks |
@@ -67,34 +63,34 @@ static void init_entry (int tag) | |||
67 | void luaT_init (void) | 63 | void luaT_init (void) |
68 | { | 64 | { |
69 | int t; | 65 | int t; |
70 | IMtable_size = NUM_TAGS*2; | 66 | L->IMtable_size = NUM_TAGS*2; |
71 | last_tag = -(NUM_TAGS-1); | 67 | L->last_tag = -(NUM_TAGS-1); |
72 | luaT_IMtable = luaM_newvector(IMtable_size, struct IM); | 68 | L->IMtable = luaM_newvector(L->IMtable_size, struct IM); |
73 | for (t=last_tag; t<=0; t++) | 69 | for (t=L->last_tag; t<=0; t++) |
74 | init_entry(t); | 70 | init_entry(t); |
75 | } | 71 | } |
76 | 72 | ||
77 | 73 | ||
78 | int lua_newtag (void) | 74 | int lua_newtag (void) |
79 | { | 75 | { |
80 | --last_tag; | 76 | --L->last_tag; |
81 | if ((-last_tag) >= IMtable_size) | 77 | if ((-L->last_tag) >= L->IMtable_size) |
82 | IMtable_size = luaM_growvector(&luaT_IMtable, IMtable_size, | 78 | L->IMtable_size = luaM_growvector(&L->IMtable, L->IMtable_size, |
83 | struct IM, memEM, MAX_INT); | 79 | struct IM, memEM, MAX_INT); |
84 | init_entry(last_tag); | 80 | init_entry(L->last_tag); |
85 | return last_tag; | 81 | return L->last_tag; |
86 | } | 82 | } |
87 | 83 | ||
88 | 84 | ||
89 | static void checktag (int tag) | 85 | static void checktag (int tag) |
90 | { | 86 | { |
91 | if (!(last_tag <= tag && tag <= 0)) | 87 | if (!(L->last_tag <= tag && tag <= 0)) |
92 | luaL_verror("%d is not a valid tag", tag); | 88 | luaL_verror("%d is not a valid tag", tag); |
93 | } | 89 | } |
94 | 90 | ||
95 | void luaT_realtag (int tag) | 91 | void luaT_realtag (int tag) |
96 | { | 92 | { |
97 | if (!(last_tag <= tag && tag < LUA_T_NIL)) | 93 | if (!(L->last_tag <= tag && tag < LUA_T_NIL)) |
98 | luaL_verror("tag %d is not result of `newtag'", tag); | 94 | luaL_verror("tag %d is not result of `newtag'", tag); |
99 | } | 95 | } |
100 | 96 | ||
@@ -145,11 +141,11 @@ void luaT_settagmethod (int t, char *event, TObject *func) | |||
145 | char *luaT_travtagmethods (int (*fn)(TObject *)) | 141 | char *luaT_travtagmethods (int (*fn)(TObject *)) |
146 | { | 142 | { |
147 | int e; | 143 | int e; |
148 | if (fn(&luaD_errorim)) | 144 | if (fn(&L->errorim)) |
149 | return "error"; | 145 | return "error"; |
150 | for (e=IM_GETTABLE; e<=IM_FUNCTION; e++) { /* ORDER IM */ | 146 | for (e=IM_GETTABLE; e<=IM_FUNCTION; e++) { /* ORDER IM */ |
151 | int t; | 147 | int t; |
152 | for (t=0; t>=last_tag; t--) | 148 | for (t=0; t>=L->last_tag; t--) |
153 | if (fn(luaT_getim(t,e))) | 149 | if (fn(luaT_getim(t,e))) |
154 | return luaT_eventname[e]; | 150 | return luaT_eventname[e]; |
155 | } | 151 | } |
@@ -203,8 +199,8 @@ void luaT_setfallback (void) | |||
203 | luaL_arg_check(lua_isfunction(func), 2, "function expected"); | 199 | luaL_arg_check(lua_isfunction(func), 2, "function expected"); |
204 | switch (luaO_findstring(name, oldnames)) { | 200 | switch (luaO_findstring(name, oldnames)) { |
205 | case 0: /* old error fallback */ | 201 | case 0: /* old error fallback */ |
206 | oldfunc = luaD_errorim; | 202 | oldfunc = L->errorim; |
207 | luaD_errorim = *luaA_Address(func); | 203 | L->errorim = *luaA_Address(func); |
208 | replace = errorFB; | 204 | replace = errorFB; |
209 | break; | 205 | break; |
210 | case 1: /* old getglobal fallback */ | 206 | case 1: /* old getglobal fallback */ |