Update LuaJIT to the latest 2.1.0 source (1d8b747)

This commit is contained in:
Alex Szpakowski
2020-10-12 18:09:06 -03:00
parent ec1ceaf373
commit 72540d2d5a
214 changed files with 4738 additions and 3800 deletions
+17 -8
View File
@@ -1,6 +1,6 @@
/*
** Lexical analyzer.
** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2020 Mike Pall. See Copyright Notice in luajit.h
**
** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@@ -48,6 +48,12 @@ static LJ_NOINLINE LexChar lex_more(LexState *ls)
size_t sz;
const char *p = ls->rfunc(ls->L, ls->rdata, &sz);
if (p == NULL || sz == 0) return LEX_EOF;
if (sz >= LJ_MAX_BUF) {
if (sz != ~(size_t)0) lj_err_mem(ls->L);
sz = ~(uintptr_t)0 - (uintptr_t)p;
if (sz >= LJ_MAX_BUF) sz = LJ_MAX_BUF-1;
ls->endmark = 1;
}
ls->pe = p + sz;
ls->p = p + 1;
return (LexChar)(uint8_t)p[0];
@@ -76,7 +82,7 @@ static LJ_AINLINE LexChar lex_savenext(LexState *ls)
static void lex_newline(LexState *ls)
{
LexChar old = ls->c;
lua_assert(lex_iseol(ls));
lj_assertLS(lex_iseol(ls), "bad usage");
lex_next(ls); /* Skip "\n" or "\r". */
if (lex_iseol(ls) && ls->c != old) lex_next(ls); /* Skip "\n\r" or "\r\n". */
if (++ls->linenumber >= LJ_MAX_LINE)
@@ -90,7 +96,7 @@ static void lex_number(LexState *ls, TValue *tv)
{
StrScanFmt fmt;
LexChar c, xp = 'e';
lua_assert(lj_char_isdigit(ls->c));
lj_assertLS(lj_char_isdigit(ls->c), "bad usage");
if ((c = ls->c) == '0' && (lex_savenext(ls) | 0x20) == 'x')
xp = 'p';
while (lj_char_isident(ls->c) || ls->c == '.' ||
@@ -99,7 +105,7 @@ static void lex_number(LexState *ls, TValue *tv)
lex_savenext(ls);
}
lex_save(ls, '\0');
fmt = lj_strscan_scan((const uint8_t *)sbufB(&ls->sb), tv,
fmt = lj_strscan_scan((const uint8_t *)sbufB(&ls->sb), sbuflen(&ls->sb)-1, tv,
(LJ_DUALNUM ? STRSCAN_OPT_TOINT : STRSCAN_OPT_TONUM) |
(LJ_HASFFI ? (STRSCAN_OPT_LL|STRSCAN_OPT_IMAG) : 0));
if (LJ_DUALNUM && fmt == STRSCAN_INT) {
@@ -110,7 +116,8 @@ static void lex_number(LexState *ls, TValue *tv)
} else if (fmt != STRSCAN_ERROR) {
lua_State *L = ls->L;
GCcdata *cd;
lua_assert(fmt == STRSCAN_I64 || fmt == STRSCAN_U64 || fmt == STRSCAN_IMAG);
lj_assertLS(fmt == STRSCAN_I64 || fmt == STRSCAN_U64 || fmt == STRSCAN_IMAG,
"unexpected number format %d", fmt);
if (!ctype_ctsG(G(L))) {
ptrdiff_t oldtop = savestack(L, L->top);
luaopen_ffi(L); /* Load FFI library on-demand. */
@@ -127,7 +134,8 @@ static void lex_number(LexState *ls, TValue *tv)
lj_parse_keepcdata(ls, tv, cd);
#endif
} else {
lua_assert(fmt == STRSCAN_ERROR);
lj_assertLS(fmt == STRSCAN_ERROR,
"unexpected number format %d", fmt);
lj_lex_error(ls, TK_number, LJ_ERR_XNUMBER);
}
}
@@ -137,7 +145,7 @@ static int lex_skipeq(LexState *ls)
{
int count = 0;
LexChar s = ls->c;
lua_assert(s == '[' || s == ']');
lj_assertLS(s == '[' || s == ']', "bad usage");
while (lex_savenext(ls) == '=' && count < 0x20000000)
count++;
return (ls->c == s) ? count : (-count) - 1;
@@ -406,6 +414,7 @@ int lj_lex_setup(lua_State *L, LexState *ls)
ls->lookahead = TK_eof; /* No look-ahead token. */
ls->linenumber = 1;
ls->lastline = 1;
ls->endmark = 0;
lex_next(ls); /* Read-ahead first char. */
if (ls->c == 0xef && ls->p + 2 <= ls->pe && (uint8_t)ls->p[0] == 0xbb &&
(uint8_t)ls->p[1] == 0xbf) { /* Skip UTF-8 BOM (if buffered). */
@@ -462,7 +471,7 @@ void lj_lex_next(LexState *ls)
/* Look ahead for the next token. */
LexToken lj_lex_lookahead(LexState *ls)
{
lua_assert(ls->lookahead == TK_eof);
lj_assertLS(ls->lookahead == TK_eof, "double lookahead");
ls->lookahead = lex_scan(ls, &ls->lookaheadval);
return ls->lookahead;
}