@@ -45,6 +45,7 @@ l_noret luaK_semerror (LexState *ls, const char *fmt, ...) {
4545 va_list argp ;
4646 pushvfstring (ls -> L , argp , fmt , msg );
4747 ls -> t .token = 0 ; /* remove "near <token>" from final message */
48+ ls -> linenumber = ls -> lastline ; /* back to line of last used token */
4849 luaX_syntaxerror (ls , msg );
4950}
5051
@@ -705,6 +706,22 @@ static void luaK_float (FuncState *fs, int reg, lua_Number f) {
705706}
706707
707708
709+ /*
710+ ** Get the value of 'var' in a register and generate an opcode to check
711+ ** whether that register is nil. 'k' is the index of the variable name
712+ ** in the list of constants. If its value cannot be encoded in Bx, a 0
713+ ** will use '?' for the name.
714+ */
715+ void luaK_codecheckglobal (FuncState * fs , expdesc * var , int k , int line ) {
716+ luaK_exp2anyreg (fs , var );
717+ luaK_fixline (fs , line );
718+ k = (k >= MAXARG_Bx ) ? 0 : k + 1 ;
719+ luaK_codeABx (fs , OP_ERRNNIL , var -> u .info , k );
720+ luaK_fixline (fs , line );
721+ freeexp (fs , var );
722+ }
723+
724+
708725/*
709726** Convert a constant in 'v' into an expression description 'e'
710727*/
@@ -1109,6 +1126,10 @@ void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
11091126 codeABRK (fs , OP_SETFIELD , var -> u .ind .t , var -> u .ind .idx , ex );
11101127 break ;
11111128 }
1129+ case VVARGIND : {
1130+ fs -> f -> flag |= PF_VATAB ; /* function will need a vararg table */
1131+ /* now, assignment is to a regular table */
1132+ } /* FALLTHROUGH */
11121133 case VINDEXED : {
11131134 codeABRK (fs , OP_SETTABLE , var -> u .ind .t , var -> u .ind .idx , ex );
11141135 break ;
@@ -1242,7 +1263,7 @@ static void codenot (FuncState *fs, expdesc *e) {
12421263** Check whether expression 'e' is a short literal string
12431264*/
12441265static int isKstr (FuncState * fs , expdesc * e ) {
1245- return (e -> k == VK && !hasjumps (e ) && e -> u .info <= MAXARG_B &&
1266+ return (e -> k == VK && !hasjumps (e ) && e -> u .info <= MAXINDEXRK &&
12461267 ttisshrstring (& fs -> f -> k [e -> u .info ]));
12471268}
12481269
0 commit comments