diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-08-10 16:50:47 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-08-10 16:50:47 -0300 |
commit | daf09c476fe375d8a9a47bc1294a1cd430290226 (patch) | |
tree | 1d4ecc2d4001f2195168eaeafb257c9af8b94793 | |
parent | e238efc5367a8d88757dd84df0683e1d8d9f9211 (diff) | |
download | lua-daf09c476fe375d8a9a47bc1294a1cd430290226.tar.gz lua-daf09c476fe375d8a9a47bc1294a1cd430290226.tar.bz2 lua-daf09c476fe375d8a9a47bc1294a1cd430290226.zip |
still better error messages
-rw-r--r-- | lcode.c | 5 | ||||
-rw-r--r-- | ldebug.c | 84 | ||||
-rw-r--r-- | ldebug.h | 6 | ||||
-rw-r--r-- | ldo.c | 4 | ||||
-rw-r--r-- | lvm.c | 34 |
5 files changed, 67 insertions, 66 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.c,v 1.45 2000/08/09 14:49:13 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 1.46 2000/08/09 19:16:57 roberto Exp roberto $ |
3 | ** Code generator for Lua | 3 | ** Code generator for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -333,7 +333,6 @@ void luaK_tostack (LexState *ls, expdesc *v, int onlyone) { | |||
333 | luaK_deltastack(fs, -1); /* next PUSHes may be skipped */ | 333 | luaK_deltastack(fs, -1); /* next PUSHes may be skipped */ |
334 | } | 334 | } |
335 | p_nil = code_label(fs, OP_PUSHNILJMP, 0); | 335 | p_nil = code_label(fs, OP_PUSHNILJMP, 0); |
336 | luaK_deltastack(fs, -1); /* next PUSH is skipped */ | ||
337 | p_1 = code_label(fs, OP_PUSHINT, 1); | 336 | p_1 = code_label(fs, OP_PUSHINT, 1); |
338 | luaK_patchlist(fs, j, luaK_getlabel(fs)); | 337 | luaK_patchlist(fs, j, luaK_getlabel(fs)); |
339 | } | 338 | } |
@@ -690,7 +689,7 @@ const struct OpProperties luaK_opproperties[NUM_OPCODES] = { | |||
690 | {iS, 0, 1}, /* OP_JMPONT */ | 689 | {iS, 0, 1}, /* OP_JMPONT */ |
691 | {iS, 0, 1}, /* OP_JMPONF */ | 690 | {iS, 0, 1}, /* OP_JMPONF */ |
692 | {iS, 0, 0}, /* OP_JMP */ | 691 | {iS, 0, 0}, /* OP_JMP */ |
693 | {iO, 1, 0}, /* OP_PUSHNILJMP */ | 692 | {iO, 0, 0}, /* OP_PUSHNILJMP */ |
694 | {iS, 0, 0}, /* OP_FORPREP */ | 693 | {iS, 0, 0}, /* OP_FORPREP */ |
695 | {iS, 0, 3}, /* OP_FORLOOP */ | 694 | {iS, 0, 3}, /* OP_FORLOOP */ |
696 | {iS, 3, 0}, /* OP_LFORPREP */ | 695 | {iS, 3, 0}, /* OP_LFORPREP */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 1.30 2000/08/08 20:42:07 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 1.31 2000/08/09 19:16:57 roberto Exp roberto $ |
3 | ** Debug Interface | 3 | ** Debug Interface |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -57,7 +57,7 @@ lua_Hook lua_setlinehook (lua_State *L, lua_Hook func) { | |||
57 | 57 | ||
58 | static StkId aux_stackedfunction (lua_State *L, int level, StkId top) { | 58 | static StkId aux_stackedfunction (lua_State *L, int level, StkId top) { |
59 | int i; | 59 | int i; |
60 | for (i = (top-1)-L->stack; i>=0; i--) { | 60 | for (i = (top-1) - L->stack; i>=0; i--) { |
61 | if (is_T_MARK(L->stack[i].ttype)) { | 61 | if (is_T_MARK(L->stack[i].ttype)) { |
62 | if (level == 0) | 62 | if (level == 0) |
63 | return L->stack+i; | 63 | return L->stack+i; |
@@ -214,7 +214,7 @@ static const char *travglobals (lua_State *L, const TObject *o) { | |||
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | static void lua_getobjname (lua_State *L, StkId f, lua_Debug *ar) { | 217 | static void lua_getname (lua_State *L, StkId f, lua_Debug *ar) { |
218 | TObject o; | 218 | TObject o; |
219 | setnormalized(&o, f); | 219 | setnormalized(&o, f); |
220 | /* try to find a name for given function */ | 220 | /* try to find a name for given function */ |
@@ -247,7 +247,7 @@ int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { | |||
247 | ar->nups = lua_nups(func); | 247 | ar->nups = lua_nups(func); |
248 | break; | 248 | break; |
249 | case 'n': | 249 | case 'n': |
250 | lua_getobjname(L, func, ar); | 250 | lua_getname(L, func, ar); |
251 | break; | 251 | break; |
252 | case 'f': | 252 | case 'f': |
253 | setnormalized(L->top, func); | 253 | setnormalized(L->top, func); |
@@ -267,8 +267,16 @@ int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { | |||
267 | ** ======================================================= | 267 | ** ======================================================= |
268 | */ | 268 | */ |
269 | 269 | ||
270 | |||
271 | static int pushpc (int *stack, int pc, int top, int n) { | ||
272 | while (n--) | ||
273 | stack[top++] = pc-1; | ||
274 | return top; | ||
275 | } | ||
276 | |||
277 | |||
270 | static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) { | 278 | static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) { |
271 | int stack[MAXSTACK]; /* stores last instruction that changes each value */ | 279 | int stack[MAXSTACK]; /* stores last instruction that changed a stack entry */ |
272 | const Instruction *code = pt->code; | 280 | const Instruction *code = pt->code; |
273 | int top = pt->numparams; | 281 | int top = pt->numparams; |
274 | int pc = 0; | 282 | int pc = 0; |
@@ -276,7 +284,7 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) { | |||
276 | top++; /* `arg' */ | 284 | top++; /* `arg' */ |
277 | while (pc < lastpc) { | 285 | while (pc < lastpc) { |
278 | const Instruction i = code[pc++]; | 286 | const Instruction i = code[pc++]; |
279 | LUA_ASSERT(top <= pt->maxstacksize, "wrong stack"); | 287 | LUA_ASSERT(0 <= top && top <= pt->maxstacksize, "wrong stack"); |
280 | switch (GET_OPCODE(i)) { | 288 | switch (GET_OPCODE(i)) { |
281 | case OP_RETURN: { | 289 | case OP_RETURN: { |
282 | LUA_ASSERT(top >= GETARG_U(i), "wrong stack"); | 290 | LUA_ASSERT(top >= GETARG_U(i), "wrong stack"); |
@@ -287,9 +295,7 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) { | |||
287 | int nresults = GETARG_B(i); | 295 | int nresults = GETARG_B(i); |
288 | if (nresults == MULT_RET) nresults = 1; | 296 | if (nresults == MULT_RET) nresults = 1; |
289 | LUA_ASSERT(top >= GETARG_A(i), "wrong stack"); | 297 | LUA_ASSERT(top >= GETARG_A(i), "wrong stack"); |
290 | top = GETARG_A(i); | 298 | top = pushpc(stack, pc, GETARG_A(i), nresults); |
291 | while (nresults--) | ||
292 | stack[top++] = pc-1; | ||
293 | break; | 299 | break; |
294 | } | 300 | } |
295 | case OP_TAILCALL: { | 301 | case OP_TAILCALL: { |
@@ -298,9 +304,7 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) { | |||
298 | break; | 304 | break; |
299 | } | 305 | } |
300 | case OP_PUSHNIL: { | 306 | case OP_PUSHNIL: { |
301 | int n; | 307 | top = pushpc(stack, pc, top, GETARG_U(i)); |
302 | for (n=0; n<GETARG_U(i); n++) | ||
303 | stack[top++] = pc-1; | ||
304 | break; | 308 | break; |
305 | } | 309 | } |
306 | case OP_POP: { | 310 | case OP_POP: { |
@@ -321,33 +325,27 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) { | |||
321 | stack[top++] = pc-1; | 325 | stack[top++] = pc-1; |
322 | break; | 326 | break; |
323 | } | 327 | } |
324 | case OP_JMPONT: | ||
325 | case OP_JMPONF: { | ||
326 | int newpc = pc + GETARG_S(i); | ||
327 | if (lastpc < newpc) | ||
328 | top--; /* original code did not jump; condition was false */ | ||
329 | else { | ||
330 | stack[top-1] = pc-1; /* value generated by or-and */ | ||
331 | pc = newpc; /* do the jump */ | ||
332 | } | ||
333 | break; | ||
334 | } | ||
335 | case OP_PUSHNILJMP: { | ||
336 | break; /* do not `push', to compensate next instruction */ | ||
337 | } | ||
338 | case OP_CLOSURE: { | 328 | case OP_CLOSURE: { |
339 | top -= GETARG_B(i); | 329 | top -= GETARG_B(i); |
340 | stack[top++] = pc-1; | 330 | stack[top++] = pc-1; |
341 | break; | 331 | break; |
342 | } | 332 | } |
343 | default: { | 333 | default: { |
344 | int n; | 334 | OpCode op = GET_OPCODE(i); |
345 | LUA_ASSERT(luaK_opproperties[GET_OPCODE(i)].push != VD, | 335 | LUA_ASSERT(luaK_opproperties[op].push != VD, |
346 | "invalid opcode for default"); | 336 | "invalid opcode for default"); |
347 | top -= luaK_opproperties[GET_OPCODE(i)].pop; | 337 | top -= luaK_opproperties[op].pop; |
348 | LUA_ASSERT(top >= 0, "wrong stack"); | 338 | LUA_ASSERT(top >= 0, "wrong stack"); |
349 | for (n=0; n<luaK_opproperties[GET_OPCODE(i)].push; n++) | 339 | top = pushpc(stack, pc, top, luaK_opproperties[op].push); |
350 | stack[top++] = pc-1; | 340 | if (ISJUMP(op)) { |
341 | int newpc = pc + GETARG_S(i); | ||
342 | /* jump is forward and do not skip `lastpc'? */ | ||
343 | if (pc < newpc && newpc <= lastpc) { | ||
344 | if (op == OP_JMPONT || op == OP_JMPONF) | ||
345 | stack[top++] = pc-1; /* do not pop when jumping */ | ||
346 | pc = newpc; /* do the jump */ | ||
347 | } | ||
348 | } | ||
351 | } | 349 | } |
352 | } | 350 | } |
353 | } | 351 | } |
@@ -355,7 +353,7 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) { | |||
355 | } | 353 | } |
356 | 354 | ||
357 | 355 | ||
358 | static const char *getname (lua_State *L, StkId obj, const char **name) { | 356 | static const char *getobjname (lua_State *L, StkId obj, const char **name) { |
359 | StkId func = aux_stackedfunction(L, 0, obj); | 357 | StkId func = aux_stackedfunction(L, 0, obj); |
360 | if (func == NULL || ttype(func) != TAG_LMARK) | 358 | if (func == NULL || ttype(func) != TAG_LMARK) |
361 | return NULL; /* not a Lua function */ | 359 | return NULL; /* not a Lua function */ |
@@ -389,23 +387,21 @@ static const char *getname (lua_State *L, StkId obj, const char **name) { | |||
389 | /* }====================================================== */ | 387 | /* }====================================================== */ |
390 | 388 | ||
391 | 389 | ||
392 | static void call_index_error (lua_State *L, StkId o, const char *op, | 390 | void luaG_typeerror (lua_State *L, StkId o, const char *op) { |
393 | const char *tp) { | ||
394 | const char *name; | 391 | const char *name; |
395 | const char *kind = getname(L, o, &name); | 392 | const char *kind = getobjname(L, o, &name); |
393 | const char *t = lua_type(L, o); | ||
396 | if (kind) | 394 | if (kind) |
397 | luaL_verror(L, "%s `%s' is not a %s", kind, name, tp); | 395 | luaL_verror(L, "attempt to %.30s %.20s `%.40s' (a %.10s value)", |
396 | op, kind, name, t); | ||
398 | else | 397 | else |
399 | luaL_verror(L, "attempt to %.10s a %.10s value", op, lua_type(L, o)); | 398 | luaL_verror(L, "attempt to %.30s a %.10s value", op, t); |
400 | } | ||
401 | |||
402 | |||
403 | void luaG_callerror (lua_State *L, StkId func) { | ||
404 | call_index_error(L, func, "call", "function"); | ||
405 | } | 399 | } |
406 | 400 | ||
407 | 401 | ||
408 | void luaG_indexerror (lua_State *L, StkId t) { | 402 | void luaG_binerror (lua_State *L, StkId p1, lua_Type t, const char *op) { |
409 | call_index_error(L, t, "index", "table"); | 403 | if (ttype(p1) == t) p1++; |
404 | LUA_ASSERT(ttype(p1) != t, "must be an error"); | ||
405 | luaG_typeerror(L, p1, op); | ||
410 | } | 406 | } |
411 | 407 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.h,v 1.2 2000/06/28 20:20:36 roberto Exp roberto $ | 2 | ** $Id: ldebug.h,v 1.3 2000/08/08 18:26:05 roberto Exp roberto $ |
3 | ** Auxiliary functions from Debug Interface module | 3 | ** Auxiliary functions from Debug Interface module |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -12,8 +12,8 @@ | |||
12 | #include "luadebug.h" | 12 | #include "luadebug.h" |
13 | 13 | ||
14 | 14 | ||
15 | void luaG_callerror (lua_State *L, StkId func); | 15 | void luaG_typeerror (lua_State *L, StkId o, const char *op); |
16 | void luaG_indexerror (lua_State *L, StkId t); | 16 | void luaG_binerror (lua_State *L, StkId p1, lua_Type t, const char *op); |
17 | int luaG_getline (int *lineinfo, int pc, int refline, int *refi); | 17 | int luaG_getline (int *lineinfo, int pc, int refline, int *refi); |
18 | 18 | ||
19 | 19 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 1.83 2000/08/08 20:42:07 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 1.84 2000/08/09 19:16:57 roberto Exp roberto $ |
3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -202,7 +202,7 @@ void luaD_call (lua_State *L, StkId func, int nResults) { | |||
202 | default: { /* `func' is not a function; check the `function' tag method */ | 202 | default: { /* `func' is not a function; check the `function' tag method */ |
203 | const TObject *im = luaT_getimbyObj(L, func, IM_FUNCTION); | 203 | const TObject *im = luaT_getimbyObj(L, func, IM_FUNCTION); |
204 | if (ttype(im) == TAG_NIL) | 204 | if (ttype(im) == TAG_NIL) |
205 | luaG_callerror(L, func); | 205 | luaG_typeerror(L, func, "call"); |
206 | luaD_openstack(L, func); | 206 | luaD_openstack(L, func); |
207 | *func = *im; /* tag method is the new function to be called */ | 207 | *func = *im; /* tag method is the new function to be called */ |
208 | goto retry; /* retry the call */ | 208 | goto retry; /* retry the call */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 1.123 2000/08/09 14:49:41 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.124 2000/08/09 19:16:57 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 | */ |
@@ -121,7 +121,7 @@ void luaV_gettable (lua_State *L, StkId top) { | |||
121 | im = luaT_getimbyObj(L, table, IM_GETTABLE); | 121 | im = luaT_getimbyObj(L, table, IM_GETTABLE); |
122 | if (ttype(im) == TAG_NIL) { | 122 | if (ttype(im) == TAG_NIL) { |
123 | L->top = top; | 123 | L->top = top; |
124 | luaG_indexerror(L, table); | 124 | luaG_typeerror(L, table, "index"); |
125 | } | 125 | } |
126 | } | 126 | } |
127 | else { /* object is a table... */ | 127 | else { /* object is a table... */ |
@@ -156,7 +156,7 @@ void luaV_settable (lua_State *L, StkId t, StkId top) { | |||
156 | L->top = top; | 156 | L->top = top; |
157 | im = luaT_getimbyObj(L, t, IM_SETTABLE); | 157 | im = luaT_getimbyObj(L, t, IM_SETTABLE); |
158 | if (ttype(im) == TAG_NIL) | 158 | if (ttype(im) == TAG_NIL) |
159 | luaG_indexerror(L, t); | 159 | luaG_typeerror(L, t, "index"); |
160 | } | 160 | } |
161 | else { /* object is a table... */ | 161 | else { /* object is a table... */ |
162 | im = luaT_getim(L, hvalue(t)->htag, IM_SETTABLE); | 162 | im = luaT_getim(L, hvalue(t)->htag, IM_SETTABLE); |
@@ -223,7 +223,7 @@ void luaV_setglobal (lua_State *L, TString *s, StkId top) { | |||
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | static void call_binTM (lua_State *L, StkId top, IMS event, const char *msg) { | 226 | static int call_binTM (lua_State *L, StkId top, IMS event) { |
227 | /* try first operand */ | 227 | /* try first operand */ |
228 | const TObject *im = luaT_getimbyObj(L, top-2, event); | 228 | const TObject *im = luaT_getimbyObj(L, top-2, event); |
229 | L->top = top; | 229 | L->top = top; |
@@ -232,16 +232,18 @@ static void call_binTM (lua_State *L, StkId top, IMS event, const char *msg) { | |||
232 | if (ttype(im) == TAG_NIL) { | 232 | if (ttype(im) == TAG_NIL) { |
233 | im = luaT_getim(L, 0, event); /* try a `global' method */ | 233 | im = luaT_getim(L, 0, event); /* try a `global' method */ |
234 | if (ttype(im) == TAG_NIL) | 234 | if (ttype(im) == TAG_NIL) |
235 | lua_error(L, msg); | 235 | return 0; /* error */ |
236 | } | 236 | } |
237 | } | 237 | } |
238 | lua_pushstring(L, luaT_eventname[event]); | 238 | lua_pushstring(L, luaT_eventname[event]); |
239 | luaD_callTM(L, im, 3, 1); | 239 | luaD_callTM(L, im, 3, 1); |
240 | return 1; | ||
240 | } | 241 | } |
241 | 242 | ||
242 | 243 | ||
243 | static void call_arith (lua_State *L, StkId top, IMS event) { | 244 | static void call_arith (lua_State *L, StkId top, IMS event) { |
244 | call_binTM(L, top, event, "unexpected type in arithmetic operation"); | 245 | if (!call_binTM(L, top, event)) |
246 | luaG_binerror(L, top-2, TAG_NUMBER, "perform arithmetic on"); | ||
245 | } | 247 | } |
246 | 248 | ||
247 | 249 | ||
@@ -276,7 +278,8 @@ int luaV_lessthan (lua_State *L, const TObject *l, const TObject *r, StkId top) | |||
276 | luaD_checkstack(L, 2); | 278 | luaD_checkstack(L, 2); |
277 | *top++ = *l; | 279 | *top++ = *l; |
278 | *top++ = *r; | 280 | *top++ = *r; |
279 | call_binTM(L, top, IM_LT, "unexpected type in comparison"); | 281 | if (!call_binTM(L, top, IM_LT)) |
282 | lua_error(L, "unexpected type in comparison"); | ||
280 | L->top--; | 283 | L->top--; |
281 | return (ttype(L->top) != TAG_NIL); | 284 | return (ttype(L->top) != TAG_NIL); |
282 | } | 285 | } |
@@ -286,8 +289,10 @@ int luaV_lessthan (lua_State *L, const TObject *l, const TObject *r, StkId top) | |||
286 | static void strconc (lua_State *L, int total, StkId top) { | 289 | static void strconc (lua_State *L, int total, StkId top) { |
287 | do { | 290 | do { |
288 | int n = 2; /* number of elements handled in this pass (at least 2) */ | 291 | int n = 2; /* number of elements handled in this pass (at least 2) */ |
289 | if (tostring(L, top-2) || tostring(L, top-1)) | 292 | if (tostring(L, top-2) || tostring(L, top-1)) { |
290 | call_binTM(L, top, IM_CONCAT, "unexpected type for concatenation"); | 293 | if (!call_binTM(L, top, IM_CONCAT)) |
294 | luaG_binerror(L, top-2, TAG_STRING, "concat"); | ||
295 | } | ||
291 | else if (tsvalue(top-1)->u.s.len > 0) { /* if len=0, do nothing */ | 296 | else if (tsvalue(top-1)->u.s.len > 0) { /* if len=0, do nothing */ |
292 | /* at least two string values; get as many as possible */ | 297 | /* at least two string values; get as many as possible */ |
293 | lint32 tl = (lint32)tsvalue(top-1)->u.s.len + | 298 | lint32 tl = (lint32)tsvalue(top-1)->u.s.len + |
@@ -508,7 +513,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { | |||
508 | } | 513 | } |
509 | 514 | ||
510 | case OP_ADD: | 515 | case OP_ADD: |
511 | if (tonumber(top-1) || tonumber(top-2)) | 516 | if (tonumber(top-2) || tonumber(top-1)) |
512 | call_arith(L, top, IM_ADD); | 517 | call_arith(L, top, IM_ADD); |
513 | else | 518 | else |
514 | nvalue(top-2) += nvalue(top-1); | 519 | nvalue(top-2) += nvalue(top-1); |
@@ -526,7 +531,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { | |||
526 | break; | 531 | break; |
527 | 532 | ||
528 | case OP_SUB: | 533 | case OP_SUB: |
529 | if (tonumber(top-1) || tonumber(top-2)) | 534 | if (tonumber(top-2) || tonumber(top-1)) |
530 | call_arith(L, top, IM_SUB); | 535 | call_arith(L, top, IM_SUB); |
531 | else | 536 | else |
532 | nvalue(top-2) -= nvalue(top-1); | 537 | nvalue(top-2) -= nvalue(top-1); |
@@ -534,7 +539,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { | |||
534 | break; | 539 | break; |
535 | 540 | ||
536 | case OP_MULT: | 541 | case OP_MULT: |
537 | if (tonumber(top-1) || tonumber(top-2)) | 542 | if (tonumber(top-2) || tonumber(top-1)) |
538 | call_arith(L, top, IM_MUL); | 543 | call_arith(L, top, IM_MUL); |
539 | else | 544 | else |
540 | nvalue(top-2) *= nvalue(top-1); | 545 | nvalue(top-2) *= nvalue(top-1); |
@@ -542,7 +547,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { | |||
542 | break; | 547 | break; |
543 | 548 | ||
544 | case OP_DIV: | 549 | case OP_DIV: |
545 | if (tonumber(top-1) || tonumber(top-2)) | 550 | if (tonumber(top-2) || tonumber(top-1)) |
546 | call_arith(L, top, IM_DIV); | 551 | call_arith(L, top, IM_DIV); |
547 | else | 552 | else |
548 | nvalue(top-2) /= nvalue(top-1); | 553 | nvalue(top-2) /= nvalue(top-1); |
@@ -550,7 +555,8 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { | |||
550 | break; | 555 | break; |
551 | 556 | ||
552 | case OP_POW: | 557 | case OP_POW: |
553 | call_binTM(L, top, IM_POW, "undefined operation"); | 558 | if (!call_binTM(L, top, IM_POW)) |
559 | lua_error(L, "undefined operation"); | ||
554 | top--; | 560 | top--; |
555 | break; | 561 | break; |
556 | 562 | ||