diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-07-02 17:42:40 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-07-02 17:42:40 -0300 |
commit | 6a02bbe1e2f8ad1b98a077bd2aac44e776fd107c (patch) | |
tree | f9923894e45cf4fcfe40c69bd198cd263fcc5529 | |
parent | 7631c29b2f1d57866e2ab885aedc19c29e93a653 (diff) | |
download | lua-6a02bbe1e2f8ad1b98a077bd2aac44e776fd107c.tar.gz lua-6a02bbe1e2f8ad1b98a077bd2aac44e776fd107c.tar.bz2 lua-6a02bbe1e2f8ad1b98a077bd2aac44e776fd107c.zip |
better organization for fields in struct 'expdesc'
-rw-r--r-- | lcode.c | 85 | ||||
-rw-r--r-- | lcode.h | 4 | ||||
-rw-r--r-- | lparser.c | 28 | ||||
-rw-r--r-- | lparser.h | 12 |
4 files changed, 67 insertions, 62 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.c,v 2.46 2010/04/17 12:46:32 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 2.47 2010/06/30 14:11:17 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 | */ |
@@ -266,7 +266,7 @@ static void freereg (FuncState *fs, int reg) { | |||
266 | 266 | ||
267 | static void freeexp (FuncState *fs, expdesc *e) { | 267 | static void freeexp (FuncState *fs, expdesc *e) { |
268 | if (e->k == VNONRELOC) | 268 | if (e->k == VNONRELOC) |
269 | freereg(fs, e->u.s.info); | 269 | freereg(fs, e->u.info); |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
@@ -352,7 +352,7 @@ void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { | |||
352 | void luaK_setoneret (FuncState *fs, expdesc *e) { | 352 | void luaK_setoneret (FuncState *fs, expdesc *e) { |
353 | if (e->k == VCALL) { /* expression is an open function call? */ | 353 | if (e->k == VCALL) { /* expression is an open function call? */ |
354 | e->k = VNONRELOC; | 354 | e->k = VNONRELOC; |
355 | e->u.s.info = GETARG_A(getcode(fs, e)); | 355 | e->u.info = GETARG_A(getcode(fs, e)); |
356 | } | 356 | } |
357 | else if (e->k == VVARARG) { | 357 | else if (e->k == VVARARG) { |
358 | SETARG_B(getcode(fs, e), 2); | 358 | SETARG_B(getcode(fs, e), 2); |
@@ -368,20 +368,20 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) { | |||
368 | break; | 368 | break; |
369 | } | 369 | } |
370 | case VUPVAL: { | 370 | case VUPVAL: { |
371 | e->u.s.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.s.info, 0); | 371 | e->u.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.info, 0); |
372 | e->k = VRELOCABLE; | 372 | e->k = VRELOCABLE; |
373 | break; | 373 | break; |
374 | } | 374 | } |
375 | case VINDEXED: { | 375 | case VINDEXED: { |
376 | freereg(fs, e->u.s.aux); | 376 | freereg(fs, e->u.ind.idx); |
377 | freereg(fs, e->u.s.info); | 377 | freereg(fs, e->u.ind.t); |
378 | e->u.s.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.s.info, e->u.s.aux); | 378 | e->u.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.ind.t, e->u.ind.idx); |
379 | e->k = VRELOCABLE; | 379 | e->k = VRELOCABLE; |
380 | break; | 380 | break; |
381 | } | 381 | } |
382 | case VINDEXEDUP: { | 382 | case VINDEXEDUP: { |
383 | freereg(fs, e->u.s.aux); | 383 | freereg(fs, e->u.ind.idx); |
384 | e->u.s.info = luaK_codeABC(fs, OP_GETTABUP, 0, e->u.s.info, e->u.s.aux); | 384 | e->u.info = luaK_codeABC(fs, OP_GETTABUP, 0, e->u.ind.t, e->u.ind.idx); |
385 | e->k = VRELOCABLE; | 385 | e->k = VRELOCABLE; |
386 | break; | 386 | break; |
387 | } | 387 | } |
@@ -413,7 +413,7 @@ static void discharge2reg (FuncState *fs, expdesc *e, int reg) { | |||
413 | break; | 413 | break; |
414 | } | 414 | } |
415 | case VK: { | 415 | case VK: { |
416 | luaK_codek(fs, reg, e->u.s.info); | 416 | luaK_codek(fs, reg, e->u.info); |
417 | break; | 417 | break; |
418 | } | 418 | } |
419 | case VKNUM: { | 419 | case VKNUM: { |
@@ -426,8 +426,8 @@ static void discharge2reg (FuncState *fs, expdesc *e, int reg) { | |||
426 | break; | 426 | break; |
427 | } | 427 | } |
428 | case VNONRELOC: { | 428 | case VNONRELOC: { |
429 | if (reg != e->u.s.info) | 429 | if (reg != e->u.info) |
430 | luaK_codeABC(fs, OP_MOVE, reg, e->u.s.info, 0); | 430 | luaK_codeABC(fs, OP_MOVE, reg, e->u.info, 0); |
431 | break; | 431 | break; |
432 | } | 432 | } |
433 | default: { | 433 | default: { |
@@ -435,7 +435,7 @@ static void discharge2reg (FuncState *fs, expdesc *e, int reg) { | |||
435 | return; /* nothing to do... */ | 435 | return; /* nothing to do... */ |
436 | } | 436 | } |
437 | } | 437 | } |
438 | e->u.s.info = reg; | 438 | e->u.info = reg; |
439 | e->k = VNONRELOC; | 439 | e->k = VNONRELOC; |
440 | } | 440 | } |
441 | 441 | ||
@@ -451,7 +451,7 @@ static void discharge2anyreg (FuncState *fs, expdesc *e) { | |||
451 | static void exp2reg (FuncState *fs, expdesc *e, int reg) { | 451 | static void exp2reg (FuncState *fs, expdesc *e, int reg) { |
452 | discharge2reg(fs, e, reg); | 452 | discharge2reg(fs, e, reg); |
453 | if (e->k == VJMP) | 453 | if (e->k == VJMP) |
454 | luaK_concat(fs, &e->t, e->u.s.info); /* put this jump in `t' list */ | 454 | luaK_concat(fs, &e->t, e->u.info); /* put this jump in `t' list */ |
455 | if (hasjumps(e)) { | 455 | if (hasjumps(e)) { |
456 | int final; /* position after whole expression */ | 456 | int final; /* position after whole expression */ |
457 | int p_f = NO_JUMP; /* position of an eventual LOAD false */ | 457 | int p_f = NO_JUMP; /* position of an eventual LOAD false */ |
@@ -467,7 +467,7 @@ static void exp2reg (FuncState *fs, expdesc *e, int reg) { | |||
467 | patchlistaux(fs, e->t, final, reg, p_t); | 467 | patchlistaux(fs, e->t, final, reg, p_t); |
468 | } | 468 | } |
469 | e->f = e->t = NO_JUMP; | 469 | e->f = e->t = NO_JUMP; |
470 | e->u.s.info = reg; | 470 | e->u.info = reg; |
471 | e->k = VNONRELOC; | 471 | e->k = VNONRELOC; |
472 | } | 472 | } |
473 | 473 | ||
@@ -483,14 +483,14 @@ void luaK_exp2nextreg (FuncState *fs, expdesc *e) { | |||
483 | int luaK_exp2anyreg (FuncState *fs, expdesc *e) { | 483 | int luaK_exp2anyreg (FuncState *fs, expdesc *e) { |
484 | luaK_dischargevars(fs, e); | 484 | luaK_dischargevars(fs, e); |
485 | if (e->k == VNONRELOC) { | 485 | if (e->k == VNONRELOC) { |
486 | if (!hasjumps(e)) return e->u.s.info; /* exp is already in a register */ | 486 | if (!hasjumps(e)) return e->u.info; /* exp is already in a register */ |
487 | if (e->u.s.info >= fs->nactvar) { /* reg. is not a local? */ | 487 | if (e->u.info >= fs->nactvar) { /* reg. is not a local? */ |
488 | exp2reg(fs, e, e->u.s.info); /* put value on it */ | 488 | exp2reg(fs, e, e->u.info); /* put value on it */ |
489 | return e->u.s.info; | 489 | return e->u.info; |
490 | } | 490 | } |
491 | } | 491 | } |
492 | luaK_exp2nextreg(fs, e); /* default */ | 492 | luaK_exp2nextreg(fs, e); /* default */ |
493 | return e->u.s.info; | 493 | return e->u.info; |
494 | } | 494 | } |
495 | 495 | ||
496 | 496 | ||
@@ -515,20 +515,20 @@ int luaK_exp2RK (FuncState *fs, expdesc *e) { | |||
515 | case VFALSE: | 515 | case VFALSE: |
516 | case VNIL: { | 516 | case VNIL: { |
517 | if (fs->nk <= MAXINDEXRK) { /* constant fits in RK operand? */ | 517 | if (fs->nk <= MAXINDEXRK) { /* constant fits in RK operand? */ |
518 | e->u.s.info = (e->k == VNIL) ? nilK(fs) : boolK(fs, (e->k == VTRUE)); | 518 | e->u.info = (e->k == VNIL) ? nilK(fs) : boolK(fs, (e->k == VTRUE)); |
519 | e->k = VK; | 519 | e->k = VK; |
520 | return RKASK(e->u.s.info); | 520 | return RKASK(e->u.info); |
521 | } | 521 | } |
522 | else break; | 522 | else break; |
523 | } | 523 | } |
524 | case VKNUM: { | 524 | case VKNUM: { |
525 | e->u.s.info = luaK_numberK(fs, e->u.nval); | 525 | e->u.info = luaK_numberK(fs, e->u.nval); |
526 | e->k = VK; | 526 | e->k = VK; |
527 | /* go through */ | 527 | /* go through */ |
528 | } | 528 | } |
529 | case VK: { | 529 | case VK: { |
530 | if (e->u.s.info <= MAXINDEXRK) /* constant fits in argC? */ | 530 | if (e->u.info <= MAXINDEXRK) /* constant fits in argC? */ |
531 | return RKASK(e->u.s.info); | 531 | return RKASK(e->u.info); |
532 | else break; | 532 | else break; |
533 | } | 533 | } |
534 | default: break; | 534 | default: break; |
@@ -542,22 +542,22 @@ void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { | |||
542 | switch (var->k) { | 542 | switch (var->k) { |
543 | case VLOCAL: { | 543 | case VLOCAL: { |
544 | freeexp(fs, ex); | 544 | freeexp(fs, ex); |
545 | exp2reg(fs, ex, var->u.s.info); | 545 | exp2reg(fs, ex, var->u.info); |
546 | return; | 546 | return; |
547 | } | 547 | } |
548 | case VUPVAL: { | 548 | case VUPVAL: { |
549 | int e = luaK_exp2anyreg(fs, ex); | 549 | int e = luaK_exp2anyreg(fs, ex); |
550 | luaK_codeABC(fs, OP_SETUPVAL, e, var->u.s.info, 0); | 550 | luaK_codeABC(fs, OP_SETUPVAL, e, var->u.info, 0); |
551 | break; | 551 | break; |
552 | } | 552 | } |
553 | case VINDEXED: { | 553 | case VINDEXED: { |
554 | int e = luaK_exp2RK(fs, ex); | 554 | int e = luaK_exp2RK(fs, ex); |
555 | luaK_codeABC(fs, OP_SETTABLE, var->u.s.info, var->u.s.aux, e); | 555 | luaK_codeABC(fs, OP_SETTABLE, var->u.ind.t, var->u.ind.idx, e); |
556 | break; | 556 | break; |
557 | } | 557 | } |
558 | case VINDEXEDUP: { | 558 | case VINDEXEDUP: { |
559 | int e = luaK_exp2RK(fs, ex); | 559 | int e = luaK_exp2RK(fs, ex); |
560 | luaK_codeABC(fs, OP_SETTABUP, var->u.s.info, var->u.s.aux, e); | 560 | luaK_codeABC(fs, OP_SETTABUP, var->u.ind.t, var->u.ind.idx, e); |
561 | break; | 561 | break; |
562 | } | 562 | } |
563 | default: { | 563 | default: { |
@@ -574,16 +574,16 @@ void luaK_self (FuncState *fs, expdesc *e, expdesc *key) { | |||
574 | luaK_exp2anyreg(fs, e); | 574 | luaK_exp2anyreg(fs, e); |
575 | freeexp(fs, e); | 575 | freeexp(fs, e); |
576 | func = fs->freereg; | 576 | func = fs->freereg; |
577 | luaK_codeABC(fs, OP_SELF, func, e->u.s.info, luaK_exp2RK(fs, key)); | 577 | luaK_codeABC(fs, OP_SELF, func, e->u.info, luaK_exp2RK(fs, key)); |
578 | freeexp(fs, key); | 578 | freeexp(fs, key); |
579 | luaK_reserveregs(fs, 2); | 579 | luaK_reserveregs(fs, 2); |
580 | e->u.s.info = func; | 580 | e->u.info = func; |
581 | e->k = VNONRELOC; | 581 | e->k = VNONRELOC; |
582 | } | 582 | } |
583 | 583 | ||
584 | 584 | ||
585 | static void invertjump (FuncState *fs, expdesc *e) { | 585 | static void invertjump (FuncState *fs, expdesc *e) { |
586 | Instruction *pc = getjumpcontrol(fs, e->u.s.info); | 586 | Instruction *pc = getjumpcontrol(fs, e->u.info); |
587 | lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET && | 587 | lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET && |
588 | GET_OPCODE(*pc) != OP_TEST); | 588 | GET_OPCODE(*pc) != OP_TEST); |
589 | SETARG_A(*pc, !(GETARG_A(*pc))); | 589 | SETARG_A(*pc, !(GETARG_A(*pc))); |
@@ -601,7 +601,7 @@ static int jumponcond (FuncState *fs, expdesc *e, int cond) { | |||
601 | } | 601 | } |
602 | discharge2anyreg(fs, e); | 602 | discharge2anyreg(fs, e); |
603 | freeexp(fs, e); | 603 | freeexp(fs, e); |
604 | return condjump(fs, OP_TESTSET, NO_REG, e->u.s.info, cond); | 604 | return condjump(fs, OP_TESTSET, NO_REG, e->u.info, cond); |
605 | } | 605 | } |
606 | 606 | ||
607 | 607 | ||
@@ -615,7 +615,7 @@ void luaK_goiftrue (FuncState *fs, expdesc *e) { | |||
615 | } | 615 | } |
616 | case VJMP: { | 616 | case VJMP: { |
617 | invertjump(fs, e); | 617 | invertjump(fs, e); |
618 | pc = e->u.s.info; | 618 | pc = e->u.info; |
619 | break; | 619 | break; |
620 | } | 620 | } |
621 | case VFALSE: { | 621 | case VFALSE: { |
@@ -645,7 +645,7 @@ static void luaK_goiffalse (FuncState *fs, expdesc *e) { | |||
645 | break; | 645 | break; |
646 | } | 646 | } |
647 | case VJMP: { | 647 | case VJMP: { |
648 | pc = e->u.s.info; | 648 | pc = e->u.info; |
649 | break; | 649 | break; |
650 | } | 650 | } |
651 | case VTRUE: { | 651 | case VTRUE: { |
@@ -685,7 +685,7 @@ static void codenot (FuncState *fs, expdesc *e) { | |||
685 | case VNONRELOC: { | 685 | case VNONRELOC: { |
686 | discharge2anyreg(fs, e); | 686 | discharge2anyreg(fs, e); |
687 | freeexp(fs, e); | 687 | freeexp(fs, e); |
688 | e->u.s.info = luaK_codeABC(fs, OP_NOT, 0, e->u.s.info, 0); | 688 | e->u.info = luaK_codeABC(fs, OP_NOT, 0, e->u.info, 0); |
689 | e->k = VRELOCABLE; | 689 | e->k = VRELOCABLE; |
690 | break; | 690 | break; |
691 | } | 691 | } |
@@ -703,7 +703,8 @@ static void codenot (FuncState *fs, expdesc *e) { | |||
703 | 703 | ||
704 | void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { | 704 | void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { |
705 | lua_assert(!hasjumps(t)); | 705 | lua_assert(!hasjumps(t)); |
706 | t->u.s.aux = luaK_exp2RK(fs, k); | 706 | t->u.ind.t = t->u.info; |
707 | t->u.ind.idx = luaK_exp2RK(fs, k); | ||
707 | t->k = (t->k == VUPVAL) ? VINDEXEDUP : VINDEXED; | 708 | t->k = (t->k == VUPVAL) ? VINDEXEDUP : VINDEXED; |
708 | } | 709 | } |
709 | 710 | ||
@@ -734,7 +735,7 @@ static void codearith (FuncState *fs, OpCode op, | |||
734 | freeexp(fs, e2); | 735 | freeexp(fs, e2); |
735 | freeexp(fs, e1); | 736 | freeexp(fs, e1); |
736 | } | 737 | } |
737 | e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2); | 738 | e1->u.info = luaK_codeABC(fs, op, 0, o1, o2); |
738 | e1->k = VRELOCABLE; | 739 | e1->k = VRELOCABLE; |
739 | luaK_fixline(fs, line); | 740 | luaK_fixline(fs, line); |
740 | } | 741 | } |
@@ -752,7 +753,7 @@ static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1, | |||
752 | temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */ | 753 | temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */ |
753 | cond = 1; | 754 | cond = 1; |
754 | } | 755 | } |
755 | e1->u.s.info = condjump(fs, op, cond, o1, o2); | 756 | e1->u.info = condjump(fs, op, cond, o1, o2); |
756 | e1->k = VJMP; | 757 | e1->k = VJMP; |
757 | } | 758 | } |
758 | 759 | ||
@@ -828,10 +829,10 @@ void luaK_posfix (FuncState *fs, BinOpr op, | |||
828 | case OPR_CONCAT: { | 829 | case OPR_CONCAT: { |
829 | luaK_exp2val(fs, e2); | 830 | luaK_exp2val(fs, e2); |
830 | if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) { | 831 | if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) { |
831 | lua_assert(e1->u.s.info == GETARG_B(getcode(fs, e2))-1); | 832 | lua_assert(e1->u.info == GETARG_B(getcode(fs, e2))-1); |
832 | freeexp(fs, e1); | 833 | freeexp(fs, e1); |
833 | SETARG_B(getcode(fs, e2), e1->u.s.info); | 834 | SETARG_B(getcode(fs, e2), e1->u.info); |
834 | e1->k = VRELOCABLE; e1->u.s.info = e2->u.s.info; | 835 | e1->k = VRELOCABLE; e1->u.info = e2->u.info; |
835 | } | 836 | } |
836 | else { | 837 | else { |
837 | luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ | 838 | luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.h,v 1.53 2010/02/26 20:40:29 roberto Exp roberto $ | 2 | ** $Id: lcode.h,v 1.54 2010/04/17 12:46:32 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 | */ |
@@ -36,7 +36,7 @@ typedef enum BinOpr { | |||
36 | typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; | 36 | typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; |
37 | 37 | ||
38 | 38 | ||
39 | #define getcode(fs,e) ((fs)->f->code[(e)->u.s.info]) | 39 | #define getcode(fs,e) ((fs)->f->code[(e)->u.info]) |
40 | 40 | ||
41 | #define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) | 41 | #define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) |
42 | 42 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 2.87 2010/05/31 16:08:55 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 2.88 2010/06/21 16:30:12 roberto Exp roberto $ |
3 | ** Lua Parser | 3 | ** Lua Parser |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -138,7 +138,7 @@ static TString *str_checkname (LexState *ls) { | |||
138 | static void init_exp (expdesc *e, expkind k, int i) { | 138 | static void init_exp (expdesc *e, expkind k, int i) { |
139 | e->f = e->t = NO_JUMP; | 139 | e->f = e->t = NO_JUMP; |
140 | e->k = k; | 140 | e->k = k; |
141 | e->u.s.info = i; | 141 | e->u.info = i; |
142 | } | 142 | } |
143 | 143 | ||
144 | 144 | ||
@@ -226,7 +226,7 @@ static int newupvalue (FuncState *fs, TString *name, expdesc *v) { | |||
226 | Upvaldesc, MAXUPVAL, "upvalues"); | 226 | Upvaldesc, MAXUPVAL, "upvalues"); |
227 | while (oldsize < f->sizeupvalues) f->upvalues[oldsize++].name = NULL; | 227 | while (oldsize < f->sizeupvalues) f->upvalues[oldsize++].name = NULL; |
228 | f->upvalues[fs->nups].instack = (v->k == VLOCAL); | 228 | f->upvalues[fs->nups].instack = (v->k == VLOCAL); |
229 | f->upvalues[fs->nups].idx = cast_byte(v->u.s.info); | 229 | f->upvalues[fs->nups].idx = cast_byte(v->u.info); |
230 | f->upvalues[fs->nups].name = name; | 230 | f->upvalues[fs->nups].name = name; |
231 | luaC_objbarrier(fs->L, f, name); | 231 | luaC_objbarrier(fs->L, f, name); |
232 | return fs->nups++; | 232 | return fs->nups++; |
@@ -518,7 +518,7 @@ static void recfield (LexState *ls, struct ConsControl *cc) { | |||
518 | checknext(ls, '='); | 518 | checknext(ls, '='); |
519 | rkkey = luaK_exp2RK(fs, &key); | 519 | rkkey = luaK_exp2RK(fs, &key); |
520 | expr(ls, &val); | 520 | expr(ls, &val); |
521 | luaK_codeABC(fs, OP_SETTABLE, cc->t->u.s.info, rkkey, luaK_exp2RK(fs, &val)); | 521 | luaK_codeABC(fs, OP_SETTABLE, cc->t->u.info, rkkey, luaK_exp2RK(fs, &val)); |
522 | fs->freereg = reg; /* free registers */ | 522 | fs->freereg = reg; /* free registers */ |
523 | } | 523 | } |
524 | 524 | ||
@@ -528,7 +528,7 @@ static void closelistfield (FuncState *fs, struct ConsControl *cc) { | |||
528 | luaK_exp2nextreg(fs, &cc->v); | 528 | luaK_exp2nextreg(fs, &cc->v); |
529 | cc->v.k = VVOID; | 529 | cc->v.k = VVOID; |
530 | if (cc->tostore == LFIELDS_PER_FLUSH) { | 530 | if (cc->tostore == LFIELDS_PER_FLUSH) { |
531 | luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); /* flush */ | 531 | luaK_setlist(fs, cc->t->u.info, cc->na, cc->tostore); /* flush */ |
532 | cc->tostore = 0; /* no more items pending */ | 532 | cc->tostore = 0; /* no more items pending */ |
533 | } | 533 | } |
534 | } | 534 | } |
@@ -538,13 +538,13 @@ static void lastlistfield (FuncState *fs, struct ConsControl *cc) { | |||
538 | if (cc->tostore == 0) return; | 538 | if (cc->tostore == 0) return; |
539 | if (hasmultret(cc->v.k)) { | 539 | if (hasmultret(cc->v.k)) { |
540 | luaK_setmultret(fs, &cc->v); | 540 | luaK_setmultret(fs, &cc->v); |
541 | luaK_setlist(fs, cc->t->u.s.info, cc->na, LUA_MULTRET); | 541 | luaK_setlist(fs, cc->t->u.info, cc->na, LUA_MULTRET); |
542 | cc->na--; /* do not count last expression (unknown number of elements) */ | 542 | cc->na--; /* do not count last expression (unknown number of elements) */ |
543 | } | 543 | } |
544 | else { | 544 | else { |
545 | if (cc->v.k != VVOID) | 545 | if (cc->v.k != VVOID) |
546 | luaK_exp2nextreg(fs, &cc->v); | 546 | luaK_exp2nextreg(fs, &cc->v); |
547 | luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); | 547 | luaK_setlist(fs, cc->t->u.info, cc->na, cc->tostore); |
548 | } | 548 | } |
549 | } | 549 | } |
550 | 550 | ||
@@ -702,7 +702,7 @@ static void funcargs (LexState *ls, expdesc *f, int line) { | |||
702 | } | 702 | } |
703 | } | 703 | } |
704 | lua_assert(f->k == VNONRELOC); | 704 | lua_assert(f->k == VNONRELOC); |
705 | base = f->u.s.info; /* base register for call */ | 705 | base = f->u.info; /* base register for call */ |
706 | if (hasmultret(args.k)) | 706 | if (hasmultret(args.k)) |
707 | nparams = LUA_MULTRET; /* open call */ | 707 | nparams = LUA_MULTRET; /* open call */ |
708 | else { | 708 | else { |
@@ -976,20 +976,20 @@ static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v, | |||
976 | int conflict = 0; | 976 | int conflict = 0; |
977 | for (; lh; lh = lh->prev) { | 977 | for (; lh; lh = lh->prev) { |
978 | if (lh->v.k == ix) { | 978 | if (lh->v.k == ix) { |
979 | if (lh->v.u.s.info == v->u.s.info) { /* conflict? */ | 979 | if (lh->v.u.ind.t == v->u.info) { /* conflict? */ |
980 | conflict = 1; | 980 | conflict = 1; |
981 | lh->v.k = VINDEXED; | 981 | lh->v.k = VINDEXED; |
982 | lh->v.u.s.info = extra; /* previous assignment will use safe copy */ | 982 | lh->v.u.ind.t = extra; /* previous assignment will use safe copy */ |
983 | } | 983 | } |
984 | if (v->k == VLOCAL && lh->v.u.s.aux == v->u.s.info) { /* conflict? */ | 984 | if (v->k == VLOCAL && lh->v.u.ind.idx == v->u.info) { /* conflict? */ |
985 | conflict = 1; | 985 | conflict = 1; |
986 | lua_assert(lh->v.k == VINDEXED); | 986 | lua_assert(lh->v.k == VINDEXED); |
987 | lh->v.u.s.aux = extra; /* previous assignment will use safe copy */ | 987 | lh->v.u.ind.idx = extra; /* previous assignment will use safe copy */ |
988 | } | 988 | } |
989 | } | 989 | } |
990 | } | 990 | } |
991 | if (conflict) { | 991 | if (conflict) { |
992 | luaK_codeABC(fs, op, fs->freereg, v->u.s.info, 0); /* make copy */ | 992 | luaK_codeABC(fs, op, fs->freereg, v->u.info, 0); /* make copy */ |
993 | luaK_reserveregs(fs, 1); | 993 | luaK_reserveregs(fs, 1); |
994 | } | 994 | } |
995 | } | 995 | } |
@@ -1108,7 +1108,7 @@ static int exp1 (LexState *ls) { | |||
1108 | expr(ls, &e); | 1108 | expr(ls, &e); |
1109 | luaK_exp2nextreg(ls->fs, &e); | 1109 | luaK_exp2nextreg(ls->fs, &e); |
1110 | lua_assert(e.k == VNONRELOC); | 1110 | lua_assert(e.k == VNONRELOC); |
1111 | reg = e.u.s.info; | 1111 | reg = e.u.info; |
1112 | return reg; | 1112 | return reg; |
1113 | } | 1113 | } |
1114 | 1114 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.h,v 1.62 2010/02/26 20:40:29 roberto Exp roberto $ | 2 | ** $Id: lparser.h,v 1.63 2010/03/12 19:14:06 roberto Exp roberto $ |
3 | ** Lua Parser | 3 | ** Lua Parser |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -25,8 +25,8 @@ typedef enum { | |||
25 | VKNUM, /* nval = numerical value */ | 25 | VKNUM, /* nval = numerical value */ |
26 | VLOCAL, /* info = local register */ | 26 | VLOCAL, /* info = local register */ |
27 | VUPVAL, /* info = index of upvalue in 'upvalues' */ | 27 | VUPVAL, /* info = index of upvalue in 'upvalues' */ |
28 | VINDEXED, /* info = table R/K; aux = index R/K */ | 28 | VINDEXED, /* t = table register; idx = index R/K */ |
29 | VINDEXEDUP, /* info = table upvalue; aux = R/K */ | 29 | VINDEXEDUP, /* t = table upvalue; idx = index R/K */ |
30 | VJMP, /* info = instruction pc */ | 30 | VJMP, /* info = instruction pc */ |
31 | VRELOCABLE, /* info = instruction pc */ | 31 | VRELOCABLE, /* info = instruction pc */ |
32 | VNONRELOC, /* info = result register */ | 32 | VNONRELOC, /* info = result register */ |
@@ -38,7 +38,11 @@ typedef enum { | |||
38 | typedef struct expdesc { | 38 | typedef struct expdesc { |
39 | expkind k; | 39 | expkind k; |
40 | union { | 40 | union { |
41 | struct { int info, aux; } s; | 41 | struct { |
42 | short idx; | ||
43 | lu_byte t; | ||
44 | } ind; /* for indexed variables */ | ||
45 | int info; | ||
42 | lua_Number nval; | 46 | lua_Number nval; |
43 | } u; | 47 | } u; |
44 | int t; /* patch list of `exit when true' */ | 48 | int t; /* patch list of `exit when true' */ |