diff options
Diffstat (limited to 'lcode.c')
-rw-r--r-- | lcode.c | 32 |
1 files changed, 16 insertions, 16 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' */ |