misc/liblua/lvm.c
changeset 10017 de822cd3df3a
parent 3697 d5b30d6373fc
equal deleted inserted replaced
10015:4feced261c68 10017:de822cd3df3a
    27 #include "lvm.h"
    27 #include "lvm.h"
    28 
    28 
    29 
    29 
    30 
    30 
    31 /* limit for table tag-method chains (to avoid loops) */
    31 /* limit for table tag-method chains (to avoid loops) */
    32 #define MAXTAGLOOP	100
    32 #define MAXTAGLOOP  100
    33 
    33 
    34 
    34 
    35 const TValue *luaV_tonumber (const TValue *obj, TValue *n) {
    35 const TValue *luaV_tonumber (const TValue *obj, TValue *n) {
    36   lua_Number num;
    36   lua_Number num;
    37   if (ttisnumber(obj)) return obj;
    37   if (ttisnumber(obj)) return obj;
   336 
   336 
   337 /*
   337 /*
   338 ** some macros for common tasks in `luaV_execute'
   338 ** some macros for common tasks in `luaV_execute'
   339 */
   339 */
   340 
   340 
   341 #define runtime_check(L, c)	{ if (!(c)) break; }
   341 #define runtime_check(L, c) { if (!(c)) break; }
   342 
   342 
   343 #define RA(i)	(base+GETARG_A(i))
   343 #define RA(i)   (base+GETARG_A(i))
   344 /* to be used after possible stack reallocation */
   344 /* to be used after possible stack reallocation */
   345 #define RB(i)	check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i))
   345 #define RB(i)   check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i))
   346 #define RC(i)	check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i))
   346 #define RC(i)   check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i))
   347 #define RKB(i)	check_exp(getBMode(GET_OPCODE(i)) == OpArgK, \
   347 #define RKB(i)  check_exp(getBMode(GET_OPCODE(i)) == OpArgK, \
   348 	ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i))
   348     ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i))
   349 #define RKC(i)	check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \
   349 #define RKC(i)  check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \
   350 	ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i))
   350     ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i))
   351 #define KBx(i)	check_exp(getBMode(GET_OPCODE(i)) == OpArgK, k+GETARG_Bx(i))
   351 #define KBx(i)  check_exp(getBMode(GET_OPCODE(i)) == OpArgK, k+GETARG_Bx(i))
   352 
   352 
   353 
   353 
   354 #define dojump(L,pc,i)	{(pc) += (i); luai_threadyield(L);}
   354 #define dojump(L,pc,i)  {(pc) += (i); luai_threadyield(L);}
   355 
   355 
   356 
   356 
   357 #define Protect(x)	{ L->savedpc = pc; {x;}; base = L->base; }
   357 #define Protect(x)  { L->savedpc = pc; {x;}; base = L->base; }
   358 
   358 
   359 
   359 
   360 #define arith_op(op,tm) { \
   360 #define arith_op(op,tm) { \
   361         TValue *rb = RKB(i); \
   361         TValue *rb = RKB(i); \
   362         TValue *rc = RKC(i); \
   362         TValue *rc = RKC(i); \