diff options
-rw-r--r-- | lcode.c | 32 | ||||
-rw-r--r-- | lparser.c | 6 | ||||
-rw-r--r-- | lparser.h | 6 |
3 files changed, 22 insertions, 22 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.c,v 2.142 2017/12/04 17:41:30 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 2.143 2017/12/13 18:32:09 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 | */ |
@@ -632,7 +632,7 @@ void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { | |||
632 | ** vararg), it already returns one result, so nothing needs to be done. | 632 | ** vararg), it already returns one result, so nothing needs to be done. |
633 | ** Function calls become VNONRELOC expressions (as its result comes | 633 | ** Function calls become VNONRELOC expressions (as its result comes |
634 | ** fixed in the base register of the call), while vararg expressions | 634 | ** fixed in the base register of the call), while vararg expressions |
635 | ** become VRELOCABLE (as OP_VARARG puts its results where it wants). | 635 | ** become VRELOC (as OP_VARARG puts its results where it wants). |
636 | ** (Calls are created returning one result, so that does not need | 636 | ** (Calls are created returning one result, so that does not need |
637 | ** to be fixed.) | 637 | ** to be fixed.) |
638 | */ | 638 | */ |
@@ -645,7 +645,7 @@ void luaK_setoneret (FuncState *fs, expdesc *e) { | |||
645 | } | 645 | } |
646 | else if (e->k == VVARARG) { | 646 | else if (e->k == VVARARG) { |
647 | SETARG_B(getinstruction(fs, e), 2); | 647 | SETARG_B(getinstruction(fs, e), 2); |
648 | e->k = VRELOCABLE; /* can relocate its simple result */ | 648 | e->k = VRELOC; /* can relocate its simple result */ |
649 | } | 649 | } |
650 | } | 650 | } |
651 | 651 | ||
@@ -661,30 +661,30 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) { | |||
661 | } | 661 | } |
662 | case VUPVAL: { /* move value to some (pending) register */ | 662 | case VUPVAL: { /* move value to some (pending) register */ |
663 | e->u.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.info, 0); | 663 | e->u.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.info, 0); |
664 | e->k = VRELOCABLE; | 664 | e->k = VRELOC; |
665 | break; | 665 | break; |
666 | } | 666 | } |
667 | case VINDEXUP: { | 667 | case VINDEXUP: { |
668 | e->u.info = luaK_codeABC(fs, OP_GETTABUP, 0, e->u.ind.t, e->u.ind.idx); | 668 | e->u.info = luaK_codeABC(fs, OP_GETTABUP, 0, e->u.ind.t, e->u.ind.idx); |
669 | e->k = VRELOCABLE; | 669 | e->k = VRELOC; |
670 | break; | 670 | break; |
671 | } | 671 | } |
672 | case VINDEXI: { | 672 | case VINDEXI: { |
673 | freereg(fs, e->u.ind.t); | 673 | freereg(fs, e->u.ind.t); |
674 | e->u.info = luaK_codeABC(fs, OP_GETI, 0, e->u.ind.t, e->u.ind.idx); | 674 | e->u.info = luaK_codeABC(fs, OP_GETI, 0, e->u.ind.t, e->u.ind.idx); |
675 | e->k = VRELOCABLE; | 675 | e->k = VRELOC; |
676 | break; | 676 | break; |
677 | } | 677 | } |
678 | case VINDEXSTR: { | 678 | case VINDEXSTR: { |
679 | freereg(fs, e->u.ind.t); | 679 | freereg(fs, e->u.ind.t); |
680 | e->u.info = luaK_codeABC(fs, OP_GETFIELD, 0, e->u.ind.t, e->u.ind.idx); | 680 | e->u.info = luaK_codeABC(fs, OP_GETFIELD, 0, e->u.ind.t, e->u.ind.idx); |
681 | e->k = VRELOCABLE; | 681 | e->k = VRELOC; |
682 | break; | 682 | break; |
683 | } | 683 | } |
684 | case VINDEXED: { | 684 | case VINDEXED: { |
685 | freeregs(fs, e->u.ind.t, e->u.ind.idx); | 685 | freeregs(fs, e->u.ind.t, e->u.ind.idx); |
686 | e->u.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.ind.t, e->u.ind.idx); | 686 | e->u.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.ind.t, e->u.ind.idx); |
687 | e->k = VRELOCABLE; | 687 | e->k = VRELOC; |
688 | break; | 688 | break; |
689 | } | 689 | } |
690 | case VVARARG: case VCALL: { | 690 | case VVARARG: case VCALL: { |
@@ -723,7 +723,7 @@ static void discharge2reg (FuncState *fs, expdesc *e, int reg) { | |||
723 | luaK_int(fs, reg, e->u.ival); | 723 | luaK_int(fs, reg, e->u.ival); |
724 | break; | 724 | break; |
725 | } | 725 | } |
726 | case VRELOCABLE: { | 726 | case VRELOC: { |
727 | Instruction *pc = &getinstruction(fs, e); | 727 | Instruction *pc = &getinstruction(fs, e); |
728 | SETARG_A(*pc, reg); /* instruction will put result in 'reg' */ | 728 | SETARG_A(*pc, reg); /* instruction will put result in 'reg' */ |
729 | break; | 729 | break; |
@@ -963,7 +963,7 @@ static void negatecondition (FuncState *fs, expdesc *e) { | |||
963 | ** and removing the 'not'. | 963 | ** and removing the 'not'. |
964 | */ | 964 | */ |
965 | static int jumponcond (FuncState *fs, expdesc *e, int cond) { | 965 | static int jumponcond (FuncState *fs, expdesc *e, int cond) { |
966 | if (e->k == VRELOCABLE) { | 966 | if (e->k == VRELOC) { |
967 | Instruction ie = getinstruction(fs, e); | 967 | Instruction ie = getinstruction(fs, e); |
968 | if (GET_OPCODE(ie) == OP_NOT) { | 968 | if (GET_OPCODE(ie) == OP_NOT) { |
969 | fs->pc--; /* remove previous OP_NOT */ | 969 | fs->pc--; /* remove previous OP_NOT */ |
@@ -1048,12 +1048,12 @@ static void codenot (FuncState *fs, expdesc *e) { | |||
1048 | negatecondition(fs, e); | 1048 | negatecondition(fs, e); |
1049 | break; | 1049 | break; |
1050 | } | 1050 | } |
1051 | case VRELOCABLE: | 1051 | case VRELOC: |
1052 | case VNONRELOC: { | 1052 | case VNONRELOC: { |
1053 | discharge2anyreg(fs, e); | 1053 | discharge2anyreg(fs, e); |
1054 | freeexp(fs, e); | 1054 | freeexp(fs, e); |
1055 | e->u.info = luaK_codeABC(fs, OP_NOT, 0, e->u.info, 0); | 1055 | e->u.info = luaK_codeABC(fs, OP_NOT, 0, e->u.info, 0); |
1056 | e->k = VRELOCABLE; | 1056 | e->k = VRELOC; |
1057 | break; | 1057 | break; |
1058 | } | 1058 | } |
1059 | default: lua_assert(0); /* cannot happen */ | 1059 | default: lua_assert(0); /* cannot happen */ |
@@ -1191,7 +1191,7 @@ static void codeunexpval (FuncState *fs, OpCode op, expdesc *e, int line) { | |||
1191 | int r = luaK_exp2anyreg(fs, e); /* opcodes operate only on registers */ | 1191 | int r = luaK_exp2anyreg(fs, e); /* opcodes operate only on registers */ |
1192 | freeexp(fs, e); | 1192 | freeexp(fs, e); |
1193 | e->u.info = luaK_codeABC(fs, op, 0, r, 0); /* generate opcode */ | 1193 | e->u.info = luaK_codeABC(fs, op, 0, r, 0); /* generate opcode */ |
1194 | e->k = VRELOCABLE; /* all those operations are relocatable */ | 1194 | e->k = VRELOC; /* all those operations are relocatable */ |
1195 | luaK_fixline(fs, line); | 1195 | luaK_fixline(fs, line); |
1196 | } | 1196 | } |
1197 | 1197 | ||
@@ -1200,7 +1200,7 @@ static void finishbinexpval (FuncState *fs, expdesc *e1, expdesc *e2, | |||
1200 | int pc, int line) { | 1200 | int pc, int line) { |
1201 | freeexps(fs, e1, e2); | 1201 | freeexps(fs, e1, e2); |
1202 | e1->u.info = pc; | 1202 | e1->u.info = pc; |
1203 | e1->k = VRELOCABLE; /* all those operations are relocatable */ | 1203 | e1->k = VRELOC; /* all those operations are relocatable */ |
1204 | luaK_fixline(fs, line); | 1204 | luaK_fixline(fs, line); |
1205 | } | 1205 | } |
1206 | 1206 | ||
@@ -1474,12 +1474,12 @@ void luaK_posfix (FuncState *fs, BinOpr opr, | |||
1474 | } | 1474 | } |
1475 | case OPR_CONCAT: { | 1475 | case OPR_CONCAT: { |
1476 | luaK_exp2val(fs, e2); | 1476 | luaK_exp2val(fs, e2); |
1477 | if (e2->k == VRELOCABLE && | 1477 | if (e2->k == VRELOC && |
1478 | GET_OPCODE(getinstruction(fs, e2)) == OP_CONCAT) { | 1478 | GET_OPCODE(getinstruction(fs, e2)) == OP_CONCAT) { |
1479 | lua_assert(e1->u.info == GETARG_B(getinstruction(fs, e2))-1); | 1479 | lua_assert(e1->u.info == GETARG_B(getinstruction(fs, e2))-1); |
1480 | freeexp(fs, e1); | 1480 | freeexp(fs, e1); |
1481 | SETARG_B(getinstruction(fs, e2), e1->u.info); | 1481 | SETARG_B(getinstruction(fs, e2), e1->u.info); |
1482 | e1->k = VRELOCABLE; e1->u.info = e2->u.info; | 1482 | e1->k = VRELOC; e1->u.info = e2->u.info; |
1483 | } | 1483 | } |
1484 | else { | 1484 | else { |
1485 | luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ | 1485 | luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 2.169 2017/11/30 13:29:18 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 2.170 2017/12/06 18:36:31 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 | */ |
@@ -533,7 +533,7 @@ static Proto *addprototype (LexState *ls) { | |||
533 | */ | 533 | */ |
534 | static void codeclosure (LexState *ls, expdesc *v) { | 534 | static void codeclosure (LexState *ls, expdesc *v) { |
535 | FuncState *fs = ls->fs->prev; | 535 | FuncState *fs = ls->fs->prev; |
536 | init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np - 1)); | 536 | init_exp(v, VRELOC, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np - 1)); |
537 | luaK_exp2nextreg(fs, v); /* fix it at the last register */ | 537 | luaK_exp2nextreg(fs, v); /* fix it at the last register */ |
538 | } | 538 | } |
539 | 539 | ||
@@ -740,7 +740,7 @@ static void constructor (LexState *ls, expdesc *t) { | |||
740 | struct ConsControl cc; | 740 | struct ConsControl cc; |
741 | cc.na = cc.nh = cc.tostore = 0; | 741 | cc.na = cc.nh = cc.tostore = 0; |
742 | cc.t = t; | 742 | cc.t = t; |
743 | init_exp(t, VRELOCABLE, pc); | 743 | init_exp(t, VRELOC, pc); |
744 | init_exp(&cc.v, VVOID, 0); /* no value (yet) */ | 744 | init_exp(&cc.v, VVOID, 0); /* no value (yet) */ |
745 | luaK_exp2nextreg(ls->fs, t); /* fix it at stack top */ | 745 | luaK_exp2nextreg(ls->fs, t); /* fix it at stack top */ |
746 | checknext(ls, '{'); | 746 | checknext(ls, '{'); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.h,v 1.78 2017/06/27 11:35:31 roberto Exp roberto $ | 2 | ** $Id: lparser.h,v 1.79 2017/11/30 13:29:18 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 | */ |
@@ -49,8 +49,8 @@ typedef enum { | |||
49 | ind.idx = key's K index */ | 49 | ind.idx = key's K index */ |
50 | VJMP, /* expression is a test/comparison; | 50 | VJMP, /* expression is a test/comparison; |
51 | info = pc of corresponding jump instruction */ | 51 | info = pc of corresponding jump instruction */ |
52 | VRELOCABLE, /* expression can put result in any register; | 52 | VRELOC, /* expression can put result in any register; |
53 | info = instruction pc */ | 53 | info = instruction pc */ |
54 | VCALL, /* expression is a function call; info = instruction pc */ | 54 | VCALL, /* expression is a function call; info = instruction pc */ |
55 | VVARARG /* vararg expression; info = instruction pc */ | 55 | VVARARG /* vararg expression; info = instruction pc */ |
56 | } expkind; | 56 | } expkind; |