Lua动态加载脚本( loadstring )

作者:糖果

下面是代码:

local lua_script = [[
     local var = 1
     print(var)
]]


local  script = lua_script 
local tb=assert(loadstring(script))()
print(tb[0].text)
const char* testfunc = "print (add(1.0, 2.0)) print(sub(20.1, 19))";

int main()
{
        lua_State* L = luaL_newstate();
        luaL_openlibs(L);
        lua_register(L, "add", add);
        lua_register(L, "sub", sub);

        if (luaL_dostring(L, testfunc))
                printf("Failed to invoke.\n");

        lua_close(L);
        return 0;
}

糖果实验室 www.lua.ren/topic/158

糖果

糖果
LUA从入门到放弃

Tweyseo Walkonluajit 1

# **0. 背景**## **a. 目的**这里主要研究LuaJIT的Trace的相关原理,并且展示如何使用LuaJIT提供的[v.lua](https://github.com/LuaJIT/LuaJIT/blob/master/src/jit/v.lua)和[dump...… Continue reading

Nginx+Lua中文WIKI

Published on March 14, 2019