├── 3rdlibs ├── lua-cjson │ ├── types.json │ ├── octets-escaped.dat │ ├── README │ ├── numbers.json │ ├── THANKS │ ├── example2.json │ ├── rfc-example1.json │ ├── json2lua.lua │ ├── lua2json.lua │ ├── rfc-example2.json │ ├── fpconv.h │ ├── example3.json │ ├── genutf8.pl │ ├── example1.json │ ├── example5.json │ ├── LICENSE │ ├── runtests.sh │ ├── lua-cjson-2.1devel-1.rockspec │ ├── NEWS │ ├── TestLua.pm │ ├── .travis.yml │ ├── dtoa_config.h │ ├── lua-cjson.spec │ ├── CMakeLists.txt │ ├── g_fmt.c │ ├── example4.json │ ├── bench.lua │ ├── performance.txt │ └── Makefile └── LuaJIT │ ├── doc │ ├── img │ │ └── contact.png │ ├── bluequad-print.css │ ├── contact.html │ └── status.html │ ├── src │ ├── lua.hpp │ ├── host │ │ ├── README │ │ ├── buildvm_libbc.h │ │ └── buildvm.h │ ├── lj_bc.c │ ├── lj_udata.h │ ├── lj_alloc.h │ ├── lj_asm.h │ ├── lj_ff.h │ ├── lj_parse.h │ ├── lj_profile.h │ ├── lj_gdbjit.h │ ├── jit │ │ ├── dis_arm64be.lua │ │ ├── dis_mips64.lua │ │ ├── dis_x64.lua │ │ ├── dis_mipsel.lua │ │ ├── dis_mips64el.lua │ │ └── zone.lua │ ├── lj_ccallback.h │ ├── lj_ffrecord.h │ ├── lj.supp │ ├── lj_mcode.h │ ├── lj_str.h │ ├── lj_clib.h │ ├── lj_func.h │ ├── lj_udata.c │ ├── lj_snap.h │ ├── lj_strscan.h │ ├── lj_state.h │ ├── lj_carith.h │ ├── lualib.h │ ├── lj_obj.c │ ├── lib_init.c │ ├── lj_char.h │ ├── lj_err.h │ ├── lj_meta.h │ ├── lj_vmevent.c │ ├── lj_vmevent.h │ ├── lj_record.h │ ├── lj_trace.h │ ├── lj_crecord.h │ ├── lj_char.c │ ├── lj_debug.h │ ├── lj_bcdump.h │ ├── lj_cconv.h │ ├── lj_traceerr.h │ ├── lj_opt_dce.c │ ├── lj_cparse.h │ ├── lj_cdata.h │ ├── ljamalg.c │ ├── lj_tab.h │ ├── luajit.h │ ├── lj_buf.h │ ├── psvitabuild.bat │ ├── lj_lex.h │ ├── xedkbuild.bat │ ├── xb1build.bat │ ├── lj_vm.h │ ├── lj_lib.h │ ├── ps4build.bat │ ├── msvcbuild.bat │ └── lj_vmmath.c │ ├── README │ ├── dynasm │ ├── dasm_x64.lua │ ├── dasm_mips64.lua │ └── dasm_proto.h │ ├── etc │ ├── luajit.pc │ └── luajit.1 │ └── COPYRIGHT ├── renovate.json ├── maclualib ├── lib │ └── liblua.a └── include │ ├── lua.hpp │ └── lualib.h ├── win64luajit ├── lua51.dll ├── lua51.lib ├── lua.hpp ├── lualib.h └── luajit.h ├── src ├── utils.h ├── MyWorkerQueue.hpp ├── MyWorkerQueue.cpp ├── MyLuaWorker.cpp ├── MyLuaState.hpp ├── MyLuaWorker.hpp ├── utils.cc ├── luastate.h └── nodelua.cc ├── .gitignore ├── test ├── luatest.lua └── test.js ├── initlua └── formatPrint.lua ├── package.json ├── prepare.js ├── index.js ├── README.md └── binding.gyp /3rdlibs/lua-cjson/types.json: -------------------------------------------------------------------------------- 1 | { "array": [ 10, true, null ] } 2 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /maclualib/lib/liblua.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/whtiehack/node-luajit/HEAD/maclualib/lib/liblua.a -------------------------------------------------------------------------------- /win64luajit/lua51.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/whtiehack/node-luajit/HEAD/win64luajit/lua51.dll -------------------------------------------------------------------------------- /win64luajit/lua51.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/whtiehack/node-luajit/HEAD/win64luajit/lua51.lib -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/doc/img/contact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/whtiehack/node-luajit/HEAD/3rdlibs/LuaJIT/doc/img/contact.png -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/octets-escaped.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/whtiehack/node-luajit/HEAD/3rdlibs/lua-cjson/octets-escaped.dat -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/README: -------------------------------------------------------------------------------- 1 | These JSON examples were taken from the JSON website 2 | (http://json.org/example.html) and RFC 4627. 3 | 4 | Used with permission. 5 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/numbers.json: -------------------------------------------------------------------------------- 1 | [ 0.110001, 2 | 0.12345678910111, 3 | 0.412454033640, 4 | 2.6651441426902, 5 | 2.718281828459, 6 | 3.1415926535898, 7 | 2.1406926327793 ] 8 | -------------------------------------------------------------------------------- /win64luajit/lua.hpp: -------------------------------------------------------------------------------- 1 | // C++ wrapper for LuaJIT header files. 2 | 3 | extern "C" { 4 | #include "lua.h" 5 | #include "lauxlib.h" 6 | #include "lualib.h" 7 | #include "luajit.h" 8 | } 9 | 10 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lua.hpp: -------------------------------------------------------------------------------- 1 | // C++ wrapper for LuaJIT header files. 2 | 3 | extern "C" { 4 | #include "lua.h" 5 | #include "lauxlib.h" 6 | #include "lualib.h" 7 | #include "luajit.h" 8 | } 9 | 10 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/host/README: -------------------------------------------------------------------------------- 1 | The files in this directory are only used during the build process of LuaJIT. 2 | For cross-compilation, they must be executed on the host, not on the target. 3 | 4 | These files should NOT be installed! 5 | -------------------------------------------------------------------------------- /maclualib/include/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/THANKS: -------------------------------------------------------------------------------- 1 | The following people have helped with bug reports, testing and/or 2 | suggestions: 3 | 4 | - Louis-Philippe Perron (@loopole) 5 | - Ondřej Jirman 6 | - Steve Donovan 7 | - Zhang "agentzh" Yichun 8 | 9 | Thanks! 10 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/example2.json: -------------------------------------------------------------------------------- 1 | {"menu": { 2 | "id": "file", 3 | "value": "File", 4 | "popup": { 5 | "menuitem": [ 6 | {"value": "New", "onclick": "CreateNewDoc()"}, 7 | {"value": "Open", "onclick": "OpenDoc()"}, 8 | {"value": "Close", "onclick": "CloseDoc()"} 9 | ] 10 | } 11 | }} 12 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_bc.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Bytecode instruction modes. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define lj_bc_c 7 | #define LUA_CORE 8 | 9 | #include "lj_obj.h" 10 | #include "lj_bc.h" 11 | 12 | /* Bytecode offsets and bytecode instruction modes. */ 13 | #include "lj_bcdef.h" 14 | 15 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/rfc-example1.json: -------------------------------------------------------------------------------- 1 | { 2 | "Image": { 3 | "Width": 800, 4 | "Height": 600, 5 | "Title": "View from 15th Floor", 6 | "Thumbnail": { 7 | "Url": "http://www.example.com/image/481989943", 8 | "Height": 125, 9 | "Width": "100" 10 | }, 11 | "IDs": [116, 943, 234, 38793] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef LUAUTILS_H 2 | #define LUAUTILS_H 3 | 4 | #include 5 | #include 6 | 7 | extern "C"{ 8 | #include 9 | #include 10 | #include 11 | } 12 | 13 | char * get_str(Napi::Value val); 14 | Napi::Value lua_to_value(Napi::Env env,lua_State* L, int); 15 | void push_value_to_lua(lua_State* L, Napi::Value value); 16 | #endif 17 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_udata.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Userdata handling. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_UDATA_H 7 | #define _LJ_UDATA_H 8 | 9 | #include "lj_obj.h" 10 | 11 | LJ_FUNC GCudata *lj_udata_new(lua_State *L, MSize sz, GCtab *env); 12 | LJ_FUNC void LJ_FASTCALL lj_udata_free(global_State *g, GCudata *ud); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/json2lua.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | -- usage: json2lua.lua [json_file] 4 | -- 5 | -- Eg: 6 | -- echo '[ "testing" ]' | ./json2lua.lua 7 | -- ./json2lua.lua test.json 8 | 9 | local json = require "cjson" 10 | local util = require "cjson.util" 11 | 12 | local json_text = util.file_load(arg[1]) 13 | local t = json.decode(json_text) 14 | print(util.serialise_value(t)) 15 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_alloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Bundled memory allocator. 3 | ** Donated to the public domain. 4 | */ 5 | 6 | #ifndef _LJ_ALLOC_H 7 | #define _LJ_ALLOC_H 8 | 9 | #include "lj_def.h" 10 | 11 | #ifndef LUAJIT_USE_SYSMALLOC 12 | LJ_FUNC void *lj_alloc_create(void); 13 | LJ_FUNC void lj_alloc_destroy(void *msp); 14 | LJ_FUNC void *lj_alloc_f(void *msp, void *ptr, size_t osize, size_t nsize); 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_asm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** IR assembler (SSA IR -> machine code). 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_ASM_H 7 | #define _LJ_ASM_H 8 | 9 | #include "lj_jit.h" 10 | 11 | #if LJ_HASJIT 12 | LJ_FUNC void lj_asm_trace(jit_State *J, GCtrace *T); 13 | LJ_FUNC void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, 14 | MCode *target); 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_ff.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Fast function IDs. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_FF_H 7 | #define _LJ_FF_H 8 | 9 | /* Fast function ID. */ 10 | typedef enum { 11 | FF_LUA_ = FF_LUA, /* Lua function (must be 0). */ 12 | FF_C_ = FF_C, /* Regular C function (must be 1). */ 13 | #define FFDEF(name) FF_##name, 14 | #include "lj_ffdef.h" 15 | FF__MAX 16 | } FastFunc; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/lua2json.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | -- usage: lua2json.lua [lua_file] 4 | -- 5 | -- Eg: 6 | -- echo '{ "testing" }' | ./lua2json.lua 7 | -- ./lua2json.lua test.lua 8 | 9 | local json = require "cjson" 10 | local util = require "cjson.util" 11 | 12 | local env = { 13 | json = { null = json.null }, 14 | null = json.null 15 | } 16 | 17 | local t = util.run_script("data = " .. util.file_load(arg[1]), env) 18 | print(json.encode(t.data)) 19 | 20 | -- vi:ai et sw=4 ts=4: 21 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_parse.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Lua parser (source code -> bytecode). 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_PARSE_H 7 | #define _LJ_PARSE_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_lex.h" 11 | 12 | LJ_FUNC GCproto *lj_parse(LexState *ls); 13 | LJ_FUNC GCstr *lj_parse_keepstr(LexState *ls, const char *str, size_t l); 14 | #if LJ_HASFFI 15 | LJ_FUNC void lj_parse_keepcdata(LexState *ls, TValue *tv, GCcdata *cd); 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/README: -------------------------------------------------------------------------------- 1 | README for LuaJIT 2.1.0-beta3 2 | ----------------------------- 3 | 4 | LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language. 5 | 6 | Project Homepage: http://luajit.org/ 7 | 8 | LuaJIT is Copyright (C) 2005-2017 Mike Pall. 9 | LuaJIT is free software, released under the MIT license. 10 | See full Copyright Notice in the COPYRIGHT file or in luajit.h. 11 | 12 | Documentation for LuaJIT is available in HTML format. 13 | Please point your favorite browser to: 14 | 15 | doc/luajit.html 16 | 17 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_profile.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Low-overhead profiling. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_PROFILE_H 7 | #define _LJ_PROFILE_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASPROFILE 12 | 13 | LJ_FUNC void LJ_FASTCALL lj_profile_interpreter(lua_State *L); 14 | #if !LJ_PROFILE_SIGPROF 15 | LJ_FUNC void LJ_FASTCALL lj_profile_hook_enter(global_State *g); 16 | LJ_FUNC void LJ_FASTCALL lj_profile_hook_leave(global_State *g); 17 | #endif 18 | 19 | #endif 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | /node_modules 3 | /.idea 4 | /cjson.so 5 | *.o 6 | 3rdlibs/**/*.a 7 | 3rdlibs/**/*.so 8 | 3rdlibs/LuaJIT/src/lj_bcdef.h 9 | 3rdlibs/LuaJIT/src/lj_ffdef.h 10 | 3rdlibs/LuaJIT/src/lj_folddef.h 11 | 3rdlibs/LuaJIT/src/lj_libdef.h 12 | 3rdlibs/LuaJIT/src/lj_recdef.h 13 | 3rdlibs/LuaJIT/src/lj_vm.S 14 | 3rdlibs/LuaJIT/src/luajit 15 | 3rdlibs/LuaJIT/src/host/buildvm 16 | 3rdlibs/LuaJIT/src/host/buildvm_arch.h 17 | 3rdlibs/LuaJIT/src/host/minilua 18 | 3rdlibs/LuaJIT/src/jit/vmdef.lua 19 | 20 | 21 | build/ 22 | build*/ 23 | binding/ 24 | 25 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_gdbjit.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Client for the GDB JIT API. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_GDBJIT_H 7 | #define _LJ_GDBJIT_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_jit.h" 11 | 12 | #if LJ_HASJIT && defined(LUAJIT_USE_GDBJIT) 13 | 14 | LJ_FUNC void lj_gdbjit_addtrace(jit_State *J, GCtrace *T); 15 | LJ_FUNC void lj_gdbjit_deltrace(jit_State *J, GCtrace *T); 16 | 17 | #else 18 | #define lj_gdbjit_addtrace(J, T) UNUSED(T) 19 | #define lj_gdbjit_deltrace(J, T) UNUSED(T) 20 | #endif 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /src/MyWorkerQueue.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // MyWorkerQueue.hpp 3 | // binding 4 | // 5 | // Created by mac on 16/8/9. 6 | // 7 | // 8 | 9 | #ifndef MyWorkerQueue_hpp 10 | #define MyWorkerQueue_hpp 11 | 12 | #include 13 | #include 14 | #include 15 | class MyLuaWorker; 16 | 17 | class MyWorkerQueue { 18 | public: 19 | MyWorkerQueue():isRunning(false){} 20 | int addQueue(MyLuaWorker*); 21 | 22 | private: 23 | bool isRunning; 24 | std::deque myqueue; 25 | 26 | void popQueue(); 27 | }; 28 | 29 | #endif /* MyWorkerQueue_hpp */ 30 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/rfc-example2.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "precision": "zip", 4 | "Latitude": 37.7668, 5 | "Longitude": -122.3959, 6 | "Address": "", 7 | "City": "SAN FRANCISCO", 8 | "State": "CA", 9 | "Zip": "94107", 10 | "Country": "US" 11 | }, 12 | { 13 | "precision": "zip", 14 | "Latitude": 37.371991, 15 | "Longitude": -122.026020, 16 | "Address": "", 17 | "City": "SUNNYVALE", 18 | "State": "CA", 19 | "Zip": "94085", 20 | "Country": "US" 21 | } 22 | ] 23 | -------------------------------------------------------------------------------- /test/luatest.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: mac 4 | -- Date: 16/8/9 5 | -- Time: 下午6:53 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | print('hello lua!! version:' .. _VERSION); 10 | 11 | 12 | print('cjson:',cjson.encode({5,6,7})) 13 | 14 | 15 | 16 | function testArgAndRetGlobalCall(arg1,arg2,arg3tbl) 17 | print('testArgAndRetGlobalCall',arg1,arg2,arg3tbl) 18 | PrintTable(arg3tbl); 19 | return arg1 .. arg2,'fdafd',{'myval',666,nestedTbl={'val1','val2'}}; 20 | end 21 | 22 | print("luatest.lua run finished") 23 | 24 | return 1,"8",{"b","12",23} -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/fpconv.h: -------------------------------------------------------------------------------- 1 | /* Lua CJSON floating point conversion routines */ 2 | 3 | /* Buffer required to store the largest string representation of a double. 4 | * 5 | * Longest double printed with %.14g is 21 characters long: 6 | * -1.7976931348623e+308 */ 7 | # define FPCONV_G_FMT_BUFSIZE 32 8 | 9 | #ifdef USE_INTERNAL_FPCONV 10 | static inline void fpconv_init() 11 | { 12 | /* Do nothing - not required */ 13 | } 14 | #else 15 | extern void fpconv_init(); 16 | #endif 17 | 18 | extern int fpconv_g_fmt(char*, double, int); 19 | extern double fpconv_strtod(const char*, char**); 20 | 21 | /* vi:ai et sw=4 ts=4: 22 | */ 23 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/dynasm/dasm_x64.lua: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- DynASM x64 module. 3 | -- 4 | -- Copyright (C) 2005-2017 Mike Pall. All rights reserved. 5 | -- See dynasm.lua for full copyright notice. 6 | ------------------------------------------------------------------------------ 7 | -- This module just sets 64 bit mode for the combined x86/x64 module. 8 | -- All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | x64 = true -- Using a global is an ugly, but effective solution. 12 | return require("dasm_x86") 13 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/dynasm/dasm_mips64.lua: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- DynASM MIPS64 module. 3 | -- 4 | -- Copyright (C) 2005-2017 Mike Pall. All rights reserved. 5 | -- See dynasm.lua for full copyright notice. 6 | ------------------------------------------------------------------------------ 7 | -- This module just sets 64 bit mode for the combined MIPS/MIPS64 module. 8 | -- All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | mips64 = true -- Using a global is an ugly, but effective solution. 12 | return require("dasm_mips") 13 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/jit/dis_arm64be.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT ARM64BE disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2017 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- ARM64 instructions are always little-endian. So just forward to the 8 | -- common ARM64 disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | return require((string.match(..., ".*%.") or "").."dis_arm64") 12 | 13 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/etc/luajit.pc: -------------------------------------------------------------------------------- 1 | # Package information for LuaJIT to be used by pkg-config. 2 | majver=2 3 | minver=1 4 | relver=0 5 | version=${majver}.${minver}.${relver}-beta3 6 | abiver=5.1 7 | 8 | prefix=/usr/local 9 | multilib=lib 10 | exec_prefix=${prefix} 11 | libdir=${exec_prefix}/${multilib} 12 | libname=luajit-${abiver} 13 | includedir=${prefix}/include/luajit-${majver}.${minver} 14 | 15 | INSTALL_LMOD=${prefix}/share/lua/${abiver} 16 | INSTALL_CMOD=${prefix}/${multilib}/lua/${abiver} 17 | 18 | Name: LuaJIT 19 | Description: Just-in-time compiler for Lua 20 | URL: http://luajit.org 21 | Version: ${version} 22 | Requires: 23 | Libs: -L${libdir} -l${libname} 24 | Libs.private: -Wl,-E -lm -ldl 25 | Cflags: -I${includedir} 26 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/example3.json: -------------------------------------------------------------------------------- 1 | {"widget": { 2 | "debug": "on", 3 | "window": { 4 | "title": "Sample Konfabulator Widget", 5 | "name": "main_window", 6 | "width": 500, 7 | "height": 500 8 | }, 9 | "image": { 10 | "src": "Images/Sun.png", 11 | "name": "sun1", 12 | "hOffset": 250, 13 | "vOffset": 250, 14 | "alignment": "center" 15 | }, 16 | "text": { 17 | "data": "Click Here", 18 | "size": 36, 19 | "style": "bold", 20 | "name": "text1", 21 | "hOffset": 250, 22 | "vOffset": 100, 23 | "alignment": "center", 24 | "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;" 25 | } 26 | }} 27 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/genutf8.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | # Create test comparison data using a different UTF-8 implementation. 4 | 5 | # The generated utf8.dat file must have the following MD5 sum: 6 | # cff03b039d850f370a7362f3313e5268 7 | 8 | use strict; 9 | 10 | # 0xD800 - 0xDFFF are used to encode supplementary codepoints 11 | # 0x10000 - 0x10FFFF are supplementary codepoints 12 | my (@codepoints) = (0 .. 0xD7FF, 0xE000 .. 0x10FFFF); 13 | 14 | my $utf8 = pack("U*", @codepoints); 15 | defined($utf8) or die "Unable create UTF-8 string\n"; 16 | 17 | open(FH, ">:utf8", "utf8.dat") 18 | or die "Unable to open utf8.dat: $!\n"; 19 | print FH $utf8 20 | or die "Unable to write utf8.dat\n"; 21 | close(FH); 22 | 23 | # vi:ai et sw=4 ts=4: 24 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_ccallback.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FFI C callback handling. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CCALLBACK_H 7 | #define _LJ_CCALLBACK_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_ctype.h" 11 | 12 | #if LJ_HASFFI 13 | 14 | /* Really belongs to lj_vm.h. */ 15 | LJ_ASMF void lj_vm_ffi_callback(void); 16 | 17 | LJ_FUNC MSize lj_ccallback_ptr2slot(CTState *cts, void *p); 18 | LJ_FUNCA lua_State * LJ_FASTCALL lj_ccallback_enter(CTState *cts, void *cf); 19 | LJ_FUNCA void LJ_FASTCALL lj_ccallback_leave(CTState *cts, TValue *o); 20 | LJ_FUNC void *lj_ccallback_new(CTState *cts, CType *ct, GCfunc *fn); 21 | LJ_FUNC void lj_ccallback_mcode_free(CTState *cts); 22 | 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_ffrecord.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Fast function call recorder. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_FFRECORD_H 7 | #define _LJ_FFRECORD_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_jit.h" 11 | 12 | #if LJ_HASJIT 13 | /* Data used by handlers to record a fast function. */ 14 | typedef struct RecordFFData { 15 | TValue *argv; /* Runtime argument values. */ 16 | ptrdiff_t nres; /* Number of returned results (defaults to 1). */ 17 | uint32_t data; /* Per-ffid auxiliary data (opcode, literal etc.). */ 18 | } RecordFFData; 19 | 20 | LJ_FUNC int32_t lj_ffrecord_select_mode(jit_State *J, TRef tr, TValue *tv); 21 | LJ_FUNC void lj_ffrecord_func(jit_State *J); 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj.supp: -------------------------------------------------------------------------------- 1 | # Valgrind suppression file for LuaJIT 2.0. 2 | { 3 | Optimized string compare 4 | Memcheck:Addr4 5 | fun:lj_str_cmp 6 | } 7 | { 8 | Optimized string compare 9 | Memcheck:Addr1 10 | fun:lj_str_cmp 11 | } 12 | { 13 | Optimized string compare 14 | Memcheck:Addr4 15 | fun:lj_str_new 16 | } 17 | { 18 | Optimized string compare 19 | Memcheck:Addr1 20 | fun:lj_str_new 21 | } 22 | { 23 | Optimized string compare 24 | Memcheck:Cond 25 | fun:lj_str_new 26 | } 27 | { 28 | Optimized string compare 29 | Memcheck:Addr4 30 | fun:str_fastcmp 31 | } 32 | { 33 | Optimized string compare 34 | Memcheck:Addr1 35 | fun:str_fastcmp 36 | } 37 | { 38 | Optimized string compare 39 | Memcheck:Cond 40 | fun:str_fastcmp 41 | } 42 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/jit/dis_mips64.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT MIPS64 disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2017 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- This module just exports the big-endian functions from the 8 | -- MIPS disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | local dis_mips = require((string.match(..., ".*%.") or "").."dis_mips") 12 | return { 13 | create = dis_mips.create, 14 | disass = dis_mips.disass, 15 | regname = dis_mips.regname 16 | } 17 | 18 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/jit/dis_x64.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT x64 disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2017 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- This module just exports the 64 bit functions from the combined 8 | -- x86/x64 disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | local dis_x86 = require((string.match(..., ".*%.") or "").."dis_x86") 12 | return { 13 | create = dis_x86.create64, 14 | disass = dis_x86.disass64, 15 | regname = dis_x86.regname64 16 | } 17 | 18 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/jit/dis_mipsel.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT MIPSEL disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2017 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- This module just exports the little-endian functions from the 8 | -- MIPS disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | local dis_mips = require((string.match(..., ".*%.") or "").."dis_mips") 12 | return { 13 | create = dis_mips.create_el, 14 | disass = dis_mips.disass_el, 15 | regname = dis_mips.regname 16 | } 17 | 18 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/jit/dis_mips64el.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT MIPS64EL disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2017 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- This module just exports the little-endian functions from the 8 | -- MIPS disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | local dis_mips = require((string.match(..., ".*%.") or "").."dis_mips") 12 | return { 13 | create = dis_mips.create_el, 14 | disass = dis_mips.disass_el, 15 | regname = dis_mips.regname 16 | } 17 | 18 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_mcode.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Machine code management. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_MCODE_H 7 | #define _LJ_MCODE_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASJIT || LJ_HASFFI 12 | LJ_FUNC void lj_mcode_sync(void *start, void *end); 13 | #endif 14 | 15 | #if LJ_HASJIT 16 | 17 | #include "lj_jit.h" 18 | 19 | LJ_FUNC void lj_mcode_free(jit_State *J); 20 | LJ_FUNC MCode *lj_mcode_reserve(jit_State *J, MCode **lim); 21 | LJ_FUNC void lj_mcode_commit(jit_State *J, MCode *m); 22 | LJ_FUNC void lj_mcode_abort(jit_State *J); 23 | LJ_FUNC MCode *lj_mcode_patch(jit_State *J, MCode *ptr, int finish); 24 | LJ_FUNC_NORET void lj_mcode_limiterr(jit_State *J, size_t need); 25 | 26 | #define lj_mcode_commitbot(J, m) (J->mcbot = (m)) 27 | 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/MyWorkerQueue.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // MyWorkerQueue.cpp 3 | // binding 4 | // 5 | // Created by mac on 16/8/9. 6 | // 7 | // 8 | 9 | #include "MyWorkerQueue.hpp" 10 | #include "MyLuaWorker.hpp" 11 | #include 12 | 13 | 14 | int MyWorkerQueue::addQueue(MyLuaWorker* worker){ 15 | myqueue.push_front(worker); 16 | worker->setQueueNotify([&](MyLuaWorker* worker)->void{ 17 | isRunning = false; 18 | popQueue(); 19 | }); 20 | popQueue(); 21 | return (int)myqueue.size(); 22 | } 23 | 24 | void MyWorkerQueue::popQueue(){ 25 | if(isRunning || myqueue.empty()){ 26 | return; 27 | } 28 | auto worker = myqueue.back(); 29 | isRunning = true; 30 | myqueue.pop_back(); 31 | 32 | // AsyncQueueWorker(worker); 33 | // printf(" queue call worker\n"); 34 | worker->Queue(); 35 | } 36 | -------------------------------------------------------------------------------- /src/MyLuaWorker.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // MyLuaWorker.cpp 3 | // binding 4 | // 5 | // Created by mac on 16/8/9. 6 | // 7 | // 8 | 9 | #include "MyLuaWorker.hpp" 10 | 11 | 12 | 13 | void MyLuaWorker::Execute () { 14 | // printf("WorkerCall begin:%ld\n",time(0)); 15 | _workerCall(this); 16 | // printf("WorkerCall end :%ld\n",time(0)); 17 | } 18 | 19 | 20 | 21 | void MyLuaWorker::OnOK () { 22 | // printf("OnOK handle ok callback:%ld\n",time(0)); 23 | _finishCb(callback,this); 24 | // printf("WorkerCall handle ok callback end:%ld\n",time(0)); 25 | _queueNotify(this); 26 | // clear no need will delete by node 27 | // delete this; 28 | // Nan::HandleScope scope; 29 | // 30 | // Local argv[] = { 31 | // Null() 32 | // , New(estimate) 33 | // }; 34 | // 35 | // callback->Call(2, argv); 36 | } 37 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_str.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** String handling. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_STR_H 7 | #define _LJ_STR_H 8 | 9 | #include 10 | 11 | #include "lj_obj.h" 12 | 13 | /* String helpers. */ 14 | LJ_FUNC int32_t LJ_FASTCALL lj_str_cmp(GCstr *a, GCstr *b); 15 | LJ_FUNC const char *lj_str_find(const char *s, const char *f, 16 | MSize slen, MSize flen); 17 | LJ_FUNC int lj_str_haspattern(GCstr *s); 18 | 19 | /* String interning. */ 20 | LJ_FUNC void lj_str_resize(lua_State *L, MSize newmask); 21 | LJ_FUNCA GCstr *lj_str_new(lua_State *L, const char *str, size_t len); 22 | LJ_FUNC void LJ_FASTCALL lj_str_free(global_State *g, GCstr *s); 23 | 24 | #define lj_str_newz(L, s) (lj_str_new(L, s, strlen(s))) 25 | #define lj_str_newlit(L, s) (lj_str_new(L, "" s, sizeof(s)-1)) 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_clib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FFI C library loader. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CLIB_H 7 | #define _LJ_CLIB_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASFFI 12 | 13 | /* Namespace for C library indexing. */ 14 | #define CLNS_INDEX ((1u<env. */ 20 | } CLibrary; 21 | 22 | LJ_FUNC TValue *lj_clib_index(lua_State *L, CLibrary *cl, GCstr *name); 23 | LJ_FUNC void lj_clib_load(lua_State *L, GCtab *mt, GCstr *name, int global); 24 | LJ_FUNC void lj_clib_unload(CLibrary *cl); 25 | LJ_FUNC void lj_clib_default(lua_State *L, GCtab *mt); 26 | 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_func.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Function handling (prototypes, functions and upvalues). 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_FUNC_H 7 | #define _LJ_FUNC_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Prototypes. */ 12 | LJ_FUNC void LJ_FASTCALL lj_func_freeproto(global_State *g, GCproto *pt); 13 | 14 | /* Upvalues. */ 15 | LJ_FUNCA void LJ_FASTCALL lj_func_closeuv(lua_State *L, TValue *level); 16 | LJ_FUNC void LJ_FASTCALL lj_func_freeuv(global_State *g, GCupval *uv); 17 | 18 | /* Functions (closures). */ 19 | LJ_FUNC GCfunc *lj_func_newC(lua_State *L, MSize nelems, GCtab *env); 20 | LJ_FUNC GCfunc *lj_func_newL_empty(lua_State *L, GCproto *pt, GCtab *env); 21 | LJ_FUNCA GCfunc *lj_func_newL_gc(lua_State *L, GCproto *pt, GCfuncL *parent); 22 | LJ_FUNC void LJ_FASTCALL lj_func_free(global_State *g, GCfunc *c); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/example1.json: -------------------------------------------------------------------------------- 1 | { 2 | "glossary": { 3 | "title": "example glossary", 4 | "GlossDiv": { 5 | "title": "S", 6 | "GlossList": { 7 | "GlossEntry": { 8 | "ID": "SGML", 9 | "SortAs": "SGML", 10 | "GlossTerm": "Standard Generalized Mark up Language", 11 | "Acronym": "SGML", 12 | "Abbrev": "ISO 8879:1986", 13 | "GlossDef": { 14 | "para": "A meta-markup language, used to create markup languages such as DocBook.", 15 | "GlossSeeAlso": ["GML", "XML"] 16 | }, 17 | "GlossSee": "markup" 18 | } 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/example5.json: -------------------------------------------------------------------------------- 1 | {"menu": { 2 | "header": "SVG Viewer", 3 | "items": [ 4 | {"id": "Open"}, 5 | {"id": "OpenNew", "label": "Open New"}, 6 | null, 7 | {"id": "ZoomIn", "label": "Zoom In"}, 8 | {"id": "ZoomOut", "label": "Zoom Out"}, 9 | {"id": "OriginalView", "label": "Original View"}, 10 | null, 11 | {"id": "Quality"}, 12 | {"id": "Pause"}, 13 | {"id": "Mute"}, 14 | null, 15 | {"id": "Find", "label": "Find..."}, 16 | {"id": "FindAgain", "label": "Find Again"}, 17 | {"id": "Copy"}, 18 | {"id": "CopyAgain", "label": "Copy Again"}, 19 | {"id": "CopySVG", "label": "Copy SVG"}, 20 | {"id": "ViewSVG", "label": "View SVG"}, 21 | {"id": "ViewSource", "label": "View Source"}, 22 | {"id": "SaveAs", "label": "Save As"}, 23 | null, 24 | {"id": "Help"}, 25 | {"id": "About", "label": "About Adobe CVG Viewer..."} 26 | ] 27 | }} 28 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_udata.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Userdata handling. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define lj_udata_c 7 | #define LUA_CORE 8 | 9 | #include "lj_obj.h" 10 | #include "lj_gc.h" 11 | #include "lj_udata.h" 12 | 13 | GCudata *lj_udata_new(lua_State *L, MSize sz, GCtab *env) 14 | { 15 | GCudata *ud = lj_mem_newt(L, sizeof(GCudata) + sz, GCudata); 16 | global_State *g = G(L); 17 | newwhite(g, ud); /* Not finalized. */ 18 | ud->gct = ~LJ_TUDATA; 19 | ud->udtype = UDTYPE_USERDATA; 20 | ud->len = sz; 21 | /* NOBARRIER: The GCudata is new (marked white). */ 22 | setgcrefnull(ud->metatable); 23 | setgcref(ud->env, obj2gco(env)); 24 | /* Chain to userdata list (after main thread). */ 25 | setgcrefr(ud->nextgc, mainthread(g)->nextgc); 26 | setgcref(mainthread(g)->nextgc, obj2gco(ud)); 27 | return ud; 28 | } 29 | 30 | void LJ_FASTCALL lj_udata_free(global_State *g, GCudata *ud) 31 | { 32 | lj_mem_free(g, ud, sizeudata(ud)); 33 | } 34 | 35 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_snap.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Snapshot handling. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_SNAP_H 7 | #define _LJ_SNAP_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_jit.h" 11 | 12 | #if LJ_HASJIT 13 | LJ_FUNC void lj_snap_add(jit_State *J); 14 | LJ_FUNC void lj_snap_purge(jit_State *J); 15 | LJ_FUNC void lj_snap_shrink(jit_State *J); 16 | LJ_FUNC IRIns *lj_snap_regspmap(GCtrace *T, SnapNo snapno, IRIns *ir); 17 | LJ_FUNC void lj_snap_replay(jit_State *J, GCtrace *T); 18 | LJ_FUNC const BCIns *lj_snap_restore(jit_State *J, void *exptr); 19 | LJ_FUNC void lj_snap_grow_buf_(jit_State *J, MSize need); 20 | LJ_FUNC void lj_snap_grow_map_(jit_State *J, MSize need); 21 | 22 | static LJ_AINLINE void lj_snap_grow_buf(jit_State *J, MSize need) 23 | { 24 | if (LJ_UNLIKELY(need > J->sizesnap)) lj_snap_grow_buf_(J, need); 25 | } 26 | 27 | static LJ_AINLINE void lj_snap_grow_map(jit_State *J, MSize need) 28 | { 29 | if (LJ_UNLIKELY(need > J->sizesnapmap)) lj_snap_grow_map_(J, need); 30 | } 31 | 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010-2012 Mark Pulford 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/jit/zone.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT profiler zones. 3 | -- 4 | -- Copyright (C) 2005-2017 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- 8 | -- This module implements a simple hierarchical zone model. 9 | -- 10 | -- Example usage: 11 | -- 12 | -- local zone = require("jit.zone") 13 | -- zone("AI") 14 | -- ... 15 | -- zone("A*") 16 | -- ... 17 | -- print(zone:get()) --> "A*" 18 | -- ... 19 | -- zone() 20 | -- ... 21 | -- print(zone:get()) --> "AI" 22 | -- ... 23 | -- zone() 24 | -- 25 | ---------------------------------------------------------------------------- 26 | 27 | local remove = table.remove 28 | 29 | return setmetatable({ 30 | flush = function(t) 31 | for i=#t,1,-1 do t[i] = nil end 32 | end, 33 | get = function(t) 34 | return t[#t] 35 | end 36 | }, { 37 | __call = function(t, zone) 38 | if zone then 39 | t[#t+1] = zone 40 | else 41 | return (assert(remove(t), "empty zone stack")) 42 | end 43 | end 44 | }) 45 | 46 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_strscan.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** String scanning. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_STRSCAN_H 7 | #define _LJ_STRSCAN_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Options for accepted/returned formats. */ 12 | #define STRSCAN_OPT_TOINT 0x01 /* Convert to int32_t, if possible. */ 13 | #define STRSCAN_OPT_TONUM 0x02 /* Always convert to double. */ 14 | #define STRSCAN_OPT_IMAG 0x04 15 | #define STRSCAN_OPT_LL 0x08 16 | #define STRSCAN_OPT_C 0x10 17 | 18 | /* Returned format. */ 19 | typedef enum { 20 | STRSCAN_ERROR, 21 | STRSCAN_NUM, STRSCAN_IMAG, 22 | STRSCAN_INT, STRSCAN_U32, STRSCAN_I64, STRSCAN_U64, 23 | } StrScanFmt; 24 | 25 | LJ_FUNC StrScanFmt lj_strscan_scan(const uint8_t *p, TValue *o, uint32_t opt); 26 | LJ_FUNC int LJ_FASTCALL lj_strscan_num(GCstr *str, TValue *o); 27 | #if LJ_DUALNUM 28 | LJ_FUNC int LJ_FASTCALL lj_strscan_number(GCstr *str, TValue *o); 29 | #else 30 | #define lj_strscan_number(s, o) lj_strscan_num((s), (o)) 31 | #endif 32 | 33 | /* Check for number or convert string to number/int in-place (!). */ 34 | static LJ_AINLINE int lj_strscan_numberobj(TValue *o) 35 | { 36 | return tvisnumber(o) || (tvisstr(o) && lj_strscan_number(strV(o), o)); 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /maclualib/include/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | /* Key to file-handle type */ 15 | #define LUA_FILEHANDLE "FILE*" 16 | 17 | 18 | #define LUA_COLIBNAME "coroutine" 19 | LUALIB_API int (luaopen_base) (lua_State *L); 20 | 21 | #define LUA_TABLIBNAME "table" 22 | LUALIB_API int (luaopen_table) (lua_State *L); 23 | 24 | #define LUA_IOLIBNAME "io" 25 | LUALIB_API int (luaopen_io) (lua_State *L); 26 | 27 | #define LUA_OSLIBNAME "os" 28 | LUALIB_API int (luaopen_os) (lua_State *L); 29 | 30 | #define LUA_STRLIBNAME "string" 31 | LUALIB_API int (luaopen_string) (lua_State *L); 32 | 33 | #define LUA_MATHLIBNAME "math" 34 | LUALIB_API int (luaopen_math) (lua_State *L); 35 | 36 | #define LUA_DBLIBNAME "debug" 37 | LUALIB_API int (luaopen_debug) (lua_State *L); 38 | 39 | #define LUA_LOADLIBNAME "package" 40 | LUALIB_API int (luaopen_package) (lua_State *L); 41 | 42 | 43 | /* open all previous libraries */ 44 | LUALIB_API void (luaL_openlibs) (lua_State *L); 45 | 46 | 47 | 48 | #ifndef lua_assert 49 | #define lua_assert(x) ((void)0) 50 | #endif 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_state.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** State and stack handling. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_STATE_H 7 | #define _LJ_STATE_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #define incr_top(L) \ 12 | (++L->top >= tvref(L->maxstack) && (lj_state_growstack1(L), 0)) 13 | 14 | #define savestack(L, p) ((char *)(p) - mref(L->stack, char)) 15 | #define restorestack(L, n) ((TValue *)(mref(L->stack, char) + (n))) 16 | 17 | LJ_FUNC void lj_state_relimitstack(lua_State *L); 18 | LJ_FUNC void lj_state_shrinkstack(lua_State *L, MSize used); 19 | LJ_FUNCA void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need); 20 | LJ_FUNC void LJ_FASTCALL lj_state_growstack1(lua_State *L); 21 | 22 | static LJ_AINLINE void lj_state_checkstack(lua_State *L, MSize need) 23 | { 24 | if ((mref(L->maxstack, char) - (char *)L->top) <= 25 | (ptrdiff_t)need*(ptrdiff_t)sizeof(TValue)) 26 | lj_state_growstack(L, need); 27 | } 28 | 29 | LJ_FUNC lua_State *lj_state_new(lua_State *L); 30 | LJ_FUNC void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L); 31 | #if LJ_64 && !LJ_GC64 && !(defined(LUAJIT_USE_VALGRIND) && defined(LUAJIT_USE_SYSMALLOC)) 32 | LJ_FUNC lua_State *lj_state_newstate(lua_Alloc f, void *ud); 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_carith.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** C data arithmetic. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CARITH_H 7 | #define _LJ_CARITH_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASFFI 12 | 13 | LJ_FUNC int lj_carith_op(lua_State *L, MMS mm); 14 | 15 | #if LJ_32 16 | LJ_FUNC uint64_t lj_carith_shl64(uint64_t x, int32_t sh); 17 | LJ_FUNC uint64_t lj_carith_shr64(uint64_t x, int32_t sh); 18 | LJ_FUNC uint64_t lj_carith_sar64(uint64_t x, int32_t sh); 19 | LJ_FUNC uint64_t lj_carith_rol64(uint64_t x, int32_t sh); 20 | LJ_FUNC uint64_t lj_carith_ror64(uint64_t x, int32_t sh); 21 | #endif 22 | LJ_FUNC uint64_t lj_carith_shift64(uint64_t x, int32_t sh, int op); 23 | LJ_FUNC uint64_t lj_carith_check64(lua_State *L, int narg, CTypeID *id); 24 | 25 | #if LJ_32 && LJ_HASJIT 26 | LJ_FUNC int64_t lj_carith_mul64(int64_t x, int64_t k); 27 | #endif 28 | LJ_FUNC uint64_t lj_carith_divu64(uint64_t a, uint64_t b); 29 | LJ_FUNC int64_t lj_carith_divi64(int64_t a, int64_t b); 30 | LJ_FUNC uint64_t lj_carith_modu64(uint64_t a, uint64_t b); 31 | LJ_FUNC int64_t lj_carith_modi64(int64_t a, int64_t b); 32 | LJ_FUNC uint64_t lj_carith_powu64(uint64_t x, uint64_t k); 33 | LJ_FUNC int64_t lj_carith_powi64(int64_t x, int64_t k); 34 | 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /win64luajit/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Standard library header. 3 | ** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LUALIB_H 7 | #define _LUALIB_H 8 | 9 | #include "lua.h" 10 | 11 | #define LUA_FILEHANDLE "FILE*" 12 | 13 | #define LUA_COLIBNAME "coroutine" 14 | #define LUA_MATHLIBNAME "math" 15 | #define LUA_STRLIBNAME "string" 16 | #define LUA_TABLIBNAME "table" 17 | #define LUA_IOLIBNAME "io" 18 | #define LUA_OSLIBNAME "os" 19 | #define LUA_LOADLIBNAME "package" 20 | #define LUA_DBLIBNAME "debug" 21 | #define LUA_BITLIBNAME "bit" 22 | #define LUA_JITLIBNAME "jit" 23 | #define LUA_FFILIBNAME "ffi" 24 | 25 | LUALIB_API int luaopen_base(lua_State *L); 26 | LUALIB_API int luaopen_math(lua_State *L); 27 | LUALIB_API int luaopen_string(lua_State *L); 28 | LUALIB_API int luaopen_table(lua_State *L); 29 | LUALIB_API int luaopen_io(lua_State *L); 30 | LUALIB_API int luaopen_os(lua_State *L); 31 | LUALIB_API int luaopen_package(lua_State *L); 32 | LUALIB_API int luaopen_debug(lua_State *L); 33 | LUALIB_API int luaopen_bit(lua_State *L); 34 | LUALIB_API int luaopen_jit(lua_State *L); 35 | LUALIB_API int luaopen_ffi(lua_State *L); 36 | 37 | LUALIB_API void luaL_openlibs(lua_State *L); 38 | 39 | #ifndef lua_assert 40 | #define lua_assert(x) ((void)0) 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Standard library header. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LUALIB_H 7 | #define _LUALIB_H 8 | 9 | #include "lua.h" 10 | 11 | #define LUA_FILEHANDLE "FILE*" 12 | 13 | #define LUA_COLIBNAME "coroutine" 14 | #define LUA_MATHLIBNAME "math" 15 | #define LUA_STRLIBNAME "string" 16 | #define LUA_TABLIBNAME "table" 17 | #define LUA_IOLIBNAME "io" 18 | #define LUA_OSLIBNAME "os" 19 | #define LUA_LOADLIBNAME "package" 20 | #define LUA_DBLIBNAME "debug" 21 | #define LUA_BITLIBNAME "bit" 22 | #define LUA_JITLIBNAME "jit" 23 | #define LUA_FFILIBNAME "ffi" 24 | 25 | LUALIB_API int luaopen_base(lua_State *L); 26 | LUALIB_API int luaopen_math(lua_State *L); 27 | LUALIB_API int luaopen_string(lua_State *L); 28 | LUALIB_API int luaopen_table(lua_State *L); 29 | LUALIB_API int luaopen_io(lua_State *L); 30 | LUALIB_API int luaopen_os(lua_State *L); 31 | LUALIB_API int luaopen_package(lua_State *L); 32 | LUALIB_API int luaopen_debug(lua_State *L); 33 | LUALIB_API int luaopen_bit(lua_State *L); 34 | LUALIB_API int luaopen_jit(lua_State *L); 35 | LUALIB_API int luaopen_ffi(lua_State *L); 36 | 37 | LUALIB_API void luaL_openlibs(lua_State *L); 38 | 39 | #ifndef lua_assert 40 | #define lua_assert(x) ((void)0) 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /initlua/formatPrint.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: mac 4 | -- Date: 16/8/10 5 | -- Time: 上午10:54 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | -- LUASINGLEIDX 10 | 11 | local oriPrint = print; 12 | function print(...) 13 | oriPrint('[LUA-' .. LUASINGLEIDX ..' PRINT]',...) 14 | io.flush() 15 | end 16 | 17 | 18 | function PrintTable( tbl , level, filteDefault) 19 | local msg = "" 20 | filteDefault = filteDefault or true --默认过滤关键字(DeleteMe, _class_type) 21 | level = level or 1 22 | local indent_str = "" 23 | for i = 1, level do 24 | indent_str = indent_str.." " 25 | end 26 | 27 | print(indent_str .. "{") 28 | for k,v in pairs(tbl) do 29 | if filteDefault then 30 | if k ~= "_class_type" and k ~= "DeleteMe" then 31 | local item_str = string.format("%s%s = %s", indent_str .. " ",tostring(k), tostring(v)) 32 | print(item_str) 33 | if type(v) == "table" then 34 | PrintTable(v, level + 1) 35 | end 36 | end 37 | else 38 | local item_str = string.format("%s%s = %s", indent_str .. " ",tostring(k), tostring(v)) 39 | print(item_str) 40 | if type(v) == "table" then 41 | PrintTable(v, level + 1) 42 | end 43 | end 44 | end 45 | print(indent_str .. "}") 46 | end -------------------------------------------------------------------------------- /src/MyLuaState.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // MyLuaState.hpp 3 | // binding 4 | // 5 | // Created by mac on 16/8/9. 6 | // 7 | // 8 | 9 | #ifndef MyLuaState_hpp 10 | #define MyLuaState_hpp 11 | 12 | #include 13 | #include 14 | 15 | extern "C"{ 16 | #include 17 | #include 18 | #include 19 | } 20 | 21 | #include "MyWorkerQueue.hpp" 22 | 23 | class MyLuaState : public Napi::ObjectWrap { 24 | public: 25 | static Napi::Object Init(Napi::Env env,Napi::Object exports); 26 | static Napi::Object NewInstance(Napi::CallbackInfo& arg); 27 | lua_State* getLuaState()const{return _L;} 28 | 29 | MyLuaState(const Napi::CallbackInfo& callbackInfo); 30 | ~MyLuaState(); 31 | private: 32 | 33 | lua_State* _L; 34 | double _idVal; 35 | static Napi::FunctionReference constructor; // 创建 FunctionReference ,防止被垃圾回收 36 | 37 | static Napi::Value New(const Napi::CallbackInfo& info); 38 | Napi::Value DoFile(const Napi::CallbackInfo& info); 39 | Napi::Value DoString(const Napi::CallbackInfo& info); 40 | Napi::Value Status(const Napi::CallbackInfo& info); 41 | Napi::Value CallGlobalFunction(const Napi::CallbackInfo& info); 42 | 43 | MyWorkerQueue workerQueue; 44 | 45 | 46 | void normalCallBack(Napi::Function& cb,MyLuaWorker* worker); 47 | void normalGetRetCallBack(Napi::Function& cb,MyLuaWorker* worker); 48 | }; 49 | 50 | #endif /* MyLuaState_hpp */ 51 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_obj.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Miscellaneous object handling. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define lj_obj_c 7 | #define LUA_CORE 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Object type names. */ 12 | LJ_DATADEF const char *const lj_obj_typename[] = { /* ORDER LUA_T */ 13 | "no value", "nil", "boolean", "userdata", "number", "string", 14 | "table", "function", "userdata", "thread", "proto", "cdata" 15 | }; 16 | 17 | LJ_DATADEF const char *const lj_obj_itypename[] = { /* ORDER LJ_T */ 18 | "nil", "boolean", "boolean", "userdata", "string", "upval", "thread", 19 | "proto", "function", "trace", "cdata", "table", "userdata", "number" 20 | }; 21 | 22 | /* Compare two objects without calling metamethods. */ 23 | int LJ_FASTCALL lj_obj_equal(cTValue *o1, cTValue *o2) 24 | { 25 | if (itype(o1) == itype(o2)) { 26 | if (tvispri(o1)) 27 | return 1; 28 | if (!tvisnum(o1)) 29 | return gcrefeq(o1->gcr, o2->gcr); 30 | } else if (!tvisnumber(o1) || !tvisnumber(o2)) { 31 | return 0; 32 | } 33 | return numberVnum(o1) == numberVnum(o2); 34 | } 35 | 36 | /* Return pointer to object or its object data. */ 37 | const void * LJ_FASTCALL lj_obj_ptr(cTValue *o) 38 | { 39 | if (tvisudata(o)) 40 | return uddata(udataV(o)); 41 | else if (tvislightud(o)) 42 | return lightudV(o); 43 | else if (LJ_HASFFI && tviscdata(o)) 44 | return cdataptr(cdataV(o)); 45 | else if (tvisgcv(o)) 46 | return gcV(o); 47 | else 48 | return NULL; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lib_init.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Library initialization. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | ** 5 | ** Major parts taken verbatim from the Lua interpreter. 6 | ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h 7 | */ 8 | 9 | #define lib_init_c 10 | #define LUA_LIB 11 | 12 | #include "lua.h" 13 | #include "lauxlib.h" 14 | #include "lualib.h" 15 | 16 | #include "lj_arch.h" 17 | 18 | static const luaL_Reg lj_lib_load[] = { 19 | { "", luaopen_base }, 20 | { LUA_LOADLIBNAME, luaopen_package }, 21 | { LUA_TABLIBNAME, luaopen_table }, 22 | { LUA_IOLIBNAME, luaopen_io }, 23 | { LUA_OSLIBNAME, luaopen_os }, 24 | { LUA_STRLIBNAME, luaopen_string }, 25 | { LUA_MATHLIBNAME, luaopen_math }, 26 | { LUA_DBLIBNAME, luaopen_debug }, 27 | { LUA_BITLIBNAME, luaopen_bit }, 28 | { LUA_JITLIBNAME, luaopen_jit }, 29 | { NULL, NULL } 30 | }; 31 | 32 | static const luaL_Reg lj_lib_preload[] = { 33 | #if LJ_HASFFI 34 | { LUA_FFILIBNAME, luaopen_ffi }, 35 | #endif 36 | { NULL, NULL } 37 | }; 38 | 39 | LUALIB_API void luaL_openlibs(lua_State *L) 40 | { 41 | const luaL_Reg *lib; 42 | for (lib = lj_lib_load; lib->func; lib++) { 43 | lua_pushcfunction(L, lib->func); 44 | lua_pushstring(L, lib->name); 45 | lua_call(L, 1, 0); 46 | } 47 | luaL_findtable(L, LUA_REGISTRYINDEX, "_PRELOAD", 48 | sizeof(lj_lib_preload)/sizeof(lj_lib_preload[0])-1); 49 | for (lib = lj_lib_preload; lib->func; lib++) { 50 | lua_pushcfunction(L, lib->func); 51 | lua_setfield(L, -2, lib->name); 52 | } 53 | lua_pop(L, 1); 54 | } 55 | 56 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-luajit", 3 | "version": "3.0.0", 4 | "description": "luajit node binding", 5 | "main": "index.js", 6 | "homepage": "https://github.com/whtiehack/node-luajit", 7 | "repository": { 8 | "type": "https", 9 | "url": "https://github.com/whtiehack/node-luajit.git" 10 | }, 11 | "bugs": { 12 | "url": "https://github.com/whtiehack/node-luajit/issues" 13 | }, 14 | "keywords": [ 15 | "lua", 16 | "luajit", 17 | "nodejs", 18 | "addon", 19 | "cjson", 20 | "lua51" 21 | ], 22 | "scripts": { 23 | "build": "node-pre-gyp rebuild", 24 | "test": "node test/test.js", 25 | "packageVersion": "echo $npm_package_version", 26 | "dev": "node index.js", 27 | "package": "node-pre-gyp package", 28 | "install": "node-pre-gyp install --fallback-to-build", 29 | "publish": "node-pre-gyp-github publish --release" 30 | }, 31 | "engines": { 32 | "node": ">= 10.20.0" 33 | }, 34 | "author": "smallwhite", 35 | "license": "ISC", 36 | "dependencies": { 37 | "node-pre-gyp": "^0.17.0" 38 | }, 39 | "devDependencies": { 40 | "co": "4.6.0", 41 | "node-addon-api": "4.2.0", 42 | "node-pre-gyp-github": "1.4.4" 43 | }, 44 | "binary": { 45 | "module_name": "node-luajit", 46 | "module_path": "./binding/Release/napi-v{napi_build_version}", 47 | "package_name": "napi-v{napi_build_version}-{platform}-{arch}.tar.gz", 48 | "host": "https://github.com/whtiehack/node-luajit/releases/download/", 49 | "remote_path": "v{version}", 50 | "napi_versions": [ 51 | 6, 52 | 7 53 | ] 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_char.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Character types. 3 | ** Donated to the public domain. 4 | */ 5 | 6 | #ifndef _LJ_CHAR_H 7 | #define _LJ_CHAR_H 8 | 9 | #include "lj_def.h" 10 | 11 | #define LJ_CHAR_CNTRL 0x01 12 | #define LJ_CHAR_SPACE 0x02 13 | #define LJ_CHAR_PUNCT 0x04 14 | #define LJ_CHAR_DIGIT 0x08 15 | #define LJ_CHAR_XDIGIT 0x10 16 | #define LJ_CHAR_UPPER 0x20 17 | #define LJ_CHAR_LOWER 0x40 18 | #define LJ_CHAR_IDENT 0x80 19 | #define LJ_CHAR_ALPHA (LJ_CHAR_LOWER|LJ_CHAR_UPPER) 20 | #define LJ_CHAR_ALNUM (LJ_CHAR_ALPHA|LJ_CHAR_DIGIT) 21 | #define LJ_CHAR_GRAPH (LJ_CHAR_ALNUM|LJ_CHAR_PUNCT) 22 | 23 | /* Only pass -1 or 0..255 to these macros. Never pass a signed char! */ 24 | #define lj_char_isa(c, t) ((lj_char_bits+1)[(c)] & t) 25 | #define lj_char_iscntrl(c) lj_char_isa((c), LJ_CHAR_CNTRL) 26 | #define lj_char_isspace(c) lj_char_isa((c), LJ_CHAR_SPACE) 27 | #define lj_char_ispunct(c) lj_char_isa((c), LJ_CHAR_PUNCT) 28 | #define lj_char_isdigit(c) lj_char_isa((c), LJ_CHAR_DIGIT) 29 | #define lj_char_isxdigit(c) lj_char_isa((c), LJ_CHAR_XDIGIT) 30 | #define lj_char_isupper(c) lj_char_isa((c), LJ_CHAR_UPPER) 31 | #define lj_char_islower(c) lj_char_isa((c), LJ_CHAR_LOWER) 32 | #define lj_char_isident(c) lj_char_isa((c), LJ_CHAR_IDENT) 33 | #define lj_char_isalpha(c) lj_char_isa((c), LJ_CHAR_ALPHA) 34 | #define lj_char_isalnum(c) lj_char_isa((c), LJ_CHAR_ALNUM) 35 | #define lj_char_isgraph(c) lj_char_isa((c), LJ_CHAR_GRAPH) 36 | 37 | #define lj_char_toupper(c) ((c) - (lj_char_islower(c) >> 1)) 38 | #define lj_char_tolower(c) ((c) + lj_char_isupper(c)) 39 | 40 | LJ_DATA const uint8_t lj_char_bits[257]; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_err.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Error handling. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_ERR_H 7 | #define _LJ_ERR_H 8 | 9 | #include 10 | 11 | #include "lj_obj.h" 12 | 13 | typedef enum { 14 | #define ERRDEF(name, msg) \ 15 | LJ_ERR_##name, LJ_ERR_##name##_ = LJ_ERR_##name + sizeof(msg)-1, 16 | #include "lj_errmsg.h" 17 | LJ_ERR__MAX 18 | } ErrMsg; 19 | 20 | LJ_DATA const char *lj_err_allmsg; 21 | #define err2msg(em) (lj_err_allmsg+(int)(em)) 22 | 23 | LJ_FUNC GCstr *lj_err_str(lua_State *L, ErrMsg em); 24 | LJ_FUNCA_NORET void LJ_FASTCALL lj_err_throw(lua_State *L, int errcode); 25 | LJ_FUNC_NORET void lj_err_mem(lua_State *L); 26 | LJ_FUNC_NORET void lj_err_run(lua_State *L); 27 | LJ_FUNC_NORET void lj_err_msg(lua_State *L, ErrMsg em); 28 | LJ_FUNC_NORET void lj_err_lex(lua_State *L, GCstr *src, const char *tok, 29 | BCLine line, ErrMsg em, va_list argp); 30 | LJ_FUNC_NORET void lj_err_optype(lua_State *L, cTValue *o, ErrMsg opm); 31 | LJ_FUNC_NORET void lj_err_comp(lua_State *L, cTValue *o1, cTValue *o2); 32 | LJ_FUNC_NORET void lj_err_optype_call(lua_State *L, TValue *o); 33 | LJ_FUNC_NORET void lj_err_callermsg(lua_State *L, const char *msg); 34 | LJ_FUNC_NORET void lj_err_callerv(lua_State *L, ErrMsg em, ...); 35 | LJ_FUNC_NORET void lj_err_caller(lua_State *L, ErrMsg em); 36 | LJ_FUNC_NORET void lj_err_arg(lua_State *L, int narg, ErrMsg em); 37 | LJ_FUNC_NORET void lj_err_argv(lua_State *L, int narg, ErrMsg em, ...); 38 | LJ_FUNC_NORET void lj_err_argtype(lua_State *L, int narg, const char *xname); 39 | LJ_FUNC_NORET void lj_err_argt(lua_State *L, int narg, int tt); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_meta.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Metamethod handling. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_META_H 7 | #define _LJ_META_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Metamethod handling */ 12 | LJ_FUNC void lj_meta_init(lua_State *L); 13 | LJ_FUNC cTValue *lj_meta_cache(GCtab *mt, MMS mm, GCstr *name); 14 | LJ_FUNC cTValue *lj_meta_lookup(lua_State *L, cTValue *o, MMS mm); 15 | #if LJ_HASFFI 16 | LJ_FUNC int lj_meta_tailcall(lua_State *L, cTValue *tv); 17 | #endif 18 | 19 | #define lj_meta_fastg(g, mt, mm) \ 20 | ((mt) == NULL ? NULL : ((mt)->nomm & (1u<<(mm))) ? NULL : \ 21 | lj_meta_cache(mt, mm, mmname_str(g, mm))) 22 | #define lj_meta_fast(L, mt, mm) lj_meta_fastg(G(L), mt, mm) 23 | 24 | /* C helpers for some instructions, called from assembler VM. */ 25 | LJ_FUNCA cTValue *lj_meta_tget(lua_State *L, cTValue *o, cTValue *k); 26 | LJ_FUNCA TValue *lj_meta_tset(lua_State *L, cTValue *o, cTValue *k); 27 | LJ_FUNCA TValue *lj_meta_arith(lua_State *L, TValue *ra, cTValue *rb, 28 | cTValue *rc, BCReg op); 29 | LJ_FUNCA TValue *lj_meta_cat(lua_State *L, TValue *top, int left); 30 | LJ_FUNCA TValue * LJ_FASTCALL lj_meta_len(lua_State *L, cTValue *o); 31 | LJ_FUNCA TValue *lj_meta_equal(lua_State *L, GCobj *o1, GCobj *o2, int ne); 32 | LJ_FUNCA TValue * LJ_FASTCALL lj_meta_equal_cd(lua_State *L, BCIns ins); 33 | LJ_FUNCA TValue *lj_meta_comp(lua_State *L, cTValue *o1, cTValue *o2, int op); 34 | LJ_FUNCA void lj_meta_istype(lua_State *L, BCReg ra, BCReg tp); 35 | LJ_FUNCA void lj_meta_call(lua_State *L, TValue *func, TValue *top); 36 | LJ_FUNCA void LJ_FASTCALL lj_meta_for(lua_State *L, TValue *o); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PLATFORM="`uname -s`" 4 | [ "$1" ] && VERSION="$1" || VERSION="2.1devel" 5 | 6 | set -e 7 | 8 | # Portable "ggrep -A" replacement. 9 | # Work around Solaris awk record limit of 2559 bytes. 10 | # contextgrep PATTERN POST_MATCH_LINES 11 | contextgrep() { 12 | cut -c -2500 | awk "/$1/ { count = ($2 + 1) } count > 0 { count--; print }" 13 | } 14 | 15 | do_tests() { 16 | echo 17 | cd tests 18 | lua -e 'print("Testing Lua CJSON version " .. require("cjson")._VERSION)' 19 | ./test.lua | contextgrep 'FAIL|Summary' 3 | grep -v PASS | cut -c -150 20 | cd .. 21 | } 22 | 23 | echo "===== Setting LuaRocks PATH =====" 24 | eval "`luarocks path`" 25 | 26 | echo "===== Building UTF-8 test data =====" 27 | ( cd tests && ./genutf8.pl; ) 28 | 29 | echo "===== Cleaning old build data =====" 30 | make clean 31 | rm -f tests/cjson.so 32 | 33 | echo "===== Verifying cjson.so is not installed =====" 34 | 35 | cd tests 36 | if lua -e 'require "cjson"' 2>/dev/null 37 | then 38 | cat < 7 | 8 | #define lj_vmevent_c 9 | #define LUA_CORE 10 | 11 | #include "lj_obj.h" 12 | #include "lj_str.h" 13 | #include "lj_tab.h" 14 | #include "lj_state.h" 15 | #include "lj_dispatch.h" 16 | #include "lj_vm.h" 17 | #include "lj_vmevent.h" 18 | 19 | ptrdiff_t lj_vmevent_prepare(lua_State *L, VMEvent ev) 20 | { 21 | global_State *g = G(L); 22 | GCstr *s = lj_str_newlit(L, LJ_VMEVENTS_REGKEY); 23 | cTValue *tv = lj_tab_getstr(tabV(registry(L)), s); 24 | if (tvistab(tv)) { 25 | int hash = VMEVENT_HASH(ev); 26 | tv = lj_tab_getint(tabV(tv), hash); 27 | if (tv && tvisfunc(tv)) { 28 | lj_state_checkstack(L, LUA_MINSTACK); 29 | setfuncV(L, L->top++, funcV(tv)); 30 | if (LJ_FR2) setnilV(L->top++); 31 | return savestack(L, L->top); 32 | } 33 | } 34 | g->vmevmask &= ~VMEVENT_MASK(ev); /* No handler: cache this fact. */ 35 | return 0; 36 | } 37 | 38 | void lj_vmevent_call(lua_State *L, ptrdiff_t argbase) 39 | { 40 | global_State *g = G(L); 41 | uint8_t oldmask = g->vmevmask; 42 | uint8_t oldh = hook_save(g); 43 | int status; 44 | g->vmevmask = 0; /* Disable all events. */ 45 | hook_vmevent(g); 46 | status = lj_vm_pcall(L, restorestack(L, argbase), 0+1, 0); 47 | if (LJ_UNLIKELY(status)) { 48 | /* Really shouldn't use stderr here, but where else to complain? */ 49 | L->top--; 50 | fputs("VM handler failed: ", stderr); 51 | fputs(tvisstr(L->top) ? strVdata(L->top) : "?", stderr); 52 | fputc('\n', stderr); 53 | } 54 | hook_restore(g, oldh); 55 | if (g->vmevmask != VMEVENT_NOCACHE) 56 | g->vmevmask = oldmask; /* Restore event mask, but not if not modified. */ 57 | } 58 | 59 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_vmevent.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** VM event handling. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_VMEVENT_H 7 | #define _LJ_VMEVENT_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Registry key for VM event handler table. */ 12 | #define LJ_VMEVENTS_REGKEY "_VMEVENTS" 13 | #define LJ_VMEVENTS_HSIZE 4 14 | 15 | #define VMEVENT_MASK(ev) ((uint8_t)1 << ((int)(ev) & 7)) 16 | #define VMEVENT_HASH(ev) ((int)(ev) & ~7) 17 | #define VMEVENT_HASHIDX(h) ((int)(h) << 3) 18 | #define VMEVENT_NOCACHE 255 19 | 20 | #define VMEVENT_DEF(name, hash) \ 21 | LJ_VMEVENT_##name##_, \ 22 | LJ_VMEVENT_##name = ((LJ_VMEVENT_##name##_) & 7)|((hash) << 3) 23 | 24 | /* VM event IDs. */ 25 | typedef enum { 26 | VMEVENT_DEF(BC, 0x00003883), 27 | VMEVENT_DEF(TRACE, 0xb2d91467), 28 | VMEVENT_DEF(RECORD, 0x9284bf4f), 29 | VMEVENT_DEF(TEXIT, 0xb29df2b0), 30 | LJ_VMEVENT__MAX 31 | } VMEvent; 32 | 33 | #ifdef LUAJIT_DISABLE_VMEVENT 34 | #define lj_vmevent_send(L, ev, args) UNUSED(L) 35 | #define lj_vmevent_send_(L, ev, args, post) UNUSED(L) 36 | #else 37 | #define lj_vmevent_send(L, ev, args) \ 38 | if (G(L)->vmevmask & VMEVENT_MASK(LJ_VMEVENT_##ev)) { \ 39 | ptrdiff_t argbase = lj_vmevent_prepare(L, LJ_VMEVENT_##ev); \ 40 | if (argbase) { \ 41 | args \ 42 | lj_vmevent_call(L, argbase); \ 43 | } \ 44 | } 45 | #define lj_vmevent_send_(L, ev, args, post) \ 46 | if (G(L)->vmevmask & VMEVENT_MASK(LJ_VMEVENT_##ev)) { \ 47 | ptrdiff_t argbase = lj_vmevent_prepare(L, LJ_VMEVENT_##ev); \ 48 | if (argbase) { \ 49 | args \ 50 | lj_vmevent_call(L, argbase); \ 51 | post \ 52 | } \ 53 | } 54 | 55 | LJ_FUNC ptrdiff_t lj_vmevent_prepare(lua_State *L, VMEvent ev); 56 | LJ_FUNC void lj_vmevent_call(lua_State *L, ptrdiff_t argbase); 57 | #endif 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/lua-cjson-2.1devel-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "lua-cjson" 2 | version = "2.1devel-1" 3 | 4 | source = { 5 | url = "http://www.kyne.com.au/~mark/software/download/lua-cjson-2.1devel.zip", 6 | } 7 | 8 | description = { 9 | summary = "A fast JSON encoding/parsing module", 10 | detailed = [[ 11 | The Lua CJSON module provides JSON support for Lua. It features: 12 | - Fast, standards compliant encoding/parsing routines 13 | - Full support for JSON with UTF-8, including decoding surrogate pairs 14 | - Optional run-time support for common exceptions to the JSON specification 15 | (infinity, NaN,..) 16 | - No dependencies on other libraries 17 | ]], 18 | homepage = "http://www.kyne.com.au/~mark/software/lua-cjson.php", 19 | license = "MIT" 20 | } 21 | 22 | dependencies = { 23 | "lua >= 5.1" 24 | } 25 | 26 | build = { 27 | type = "builtin", 28 | modules = { 29 | cjson = { 30 | sources = { "lua_cjson.c", "strbuf.c", "fpconv.c" }, 31 | defines = { 32 | -- LuaRocks does not support platform specific configuration for Solaris. 33 | -- Uncomment the line below on Solaris platforms if required. 34 | -- "USE_INTERNAL_ISINF" 35 | } 36 | } 37 | }, 38 | install = { 39 | lua = { 40 | ["cjson.util"] = "lua/cjson/util.lua" 41 | }, 42 | bin = { 43 | json2lua = "lua/json2lua.lua", 44 | lua2json = "lua/lua2json.lua" 45 | } 46 | }, 47 | -- Override default build options (per platform) 48 | platforms = { 49 | win32 = { modules = { cjson = { defines = { 50 | "DISABLE_INVALID_NUMBERS", "USE_INTERNAL_ISINF" 51 | } } } } 52 | }, 53 | copy_directories = { "tests" } 54 | } 55 | 56 | -- vi:ai et sw=4 ts=4: 57 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_record.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Trace recorder (bytecode -> SSA IR). 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_RECORD_H 7 | #define _LJ_RECORD_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_jit.h" 11 | 12 | #if LJ_HASJIT 13 | /* Context for recording an indexed load/store. */ 14 | typedef struct RecordIndex { 15 | TValue tabv; /* Runtime value of table (or indexed object). */ 16 | TValue keyv; /* Runtime value of key. */ 17 | TValue valv; /* Runtime value of stored value. */ 18 | TValue mobjv; /* Runtime value of metamethod object. */ 19 | GCtab *mtv; /* Runtime value of metatable object. */ 20 | cTValue *oldv; /* Runtime value of previously stored value. */ 21 | TRef tab; /* Table (or indexed object) reference. */ 22 | TRef key; /* Key reference. */ 23 | TRef val; /* Value reference for a store or 0 for a load. */ 24 | TRef mt; /* Metatable reference. */ 25 | TRef mobj; /* Metamethod object reference. */ 26 | int idxchain; /* Index indirections left or 0 for raw lookup. */ 27 | } RecordIndex; 28 | 29 | LJ_FUNC int lj_record_objcmp(jit_State *J, TRef a, TRef b, 30 | cTValue *av, cTValue *bv); 31 | LJ_FUNC void lj_record_stop(jit_State *J, TraceLink linktype, TraceNo lnk); 32 | LJ_FUNC TRef lj_record_constify(jit_State *J, cTValue *o); 33 | 34 | LJ_FUNC void lj_record_call(jit_State *J, BCReg func, ptrdiff_t nargs); 35 | LJ_FUNC void lj_record_tailcall(jit_State *J, BCReg func, ptrdiff_t nargs); 36 | LJ_FUNC void lj_record_ret(jit_State *J, BCReg rbase, ptrdiff_t gotresults); 37 | 38 | LJ_FUNC int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm); 39 | LJ_FUNC TRef lj_record_idx(jit_State *J, RecordIndex *ix); 40 | 41 | LJ_FUNC void lj_record_ins(jit_State *J); 42 | LJ_FUNC void lj_record_setup(jit_State *J); 43 | #endif 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_trace.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Trace management. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_TRACE_H 7 | #define _LJ_TRACE_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASJIT 12 | #include "lj_jit.h" 13 | #include "lj_dispatch.h" 14 | 15 | /* Trace errors. */ 16 | typedef enum { 17 | #define TREDEF(name, msg) LJ_TRERR_##name, 18 | #include "lj_traceerr.h" 19 | LJ_TRERR__MAX 20 | } TraceError; 21 | 22 | LJ_FUNC_NORET void lj_trace_err(jit_State *J, TraceError e); 23 | LJ_FUNC_NORET void lj_trace_err_info(jit_State *J, TraceError e); 24 | 25 | /* Trace management. */ 26 | LJ_FUNC GCtrace * LJ_FASTCALL lj_trace_alloc(lua_State *L, GCtrace *T); 27 | LJ_FUNC void LJ_FASTCALL lj_trace_free(global_State *g, GCtrace *T); 28 | LJ_FUNC void lj_trace_reenableproto(GCproto *pt); 29 | LJ_FUNC void lj_trace_flushproto(global_State *g, GCproto *pt); 30 | LJ_FUNC void lj_trace_flush(jit_State *J, TraceNo traceno); 31 | LJ_FUNC int lj_trace_flushall(lua_State *L); 32 | LJ_FUNC void lj_trace_initstate(global_State *g); 33 | LJ_FUNC void lj_trace_freestate(global_State *g); 34 | 35 | /* Event handling. */ 36 | LJ_FUNC void lj_trace_ins(jit_State *J, const BCIns *pc); 37 | LJ_FUNCA void LJ_FASTCALL lj_trace_hot(jit_State *J, const BCIns *pc); 38 | LJ_FUNCA void LJ_FASTCALL lj_trace_stitch(jit_State *J, const BCIns *pc); 39 | LJ_FUNCA int LJ_FASTCALL lj_trace_exit(jit_State *J, void *exptr); 40 | 41 | /* Signal asynchronous abort of trace or end of trace. */ 42 | #define lj_trace_abort(g) (G2J(g)->state &= ~LJ_TRACE_ACTIVE) 43 | #define lj_trace_end(J) (J->state = LJ_TRACE_END) 44 | 45 | #else 46 | 47 | #define lj_trace_flushall(L) (UNUSED(L), 0) 48 | #define lj_trace_initstate(g) UNUSED(g) 49 | #define lj_trace_freestate(g) UNUSED(g) 50 | #define lj_trace_abort(g) UNUSED(g) 51 | #define lj_trace_end(J) UNUSED(J) 52 | 53 | #endif 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/NEWS: -------------------------------------------------------------------------------- 1 | Version 2.1.0 (Mar 1 2012) 2 | * Added cjson.safe module interface which returns nil after an error 3 | * Improved Makefile compatibility with Solaris make 4 | 5 | Version 2.0.0 (Jan 22 2012) 6 | * Improved platform compatibility for strtod/sprintf locale workaround 7 | * Added option to build with David Gay's dtoa.c for improved performance 8 | * Added support for Lua 5.2 9 | * Added option to encode infinity/NaN as JSON null 10 | * Fixed encode bug with a raised default limit and deeply nested tables 11 | * Updated Makefile for compatibility with non-GNU make implementations 12 | * Added CMake build support 13 | * Added HTML manual 14 | * Increased default nesting limit to 1000 15 | * Added support for re-entrant use of encode and decode 16 | * Added support for installing lua2json and json2lua utilities 17 | * Added encode_invalid_numbers() and decode_invalid_numbers() 18 | * Added decode_max_depth() 19 | * Removed registration of global cjson module table 20 | * Removed refuse_invalid_numbers() 21 | 22 | Version 1.0.4 (Nov 30 2011) 23 | * Fixed numeric conversion under locales with a comma decimal separator 24 | 25 | Version 1.0.3 (Sep 15 2011) 26 | * Fixed detection of objects with numeric string keys 27 | * Provided work around for missing isinf() on Solaris 28 | 29 | Version 1.0.2 (May 30 2011) 30 | * Portability improvements for Windows 31 | - No longer links with -lm 32 | - Use "socket" instead of "posix" for sub-second timing 33 | * Removed UTF-8 test dependency on Perl Text::Iconv 34 | * Added simple CLI commands for testing Lua <-> JSON conversions 35 | * Added cjson.encode_number_precision() 36 | 37 | Version 1.0.1 (May 10 2011) 38 | * Added build support for OSX 39 | * Removed unnecessary whitespace from JSON output 40 | * Added cjson.encode_keep_buffer() 41 | * Fixed memory leak on Lua stack overflow exception 42 | 43 | Version 1.0 (May 9 2011) 44 | * Initial release 45 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_crecord.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Trace recorder for C data operations. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CRECORD_H 7 | #define _LJ_CRECORD_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_jit.h" 11 | #include "lj_ffrecord.h" 12 | 13 | #if LJ_HASJIT && LJ_HASFFI 14 | LJ_FUNC void LJ_FASTCALL recff_cdata_index(jit_State *J, RecordFFData *rd); 15 | LJ_FUNC void LJ_FASTCALL recff_cdata_call(jit_State *J, RecordFFData *rd); 16 | LJ_FUNC void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd); 17 | LJ_FUNC void LJ_FASTCALL recff_clib_index(jit_State *J, RecordFFData *rd); 18 | LJ_FUNC void LJ_FASTCALL recff_ffi_new(jit_State *J, RecordFFData *rd); 19 | LJ_FUNC void LJ_FASTCALL recff_ffi_errno(jit_State *J, RecordFFData *rd); 20 | LJ_FUNC void LJ_FASTCALL recff_ffi_string(jit_State *J, RecordFFData *rd); 21 | LJ_FUNC void LJ_FASTCALL recff_ffi_copy(jit_State *J, RecordFFData *rd); 22 | LJ_FUNC void LJ_FASTCALL recff_ffi_fill(jit_State *J, RecordFFData *rd); 23 | LJ_FUNC void LJ_FASTCALL recff_ffi_typeof(jit_State *J, RecordFFData *rd); 24 | LJ_FUNC void LJ_FASTCALL recff_ffi_istype(jit_State *J, RecordFFData *rd); 25 | LJ_FUNC void LJ_FASTCALL recff_ffi_abi(jit_State *J, RecordFFData *rd); 26 | LJ_FUNC void LJ_FASTCALL recff_ffi_xof(jit_State *J, RecordFFData *rd); 27 | LJ_FUNC void LJ_FASTCALL recff_ffi_gc(jit_State *J, RecordFFData *rd); 28 | 29 | LJ_FUNC void LJ_FASTCALL recff_bit64_tobit(jit_State *J, RecordFFData *rd); 30 | LJ_FUNC int LJ_FASTCALL recff_bit64_unary(jit_State *J, RecordFFData *rd); 31 | LJ_FUNC int LJ_FASTCALL recff_bit64_nary(jit_State *J, RecordFFData *rd); 32 | LJ_FUNC int LJ_FASTCALL recff_bit64_shift(jit_State *J, RecordFFData *rd); 33 | LJ_FUNC TRef recff_bit64_tohex(jit_State *J, RecordFFData *rd, TRef hdr); 34 | 35 | LJ_FUNC void LJ_FASTCALL lj_crecord_tonumber(jit_State *J, RecordFFData *rd); 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/TestLua.pm: -------------------------------------------------------------------------------- 1 | package TestLua; 2 | 3 | use Test::Base -Base; 4 | use IPC::Run3; 5 | use Cwd; 6 | 7 | use Test::LongString; 8 | 9 | our @EXPORT = qw( run_tests ); 10 | 11 | $ENV{LUA_CPATH} = "../?.so;;"; 12 | $ENV{LUA_PATH} = "../lua/?.lua;;"; 13 | #$ENV{LUA_PATH} = ($ENV{LUA_PATH} || "" ) . ';' . getcwd . "/runtime/?.lua" . ';;'; 14 | 15 | sub run_test ($) { 16 | my $block = shift; 17 | #print $json_xs->pretty->encode(\@new_rows); 18 | #my $res = #print $json_xs->pretty->encode($res); 19 | my $name = $block->name; 20 | 21 | my $lua = $block->lua or 22 | die "No --- lua specified for test $name\n"; 23 | 24 | my $luafile = "test_case.lua"; 25 | 26 | open my $fh, ">$luafile" or 27 | die "Cannot open $luafile for writing: $!\n"; 28 | 29 | print $fh $lua; 30 | close $fh; 31 | 32 | my ($res, $err); 33 | 34 | my @cmd; 35 | 36 | if ($ENV{TEST_LUA_USE_VALGRIND}) { 37 | warn "$name\n"; 38 | @cmd = ('valgrind', '-q', '--leak-check=full', 'luajit', 'test_case.lua'); 39 | } else { 40 | @cmd = ('luajit', 'test_case.lua'); 41 | } 42 | 43 | run3 \@cmd, undef, \$res, \$err; 44 | my $rc = $?; 45 | 46 | #warn "res:$res\nerr:$err\n"; 47 | 48 | if (defined $block->err) { 49 | $err =~ /.*:.*:.*: (.*\s)?/; 50 | $err = $1; 51 | is $err, $block->err, "$name - err expected"; 52 | 53 | } elsif ($rc) { 54 | die "Failed to execute --- lua for test $name: $err\n"; 55 | 56 | } else { 57 | #is $res, $block->out, "$name - output ok"; 58 | is $res, $block->out, "$name - output ok"; 59 | } 60 | 61 | is $rc, ($block->exit || 0), "$name - exit code ok"; 62 | #unlink 'test_case.lua' or warn "could not delete \'test_case.lua\':$!"; 63 | } 64 | 65 | sub run_tests () { 66 | for my $block (blocks()) { 67 | run_test($block); 68 | } 69 | } 70 | 71 | 1; 72 | -------------------------------------------------------------------------------- /src/MyLuaWorker.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // MyLuaWorker.hpp 3 | // binding 4 | // 5 | // Created by mac on 16/8/9. 6 | // 7 | // 8 | 9 | #ifndef MyLuaWorker_hpp 10 | #define MyLuaWorker_hpp 11 | 12 | #include 13 | #include 14 | #include 15 | class MyWorkerQueue; 16 | 17 | class MyLuaWorker; 18 | //typedef void(*FinishCallBack)(Nan::Callback *); 19 | typedef std::function FinishCallBack; 20 | //typedef void(*WorkerCall)(void); 21 | typedef std::function WorkerCall; 22 | 23 | class MyLuaWorker : public Napi::AsyncWorker { 24 | public: 25 | MyLuaWorker(Napi::Function&callback,WorkerCall workerCall,FinishCallBack finishCb) : 26 | Napi::AsyncWorker(callback),userParam(nullptr),callback(callback) 27 | { 28 | this->_workerCall = workerCall; 29 | _finishCb = finishCb; 30 | _userData.hasErr = false; 31 | _userData.customVal = 0; 32 | _userData.buff[0] = 0; 33 | } 34 | ~MyLuaWorker(){ 35 | // printf("~MyLuaWorker\n"); 36 | } 37 | 38 | void Execute (); 39 | struct UserDatas{ 40 | bool hasErr; 41 | char buff[3024]; 42 | int customVal; 43 | 44 | }; 45 | // Executed when the async work is complete 46 | // this function will be run inside the main event loop 47 | // so it is safe to use V8 again 48 | void OnOK(); 49 | 50 | void setQueueNotify(WorkerCall qn){ 51 | _queueNotify = qn; 52 | } 53 | 54 | void setUserData(bool hasErr,const char* buff){ 55 | _userData.hasErr = hasErr; 56 | if(buff){ 57 | strcpy(_userData.buff, buff); 58 | } 59 | } 60 | UserDatas& getUserData(){ 61 | return _userData; 62 | } 63 | 64 | void* userParam; 65 | private: 66 | Napi::Function& callback; 67 | FinishCallBack _finishCb; 68 | WorkerCall _workerCall; 69 | WorkerCall _queueNotify; 70 | UserDatas _userData; 71 | }; 72 | #endif /* MyLuaWorker_hpp */ 73 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | dist: trusty 3 | 4 | os: linux 5 | 6 | language: c 7 | 8 | compiler: 9 | - gcc 10 | - clang 11 | 12 | addons: 13 | apt: 14 | packages: 15 | - cppcheck 16 | - valgrind 17 | - cpanminus 18 | - libipc-run3-perl 19 | - lua5.1 20 | - lua5.1-dev 21 | 22 | cache: 23 | apt: true 24 | 25 | env: 26 | global: 27 | - JOBS=3 28 | - LUAROCKS_VER=2.4.2 29 | matrix: 30 | #- LUA=1 LUA_DIR=/usr LUA_INCLUDE_DIR=$LUA_DIR/include/lua5.1 31 | - LUAJIT=1 LUA_DIR=/usr/local LUA_INCLUDE_DIR=$LUA_DIR/include/luajit-2.1 LUA_SUFFIX=--lua-suffix=jit 32 | 33 | install: 34 | - if [ -n "$LUAJIT" ]; then git clone -b v2.1-agentzh https://github.com/openresty/luajit2.git; fi 35 | - if [ -n "$LUAJIT" ]; then cd ./luajit2; fi 36 | - if [ -n "$LUAJIT" ]; then make -j$JOBS CCDEBUG=-g Q= PREFIX=$LUAJIT_PREFIX CC=$CC XCFLAGS='-DLUA_USE_APICHECK -DLUA_USE_ASSERT' > build.log 2>&1 || (cat build.log && exit 1); fi 37 | - if [ -n "$LUAJIT" ]; then sudo make install > build.log 2>&1 || (cat build.log && exit 1); fi 38 | - if [ -n "$LUAJIT" ]; then cd ..; fi 39 | - if [ -n "$LUAJIT" ]; then sudo ln -s $LUA_DIR/bin/luajit $LUA_DIR/bin/lua; fi 40 | - sudo cpanm --notest Test::Base Test::LongString > build.log 2>&1 || (cat build.log && exit 1) 41 | - wget https://luarocks.github.io/luarocks/releases/luarocks-$LUAROCKS_VER.tar.gz 42 | - tar -zxf luarocks-$LUAROCKS_VER.tar.gz 43 | - cd luarocks-$LUAROCKS_VER 44 | - ./configure --with-lua=$LUA_DIR --with-lua-include=$LUA_INCLUDE_DIR $LUA_SUFFIX 45 | - make build 46 | - sudo make install 47 | - cd .. 48 | 49 | script: 50 | - cppcheck -i ./luajit2 -i --force --error-exitcode=1 --enable=warning . > build.log 2>&1 || (cat build.log && exit 1) 51 | - sh runtests.sh 52 | - make 53 | - prove -Itests tests 54 | - TEST_LUA_USE_VALGRIND=1 prove -Itests tests > build.log 2>&1; export e=$? 55 | - cat build.log 56 | - grep -E '^==[0-9]+==' build.log; if [ "$?" == 0 ]; then exit 1; else exit $e; fi 57 | -------------------------------------------------------------------------------- /src/utils.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "utils.h" 3 | #include 4 | 5 | char * get_str(Napi::Value val){ 6 | if(!val.IsString()){ 7 | Napi::Error::New(val.Env(), "Argument Must Be A String"); 8 | return NULL; 9 | } 10 | Napi::String val_string(val.Env(),val); 11 | char * val_char_ptr = (char *) malloc(val_string.Utf8Value().length() + 1); 12 | strcpy(val_char_ptr, val_string.Utf8Value().c_str()); 13 | return val_char_ptr; 14 | } 15 | 16 | 17 | Napi::Value lua_to_value(Napi::Env env, lua_State* L, int i){ 18 | switch(lua_type(L, i)){ 19 | case LUA_TBOOLEAN: 20 | return Napi::Boolean::New(env,(int)lua_toboolean(L, i)); 21 | break; 22 | case LUA_TNUMBER: 23 | return Napi::Number::New(env, lua_tonumber(L, i)); 24 | break; 25 | case LUA_TSTRING: 26 | return Napi::String::New(env,(char *)lua_tostring(L, i)); 27 | break; 28 | case LUA_TTABLE: 29 | { 30 | Napi::Object obj = Napi::Object::New(env); 31 | lua_pushnil(L); 32 | while(lua_next(L, -2) != 0){ 33 | Napi::Value key = lua_to_value(env,L, -2); 34 | Napi::Value value = lua_to_value(env,L, -1); 35 | obj.Set(key, value); 36 | lua_pop(L, 1); 37 | } 38 | return obj; 39 | break; 40 | } 41 | default: 42 | return env.Undefined(); 43 | break; 44 | } 45 | } 46 | 47 | void push_value_to_lua(lua_State* L, Napi::Value value){ 48 | if (value.IsString()){ 49 | lua_pushstring(L, get_str(value)); 50 | }else if(value.IsNumber()){ 51 | int i_value = value.ToNumber(); 52 | lua_pushinteger(L, i_value); 53 | }else if(value.IsBoolean()){ 54 | int b_value = (int)value.ToBoolean(); 55 | lua_pushboolean(L, b_value); 56 | }else if(value.IsObject()){ 57 | lua_newtable(L); 58 | Napi::Object obj = value.ToObject(); 59 | Napi::Array keys = obj.GetPropertyNames(); 60 | for(uint32_t i = 0; i < keys.Length(); ++i){ 61 | Napi::Value key = keys.Get(i); 62 | Napi::Value val = obj.Get(key); 63 | push_value_to_lua(L, key); 64 | push_value_to_lua(L, val); 65 | lua_settable(L, -3); 66 | } 67 | }else{ 68 | lua_pushnil(L); 69 | } 70 | } 71 | 72 | 73 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_char.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Character types. 3 | ** Donated to the public domain. 4 | ** 5 | ** This is intended to replace the problematic libc single-byte NLS functions. 6 | ** These just don't make sense anymore with UTF-8 locales becoming the norm 7 | ** on POSIX systems. It never worked too well on Windows systems since hardly 8 | ** anyone bothered to call setlocale(). 9 | ** 10 | ** This table is hardcoded for ASCII. Identifiers include the characters 11 | ** 128-255, too. This allows for the use of all non-ASCII chars as identifiers 12 | ** in the lexer. This is a broad definition, but works well in practice 13 | ** for both UTF-8 locales and most single-byte locales (such as ISO-8859-*). 14 | ** 15 | ** If you really need proper character types for UTF-8 strings, please use 16 | ** an add-on library such as slnunicode: http://luaforge.net/projects/sln/ 17 | */ 18 | 19 | #define lj_char_c 20 | #define LUA_CORE 21 | 22 | #include "lj_char.h" 23 | 24 | LJ_DATADEF const uint8_t lj_char_bits[257] = { 25 | 0, 26 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 1, 1, 27 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 28 | 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 29 | 152,152,152,152,152,152,152,152,152,152, 4, 4, 4, 4, 4, 4, 30 | 4,176,176,176,176,176,176,160,160,160,160,160,160,160,160,160, 31 | 160,160,160,160,160,160,160,160,160,160,160, 4, 4, 4, 4,132, 32 | 4,208,208,208,208,208,208,192,192,192,192,192,192,192,192,192, 33 | 192,192,192,192,192,192,192,192,192,192,192, 4, 4, 4, 4, 1, 34 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 35 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 36 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 37 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 38 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 39 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 40 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 41 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128 42 | }; 43 | 44 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Debugging and introspection. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_DEBUG_H 7 | #define _LJ_DEBUG_H 8 | 9 | #include "lj_obj.h" 10 | 11 | typedef struct lj_Debug { 12 | /* Common fields. Must be in the same order as in lua.h. */ 13 | int event; 14 | const char *name; 15 | const char *namewhat; 16 | const char *what; 17 | const char *source; 18 | int currentline; 19 | int nups; 20 | int linedefined; 21 | int lastlinedefined; 22 | char short_src[LUA_IDSIZE]; 23 | int i_ci; 24 | /* Extended fields. Only valid if lj_debug_getinfo() is called with ext = 1.*/ 25 | int nparams; 26 | int isvararg; 27 | } lj_Debug; 28 | 29 | LJ_FUNC cTValue *lj_debug_frame(lua_State *L, int level, int *size); 30 | LJ_FUNC BCLine LJ_FASTCALL lj_debug_line(GCproto *pt, BCPos pc); 31 | LJ_FUNC const char *lj_debug_uvname(GCproto *pt, uint32_t idx); 32 | LJ_FUNC const char *lj_debug_uvnamev(cTValue *o, uint32_t idx, TValue **tvp); 33 | LJ_FUNC const char *lj_debug_slotname(GCproto *pt, const BCIns *pc, 34 | BCReg slot, const char **name); 35 | LJ_FUNC const char *lj_debug_funcname(lua_State *L, cTValue *frame, 36 | const char **name); 37 | LJ_FUNC void lj_debug_shortname(char *out, GCstr *str, BCLine line); 38 | LJ_FUNC void lj_debug_addloc(lua_State *L, const char *msg, 39 | cTValue *frame, cTValue *nextframe); 40 | LJ_FUNC void lj_debug_pushloc(lua_State *L, GCproto *pt, BCPos pc); 41 | LJ_FUNC int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar, 42 | int ext); 43 | #if LJ_HASPROFILE 44 | LJ_FUNC void lj_debug_dumpstack(lua_State *L, SBuf *sb, const char *fmt, 45 | int depth); 46 | #endif 47 | 48 | /* Fixed internal variable names. */ 49 | #define VARNAMEDEF(_) \ 50 | _(FOR_IDX, "(for index)") \ 51 | _(FOR_STOP, "(for limit)") \ 52 | _(FOR_STEP, "(for step)") \ 53 | _(FOR_GEN, "(for generator)") \ 54 | _(FOR_STATE, "(for state)") \ 55 | _(FOR_CTL, "(for control)") 56 | 57 | enum { 58 | VARNAME_END, 59 | #define VARNAMEENUM(name, str) VARNAME_##name, 60 | VARNAMEDEF(VARNAMEENUM) 61 | #undef VARNAMEENUM 62 | VARNAME__MAX 63 | }; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/dtoa_config.h: -------------------------------------------------------------------------------- 1 | #ifndef _DTOA_CONFIG_H 2 | #define _DTOA_CONFIG_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | /* Ensure dtoa.c does not USE_LOCALE. Lua CJSON must not use locale 9 | * aware conversion routines. */ 10 | #undef USE_LOCALE 11 | 12 | /* dtoa.c should not touch errno, Lua CJSON does not use it, and it 13 | * may not be threadsafe */ 14 | #define NO_ERRNO 15 | 16 | #define Long int32_t 17 | #define ULong uint32_t 18 | #define Llong int64_t 19 | #define ULLong uint64_t 20 | 21 | #ifdef IEEE_BIG_ENDIAN 22 | #define IEEE_MC68k 23 | #else 24 | #define IEEE_8087 25 | #endif 26 | 27 | #define MALLOC(n) xmalloc(n) 28 | 29 | static void *xmalloc(size_t size) 30 | { 31 | void *p; 32 | 33 | p = malloc(size); 34 | if (!p) { 35 | fprintf(stderr, "Out of memory"); 36 | abort(); 37 | } 38 | 39 | return p; 40 | } 41 | 42 | #ifdef MULTIPLE_THREADS 43 | 44 | /* Enable locking to support multi-threaded applications */ 45 | 46 | #include 47 | 48 | static pthread_mutex_t private_dtoa_lock[2] = { 49 | PTHREAD_MUTEX_INITIALIZER, 50 | PTHREAD_MUTEX_INITIALIZER 51 | }; 52 | 53 | #define ACQUIRE_DTOA_LOCK(n) do { \ 54 | int r = pthread_mutex_lock(&private_dtoa_lock[n]); \ 55 | if (r) { \ 56 | fprintf(stderr, "pthread_mutex_lock failed with %d\n", r); \ 57 | abort(); \ 58 | } \ 59 | } while (0) 60 | 61 | #define FREE_DTOA_LOCK(n) do { \ 62 | int r = pthread_mutex_unlock(&private_dtoa_lock[n]); \ 63 | if (r) { \ 64 | fprintf(stderr, "pthread_mutex_unlock failed with %d\n", r);\ 65 | abort(); \ 66 | } \ 67 | } while (0) 68 | 69 | #endif /* MULTIPLE_THREADS */ 70 | 71 | #endif /* _DTOA_CONFIG_H */ 72 | 73 | /* vi:ai et sw=4 ts=4: 74 | */ 75 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_bcdump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Bytecode dump definitions. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_BCDUMP_H 7 | #define _LJ_BCDUMP_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_lex.h" 11 | 12 | /* -- Bytecode dump format ------------------------------------------------ */ 13 | 14 | /* 15 | ** dump = header proto+ 0U 16 | ** header = ESC 'L' 'J' versionB flagsU [namelenU nameB*] 17 | ** proto = lengthU pdata 18 | ** pdata = phead bcinsW* uvdataH* kgc* knum* [debugB*] 19 | ** phead = flagsB numparamsB framesizeB numuvB numkgcU numknU numbcU 20 | ** [debuglenU [firstlineU numlineU]] 21 | ** kgc = kgctypeU { ktab | (loU hiU) | (rloU rhiU iloU ihiU) | strB* } 22 | ** knum = intU0 | (loU1 hiU) 23 | ** ktab = narrayU nhashU karray* khash* 24 | ** karray = ktabk 25 | ** khash = ktabk ktabk 26 | ** ktabk = ktabtypeU { intU | (loU hiU) | strB* } 27 | ** 28 | ** B = 8 bit, H = 16 bit, W = 32 bit, U = ULEB128 of W, U0/U1 = ULEB128 of W+1 29 | */ 30 | 31 | /* Bytecode dump header. */ 32 | #define BCDUMP_HEAD1 0x1b 33 | #define BCDUMP_HEAD2 0x4c 34 | #define BCDUMP_HEAD3 0x4a 35 | 36 | /* If you perform *any* kind of private modifications to the bytecode itself 37 | ** or to the dump format, you *must* set BCDUMP_VERSION to 0x80 or higher. 38 | */ 39 | #define BCDUMP_VERSION 2 40 | 41 | /* Compatibility flags. */ 42 | #define BCDUMP_F_BE 0x01 43 | #define BCDUMP_F_STRIP 0x02 44 | #define BCDUMP_F_FFI 0x04 45 | #define BCDUMP_F_FR2 0x08 46 | 47 | #define BCDUMP_F_KNOWN (BCDUMP_F_FR2*2-1) 48 | 49 | /* Type codes for the GC constants of a prototype. Plus length for strings. */ 50 | enum { 51 | BCDUMP_KGC_CHILD, BCDUMP_KGC_TAB, BCDUMP_KGC_I64, BCDUMP_KGC_U64, 52 | BCDUMP_KGC_COMPLEX, BCDUMP_KGC_STR 53 | }; 54 | 55 | /* Type codes for the keys/values of a constant table. */ 56 | enum { 57 | BCDUMP_KTAB_NIL, BCDUMP_KTAB_FALSE, BCDUMP_KTAB_TRUE, 58 | BCDUMP_KTAB_INT, BCDUMP_KTAB_NUM, BCDUMP_KTAB_STR 59 | }; 60 | 61 | /* -- Bytecode reader/writer ---------------------------------------------- */ 62 | 63 | LJ_FUNC int lj_bcwrite(lua_State *L, GCproto *pt, lua_Writer writer, 64 | void *data, int strip); 65 | LJ_FUNC GCproto *lj_bcread_proto(LexState *ls); 66 | LJ_FUNC GCproto *lj_bcread(LexState *ls); 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_cconv.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** C type conversions. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CCONV_H 7 | #define _LJ_CCONV_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_ctype.h" 11 | 12 | #if LJ_HASFFI 13 | 14 | /* Compressed C type index. ORDER CCX. */ 15 | enum { 16 | CCX_B, /* Bool. */ 17 | CCX_I, /* Integer. */ 18 | CCX_F, /* Floating-point number. */ 19 | CCX_C, /* Complex. */ 20 | CCX_V, /* Vector. */ 21 | CCX_P, /* Pointer. */ 22 | CCX_A, /* Refarray. */ 23 | CCX_S /* Struct/union. */ 24 | }; 25 | 26 | /* Convert C type info to compressed C type index. ORDER CT. ORDER CCX. */ 27 | static LJ_AINLINE uint32_t cconv_idx(CTInfo info) 28 | { 29 | uint32_t idx = ((info >> 26) & 15u); /* Dispatch bits. */ 30 | lua_assert(ctype_type(info) <= CT_MAYCONVERT); 31 | #if LJ_64 32 | idx = ((uint32_t)(U64x(f436fff5,fff7f021) >> 4*idx) & 15u); 33 | #else 34 | idx = (((idx < 8 ? 0xfff7f021u : 0xf436fff5) >> 4*(idx & 7u)) & 15u); 35 | #endif 36 | lua_assert(idx < 8); 37 | return idx; 38 | } 39 | 40 | #define cconv_idx2(dinfo, sinfo) \ 41 | ((cconv_idx((dinfo)) << 3) + cconv_idx((sinfo))) 42 | 43 | #define CCX(dst, src) ((CCX_##dst << 3) + CCX_##src) 44 | 45 | /* Conversion flags. */ 46 | #define CCF_CAST 0x00000001u 47 | #define CCF_FROMTV 0x00000002u 48 | #define CCF_SAME 0x00000004u 49 | #define CCF_IGNQUAL 0x00000008u 50 | 51 | #define CCF_ARG_SHIFT 8 52 | #define CCF_ARG(n) ((n) << CCF_ARG_SHIFT) 53 | #define CCF_GETARG(f) ((f) >> CCF_ARG_SHIFT) 54 | 55 | LJ_FUNC int lj_cconv_compatptr(CTState *cts, CType *d, CType *s, CTInfo flags); 56 | LJ_FUNC void lj_cconv_ct_ct(CTState *cts, CType *d, CType *s, 57 | uint8_t *dp, uint8_t *sp, CTInfo flags); 58 | LJ_FUNC int lj_cconv_tv_ct(CTState *cts, CType *s, CTypeID sid, 59 | TValue *o, uint8_t *sp); 60 | LJ_FUNC int lj_cconv_tv_bf(CTState *cts, CType *s, TValue *o, uint8_t *sp); 61 | LJ_FUNC void lj_cconv_ct_tv(CTState *cts, CType *d, 62 | uint8_t *dp, TValue *o, CTInfo flags); 63 | LJ_FUNC void lj_cconv_bf_tv(CTState *cts, CType *d, uint8_t *dp, TValue *o); 64 | LJ_FUNC int lj_cconv_multi_init(CTState *cts, CType *d, TValue *o); 65 | LJ_FUNC void lj_cconv_ct_init(CTState *cts, CType *d, CTSize sz, 66 | uint8_t *dp, TValue *o, MSize len); 67 | 68 | #endif 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_traceerr.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Trace compiler error messages. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | /* This file may be included multiple times with different TREDEF macros. */ 7 | 8 | /* Recording. */ 9 | TREDEF(RECERR, "error thrown or hook called during recording") 10 | TREDEF(TRACEUV, "trace too short") 11 | TREDEF(TRACEOV, "trace too long") 12 | TREDEF(STACKOV, "trace too deep") 13 | TREDEF(SNAPOV, "too many snapshots") 14 | TREDEF(BLACKL, "blacklisted") 15 | TREDEF(RETRY, "retry recording") 16 | TREDEF(NYIBC, "NYI: bytecode %d") 17 | 18 | /* Recording loop ops. */ 19 | TREDEF(LLEAVE, "leaving loop in root trace") 20 | TREDEF(LINNER, "inner loop in root trace") 21 | TREDEF(LUNROLL, "loop unroll limit reached") 22 | 23 | /* Recording calls/returns. */ 24 | TREDEF(BADTYPE, "bad argument type") 25 | TREDEF(CJITOFF, "JIT compilation disabled for function") 26 | TREDEF(CUNROLL, "call unroll limit reached") 27 | TREDEF(DOWNREC, "down-recursion, restarting") 28 | TREDEF(NYIFFU, "NYI: unsupported variant of FastFunc %s") 29 | TREDEF(NYIRETL, "NYI: return to lower frame") 30 | 31 | /* Recording indexed load/store. */ 32 | TREDEF(STORENN, "store with nil or NaN key") 33 | TREDEF(NOMM, "missing metamethod") 34 | TREDEF(IDXLOOP, "looping index lookup") 35 | TREDEF(NYITMIX, "NYI: mixed sparse/dense table") 36 | 37 | /* Recording C data operations. */ 38 | TREDEF(NOCACHE, "symbol not in cache") 39 | TREDEF(NYICONV, "NYI: unsupported C type conversion") 40 | TREDEF(NYICALL, "NYI: unsupported C function type") 41 | 42 | /* Optimizations. */ 43 | TREDEF(GFAIL, "guard would always fail") 44 | TREDEF(PHIOV, "too many PHIs") 45 | TREDEF(TYPEINS, "persistent type instability") 46 | 47 | /* Assembler. */ 48 | TREDEF(MCODEAL, "failed to allocate mcode memory") 49 | TREDEF(MCODEOV, "machine code too long") 50 | TREDEF(MCODELM, "hit mcode limit (retrying)") 51 | TREDEF(SPILLOV, "too many spill slots") 52 | TREDEF(BADRA, "inconsistent register allocation") 53 | TREDEF(NYIIR, "NYI: cannot assemble IR instruction %d") 54 | TREDEF(NYIPHI, "NYI: PHI shuffling too complex") 55 | TREDEF(NYICOAL, "NYI: register coalescing too complex") 56 | 57 | #undef TREDEF 58 | 59 | /* Detecting unused error messages: 60 | awk -F, '/^TREDEF/ { gsub(/TREDEF./, ""); printf "grep -q LJ_TRERR_%s *.[ch] || echo %s\n", $1, $1}' lj_traceerr.h | sh 61 | */ 62 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_opt_dce.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** DCE: Dead Code Elimination. Pre-LOOP only -- ASM already performs DCE. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define lj_opt_dce_c 7 | #define LUA_CORE 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASJIT 12 | 13 | #include "lj_ir.h" 14 | #include "lj_jit.h" 15 | #include "lj_iropt.h" 16 | 17 | /* Some local macros to save typing. Undef'd at the end. */ 18 | #define IR(ref) (&J->cur.ir[(ref)]) 19 | 20 | /* Scan through all snapshots and mark all referenced instructions. */ 21 | static void dce_marksnap(jit_State *J) 22 | { 23 | SnapNo i, nsnap = J->cur.nsnap; 24 | for (i = 0; i < nsnap; i++) { 25 | SnapShot *snap = &J->cur.snap[i]; 26 | SnapEntry *map = &J->cur.snapmap[snap->mapofs]; 27 | MSize n, nent = snap->nent; 28 | for (n = 0; n < nent; n++) { 29 | IRRef ref = snap_ref(map[n]); 30 | if (ref >= REF_FIRST) 31 | irt_setmark(IR(ref)->t); 32 | } 33 | } 34 | } 35 | 36 | /* Backwards propagate marks. Replace unused instructions with NOPs. */ 37 | static void dce_propagate(jit_State *J) 38 | { 39 | IRRef1 *pchain[IR__MAX]; 40 | IRRef ins; 41 | uint32_t i; 42 | for (i = 0; i < IR__MAX; i++) pchain[i] = &J->chain[i]; 43 | for (ins = J->cur.nins-1; ins >= REF_FIRST; ins--) { 44 | IRIns *ir = IR(ins); 45 | if (irt_ismarked(ir->t)) { 46 | irt_clearmark(ir->t); 47 | pchain[ir->o] = &ir->prev; 48 | } else if (!ir_sideeff(ir)) { 49 | *pchain[ir->o] = ir->prev; /* Reroute original instruction chain. */ 50 | ir->t.irt = IRT_NIL; 51 | ir->o = IR_NOP; /* Replace instruction with NOP. */ 52 | ir->op1 = ir->op2 = 0; 53 | ir->prev = 0; 54 | continue; 55 | } 56 | if (ir->op1 >= REF_FIRST) irt_setmark(IR(ir->op1)->t); 57 | if (ir->op2 >= REF_FIRST) irt_setmark(IR(ir->op2)->t); 58 | } 59 | } 60 | 61 | /* Dead Code Elimination. 62 | ** 63 | ** First backpropagate marks for all used instructions. Then replace 64 | ** the unused ones with a NOP. Note that compressing the IR to eliminate 65 | ** the NOPs does not pay off. 66 | */ 67 | void lj_opt_dce(jit_State *J) 68 | { 69 | if ((J->flags & JIT_F_OPT_DCE)) { 70 | dce_marksnap(J); 71 | dce_propagate(J); 72 | memset(J->bpropcache, 0, sizeof(J->bpropcache)); /* Invalidate cache. */ 73 | } 74 | } 75 | 76 | #undef IR 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/dynasm/dasm_proto.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** DynASM encoding engine prototypes. 3 | ** Copyright (C) 2005-2017 Mike Pall. All rights reserved. 4 | ** Released under the MIT license. See dynasm.lua for full copyright notice. 5 | */ 6 | 7 | #ifndef _DASM_PROTO_H 8 | #define _DASM_PROTO_H 9 | 10 | #include 11 | #include 12 | 13 | #define DASM_IDENT "DynASM 1.4.0" 14 | #define DASM_VERSION 10400 /* 1.4.0 */ 15 | 16 | #ifndef Dst_DECL 17 | #define Dst_DECL dasm_State **Dst 18 | #endif 19 | 20 | #ifndef Dst_REF 21 | #define Dst_REF (*Dst) 22 | #endif 23 | 24 | #ifndef DASM_FDEF 25 | #define DASM_FDEF extern 26 | #endif 27 | 28 | #ifndef DASM_M_GROW 29 | #define DASM_M_GROW(ctx, t, p, sz, need) \ 30 | do { \ 31 | size_t _sz = (sz), _need = (need); \ 32 | if (_sz < _need) { \ 33 | if (_sz < 16) _sz = 16; \ 34 | while (_sz < _need) _sz += _sz; \ 35 | (p) = (t *)realloc((p), _sz); \ 36 | if ((p) == NULL) exit(1); \ 37 | (sz) = _sz; \ 38 | } \ 39 | } while(0) 40 | #endif 41 | 42 | #ifndef DASM_M_FREE 43 | #define DASM_M_FREE(ctx, p, sz) free(p) 44 | #endif 45 | 46 | /* Internal DynASM encoder state. */ 47 | typedef struct dasm_State dasm_State; 48 | 49 | 50 | /* Initialize and free DynASM state. */ 51 | DASM_FDEF void dasm_init(Dst_DECL, int maxsection); 52 | DASM_FDEF void dasm_free(Dst_DECL); 53 | 54 | /* Setup global array. Must be called before dasm_setup(). */ 55 | DASM_FDEF void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl); 56 | 57 | /* Grow PC label array. Can be called after dasm_setup(), too. */ 58 | DASM_FDEF void dasm_growpc(Dst_DECL, unsigned int maxpc); 59 | 60 | /* Setup encoder. */ 61 | DASM_FDEF void dasm_setup(Dst_DECL, const void *actionlist); 62 | 63 | /* Feed encoder with actions. Calls are generated by pre-processor. */ 64 | DASM_FDEF void dasm_put(Dst_DECL, int start, ...); 65 | 66 | /* Link sections and return the resulting size. */ 67 | DASM_FDEF int dasm_link(Dst_DECL, size_t *szp); 68 | 69 | /* Encode sections into buffer. */ 70 | DASM_FDEF int dasm_encode(Dst_DECL, void *buffer); 71 | 72 | /* Get PC label offset. */ 73 | DASM_FDEF int dasm_getpclabel(Dst_DECL, unsigned int pc); 74 | 75 | #ifdef DASM_CHECKS 76 | /* Optional sanity checker to call between isolated encoding steps. */ 77 | DASM_FDEF int dasm_checkstep(Dst_DECL, int secmatch); 78 | #else 79 | #define dasm_checkstep(a, b) 0 80 | #endif 81 | 82 | 83 | #endif /* _DASM_PROTO_H */ 84 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/lua-cjson.spec: -------------------------------------------------------------------------------- 1 | %define luaver 5.1 2 | %define lualibdir %{_libdir}/lua/%{luaver} 3 | %define luadatadir %{_datadir}/lua/%{luaver} 4 | 5 | Name: lua-cjson 6 | Version: 2.1devel 7 | Release: 1%{?dist} 8 | Summary: A fast JSON encoding/parsing module for Lua 9 | 10 | Group: Development/Libraries 11 | License: MIT 12 | URL: http://www.kyne.com.au/~mark/software/lua-cjson/ 13 | Source0: http://www.kyne.com.au/~mark/software/lua-cjson/download/lua-cjson-%{version}.tar.gz 14 | BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) 15 | 16 | BuildRequires: lua >= %{luaver}, lua-devel >= %{luaver} 17 | Requires: lua >= %{luaver} 18 | 19 | %description 20 | The Lua CJSON module provides JSON support for Lua. It features: 21 | - Fast, standards compliant encoding/parsing routines 22 | - Full support for JSON with UTF-8, including decoding surrogate pairs 23 | - Optional run-time support for common exceptions to the JSON specification 24 | (infinity, NaN,..) 25 | - No dependencies on other libraries 26 | 27 | 28 | %prep 29 | %setup -q 30 | 31 | 32 | %build 33 | make %{?_smp_mflags} CFLAGS="%{optflags}" LUA_INCLUDE_DIR="%{_includedir}" 34 | 35 | 36 | %install 37 | rm -rf "$RPM_BUILD_ROOT" 38 | make install DESTDIR="$RPM_BUILD_ROOT" LUA_CMODULE_DIR="%{lualibdir}" 39 | make install-extra DESTDIR="$RPM_BUILD_ROOT" LUA_MODULE_DIR="%{luadatadir}" \ 40 | LUA_BIN_DIR="%{_bindir}" 41 | 42 | 43 | %clean 44 | rm -rf "$RPM_BUILD_ROOT" 45 | 46 | 47 | %preun 48 | /bin/rm -f "%{luadatadir}/cjson/tests/utf8.dat" 49 | 50 | 51 | %files 52 | %defattr(-,root,root,-) 53 | %doc LICENSE NEWS performance.html performance.txt manual.html manual.txt rfc4627.txt THANKS 54 | %{lualibdir}/* 55 | %{luadatadir}/* 56 | %{_bindir}/* 57 | 58 | 59 | %changelog 60 | * Thu Mar 1 2012 Mark Pulford - 2.1.0-1 61 | - Update for 2.1.0 62 | 63 | * Sun Jan 22 2012 Mark Pulford - 2.0.0-1 64 | - Update for 2.0.0 65 | - Install lua2json / json2lua utilities 66 | 67 | * Wed Nov 27 2011 Mark Pulford - 1.0.4-1 68 | - Update for 1.0.4 69 | 70 | * Wed Sep 15 2011 Mark Pulford - 1.0.3-1 71 | - Update for 1.0.3 72 | 73 | * Sun May 29 2011 Mark Pulford - 1.0.2-1 74 | - Update for 1.0.2 75 | 76 | * Sun May 10 2011 Mark Pulford - 1.0.1-1 77 | - Update for 1.0.1 78 | 79 | * Sun May 1 2011 Mark Pulford - 1.0-1 80 | - Initial package 81 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_cparse.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** C declaration parser. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CPARSE_H 7 | #define _LJ_CPARSE_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_ctype.h" 11 | 12 | #if LJ_HASFFI 13 | 14 | /* C parser limits. */ 15 | #define CPARSE_MAX_BUF 32768 /* Max. token buffer size. */ 16 | #define CPARSE_MAX_DECLSTACK 100 /* Max. declaration stack depth. */ 17 | #define CPARSE_MAX_DECLDEPTH 20 /* Max. recursive declaration depth. */ 18 | #define CPARSE_MAX_PACKSTACK 7 /* Max. pack pragma stack depth. */ 19 | 20 | /* Flags for C parser mode. */ 21 | #define CPARSE_MODE_MULTI 1 /* Process multiple declarations. */ 22 | #define CPARSE_MODE_ABSTRACT 2 /* Accept abstract declarators. */ 23 | #define CPARSE_MODE_DIRECT 4 /* Accept direct declarators. */ 24 | #define CPARSE_MODE_FIELD 8 /* Accept field width in bits, too. */ 25 | #define CPARSE_MODE_NOIMPLICIT 16 /* Reject implicit declarations. */ 26 | #define CPARSE_MODE_SKIP 32 /* Skip definitions, ignore errors. */ 27 | 28 | typedef int CPChar; /* C parser character. Unsigned ext. from char. */ 29 | typedef int CPToken; /* C parser token. */ 30 | 31 | /* C parser internal value representation. */ 32 | typedef struct CPValue { 33 | union { 34 | int32_t i32; /* Value for CTID_INT32. */ 35 | uint32_t u32; /* Value for CTID_UINT32. */ 36 | }; 37 | CTypeID id; /* C Type ID of the value. */ 38 | } CPValue; 39 | 40 | /* C parser state. */ 41 | typedef struct CPState { 42 | CPChar c; /* Current character. */ 43 | CPToken tok; /* Current token. */ 44 | CPValue val; /* Token value. */ 45 | GCstr *str; /* Interned string of identifier/keyword. */ 46 | CType *ct; /* C type table entry. */ 47 | const char *p; /* Current position in input buffer. */ 48 | SBuf sb; /* String buffer for tokens. */ 49 | lua_State *L; /* Lua state. */ 50 | CTState *cts; /* C type state. */ 51 | TValue *param; /* C type parameters. */ 52 | const char *srcname; /* Current source name. */ 53 | BCLine linenumber; /* Input line counter. */ 54 | int depth; /* Recursive declaration depth. */ 55 | uint32_t tmask; /* Type mask for next identifier. */ 56 | uint32_t mode; /* C parser mode. */ 57 | uint8_t packstack[CPARSE_MAX_PACKSTACK]; /* Stack for pack pragmas. */ 58 | uint8_t curpack; /* Current position in pack pragma stack. */ 59 | } CPState; 60 | 61 | LJ_FUNC int lj_cparse(CPState *cp); 62 | 63 | #endif 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/luastate.h: -------------------------------------------------------------------------------- 1 | #ifndef LUASTATE_H 2 | #define LUASTATE_H 3 | // 4 | //#include 5 | //#include 6 | // 7 | //#include "utils.h" 8 | //#include 9 | // 10 | //extern "C"{ 11 | //#include 12 | //#include 13 | //#include 14 | //} 15 | // 16 | //class LuaState : public Nan::ObjectWrap{ 17 | // public: 18 | // lua_State* lua_; 19 | // char* name_; 20 | // 21 | // static void Init(v8::Handle target); 22 | // static int CallFunction(lua_State* L); 23 | // 24 | // private: 25 | // LuaState(); 26 | // ~LuaState(); 27 | // 28 | // static v8::Handle New(const Nan::FunctionCallbackInfo& args); 29 | // static v8::Handle Close(const Nan::FunctionCallbackInfo& args); 30 | // static v8::Handle GetName(const Nan::FunctionCallbackInfo& args); 31 | // 32 | // static v8::Handle CollectGarbage(const Nan::FunctionCallbackInfo& args); 33 | // static v8::Handle CollectGarbageSync(const Nan::FunctionCallbackInfo& args); 34 | // 35 | // static v8::Handle Status(const Nan::FunctionCallbackInfo& args); 36 | // static v8::Handle StatusSync(const Nan::FunctionCallbackInfo& args); 37 | // 38 | // 39 | // static v8::Handle DoFileSync(const Nan::FunctionCallbackInfo& args); 40 | // static v8::Handle DoFile(const Nan::FunctionCallbackInfo& args); 41 | // 42 | // static v8::Handle DoStringSync(const Nan::FunctionCallbackInfo& args); 43 | // static v8::Handle DoString(const Nan::FunctionCallbackInfo& args); 44 | // 45 | // static v8::Handle SetGlobal(const Nan::FunctionCallbackInfo& args); 46 | // static v8::Handle GetGlobal(const Nan::FunctionCallbackInfo& args); 47 | // 48 | // static v8::Handle RegisterFunction(const Nan::FunctionCallbackInfo& args); 49 | // 50 | // static v8::Handle Push(const Nan::FunctionCallbackInfo& args); 51 | // static v8::Handle Pop(const Nan::FunctionCallbackInfo& args); 52 | // static v8::Handle GetTop(const Nan::FunctionCallbackInfo& args); 53 | // static v8::Handle SetTop(const Nan::FunctionCallbackInfo& args); 54 | // static v8::Handle Replace(const Nan::FunctionCallbackInfo& args); 55 | //}; 56 | #endif 57 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_cdata.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** C data management. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CDATA_H 7 | #define _LJ_CDATA_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_gc.h" 11 | #include "lj_ctype.h" 12 | 13 | #if LJ_HASFFI 14 | 15 | /* Get C data pointer. */ 16 | static LJ_AINLINE void *cdata_getptr(void *p, CTSize sz) 17 | { 18 | if (LJ_64 && sz == 4) { /* Support 32 bit pointers on 64 bit targets. */ 19 | return ((void *)(uintptr_t)*(uint32_t *)p); 20 | } else { 21 | lua_assert(sz == CTSIZE_PTR); 22 | return *(void **)p; 23 | } 24 | } 25 | 26 | /* Set C data pointer. */ 27 | static LJ_AINLINE void cdata_setptr(void *p, CTSize sz, const void *v) 28 | { 29 | if (LJ_64 && sz == 4) { /* Support 32 bit pointers on 64 bit targets. */ 30 | *(uint32_t *)p = (uint32_t)(uintptr_t)v; 31 | } else { 32 | lua_assert(sz == CTSIZE_PTR); 33 | *(void **)p = (void *)v; 34 | } 35 | } 36 | 37 | /* Allocate fixed-size C data object. */ 38 | static LJ_AINLINE GCcdata *lj_cdata_new(CTState *cts, CTypeID id, CTSize sz) 39 | { 40 | GCcdata *cd; 41 | #ifdef LUA_USE_ASSERT 42 | CType *ct = ctype_raw(cts, id); 43 | lua_assert((ctype_hassize(ct->info) ? ct->size : CTSIZE_PTR) == sz); 44 | #endif 45 | cd = (GCcdata *)lj_mem_newgco(cts->L, sizeof(GCcdata) + sz); 46 | cd->gct = ~LJ_TCDATA; 47 | cd->ctypeid = ctype_check(cts, id); 48 | return cd; 49 | } 50 | 51 | /* Variant which works without a valid CTState. */ 52 | static LJ_AINLINE GCcdata *lj_cdata_new_(lua_State *L, CTypeID id, CTSize sz) 53 | { 54 | GCcdata *cd = (GCcdata *)lj_mem_newgco(L, sizeof(GCcdata) + sz); 55 | cd->gct = ~LJ_TCDATA; 56 | cd->ctypeid = id; 57 | return cd; 58 | } 59 | 60 | LJ_FUNC GCcdata *lj_cdata_newref(CTState *cts, const void *pp, CTypeID id); 61 | LJ_FUNC GCcdata *lj_cdata_newv(lua_State *L, CTypeID id, CTSize sz, 62 | CTSize align); 63 | LJ_FUNC GCcdata *lj_cdata_newx(CTState *cts, CTypeID id, CTSize sz, 64 | CTInfo info); 65 | 66 | LJ_FUNC void LJ_FASTCALL lj_cdata_free(global_State *g, GCcdata *cd); 67 | LJ_FUNC void lj_cdata_setfin(lua_State *L, GCcdata *cd, GCobj *obj, 68 | uint32_t it); 69 | 70 | LJ_FUNC CType *lj_cdata_index(CTState *cts, GCcdata *cd, cTValue *key, 71 | uint8_t **pp, CTInfo *qual); 72 | LJ_FUNC int lj_cdata_get(CTState *cts, CType *s, TValue *o, uint8_t *sp); 73 | LJ_FUNC void lj_cdata_set(CTState *cts, CType *d, uint8_t *dp, TValue *o, 74 | CTInfo qual); 75 | 76 | #endif 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | let path = require('path'); 3 | const binary = require('node-pre-gyp'); 4 | const binding_path = binary.find(path.resolve(path.join(__dirname, 'package.json'))); 5 | const nodelua = require(binding_path); 6 | 7 | let MyCLua = nodelua['MyLuaState']; 8 | 9 | if (!nodelua) { 10 | console.error('no node lua') 11 | return; 12 | } 13 | let singleIdx = 0; 14 | 15 | class MyLua { 16 | constructor(formatprint) { 17 | if (typeof (formatprint) == 'undefined') { 18 | formatprint = true; 19 | } 20 | singleIdx++; 21 | let self = this; 22 | self.lua = new MyCLua(singleIdx); 23 | //init path 24 | let paths = ';' + __dirname + '/?.so;' + __dirname + '/build/Release/?.so;' + __dirname + '/build/Release/?.dll'; 25 | let luapaths = ';' + __dirname + '/?.lua;' + __dirname + '/test/?.lua;' + process.cwd() + '/?.lua'; 26 | let luastr = 'package.cpath = package.cpath .. "' + paths + '";package.path = package.path .. "' + luapaths + '";LUASINGLEIDX = ' + singleIdx + ';'; 27 | if (formatprint) { 28 | luastr += 'require("initlua.formatPrint");'; 29 | } 30 | if (process.platform === 'win32') { 31 | luastr = luastr.replace(new RegExp('\\\\', 'g'), '/'); 32 | } 33 | self.lua.doString(luastr, function (err, ret) { 34 | // console.log(' package path:',err,ret); 35 | if (err) { 36 | console.log('!!add find pash err:', err); 37 | console.log('lua:', luastr); 38 | } 39 | }); 40 | } 41 | 42 | doFile(fn, cb) { 43 | return this.lua.doFile(fn, cb); 44 | } 45 | 46 | doString(str, cb) { 47 | return this.lua.doString(str, cb); 48 | } 49 | 50 | /** 51 | * cb(null,status) 52 | * @param cb 53 | */ 54 | status(cb) { 55 | return this.lua.status(cb); 56 | } 57 | 58 | addPachagePath(path, isC) { 59 | let luavar = 'package.path'; 60 | if (isC) { 61 | luavar = 'package.cpath'; 62 | } 63 | let luastr = luavar + ' = ' + luavar + ' .. ";' + path + '";'; 64 | return this.lua.doString(luastr); 65 | } 66 | 67 | /** 68 | * call(funname[,args][,cb]) cb(err,ret) 69 | * @param funName 70 | * @returns {number} 71 | */ 72 | callGlobalFunction(funName) { 73 | return this.lua.callGlobalFunction.apply(this.lua, arguments); 74 | } 75 | 76 | static GC = nodelua.GC; 77 | static STATUS = nodelua.STATUS; 78 | static INFO = nodelua.INFO; 79 | } 80 | 81 | module.exports = MyLua; 82 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/etc/luajit.1: -------------------------------------------------------------------------------- 1 | .TH luajit 1 "" "" "LuaJIT documentation" 2 | .SH NAME 3 | luajit \- Just-In-Time Compiler for the Lua Language 4 | \fB 5 | .SH SYNOPSIS 6 | .B luajit 7 | [\fIoptions\fR]... [\fIscript\fR [\fIargs\fR]...] 8 | .SH "WEB SITE" 9 | .IR http://luajit.org 10 | .SH DESCRIPTION 11 | .PP 12 | This is the command-line program to run Lua programs with \fBLuaJIT\fR. 13 | .PP 14 | \fBLuaJIT\fR is a just-in-time (JIT) compiler for the Lua language. 15 | The virtual machine (VM) is based on a fast interpreter combined with 16 | a trace compiler. It can significantly improve the performance of Lua programs. 17 | .PP 18 | \fBLuaJIT\fR is API\- and ABI-compatible with the VM of the standard 19 | Lua\ 5.1 interpreter. When embedding the VM into an application, 20 | the built library can be used as a drop-in replacement. 21 | .SH OPTIONS 22 | .TP 23 | .BI "\-e " chunk 24 | Run the given chunk of Lua code. 25 | .TP 26 | .BI "\-l " library 27 | Load the named library, just like \fBrequire("\fR\fIlibrary\fR\fB")\fR. 28 | .TP 29 | .BI "\-b " ... 30 | Save or list bytecode. Run without arguments to get help on options. 31 | .TP 32 | .BI "\-j " command 33 | Perform LuaJIT control command (optional space after \fB\-j\fR). 34 | .TP 35 | .BI "\-O" [opt] 36 | Control LuaJIT optimizations. 37 | .TP 38 | .B "\-i" 39 | Run in interactive mode. 40 | .TP 41 | .B "\-v" 42 | Show \fBLuaJIT\fR version. 43 | .TP 44 | .B "\-E" 45 | Ignore environment variables. 46 | .TP 47 | .B "\-\-" 48 | Stop processing options. 49 | .TP 50 | .B "\-" 51 | Read script from stdin instead. 52 | .PP 53 | After all options are processed, the given \fIscript\fR is run. 54 | The arguments are passed in the global \fIarg\fR table. 55 | .PP 56 | Interactive mode is only entered, if no \fIscript\fR and no \fB\-e\fR 57 | option is given. Interactive mode can be left with EOF (\fICtrl\-Z\fB). 58 | .SH EXAMPLES 59 | .TP 60 | luajit hello.lua world 61 | 62 | Prints "Hello world", assuming \fIhello.lua\fR contains: 63 | .br 64 | print("Hello", arg[1]) 65 | .TP 66 | luajit \-e "local x=0; for i=1,1e9 do x=x+i end; print(x)" 67 | 68 | Calculates the sum of the numbers from 1 to 1000000000. 69 | .br 70 | And finishes in a reasonable amount of time, too. 71 | .TP 72 | luajit \-jv \-e "for i=1,10 do for j=1,10 do for k=1,100 do end end end" 73 | 74 | Runs some nested loops and shows the resulting traces. 75 | .SH COPYRIGHT 76 | .PP 77 | \fBLuaJIT\fR is Copyright \(co 2005-2017 Mike Pall. 78 | .br 79 | \fBLuaJIT\fR is open source software, released under the MIT license. 80 | .SH SEE ALSO 81 | .PP 82 | More details in the provided HTML docs or at: 83 | .IR http://luajit.org 84 | .br 85 | More about the Lua language can be found at: 86 | .IR http://lua.org/docs.html 87 | .PP 88 | lua(1) 89 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | let co = require('co') 3 | console.time('luabegin'); 4 | let MyLua = require('../'); 5 | console.timeEnd('luabegin'); 6 | console.log('test', MyLua.GC, MyLua.INFO, MyLua.STATUS); 7 | testAsyncAndSingle(); 8 | co(function* () { 9 | let lua = new MyLua(); 10 | console.log('test cjson') 11 | console.time('dostr'); 12 | let strret = yield (done) => { 13 | lua.doString(` 14 | -- cjson = require("cjson"); 15 | return {1,2,3} 16 | `, done); 17 | }; 18 | console.log('dostr test :', strret); 19 | console.timeEnd('dostr'); 20 | console.time('dostr2'); 21 | strret = yield (done) => { 22 | lua.doString(` 23 | -- cjson = require("cjson"); 24 | return {1,2,3} 25 | `, done); 26 | }; 27 | console.log('dostr test :', strret); 28 | console.timeEnd('dostr2'); 29 | console.time('dofile'); 30 | let dofileret = yield (done) => { 31 | lua.doFile(__dirname + '/luatest.lua', done); 32 | }; 33 | console.log('do file test retret:', dofileret); 34 | console.timeEnd('dofile'); 35 | console.time('status'); 36 | let status = yield (done) => { 37 | lua.status(done); 38 | }; 39 | console.log('lua status:', status, MyLua.STATUS); 40 | console.timeEnd('status'); 41 | 42 | 43 | let fs = require('fs'); 44 | console.time('fs1'); 45 | let file = yield (done) => { 46 | fs.readFile(__dirname + '/luatest.lua', done); 47 | }; 48 | console.log('file:', file.toString().split('\n')[0]); 49 | console.timeEnd('fs1'); 50 | 51 | 52 | yield (done) => { 53 | lua.callGlobalFunction('testArgAndRetGlobalCall', 11, 22, [666, 888, { 54 | 'key1': 'arrval1', 55 | 'key2': 'arrval2' 56 | }], function (err, ret, ret2, table) { 57 | console.log('callGlobalFunction!!:', err, ret, ret2, table); 58 | done(); 59 | }) 60 | }; 61 | 62 | 63 | }).catch((err) => { 64 | console.log('!! test err:', err); 65 | }); 66 | 67 | 68 | function testAsyncAndSingle() { 69 | 70 | let lua1 = new MyLua(); 71 | let lua2 = new MyLua(); 72 | 73 | lua1.doString('print("hello world") return "rettest"', function (err, ret) { 74 | console.log('lua1 dostring ret:', err, ret) 75 | }); 76 | lua2.doString('print("hello world") return "rettest"', function (err, ret) { 77 | console.log('lua2 dostring ret:', err, ret) 78 | }); 79 | 80 | 81 | lua1.doFile(__dirname + '/luatest.lua', function (err, ret) { 82 | console.log('lua1 doFile ret:', err, ret) 83 | }); 84 | 85 | 86 | lua2.doFile(__dirname + '/luatest.lua', function (err, ret) { 87 | console.log('lua2 doFile ret:', err, ret) 88 | }); 89 | 90 | } 91 | 92 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/ljamalg.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** LuaJIT core and libraries amalgamation. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | /* 7 | +--------------------------------------------------------------------------+ 8 | | WARNING: Compiling the amalgamation needs a lot of virtual memory | 9 | | (around 300 MB with GCC 4.x)! If you don't have enough physical memory | 10 | | your machine will start swapping to disk and the compile will not finish | 11 | | within a reasonable amount of time. | 12 | | So either compile on a bigger machine or use the non-amalgamated build. | 13 | +--------------------------------------------------------------------------+ 14 | */ 15 | 16 | #define ljamalg_c 17 | #define LUA_CORE 18 | 19 | /* To get the mremap prototype. Must be defined before any system includes. */ 20 | #if defined(__linux__) && !defined(_GNU_SOURCE) 21 | #define _GNU_SOURCE 22 | #endif 23 | 24 | #ifndef WINVER 25 | #define WINVER 0x0501 26 | #endif 27 | 28 | #include "lua.h" 29 | #include "lauxlib.h" 30 | 31 | #include "lj_gc.c" 32 | #include "lj_err.c" 33 | #include "lj_char.c" 34 | #include "lj_bc.c" 35 | #include "lj_obj.c" 36 | #include "lj_buf.c" 37 | #include "lj_str.c" 38 | #include "lj_tab.c" 39 | #include "lj_func.c" 40 | #include "lj_udata.c" 41 | #include "lj_meta.c" 42 | #include "lj_debug.c" 43 | #include "lj_state.c" 44 | #include "lj_dispatch.c" 45 | #include "lj_vmevent.c" 46 | #include "lj_vmmath.c" 47 | #include "lj_strscan.c" 48 | #include "lj_strfmt.c" 49 | #include "lj_strfmt_num.c" 50 | #include "lj_api.c" 51 | #include "lj_profile.c" 52 | #include "lj_lex.c" 53 | #include "lj_parse.c" 54 | #include "lj_bcread.c" 55 | #include "lj_bcwrite.c" 56 | #include "lj_load.c" 57 | #include "lj_ctype.c" 58 | #include "lj_cdata.c" 59 | #include "lj_cconv.c" 60 | #include "lj_ccall.c" 61 | #include "lj_ccallback.c" 62 | #include "lj_carith.c" 63 | #include "lj_clib.c" 64 | #include "lj_cparse.c" 65 | #include "lj_lib.c" 66 | #include "lj_ir.c" 67 | #include "lj_opt_mem.c" 68 | #include "lj_opt_fold.c" 69 | #include "lj_opt_narrow.c" 70 | #include "lj_opt_dce.c" 71 | #include "lj_opt_loop.c" 72 | #include "lj_opt_split.c" 73 | #include "lj_opt_sink.c" 74 | #include "lj_mcode.c" 75 | #include "lj_snap.c" 76 | #include "lj_record.c" 77 | #include "lj_crecord.c" 78 | #include "lj_ffrecord.c" 79 | #include "lj_asm.c" 80 | #include "lj_trace.c" 81 | #include "lj_gdbjit.c" 82 | #include "lj_alloc.c" 83 | 84 | #include "lib_aux.c" 85 | #include "lib_base.c" 86 | #include "lib_math.c" 87 | #include "lib_string.c" 88 | #include "lib_table.c" 89 | #include "lib_io.c" 90 | #include "lib_os.c" 91 | #include "lib_package.c" 92 | #include "lib_debug.c" 93 | #include "lib_bit.c" 94 | #include "lib_jit.c" 95 | #include "lib_ffi.c" 96 | #include "lib_init.c" 97 | 98 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # If Lua is installed in a non-standard location, please set the LUA_DIR 2 | # environment variable to point to prefix for the install. Eg: 3 | # Unix: export LUA_DIR=/home/user/pkg 4 | # Windows: set LUA_DIR=c:\lua51 5 | 6 | project(lua-cjson C) 7 | cmake_minimum_required(VERSION 2.6) 8 | 9 | option(USE_INTERNAL_FPCONV "Use internal strtod() / g_fmt() code for performance") 10 | option(MULTIPLE_THREADS "Support multi-threaded apps with internal fpconv - recommended" ON) 11 | 12 | if(NOT CMAKE_BUILD_TYPE) 13 | set(CMAKE_BUILD_TYPE Release CACHE STRING 14 | "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." 15 | FORCE) 16 | endif() 17 | 18 | find_package(Lua51 REQUIRED) 19 | include_directories(${LUA_INCLUDE_DIR}) 20 | 21 | if(NOT USE_INTERNAL_FPCONV) 22 | # Use libc number conversion routines (strtod(), sprintf()) 23 | set(FPCONV_SOURCES fpconv.c) 24 | else() 25 | # Use internal number conversion routines 26 | add_definitions(-DUSE_INTERNAL_FPCONV) 27 | set(FPCONV_SOURCES g_fmt.c dtoa.c) 28 | 29 | include(TestBigEndian) 30 | TEST_BIG_ENDIAN(IEEE_BIG_ENDIAN) 31 | if(IEEE_BIG_ENDIAN) 32 | add_definitions(-DIEEE_BIG_ENDIAN) 33 | endif() 34 | 35 | if(MULTIPLE_THREADS) 36 | set(CMAKE_THREAD_PREFER_PTHREAD TRUE) 37 | find_package(Threads REQUIRED) 38 | if(NOT CMAKE_USE_PTHREADS_INIT) 39 | message(FATAL_ERROR 40 | "Pthreads not found - required by MULTIPLE_THREADS option") 41 | endif() 42 | add_definitions(-DMULTIPLE_THREADS) 43 | endif() 44 | endif() 45 | 46 | # Handle platforms missing isinf() macro (Eg, some Solaris systems). 47 | include(CheckSymbolExists) 48 | CHECK_SYMBOL_EXISTS(isinf math.h HAVE_ISINF) 49 | if(NOT HAVE_ISINF) 50 | add_definitions(-DUSE_INTERNAL_ISINF) 51 | endif() 52 | 53 | set(_MODULE_LINK "${CMAKE_THREAD_LIBS_INIT}") 54 | get_filename_component(_lua_lib_dir ${LUA_LIBRARY} PATH) 55 | 56 | if(APPLE) 57 | set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS 58 | "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -undefined dynamic_lookup") 59 | endif() 60 | 61 | if(WIN32) 62 | # Win32 modules need to be linked to the Lua library. 63 | set(_MODULE_LINK ${LUA_LIBRARY} ${_MODULE_LINK}) 64 | set(_lua_module_dir "${_lua_lib_dir}") 65 | # Windows sprintf()/strtod() handle NaN/inf differently. Not supported. 66 | add_definitions(-DDISABLE_INVALID_NUMBERS) 67 | else() 68 | set(_lua_module_dir "${_lua_lib_dir}/lua/5.1") 69 | endif() 70 | 71 | add_library(cjson MODULE lua_cjson.c strbuf.c ${FPCONV_SOURCES}) 72 | set_target_properties(cjson PROPERTIES PREFIX "") 73 | target_link_libraries(cjson ${_MODULE_LINK}) 74 | install(TARGETS cjson DESTINATION "${_lua_module_dir}") 75 | 76 | # vi:ai et sw=4 ts=4: 77 | -------------------------------------------------------------------------------- /src/nodelua.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "luastate.h" 4 | #ifndef WIN32 5 | #include 6 | #else 7 | //TODO 8 | #endif 9 | #include "MyLuaState.hpp" 10 | 11 | extern "C"{ 12 | #include 13 | } 14 | 15 | 16 | void init_info_constants(Napi::Env env,Napi::Object exports){ 17 | Napi::Object constants = Napi::Object::New(env); 18 | constants.Set("VERSION", LUA_VERSION); 19 | constants.Set("VERSION_NUM", LUA_VERSION_NUM); 20 | constants.Set("COPYRIGHT", LUA_COPYRIGHT); 21 | constants.Set("AUTHORS", LUA_AUTHORS); 22 | exports.Set("INFO", constants); 23 | } 24 | 25 | 26 | void init_status_constants(Napi::Env env,Napi::Object exports){ 27 | Napi::Object constants = Napi::Object::New(env); 28 | constants.Set("YIELD", LUA_YIELD); 29 | constants.Set("ERRRUN", LUA_ERRRUN); 30 | constants.Set("ERRSYNTAX", LUA_ERRSYNTAX); 31 | constants.Set("ERRMEM", LUA_ERRMEM); 32 | constants.Set("ERRERR", LUA_ERRERR); 33 | exports.Set("STATUS", constants); 34 | } 35 | 36 | 37 | void init_gc_constants(Napi::Env env,Napi::Object exports){ 38 | Napi::Object constants = Napi::Object::New(env); 39 | constants.Set("STOP", LUA_GCSTOP); 40 | constants.Set("RESTART", LUA_GCRESTART); 41 | constants.Set("COLLECT", LUA_GCCOLLECT); 42 | constants.Set("COUNT", LUA_GCCOUNT); 43 | constants.Set("COUNTB", LUA_GCCOUNTB); 44 | constants.Set("STEP", LUA_GCSTEP); 45 | constants.Set("SETPAUSE", LUA_GCSETPAUSE); 46 | constants.Set("SETSTEPMUL", LUA_GCSETSTEPMUL); 47 | exports.Set("GC", constants); 48 | } 49 | 50 | /* 51 | void init(v8::Local exports, v8::Local module) { 52 | // LuaState::Init(exports); 53 | MyLuaState::Init(exports); 54 | init_gc_constants(exports); 55 | init_status_constants(exports); 56 | init_info_constants(exports); 57 | printf("node-lua loaded\n"); 58 | fflush(stdout); 59 | // auto L = luaL_newstate(); 60 | // if(L){ 61 | // char buf[80]; 62 | // getcwd(buf,sizeof(buf)); 63 | // printf("havahave have2222\n"); 64 | // printf("cwd:%s\n",buf); 65 | // luaL_openlibs(L); 66 | // auto ret = luaL_dostring(L,"print('path:' .. package.path);"); 67 | // if(ret){ 68 | // printf("err:%s\n",lua_tostring(L,-1)); 69 | // } 70 | // lua_close(L); 71 | // }else{ 72 | // printf("not not not \n"); 73 | // } 74 | 75 | } 76 | */ 77 | 78 | 79 | Napi::Object InitAll(Napi::Env env, Napi::Object exports) { 80 | // return List::Init(env, exports); 81 | MyLuaState::Init(env,exports); 82 | init_gc_constants(env,exports); 83 | init_status_constants(env,exports); 84 | init_info_constants(env,exports); 85 | printf("node-lua loaded\n"); 86 | fflush(stdout); 87 | return exports; 88 | } 89 | 90 | NODE_API_MODULE(nodelua, InitAll) 91 | -------------------------------------------------------------------------------- /win64luajit/luajit.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/ 3 | ** 4 | ** Copyright (C) 2005-2014 Mike Pall. All rights reserved. 5 | ** 6 | ** Permission is hereby granted, free of charge, to any person obtaining 7 | ** a copy of this software and associated documentation files (the 8 | ** "Software"), to deal in the Software without restriction, including 9 | ** without limitation the rights to use, copy, modify, merge, publish, 10 | ** distribute, sublicense, and/or sell copies of the Software, and to 11 | ** permit persons to whom the Software is furnished to do so, subject to 12 | ** the following conditions: 13 | ** 14 | ** The above copyright notice and this permission notice shall be 15 | ** included in all copies or substantial portions of the Software. 16 | ** 17 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | ** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | ** 25 | ** [ MIT license: http://www.opensource.org/licenses/mit-license.php ] 26 | */ 27 | 28 | #ifndef _LUAJIT_H 29 | #define _LUAJIT_H 30 | 31 | #include "lua.h" 32 | 33 | #define LUAJIT_VERSION "LuaJIT 2.0.3" 34 | #define LUAJIT_VERSION_NUM 20003 /* Version 2.0.3 = 02.00.03. */ 35 | #define LUAJIT_VERSION_SYM luaJIT_version_2_0_3 36 | #define LUAJIT_COPYRIGHT "Copyright (C) 2005-2014 Mike Pall" 37 | #define LUAJIT_URL "http://luajit.org/" 38 | 39 | /* Modes for luaJIT_setmode. */ 40 | #define LUAJIT_MODE_MASK 0x00ff 41 | 42 | enum { 43 | LUAJIT_MODE_ENGINE, /* Set mode for whole JIT engine. */ 44 | LUAJIT_MODE_DEBUG, /* Set debug mode (idx = level). */ 45 | 46 | LUAJIT_MODE_FUNC, /* Change mode for a function. */ 47 | LUAJIT_MODE_ALLFUNC, /* Recurse into subroutine protos. */ 48 | LUAJIT_MODE_ALLSUBFUNC, /* Change only the subroutines. */ 49 | 50 | LUAJIT_MODE_TRACE, /* Flush a compiled trace. */ 51 | 52 | LUAJIT_MODE_WRAPCFUNC = 0x10, /* Set wrapper mode for C function calls. */ 53 | 54 | LUAJIT_MODE_MAX 55 | }; 56 | 57 | /* Flags or'ed in to the mode. */ 58 | #define LUAJIT_MODE_OFF 0x0000 /* Turn feature off. */ 59 | #define LUAJIT_MODE_ON 0x0100 /* Turn feature on. */ 60 | #define LUAJIT_MODE_FLUSH 0x0200 /* Flush JIT-compiled code. */ 61 | 62 | /* LuaJIT public C API. */ 63 | 64 | /* Control the JIT engine. */ 65 | LUA_API int luaJIT_setmode(lua_State *L, int idx, int mode); 66 | 67 | /* Enforce (dynamic) linker error for version mismatches. Call from main. */ 68 | LUA_API void LUAJIT_VERSION_SYM(void); 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_tab.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Table handling. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_TAB_H 7 | #define _LJ_TAB_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Hash constants. Tuned using a brute force search. */ 12 | #define HASH_BIAS (-0x04c11db7) 13 | #define HASH_ROT1 14 14 | #define HASH_ROT2 5 15 | #define HASH_ROT3 13 16 | 17 | /* Scramble the bits of numbers and pointers. */ 18 | static LJ_AINLINE uint32_t hashrot(uint32_t lo, uint32_t hi) 19 | { 20 | #if LJ_TARGET_X86ORX64 21 | /* Prefer variant that compiles well for a 2-operand CPU. */ 22 | lo ^= hi; hi = lj_rol(hi, HASH_ROT1); 23 | lo -= hi; hi = lj_rol(hi, HASH_ROT2); 24 | hi ^= lo; hi -= lj_rol(lo, HASH_ROT3); 25 | #else 26 | lo ^= hi; 27 | lo = lo - lj_rol(hi, HASH_ROT1); 28 | hi = lo ^ lj_rol(hi, HASH_ROT1 + HASH_ROT2); 29 | hi = hi - lj_rol(lo, HASH_ROT3); 30 | #endif 31 | return hi; 32 | } 33 | 34 | #define hsize2hbits(s) ((s) ? ((s)==1 ? 1 : 1+lj_fls((uint32_t)((s)-1))) : 0) 35 | 36 | LJ_FUNCA GCtab *lj_tab_new(lua_State *L, uint32_t asize, uint32_t hbits); 37 | LJ_FUNC GCtab *lj_tab_new_ah(lua_State *L, int32_t a, int32_t h); 38 | #if LJ_HASJIT 39 | LJ_FUNC GCtab * LJ_FASTCALL lj_tab_new1(lua_State *L, uint32_t ahsize); 40 | #endif 41 | LJ_FUNCA GCtab * LJ_FASTCALL lj_tab_dup(lua_State *L, const GCtab *kt); 42 | LJ_FUNC void LJ_FASTCALL lj_tab_clear(GCtab *t); 43 | LJ_FUNC void LJ_FASTCALL lj_tab_free(global_State *g, GCtab *t); 44 | #if LJ_HASFFI 45 | LJ_FUNC void lj_tab_rehash(lua_State *L, GCtab *t); 46 | #endif 47 | LJ_FUNC void lj_tab_resize(lua_State *L, GCtab *t, uint32_t asize, uint32_t hbits); 48 | LJ_FUNCA void lj_tab_reasize(lua_State *L, GCtab *t, uint32_t nasize); 49 | 50 | /* Caveat: all getters except lj_tab_get() can return NULL! */ 51 | 52 | LJ_FUNCA cTValue * LJ_FASTCALL lj_tab_getinth(GCtab *t, int32_t key); 53 | LJ_FUNC cTValue *lj_tab_getstr(GCtab *t, GCstr *key); 54 | LJ_FUNCA cTValue *lj_tab_get(lua_State *L, GCtab *t, cTValue *key); 55 | 56 | /* Caveat: all setters require a write barrier for the stored value. */ 57 | 58 | LJ_FUNCA TValue *lj_tab_newkey(lua_State *L, GCtab *t, cTValue *key); 59 | LJ_FUNCA TValue *lj_tab_setinth(lua_State *L, GCtab *t, int32_t key); 60 | LJ_FUNC TValue *lj_tab_setstr(lua_State *L, GCtab *t, GCstr *key); 61 | LJ_FUNC TValue *lj_tab_set(lua_State *L, GCtab *t, cTValue *key); 62 | 63 | #define inarray(t, key) ((MSize)(key) < (MSize)(t)->asize) 64 | #define arrayslot(t, i) (&tvref((t)->array)[(i)]) 65 | #define lj_tab_getint(t, key) \ 66 | (inarray((t), (key)) ? arrayslot((t), (key)) : lj_tab_getinth((t), (key))) 67 | #define lj_tab_setint(L, t, key) \ 68 | (inarray((t), (key)) ? arrayslot((t), (key)) : lj_tab_setinth(L, (t), (key))) 69 | 70 | LJ_FUNCA int lj_tab_next(lua_State *L, GCtab *t, TValue *key); 71 | LJ_FUNCA MSize LJ_FASTCALL lj_tab_len(GCtab *t); 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Node-luajit binding 3 | 4 | support npai version 6(node minimum version v10.20.0). 5 | 6 | need lower version check the branch 8.x-10.x or 6.x. 7 | 8 | 9 | #### Cross platform. (win,mac,linux)[x64] 10 | similar as `https://github.com/brettlangdon/NodeLua` 11 | 12 | 13 | ## feature 14 | 15 | 1. nodejs -> lua is async. 16 | 2. nodejs -> lua in queue, so lua internal is sync. 17 | 3. all luaState are independent. 18 | 4. now lua can't call nodejs direct. 19 | 5. add,linux auto compile luajit.[2018-01-29] http://luajit.org/download/LuaJIT-2.1.0-beta3.tar.gz 20 | 6. add, cjson compile and auto load. [2018-01-29] https://github.com/openresty/lua-cjson/archive/master.zip 21 | 7. > win64 need fix. 22 | 8. support napi. support node 10.20.x-14.x [2021-01-06] 23 | 24 | 25 | ##Installation 26 | 27 | `npm install node-luajit` 28 | ``` 29 | // some times maybe need 30 | npm install node-luajit --unsafe-perm 31 | 32 | ``` 33 | 34 | #### node napi 35 | 36 | Linux build luajit 37 | ``` 38 | git clone https://github.com/LuaJIT/LuaJIT.git 39 | make 40 | sudo make install 41 | ``` 42 | 43 | and need add one line `/usr/local/lib` to ` /etc/ld.so.conf` file, and run `「/sbin/ldconfig –v」` refresh. 44 | 45 | or 46 | 47 | ``` 48 | ln -s /usr/local/lib/libluajit-5.1.so.2.0.4 /usr/lib 49 | 50 | sudo ldconfig 51 | ``` 52 | 53 | 54 | ## simple usage 55 | 56 | ```js 57 | var MyLua = require('node-luajit'); 58 | var lua = new MyLua(); 59 | 60 | lua.doString('print("hello world") return "rettest"',function(err,ret){ 61 | console.log('dostring ret:',err,ret) 62 | }); 63 | 64 | 65 | 66 | lua.doFile(__dirname+'/test/luatest.lua',function(err,ret){ 67 | console.log('doFile ret:',err,ret) 68 | }); 69 | 70 | 71 | 72 | lua.callGlobalFunction('print',11,22,function(err,ret){ 73 | console.log('callGlobalFunction!!:',err,ret); 74 | }) 75 | 76 | var lua1 = new MyLua(); 77 | var lua2 = new MyLua(); 78 | 79 | lua1.doString('print("hello world") return "rettest"',function(err,ret){ 80 | console.log('lua1 dostring ret:',err,ret) 81 | }); 82 | lua2.doString('print("hello world") return "rettest"',function(err,ret){ 83 | console.log('lua2 dostring ret:',err,ret) 84 | }); 85 | 86 | 87 | lua1.doFile(__dirname+'/luatest.lua',function(err,ret){ 88 | console.log('lua1 doFile ret:',err,ret) 89 | }); 90 | 91 | 92 | 93 | lua2.doFile(__dirname+'/luatest.lua',function(err,ret){ 94 | console.log('lua2 doFile ret:',err,ret) 95 | }); 96 | 97 | 98 | 99 | 100 | ``` 101 | 102 | ### development 103 | 104 | 105 | generate xcode project: 106 | 107 | `node-gyp configure --debug -- -f xcode` 108 | 109 | if got `TypeError: 'cmp' is an invalid keyword argument for sort()` error. 110 | 111 | 112 | use `python2` instead, such as `PYTHON=/usr/bin/python node-gyp configure -- -f xcode` 113 | 114 | Now you should have a ./build/binding.xcodeproj which you can open. 115 | 116 | Configure the executable of the project in Xcode as node and debug away :) 117 | 118 | 119 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/g_fmt.c: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * The author of this software is David M. Gay. 4 | * 5 | * Copyright (c) 1991, 1996 by Lucent Technologies. 6 | * 7 | * Permission to use, copy, modify, and distribute this software for any 8 | * purpose without fee is hereby granted, provided that this entire notice 9 | * is included in all copies of any software which is or includes a copy 10 | * or modification of this software and in all copies of the supporting 11 | * documentation for such software. 12 | * 13 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 14 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY 15 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 16 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 17 | * 18 | ***************************************************************/ 19 | 20 | /* g_fmt(buf,x) stores the closest decimal approximation to x in buf; 21 | * it suffices to declare buf 22 | * char buf[32]; 23 | */ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | extern char *dtoa(double, int, int, int *, int *, char **); 29 | extern int g_fmt(char *, double, int); 30 | extern void freedtoa(char*); 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | int 36 | fpconv_g_fmt(char *b, double x, int precision) 37 | { 38 | register int i, k; 39 | register char *s; 40 | int decpt, j, sign; 41 | char *b0, *s0, *se; 42 | 43 | b0 = b; 44 | #ifdef IGNORE_ZERO_SIGN 45 | if (!x) { 46 | *b++ = '0'; 47 | *b = 0; 48 | goto done; 49 | } 50 | #endif 51 | s = s0 = dtoa(x, 2, precision, &decpt, &sign, &se); 52 | if (sign) 53 | *b++ = '-'; 54 | if (decpt == 9999) /* Infinity or Nan */ { 55 | while((*b++ = *s++)); 56 | /* "b" is used to calculate the return length. Decrement to exclude the 57 | * Null terminator from the length */ 58 | b--; 59 | goto done0; 60 | } 61 | if (decpt <= -4 || decpt > precision) { 62 | *b++ = *s++; 63 | if (*s) { 64 | *b++ = '.'; 65 | while((*b = *s++)) 66 | b++; 67 | } 68 | *b++ = 'e'; 69 | /* sprintf(b, "%+.2d", decpt - 1); */ 70 | if (--decpt < 0) { 71 | *b++ = '-'; 72 | decpt = -decpt; 73 | } 74 | else 75 | *b++ = '+'; 76 | for(j = 2, k = 10; 10*k <= decpt; j++, k *= 10); 77 | for(;;) { 78 | i = decpt / k; 79 | *b++ = i + '0'; 80 | if (--j <= 0) 81 | break; 82 | decpt -= i*k; 83 | decpt *= 10; 84 | } 85 | *b = 0; 86 | } 87 | else if (decpt <= 0) { 88 | *b++ = '0'; 89 | *b++ = '.'; 90 | for(; decpt < 0; decpt++) 91 | *b++ = '0'; 92 | while((*b++ = *s++)); 93 | b--; 94 | } 95 | else { 96 | while((*b = *s++)) { 97 | b++; 98 | if (--decpt == 0 && *s) 99 | *b++ = '.'; 100 | } 101 | for(; decpt > 0; decpt--) 102 | *b++ = '0'; 103 | *b = 0; 104 | } 105 | done0: 106 | freedtoa(s0); 107 | #ifdef IGNORE_ZERO_SIGN 108 | done: 109 | #endif 110 | return b - b0; 111 | } 112 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/host/buildvm_libbc.h: -------------------------------------------------------------------------------- 1 | /* This is a generated file. DO NOT EDIT! */ 2 | 3 | static const int libbc_endian = 0; 4 | 5 | static const uint8_t libbc_code[] = { 6 | #if LJ_FR2 7 | 0,1,2,0,0,1,2,24,1,0,0,76,1,2,0,241,135,158,166,3,220,203,178,130,4,0,1,2,0, 8 | 0,1,2,24,1,0,0,76,1,2,0,243,244,148,165,20,198,190,199,252,3,0,1,2,0,0,0,3, 9 | 16,0,5,0,21,1,0,0,76,1,2,0,0,2,10,0,0,0,15,16,0,12,0,16,1,9,0,41,2,1,0,21,3, 10 | 0,0,41,4,1,0,77,2,8,128,18,6,1,0,18,8,5,0,59,9,5,0,66,6,3,2,10,6,0,0,88,7,1, 11 | 128,76,6,2,0,79,2,248,127,75,0,1,0,0,2,11,0,0,0,16,16,0,12,0,16,1,9,0,43,2, 12 | 0,0,18,3,0,0,41,4,0,0,88,5,7,128,18,7,1,0,18,9,5,0,18,10,6,0,66,7,3,2,10,7, 13 | 0,0,88,8,1,128,76,7,2,0,70,5,3,3,82,5,247,127,75,0,1,0,0,1,2,0,0,0,3,16,0,12, 14 | 0,21,1,0,0,76,1,2,0,0,2,10,0,0,2,30,16,0,12,0,21,2,0,0,11,1,0,0,88,3,7,128, 15 | 8,2,0,0,88,3,23,128,59,3,2,0,43,4,0,0,64,4,2,0,76,3,2,0,88,3,18,128,16,1,14, 16 | 0,41,3,1,0,3,3,1,0,88,3,14,128,3,1,2,0,88,3,12,128,59,3,1,0,22,4,1,1,18,5,2, 17 | 0,41,6,1,0,77,4,4,128,23,8,1,7,59,9,7,0,64,9,8,0,79,4,252,127,43,4,0,0,64,4, 18 | 2,0,76,3,2,0,75,0,1,0,0,2,0,5,12,0,0,0,35,16,0,12,0,16,1,14,0,16,2,14,0,16, 19 | 3,14,0,11,4,0,0,88,5,1,128,18,4,0,0,16,4,12,0,3,1,2,0,88,5,24,128,33,5,1,3, 20 | 0,2,3,0,88,6,4,128,2,3,1,0,88,6,2,128,4,4,0,0,88,6,9,128,18,6,1,0,18,7,2,0, 21 | 41,8,1,0,77,6,4,128,32,10,5,9,59,11,9,0,64,11,10,4,79,6,252,127,88,6,8,128, 22 | 18,6,2,0,18,7,1,0,41,8,255,255,77,6,4,128,32,10,5,9,59,11,9,0,64,11,10,4,79, 23 | 6,252,127,76,4,2,0,0 24 | #else 25 | 0,1,2,0,0,1,2,24,1,0,0,76,1,2,0,241,135,158,166,3,220,203,178,130,4,0,1,2,0, 26 | 0,1,2,24,1,0,0,76,1,2,0,243,244,148,165,20,198,190,199,252,3,0,1,2,0,0,0,3, 27 | 16,0,5,0,21,1,0,0,76,1,2,0,0,2,9,0,0,0,15,16,0,12,0,16,1,9,0,41,2,1,0,21,3, 28 | 0,0,41,4,1,0,77,2,8,128,18,6,1,0,18,7,5,0,59,8,5,0,66,6,3,2,10,6,0,0,88,7,1, 29 | 128,76,6,2,0,79,2,248,127,75,0,1,0,0,2,10,0,0,0,16,16,0,12,0,16,1,9,0,43,2, 30 | 0,0,18,3,0,0,41,4,0,0,88,5,7,128,18,7,1,0,18,8,5,0,18,9,6,0,66,7,3,2,10,7,0, 31 | 0,88,8,1,128,76,7,2,0,70,5,3,3,82,5,247,127,75,0,1,0,0,1,2,0,0,0,3,16,0,12, 32 | 0,21,1,0,0,76,1,2,0,0,2,10,0,0,2,30,16,0,12,0,21,2,0,0,11,1,0,0,88,3,7,128, 33 | 8,2,0,0,88,3,23,128,59,3,2,0,43,4,0,0,64,4,2,0,76,3,2,0,88,3,18,128,16,1,14, 34 | 0,41,3,1,0,3,3,1,0,88,3,14,128,3,1,2,0,88,3,12,128,59,3,1,0,22,4,1,1,18,5,2, 35 | 0,41,6,1,0,77,4,4,128,23,8,1,7,59,9,7,0,64,9,8,0,79,4,252,127,43,4,0,0,64,4, 36 | 2,0,76,3,2,0,75,0,1,0,0,2,0,5,12,0,0,0,35,16,0,12,0,16,1,14,0,16,2,14,0,16, 37 | 3,14,0,11,4,0,0,88,5,1,128,18,4,0,0,16,4,12,0,3,1,2,0,88,5,24,128,33,5,1,3, 38 | 0,2,3,0,88,6,4,128,2,3,1,0,88,6,2,128,4,4,0,0,88,6,9,128,18,6,1,0,18,7,2,0, 39 | 41,8,1,0,77,6,4,128,32,10,5,9,59,11,9,0,64,11,10,4,79,6,252,127,88,6,8,128, 40 | 18,6,2,0,18,7,1,0,41,8,255,255,77,6,4,128,32,10,5,9,59,11,9,0,64,11,10,4,79, 41 | 6,252,127,76,4,2,0,0 42 | #endif 43 | }; 44 | 45 | static const struct { const char *name; int ofs; } libbc_map[] = { 46 | {"math_deg",0}, 47 | {"math_rad",25}, 48 | {"string_len",50}, 49 | {"table_foreachi",69}, 50 | {"table_foreach",136}, 51 | {"table_getn",207}, 52 | {"table_remove",226}, 53 | {"table_move",355}, 54 | {NULL,502} 55 | }; 56 | 57 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/COPYRIGHT: -------------------------------------------------------------------------------- 1 | =============================================================================== 2 | LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/ 3 | 4 | Copyright (C) 2005-2017 Mike Pall. All rights reserved. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | 24 | [ MIT license: http://www.opensource.org/licenses/mit-license.php ] 25 | 26 | =============================================================================== 27 | [ LuaJIT includes code from Lua 5.1/5.2, which has this license statement: ] 28 | 29 | Copyright (C) 1994-2012 Lua.org, PUC-Rio. 30 | 31 | Permission is hereby granted, free of charge, to any person obtaining a copy 32 | of this software and associated documentation files (the "Software"), to deal 33 | in the Software without restriction, including without limitation the rights 34 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 35 | copies of the Software, and to permit persons to whom the Software is 36 | furnished to do so, subject to the following conditions: 37 | 38 | The above copyright notice and this permission notice shall be included in 39 | all copies or substantial portions of the Software. 40 | 41 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 42 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 43 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 44 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 45 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 46 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 47 | THE SOFTWARE. 48 | 49 | =============================================================================== 50 | [ LuaJIT includes code from dlmalloc, which has this license statement: ] 51 | 52 | This is a version (aka dlmalloc) of malloc/free/realloc written by 53 | Doug Lea and released to the public domain, as explained at 54 | http://creativecommons.org/licenses/publicdomain 55 | 56 | =============================================================================== 57 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/host/buildvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** LuaJIT VM builder. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _BUILDVM_H 7 | #define _BUILDVM_H 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "lj_def.h" 16 | #include "lj_arch.h" 17 | 18 | /* Hardcoded limits. Increase as needed. */ 19 | #define BUILD_MAX_RELOC 200 /* Max. number of relocations. */ 20 | #define BUILD_MAX_FOLD 4096 /* Max. number of fold rules. */ 21 | 22 | /* Prefix for scanned library definitions. */ 23 | #define LIBDEF_PREFIX "LJLIB_" 24 | 25 | /* Prefix for scanned fold definitions. */ 26 | #define FOLDDEF_PREFIX "LJFOLD" 27 | 28 | /* Prefixes for generated labels. */ 29 | #define LABEL_PREFIX "lj_" 30 | #define LABEL_PREFIX_BC LABEL_PREFIX "BC_" 31 | #define LABEL_PREFIX_FF LABEL_PREFIX "ff_" 32 | #define LABEL_PREFIX_CF LABEL_PREFIX "cf_" 33 | #define LABEL_PREFIX_FFH LABEL_PREFIX "ffh_" 34 | #define LABEL_PREFIX_LIBCF LABEL_PREFIX "lib_cf_" 35 | #define LABEL_PREFIX_LIBINIT LABEL_PREFIX "lib_init_" 36 | 37 | /* Forward declaration. */ 38 | struct dasm_State; 39 | 40 | /* Build modes. */ 41 | #define BUILDDEF(_) \ 42 | _(elfasm) _(coffasm) _(machasm) _(peobj) _(raw) \ 43 | _(bcdef) _(ffdef) _(libdef) _(recdef) _(vmdef) \ 44 | _(folddef) 45 | 46 | typedef enum { 47 | #define BUILDENUM(name) BUILD_##name, 48 | BUILDDEF(BUILDENUM) 49 | #undef BUILDENUM 50 | BUILD__MAX 51 | } BuildMode; 52 | 53 | /* Code relocation. */ 54 | typedef struct BuildReloc { 55 | int32_t ofs; 56 | int sym; 57 | int type; 58 | } BuildReloc; 59 | 60 | typedef struct BuildSym { 61 | const char *name; 62 | int32_t ofs; 63 | } BuildSym; 64 | 65 | /* Build context structure. */ 66 | typedef struct BuildCtx { 67 | /* DynASM state pointer. Should be first member. */ 68 | struct dasm_State *D; 69 | /* Parsed command line. */ 70 | BuildMode mode; 71 | FILE *fp; 72 | const char *outname; 73 | char **args; 74 | /* Code and symbols generated by DynASM. */ 75 | uint8_t *code; 76 | size_t codesz; 77 | int npc, nglob, nsym, nreloc, nrelocsym; 78 | void **glob; 79 | BuildSym *sym; 80 | const char **relocsym; 81 | int32_t *bc_ofs; 82 | const char *beginsym; 83 | /* Strings generated by DynASM. */ 84 | const char *const *globnames; 85 | const char *const *extnames; 86 | const char *dasm_ident; 87 | const char *dasm_arch; 88 | /* Relocations. */ 89 | BuildReloc reloc[BUILD_MAX_RELOC]; 90 | } BuildCtx; 91 | 92 | extern void owrite(BuildCtx *ctx, const void *ptr, size_t sz); 93 | extern void emit_asm(BuildCtx *ctx); 94 | extern void emit_peobj(BuildCtx *ctx); 95 | extern void emit_lib(BuildCtx *ctx); 96 | extern void emit_fold(BuildCtx *ctx); 97 | 98 | extern const char *const bc_names[]; 99 | extern const char *const ir_names[]; 100 | extern const char *const irt_names[]; 101 | extern const char *const irfpm_names[]; 102 | extern const char *const irfield_names[]; 103 | extern const char *const ircall_names[]; 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/luajit.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/ 3 | ** 4 | ** Copyright (C) 2005-2017 Mike Pall. All rights reserved. 5 | ** 6 | ** Permission is hereby granted, free of charge, to any person obtaining 7 | ** a copy of this software and associated documentation files (the 8 | ** "Software"), to deal in the Software without restriction, including 9 | ** without limitation the rights to use, copy, modify, merge, publish, 10 | ** distribute, sublicense, and/or sell copies of the Software, and to 11 | ** permit persons to whom the Software is furnished to do so, subject to 12 | ** the following conditions: 13 | ** 14 | ** The above copyright notice and this permission notice shall be 15 | ** included in all copies or substantial portions of the Software. 16 | ** 17 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | ** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | ** 25 | ** [ MIT license: http://www.opensource.org/licenses/mit-license.php ] 26 | */ 27 | 28 | #ifndef _LUAJIT_H 29 | #define _LUAJIT_H 30 | 31 | #include "lua.h" 32 | 33 | #define LUAJIT_VERSION "LuaJIT 2.1.0-beta3" 34 | #define LUAJIT_VERSION_NUM 20100 /* Version 2.1.0 = 02.01.00. */ 35 | #define LUAJIT_VERSION_SYM luaJIT_version_2_1_0_beta3 36 | #define LUAJIT_COPYRIGHT "Copyright (C) 2005-2017 Mike Pall" 37 | #define LUAJIT_URL "http://luajit.org/" 38 | 39 | /* Modes for luaJIT_setmode. */ 40 | #define LUAJIT_MODE_MASK 0x00ff 41 | 42 | enum { 43 | LUAJIT_MODE_ENGINE, /* Set mode for whole JIT engine. */ 44 | LUAJIT_MODE_DEBUG, /* Set debug mode (idx = level). */ 45 | 46 | LUAJIT_MODE_FUNC, /* Change mode for a function. */ 47 | LUAJIT_MODE_ALLFUNC, /* Recurse into subroutine protos. */ 48 | LUAJIT_MODE_ALLSUBFUNC, /* Change only the subroutines. */ 49 | 50 | LUAJIT_MODE_TRACE, /* Flush a compiled trace. */ 51 | 52 | LUAJIT_MODE_WRAPCFUNC = 0x10, /* Set wrapper mode for C function calls. */ 53 | 54 | LUAJIT_MODE_MAX 55 | }; 56 | 57 | /* Flags or'ed in to the mode. */ 58 | #define LUAJIT_MODE_OFF 0x0000 /* Turn feature off. */ 59 | #define LUAJIT_MODE_ON 0x0100 /* Turn feature on. */ 60 | #define LUAJIT_MODE_FLUSH 0x0200 /* Flush JIT-compiled code. */ 61 | 62 | /* LuaJIT public C API. */ 63 | 64 | /* Control the JIT engine. */ 65 | LUA_API int luaJIT_setmode(lua_State *L, int idx, int mode); 66 | 67 | /* Low-overhead profiling API. */ 68 | typedef void (*luaJIT_profile_callback)(void *data, lua_State *L, 69 | int samples, int vmstate); 70 | LUA_API void luaJIT_profile_start(lua_State *L, const char *mode, 71 | luaJIT_profile_callback cb, void *data); 72 | LUA_API void luaJIT_profile_stop(lua_State *L); 73 | LUA_API const char *luaJIT_profile_dumpstack(lua_State *L, const char *fmt, 74 | int depth, size_t *len); 75 | 76 | /* Enforce (dynamic) linker error for version mismatches. Call from main. */ 77 | LUA_API void LUAJIT_VERSION_SYM(void); 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/doc/bluequad-print.css: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004-2017 Mike Pall. 2 | * 3 | * You are welcome to use the general ideas of this design for your own sites. 4 | * But please do not steal the stylesheet, the layout or the color scheme. 5 | */ 6 | body { 7 | font-family: serif; 8 | font-size: 11pt; 9 | margin: 0 3em; 10 | padding: 0; 11 | border: none; 12 | } 13 | a:link, a:visited, a:hover, a:active { 14 | text-decoration: none; 15 | background: transparent; 16 | color: #0000ff; 17 | } 18 | h1, h2, h3 { 19 | font-family: sans-serif; 20 | font-weight: bold; 21 | text-align: left; 22 | margin: 0.5em 0; 23 | padding: 0; 24 | } 25 | h1 { 26 | font-size: 200%; 27 | } 28 | h2 { 29 | font-size: 150%; 30 | } 31 | h3 { 32 | font-size: 125%; 33 | } 34 | p { 35 | margin: 0 0 0.5em 0; 36 | padding: 0; 37 | } 38 | ul, ol { 39 | margin: 0.5em 0; 40 | padding: 0 0 0 2em; 41 | } 42 | ul { 43 | list-style: outside square; 44 | } 45 | ol { 46 | list-style: outside decimal; 47 | } 48 | li { 49 | margin: 0; 50 | padding: 0; 51 | } 52 | dl { 53 | margin: 1em 0; 54 | padding: 1em; 55 | border: 1px solid black; 56 | } 57 | dt { 58 | font-weight: bold; 59 | margin: 0; 60 | padding: 0; 61 | } 62 | dt sup { 63 | float: right; 64 | margin-left: 1em; 65 | } 66 | dd { 67 | margin: 0.5em 0 0 2em; 68 | padding: 0; 69 | } 70 | table { 71 | table-layout: fixed; 72 | width: 100%; 73 | margin: 1em 0; 74 | padding: 0; 75 | border: 1px solid black; 76 | border-spacing: 0; 77 | border-collapse: collapse; 78 | } 79 | tr { 80 | margin: 0; 81 | padding: 0; 82 | border: none; 83 | } 84 | td { 85 | text-align: left; 86 | margin: 0; 87 | padding: 0.2em 0.5em; 88 | border-top: 1px solid black; 89 | border-bottom: 1px solid black; 90 | } 91 | tr.separate td { 92 | border-top: double; 93 | } 94 | tt, pre, code, kbd, samp { 95 | font-family: monospace; 96 | font-size: 75%; 97 | } 98 | kbd { 99 | font-weight: bolder; 100 | } 101 | blockquote, pre { 102 | margin: 1em 2em; 103 | padding: 0; 104 | } 105 | img { 106 | border: none; 107 | vertical-align: baseline; 108 | margin: 0; 109 | padding: 0; 110 | } 111 | img.left { 112 | float: left; 113 | margin: 0.5em 1em 0.5em 0; 114 | } 115 | img.right { 116 | float: right; 117 | margin: 0.5em 0 0.5em 1em; 118 | } 119 | .flush { 120 | clear: both; 121 | visibility: hidden; 122 | } 123 | .hide, .noprint, #nav { 124 | display: none !important; 125 | } 126 | .pagebreak { 127 | page-break-before: always; 128 | } 129 | #site { 130 | text-align: right; 131 | font-family: sans-serif; 132 | font-weight: bold; 133 | margin: 0 1em; 134 | border-bottom: 1pt solid black; 135 | } 136 | #site a { 137 | font-size: 1.2em; 138 | } 139 | #site a:link, #site a:visited { 140 | text-decoration: none; 141 | font-weight: bold; 142 | background: transparent; 143 | color: #ffffff; 144 | } 145 | #logo { 146 | color: #ff8000; 147 | } 148 | #head { 149 | clear: both; 150 | margin: 0 1em; 151 | } 152 | #main { 153 | line-height: 1.3; 154 | text-align: justify; 155 | margin: 1em; 156 | } 157 | #foot { 158 | clear: both; 159 | font-size: 80%; 160 | text-align: center; 161 | margin: 0 1.25em; 162 | padding: 0.5em 0 0 0; 163 | border-top: 1pt solid black; 164 | page-break-before: avoid; 165 | page-break-after: avoid; 166 | } 167 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_buf.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Buffer handling. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_BUF_H 7 | #define _LJ_BUF_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_gc.h" 11 | #include "lj_str.h" 12 | 13 | /* Resizable string buffers. Struct definition in lj_obj.h. */ 14 | #define sbufB(sb) (mref((sb)->b, char)) 15 | #define sbufP(sb) (mref((sb)->p, char)) 16 | #define sbufE(sb) (mref((sb)->e, char)) 17 | #define sbufL(sb) (mref((sb)->L, lua_State)) 18 | #define sbufsz(sb) ((MSize)(sbufE((sb)) - sbufB((sb)))) 19 | #define sbuflen(sb) ((MSize)(sbufP((sb)) - sbufB((sb)))) 20 | #define sbufleft(sb) ((MSize)(sbufE((sb)) - sbufP((sb)))) 21 | #define setsbufP(sb, q) (setmref((sb)->p, (q))) 22 | #define setsbufL(sb, l) (setmref((sb)->L, (l))) 23 | 24 | /* Buffer management */ 25 | LJ_FUNC char *LJ_FASTCALL lj_buf_need2(SBuf *sb, MSize sz); 26 | LJ_FUNC char *LJ_FASTCALL lj_buf_more2(SBuf *sb, MSize sz); 27 | LJ_FUNC void LJ_FASTCALL lj_buf_shrink(lua_State *L, SBuf *sb); 28 | LJ_FUNC char * LJ_FASTCALL lj_buf_tmp(lua_State *L, MSize sz); 29 | 30 | static LJ_AINLINE void lj_buf_init(lua_State *L, SBuf *sb) 31 | { 32 | setsbufL(sb, L); 33 | setmref(sb->p, NULL); setmref(sb->e, NULL); setmref(sb->b, NULL); 34 | } 35 | 36 | static LJ_AINLINE void lj_buf_reset(SBuf *sb) 37 | { 38 | setmrefr(sb->p, sb->b); 39 | } 40 | 41 | static LJ_AINLINE SBuf *lj_buf_tmp_(lua_State *L) 42 | { 43 | SBuf *sb = &G(L)->tmpbuf; 44 | setsbufL(sb, L); 45 | lj_buf_reset(sb); 46 | return sb; 47 | } 48 | 49 | static LJ_AINLINE void lj_buf_free(global_State *g, SBuf *sb) 50 | { 51 | lj_mem_free(g, sbufB(sb), sbufsz(sb)); 52 | } 53 | 54 | static LJ_AINLINE char *lj_buf_need(SBuf *sb, MSize sz) 55 | { 56 | if (LJ_UNLIKELY(sz > sbufsz(sb))) 57 | return lj_buf_need2(sb, sz); 58 | return sbufB(sb); 59 | } 60 | 61 | static LJ_AINLINE char *lj_buf_more(SBuf *sb, MSize sz) 62 | { 63 | if (LJ_UNLIKELY(sz > sbufleft(sb))) 64 | return lj_buf_more2(sb, sz); 65 | return sbufP(sb); 66 | } 67 | 68 | /* Low-level buffer put operations */ 69 | LJ_FUNC SBuf *lj_buf_putmem(SBuf *sb, const void *q, MSize len); 70 | LJ_FUNC SBuf * LJ_FASTCALL lj_buf_putchar(SBuf *sb, int c); 71 | LJ_FUNC SBuf * LJ_FASTCALL lj_buf_putstr(SBuf *sb, GCstr *s); 72 | 73 | static LJ_AINLINE char *lj_buf_wmem(char *p, const void *q, MSize len) 74 | { 75 | return (char *)memcpy(p, q, len) + len; 76 | } 77 | 78 | static LJ_AINLINE void lj_buf_putb(SBuf *sb, int c) 79 | { 80 | char *p = lj_buf_more(sb, 1); 81 | *p++ = (char)c; 82 | setsbufP(sb, p); 83 | } 84 | 85 | /* High-level buffer put operations */ 86 | LJ_FUNCA SBuf * LJ_FASTCALL lj_buf_putstr_reverse(SBuf *sb, GCstr *s); 87 | LJ_FUNCA SBuf * LJ_FASTCALL lj_buf_putstr_lower(SBuf *sb, GCstr *s); 88 | LJ_FUNCA SBuf * LJ_FASTCALL lj_buf_putstr_upper(SBuf *sb, GCstr *s); 89 | LJ_FUNC SBuf *lj_buf_putstr_rep(SBuf *sb, GCstr *s, int32_t rep); 90 | LJ_FUNC SBuf *lj_buf_puttab(SBuf *sb, GCtab *t, GCstr *sep, 91 | int32_t i, int32_t e); 92 | 93 | /* Miscellaneous buffer operations */ 94 | LJ_FUNCA GCstr * LJ_FASTCALL lj_buf_tostr(SBuf *sb); 95 | LJ_FUNC GCstr *lj_buf_cat2str(lua_State *L, GCstr *s1, GCstr *s2); 96 | LJ_FUNC uint32_t LJ_FASTCALL lj_buf_ruleb128(const char **pp); 97 | 98 | static LJ_AINLINE GCstr *lj_buf_str(lua_State *L, SBuf *sb) 99 | { 100 | return lj_str_new(L, sbufB(sb), sbuflen(sb)); 101 | } 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/psvitabuild.bat: -------------------------------------------------------------------------------- 1 | @rem Script to build LuaJIT with the PS Vita SDK. 2 | @rem Donated to the public domain. 3 | @rem 4 | @rem Open a "Visual Studio .NET Command Prompt" (32 bit host compiler) 5 | @rem Then cd to this directory and run this script. 6 | 7 | @if not defined INCLUDE goto :FAIL 8 | @if not defined SCE_PSP2_SDK_DIR goto :FAIL 9 | 10 | @setlocal 11 | @rem ---- Host compiler ---- 12 | @set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE 13 | @set LJLINK=link /nologo 14 | @set LJMT=mt /nologo 15 | @set DASMDIR=..\dynasm 16 | @set DASM=%DASMDIR%\dynasm.lua 17 | @set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c 18 | 19 | %LJCOMPILE% host\minilua.c 20 | @if errorlevel 1 goto :BAD 21 | %LJLINK% /out:minilua.exe minilua.obj 22 | @if errorlevel 1 goto :BAD 23 | if exist minilua.exe.manifest^ 24 | %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe 25 | 26 | @rem Check for 32 bit host compiler. 27 | @minilua 28 | @if errorlevel 8 goto :FAIL 29 | 30 | @set DASMFLAGS=-D FPU -D HFABI 31 | minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_arm.dasc 32 | @if errorlevel 1 goto :BAD 33 | 34 | %LJCOMPILE% /I "." /I %DASMDIR% -DLUAJIT_TARGET=LUAJIT_ARCH_ARM -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLJ_TARGET_PSVITA=1 host\buildvm*.c 35 | @if errorlevel 1 goto :BAD 36 | %LJLINK% /out:buildvm.exe buildvm*.obj 37 | @if errorlevel 1 goto :BAD 38 | if exist buildvm.exe.manifest^ 39 | %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe 40 | 41 | buildvm -m elfasm -o lj_vm.s 42 | @if errorlevel 1 goto :BAD 43 | buildvm -m bcdef -o lj_bcdef.h %ALL_LIB% 44 | @if errorlevel 1 goto :BAD 45 | buildvm -m ffdef -o lj_ffdef.h %ALL_LIB% 46 | @if errorlevel 1 goto :BAD 47 | buildvm -m libdef -o lj_libdef.h %ALL_LIB% 48 | @if errorlevel 1 goto :BAD 49 | buildvm -m recdef -o lj_recdef.h %ALL_LIB% 50 | @if errorlevel 1 goto :BAD 51 | buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB% 52 | @if errorlevel 1 goto :BAD 53 | buildvm -m folddef -o lj_folddef.h lj_opt_fold.c 54 | @if errorlevel 1 goto :BAD 55 | 56 | @rem ---- Cross compiler ---- 57 | @set LJCOMPILE="%SCE_PSP2_SDK_DIR%\host_tools\build\bin\psp2snc" -c -w -DLUAJIT_DISABLE_FFI -DLUAJIT_USE_SYSMALLOC 58 | @set LJLIB="%SCE_PSP2_SDK_DIR%\host_tools\build\bin\psp2ld32" -r --output= 59 | @set INCLUDE="" 60 | 61 | "%SCE_PSP2_SDK_DIR%\host_tools\build\bin\psp2as" -o lj_vm.o lj_vm.s 62 | 63 | @if "%1" neq "debug" goto :NODEBUG 64 | @shift 65 | @set LJCOMPILE=%LJCOMPILE% -g -O0 66 | @set TARGETLIB=libluajitD.a 67 | goto :BUILD 68 | :NODEBUG 69 | @set LJCOMPILE=%LJCOMPILE% -O2 70 | @set TARGETLIB=libluajit.a 71 | :BUILD 72 | del %TARGETLIB% 73 | 74 | %LJCOMPILE% ljamalg.c 75 | @if errorlevel 1 goto :BAD 76 | %LJLIB%%TARGETLIB% ljamalg.o lj_vm.o 77 | @if errorlevel 1 goto :BAD 78 | 79 | @del *.o *.obj *.manifest minilua.exe buildvm.exe 80 | @echo. 81 | @echo === Successfully built LuaJIT for PS Vita === 82 | 83 | @goto :END 84 | :BAD 85 | @echo. 86 | @echo ******************************************************* 87 | @echo *** Build FAILED -- Please check the error messages *** 88 | @echo ******************************************************* 89 | @goto :END 90 | :FAIL 91 | @echo To run this script you must open a "Visual Studio .NET Command Prompt" 92 | @echo (32 bit host compiler). The PS Vita SDK must be installed, too. 93 | :END 94 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_lex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Lexical analyzer. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_LEX_H 7 | #define _LJ_LEX_H 8 | 9 | #include 10 | 11 | #include "lj_obj.h" 12 | #include "lj_err.h" 13 | 14 | /* Lua lexer tokens. */ 15 | #define TKDEF(_, __) \ 16 | _(and) _(break) _(do) _(else) _(elseif) _(end) _(false) \ 17 | _(for) _(function) _(goto) _(if) _(in) _(local) _(nil) _(not) _(or) \ 18 | _(repeat) _(return) _(then) _(true) _(until) _(while) \ 19 | __(concat, ..) __(dots, ...) __(eq, ==) __(ge, >=) __(le, <=) __(ne, ~=) \ 20 | __(label, ::) __(number, ) __(name, ) __(string, ) \ 21 | __(eof, ) 22 | 23 | enum { 24 | TK_OFS = 256, 25 | #define TKENUM1(name) TK_##name, 26 | #define TKENUM2(name, sym) TK_##name, 27 | TKDEF(TKENUM1, TKENUM2) 28 | #undef TKENUM1 29 | #undef TKENUM2 30 | TK_RESERVED = TK_while - TK_OFS 31 | }; 32 | 33 | typedef int LexChar; /* Lexical character. Unsigned ext. from char. */ 34 | typedef int LexToken; /* Lexical token. */ 35 | 36 | /* Combined bytecode ins/line. Only used during bytecode generation. */ 37 | typedef struct BCInsLine { 38 | BCIns ins; /* Bytecode instruction. */ 39 | BCLine line; /* Line number for this bytecode. */ 40 | } BCInsLine; 41 | 42 | /* Info for local variables. Only used during bytecode generation. */ 43 | typedef struct VarInfo { 44 | GCRef name; /* Local variable name or goto/label name. */ 45 | BCPos startpc; /* First point where the local variable is active. */ 46 | BCPos endpc; /* First point where the local variable is dead. */ 47 | uint8_t slot; /* Variable slot. */ 48 | uint8_t info; /* Variable/goto/label info. */ 49 | } VarInfo; 50 | 51 | /* Lua lexer state. */ 52 | typedef struct LexState { 53 | struct FuncState *fs; /* Current FuncState. Defined in lj_parse.c. */ 54 | struct lua_State *L; /* Lua state. */ 55 | TValue tokval; /* Current token value. */ 56 | TValue lookaheadval; /* Lookahead token value. */ 57 | const char *p; /* Current position in input buffer. */ 58 | const char *pe; /* End of input buffer. */ 59 | LexChar c; /* Current character. */ 60 | LexToken tok; /* Current token. */ 61 | LexToken lookahead; /* Lookahead token. */ 62 | SBuf sb; /* String buffer for tokens. */ 63 | lua_Reader rfunc; /* Reader callback. */ 64 | void *rdata; /* Reader callback data. */ 65 | BCLine linenumber; /* Input line counter. */ 66 | BCLine lastline; /* Line of last token. */ 67 | GCstr *chunkname; /* Current chunk name (interned string). */ 68 | const char *chunkarg; /* Chunk name argument. */ 69 | const char *mode; /* Allow loading bytecode (b) and/or source text (t). */ 70 | VarInfo *vstack; /* Stack for names and extents of local variables. */ 71 | MSize sizevstack; /* Size of variable stack. */ 72 | MSize vtop; /* Top of variable stack. */ 73 | BCInsLine *bcstack; /* Stack for bytecode instructions/line numbers. */ 74 | MSize sizebcstack; /* Size of bytecode stack. */ 75 | uint32_t level; /* Syntactical nesting level. */ 76 | } LexState; 77 | 78 | LJ_FUNC int lj_lex_setup(lua_State *L, LexState *ls); 79 | LJ_FUNC void lj_lex_cleanup(lua_State *L, LexState *ls); 80 | LJ_FUNC void lj_lex_next(LexState *ls); 81 | LJ_FUNC LexToken lj_lex_lookahead(LexState *ls); 82 | LJ_FUNC const char *lj_lex_token2str(LexState *ls, LexToken tok); 83 | LJ_FUNC_NORET void lj_lex_error(LexState *ls, LexToken tok, ErrMsg em, ...); 84 | LJ_FUNC void lj_lex_init(lua_State *L); 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [ 3 | { 4 | "target_name": "<(module_name)", 5 | "variables": { 6 | "lua_include": "", 7 | "lib_dirs": "" 8 | }, 9 | "conditions": [ 10 | [ 11 | "OS=='win'", 12 | { 13 | "include_dirs": [ 14 | "<(module_root_dir)/3rdlibs/LuaJIT/src" 15 | ], 16 | "library_dirs": [ 17 | "./win64luajit" 18 | ], 19 | "libraries": [ 20 | "lua51.lib" 21 | ], 22 | "actions": [ 23 | { 24 | 'action_name': 'move_lua', 25 | 'inputs': [ 26 | '<(module_root_dir)/win64luajit/lua51.dll' 27 | ], 28 | 'outputs': [ 29 | '<(module_root_dir)/build/Release/lua51.dll' 30 | ], 31 | 'action': [ 32 | 'copy', 33 | '<(module_root_dir)/win64luajit/lua51.dll', 34 | '<(module_root_dir)/build/Release/lua51.dll' 35 | ] 36 | } 37 | ], 38 | } 39 | ], 40 | [ 41 | 'OS=="mac"', 42 | { 43 | "include_dirs": [ 44 | "<(module_root_dir)/maclualib/include" 45 | ], 46 | "libraries": [ 47 | "<(module_root_dir)/maclualib/lib/liblua.a" 48 | ], 49 | "actions": [ 50 | ], 51 | "cflags": [ 52 | "-std=c++11", 53 | "-stdlib=libc++" 54 | ], 55 | "xcode_settings": { 56 | "CLANG_CXX_LANGUAGE_STANDARD": "c++0x", 57 | "CLANG_CXX_LIBRARY": "libc++" 58 | } 59 | } 60 | ], 61 | [ 62 | 'OS=="linux"', 63 | { 64 | "include_dirs": [ 65 | "<(module_root_dir)/3rdlibs/LuaJIT/src" 66 | ], 67 | "library_dirs": [ 68 | "<(module_root_dir)/3rdlibs/LuaJIT/src" 69 | ], 70 | "libraries": [ 71 | "<(module_root_dir)/3rdlibs/LuaJIT/src/libluajit.so" 72 | ], 73 | "actions": [ 74 | ] 75 | } 76 | ] 77 | ], 78 | "sources": [ 79 | "src/utils.cc", 80 | "src/luastate.cc", 81 | "src/nodelua.cc", 82 | "src/MyLuaWorker.cpp", 83 | "src/MyWorkerQueue.cpp", 84 | "src/MyLuaState.cpp", 85 | "3rdlibs/lua-cjson/fpconv.c", 86 | "3rdlibs/lua-cjson/lua_cjson.c", 87 | "3rdlibs/lua-cjson/strbuf.c" 88 | ], 89 | "include_dirs": [ 90 | " 2 | 3 | 4 | Contact 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | Lua 15 |
16 | 19 | 62 |
63 |

64 | If you want to report bugs, propose fixes or suggest enhancements, 65 | please use the 66 | GitHub issue tracker. 67 |

68 |

69 | Please send general questions to the 70 | » LuaJIT mailing list. 71 |

72 |

73 | You can also send any questions you have directly to me: 74 |

75 | 76 | 84 | 88 | 92 | 93 |

Copyright

94 |

95 | All documentation is 96 | Copyright © 2005-2017 Mike Pall. 97 |

98 | 99 | 100 |
101 |
102 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/xb1build.bat: -------------------------------------------------------------------------------- 1 | @rem Script to build LuaJIT with the Xbox One SDK. 2 | @rem Donated to the public domain. 3 | @rem 4 | @rem Open a "Visual Studio .NET Command Prompt" (64 bit host compiler) 5 | @rem Then cd to this directory and run this script. 6 | 7 | @if not defined INCLUDE goto :FAIL 8 | @if not defined DurangoXDK goto :FAIL 9 | 10 | @setlocal 11 | @echo ---- Host compiler ---- 12 | @set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /DLUAJIT_ENABLE_GC64 13 | @set LJLINK=link /nologo 14 | @set LJMT=mt /nologo 15 | @set DASMDIR=..\dynasm 16 | @set DASM=%DASMDIR%\dynasm.lua 17 | @set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c 18 | 19 | %LJCOMPILE% host\minilua.c 20 | @if errorlevel 1 goto :BAD 21 | %LJLINK% /out:minilua.exe minilua.obj 22 | @if errorlevel 1 goto :BAD 23 | if exist minilua.exe.manifest^ 24 | %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe 25 | 26 | @rem Error out for 64 bit host compiler 27 | @minilua 28 | @if not errorlevel 8 goto :FAIL 29 | 30 | @set DASMFLAGS=-D WIN -D FFI -D P64 31 | minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_x64.dasc 32 | @if errorlevel 1 goto :BAD 33 | 34 | %LJCOMPILE% /I "." /I %DASMDIR% /D_DURANGO host\buildvm*.c 35 | @if errorlevel 1 goto :BAD 36 | %LJLINK% /out:buildvm.exe buildvm*.obj 37 | @if errorlevel 1 goto :BAD 38 | if exist buildvm.exe.manifest^ 39 | %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe 40 | 41 | buildvm -m peobj -o lj_vm.obj 42 | @if errorlevel 1 goto :BAD 43 | buildvm -m bcdef -o lj_bcdef.h %ALL_LIB% 44 | @if errorlevel 1 goto :BAD 45 | buildvm -m ffdef -o lj_ffdef.h %ALL_LIB% 46 | @if errorlevel 1 goto :BAD 47 | buildvm -m libdef -o lj_libdef.h %ALL_LIB% 48 | @if errorlevel 1 goto :BAD 49 | buildvm -m recdef -o lj_recdef.h %ALL_LIB% 50 | @if errorlevel 1 goto :BAD 51 | buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB% 52 | @if errorlevel 1 goto :BAD 53 | buildvm -m folddef -o lj_folddef.h lj_opt_fold.c 54 | @if errorlevel 1 goto :BAD 55 | 56 | @echo ---- Cross compiler ---- 57 | 58 | @set CWD=%cd% 59 | @call "%DurangoXDK%\xdk\DurangoVars.cmd" XDK 60 | @cd /D "%CWD%" 61 | @shift 62 | 63 | @set LJCOMPILE="cl" /nologo /c /W3 /GF /Gm- /GR- /GS- /Gy /openmp- /D_CRT_SECURE_NO_DEPRECATE /D_LIB /D_UNICODE /D_DURANGO 64 | @set LJLIB="lib" /nologo 65 | 66 | @if "%1"=="debug" ( 67 | @shift 68 | @set LJCOMPILE=%LJCOMPILE% /Zi /MDd /Od 69 | @set LJLINK=%LJLINK% /debug 70 | ) else ( 71 | @set LJCOMPILE=%LJCOMPILE% /MD /O2 /DNDEBUG 72 | ) 73 | 74 | @if "%1"=="amalg" goto :AMALG 75 | %LJCOMPILE% /DLUA_BUILD_AS_DLL lj_*.c lib_*.c 76 | @if errorlevel 1 goto :BAD 77 | %LJLIB% /OUT:luajit.lib lj_*.obj lib_*.obj 78 | @if errorlevel 1 goto :BAD 79 | @goto :NOAMALG 80 | :AMALG 81 | %LJCOMPILE% /DLUA_BUILD_AS_DLL ljamalg.c 82 | @if errorlevel 1 goto :BAD 83 | %LJLIB% /OUT:luajit.lib ljamalg.obj lj_vm.obj 84 | @if errorlevel 1 goto :BAD 85 | :NOAMALG 86 | 87 | @del *.obj *.manifest minilua.exe buildvm.exe 88 | @echo. 89 | @echo === Successfully built LuaJIT for Xbox One === 90 | 91 | @goto :END 92 | :BAD 93 | @echo. 94 | @echo ******************************************************* 95 | @echo *** Build FAILED -- Please check the error messages *** 96 | @echo ******************************************************* 97 | @goto :END 98 | :FAIL 99 | @echo To run this script you must open a "Visual Studio .NET Command Prompt" 100 | @echo (64 bit host compiler). The Xbox One SDK must be installed, too. 101 | :END 102 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/example4.json: -------------------------------------------------------------------------------- 1 | {"web-app": { 2 | "servlet": [ 3 | { 4 | "servlet-name": "cofaxCDS", 5 | "servlet-class": "org.cofax.cds.CDSServlet", 6 | "init-param": { 7 | "configGlossary:installationAt": "Philadelphia, PA", 8 | "configGlossary:adminEmail": "ksm@pobox.com", 9 | "configGlossary:poweredBy": "Cofax", 10 | "configGlossary:poweredByIcon": "/images/cofax.gif", 11 | "configGlossary:staticPath": "/content/static", 12 | "templateProcessorClass": "org.cofax.WysiwygTemplate", 13 | "templateLoaderClass": "org.cofax.FilesTemplateLoader", 14 | "templatePath": "templates", 15 | "templateOverridePath": "", 16 | "defaultListTemplate": "listTemplate.htm", 17 | "defaultFileTemplate": "articleTemplate.htm", 18 | "useJSP": false, 19 | "jspListTemplate": "listTemplate.jsp", 20 | "jspFileTemplate": "articleTemplate.jsp", 21 | "cachePackageTagsTrack": 200, 22 | "cachePackageTagsStore": 200, 23 | "cachePackageTagsRefresh": 60, 24 | "cacheTemplatesTrack": 100, 25 | "cacheTemplatesStore": 50, 26 | "cacheTemplatesRefresh": 15, 27 | "cachePagesTrack": 200, 28 | "cachePagesStore": 100, 29 | "cachePagesRefresh": 10, 30 | "cachePagesDirtyRead": 10, 31 | "searchEngineListTemplate": "forSearchEnginesList.htm", 32 | "searchEngineFileTemplate": "forSearchEngines.htm", 33 | "searchEngineRobotsDb": "WEB-INF/robots.db", 34 | "useDataStore": true, 35 | "dataStoreClass": "org.cofax.SqlDataStore", 36 | "redirectionClass": "org.cofax.SqlRedirection", 37 | "dataStoreName": "cofax", 38 | "dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver", 39 | "dataStoreUrl": "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon", 40 | "dataStoreUser": "sa", 41 | "dataStorePassword": "dataStoreTestQuery", 42 | "dataStoreTestQuery": "SET NOCOUNT ON;select test='test';", 43 | "dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log", 44 | "dataStoreInitConns": 10, 45 | "dataStoreMaxConns": 100, 46 | "dataStoreConnUsageLimit": 100, 47 | "dataStoreLogLevel": "debug", 48 | "maxUrlLength": 500}}, 49 | { 50 | "servlet-name": "cofaxEmail", 51 | "servlet-class": "org.cofax.cds.EmailServlet", 52 | "init-param": { 53 | "mailHost": "mail1", 54 | "mailHostOverride": "mail2"}}, 55 | { 56 | "servlet-name": "cofaxAdmin", 57 | "servlet-class": "org.cofax.cds.AdminServlet"}, 58 | 59 | { 60 | "servlet-name": "fileServlet", 61 | "servlet-class": "org.cofax.cds.FileServlet"}, 62 | { 63 | "servlet-name": "cofaxTools", 64 | "servlet-class": "org.cofax.cms.CofaxToolsServlet", 65 | "init-param": { 66 | "templatePath": "toolstemplates/", 67 | "log": 1, 68 | "logLocation": "/usr/local/tomcat/logs/CofaxTools.log", 69 | "logMaxSize": "", 70 | "dataLog": 1, 71 | "dataLogLocation": "/usr/local/tomcat/logs/dataLog.log", 72 | "dataLogMaxSize": "", 73 | "removePageCache": "/content/admin/remove?cache=pages&id=", 74 | "removeTemplateCache": "/content/admin/remove?cache=templates&id=", 75 | "fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder", 76 | "lookInContext": 1, 77 | "adminGroupID": 4, 78 | "betaServer": true}}], 79 | "servlet-mapping": { 80 | "cofaxCDS": "/", 81 | "cofaxEmail": "/cofaxutil/aemail/*", 82 | "cofaxAdmin": "/admin/*", 83 | "fileServlet": "/static/*", 84 | "cofaxTools": "/tools/*"}, 85 | 86 | "taglib": { 87 | "taglib-uri": "cofax.tld", 88 | "taglib-location": "/WEB-INF/tlds/cofax.tld"}}} 89 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/bench.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | -- This benchmark script measures wall clock time and should be 4 | -- run on an unloaded system. 5 | -- 6 | -- Your Mileage May Vary. 7 | -- 8 | -- Mark Pulford 9 | 10 | local json_module = os.getenv("JSON_MODULE") or "cjson" 11 | 12 | require "socket" 13 | local json = require(json_module) 14 | local util = require "cjson.util" 15 | 16 | local function find_func(mod, funcnames) 17 | for _, v in ipairs(funcnames) do 18 | if mod[v] then 19 | return mod[v] 20 | end 21 | end 22 | 23 | return nil 24 | end 25 | 26 | local json_encode = find_func(json, { "encode", "Encode", "to_string", "stringify", "json" }) 27 | local json_decode = find_func(json, { "decode", "Decode", "to_value", "parse" }) 28 | 29 | local function average(t) 30 | local total = 0 31 | for _, v in ipairs(t) do 32 | total = total + v 33 | end 34 | return total / #t 35 | end 36 | 37 | function benchmark(tests, seconds, rep) 38 | local function bench(func, iter) 39 | -- Use socket.gettime() to measure microsecond resolution 40 | -- wall clock time. 41 | local t = socket.gettime() 42 | for i = 1, iter do 43 | func(i) 44 | end 45 | t = socket.gettime() - t 46 | 47 | -- Don't trust any results when the run lasted for less than a 48 | -- millisecond - return nil. 49 | if t < 0.001 then 50 | return nil 51 | end 52 | 53 | return (iter / t) 54 | end 55 | 56 | -- Roughly calculate the number of interations required 57 | -- to obtain a particular time period. 58 | local function calc_iter(func, seconds) 59 | local iter = 1 60 | local rate 61 | -- Warm up the bench function first. 62 | func() 63 | while not rate do 64 | rate = bench(func, iter) 65 | iter = iter * 10 66 | end 67 | return math.ceil(seconds * rate) 68 | end 69 | 70 | local test_results = {} 71 | for name, func in pairs(tests) do 72 | -- k(number), v(string) 73 | -- k(string), v(function) 74 | -- k(number), v(function) 75 | if type(func) == "string" then 76 | name = func 77 | func = _G[name] 78 | end 79 | 80 | local iter = calc_iter(func, seconds) 81 | 82 | local result = {} 83 | for i = 1, rep do 84 | result[i] = bench(func, iter) 85 | end 86 | 87 | -- Remove the slowest half (round down) of the result set 88 | table.sort(result) 89 | for i = 1, math.floor(#result / 2) do 90 | table.remove(result, 1) 91 | end 92 | 93 | test_results[name] = average(result) 94 | end 95 | 96 | return test_results 97 | end 98 | 99 | function bench_file(filename) 100 | local data_json = util.file_load(filename) 101 | local data_obj = json_decode(data_json) 102 | 103 | local function test_encode() 104 | json_encode(data_obj) 105 | end 106 | local function test_decode() 107 | json_decode(data_json) 108 | end 109 | 110 | local tests = {} 111 | if json_encode then tests.encode = test_encode end 112 | if json_decode then tests.decode = test_decode end 113 | 114 | return benchmark(tests, 0.1, 5) 115 | end 116 | 117 | -- Optionally load any custom configuration required for this module 118 | local success, data = pcall(util.file_load, ("bench-%s.lua"):format(json_module)) 119 | if success then 120 | util.run_script(data, _G) 121 | configure(json) 122 | end 123 | 124 | for i = 1, #arg do 125 | local results = bench_file(arg[i]) 126 | for k, v in pairs(results) do 127 | print(("%s\t%s\t%d"):format(arg[i], k, v)) 128 | end 129 | end 130 | 131 | -- vi:ai et sw=4 ts=4: 132 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_vm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Assembler VM interface definitions. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_VM_H 7 | #define _LJ_VM_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Entry points for ASM parts of VM. */ 12 | LJ_ASMF void lj_vm_call(lua_State *L, TValue *base, int nres1); 13 | LJ_ASMF int lj_vm_pcall(lua_State *L, TValue *base, int nres1, ptrdiff_t ef); 14 | typedef TValue *(*lua_CPFunction)(lua_State *L, lua_CFunction func, void *ud); 15 | LJ_ASMF int lj_vm_cpcall(lua_State *L, lua_CFunction func, void *ud, 16 | lua_CPFunction cp); 17 | LJ_ASMF int lj_vm_resume(lua_State *L, TValue *base, int nres1, ptrdiff_t ef); 18 | LJ_ASMF_NORET void LJ_FASTCALL lj_vm_unwind_c(void *cframe, int errcode); 19 | LJ_ASMF_NORET void LJ_FASTCALL lj_vm_unwind_ff(void *cframe); 20 | #if LJ_ABI_WIN && LJ_TARGET_X86 21 | LJ_ASMF_NORET void LJ_FASTCALL lj_vm_rtlunwind(void *cframe, void *excptrec, 22 | void *unwinder, int errcode); 23 | #endif 24 | LJ_ASMF void lj_vm_unwind_c_eh(void); 25 | LJ_ASMF void lj_vm_unwind_ff_eh(void); 26 | #if LJ_TARGET_X86ORX64 27 | LJ_ASMF void lj_vm_unwind_rethrow(void); 28 | #endif 29 | 30 | /* Miscellaneous functions. */ 31 | #if LJ_TARGET_X86ORX64 32 | LJ_ASMF int lj_vm_cpuid(uint32_t f, uint32_t res[4]); 33 | #endif 34 | #if LJ_TARGET_PPC 35 | void lj_vm_cachesync(void *start, void *end); 36 | #endif 37 | LJ_ASMF double lj_vm_foldarith(double x, double y, int op); 38 | #if LJ_HASJIT 39 | LJ_ASMF double lj_vm_foldfpm(double x, int op); 40 | #endif 41 | #if !LJ_ARCH_HASFPU 42 | /* Declared in lj_obj.h: LJ_ASMF int32_t lj_vm_tobit(double x); */ 43 | #endif 44 | 45 | /* Dispatch targets for recording and hooks. */ 46 | LJ_ASMF void lj_vm_record(void); 47 | LJ_ASMF void lj_vm_inshook(void); 48 | LJ_ASMF void lj_vm_rethook(void); 49 | LJ_ASMF void lj_vm_callhook(void); 50 | LJ_ASMF void lj_vm_profhook(void); 51 | 52 | /* Trace exit handling. */ 53 | LJ_ASMF void lj_vm_exit_handler(void); 54 | LJ_ASMF void lj_vm_exit_interp(void); 55 | 56 | /* Internal math helper functions. */ 57 | #if LJ_TARGET_PPC || LJ_TARGET_ARM64 || (LJ_TARGET_MIPS && LJ_ABI_SOFTFP) 58 | #define lj_vm_floor floor 59 | #define lj_vm_ceil ceil 60 | #else 61 | LJ_ASMF double lj_vm_floor(double); 62 | LJ_ASMF double lj_vm_ceil(double); 63 | #if LJ_TARGET_ARM 64 | LJ_ASMF double lj_vm_floor_sf(double); 65 | LJ_ASMF double lj_vm_ceil_sf(double); 66 | #endif 67 | #endif 68 | #ifdef LUAJIT_NO_LOG2 69 | LJ_ASMF double lj_vm_log2(double); 70 | #else 71 | #define lj_vm_log2 log2 72 | #endif 73 | #if !(defined(_LJ_DISPATCH_H) && LJ_TARGET_MIPS) 74 | LJ_ASMF int32_t LJ_FASTCALL lj_vm_modi(int32_t, int32_t); 75 | #endif 76 | 77 | #if LJ_HASJIT 78 | #if LJ_TARGET_X86ORX64 79 | LJ_ASMF void lj_vm_floor_sse(void); 80 | LJ_ASMF void lj_vm_ceil_sse(void); 81 | LJ_ASMF void lj_vm_trunc_sse(void); 82 | LJ_ASMF void lj_vm_powi_sse(void); 83 | #define lj_vm_powi NULL 84 | #else 85 | LJ_ASMF double lj_vm_powi(double, int32_t); 86 | #endif 87 | #if LJ_TARGET_PPC || LJ_TARGET_ARM64 88 | #define lj_vm_trunc trunc 89 | #else 90 | LJ_ASMF double lj_vm_trunc(double); 91 | #if LJ_TARGET_ARM 92 | LJ_ASMF double lj_vm_trunc_sf(double); 93 | #endif 94 | #endif 95 | #ifdef LUAJIT_NO_EXP2 96 | LJ_ASMF double lj_vm_exp2(double); 97 | #else 98 | #define lj_vm_exp2 exp2 99 | #endif 100 | #if LJ_HASFFI 101 | LJ_ASMF int lj_vm_errno(void); 102 | #endif 103 | #endif 104 | 105 | /* Continuations for metamethods. */ 106 | LJ_ASMF void lj_cont_cat(void); /* Continue with concatenation. */ 107 | LJ_ASMF void lj_cont_ra(void); /* Store result in RA from instruction. */ 108 | LJ_ASMF void lj_cont_nop(void); /* Do nothing, just continue execution. */ 109 | LJ_ASMF void lj_cont_condt(void); /* Branch if result is true. */ 110 | LJ_ASMF void lj_cont_condf(void); /* Branch if result is false. */ 111 | LJ_ASMF void lj_cont_hook(void); /* Continue from hook yield. */ 112 | LJ_ASMF void lj_cont_stitch(void); /* Trace stitching. */ 113 | 114 | /* Start of the ASM code. */ 115 | LJ_ASMF char lj_vm_asm_begin[]; 116 | 117 | /* Bytecode offsets are relative to lj_vm_asm_begin. */ 118 | #define makeasmfunc(ofs) ((ASMFunction)(lj_vm_asm_begin + (ofs))) 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_lib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Library function support. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_LIB_H 7 | #define _LJ_LIB_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* 12 | ** A fallback handler is called by the assembler VM if the fast path fails: 13 | ** 14 | ** - too few arguments: unrecoverable. 15 | ** - wrong argument type: recoverable, if coercion succeeds. 16 | ** - bad argument value: unrecoverable. 17 | ** - stack overflow: recoverable, if stack reallocation succeeds. 18 | ** - extra handling: recoverable. 19 | ** 20 | ** The unrecoverable cases throw an error with lj_err_arg(), lj_err_argtype(), 21 | ** lj_err_caller() or lj_err_callermsg(). 22 | ** The recoverable cases return 0 or the number of results + 1. 23 | ** The assembler VM retries the fast path only if 0 is returned. 24 | ** This time the fallback must not be called again or it gets stuck in a loop. 25 | */ 26 | 27 | /* Return values from fallback handler. */ 28 | #define FFH_RETRY 0 29 | #define FFH_UNREACHABLE FFH_RETRY 30 | #define FFH_RES(n) ((n)+1) 31 | #define FFH_TAILCALL (-1) 32 | 33 | LJ_FUNC TValue *lj_lib_checkany(lua_State *L, int narg); 34 | LJ_FUNC GCstr *lj_lib_checkstr(lua_State *L, int narg); 35 | LJ_FUNC GCstr *lj_lib_optstr(lua_State *L, int narg); 36 | #if LJ_DUALNUM 37 | LJ_FUNC void lj_lib_checknumber(lua_State *L, int narg); 38 | #else 39 | #define lj_lib_checknumber(L, narg) lj_lib_checknum((L), (narg)) 40 | #endif 41 | LJ_FUNC lua_Number lj_lib_checknum(lua_State *L, int narg); 42 | LJ_FUNC int32_t lj_lib_checkint(lua_State *L, int narg); 43 | LJ_FUNC int32_t lj_lib_optint(lua_State *L, int narg, int32_t def); 44 | LJ_FUNC GCfunc *lj_lib_checkfunc(lua_State *L, int narg); 45 | LJ_FUNC GCtab *lj_lib_checktab(lua_State *L, int narg); 46 | LJ_FUNC GCtab *lj_lib_checktabornil(lua_State *L, int narg); 47 | LJ_FUNC int lj_lib_checkopt(lua_State *L, int narg, int def, const char *lst); 48 | 49 | /* Avoid including lj_frame.h. */ 50 | #if LJ_GC64 51 | #define lj_lib_upvalue(L, n) \ 52 | (&gcval(L->base-2)->fn.c.upvalue[(n)-1]) 53 | #elif LJ_FR2 54 | #define lj_lib_upvalue(L, n) \ 55 | (&gcref((L->base-2)->gcr)->fn.c.upvalue[(n)-1]) 56 | #else 57 | #define lj_lib_upvalue(L, n) \ 58 | (&gcref((L->base-1)->fr.func)->fn.c.upvalue[(n)-1]) 59 | #endif 60 | 61 | #if LJ_TARGET_WINDOWS 62 | #define lj_lib_checkfpu(L) \ 63 | do { setnumV(L->top++, (lua_Number)1437217655); \ 64 | if (lua_tointeger(L, -1) != 1437217655) lj_err_caller(L, LJ_ERR_BADFPU); \ 65 | L->top--; } while (0) 66 | #else 67 | #define lj_lib_checkfpu(L) UNUSED(L) 68 | #endif 69 | 70 | LJ_FUNC GCfunc *lj_lib_pushcc(lua_State *L, lua_CFunction f, int id, int n); 71 | #define lj_lib_pushcf(L, fn, id) (lj_lib_pushcc(L, (fn), (id), 0)) 72 | 73 | /* Library function declarations. Scanned by buildvm. */ 74 | #define LJLIB_CF(name) static int lj_cf_##name(lua_State *L) 75 | #define LJLIB_ASM(name) static int lj_ffh_##name(lua_State *L) 76 | #define LJLIB_ASM_(name) 77 | #define LJLIB_LUA(name) 78 | #define LJLIB_SET(name) 79 | #define LJLIB_PUSH(arg) 80 | #define LJLIB_REC(handler) 81 | #define LJLIB_NOREGUV 82 | #define LJLIB_NOREG 83 | 84 | #define LJ_LIB_REG(L, regname, name) \ 85 | lj_lib_register(L, regname, lj_lib_init_##name, lj_lib_cf_##name) 86 | 87 | LJ_FUNC void lj_lib_register(lua_State *L, const char *libname, 88 | const uint8_t *init, const lua_CFunction *cf); 89 | LJ_FUNC void lj_lib_prereg(lua_State *L, const char *name, lua_CFunction f, 90 | GCtab *env); 91 | LJ_FUNC int lj_lib_postreg(lua_State *L, lua_CFunction cf, int id, 92 | const char *name); 93 | 94 | /* Library init data tags. */ 95 | #define LIBINIT_LENMASK 0x3f 96 | #define LIBINIT_TAGMASK 0xc0 97 | #define LIBINIT_CF 0x00 98 | #define LIBINIT_ASM 0x40 99 | #define LIBINIT_ASM_ 0x80 100 | #define LIBINIT_STRING 0xc0 101 | #define LIBINIT_MAXSTR 0x38 102 | #define LIBINIT_LUA 0xf9 103 | #define LIBINIT_SET 0xfa 104 | #define LIBINIT_NUMBER 0xfb 105 | #define LIBINIT_COPY 0xfc 106 | #define LIBINIT_LASTCL 0xfd 107 | #define LIBINIT_FFID 0xfe 108 | #define LIBINIT_END 0xff 109 | 110 | /* Exported library functions. */ 111 | 112 | typedef struct RandomState RandomState; 113 | LJ_FUNC uint64_t LJ_FASTCALL lj_math_random_step(RandomState *rs); 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/performance.txt: -------------------------------------------------------------------------------- 1 | JSON module performance comparison under Lua 2 | ============================================ 3 | Mark Pulford 4 | :revdate: January 22, 2012 5 | 6 | This performance comparison aims to provide a guide of relative 7 | performance between several fast and popular JSON modules. 8 | 9 | The examples used in this comparison were mostly sourced from the 10 | http://json.org[JSON website] and 11 | http://tools.ietf.org/html/rfc4627[RFC 4627]. 12 | 13 | Performance will vary widely between platforms and data sets. These 14 | results should only be used as an approximation. 15 | 16 | 17 | Modules 18 | ------- 19 | 20 | The following JSON modules for Lua were tested: 21 | 22 | http://chiselapp.com/user/dhkolf/repository/dkjson/[DKJSON 2.1]:: 23 | - Lua implementation with no dependencies on other libraries 24 | - Supports LPeg to improve decode performance 25 | 26 | https://github.com/brimworks/lua-yajl[Lua YAJL 2.0]:: 27 | - C wrapper for the YAJL library 28 | 29 | http://www.kyne.com.au/%7Emark/software/lua-cjson.php[Lua CSJON 2.0.0]:: 30 | - C implementation with no dependencies on other libraries 31 | 32 | 33 | Summary 34 | ------- 35 | 36 | All modules were built and tested as follows: 37 | 38 | DKJSON:: Tested with/without LPeg 10.2. 39 | Lua YAJL:: Tested with YAJL 2.0.4. 40 | Lua CJSON:: Tested with Libc and internal floating point conversion 41 | routines. 42 | 43 | The following Lua implementations were used for this comparison: 44 | 45 | - http://www.lua.org[Lua 5.1.4] (_Lua_) 46 | - http://www.luajit.org[LuaJIT 2.0.0-beta9] (_JIT_) 47 | 48 | These results show the number of JSON operations per second sustained by 49 | each module. All results have been normalised against the pure Lua 50 | DKJSON implementation. 51 | 52 | .Decoding performance 53 | ............................................................................ 54 | | DKJSON | Lua YAJL | Lua CJSON 55 | | No LPeg With LPeg | | Libc Internal 56 | | Lua JIT Lua JIT | Lua JIT | Lua JIT Lua JIT 57 | example1 | 1x 2x 2.6x 3.4x | 7.1x 10x | 14x 20x 14x 20x 58 | example2 | 1x 2.2x 2.9x 4.4x | 6.7x 9.9x | 14x 22x 14x 22x 59 | example3 | 1x 2.1x 3x 4.3x | 6.9x 9.3x | 14x 21x 15x 22x 60 | example4 | 1x 2x 2.5x 3.7x | 7.3x 10x | 12x 19x 12x 20x 61 | example5 | 1x 2.2x 3x 4.5x | 7.8x 11x | 16x 24x 16x 24x 62 | numbers | 1x 2.2x 2.3x 4x | 4.6x 5.5x | 8.9x 10x 13x 17x 63 | rfc-example1 | 1x 2.1x 2.8x 4.3x | 6.1x 8.1x | 13x 19x 14x 21x 64 | rfc-example2 | 1x 2.1x 3.1x 4.2x | 7.1x 9.2x | 15x 21x 17x 24x 65 | types | 1x 2.2x 2.6x 4.3x | 5.3x 7.4x | 12x 20x 13x 21x 66 | -------------|-------------------------|------------|----------------------- 67 | = Average => | 1x 2.1x 2.7x 4.1x | 6.5x 9x | 13x 20x 14x 21x 68 | ............................................................................ 69 | 70 | .Encoding performance 71 | ............................................................................. 72 | | DKJSON | Lua YAJL | Lua CJSON 73 | | No LPeg With LPeg | | Libc Internal 74 | | Lua JIT Lua JIT | Lua JIT | Lua JIT Lua JIT 75 | example1 | 1x 1.8x 0.97x 1.6x | 3.1x 5.2x | 23x 29x 23x 29x 76 | example2 | 1x 2x 0.97x 1.7x | 2.6x 4.3x | 22x 28x 22x 28x 77 | example3 | 1x 1.9x 0.98x 1.6x | 2.8x 4.3x | 13x 15x 16x 18x 78 | example4 | 1x 1.7x 0.96x 1.3x | 3.9x 6.1x | 15x 19x 17x 21x 79 | example5 | 1x 2x 0.98x 1.7x | 2.7x 4.5x | 20x 23x 20x 23x 80 | numbers | 1x 2.3x 1x 2.2x | 1.3x 1.9x | 3.8x 4.1x 4.2x 4.6x 81 | rfc-example1 | 1x 1.9x 0.97x 1.6x | 2.2x 3.2x | 8.5x 9.3x 11x 12x 82 | rfc-example2 | 1x 1.9x 0.98x 1.6x | 2.6x 3.9x | 10x 11x 17x 19x 83 | types | 1x 2.2x 0.97x 2x | 1.2x 1.9x | 11x 13x 12x 14x 84 | -------------|-------------------------|------------|----------------------- 85 | = Average => | 1x 1.9x 0.98x 1.7x | 2.5x 3.9x | 14x 17x 16x 19x 86 | ............................................................................. 87 | 88 | 89 | // vi:ft=asciidoc tw=72: 90 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/ps4build.bat: -------------------------------------------------------------------------------- 1 | @rem Script to build LuaJIT with the PS4 SDK. 2 | @rem Donated to the public domain. 3 | @rem 4 | @rem Open a "Visual Studio .NET Command Prompt" (64 bit host compiler) 5 | @rem or "VS2015 x64 Native Tools Command Prompt". 6 | @rem 7 | @rem Then cd to this directory and run this script. 8 | @rem 9 | @rem Recommended invocation: 10 | @rem 11 | @rem ps4build release build, amalgamated, 64-bit GC 12 | @rem ps4build debug debug build, amalgamated, 64-bit GC 13 | @rem 14 | @rem Additional command-line options (not generally recommended): 15 | @rem 16 | @rem gc32 (before debug) 32-bit GC 17 | @rem noamalg (after debug) non-amalgamated build 18 | 19 | @if not defined INCLUDE goto :FAIL 20 | @if not defined SCE_ORBIS_SDK_DIR goto :FAIL 21 | 22 | @setlocal 23 | @rem ---- Host compiler ---- 24 | @set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE 25 | @set LJLINK=link /nologo 26 | @set LJMT=mt /nologo 27 | @set DASMDIR=..\dynasm 28 | @set DASM=%DASMDIR%\dynasm.lua 29 | @set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c 30 | @set GC64=-DLUAJIT_ENABLE_GC64 31 | @set DASC=vm_x64.dasc 32 | 33 | @if "%1" neq "gc32" goto :NOGC32 34 | @shift 35 | @set GC64= 36 | @set DASC=vm_x86.dasc 37 | :NOGC32 38 | 39 | %LJCOMPILE% host\minilua.c 40 | @if errorlevel 1 goto :BAD 41 | %LJLINK% /out:minilua.exe minilua.obj 42 | @if errorlevel 1 goto :BAD 43 | if exist minilua.exe.manifest^ 44 | %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe 45 | 46 | @rem Check for 64 bit host compiler. 47 | @minilua 48 | @if not errorlevel 8 goto :FAIL 49 | 50 | @set DASMFLAGS=-D P64 -D NO_UNWIND 51 | minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC% 52 | @if errorlevel 1 goto :BAD 53 | 54 | %LJCOMPILE% /I "." /I %DASMDIR% %GC64% -DLUAJIT_TARGET=LUAJIT_ARCH_X64 -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLUAJIT_NO_UNWIND host\buildvm*.c 55 | @if errorlevel 1 goto :BAD 56 | %LJLINK% /out:buildvm.exe buildvm*.obj 57 | @if errorlevel 1 goto :BAD 58 | if exist buildvm.exe.manifest^ 59 | %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe 60 | 61 | buildvm -m elfasm -o lj_vm.s 62 | @if errorlevel 1 goto :BAD 63 | buildvm -m bcdef -o lj_bcdef.h %ALL_LIB% 64 | @if errorlevel 1 goto :BAD 65 | buildvm -m ffdef -o lj_ffdef.h %ALL_LIB% 66 | @if errorlevel 1 goto :BAD 67 | buildvm -m libdef -o lj_libdef.h %ALL_LIB% 68 | @if errorlevel 1 goto :BAD 69 | buildvm -m recdef -o lj_recdef.h %ALL_LIB% 70 | @if errorlevel 1 goto :BAD 71 | buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB% 72 | @if errorlevel 1 goto :BAD 73 | buildvm -m folddef -o lj_folddef.h lj_opt_fold.c 74 | @if errorlevel 1 goto :BAD 75 | 76 | @rem ---- Cross compiler ---- 77 | @set LJCOMPILE="%SCE_ORBIS_SDK_DIR%\host_tools\bin\orbis-clang" -c -Wall -DLUAJIT_DISABLE_FFI %GC64% 78 | @set LJLIB="%SCE_ORBIS_SDK_DIR%\host_tools\bin\orbis-ar" rcus 79 | @set INCLUDE="" 80 | 81 | orbis-as -o lj_vm.o lj_vm.s 82 | 83 | @if "%1" neq "debug" goto :NODEBUG 84 | @shift 85 | @set LJCOMPILE=%LJCOMPILE% -g -O0 86 | @set TARGETLIB=libluajitD_ps4.a 87 | goto :BUILD 88 | :NODEBUG 89 | @set LJCOMPILE=%LJCOMPILE% -O2 90 | @set TARGETLIB=libluajit_ps4.a 91 | :BUILD 92 | del %TARGETLIB% 93 | @if "%1" neq "noamalg" goto :AMALG 94 | for %%f in (lj_*.c lib_*.c) do ( 95 | %LJCOMPILE% %%f 96 | @if errorlevel 1 goto :BAD 97 | ) 98 | 99 | %LJLIB% %TARGETLIB% lj_*.o lib_*.o 100 | @if errorlevel 1 goto :BAD 101 | @goto :NOAMALG 102 | :AMALG 103 | %LJCOMPILE% ljamalg.c 104 | @if errorlevel 1 goto :BAD 105 | %LJLIB% %TARGETLIB% ljamalg.o lj_vm.o 106 | @if errorlevel 1 goto :BAD 107 | :NOAMALG 108 | 109 | @del *.o *.obj *.manifest minilua.exe buildvm.exe 110 | @echo. 111 | @echo === Successfully built LuaJIT for PS4 === 112 | 113 | @goto :END 114 | :BAD 115 | @echo. 116 | @echo ******************************************************* 117 | @echo *** Build FAILED -- Please check the error messages *** 118 | @echo ******************************************************* 119 | @goto :END 120 | :FAIL 121 | @echo To run this script you must open a "Visual Studio .NET Command Prompt" 122 | @echo (64 bit host compiler). The PS4 Orbis SDK must be installed, too. 123 | :END 124 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/doc/status.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Status 5 | 6 | 7 | 8 | 9 | 10 | 11 | 14 | 15 | 16 |
17 | Lua 18 |
19 | 22 | 65 |
66 |

67 | LuaJIT 2.0 is the current 68 | stable branch. This branch is in 69 | feature-freeze — new features will only be added to LuaJIT 2.1. 70 |

71 | 72 |

Current Status

73 |

74 | LuaJIT ought to run all Lua 5.1-compatible source code just fine. 75 | It's considered a serious bug if the VM crashes or produces unexpected 76 | results — please report this. 77 |

78 |

79 | Known incompatibilities and issues in LuaJIT 2.0: 80 |

81 |
    82 |
  • 83 | There are some differences in implementation-defined behavior. 84 | These either have a good reason, are arbitrary design choices 85 | or are due to quirks in the VM. The latter cases may get fixed if a 86 | demonstrable need is shown. 87 |
  • 88 |
  • 89 | The Lua debug API is missing a couple of features (return 90 | hooks for non-Lua functions) and shows slightly different behavior 91 | in LuaJIT (no per-coroutine hooks, no tail call counting). 92 |
  • 93 |
  • 94 | Currently some out-of-memory errors from on-trace code are not 95 | handled correctly. The error may fall through an on-trace 96 | pcall or it may be passed on to the function set with 97 | lua_atpanic on x64. This issue will be fixed with the new 98 | garbage collector. 99 |
  • 100 |
  • 101 | LuaJIT on 64 bit systems provides a limited range of 47 bits for the 102 | legacy lightuserdata data type. 103 | This is only relevant on x64 systems which use the negative part of the 104 | virtual address space in user mode, e.g. Solaris/x64, and on ARM64 systems 105 | configured with a 48 bit or 52 bit VA. 106 | Avoid using lightuserdata to hold pointers that may point outside 107 | of that range, e.g. variables on the stack. In general, avoid this data 108 | type for new code and replace it with (much more performant) FFI bindings. 109 | FFI cdata pointers can address the full 64 bit range. 110 |
  • 111 |
112 |
113 |
114 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/msvcbuild.bat: -------------------------------------------------------------------------------- 1 | @rem Script to build LuaJIT with MSVC. 2 | @rem Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 3 | @rem 4 | @rem Either open a "Visual Studio .NET Command Prompt" 5 | @rem (Note that the Express Edition does not contain an x64 compiler) 6 | @rem -or- 7 | @rem Open a "Windows SDK Command Shell" and set the compiler environment: 8 | @rem setenv /release /x86 9 | @rem -or- 10 | @rem setenv /release /x64 11 | @rem 12 | @rem Then cd to this directory and run this script. 13 | 14 | @if not defined INCLUDE goto :FAIL 15 | 16 | @setlocal 17 | @set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline 18 | @set LJLINK=link /nologo 19 | @set LJMT=mt /nologo 20 | @set LJLIB=lib /nologo /nodefaultlib 21 | @set DASMDIR=..\dynasm 22 | @set DASM=%DASMDIR%\dynasm.lua 23 | @set DASC=vm_x86.dasc 24 | @set LJDLLNAME=lua51.dll 25 | @set LJLIBNAME=lua51.lib 26 | @set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c 27 | 28 | %LJCOMPILE% host\minilua.c 29 | @if errorlevel 1 goto :BAD 30 | %LJLINK% /out:minilua.exe minilua.obj 31 | @if errorlevel 1 goto :BAD 32 | if exist minilua.exe.manifest^ 33 | %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe 34 | 35 | @set DASMFLAGS=-D WIN -D JIT -D FFI -D P64 36 | @set LJARCH=x64 37 | @minilua 38 | @if errorlevel 8 goto :X64 39 | @set DASMFLAGS=-D WIN -D JIT -D FFI 40 | @set LJARCH=x86 41 | @set LJCOMPILE=%LJCOMPILE% /arch:SSE2 42 | :X64 43 | @if "%1" neq "gc64" goto :NOGC64 44 | @shift 45 | @set DASC=vm_x64.dasc 46 | @set LJCOMPILE=%LJCOMPILE% /DLUAJIT_ENABLE_GC64 47 | :NOGC64 48 | minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC% 49 | @if errorlevel 1 goto :BAD 50 | 51 | %LJCOMPILE% /I "." /I %DASMDIR% host\buildvm*.c 52 | @if errorlevel 1 goto :BAD 53 | %LJLINK% /out:buildvm.exe buildvm*.obj 54 | @if errorlevel 1 goto :BAD 55 | if exist buildvm.exe.manifest^ 56 | %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe 57 | 58 | buildvm -m peobj -o lj_vm.obj 59 | @if errorlevel 1 goto :BAD 60 | buildvm -m bcdef -o lj_bcdef.h %ALL_LIB% 61 | @if errorlevel 1 goto :BAD 62 | buildvm -m ffdef -o lj_ffdef.h %ALL_LIB% 63 | @if errorlevel 1 goto :BAD 64 | buildvm -m libdef -o lj_libdef.h %ALL_LIB% 65 | @if errorlevel 1 goto :BAD 66 | buildvm -m recdef -o lj_recdef.h %ALL_LIB% 67 | @if errorlevel 1 goto :BAD 68 | buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB% 69 | @if errorlevel 1 goto :BAD 70 | buildvm -m folddef -o lj_folddef.h lj_opt_fold.c 71 | @if errorlevel 1 goto :BAD 72 | 73 | @if "%1" neq "debug" goto :NODEBUG 74 | @shift 75 | @set LJCOMPILE=%LJCOMPILE% /Zi 76 | @set LJLINK=%LJLINK% /debug /opt:ref /opt:icf /incremental:no 77 | :NODEBUG 78 | @if "%1"=="amalg" goto :AMALGDLL 79 | @if "%1"=="static" goto :STATIC 80 | %LJCOMPILE% /MD /DLUA_BUILD_AS_DLL lj_*.c lib_*.c 81 | @if errorlevel 1 goto :BAD 82 | %LJLINK% /DLL /out:%LJDLLNAME% lj_*.obj lib_*.obj 83 | @if errorlevel 1 goto :BAD 84 | @goto :MTDLL 85 | :STATIC 86 | %LJCOMPILE% lj_*.c lib_*.c 87 | @if errorlevel 1 goto :BAD 88 | %LJLIB% /OUT:%LJLIBNAME% lj_*.obj lib_*.obj 89 | @if errorlevel 1 goto :BAD 90 | @goto :MTDLL 91 | :AMALGDLL 92 | %LJCOMPILE% /MD /DLUA_BUILD_AS_DLL ljamalg.c 93 | @if errorlevel 1 goto :BAD 94 | %LJLINK% /DLL /out:%LJDLLNAME% ljamalg.obj lj_vm.obj 95 | @if errorlevel 1 goto :BAD 96 | :MTDLL 97 | if exist %LJDLLNAME%.manifest^ 98 | %LJMT% -manifest %LJDLLNAME%.manifest -outputresource:%LJDLLNAME%;2 99 | 100 | %LJCOMPILE% luajit.c 101 | @if errorlevel 1 goto :BAD 102 | %LJLINK% /out:luajit.exe luajit.obj %LJLIBNAME% 103 | @if errorlevel 1 goto :BAD 104 | if exist luajit.exe.manifest^ 105 | %LJMT% -manifest luajit.exe.manifest -outputresource:luajit.exe 106 | 107 | @del *.obj *.manifest minilua.exe buildvm.exe 108 | @del host\buildvm_arch.h 109 | @del lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h 110 | @echo. 111 | @echo === Successfully built LuaJIT for Windows/%LJARCH% === 112 | 113 | @goto :END 114 | :BAD 115 | @echo. 116 | @echo ******************************************************* 117 | @echo *** Build FAILED -- Please check the error messages *** 118 | @echo ******************************************************* 119 | @goto :END 120 | :FAIL 121 | @echo You must open a "Visual Studio .NET Command Prompt" to run this script 122 | :END 123 | -------------------------------------------------------------------------------- /3rdlibs/lua-cjson/Makefile: -------------------------------------------------------------------------------- 1 | ##### Available defines for CJSON_CFLAGS ##### 2 | ## 3 | ## USE_INTERNAL_ISINF: Workaround for Solaris platforms missing isinf(). 4 | ## DISABLE_INVALID_NUMBERS: Permanently disable invalid JSON numbers: 5 | ## NaN, Infinity, hex. 6 | ## 7 | ## Optional built-in number conversion uses the following defines: 8 | ## USE_INTERNAL_FPCONV: Use builtin strtod/dtoa for numeric conversions. 9 | ## IEEE_BIG_ENDIAN: Required on big endian architectures. 10 | ## MULTIPLE_THREADS: Must be set when Lua CJSON may be used in a 11 | ## multi-threaded application. Requries _pthreads_. 12 | 13 | ##### Build defaults ##### 14 | LUA_VERSION = 5.1 15 | TARGET = cjson.so 16 | PREFIX = /usr/local 17 | #CFLAGS = -g -Wall -pedantic -fno-inline 18 | CFLAGS = -O3 -Wall -pedantic -DNDEBUG 19 | CJSON_CFLAGS = -fpic 20 | CJSON_LDFLAGS = -shared 21 | LUA_INCLUDE_DIR ?= $(PREFIX)/include 22 | LUA_CMODULE_DIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION) 23 | LUA_MODULE_DIR ?= $(PREFIX)/share/lua/$(LUA_VERSION) 24 | LUA_BIN_DIR ?= $(PREFIX)/bin 25 | 26 | ##### Platform overrides ##### 27 | ## 28 | ## Tweak one of the platform sections below to suit your situation. 29 | ## 30 | ## See http://lua-users.org/wiki/BuildingModules for further platform 31 | ## specific details. 32 | 33 | ## Linux 34 | 35 | ## FreeBSD 36 | #LUA_INCLUDE_DIR = $(PREFIX)/include/lua51 37 | 38 | ## MacOSX (Macports) 39 | #PREFIX = /opt/local 40 | #CJSON_LDFLAGS = -bundle -undefined dynamic_lookup 41 | 42 | ## Solaris 43 | #PREFIX = /home/user/opt 44 | #CC = gcc 45 | #CJSON_CFLAGS = -fpic -DUSE_INTERNAL_ISINF 46 | 47 | ## Windows (MinGW) 48 | #TARGET = cjson.dll 49 | #PREFIX = /home/user/opt 50 | #CJSON_CFLAGS = -DDISABLE_INVALID_NUMBERS 51 | #CJSON_LDFLAGS = -shared -L$(PREFIX)/lib -llua51 52 | #LUA_BIN_SUFFIX = .lua 53 | 54 | ##### Number conversion configuration ##### 55 | 56 | ## Use Libc support for number conversion (default) 57 | FPCONV_OBJS = fpconv.o 58 | 59 | ## Use built in number conversion 60 | #FPCONV_OBJS = g_fmt.o dtoa.o 61 | #CJSON_CFLAGS += -DUSE_INTERNAL_FPCONV 62 | 63 | ## Compile built in number conversion for big endian architectures 64 | #CJSON_CFLAGS += -DIEEE_BIG_ENDIAN 65 | 66 | ## Compile built in number conversion to support multi-threaded 67 | ## applications (recommended) 68 | #CJSON_CFLAGS += -pthread -DMULTIPLE_THREADS 69 | #CJSON_LDFLAGS += -pthread 70 | 71 | ##### End customisable sections ##### 72 | 73 | TEST_FILES = README bench.lua genutf8.pl test.lua octets-escaped.dat \ 74 | example1.json example2.json example3.json example4.json \ 75 | example5.json numbers.json rfc-example1.json \ 76 | rfc-example2.json types.json 77 | DATAPERM = 644 78 | EXECPERM = 755 79 | 80 | ASCIIDOC = asciidoc 81 | 82 | BUILD_CFLAGS = -I$(LUA_INCLUDE_DIR) $(CJSON_CFLAGS) 83 | OBJS = lua_cjson.o strbuf.o $(FPCONV_OBJS) 84 | 85 | .PHONY: all clean install install-extra doc 86 | 87 | .SUFFIXES: .html .txt 88 | 89 | .c.o: 90 | $(CC) -c $(CFLAGS) $(CPPFLAGS) $(BUILD_CFLAGS) -o $@ $< 91 | 92 | .txt.html: 93 | $(ASCIIDOC) -n -a toc $< 94 | 95 | all: $(TARGET) 96 | 97 | doc: manual.html performance.html 98 | 99 | $(TARGET): $(OBJS) 100 | $(CC) $(LDFLAGS) $(CJSON_LDFLAGS) -o $@ $(OBJS) 101 | 102 | install: $(TARGET) 103 | mkdir -p $(DESTDIR)$(LUA_CMODULE_DIR) 104 | rm -f $(DESTDIR)$(LUA_CMODULE_DIR)/$(TARGET) 105 | cp $(TARGET) $(DESTDIR)$(LUA_CMODULE_DIR) 106 | chmod $(EXECPERM) $(DESTDIR)$(LUA_CMODULE_DIR)/$(TARGET) 107 | 108 | install-extra: 109 | mkdir -p $(DESTDIR)$(LUA_MODULE_DIR)/cjson/tests \ 110 | $(DESTDIR)$(LUA_BIN_DIR) 111 | cp lua/cjson/util.lua $(DESTDIR)$(LUA_MODULE_DIR)/cjson 112 | chmod $(DATAPERM) $(DESTDIR)$(LUA_MODULE_DIR)/cjson/util.lua 113 | cp lua/lua2json.lua $(DESTDIR)$(LUA_BIN_DIR)/lua2json$(LUA_BIN_SUFFIX) 114 | chmod $(EXECPERM) $(DESTDIR)$(LUA_BIN_DIR)/lua2json$(LUA_BIN_SUFFIX) 115 | cp lua/json2lua.lua $(DESTDIR)$(LUA_BIN_DIR)/json2lua$(LUA_BIN_SUFFIX) 116 | chmod $(EXECPERM) $(DESTDIR)$(LUA_BIN_DIR)/json2lua$(LUA_BIN_SUFFIX) 117 | cd tests; cp $(TEST_FILES) $(DESTDIR)$(LUA_MODULE_DIR)/cjson/tests 118 | cd tests; chmod $(DATAPERM) $(TEST_FILES); chmod $(EXECPERM) *.lua *.pl 119 | 120 | clean: 121 | rm -f *.o $(TARGET) 122 | -------------------------------------------------------------------------------- /3rdlibs/LuaJIT/src/lj_vmmath.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Math helper functions for assembler VM. 3 | ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define lj_vmmath_c 7 | #define LUA_CORE 8 | 9 | #include 10 | #include 11 | 12 | #include "lj_obj.h" 13 | #include "lj_ir.h" 14 | #include "lj_vm.h" 15 | 16 | /* -- Wrapper functions --------------------------------------------------- */ 17 | 18 | #if LJ_TARGET_X86 && __ELF__ && __PIC__ 19 | /* Wrapper functions to deal with the ELF/x86 PIC disaster. */ 20 | LJ_FUNCA double lj_wrap_log(double x) { return log(x); } 21 | LJ_FUNCA double lj_wrap_log10(double x) { return log10(x); } 22 | LJ_FUNCA double lj_wrap_exp(double x) { return exp(x); } 23 | LJ_FUNCA double lj_wrap_sin(double x) { return sin(x); } 24 | LJ_FUNCA double lj_wrap_cos(double x) { return cos(x); } 25 | LJ_FUNCA double lj_wrap_tan(double x) { return tan(x); } 26 | LJ_FUNCA double lj_wrap_asin(double x) { return asin(x); } 27 | LJ_FUNCA double lj_wrap_acos(double x) { return acos(x); } 28 | LJ_FUNCA double lj_wrap_atan(double x) { return atan(x); } 29 | LJ_FUNCA double lj_wrap_sinh(double x) { return sinh(x); } 30 | LJ_FUNCA double lj_wrap_cosh(double x) { return cosh(x); } 31 | LJ_FUNCA double lj_wrap_tanh(double x) { return tanh(x); } 32 | LJ_FUNCA double lj_wrap_atan2(double x, double y) { return atan2(x, y); } 33 | LJ_FUNCA double lj_wrap_pow(double x, double y) { return pow(x, y); } 34 | LJ_FUNCA double lj_wrap_fmod(double x, double y) { return fmod(x, y); } 35 | #endif 36 | 37 | /* -- Helper functions for generated machine code ------------------------- */ 38 | 39 | double lj_vm_foldarith(double x, double y, int op) 40 | { 41 | switch (op) { 42 | case IR_ADD - IR_ADD: return x+y; break; 43 | case IR_SUB - IR_ADD: return x-y; break; 44 | case IR_MUL - IR_ADD: return x*y; break; 45 | case IR_DIV - IR_ADD: return x/y; break; 46 | case IR_MOD - IR_ADD: return x-lj_vm_floor(x/y)*y; break; 47 | case IR_POW - IR_ADD: return pow(x, y); break; 48 | case IR_NEG - IR_ADD: return -x; break; 49 | case IR_ABS - IR_ADD: return fabs(x); break; 50 | #if LJ_HASJIT 51 | case IR_ATAN2 - IR_ADD: return atan2(x, y); break; 52 | case IR_LDEXP - IR_ADD: return ldexp(x, (int)y); break; 53 | case IR_MIN - IR_ADD: return x > y ? y : x; break; 54 | case IR_MAX - IR_ADD: return x < y ? y : x; break; 55 | #endif 56 | default: return x; 57 | } 58 | } 59 | 60 | #if (LJ_HASJIT && !(LJ_TARGET_ARM || LJ_TARGET_ARM64 || LJ_TARGET_PPC)) || LJ_TARGET_MIPS 61 | int32_t LJ_FASTCALL lj_vm_modi(int32_t a, int32_t b) 62 | { 63 | uint32_t y, ua, ub; 64 | lua_assert(b != 0); /* This must be checked before using this function. */ 65 | ua = a < 0 ? (uint32_t)-a : (uint32_t)a; 66 | ub = b < 0 ? (uint32_t)-b : (uint32_t)b; 67 | y = ua % ub; 68 | if (y != 0 && (a^b) < 0) y = y - ub; 69 | if (((int32_t)y^b) < 0) y = (uint32_t)-(int32_t)y; 70 | return (int32_t)y; 71 | } 72 | #endif 73 | 74 | #if LJ_HASJIT 75 | 76 | #ifdef LUAJIT_NO_LOG2 77 | double lj_vm_log2(double a) 78 | { 79 | return log(a) * 1.4426950408889634074; 80 | } 81 | #endif 82 | 83 | #ifdef LUAJIT_NO_EXP2 84 | double lj_vm_exp2(double a) 85 | { 86 | return exp(a * 0.6931471805599453); 87 | } 88 | #endif 89 | 90 | #if !LJ_TARGET_X86ORX64 91 | /* Unsigned x^k. */ 92 | static double lj_vm_powui(double x, uint32_t k) 93 | { 94 | double y; 95 | lua_assert(k != 0); 96 | for (; (k & 1) == 0; k >>= 1) x *= x; 97 | y = x; 98 | if ((k >>= 1) != 0) { 99 | for (;;) { 100 | x *= x; 101 | if (k == 1) break; 102 | if (k & 1) y *= x; 103 | k >>= 1; 104 | } 105 | y *= x; 106 | } 107 | return y; 108 | } 109 | 110 | /* Signed x^k. */ 111 | double lj_vm_powi(double x, int32_t k) 112 | { 113 | if (k > 1) 114 | return lj_vm_powui(x, (uint32_t)k); 115 | else if (k == 1) 116 | return x; 117 | else if (k == 0) 118 | return 1.0; 119 | else 120 | return 1.0 / lj_vm_powui(x, (uint32_t)-k); 121 | } 122 | #endif 123 | 124 | /* Computes fpm(x) for extended math functions. */ 125 | double lj_vm_foldfpm(double x, int fpm) 126 | { 127 | switch (fpm) { 128 | case IRFPM_FLOOR: return lj_vm_floor(x); 129 | case IRFPM_CEIL: return lj_vm_ceil(x); 130 | case IRFPM_TRUNC: return lj_vm_trunc(x); 131 | case IRFPM_SQRT: return sqrt(x); 132 | case IRFPM_EXP: return exp(x); 133 | case IRFPM_EXP2: return lj_vm_exp2(x); 134 | case IRFPM_LOG: return log(x); 135 | case IRFPM_LOG2: return lj_vm_log2(x); 136 | case IRFPM_LOG10: return log10(x); 137 | case IRFPM_SIN: return sin(x); 138 | case IRFPM_COS: return cos(x); 139 | case IRFPM_TAN: return tan(x); 140 | default: lua_assert(0); 141 | } 142 | return 0; 143 | } 144 | 145 | #if LJ_HASFFI 146 | int lj_vm_errno(void) 147 | { 148 | return errno; 149 | } 150 | #endif 151 | 152 | #endif 153 | --------------------------------------------------------------------------------