diff options
Diffstat (limited to '')
| -rw-r--r-- | lopcodes.h | 46 | ||||
| -rw-r--r-- | lparser.c | 54 | ||||
| -rw-r--r-- | lvm.c | 78 |
3 files changed, 111 insertions, 67 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lopcodes.h,v 1.18 1998/06/25 14:37:00 roberto Exp roberto $ | 2 | ** $Id: lopcodes.h,v 1.19 1999/02/02 17:57:49 roberto Exp roberto $ |
| 3 | ** Opcodes for Lua virtual machine | 3 | ** Opcodes for Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -12,7 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | /* | 13 | /* |
| 14 | ** NOTICE: variants of the same opcode must be consecutive: First, those | 14 | ** NOTICE: variants of the same opcode must be consecutive: First, those |
| 15 | ** with byte parameter, then with word parameter. | 15 | ** with word parameter, then with byte parameter. |
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | 18 | ||
| @@ -20,49 +20,55 @@ typedef enum { | |||
| 20 | /* name parm before after side effect | 20 | /* name parm before after side effect |
| 21 | -----------------------------------------------------------------------------*/ | 21 | -----------------------------------------------------------------------------*/ |
| 22 | ENDCODE,/* - - - */ | 22 | ENDCODE,/* - - - */ |
| 23 | RETCODE,/* b - - */ | ||
| 23 | 24 | ||
| 24 | PUSHNIL,/* b - nil_0...nil_b */ | 25 | PUSHNIL,/* b - nil_0...nil_b */ |
| 26 | POP,/* b - - TOP-=(b+1) */ | ||
| 25 | 27 | ||
| 26 | PUSHNUMBER,/* b - (float)(b-NUMOFFSET) */ | ||
| 27 | PUSHNUMBERW,/* w - (float)(w-NUMOFFSET) */ | 28 | PUSHNUMBERW,/* w - (float)(w-NUMOFFSET) */ |
| 29 | PUSHNUMBER,/* b - (float)(b-NUMOFFSET) */ | ||
| 28 | 30 | ||
| 29 | PUSHCONSTANT,/* b - CNST[b] */ | ||
| 30 | PUSHCONSTANTW,/*w - CNST[w] */ | 31 | PUSHCONSTANTW,/*w - CNST[w] */ |
| 32 | PUSHCONSTANT,/* b - CNST[b] */ | ||
| 31 | 33 | ||
| 32 | PUSHUPVALUE,/* b - Closure[b] */ | 34 | PUSHUPVALUE,/* b - Closure[b] */ |
| 33 | 35 | ||
| 34 | PUSHLOCAL,/* b - LOC[b] */ | 36 | PUSHLOCAL,/* b - LOC[b] */ |
| 35 | 37 | ||
| 36 | GETGLOBAL,/* b - VAR[CNST[b]] */ | ||
| 37 | GETGLOBALW,/* w - VAR[CNST[w]] */ | 38 | GETGLOBALW,/* w - VAR[CNST[w]] */ |
| 39 | GETGLOBAL,/* b - VAR[CNST[b]] */ | ||
| 38 | 40 | ||
| 39 | GETTABLE,/* - i t t[i] */ | 41 | GETTABLE,/* - i t t[i] */ |
| 40 | 42 | ||
| 41 | GETDOTTED,/* b t t[CNST[b]] */ | ||
| 42 | GETDOTTEDW,/* w t t[CNST[w]] */ | 43 | GETDOTTEDW,/* w t t[CNST[w]] */ |
| 44 | GETDOTTED,/* b t t[CNST[b]] */ | ||
| 43 | 45 | ||
| 44 | PUSHSELF,/* b t t t[CNST[b]] */ | ||
| 45 | PUSHSELFW,/* w t t t[CNST[w]] */ | 46 | PUSHSELFW,/* w t t t[CNST[w]] */ |
| 47 | PUSHSELF,/* b t t t[CNST[b]] */ | ||
| 46 | 48 | ||
| 47 | CREATEARRAY,/* b - newarray(size = b) */ | ||
| 48 | CREATEARRAYW,/* w - newarray(size = w) */ | 49 | CREATEARRAYW,/* w - newarray(size = w) */ |
| 50 | CREATEARRAY,/* b - newarray(size = b) */ | ||
| 49 | 51 | ||
| 50 | SETLOCAL,/* b x - LOC[b]=x */ | 52 | SETLOCAL,/* b x - LOC[b]=x */ |
| 53 | SETLOCALDUP,/* b x x LOC[b]=x */ | ||
| 51 | 54 | ||
| 52 | SETGLOBAL,/* b x - VAR[CNST[b]]=x */ | ||
| 53 | SETGLOBALW,/* w x - VAR[CNST[w]]=x */ | 55 | SETGLOBALW,/* w x - VAR[CNST[w]]=x */ |
| 56 | SETGLOBAL,/* b x - VAR[CNST[b]]=x */ | ||
| 57 | SETGLOBALDUPW,/*w x x VAR[CNST[w]]=x */ | ||
| 58 | SETGLOBALDUP,/* b x x VAR[CNST[b]]=x */ | ||
| 54 | 59 | ||
| 55 | SETTABLE0,/* - v i t - t[i]=v */ | 60 | SETTABLE0,/* - v i t - t[i]=v */ |
| 61 | SETTABLEDUP,/* - v i t v t[i]=v */ | ||
| 56 | 62 | ||
| 57 | SETTABLE,/* b v a_b...a_1 i t a_b...a_1 i t t[i]=v */ | 63 | SETTABLE,/* b v a_b...a_1 i t a_b...a_1 i t t[i]=v */ |
| 58 | 64 | ||
| 59 | SETLIST,/* b c v_c...v_1 t - t[i+b*FPF]=v_i */ | ||
| 60 | SETLISTW,/* w c v_c...v_1 t - t[i+w*FPF]=v_i */ | 65 | SETLISTW,/* w c v_c...v_1 t - t[i+w*FPF]=v_i */ |
| 66 | SETLIST,/* b c v_c...v_1 t - t[i+b*FPF]=v_i */ | ||
| 61 | 67 | ||
| 62 | SETMAP,/* b v_b k_b ...v_0 k_0 t t t[k_i]=v_i */ | 68 | SETMAP,/* b v_b k_b ...v_0 k_0 t t t[k_i]=v_i */ |
| 63 | 69 | ||
| 64 | EQOP,/* - y x (x==y)? 1 : nil */ | ||
| 65 | NEQOP,/* - y x (x~=y)? 1 : nil */ | 70 | NEQOP,/* - y x (x~=y)? 1 : nil */ |
| 71 | EQOP,/* - y x (x==y)? 1 : nil */ | ||
| 66 | LTOP,/* - y x (x<y)? 1 : nil */ | 72 | LTOP,/* - y x (x<y)? 1 : nil */ |
| 67 | LEOP,/* - y x (x<y)? 1 : nil */ | 73 | LEOP,/* - y x (x<y)? 1 : nil */ |
| 68 | GTOP,/* - y x (x>y)? 1 : nil */ | 74 | GTOP,/* - y x (x>y)? 1 : nil */ |
| @@ -76,29 +82,25 @@ CONCOP,/* - y x x..y */ | |||
| 76 | MINUSOP,/* - x -x */ | 82 | MINUSOP,/* - x -x */ |
| 77 | NOTOP,/* - x (x==nil)? 1 : nil */ | 83 | NOTOP,/* - x (x==nil)? 1 : nil */ |
| 78 | 84 | ||
| 79 | ONTJMP,/* b x (x!=nil)? x : - (x!=nil)? PC+=b */ | ||
| 80 | ONTJMPW,/* w x (x!=nil)? x : - (x!=nil)? PC+=w */ | 85 | ONTJMPW,/* w x (x!=nil)? x : - (x!=nil)? PC+=w */ |
| 81 | ONFJMP,/* b x (x==nil)? x : - (x==nil)? PC+=b */ | 86 | ONTJMP,/* b x (x!=nil)? x : - (x!=nil)? PC+=b */ |
| 82 | ONFJMPW,/* w x (x==nil)? x : - (x==nil)? PC+=w */ | 87 | ONFJMPW,/* w x (x==nil)? x : - (x==nil)? PC+=w */ |
| 83 | JMP,/* b - - PC+=b */ | 88 | ONFJMP,/* b x (x==nil)? x : - (x==nil)? PC+=b */ |
| 84 | JMPW,/* w - - PC+=w */ | 89 | JMPW,/* w - - PC+=w */ |
| 85 | IFFJMP,/* b x - (x==nil)? PC+=b */ | 90 | JMP,/* b - - PC+=b */ |
| 86 | IFFJMPW,/* w x - (x==nil)? PC+=w */ | 91 | IFFJMPW,/* w x - (x==nil)? PC+=w */ |
| 87 | IFTUPJMP,/* b x - (x!=nil)? PC-=b */ | 92 | IFFJMP,/* b x - (x==nil)? PC+=b */ |
| 88 | IFTUPJMPW,/* w x - (x!=nil)? PC-=w */ | 93 | IFTUPJMPW,/* w x - (x!=nil)? PC-=w */ |
| 89 | IFFUPJMP,/* b x - (x==nil)? PC-=b */ | 94 | IFTUPJMP,/* b x - (x!=nil)? PC-=b */ |
| 90 | IFFUPJMPW,/* w x - (x==nil)? PC-=w */ | 95 | IFFUPJMPW,/* w x - (x==nil)? PC-=w */ |
| 96 | IFFUPJMP,/* b x - (x==nil)? PC-=b */ | ||
| 91 | 97 | ||
| 92 | CLOSURE,/* b c v_c...v_1 closure(CNST[b], v_c...v_1) */ | 98 | CLOSURE,/* b c v_c...v_1 closure(CNST[b], v_c...v_1) */ |
| 93 | 99 | ||
| 94 | CALLFUNC,/* b c v_c...v_1 f r_b...r_1 f(v1,...,v_c) */ | 100 | CALLFUNC,/* b c v_c...v_1 f r_b...r_1 f(v1,...,v_c) */ |
| 95 | 101 | ||
| 96 | RETCODE,/* b - - */ | ||
| 97 | |||
| 98 | SETLINE,/* b - - LINE=b */ | ||
| 99 | SETLINEW,/* w - - LINE=w */ | 102 | SETLINEW,/* w - - LINE=w */ |
| 100 | 103 | SETLINE /* b - - LINE=b */ | |
| 101 | POP /* b - - TOP-=(b+1) */ | ||
| 102 | 104 | ||
| 103 | } OpCode; | 105 | } OpCode; |
| 104 | 106 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lparser.c,v 1.12 1999/02/02 13:47:31 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 1.13 1999/02/02 17:57:49 roberto Exp roberto $ |
| 3 | ** LL(1) Parser and code generator for Lua | 3 | ** LL(1) Parser and code generator for Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -114,6 +114,7 @@ static void chunk (LexState *ls); | |||
| 114 | static void constructor (LexState *ls); | 114 | static void constructor (LexState *ls); |
| 115 | static void decinit (LexState *ls, listdesc *d); | 115 | static void decinit (LexState *ls, listdesc *d); |
| 116 | static void exp0 (LexState *ls, vardesc *v); | 116 | static void exp0 (LexState *ls, vardesc *v); |
| 117 | static void Gexp (LexState *ls, vardesc *v); | ||
| 117 | static void exp1 (LexState *ls); | 118 | static void exp1 (LexState *ls); |
| 118 | static void exp2 (LexState *ls, vardesc *v); | 119 | static void exp2 (LexState *ls, vardesc *v); |
| 119 | static void explist (LexState *ls, listdesc *e); | 120 | static void explist (LexState *ls, listdesc *e); |
| @@ -162,7 +163,7 @@ static int code_oparg_at (LexState *ls, int pc, OpCode op, int arg, int delta) { | |||
| 162 | return 2; /* code size (opcode + 1 byte) */ | 163 | return 2; /* code size (opcode + 1 byte) */ |
| 163 | } | 164 | } |
| 164 | else if (arg <= MAX_WORD) { | 165 | else if (arg <= MAX_WORD) { |
| 165 | code[pc] = (Byte)(op+1); | 166 | code[pc] = (Byte)(op-1); |
| 166 | code[pc+1] = (Byte)(arg>>8); | 167 | code[pc+1] = (Byte)(arg>>8); |
| 167 | code[pc+2] = (Byte)(arg&0xFF); | 168 | code[pc+2] = (Byte)(arg&0xFF); |
| 168 | return 3; /* code size (opcode + 1 word) */ | 169 | return 3; /* code size (opcode + 1 word) */ |
| @@ -429,6 +430,15 @@ static void code_args (LexState *ls, int nparams, int dots) { | |||
| 429 | } | 430 | } |
| 430 | 431 | ||
| 431 | 432 | ||
| 433 | static void unloaddot (LexState *ls, vardesc *v) { | ||
| 434 | /* dotted variables <a.x> must be stored like regular indexed vars <a["x"]> */ | ||
| 435 | if (v->k == VDOT) { | ||
| 436 | code_constant(ls, v->info); | ||
| 437 | v->k = VINDEXED; | ||
| 438 | } | ||
| 439 | } | ||
| 440 | |||
| 441 | |||
| 432 | static void lua_pushvar (LexState *ls, vardesc *var) { | 442 | static void lua_pushvar (LexState *ls, vardesc *var) { |
| 433 | switch (var->k) { | 443 | switch (var->k) { |
| 434 | case VLOCAL: | 444 | case VLOCAL: |
| @@ -452,16 +462,16 @@ static void lua_pushvar (LexState *ls, vardesc *var) { | |||
| 452 | } | 462 | } |
| 453 | 463 | ||
| 454 | 464 | ||
| 455 | static void storevar (LexState *ls, vardesc *var) { | 465 | static void genstorevar (LexState *ls, vardesc *var, OpCode *codes) { |
| 456 | switch (var->k) { | 466 | switch (var->k) { |
| 457 | case VLOCAL: | 467 | case VLOCAL: |
| 458 | code_oparg(ls, SETLOCAL, var->info, -1); | 468 | code_oparg(ls, codes[0], var->info, -1); |
| 459 | break; | 469 | break; |
| 460 | case VGLOBAL: | 470 | case VGLOBAL: |
| 461 | code_oparg(ls, SETGLOBAL, var->info, -1); | 471 | code_oparg(ls, codes[1], var->info, -1); |
| 462 | break; | 472 | break; |
| 463 | case VINDEXED: | 473 | case VINDEXED: |
| 464 | code_opcode(ls, SETTABLE0, -3); | 474 | code_opcode(ls, codes[2], -3); |
| 465 | break; | 475 | break; |
| 466 | default: | 476 | default: |
| 467 | LUA_INTERNALERROR("invalid var kind to store"); | 477 | LUA_INTERNALERROR("invalid var kind to store"); |
| @@ -469,6 +479,12 @@ static void storevar (LexState *ls, vardesc *var) { | |||
| 469 | } | 479 | } |
| 470 | 480 | ||
| 471 | 481 | ||
| 482 | static void storevar (LexState *ls, vardesc *var) { | ||
| 483 | static OpCode codes[] = {SETLOCAL, SETGLOBAL, SETTABLE0}; | ||
| 484 | genstorevar(ls, var, codes); | ||
| 485 | } | ||
| 486 | |||
| 487 | |||
| 472 | static int fix_jump (LexState *ls, int pc, OpCode op, int n) { | 488 | static int fix_jump (LexState *ls, int pc, OpCode op, int n) { |
| 473 | /* jump is relative to position following jump instruction */ | 489 | /* jump is relative to position following jump instruction */ |
| 474 | return fix_opcode(ls, pc, op, n-(pc+JMPSIZE)); | 490 | return fix_opcode(ls, pc, op, n-(pc+JMPSIZE)); |
| @@ -932,6 +948,21 @@ static void exp0 (LexState *ls, vardesc *v) { | |||
| 932 | } | 948 | } |
| 933 | 949 | ||
| 934 | 950 | ||
| 951 | static void Gexp (LexState *ls, vardesc *v) { | ||
| 952 | /* Gexp -> exp0 | var '=' exp1 */ | ||
| 953 | static OpCode codes[] = {SETLOCALDUP, SETGLOBALDUP, SETTABLEDUP}; | ||
| 954 | exp0(ls, v); | ||
| 955 | if (ls->token == '=' && v->k != VEXP) { /* assignment expression? */ | ||
| 956 | next(ls); /* skip '=' */ | ||
| 957 | unloaddot(ls, v); | ||
| 958 | exp1(ls); | ||
| 959 | genstorevar(ls, v, codes); | ||
| 960 | deltastack(ls, 1); /* DUP operations push an extra value */ | ||
| 961 | v->k = VEXP; v->info = 0; | ||
| 962 | } | ||
| 963 | } | ||
| 964 | |||
| 965 | |||
| 935 | static void push (LexState *ls, stack_op *s, int op) { | 966 | static void push (LexState *ls, stack_op *s, int op) { |
| 936 | if (s->top == MAXOPS) | 967 | if (s->top == MAXOPS) |
| 937 | luaX_error(ls, "expression too complex"); | 968 | luaX_error(ls, "expression too complex"); |
| @@ -993,9 +1024,9 @@ static void simpleexp (LexState *ls, vardesc *v, stack_op *s) { | |||
| 993 | ifpart(ls, 1, ls->linenumber); | 1024 | ifpart(ls, 1, ls->linenumber); |
| 994 | break; | 1025 | break; |
| 995 | 1026 | ||
| 996 | case '(': /* simpleexp -> '(' exp0 ')' */ | 1027 | case '(': /* simpleexp -> '(' Gexp ')' */ |
| 997 | next(ls); | 1028 | next(ls); |
| 998 | exp0(ls, v); | 1029 | Gexp(ls, v); |
| 999 | check(ls, ')'); | 1030 | check(ls, ')'); |
| 1000 | return; | 1031 | return; |
| 1001 | 1032 | ||
| @@ -1206,13 +1237,10 @@ static void decinit (LexState *ls, listdesc *d) { | |||
| 1206 | } | 1237 | } |
| 1207 | } | 1238 | } |
| 1208 | 1239 | ||
| 1240 | |||
| 1209 | static int assignment (LexState *ls, vardesc *v, int nvars) { | 1241 | static int assignment (LexState *ls, vardesc *v, int nvars) { |
| 1210 | int left = 0; | 1242 | int left = 0; |
| 1211 | /* dotted variables <a.x> must be stored like regular indexed vars <a["x"]> */ | 1243 | unloaddot(ls, v); |
| 1212 | if (v->k == VDOT) { | ||
| 1213 | code_constant(ls, v->info); | ||
| 1214 | v->k = VINDEXED; | ||
| 1215 | } | ||
| 1216 | if (ls->token == ',') { /* assignment -> ',' NAME assignment */ | 1244 | if (ls->token == ',') { /* assignment -> ',' NAME assignment */ |
| 1217 | vardesc nv; | 1245 | vardesc nv; |
| 1218 | next(ls); | 1246 | next(ls); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 1.41 1999/01/25 17:39:28 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.42 1999/02/02 17:57:49 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 | */ |
| @@ -330,12 +330,24 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base) { | |||
| 330 | register int aux = 0; | 330 | register int aux = 0; |
| 331 | switch ((OpCode)*pc++) { | 331 | switch ((OpCode)*pc++) { |
| 332 | 332 | ||
| 333 | case ENDCODE: aux = 1; | ||
| 334 | S->top = S->stack + base; | ||
| 335 | /* goes through */ | ||
| 336 | case RETCODE: | ||
| 337 | if (lua_callhook) | ||
| 338 | luaD_callHook(base, NULL, 1); | ||
| 339 | return base + (aux ? 0 : *pc); | ||
| 340 | |||
| 333 | case PUSHNIL: aux = *pc++; | 341 | case PUSHNIL: aux = *pc++; |
| 334 | do { | 342 | do { |
| 335 | ttype(S->top++) = LUA_T_NIL; | 343 | ttype(S->top++) = LUA_T_NIL; |
| 336 | } while (aux--); | 344 | } while (aux--); |
| 337 | break; | 345 | break; |
| 338 | 346 | ||
| 347 | case POP: aux = *pc++; | ||
| 348 | S->top -= (aux+1); | ||
| 349 | break; | ||
| 350 | |||
| 339 | case PUSHNUMBERW: aux = highbyte(*pc++); | 351 | case PUSHNUMBERW: aux = highbyte(*pc++); |
| 340 | case PUSHNUMBER: aux += *pc++; | 352 | case PUSHNUMBER: aux += *pc++; |
| 341 | ttype(S->top) = LUA_T_NUMBER; | 353 | ttype(S->top) = LUA_T_NUMBER; |
| @@ -343,6 +355,15 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base) { | |||
| 343 | S->top++; | 355 | S->top++; |
| 344 | break; | 356 | break; |
| 345 | 357 | ||
| 358 | case PUSHCONSTANTW: aux = highbyte(*pc++); | ||
| 359 | case PUSHCONSTANT: aux += *pc++; | ||
| 360 | *S->top++ = consts[aux]; | ||
| 361 | break; | ||
| 362 | |||
| 363 | case PUSHUPVALUE: aux = *pc++; | ||
| 364 | *S->top++ = cl->consts[aux+1]; | ||
| 365 | break; | ||
| 366 | |||
| 346 | case PUSHLOCAL: aux = *pc++; | 367 | case PUSHLOCAL: aux = *pc++; |
| 347 | *S->top++ = *((S->stack+base) + aux); | 368 | *S->top++ = *((S->stack+base) + aux); |
| 348 | break; | 369 | break; |
| @@ -371,28 +392,45 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base) { | |||
| 371 | break; | 392 | break; |
| 372 | } | 393 | } |
| 373 | 394 | ||
| 374 | case PUSHCONSTANTW: aux = highbyte(*pc++); | 395 | case CREATEARRAYW: aux = highbyte(*pc++); |
| 375 | case PUSHCONSTANT: aux += *pc++; | 396 | case CREATEARRAY: aux += *pc++; |
| 376 | *S->top++ = consts[aux]; | 397 | luaC_checkGC(); |
| 377 | break; | 398 | avalue(S->top) = luaH_new(aux); |
| 378 | 399 | ttype(S->top) = LUA_T_ARRAY; | |
| 379 | case PUSHUPVALUE: aux = *pc++; | 400 | S->top++; |
| 380 | *S->top++ = cl->consts[aux+1]; | ||
| 381 | break; | 401 | break; |
| 382 | 402 | ||
| 383 | case SETLOCAL: aux = *pc++; | 403 | case SETLOCAL: aux = *pc++; |
| 384 | *((S->stack+base) + aux) = *(--S->top); | 404 | *((S->stack+base) + aux) = *(--S->top); |
| 385 | break; | 405 | break; |
| 386 | 406 | ||
| 407 | case SETLOCALDUP: aux = *pc++; | ||
| 408 | *((S->stack+base) + aux) = *(S->top-1); | ||
| 409 | break; | ||
| 410 | |||
| 387 | case SETGLOBALW: aux = highbyte(*pc++); | 411 | case SETGLOBALW: aux = highbyte(*pc++); |
| 388 | case SETGLOBAL: aux += *pc++; | 412 | case SETGLOBAL: aux += *pc++; |
| 389 | luaV_setglobal(tsvalue(&consts[aux])); | 413 | luaV_setglobal(tsvalue(&consts[aux])); |
| 390 | break; | 414 | break; |
| 391 | 415 | ||
| 416 | case SETGLOBALDUPW: aux = highbyte(*pc++); | ||
| 417 | case SETGLOBALDUP: aux += *pc++; | ||
| 418 | *S->top = *(S->top-1); | ||
| 419 | S->top++; | ||
| 420 | luaV_setglobal(tsvalue(&consts[aux])); | ||
| 421 | break; | ||
| 422 | |||
| 392 | case SETTABLE0: | 423 | case SETTABLE0: |
| 393 | luaV_settable(S->top-3, 0); | 424 | luaV_settable(S->top-3, 0); |
| 394 | break; | 425 | break; |
| 395 | 426 | ||
| 427 | case SETTABLEDUP: { | ||
| 428 | TObject temp = *(S->top-1); | ||
| 429 | luaV_settable(S->top-3, 0); | ||
| 430 | *(S->top++) = temp; | ||
| 431 | break; | ||
| 432 | } | ||
| 433 | |||
| 396 | case SETTABLE: | 434 | case SETTABLE: |
| 397 | luaV_settable(S->top-3-(*pc++), 1); | 435 | luaV_settable(S->top-3-(*pc++), 1); |
| 398 | break; | 436 | break; |
| @@ -416,18 +454,6 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base) { | |||
| 416 | break; | 454 | break; |
| 417 | } | 455 | } |
| 418 | 456 | ||
| 419 | case POP: aux = *pc++; | ||
| 420 | S->top -= (aux+1); | ||
| 421 | break; | ||
| 422 | |||
| 423 | case CREATEARRAYW: aux = highbyte(*pc++); | ||
| 424 | case CREATEARRAY: aux += *pc++; | ||
| 425 | luaC_checkGC(); | ||
| 426 | avalue(S->top) = luaH_new(aux); | ||
| 427 | ttype(S->top) = LUA_T_ARRAY; | ||
| 428 | S->top++; | ||
| 429 | break; | ||
| 430 | |||
| 431 | case NEQOP: aux = 1; | 457 | case NEQOP: aux = 1; |
| 432 | case EQOP: { | 458 | case EQOP: { |
| 433 | int res = luaO_equalObj(S->top-2, S->top-1); | 459 | int res = luaO_equalObj(S->top-2, S->top-1); |
| @@ -579,14 +605,6 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base) { | |||
| 579 | break; | 605 | break; |
| 580 | } | 606 | } |
| 581 | 607 | ||
| 582 | case ENDCODE: aux = 1; | ||
| 583 | S->top = S->stack + base; | ||
| 584 | /* goes through */ | ||
| 585 | case RETCODE: | ||
| 586 | if (lua_callhook) | ||
| 587 | luaD_callHook(base, NULL, 1); | ||
| 588 | return base + (aux ? 0 : *pc); | ||
| 589 | |||
| 590 | case SETLINEW: aux = highbyte(*pc++); | 608 | case SETLINEW: aux = highbyte(*pc++); |
| 591 | case SETLINE: aux += *pc++; | 609 | case SETLINE: aux += *pc++; |
| 592 | if ((S->stack+base-1)->ttype != LUA_T_LINE) { | 610 | if ((S->stack+base-1)->ttype != LUA_T_LINE) { |
| @@ -600,10 +618,6 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base) { | |||
| 600 | luaD_lineHook(aux); | 618 | luaD_lineHook(aux); |
| 601 | break; | 619 | break; |
| 602 | 620 | ||
| 603 | #ifdef DEBUG | ||
| 604 | default: | ||
| 605 | LUA_INTERNALERROR("opcode doesn't match"); | ||
| 606 | #endif | ||
| 607 | } | 621 | } |
| 608 | } | 622 | } |
| 609 | } | 623 | } |
