-
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: README.md src/Makefile
- Loading branch information
Showing
9 changed files
with
133 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.h | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
LANG_LUA_FILES = ast-boolean-const-eval.lua ast-const-eval.lua bcread.lua bcsave.lua \ | ||
bytecode.lua compile.lua generator.lua lexer.lua lua-ast.lua operator.lua \ | ||
parser.lua reader.lua | ||
|
||
LANG_H_FILES = $(LANG_LUA_FILES:%.lua=%.h) | ||
|
||
all: $(LANG_H_FILES) | ||
|
||
clean: | ||
rm -fr $(LANG_H_FILES) | ||
|
||
%.h: %.lua | ||
luajit -b $< $@ | ||
|
||
.PHONY: all clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include <string.h> | ||
#include <lua.h> | ||
#include <lauxlib.h> | ||
|
||
#include "language_bcloader.h" | ||
|
||
#include "lang/ast-boolean-const-eval.h" | ||
#include "lang/ast-const-eval.h" | ||
#include "lang/bcread.h" | ||
#include "lang/bcsave.h" | ||
#include "lang/bytecode.h" | ||
#include "lang/compile.h" | ||
#include "lang/generator.h" | ||
#include "lang/lexer.h" | ||
#include "lang/lua-ast.h" | ||
#include "lang/operator.h" | ||
#include "lang/parser.h" | ||
#include "lang/reader.h" | ||
|
||
struct bcpair { | ||
const char *name; | ||
const char *bc; | ||
size_t size; | ||
}; | ||
|
||
static struct bcpair bcmodule[] = { | ||
{"ast-boolean-const-eval", luaJIT_BC_ast_boolean_const_eval, luaJIT_BC_ast_boolean_const_eval_SIZE}, | ||
{"ast-const-eval", luaJIT_BC_ast_const_eval, luaJIT_BC_ast_const_eval_SIZE}, | ||
{"bcread", luaJIT_BC_bcread, luaJIT_BC_bcread_SIZE}, | ||
{"bcsave", luaJIT_BC_bcsave, luaJIT_BC_bcsave_SIZE}, | ||
{"bytecode", luaJIT_BC_bytecode, luaJIT_BC_bytecode_SIZE}, | ||
{"compile", luaJIT_BC_compile, luaJIT_BC_compile_SIZE}, | ||
{"generator", luaJIT_BC_generator, luaJIT_BC_generator_SIZE}, | ||
{"lexer", luaJIT_BC_lexer, luaJIT_BC_lexer_SIZE}, | ||
{"lua-ast", luaJIT_BC_lua_ast, luaJIT_BC_lua_ast_SIZE}, | ||
{"operator", luaJIT_BC_operator, luaJIT_BC_operator_SIZE}, | ||
{"parser", luaJIT_BC_parser, luaJIT_BC_parser_SIZE}, | ||
{"reader", luaJIT_BC_reader, luaJIT_BC_reader_SIZE}, | ||
{0, 0, 0} | ||
}; | ||
|
||
/* Load into package.preload lang.* modules using embedded bytecode. */ | ||
void language_bc_preload(lua_State *L) | ||
{ | ||
struct bcpair *i; | ||
lua_getfield(L, LUA_GLOBALSINDEX, "package"); | ||
lua_getfield(L, -1, "preload"); | ||
for (i = bcmodule; i->name; i++) { | ||
lua_pushstring(L, "lang."); | ||
lua_pushstring(L, i->name); | ||
lua_concat(L, 2); | ||
luaL_loadbuffer(L, i->bc, i->size, lua_tostring(L, -1)); | ||
lua_rawset(L, -3); | ||
} | ||
lua_pop(L, 2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef LANG_LANGBC_H | ||
#define LANG_LANGBC_H | ||
|
||
#include <lua.h> | ||
|
||
extern void language_bc_preload(lua_State *L); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters