标签:
options | 说明 |
-l | 生成lua编译后字节码的可视化数据,这对于学习lua虚拟机很有帮助 |
-o file | 编译lua代码,输出文件为file。默认生成 luac.out |
-s | 写入输出文件时去掉调试信息。可以减少输出文件的大小,但错误信息就比较简单,例如,少了行号和局部变量名 |
-v | 显示版本信息 |
#!/bin/bash LUAC=./3rd/lua/luac mkdir -p bin Luas=`find . -name "*.lua"` for file in $Luas do filename = `basename $file` $LUAC -o bin/$filename $file done |
root = "./" thread = 8 logger = nil logpath = "." harbor = 1 address = "127.0.0.1:2526" master = "127.0.0.1:2013" start = "main" -- main script bootstrap = "snlua bootstrap" -- The service for bootstrap standalone = "0.0.0.0:2013" luaservice = root.."bin/?.lua;" lualoader = root.."bin/loader.lua" snax = root.."bin/?.lua" -- snax_interface_g = "snax_g" cpath = root.."cservice/?.so" -- daemon = "./skynet.pid" |
// luac.c static int writer(lua_State* L, const void* p, size_t size, void* u) { int ret = !0; size_t i =0; char* pp = (char *)malloc(sizeof(char*)*size); UNUSED(L); memcpy(pp, p, size); for(;i<size;i++) pp[i] ^=250; ret = (fwrite((void*)pp,size,1,(FILE*)u)!=1) && (size!=0); free(pp); return ret; } |
//lauxlib.c static const char *getF (lua_State *L, void *ud, size_t *size) { LoadF *lf = (LoadF *)ud; (void)L; /* not used */ if (lf->n > 0) { /* are there pre-read characters to be read? */ *size = lf->n; /* return them (chars already in buffer) */ lf->n = 0; /* no more pre-read characters */ } else { /* read a block from file */ /* ‘fread‘ can return > 0 *and* set the EOF flag. If next call to ‘getF‘ called ‘fread‘, it might still wait for user input. The next check avoids this problem. */ if (feof(lf->f)) return NULL; *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); /* read block */ } do{size_t i=0; for(;i<*size;) lf->buff[i++] ^= 250;}while(0); return lf->buff; } |
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/mycwq/article/details/47406337