mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 13:52:28 +00:00
Add Lua compiler
Redbean Lua Server Pages may now be stored in the zip as byte code. This can improve performance, since redbean currently doesn't cache byte code but it might be more useful for anyone wanting to create a closed source redbean. The .lua extension should be used for byte code files. Lua will tell them apart based on a magic number at the start of the file. This change also improves some Lua error reporting conditions. See #97
This commit is contained in:
parent
b703eee96e
commit
3bfb7580c5
16 changed files with 864 additions and 91 deletions
20
third_party/lua/lobject.h
vendored
20
third_party/lua/lobject.h
vendored
|
@ -7,6 +7,7 @@
|
|||
#ifndef lobject_h
|
||||
#define lobject_h
|
||||
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
#include "third_party/lua/llimits.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
|
||||
|
@ -15,17 +16,14 @@
|
|||
/*
|
||||
** Extra types for collectable non-values
|
||||
*/
|
||||
#define LUA_TUPVAL LUA_NUMTYPES /* upvalues */
|
||||
#define LUA_TPROTO (LUA_NUMTYPES+1) /* function prototypes */
|
||||
#define LUA_TDEADKEY (LUA_NUMTYPES+2) /* removed keys in tables */
|
||||
|
||||
|
||||
#define LUA_TUPVAL LUA_NUMTYPES /* upvalues */
|
||||
#define LUA_TPROTO (LUA_NUMTYPES + 1) /* function prototypes */
|
||||
#define LUA_TDEADKEY (LUA_NUMTYPES + 2) /* removed keys in tables */
|
||||
|
||||
/*
|
||||
** number of all possible types (including LUA_TNONE but excluding DEADKEY)
|
||||
*/
|
||||
#define LUA_TOTALTYPES (LUA_TPROTO + 2)
|
||||
|
||||
#define LUA_TOTALTYPES (LUA_TPROTO + 2)
|
||||
|
||||
/*
|
||||
** tags for Tagged Values have the following use of bits:
|
||||
|
@ -778,7 +776,6 @@ typedef struct Table {
|
|||
#define UTF8BUFFSZ 8
|
||||
|
||||
LUAI_FUNC int luaO_utf8esc (char *buff, unsigned long x);
|
||||
LUAI_FUNC int luaO_ceillog2 (unsigned int x);
|
||||
LUAI_FUNC int luaO_rawarith (lua_State *L, int op, const TValue *p1,
|
||||
const TValue *p2, TValue *res);
|
||||
LUAI_FUNC void luaO_arith (lua_State *L, int op, const TValue *p1,
|
||||
|
@ -791,6 +788,11 @@ LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt,
|
|||
LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...);
|
||||
LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t srclen);
|
||||
|
||||
/*
|
||||
** Computes ceil(log2(x))
|
||||
*/
|
||||
static inline int luaO_ceillog2 (unsigned int x) {
|
||||
return --x ? bsr(x) + 1 : 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue