diff options
Diffstat (limited to 'opcode.c')
| -rw-r--r-- | opcode.c | 42 |
1 files changed, 12 insertions, 30 deletions
| @@ -3,7 +3,7 @@ | |||
| 3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_opcode="$Id: opcode.c,v 3.61 1996/03/19 16:50:24 roberto Exp roberto $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 3.62 1996/03/19 22:28:37 roberto Exp roberto $"; |
| 7 | 7 | ||
| 8 | #include <setjmp.h> | 8 | #include <setjmp.h> |
| 9 | #include <stdio.h> | 9 | #include <stdio.h> |
| @@ -54,8 +54,8 @@ static jmp_buf *errorJmp = NULL; /* current error recover point */ | |||
| 54 | 54 | ||
| 55 | 55 | ||
| 56 | /* Hooks */ | 56 | /* Hooks */ |
| 57 | static lua_LHFunction line_hook = NULL; | 57 | lua_LHFunction lua_linehook = NULL; |
| 58 | static lua_CHFunction call_hook = NULL; | 58 | lua_CHFunction lua_callhook = NULL; |
| 59 | 59 | ||
| 60 | 60 | ||
| 61 | static StkId lua_execute (Byte *pc, StkId base); | 61 | static StkId lua_execute (Byte *pc, StkId base); |
| @@ -70,24 +70,6 @@ Object *luaI_Address (lua_Object o) | |||
| 70 | 70 | ||
| 71 | 71 | ||
| 72 | /* | 72 | /* |
| 73 | ** Functions to change hook functions. | ||
| 74 | */ | ||
| 75 | lua_LHFunction lua_setlinehook (lua_LHFunction hook) | ||
| 76 | { | ||
| 77 | lua_LHFunction temp = line_hook; | ||
| 78 | line_hook = hook; | ||
| 79 | return temp; | ||
| 80 | } | ||
| 81 | |||
| 82 | lua_CHFunction lua_setcallhook (lua_CHFunction hook) | ||
| 83 | { | ||
| 84 | lua_CHFunction temp = call_hook; | ||
| 85 | call_hook = hook; | ||
| 86 | return temp; | ||
| 87 | } | ||
| 88 | |||
| 89 | |||
| 90 | /* | ||
| 91 | ** Init stack | 73 | ** Init stack |
| 92 | */ | 74 | */ |
| 93 | static void lua_initstack (void) | 75 | static void lua_initstack (void) |
| @@ -212,7 +194,7 @@ static void lineHook (int line) | |||
| 212 | int oldCnResults = CnResults; | 194 | int oldCnResults = CnResults; |
| 213 | StkId old_top = CBase = top-stack; | 195 | StkId old_top = CBase = top-stack; |
| 214 | CnResults = 0; | 196 | CnResults = 0; |
| 215 | (*line_hook)(line); | 197 | (*lua_linehook)(line); |
| 216 | top = stack+old_top; | 198 | top = stack+old_top; |
| 217 | CnResults = oldCnResults; | 199 | CnResults = oldCnResults; |
| 218 | CBase = oldBase; | 200 | CBase = oldBase; |
| @@ -230,14 +212,14 @@ static void callHook (StkId base, lua_Type type, int isreturn) | |||
| 230 | StkId old_top = CBase = top-stack; | 212 | StkId old_top = CBase = top-stack; |
| 231 | CnResults = 0; | 213 | CnResults = 0; |
| 232 | if (isreturn) | 214 | if (isreturn) |
| 233 | (*call_hook)(LUA_NOOBJECT, "(return)", 0); | 215 | (*lua_callhook)(LUA_NOOBJECT, "(return)", 0); |
| 234 | else | 216 | else |
| 235 | { | 217 | { |
| 236 | Object *f = stack+base-1; | 218 | Object *f = stack+base-1; |
| 237 | if (type == LUA_T_MARK) | 219 | if (type == LUA_T_MARK) |
| 238 | (*call_hook)(Ref(f), f->value.tf->fileName, f->value.tf->lineDefined); | 220 | (*lua_callhook)(Ref(f), f->value.tf->fileName, f->value.tf->lineDefined); |
| 239 | else | 221 | else |
| 240 | (*call_hook)(Ref(f), "(C)", -1); | 222 | (*lua_callhook)(Ref(f), "(C)", -1); |
| 241 | } | 223 | } |
| 242 | top = stack+old_top; | 224 | top = stack+old_top; |
| 243 | CnResults = oldCnResults; | 225 | CnResults = oldCnResults; |
| @@ -258,10 +240,10 @@ static StkId callC (lua_CFunction func, StkId base) | |||
| 258 | CnResults = (top-stack) - base; | 240 | CnResults = (top-stack) - base; |
| 259 | /* incorporate parameters on the stack */ | 241 | /* incorporate parameters on the stack */ |
| 260 | CBase = base+CnResults; /* == top-stack */ | 242 | CBase = base+CnResults; /* == top-stack */ |
| 261 | if (call_hook) | 243 | if (lua_callhook) |
| 262 | callHook(base, LUA_T_CMARK, 0); | 244 | callHook(base, LUA_T_CMARK, 0); |
| 263 | (*func)(); | 245 | (*func)(); |
| 264 | if (call_hook) /* func may have changed call_hook */ | 246 | if (lua_callhook) /* func may have changed lua_callhook */ |
| 265 | callHook(base, LUA_T_CMARK, 1); | 247 | callHook(base, LUA_T_CMARK, 1); |
| 266 | firstResult = CBase; | 248 | firstResult = CBase; |
| 267 | CBase = oldBase; | 249 | CBase = oldBase; |
| @@ -899,7 +881,7 @@ static void comparison (lua_Type tag_less, lua_Type tag_equal, | |||
| 899 | */ | 881 | */ |
| 900 | static StkId lua_execute (Byte *pc, StkId base) | 882 | static StkId lua_execute (Byte *pc, StkId base) |
| 901 | { | 883 | { |
| 902 | if (call_hook) | 884 | if (lua_callhook) |
| 903 | callHook (base, LUA_T_MARK, 0); | 885 | callHook (base, LUA_T_MARK, 0); |
| 904 | while (1) | 886 | while (1) |
| 905 | { | 887 | { |
| @@ -1261,7 +1243,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1261 | 1243 | ||
| 1262 | case RETCODE0: | 1244 | case RETCODE0: |
| 1263 | case RETCODE: | 1245 | case RETCODE: |
| 1264 | if (call_hook) | 1246 | if (lua_callhook) |
| 1265 | callHook (base, LUA_T_MARK, 1); | 1247 | callHook (base, LUA_T_MARK, 1); |
| 1266 | return (base + ((opcode==RETCODE0) ? 0 : *pc)); | 1248 | return (base + ((opcode==RETCODE0) ? 0 : *pc)); |
| 1267 | 1249 | ||
| @@ -1277,7 +1259,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1277 | (stack+base-1)->tag = LUA_T_LINE; | 1259 | (stack+base-1)->tag = LUA_T_LINE; |
| 1278 | } | 1260 | } |
| 1279 | (stack+base-1)->value.i = code.w; | 1261 | (stack+base-1)->value.i = code.w; |
| 1280 | if (line_hook) | 1262 | if (lua_linehook) |
| 1281 | lineHook (code.w); | 1263 | lineHook (code.w); |
| 1282 | break; | 1264 | break; |
| 1283 | } | 1265 | } |
