widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #13801
[Merge] lp:~widelands-dev/widelands/update_eris_to_1_1_2 into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/update_eris_to_1_1_2 into lp:widelands.
Commit message:
Updated Eris to version 1.1.2 (Lua 5.3.4)
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/update_eris_to_1_1_2/+merge/349095
Copied over the latest Eris release.
Merge ASAP after https://code.launchpad.net/~widelands-dev/widelands/bug-1732765-economy-refactoring/+merge/345277 has been merged.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/update_eris_to_1_1_2 into lp:widelands.
=== modified file 'src/map_io/map_scripting_packet.cc'
--- src/map_io/map_scripting_packet.cc 2018-04-07 16:59:00 +0000
+++ src/map_io/map_scripting_packet.cc 2018-07-08 12:35:11 +0000
@@ -37,7 +37,7 @@
namespace Widelands {
namespace {
-constexpr uint32_t kCurrentPacketVersion = 3;
+constexpr uint32_t kCurrentPacketVersion = 4;
// Write all .lua files that exist in the given 'path' in 'map_fs' to the 'target_fs'.
void write_lua_dir(FileSystem& target_fs, FileSystem* map_fs, const std::string& path) {
=== modified file 'src/third_party/eris/README.eris'
--- src/third_party/eris/README.eris 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/README.eris 2018-07-08 12:35:11 +0000
@@ -1,8 +1,8 @@
This directory contains a verbatim copy of Eris by Florian Nücke.
URL: https://github.com/fnuecke/eris
-VERSION: 683ac97476a8634d9e5c17f0dec8dff8b7f3e595 (Lua 5.3)
-SNAPSHOT: https://github.com/fnuecke/eris/commits/683ac97476a8634d9e5c17f0dec8dff8b7f3e595
+VERSION: 1.1.2 (Lua 5.3.4)
+TAG: https://github.com/fnuecke/eris/releases/tag/v1.1.2-lua5.3
We use this for heavy persistence and it also brings with it the Lua version
that we use in Widelands. The Widelands team wishes to expresses total and
=== modified file 'src/third_party/eris/eris.c'
--- src/third_party/eris/eris.c 2017-11-09 17:37:13 +0000
+++ src/third_party/eris/eris.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-Eris - Heavy-duty persistence for Lua 5.3.0 - Based on Pluto
+Eris - Heavy-duty persistence for Lua 5.3.4 - Based on Pluto
Copyright (c) 2013-2015 by Florian Nuecke.
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -29,9 +29,11 @@
#include <string.h>
/* Not using stdbool because Visual Studio lives in the past... */
+#ifndef __cplusplus
typedef int bool;
#define false 0
#define true 1
+#endif
/* Mark us as part of the Lua core to get access to what we need. */
#define LUA_CORE
@@ -151,11 +153,11 @@
/* Functions in Lua libraries used to access C functions we need to add to the
* permanents table to fully support yielded coroutines. */
-extern void eris_permbaselib(lua_State *L, bool forUnpersist);
-extern void eris_permcorolib(lua_State *L, bool forUnpersist);
-extern void eris_permloadlib(lua_State *L, bool forUnpersist);
-extern void eris_permiolib(lua_State *L, bool forUnpersist);
-extern void eris_permstrlib(lua_State *L, bool forUnpersist);
+extern void eris_permbaselib(lua_State *L, int forUnpersist);
+extern void eris_permcorolib(lua_State *L, int forUnpersist);
+extern void eris_permloadlib(lua_State *L, int forUnpersist);
+extern void eris_permiolib(lua_State *L, int forUnpersist);
+extern void eris_permstrlib(lua_State *L, int forUnpersist);
/* Utility macro for populating the perms table with internal C functions. */
#define populateperms(L, forUnpersist) {\
@@ -793,10 +795,10 @@
static lua_Integer
read_lua_Integer(Info *info) {
if (sizeof(lua_Integer) == sizeof(uint32_t)) {
- return (lua_Integer) read_uint32_t(info);
+ return (lua_Integer)read_uint32_t(info);
}
else if (sizeof(lua_Integer) == sizeof(uint64_t)) {
- return (lua_Integer) read_uint64_t(info);
+ return (lua_Integer)read_uint64_t(info);
}
else {
eris_error(info, ERIS_ERR_TYPE_INT);
@@ -893,7 +895,7 @@
{
/* TODO Can we avoid this copy somehow? (Without it getting too nasty) */
const size_t length = READ_VALUE(size_t);
- char *value = lua_newuserdata(info->L, length * sizeof(char)); /* ... tmp */
+ char *value = (char*)lua_newuserdata(info->L, length * sizeof(char)); /* ... tmp */
READ_RAW(value, length);
lua_pushlstring(info->L, value, length); /* ... tmp str */
lua_replace(info->L, -2); /* ... str */
@@ -1076,7 +1078,7 @@
lua_pushvalue(info->L, -2); /* ... obj func obj */
if (info->passIOToPersist) {
- lua_pushlightuserdata(info->L, info->u.pi.writer);
+ lua_pushlightuserdata(info->L, (void*)info->u.pi.writer);
/* ... obj func obj writer */
lua_pushlightuserdata(info->L, info->u.pi.ud);
/* ... obj func obj writer ud */
@@ -1196,7 +1198,7 @@
static void
p_proto(Info *info) { /* ... proto */
int i;
- const Proto *p = lua_touserdata(info->L, -1);
+ const Proto *p = (Proto*)lua_touserdata(info->L, -1);
eris_checkstack(info->L, 3);
/* Write general information. */
@@ -1286,7 +1288,7 @@
static void
u_proto(Info *info) { /* ... proto */
int i, n;
- Proto *p = lua_touserdata(info->L, -1);
+ Proto *p = (Proto*)lua_touserdata(info->L, -1);
eris_assert(p);
eris_checkstack(info->L, 2);
@@ -1334,9 +1336,9 @@
Proto *cp;
pushpath(info, "[%d]", i);
p->p[i] = eris_newproto(info->L);
- lua_pushlightuserdata(info->L, p->p[i]); /* ... proto nproto */
+ lua_pushlightuserdata(info->L, (void*)p->p[i]); /* ... proto nproto */
unpersist(info); /* ... proto nproto nproto/oproto */
- cp = lua_touserdata(info->L, -1);
+ cp = (Proto*)lua_touserdata(info->L, -1);
if (cp != p->p[i]) { /* ... proto nproto oproto */
/* Just overwrite it, GC will clean this up. */
p->p[i] = cp;
@@ -1591,7 +1593,7 @@
/* The proto we have now may differ, if we already unpersisted it before.
* In that case we now have a reference to the originally unpersisted
* proto so we'll use that. */
- p = lua_touserdata(info->L, -1);
+ p = (Proto*)lua_touserdata(info->L, -1);
if (p != cl->p) { /* ... lcl nproto oproto */
/* Just overwrite the old one, GC will clean this up. */
cl->p = p;
@@ -1802,7 +1804,7 @@
/* NOTE Ugly hack. We have to push the continuation function as a C
* function to properly track it in our ref table. It's never called,
* so we can get away with this. */
- lua_pushcfunction(info->L, (lua_CFunction) ci->u.c.k);
+ lua_pushcfunction(info->L, (lua_CFunction)ci->u.c.k);
/* ... thread func */
persist(info); /* ... thread func/nil */
lua_pop(info->L, 1); /* ... thread */
@@ -1980,7 +1982,7 @@
UNLOCK(thread);
if (lua_iscfunction(info->L, -1)) { /* ... thread func */
/* NOTE Ugly hack. See p_thread. */
- thread->ci->u.c.k = (lua_KFunction) lua_tocfunction(info->L, -1);
+ thread->ci->u.c.k = (lua_KFunction)lua_tocfunction(info->L, -1);
}
else {
eris_error(info, ERIS_ERR_THREADCTX);
@@ -2363,7 +2365,7 @@
eris_checkstack(L, 1);
newbuff = (char*)lua_newuserdata(L, newcapacity * sizeof(char));
/* perms reftbl buff path? ... nbuff */
- memcpy(newbuff, eris_buffer(buff), eris_bufflen(buff)); // NOLINT
+ memcpy(newbuff, eris_buffer(buff), eris_bufflen(buff));
lua_replace(L, BUFFIDX); /* perms reftbl nbuff path? ... */
eris_buffer(buff) = newbuff;
eris_sizebuffer(buff) = newcapacity;
=== modified file 'src/third_party/eris/eris.h'
--- src/third_party/eris/eris.h 2016-08-04 15:49:05 +0000
+++ src/third_party/eris/eris.h 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-Eris - Heavy-duty persistence for Lua 5.3.0 - Based on Pluto
+Eris - Heavy-duty persistence for Lua 5.3.4 - Based on Pluto
Copyright (c) 2013-2015 by Florian Nuecke.
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -26,10 +26,10 @@
#ifndef ERIS_H
#define ERIS_H
-#define ERIS_VERSION_MAJOR "1"
-#define ERIS_VERSION_MINOR "1"
-#define ERIS_VERSION_NUM 101
-#define ERIS_VERSION_RELEASE "0"
+#define ERIS_VERSION_MAJOR "1"
+#define ERIS_VERSION_MINOR "1"
+#define ERIS_VERSION_NUM 101
+#define ERIS_VERSION_RELEASE "2"
/*
** ==================================================================
@@ -114,7 +114,7 @@
*
* [-0, +1, e]
*/
-LUA_API void eris_get_setting(lua_State* L, const char* name);
+LUA_API void eris_get_setting(lua_State *L, const char *name);
/**
* Changes the value of a setting to a value on the stack.
@@ -126,7 +126,7 @@
*
* [-0, +0, e]
*/
-LUA_API void eris_set_setting(lua_State* L, const char* name, int value);
+LUA_API void eris_set_setting(lua_State *L, const char *name, int value);
/*
** ==================================================================
@@ -150,3 +150,4 @@
LUA_API int luaopen_eris(lua_State* L);
#endif
+
=== modified file 'src/third_party/eris/lapi.c'
--- src/third_party/eris/lapi.c 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/lapi.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: lapi.c,v 2.257 2015/11/02 18:48:07 roberto Exp $
+** $Id: lapi.c,v 2.259 2016/02/29 14:27:14 roberto Exp $
** Lua API
** See Copyright Notice in lua.h
*/
@@ -378,9 +378,9 @@
return NULL;
}
lua_lock(L); /* 'luaO_tostring' may create a new string */
+ luaO_tostring(L, o);
luaC_checkGC(L);
o = index2addr(L, idx); /* previous call may reallocate the stack */
- luaO_tostring(L, o);
lua_unlock(L);
}
if (len != NULL)
@@ -479,10 +479,10 @@
LUA_API const char *lua_pushlstring (lua_State *L, const char *s, size_t len) {
TString *ts;
lua_lock(L);
- luaC_checkGC(L);
ts = (len == 0) ? luaS_new(L, "") : luaS_newlstr(L, s, len);
setsvalue2s(L, L->top, ts);
api_incr_top(L);
+ luaC_checkGC(L);
lua_unlock(L);
return getstr(ts);
}
@@ -494,12 +494,12 @@
setnilvalue(L->top);
else {
TString *ts;
- luaC_checkGC(L);
ts = luaS_new(L, s);
setsvalue2s(L, L->top, ts);
s = getstr(ts); /* internal copy's address */
}
api_incr_top(L);
+ luaC_checkGC(L);
lua_unlock(L);
return s;
}
@@ -509,8 +509,8 @@
va_list argp) {
const char *ret;
lua_lock(L);
+ ret = luaO_pushvfstring(L, fmt, argp);
luaC_checkGC(L);
- ret = luaO_pushvfstring(L, fmt, argp);
lua_unlock(L);
return ret;
}
@@ -520,10 +520,10 @@
const char *ret;
va_list argp;
lua_lock(L);
- luaC_checkGC(L);
va_start(argp, fmt);
ret = luaO_pushvfstring(L, fmt, argp);
va_end(argp);
+ luaC_checkGC(L);
lua_unlock(L);
return ret;
}
@@ -538,7 +538,6 @@
CClosure *cl;
api_checknelems(L, n);
api_check(L, n <= MAXUPVAL, "upvalue index too large");
- luaC_checkGC(L);
cl = luaF_newCclosure(L, n);
cl->f = fn;
L->top -= n;
@@ -549,6 +548,7 @@
setclCvalue(L, L->top, cl);
}
api_incr_top(L);
+ luaC_checkGC(L);
lua_unlock(L);
}
@@ -585,16 +585,16 @@
static int auxgetstr (lua_State *L, const TValue *t, const char *k) {
- const TValue *aux;
+ const TValue *slot;
TString *str = luaS_new(L, k);
- if (luaV_fastget(L, t, str, aux, luaH_getstr)) {
- setobj2s(L, L->top, aux);
+ if (luaV_fastget(L, t, str, slot, luaH_getstr)) {
+ setobj2s(L, L->top, slot);
api_incr_top(L);
}
else {
setsvalue2s(L, L->top, str);
api_incr_top(L);
- luaV_finishget(L, t, L->top - 1, L->top - 1, aux);
+ luaV_finishget(L, t, L->top - 1, L->top - 1, slot);
}
lua_unlock(L);
return ttnov(L->top - 1);
@@ -626,17 +626,17 @@
LUA_API int lua_geti (lua_State *L, int idx, lua_Integer n) {
StkId t;
- const TValue *aux;
+ const TValue *slot;
lua_lock(L);
t = index2addr(L, idx);
- if (luaV_fastget(L, t, n, aux, luaH_getint)) {
- setobj2s(L, L->top, aux);
+ if (luaV_fastget(L, t, n, slot, luaH_getint)) {
+ setobj2s(L, L->top, slot);
api_incr_top(L);
}
else {
setivalue(L->top, n);
api_incr_top(L);
- luaV_finishget(L, t, L->top - 1, L->top - 1, aux);
+ luaV_finishget(L, t, L->top - 1, L->top - 1, slot);
}
lua_unlock(L);
return ttnov(L->top - 1);
@@ -683,12 +683,12 @@
LUA_API void lua_createtable (lua_State *L, int narray, int nrec) {
Table *t;
lua_lock(L);
- luaC_checkGC(L);
t = luaH_new(L);
sethvalue(L, L->top, t);
api_incr_top(L);
if (narray > 0 || nrec > 0)
luaH_resize(L, t, narray, nrec);
+ luaC_checkGC(L);
lua_unlock(L);
}
@@ -740,15 +740,15 @@
** t[k] = value at the top of the stack (where 'k' is a string)
*/
static void auxsetstr (lua_State *L, const TValue *t, const char *k) {
- const TValue *aux;
+ const TValue *slot;
TString *str = luaS_new(L, k);
api_checknelems(L, 1);
- if (luaV_fastset(L, t, str, aux, luaH_getstr, L->top - 1))
+ if (luaV_fastset(L, t, str, slot, luaH_getstr, L->top - 1))
L->top--; /* pop value */
else {
setsvalue2s(L, L->top, str); /* push 'str' (to make it a TValue) */
api_incr_top(L);
- luaV_finishset(L, t, L->top - 1, L->top - 2, aux);
+ luaV_finishset(L, t, L->top - 1, L->top - 2, slot);
L->top -= 2; /* pop value and key */
}
lua_unlock(L); /* lock done by caller */
@@ -781,16 +781,16 @@
LUA_API void lua_seti (lua_State *L, int idx, lua_Integer n) {
StkId t;
- const TValue *aux;
+ const TValue *slot;
lua_lock(L);
api_checknelems(L, 1);
t = index2addr(L, idx);
- if (luaV_fastset(L, t, n, aux, luaH_getint, L->top - 1))
+ if (luaV_fastset(L, t, n, slot, luaH_getint, L->top - 1))
L->top--; /* pop value */
else {
setivalue(L->top, n);
api_incr_top(L);
- luaV_finishset(L, t, L->top - 1, L->top - 2, aux);
+ luaV_finishset(L, t, L->top - 1, L->top - 2, slot);
L->top -= 2; /* pop value and key */
}
lua_unlock(L);
@@ -1140,7 +1140,6 @@
lua_lock(L);
api_checknelems(L, n);
if (n >= 2) {
- luaC_checkGC(L);
luaV_concat(L, n);
}
else if (n == 0) { /* push empty string */
@@ -1148,6 +1147,7 @@
api_incr_top(L);
}
/* else n == 1; nothing to do */
+ luaC_checkGC(L);
lua_unlock(L);
}
@@ -1183,10 +1183,10 @@
LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
Udata *u;
lua_lock(L);
- luaC_checkGC(L);
u = luaS_newudata(L, size);
setuvalue(L, L->top, u);
api_incr_top(L);
+ luaC_checkGC(L);
lua_unlock(L);
return getudatamem(u);
}
=== modified file 'src/third_party/eris/lapi.h'
--- src/third_party/eris/lapi.h 2016-08-04 15:49:05 +0000
+++ src/third_party/eris/lapi.h 2018-07-08 12:35:11 +0000
@@ -7,22 +7,18 @@
#ifndef lapi_h
#define lapi_h
+
#include "llimits.h"
#include "lstate.h"
-#define api_incr_top(L) \
- { \
- L->top++; \
- api_check(L, L->top <= L->ci->top, "stack overflow"); \
- }
-
-#define adjustresults(L, nres) \
- { \
- if ((nres) == LUA_MULTRET && L->ci->top < L->top) \
- L->ci->top = L->top; \
- }
-
-#define api_checknelems(L, n) \
- api_check(L, (n) < (L->top - L->ci->func), "not enough elements in the stack")
+#define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \
+ "stack overflow");}
+
+#define adjustresults(L,nres) \
+ { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; }
+
+#define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \
+ "not enough elements in the stack")
+
#endif
=== modified file 'src/third_party/eris/lauxlib.c'
--- src/third_party/eris/lauxlib.c 2017-11-09 17:37:13 +0000
+++ src/third_party/eris/lauxlib.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: lauxlib.c,v 1.284 2015/11/19 19:16:22 roberto Exp $
+** $Id: lauxlib.c,v 1.289 2016/12/20 18:37:00 roberto Exp $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@@ -17,7 +17,8 @@
#include <string.h>
-/* This file uses only the official API of Lua.
+/*
+** This file uses only the official API of Lua.
** Any function declared here could be written as an application function.
*/
@@ -68,12 +69,11 @@
/*
** Search for a name for a function in all loaded modules
-** (registry._LOADED).
*/
static int pushglobalfuncname (lua_State *L, lua_Debug *ar) {
int top = lua_gettop(L);
lua_getinfo(L, "f", ar); /* push function */
- lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED");
+ lua_getfield(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
if (findfield(L, top + 1, 2)) {
const char *name = lua_tostring(L, -1);
if (strncmp(name, "_G.", 3) == 0) { /* name start with '_G.'? */
@@ -198,6 +198,10 @@
}
+/*
+** The use of 'lua_pushfstring' ensures this function does not
+** need reserved stack space when called.
+*/
LUALIB_API void luaL_where (lua_State *L, int level) {
lua_Debug ar;
if (lua_getstack(L, level, &ar)) { /* check function at level */
@@ -207,10 +211,15 @@
return;
}
}
- lua_pushliteral(L, ""); /* else, no information available... */
+ lua_pushfstring(L, ""); /* else, no information available... */
}
+/*
+** Again, the use of 'lua_pushvfstring' ensures this function does
+** not need reserved stack space when called. (At worst, it generates
+** an error with "stack overflow" instead of the given message.)
+*/
LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) {
va_list argp;
va_start(argp, fmt);
@@ -349,10 +358,15 @@
}
+/*
+** Ensures the stack has at least 'space' extra slots, raising an error
+** if it cannot fulfill the request. (The error handling needs a few
+** extra slots to format the error message. In case of an error without
+** this extra space, Lua will generate the same 'stack overflow' error,
+** but without 'msg'.)
+*/
LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *msg) {
- /* keep some extra space to run error routines, if needed */
- const int extra = LUA_MINSTACK;
- if (!lua_checkstack(L, space + extra)) {
+ if (!lua_checkstack(L, space)) {
if (msg)
luaL_error(L, "stack overflow (%s)", msg);
else
@@ -502,7 +516,7 @@
newbuff = (char *)resizebox(L, -1, newsize);
else { /* no buffer yet */
newbuff = (char *)newbox(L, newsize);
- memcpy(newbuff, B->b, B->n * sizeof(char)); /* copy original content */ // NOLINT
+ memcpy(newbuff, B->b, B->n * sizeof(char)); /* copy original content */
}
B->b = newbuff;
B->size = newsize;
@@ -527,7 +541,7 @@
LUALIB_API void luaL_pushresult (luaL_Buffer *B) {
lua_State *L = B->L;
- lua_pushlstring(L, B->b, B->n); // NOLINT
+ lua_pushlstring(L, B->b, B->n);
if (buffonstack(B)) {
resizebox(L, -2, 0); /* delete old buffer */
lua_remove(L, -2); /* remove its header from the stack */
@@ -678,7 +692,7 @@
if (c == '#') { /* first line is a comment (Unix exec. file)? */
do { /* skip first line */
c = getc(lf->f);
- } while (c != EOF && c != '\n') ;
+ } while (c != EOF && c != '\n');
*cp = getc(lf->f); /* skip end-of-line, if present */
return 1; /* there was a comment */
}
@@ -794,13 +808,17 @@
LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) {
- if (!luaL_callmeta(L, idx, "__tostring")) { /* no metafield? */
+ if (luaL_callmeta(L, idx, "__tostring")) { /* metafield? */
+ if (!lua_isstring(L, -1))
+ luaL_error(L, "'__tostring' must return a string");
+ }
+ else {
switch (lua_type(L, idx)) {
case LUA_TNUMBER: {
if (lua_isinteger(L, idx))
- lua_pushfstring(L, "%I", lua_tointeger(L, idx));
+ lua_pushfstring(L, "%I", (LUAI_UACINT)lua_tointeger(L, idx));
else
- lua_pushfstring(L, "%f", lua_tonumber(L, idx));
+ lua_pushfstring(L, "%f", (LUAI_UACNUMBER)lua_tonumber(L, idx));
break;
}
case LUA_TSTRING:
@@ -812,10 +830,15 @@
case LUA_TNIL:
lua_pushliteral(L, "nil");
break;
- default:
- lua_pushfstring(L, "%s: %p", luaL_typename(L, idx),
- lua_topointer(L, idx));
+ default: {
+ int tt = luaL_getmetafield(L, idx, "__name"); /* try name */
+ const char *kind = (tt == LUA_TSTRING) ? lua_tostring(L, -1) :
+ luaL_typename(L, idx);
+ lua_pushfstring(L, "%s: %p", kind, lua_topointer(L, idx));
+ if (tt != LUA_TNIL)
+ lua_remove(L, -2); /* remove '__name' */
break;
+ }
}
}
return lua_tolstring(L, -1, len);
@@ -867,23 +890,23 @@
/*
** Find or create a module table with a given name. The function
-** first looks at the _LOADED table and, if that fails, try a
+** first looks at the LOADED table and, if that fails, try a
** global variable with that name. In any case, leaves on the stack
** the module table.
*/
LUALIB_API void luaL_pushmodule (lua_State *L, const char *modname,
int sizehint) {
- luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); /* get _LOADED table */
- if (lua_getfield(L, -1, modname) != LUA_TTABLE) { /* no _LOADED[modname]? */
+ luaL_findtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE, 1);
+ if (lua_getfield(L, -1, modname) != LUA_TTABLE) { /* no LOADED[modname]? */
lua_pop(L, 1); /* remove previous result */
/* try global variable (and create one if it does not exist) */
lua_pushglobaltable(L);
if (luaL_findtable(L, 0, modname, sizehint) != NULL)
luaL_error(L, "name conflict for module '%s'", modname);
lua_pushvalue(L, -1);
- lua_setfield(L, -3, modname); /* _LOADED[modname] = new table */
+ lua_setfield(L, -3, modname); /* LOADED[modname] = new table */
}
- lua_remove(L, -2); /* remove _LOADED table */
+ lua_remove(L, -2); /* remove LOADED table */
}
@@ -947,17 +970,17 @@
*/
LUALIB_API void luaL_requiref (lua_State *L, const char *modname,
lua_CFunction openf, int glb) {
- luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED");
- lua_getfield(L, -1, modname); /* _LOADED[modname] */
+ luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
+ lua_getfield(L, -1, modname); /* LOADED[modname] */
if (!lua_toboolean(L, -1)) { /* package not already loaded? */
lua_pop(L, 1); /* remove field */
lua_pushcfunction(L, openf);
lua_pushstring(L, modname); /* argument to open function */
lua_call(L, 1, 1); /* call 'openf' to open module */
lua_pushvalue(L, -1); /* make copy of module (call result) */
- lua_setfield(L, -3, modname); /* _LOADED[modname] = module */
+ lua_setfield(L, -3, modname); /* LOADED[modname] = module */
}
- lua_remove(L, -2); /* remove _LOADED table */
+ lua_remove(L, -2); /* remove LOADED table */
if (glb) {
lua_pushvalue(L, -1); /* copy of module */
lua_setglobal(L, modname); /* _G[modname] = module */
@@ -1015,6 +1038,6 @@
luaL_error(L, "multiple Lua VMs detected");
else if (*v != ver)
luaL_error(L, "version mismatch: app. needs %f, Lua core provides %f",
- ver, *v);
+ (LUAI_UACNUMBER)ver, (LUAI_UACNUMBER)*v);
}
=== modified file 'src/third_party/eris/lauxlib.h'
--- src/third_party/eris/lauxlib.h 2017-11-29 17:41:03 +0000
+++ src/third_party/eris/lauxlib.h 2018-07-08 12:35:11 +0000
@@ -1,92 +1,110 @@
/*
-** $Id: lauxlib.h,v 1.129 2015/11/23 11:29:43 roberto Exp $
+** $Id: lauxlib.h,v 1.131 2016/12/06 14:54:31 roberto Exp $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
+
#ifndef lauxlib_h
#define lauxlib_h
+
#include <stddef.h>
#include <stdio.h>
#include "lua.h"
-#ifdef __clang__
-#pragma clang diagnostic ignored "-Wunknown-pragmas"
-#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
-#endif
-
-/* extra error code for 'luaL_load' */
-#define LUA_ERRFILE (LUA_ERRERR + 1)
+
+
+/* extra error code for 'luaL_loadfilex' */
+#define LUA_ERRFILE (LUA_ERRERR+1)
+
+
+/* key, in the registry, for table of loaded modules */
+#define LUA_LOADED_TABLE "_LOADED"
+
+
+/* key, in the registry, for table of preloaded loaders */
+#define LUA_PRELOAD_TABLE "_PRELOAD"
+
typedef struct luaL_Reg {
- const char* name;
- lua_CFunction func;
+ const char *name;
+ lua_CFunction func;
} luaL_Reg;
-#define LUAL_NUMSIZES (sizeof(lua_Integer) * 16 + sizeof(lua_Number))
-
-LUALIB_API void(luaL_checkversion_)(lua_State* L, lua_Number ver, size_t sz);
-#define luaL_checkversion(L) luaL_checkversion_(L, LUA_VERSION_NUM, LUAL_NUMSIZES)
-
-LUALIB_API int(luaL_getmetafield)(lua_State* L, int obj, const char* e);
-LUALIB_API int(luaL_callmeta)(lua_State* L, int obj, const char* e);
-LUALIB_API const char*(luaL_tolstring)(lua_State* L, int idx, size_t* len);
-LUALIB_API int(luaL_argerror)(lua_State* L, int arg, const char* extramsg);
-LUALIB_API const char*(luaL_checklstring)(lua_State* L, int arg, size_t* l);
-LUALIB_API const char*(luaL_optlstring)(lua_State* L, int arg, const char* def, size_t* l);
-LUALIB_API lua_Number(luaL_checknumber)(lua_State* L, int arg);
-LUALIB_API lua_Number(luaL_optnumber)(lua_State* L, int arg, lua_Number def);
-
-LUALIB_API lua_Integer(luaL_checkinteger)(lua_State* L, int arg);
-LUALIB_API lua_Integer(luaL_optinteger)(lua_State* L, int arg, lua_Integer def);
-
-LUALIB_API void(luaL_checkstack)(lua_State* L, int sz, const char* msg);
-LUALIB_API void(luaL_checktype)(lua_State* L, int arg, int t);
-LUALIB_API void(luaL_checkany)(lua_State* L, int arg);
-
-LUALIB_API int(luaL_newmetatable)(lua_State* L, const char* tname);
-LUALIB_API void(luaL_setmetatable)(lua_State* L, const char* tname);
-LUALIB_API void*(luaL_testudata)(lua_State* L, int ud, const char* tname);
-LUALIB_API void*(luaL_checkudata)(lua_State* L, int ud, const char* tname);
-
-LUALIB_API void(luaL_where)(lua_State* L, int lvl);
-LUALIB_API int(luaL_error)(lua_State* L, const char* fmt, ...);
-
-LUALIB_API int(luaL_checkoption)(lua_State* L, int arg, const char* def, const char* const lst[]);
-
-LUALIB_API int(luaL_fileresult)(lua_State* L, int stat, const char* fname);
-LUALIB_API int(luaL_execresult)(lua_State* L, int stat);
+
+#define LUAL_NUMSIZES (sizeof(lua_Integer)*16 + sizeof(lua_Number))
+
+LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver, size_t sz);
+#define luaL_checkversion(L) \
+ luaL_checkversion_(L, LUA_VERSION_NUM, LUAL_NUMSIZES)
+
+LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
+LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);
+LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len);
+LUALIB_API int (luaL_argerror) (lua_State *L, int arg, const char *extramsg);
+LUALIB_API const char *(luaL_checklstring) (lua_State *L, int arg,
+ size_t *l);
+LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg,
+ const char *def, size_t *l);
+LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int arg);
+LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int arg, lua_Number def);
+
+LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int arg);
+LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int arg,
+ lua_Integer def);
+
+LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
+LUALIB_API void (luaL_checktype) (lua_State *L, int arg, int t);
+LUALIB_API void (luaL_checkany) (lua_State *L, int arg);
+
+LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname);
+LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname);
+LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname);
+LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname);
+
+LUALIB_API void (luaL_where) (lua_State *L, int lvl);
+LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
+
+LUALIB_API int (luaL_checkoption) (lua_State *L, int arg, const char *def,
+ const char *const lst[]);
+
+LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname);
+LUALIB_API int (luaL_execresult) (lua_State *L, int stat);
/* predefined references */
-#define LUA_NOREF (-2)
-#define LUA_REFNIL (-1)
-
-LUALIB_API int(luaL_ref)(lua_State* L, int t);
-LUALIB_API void(luaL_unref)(lua_State* L, int t, int ref);
-
-LUALIB_API int(luaL_loadfilex)(lua_State* L, const char* filename, const char* mode);
-
-#define luaL_loadfile(L, f) luaL_loadfilex(L, f, NULL)
-
-LUALIB_API int(luaL_loadbufferx)(
- lua_State* L, const char* buff, size_t sz, const char* name, const char* mode);
-LUALIB_API int(luaL_loadstring)(lua_State* L, const char* s);
-
-LUALIB_API lua_State*(luaL_newstate)(void);
-
-LUALIB_API lua_Integer(luaL_len)(lua_State* L, int idx);
-
-LUALIB_API const char*(luaL_gsub)(lua_State* L, const char* s, const char* p, const char* r);
-
-LUALIB_API void(luaL_setfuncs)(lua_State* L, const luaL_Reg* l, int nup);
-
-LUALIB_API int(luaL_getsubtable)(lua_State* L, int idx, const char* fname);
-
-LUALIB_API void(luaL_traceback)(lua_State* L, lua_State* L1, const char* msg, int level);
-
-LUALIB_API void(luaL_requiref)(lua_State* L, const char* modname, lua_CFunction openf, int glb);
+#define LUA_NOREF (-2)
+#define LUA_REFNIL (-1)
+
+LUALIB_API int (luaL_ref) (lua_State *L, int t);
+LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
+
+LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename,
+ const char *mode);
+
+#define luaL_loadfile(L,f) luaL_loadfilex(L,f,NULL)
+
+LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz,
+ const char *name, const char *mode);
+LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);
+
+LUALIB_API lua_State *(luaL_newstate) (void);
+
+LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx);
+
+LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p,
+ const char *r);
+
+LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup);
+
+LUALIB_API int (luaL_getsubtable) (lua_State *L, int idx, const char *fname);
+
+LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1,
+ const char *msg, int level);
+
+LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname,
+ lua_CFunction openf, int glb);
/*
** ===============================================================
@@ -94,26 +112,32 @@
** ===============================================================
*/
-#define luaL_newlibtable(L, l) lua_createtable(L, 0, sizeof(l) / sizeof((l)[0]) - 1)
-
-#define luaL_newlib(L, l) (luaL_checkversion(L), luaL_newlibtable(L, l), luaL_setfuncs(L, l, 0))
-
-#define luaL_argcheck(L, cond, arg, extramsg) \
- ((void)((cond) || luaL_argerror(L, (arg), (extramsg))))
-#define luaL_checkstring(L, n) (luaL_checklstring(L, (n), NULL))
-#define luaL_optstring(L, n, d) (luaL_optlstring(L, (n), (d), NULL))
-
-#define luaL_typename(L, i) lua_typename(L, lua_type(L, (i)))
-
-#define luaL_dofile(L, fn) (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
-
-#define luaL_dostring(L, s) (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
-
-#define luaL_getmetatable(L, n) (lua_getfield(L, LUA_REGISTRYINDEX, (n)))
-
-#define luaL_opt(L, f, n, d) (lua_isnoneornil(L, (n)) ? (d) : f(L, (n)))
-
-#define luaL_loadbuffer(L, s, sz, n) luaL_loadbufferx(L, s, sz, n, NULL)
+
+#define luaL_newlibtable(L,l) \
+ lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1)
+
+#define luaL_newlib(L,l) \
+ (luaL_checkversion(L), luaL_newlibtable(L,l), luaL_setfuncs(L,l,0))
+
+#define luaL_argcheck(L, cond,arg,extramsg) \
+ ((void)((cond) || luaL_argerror(L, (arg), (extramsg))))
+#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
+#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL))
+
+#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i)))
+
+#define luaL_dofile(L, fn) \
+ (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
+
+#define luaL_dostring(L, s) \
+ (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
+
+#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n)))
+
+#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
+
+#define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL)
+
/*
** {======================================================
@@ -122,31 +146,35 @@
*/
typedef struct luaL_Buffer {
- char* b; /* buffer address */
- size_t size; /* buffer size */
- size_t n; /* number of characters in buffer */
- lua_State* L;
- char initb[LUAL_BUFFERSIZE]; /* initial buffer */
+ char *b; /* buffer address */
+ size_t size; /* buffer size */
+ size_t n; /* number of characters in buffer */
+ lua_State *L;
+ char initb[LUAL_BUFFERSIZE]; /* initial buffer */
} luaL_Buffer;
-#define luaL_addchar(B, c) \
- ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), ((B)->b[(B)->n++] = (c)))
-
-#define luaL_addsize(B, s) ((B)->n += (s))
-
-LUALIB_API void(luaL_buffinit)(lua_State* L, luaL_Buffer* B);
-LUALIB_API char*(luaL_prepbuffsize)(luaL_Buffer* B, size_t sz);
-LUALIB_API void(luaL_addlstring)(luaL_Buffer* B, const char* s, size_t l);
-LUALIB_API void(luaL_addstring)(luaL_Buffer* B, const char* s);
-LUALIB_API void(luaL_addvalue)(luaL_Buffer* B);
-LUALIB_API void(luaL_pushresult)(luaL_Buffer* B);
-LUALIB_API void(luaL_pushresultsize)(luaL_Buffer* B, size_t sz);
-LUALIB_API char*(luaL_buffinitsize)(lua_State* L, luaL_Buffer* B, size_t sz);
-
-#define luaL_prepbuffer(B) luaL_prepbuffsize(B, LUAL_BUFFERSIZE)
+
+#define luaL_addchar(B,c) \
+ ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \
+ ((B)->b[(B)->n++] = (c)))
+
+#define luaL_addsize(B,s) ((B)->n += (s))
+
+LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);
+LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz);
+LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);
+LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s);
+LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);
+LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);
+LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz);
+LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz);
+
+#define luaL_prepbuffer(B) luaL_prepbuffsize(B, LUAL_BUFFERSIZE)
/* }====================================================== */
+
+
/*
** {======================================================
** File handles for IO library
@@ -159,25 +187,31 @@
** after that initial structure).
*/
-#define LUA_FILEHANDLE "FILE*"
+#define LUA_FILEHANDLE "FILE*"
+
typedef struct luaL_Stream {
- FILE* f; /* stream (NULL for incompletely created streams) */
- lua_CFunction closef; /* to close stream (NULL for closed streams) */
+ FILE *f; /* stream (NULL for incompletely created streams) */
+ lua_CFunction closef; /* to close stream (NULL for closed streams) */
} luaL_Stream;
/* }====================================================== */
+
+
/* compatibility with old module system */
#if defined(LUA_COMPAT_MODULE)
-LUALIB_API void(luaL_pushmodule)(lua_State* L, const char* modname, int sizehint);
-LUALIB_API void(luaL_openlib)(lua_State* L, const char* libname, const luaL_Reg* l, int nup);
+LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname,
+ int sizehint);
+LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname,
+ const luaL_Reg *l, int nup);
-#define luaL_register(L, n, l) (luaL_openlib(L, (n), (l), 0))
+#define luaL_register(L,n,l) (luaL_openlib(L,(n),(l),0))
#endif
+
/*
** {==================================================================
** "Abstraction Layer" for basic report of messages and errors
@@ -186,21 +220,23 @@
/* print a string */
#if !defined(lua_writestring)
-#define lua_writestring(s, l) fwrite((s), sizeof(char), (l), stdout)
+#define lua_writestring(s,l) fwrite((s), sizeof(char), (l), stdout)
#endif
/* print a newline and flush the output */
#if !defined(lua_writeline)
-#define lua_writeline() (lua_writestring("\n", 1), fflush(stdout))
+#define lua_writeline() (lua_writestring("\n", 1), fflush(stdout))
#endif
/* print an error message */
#if !defined(lua_writestringerror)
-#define lua_writestringerror(s, p) (fprintf(stderr, (s), (p)), fflush(stderr))
+#define lua_writestringerror(s,p) \
+ (fprintf(stderr, (s), (p)), fflush(stderr))
#endif
/* }================================================================== */
+
/*
** {============================================================
** Compatibility with deprecated conversions
@@ -208,16 +244,21 @@
*/
#if defined(LUA_COMPAT_APIINTCASTS)
-#define luaL_checkunsigned(L, a) ((lua_Unsigned)luaL_checkinteger(L, a))
-#define luaL_optunsigned(L, a, d) ((lua_Unsigned)luaL_optinteger(L, a, (lua_Integer)(d)))
-
-#define luaL_checkint(L, n) ((int)luaL_checkinteger(L, (n)))
-#define luaL_optint(L, n, d) ((int)luaL_optinteger(L, (n), (d)))
-
-#define luaL_checklong(L, n) ((long)luaL_checkinteger(L, (n)))
-#define luaL_optlong(L, n, d) ((long)luaL_optinteger(L, (n), (d)))
+#define luaL_checkunsigned(L,a) ((lua_Unsigned)luaL_checkinteger(L,a))
+#define luaL_optunsigned(L,a,d) \
+ ((lua_Unsigned)luaL_optinteger(L,a,(lua_Integer)(d)))
+
+#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))
+#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d)))
+
+#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n)))
+#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d)))
#endif
/* }============================================================ */
+
+
#endif
+
+
=== modified file 'src/third_party/eris/lbaselib.c'
--- src/third_party/eris/lbaselib.c 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/lbaselib.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: lbaselib.c,v 1.312 2015/10/29 15:21:04 roberto Exp $
+** $Id: lbaselib.c,v 1.314 2016/09/05 19:06:34 roberto Exp $
** Basic library
** See Copyright Notice in lua.h
*/
@@ -102,8 +102,8 @@
static int luaB_error (lua_State *L) {
int level = (int)luaL_optinteger(L, 2, 1);
lua_settop(L, 1);
- if (lua_isstring(L, 1) && level > 0) { /* add extra information? */
- luaL_where(L, level);
+ if (lua_type(L, 1) == LUA_TSTRING && level > 0) {
+ luaL_where(L, level); /* add extra information */
lua_pushvalue(L, 1);
lua_concat(L, 2);
}
@@ -208,8 +208,8 @@
static int pairsmeta (lua_State *L, const char *method, int iszero,
lua_CFunction iter) {
+ luaL_checkany(L, 1);
if (luaL_getmetafield(L, 1, method) == LUA_TNIL) { /* no metamethod? */
- luaL_checktype(L, 1, LUA_TTABLE); /* argument must be a table */
lua_pushcfunction(L, iter); /* will return generator, */
lua_pushvalue(L, 1); /* state, */
if (iszero) lua_pushinteger(L, 0); /* and initial value */
@@ -251,9 +251,8 @@
/*
-** This function will use either 'ipairsaux' or 'ipairsaux_raw' to
-** traverse a table, depending on whether the table has metamethods
-** that can affect the traversal.
+** 'ipairs' function. Returns 'ipairsaux', given "table", 0.
+** (The given "table" may not be a table.)
*/
static int luaB_ipairs (lua_State *L) {
#if defined(LUA_COMPAT_IPAIRS)
=== modified file 'src/third_party/eris/lcode.c'
--- src/third_party/eris/lcode.c 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/lcode.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: lcode.c,v 2.103 2015/11/19 19:16:22 roberto Exp $
+** $Id: lcode.c,v 2.112 2016/12/22 13:08:50 roberto Exp $
** Code generator for Lua
** See Copyright Notice in lua.h
*/
@@ -36,7 +36,11 @@
#define hasjumps(e) ((e)->t != (e)->f)
-static int tonumeral(expdesc *e, TValue *v) {
+/*
+** If expression is a numeric constant, fills 'v' with its value
+** and returns 1. Otherwise, returns 0.
+*/
+static int tonumeral(const expdesc *e, TValue *v) {
if (hasjumps(e))
return 0; /* not a numeral */
switch (e->k) {
@@ -51,13 +55,19 @@
}
+/*
+** Create a OP_LOADNIL instruction, but try to optimize: if the previous
+** instruction is also OP_LOADNIL and ranges are compatible, adjust
+** range of previous instruction instead of emitting a new one. (For
+** instance, 'local a; local b' will generate a single opcode.)
+*/
void luaK_nil (FuncState *fs, int from, int n) {
Instruction *previous;
int l = from + n - 1; /* last register to set nil */
if (fs->pc > fs->lasttarget) { /* no jumps to current position? */
previous = &fs->f->code[fs->pc-1];
- if (GET_OPCODE(*previous) == OP_LOADNIL) {
- int pfrom = GETARG_A(*previous);
+ if (GET_OPCODE(*previous) == OP_LOADNIL) { /* previous is LOADNIL? */
+ int pfrom = GETARG_A(*previous); /* get previous range */
int pl = pfrom + GETARG_B(*previous);
if ((pfrom <= from && from <= pl + 1) ||
(from <= pfrom && pfrom <= l + 1)) { /* can connect both? */
@@ -73,37 +83,84 @@
}
+/*
+** Gets the destination address of a jump instruction. Used to traverse
+** a list of jumps.
+*/
+static int getjump (FuncState *fs, int pc) {
+ int offset = GETARG_sBx(fs->f->code[pc]);
+ if (offset == NO_JUMP) /* point to itself represents end of list */
+ return NO_JUMP; /* end of list */
+ else
+ return (pc+1)+offset; /* turn offset into absolute position */
+}
+
+
+/*
+** Fix jump instruction at position 'pc' to jump to 'dest'.
+** (Jump addresses are relative in Lua)
+*/
+static void fixjump (FuncState *fs, int pc, int dest) {
+ Instruction *jmp = &fs->f->code[pc];
+ int offset = dest - (pc + 1);
+ lua_assert(dest != NO_JUMP);
+ if (abs(offset) > MAXARG_sBx)
+ luaX_syntaxerror(fs->ls, "control structure too long");
+ SETARG_sBx(*jmp, offset);
+}
+
+
+/*
+** Concatenate jump-list 'l2' into jump-list 'l1'
+*/
+void luaK_concat (FuncState *fs, int *l1, int l2) {
+ if (l2 == NO_JUMP) return; /* nothing to concatenate? */
+ else if (*l1 == NO_JUMP) /* no original list? */
+ *l1 = l2; /* 'l1' points to 'l2' */
+ else {
+ int list = *l1;
+ int next;
+ while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */
+ list = next;
+ fixjump(fs, list, l2); /* last element links to 'l2' */
+ }
+}
+
+
+/*
+** Create a jump instruction and return its position, so its destination
+** can be fixed later (with 'fixjump'). If there are jumps to
+** this position (kept in 'jpc'), link them all together so that
+** 'patchlistaux' will fix all them directly to the final destination.
+*/
int luaK_jump (FuncState *fs) {
int jpc = fs->jpc; /* save list of jumps to here */
int j;
- fs->jpc = NO_JUMP;
+ fs->jpc = NO_JUMP; /* no more jumps to here */
j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP);
luaK_concat(fs, &j, jpc); /* keep them on hold */
return j;
}
+/*
+** Code a 'return' instruction
+*/
void luaK_ret (FuncState *fs, int first, int nret) {
luaK_codeABC(fs, OP_RETURN, first, nret+1, 0);
}
+/*
+** Code a "conditional jump", that is, a test or comparison opcode
+** followed by a jump. Return jump position.
+*/
static int condjump (FuncState *fs, OpCode op, int A, int B, int C) {
luaK_codeABC(fs, op, A, B, C);
return luaK_jump(fs);
}
-static void fixjump (FuncState *fs, int pc, int dest) {
- Instruction *jmp = &fs->f->code[pc];
- int offset = dest-(pc+1);
- lua_assert(dest != NO_JUMP);
- if (abs(offset) > MAXARG_sBx)
- luaX_syntaxerror(fs->ls, "control structure too long");
- SETARG_sBx(*jmp, offset);
-}
-
-
/*
** returns current 'pc' and marks it as a jump target (to avoid wrong
** optimizations with consecutive instructions not in the same basic block).
@@ -114,15 +171,11 @@
}
-static int getjump (FuncState *fs, int pc) {
- int offset = GETARG_sBx(fs->f->code[pc]);
- if (offset == NO_JUMP) /* point to itself represents end of list */
- return NO_JUMP; /* end of list */
- else
- return (pc+1)+offset; /* turn offset into absolute position */
-}
-
-
+/*
+** Returns the position of the instruction "controlling" a given
+** jump (that is, its condition), or the jump itself if it is
+** unconditional.
+*/
static Instruction *getjumpcontrol (FuncState *fs, int pc) {
Instruction *pi = &fs->f->code[pc];
if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1))))
@@ -133,37 +186,41 @@
/*
-** check whether list has any jump that do not produce a value
-** (or produce an inverted value)
+** Patch destination register for a TESTSET instruction.
+** If instruction in position 'node' is not a TESTSET, return 0 ("fails").
+** Otherwise, if 'reg' is not 'NO_REG', set it as the destination
+** register. Otherwise, change instruction to a simple 'TEST' (produces
+** no register value)
*/
-static int need_value (FuncState *fs, int list) {
- for (; list != NO_JUMP; list = getjump(fs, list)) {
- Instruction i = *getjumpcontrol(fs, list);
- if (GET_OPCODE(i) != OP_TESTSET) return 1;
- }
- return 0; /* not found */
-}
-
-
static int patchtestreg (FuncState *fs, int node, int reg) {
Instruction *i = getjumpcontrol(fs, node);
if (GET_OPCODE(*i) != OP_TESTSET)
return 0; /* cannot patch other instructions */
if (reg != NO_REG && reg != GETARG_B(*i))
SETARG_A(*i, reg);
- else /* no register to put value or register already has the value */
+ else {
+ /* no register to put value or register already has the value;
+ change instruction to simple test */
*i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i));
-
+ }
return 1;
}
+/*
+** Traverse a list of tests ensuring no one produces a value
+*/
static void removevalues (FuncState *fs, int list) {
for (; list != NO_JUMP; list = getjump(fs, list))
patchtestreg(fs, list, NO_REG);
}
+/*
+** Traverse a list of tests, patching their destination address and
+** registers: tests producing values jump to 'vtarget' (and put their
+** values in 'reg'), other tests jump to 'dtarget'.
+*/
static void patchlistaux (FuncState *fs, int list, int vtarget, int reg,
int dtarget) {
while (list != NO_JUMP) {
@@ -177,15 +234,35 @@
}
+/*
+** Ensure all pending jumps to current position are fixed (jumping
+** to current position with no values) and reset list of pending
+** jumps
+*/
static void dischargejpc (FuncState *fs) {
patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc);
fs->jpc = NO_JUMP;
}
+/*
+** Add elements in 'list' to list of pending jumps to "here"
+** (current position)
+*/
+void luaK_patchtohere (FuncState *fs, int list) {
+ luaK_getlabel(fs); /* mark "here" as a jump target */
+ luaK_concat(fs, &fs->jpc, list);
+}
+
+
+/*
+** Path all jumps in 'list' to jump to 'target'.
+** (The assert means that we cannot fix a jump to a forward address
+** because we only know addresses once code is generated.)
+*/
void luaK_patchlist (FuncState *fs, int list, int target) {
- if (target == fs->pc)
- luaK_patchtohere(fs, list);
+ if (target == fs->pc) /* 'target' is current position? */
+ luaK_patchtohere(fs, list); /* add list to pending jumps */
else {
lua_assert(target < fs->pc);
patchlistaux(fs, list, target, NO_REG, target);
@@ -193,39 +270,26 @@
}
+/*
+** Path all jumps in 'list' to close upvalues up to given 'level'
+** (The assertion checks that jumps either were closing nothing
+** or were closing higher levels, from inner blocks.)
+*/
void luaK_patchclose (FuncState *fs, int list, int level) {
level++; /* argument is +1 to reserve 0 as non-op */
- while (list != NO_JUMP) {
- int next = getjump(fs, list);
+ for (; list != NO_JUMP; list = getjump(fs, list)) {
lua_assert(GET_OPCODE(fs->f->code[list]) == OP_JMP &&
(GETARG_A(fs->f->code[list]) == 0 ||
GETARG_A(fs->f->code[list]) >= level));
SETARG_A(fs->f->code[list], level);
- list = next;
- }
-}
-
-
-void luaK_patchtohere (FuncState *fs, int list) {
- luaK_getlabel(fs);
- luaK_concat(fs, &fs->jpc, list);
-}
-
-
-void luaK_concat (FuncState *fs, int *l1, int l2) {
- if (l2 == NO_JUMP) return;
- else if (*l1 == NO_JUMP)
- *l1 = l2;
- else {
- int list = *l1;
- int next;
- while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */
- list = next;
- fixjump(fs, list, l2);
- }
-}
-
-
+ }
+}
+
+
+/*
+** Emit instruction 'i', checking for array sizes and saving also its
+** line information. Return 'i' position.
+*/
static int luaK_code (FuncState *fs, Instruction i) {
Proto *f = fs->f;
dischargejpc(fs); /* 'pc' will change */
@@ -241,6 +305,10 @@
}
+/*
+** Format and emit an 'iABC' instruction. (Assertions check consistency
+** of parameters versus opcode.)
+*/
int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) {
lua_assert(getOpMode(o) == iABC);
lua_assert(getBMode(o) != OpArgN || b == 0);
@@ -250,6 +318,9 @@
}
+/*
+** Format and emit an 'iABx' instruction.
+*/
int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) {
lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx);
lua_assert(getCMode(o) == OpArgN);
@@ -258,12 +329,20 @@
}
+/*
+** Emit an "extra argument" instruction (format 'iAx')
+*/
static int codeextraarg (FuncState *fs, int a) {
lua_assert(a <= MAXARG_Ax);
return luaK_code(fs, CREATE_Ax(OP_EXTRAARG, a));
}
+/*
+** Emit a "load constant" instruction, using either 'OP_LOADK'
+** (if constant index 'k' fits in 18 bits) or an 'OP_LOADKX'
+** instruction with "extra argument".
+*/
int luaK_codek (FuncState *fs, int reg, int k) {
if (k <= MAXARG_Bx)
return luaK_codeABx(fs, OP_LOADK, reg, k);
@@ -275,6 +354,10 @@
}
+/*
+** Check register-stack level, keeping track of its maximum size
+** in field 'maxstacksize'
+*/
void luaK_checkstack (FuncState *fs, int n) {
int newstack = fs->freereg + n;
if (newstack > fs->f->maxstacksize) {
@@ -286,12 +369,20 @@
}
+/*
+** Reserve 'n' registers in register stack
+*/
void luaK_reserveregs (FuncState *fs, int n) {
luaK_checkstack(fs, n);
fs->freereg += n;
}
+/*
+** Free register 'reg', if it is neither a constant index nor
+** a local variable.
+)
+*/
static void freereg (FuncState *fs, int reg) {
if (!ISK(reg) && reg >= fs->nactvar) {
fs->freereg--;
@@ -300,6 +391,9 @@
}
+/*
+** Free register used by expression 'e' (if any)
+*/
static void freeexp (FuncState *fs, expdesc *e) {
if (e->k == VNONRELOC)
freereg(fs, e->u.info);
@@ -307,8 +401,29 @@
/*
+** Free registers used by expressions 'e1' and 'e2' (if any) in proper
+** order.
+*/
+static void freeexps (FuncState *fs, expdesc *e1, expdesc *e2) {
+ int r1 = (e1->k == VNONRELOC) ? e1->u.info : -1;
+ int r2 = (e2->k == VNONRELOC) ? e2->u.info : -1;
+ if (r1 > r2) {
+ freereg(fs, r1);
+ freereg(fs, r2);
+ }
+ else {
+ freereg(fs, r2);
+ freereg(fs, r1);
+ }
+}
+
+
+/*
+** Add constant 'v' to prototype's list of constants (field 'k').
** Use scanner's table to cache position of constants in constant list
-** and try to reuse constants
+** and try to reuse constants. Because some values should not be used
+** as keys (nil cannot be a key, integer keys can collapse with float
+** keys), the caller must provide a useful 'key' for indexing the cache.
*/
static int addk (FuncState *fs, TValue *key, TValue *v) {
lua_State *L = fs->ls->L;
@@ -337,17 +452,21 @@
}
+/*
+** Add a string to list of constants and return its index.
+*/
int luaK_stringK (FuncState *fs, TString *s) {
TValue o;
setsvalue(fs->ls->L, &o, s);
- return addk(fs, &o, &o);
+ return addk(fs, &o, &o); /* use string itself as key */
}
/*
-** Integers use userdata as keys to avoid collision with floats with same
-** value; conversion to 'void*' used only for hashing, no "precision"
-** problems
+** Add an integer to list of constants and return its index.
+** Integers use userdata as keys to avoid collision with floats with
+** same value; conversion to 'void*' is used only for hashing, so there
+** are no "precision" problems.
*/
int luaK_intK (FuncState *fs, lua_Integer n) {
TValue k, o;
@@ -356,21 +475,29 @@
return addk(fs, &k, &o);
}
-
+/*
+** Add a float to list of constants and return its index.
+*/
static int luaK_numberK (FuncState *fs, lua_Number r) {
TValue o;
setfltvalue(&o, r);
- return addk(fs, &o, &o);
+ return addk(fs, &o, &o); /* use number itself as key */
}
+/*
+** Add a boolean to list of constants and return its index.
+*/
static int boolK (FuncState *fs, int b) {
TValue o;
setbvalue(&o, b);
- return addk(fs, &o, &o);
+ return addk(fs, &o, &o); /* use boolean itself as key */
}
+/*
+** Add nil to list of constants and return its index.
+*/
static int nilK (FuncState *fs) {
TValue k, v;
setnilvalue(&v);
@@ -380,54 +507,79 @@
}
+/*
+** Fix an expression to return the number of results 'nresults'.
+** Either 'e' is a multi-ret expression (function call or vararg)
+** or 'nresults' is LUA_MULTRET (as any expression can satisfy that).
+*/
void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) {
if (e->k == VCALL) { /* expression is an open function call? */
- SETARG_C(getcode(fs, e), nresults+1);
+ SETARG_C(getinstruction(fs, e), nresults + 1);
}
else if (e->k == VVARARG) {
- SETARG_B(getcode(fs, e), nresults+1);
- SETARG_A(getcode(fs, e), fs->freereg);
+ Instruction *pc = &getinstruction(fs, e);
+ SETARG_B(*pc, nresults + 1);
+ SETARG_A(*pc, fs->freereg);
luaK_reserveregs(fs, 1);
}
+ else lua_assert(nresults == LUA_MULTRET);
}
+/*
+** Fix an expression to return one result.
+** If expression is not a multi-ret expression (function call or
+** vararg), it already returns one result, so nothing needs to be done.
+** Function calls become VNONRELOC expressions (as its result comes
+** fixed in the base register of the call), while vararg expressions
+** become VRELOCABLE (as OP_VARARG puts its results where it wants).
+** (Calls are created returning one result, so that does not need
+** to be fixed.)
+*/
void luaK_setoneret (FuncState *fs, expdesc *e) {
if (e->k == VCALL) { /* expression is an open function call? */
- e->k = VNONRELOC;
- e->u.info = GETARG_A(getcode(fs, e));
+ /* already returns 1 value */
+ lua_assert(GETARG_C(getinstruction(fs, e)) == 2);
+ e->k = VNONRELOC; /* result has fixed position */
+ e->u.info = GETARG_A(getinstruction(fs, e));
}
else if (e->k == VVARARG) {
- SETARG_B(getcode(fs, e), 2);
+ SETARG_B(getinstruction(fs, e), 2);
e->k = VRELOCABLE; /* can relocate its simple result */
}
}
+/*
+** Ensure that expression 'e' is not a variable.
+*/
void luaK_dischargevars (FuncState *fs, expdesc *e) {
switch (e->k) {
- case VLOCAL: {
- e->k = VNONRELOC;
+ case VLOCAL: { /* already in a register */
+ e->k = VNONRELOC; /* becomes a non-relocatable value */
break;
}
- case VUPVAL: {
+ case VUPVAL: { /* move value to some (pending) register */
e->u.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.info, 0);
e->k = VRELOCABLE;
break;
}
case VINDEXED: {
- OpCode op = OP_GETTABUP; /* assume 't' is in an upvalue */
+ OpCode op;
freereg(fs, e->u.ind.idx);
- if (e->u.ind.vt == VLOCAL) { /* 't' is in a register? */
+ if (e->u.ind.vt == VLOCAL) { /* is 't' in a register? */
freereg(fs, e->u.ind.t);
op = OP_GETTABLE;
}
+ else {
+ lua_assert(e->u.ind.vt == VUPVAL);
+ op = OP_GETTABUP; /* 't' is in an upvalue */
+ }
e->u.info = luaK_codeABC(fs, op, 0, e->u.ind.t, e->u.ind.idx);
e->k = VRELOCABLE;
break;
}
- case VVARARG:
- case VCALL: {
+ case VVARARG: case VCALL: {
luaK_setoneret(fs, e);
break;
}
@@ -436,12 +588,10 @@
}
-static int code_label (FuncState *fs, int A, int b, int jump) {
- luaK_getlabel(fs); /* those instructions may be jump targets */
- return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump);
-}
-
-
+/*
+** Ensures expression value is in register 'reg' (and therefore
+** 'e' will become a non-relocatable expression).
+*/
static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
luaK_dischargevars(fs, e);
switch (e->k) {
@@ -466,8 +616,8 @@
break;
}
case VRELOCABLE: {
- Instruction *pc = &getcode(fs, e);
- SETARG_A(*pc, reg);
+ Instruction *pc = &getinstruction(fs, e);
+ SETARG_A(*pc, reg); /* instruction will put result in 'reg' */
break;
}
case VNONRELOC: {
@@ -476,7 +626,7 @@
break;
}
default: {
- lua_assert(e->k == VVOID || e->k == VJMP);
+ lua_assert(e->k == VJMP);
return; /* nothing to do... */
}
}
@@ -485,17 +635,46 @@
}
+/*
+** Ensures expression value is in any register.
+*/
static void discharge2anyreg (FuncState *fs, expdesc *e) {
- if (e->k != VNONRELOC) {
- luaK_reserveregs(fs, 1);
- discharge2reg(fs, e, fs->freereg-1);
- }
-}
-
-
+ if (e->k != VNONRELOC) { /* no fixed register yet? */
+ luaK_reserveregs(fs, 1); /* get a register */
+ discharge2reg(fs, e, fs->freereg-1); /* put value there */
+ }
+}
+
+
+static int code_loadbool (FuncState *fs, int A, int b, int jump) {
+ luaK_getlabel(fs); /* those instructions may be jump targets */
+ return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump);
+}
+
+
+/*
+** check whether list has any jump that do not produce a value
+** or produce an inverted value
+*/
+static int need_value (FuncState *fs, int list) {
+ for (; list != NO_JUMP; list = getjump(fs, list)) {
+ Instruction i = *getjumpcontrol(fs, list);
+ if (GET_OPCODE(i) != OP_TESTSET) return 1;
+ }
+ return 0; /* not found */
+}
+
+
+/*
+** Ensures final expression result (including results from its jump
+** lists) is in register 'reg'.
+** If expression has jumps, need to patch these jumps either to
+** its final position or to "load" instructions (for those tests
+** that do not produce values).
+*/
static void exp2reg (FuncState *fs, expdesc *e, int reg) {
discharge2reg(fs, e, reg);
- if (e->k == VJMP)
+ if (e->k == VJMP) /* expression itself is a test? */
luaK_concat(fs, &e->t, e->u.info); /* put this jump in 't' list */
if (hasjumps(e)) {
int final; /* position after whole expression */
@@ -503,8 +682,8 @@
int p_t = NO_JUMP; /* position of an eventual LOAD true */
if (need_value(fs, e->t) || need_value(fs, e->f)) {
int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs);
- p_f = code_label(fs, reg, 0, 1);
- p_t = code_label(fs, reg, 1, 0);
+ p_f = code_loadbool(fs, reg, 0, 1);
+ p_t = code_loadbool(fs, reg, 1, 0);
luaK_patchtohere(fs, fj);
}
final = luaK_getlabel(fs);
@@ -517,6 +696,10 @@
}
+/*
+** Ensures final expression result (including results from its jump
+** lists) is in next available register.
+*/
void luaK_exp2nextreg (FuncState *fs, expdesc *e) {
luaK_dischargevars(fs, e);
freeexp(fs, e);
@@ -525,26 +708,39 @@
}
+/*
+** Ensures final expression result (including results from its jump
+** lists) is in some (any) register and return that register.
+*/
int luaK_exp2anyreg (FuncState *fs, expdesc *e) {
luaK_dischargevars(fs, e);
- if (e->k == VNONRELOC) {
- if (!hasjumps(e)) return e->u.info; /* exp is already in a register */
+ if (e->k == VNONRELOC) { /* expression already has a register? */
+ if (!hasjumps(e)) /* no jumps? */
+ return e->u.info; /* result is already in a register */
if (e->u.info >= fs->nactvar) { /* reg. is not a local? */
- exp2reg(fs, e, e->u.info); /* put value on it */
+ exp2reg(fs, e, e->u.info); /* put final result in it */
return e->u.info;
}
}
- luaK_exp2nextreg(fs, e); /* default */
+ luaK_exp2nextreg(fs, e); /* otherwise, use next available register */
return e->u.info;
}
+/*
+** Ensures final expression result is either in a register or in an
+** upvalue.
+*/
void luaK_exp2anyregup (FuncState *fs, expdesc *e) {
if (e->k != VUPVAL || hasjumps(e))
luaK_exp2anyreg(fs, e);
}
+/*
+** Ensures final expression result is either in a register or it is
+** a constant.
+*/
void luaK_exp2val (FuncState *fs, expdesc *e) {
if (hasjumps(e))
luaK_exp2anyreg(fs, e);
@@ -553,35 +749,26 @@
}
+/*
+** Ensures final expression result is in a valid R/K index
+** (that is, it is either in a register or in 'k' with an index
+** in the range of R/K indices).
+** Returns R/K index.
+*/
int luaK_exp2RK (FuncState *fs, expdesc *e) {
luaK_exp2val(fs, e);
- switch (e->k) {
- case VTRUE:
- case VFALSE:
- case VNIL: {
- if (fs->nk <= MAXINDEXRK) { /* constant fits in RK operand? */
- e->u.info = (e->k == VNIL) ? nilK(fs) : boolK(fs, (e->k == VTRUE));
- e->k = VK;
- return RKASK(e->u.info);
- }
- else break;
- }
- case VKINT: {
- e->u.info = luaK_intK(fs, e->u.ival);
- e->k = VK;
- goto vk;
- }
- case VKFLT: {
- e->u.info = luaK_numberK(fs, e->u.nval);
- e->k = VK;
- }
- /* FALLTHROUGH */
- case VK: {
+ switch (e->k) { /* move constants to 'k' */
+ case VTRUE: e->u.info = boolK(fs, 1); goto vk;
+ case VFALSE: e->u.info = boolK(fs, 0); goto vk;
+ case VNIL: e->u.info = nilK(fs); goto vk;
+ case VKINT: e->u.info = luaK_intK(fs, e->u.ival); goto vk;
+ case VKFLT: e->u.info = luaK_numberK(fs, e->u.nval); goto vk;
+ case VK:
vk:
+ e->k = VK;
if (e->u.info <= MAXINDEXRK) /* constant fits in 'argC'? */
return RKASK(e->u.info);
else break;
- }
default: break;
}
/* not a constant in the right range: put it in a register */
@@ -589,11 +776,14 @@
}
+/*
+** Generate code to store result of expression 'ex' into variable 'var'.
+*/
void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
switch (var->k) {
case VLOCAL: {
freeexp(fs, ex);
- exp2reg(fs, ex, var->u.info);
+ exp2reg(fs, ex, var->u.info); /* compute 'ex' into proper place */
return;
}
case VUPVAL: {
@@ -607,29 +797,32 @@
luaK_codeABC(fs, op, var->u.ind.t, var->u.ind.idx, e);
break;
}
- default: {
- lua_assert(0); /* invalid var kind to store */
- break;
- }
+ default: lua_assert(0); /* invalid var kind to store */
}
freeexp(fs, ex);
}
+/*
+** Emit SELF instruction (convert expression 'e' into 'e:key(e,').
+*/
void luaK_self (FuncState *fs, expdesc *e, expdesc *key) {
int ereg;
luaK_exp2anyreg(fs, e);
ereg = e->u.info; /* register where 'e' was placed */
freeexp(fs, e);
e->u.info = fs->freereg; /* base register for op_self */
- e->k = VNONRELOC;
+ e->k = VNONRELOC; /* self expression has a fixed register */
luaK_reserveregs(fs, 2); /* function and 'self' produced by op_self */
luaK_codeABC(fs, OP_SELF, e->u.info, ereg, luaK_exp2RK(fs, key));
freeexp(fs, key);
}
-static void invertjump (FuncState *fs, expdesc *e) {
+/*
+** Negate condition 'e' (where 'e' is a comparison).
+*/
+static void negatecondition (FuncState *fs, expdesc *e) {
Instruction *pc = getjumpcontrol(fs, e->u.info);
lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET &&
GET_OPCODE(*pc) != OP_TEST);
@@ -637,9 +830,15 @@
}
+/*
+** Emit instruction to jump if 'e' is 'cond' (that is, if 'cond'
+** is true, code will jump if 'e' is true.) Return jump position.
+** Optimize when 'e' is 'not' something, inverting the condition
+** and removing the 'not'.
+*/
static int jumponcond (FuncState *fs, expdesc *e, int cond) {
if (e->k == VRELOCABLE) {
- Instruction ie = getcode(fs, e);
+ Instruction ie = getinstruction(fs, e);
if (GET_OPCODE(ie) == OP_NOT) {
fs->pc--; /* remove previous OP_NOT */
return condjump(fs, OP_TEST, GETARG_B(ie), 0, !cond);
@@ -652,13 +851,16 @@
}
+/*
+** Emit code to go through if 'e' is true, jump otherwise.
+*/
void luaK_goiftrue (FuncState *fs, expdesc *e) {
- int pc; /* pc of last jump */
+ int pc; /* pc of new jump */
luaK_dischargevars(fs, e);
switch (e->k) {
- case VJMP: {
- invertjump(fs, e);
- pc = e->u.info;
+ case VJMP: { /* condition? */
+ negatecondition(fs, e); /* jump when it is false */
+ pc = e->u.info; /* save jump position */
break;
}
case VK: case VKFLT: case VKINT: case VTRUE: {
@@ -666,22 +868,25 @@
break;
}
default: {
- pc = jumponcond(fs, e, 0);
+ pc = jumponcond(fs, e, 0); /* jump when false */
break;
}
}
- luaK_concat(fs, &e->f, pc); /* insert last jump in 'f' list */
- luaK_patchtohere(fs, e->t);
+ luaK_concat(fs, &e->f, pc); /* insert new jump in false list */
+ luaK_patchtohere(fs, e->t); /* true list jumps to here (to go through) */
e->t = NO_JUMP;
}
+/*
+** Emit code to go through if 'e' is false, jump otherwise.
+*/
void luaK_goiffalse (FuncState *fs, expdesc *e) {
- int pc; /* pc of last jump */
+ int pc; /* pc of new jump */
luaK_dischargevars(fs, e);
switch (e->k) {
case VJMP: {
- pc = e->u.info;
+ pc = e->u.info; /* already jump if true */
break;
}
case VNIL: case VFALSE: {
@@ -689,29 +894,32 @@
break;
}
default: {
- pc = jumponcond(fs, e, 1);
+ pc = jumponcond(fs, e, 1); /* jump if true */
break;
}
}
- luaK_concat(fs, &e->t, pc); /* insert last jump in 't' list */
- luaK_patchtohere(fs, e->f);
+ luaK_concat(fs, &e->t, pc); /* insert new jump in 't' list */
+ luaK_patchtohere(fs, e->f); /* false list jumps to here (to go through) */
e->f = NO_JUMP;
}
+/*
+** Code 'not e', doing constant folding.
+*/
static void codenot (FuncState *fs, expdesc *e) {
luaK_dischargevars(fs, e);
switch (e->k) {
case VNIL: case VFALSE: {
- e->k = VTRUE;
+ e->k = VTRUE; /* true == not nil == not false */
break;
}
case VK: case VKFLT: case VKINT: case VTRUE: {
- e->k = VFALSE;
+ e->k = VFALSE; /* false == not "x" == not 0.5 == not 1 == not true */
break;
}
case VJMP: {
- invertjump(fs, e);
+ negatecondition(fs, e);
break;
}
case VRELOCABLE:
@@ -722,30 +930,32 @@
e->k = VRELOCABLE;
break;
}
- default: {
- lua_assert(0); /* cannot happen */
- break;
- }
+ default: lua_assert(0); /* cannot happen */
}
/* interchange true and false lists */
{ int temp = e->f; e->f = e->t; e->t = temp; }
- removevalues(fs, e->f);
+ removevalues(fs, e->f); /* values are useless when negated */
removevalues(fs, e->t);
}
+/*
+** Create expression 't[k]'. 't' must have its final result already in a
+** register or upvalue.
+*/
void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
- lua_assert(!hasjumps(t));
- t->u.ind.t = t->u.info;
- t->u.ind.idx = luaK_exp2RK(fs, k);
- t->u.ind.vt = (t->k == VUPVAL) ? VUPVAL
- : check_exp(vkisinreg(t->k), VLOCAL);
+ lua_assert(!hasjumps(t) && (vkisinreg(t->k) || t->k == VUPVAL));
+ t->u.ind.t = t->u.info; /* register or upvalue index */
+ t->u.ind.idx = luaK_exp2RK(fs, k); /* R/K index for key */
+ t->u.ind.vt = (t->k == VUPVAL) ? VUPVAL : VLOCAL;
t->k = VINDEXED;
}
/*
-** return false if folding can raise an error
+** Return false if folding can raise an error.
+** Bitwise operations need operands convertible to integers; division
+** operations cannot have 0 as divisor.
*/
static int validop (int op, TValue *v1, TValue *v2) {
switch (op) {
@@ -762,9 +972,11 @@
/*
-** Try to "constant-fold" an operation; return 1 iff successful
+** Try to "constant-fold" an operation; return 1 iff successful.
+** (In this case, 'e1' has the final result.)
*/
-static int constfolding (FuncState *fs, int op, expdesc *e1, expdesc *e2) {
+static int constfolding (FuncState *fs, int op, expdesc *e1,
+ const expdesc *e2) {
TValue v1, v2, res;
if (!tonumeral(e1, &v1) || !tonumeral(e2, &v2) || !validop(op, &v1, &v2))
return 0; /* non-numeric operands or not safe to fold */
@@ -773,7 +985,7 @@
e1->k = VKINT;
e1->u.ival = ivalue(&res);
}
- else { /* folds neither NaN nor 0.0 (to avoid collapsing with -0.0) */
+ else { /* folds neither NaN nor 0.0 (to avoid problems with -0.0) */
lua_Number n = fltvalue(&res);
if (luai_numisnan(n) || n == 0)
return 0;
@@ -785,81 +997,100 @@
/*
-** Code for binary and unary expressions that "produce values"
-** (arithmetic operations, bitwise operations, concat, length). First
-** try to do constant folding (only for numeric [arithmetic and
-** bitwise] operations, which is what 'lua_arith' accepts).
+** Emit code for unary expressions that "produce values"
+** (everything but 'not').
+** Expression to produce final result will be encoded in 'e'.
+*/
+static void codeunexpval (FuncState *fs, OpCode op, expdesc *e, int line) {
+ int r = luaK_exp2anyreg(fs, e); /* opcodes operate only on registers */
+ freeexp(fs, e);
+ e->u.info = luaK_codeABC(fs, op, 0, r, 0); /* generate opcode */
+ e->k = VRELOCABLE; /* all those operations are relocatable */
+ luaK_fixline(fs, line);
+}
+
+
+/*
+** Emit code for binary expressions that "produce values"
+** (everything but logical operators 'and'/'or' and comparison
+** operators).
** Expression to produce final result will be encoded in 'e1'.
+** Because 'luaK_exp2RK' can free registers, its calls must be
+** in "stack order" (that is, first on 'e2', which may have more
+** recent registers to be released).
*/
-static void codeexpval (FuncState *fs, OpCode op,
- expdesc *e1, expdesc *e2, int line) {
- lua_assert(op >= OP_ADD);
- if (op <= OP_BNOT && constfolding(fs, (op - OP_ADD) + LUA_OPADD, e1, e2))
- return; /* result has been folded */
- else {
- int o1, o2;
- /* move operands to registers (if needed) */
- if (op == OP_UNM || op == OP_BNOT || op == OP_LEN) { /* unary op? */
- o2 = 0; /* no second expression */
- o1 = luaK_exp2anyreg(fs, e1); /* cannot operate on constants */
- }
- else { /* regular case (binary operators) */
- o2 = luaK_exp2RK(fs, e2); /* both operands are "RK" */
- o1 = luaK_exp2RK(fs, e1);
- }
- if (o1 > o2) { /* free registers in proper order */
- freeexp(fs, e1);
- freeexp(fs, e2);
- }
- else {
- freeexp(fs, e2);
- freeexp(fs, e1);
- }
- e1->u.info = luaK_codeABC(fs, op, 0, o1, o2); /* generate opcode */
- e1->k = VRELOCABLE; /* all those operations are relocatable */
- luaK_fixline(fs, line);
- }
+static void codebinexpval (FuncState *fs, OpCode op,
+ expdesc *e1, expdesc *e2, int line) {
+ int rk2 = luaK_exp2RK(fs, e2); /* both operands are "RK" */
+ int rk1 = luaK_exp2RK(fs, e1);
+ freeexps(fs, e1, e2);
+ e1->u.info = luaK_codeABC(fs, op, 0, rk1, rk2); /* generate opcode */
+ e1->k = VRELOCABLE; /* all those operations are relocatable */
+ luaK_fixline(fs, line);
}
-static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1,
- expdesc *e2) {
- int o1 = luaK_exp2RK(fs, e1);
- int o2 = luaK_exp2RK(fs, e2);
- freeexp(fs, e2);
- freeexp(fs, e1);
- if (cond == 0 && op != OP_EQ) {
- int temp; /* exchange args to replace by '<' or '<=' */
- temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */
- cond = 1;
+/*
+** Emit code for comparisons.
+** 'e1' was already put in R/K form by 'luaK_infix'.
+*/
+static void codecomp (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) {
+ int rk1 = (e1->k == VK) ? RKASK(e1->u.info)
+ : check_exp(e1->k == VNONRELOC, e1->u.info);
+ int rk2 = luaK_exp2RK(fs, e2);
+ freeexps(fs, e1, e2);
+ switch (opr) {
+ case OPR_NE: { /* '(a ~= b)' ==> 'not (a == b)' */
+ e1->u.info = condjump(fs, OP_EQ, 0, rk1, rk2);
+ break;
+ }
+ case OPR_GT: case OPR_GE: {
+ /* '(a > b)' ==> '(b < a)'; '(a >= b)' ==> '(b <= a)' */
+ OpCode op = cast(OpCode, (opr - OPR_NE) + OP_EQ);
+ e1->u.info = condjump(fs, op, 1, rk2, rk1); /* invert operands */
+ break;
+ }
+ default: { /* '==', '<', '<=' use their own opcodes */
+ OpCode op = cast(OpCode, (opr - OPR_EQ) + OP_EQ);
+ e1->u.info = condjump(fs, op, 1, rk1, rk2);
+ break;
+ }
}
- e1->u.info = condjump(fs, op, cond, o1, o2);
e1->k = VJMP;
}
+/*
+** Aplly prefix operation 'op' to expression 'e'.
+*/
void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e, int line) {
- expdesc e2;
- e2.t = e2.f = NO_JUMP; e2.k = VKINT; e2.u.ival = 0;
+ static const expdesc ef = {VKINT, {0}, NO_JUMP, NO_JUMP};
switch (op) {
- case OPR_MINUS: case OPR_BNOT: case OPR_LEN: {
- codeexpval(fs, cast(OpCode, (op - OPR_MINUS) + OP_UNM), e, &e2, line);
+ case OPR_MINUS: case OPR_BNOT: /* use 'ef' as fake 2nd operand */
+ if (constfolding(fs, op + LUA_OPUNM, e, &ef))
+ break;
+ /* FALLTHROUGH */
+ case OPR_LEN:
+ codeunexpval(fs, cast(OpCode, op + OP_UNM), e, line);
break;
- }
case OPR_NOT: codenot(fs, e); break;
default: lua_assert(0);
}
}
+/*
+** Process 1st operand 'v' of binary operation 'op' before reading
+** 2nd operand.
+*/
void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
switch (op) {
case OPR_AND: {
- luaK_goiftrue(fs, v);
+ luaK_goiftrue(fs, v); /* go ahead only if 'v' is true */
break;
}
case OPR_OR: {
- luaK_goiffalse(fs, v);
+ luaK_goiffalse(fs, v); /* go ahead only if 'v' is false */
break;
}
case OPR_CONCAT: {
@@ -871,7 +1102,9 @@
case OPR_MOD: case OPR_POW:
case OPR_BAND: case OPR_BOR: case OPR_BXOR:
case OPR_SHL: case OPR_SHR: {
- if (!tonumeral(v, NULL)) luaK_exp2RK(fs, v);
+ if (!tonumeral(v, NULL))
+ luaK_exp2RK(fs, v);
+ /* else keep numeral, which may be folded with 2nd operand */
break;
}
default: {
@@ -882,18 +1115,24 @@
}
+/*
+** Finalize code for binary operation, after reading 2nd operand.
+** For '(a .. b .. c)' (which is '(a .. (b .. c))', because
+** concatenation is right associative), merge second CONCAT into first
+** one.
+*/
void luaK_posfix (FuncState *fs, BinOpr op,
expdesc *e1, expdesc *e2, int line) {
switch (op) {
case OPR_AND: {
- lua_assert(e1->t == NO_JUMP); /* list must be closed */
+ lua_assert(e1->t == NO_JUMP); /* list closed by 'luK_infix' */
luaK_dischargevars(fs, e2);
luaK_concat(fs, &e2->f, e1->f);
*e1 = *e2;
break;
}
case OPR_OR: {
- lua_assert(e1->f == NO_JUMP); /* list must be closed */
+ lua_assert(e1->f == NO_JUMP); /* list closed by 'luK_infix' */
luaK_dischargevars(fs, e2);
luaK_concat(fs, &e2->t, e1->t);
*e1 = *e2;
@@ -901,15 +1140,16 @@
}
case OPR_CONCAT: {
luaK_exp2val(fs, e2);
- if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) {
- lua_assert(e1->u.info == GETARG_B(getcode(fs, e2))-1);
+ if (e2->k == VRELOCABLE &&
+ GET_OPCODE(getinstruction(fs, e2)) == OP_CONCAT) {
+ lua_assert(e1->u.info == GETARG_B(getinstruction(fs, e2))-1);
freeexp(fs, e1);
- SETARG_B(getcode(fs, e2), e1->u.info);
+ SETARG_B(getinstruction(fs, e2), e1->u.info);
e1->k = VRELOCABLE; e1->u.info = e2->u.info;
}
else {
luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */
- codeexpval(fs, OP_CONCAT, e1, e2, line);
+ codebinexpval(fs, OP_CONCAT, e1, e2, line);
}
break;
}
@@ -917,15 +1157,13 @@
case OPR_IDIV: case OPR_MOD: case OPR_POW:
case OPR_BAND: case OPR_BOR: case OPR_BXOR:
case OPR_SHL: case OPR_SHR: {
- codeexpval(fs, cast(OpCode, (op - OPR_ADD) + OP_ADD), e1, e2, line);
- break;
- }
- case OPR_EQ: case OPR_LT: case OPR_LE: {
- codecomp(fs, cast(OpCode, (op - OPR_EQ) + OP_EQ), 1, e1, e2);
- break;
- }
+ if (!constfolding(fs, op + LUA_OPADD, e1, e2))
+ codebinexpval(fs, cast(OpCode, op + OP_ADD), e1, e2, line);
+ break;
+ }
+ case OPR_EQ: case OPR_LT: case OPR_LE:
case OPR_NE: case OPR_GT: case OPR_GE: {
- codecomp(fs, cast(OpCode, (op - OPR_NE) + OP_EQ), 0, e1, e2);
+ codecomp(fs, op, e1, e2);
break;
}
default: lua_assert(0);
@@ -933,15 +1171,25 @@
}
+/*
+** Change line information associated with current position.
+*/
void luaK_fixline (FuncState *fs, int line) {
fs->f->lineinfo[fs->pc - 1] = line;
}
+/*
+** Emit a SETLIST instruction.
+** 'base' is register that keeps table;
+** 'nelems' is #table plus those to be stored now;
+** 'tostore' is number of values (in registers 'base + 1',...) to add to
+** table (or LUA_MULTRET to add up to stack top).
+*/
void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) {
int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1;
int b = (tostore == LUA_MULTRET) ? 0 : tostore;
- lua_assert(tostore != 0);
+ lua_assert(tostore != 0 && tostore <= LFIELDS_PER_FLUSH);
if (c <= MAXARG_C)
luaK_codeABC(fs, OP_SETLIST, base, b, c);
else if (c <= MAXARG_Ax) {
=== modified file 'src/third_party/eris/lcode.h'
--- src/third_party/eris/lcode.h 2016-08-04 15:49:05 +0000
+++ src/third_party/eris/lcode.h 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: lcode.h,v 1.63 2013/12/30 20:47:58 roberto Exp $
+** $Id: lcode.h,v 1.64 2016/01/05 16:22:37 roberto Exp $
** Code generator for Lua
** See Copyright Notice in lua.h
*/
@@ -12,82 +12,77 @@
#include "lopcodes.h"
#include "lparser.h"
+
/*
** Marks the end of a patch list. It is an invalid value both as an absolute
** address, and as a list link (would link an element to itself).
*/
#define NO_JUMP (-1)
+
/*
** grep "ORDER OPR" if you change these enums (ORDER OP)
*/
typedef enum BinOpr {
- OPR_ADD,
- OPR_SUB,
- OPR_MUL,
- OPR_MOD,
- OPR_POW,
- OPR_DIV,
- OPR_IDIV,
- OPR_BAND,
- OPR_BOR,
- OPR_BXOR,
- OPR_SHL,
- OPR_SHR,
- OPR_CONCAT,
- OPR_EQ,
- OPR_LT,
- OPR_LE,
- OPR_NE,
- OPR_GT,
- OPR_GE,
- OPR_AND,
- OPR_OR,
- OPR_NOBINOPR
+ OPR_ADD, OPR_SUB, OPR_MUL, OPR_MOD, OPR_POW,
+ OPR_DIV,
+ OPR_IDIV,
+ OPR_BAND, OPR_BOR, OPR_BXOR,
+ OPR_SHL, OPR_SHR,
+ OPR_CONCAT,
+ OPR_EQ, OPR_LT, OPR_LE,
+ OPR_NE, OPR_GT, OPR_GE,
+ OPR_AND, OPR_OR,
+ OPR_NOBINOPR
} BinOpr;
+
typedef enum UnOpr { OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
-#define getcode(fs, e) ((fs)->f->code[(e)->u.info])
-
-#define luaK_codeAsBx(fs, o, A, sBx) luaK_codeABx(fs, o, A, (sBx) + MAXARG_sBx)
-
-#define luaK_setmultret(fs, e) luaK_setreturns(fs, e, LUA_MULTRET)
-
-#define luaK_jumpto(fs, t) luaK_patchlist(fs, luaK_jump(fs), t)
-
-LUAI_FUNC int luaK_codeABx(FuncState* fs, OpCode o, int A, unsigned int Bx);
-LUAI_FUNC int luaK_codeABC(FuncState* fs, OpCode o, int A, int B, int C);
-LUAI_FUNC int luaK_codek(FuncState* fs, int reg, int k);
-LUAI_FUNC void luaK_fixline(FuncState* fs, int line);
-LUAI_FUNC void luaK_nil(FuncState* fs, int from, int n);
-LUAI_FUNC void luaK_reserveregs(FuncState* fs, int n);
-LUAI_FUNC void luaK_checkstack(FuncState* fs, int n);
-LUAI_FUNC int luaK_stringK(FuncState* fs, TString* s);
-LUAI_FUNC int luaK_intK(FuncState* fs, lua_Integer n);
-LUAI_FUNC void luaK_dischargevars(FuncState* fs, expdesc* e);
-LUAI_FUNC int luaK_exp2anyreg(FuncState* fs, expdesc* e);
-LUAI_FUNC void luaK_exp2anyregup(FuncState* fs, expdesc* e);
-LUAI_FUNC void luaK_exp2nextreg(FuncState* fs, expdesc* e);
-LUAI_FUNC void luaK_exp2val(FuncState* fs, expdesc* e);
-LUAI_FUNC int luaK_exp2RK(FuncState* fs, expdesc* e);
-LUAI_FUNC void luaK_self(FuncState* fs, expdesc* e, expdesc* key);
-LUAI_FUNC void luaK_indexed(FuncState* fs, expdesc* t, expdesc* k);
-LUAI_FUNC void luaK_goiftrue(FuncState* fs, expdesc* e);
-LUAI_FUNC void luaK_goiffalse(FuncState* fs, expdesc* e);
-LUAI_FUNC void luaK_storevar(FuncState* fs, expdesc* var, expdesc* e);
-LUAI_FUNC void luaK_setreturns(FuncState* fs, expdesc* e, int nresults);
-LUAI_FUNC void luaK_setoneret(FuncState* fs, expdesc* e);
-LUAI_FUNC int luaK_jump(FuncState* fs);
-LUAI_FUNC void luaK_ret(FuncState* fs, int first, int nret);
-LUAI_FUNC void luaK_patchlist(FuncState* fs, int list, int target);
-LUAI_FUNC void luaK_patchtohere(FuncState* fs, int list);
-LUAI_FUNC void luaK_patchclose(FuncState* fs, int list, int level);
-LUAI_FUNC void luaK_concat(FuncState* fs, int* l1, int l2);
-LUAI_FUNC int luaK_getlabel(FuncState* fs);
-LUAI_FUNC void luaK_prefix(FuncState* fs, UnOpr op, expdesc* v, int line);
-LUAI_FUNC void luaK_infix(FuncState* fs, BinOpr op, expdesc* v);
-LUAI_FUNC void luaK_posfix(FuncState* fs, BinOpr op, expdesc* v1, expdesc* v2, int line);
-LUAI_FUNC void luaK_setlist(FuncState* fs, int base, int nelems, int tostore);
+
+/* get (pointer to) instruction of given 'expdesc' */
+#define getinstruction(fs,e) ((fs)->f->code[(e)->u.info])
+
+#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx)
+
+#define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET)
+
+#define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t)
+
+LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx);
+LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C);
+LUAI_FUNC int luaK_codek (FuncState *fs, int reg, int k);
+LUAI_FUNC void luaK_fixline (FuncState *fs, int line);
+LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n);
+LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n);
+LUAI_FUNC void luaK_checkstack (FuncState *fs, int n);
+LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s);
+LUAI_FUNC int luaK_intK (FuncState *fs, lua_Integer n);
+LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e);
+LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e);
+LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e);
+LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e);
+LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e);
+LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e);
+LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key);
+LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k);
+LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e);
+LUAI_FUNC void luaK_goiffalse (FuncState *fs, expdesc *e);
+LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e);
+LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults);
+LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e);
+LUAI_FUNC int luaK_jump (FuncState *fs);
+LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret);
+LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target);
+LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list);
+LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level);
+LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2);
+LUAI_FUNC int luaK_getlabel (FuncState *fs);
+LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line);
+LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v);
+LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1,
+ expdesc *v2, int line);
+LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore);
+
#endif
=== modified file 'src/third_party/eris/lcorolib.c'
--- src/third_party/eris/lcorolib.c 2016-04-08 18:00:30 +0000
+++ src/third_party/eris/lcorolib.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: lcorolib.c,v 1.9 2014/11/02 19:19:04 roberto Exp $
+** $Id: lcorolib.c,v 1.10 2016/04/11 19:19:55 roberto Exp $
** Coroutine Library
** See Copyright Notice in lua.h
*/
@@ -75,7 +75,7 @@
lua_State *co = lua_tothread(L, lua_upvalueindex(1));
int r = auxresume(L, co, lua_gettop(L));
if (r < 0) {
- if (lua_isstring(L, -1)) { /* error object is a string? */
+ if (lua_type(L, -1) == LUA_TSTRING) { /* error object is a string? */
luaL_where(L, 1); /* add extra info */
lua_insert(L, -2);
lua_concat(L, 2);
=== modified file 'src/third_party/eris/lctype.h'
--- src/third_party/eris/lctype.h 2016-08-04 15:49:05 +0000
+++ src/third_party/eris/lctype.h 2018-07-08 12:35:11 +0000
@@ -9,6 +9,7 @@
#include "lua.h"
+
/*
** WARNING: the functions defined here do not necessarily correspond
** to the similar functions in the standard C ctype.h. They are
@@ -19,52 +20,58 @@
#if 'A' == 65 && '0' == 48
/* ASCII case: can use its own tables; faster and fixed */
-#define LUA_USE_CTYPE 0
+#define LUA_USE_CTYPE 0
#else
/* must use standard C ctype */
-#define LUA_USE_CTYPE 1
-#endif
-
-#endif
-
-#if !LUA_USE_CTYPE /* { */
+#define LUA_USE_CTYPE 1
+#endif
+
+#endif
+
+
+#if !LUA_USE_CTYPE /* { */
#include <limits.h>
#include "llimits.h"
-#define ALPHABIT 0
-#define DIGITBIT 1
-#define PRINTBIT 2
-#define SPACEBIT 3
-#define XDIGITBIT 4
-
-#define MASK(B) (1 << (B))
+
+#define ALPHABIT 0
+#define DIGITBIT 1
+#define PRINTBIT 2
+#define SPACEBIT 3
+#define XDIGITBIT 4
+
+
+#define MASK(B) (1 << (B))
+
/*
** add 1 to char to allow index -1 (EOZ)
*/
-#define testprop(c, p) (luai_ctype_[(c) + 1] & (p))
+#define testprop(c,p) (luai_ctype_[(c)+1] & (p))
/*
** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_'
*/
-#define lislalpha(c) testprop(c, MASK(ALPHABIT))
-#define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT)))
-#define lisdigit(c) testprop(c, MASK(DIGITBIT))
-#define lisspace(c) testprop(c, MASK(SPACEBIT))
-#define lisprint(c) testprop(c, MASK(PRINTBIT))
-#define lisxdigit(c) testprop(c, MASK(XDIGITBIT))
+#define lislalpha(c) testprop(c, MASK(ALPHABIT))
+#define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT)))
+#define lisdigit(c) testprop(c, MASK(DIGITBIT))
+#define lisspace(c) testprop(c, MASK(SPACEBIT))
+#define lisprint(c) testprop(c, MASK(PRINTBIT))
+#define lisxdigit(c) testprop(c, MASK(XDIGITBIT))
/*
** this 'ltolower' only works for alphabetic characters
*/
-#define ltolower(c) ((c) | ('A' ^ 'a'))
+#define ltolower(c) ((c) | ('A' ^ 'a'))
+
/* two more entries for 0 and -1 (EOZ) */
LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2];
-#else /* }{ */
+
+#else /* }{ */
/*
** use standard C ctypes
@@ -72,15 +79,17 @@
#include <ctype.h>
-#define lislalpha(c) (isalpha(c) || (c) == '_')
-#define lislalnum(c) (isalnum(c) || (c) == '_')
-#define lisdigit(c) (isdigit(c))
-#define lisspace(c) (isspace(c))
-#define lisprint(c) (isprint(c))
-#define lisxdigit(c) (isxdigit(c))
-
-#define ltolower(c) (tolower(c))
-
-#endif /* } */
+
+#define lislalpha(c) (isalpha(c) || (c) == '_')
+#define lislalnum(c) (isalnum(c) || (c) == '_')
+#define lisdigit(c) (isdigit(c))
+#define lisspace(c) (isspace(c))
+#define lisprint(c) (isprint(c))
+#define lisxdigit(c) (isxdigit(c))
+
+#define ltolower(c) (tolower(c))
+
+#endif /* } */
#endif
+
=== modified file 'src/third_party/eris/ldebug.c'
--- src/third_party/eris/ldebug.c 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/ldebug.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: ldebug.c,v 2.117 2015/11/02 18:48:07 roberto Exp $
+** $Id: ldebug.c,v 2.121 2016/10/19 12:32:10 roberto Exp $
** Debug Interface
** See Copyright Notice in lua.h
*/
@@ -38,7 +38,8 @@
#define ci_func(ci) (clLvalue((ci)->func))
-static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name);
+static const char *funcnamefromcode (lua_State *L, CallInfo *ci,
+ const char **name);
static int currentpc (CallInfo *ci) {
@@ -69,7 +70,13 @@
/*
-** this function can be called asynchronous (e.g. during a signal)
+** This function can be called asynchronously (e.g. during a signal).
+** Fields 'oldpc', 'basehookcount', and 'hookcount' (set by
+** 'resethookcount') are for debug only, and it is no problem if they
+** get arbitrary values (causes at most one wrong hook call). 'hookmask'
+** is an atomic value. We assume that pointers are atomic too (e.g., gcc
+** ensures that for all platforms where it runs). Moreover, 'hook' is
+** always checked before being called (see 'luaD_hook').
*/
LUA_API void lua_sethook (lua_State *L, lua_Hook func, int mask, int count) {
if (func == NULL || mask == 0) { /* turn off hooks? */
@@ -238,6 +245,20 @@
}
+static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
+ if (ci == NULL) /* no 'ci'? */
+ return NULL; /* no info */
+ else if (ci->callstatus & CIST_FIN) { /* is this a finalizer? */
+ *name = "__gc";
+ return "metamethod"; /* report it as such */
+ }
+ /* calling function is a known Lua function? */
+ else if (!(ci->callstatus & CIST_TAIL) && isLua(ci->previous))
+ return funcnamefromcode(L, ci->previous, name);
+ else return NULL; /* no way to find a name */
+}
+
+
static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
Closure *f, CallInfo *ci) {
int status = 1;
@@ -268,11 +289,7 @@
break;
}
case 'n': {
- /* calling function is a known Lua function? */
- if (ci && !(ci->callstatus & CIST_TAIL) && isLua(ci->previous))
- ar->namewhat = getfuncname(L, ci->previous, &ar->name);
- else
- ar->namewhat = NULL;
+ ar->namewhat = getfuncname(L, ci, &ar->name);
if (ar->namewhat == NULL) {
ar->namewhat = ""; /* not found */
ar->name = NULL;
@@ -465,8 +482,15 @@
}
-static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
- TMS tm = (TMS)0; /* to avoid warnings */
+/*
+** Try to find a name for a function based on the code that called it.
+** (Only works when function was called by a Lua function.)
+** Returns what the name is (e.g., "for iterator", "method",
+** "metamethod") and sets '*name' to point to the name.
+*/
+static const char *funcnamefromcode (lua_State *L, CallInfo *ci,
+ const char **name) {
+ TMS tm = (TMS)0; /* (initial value avoids warnings) */
Proto *p = ci_func(ci)->p; /* calling function */
int pc = currentpc(ci); /* calling instruction index */
Instruction i = p->code[pc]; /* calling instruction */
@@ -476,13 +500,13 @@
}
switch (GET_OPCODE(i)) {
case OP_CALL:
- case OP_TAILCALL: /* get function name */
- return getobjname(p, pc, GETARG_A(i), name);
+ case OP_TAILCALL:
+ return getobjname(p, pc, GETARG_A(i), name); /* get function name */
case OP_TFORCALL: { /* for iterator */
*name = "for iterator";
return "for iterator";
}
- /* all other instructions can call only through metamethods */
+ /* other instructions can do calls through metamethods */
case OP_SELF: case OP_GETTABUP: case OP_GETTABLE:
tm = TM_INDEX;
break;
@@ -503,7 +527,8 @@
case OP_EQ: tm = TM_EQ; break;
case OP_LT: tm = TM_LT; break;
case OP_LE: tm = TM_LE; break;
- default: lua_assert(0); /* other instructions cannot call a function */
+ default:
+ return NULL; /* cannot find a reasonable name */
}
*name = getstr(G(L)->tmname[tm]);
return "metamethod";
@@ -558,7 +583,7 @@
l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
- const char *t = objtypename(o);
+ const char *t = luaT_objtypename(L, o);
luaG_runerror(L, "attempt to %s a %s value%s", op, t, varinfo(L, o));
}
@@ -590,9 +615,9 @@
l_noret luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
- const char *t1 = objtypename(p1);
- const char *t2 = objtypename(p2);
- if (t1 == t2)
+ const char *t1 = luaT_objtypename(L, p1);
+ const char *t2 = luaT_objtypename(L, p2);
+ if (strcmp(t1, t2) == 0)
luaG_runerror(L, "attempt to compare two %s values", t1);
else
luaG_runerror(L, "attempt to compare %s with %s", t1, t2);
=== modified file 'src/third_party/eris/ldebug.h'
--- src/third_party/eris/ldebug.h 2016-08-04 15:49:05 +0000
+++ src/third_party/eris/ldebug.h 2018-07-08 12:35:11 +0000
@@ -7,25 +7,33 @@
#ifndef ldebug_h
#define ldebug_h
+
#include "lstate.h"
-#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1)
-
-#define getfuncline(f, pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : -1)
-
-#define resethookcount(L) (L->hookcount = L->basehookcount)
-
-LUAI_FUNC l_noret luaG_typeerror(lua_State* L, const TValue* o, const char* opname);
-LUAI_FUNC l_noret luaG_concaterror(lua_State* L, const TValue* p1, const TValue* p2);
-LUAI_FUNC l_noret luaG_opinterror(lua_State* L,
- const TValue* p1,
- const TValue* p2,
- const char* msg);
-LUAI_FUNC l_noret luaG_tointerror(lua_State* L, const TValue* p1, const TValue* p2);
-LUAI_FUNC l_noret luaG_ordererror(lua_State* L, const TValue* p1, const TValue* p2);
-LUAI_FUNC l_noret luaG_runerror(lua_State* L, const char* fmt, ...);
-LUAI_FUNC const char* luaG_addinfo(lua_State* L, const char* msg, TString* src, int line);
-LUAI_FUNC l_noret luaG_errormsg(lua_State* L);
-LUAI_FUNC void luaG_traceexec(lua_State* L);
+
+#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1)
+
+#define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : -1)
+
+#define resethookcount(L) (L->hookcount = L->basehookcount)
+
+
+LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o,
+ const char *opname);
+LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1,
+ const TValue *p2);
+LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1,
+ const TValue *p2,
+ const char *msg);
+LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1,
+ const TValue *p2);
+LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1,
+ const TValue *p2);
+LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...);
+LUAI_FUNC const char *luaG_addinfo (lua_State *L, const char *msg,
+ TString *src, int line);
+LUAI_FUNC l_noret luaG_errormsg (lua_State *L);
+LUAI_FUNC void luaG_traceexec (lua_State *L);
+
#endif
=== modified file 'src/third_party/eris/ldo.c'
--- src/third_party/eris/ldo.c 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/ldo.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: ldo.c,v 2.150 2015/11/19 19:16:22 roberto Exp $
+** $Id: ldo.c,v 2.157 2016/12/13 15:52:21 roberto Exp $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@@ -211,9 +211,9 @@
CallInfo *ci;
StkId lim = L->top;
for (ci = L->ci; ci != NULL; ci = ci->previous) {
- lua_assert(ci->top <= L->stack_last);
if (lim < ci->top) lim = ci->top;
}
+ lua_assert(lim <= L->stack_last);
return cast_int(lim - L->stack) + 1; /* part of stack in use */
}
@@ -221,16 +221,19 @@
void luaD_shrinkstack (lua_State *L) {
int inuse = stackinuse(L);
int goodsize = inuse + (inuse / 8) + 2*EXTRA_STACK;
- if (goodsize > LUAI_MAXSTACK) goodsize = LUAI_MAXSTACK;
- if (L->stacksize > LUAI_MAXSTACK) /* was handling stack overflow? */
+ if (goodsize > LUAI_MAXSTACK)
+ goodsize = LUAI_MAXSTACK; /* respect stack limit */
+ if (L->stacksize > LUAI_MAXSTACK) /* had been handling stack overflow? */
luaE_freeCI(L); /* free all CIs (list grew because of an error) */
else
luaE_shrinkCI(L); /* shrink list */
- if (inuse <= LUAI_MAXSTACK && /* not handling stack overflow? */
- goodsize < L->stacksize) /* trying to shrink? */
- luaD_reallocstack(L, goodsize); /* shrink it */
- else
- condmovestack(L,,); /* don't change stack (change only for debugging) */
+ /* if thread is currently not handling a stack overflow and its
+ good size is smaller than current size, shrink its stack */
+ if (inuse <= (LUAI_MAXSTACK - EXTRA_STACK) &&
+ goodsize < L->stacksize)
+ luaD_reallocstack(L, goodsize);
+ else /* don't change stack */
+ condmovestack(L,{},{}); /* (change only for debugging) */
}
@@ -242,9 +245,14 @@
/* }================================================================== */
+/*
+** Call a hook for the given event. Make sure there is a hook to be
+** called. (Both 'L->hook' and 'L->hookmask', which triggers this
+** function, can be changed asynchronously by signals.)
+*/
void luaD_hook (lua_State *L, int event, int line) {
lua_Hook hook = L->hook;
- if (hook && L->allowhook) {
+ if (hook && L->allowhook) { /* make sure there is a hook */
CallInfo *ci = L->ci;
ptrdiff_t top = savestack(L, L->top);
ptrdiff_t ci_top = savestack(L, ci->top);
@@ -317,6 +325,72 @@
}
+/*
+** Given 'nres' results at 'firstResult', move 'wanted' of them to 'res'.
+** Handle most typical cases (zero results for commands, one result for
+** expressions, multiple results for tail calls/single parameters)
+** separated.
+*/
+static int moveresults (lua_State *L, const TValue *firstResult, StkId res,
+ int nres, int wanted) {
+ switch (wanted) { /* handle typical cases separately */
+ case 0: break; /* nothing to move */
+ case 1: { /* one result needed */
+ if (nres == 0) /* no results? */
+ firstResult = luaO_nilobject; /* adjust with nil */
+ setobjs2s(L, res, firstResult); /* move it to proper place */
+ break;
+ }
+ case LUA_MULTRET: {
+ int i;
+ for (i = 0; i < nres; i++) /* move all results to correct place */
+ setobjs2s(L, res + i, firstResult + i);
+ L->top = res + nres;
+ return 0; /* wanted == LUA_MULTRET */
+ }
+ default: {
+ int i;
+ if (wanted <= nres) { /* enough results? */
+ for (i = 0; i < wanted; i++) /* move wanted results to correct place */
+ setobjs2s(L, res + i, firstResult + i);
+ }
+ else { /* not enough results; use all of them plus nils */
+ for (i = 0; i < nres; i++) /* move all results to correct place */
+ setobjs2s(L, res + i, firstResult + i);
+ for (; i < wanted; i++) /* complete wanted number of results */
+ setnilvalue(res + i);
+ }
+ break;
+ }
+ }
+ L->top = res + wanted; /* top points after the last result */
+ return 1;
+}
+
+
+/*
+** Finishes a function call: calls hook if necessary, removes CallInfo,
+** moves current number of results to proper place; returns 0 iff call
+** wanted multiple (variable number of) results.
+*/
+int luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult, int nres) {
+ StkId res;
+ int wanted = ci->nresults;
+ if (L->hookmask & (LUA_MASKRET | LUA_MASKLINE)) {
+ if (L->hookmask & LUA_MASKRET) {
+ ptrdiff_t fr = savestack(L, firstResult); /* hook may change stack */
+ luaD_hook(L, LUA_HOOKRET, -1);
+ firstResult = restorestack(L, fr);
+ }
+ L->oldpc = ci->previous->u.l.savedpc; /* 'oldpc' for caller function */
+ }
+ res = ci->func; /* res == final position of 1st result */
+ L->ci = ci->previous; /* back to caller */
+ /* move results to proper place */
+ return moveresults(L, firstResult, res, nres, wanted);
+}
+
+
#define next_ci(L) (L->ci = (L->ci->next ? L->ci->next : luaE_extendCI(L)))
@@ -369,13 +443,13 @@
int n = cast_int(L->top - func) - 1; /* number of real arguments */
int fsize = p->maxstacksize; /* frame size */
checkstackp(L, fsize, func);
- if (p->is_vararg != 1) { /* do not use vararg? */
+ if (p->is_vararg)
+ base = adjust_varargs(L, p, n);
+ else { /* non vararg function */
for (; n < p->numparams; n++)
setnilvalue(L->top++); /* complete missing arguments */
base = func + 1;
}
- else
- base = adjust_varargs(L, p, n);
ci = next_ci(L); /* now 'enter' new function */
ci->nresults = nresults;
ci->func = func;
@@ -398,72 +472,6 @@
/*
-** Given 'nres' results at 'firstResult', move 'wanted' of them to 'res'.
-** Handle most typical cases (zero results for commands, one result for
-** expressions, multiple results for tail calls/single parameters)
-** separated.
-*/
-static int moveresults (lua_State *L, const TValue *firstResult, StkId res,
- int nres, int wanted) {
- switch (wanted) { /* handle typical cases separately */
- case 0: break; /* nothing to move */
- case 1: { /* one result needed */
- if (nres == 0) /* no results? */
- firstResult = luaO_nilobject; /* adjust with nil */
- setobjs2s(L, res, firstResult); /* move it to proper place */
- break;
- }
- case LUA_MULTRET: {
- int i;
- for (i = 0; i < nres; i++) /* move all results to correct place */
- setobjs2s(L, res + i, firstResult + i);
- L->top = res + nres;
- return 0; /* wanted == LUA_MULTRET */
- }
- default: {
- int i;
- if (wanted <= nres) { /* enough results? */
- for (i = 0; i < wanted; i++) /* move wanted results to correct place */
- setobjs2s(L, res + i, firstResult + i);
- }
- else { /* not enough results; use all of them plus nils */
- for (i = 0; i < nres; i++) /* move all results to correct place */
- setobjs2s(L, res + i, firstResult + i);
- for (; i < wanted; i++) /* complete wanted number of results */
- setnilvalue(res + i);
- }
- break;
- }
- }
- L->top = res + wanted; /* top points after the last result */
- return 1;
-}
-
-
-/*
-** Finishes a function call: calls hook if necessary, removes CallInfo,
-** moves current number of results to proper place; returns 0 iff call
-** wanted multiple (variable number of) results.
-*/
-int luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult, int nres) {
- StkId res;
- int wanted = ci->nresults;
- if (L->hookmask & (LUA_MASKRET | LUA_MASKLINE)) {
- if (L->hookmask & LUA_MASKRET) {
- ptrdiff_t fr = savestack(L, firstResult); /* hook may change stack */
- luaD_hook(L, LUA_HOOKRET, -1);
- firstResult = restorestack(L, fr);
- }
- L->oldpc = ci->previous->u.l.savedpc; /* 'oldpc' for caller function */
- }
- res = ci->func; /* res == final position of 1st result */
- L->ci = ci->previous; /* back to caller */
- /* move results to proper place */
- return moveresults(L, firstResult, res, nres, wanted);
-}
-
-
-/*
** Check appropriate error for stack overflow ("regular" overflow or
** overflow while handling stack overflow). If 'nCalls' is larger than
** LUAI_MAXCCALLS (which means it is handling a "regular" overflow) but
@@ -515,19 +523,17 @@
/* error status can only happen in a protected call */
lua_assert((ci->callstatus & CIST_YPCALL) || status == LUA_YIELD);
if (ci->callstatus & CIST_YPCALL) { /* was inside a pcall? */
- ci->callstatus &= ~CIST_YPCALL; /* finish 'lua_pcall' */
- L->errfunc = ci->u.c.old_errfunc;
+ ci->callstatus &= ~CIST_YPCALL; /* continuation is also inside it */
+ L->errfunc = ci->u.c.old_errfunc; /* with the same error function */
}
/* finish 'lua_callk'/'lua_pcall'; CIST_YPCALL and 'errfunc' already
handled */
adjustresults(L, ci->nresults);
- /* call continuation function */
lua_unlock(L);
- n = (*ci->u.c.k)(L, status, ci->u.c.ctx);
+ n = (*ci->u.c.k)(L, status, ci->u.c.ctx); /* call continuation function */
lua_lock(L);
api_checknelems(L, n);
- /* finish 'luaD_precall' */
- luaD_poscall(L, ci, L->top - n, n);
+ luaD_poscall(L, ci, L->top - n, n); /* finish 'luaD_precall' */
}
@@ -590,15 +596,16 @@
/*
-** signal an error in the call to 'resume', not in the execution of the
-** coroutine itself. (Such errors should not be handled by any coroutine
-** error handler and should not kill the coroutine.)
+** Signal an error in the call to 'lua_resume', not in the execution
+** of the coroutine itself. (Such errors should not be handled by any
+** coroutine error handler and should not kill the coroutine.)
*/
-static l_noret resume_error (lua_State *L, const char *msg, StkId firstArg) {
- L->top = firstArg; /* remove args from the stack */
+static int resume_error (lua_State *L, const char *msg, int narg) {
+ L->top -= narg; /* remove args from the stack */
setsvalue2s(L, L->top, luaS_new(L, msg)); /* push error message */
api_incr_top(L);
- luaD_throw(L, -1); /* jump back to 'lua_resume' */
+ lua_unlock(L);
+ return LUA_ERRRUN;
}
@@ -610,22 +617,15 @@
** coroutine.
*/
static void resume (lua_State *L, void *ud) {
- int nCcalls = L->nCcalls;
int n = *(cast(int*, ud)); /* number of arguments */
StkId firstArg = L->top - n; /* first argument */
CallInfo *ci = L->ci;
- if (nCcalls >= LUAI_MAXCCALLS)
- resume_error(L, "C stack overflow", firstArg);
- if (L->status == LUA_OK) { /* may be starting a coroutine */
- if (ci != &L->base_ci) /* not in base level? */
- resume_error(L, "cannot resume non-suspended coroutine", firstArg);
- /* coroutine is in base level; start running it */
+ if (L->status == LUA_OK) { /* starting a coroutine? */
if (!luaD_precall(L, firstArg - 1, LUA_MULTRET)) /* Lua function? */
luaV_execute(L); /* call it */
}
- else if (L->status != LUA_YIELD)
- resume_error(L, "cannot resume dead coroutine", firstArg);
else { /* resuming from previous yield */
+ lua_assert(L->status == LUA_YIELD);
L->status = LUA_OK; /* mark that it is running (again) */
ci->func = restorestack(L, ci->extra);
if (isLua(ci)) /* yielded inside a hook? */
@@ -642,7 +642,6 @@
}
unroll(L, NULL); /* run continuation */
}
- lua_assert(nCcalls == L->nCcalls);
}
@@ -650,8 +649,16 @@
int status;
unsigned short oldnny = L->nny; /* save "number of non-yieldable" calls */
lua_lock(L);
+ if (L->status == LUA_OK) { /* may be starting a coroutine */
+ if (L->ci != &L->base_ci) /* not in base level? */
+ return resume_error(L, "cannot resume non-suspended coroutine", nargs);
+ }
+ else if (L->status != LUA_YIELD)
+ return resume_error(L, "cannot resume dead coroutine", nargs);
+ L->nCcalls = (from) ? from->nCcalls + 1 : 1;
+ if (L->nCcalls >= LUAI_MAXCCALLS)
+ return resume_error(L, "C stack overflow", nargs);
luai_userstateresume(L, nargs);
- L->nCcalls = (from) ? from->nCcalls + 1 : 1;
L->nny = 0; /* allow yields */
api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs);
status = luaD_rawrunprotected(L, resume, &nargs);
=== modified file 'src/third_party/eris/ldo.h'
--- src/third_party/eris/ldo.h 2016-08-04 15:49:05 +0000
+++ src/third_party/eris/ldo.h 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: ldo.h,v 2.28 2015/11/23 11:29:43 roberto Exp $
+** $Id: ldo.h,v 2.29 2015/12/21 13:02:14 roberto Exp $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@@ -7,10 +7,12 @@
#ifndef ldo_h
#define ldo_h
+
#include "lobject.h"
#include "lstate.h"
#include "lzio.h"
+
/*
** Macro to check stack size and grow stack if needed. Parameters
** 'pre'/'pos' allow the macro to preserve a pointer into the
@@ -18,37 +20,39 @@
** 'condmovestack' is used in heavy tests to force a stack reallocation
** at every check.
*/
-#define luaD_checkstackaux(L, n, pre, pos) \
- if (L->stack_last - L->top <= (n)) { \
- pre; \
- luaD_growstack(L, n); \
- pos; \
- } else { \
- condmovestack(L, pre, pos); \
- }
+#define luaD_checkstackaux(L,n,pre,pos) \
+ if (L->stack_last - L->top <= (n)) \
+ { pre; luaD_growstack(L, n); pos; } else { condmovestack(L,pre,pos); }
/* In general, 'pre'/'pos' are empty (nothing to save) */
-#define luaD_checkstack(L, n) luaD_checkstackaux(L, n, , )
-
-#define savestack(L, p) ((char*)(p) - (char*)L->stack)
-#define restorestack(L, n) ((TValue*)((char*)L->stack + (n)))
+#define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0)
+
+
+
+#define savestack(L,p) ((char *)(p) - (char *)L->stack)
+#define restorestack(L,n) ((TValue *)((char *)L->stack + (n)))
+
/* type of protected functions, to be ran by 'runprotected' */
-typedef void (*Pfunc)(lua_State* L, void* ud);
-
-LUAI_FUNC int luaD_protectedparser(lua_State* L, ZIO* z, const char* name, const char* mode);
-LUAI_FUNC void luaD_hook(lua_State* L, int event, int line);
-LUAI_FUNC int luaD_precall(lua_State* L, StkId func, int nresults);
-LUAI_FUNC void luaD_call(lua_State* L, StkId func, int nResults);
-LUAI_FUNC void luaD_callnoyield(lua_State* L, StkId func, int nResults);
-LUAI_FUNC int luaD_pcall(lua_State* L, Pfunc func, void* u, ptrdiff_t oldtop, ptrdiff_t ef);
-LUAI_FUNC int luaD_poscall(lua_State* L, CallInfo* ci, StkId firstResult, int nres);
-LUAI_FUNC void luaD_reallocstack(lua_State* L, int newsize);
-LUAI_FUNC void luaD_growstack(lua_State* L, int n);
-LUAI_FUNC void luaD_shrinkstack(lua_State* L);
-LUAI_FUNC void luaD_inctop(lua_State* L);
-
-LUAI_FUNC l_noret luaD_throw(lua_State* L, int errcode);
-LUAI_FUNC int luaD_rawrunprotected(lua_State* L, Pfunc f, void* ud);
+typedef void (*Pfunc) (lua_State *L, void *ud);
+
+LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name,
+ const char *mode);
+LUAI_FUNC void luaD_hook (lua_State *L, int event, int line);
+LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults);
+LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
+LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults);
+LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
+ ptrdiff_t oldtop, ptrdiff_t ef);
+LUAI_FUNC int luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult,
+ int nres);
+LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
+LUAI_FUNC void luaD_growstack (lua_State *L, int n);
+LUAI_FUNC void luaD_shrinkstack (lua_State *L);
+LUAI_FUNC void luaD_inctop (lua_State *L);
+
+LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode);
+LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
#endif
+
=== modified file 'src/third_party/eris/lfunc.h'
--- src/third_party/eris/lfunc.h 2016-08-04 15:49:05 +0000
+++ src/third_party/eris/lfunc.h 2018-07-08 12:35:11 +0000
@@ -7,45 +7,55 @@
#ifndef lfunc_h
#define lfunc_h
+
#include "lobject.h"
-#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + cast(int, sizeof(TValue) * ((n)-1)))
-
-#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + cast(int, sizeof(TValue*) * ((n)-1)))
+
+#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \
+ cast(int, sizeof(TValue)*((n)-1)))
+
+#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \
+ cast(int, sizeof(TValue *)*((n)-1)))
+
/* test whether thread is in 'twups' list */
-#define isintwups(L) (L->twups != L)
+#define isintwups(L) (L->twups != L)
+
/*
** maximum number of upvalues in a closure (both C and Lua). (Value
** must fit in a VM register.)
*/
-#define MAXUPVAL 255
+#define MAXUPVAL 255
+
/*
** Upvalues for Lua closures
*/
struct UpVal {
- TValue* v; /* points to stack or to its own value */
- lu_mem refcount; /* reference counter */
- union {
- struct { /* (when open) */
- UpVal* next; /* linked list */
- int touched; /* mark to avoid cycles with dead threads */
- } open;
- TValue value; /* the value (when closed) */
- } u;
+ TValue *v; /* points to stack or to its own value */
+ lu_mem refcount; /* reference counter */
+ union {
+ struct { /* (when open) */
+ UpVal *next; /* linked list */
+ int touched; /* mark to avoid cycles with dead threads */
+ } open;
+ TValue value; /* the value (when closed) */
+ } u;
};
-#define upisopen(up) ((up)->v != &(up)->u.value)
-
-LUAI_FUNC Proto* luaF_newproto(lua_State* L);
-LUAI_FUNC CClosure* luaF_newCclosure(lua_State* L, int nelems);
-LUAI_FUNC LClosure* luaF_newLclosure(lua_State* L, int nelems);
-LUAI_FUNC void luaF_initupvals(lua_State* L, LClosure* cl);
-LUAI_FUNC UpVal* luaF_findupval(lua_State* L, StkId level);
-LUAI_FUNC void luaF_close(lua_State* L, StkId level);
-LUAI_FUNC void luaF_freeproto(lua_State* L, Proto* f);
-LUAI_FUNC const char* luaF_getlocalname(const Proto* func, int local_number, int pc);
+#define upisopen(up) ((up)->v != &(up)->u.value)
+
+
+LUAI_FUNC Proto *luaF_newproto (lua_State *L);
+LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems);
+LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems);
+LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl);
+LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
+LUAI_FUNC void luaF_close (lua_State *L, StkId level);
+LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f);
+LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number,
+ int pc);
+
#endif
=== modified file 'src/third_party/eris/lgc.c'
--- src/third_party/eris/lgc.c 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/lgc.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: lgc.c,v 2.210 2015/11/03 18:10:44 roberto Exp $
+** $Id: lgc.c,v 2.215 2016/12/22 13:08:50 roberto Exp $
** Garbage Collector
** See Copyright Notice in lua.h
*/
@@ -467,7 +467,7 @@
else /* not weak */
traversestrongtable(g, h);
return sizeof(Table) + sizeof(TValue) * h->sizearray +
- sizeof(Node) * cast(size_t, sizenode(h));
+ sizeof(Node) * cast(size_t, allocsizenode(h));
}
@@ -539,7 +539,7 @@
StkId lim = th->stack + th->stacksize; /* real end of stack */
for (; o < lim; o++) /* clear not-marked stack slice */
setnilvalue(o);
- /* 'remarkupvals' may have removed thread from 'twups' list */
+ /* 'remarkupvals' may have removed thread from 'twups' list */
if (!isintwups(th) && th->openupval != NULL) {
th->twups = g->twups; /* link it back to the list */
g->twups = th;
@@ -754,14 +754,11 @@
/*
** sweep a list until a live object (or end of list)
*/
-static GCObject **sweeptolive (lua_State *L, GCObject **p, int *n) {
+static GCObject **sweeptolive (lua_State *L, GCObject **p) {
GCObject **old = p;
- int i = 0;
do {
- i++;
p = sweeplist(L, p, 1);
} while (p == old);
- if (n) *n += i;
return p;
}
@@ -821,7 +818,9 @@
setobj2s(L, L->top, tm); /* push finalizer... */
setobj2s(L, L->top + 1, &v); /* ... and its argument */
L->top += 2; /* and (next line) call the finalizer */
+ L->ci->callstatus |= CIST_FIN; /* will run a finalizer */
status = luaD_pcall(L, dothecall, NULL, savestack(L, L->top - 2), 0);
+ L->ci->callstatus &= ~CIST_FIN; /* not running a finalizer anymore */
L->allowhook = oldah; /* restore hooks */
g->gcrunning = running; /* restore state */
if (status != LUA_OK && propagateerrors) { /* error while running __gc? */
@@ -856,10 +855,10 @@
/*
** call all pending finalizers
*/
-static void callallpendingfinalizers (lua_State *L, int propagateerrors) {
+static void callallpendingfinalizers (lua_State *L) {
global_State *g = G(L);
while (g->tobefnz)
- GCTM(L, propagateerrors);
+ GCTM(L, 0);
}
@@ -909,7 +908,7 @@
if (issweepphase(g)) {
makewhite(g, o); /* "sweep" object 'o' */
if (g->sweepgc == &o->next) /* should not remove 'sweepgc' object */
- g->sweepgc = sweeptolive(L, g->sweepgc, NULL); /* change 'sweepgc' */
+ g->sweepgc = sweeptolive(L, g->sweepgc); /* change 'sweepgc' */
}
/* search for pointer pointing to 'o' */
for (p = &g->allgc; *p != o; p = &(*p)->next) { /* empty */ }
@@ -951,19 +950,16 @@
/*
** Enter first sweep phase.
-** The call to 'sweeptolive' makes pointer point to an object inside
-** the list (instead of to the header), so that the real sweep do not
-** need to skip objects created between "now" and the start of the real
-** sweep.
-** Returns how many objects it swept.
+** The call to 'sweeplist' tries to make pointer point to an object
+** inside the list (instead of to the header), so that the real sweep do
+** not need to skip objects created between "now" and the start of the
+** real sweep.
*/
-static int entersweep (lua_State *L) {
+static void entersweep (lua_State *L) {
global_State *g = G(L);
- int n = 0;
g->gcstate = GCSswpallgc;
lua_assert(g->sweepgc == NULL);
- g->sweepgc = sweeptolive(L, &g->allgc, &n);
- return n;
+ g->sweepgc = sweeplist(L, &g->allgc, 1);
}
@@ -971,7 +967,7 @@
global_State *g = G(L);
separatetobefnz(g, 1); /* separate all objects with finalizers */
lua_assert(g->finobj == NULL);
- callallpendingfinalizers(L, 0);
+ callallpendingfinalizers(L);
lua_assert(g->tobefnz == NULL);
g->currentwhite = WHITEBITS; /* this "white" makes all objects look dead */
g->gckind = KGC_NORMAL;
@@ -1064,12 +1060,11 @@
}
case GCSatomic: {
lu_mem work;
- int sw;
propagateall(g); /* make sure gray list is empty */
work = atomic(L); /* work is what was traversed by 'atomic' */
- sw = entersweep(L);
+ entersweep(L);
g->GCestimate = gettotalbytes(g); /* first estimate */;
- return work + sw * GCSWEEPCOST;
+ return work;
}
case GCSswpallgc: { /* sweep "regular" objects */
return sweepstep(L, g, GCSswpfinobj, &g->finobj);
=== modified file 'src/third_party/eris/lgc.h'
--- src/third_party/eris/lgc.h 2016-08-04 15:49:05 +0000
+++ src/third_party/eris/lgc.h 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: lgc.h,v 2.90 2015/10/21 18:15:15 roberto Exp $
+** $Id: lgc.h,v 2.91 2015/12/21 13:02:14 roberto Exp $
** Garbage Collector
** See Copyright Notice in lua.h
*/
@@ -7,6 +7,7 @@
#ifndef lgc_h
#define lgc_h
+
#include "lobject.h"
#include "lstate.h"
@@ -23,25 +24,31 @@
** is not being enforced (e.g., sweep phase).
*/
+
+
/* how much to allocate before next GC step */
#if !defined(GCSTEPSIZE)
/* ~100 small strings */
-#define GCSTEPSIZE (cast_int(100 * sizeof(TString)))
+#define GCSTEPSIZE (cast_int(100 * sizeof(TString)))
#endif
+
/*
** Possible states of the Garbage Collector
*/
-#define GCSpropagate 0
-#define GCSatomic 1
-#define GCSswpallgc 2
-#define GCSswpfinobj 3
-#define GCSswptobefnz 4
-#define GCSswpend 5
-#define GCScallfin 6
-#define GCSpause 7
-
-#define issweepphase(g) (GCSswpallgc <= (g)->gcstate && (g)->gcstate <= GCSswpend)
+#define GCSpropagate 0
+#define GCSatomic 1
+#define GCSswpallgc 2
+#define GCSswpfinobj 3
+#define GCSswptobefnz 4
+#define GCSswpend 5
+#define GCScallfin 6
+#define GCSpause 7
+
+
+#define issweepphase(g) \
+ (GCSswpallgc <= (g)->gcstate && (g)->gcstate <= GCSswpend)
+
/*
** macro to tell when main invariant (white objects cannot point to black
@@ -51,44 +58,48 @@
** all objects are white again.
*/
-#define keepinvariant(g) ((g)->gcstate <= GCSatomic)
+#define keepinvariant(g) ((g)->gcstate <= GCSatomic)
+
/*
** some useful bit tricks
*/
-#define resetbits(x, m) ((x) &= cast(lu_byte, ~(m)))
-#define setbits(x, m) ((x) |= (m))
-#define testbits(x, m) ((x) & (m))
-#define bitmask(b) (1 << (b))
-#define bit2mask(b1, b2) (bitmask(b1) | bitmask(b2))
-#define l_setbit(x, b) setbits(x, bitmask(b))
-#define resetbit(x, b) resetbits(x, bitmask(b))
-#define testbit(x, b) testbits(x, bitmask(b))
+#define resetbits(x,m) ((x) &= cast(lu_byte, ~(m)))
+#define setbits(x,m) ((x) |= (m))
+#define testbits(x,m) ((x) & (m))
+#define bitmask(b) (1<<(b))
+#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2))
+#define l_setbit(x,b) setbits(x, bitmask(b))
+#define resetbit(x,b) resetbits(x, bitmask(b))
+#define testbit(x,b) testbits(x, bitmask(b))
+
/* Layout for bit use in 'marked' field: */
-#define WHITE0BIT 0 /* object is white (type 0) */
-#define WHITE1BIT 1 /* object is white (type 1) */
-#define BLACKBIT 2 /* object is black */
-#define FINALIZEDBIT 3 /* object has been marked for finalization */
+#define WHITE0BIT 0 /* object is white (type 0) */
+#define WHITE1BIT 1 /* object is white (type 1) */
+#define BLACKBIT 2 /* object is black */
+#define FINALIZEDBIT 3 /* object has been marked for finalization */
/* bit 7 is currently used by tests (luaL_checkmemory) */
-#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT)
-
-#define iswhite(x) testbits((x)->marked, WHITEBITS)
-#define isblack(x) testbit((x)->marked, BLACKBIT)
-#define isgray(x) /* neither white nor black */ \
+#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT)
+
+
+#define iswhite(x) testbits((x)->marked, WHITEBITS)
+#define isblack(x) testbit((x)->marked, BLACKBIT)
+#define isgray(x) /* neither white nor black */ \
(!testbits((x)->marked, WHITEBITS | bitmask(BLACKBIT)))
-#define tofinalize(x) testbit((x)->marked, FINALIZEDBIT)
-
-#define otherwhite(g) ((g)->currentwhite ^ WHITEBITS)
-#define isdeadm(ow, m) (!(((m) ^ WHITEBITS) & (ow)))
-#define isdead(g, v) isdeadm(otherwhite(g), (v)->marked)
-
-#define changewhite(x) ((x)->marked ^= WHITEBITS)
-#define gray2black(x) l_setbit((x)->marked, BLACKBIT)
-
-#define luaC_white(g) cast(lu_byte, (g)->currentwhite& WHITEBITS)
+#define tofinalize(x) testbit((x)->marked, FINALIZEDBIT)
+
+#define otherwhite(g) ((g)->currentwhite ^ WHITEBITS)
+#define isdeadm(ow,m) (!(((m) ^ WHITEBITS) & (ow)))
+#define isdead(g,v) isdeadm(otherwhite(g), (v)->marked)
+
+#define changewhite(x) ((x)->marked ^= WHITEBITS)
+#define gray2black(x) l_setbit((x)->marked, BLACKBIT)
+
+#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS)
+
/*
** Does one step of collection when debt becomes positive. 'pre'/'pos'
@@ -96,44 +107,41 @@
** 'condchangemem' is used only for heavy tests (forcing a full
** GC cycle on every opportunity)
*/
-#define luaC_condGC(L, pre, pos) \
- { \
- if (G(L)->GCdebt > 0) { \
- pre; \
- luaC_step(L); \
- pos; \
- }; \
- condchangemem(L, pre, pos); \
- }
+#define luaC_condGC(L,pre,pos) \
+ { if (G(L)->GCdebt > 0) { pre; luaC_step(L); pos;}; \
+ condchangemem(L,pre,pos); }
/* more often than not, 'pre'/'pos' are empty */
-#define luaC_checkGC(L) luaC_condGC(L, , )
-
-#define luaC_barrier(L, p, v) \
- ((iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \
- luaC_barrier_(L, obj2gco(p), gcvalue(v)) : \
- cast_void(0))
-
-#define luaC_barrierback(L, p, v) \
- ((iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? luaC_barrierback_(L, p) : \
- cast_void(0))
-
-#define luaC_objbarrier(L, p, o) \
- ((isblack(p) && iswhite(o)) ? luaC_barrier_(L, obj2gco(p), obj2gco(o)) : cast_void(0))
-
-#define luaC_upvalbarrier(L, uv) \
- ((iscollectable((uv)->v) && !upisopen(uv)) ? luaC_upvalbarrier_(L, uv) : cast_void(0))
-
-LUAI_FUNC void luaC_fix(lua_State* L, GCObject* o);
-LUAI_FUNC void luaC_freeallobjects(lua_State* L);
-LUAI_FUNC void luaC_step(lua_State* L);
-LUAI_FUNC void luaC_runtilstate(lua_State* L, int statesmask);
-LUAI_FUNC void luaC_fullgc(lua_State* L, int isemergency);
-LUAI_FUNC GCObject* luaC_newobj(lua_State* L, int tt, size_t sz);
-LUAI_FUNC void luaC_barrier_(lua_State* L, GCObject* o, GCObject* v);
-LUAI_FUNC void luaC_barrierback_(lua_State* L, Table* o);
-LUAI_FUNC void luaC_upvalbarrier_(lua_State* L, UpVal* uv);
-LUAI_FUNC void luaC_checkfinalizer(lua_State* L, GCObject* o, Table* mt);
-LUAI_FUNC void luaC_upvdeccount(lua_State* L, UpVal* uv);
+#define luaC_checkGC(L) luaC_condGC(L,(void)0,(void)0)
+
+
+#define luaC_barrier(L,p,v) ( \
+ (iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \
+ luaC_barrier_(L,obj2gco(p),gcvalue(v)) : cast_void(0))
+
+#define luaC_barrierback(L,p,v) ( \
+ (iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \
+ luaC_barrierback_(L,p) : cast_void(0))
+
+#define luaC_objbarrier(L,p,o) ( \
+ (isblack(p) && iswhite(o)) ? \
+ luaC_barrier_(L,obj2gco(p),obj2gco(o)) : cast_void(0))
+
+#define luaC_upvalbarrier(L,uv) ( \
+ (iscollectable((uv)->v) && !upisopen(uv)) ? \
+ luaC_upvalbarrier_(L,uv) : cast_void(0))
+
+LUAI_FUNC void luaC_fix (lua_State *L, GCObject *o);
+LUAI_FUNC void luaC_freeallobjects (lua_State *L);
+LUAI_FUNC void luaC_step (lua_State *L);
+LUAI_FUNC void luaC_runtilstate (lua_State *L, int statesmask);
+LUAI_FUNC void luaC_fullgc (lua_State *L, int isemergency);
+LUAI_FUNC GCObject *luaC_newobj (lua_State *L, int tt, size_t sz);
+LUAI_FUNC void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v);
+LUAI_FUNC void luaC_barrierback_ (lua_State *L, Table *o);
+LUAI_FUNC void luaC_upvalbarrier_ (lua_State *L, UpVal *uv);
+LUAI_FUNC void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt);
+LUAI_FUNC void luaC_upvdeccount (lua_State *L, UpVal *uv);
+
#endif
=== modified file 'src/third_party/eris/linit.c'
--- src/third_party/eris/linit.c 2016-04-08 18:00:30 +0000
+++ src/third_party/eris/linit.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: linit.c,v 1.38 2015/01/05 13:48:33 roberto Exp $
+** $Id: linit.c,v 1.39 2016/12/04 20:17:24 roberto Exp $
** Initialization of libraries for lua.c and other clients
** See Copyright Notice in lua.h
*/
@@ -18,10 +18,10 @@
** open the library, which is already linked to the application.
** For that, do the following code:
**
-** luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
+** luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE);
** lua_pushcfunction(L, luaopen_modname);
** lua_setfield(L, -2, modname);
-** lua_pop(L, 1); // remove _PRELOAD table
+** lua_pop(L, 1); // remove PRELOAD table
*/
#include "lprefix.h"
=== modified file 'src/third_party/eris/liolib.c'
--- src/third_party/eris/liolib.c 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/liolib.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: liolib.c,v 2.148 2015/11/23 11:36:11 roberto Exp $
+** $Id: liolib.c,v 2.151 2016/12/20 18:37:00 roberto Exp $
** Standard I/O (and system) library
** See Copyright Notice in lua.h
*/
@@ -37,10 +37,11 @@
#endif
/* Check whether 'mode' matches '[rwa]%+?[L_MODEEXT]*' */
-#define l_checkmode(mode) \
- (*mode != '\0' && strchr("rwa", *(mode++)) != NULL && \
- (*mode != '+' || (++mode, 1)) && /* skip if char is '+' */ \
- (strspn(mode, L_MODEEXT) == strlen(mode)))
+static int l_checkmode (const char *mode) {
+ return (*mode != '\0' && strchr("rwa", *(mode++)) != NULL &&
+ (*mode != '+' || (++mode, 1)) && /* skip if char is '+' */
+ (strspn(mode, L_MODEEXT) == strlen(mode))); /* check extensions */
+}
#endif
@@ -375,14 +376,17 @@
/* maximum length of a numeral */
-#define MAXRN 200
+#if !defined (L_MAXLENNUM)
+#define L_MAXLENNUM 200
+#endif
+
/* auxiliary structure used by 'read_number' */
typedef struct {
FILE *f; /* file being read */
int c; /* current character (look ahead) */
int n; /* number of elements in buffer 'buff' */
- char buff[MAXRN + 1]; /* +1 for ending '\0' */
+ char buff[L_MAXLENNUM + 1]; /* +1 for ending '\0' */
} RN;
@@ -390,7 +394,7 @@
** Add current char to buffer (if not out of space) and read next one
*/
static int nextc (RN *rn) {
- if (rn->n >= MAXRN) { /* buffer overflow? */
+ if (rn->n >= L_MAXLENNUM) { /* buffer overflow? */
rn->buff[0] = '\0'; /* invalidate result */
return 0; /* fail */
}
@@ -403,10 +407,10 @@
/*
-** Accept current char if it is in 'set' (of size 1 or 2)
+** Accept current char if it is in 'set' (of size 2)
*/
static int test2 (RN *rn, const char *set) {
- if (rn->c == set[0] || (rn->c == set[1] && rn->c != '\0'))
+ if (rn->c == set[0] || rn->c == set[1])
return nextc(rn);
else return 0;
}
@@ -435,11 +439,11 @@
char decp[2];
rn.f = f; rn.n = 0;
decp[0] = lua_getlocaledecpoint(); /* get decimal point from locale */
- decp[1] = '\0';
+ decp[1] = '.'; /* always accept a dot */
l_lockfile(rn.f);
do { rn.c = l_getc(rn.f); } while (isspace(rn.c)); /* skip spaces */
test2(&rn, "-+"); /* optional signal */
- if (test2(&rn, "0")) {
+ if (test2(&rn, "00")) {
if (test2(&rn, "xX")) hex = 1; /* numeral is hexadecimal */
else count = 1; /* count initial '0' as a valid digit */
}
@@ -615,8 +619,10 @@
if (lua_type(L, arg) == LUA_TNUMBER) {
/* optimization: could be done exactly as for strings */
int len = lua_isinteger(L, arg)
- ? fprintf(f, LUA_INTEGER_FMT, lua_tointeger(L, arg))
- : fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg));
+ ? fprintf(f, LUA_INTEGER_FMT,
+ (LUAI_UACINT)lua_tointeger(L, arg))
+ : fprintf(f, LUA_NUMBER_FMT,
+ (LUAI_UACNUMBER)lua_tonumber(L, arg));
status = status && (len > 0);
}
else {
=== modified file 'src/third_party/eris/llex.c'
--- src/third_party/eris/llex.c 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/llex.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: llex.c,v 2.95 2015/11/19 19:16:22 roberto Exp $
+** $Id: llex.c,v 2.96 2016/05/02 14:02:12 roberto Exp $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
@@ -162,7 +162,6 @@
void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source,
int firstchar) {
ls->t.token = 0;
- ls->decpoint = '.';
ls->L = L;
ls->current = firstchar;
ls->lookahead.token = TK_EOS; /* no look-ahead token */
@@ -207,35 +206,6 @@
}
-/*
-** change all characters 'from' in buffer to 'to'
-*/
-static void buffreplace (LexState *ls, char from, char to) {
- if (from != to) {
- size_t n = luaZ_bufflen(ls->buff);
- char *p = luaZ_buffer(ls->buff);
- while (n--)
- if (p[n] == from) p[n] = to;
- }
-}
-
-
-/*
-** in case of format error, try to change decimal point separator to
-** the one defined in the current locale and check again
-*/
-static void trydecpoint (LexState *ls, TValue *o) {
- char old = ls->decpoint;
- ls->decpoint = lua_getlocaledecpoint();
- buffreplace(ls, old, ls->decpoint); /* try new decimal separator */
- if (luaO_str2num(luaZ_buffer(ls->buff), o) == 0) {
- /* format error with correct decimal point: no more options */
- buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */
- lexerror(ls, "malformed number", TK_FLT);
- }
-}
-
-
/* LUA_NUMBER */
/*
** this function is quite liberal in what it accepts, as 'luaO_str2num'
@@ -259,9 +229,8 @@
else break;
}
save(ls, '\0');
- buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */
if (luaO_str2num(luaZ_buffer(ls->buff), &obj) == 0) /* format error? */
- trydecpoint(ls, &obj); /* try to update decimal point separator */
+ lexerror(ls, "malformed number", TK_FLT);
if (ttisinteger(&obj)) {
seminfo->i = ivalue(&obj);
return TK_INT;
=== modified file 'src/third_party/eris/llex.h'
--- src/third_party/eris/llex.h 2016-08-04 15:49:05 +0000
+++ src/third_party/eris/llex.h 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: llex.h,v 1.78 2014/10/29 15:38:24 roberto Exp $
+** $Id: llex.h,v 1.79 2016/05/02 14:02:12 roberto Exp $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
@@ -10,97 +10,76 @@
#include "lobject.h"
#include "lzio.h"
-#define FIRST_RESERVED 257
+
+#define FIRST_RESERVED 257
+
#if !defined(LUA_ENV)
-#define LUA_ENV "_ENV"
+#define LUA_ENV "_ENV"
#endif
+
/*
* WARNING: if you change the order of this enumeration,
* grep "ORDER RESERVED"
*/
enum RESERVED {
- /* terminal symbols denoted by reserved words */
- TK_AND = FIRST_RESERVED,
- TK_BREAK,
- TK_DO,
- TK_ELSE,
- TK_ELSEIF,
- TK_END,
- TK_FALSE,
- TK_FOR,
- TK_FUNCTION,
- TK_GOTO,
- TK_IF,
- TK_IN,
- TK_LOCAL,
- TK_NIL,
- TK_NOT,
- TK_OR,
- TK_REPEAT,
- TK_RETURN,
- TK_THEN,
- TK_TRUE,
- TK_UNTIL,
- TK_WHILE,
- /* other terminal symbols */
- TK_IDIV,
- TK_CONCAT,
- TK_DOTS,
- TK_EQ,
- TK_GE,
- TK_LE,
- TK_NE,
- TK_SHL,
- TK_SHR,
- TK_DBCOLON,
- TK_EOS,
- TK_FLT,
- TK_INT,
- TK_NAME,
- TK_STRING
+ /* terminal symbols denoted by reserved words */
+ TK_AND = FIRST_RESERVED, TK_BREAK,
+ TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION,
+ TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT,
+ TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
+ /* other terminal symbols */
+ TK_IDIV, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE,
+ TK_SHL, TK_SHR,
+ TK_DBCOLON, TK_EOS,
+ TK_FLT, TK_INT, TK_NAME, TK_STRING
};
/* number of reserved words */
-#define NUM_RESERVED (cast(int, TK_WHILE - FIRST_RESERVED + 1))
+#define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1))
+
typedef union {
- lua_Number r;
- lua_Integer i;
- TString* ts;
-} SemInfo; /* semantics information */
+ lua_Number r;
+ lua_Integer i;
+ TString *ts;
+} SemInfo; /* semantics information */
+
typedef struct Token {
- int token;
- SemInfo seminfo;
+ int token;
+ SemInfo seminfo;
} Token;
+
/* state of the lexer plus state of the parser when shared by all
functions */
typedef struct LexState {
- int current; /* current character (charint) */
- int linenumber; /* input line counter */
- int lastline; /* line of last token 'consumed' */
- Token t; /* current token */
- Token lookahead; /* look ahead token */
- struct FuncState* fs; /* current function (parser) */
- struct lua_State* L;
- ZIO* z; /* input stream */
- Mbuffer* buff; /* buffer for tokens */
- Table* h; /* to avoid collection/reuse strings */
- struct Dyndata* dyd; /* dynamic structures used by the parser */
- TString* source; /* current source name */
- TString* envn; /* environment variable name */
- char decpoint; /* locale decimal point */
+ int current; /* current character (charint) */
+ int linenumber; /* input line counter */
+ int lastline; /* line of last token 'consumed' */
+ Token t; /* current token */
+ Token lookahead; /* look ahead token */
+ struct FuncState *fs; /* current function (parser) */
+ struct lua_State *L;
+ ZIO *z; /* input stream */
+ Mbuffer *buff; /* buffer for tokens */
+ Table *h; /* to avoid collection/reuse strings */
+ struct Dyndata *dyd; /* dynamic structures used by the parser */
+ TString *source; /* current source name */
+ TString *envn; /* environment variable name */
} LexState;
-LUAI_FUNC void luaX_init(lua_State* L);
-LUAI_FUNC void luaX_setinput(lua_State* L, LexState* ls, ZIO* z, TString* source, int firstchar);
-LUAI_FUNC TString* luaX_newstring(LexState* ls, const char* str, size_t l);
-LUAI_FUNC void luaX_next(LexState* ls);
-LUAI_FUNC int luaX_lookahead(LexState* ls);
-LUAI_FUNC l_noret luaX_syntaxerror(LexState* ls, const char* s);
-LUAI_FUNC const char* luaX_token2str(LexState* ls, int token);
+
+LUAI_FUNC void luaX_init (lua_State *L);
+LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z,
+ TString *source, int firstchar);
+LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l);
+LUAI_FUNC void luaX_next (LexState *ls);
+LUAI_FUNC int luaX_lookahead (LexState *ls);
+LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s);
+LUAI_FUNC const char *luaX_token2str (LexState *ls, int token);
+
#endif
=== modified file 'src/third_party/eris/llimits.h'
--- src/third_party/eris/llimits.h 2016-08-04 15:49:05 +0000
+++ src/third_party/eris/llimits.h 2018-07-08 12:35:11 +0000
@@ -7,9 +7,11 @@
#ifndef llimits_h
#define llimits_h
+
#include <limits.h>
#include <stddef.h>
+
#include "lua.h"
/*
@@ -17,93 +19,107 @@
** the total memory used by Lua (in bytes). Usually, 'size_t' and
** 'ptrdiff_t' should work, but we use 'long' for 16-bit machines.
*/
-#if defined(LUAI_MEM) /* { external definitions? */
+#if defined(LUAI_MEM) /* { external definitions? */
typedef LUAI_UMEM lu_mem;
typedef LUAI_MEM l_mem;
-#elif LUAI_BITSINT >= 32 /* }{ */
+#elif LUAI_BITSINT >= 32 /* }{ */
typedef size_t lu_mem;
typedef ptrdiff_t l_mem;
-#else /* 16-bit ints */ /* }{ */
+#else /* 16-bit ints */ /* }{ */
typedef unsigned long lu_mem;
typedef long l_mem;
-#endif /* } */
+#endif /* } */
+
/* chars used as small naturals (so that 'char' is reserved for characters) */
typedef unsigned char lu_byte;
+
/* maximum value for size_t */
-#define MAX_SIZET ((size_t)(~(size_t)0))
+#define MAX_SIZET ((size_t)(~(size_t)0))
/* maximum size visible for Lua (must be representable in a lua_Integer */
-#define MAX_SIZE (sizeof(size_t) < sizeof(lua_Integer) ? MAX_SIZET : (size_t)(LUA_MAXINTEGER))
-
-#define MAX_LUMEM ((lu_mem)(~(lu_mem)0))
-
-#define MAX_LMEM ((l_mem)(MAX_LUMEM >> 1))
-
-#define MAX_INT INT_MAX /* maximum value of an int */
+#define MAX_SIZE (sizeof(size_t) < sizeof(lua_Integer) ? MAX_SIZET \
+ : (size_t)(LUA_MAXINTEGER))
+
+
+#define MAX_LUMEM ((lu_mem)(~(lu_mem)0))
+
+#define MAX_LMEM ((l_mem)(MAX_LUMEM >> 1))
+
+
+#define MAX_INT INT_MAX /* maximum value of an int */
+
/*
** conversion of pointer to unsigned integer:
** this is for hashing only; there is no problem if the integer
** cannot hold the whole pointer value
*/
-#define point2uint(p) ((unsigned int)((size_t)(p)&UINT_MAX))
+#define point2uint(p) ((unsigned int)((size_t)(p) & UINT_MAX))
+
+
/* type to ensure maximum alignment */
#if defined(LUAI_USER_ALIGNMENT_T)
typedef LUAI_USER_ALIGNMENT_T L_Umaxalign;
#else
typedef union {
- lua_Number n;
- double u;
- void* s;
- lua_Integer i;
- long l;
+ lua_Number n;
+ double u;
+ void *s;
+ lua_Integer i;
+ long l;
} L_Umaxalign;
#endif
+
+
/* types of 'usual argument conversions' for lua_Number and lua_Integer */
typedef LUAI_UACNUMBER l_uacNumber;
typedef LUAI_UACINT l_uacInt;
+
/* internal assertions for in-house debugging */
#if defined(lua_assert)
-#define check_exp(c, e) (lua_assert(c), (e))
+#define check_exp(c,e) (lua_assert(c), (e))
/* to avoid problems with conditions too long */
-#define lua_longassert(c) ((c) ? (void)0 : lua_assert(0))
+#define lua_longassert(c) ((c) ? (void)0 : lua_assert(0))
#else
-#define lua_assert(c) ((void)0)
-#define check_exp(c, e) (e)
-#define lua_longassert(c) ((void)0)
+#define lua_assert(c) ((void)0)
+#define check_exp(c,e) (e)
+#define lua_longassert(c) ((void)0)
#endif
/*
** assertion for checking API calls
*/
#if !defined(luai_apicheck)
-#define luai_apicheck(l, e) lua_assert(e)
+#define luai_apicheck(l,e) lua_assert(e)
#endif
-#define api_check(l, e, msg) luai_apicheck(l, (e) && msg)
+#define api_check(l,e,msg) luai_apicheck(l,(e) && msg)
+
/* macro to avoid warnings about unused variables */
#if !defined(UNUSED)
-#define UNUSED(x) ((void)(x))
+#define UNUSED(x) ((void)(x))
#endif
+
/* type casts (a macro highlights casts in the code) */
-#define cast(t, exp) ((t)(exp))
-
-#define cast_void(i) cast(void, (i))
-#define cast_byte(i) cast(lu_byte, (i))
-#define cast_num(i) cast(lua_Number, (i))
-#define cast_int(i) cast(int, (i))
-#define cast_uchar(i) cast(unsigned char, (i))
+#define cast(t, exp) ((t)(exp))
+
+#define cast_void(i) cast(void, (i))
+#define cast_byte(i) cast(lu_byte, (i))
+#define cast_num(i) cast(lua_Number, (i))
+#define cast_int(i) cast(int, (i))
+#define cast_uchar(i) cast(unsigned char, (i))
+
/* cast a signed lua_Integer to lua_Unsigned */
#if !defined(l_castS2U)
-#define l_castS2U(i) ((lua_Unsigned)(i))
+#define l_castS2U(i) ((lua_Unsigned)(i))
#endif
/*
@@ -112,28 +128,33 @@
** work fine.
*/
#if !defined(l_castU2S)
-#define l_castU2S(i) ((lua_Integer)(i))
+#define l_castU2S(i) ((lua_Integer)(i))
#endif
+
/*
** non-return type
*/
#if defined(__GNUC__)
-#define l_noret void __attribute__((noreturn))
+#define l_noret void __attribute__((noreturn))
#elif defined(_MSC_VER) && _MSC_VER >= 1200
-#define l_noret void __declspec(noreturn)
+#define l_noret void __declspec(noreturn)
#else
-#define l_noret void
+#define l_noret void
#endif
+
+
/*
** maximum depth for nested C calls and syntactical nested non-terminals
** in a program. (Value must fit in an unsigned short int.)
*/
#if !defined(LUAI_MAXCCALLS)
-#define LUAI_MAXCCALLS 200
+#define LUAI_MAXCCALLS 200
#endif
+
+
/*
** type for virtual-machine instructions;
** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
@@ -144,6 +165,8 @@
typedef unsigned long Instruction;
#endif
+
+
/*
** Maximum length for short strings, that is, strings that are
** internalized. (Cannot be smaller than reserved words or tags for
@@ -151,9 +174,10 @@
** #("function") = 8, #("__newindex") = 10.)
*/
#if !defined(LUAI_MAXSHORTLEN)
-#define LUAI_MAXSHORTLEN 40
+#define LUAI_MAXSHORTLEN 40
#endif
+
/*
** Initial size for the string table (must be power of 2).
** The Lua core alone registers ~50 strings (reserved words +
@@ -161,31 +185,34 @@
** a few dozens more.
*/
#if !defined(MINSTRTABSIZE)
-#define MINSTRTABSIZE 128
+#define MINSTRTABSIZE 128
#endif
+
/*
** Size of cache for strings in the API. 'N' is the number of
** sets (better be a prime) and "M" is the size of each set (M == 1
** makes a direct cache.)
*/
#if !defined(STRCACHE_N)
-#define STRCACHE_N 53
-#define STRCACHE_M 2
+#define STRCACHE_N 53
+#define STRCACHE_M 2
#endif
+
/* minimum size for string buffer */
#if !defined(LUA_MINBUFFER)
-#define LUA_MINBUFFER 32
+#define LUA_MINBUFFER 32
#endif
+
/*
** macros that are executed whenever program enters the Lua core
** ('lua_lock') and leaves the core ('lua_unlock')
*/
#if !defined(lua_lock)
-#define lua_lock(L) ((void)0)
-#define lua_unlock(L) ((void)0)
+#define lua_lock(L) ((void) 0)
+#define lua_unlock(L) ((void) 0)
#endif
/*
@@ -193,54 +220,53 @@
** function can yield.
*/
#if !defined(luai_threadyield)
-#define luai_threadyield(L) \
- { \
- lua_unlock(L); \
- lua_lock(L); \
- }
+#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);}
#endif
+
/*
** these macros allow user-specific actions on threads when you defined
** LUAI_EXTRASPACE and need to do something extra when a thread is
** created/deleted/resumed/yielded.
*/
#if !defined(luai_userstateopen)
-#define luai_userstateopen(L) ((void)L)
+#define luai_userstateopen(L) ((void)L)
#endif
#if !defined(luai_userstateclose)
-#define luai_userstateclose(L) ((void)L)
+#define luai_userstateclose(L) ((void)L)
#endif
#if !defined(luai_userstatethread)
-#define luai_userstatethread(L, L1) ((void)L)
+#define luai_userstatethread(L,L1) ((void)L)
#endif
#if !defined(luai_userstatefree)
-#define luai_userstatefree(L, L1) ((void)L)
+#define luai_userstatefree(L,L1) ((void)L)
#endif
#if !defined(luai_userstateresume)
-#define luai_userstateresume(L, n) ((void)L)
+#define luai_userstateresume(L,n) ((void)L)
#endif
#if !defined(luai_userstateyield)
-#define luai_userstateyield(L, n) ((void)L)
+#define luai_userstateyield(L,n) ((void)L)
#endif
+
+
/*
** The luai_num* macros define the primitive operations over numbers.
*/
/* floor division (defined as 'floor(a/b)') */
#if !defined(luai_numidiv)
-#define luai_numidiv(L, a, b) ((void)L, l_floor(luai_numdiv(L, a, b)))
+#define luai_numidiv(L,a,b) ((void)L, l_floor(luai_numdiv(L,a,b)))
#endif
/* float division */
#if !defined(luai_numdiv)
-#define luai_numdiv(L, a, b) ((a) / (b))
+#define luai_numdiv(L,a,b) ((a)/(b))
#endif
/*
@@ -251,58 +277,47 @@
** negative result, which is equivalent to the test below.
*/
#if !defined(luai_nummod)
-#define luai_nummod(L, a, b, m) \
- { \
- (m) = l_mathop(fmod)(a, b); \
- if ((m) * (b) < 0) \
- (m) += (b); \
- }
+#define luai_nummod(L,a,b,m) \
+ { (m) = l_mathop(fmod)(a,b); if ((m)*(b) < 0) (m) += (b); }
#endif
/* exponentiation */
#if !defined(luai_numpow)
-#define luai_numpow(L, a, b) ((void)L, l_mathop(pow)(a, b))
+#define luai_numpow(L,a,b) ((void)L, l_mathop(pow)(a,b))
#endif
/* the others are quite standard operations */
#if !defined(luai_numadd)
-#define luai_numadd(L, a, b) ((a) + (b))
-#define luai_numsub(L, a, b) ((a) - (b))
-#define luai_nummul(L, a, b) ((a) * (b))
-#define luai_numunm(L, a) (-(a))
-#define luai_numeq(a, b) ((a) == (b))
-#define luai_numlt(a, b) ((a) < (b))
-#define luai_numle(a, b) ((a) <= (b))
-#define luai_numisnan(a) (!luai_numeq((a), (a)))
+#define luai_numadd(L,a,b) ((a)+(b))
+#define luai_numsub(L,a,b) ((a)-(b))
+#define luai_nummul(L,a,b) ((a)*(b))
+#define luai_numunm(L,a) (-(a))
+#define luai_numeq(a,b) ((a)==(b))
+#define luai_numlt(a,b) ((a)<(b))
+#define luai_numle(a,b) ((a)<=(b))
+#define luai_numisnan(a) (!luai_numeq((a), (a)))
#endif
+
+
+
+
/*
** macro to control inclusion of some hard tests on stack reallocation
*/
#if !defined(HARDSTACKTESTS)
-#define condmovestack(L, pre, pos) ((void)0)
+#define condmovestack(L,pre,pos) ((void)0)
#else
/* realloc stack keeping its size */
-#define condmovestack(L, pre, pos) \
- { \
- int sz_ = (L)->stacksize; \
- pre; \
- luaD_reallocstack((L), sz_); \
- pos; \
- }
+#define condmovestack(L,pre,pos) \
+ { int sz_ = (L)->stacksize; pre; luaD_reallocstack((L), sz_); pos; }
#endif
#if !defined(HARDMEMTESTS)
-#define condchangemem(L, pre, pos) ((void)0)
+#define condchangemem(L,pre,pos) ((void)0)
#else
-#define condchangemem(L, pre, pos) \
- { \
- if (G(L)->gcrunning) { \
- pre; \
- luaC_fullgc(L, 0); \
- pos; \
- } \
- }
+#define condchangemem(L,pre,pos) \
+ { if (G(L)->gcrunning) { pre; luaC_fullgc(L, 0); pos; } }
#endif
#endif
=== modified file 'src/third_party/eris/lmathlib.c'
--- src/third_party/eris/lmathlib.c 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/lmathlib.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: lmathlib.c,v 1.117 2015/10/02 15:39:23 roberto Exp $
+** $Id: lmathlib.c,v 1.119 2016/12/22 13:08:50 roberto Exp $
** Standard mathematical library
** See Copyright Notice in lua.h
*/
@@ -184,10 +184,13 @@
else {
lua_Number base = luaL_checknumber(L, 2);
#if !defined(LUA_USE_C89)
- if (base == 2.0) res = l_mathop(log2)(x); else
+ if (base == l_mathop(2.0))
+ res = l_mathop(log2)(x); else
#endif
- if (base == 10.0) res = l_mathop(log10)(x);
- else res = l_mathop(log)(x)/l_mathop(log)(base);
+ if (base == l_mathop(10.0))
+ res = l_mathop(log10)(x);
+ else
+ res = l_mathop(log)(x)/l_mathop(log)(base);
}
lua_pushnumber(L, res);
return 1;
@@ -262,7 +265,7 @@
default: return luaL_error(L, "wrong number of arguments");
}
/* random integer in the interval [low, up] */
- luaL_argcheck(L, low <= up, 1, "interval is empty");
+ luaL_argcheck(L, low <= up, 1, "interval is empty");
luaL_argcheck(L, low >= 0 || up <= LUA_MAXINTEGER + low, 1,
"interval too large");
r *= (double)(up - low) + 1.0;
@@ -281,9 +284,9 @@
static int math_type (lua_State *L) {
if (lua_type(L, 1) == LUA_TNUMBER) {
if (lua_isinteger(L, 1))
- lua_pushliteral(L, "integer");
+ lua_pushliteral(L, "integer");
else
- lua_pushliteral(L, "float");
+ lua_pushliteral(L, "float");
}
else {
luaL_checkany(L, 1);
=== modified file 'src/third_party/eris/lmem.h'
--- src/third_party/eris/lmem.h 2016-08-04 15:49:05 +0000
+++ src/third_party/eris/lmem.h 2018-07-08 12:35:11 +0000
@@ -7,11 +7,13 @@
#ifndef lmem_h
#define lmem_h
+
#include <stddef.h>
#include "llimits.h"
#include "lua.h"
+
/*
** This macro reallocs a vector 'b' from 'on' to 'n' elements, where
** each element has size 'e'. In case of arithmetic overflow of the
@@ -25,39 +27,43 @@
** false due to limited range of data type"; the +1 tricks the compiler,
** avoiding this warning but also this optimization.)
*/
-#define luaM_reallocv(L, b, on, n, e) \
- (((sizeof(n) >= sizeof(size_t) && cast(size_t, (n)) + 1 > MAX_SIZET / (e)) ? luaM_toobig(L) : \
- cast_void(0)), \
- luaM_realloc_(L, (b), (on) * (e), (n) * (e)))
+#define luaM_reallocv(L,b,on,n,e) \
+ (((sizeof(n) >= sizeof(size_t) && cast(size_t, (n)) + 1 > MAX_SIZET/(e)) \
+ ? luaM_toobig(L) : cast_void(0)) , \
+ luaM_realloc_(L, (b), (on)*(e), (n)*(e)))
/*
** Arrays of chars do not need any test
*/
-#define luaM_reallocvchar(L, b, on, n) \
- cast(char*, luaM_realloc_(L, (b), (on) * sizeof(char), (n) * sizeof(char)))
-
-#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0)
-#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0)
-#define luaM_freearray(L, b, n) luaM_realloc_(L, (b), (n) * sizeof(*(b)), 0)
-
-#define luaM_malloc(L, s) luaM_realloc_(L, NULL, 0, (s))
-#define luaM_new(L, t) cast(t*, luaM_malloc(L, sizeof(t)))
-#define luaM_newvector(L, n, t) cast(t*, luaM_reallocv(L, NULL, 0, n, sizeof(t)))
-
-#define luaM_newobject(L, tag, s) luaM_realloc_(L, NULL, tag, (s))
-
-#define luaM_growvector(L, v, nelems, size, t, limit, e) \
- if ((nelems) + 1 > (size)) \
- ((v) = cast(t*, luaM_growaux_(L, v, &(size), sizeof(t), limit, e)))
-
-#define luaM_reallocvector(L, v, oldn, n, t) \
- ((v) = cast(t*, luaM_reallocv(L, v, oldn, n, sizeof(t))))
-
-LUAI_FUNC l_noret luaM_toobig(lua_State* L);
+#define luaM_reallocvchar(L,b,on,n) \
+ cast(char *, luaM_realloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char)))
+
+#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0)
+#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0)
+#define luaM_freearray(L, b, n) luaM_realloc_(L, (b), (n)*sizeof(*(b)), 0)
+
+#define luaM_malloc(L,s) luaM_realloc_(L, NULL, 0, (s))
+#define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t)))
+#define luaM_newvector(L,n,t) \
+ cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t)))
+
+#define luaM_newobject(L,tag,s) luaM_realloc_(L, NULL, tag, (s))
+
+#define luaM_growvector(L,v,nelems,size,t,limit,e) \
+ if ((nelems)+1 > (size)) \
+ ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e)))
+
+#define luaM_reallocvector(L, v,oldn,n,t) \
+ ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
+
+LUAI_FUNC l_noret luaM_toobig (lua_State *L);
/* not to be called directly */
-LUAI_FUNC void* luaM_realloc_(lua_State* L, void* block, size_t oldsize, size_t size);
-LUAI_FUNC void*
-luaM_growaux_(lua_State* L, void* block, int* size, size_t size_elem, int limit, const char* what);
+LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
+ size_t size);
+LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size,
+ size_t size_elem, int limit,
+ const char *what);
#endif
+
=== modified file 'src/third_party/eris/loadlib.c'
--- src/third_party/eris/loadlib.c 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/loadlib.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: loadlib.c,v 1.127 2015/11/23 11:30:45 roberto Exp $
+** $Id: loadlib.c,v 1.130 2017/01/12 17:14:26 roberto Exp $
** Dynamic library loader for Lua
** See Copyright Notice in lua.h
**
@@ -25,40 +25,9 @@
/*
-** LUA_PATH_VAR and LUA_CPATH_VAR are the names of the environment
-** variables that Lua check to set its paths.
-*/
-#if !defined(LUA_PATH_VAR)
-#define LUA_PATH_VAR "LUA_PATH"
-#endif
-
-#if !defined(LUA_CPATH_VAR)
-#define LUA_CPATH_VAR "LUA_CPATH"
-#endif
-
-#define LUA_PATHSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR
-
-#define LUA_PATHVARVERSION LUA_PATH_VAR LUA_PATHSUFFIX
-#define LUA_CPATHVARVERSION LUA_CPATH_VAR LUA_PATHSUFFIX
-
-/*
-** LUA_PATH_SEP is the character that separates templates in a path.
-** LUA_PATH_MARK is the string that marks the substitution points in a
-** template.
-** LUA_EXEC_DIR in a Windows path is replaced by the executable's
-** directory.
** LUA_IGMARK is a mark to ignore all before it when building the
** luaopen_ function name.
*/
-#if !defined (LUA_PATH_SEP)
-#define LUA_PATH_SEP ";"
-#endif
-#if !defined (LUA_PATH_MARK)
-#define LUA_PATH_MARK "?"
-#endif
-#if !defined (LUA_EXEC_DIR)
-#define LUA_EXEC_DIR "!"
-#endif
#if !defined (LUA_IGMARK)
#define LUA_IGMARK "-"
#endif
@@ -94,7 +63,8 @@
#define LIB_FAIL "open"
-#define setprogdir(L) ((void)0)
+
+#define setprogdir(L) ((void)0)
/*
@@ -179,7 +149,6 @@
#include <windows.h>
-#undef setprogdir
/*
** optional flags for LoadLibraryEx
@@ -189,21 +158,30 @@
#endif
+#undef setprogdir
+
+
+/*
+** Replace in the path (on the top of the stack) any occurrence
+** of LUA_EXEC_DIR with the executable's path.
+*/
static void setprogdir (lua_State *L) {
char buff[MAX_PATH + 1];
char *lb;
DWORD nsize = sizeof(buff)/sizeof(char);
- DWORD n = GetModuleFileNameA(NULL, buff, nsize);
+ DWORD n = GetModuleFileNameA(NULL, buff, nsize); /* get exec. name */
if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL)
luaL_error(L, "unable to get ModuleFileName");
else {
- *lb = '\0';
+ *lb = '\0'; /* cut name on the last '\\' to get the path */
luaL_gsub(L, lua_tostring(L, -1), LUA_EXEC_DIR, buff);
lua_remove(L, -2); /* remove original string */
}
}
+
+
static void pusherror (lua_State *L) {
int error = GetLastError();
char buffer[128];
@@ -273,6 +251,67 @@
/*
+** {==================================================================
+** Set Paths
+** ===================================================================
+*/
+
+/*
+** LUA_PATH_VAR and LUA_CPATH_VAR are the names of the environment
+** variables that Lua check to set its paths.
+*/
+#if !defined(LUA_PATH_VAR)
+#define LUA_PATH_VAR "LUA_PATH"
+#endif
+
+#if !defined(LUA_CPATH_VAR)
+#define LUA_CPATH_VAR "LUA_CPATH"
+#endif
+
+
+#define AUXMARK "\1" /* auxiliary mark */
+
+
+/*
+** return registry.LUA_NOENV as a boolean
+*/
+static int noenv (lua_State *L) {
+ int b;
+ lua_getfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
+ b = lua_toboolean(L, -1);
+ lua_pop(L, 1); /* remove value */
+ return b;
+}
+
+
+/*
+** Set a path
+*/
+static void setpath (lua_State *L, const char *fieldname,
+ const char *envname,
+ const char *dft) {
+ const char *nver = lua_pushfstring(L, "%s%s", envname, LUA_VERSUFFIX);
+ const char *path = getenv(nver); /* use versioned name */
+ if (path == NULL) /* no environment variable? */
+ path = getenv(envname); /* try unversioned name */
+ if (path == NULL || noenv(L)) /* no environment variable? */
+ lua_pushstring(L, dft); /* use default */
+ else {
+ /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */
+ path = luaL_gsub(L, path, LUA_PATH_SEP LUA_PATH_SEP,
+ LUA_PATH_SEP AUXMARK LUA_PATH_SEP);
+ luaL_gsub(L, path, AUXMARK, dft);
+ lua_remove(L, -2); /* remove result from 1st 'gsub' */
+ }
+ setprogdir(L);
+ lua_setfield(L, -3, fieldname); /* package[fieldname] = path value */
+ lua_pop(L, 1); /* pop versioned variable name */
+}
+
+/* }================================================================== */
+
+
+/*
** return registry.CLIBS[path]
*/
static void *checkclib (lua_State *L, const char *path) {
@@ -520,7 +559,7 @@
static int searcher_preload (lua_State *L) {
const char *name = luaL_checkstring(L, 1);
- lua_getfield(L, LUA_REGISTRYINDEX, "_PRELOAD");
+ lua_getfield(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE);
if (lua_getfield(L, -1, name) == LUA_TNIL) /* not found? */
lua_pushfstring(L, "\n\tno field package.preload['%s']", name);
return 1;
@@ -557,9 +596,9 @@
static int ll_require (lua_State *L) {
const char *name = luaL_checkstring(L, 1);
- lua_settop(L, 1); /* _LOADED table will be at index 2 */
- lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED");
- lua_getfield(L, 2, name); /* _LOADED[name] */
+ lua_settop(L, 1); /* LOADED table will be at index 2 */
+ lua_getfield(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
+ lua_getfield(L, 2, name); /* LOADED[name] */
if (lua_toboolean(L, -1)) /* is it there? */
return 1; /* package is already loaded */
/* else must load package */
@@ -569,11 +608,11 @@
lua_insert(L, -2); /* name is 1st argument (before search data) */
lua_call(L, 2, 1); /* run loader to load module */
if (!lua_isnil(L, -1)) /* non-nil return? */
- lua_setfield(L, 2, name); /* _LOADED[name] = returned value */
+ lua_setfield(L, 2, name); /* LOADED[name] = returned value */
if (lua_getfield(L, 2, name) == LUA_TNIL) { /* module set no value? */
lua_pushboolean(L, 1); /* use true as result */
lua_pushvalue(L, -1); /* extra copy to be returned */
- lua_setfield(L, 2, name); /* _LOADED[name] = true */
+ lua_setfield(L, 2, name); /* LOADED[name] = true */
}
return 1;
}
@@ -666,41 +705,6 @@
-/* auxiliary mark (for internal use) */
-#define AUXMARK "\1"
-
-
-/*
-** return registry.LUA_NOENV as a boolean
-*/
-static int noenv (lua_State *L) {
- int b;
- lua_getfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
- b = lua_toboolean(L, -1);
- lua_pop(L, 1); /* remove value */
- return b;
-}
-
-
-static void setpath (lua_State *L, const char *fieldname, const char *envname1,
- const char *envname2, const char *def) {
- const char *path = getenv(envname1);
- if (path == NULL) /* no environment variable? */
- path = getenv(envname2); /* try alternative name */
- if (path == NULL || noenv(L)) /* no environment variable? */
- lua_pushstring(L, def); /* use default */
- else {
- /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */
- path = luaL_gsub(L, path, LUA_PATH_SEP LUA_PATH_SEP,
- LUA_PATH_SEP AUXMARK LUA_PATH_SEP);
- luaL_gsub(L, path, AUXMARK, def);
- lua_remove(L, -2);
- }
- setprogdir(L);
- lua_setfield(L, -2, fieldname);
-}
-
-
static const luaL_Reg pk_funcs[] = {
{"loadlib", ll_loadlib},
{"searchpath", ll_searchpath},
@@ -764,19 +768,18 @@
createclibstable(L);
luaL_newlib(L, pk_funcs); /* create 'package' table */
createsearcherstable(L);
- /* set field 'path' */
- setpath(L, "path", LUA_PATHVARVERSION, LUA_PATH_VAR, LUA_PATH_DEFAULT);
- /* set field 'cpath' */
- setpath(L, "cpath", LUA_CPATHVARVERSION, LUA_CPATH_VAR, LUA_CPATH_DEFAULT);
+ /* set paths */
+ setpath(L, "path", LUA_PATH_VAR, LUA_PATH_DEFAULT);
+ setpath(L, "cpath", LUA_CPATH_VAR, LUA_CPATH_DEFAULT);
/* store config information */
lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATH_SEP "\n" LUA_PATH_MARK "\n"
LUA_EXEC_DIR "\n" LUA_IGMARK "\n");
lua_setfield(L, -2, "config");
/* set field 'loaded' */
- luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED");
+ luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
lua_setfield(L, -2, "loaded");
/* set field 'preload' */
- luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
+ luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE);
lua_setfield(L, -2, "preload");
lua_pushglobaltable(L);
lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */
=== modified file 'src/third_party/eris/lobject.c'
--- src/third_party/eris/lobject.c 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/lobject.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: lobject.c,v 2.108 2015/11/02 16:09:30 roberto Exp $
+** $Id: lobject.c,v 2.113 2016/12/22 13:08:50 roberto Exp $
** Some generic functions over Lua objects
** See Copyright Notice in lua.h
*/
@@ -243,20 +243,59 @@
/* }====================================================== */
+/* maximum length of a numeral */
+#if !defined (L_MAXLENNUM)
+#define L_MAXLENNUM 200
+#endif
+
+static const char *l_str2dloc (const char *s, lua_Number *result, int mode) {
+ char *endptr;
+ *result = (mode == 'x') ? lua_strx2number(s, &endptr) /* try to convert */
+ : lua_str2number(s, &endptr);
+ if (endptr == s) return NULL; /* nothing recognized? */
+ while (lisspace(cast_uchar(*endptr))) endptr++; /* skip trailing spaces */
+ return (*endptr == '\0') ? endptr : NULL; /* OK if no trailing characters */
+}
+
+
+/*
+** Convert string 's' to a Lua number (put in 'result'). Return NULL
+** on fail or the address of the ending '\0' on success.
+** 'pmode' points to (and 'mode' contains) special things in the string:
+** - 'x'/'X' means an hexadecimal numeral
+** - 'n'/'N' means 'inf' or 'nan' (which should be rejected)
+** - '.' just optimizes the search for the common case (nothing special)
+** This function accepts both the current locale or a dot as the radix
+** mark. If the convertion fails, it may mean number has a dot but
+** locale accepts something else. In that case, the code copies 's'
+** to a buffer (because 's' is read-only), changes the dot to the
+** current locale radix mark, and tries to convert again.
+*/
static const char *l_str2d (const char *s, lua_Number *result) {
- char *endptr;
- if (strpbrk(s, "nN")) /* reject 'inf' and 'nan' */
+ const char *endptr;
+ const char *pmode = strpbrk(s, ".xXnN");
+ int mode = pmode ? ltolower(cast_uchar(*pmode)) : 0;
+ if (mode == 'n') /* reject 'inf' and 'nan' */
return NULL;
- else if (strpbrk(s, "xX")) /* hex? */
- *result = lua_strx2number(s, &endptr);
- else
- *result = lua_str2number(s, &endptr);
- if (endptr == s) return NULL; /* nothing recognized */
- while (lisspace(cast_uchar(*endptr))) endptr++;
- return (*endptr == '\0' ? endptr : NULL); /* OK if no trailing characters */
+ endptr = l_str2dloc(s, result, mode); /* try to convert */
+ if (endptr == NULL) { /* failed? may be a different locale */
+ char buff[L_MAXLENNUM + 1];
+ const char *pdot = strchr(s, '.');
+ if (strlen(s) > L_MAXLENNUM || pdot == NULL)
+ return NULL; /* string too long or no dot; fail */
+ strcpy(buff, s); /* copy string to buffer */
+ buff[pdot - s] = lua_getlocaledecpoint(); /* correct decimal point */
+ endptr = l_str2dloc(buff, result, mode); /* try again */
+ if (endptr != NULL)
+ endptr = s + (endptr - buff); /* make relative to 's' */
+ }
+ return endptr;
}
+#define MAXBY10 cast(lua_Unsigned, LUA_MAXINTEGER / 10)
+#define MAXLASTD cast_int(LUA_MAXINTEGER % 10)
+
static const char *l_str2int (const char *s, lua_Integer *result) {
lua_Unsigned a = 0;
int empty = 1;
@@ -273,7 +312,10 @@
}
else { /* decimal */
for (; lisdigit(cast_uchar(*s)); s++) {
- a = a * 10 + *s - '0';
+ int d = *s - '0';
+ if (a >= MAXBY10 && (a > MAXBY10 || d > MAXLASTD + neg)) /* overflow? */
+ return NULL; /* do not accept it (as integer) */
+ a = a * 10 + d;
empty = 0;
}
}
@@ -351,8 +393,10 @@
}
-/* this function handles only '%d', '%c', '%f', '%p', and '%s'
- conventional formats, plus Lua-specific '%I' and '%U' */
+/*
+** this function handles only '%d', '%c', '%f', '%p', and '%s'
+ conventional formats, plus Lua-specific '%I' and '%U'
+*/
const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
int n = 0;
for (;;) {
@@ -360,13 +404,13 @@
if (e == NULL) break;
pushstr(L, fmt, e - fmt);
switch (*(e+1)) {
- case 's': {
+ case 's': { /* zero-terminated string */
const char *s = va_arg(argp, char *);
if (s == NULL) s = "(null)";
pushstr(L, s, strlen(s));
break;
}
- case 'c': {
+ case 'c': { /* an 'int' as a character */
char buff = cast(char, va_arg(argp, int));
if (lisprint(cast_uchar(buff)))
pushstr(L, &buff, 1);
@@ -374,28 +418,28 @@
luaO_pushfstring(L, "<\\%d>", cast_uchar(buff));
break;
}
- case 'd': {
+ case 'd': { /* an 'int' */
setivalue(L->top, va_arg(argp, int));
goto top2str;
}
- case 'I': {
+ case 'I': { /* a 'lua_Integer' */
setivalue(L->top, cast(lua_Integer, va_arg(argp, l_uacInt)));
goto top2str;
}
- case 'f': {
+ case 'f': { /* a 'lua_Number' */
setfltvalue(L->top, cast_num(va_arg(argp, l_uacNumber)));
- top2str:
+ top2str: /* convert the top element to a string */
luaD_inctop(L);
luaO_tostring(L, L->top - 1);
break;
}
- case 'p': {
+ case 'p': { /* a pointer */
char buff[4*sizeof(void *) + 8]; /* should be enough space for a '%p' */
int l = l_sprintf(buff, sizeof(buff), "%p", va_arg(argp, void *));
pushstr(L, buff, l);
break;
}
- case 'U': {
+ case 'U': { /* an 'int' as a UTF-8 sequence */
char buff[UTF8BUFFSZ];
int l = luaO_utf8esc(buff, cast(long, va_arg(argp, long)));
pushstr(L, buff + UTF8BUFFSZ - l, l);
=== modified file 'src/third_party/eris/lobject.h'
--- src/third_party/eris/lobject.h 2016-12-10 19:28:54 +0000
+++ src/third_party/eris/lobject.h 2018-07-08 12:35:11 +0000
@@ -1,27 +1,32 @@
/*
-** $Id: lobject.h,v 2.116 2015/11/03 18:33:10 roberto Exp $
+** $Id: lobject.h,v 2.117 2016/08/01 19:51:24 roberto Exp $
** Type definitions for Lua objects
** See Copyright Notice in lua.h
*/
+
#ifndef lobject_h
#define lobject_h
+
#include <stdarg.h>
+
#include "llimits.h"
#include "lua.h"
+
/*
** Extra tags for non-values
*/
-#define LUA_TPROTO LUA_NUMTAGS /* function prototypes */
-#define LUA_TDEADKEY (LUA_NUMTAGS + 1) /* removed keys in tables */
+#define LUA_TPROTO LUA_NUMTAGS /* function prototypes */
+#define LUA_TDEADKEY (LUA_NUMTAGS+1) /* removed keys in tables */
/*
** number of all possible tags (including LUA_TNONE but excluding DEADKEY)
*/
-#define LUA_TOTALTAGS (LUA_TPROTO + 2)
+#define LUA_TOTALTAGS (LUA_TPROTO + 2)
+
/*
** tags for Tagged Values have the following use of bits:
@@ -30,6 +35,7 @@
** bit 6: whether value is collectable
*/
+
/*
** LUA_TFUNCTION variants:
** 0 - Lua function
@@ -38,45 +44,51 @@
*/
/* Variant tags for functions */
-#define LUA_TLCL (LUA_TFUNCTION | (0 << 4)) /* Lua closure */
-#define LUA_TLCF (LUA_TFUNCTION | (1 << 4)) /* light C function */
-#define LUA_TCCL (LUA_TFUNCTION | (2 << 4)) /* C closure */
+#define LUA_TLCL (LUA_TFUNCTION | (0 << 4)) /* Lua closure */
+#define LUA_TLCF (LUA_TFUNCTION | (1 << 4)) /* light C function */
+#define LUA_TCCL (LUA_TFUNCTION | (2 << 4)) /* C closure */
+
/* Variant tags for strings */
-#define LUA_TSHRSTR (LUA_TSTRING | (0 << 4)) /* short strings */
-#define LUA_TLNGSTR (LUA_TSTRING | (1 << 4)) /* long strings */
+#define LUA_TSHRSTR (LUA_TSTRING | (0 << 4)) /* short strings */
+#define LUA_TLNGSTR (LUA_TSTRING | (1 << 4)) /* long strings */
+
/* Variant tags for numbers */
-#define LUA_TNUMFLT (LUA_TNUMBER | (0 << 4)) /* float numbers */
-#define LUA_TNUMINT (LUA_TNUMBER | (1 << 4)) /* integer numbers */
+#define LUA_TNUMFLT (LUA_TNUMBER | (0 << 4)) /* float numbers */
+#define LUA_TNUMINT (LUA_TNUMBER | (1 << 4)) /* integer numbers */
+
/* Bit mark for collectable types */
-#define BIT_ISCOLLECTABLE (1 << 6)
+#define BIT_ISCOLLECTABLE (1 << 6)
/* mark a tag as collectable */
-#define ctb(t) ((t) | BIT_ISCOLLECTABLE)
+#define ctb(t) ((t) | BIT_ISCOLLECTABLE)
+
/*
** Common type for all collectable objects
*/
typedef struct GCObject GCObject;
+
/*
** Common Header for all collectable objects (in macro form, to be
** included in other objects)
*/
-#define CommonHeader \
- GCObject* next; \
- lu_byte tt; \
- lu_byte marked
+#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked
+
/*
** Common type has only the common header
*/
struct GCObject {
- CommonHeader;
+ CommonHeader;
};
+
+
+
/*
** Tagged Values. This is the basic representation of values in Lua,
** an actual value plus a tag with its type.
@@ -86,235 +98,191 @@
** Union of all Lua values
*/
typedef union Value {
- GCObject* gc; /* collectable objects */
- void* p; /* light userdata */
- int b; /* booleans */
- lua_CFunction f; /* light C functions */
- lua_Integer i; /* integer numbers */
- lua_Number n; /* float numbers */
+ GCObject *gc; /* collectable objects */
+ void *p; /* light userdata */
+ int b; /* booleans */
+ lua_CFunction f; /* light C functions */
+ lua_Integer i; /* integer numbers */
+ lua_Number n; /* float numbers */
} Value;
-#define TValuefields \
- Value value_; \
- int tt_
-
-typedef struct lua_TValue { TValuefields; } TValue;
+
+#define TValuefields Value value_; int tt_
+
+
+typedef struct lua_TValue {
+ TValuefields;
+} TValue;
+
+
/* macro defining a nil value */
-#define NILCONSTANT \
- { NULL } \
- , LUA_TNIL
-
-#define val_(o) ((o)->value_)
+#define NILCONSTANT {NULL}, LUA_TNIL
+
+
+#define val_(o) ((o)->value_)
+
/* raw type tag of a TValue */
-#define rttype(o) ((o)->tt_)
+#define rttype(o) ((o)->tt_)
/* tag with no variants (bits 0-3) */
-#define novariant(x) ((x)&0x0F)
+#define novariant(x) ((x) & 0x0F)
/* type tag of a TValue (bits 0-3 for tags + variant bits 4-5) */
-#define ttype(o) (rttype(o) & 0x3F)
+#define ttype(o) (rttype(o) & 0x3F)
/* type tag of a TValue with no variants (bits 0-3) */
-#define ttnov(o) (novariant(rttype(o)))
+#define ttnov(o) (novariant(rttype(o)))
+
/* Macros to test type */
-#define checktag(o, t) (rttype(o) == (t))
-#define checktype(o, t) (ttnov(o) == (t))
-#define ttisnumber(o) checktype((o), LUA_TNUMBER)
-#define ttisfloat(o) checktag((o), LUA_TNUMFLT)
-#define ttisinteger(o) checktag((o), LUA_TNUMINT)
-#define ttisnil(o) checktag((o), LUA_TNIL)
-#define ttisboolean(o) checktag((o), LUA_TBOOLEAN)
-#define ttislightuserdata(o) checktag((o), LUA_TLIGHTUSERDATA)
-#define ttisstring(o) checktype((o), LUA_TSTRING)
-#define ttisshrstring(o) checktag((o), ctb(LUA_TSHRSTR))
-#define ttislngstring(o) checktag((o), ctb(LUA_TLNGSTR))
-#define ttistable(o) checktag((o), ctb(LUA_TTABLE))
-#define ttisfunction(o) checktype(o, LUA_TFUNCTION)
-#define ttisclosure(o) ((rttype(o) & 0x1F) == LUA_TFUNCTION)
-#define ttisCclosure(o) checktag((o), ctb(LUA_TCCL))
-#define ttisLclosure(o) checktag((o), ctb(LUA_TLCL))
-#define ttislcf(o) checktag((o), LUA_TLCF)
-#define ttisfulluserdata(o) checktag((o), ctb(LUA_TUSERDATA))
-#define ttisthread(o) checktag((o), ctb(LUA_TTHREAD))
-#define ttisdeadkey(o) checktag((o), LUA_TDEADKEY)
+#define checktag(o,t) (rttype(o) == (t))
+#define checktype(o,t) (ttnov(o) == (t))
+#define ttisnumber(o) checktype((o), LUA_TNUMBER)
+#define ttisfloat(o) checktag((o), LUA_TNUMFLT)
+#define ttisinteger(o) checktag((o), LUA_TNUMINT)
+#define ttisnil(o) checktag((o), LUA_TNIL)
+#define ttisboolean(o) checktag((o), LUA_TBOOLEAN)
+#define ttislightuserdata(o) checktag((o), LUA_TLIGHTUSERDATA)
+#define ttisstring(o) checktype((o), LUA_TSTRING)
+#define ttisshrstring(o) checktag((o), ctb(LUA_TSHRSTR))
+#define ttislngstring(o) checktag((o), ctb(LUA_TLNGSTR))
+#define ttistable(o) checktag((o), ctb(LUA_TTABLE))
+#define ttisfunction(o) checktype(o, LUA_TFUNCTION)
+#define ttisclosure(o) ((rttype(o) & 0x1F) == LUA_TFUNCTION)
+#define ttisCclosure(o) checktag((o), ctb(LUA_TCCL))
+#define ttisLclosure(o) checktag((o), ctb(LUA_TLCL))
+#define ttislcf(o) checktag((o), LUA_TLCF)
+#define ttisfulluserdata(o) checktag((o), ctb(LUA_TUSERDATA))
+#define ttisthread(o) checktag((o), ctb(LUA_TTHREAD))
+#define ttisdeadkey(o) checktag((o), LUA_TDEADKEY)
+
/* Macros to access values */
-#define ivalue(o) check_exp(ttisinteger(o), val_(o).i)
-#define fltvalue(o) check_exp(ttisfloat(o), val_(o).n)
-#define nvalue(o) check_exp(ttisnumber(o), (ttisinteger(o) ? cast_num(ivalue(o)) : fltvalue(o)))
-#define gcvalue(o) check_exp(iscollectable(o), val_(o).gc)
-#define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p)
-#define tsvalue(o) check_exp(ttisstring(o), gco2ts(val_(o).gc))
-#define uvalue(o) check_exp(ttisfulluserdata(o), gco2u(val_(o).gc))
-#define clvalue(o) check_exp(ttisclosure(o), gco2cl(val_(o).gc))
-#define clLvalue(o) check_exp(ttisLclosure(o), gco2lcl(val_(o).gc))
-#define clCvalue(o) check_exp(ttisCclosure(o), gco2ccl(val_(o).gc))
-#define fvalue(o) check_exp(ttislcf(o), val_(o).f)
-#define hvalue(o) check_exp(ttistable(o), gco2t(val_(o).gc))
-#define bvalue(o) check_exp(ttisboolean(o), val_(o).b)
-#define thvalue(o) check_exp(ttisthread(o), gco2th(val_(o).gc))
+#define ivalue(o) check_exp(ttisinteger(o), val_(o).i)
+#define fltvalue(o) check_exp(ttisfloat(o), val_(o).n)
+#define nvalue(o) check_exp(ttisnumber(o), \
+ (ttisinteger(o) ? cast_num(ivalue(o)) : fltvalue(o)))
+#define gcvalue(o) check_exp(iscollectable(o), val_(o).gc)
+#define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p)
+#define tsvalue(o) check_exp(ttisstring(o), gco2ts(val_(o).gc))
+#define uvalue(o) check_exp(ttisfulluserdata(o), gco2u(val_(o).gc))
+#define clvalue(o) check_exp(ttisclosure(o), gco2cl(val_(o).gc))
+#define clLvalue(o) check_exp(ttisLclosure(o), gco2lcl(val_(o).gc))
+#define clCvalue(o) check_exp(ttisCclosure(o), gco2ccl(val_(o).gc))
+#define fvalue(o) check_exp(ttislcf(o), val_(o).f)
+#define hvalue(o) check_exp(ttistable(o), gco2t(val_(o).gc))
+#define bvalue(o) check_exp(ttisboolean(o), val_(o).b)
+#define thvalue(o) check_exp(ttisthread(o), gco2th(val_(o).gc))
/* a dead value may get the 'gc' field, but cannot access its contents */
-#define deadvalue(o) check_exp(ttisdeadkey(o), cast(void*, val_(o).gc))
-
-#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0))
-
-#define iscollectable(o) (rttype(o) & BIT_ISCOLLECTABLE)
+#define deadvalue(o) check_exp(ttisdeadkey(o), cast(void *, val_(o).gc))
+
+#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0))
+
+
+#define iscollectable(o) (rttype(o) & BIT_ISCOLLECTABLE)
+
/* Macros for internal tests */
-#define righttt(obj) (ttype(obj) == gcvalue(obj)->tt)
-
-#define checkliveness(L, obj) \
- lua_longassert(!iscollectable(obj) || \
- (righttt(obj) && (L == NULL || !isdead(G(L), gcvalue(obj)))))
+#define righttt(obj) (ttype(obj) == gcvalue(obj)->tt)
+
+#define checkliveness(L,obj) \
+ lua_longassert(!iscollectable(obj) || \
+ (righttt(obj) && (L == NULL || !isdead(G(L),gcvalue(obj)))))
+
/* Macros to set values */
-#define settt_(o, t) ((o)->tt_ = (t))
-
-#define setfltvalue(obj, x) \
- { \
- TValue* io = (obj); \
- val_(io).n = (x); \
- settt_(io, LUA_TNUMFLT); \
- }
-
-#define chgfltvalue(obj, x) \
- { \
- TValue* io = (obj); \
- lua_assert(ttisfloat(io)); \
- val_(io).n = (x); \
- }
-
-#define setivalue(obj, x) \
- { \
- TValue* io = (obj); \
- val_(io).i = (x); \
- settt_(io, LUA_TNUMINT); \
- }
-
-#define chgivalue(obj, x) \
- { \
- TValue* io = (obj); \
- lua_assert(ttisinteger(io)); \
- val_(io).i = (x); \
- }
+#define settt_(o,t) ((o)->tt_=(t))
+
+#define setfltvalue(obj,x) \
+ { TValue *io=(obj); val_(io).n=(x); settt_(io, LUA_TNUMFLT); }
+
+#define chgfltvalue(obj,x) \
+ { TValue *io=(obj); lua_assert(ttisfloat(io)); val_(io).n=(x); }
+
+#define setivalue(obj,x) \
+ { TValue *io=(obj); val_(io).i=(x); settt_(io, LUA_TNUMINT); }
+
+#define chgivalue(obj,x) \
+ { TValue *io=(obj); lua_assert(ttisinteger(io)); val_(io).i=(x); }
#define setnilvalue(obj) settt_(obj, LUA_TNIL)
-#define setfvalue(obj, x) \
- { \
- TValue* io = (obj); \
- val_(io).f = (x); \
- settt_(io, LUA_TLCF); \
- }
-
-#define setpvalue(obj, x) \
- { \
- TValue* io = (obj); \
- val_(io).p = (x); \
- settt_(io, LUA_TLIGHTUSERDATA); \
- }
-
-#define setbvalue(obj, x) \
- { \
- TValue* io = (obj); \
- val_(io).b = (x); \
- settt_(io, LUA_TBOOLEAN); \
- }
-
-#define setgcovalue(L, obj, x) \
- { \
- TValue* io = (obj); \
- GCObject* i_g = (x); \
- val_(io).gc = i_g; \
- settt_(io, ctb(i_g->tt)); \
- }
-
-#define setsvalue(L, obj, x) \
- { \
- TValue* io = (obj); \
- TString* x_ = (x); \
- val_(io).gc = obj2gco(x_); \
- settt_(io, ctb(x_->tt)); \
- checkliveness(L, io); \
- }
-
-#define setuvalue(L, obj, x) \
- { \
- TValue* io = (obj); \
- Udata* x_ = (x); \
- val_(io).gc = obj2gco(x_); \
- settt_(io, ctb(LUA_TUSERDATA)); \
- checkliveness(L, io); \
- }
-
-#define setthvalue(L, obj, x) \
- { \
- TValue* io = (obj); \
- lua_State* x_ = (x); \
- val_(io).gc = obj2gco(x_); \
- settt_(io, ctb(LUA_TTHREAD)); \
- checkliveness(L, io); \
- }
-
-#define setclLvalue(L, obj, x) \
- { \
- TValue* io = (obj); \
- LClosure* x_ = (x); \
- val_(io).gc = obj2gco(x_); \
- settt_(io, ctb(LUA_TLCL)); \
- checkliveness(L, io); \
- }
-
-#define setclCvalue(L, obj, x) \
- { \
- TValue* io = (obj); \
- CClosure* x_ = (x); \
- val_(io).gc = obj2gco(x_); \
- settt_(io, ctb(LUA_TCCL)); \
- checkliveness(L, io); \
- }
-
-#define sethvalue(L, obj, x) \
- { \
- TValue* io = (obj); \
- Table* x_ = (x); \
- val_(io).gc = obj2gco(x_); \
- settt_(io, ctb(LUA_TTABLE)); \
- checkliveness(L, io); \
- }
-
-#define setdeadvalue(obj) settt_(obj, LUA_TDEADKEY)
-
-#define setobj(L, obj1, obj2) \
- { \
- TValue* io1 = (obj1); \
- *io1 = *(obj2); \
- (void) L; \
- checkliveness(L, io1); \
- }
+#define setfvalue(obj,x) \
+ { TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_TLCF); }
+
+#define setpvalue(obj,x) \
+ { TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_TLIGHTUSERDATA); }
+
+#define setbvalue(obj,x) \
+ { TValue *io=(obj); val_(io).b=(x); settt_(io, LUA_TBOOLEAN); }
+
+#define setgcovalue(L,obj,x) \
+ { TValue *io = (obj); GCObject *i_g=(x); \
+ val_(io).gc = i_g; settt_(io, ctb(i_g->tt)); }
+
+#define setsvalue(L,obj,x) \
+ { TValue *io = (obj); TString *x_ = (x); \
+ val_(io).gc = obj2gco(x_); settt_(io, ctb(x_->tt)); \
+ checkliveness(L,io); }
+
+#define setuvalue(L,obj,x) \
+ { TValue *io = (obj); Udata *x_ = (x); \
+ val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TUSERDATA)); \
+ checkliveness(L,io); }
+
+#define setthvalue(L,obj,x) \
+ { TValue *io = (obj); lua_State *x_ = (x); \
+ val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TTHREAD)); \
+ checkliveness(L,io); }
+
+#define setclLvalue(L,obj,x) \
+ { TValue *io = (obj); LClosure *x_ = (x); \
+ val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TLCL)); \
+ checkliveness(L,io); }
+
+#define setclCvalue(L,obj,x) \
+ { TValue *io = (obj); CClosure *x_ = (x); \
+ val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TCCL)); \
+ checkliveness(L,io); }
+
+#define sethvalue(L,obj,x) \
+ { TValue *io = (obj); Table *x_ = (x); \
+ val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TTABLE)); \
+ checkliveness(L,io); }
+
+#define setdeadvalue(obj) settt_(obj, LUA_TDEADKEY)
+
+
+
+#define setobj(L,obj1,obj2) \
+ { TValue *io1=(obj1); *io1 = *(obj2); \
+ (void)L; checkliveness(L,io1); }
+
/*
** different types of assignments, according to destination
*/
/* from stack to (same) stack */
-#define setobjs2s setobj
+#define setobjs2s setobj
/* to stack (not from same stack) */
-#define setobj2s setobj
-#define setsvalue2s setsvalue
-#define sethvalue2s sethvalue
-#define setptvalue2s setptvalue
+#define setobj2s setobj
+#define setsvalue2s setsvalue
+#define sethvalue2s sethvalue
+#define setptvalue2s setptvalue
/* from table to same table */
-#define setobjt2t setobj
+#define setobjt2t setobj
/* to new object */
-#define setobj2n setobj
-#define setsvalue2n setsvalue
+#define setobj2n setobj
+#define setsvalue2n setsvalue
/* to table (define it as an expression to be used in macros) */
-#define setobj2t(L, o1, o2) ((void)L, *(o1) = *(o2), checkliveness(L, (o1)))
+#define setobj2t(L,o1,o2) ((void)L, *(o1)=*(o2), checkliveness(L,(o1)))
+
+
+
/*
** {======================================================
@@ -322,239 +290,260 @@
** =======================================================
*/
-typedef TValue* StkId; /* index to stack elements */
+
+typedef TValue *StkId; /* index to stack elements */
+
+
+
/*
** Header for string value; string bytes follow the end of this structure
** (aligned according to 'UTString'; see next).
*/
typedef struct TString {
- CommonHeader;
- lu_byte extra; /* reserved words for short strings; "has hash" for longs */
- lu_byte shrlen; /* length for short strings */
- unsigned int hash;
- union {
- size_t lnglen; /* length for long strings */
- struct TString* hnext; /* linked list for hash table */
- } u;
+ CommonHeader;
+ lu_byte extra; /* reserved words for short strings; "has hash" for longs */
+ lu_byte shrlen; /* length for short strings */
+ unsigned int hash;
+ union {
+ size_t lnglen; /* length for long strings */
+ struct TString *hnext; /* linked list for hash table */
+ } u;
} TString;
+
/*
** Ensures that address after this type is always fully aligned.
*/
typedef union UTString {
- L_Umaxalign dummy; /* ensures maximum alignment for strings */
- TString tsv;
+ L_Umaxalign dummy; /* ensures maximum alignment for strings */
+ TString tsv;
} UTString;
+
/*
** Get the actual string (array of bytes) from a 'TString'.
** (Access to 'extra' ensures that value is really a 'TString'.)
*/
-#define getstr(ts) check_exp(sizeof((ts)->extra), cast(char*, (ts)) + sizeof(UTString))
+#define getstr(ts) \
+ check_exp(sizeof((ts)->extra), cast(char *, (ts)) + sizeof(UTString))
+
/* get the actual string (array of bytes) from a Lua value */
-#define svalue(o) getstr(tsvalue(o))
+#define svalue(o) getstr(tsvalue(o))
/* get string length from 'TString *s' */
-#define tsslen(s) ((s)->tt == LUA_TSHRSTR ? (s)->shrlen : (s)->u.lnglen)
+#define tsslen(s) ((s)->tt == LUA_TSHRSTR ? (s)->shrlen : (s)->u.lnglen)
/* get string length from 'TValue *o' */
-#define vslen(o) tsslen(tsvalue(o))
+#define vslen(o) tsslen(tsvalue(o))
+
/*
** Header for userdata; memory area follows the end of this structure
** (aligned according to 'UUdata'; see next).
*/
typedef struct Udata {
- CommonHeader;
- lu_byte ttuv_; /* user value's tag */
- struct Table* metatable;
- size_t len; /* number of bytes */
- union Value user_; /* user value */
+ CommonHeader;
+ lu_byte ttuv_; /* user value's tag */
+ struct Table *metatable;
+ size_t len; /* number of bytes */
+ union Value user_; /* user value */
} Udata;
+
/*
** Ensures that address after this type is always fully aligned.
*/
typedef union UUdata {
- L_Umaxalign dummy; /* ensures maximum alignment for 'local' udata */
- Udata uv;
+ L_Umaxalign dummy; /* ensures maximum alignment for 'local' udata */
+ Udata uv;
} UUdata;
+
/*
** Get the address of memory block inside 'Udata'.
** (Access to 'ttuv_' ensures that value is really a 'Udata'.)
*/
-#define getudatamem(u) check_exp(sizeof((u)->ttuv_), (cast(char*, (u)) + sizeof(UUdata)))
-
-#define setuservalue(L, u, o) \
- { \
- const TValue* io = (o); \
- Udata* iu = (u); \
- iu->user_ = io->value_; \
- iu->ttuv_ = rttype(io); \
- checkliveness(L, io); \
- }
-
-#define getuservalue(L, u, o) \
- { \
- TValue* io = (o); \
- const Udata* iu = (u); \
- io->value_ = iu->user_; \
- settt_(io, iu->ttuv_); \
- checkliveness(L, io); \
- }
+#define getudatamem(u) \
+ check_exp(sizeof((u)->ttuv_), (cast(char*, (u)) + sizeof(UUdata)))
+
+#define setuservalue(L,u,o) \
+ { const TValue *io=(o); Udata *iu = (u); \
+ iu->user_ = io->value_; iu->ttuv_ = rttype(io); \
+ checkliveness(L,io); }
+
+
+#define getuservalue(L,u,o) \
+ { TValue *io=(o); const Udata *iu = (u); \
+ io->value_ = iu->user_; settt_(io, iu->ttuv_); \
+ checkliveness(L,io); }
+
/*
** Description of an upvalue for function prototypes
*/
typedef struct Upvaldesc {
- TString* name; /* upvalue name (for debug information) */
- lu_byte instack; /* whether it is in stack (register) */
- lu_byte idx; /* index of upvalue (in stack or in outer function's list) */
+ TString *name; /* upvalue name (for debug information) */
+ lu_byte instack; /* whether it is in stack (register) */
+ lu_byte idx; /* index of upvalue (in stack or in outer function's list) */
} Upvaldesc;
+
/*
** Description of a local variable for function prototypes
** (used for debug information)
*/
typedef struct LocVar {
- TString* varname;
- int startpc; /* first point where variable is active */
- int endpc; /* first point where variable is dead */
+ TString *varname;
+ int startpc; /* first point where variable is active */
+ int endpc; /* first point where variable is dead */
} LocVar;
+
/*
** Function Prototypes
*/
typedef struct Proto {
- CommonHeader;
- lu_byte numparams; /* number of fixed parameters */
- lu_byte is_vararg; /* 2: declared vararg; 1: uses vararg */
- lu_byte maxstacksize; /* number of registers needed by this function */
- int sizeupvalues; /* size of 'upvalues' */
- int sizek; /* size of 'k' */
- int sizecode;
- int sizelineinfo;
- int sizep; /* size of 'p' */
- int sizelocvars;
- int linedefined; /* debug information */
- int lastlinedefined; /* debug information */
- TValue* k; /* constants used by the function */
- Instruction* code; /* opcodes */
- struct Proto** p; /* functions defined inside the function */
- int* lineinfo; /* map from opcodes to source lines (debug information) */
- LocVar* locvars; /* information about local variables (debug information) */
- Upvaldesc* upvalues; /* upvalue information */
- struct LClosure* cache; /* last-created closure with this prototype */
- TString* source; /* used for debug information */
- GCObject* gclist;
+ CommonHeader;
+ lu_byte numparams; /* number of fixed parameters */
+ lu_byte is_vararg;
+ lu_byte maxstacksize; /* number of registers needed by this function */
+ int sizeupvalues; /* size of 'upvalues' */
+ int sizek; /* size of 'k' */
+ int sizecode;
+ int sizelineinfo;
+ int sizep; /* size of 'p' */
+ int sizelocvars;
+ int linedefined; /* debug information */
+ int lastlinedefined; /* debug information */
+ TValue *k; /* constants used by the function */
+ Instruction *code; /* opcodes */
+ struct Proto **p; /* functions defined inside the function */
+ int *lineinfo; /* map from opcodes to source lines (debug information) */
+ LocVar *locvars; /* information about local variables (debug information) */
+ Upvaldesc *upvalues; /* upvalue information */
+ struct LClosure *cache; /* last-created closure with this prototype */
+ TString *source; /* used for debug information */
+ GCObject *gclist;
} Proto;
+
+
/*
** Lua Upvalues
*/
typedef struct UpVal UpVal;
+
/*
** Closures
*/
-#define ClosureHeader \
- CommonHeader; \
- lu_byte nupvalues; \
- GCObject* gclist
+#define ClosureHeader \
+ CommonHeader; lu_byte nupvalues; GCObject *gclist
typedef struct CClosure {
- ClosureHeader;
- lua_CFunction f;
- TValue upvalue[1]; /* list of upvalues */
+ ClosureHeader;
+ lua_CFunction f;
+ TValue upvalue[1]; /* list of upvalues */
} CClosure;
+
typedef struct LClosure {
- ClosureHeader;
- struct Proto* p;
- UpVal* upvals[1]; /* list of upvalues */
+ ClosureHeader;
+ struct Proto *p;
+ UpVal *upvals[1]; /* list of upvalues */
} LClosure;
+
typedef union Closure {
- CClosure c;
- LClosure l;
+ CClosure c;
+ LClosure l;
} Closure;
-#define isLfunction(o) ttisLclosure(o)
-
-#define getproto(o) (clLvalue(o)->p)
+
+#define isLfunction(o) ttisLclosure(o)
+
+#define getproto(o) (clLvalue(o)->p)
+
/*
** Tables
*/
typedef union TKey {
- struct {
- TValuefields;
- int next; /* for chaining (offset for next node) */
- } nk;
- TValue tvk;
+ struct {
+ TValuefields;
+ int next; /* for chaining (offset for next node) */
+ } nk;
+ TValue tvk;
} TKey;
+
/* copy a value into a key without messing up field 'next' */
-#define setnodekey(L, key, obj) \
- { \
- TKey* k_ = (key); \
- const TValue* io_ = (obj); \
- k_->nk.value_ = io_->value_; \
- k_->nk.tt_ = io_->tt_; \
- (void) L; \
- checkliveness(L, io_); \
- }
+#define setnodekey(L,key,obj) \
+ { TKey *k_=(key); const TValue *io_=(obj); \
+ k_->nk.value_ = io_->value_; k_->nk.tt_ = io_->tt_; \
+ (void)L; checkliveness(L,io_); }
+
typedef struct Node {
- TValue i_val;
- TKey i_key;
+ TValue i_val;
+ TKey i_key;
} Node;
+
typedef struct Table {
- CommonHeader;
- lu_byte flags; /* 1<<p means tagmethod(p) is not present */
- lu_byte lsizenode; /* log2 of size of 'node' array */
- unsigned int sizearray; /* size of 'array' array */
- TValue* array; /* array part */
- Node* node;
- Node* lastfree; /* any free position is before this position */
- struct Table* metatable;
- GCObject* gclist;
+ CommonHeader;
+ lu_byte flags; /* 1<<p means tagmethod(p) is not present */
+ lu_byte lsizenode; /* log2 of size of 'node' array */
+ unsigned int sizearray; /* size of 'array' array */
+ TValue *array; /* array part */
+ Node *node;
+ Node *lastfree; /* any free position is before this position */
+ struct Table *metatable;
+ GCObject *gclist;
} Table;
+
+
/*
** 'module' operation for hashing (size is always a power of 2)
*/
-#define lmod(s, size) (check_exp((size & (size - 1)) == 0, (cast(int, (s) & ((size)-1)))))
-
-#define twoto(x) (1 << (x))
-#define sizenode(t) (twoto((t)->lsizenode))
+#define lmod(s,size) \
+ (check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1)))))
+
+
+#define twoto(x) (1<<(x))
+#define sizenode(t) (twoto((t)->lsizenode))
+
/*
** (address of) a fixed nil value
*/
-#define luaO_nilobject (&luaO_nilobject_)
+#define luaO_nilobject (&luaO_nilobject_)
+
LUAI_DDEC const TValue luaO_nilobject_;
/* size of buffer for 'luaO_utf8esc' function */
-#define UTF8BUFFSZ 8
-
-LUAI_FUNC int luaO_int2fb(unsigned int x);
-LUAI_FUNC int luaO_fb2int(int x);
-LUAI_FUNC int luaO_utf8esc(char* buff, unsigned long x);
-LUAI_FUNC int luaO_ceillog2(unsigned int x);
-LUAI_FUNC void luaO_arith(lua_State* L, int op, const TValue* p1, const TValue* p2, TValue* res);
-LUAI_FUNC size_t luaO_str2num(const char* s, TValue* o);
-LUAI_FUNC int luaO_hexavalue(int c);
-LUAI_FUNC void luaO_tostring(lua_State* L, StkId obj);
-LUAI_FUNC const char* luaO_pushvfstring(lua_State* L, const char* fmt, va_list argp);
-LUAI_FUNC const char* luaO_pushfstring(lua_State* L, const char* fmt, ...);
-LUAI_FUNC void luaO_chunkid(char* out, const char* source, size_t len);
+#define UTF8BUFFSZ 8
+
+LUAI_FUNC int luaO_int2fb (unsigned int x);
+LUAI_FUNC int luaO_fb2int (int x);
+LUAI_FUNC int luaO_utf8esc (char *buff, unsigned long x);
+LUAI_FUNC int luaO_ceillog2 (unsigned int x);
+LUAI_FUNC void luaO_arith (lua_State *L, int op, const TValue *p1,
+ const TValue *p2, TValue *res);
+LUAI_FUNC size_t luaO_str2num (const char *s, TValue *o);
+LUAI_FUNC int luaO_hexavalue (int c);
+LUAI_FUNC void luaO_tostring (lua_State *L, StkId obj);
+LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt,
+ va_list argp);
+LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...);
+LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len);
+
#endif
+
=== modified file 'src/third_party/eris/lopcodes.h'
--- src/third_party/eris/lopcodes.h 2016-08-04 15:49:05 +0000
+++ src/third_party/eris/lopcodes.h 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: lopcodes.h,v 1.148 2014/10/25 11:50:46 roberto Exp $
+** $Id: lopcodes.h,v 1.149 2016/07/19 17:12:21 roberto Exp $
** Opcodes for Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -9,16 +9,17 @@
#include "llimits.h"
+
/*===========================================================================
We assume that instructions are unsigned numbers.
All instructions have an opcode in the first 6 bits.
Instructions can have the following fields:
- 'A' : 8 bits
- 'B' : 9 bits
- 'C' : 9 bits
- 'Ax' : 26 bits ('A', 'B', and 'C' together)
- 'Bx' : 18 bits ('B' and 'C' together)
- 'sBx' : signed Bx
+ 'A' : 8 bits
+ 'B' : 9 bits
+ 'C' : 9 bits
+ 'Ax' : 26 bits ('A', 'B', and 'C' together)
+ 'Bx' : 18 bits ('B' and 'C' together)
+ 'sBx' : signed Bx
A signed argument is represented in excess K; that is, the number
value is the unsigned value minus K. K is exactly the maximum value
@@ -27,118 +28,130 @@
unsigned argument.
===========================================================================*/
-enum OpMode { iABC, iABx, iAsBx, iAx }; /* basic instruction format */
+
+enum OpMode {iABC, iABx, iAsBx, iAx}; /* basic instruction format */
+
/*
** size and position of opcode arguments.
*/
-#define SIZE_C 9
-#define SIZE_B 9
-#define SIZE_Bx (SIZE_C + SIZE_B)
-#define SIZE_A 8
-#define SIZE_Ax (SIZE_C + SIZE_B + SIZE_A)
-
-#define SIZE_OP 6
-
-#define POS_OP 0
-#define POS_A (POS_OP + SIZE_OP)
-#define POS_C (POS_A + SIZE_A)
-#define POS_B (POS_C + SIZE_C)
-#define POS_Bx POS_C
-#define POS_Ax POS_A
+#define SIZE_C 9
+#define SIZE_B 9
+#define SIZE_Bx (SIZE_C + SIZE_B)
+#define SIZE_A 8
+#define SIZE_Ax (SIZE_C + SIZE_B + SIZE_A)
+
+#define SIZE_OP 6
+
+#define POS_OP 0
+#define POS_A (POS_OP + SIZE_OP)
+#define POS_C (POS_A + SIZE_A)
+#define POS_B (POS_C + SIZE_C)
+#define POS_Bx POS_C
+#define POS_Ax POS_A
+
/*
** limits for opcode arguments.
** we use (signed) int to manipulate most arguments,
** so they must fit in LUAI_BITSINT-1 bits (-1 for sign)
*/
-#if SIZE_Bx < LUAI_BITSINT - 1
-#define MAXARG_Bx ((1 << SIZE_Bx) - 1)
-#define MAXARG_sBx (MAXARG_Bx >> 1) /* 'sBx' is signed */
-#else
-#define MAXARG_Bx MAX_INT
-#define MAXARG_sBx MAX_INT
-#endif
-
-#if SIZE_Ax < LUAI_BITSINT - 1
-#define MAXARG_Ax ((1 << SIZE_Ax) - 1)
-#else
-#define MAXARG_Ax MAX_INT
-#endif
-
-#define MAXARG_A ((1 << SIZE_A) - 1)
-#define MAXARG_B ((1 << SIZE_B) - 1)
-#define MAXARG_C ((1 << SIZE_C) - 1)
+#if SIZE_Bx < LUAI_BITSINT-1
+#define MAXARG_Bx ((1<<SIZE_Bx)-1)
+#define MAXARG_sBx (MAXARG_Bx>>1) /* 'sBx' is signed */
+#else
+#define MAXARG_Bx MAX_INT
+#define MAXARG_sBx MAX_INT
+#endif
+
+#if SIZE_Ax < LUAI_BITSINT-1
+#define MAXARG_Ax ((1<<SIZE_Ax)-1)
+#else
+#define MAXARG_Ax MAX_INT
+#endif
+
+
+#define MAXARG_A ((1<<SIZE_A)-1)
+#define MAXARG_B ((1<<SIZE_B)-1)
+#define MAXARG_C ((1<<SIZE_C)-1)
+
/* creates a mask with 'n' 1 bits at position 'p' */
-#define MASK1(n, p) ((~((~(Instruction)0) << (n))) << (p))
+#define MASK1(n,p) ((~((~(Instruction)0)<<(n)))<<(p))
/* creates a mask with 'n' 0 bits at position 'p' */
-#define MASK0(n, p) (~MASK1(n, p))
+#define MASK0(n,p) (~MASK1(n,p))
/*
** the following macros help to manipulate instructions
*/
-#define GET_OPCODE(i) (cast(OpCode, ((i) >> POS_OP) & MASK1(SIZE_OP, 0)))
-#define SET_OPCODE(i, o) \
- ((i) = (((i)&MASK0(SIZE_OP, POS_OP)) | \
- ((cast(Instruction, o) << POS_OP) & MASK1(SIZE_OP, POS_OP))))
-
-#define getarg(i, pos, size) (cast(int, ((i) >> pos) & MASK1(size, 0)))
-#define setarg(i, v, pos, size) \
- ((i) = (((i)&MASK0(size, pos)) | ((cast(Instruction, v) << pos) & MASK1(size, pos))))
-
-#define GETARG_A(i) getarg(i, POS_A, SIZE_A)
-#define SETARG_A(i, v) setarg(i, v, POS_A, SIZE_A)
-
-#define GETARG_B(i) getarg(i, POS_B, SIZE_B)
-#define SETARG_B(i, v) setarg(i, v, POS_B, SIZE_B)
-
-#define GETARG_C(i) getarg(i, POS_C, SIZE_C)
-#define SETARG_C(i, v) setarg(i, v, POS_C, SIZE_C)
-
-#define GETARG_Bx(i) getarg(i, POS_Bx, SIZE_Bx)
-#define SETARG_Bx(i, v) setarg(i, v, POS_Bx, SIZE_Bx)
-
-#define GETARG_Ax(i) getarg(i, POS_Ax, SIZE_Ax)
-#define SETARG_Ax(i, v) setarg(i, v, POS_Ax, SIZE_Ax)
-
-#define GETARG_sBx(i) (GETARG_Bx(i) - MAXARG_sBx)
-#define SETARG_sBx(i, b) SETARG_Bx((i), cast(unsigned int, (b) + MAXARG_sBx))
-
-#define CREATE_ABC(o, a, b, c) \
- ((cast(Instruction, o) << POS_OP) | (cast(Instruction, a) << POS_A) | \
- (cast(Instruction, b) << POS_B) | (cast(Instruction, c) << POS_C))
-
-#define CREATE_ABx(o, a, bc) \
- ((cast(Instruction, o) << POS_OP) | (cast(Instruction, a) << POS_A) | \
- (cast(Instruction, bc) << POS_Bx))
-
-#define CREATE_Ax(o, a) ((cast(Instruction, o) << POS_OP) | (cast(Instruction, a) << POS_Ax))
+#define GET_OPCODE(i) (cast(OpCode, ((i)>>POS_OP) & MASK1(SIZE_OP,0)))
+#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \
+ ((cast(Instruction, o)<<POS_OP)&MASK1(SIZE_OP,POS_OP))))
+
+#define getarg(i,pos,size) (cast(int, ((i)>>pos) & MASK1(size,0)))
+#define setarg(i,v,pos,size) ((i) = (((i)&MASK0(size,pos)) | \
+ ((cast(Instruction, v)<<pos)&MASK1(size,pos))))
+
+#define GETARG_A(i) getarg(i, POS_A, SIZE_A)
+#define SETARG_A(i,v) setarg(i, v, POS_A, SIZE_A)
+
+#define GETARG_B(i) getarg(i, POS_B, SIZE_B)
+#define SETARG_B(i,v) setarg(i, v, POS_B, SIZE_B)
+
+#define GETARG_C(i) getarg(i, POS_C, SIZE_C)
+#define SETARG_C(i,v) setarg(i, v, POS_C, SIZE_C)
+
+#define GETARG_Bx(i) getarg(i, POS_Bx, SIZE_Bx)
+#define SETARG_Bx(i,v) setarg(i, v, POS_Bx, SIZE_Bx)
+
+#define GETARG_Ax(i) getarg(i, POS_Ax, SIZE_Ax)
+#define SETARG_Ax(i,v) setarg(i, v, POS_Ax, SIZE_Ax)
+
+#define GETARG_sBx(i) (GETARG_Bx(i)-MAXARG_sBx)
+#define SETARG_sBx(i,b) SETARG_Bx((i),cast(unsigned int, (b)+MAXARG_sBx))
+
+
+#define CREATE_ABC(o,a,b,c) ((cast(Instruction, o)<<POS_OP) \
+ | (cast(Instruction, a)<<POS_A) \
+ | (cast(Instruction, b)<<POS_B) \
+ | (cast(Instruction, c)<<POS_C))
+
+#define CREATE_ABx(o,a,bc) ((cast(Instruction, o)<<POS_OP) \
+ | (cast(Instruction, a)<<POS_A) \
+ | (cast(Instruction, bc)<<POS_Bx))
+
+#define CREATE_Ax(o,a) ((cast(Instruction, o)<<POS_OP) \
+ | (cast(Instruction, a)<<POS_Ax))
+
/*
** Macros to operate RK indices
*/
/* this bit 1 means constant (0 means register) */
-#define BITRK (1 << (SIZE_B - 1))
+#define BITRK (1 << (SIZE_B - 1))
/* test whether value is a constant */
-#define ISK(x) ((x)&BITRK)
+#define ISK(x) ((x) & BITRK)
/* gets the index of the constant */
-#define INDEXK(r) ((int)(r) & ~BITRK)
+#define INDEXK(r) ((int)(r) & ~BITRK)
-#define MAXINDEXRK (BITRK - 1)
+#if !defined(MAXINDEXRK) /* (for debugging only) */
+#define MAXINDEXRK (BITRK - 1)
+#endif
/* code a constant index as a RK value */
-#define RKASK(x) ((x) | BITRK)
+#define RKASK(x) ((x) | BITRK)
+
/*
** invalid register that fits in 8 bits
*/
-#define NO_REG MAXARG_A
+#define NO_REG MAXARG_A
+
/*
** R(x) - register
@@ -146,80 +159,84 @@
** RK(x) == if ISK(x) then Kst(INDEXK(x)) else R(x)
*/
+
/*
** grep "ORDER OP" if you change these enums
*/
typedef enum {
- /*----------------------------------------------------------------------
- name args description
- ------------------------------------------------------------------------*/
- OP_MOVE, /* A B R(A) := R(B) */
- OP_LOADK, /* A Bx R(A) := Kst(Bx) */
- OP_LOADKX, /* A R(A) := Kst(extra arg) */
- OP_LOADBOOL, /* A B C R(A) := (Bool)B; if (C) pc++ */
- OP_LOADNIL, /* A B R(A), R(A+1), ..., R(A+B) := nil */
- OP_GETUPVAL, /* A B R(A) := UpValue[B] */
-
- OP_GETTABUP, /* A B C R(A) := UpValue[B][RK(C)] */
- OP_GETTABLE, /* A B C R(A) := R(B)[RK(C)] */
-
- OP_SETTABUP, /* A B C UpValue[A][RK(B)] := RK(C) */
- OP_SETUPVAL, /* A B UpValue[B] := R(A) */
- OP_SETTABLE, /* A B C R(A)[RK(B)] := RK(C) */
-
- OP_NEWTABLE, /* A B C R(A) := {} (size = B,C) */
-
- OP_SELF, /* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)] */
-
- OP_ADD, /* A B C R(A) := RK(B) + RK(C) */
- OP_SUB, /* A B C R(A) := RK(B) - RK(C) */
- OP_MUL, /* A B C R(A) := RK(B) * RK(C) */
- OP_MOD, /* A B C R(A) := RK(B) % RK(C) */
- OP_POW, /* A B C R(A) := RK(B) ^ RK(C) */
- OP_DIV, /* A B C R(A) := RK(B) / RK(C) */
- OP_IDIV, /* A B C R(A) := RK(B) // RK(C) */
- OP_BAND, /* A B C R(A) := RK(B) & RK(C) */
- OP_BOR, /* A B C R(A) := RK(B) | RK(C) */
- OP_BXOR, /* A B C R(A) := RK(B) ~ RK(C) */
- OP_SHL, /* A B C R(A) := RK(B) << RK(C) */
- OP_SHR, /* A B C R(A) := RK(B) >> RK(C) */
- OP_UNM, /* A B R(A) := -R(B) */
- OP_BNOT, /* A B R(A) := ~R(B) */
- OP_NOT, /* A B R(A) := not R(B) */
- OP_LEN, /* A B R(A) := length of R(B) */
-
- OP_CONCAT, /* A B C R(A) := R(B).. ... ..R(C) */
-
- OP_JMP, /* A sBx pc+=sBx; if (A) close all upvalues >= R(A - 1) */
- OP_EQ, /* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */
- OP_LT, /* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */
- OP_LE, /* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */
-
- OP_TEST, /* A C if not (R(A) <=> C) then pc++ */
- OP_TESTSET, /* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */
-
- OP_CALL, /* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
- OP_TAILCALL, /* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */
- OP_RETURN, /* A B return R(A), ... ,R(A+B-2) (see note) */
-
- OP_FORLOOP, /* A sBx R(A)+=R(A+2);
- if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/
- OP_FORPREP, /* A sBx R(A)-=R(A+2); pc+=sBx */
-
- OP_TFORCALL, /* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2)); */
- OP_TFORLOOP, /* A sBx if R(A+1) ~= nil then { R(A)=R(A+1); pc += sBx }*/
-
- OP_SETLIST, /* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */
-
- OP_CLOSURE, /* A Bx R(A) := closure(KPROTO[Bx]) */
-
- OP_VARARG, /* A B R(A), R(A+1), ..., R(A+B-2) = vararg */
-
- OP_EXTRAARG /* Ax extra (larger) argument for previous opcode */
+/*----------------------------------------------------------------------
+name args description
+------------------------------------------------------------------------*/
+OP_MOVE,/* A B R(A) := R(B) */
+OP_LOADK,/* A Bx R(A) := Kst(Bx) */
+OP_LOADKX,/* A R(A) := Kst(extra arg) */
+OP_LOADBOOL,/* A B C R(A) := (Bool)B; if (C) pc++ */
+OP_LOADNIL,/* A B R(A), R(A+1), ..., R(A+B) := nil */
+OP_GETUPVAL,/* A B R(A) := UpValue[B] */
+
+OP_GETTABUP,/* A B C R(A) := UpValue[B][RK(C)] */
+OP_GETTABLE,/* A B C R(A) := R(B)[RK(C)] */
+
+OP_SETTABUP,/* A B C UpValue[A][RK(B)] := RK(C) */
+OP_SETUPVAL,/* A B UpValue[B] := R(A) */
+OP_SETTABLE,/* A B C R(A)[RK(B)] := RK(C) */
+
+OP_NEWTABLE,/* A B C R(A) := {} (size = B,C) */
+
+OP_SELF,/* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)] */
+
+OP_ADD,/* A B C R(A) := RK(B) + RK(C) */
+OP_SUB,/* A B C R(A) := RK(B) - RK(C) */
+OP_MUL,/* A B C R(A) := RK(B) * RK(C) */
+OP_MOD,/* A B C R(A) := RK(B) % RK(C) */
+OP_POW,/* A B C R(A) := RK(B) ^ RK(C) */
+OP_DIV,/* A B C R(A) := RK(B) / RK(C) */
+OP_IDIV,/* A B C R(A) := RK(B) // RK(C) */
+OP_BAND,/* A B C R(A) := RK(B) & RK(C) */
+OP_BOR,/* A B C R(A) := RK(B) | RK(C) */
+OP_BXOR,/* A B C R(A) := RK(B) ~ RK(C) */
+OP_SHL,/* A B C R(A) := RK(B) << RK(C) */
+OP_SHR,/* A B C R(A) := RK(B) >> RK(C) */
+OP_UNM,/* A B R(A) := -R(B) */
+OP_BNOT,/* A B R(A) := ~R(B) */
+OP_NOT,/* A B R(A) := not R(B) */
+OP_LEN,/* A B R(A) := length of R(B) */
+
+OP_CONCAT,/* A B C R(A) := R(B).. ... ..R(C) */
+
+OP_JMP,/* A sBx pc+=sBx; if (A) close all upvalues >= R(A - 1) */
+OP_EQ,/* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */
+OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */
+OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */
+
+OP_TEST,/* A C if not (R(A) <=> C) then pc++ */
+OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */
+
+OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
+OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */
+OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */
+
+OP_FORLOOP,/* A sBx R(A)+=R(A+2);
+ if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/
+OP_FORPREP,/* A sBx R(A)-=R(A+2); pc+=sBx */
+
+OP_TFORCALL,/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2)); */
+OP_TFORLOOP,/* A sBx if R(A+1) ~= nil then { R(A)=R(A+1); pc += sBx }*/
+
+OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */
+
+OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx]) */
+
+OP_VARARG,/* A B R(A), R(A+1), ..., R(A+B-2) = vararg */
+
+OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */
} OpCode;
-#define NUM_OPCODES (cast(int, OP_EXTRAARG) + 1)
+
+#define NUM_OPCODES (cast(int, OP_EXTRAARG) + 1)
+
+
/*===========================================================================
Notes:
@@ -244,6 +261,7 @@
===========================================================================*/
+
/*
** masks for instruction properties. The format is:
** bits 0-1: op mode
@@ -254,23 +272,26 @@
*/
enum OpArgMask {
- OpArgN, /* argument is not used */
- OpArgU, /* argument is used */
- OpArgR, /* argument is a register or a jump offset */
- OpArgK /* argument is a constant or register/constant */
+ OpArgN, /* argument is not used */
+ OpArgU, /* argument is used */
+ OpArgR, /* argument is a register or a jump offset */
+ OpArgK /* argument is a constant or register/constant */
};
LUAI_DDEC const lu_byte luaP_opmodes[NUM_OPCODES];
-#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3))
-#define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3))
-#define getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3))
-#define testAMode(m) (luaP_opmodes[m] & (1 << 6))
-#define testTMode(m) (luaP_opmodes[m] & (1 << 7))
-
-LUAI_DDEC const char* const luaP_opnames[NUM_OPCODES + 1]; /* opcode names */
+#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3))
+#define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3))
+#define getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3))
+#define testAMode(m) (luaP_opmodes[m] & (1 << 6))
+#define testTMode(m) (luaP_opmodes[m] & (1 << 7))
+
+
+LUAI_DDEC const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */
+
/* number of list items to accumulate before a SETLIST instruction */
-#define LFIELDS_PER_FLUSH 50
+#define LFIELDS_PER_FLUSH 50
+
#endif
=== modified file 'src/third_party/eris/loslib.c'
--- src/third_party/eris/loslib.c 2017-11-09 17:37:13 +0000
+++ src/third_party/eris/loslib.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: loslib.c,v 1.60 2015/11/19 19:16:22 roberto Exp $
+** $Id: loslib.c,v 1.65 2016/07/18 17:58:58 roberto Exp $
** Standard Operating System library
** See Copyright Notice in lua.h
*/
@@ -24,18 +24,29 @@
/*
** {==================================================================
-** list of valid conversion specifiers for the 'strftime' function
+** List of valid conversion specifiers for the 'strftime' function;
+** options are grouped by length; group of length 2 start with '||'.
** ===================================================================
*/
#if !defined(LUA_STRFTIMEOPTIONS) /* { */
-#if defined(LUA_USE_C89)
-#define LUA_STRFTIMEOPTIONS { "aAbBcdHIjmMpSUwWxXyYz%", "" }
+/* options for ANSI C 89 (only 1-char options) */
+#define L_STRFTIMEC89 "aAbBcdHIjmMpSUwWxXyYZ%"
+
+/* options for ISO C 99 and POSIX */
+#define L_STRFTIMEC99 "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%" \
+ "||" "EcECExEXEyEY" "OdOeOHOIOmOMOSOuOUOVOwOWOy" /* two-char options */
+
+/* options for Windows */
+#define L_STRFTIMEWIN "aAbBcdHIjmMpSUwWxXyYzZ%" \
+ "||" "#c#x#d#H#I#j#m#M#S#U#w#W#y#Y" /* two-char options */
+
+#if defined(LUA_USE_WINDOWS)
+#define LUA_STRFTIMEOPTIONS L_STRFTIMEWIN
+#elif defined(LUA_USE_C89)
+#define LUA_STRFTIMEOPTIONS L_STRFTIMEC89
#else /* C99 specification */
-#define LUA_STRFTIMEOPTIONS \
- { "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%", "", \
- "E", "cCxXyY", \
- "O", "deHImMSuUVwWy" }
+#define LUA_STRFTIMEOPTIONS L_STRFTIMEC99
#endif
#endif /* } */
@@ -195,6 +206,23 @@
lua_setfield(L, -2, key);
}
+
+/*
+** Set all fields from structure 'tm' in the table on top of the stack
+*/
+static void setallfields (lua_State *L, struct tm *stm) {
+ setfield(L, "sec", stm->tm_sec);
+ setfield(L, "min", stm->tm_min);
+ setfield(L, "hour", stm->tm_hour);
+ setfield(L, "day", stm->tm_mday);
+ setfield(L, "month", stm->tm_mon + 1);
+ setfield(L, "year", stm->tm_year + 1900);
+ setfield(L, "wday", stm->tm_wday + 1);
+ setfield(L, "yday", stm->tm_yday + 1);
+ setboolfield(L, "isdst", stm->tm_isdst);
+}
+
+
static int getboolfield (lua_State *L, const char *key) {
int res;
res = (lua_getfield(L, -1, key) == LUA_TNIL) ? -1 : lua_toboolean(L, -1);
@@ -210,18 +238,18 @@
static int getfield (lua_State *L, const char *key, int d, int delta) {
int isnum;
- int t = lua_getfield(L, -1, key);
+ int t = lua_getfield(L, -1, key); /* get field and its type */
lua_Integer res = lua_tointegerx(L, -1, &isnum);
- if (!isnum) { /* field is not a number? */
+ if (!isnum) { /* field is not an integer? */
if (t != LUA_TNIL) /* some other value? */
- return luaL_error(L, "field '%s' not an integer", key);
+ return luaL_error(L, "field '%s' is not an integer", key);
else if (d < 0) /* absent field; no default? */
return luaL_error(L, "field '%s' missing in date table", key);
res = d;
}
else {
if (!(-L_MAXDATEFIELD <= res && res <= L_MAXDATEFIELD))
- return luaL_error(L, "field '%s' out-of-bounds", key);
+ return luaL_error(L, "field '%s' is out-of-bound", key);
res -= delta;
}
lua_pop(L, 1);
@@ -229,22 +257,17 @@
}
-static const char *checkoption (lua_State *L, const char *conv, char *buff) {
- static const char *const options[] = LUA_STRFTIMEOPTIONS;
- unsigned int i;
- for (i = 0; i < sizeof(options)/sizeof(options[0]); i += 2) {
- if (*conv != '\0' && strchr(options[i], *conv) != NULL) {
- buff[1] = *conv;
- if (*options[i + 1] == '\0') { /* one-char conversion specifier? */
- buff[2] = '\0'; /* end buffer */
- return conv + 1;
- }
- else if (*(conv + 1) != '\0' &&
- strchr(options[i + 1], *(conv + 1)) != NULL) {
- buff[2] = *(conv + 1); /* valid two-char conversion specifier */
- buff[3] = '\0'; /* end buffer */
- return conv + 2;
- }
+static const char *checkoption (lua_State *L, const char *conv,
+ ptrdiff_t convlen, char *buff) {
+ const char *option = LUA_STRFTIMEOPTIONS;
+ int oplen = 1; /* length of options being checked */
+ for (; *option != '\0' && oplen <= convlen; option += oplen) {
+ if (*option == '|') /* next block? */
+ oplen++; /* will check options with next length (+1) */
+ else if (memcmp(conv, option, oplen) == 0) { /* match? */
+ memcpy(buff, conv, oplen); /* copy valid option to buffer */
+ buff[oplen] = '\0';
+ return conv + oplen; /* return next item */
}
}
luaL_argerror(L, 1,
@@ -258,8 +281,10 @@
static int os_date (lua_State *L) {
- const char *s = luaL_optstring(L, 1, "%c");
+ size_t slen;
+ const char *s = luaL_optlstring(L, 1, "%c", &slen);
time_t t = luaL_opt(L, l_checktime, 2, time(NULL));
+ const char *se = s + slen; /* 's' end */
struct tm tmr, *stm;
if (*s == '!') { /* UTC? */
stm = l_gmtime(&t, &tmr);
@@ -271,28 +296,21 @@
luaL_error(L, "time result cannot be represented in this installation");
if (strcmp(s, "*t") == 0) {
lua_createtable(L, 0, 9); /* 9 = number of fields */
- setfield(L, "sec", stm->tm_sec); // NOLINT
- setfield(L, "min", stm->tm_min);
- setfield(L, "hour", stm->tm_hour);
- setfield(L, "day", stm->tm_mday);
- setfield(L, "month", stm->tm_mon+1);
- setfield(L, "year", stm->tm_year+1900);
- setfield(L, "wday", stm->tm_wday+1);
- setfield(L, "yday", stm->tm_yday+1);
- setboolfield(L, "isdst", stm->tm_isdst);
+ setallfields(L, stm);
}
else {
- char cc[4];
+ char cc[4]; /* buffer for individual conversion specifiers */
luaL_Buffer b;
cc[0] = '%';
luaL_buffinit(L, &b);
- while (*s) {
+ while (s < se) {
if (*s != '%') /* not a conversion specifier? */
luaL_addchar(&b, *s++);
else {
size_t reslen;
char *buff = luaL_prepbuffsize(&b, SIZETIMEFMT);
- s = checkoption(L, s + 1, cc);
+ s++; /* skip '%' */
+ s = checkoption(L, s, se - s, cc + 1); /* copy specifier to 'cc' */
reslen = strftime(buff, SIZETIMEFMT, cc, stm);
luaL_addsize(&b, reslen);
}
@@ -319,6 +337,7 @@
ts.tm_year = getfield(L, "year", -1, 1900);
ts.tm_isdst = getboolfield(L, "isdst");
t = mktime(&ts);
+ setallfields(L, &ts); /* update fields with normalized values */
}
if (t != (time_t)(l_timet)t || t == (time_t)(-1))
luaL_error(L, "time result cannot be represented in this installation");
=== modified file 'src/third_party/eris/lparser.c'
--- src/third_party/eris/lparser.c 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/lparser.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: lparser.c,v 2.149 2015/11/02 16:09:30 roberto Exp $
+** $Id: lparser.c,v 2.155 2016/08/01 19:51:24 roberto Exp $
** Lua Parser
** See Copyright Notice in lua.h
*/
@@ -164,7 +164,8 @@
int oldsize = f->sizelocvars;
luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars,
LocVar, SHRT_MAX, "local variables");
- while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = NULL;
+ while (oldsize < f->sizelocvars)
+ f->locvars[oldsize++].varname = NULL;
f->locvars[fs->nlocvars].varname = varname;
luaC_objbarrier(ls->L, f, varname);
return fs->nlocvars++;
@@ -230,7 +231,8 @@
checklimit(fs, fs->nups + 1, MAXUPVAL, "upvalues");
luaM_growvector(fs->ls->L, f->upvalues, fs->nups, f->sizeupvalues,
Upvaldesc, MAXUPVAL, "upvalues");
- while (oldsize < f->sizeupvalues) f->upvalues[oldsize++].name = NULL;
+ while (oldsize < f->sizeupvalues)
+ f->upvalues[oldsize++].name = NULL;
f->upvalues[fs->nups].instack = (v->k == VLOCAL);
f->upvalues[fs->nups].idx = cast_byte(v->u.info);
f->upvalues[fs->nups].name = name;
@@ -255,7 +257,8 @@
*/
static void markupval (FuncState *fs, int level) {
BlockCnt *bl = fs->bl;
- while (bl->nactvar > level) bl = bl->previous;
+ while (bl->nactvar > level)
+ bl = bl->previous;
bl->upval = 1;
}
@@ -264,27 +267,26 @@
Find variable with given name 'n'. If it is an upvalue, add this
upvalue into all intermediate functions.
*/
-static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) {
+static void singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) {
if (fs == NULL) /* no more levels? */
- return VVOID; /* default is global */
+ init_exp(var, VVOID, 0); /* default is global */
else {
int v = searchvar(fs, n); /* look up locals at current level */
if (v >= 0) { /* found? */
init_exp(var, VLOCAL, v); /* variable is local */
if (!base)
markupval(fs, v); /* local will be used as an upval */
- return VLOCAL;
}
else { /* not found as local at current level; try upvalues */
int idx = searchupvalue(fs, n); /* try existing upvalues */
if (idx < 0) { /* not found? */
- if (singlevaraux(fs->prev, n, var, 0) == VVOID) /* try upper levels */
- return VVOID; /* not found; is a global */
+ singlevaraux(fs->prev, n, var, 0); /* try upper levels */
+ if (var->k == VVOID) /* not found? */
+ return; /* it is a global */
/* else was LOCAL or UPVAL */
idx = newupvalue(fs, n, var); /* will be a new upvalue */
}
- init_exp(var, VUPVAL, idx);
- return VUPVAL;
+ init_exp(var, VUPVAL, idx); /* new or old upvalue */
}
}
}
@@ -293,10 +295,11 @@
static void singlevar (LexState *ls, expdesc *var) {
TString *varname = str_checkname(ls);
FuncState *fs = ls->fs;
- if (singlevaraux(fs, varname, var, 1) == VVOID) { /* global name? */
+ singlevaraux(fs, varname, var, 1);
+ if (var->k == VVOID) { /* global name? */
expdesc key;
singlevaraux(fs, ls->envn, var, 1); /* get environment variable */
- lua_assert(var->k == VLOCAL || var->k == VUPVAL);
+ lua_assert(var->k != VVOID); /* this one must exist */
codestring(ls, &key, varname); /* key is variable name */
luaK_indexed(fs, var, &key); /* env[varname] */
}
@@ -320,6 +323,8 @@
luaK_nil(fs, reg, extra);
}
}
+ if (nexps > nvars)
+ ls->fs->freereg -= nexps - nvars; /* remove extra values */
}
@@ -499,7 +504,8 @@
if (fs->np >= f->sizep) {
int oldsize = f->sizep;
luaM_growvector(L, f->p, fs->np, f->sizep, Proto *, MAXARG_Bx, "functions");
- while (oldsize < f->sizep) f->p[oldsize++] = NULL;
+ while (oldsize < f->sizep)
+ f->p[oldsize++] = NULL;
}
f->p[fs->np++] = clp = luaF_newproto(L);
luaC_objbarrier(L, f, clp);
@@ -760,7 +766,7 @@
}
case TK_DOTS: { /* param -> '...' */
luaX_next(ls);
- f->is_vararg = 2; /* declared vararg */
+ f->is_vararg = 1; /* declared vararg */
break;
}
default: luaX_syntaxerror(ls, "<name> or '...' expected");
@@ -956,7 +962,6 @@
FuncState *fs = ls->fs;
check_condition(ls, fs->f->is_vararg,
"cannot use '...' outside a vararg function");
- fs->f->is_vararg = 1; /* function actually uses vararg */
init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0));
break;
}
@@ -1156,11 +1161,8 @@
int nexps;
checknext(ls, '=');
nexps = explist(ls, &e);
- if (nexps != nvars) {
+ if (nexps != nvars)
adjust_assign(ls, nvars, nexps, &e);
- if (nexps > nvars)
- ls->fs->freereg -= nexps - nvars; /* remove extra values */
- }
else {
luaK_setoneret(ls->fs, &e); /* close last expression */
luaK_storevar(ls->fs, &lh->v, &e);
@@ -1226,7 +1228,7 @@
checkrepeated(fs, ll, label); /* check for repeated labels */
checknext(ls, TK_DBCOLON); /* skip double colon */
/* create new entry for this label */
- l = newlabelentry(ls, ll, label, line, fs->pc);
+ l = newlabelentry(ls, ll, label, line, luaK_getlabel(fs));
skipnoopstat(ls); /* skip other no-op statements */
if (block_follow(ls, 0)) { /* label is last no-op statement in the block? */
/* assume that locals are already out of scope */
@@ -1494,7 +1496,7 @@
}
else { /* stat -> func */
check_condition(ls, v.v.k == VCALL, "syntax error");
- SETARG_C(getcode(fs, &v.v), 1); /* call statement uses no results */
+ SETARG_C(getinstruction(fs, &v.v), 1); /* call statement uses no results */
}
}
@@ -1511,8 +1513,8 @@
if (hasmultret(e.k)) {
luaK_setmultret(fs, &e);
if (e.k == VCALL && nret == 1) { /* tail call? */
- SET_OPCODE(getcode(fs,&e), OP_TAILCALL);
- lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar);
+ SET_OPCODE(getinstruction(fs,&e), OP_TAILCALL);
+ lua_assert(GETARG_A(getinstruction(fs,&e)) == fs->nactvar);
}
first = fs->nactvar;
nret = LUA_MULTRET; /* return all values */
@@ -1611,7 +1613,7 @@
BlockCnt bl;
expdesc v;
open_func(ls, fs, &bl);
- fs->f->is_vararg = 2; /* main function is always declared vararg */
+ fs->f->is_vararg = 1; /* main function is always declared vararg */
init_exp(&v, VLOCAL, 0); /* create and... */
newupvalue(fs, ls->envn, &v); /* ...set environment upvalue */
luaX_next(ls); /* read first token */
=== modified file 'src/third_party/eris/lparser.h'
--- src/third_party/eris/lparser.h 2016-12-10 19:28:54 +0000
+++ src/third_party/eris/lparser.h 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: lparser.h,v 1.74 2014/10/25 11:50:46 roberto Exp $
+** $Id: lparser.h,v 1.76 2015/12/30 18:16:13 roberto Exp $
** Lua Parser
** See Copyright Notice in lua.h
*/
@@ -11,98 +11,123 @@
#include "lobject.h"
#include "lzio.h"
+
/*
-** Expression descriptor
+** Expression and variable descriptor.
+** Code generation for variables and expressions can be delayed to allow
+** optimizations; An 'expdesc' structure describes a potentially-delayed
+** variable/expression. It has a description of its "main" value plus a
+** list of conditional jumps that can also produce its value (generated
+** by short-circuit operators 'and'/'or').
*/
+/* kinds of variables/expressions */
typedef enum {
- VVOID, /* no value */
- VNIL,
- VTRUE,
- VFALSE,
- VK, /* info = index of constant in 'k' */
- VKFLT, /* nval = numerical float value */
- VKINT, /* nval = numerical integer value */
- VNONRELOC, /* info = result register */
- VLOCAL, /* info = local register */
- VUPVAL, /* info = index of upvalue in 'upvalues' */
- VINDEXED, /* t = table register/upvalue; idx = index R/K */
- VJMP, /* info = instruction pc */
- VRELOCABLE, /* info = instruction pc */
- VCALL, /* info = instruction pc */
- VVARARG /* info = instruction pc */
+ VVOID, /* when 'expdesc' describes the last expression a list,
+ this kind means an empty list (so, no expression) */
+ VNIL, /* constant nil */
+ VTRUE, /* constant true */
+ VFALSE, /* constant false */
+ VK, /* constant in 'k'; info = index of constant in 'k' */
+ VKFLT, /* floating constant; nval = numerical float value */
+ VKINT, /* integer constant; nval = numerical integer value */
+ VNONRELOC, /* expression has its value in a fixed register;
+ info = result register */
+ VLOCAL, /* local variable; info = local register */
+ VUPVAL, /* upvalue variable; info = index of upvalue in 'upvalues' */
+ VINDEXED, /* indexed variable;
+ ind.vt = whether 't' is register or upvalue;
+ ind.t = table register or upvalue;
+ ind.idx = key's R/K index */
+ VJMP, /* expression is a test/comparison;
+ info = pc of corresponding jump instruction */
+ VRELOCABLE, /* expression can put result in any register;
+ info = instruction pc */
+ VCALL, /* expression is a function call; info = instruction pc */
+ VVARARG /* vararg expression; info = instruction pc */
} expkind;
-#define vkisvar(k) (VLOCAL <= (k) && (k) <= VINDEXED)
-#define vkisinreg(k) ((k) == VNONRELOC || (k) == VLOCAL)
+
+#define vkisvar(k) (VLOCAL <= (k) && (k) <= VINDEXED)
+#define vkisinreg(k) ((k) == VNONRELOC || (k) == VLOCAL)
typedef struct expdesc {
- expkind k;
- union {
- struct { /* for indexed variables (VINDEXED) */
- short idx; /* index (R/K) */
- lu_byte t; /* table (register or upvalue) */
- lu_byte vt; /* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */
- } ind;
- int info; /* for generic use */
- lua_Number nval; /* for VKFLT */
- lua_Integer ival; /* for VKINT */
- } u;
- int t; /* patch list of 'exit when true' */
- int f; /* patch list of 'exit when false' */
+ expkind k;
+ union {
+ lua_Integer ival; /* for VKINT */
+ lua_Number nval; /* for VKFLT */
+ int info; /* for generic use */
+ struct { /* for indexed variables (VINDEXED) */
+ short idx; /* index (R/K) */
+ lu_byte t; /* table (register or upvalue) */
+ lu_byte vt; /* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */
+ } ind;
+ } u;
+ int t; /* patch list of 'exit when true' */
+ int f; /* patch list of 'exit when false' */
} expdesc;
+
/* description of active local variable */
-typedef struct Vardesc { short idx; /* variable index in stack */ } Vardesc;
+typedef struct Vardesc {
+ short idx; /* variable index in stack */
+} Vardesc;
+
/* description of pending goto statements and label statements */
typedef struct Labeldesc {
- TString* name; /* label identifier */
- int pc; /* position in code */
- int line; /* line where it appeared */
- lu_byte nactvar; /* local level where it appears in current block */
+ TString *name; /* label identifier */
+ int pc; /* position in code */
+ int line; /* line where it appeared */
+ lu_byte nactvar; /* local level where it appears in current block */
} Labeldesc;
+
/* list of labels or gotos */
typedef struct Labellist {
- Labeldesc* arr; /* array */
- int n; /* number of entries in use */
- int size; /* array size */
+ Labeldesc *arr; /* array */
+ int n; /* number of entries in use */
+ int size; /* array size */
} Labellist;
+
/* dynamic structures used by the parser */
typedef struct Dyndata {
- struct {/* list of active local variables */
- Vardesc* arr;
- int n;
- int size;
- } actvar;
- Labellist gt; /* list of pending gotos */
- Labellist label; /* list of active labels */
+ struct { /* list of active local variables */
+ Vardesc *arr;
+ int n;
+ int size;
+ } actvar;
+ Labellist gt; /* list of pending gotos */
+ Labellist label; /* list of active labels */
} Dyndata;
+
/* control of blocks */
-struct BlockCnt; /* defined in lparser.c */
+struct BlockCnt; /* defined in lparser.c */
+
/* state needed to generate code for a given function */
typedef struct FuncState {
- Proto* f; /* current function header */
- struct FuncState* prev; /* enclosing function */
- struct LexState* ls; /* lexical state */
- struct BlockCnt* bl; /* chain of current blocks */
- int pc; /* next position to code (equivalent to 'ncode') */
- int lasttarget; /* 'label' of last 'jump label' */
- int jpc; /* list of pending jumps to 'pc' */
- int nk; /* number of elements in 'k' */
- int np; /* number of elements in 'p' */
- int firstlocal; /* index of first local var (in Dyndata array) */
- short nlocvars; /* number of elements in 'f->locvars' */
- lu_byte nactvar; /* number of active local variables */
- lu_byte nups; /* number of upvalues */
- lu_byte freereg; /* first free register */
+ Proto *f; /* current function header */
+ struct FuncState *prev; /* enclosing function */
+ struct LexState *ls; /* lexical state */
+ struct BlockCnt *bl; /* chain of current blocks */
+ int pc; /* next position to code (equivalent to 'ncode') */
+ int lasttarget; /* 'label' of last 'jump label' */
+ int jpc; /* list of pending jumps to 'pc' */
+ int nk; /* number of elements in 'k' */
+ int np; /* number of elements in 'p' */
+ int firstlocal; /* index of first local var (in Dyndata array) */
+ short nlocvars; /* number of elements in 'f->locvars' */
+ lu_byte nactvar; /* number of active local variables */
+ lu_byte nups; /* number of upvalues */
+ lu_byte freereg; /* first free register */
} FuncState;
-LUAI_FUNC LClosure*
-luaY_parser(lua_State* L, ZIO* z, Mbuffer* buff, Dyndata* dyd, const char* name, int firstchar);
+
+LUAI_FUNC LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
+ Dyndata *dyd, const char *name, int firstchar);
+
#endif
=== modified file 'src/third_party/eris/lprefix.h'
--- src/third_party/eris/lprefix.h 2016-08-04 15:49:05 +0000
+++ src/third_party/eris/lprefix.h 2018-07-08 12:35:11 +0000
@@ -7,36 +7,39 @@
#ifndef lprefix_h
#define lprefix_h
+
/*
** Allows POSIX/XSI stuff
*/
-#if !defined(LUA_USE_C89) /* { */
+#if !defined(LUA_USE_C89) /* { */
#if !defined(_XOPEN_SOURCE)
-#define _XOPEN_SOURCE 600
+#define _XOPEN_SOURCE 600
#elif _XOPEN_SOURCE == 0
-#undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */
+#undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */
#endif
/*
** Allows manipulation of large files in gcc and some other compilers
*/
#if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS)
-#define _LARGEFILE_SOURCE 1
-#define _FILE_OFFSET_BITS 64
+#define _LARGEFILE_SOURCE 1
+#define _FILE_OFFSET_BITS 64
#endif
-#endif /* } */
+#endif /* } */
+
/*
** Windows stuff
*/
-#if defined(_WIN32) /* { */
+#if defined(_WIN32) /* { */
#if !defined(_CRT_SECURE_NO_WARNINGS)
-#define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */
-#endif
-
-#endif /* } */
-
-#endif
+#define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */
+#endif
+
+#endif /* } */
+
+#endif
+
=== modified file 'src/third_party/eris/lstate.h'
--- src/third_party/eris/lstate.h 2017-01-21 09:41:07 +0000
+++ src/third_party/eris/lstate.h 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: lstate.h,v 2.128 2015/11/13 12:16:51 roberto Exp $
+** $Id: lstate.h,v 2.133 2016/12/22 13:08:50 roberto Exp $
** Global State
** See Copyright Notice in lua.h
*/
@@ -13,6 +13,7 @@
#include "ltm.h"
#include "lzio.h"
+
/*
** Some notes about garbage-collected objects: All objects in Lua must
@@ -28,23 +29,39 @@
*/
-struct lua_longjmp; /* defined in ldo.c */
+
+struct lua_longjmp; /* defined in ldo.c */
+
+
+/*
+** Atomic type (relative to signals) to better ensure that 'lua_sethook'
+** is thread safe
+*/
+#if !defined(l_signalT)
+#include <signal.h>
+#define l_signalT sig_atomic_t
+#endif
+
/* extra stack space to handle TM calls and some other extras */
-#define EXTRA_STACK 5
-
-#define BASIC_STACK_SIZE (2 * LUA_MINSTACK)
+#define EXTRA_STACK 5
+
+
+#define BASIC_STACK_SIZE (2*LUA_MINSTACK)
+
/* kinds of Garbage Collection */
-#define KGC_NORMAL 0
-#define KGC_EMERGENCY 1 /* gc was forced by an allocation failure */
+#define KGC_NORMAL 0
+#define KGC_EMERGENCY 1 /* gc was forced by an allocation failure */
+
typedef struct stringtable {
- TString** hash;
- int nuse; /* number of elements */
- int size;
+ TString **hash;
+ int nuse; /* number of elements */
+ int size;
} stringtable;
+
/*
** Information about a call.
** When a thread yields, 'func' is adjusted to pretend that the
@@ -55,151 +72,164 @@
** function can be called with the correct top.
*/
typedef struct CallInfo {
- StkId func; /* function index in the stack */
- StkId top; /* top for this function */
- struct CallInfo *previous, *next; /* dynamic call link */
- union {
- struct { /* only for Lua functions */
- StkId base; /* base for this function */
- const Instruction* savedpc;
- } l;
- struct { /* only for C functions */
- lua_KFunction k; /* continuation in case of yields */
- ptrdiff_t old_errfunc;
- lua_KContext ctx; /* context info. in case of yields */
- } c;
- } u;
- ptrdiff_t extra;
- short nresults; /* expected number of results from this function */
- lu_byte callstatus;
+ StkId func; /* function index in the stack */
+ StkId top; /* top for this function */
+ struct CallInfo *previous, *next; /* dynamic call link */
+ union {
+ struct { /* only for Lua functions */
+ StkId base; /* base for this function */
+ const Instruction *savedpc;
+ } l;
+ struct { /* only for C functions */
+ lua_KFunction k; /* continuation in case of yields */
+ ptrdiff_t old_errfunc;
+ lua_KContext ctx; /* context info. in case of yields */
+ } c;
+ } u;
+ ptrdiff_t extra;
+ short nresults; /* expected number of results from this function */
+ unsigned short callstatus;
} CallInfo;
+
/*
** Bits in CallInfo status
*/
-#define CIST_OAH (1 << 0) /* original value of 'allowhook' */
-#define CIST_LUA (1 << 1) /* call is running a Lua function */
-#define CIST_HOOKED (1 << 2) /* call is running a debug hook */
-#define CIST_FRESH \
- (1 << 3) /* call is running on a fresh invocation \
- of luaV_execute */
-#define CIST_YPCALL (1 << 4) /* call is a yieldable protected call */
-#define CIST_TAIL (1 << 5) /* call was tail called */
-#define CIST_HOOKYIELD (1 << 6) /* last hook called yielded */
-#define CIST_LEQ (1 << 7) /* using __lt for __le */
+#define CIST_OAH (1<<0) /* original value of 'allowhook' */
+#define CIST_LUA (1<<1) /* call is running a Lua function */
+#define CIST_HOOKED (1<<2) /* call is running a debug hook */
+#define CIST_FRESH (1<<3) /* call is running on a fresh invocation
+ of luaV_execute */
+#define CIST_YPCALL (1<<4) /* call is a yieldable protected call */
+#define CIST_TAIL (1<<5) /* call was tail called */
+#define CIST_HOOKYIELD (1<<6) /* last hook called yielded */
+#define CIST_LEQ (1<<7) /* using __lt for __le */
+#define CIST_FIN (1<<8) /* call is running a finalizer */
-#define isLua(ci) ((ci)->callstatus & CIST_LUA)
+#define isLua(ci) ((ci)->callstatus & CIST_LUA)
/* assume that CIST_OAH has offset 0 and that 'v' is strictly 0/1 */
-#define setoah(st, v) ((st) = ((st) & ~CIST_OAH) | (v))
-#define getoah(st) ((st)&CIST_OAH)
+#define setoah(st,v) ((st) = ((st) & ~CIST_OAH) | (v))
+#define getoah(st) ((st) & CIST_OAH)
+
/*
** 'global state', shared by all threads of this state
*/
typedef struct global_State {
- lua_Alloc frealloc; /* function to reallocate memory */
- void* ud; /* auxiliary data to 'frealloc' */
- l_mem totalbytes; /* number of bytes currently allocated - GCdebt */
- l_mem GCdebt; /* bytes allocated not yet compensated by the collector */
- lu_mem GCmemtrav; /* memory traversed by the GC */
- lu_mem GCestimate; /* an estimate of the non-garbage memory in use */
- stringtable strt; /* hash table for strings */
- TValue l_registry;
- unsigned int seed; /* randomized seed for hashes */
- lu_byte currentwhite;
- lu_byte gcstate; /* state of garbage collector */
- lu_byte gckind; /* kind of GC running */
- lu_byte gcrunning; /* true if GC is running */
- GCObject* allgc; /* list of all collectable objects */
- GCObject** sweepgc; /* current position of sweep in list */
- GCObject* finobj; /* list of collectable objects with finalizers */
- GCObject* gray; /* list of gray objects */
- GCObject* grayagain; /* list of objects to be traversed atomically */
- GCObject* weak; /* list of tables with weak values */
- GCObject* ephemeron; /* list of ephemeron tables (weak keys) */
- GCObject* allweak; /* list of all-weak tables */
- GCObject* tobefnz; /* list of userdata to be GC */
- GCObject* fixedgc; /* list of objects not to be collected */
- struct lua_State* twups; /* list of threads with open upvalues */
- unsigned int gcfinnum; /* number of finalizers to call in each GC step */
- int gcpause; /* size of pause between successive GCs */
- int gcstepmul; /* GC 'granularity' */
- lua_CFunction panic; /* to be called in unprotected errors */
- struct lua_State* mainthread;
- const lua_Number* version; /* pointer to version number */
- TString* memerrmsg; /* memory-error message */
- TString* tmname[TM_N]; /* array with tag-method names */
- struct Table* mt[LUA_NUMTAGS]; /* metatables for basic types */
- TString* strcache[STRCACHE_N][STRCACHE_M]; /* cache for strings in API */
+ lua_Alloc frealloc; /* function to reallocate memory */
+ void *ud; /* auxiliary data to 'frealloc' */
+ l_mem totalbytes; /* number of bytes currently allocated - GCdebt */
+ l_mem GCdebt; /* bytes allocated not yet compensated by the collector */
+ lu_mem GCmemtrav; /* memory traversed by the GC */
+ lu_mem GCestimate; /* an estimate of the non-garbage memory in use */
+ stringtable strt; /* hash table for strings */
+ TValue l_registry;
+ unsigned int seed; /* randomized seed for hashes */
+ lu_byte currentwhite;
+ lu_byte gcstate; /* state of garbage collector */
+ lu_byte gckind; /* kind of GC running */
+ lu_byte gcrunning; /* true if GC is running */
+ GCObject *allgc; /* list of all collectable objects */
+ GCObject **sweepgc; /* current position of sweep in list */
+ GCObject *finobj; /* list of collectable objects with finalizers */
+ GCObject *gray; /* list of gray objects */
+ GCObject *grayagain; /* list of objects to be traversed atomically */
+ GCObject *weak; /* list of tables with weak values */
+ GCObject *ephemeron; /* list of ephemeron tables (weak keys) */
+ GCObject *allweak; /* list of all-weak tables */
+ GCObject *tobefnz; /* list of userdata to be GC */
+ GCObject *fixedgc; /* list of objects not to be collected */
+ struct lua_State *twups; /* list of threads with open upvalues */
+ unsigned int gcfinnum; /* number of finalizers to call in each GC step */
+ int gcpause; /* size of pause between successive GCs */
+ int gcstepmul; /* GC 'granularity' */
+ lua_CFunction panic; /* to be called in unprotected errors */
+ struct lua_State *mainthread;
+ const lua_Number *version; /* pointer to version number */
+ TString *memerrmsg; /* memory-error message */
+ TString *tmname[TM_N]; /* array with tag-method names */
+ struct Table *mt[LUA_NUMTAGS]; /* metatables for basic types */
+ TString *strcache[STRCACHE_N][STRCACHE_M]; /* cache for strings in API */
} global_State;
+
/*
** 'per thread' state
*/
struct lua_State {
- CommonHeader;
- unsigned short nci; /* number of items in 'ci' list */
- lu_byte status;
- StkId top; /* first free slot in the stack */
- global_State* l_G;
- CallInfo* ci; /* call info for current function */
- const Instruction* oldpc; /* last pc traced */
- StkId stack_last; /* last free slot in the stack */
- StkId stack; /* stack base */
- UpVal* openupval; /* list of open upvalues in this stack */
- GCObject* gclist;
- struct lua_State* twups; /* list of threads with open upvalues */
- struct lua_longjmp* errorJmp; /* current error recover point */
- CallInfo base_ci; /* CallInfo for first level (C calling Lua) */
- lua_Hook hook;
- ptrdiff_t errfunc; /* current error handling function (stack index) */
- int stacksize;
- int basehookcount;
- int hookcount;
- unsigned short nny; /* number of non-yieldable calls in stack */
- unsigned short nCcalls; /* number of nested C calls */
- lu_byte hookmask;
- lu_byte allowhook;
+ CommonHeader;
+ unsigned short nci; /* number of items in 'ci' list */
+ lu_byte status;
+ StkId top; /* first free slot in the stack */
+ global_State *l_G;
+ CallInfo *ci; /* call info for current function */
+ const Instruction *oldpc; /* last pc traced */
+ StkId stack_last; /* last free slot in the stack */
+ StkId stack; /* stack base */
+ UpVal *openupval; /* list of open upvalues in this stack */
+ GCObject *gclist;
+ struct lua_State *twups; /* list of threads with open upvalues */
+ struct lua_longjmp *errorJmp; /* current error recover point */
+ CallInfo base_ci; /* CallInfo for first level (C calling Lua) */
+ volatile lua_Hook hook;
+ ptrdiff_t errfunc; /* current error handling function (stack index) */
+ int stacksize;
+ int basehookcount;
+ int hookcount;
+ unsigned short nny; /* number of non-yieldable calls in stack */
+ unsigned short nCcalls; /* number of nested C calls */
+ l_signalT hookmask;
+ lu_byte allowhook;
};
-#define G(L) (L->l_G)
+
+#define G(L) (L->l_G)
+
/*
** Union of all collectable objects (only for conversions)
*/
union GCUnion {
- GCObject gc; /* common header */
- struct TString ts;
- struct Udata u;
- union Closure cl;
- struct Table h;
- struct Proto p;
- struct lua_State th; /* thread */
+ GCObject gc; /* common header */
+ struct TString ts;
+ struct Udata u;
+ union Closure cl;
+ struct Table h;
+ struct Proto p;
+ struct lua_State th; /* thread */
};
-#define cast_u(o) cast(union GCUnion*, (o))
+
+#define cast_u(o) cast(union GCUnion *, (o))
/* macros to convert a GCObject into a specific value */
-#define gco2ts(o) check_exp(novariant((o)->tt) == LUA_TSTRING, &((cast_u(o))->ts))
-#define gco2u(o) check_exp((o)->tt == LUA_TUSERDATA, &((cast_u(o))->u))
-#define gco2lcl(o) check_exp((o)->tt == LUA_TLCL, &((cast_u(o))->cl.l))
-#define gco2ccl(o) check_exp((o)->tt == LUA_TCCL, &((cast_u(o))->cl.c))
-#define gco2cl(o) check_exp(novariant((o)->tt) == LUA_TFUNCTION, &((cast_u(o))->cl))
-#define gco2t(o) check_exp((o)->tt == LUA_TTABLE, &((cast_u(o))->h))
-#define gco2p(o) check_exp((o)->tt == LUA_TPROTO, &((cast_u(o))->p))
-#define gco2th(o) check_exp((o)->tt == LUA_TTHREAD, &((cast_u(o))->th))
+#define gco2ts(o) \
+ check_exp(novariant((o)->tt) == LUA_TSTRING, &((cast_u(o))->ts))
+#define gco2u(o) check_exp((o)->tt == LUA_TUSERDATA, &((cast_u(o))->u))
+#define gco2lcl(o) check_exp((o)->tt == LUA_TLCL, &((cast_u(o))->cl.l))
+#define gco2ccl(o) check_exp((o)->tt == LUA_TCCL, &((cast_u(o))->cl.c))
+#define gco2cl(o) \
+ check_exp(novariant((o)->tt) == LUA_TFUNCTION, &((cast_u(o))->cl))
+#define gco2t(o) check_exp((o)->tt == LUA_TTABLE, &((cast_u(o))->h))
+#define gco2p(o) check_exp((o)->tt == LUA_TPROTO, &((cast_u(o))->p))
+#define gco2th(o) check_exp((o)->tt == LUA_TTHREAD, &((cast_u(o))->th))
+
/* macro to convert a Lua object into a GCObject */
-#define obj2gco(v) check_exp(novariant((v)->tt) < LUA_TDEADKEY, (&(cast_u(v)->gc)))
+#define obj2gco(v) \
+ check_exp(novariant((v)->tt) < LUA_TDEADKEY, (&(cast_u(v)->gc)))
+
/* actual number of total bytes allocated */
-#define gettotalbytes(g) cast(lu_mem, (g)->totalbytes + (g)->GCdebt)
-
-LUAI_FUNC void luaE_setdebt(global_State* g, l_mem debt);
-LUAI_FUNC void luaE_freethread(lua_State* L, lua_State* L1);
-LUAI_FUNC CallInfo* luaE_extendCI(lua_State* L);
-LUAI_FUNC void luaE_freeCI(lua_State* L);
-LUAI_FUNC void luaE_shrinkCI(lua_State* L);
+#define gettotalbytes(g) cast(lu_mem, (g)->totalbytes + (g)->GCdebt)
+
+LUAI_FUNC void luaE_setdebt (global_State *g, l_mem debt);
+LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1);
+LUAI_FUNC CallInfo *luaE_extendCI (lua_State *L);
+LUAI_FUNC void luaE_freeCI (lua_State *L);
+LUAI_FUNC void luaE_shrinkCI (lua_State *L);
+
#endif
+
=== modified file 'src/third_party/eris/lstring.h'
--- src/third_party/eris/lstring.h 2016-08-04 15:49:05 +0000
+++ src/third_party/eris/lstring.h 2018-07-08 12:35:11 +0000
@@ -11,33 +11,39 @@
#include "lobject.h"
#include "lstate.h"
-#define sizelstring(l) (sizeof(union UTString) + ((l) + 1) * sizeof(char))
-
-#define sizeludata(l) (sizeof(union UUdata) + (l))
-#define sizeudata(u) sizeludata((u)->len)
-
-#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, (sizeof(s) / sizeof(char)) - 1))
+
+#define sizelstring(l) (sizeof(union UTString) + ((l) + 1) * sizeof(char))
+
+#define sizeludata(l) (sizeof(union UUdata) + (l))
+#define sizeudata(u) sizeludata((u)->len)
+
+#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \
+ (sizeof(s)/sizeof(char))-1))
+
/*
** test whether a string is a reserved word
*/
-#define isreserved(s) ((s)->tt == LUA_TSHRSTR && (s)->extra > 0)
+#define isreserved(s) ((s)->tt == LUA_TSHRSTR && (s)->extra > 0)
+
/*
** equality for short strings, which are always internalized
*/
-#define eqshrstr(a, b) check_exp((a)->tt == LUA_TSHRSTR, (a) == (b))
-
-LUAI_FUNC unsigned int luaS_hash(const char* str, size_t l, unsigned int seed);
-LUAI_FUNC unsigned int luaS_hashlongstr(TString* ts);
-LUAI_FUNC int luaS_eqlngstr(TString* a, TString* b);
-LUAI_FUNC void luaS_resize(lua_State* L, int newsize);
-LUAI_FUNC void luaS_clearcache(global_State* g);
-LUAI_FUNC void luaS_init(lua_State* L);
-LUAI_FUNC void luaS_remove(lua_State* L, TString* ts);
-LUAI_FUNC Udata* luaS_newudata(lua_State* L, size_t s);
-LUAI_FUNC TString* luaS_newlstr(lua_State* L, const char* str, size_t l);
-LUAI_FUNC TString* luaS_new(lua_State* L, const char* str);
-LUAI_FUNC TString* luaS_createlngstrobj(lua_State* L, size_t l);
+#define eqshrstr(a,b) check_exp((a)->tt == LUA_TSHRSTR, (a) == (b))
+
+
+LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed);
+LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts);
+LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b);
+LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
+LUAI_FUNC void luaS_clearcache (global_State *g);
+LUAI_FUNC void luaS_init (lua_State *L);
+LUAI_FUNC void luaS_remove (lua_State *L, TString *ts);
+LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s);
+LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
+LUAI_FUNC TString *luaS_new (lua_State *L, const char *str);
+LUAI_FUNC TString *luaS_createlngstrobj (lua_State *L, size_t l);
+
#endif
=== modified file 'src/third_party/eris/lstrlib.c'
--- src/third_party/eris/lstrlib.c 2017-11-09 17:37:13 +0000
+++ src/third_party/eris/lstrlib.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: lstrlib.c,v 1.239 2015/11/25 16:28:17 roberto Exp $
+** $Id: lstrlib.c,v 1.254 2016/12/22 13:08:50 roberto Exp $
** Standard library for string operations and pattern-matching
** See Copyright Notice in lua.h
*/
@@ -13,6 +13,7 @@
#include <ctype.h>
#include <float.h>
#include <limits.h>
+#include <locale.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
@@ -26,7 +27,8 @@
/*
** maximum number of captures that a pattern can do during
-** pattern-matching. This limit is arbitrary.
+** pattern-matching. This limit is arbitrary, but must fit in
+** an unsigned char.
*/
#if !defined(LUA_MAXCAPTURES)
#define LUA_MAXCAPTURES 32
@@ -214,9 +216,8 @@
const char *src_end; /* end ('\0') of source string */
const char *p_end; /* end ('\0') of pattern */
lua_State *L;
- size_t nrep; /* limit to avoid non-linear complexity */
int matchdepth; /* control for recursive depth (to avoid C stack overflow) */
- int level; /* total number of captures (finished or unfinished) */
+ unsigned char level; /* total number of captures (finished or unfinished) */
struct {
const char *init;
ptrdiff_t len;
@@ -234,17 +235,6 @@
#endif
-/*
-** parameters to control the maximum number of operators handled in
-** a match (to avoid non-linear complexity). The maximum will be:
-** (subject length) * A_REPS + B_REPS
-*/
-#if !defined(A_REPS)
-#define A_REPS 4
-#define B_REPS 100000
-#endif
-
-
#define L_ESC '%'
#define SPECIALS "^$*+?.([%-"
@@ -502,8 +492,6 @@
s = NULL; /* fail */
}
else { /* matched once */
- if (ms->nrep-- == 0)
- luaL_error(ms->L, "pattern too complex");
switch (*ep) { /* handle optional suffix */
case '?': { /* optional */
const char *res;
@@ -607,10 +595,6 @@
ms->src_init = s;
ms->src_end = s + ls;
ms->p_end = p + lp;
- if (ls < (MAX_SIZET - B_REPS) / A_REPS)
- ms->nrep = A_REPS * ls + B_REPS;
- else /* overflow (very long subject) */
- ms->nrep = MAX_SIZET; /* no limit */
}
@@ -681,6 +665,7 @@
typedef struct GMatchState {
const char *src; /* current position */
const char *p; /* pattern */
+ const char *lastmatch; /* end of last match */
MatchState ms; /* match state */
} GMatchState;
@@ -688,14 +673,12 @@
static int gmatch_aux (lua_State *L) {
GMatchState *gm = (GMatchState *)lua_touserdata(L, lua_upvalueindex(3));
const char *src;
+ gm->ms.L = L;
for (src = gm->src; src <= gm->ms.src_end; src++) {
const char *e;
reprepstate(&gm->ms);
- if ((e = match(&gm->ms, src, gm->p)) != NULL) {
- if (e == src) /* empty match? */
- gm->src =src + 1; /* go at least one position */
- else
- gm->src = e;
+ if ((e = match(&gm->ms, src, gm->p)) != NULL && e != gm->lastmatch) {
+ gm->src = gm->lastmatch = e;
return push_captures(&gm->ms, src, e);
}
}
@@ -711,7 +694,7 @@
lua_settop(L, 2); /* keep them on closure to avoid being collected */
gm = (GMatchState *)lua_newuserdata(L, sizeof(GMatchState));
prepstate(&gm->ms, L, s, ls, p, lp);
- gm->src = s; gm->p = p;
+ gm->src = s; gm->p = p; gm->lastmatch = NULL;
lua_pushcclosure(L, gmatch_aux, 3);
return 1;
}
@@ -778,12 +761,13 @@
static int str_gsub (lua_State *L) {
size_t srcl, lp;
- const char *src = luaL_checklstring(L, 1, &srcl);
- const char *p = luaL_checklstring(L, 2, &lp);
- int tr = lua_type(L, 3);
- lua_Integer max_s = luaL_optinteger(L, 4, srcl + 1);
+ const char *src = luaL_checklstring(L, 1, &srcl); /* subject */
+ const char *p = luaL_checklstring(L, 2, &lp); /* pattern */
+ const char *lastmatch = NULL; /* end of last match */
+ int tr = lua_type(L, 3); /* replacement type */
+ lua_Integer max_s = luaL_optinteger(L, 4, srcl + 1); /* max replacements */
int anchor = (*p == '^');
- lua_Integer n = 0;
+ lua_Integer n = 0; /* replacement count */
MatchState ms;
luaL_Buffer b;
luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING ||
@@ -796,16 +780,15 @@
prepstate(&ms, L, src, srcl, p, lp);
while (n < max_s) {
const char *e;
- reprepstate(&ms);
- if ((e = match(&ms, src, p)) != NULL) {
+ reprepstate(&ms); /* (re)prepare state for new match */
+ if ((e = match(&ms, src, p)) != NULL && e != lastmatch) { /* match? */
n++;
- add_value(&ms, &b, src, e, tr);
+ add_value(&ms, &b, src, e, tr); /* add replacement to buffer */
+ src = lastmatch = e;
}
- if (e && e>src) /* non empty match? */
- src = e; /* skip it */
- else if (src < ms.src_end)
+ else if (src < ms.src_end) /* otherwise, skip one character */
luaL_addchar(&b, *src++);
- else break;
+ else break; /* end of subject */
if (anchor) break;
}
luaL_addlstring(&b, src, ms.src_end-src);
@@ -830,7 +813,6 @@
** Hexadecimal floating-point formatter
*/
-#include <locale.h>
#include <math.h>
#define SIZELENMOD (sizeof(LUA_NUMBER_FRMLEN)/sizeof(char))
@@ -857,11 +839,12 @@
static int num2straux (char *buff, int sz, lua_Number x) {
- if (x != x || x == HUGE_VAL || x == -HUGE_VAL) /* inf or NaN? */
- return l_sprintf(buff, sz, LUA_NUMBER_FMT, x); /* equal to '%g' */
+ /* if 'inf' or 'NaN', format it like '%g' */
+ if (x != x || x == (lua_Number)HUGE_VAL || x == -(lua_Number)HUGE_VAL)
+ return l_sprintf(buff, sz, LUA_NUMBER_FMT, (LUAI_UACNUMBER)x);
else if (x == 0) { /* can be -0... */
/* create "0" or "-0" followed by exponent */
- return l_sprintf(buff, sz, LUA_NUMBER_FMT "x0p+0", x);
+ return l_sprintf(buff, sz, LUA_NUMBER_FMT "x0p+0", (LUAI_UACNUMBER)x);
}
else {
int e;
@@ -922,16 +905,14 @@
#define MAX_FORMAT 32
-static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
- size_t l;
- const char *s = luaL_checklstring(L, arg, &l);
+static void addquoted (luaL_Buffer *b, const char *s, size_t len) {
luaL_addchar(b, '"');
- while (l--) {
+ while (len--) {
if (*s == '"' || *s == '\\' || *s == '\n') {
luaL_addchar(b, '\\');
luaL_addchar(b, *s);
}
- else if (*s == '\0' || iscntrl(uchar(*s))) {
+ else if (iscntrl(uchar(*s))) {
char buff[10];
if (!isdigit(uchar(*(s+1))))
l_sprintf(buff, sizeof(buff), "\\%d", (int)uchar(*s));
@@ -946,6 +927,57 @@
luaL_addchar(b, '"');
}
+
+/*
+** Ensures the 'buff' string uses a dot as the radix character.
+*/
+static void checkdp (char *buff, int nb) {
+ if (memchr(buff, '.', nb) == NULL) { /* no dot? */
+ char point = lua_getlocaledecpoint(); /* try locale point */
+ char *ppoint = (char *)memchr(buff, point, nb);
+ if (ppoint) *ppoint = '.'; /* change it to a dot */
+ }
+}
+
+
+static void addliteral (lua_State *L, luaL_Buffer *b, int arg) {
+ switch (lua_type(L, arg)) {
+ case LUA_TSTRING: {
+ size_t len;
+ const char *s = lua_tolstring(L, arg, &len);
+ addquoted(b, s, len);
+ break;
+ }
+ case LUA_TNUMBER: {
+ char *buff = luaL_prepbuffsize(b, MAX_ITEM);
+ int nb;
+ if (!lua_isinteger(L, arg)) { /* float? */
+ lua_Number n = lua_tonumber(L, arg); /* write as hexa ('%a') */
+ nb = lua_number2strx(L, buff, MAX_ITEM, "%" LUA_NUMBER_FRMLEN "a", n);
+ checkdp(buff, nb); /* ensure it uses a dot */
+ }
+ else { /* integers */
+ lua_Integer n = lua_tointeger(L, arg);
+ const char *format = (n == LUA_MININTEGER) /* corner case? */
+ ? "0x%" LUA_INTEGER_FRMLEN "x" /* use hexa */
+ : LUA_INTEGER_FMT; /* else use default format */
+ nb = l_sprintf(buff, MAX_ITEM, format, (LUAI_UACINT)n);
+ }
+ luaL_addsize(b, nb);
+ break;
+ }
+ case LUA_TNIL: case LUA_TBOOLEAN: {
+ luaL_tolstring(L, arg, NULL);
+ luaL_addvalue(b);
+ break;
+ }
+ default: {
+ luaL_argerror(L, arg, "value has no literal form");
+ }
+ }
+}
+
+
static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
const char *p = strfrmt;
while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */
@@ -975,7 +1007,7 @@
size_t l = strlen(form);
size_t lm = strlen(lenmod);
char spec = form[l - 1];
- strcpy(form + l - 1, lenmod); // NOLINT
+ strcpy(form + l - 1, lenmod);
form[l + lm - 1] = spec;
form[l + lm] = '\0';
}
@@ -1010,7 +1042,7 @@
case 'o': case 'u': case 'x': case 'X': {
lua_Integer n = luaL_checkinteger(L, arg);
addlenmod(form, LUA_INTEGER_FRMLEN);
- nb = l_sprintf(buff, MAX_ITEM, form, n);
+ nb = l_sprintf(buff, MAX_ITEM, form, (LUAI_UACINT)n);
break;
}
case 'a': case 'A':
@@ -1020,12 +1052,13 @@
break;
case 'e': case 'E': case 'f':
case 'g': case 'G': {
+ lua_Number n = luaL_checknumber(L, arg);
addlenmod(form, LUA_NUMBER_FRMLEN);
- nb = l_sprintf(buff, MAX_ITEM, form, luaL_checknumber(L, arg));
+ nb = l_sprintf(buff, MAX_ITEM, form, (LUAI_UACNUMBER)n);
break;
}
case 'q': {
- addquoted(L, &b, arg);
+ addliteral(L, &b, arg);
break;
}
case 's': {
@@ -1070,8 +1103,8 @@
/* value used for padding */
-#if !defined(LUA_PACKPADBYTE)
-#define LUA_PACKPADBYTE 0x00
+#if !defined(LUAL_PACKPADBYTE)
+#define LUAL_PACKPADBYTE 0x00
#endif
/* maximum size for the binary representation of an integer */
@@ -1228,7 +1261,7 @@
** 'psize' is filled with option's size, 'notoalign' with its
** alignment requirements.
** Local variable 'size' gets the size to be aligned. (Kpadal option
-** always gets its full alignment, other options are limited by
+** always gets its full alignment, other options are limited by
** the maximum alignment ('maxalign'). Kchar option needs no alignment
** despite its size.
*/
@@ -1308,7 +1341,7 @@
KOption opt = getdetails(&h, totalsize, &fmt, &size, &ntoalign);
totalsize += ntoalign + size;
while (ntoalign-- > 0)
- luaL_addchar(&b, LUA_PACKPADBYTE); /* fill alignment */
+ luaL_addchar(&b, LUAL_PACKPADBYTE); /* fill alignment */
arg++;
switch (opt) {
case Kint: { /* signed integers */
@@ -1343,13 +1376,11 @@
case Kchar: { /* fixed-size string */
size_t len;
const char *s = luaL_checklstring(L, arg, &len);
- if ((size_t)size <= len) /* string larger than (or equal to) needed? */
- luaL_addlstring(&b, s, size); /* truncate string to asked size */
- else { /* string smaller than needed */
- luaL_addlstring(&b, s, len); /* add it all */
- while (len++ < (size_t)size) /* pad extra space */
- luaL_addchar(&b, LUA_PACKPADBYTE);
- }
+ luaL_argcheck(L, len <= (size_t)size, arg,
+ "string longer than given size");
+ luaL_addlstring(&b, s, len); /* add string */
+ while (len++ < (size_t)size) /* pad extra space */
+ luaL_addchar(&b, LUAL_PACKPADBYTE);
break;
}
case Kstring: { /* strings with length count */
@@ -1372,7 +1403,7 @@
totalsize += len + 1;
break;
}
- case Kpadding: luaL_addchar(&b, LUA_PACKPADBYTE); /* FALLTHROUGH */
+ case Kpadding: luaL_addchar(&b, LUAL_PACKPADBYTE); /* FALLTHROUGH */
case Kpaddalign: case Knop:
arg--; /* undo increment */
break;
=== modified file 'src/third_party/eris/ltable.c'
--- src/third_party/eris/ltable.c 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/ltable.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: ltable.c,v 2.117 2015/11/19 19:16:22 roberto Exp $
+** $Id: ltable.c,v 2.118 2016/11/07 12:38:35 roberto Exp $
** Lua tables (hash)
** See Copyright Notice in lua.h
*/
@@ -74,8 +74,6 @@
#define dummynode (&dummynode_)
-#define isdummy(n) ((n) == dummynode)
-
static const Node dummynode_ = {
{NILCONSTANT}, /* value */
{{NILCONSTANT, 0}} /* key */
@@ -308,14 +306,14 @@
static void setnodevector (lua_State *L, Table *t, unsigned int size) {
- int lsize;
if (size == 0) { /* no elements to hash part? */
t->node = cast(Node *, dummynode); /* use common 'dummynode' */
- lsize = 0;
+ t->lsizenode = 0;
+ t->lastfree = NULL; /* signal that it is using dummy node */
}
else {
int i;
- lsize = luaO_ceillog2(size);
+ int lsize = luaO_ceillog2(size);
if (lsize > MAXHBITS)
luaG_runerror(L, "table overflow");
size = twoto(lsize);
@@ -326,9 +324,9 @@
setnilvalue(wgkey(n));
setnilvalue(gval(n));
}
+ t->lsizenode = cast_byte(lsize);
+ t->lastfree = gnode(t, size); /* all positions are free */
}
- t->lsizenode = cast_byte(lsize);
- t->lastfree = gnode(t, size); /* all positions are free */
}
@@ -337,7 +335,7 @@
unsigned int i;
int j;
unsigned int oldasize = t->sizearray;
- int oldhsize = t->lsizenode;
+ int oldhsize = allocsizenode(t);
Node *nold = t->node; /* save old hash ... */
if (nasize > oldasize) /* array part must grow? */
setarrayvector(L, t, nasize);
@@ -354,7 +352,7 @@
luaM_reallocvector(L, t->array, oldasize, nasize, TValue);
}
/* re-insert elements from hash part */
- for (j = twoto(oldhsize) - 1; j >= 0; j--) {
+ for (j = oldhsize - 1; j >= 0; j--) {
Node *old = nold + j;
if (!ttisnil(gval(old))) {
/* doesn't need barrier/invalidate cache, as entry was
@@ -362,13 +360,13 @@
setobjt2t(L, luaH_set(L, t, gkey(old)), gval(old));
}
}
- if (!isdummy(nold))
- luaM_freearray(L, nold, cast(size_t, twoto(oldhsize))); /* free old hash */
+ if (oldhsize > 0) /* not the dummy node? */
+ luaM_freearray(L, nold, cast(size_t, oldhsize)); /* free old hash */
}
void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize) {
- int nsize = isdummy(t->node) ? 0 : sizenode(t);
+ int nsize = allocsizenode(t);
luaH_resize(L, t, nasize, nsize);
}
@@ -414,7 +412,7 @@
void luaH_free (lua_State *L, Table *t) {
- if (!isdummy(t->node))
+ if (!isdummy(t))
luaM_freearray(L, t->node, cast(size_t, sizenode(t)));
luaM_freearray(L, t->array, t->sizearray);
luaM_free(L, t);
@@ -422,10 +420,12 @@
static Node *getfreepos (Table *t) {
- while (t->lastfree > t->node) {
- t->lastfree--;
- if (ttisnil(gkey(t->lastfree)))
- return t->lastfree;
+ if (!isdummy(t)) {
+ while (t->lastfree > t->node) {
+ t->lastfree--;
+ if (ttisnil(gkey(t->lastfree)))
+ return t->lastfree;
+ }
}
return NULL; /* could not find a free place */
}
@@ -445,7 +445,7 @@
if (ttisnil(key)) luaG_runerror(L, "table index is nil");
else if (ttisfloat(key)) {
lua_Integer k;
- if (luaV_tointeger(key, &k, 0)) { /* index is int? */
+ if (luaV_tointeger(key, &k, 0)) { /* does index fit in an integer? */
setivalue(&aux, k);
key = &aux; /* insert it as an integer */
}
@@ -453,7 +453,7 @@
luaG_runerror(L, "table index is NaN");
}
mp = mainposition(t, key);
- if (!ttisnil(gval(mp)) || isdummy(mp)) { /* main position is taken? */
+ if (!ttisnil(gval(mp)) || isdummy(t)) { /* main position is taken? */
Node *othern;
Node *f = getfreepos(t); /* get a free place */
if (f == NULL) { /* cannot find a free place? */
@@ -461,7 +461,7 @@
/* whatever called 'newkey' takes care of TM cache */
return luaH_set(L, t, key); /* insert key into grown table */
}
- lua_assert(!isdummy(f));
+ lua_assert(!isdummy(t));
othern = mainposition(t, gkey(mp));
if (othern != mp) { /* is colliding node out of its main position? */
/* yes; move colliding node into free position */
@@ -651,7 +651,7 @@
return i;
}
/* else must find a boundary in hash part */
- else if (isdummy(t->node)) /* hash part is empty? */
+ else if (isdummy(t)) /* hash part is empty? */
return j; /* that is easy... */
else return unbound_search(t, j);
}
@@ -664,6 +664,6 @@
return mainposition(t, key);
}
-int luaH_isdummy (Node *n) { return isdummy(n); }
+int luaH_isdummy (const Table *t) { return isdummy(t); }
#endif
=== modified file 'src/third_party/eris/ltable.h'
--- src/third_party/eris/ltable.h 2016-08-04 15:49:05 +0000
+++ src/third_party/eris/ltable.h 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: ltable.h,v 2.21 2015/11/03 15:47:30 roberto Exp $
+** $Id: ltable.h,v 2.23 2016/12/22 13:08:50 roberto Exp $
** Lua tables (hash)
** See Copyright Notice in lua.h
*/
@@ -9,41 +9,58 @@
#include "lobject.h"
-#define gnode(t, i) (&(t)->node[i])
-#define gval(n) (&(n)->i_val)
-#define gnext(n) ((n)->i_key.nk.next)
+
+#define gnode(t,i) (&(t)->node[i])
+#define gval(n) (&(n)->i_val)
+#define gnext(n) ((n)->i_key.nk.next)
+
/* 'const' to avoid wrong writings that can mess up field 'next' */
-#define gkey(n) cast(const TValue*, (&(n)->i_key.tvk))
+#define gkey(n) cast(const TValue*, (&(n)->i_key.tvk))
/*
** writable version of 'gkey'; allows updates to individual fields,
** but not to the whole (which has incompatible type)
*/
-#define wgkey(n) (&(n)->i_key.nk)
-
-#define invalidateTMcache(t) ((t)->flags = 0)
+#define wgkey(n) (&(n)->i_key.nk)
+
+#define invalidateTMcache(t) ((t)->flags = 0)
+
+
+/* true when 't' is using 'dummynode' as its hash part */
+#define isdummy(t) ((t)->lastfree == NULL)
+
+
+/* allocated size for hash nodes */
+#define allocsizenode(t) (isdummy(t) ? 0 : sizenode(t))
+
/* returns the key, given the value of a table entry */
-#define keyfromval(v) (gkey(cast(Node*, cast(char*, (v)) - offsetof(Node, i_val))))
-
-LUAI_FUNC const TValue* luaH_getint(Table* t, lua_Integer key);
-LUAI_FUNC void luaH_setint(lua_State* L, Table* t, lua_Integer key, TValue* value);
-LUAI_FUNC const TValue* luaH_getshortstr(Table* t, TString* key);
-LUAI_FUNC const TValue* luaH_getstr(Table* t, TString* key);
-LUAI_FUNC const TValue* luaH_get(Table* t, const TValue* key);
-LUAI_FUNC TValue* luaH_newkey(lua_State* L, Table* t, const TValue* key);
-LUAI_FUNC TValue* luaH_set(lua_State* L, Table* t, const TValue* key);
-LUAI_FUNC Table* luaH_new(lua_State* L);
-LUAI_FUNC void luaH_resize(lua_State* L, Table* t, unsigned int nasize, unsigned int nhsize);
-LUAI_FUNC void luaH_resizearray(lua_State* L, Table* t, unsigned int nasize);
-LUAI_FUNC void luaH_free(lua_State* L, Table* t);
-LUAI_FUNC int luaH_next(lua_State* L, Table* t, StkId key);
-LUAI_FUNC int luaH_getn(Table* t);
+#define keyfromval(v) \
+ (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val))))
+
+
+LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key);
+LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key,
+ TValue *value);
+LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key);
+LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
+LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
+LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key);
+LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key);
+LUAI_FUNC Table *luaH_new (lua_State *L);
+LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize,
+ unsigned int nhsize);
+LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize);
+LUAI_FUNC void luaH_free (lua_State *L, Table *t);
+LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key);
+LUAI_FUNC int luaH_getn (Table *t);
+
#if defined(LUA_DEBUG)
-LUAI_FUNC Node* luaH_mainposition(const Table* t, const TValue* key);
-LUAI_FUNC int luaH_isdummy(Node* n);
+LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
+LUAI_FUNC int luaH_isdummy (const Table *t);
#endif
+
#endif
=== modified file 'src/third_party/eris/ltablib.c'
--- src/third_party/eris/ltablib.c 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/ltablib.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: ltablib.c,v 1.90 2015/11/25 12:48:57 roberto Exp $
+** $Id: ltablib.c,v 1.93 2016/02/25 19:41:54 roberto Exp $
** Library for Table Manipulation
** See Copyright Notice in lua.h
*/
@@ -53,7 +53,7 @@
lua_pop(L, n); /* pop metatable and tested metamethods */
}
else
- luaL_argerror(L, arg, "table expected"); /* force an error */
+ luaL_checktype(L, arg, LUA_TTABLE); /* force an error */
}
}
@@ -139,7 +139,7 @@
n = e - f + 1; /* number of elements to move */
luaL_argcheck(L, t <= LUA_MAXINTEGER - n + 1, 4,
"destination wrap around");
- if (t > e || t <= f || tt != 1) {
+ if (t > e || t <= f || (tt != 1 && !lua_compare(L, 1, tt, LUA_OPEQ))) {
for (i = 0; i < n; i++) {
lua_geti(L, 1, f + i);
lua_seti(L, tt, t + i);
@@ -152,7 +152,7 @@
}
}
}
- lua_pushvalue(L, tt); /* return "to table" */
+ lua_pushvalue(L, tt); /* return destination table */
return 1;
}
@@ -172,7 +172,7 @@
size_t lsep;
const char *sep = luaL_optlstring(L, 2, "", &lsep);
lua_Integer i = luaL_optinteger(L, 3, 1);
- last = luaL_opt(L, luaL_checkinteger, 4, last);
+ last = luaL_optinteger(L, 4, last);
luaL_buffinit(L, &b);
for (; i < last; i++) {
addfield(L, &b, i);
@@ -232,6 +232,10 @@
*/
+/* type for array indices */
+typedef unsigned int IdxT;
+
+
/*
** Produce a "random" 'unsigned int' to randomize pivot choice. This
** macro is used only when 'sort' detects a big imbalance in the result
@@ -270,7 +274,7 @@
#define RANLIMIT 100u
-static void set2 (lua_State *L, unsigned int i, unsigned int j) {
+static void set2 (lua_State *L, IdxT i, IdxT j) {
lua_seti(L, 1, i);
lua_seti(L, 1, j);
}
@@ -303,10 +307,9 @@
** Pos-condition: a[lo .. i - 1] <= a[i] == P <= a[i + 1 .. up]
** returns 'i'.
*/
-static unsigned int partition (lua_State *L, unsigned int lo,
- unsigned int up) {
- unsigned int i = lo; /* will be incremented before first use */
- unsigned int j = up - 1; /* will be decremented before first use */
+static IdxT partition (lua_State *L, IdxT lo, IdxT up) {
+ IdxT i = lo; /* will be incremented before first use */
+ IdxT j = up - 1; /* will be decremented before first use */
/* loop invariant: a[lo .. i] <= P <= a[j .. up] */
for (;;) {
/* next loop: repeat ++i while a[i] < P */
@@ -340,10 +343,9 @@
** Choose an element in the middle (2nd-3th quarters) of [lo,up]
** "randomized" by 'rnd'
*/
-static unsigned int choosePivot (unsigned int lo, unsigned int up,
- unsigned int rnd) {
- unsigned int r4 = (unsigned int)(up - lo) / 4u; /* range/4 */
- unsigned int p = rnd % (r4 * 2) + (lo + r4);
+static IdxT choosePivot (IdxT lo, IdxT up, unsigned int rnd) {
+ IdxT r4 = (up - lo) / 4; /* range/4 */
+ IdxT p = rnd % (r4 * 2) + (lo + r4);
lua_assert(lo + r4 <= p && p <= up - r4);
return p;
}
@@ -352,11 +354,11 @@
/*
** QuickSort algorithm (recursive function)
*/
-static void auxsort (lua_State *L, unsigned int lo, unsigned int up,
+static void auxsort (lua_State *L, IdxT lo, IdxT up,
unsigned int rnd) {
while (lo < up) { /* loop for tail recursion */
- unsigned int p; /* Pivot index */
- unsigned int n; /* to be used later */
+ IdxT p; /* Pivot index */
+ IdxT n; /* to be used later */
/* sort elements 'lo', 'p', and 'up' */
lua_geti(L, 1, lo);
lua_geti(L, 1, up);
@@ -400,7 +402,7 @@
n = up - p; /* size of smaller interval */
up = p - 1; /* tail call for [lo .. p - 1] (lower interval) */
}
- if ((up - lo) / 128u > n) /* partition too imbalanced? */
+ if ((up - lo) / 128 > n) /* partition too imbalanced? */
rnd = l_randomizePivot(); /* try a new randomization */
} /* tail call auxsort(L, lo, up, rnd) */
}
@@ -410,11 +412,10 @@
lua_Integer n = aux_getn(L, 1, TAB_RW);
if (n > 1) { /* non-trivial interval? */
luaL_argcheck(L, n < INT_MAX, 1, "array too big");
- luaL_checkstack(L, 40, ""); /* assume array is smaller than 2^40 */
if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */
luaL_checktype(L, 2, LUA_TFUNCTION); /* must be a function */
lua_settop(L, 2); /* make sure there are two arguments */
- auxsort(L, 1, (unsigned int)n, 0u);
+ auxsort(L, 1, (IdxT)n, 0);
}
return 0;
}
=== modified file 'src/third_party/eris/ltm.c'
--- src/third_party/eris/ltm.c 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/ltm.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: ltm.c,v 2.36 2015/11/03 15:47:30 roberto Exp $
+** $Id: ltm.c,v 2.38 2016/12/22 13:08:50 roberto Exp $
** Tag methods
** See Copyright Notice in lua.h
*/
@@ -15,7 +15,7 @@
#include "lua.h"
#include "ldebug.h"
-#include "ldo.h"
+#include "ldo.h"
#include "lobject.h"
#include "lstate.h"
#include "lstring.h"
@@ -83,6 +83,22 @@
}
+/*
+** Return the name of the type of an object. For tables and userdata
+** with metatable, use their '__name' metafield, if present.
+*/
+const char *luaT_objtypename (lua_State *L, const TValue *o) {
+ Table *mt;
+ if ((ttistable(o) && (mt = hvalue(o)->metatable) != NULL) ||
+ (ttisfulluserdata(o) && (mt = uvalue(o)->metatable) != NULL)) {
+ const TValue *name = luaH_getshortstr(mt, luaS_new(L, "__name"));
+ if (ttisstring(name)) /* is '__name' a string? */
+ return getstr(tsvalue(name)); /* use it as type name */
+ }
+ return ttypename(ttnov(o)); /* else use standard type name */
+}
+
+
void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1,
const TValue *p2, TValue *p3, int hasres) {
ptrdiff_t result = savestack(L, p3);
=== modified file 'src/third_party/eris/ltm.h'
--- src/third_party/eris/ltm.h 2016-08-04 15:49:05 +0000
+++ src/third_party/eris/ltm.h 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: ltm.h,v 2.21 2014/10/25 11:50:46 roberto Exp $
+** $Id: ltm.h,v 2.22 2016/02/26 19:20:15 roberto Exp $
** Tag methods
** See Copyright Notice in lua.h
*/
@@ -7,60 +7,70 @@
#ifndef ltm_h
#define ltm_h
+
#include "lobject.h"
+
/*
* WARNING: if you change the order of this enumeration,
* grep "ORDER TM" and "ORDER OP"
*/
typedef enum {
- TM_INDEX,
- TM_NEWINDEX,
- TM_GC,
- TM_MODE,
- TM_LEN,
- TM_EQ, /* last tag method with fast access */
- TM_ADD,
- TM_SUB,
- TM_MUL,
- TM_MOD,
- TM_POW,
- TM_DIV,
- TM_IDIV,
- TM_BAND,
- TM_BOR,
- TM_BXOR,
- TM_SHL,
- TM_SHR,
- TM_UNM,
- TM_BNOT,
- TM_LT,
- TM_LE,
- TM_CONCAT,
- TM_CALL,
- TM_N /* number of elements in the enum */
+ TM_INDEX,
+ TM_NEWINDEX,
+ TM_GC,
+ TM_MODE,
+ TM_LEN,
+ TM_EQ, /* last tag method with fast access */
+ TM_ADD,
+ TM_SUB,
+ TM_MUL,
+ TM_MOD,
+ TM_POW,
+ TM_DIV,
+ TM_IDIV,
+ TM_BAND,
+ TM_BOR,
+ TM_BXOR,
+ TM_SHL,
+ TM_SHR,
+ TM_UNM,
+ TM_BNOT,
+ TM_LT,
+ TM_LE,
+ TM_CONCAT,
+ TM_CALL,
+ TM_N /* number of elements in the enum */
} TMS;
-#define gfasttm(g, et, e) \
- ((et) == NULL ? NULL : ((et)->flags & (1u << (e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
-
-#define fasttm(l, et, e) gfasttm(G(l), et, e)
-
-#define ttypename(x) luaT_typenames_[(x) + 1]
-#define objtypename(x) ttypename(ttnov(x))
-
-LUAI_DDEC const char* const luaT_typenames_[LUA_TOTALTAGS];
-
-LUAI_FUNC const TValue* luaT_gettm(Table* events, TMS event, TString* ename);
-LUAI_FUNC const TValue* luaT_gettmbyobj(lua_State* L, const TValue* o, TMS event);
-LUAI_FUNC void luaT_init(lua_State* L);
-
-LUAI_FUNC void luaT_callTM(
- lua_State* L, const TValue* f, const TValue* p1, const TValue* p2, TValue* p3, int hasres);
-LUAI_FUNC int
-luaT_callbinTM(lua_State* L, const TValue* p1, const TValue* p2, StkId res, TMS event);
-LUAI_FUNC void
-luaT_trybinTM(lua_State* L, const TValue* p1, const TValue* p2, StkId res, TMS event);
-LUAI_FUNC int luaT_callorderTM(lua_State* L, const TValue* p1, const TValue* p2, TMS event);
+
+
+#define gfasttm(g,et,e) ((et) == NULL ? NULL : \
+ ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
+
+#define fasttm(l,et,e) gfasttm(G(l), et, e)
+
+#define ttypename(x) luaT_typenames_[(x) + 1]
+
+LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS];
+
+
+LUAI_FUNC const char *luaT_objtypename (lua_State *L, const TValue *o);
+
+LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
+LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o,
+ TMS event);
+LUAI_FUNC void luaT_init (lua_State *L);
+
+LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1,
+ const TValue *p2, TValue *p3, int hasres);
+LUAI_FUNC int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2,
+ StkId res, TMS event);
+LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2,
+ StkId res, TMS event);
+LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1,
+ const TValue *p2, TMS event);
+
+
#endif
=== modified file 'src/third_party/eris/lua.c'
--- src/third_party/eris/lua.c 2017-11-09 17:37:13 +0000
+++ src/third_party/eris/lua.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: lua.c,v 1.226 2015/08/14 19:11:20 roberto Exp $
+** $Id: lua.c,v 1.230 2017/01/12 17:14:26 roberto Exp $
** Lua stand-alone interpreter
** See Copyright Notice in lua.h
*/
@@ -20,6 +20,7 @@
#include "lualib.h"
+
#if !defined(LUA_PROMPT)
#define LUA_PROMPT "> "
#define LUA_PROMPT2 ">> "
@@ -37,8 +38,7 @@
#define LUA_INIT_VAR "LUA_INIT"
#endif
-#define LUA_INITVARVERSION \
- LUA_INIT_VAR "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR
+#define LUA_INITVARVERSION LUA_INIT_VAR LUA_VERSUFFIX
/*
@@ -55,6 +55,8 @@
#elif defined(LUA_USE_WINDOWS) /* }{ */
#include <io.h>
+#include <windows.h>
+
#define lua_stdin_is_tty() _isatty(_fileno(stdin))
#else /* }{ */
@@ -435,7 +437,7 @@
static int handle_script (lua_State *L, char **argv) {
int status;
const char *fname = argv[0];
- if (strcmp(fname, "-") == 0 && strcmp(argv[-1], "--") != 0) // NOLINT
+ if (strcmp(fname, "-") == 0 && strcmp(argv[-1], "--") != 0)
fname = NULL; /* stdin */
status = luaL_loadfile(L, fname);
if (status == LUA_OK) {
@@ -457,7 +459,7 @@
/*
** Traverses all arguments from 'argv', returning a mask with those
** needed before running any Lua code (or an error code if it finds
-** any invalid argument). 'first' returns the first not-handled argument
+** any invalid argument). 'first' returns the first not-handled argument
** (either the script name or a bad argument in case of error).
*/
static int collectargs (char **argv, int *first) {
@@ -481,7 +483,7 @@
args |= has_E;
break;
case 'i':
- args |= has_i; /* (-i implies -v) *//* FALLTHROUGH */
+ args |= has_i; /* (-i implies -v) *//* FALLTHROUGH */
case 'v':
if (argv[i][2] != '\0') /* extra characters after 1st? */
return has_error; /* invalid option */
@@ -529,6 +531,7 @@
}
+
static int handle_luainit (lua_State *L) {
const char *name = "=" LUA_INITVARVERSION;
const char *init = getenv(name + 1);
=== modified file 'src/third_party/eris/lua.h'
--- src/third_party/eris/lua.h 2017-11-29 17:41:03 +0000
+++ src/third_party/eris/lua.h 2018-07-08 12:35:11 +0000
@@ -1,86 +1,94 @@
/*
-** $Id: lua.h,v 1.329 2015/11/13 17:18:42 roberto Exp $
+** $Id: lua.h,v 1.332 2016/12/22 15:51:20 roberto Exp $
** Lua - A Scripting Language
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
** See Copyright Notice at the end of this file
*/
+
#ifndef lua_h
#define lua_h
#include <stdarg.h>
#include <stddef.h>
+
#include "luaconf.h"
-#ifdef __clang__
-#pragma clang diagnostic ignored "-Wunknown-pragmas"
-#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
-#endif
-
-#define LUA_VERSION_MAJOR "5"
-#define LUA_VERSION_MINOR "3"
-#define LUA_VERSION_NUM 503
-#define LUA_VERSION_RELEASE "2"
-
-#define LUA_VERSION "Lua+Eris " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
-#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
-#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2015 Lua.org, PUC-Rio"
-#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
+
+#define LUA_VERSION_MAJOR "5"
+#define LUA_VERSION_MINOR "3"
+#define LUA_VERSION_NUM 503
+#define LUA_VERSION_RELEASE "4"
+
+#define LUA_VERSION "Lua+Eris " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
+#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
+#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2017 Lua.org, PUC-Rio"
+#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
+
/* mark for precompiled code ('<esc>Lua') */
-#define LUA_SIGNATURE "\x1bLua"
+#define LUA_SIGNATURE "\x1bLua"
/* option for multiple returns in 'lua_pcall' and 'lua_call' */
-#define LUA_MULTRET (-1)
+#define LUA_MULTRET (-1)
+
/*
** Pseudo-indices
** (-LUAI_MAXSTACK is the minimum valid index; we keep some free empty
** space after that to help overflow detection)
*/
-#define LUA_REGISTRYINDEX (-LUAI_MAXSTACK - 1000)
-#define lua_upvalueindex(i) (LUA_REGISTRYINDEX - (i))
+#define LUA_REGISTRYINDEX (-LUAI_MAXSTACK - 1000)
+#define lua_upvalueindex(i) (LUA_REGISTRYINDEX - (i))
+
/* thread status */
-#define LUA_OK 0
-#define LUA_YIELD 1
-#define LUA_ERRRUN 2
-#define LUA_ERRSYNTAX 3
-#define LUA_ERRMEM 4
-#define LUA_ERRGCMM 5
-#define LUA_ERRERR 6
+#define LUA_OK 0
+#define LUA_YIELD 1
+#define LUA_ERRRUN 2
+#define LUA_ERRSYNTAX 3
+#define LUA_ERRMEM 4
+#define LUA_ERRGCMM 5
+#define LUA_ERRERR 6
+
typedef struct lua_State lua_State;
+
/*
** basic types
*/
-#define LUA_TNONE (-1)
-
-#define LUA_TNIL 0
-#define LUA_TBOOLEAN 1
-#define LUA_TLIGHTUSERDATA 2
-#define LUA_TNUMBER 3
-#define LUA_TSTRING 4
-#define LUA_TTABLE 5
-#define LUA_TFUNCTION 6
-#define LUA_TUSERDATA 7
-#define LUA_TTHREAD 8
-
-#define LUA_NUMTAGS 9
+#define LUA_TNONE (-1)
+
+#define LUA_TNIL 0
+#define LUA_TBOOLEAN 1
+#define LUA_TLIGHTUSERDATA 2
+#define LUA_TNUMBER 3
+#define LUA_TSTRING 4
+#define LUA_TTABLE 5
+#define LUA_TFUNCTION 6
+#define LUA_TUSERDATA 7
+#define LUA_TTHREAD 8
+
+#define LUA_NUMTAGS 9
+
+
/* minimum Lua stack available to a C function */
-#define LUA_MINSTACK 20
+#define LUA_MINSTACK 20
+
/* predefined values in the registry */
-#define LUA_RIDX_MAINTHREAD 1
-#define LUA_RIDX_GLOBALS 2
-#define LUA_RIDX_LAST LUA_RIDX_GLOBALS
+#define LUA_RIDX_MAINTHREAD 1
+#define LUA_RIDX_GLOBALS 2
+#define LUA_RIDX_LAST LUA_RIDX_GLOBALS
+
/* type of numbers in Lua */
typedef LUA_NUMBER lua_Number;
+
/* type for integer functions */
typedef LUA_INTEGER lua_Integer;
@@ -90,27 +98,32 @@
/* type for continuation-function contexts */
typedef LUA_KCONTEXT lua_KContext;
+
/*
** Type for C functions registered with Lua
*/
-typedef int (*lua_CFunction)(lua_State* L);
+typedef int (*lua_CFunction) (lua_State *L);
/*
** Type for continuation functions
*/
-typedef int (*lua_KFunction)(lua_State* L, int status, lua_KContext ctx);
+typedef int (*lua_KFunction) (lua_State *L, int status, lua_KContext ctx);
+
/*
** Type for functions that read/write blocks when loading/dumping Lua chunks
*/
-typedef const char* (*lua_Reader)(lua_State* L, void* ud, size_t* sz);
-
-typedef int (*lua_Writer)(lua_State* L, const void* p, size_t sz, void* ud);
+typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
+
+typedef int (*lua_Writer) (lua_State *L, const void *p, size_t sz, void *ud);
+
/*
** Type for memory-allocation functions
*/
-typedef void* (*lua_Alloc)(void* ud, void* ptr, size_t osize, size_t nsize);
+typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
+
+
/*
** generic extra include file
@@ -119,185 +132,203 @@
#include LUA_USER_H
#endif
+
/*
** RCS ident string
*/
extern const char lua_ident[];
+
/*
** state manipulation
*/
-LUA_API lua_State*(lua_newstate)(lua_Alloc f, void* ud);
-LUA_API void(lua_close)(lua_State* L);
-LUA_API lua_State*(lua_newthread)(lua_State* L);
-
-LUA_API lua_CFunction(lua_atpanic)(lua_State* L, lua_CFunction panicf);
-
-LUA_API const lua_Number*(lua_version)(lua_State* L);
+LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
+LUA_API void (lua_close) (lua_State *L);
+LUA_API lua_State *(lua_newthread) (lua_State *L);
+
+LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
+
+
+LUA_API const lua_Number *(lua_version) (lua_State *L);
+
/*
** basic stack manipulation
*/
-LUA_API int(lua_absindex)(lua_State* L, int idx);
-LUA_API int(lua_gettop)(lua_State* L);
-LUA_API void(lua_settop)(lua_State* L, int idx);
-LUA_API void(lua_pushvalue)(lua_State* L, int idx);
-LUA_API void(lua_rotate)(lua_State* L, int idx, int n);
-LUA_API void(lua_copy)(lua_State* L, int fromidx, int toidx);
-LUA_API int(lua_checkstack)(lua_State* L, int n);
-
-LUA_API void(lua_xmove)(lua_State* from, lua_State* to, int n);
+LUA_API int (lua_absindex) (lua_State *L, int idx);
+LUA_API int (lua_gettop) (lua_State *L);
+LUA_API void (lua_settop) (lua_State *L, int idx);
+LUA_API void (lua_pushvalue) (lua_State *L, int idx);
+LUA_API void (lua_rotate) (lua_State *L, int idx, int n);
+LUA_API void (lua_copy) (lua_State *L, int fromidx, int toidx);
+LUA_API int (lua_checkstack) (lua_State *L, int n);
+
+LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n);
+
/*
** access functions (stack -> C)
*/
-LUA_API int(lua_isnumber)(lua_State* L, int idx);
-LUA_API int(lua_isstring)(lua_State* L, int idx);
-LUA_API int(lua_iscfunction)(lua_State* L, int idx);
-LUA_API int(lua_isinteger)(lua_State* L, int idx);
-LUA_API int(lua_isuserdata)(lua_State* L, int idx);
-LUA_API int(lua_type)(lua_State* L, int idx);
-LUA_API const char*(lua_typename)(lua_State* L, int tp);
-
-LUA_API lua_Number(lua_tonumberx)(lua_State* L, int idx, int* isnum);
-LUA_API lua_Integer(lua_tointegerx)(lua_State* L, int idx, int* isnum);
-LUA_API int(lua_toboolean)(lua_State* L, int idx);
-LUA_API const char*(lua_tolstring)(lua_State* L, int idx, size_t* len);
-LUA_API size_t(lua_rawlen)(lua_State* L, int idx);
-LUA_API lua_CFunction(lua_tocfunction)(lua_State* L, int idx);
-LUA_API void*(lua_touserdata)(lua_State* L, int idx);
-LUA_API lua_State*(lua_tothread)(lua_State* L, int idx);
-LUA_API const void*(lua_topointer)(lua_State* L, int idx);
+LUA_API int (lua_isnumber) (lua_State *L, int idx);
+LUA_API int (lua_isstring) (lua_State *L, int idx);
+LUA_API int (lua_iscfunction) (lua_State *L, int idx);
+LUA_API int (lua_isinteger) (lua_State *L, int idx);
+LUA_API int (lua_isuserdata) (lua_State *L, int idx);
+LUA_API int (lua_type) (lua_State *L, int idx);
+LUA_API const char *(lua_typename) (lua_State *L, int tp);
+
+LUA_API lua_Number (lua_tonumberx) (lua_State *L, int idx, int *isnum);
+LUA_API lua_Integer (lua_tointegerx) (lua_State *L, int idx, int *isnum);
+LUA_API int (lua_toboolean) (lua_State *L, int idx);
+LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len);
+LUA_API size_t (lua_rawlen) (lua_State *L, int idx);
+LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx);
+LUA_API void *(lua_touserdata) (lua_State *L, int idx);
+LUA_API lua_State *(lua_tothread) (lua_State *L, int idx);
+LUA_API const void *(lua_topointer) (lua_State *L, int idx);
+
/*
** Comparison and arithmetic functions
*/
-#define LUA_OPADD 0 /* ORDER TM, ORDER OP */
-#define LUA_OPSUB 1
-#define LUA_OPMUL 2
-#define LUA_OPMOD 3
-#define LUA_OPPOW 4
-#define LUA_OPDIV 5
-#define LUA_OPIDIV 6
-#define LUA_OPBAND 7
-#define LUA_OPBOR 8
-#define LUA_OPBXOR 9
-#define LUA_OPSHL 10
-#define LUA_OPSHR 11
-#define LUA_OPUNM 12
-#define LUA_OPBNOT 13
-
-LUA_API void(lua_arith)(lua_State* L, int op);
-
-#define LUA_OPEQ 0
-#define LUA_OPLT 1
-#define LUA_OPLE 2
-
-LUA_API int(lua_rawequal)(lua_State* L, int idx1, int idx2);
-LUA_API int(lua_compare)(lua_State* L, int idx1, int idx2, int op);
+#define LUA_OPADD 0 /* ORDER TM, ORDER OP */
+#define LUA_OPSUB 1
+#define LUA_OPMUL 2
+#define LUA_OPMOD 3
+#define LUA_OPPOW 4
+#define LUA_OPDIV 5
+#define LUA_OPIDIV 6
+#define LUA_OPBAND 7
+#define LUA_OPBOR 8
+#define LUA_OPBXOR 9
+#define LUA_OPSHL 10
+#define LUA_OPSHR 11
+#define LUA_OPUNM 12
+#define LUA_OPBNOT 13
+
+LUA_API void (lua_arith) (lua_State *L, int op);
+
+#define LUA_OPEQ 0
+#define LUA_OPLT 1
+#define LUA_OPLE 2
+
+LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2);
+LUA_API int (lua_compare) (lua_State *L, int idx1, int idx2, int op);
+
/*
** push functions (C -> stack)
*/
-LUA_API void(lua_pushnil)(lua_State* L);
-LUA_API void(lua_pushnumber)(lua_State* L, lua_Number n);
-LUA_API void(lua_pushinteger)(lua_State* L, lua_Integer n);
-LUA_API const char*(lua_pushlstring)(lua_State* L, const char* s, size_t len);
-LUA_API const char*(lua_pushstring)(lua_State* L, const char* s);
-LUA_API const char*(lua_pushvfstring)(lua_State* L, const char* fmt, va_list argp);
-LUA_API const char*(lua_pushfstring)(lua_State* L, const char* fmt, ...);
-LUA_API void(lua_pushcclosure)(lua_State* L, lua_CFunction fn, int n);
-LUA_API void(lua_pushboolean)(lua_State* L, int b);
-LUA_API void(lua_pushlightuserdata)(lua_State* L, void* p);
-LUA_API int(lua_pushthread)(lua_State* L);
+LUA_API void (lua_pushnil) (lua_State *L);
+LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n);
+LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n);
+LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t len);
+LUA_API const char *(lua_pushstring) (lua_State *L, const char *s);
+LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,
+ va_list argp);
+LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);
+LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n);
+LUA_API void (lua_pushboolean) (lua_State *L, int b);
+LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p);
+LUA_API int (lua_pushthread) (lua_State *L);
+
/*
** get functions (Lua -> stack)
*/
-LUA_API int(lua_getglobal)(lua_State* L, const char* name);
-LUA_API int(lua_gettable)(lua_State* L, int idx);
-LUA_API int(lua_getfield)(lua_State* L, int idx, const char* k);
-LUA_API int(lua_geti)(lua_State* L, int idx, lua_Integer n);
-LUA_API int(lua_rawget)(lua_State* L, int idx);
-LUA_API int(lua_rawgeti)(lua_State* L, int idx, lua_Integer n);
-LUA_API int(lua_rawgetp)(lua_State* L, int idx, const void* p);
-
-LUA_API void(lua_createtable)(lua_State* L, int narr, int nrec);
-LUA_API void*(lua_newuserdata)(lua_State* L, size_t sz);
-LUA_API int(lua_getmetatable)(lua_State* L, int objindex);
-LUA_API int(lua_getuservalue)(lua_State* L, int idx);
+LUA_API int (lua_getglobal) (lua_State *L, const char *name);
+LUA_API int (lua_gettable) (lua_State *L, int idx);
+LUA_API int (lua_getfield) (lua_State *L, int idx, const char *k);
+LUA_API int (lua_geti) (lua_State *L, int idx, lua_Integer n);
+LUA_API int (lua_rawget) (lua_State *L, int idx);
+LUA_API int (lua_rawgeti) (lua_State *L, int idx, lua_Integer n);
+LUA_API int (lua_rawgetp) (lua_State *L, int idx, const void *p);
+
+LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec);
+LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz);
+LUA_API int (lua_getmetatable) (lua_State *L, int objindex);
+LUA_API int (lua_getuservalue) (lua_State *L, int idx);
+
/*
** set functions (stack -> Lua)
*/
-LUA_API void(lua_setglobal)(lua_State* L, const char* name);
-LUA_API void(lua_settable)(lua_State* L, int idx);
-LUA_API void(lua_setfield)(lua_State* L, int idx, const char* k);
-LUA_API void(lua_seti)(lua_State* L, int idx, lua_Integer n);
-LUA_API void(lua_rawset)(lua_State* L, int idx);
-LUA_API void(lua_rawseti)(lua_State* L, int idx, lua_Integer n);
-LUA_API void(lua_rawsetp)(lua_State* L, int idx, const void* p);
-LUA_API int(lua_setmetatable)(lua_State* L, int objindex);
-LUA_API void(lua_setuservalue)(lua_State* L, int idx);
+LUA_API void (lua_setglobal) (lua_State *L, const char *name);
+LUA_API void (lua_settable) (lua_State *L, int idx);
+LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k);
+LUA_API void (lua_seti) (lua_State *L, int idx, lua_Integer n);
+LUA_API void (lua_rawset) (lua_State *L, int idx);
+LUA_API void (lua_rawseti) (lua_State *L, int idx, lua_Integer n);
+LUA_API void (lua_rawsetp) (lua_State *L, int idx, const void *p);
+LUA_API int (lua_setmetatable) (lua_State *L, int objindex);
+LUA_API void (lua_setuservalue) (lua_State *L, int idx);
+
/*
** 'load' and 'call' functions (load and run Lua code)
*/
-LUA_API void(lua_callk)(lua_State* L, int nargs, int nresults, lua_KContext ctx, lua_KFunction k);
-#define lua_call(L, n, r) lua_callk(L, (n), (r), 0, NULL)
-
-LUA_API int(lua_pcallk)(
- lua_State* L, int nargs, int nresults, int errfunc, lua_KContext ctx, lua_KFunction k);
-#define lua_pcall(L, n, r, f) lua_pcallk(L, (n), (r), (f), 0, NULL)
-
-LUA_API int(lua_load)(
- lua_State* L, lua_Reader reader, void* dt, const char* chunkname, const char* mode);
-
-LUA_API int(lua_dump)(lua_State* L, lua_Writer writer, void* data, int strip);
+LUA_API void (lua_callk) (lua_State *L, int nargs, int nresults,
+ lua_KContext ctx, lua_KFunction k);
+#define lua_call(L,n,r) lua_callk(L, (n), (r), 0, NULL)
+
+LUA_API int (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc,
+ lua_KContext ctx, lua_KFunction k);
+#define lua_pcall(L,n,r,f) lua_pcallk(L, (n), (r), (f), 0, NULL)
+
+LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt,
+ const char *chunkname, const char *mode);
+
+LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data, int strip);
+
/*
** coroutine functions
*/
-LUA_API int(lua_yieldk)(lua_State* L, int nresults, lua_KContext ctx, lua_KFunction k);
-LUA_API int(lua_resume)(lua_State* L, lua_State* from, int narg);
-LUA_API int(lua_status)(lua_State* L);
-LUA_API int(lua_isyieldable)(lua_State* L);
-
-#define lua_yield(L, n) lua_yieldk(L, (n), 0, NULL)
+LUA_API int (lua_yieldk) (lua_State *L, int nresults, lua_KContext ctx,
+ lua_KFunction k);
+LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg);
+LUA_API int (lua_status) (lua_State *L);
+LUA_API int (lua_isyieldable) (lua_State *L);
+
+#define lua_yield(L,n) lua_yieldk(L, (n), 0, NULL)
+
/*
** garbage-collection function and options
*/
-#define LUA_GCSTOP 0
-#define LUA_GCRESTART 1
-#define LUA_GCCOLLECT 2
-#define LUA_GCCOUNT 3
-#define LUA_GCCOUNTB 4
-#define LUA_GCSTEP 5
-#define LUA_GCSETPAUSE 6
-#define LUA_GCSETSTEPMUL 7
-#define LUA_GCISRUNNING 9
-
-LUA_API int(lua_gc)(lua_State* L, int what, int data);
+#define LUA_GCSTOP 0
+#define LUA_GCRESTART 1
+#define LUA_GCCOLLECT 2
+#define LUA_GCCOUNT 3
+#define LUA_GCCOUNTB 4
+#define LUA_GCSTEP 5
+#define LUA_GCSETPAUSE 6
+#define LUA_GCSETSTEPMUL 7
+#define LUA_GCISRUNNING 9
+
+LUA_API int (lua_gc) (lua_State *L, int what, int data);
+
/*
** miscellaneous functions
*/
-LUA_API int(lua_error)(lua_State* L);
-
-LUA_API int(lua_next)(lua_State* L, int idx);
-
-LUA_API void(lua_concat)(lua_State* L, int n);
-LUA_API void(lua_len)(lua_State* L, int idx);
-
-LUA_API size_t(lua_stringtonumber)(lua_State* L, const char* s);
-
-LUA_API lua_Alloc(lua_getallocf)(lua_State* L, void** ud);
-LUA_API void(lua_setallocf)(lua_State* L, lua_Alloc f, void* ud);
+LUA_API int (lua_error) (lua_State *L);
+
+LUA_API int (lua_next) (lua_State *L, int idx);
+
+LUA_API void (lua_concat) (lua_State *L, int n);
+LUA_API void (lua_len) (lua_State *L, int idx);
+
+LUA_API size_t (lua_stringtonumber) (lua_State *L, const char *s);
+
+LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
+LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud);
+
+
/*
** {==============================================================
@@ -305,42 +336,45 @@
** ===============================================================
*/
-#define lua_getextraspace(L) ((void*)((char*)(L)-LUA_EXTRASPACE))
-
-#define lua_tonumber(L, i) lua_tonumberx(L, (i), NULL)
-#define lua_tointeger(L, i) lua_tointegerx(L, (i), NULL)
-
-#define lua_pop(L, n) lua_settop(L, -(n)-1)
-
-#define lua_newtable(L) lua_createtable(L, 0, 0)
-
-#define lua_register(L, n, f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
-
-#define lua_pushcfunction(L, f) lua_pushcclosure(L, (f), 0)
-
-#define lua_isfunction(L, n) (lua_type(L, (n)) == LUA_TFUNCTION)
-#define lua_istable(L, n) (lua_type(L, (n)) == LUA_TTABLE)
-#define lua_islightuserdata(L, n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
-#define lua_isnil(L, n) (lua_type(L, (n)) == LUA_TNIL)
-#define lua_isboolean(L, n) (lua_type(L, (n)) == LUA_TBOOLEAN)
-#define lua_isthread(L, n) (lua_type(L, (n)) == LUA_TTHREAD)
-#define lua_isnone(L, n) (lua_type(L, (n)) == LUA_TNONE)
-#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
-
-#define lua_pushliteral(L, s) lua_pushstring(L, "" s)
-
-#define lua_pushglobaltable(L) lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS)
-
-#define lua_tostring(L, i) lua_tolstring(L, (i), NULL)
-
-#define lua_insert(L, idx) lua_rotate(L, (idx), 1)
-
-#define lua_remove(L, idx) (lua_rotate(L, (idx), -1), lua_pop(L, 1))
-
-#define lua_replace(L, idx) (lua_copy(L, -1, (idx)), lua_pop(L, 1))
+#define lua_getextraspace(L) ((void *)((char *)(L) - LUA_EXTRASPACE))
+
+#define lua_tonumber(L,i) lua_tonumberx(L,(i),NULL)
+#define lua_tointeger(L,i) lua_tointegerx(L,(i),NULL)
+
+#define lua_pop(L,n) lua_settop(L, -(n)-1)
+
+#define lua_newtable(L) lua_createtable(L, 0, 0)
+
+#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
+
+#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0)
+
+#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION)
+#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE)
+#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
+#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL)
+#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN)
+#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD)
+#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE)
+#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
+
+#define lua_pushliteral(L, s) lua_pushstring(L, "" s)
+
+#define lua_pushglobaltable(L) \
+ ((void)lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS))
+
+#define lua_tostring(L,i) lua_tolstring(L, (i), NULL)
+
+
+#define lua_insert(L,idx) lua_rotate(L, (idx), 1)
+
+#define lua_remove(L,idx) (lua_rotate(L, (idx), -1), lua_pop(L, 1))
+
+#define lua_replace(L,idx) (lua_copy(L, -1, (idx)), lua_pop(L, 1))
/* }============================================================== */
+
/*
** {==============================================================
** compatibility macros for unsigned conversions
@@ -348,9 +382,9 @@
*/
#if defined(LUA_COMPAT_APIINTCASTS)
-#define lua_pushunsigned(L, n) lua_pushinteger(L, (lua_Integer)(n))
-#define lua_tounsignedx(L, i, is) ((lua_Unsigned)lua_tointegerx(L, i, is))
-#define lua_tounsigned(L, i) lua_tounsignedx(L, (i), NULL)
+#define lua_pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n))
+#define lua_tounsignedx(L,i,is) ((lua_Unsigned)lua_tointegerx(L,i,is))
+#define lua_tounsigned(L,i) lua_tounsignedx(L,(i),NULL)
#endif
/* }============================================================== */
@@ -361,65 +395,72 @@
** =======================================================================
*/
+
/*
** Event codes
*/
-#define LUA_HOOKCALL 0
-#define LUA_HOOKRET 1
-#define LUA_HOOKLINE 2
-#define LUA_HOOKCOUNT 3
+#define LUA_HOOKCALL 0
+#define LUA_HOOKRET 1
+#define LUA_HOOKLINE 2
+#define LUA_HOOKCOUNT 3
#define LUA_HOOKTAILCALL 4
+
/*
** Event masks
*/
-#define LUA_MASKCALL (1 << LUA_HOOKCALL)
-#define LUA_MASKRET (1 << LUA_HOOKRET)
-#define LUA_MASKLINE (1 << LUA_HOOKLINE)
-#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT)
-
-typedef struct lua_Debug lua_Debug; /* activation record */
+#define LUA_MASKCALL (1 << LUA_HOOKCALL)
+#define LUA_MASKRET (1 << LUA_HOOKRET)
+#define LUA_MASKLINE (1 << LUA_HOOKLINE)
+#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT)
+
+typedef struct lua_Debug lua_Debug; /* activation record */
+
/* Functions to be called by the debugger in specific events */
-typedef void (*lua_Hook)(lua_State* L, lua_Debug* ar);
-
-LUA_API int(lua_getstack)(lua_State* L, int level, lua_Debug* ar);
-LUA_API int(lua_getinfo)(lua_State* L, const char* what, lua_Debug* ar);
-LUA_API const char*(lua_getlocal)(lua_State* L, const lua_Debug* ar, int n);
-LUA_API const char*(lua_setlocal)(lua_State* L, const lua_Debug* ar, int n);
-LUA_API const char*(lua_getupvalue)(lua_State* L, int funcindex, int n);
-LUA_API const char*(lua_setupvalue)(lua_State* L, int funcindex, int n);
-
-LUA_API void*(lua_upvalueid)(lua_State* L, int fidx, int n);
-LUA_API void(lua_upvaluejoin)(lua_State* L, int fidx1, int n1, int fidx2, int n2);
-
-LUA_API void(lua_sethook)(lua_State* L, lua_Hook func, int mask, int count);
-LUA_API lua_Hook(lua_gethook)(lua_State* L);
-LUA_API int(lua_gethookmask)(lua_State* L);
-LUA_API int(lua_gethookcount)(lua_State* L);
+typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
+
+
+LUA_API int (lua_getstack) (lua_State *L, int level, lua_Debug *ar);
+LUA_API int (lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar);
+LUA_API const char *(lua_getlocal) (lua_State *L, const lua_Debug *ar, int n);
+LUA_API const char *(lua_setlocal) (lua_State *L, const lua_Debug *ar, int n);
+LUA_API const char *(lua_getupvalue) (lua_State *L, int funcindex, int n);
+LUA_API const char *(lua_setupvalue) (lua_State *L, int funcindex, int n);
+
+LUA_API void *(lua_upvalueid) (lua_State *L, int fidx, int n);
+LUA_API void (lua_upvaluejoin) (lua_State *L, int fidx1, int n1,
+ int fidx2, int n2);
+
+LUA_API void (lua_sethook) (lua_State *L, lua_Hook func, int mask, int count);
+LUA_API lua_Hook (lua_gethook) (lua_State *L);
+LUA_API int (lua_gethookmask) (lua_State *L);
+LUA_API int (lua_gethookcount) (lua_State *L);
+
struct lua_Debug {
- int event;
- const char* name; /* (n) */
- const char* namewhat; /* (n) 'global', 'local', 'field', 'method' */
- const char* what; /* (S) 'Lua', 'C', 'main', 'tail' */
- const char* source; /* (S) */
- int currentline; /* (l) */
- int linedefined; /* (S) */
- int lastlinedefined; /* (S) */
- unsigned char nups; /* (u) number of upvalues */
- unsigned char nparams; /* (u) number of parameters */
- char isvararg; /* (u) */
- char istailcall; /* (t) */
- char short_src[LUA_IDSIZE]; /* (S) */
- /* private part */
- struct CallInfo* i_ci; /* active function */
+ int event;
+ const char *name; /* (n) */
+ const char *namewhat; /* (n) 'global', 'local', 'field', 'method' */
+ const char *what; /* (S) 'Lua', 'C', 'main', 'tail' */
+ const char *source; /* (S) */
+ int currentline; /* (l) */
+ int linedefined; /* (S) */
+ int lastlinedefined; /* (S) */
+ unsigned char nups; /* (u) number of upvalues */
+ unsigned char nparams;/* (u) number of parameters */
+ char isvararg; /* (u) */
+ char istailcall; /* (t) */
+ char short_src[LUA_IDSIZE]; /* (S) */
+ /* private part */
+ struct CallInfo *i_ci; /* active function */
};
/* }====================================================================== */
+
/******************************************************************************
-* Copyright (C) 1994-2015 Lua.org, PUC-Rio.
+* Copyright (C) 1994-2017 Lua.org, PUC-Rio.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@@ -441,4 +482,5 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
******************************************************************************/
+
#endif
=== modified file 'src/third_party/eris/luaconf.h'
--- src/third_party/eris/luaconf.h 2016-08-04 15:49:05 +0000
+++ src/third_party/eris/luaconf.h 2018-07-08 12:35:11 +0000
@@ -1,21 +1,24 @@
/*
-** $Id: luaconf.h,v 1.254 2015/10/21 18:17:40 roberto Exp $
+** $Id: luaconf.h,v 1.259 2016/12/22 13:08:50 roberto Exp $
** Configuration file for Lua
** See Copyright Notice in lua.h
*/
+
#ifndef luaconf_h
#define luaconf_h
#include <limits.h>
#include <stddef.h>
+
/*
** ===================================================================
** Search for "@@" to find all configurable definitions.
** ===================================================================
*/
+
/*
** {====================================================================
** System Configuration: macros to adapt (if needed) Lua to some
@@ -32,6 +35,7 @@
*/
/* #define LUA_32BITS */
+
/*
@@ LUA_USE_C89 controls the use of non-ISO-C89 features.
** Define it if you want Lua to avoid the use of a few C99 features
@@ -39,30 +43,35 @@
*/
/* #define LUA_USE_C89 */
+
/*
** By default, Lua on Windows use (some) specific Windows features
*/
#if !defined(LUA_USE_C89) && defined(_WIN32) && !defined(_WIN32_WCE)
-#define LUA_USE_WINDOWS /* enable goodies for regular Windows */
+#define LUA_USE_WINDOWS /* enable goodies for regular Windows */
#endif
+
#if defined(LUA_USE_WINDOWS)
-#define LUA_DL_DLL /* enable support for DLL */
-#define LUA_USE_C89 /* broadly, Windows is C89 */
+#define LUA_DL_DLL /* enable support for DLL */
+#define LUA_USE_C89 /* broadly, Windows is C89 */
#endif
+
#if defined(LUA_USE_LINUX)
#define LUA_USE_POSIX
-#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
-#define LUA_USE_READLINE /* needs some extra libraries */
+#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
+#define LUA_USE_READLINE /* needs some extra libraries */
#endif
+
#if defined(LUA_USE_MACOSX)
#define LUA_USE_POSIX
-#define LUA_USE_DLOPEN /* MacOS does not need -ldl */
-#define LUA_USE_READLINE /* needs an extra library: -lreadline */
+#define LUA_USE_DLOPEN /* MacOS does not need -ldl */
+#define LUA_USE_READLINE /* needs an extra library: -lreadline */
#endif
+
/*
@@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for
** C89 ('long' and 'double'); Windows always has '__int64', so it does
@@ -72,17 +81,20 @@
#define LUA_C89_NUMBERS
#endif
+
+
/*
@@ LUAI_BITSINT defines the (minimum) number of bits in an 'int'.
*/
/* avoid undefined shifts */
#if ((INT_MAX >> 15) >> 15) >= 1
-#define LUAI_BITSINT 32
+#define LUAI_BITSINT 32
#else
/* 'int' always must have at least 16 bits */
-#define LUAI_BITSINT 16
+#define LUAI_BITSINT 16
#endif
+
/*
@@ LUA_INT_TYPE defines the type for Lua integers.
@@ LUA_FLOAT_TYPE defines the type for Lua floats.
@@ -94,48 +106,52 @@
*/
/* predefined options for LUA_INT_TYPE */
-#define LUA_INT_INT 1
-#define LUA_INT_LONG 2
-#define LUA_INT_LONGLONG 3
+#define LUA_INT_INT 1
+#define LUA_INT_LONG 2
+#define LUA_INT_LONGLONG 3
/* predefined options for LUA_FLOAT_TYPE */
-#define LUA_FLOAT_FLOAT 1
-#define LUA_FLOAT_DOUBLE 2
-#define LUA_FLOAT_LONGDOUBLE 3
+#define LUA_FLOAT_FLOAT 1
+#define LUA_FLOAT_DOUBLE 2
+#define LUA_FLOAT_LONGDOUBLE 3
-#if defined(LUA_32BITS) /* { */
- /*
- ** 32-bit integers and 'float'
- */
+#if defined(LUA_32BITS) /* { */
+/*
+** 32-bit integers and 'float'
+*/
#if LUAI_BITSINT >= 32 /* use 'int' if big enough */
-#define LUA_INT_TYPE LUA_INT_INT
-#else /* otherwise use 'long' */
-#define LUA_INT_TYPE LUA_INT_LONG
+#define LUA_INT_TYPE LUA_INT_INT
+#else /* otherwise use 'long' */
+#define LUA_INT_TYPE LUA_INT_LONG
#endif
-#define LUA_FLOAT_TYPE LUA_FLOAT_FLOAT
+#define LUA_FLOAT_TYPE LUA_FLOAT_FLOAT
-#elif defined(LUA_C89_NUMBERS) /* }{ */
+#elif defined(LUA_C89_NUMBERS) /* }{ */
/*
** largest types available for C89 ('long' and 'double')
*/
-#define LUA_INT_TYPE LUA_INT_LONG
-#define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE
-
-#endif /* } */
+#define LUA_INT_TYPE LUA_INT_LONG
+#define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE
+
+#endif /* } */
+
/*
** default configuration for 64-bit Lua ('long long' and 'double')
*/
#if !defined(LUA_INT_TYPE)
-#define LUA_INT_TYPE LUA_INT_LONGLONG
+#define LUA_INT_TYPE LUA_INT_LONGLONG
#endif
#if !defined(LUA_FLOAT_TYPE)
-#define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE
+#define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE
#endif
/* }================================================================== */
+
+
+
/*
** {==================================================================
** Configuration for Paths.
@@ -143,6 +159,18 @@
*/
/*
+** LUA_PATH_SEP is the character that separates templates in a path.
+** LUA_PATH_MARK is the string that marks the substitution points in a
+** template.
+** LUA_EXEC_DIR in a Windows path is replaced by the executable's
+** directory.
+*/
+#define LUA_PATH_SEP ";"
+#define LUA_PATH_MARK "?"
+#define LUA_EXEC_DIR "!"
+
+
+/*
@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
** Lua libraries.
@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
@@ -151,37 +179,38 @@
** hierarchy or if you want to install your libraries in
** non-conventional directories.
*/
-#define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
-#if defined(_WIN32) /* { */
- /*
- ** In Windows, any exclamation mark ('!') in the path is replaced by the
- ** path of the directory of the executable file of the current process.
- */
-#define LUA_LDIR "!\\lua\\"
-#define LUA_CDIR "!\\"
-#define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\"
-#define LUA_PATH_DEFAULT \
- LUA_LDIR "?.lua;" LUA_LDIR "?\\init.lua;" LUA_CDIR "?.lua;" LUA_CDIR "?\\init.lua;" LUA_SHRDIR \
- "?.lua;" LUA_SHRDIR "?\\init.lua;" \
- ".\\?.lua;" \
- ".\\?\\init.lua"
-#define LUA_CPATH_DEFAULT \
- LUA_CDIR "?.dll;" LUA_CDIR "..\\lib\\lua\\" LUA_VDIR "\\?.dll;" LUA_CDIR "loadall.dll;" \
- ".\\?.dll"
-
-#else /* }{ */
-
-#define LUA_ROOT "/usr/local/"
-#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/"
-#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/"
-#define LUA_PATH_DEFAULT \
- LUA_LDIR "?.lua;" LUA_LDIR "?/init.lua;" LUA_CDIR "?.lua;" LUA_CDIR "?/init.lua;" \
- "./?.lua;" \
- "./?/init.lua"
-#define LUA_CPATH_DEFAULT \
- LUA_CDIR "?.so;" LUA_CDIR "loadall.so;" \
- "./?.so"
-#endif /* } */
+#define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
+#if defined(_WIN32) /* { */
+/*
+** In Windows, any exclamation mark ('!') in the path is replaced by the
+** path of the directory of the executable file of the current process.
+*/
+#define LUA_LDIR "!\\lua\\"
+#define LUA_CDIR "!\\"
+#define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\"
+#define LUA_PATH_DEFAULT \
+ LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
+ LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \
+ LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \
+ ".\\?.lua;" ".\\?\\init.lua"
+#define LUA_CPATH_DEFAULT \
+ LUA_CDIR"?.dll;" \
+ LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \
+ LUA_CDIR"loadall.dll;" ".\\?.dll"
+
+#else /* }{ */
+
+#define LUA_ROOT "/usr/local/"
+#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/"
+#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/"
+#define LUA_PATH_DEFAULT \
+ LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
+ LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \
+ "./?.lua;" "./?/init.lua"
+#define LUA_CPATH_DEFAULT \
+ LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so"
+#endif /* } */
+
/*
@@ LUA_DIRSEP is the directory separator (for submodules).
@@ -189,13 +218,14 @@
** and is not Windows. (On Windows Lua automatically uses "\".)
*/
#if defined(_WIN32)
-#define LUA_DIRSEP "\\"
+#define LUA_DIRSEP "\\"
#else
-#define LUA_DIRSEP "/"
+#define LUA_DIRSEP "/"
#endif
/* }================================================================== */
+
/*
** {==================================================================
** Marks for exported symbols in the C code
@@ -211,23 +241,25 @@
** the libraries, you may want to use the following definition (define
** LUA_BUILD_AS_DLL to get it).
*/
-#if defined(LUA_BUILD_AS_DLL) /* { */
+#if defined(LUA_BUILD_AS_DLL) /* { */
-#if defined(LUA_CORE) || defined(LUA_LIB) /* { */
+#if defined(LUA_CORE) || defined(LUA_LIB) /* { */
#define LUA_API __declspec(dllexport)
-#else /* }{ */
+#else /* }{ */
#define LUA_API __declspec(dllimport)
-#endif /* } */
-
-#else /* }{ */
-
-#define LUA_API extern
-
-#endif /* } */
+#endif /* } */
+
+#else /* }{ */
+
+#define LUA_API extern
+
+#endif /* } */
+
/* more often than not the libs go together with the core */
-#define LUALIB_API LUA_API
-#define LUAMOD_API LUALIB_API
+#define LUALIB_API LUA_API
+#define LUAMOD_API LUALIB_API
+
/*
@@ LUAI_FUNC is a mark for all extern functions that are not to be
@@ -243,17 +275,19 @@
** give a warning about it. To avoid these warnings, change to the
** default definition.
*/
-#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 302) && defined(__ELF__) /* { */
-#define LUAI_FUNC __attribute__((visibility("hidden"))) extern
-#else /* }{ */
-#define LUAI_FUNC extern
-#endif /* } */
+#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
+ defined(__ELF__) /* { */
+#define LUAI_FUNC __attribute__((visibility("hidden"))) extern
+#else /* }{ */
+#define LUAI_FUNC extern
+#endif /* } */
-#define LUAI_DDEC LUAI_FUNC
-#define LUAI_DDEF /* empty */
+#define LUAI_DDEC LUAI_FUNC
+#define LUAI_DDEF /* empty */
/* }================================================================== */
+
/*
** {==================================================================
** Compatibility with previous versions
@@ -266,7 +300,7 @@
** You can define it to get all options, or change specific options
** to fit your specific needs.
*/
-#if defined(LUA_COMPAT_5_2) /* { */
+#if defined(LUA_COMPAT_5_2) /* { */
/*
@@ LUA_COMPAT_MATHLIB controls the presence of several deprecated
@@ -291,9 +325,10 @@
*/
#define LUA_COMPAT_APIINTCASTS
-#endif /* } */
-
-#if defined(LUA_COMPAT_5_1) /* { */
+#endif /* } */
+
+
+#if defined(LUA_COMPAT_5_1) /* { */
/* Incompatibilities from 5.2 -> 5.3 */
#define LUA_COMPAT_MATHLIB
@@ -315,8 +350,11 @@
@@ macro 'lua_cpcall' emulates deprecated function lua_cpcall.
** You can call your C function directly (with light C functions).
*/
-#define lua_cpcall(L, f, u) \
- (lua_pushcfunction(L, (f)), lua_pushlightuserdata(L, (u)), lua_pcall(L, 1, 0, 0))
+#define lua_cpcall(L,f,u) \
+ (lua_pushcfunction(L, (f)), \
+ lua_pushlightuserdata(L,(u)), \
+ lua_pcall(L,1,0,0))
+
/*
@@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library.
@@ -340,12 +378,12 @@
** changes in the API. The macros themselves document how to
** change your code to avoid using them.
*/
-#define lua_strlen(L, i) lua_rawlen(L, (i))
-
-#define lua_objlen(L, i) lua_rawlen(L, (i))
-
-#define lua_equal(L, idx1, idx2) lua_compare(L, (idx1), (idx2), LUA_OPEQ)
-#define lua_lessthan(L, idx1, idx2) lua_compare(L, (idx1), (idx2), LUA_OPLT)
+#define lua_strlen(L,i) lua_rawlen(L, (i))
+
+#define lua_objlen(L,i) lua_rawlen(L, (i))
+
+#define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ)
+#define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT)
/*
@@ LUA_COMPAT_MODULE controls compatibility with previous
@@ -353,7 +391,8 @@
*/
#define LUA_COMPAT_MODULE
-#endif /* } */
+#endif /* } */
+
/*
@@ LUA_COMPAT_FLOATSTRING makes Lua format integral floats without a
@@ -365,6 +404,8 @@
/* }================================================================== */
+
+
/*
** {==================================================================
** Configuration for Numbers.
@@ -375,7 +416,7 @@
/*
@@ LUA_NUMBER is the floating-point type used by Lua.
-@@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
+@@ LUAI_UACNUMBER is the result of a 'default argument promotion'
@@ over a floating number.
@@ l_mathlim(x) corrects limit name 'x' to the proper float type
** by prefixing it with one of FLT/DBL/LDBL.
@@ -387,11 +428,13 @@
@@ lua_str2number converts a decimal numeric string to a number.
*/
+
/* The following definitions are good for most cases here */
-#define l_floor(x) (l_mathop(floor)(x))
+#define l_floor(x) (l_mathop(floor)(x))
-#define lua_number2str(s, sz, n) l_sprintf((s), sz, LUA_NUMBER_FMT, (n))
+#define lua_number2str(s,sz,n) \
+ l_sprintf((s), sz, LUA_NUMBER_FMT, (LUAI_UACNUMBER)(n))
/*
@@ lua_numbertointeger converts a float number to an integer, or
@@ -401,69 +444,74 @@
** has an exact representation as a float; MAXINTEGER may not have one,
** and therefore its conversion to float may have an ill-defined value.)
*/
-#define lua_numbertointeger(n, p) \
- ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \
- (*(p) = (LUA_INTEGER)(n), 1))
+#define lua_numbertointeger(n,p) \
+ ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \
+ (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \
+ (*(p) = (LUA_INTEGER)(n), 1))
+
/* now the variable definitions */
-#if LUA_FLOAT_TYPE == LUA_FLOAT_FLOAT /* { single float */
-
-#define LUA_NUMBER float
-
-#define l_mathlim(n) (FLT_##n)
-
-#define LUAI_UACNUMBER double
-
-#define LUA_NUMBER_FRMLEN ""
-#define LUA_NUMBER_FMT "%.7g"
-
-#define l_mathop(op) op##f
-
-#define lua_str2number(s, p) strtof((s), (p))
-
-#elif LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE /* }{ long double */
-
-#define LUA_NUMBER long double
-
-#define l_mathlim(n) (LDBL_##n)
-
-#define LUAI_UACNUMBER long double
-
-#define LUA_NUMBER_FRMLEN "L"
-#define LUA_NUMBER_FMT "%.19Lg"
-
-#define l_mathop(op) op##l
-
-#define lua_str2number(s, p) strtold((s), (p))
-
-#elif LUA_FLOAT_TYPE == LUA_FLOAT_DOUBLE /* }{ double */
-
-#define LUA_NUMBER double
-
-#define l_mathlim(n) (DBL_##n)
-
-#define LUAI_UACNUMBER double
-
-#define LUA_NUMBER_FRMLEN ""
-#define LUA_NUMBER_FMT "%.14g"
-
-#define l_mathop(op) op
-
-#define lua_str2number(s, p) strtod((s), (p))
-
-#else /* }{ */
+#if LUA_FLOAT_TYPE == LUA_FLOAT_FLOAT /* { single float */
+
+#define LUA_NUMBER float
+
+#define l_mathlim(n) (FLT_##n)
+
+#define LUAI_UACNUMBER double
+
+#define LUA_NUMBER_FRMLEN ""
+#define LUA_NUMBER_FMT "%.7g"
+
+#define l_mathop(op) op##f
+
+#define lua_str2number(s,p) strtof((s), (p))
+
+
+#elif LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE /* }{ long double */
+
+#define LUA_NUMBER long double
+
+#define l_mathlim(n) (LDBL_##n)
+
+#define LUAI_UACNUMBER long double
+
+#define LUA_NUMBER_FRMLEN "L"
+#define LUA_NUMBER_FMT "%.19Lg"
+
+#define l_mathop(op) op##l
+
+#define lua_str2number(s,p) strtold((s), (p))
+
+#elif LUA_FLOAT_TYPE == LUA_FLOAT_DOUBLE /* }{ double */
+
+#define LUA_NUMBER double
+
+#define l_mathlim(n) (DBL_##n)
+
+#define LUAI_UACNUMBER double
+
+#define LUA_NUMBER_FRMLEN ""
+#define LUA_NUMBER_FMT "%.14g"
+
+#define l_mathop(op) op
+
+#define lua_str2number(s,p) strtod((s), (p))
+
+#else /* }{ */
#error "numeric float type not defined"
-#endif /* } */
+#endif /* } */
+
+
/*
@@ LUA_INTEGER is the integer type used by Lua.
**
@@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER.
**
-@@ LUAI_UACINT is the result of an 'usual argument conversion'
+@@ LUAI_UACINT is the result of a 'default argument promotion'
@@ over a lUA_INTEGER.
@@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers.
@@ LUA_INTEGER_FMT is the format for writing integers.
@@ -472,73 +520,78 @@
@@ lua_integer2str converts an integer to a string.
*/
+
/* The following definitions are good for most cases here */
-#define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d"
-#define lua_integer2str(s, sz, n) l_sprintf((s), sz, LUA_INTEGER_FMT, (n))
-
-#define LUAI_UACINT LUA_INTEGER
+#define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d"
+
+#define LUAI_UACINT LUA_INTEGER
+
+#define lua_integer2str(s,sz,n) \
+ l_sprintf((s), sz, LUA_INTEGER_FMT, (LUAI_UACINT)(n))
/*
** use LUAI_UACINT here to avoid problems with promotions (which
** can turn a comparison between unsigneds into a signed comparison)
*/
-#define LUA_UNSIGNED unsigned LUAI_UACINT
+#define LUA_UNSIGNED unsigned LUAI_UACINT
+
/* now the variable definitions */
-#if LUA_INT_TYPE == LUA_INT_INT /* { int */
-
-#define LUA_INTEGER int
-#define LUA_INTEGER_FRMLEN ""
-
-#define LUA_MAXINTEGER INT_MAX
-#define LUA_MININTEGER INT_MIN
-
-#elif LUA_INT_TYPE == LUA_INT_LONG /* }{ long */
-
-#define LUA_INTEGER long
-#define LUA_INTEGER_FRMLEN "l"
-
-#define LUA_MAXINTEGER LONG_MAX
-#define LUA_MININTEGER LONG_MIN
-
-#elif LUA_INT_TYPE == LUA_INT_LONGLONG /* }{ long long */
+#if LUA_INT_TYPE == LUA_INT_INT /* { int */
+
+#define LUA_INTEGER int
+#define LUA_INTEGER_FRMLEN ""
+
+#define LUA_MAXINTEGER INT_MAX
+#define LUA_MININTEGER INT_MIN
+
+#elif LUA_INT_TYPE == LUA_INT_LONG /* }{ long */
+
+#define LUA_INTEGER long
+#define LUA_INTEGER_FRMLEN "l"
+
+#define LUA_MAXINTEGER LONG_MAX
+#define LUA_MININTEGER LONG_MIN
+
+#elif LUA_INT_TYPE == LUA_INT_LONGLONG /* }{ long long */
/* use presence of macro LLONG_MAX as proxy for C99 compliance */
-#if defined(LLONG_MAX) /* { */
+#if defined(LLONG_MAX) /* { */
/* use ISO C99 stuff */
-#define LUA_INTEGER long long
-#define LUA_INTEGER_FRMLEN "ll"
+#define LUA_INTEGER long long
+#define LUA_INTEGER_FRMLEN "ll"
-#define LUA_MAXINTEGER LLONG_MAX
-#define LUA_MININTEGER LLONG_MIN
+#define LUA_MAXINTEGER LLONG_MAX
+#define LUA_MININTEGER LLONG_MIN
#elif defined(LUA_USE_WINDOWS) /* }{ */
/* in Windows, can use specific Windows types */
-#define LUA_INTEGER __int64
-#define LUA_INTEGER_FRMLEN "I64"
-
-#define LUA_MAXINTEGER _I64_MAX
-#define LUA_MININTEGER _I64_MIN
-
-#else /* }{ */
+#define LUA_INTEGER __int64
+#define LUA_INTEGER_FRMLEN "I64"
+
+#define LUA_MAXINTEGER _I64_MAX
+#define LUA_MININTEGER _I64_MIN
+
+#else /* }{ */
#error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \
or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)"
-#endif /* } */
+#endif /* } */
-#else /* }{ */
+#else /* }{ */
#error "numeric integer type not defined"
-#endif /* } */
+#endif /* } */
/* }================================================================== */
+
/*
** {==================================================================
** Dependencies with C99 and other C details
@@ -550,11 +603,12 @@
** (All uses in Lua have only one format item.)
*/
#if !defined(LUA_USE_C89)
-#define l_sprintf(s, sz, f, i) snprintf(s, sz, f, i)
+#define l_sprintf(s,sz,f,i) snprintf(s,sz,f,i)
#else
-#define l_sprintf(s, sz, f, i) ((void)(sz), sprintf(s, f, i))
+#define l_sprintf(s,sz,f,i) ((void)(sz), sprintf(s,f,i))
#endif
+
/*
@@ lua_strx2number converts an hexadecimal numeric string to a number.
** In C99, 'strtod' does that conversion. Otherwise, you can
@@ -562,9 +616,10 @@
** implementation.
*/
#if !defined(LUA_USE_C89)
-#define lua_strx2number(s, p) lua_str2number(s, p)
+#define lua_strx2number(s,p) lua_str2number(s,p)
#endif
+
/*
@@ lua_number2strx converts a float to an hexadecimal numeric string.
** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that.
@@ -572,9 +627,11 @@
** provide its own implementation.
*/
#if !defined(LUA_USE_C89)
-#define lua_number2strx(L, b, sz, f, n) l_sprintf(b, sz, f, n)
+#define lua_number2strx(L,b,sz,f,n) \
+ ((void)L, l_sprintf(b,sz,f,(LUAI_UACNUMBER)(n)))
#endif
+
/*
** 'strtof' and 'opf' variants for math functions are not valid in
** C89. Otherwise, the macro 'HUGE_VALF' is a good proxy for testing the
@@ -582,27 +639,30 @@
** all files that use these macros.)
*/
#if defined(LUA_USE_C89) || (defined(HUGE_VAL) && !defined(HUGE_VALF))
-#undef l_mathop /* variants not available */
+#undef l_mathop /* variants not available */
#undef lua_str2number
-#define l_mathop(op) (lua_Number) op /* no variant */
-#define lua_str2number(s, p) ((lua_Number)strtod((s), (p)))
+#define l_mathop(op) (lua_Number)op /* no variant */
+#define lua_str2number(s,p) ((lua_Number)strtod((s), (p)))
#endif
+
/*
@@ LUA_KCONTEXT is the type of the context ('ctx') for continuation
** functions. It must be a numerical type; Lua will use 'intptr_t' if
** available, otherwise it will use 'ptrdiff_t' (the nearest thing to
** 'intptr_t' in C89)
*/
-#define LUA_KCONTEXT ptrdiff_t
+#define LUA_KCONTEXT ptrdiff_t
-#if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \
+ __STDC_VERSION__ >= 199901L
#include <stdint.h>
-#if defined(INTPTR_MAX) /* even in C99 this type is optional */
+#if defined(INTPTR_MAX) /* even in C99 this type is optional */
#undef LUA_KCONTEXT
-#define LUA_KCONTEXT intptr_t
-#endif
-#endif
+#define LUA_KCONTEXT intptr_t
+#endif
+#endif
+
/*
@@ lua_getlocaledecpoint gets the locale "radix character" (decimal point).
@@ -610,11 +670,12 @@
** macro must include header 'locale.h'.)
*/
#if !defined(lua_getlocaledecpoint)
-#define lua_getlocaledecpoint() (localeconv()->decimal_point[0])
+#define lua_getlocaledecpoint() (localeconv()->decimal_point[0])
#endif
/* }================================================================== */
+
/*
** {==================================================================
** Language Variations
@@ -630,17 +691,19 @@
/* #define LUA_NOCVTN2S */
/* #define LUA_NOCVTS2N */
+
/*
@@ LUA_USE_APICHECK turns on several consistency checks on the C API.
** Define it as a help when debugging C code.
*/
#if defined(LUA_USE_APICHECK)
#include <assert.h>
-#define luai_apicheck(l, e) assert(e)
+#define luai_apicheck(l,e) assert(e)
#endif
/* }================================================================== */
+
/*
** {==================================================================
** Macros that affect the API and must be stable (that is, must be the
@@ -656,47 +719,54 @@
** space (and to reserve some numbers for pseudo-indices).
*/
#if LUAI_BITSINT >= 32
-#define LUAI_MAXSTACK 1000000
+#define LUAI_MAXSTACK 1000000
#else
-#define LUAI_MAXSTACK 15000
+#define LUAI_MAXSTACK 15000
#endif
+
/*
@@ LUA_EXTRASPACE defines the size of a raw memory area associated with
** a Lua state with very fast access.
** CHANGE it if you need a different size.
*/
-#define LUA_EXTRASPACE (sizeof(void*))
+#define LUA_EXTRASPACE (sizeof(void *))
+
/*
@@ LUA_IDSIZE gives the maximum size for the description of the source
@@ of a function in debug information.
** CHANGE it if you want a different size.
*/
-#define LUA_IDSIZE 60
+#define LUA_IDSIZE 60
+
/*
@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
** CHANGE it if it uses too much C-stack space. (For long double,
-** 'string.format("%.99f", 1e4932)' needs ~5030 bytes, so a
+** 'string.format("%.99f", -1e4932)' needs 5034 bytes, so a
** smaller buffer would force a memory allocation for each call to
** 'string.format'.)
*/
-#if defined(LUA_FLOAT_LONGDOUBLE)
-#define LUAL_BUFFERSIZE 8192
+#if LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE
+#define LUAL_BUFFERSIZE 8192
#else
-#define LUAL_BUFFERSIZE ((int)(0x80 * sizeof(void*) * sizeof(lua_Integer)))
+#define LUAL_BUFFERSIZE ((int)(0x80 * sizeof(void*) * sizeof(lua_Integer)))
#endif
/* }================================================================== */
+
/*
@@ LUA_QL describes how error messages quote program elements.
** Lua does not use these macros anymore; they are here for
** compatibility only.
*/
-#define LUA_QL(x) "'" x "'"
-#define LUA_QS LUA_QL("%s")
+#define LUA_QL(x) "'" x "'"
+#define LUA_QS LUA_QL("%s")
+
+
+
/* =================================================================== */
@@ -705,4 +775,9 @@
** without modifying the main part of the file.
*/
+
+
+
+
#endif
+
=== modified file 'src/third_party/eris/lualib.h'
--- src/third_party/eris/lualib.h 2016-08-04 15:49:05 +0000
+++ src/third_party/eris/lualib.h 2018-07-08 12:35:11 +0000
@@ -1,54 +1,63 @@
/*
-** $Id: lualib.h,v 1.44 2014/02/06 17:32:33 roberto Exp $
+** $Id: lualib.h,v 1.45 2017/01/12 17:14:26 roberto Exp $
** Lua standard libraries
** See Copyright Notice in lua.h
*/
+
#ifndef lualib_h
#define lualib_h
#include "lua.h"
-LUAMOD_API int(luaopen_base)(lua_State* L);
-
-#define LUA_COLIBNAME "coroutine"
-LUAMOD_API int(luaopen_coroutine)(lua_State* L);
-
-#define LUA_TABLIBNAME "table"
-LUAMOD_API int(luaopen_table)(lua_State* L);
-
-#define LUA_IOLIBNAME "io"
-LUAMOD_API int(luaopen_io)(lua_State* L);
-
-#define LUA_OSLIBNAME "os"
-LUAMOD_API int(luaopen_os)(lua_State* L);
-
-#define LUA_STRLIBNAME "string"
-LUAMOD_API int(luaopen_string)(lua_State* L);
-
-#define LUA_UTF8LIBNAME "utf8"
-LUAMOD_API int(luaopen_utf8)(lua_State* L);
-
-#define LUA_BITLIBNAME "bit32"
-LUAMOD_API int(luaopen_bit32)(lua_State* L);
-
-#define LUA_MATHLIBNAME "math"
-LUAMOD_API int(luaopen_math)(lua_State* L);
-
-#define LUA_DBLIBNAME "debug"
-LUAMOD_API int(luaopen_debug)(lua_State* L);
-
-#define LUA_LOADLIBNAME "package"
-LUAMOD_API int(luaopen_package)(lua_State* L);
-
-#define LUA_ERISLIBNAME "eris"
-LUAMOD_API int(luaopen_eris)(lua_State* L);
+
+/* version suffix for environment variable names */
+#define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR
+
+
+LUAMOD_API int (luaopen_base) (lua_State *L);
+
+#define LUA_COLIBNAME "coroutine"
+LUAMOD_API int (luaopen_coroutine) (lua_State *L);
+
+#define LUA_TABLIBNAME "table"
+LUAMOD_API int (luaopen_table) (lua_State *L);
+
+#define LUA_IOLIBNAME "io"
+LUAMOD_API int (luaopen_io) (lua_State *L);
+
+#define LUA_OSLIBNAME "os"
+LUAMOD_API int (luaopen_os) (lua_State *L);
+
+#define LUA_STRLIBNAME "string"
+LUAMOD_API int (luaopen_string) (lua_State *L);
+
+#define LUA_UTF8LIBNAME "utf8"
+LUAMOD_API int (luaopen_utf8) (lua_State *L);
+
+#define LUA_BITLIBNAME "bit32"
+LUAMOD_API int (luaopen_bit32) (lua_State *L);
+
+#define LUA_MATHLIBNAME "math"
+LUAMOD_API int (luaopen_math) (lua_State *L);
+
+#define LUA_DBLIBNAME "debug"
+LUAMOD_API int (luaopen_debug) (lua_State *L);
+
+#define LUA_LOADLIBNAME "package"
+LUAMOD_API int (luaopen_package) (lua_State *L);
+
+#define LUA_ERISLIBNAME "eris"
+LUAMOD_API int (luaopen_eris) (lua_State *L);
/* open all previous libraries */
-LUALIB_API void(luaL_openlibs)(lua_State* L);
+LUALIB_API void (luaL_openlibs) (lua_State *L);
+
+
#if !defined(lua_assert)
-#define lua_assert(x) ((void)0)
+#define lua_assert(x) ((void)0)
#endif
+
#endif
=== modified file 'src/third_party/eris/lundump.h'
--- src/third_party/eris/lundump.h 2016-08-04 15:49:05 +0000
+++ src/third_party/eris/lundump.h 2018-07-08 12:35:11 +0000
@@ -11,20 +11,22 @@
#include "lobject.h"
#include "lzio.h"
+
/* data to catch conversion errors */
-#define LUAC_DATA "\x19\x93\r\n\x1a\n"
-
-#define LUAC_INT 0x5678
-#define LUAC_NUM cast_num(370.5)
-
-#define MYINT(s) (s[0] - '0')
-#define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR) * 16 + MYINT(LUA_VERSION_MINOR))
-#define LUAC_FORMAT 0 /* this is the official format */
+#define LUAC_DATA "\x19\x93\r\n\x1a\n"
+
+#define LUAC_INT 0x5678
+#define LUAC_NUM cast_num(370.5)
+
+#define MYINT(s) (s[0]-'0')
+#define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR))
+#define LUAC_FORMAT 0 /* this is the official format */
/* load one chunk; from lundump.c */
-LUAI_FUNC LClosure* luaU_undump(lua_State* L, ZIO* Z, const char* name);
+LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name);
/* dump one chunk; from ldump.c */
-LUAI_FUNC int luaU_dump(lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
+LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w,
+ void* data, int strip);
#endif
=== modified file 'src/third_party/eris/lutf8lib.c'
--- src/third_party/eris/lutf8lib.c 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/lutf8lib.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: lutf8lib.c,v 1.15 2015/03/28 19:16:55 roberto Exp $
+** $Id: lutf8lib.c,v 1.16 2016/12/22 13:08:50 roberto Exp $
** Standard library for UTF-8 manipulation
** See Copyright Notice in lua.h
*/
@@ -194,7 +194,7 @@
lua_pushinteger(L, posi + 1);
else /* no such character */
lua_pushnil(L);
- return 1;
+ return 1;
}
=== modified file 'src/third_party/eris/lvm.c'
--- src/third_party/eris/lvm.c 2017-11-09 17:37:13 +0000
+++ src/third_party/eris/lvm.c 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: lvm.c,v 2.265 2015/11/23 11:30:45 roberto Exp $
+** $Id: lvm.c,v 2.268 2016/02/05 19:59:14 roberto Exp $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -153,54 +153,67 @@
/*
-** Complete a table access: if 't' is a table, 'tm' has its metamethod;
-** otherwise, 'tm' is NULL.
+** Finish the table access 'val = t[key]'.
+** if 'slot' is NULL, 't' is not a table; otherwise, 'slot' points to
+** t[k] entry (which must be nil).
*/
void luaV_finishget (lua_State *L, const TValue *t, TValue *key, StkId val,
- const TValue *tm) {
+ const TValue *slot) {
int loop; /* counter to avoid infinite loops */
- lua_assert(tm != NULL || !ttistable(t));
+ const TValue *tm; /* metamethod */
for (loop = 0; loop < MAXTAGLOOP; loop++) {
- if (tm == NULL) { /* no metamethod (from a table)? */
- if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))
+ if (slot == NULL) { /* 't' is not a table? */
+ lua_assert(!ttistable(t));
+ tm = luaT_gettmbyobj(L, t, TM_INDEX);
+ if (ttisnil(tm))
luaG_typeerror(L, t, "index"); /* no metamethod */
- }
- if (ttisfunction(tm)) { /* metamethod is a function */
+ /* else will try the metamethod */
+ }
+ else { /* 't' is a table */
+ lua_assert(ttisnil(slot));
+ tm = fasttm(L, hvalue(t)->metatable, TM_INDEX); /* table's metamethod */
+ if (tm == NULL) { /* no metamethod? */
+ setnilvalue(val); /* result is nil */
+ return;
+ }
+ /* else will try the metamethod */
+ }
+ if (ttisfunction(tm)) { /* is metamethod a function? */
luaT_callTM(L, tm, t, key, val, 1); /* call it */
return;
}
- t = tm; /* else repeat access over 'tm' */
- if (luaV_fastget(L,t,key,tm,luaH_get)) { /* try fast track */
- setobj2s(L, val, tm); /* done */
+ t = tm; /* else try to access 'tm[key]' */
+ if (luaV_fastget(L,t,key,slot,luaH_get)) { /* fast track? */
+ setobj2s(L, val, slot); /* done */
return;
}
- /* else repeat */
+ /* else repeat (tail call 'luaV_finishget') */
}
- luaG_runerror(L, "gettable chain too long; possible loop");
+ luaG_runerror(L, "'__index' chain too long; possible loop");
}
/*
-** Main function for table assignment (invoking metamethods if needed).
-** Compute 't[key] = val'
+** Finish a table assignment 't[key] = val'.
+** If 'slot' is NULL, 't' is not a table. Otherwise, 'slot' points
+** to the entry 't[key]', or to 'luaO_nilobject' if there is no such
+** entry. (The value at 'slot' must be nil, otherwise 'luaV_fastset'
+** would have done the job.)
*/
void luaV_finishset (lua_State *L, const TValue *t, TValue *key,
- StkId val, const TValue *oldval) {
+ StkId val, const TValue *slot) {
int loop; /* counter to avoid infinite loops */
for (loop = 0; loop < MAXTAGLOOP; loop++) {
- const TValue *tm;
- if (oldval != NULL) {
- Table *h = hvalue(t);
- lua_assert(ttisnil(oldval));
- /* must check the metamethod */
- if ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL &&
- /* no metamethod; is there a previous entry in the table? */
- (oldval != luaO_nilobject ||
- /* no previous entry; must create one. (The next test is
- always true; we only need the assignment.) */
- (oldval = luaH_newkey(L, h, key), 1))) {
+ const TValue *tm; /* '__newindex' metamethod */
+ if (slot != NULL) { /* is 't' a table? */
+ Table *h = hvalue(t); /* save 't' table */
+ lua_assert(ttisnil(slot)); /* old value must be nil */
+ tm = fasttm(L, h->metatable, TM_NEWINDEX); /* get metamethod */
+ if (tm == NULL) { /* no metamethod? */
+ if (slot == luaO_nilobject) /* no previous entry? */
+ slot = luaH_newkey(L, h, key); /* create one */
/* no metamethod and (now) there is an entry with given key */
- setobj2t(L, cast(TValue *, oldval), val);
+ setobj2t(L, cast(TValue *, slot), val); /* set its new value */
invalidateTMcache(h);
luaC_barrierback(L, h, val);
return;
@@ -217,11 +230,11 @@
return;
}
t = tm; /* else repeat assignment over 'tm' */
- if (luaV_fastset(L, t, key, oldval, luaH_get, val))
+ if (luaV_fastset(L, t, key, slot, luaH_get, val))
return; /* done */
/* else loop */
}
- luaG_runerror(L, "settable chain too long; possible loop");
+ luaG_runerror(L, "'__newindex' chain too long; possible loop");
}
@@ -739,18 +752,28 @@
luai_threadyield(L); }
+/* fetch an instruction and prepare its execution */
+#define vmfetch() { \
+ i = *(ci->u.l.savedpc++); \
+ if (L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) \
+ Protect(luaG_traceexec(L)); \
+ ra = RA(i); /* WARNING: any stack reallocation invalidates 'ra' */ \
+ lua_assert(base == ci->u.l.base); \
+ lua_assert(base <= L->top && L->top < L->stack + L->stacksize); \
+}
+
#define vmdispatch(o) switch(o)
#define vmcase(l) case l:
#define vmbreak break
/*
-** copy of 'luaV_gettable', but protecting call to potential metamethod
-** (which can reallocate the stack)
+** copy of 'luaV_gettable', but protecting the call to potential
+** metamethod (which can reallocate the stack)
*/
-#define gettableProtected(L,t,k,v) { const TValue *aux; \
- if (luaV_fastget(L,t,k,aux,luaH_get)) { setobj2s(L, v, aux); } \
- else Protect(luaV_finishget(L,t,k,v,aux)); }
+#define gettableProtected(L,t,k,v) { const TValue *slot; \
+ if (luaV_fastget(L,t,k,slot,luaH_get)) { setobj2s(L, v, slot); } \
+ else Protect(luaV_finishget(L,t,k,v,slot)); }
/* same for 'luaV_settable' */
@@ -760,7 +783,7 @@
-void luaV_execute (lua_State *L) { // NOLINT
+void luaV_execute (lua_State *L) {
CallInfo *ci = L->ci;
LClosure *cl;
TValue *k;
@@ -773,14 +796,9 @@
base = ci->u.l.base; /* local copy of function's base */
/* main loop of interpreter */
for (;;) {
- Instruction i = *(ci->u.l.savedpc++);
+ Instruction i;
StkId ra;
- if (L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT))
- Protect(luaG_traceexec(L));
- /* WARNING: several calls may realloc the stack and invalidate 'ra' */
- ra = RA(i);
- lua_assert(base == ci->u.l.base);
- lua_assert(base <= L->top && L->top < L->stack + L->stacksize);
+ vmfetch();
vmdispatch (GET_OPCODE(i)) {
vmcase(OP_MOVE) {
setobjs2s(L, ra, RB(i));
=== modified file 'src/third_party/eris/lvm.h'
--- src/third_party/eris/lvm.h 2016-08-04 15:49:05 +0000
+++ src/third_party/eris/lvm.h 2018-07-08 12:35:11 +0000
@@ -1,5 +1,5 @@
/*
-** $Id: lvm.h,v 2.39 2015/09/09 13:44:07 roberto Exp $
+** $Id: lvm.h,v 2.41 2016/12/22 13:08:50 roberto Exp $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -7,69 +7,67 @@
#ifndef lvm_h
#define lvm_h
+
#include "ldo.h"
#include "lobject.h"
#include "ltm.h"
+
#if !defined(LUA_NOCVTN2S)
-#define cvt2str(o) ttisnumber(o)
+#define cvt2str(o) ttisnumber(o)
#else
-#define cvt2str(o) 0 /* no conversion from numbers to strings */
+#define cvt2str(o) 0 /* no conversion from numbers to strings */
#endif
+
#if !defined(LUA_NOCVTS2N)
-#define cvt2num(o) ttisstring(o)
+#define cvt2num(o) ttisstring(o)
#else
-#define cvt2num(o) 0 /* no conversion from strings to numbers */
+#define cvt2num(o) 0 /* no conversion from strings to numbers */
#endif
+
/*
** You can define LUA_FLOORN2I if you want to convert floats to integers
** by flooring them (instead of raising an error if they are not
** integral values)
*/
#if !defined(LUA_FLOORN2I)
-#define LUA_FLOORN2I 0
+#define LUA_FLOORN2I 0
#endif
-#define tonumber(o, n) (ttisfloat(o) ? (*(n) = fltvalue(o), 1) : luaV_tonumber_(o, n))
-
-#define tointeger(o, i) \
- (ttisinteger(o) ? (*(i) = ivalue(o), 1) : luaV_tointeger(o, i, LUA_FLOORN2I))
-
-#define intop(op, v1, v2) l_castU2S(l_castS2U(v1) op l_castS2U(v2))
-
-#define luaV_rawequalobj(t1, t2) luaV_equalobj(NULL, t1, t2)
+
+#define tonumber(o,n) \
+ (ttisfloat(o) ? (*(n) = fltvalue(o), 1) : luaV_tonumber_(o,n))
+
+#define tointeger(o,i) \
+ (ttisinteger(o) ? (*(i) = ivalue(o), 1) : luaV_tointeger(o,i,LUA_FLOORN2I))
+
+#define intop(op,v1,v2) l_castU2S(l_castS2U(v1) op l_castS2U(v2))
+
+#define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2)
+
/*
-** fast track for 'gettable': 1 means 'aux' points to resulted value;
-** 0 means 'aux' is metamethod (if 't' is a table) or NULL. 'f' is
-** the raw get function to use.
+** fast track for 'gettable': if 't' is a table and 't[k]' is not nil,
+** return 1 with 'slot' pointing to 't[k]' (final result). Otherwise,
+** return 0 (meaning it will have to check metamethod) with 'slot'
+** pointing to a nil 't[k]' (if 't' is a table) or NULL (otherwise).
+** 'f' is the raw get function to use.
*/
-#define luaV_fastget(L, t, k, aux, f) \
- (!ttistable(t) ? \
- (aux = NULL, 0) /* not a table; 'aux' is NULL and result is 0 */ \
- : \
- (aux = f(hvalue(t), k), /* else, do raw access */ \
- !ttisnil(aux) ? \
- 1 /* result not nil? 'aux' has it */ \
- : \
- (aux = fasttm(L, hvalue(t)->metatable, TM_INDEX), /* get metamethod */ \
- aux != NULL ? 0 /* has metamethod? must call it */ \
- : \
- (aux = luaO_nilobject, 1)))) /* else, final result is nil */
+#define luaV_fastget(L,t,k,slot,f) \
+ (!ttistable(t) \
+ ? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \
+ : (slot = f(hvalue(t), k), /* else, do raw access */ \
+ !ttisnil(slot))) /* result not nil? */
/*
** standard implementation for 'gettable'
*/
-#define luaV_gettable(L, t, k, v) \
- { \
- const TValue* aux; \
- if (luaV_fastget(L, t, k, aux, luaH_get)) { \
- setobj2s(L, v, aux); \
- } else \
- luaV_finishget(L, t, k, v, aux); \
- }
+#define luaV_gettable(L,t,k,v) { const TValue *slot; \
+ if (luaV_fastget(L,t,k,slot,luaH_get)) { setobj2s(L, v, slot); } \
+ else luaV_finishget(L,t,k,v,slot); }
+
/*
** Fast track for set table. If 't' is a table and 't[k]' is not nil,
@@ -79,34 +77,37 @@
** returns true, there is no need to 'invalidateTMcache', because the
** call is not creating a new entry.
*/
-#define luaV_fastset(L, t, k, slot, f, v) \
- (!ttistable(t) ? \
- (slot = NULL, 0) : \
- (slot = f(hvalue(t), k), ttisnil(slot) ? 0 : (luaC_barrierback(L, hvalue(t), v), \
- setobj2t(L, cast(TValue*, slot), v), 1)))
-
-#define luaV_settable(L, t, k, v) \
- { \
- const TValue* slot; \
- if (!luaV_fastset(L, t, k, slot, luaH_get, v)) \
- luaV_finishset(L, t, k, v, slot); \
- }
-
-LUAI_FUNC int luaV_equalobj(lua_State* L, const TValue* t1, const TValue* t2);
-LUAI_FUNC int luaV_lessthan(lua_State* L, const TValue* l, const TValue* r);
-LUAI_FUNC int luaV_lessequal(lua_State* L, const TValue* l, const TValue* r);
-LUAI_FUNC int luaV_tonumber_(const TValue* obj, lua_Number* n);
-LUAI_FUNC int luaV_tointeger(const TValue* obj, lua_Integer* p, int mode);
-LUAI_FUNC void
-luaV_finishget(lua_State* L, const TValue* t, TValue* key, StkId val, const TValue* tm);
-LUAI_FUNC void
-luaV_finishset(lua_State* L, const TValue* t, TValue* key, StkId val, const TValue* oldval);
-LUAI_FUNC void luaV_finishOp(lua_State* L);
-LUAI_FUNC void luaV_execute(lua_State* L);
-LUAI_FUNC void luaV_concat(lua_State* L, int total);
-LUAI_FUNC lua_Integer luaV_div(lua_State* L, lua_Integer x, lua_Integer y);
-LUAI_FUNC lua_Integer luaV_mod(lua_State* L, lua_Integer x, lua_Integer y);
-LUAI_FUNC lua_Integer luaV_shiftl(lua_Integer x, lua_Integer y);
-LUAI_FUNC void luaV_objlen(lua_State* L, StkId ra, const TValue* rb);
+#define luaV_fastset(L,t,k,slot,f,v) \
+ (!ttistable(t) \
+ ? (slot = NULL, 0) \
+ : (slot = f(hvalue(t), k), \
+ ttisnil(slot) ? 0 \
+ : (luaC_barrierback(L, hvalue(t), v), \
+ setobj2t(L, cast(TValue *,slot), v), \
+ 1)))
+
+
+#define luaV_settable(L,t,k,v) { const TValue *slot; \
+ if (!luaV_fastset(L,t,k,slot,luaH_get,v)) \
+ luaV_finishset(L,t,k,v,slot); }
+
+
+
+LUAI_FUNC int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2);
+LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r);
+LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r);
+LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n);
+LUAI_FUNC int luaV_tointeger (const TValue *obj, lua_Integer *p, int mode);
+LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key,
+ StkId val, const TValue *slot);
+LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key,
+ StkId val, const TValue *slot);
+LUAI_FUNC void luaV_finishOp (lua_State *L);
+LUAI_FUNC void luaV_execute (lua_State *L);
+LUAI_FUNC void luaV_concat (lua_State *L, int total);
+LUAI_FUNC lua_Integer luaV_div (lua_State *L, lua_Integer x, lua_Integer y);
+LUAI_FUNC lua_Integer luaV_mod (lua_State *L, lua_Integer x, lua_Integer y);
+LUAI_FUNC lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y);
+LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb);
#endif
=== modified file 'src/third_party/eris/lzio.h'
--- src/third_party/eris/lzio.h 2016-08-04 15:49:05 +0000
+++ src/third_party/eris/lzio.h 2018-07-08 12:35:11 +0000
@@ -4,6 +4,7 @@
** See Copyright Notice in lua.h
*/
+
#ifndef lzio_h
#define lzio_h
@@ -11,46 +12,55 @@
#include "lmem.h"
-#define EOZ (-1) /* end of stream */
+
+#define EOZ (-1) /* end of stream */
typedef struct Zio ZIO;
-#define zgetc(z) (((z)->n--) > 0 ? cast_uchar(*(z)->p++) : luaZ_fill(z))
+#define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z))
+
typedef struct Mbuffer {
- char* buffer;
- size_t n;
- size_t buffsize;
+ char *buffer;
+ size_t n;
+ size_t buffsize;
} Mbuffer;
#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
-#define luaZ_buffer(buff) ((buff)->buffer)
-#define luaZ_sizebuffer(buff) ((buff)->buffsize)
-#define luaZ_bufflen(buff) ((buff)->n)
+#define luaZ_buffer(buff) ((buff)->buffer)
+#define luaZ_sizebuffer(buff) ((buff)->buffsize)
+#define luaZ_bufflen(buff) ((buff)->n)
-#define luaZ_buffremove(buff, i) ((buff)->n -= (i))
+#define luaZ_buffremove(buff,i) ((buff)->n -= (i))
#define luaZ_resetbuffer(buff) ((buff)->n = 0)
-#define luaZ_resizebuffer(L, buff, size) \
- ((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, (buff)->buffsize, size), \
- (buff)->buffsize = size)
-
-#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
-
-LUAI_FUNC void luaZ_init(lua_State* L, ZIO* z, lua_Reader reader, void* data);
-LUAI_FUNC size_t luaZ_read(ZIO* z, void* b, size_t n); /* read next n bytes */
+
+#define luaZ_resizebuffer(L, buff, size) \
+ ((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, \
+ (buff)->buffsize, size), \
+ (buff)->buffsize = size)
+
+#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
+
+
+LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader,
+ void *data);
+LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n); /* read next n bytes */
+
+
/* --------- Private Part ------------------ */
struct Zio {
- size_t n; /* bytes still unread */
- const char* p; /* current position in buffer */
- lua_Reader reader; /* reader function */
- void* data; /* additional data */
- lua_State* L; /* Lua state (for reader) */
+ size_t n; /* bytes still unread */
+ const char *p; /* current position in buffer */
+ lua_Reader reader; /* reader function */
+ void *data; /* additional data */
+ lua_State *L; /* Lua state (for reader) */
};
-LUAI_FUNC int luaZ_fill(ZIO* z);
+
+LUAI_FUNC int luaZ_fill (ZIO *z);
#endif
Follow ups