Lua源文件目录分析,lua源文件目录
Lua源文件目录分析,lua源文件目录
关于Lua源文件分析是本文要介绍的内容,主要是来聊lua的源文件,本人认为作为初学者应该去了解并学习这些内容,具体来看本文详解。
lua 5.1.4核心的源代码共55个文件,大致分析如下:
lapi.c // Lua API,C调用API
lapi.h // Auxiliary functions from Lua API
lauxlib.c // Auxiliary functions for building Lua libraries
lauxlib.h // Auxiliary functions for building Lua libraries
lbaselib.c // Basic library
lcode.c // Code generator for Lua
lcode.h // Code generator for Lua
ldblib.c // Interface from Lua to its debug API,调试
ldebug.c // Debug Interface,调试
ldebug.h // Auxiliary functions from Debug Interface module,调试
ldo.c // Stack and Call structure of Lua
ldo.h // Stack and Call structure of Lua
ldump.c // save precompiled Lua chunks
lfunc.c // Auxiliary functions to manipulate prototypes and closures
lfunc.h // Auxiliary functions to manipulate prototypes and closures
lgc.c // Garbage Collector
lgc.h // Garbage Collector
linit.c // Initialization of libraries for lua.c
liolib.c // Standard I/O (and system) library
llex.c // Lexical Analyzer
llex.h // Lexical Analyzer
llimits.h // Limits, basic types, and some other `installation-dependent' definitions
lmathlib.c // Standard mathematical library
lmem.c // Interface to Memory Manager
lmem.h // Interface to Memory Manager
loadlib.c // Dynamic library loader for Lua
lobject.c // Some generic functions over Lua objects
lobject.h // Type definitions for Lua objects
lopcodes.c // 指令定义
lopcodes.h // Opcodes for Lua virtual machine
loslib.c // Standard Operating System library
lparser.c // Lua Parser
lparser.h // Lua Parser
lstate.c // Global State
lstate.h // Global State
lstring.c // String table (keeps all strings handled by Lua)
lstring.h // String table (keeps all strings handled by Lua)
lstrlib.c // Standard library for string operations and pattern-matching
ltable.c // Lua tables (hash)
ltable.h // Lua tables (hash)
ltablib.c // Library for Table Manipulation
ltm.c // Tag methods
ltm.h // Tag methods
lua.c // Lua stand-alone interpreter
lua.h // Lua - An Extensible Extension Language,C语言中用来调用Lua函数的头文件
luac.c // Lua compiler (saves bytecodes to files; also list bytecodes)
luaconf.h // Configuration file for Lua
lualib.h // Lua standard libraries,Lua标准库的定义文件
lundump.c // load precompiled Lua chunks
lundump.h // load precompiled Lua chunks
lvm.c // Lua virtual machine
lvm.h // Lua virtual machine
lzio.c // a generic input stream interface
lzio.h // Buffered streams
print.c // print bytecodes
原文是英文版的,利用一点时间翻译成中文的。希望bina大虾指点一二。
ldebug.c - 调试接口:包含访问调试钩子的函数(lua_sethook/lua_gethook/lua_gethookcount),访问运行时堆栈信息的函数
(lua_getstatck/lua_getlocal/lua_setlocal),检查字节码函数(luaG_checkopenop /luaG_checkcode),
和抛出错误的函数(luaG_typeerror/luaG_concaterror /luaG_aritherror/luaG_ordererror/luaG_errormsg/luaG_runerror)
lzio.c - 一个通用的带缓冲区的输入流接口
lmem.c - 内存管理的接口.通过封装内存分配函数,实现了luaM_realloc / luaM_growaux_两个函数.
lgc.c - 垃圾回收器(内存管理)
lstate.c - 全局上下文. 包括打开和关闭LUA上线文的函数(lua_newstate/lua_close)和lua线程函数(luaE_newthread/luaE_freethread)
lobject.c - 一些针对Lua对象的通用函数。 包括数据类型到字符串转换函数,纯数据相等测试函数(luaO_rawequalObj),和日志基础2(luaO_log2)
lstring.c - 字符串表(保存所有由Lua操作的字符串集合)
lfunc.c - 包装原型和闭包的辅助函数
ltable.c - Lua表实现(哈希)
lcode.c - Lua的代码生成器。被lparser.c使用
llex.c - 此法分析器。被lparser.c使用
lparser.c - Lua语法检查器
lundump.c - 加载预编译后的Lua代码块,函数luaU_undump,加载一个预编译后的代码块;luaU_header(被luaU_undump使用的内部函数),用来检查函数头部。
ldump.c - 保存预编译后的Lua代码块。函数luaU_dump,使用预编译后的代码字符串展示一个函数;
lopcodes.c - Lua虚拟机的操作符。定义所有操作符的名称和信息(使用luaP_opnames和luaP_opmodes两个表保存)
lvm.c - Lua虚拟机。执行字节码(luaV_execute)。也暴漏一些lapi.c可能用到的函数(例如:luaV_concat)
ldo.c - Lua的栈和调用结构。控制函数调用(luaD_call/luaD_pcall),栈增长,协同代码的同步
ltm.c - 标记原语方法。实现对象访问原语方法(metathods)
lbaselib.c - 基础函数库
lstrlib.c - 字符串库
ltable.c - 表操作库
lmathlib.c - 数学库
loslib.c - 操作系统相关库
liolib.c - 输入输入库
loadlib.c - 模块库(实现require函数,package函数)
ldblib.c - 调试库
lapi.c - Lua的API.实现Lua C API(lua_*函数)集合
lauxlib.c - 定义所有的luaL_*函数集
linit.c - 实现luaL_openlibs方法,便于在C语言中加载上述模块
lua.c - Lua独立解释器
print.c - 定义 "PrintFunction?" 函数,用于在函数中打印字节码(被luac.c中-l参数所用)
luac.c - Lua编译器(保存字节码到一个文件,也可以列出字节码)
The prefix of a external symbol indicates the module it comes from:
外部符号的前缀暗示他来自哪一个文件:
luaA_ - lapi.c
luaB_ - lbaselib.c
luaC_ - lgc.c
luaD_ - ldo.c
luaE_ - lstate.c
luaF_ - lfunc.c
luaG_ - ldebug.c
luaH_ - ltable.c
luaI_ - lauxlib.c
luaK_ - lcode.c
luaL_ - lauxlib.c/h, linit.c (public functions)
luaM_ - lmem.c
luaO_ - lobject.c
luaP_ - lopcodes.c
luaS_ - lstring.c
luaT_ - ltm.c
luaU_ - lundump.c
luaV_ - lvm.c
luaX_ - llex.c
luaY_ - lparser.c
luaZ_ - lzio.c
lua_? - lapi.c/h + luaconf.h, debug.c
luai_ - luaconf.h
luaopen_ - luaconf.h + libraries (lbaselib.c, ldblib.c, liolib.c, lmathlib.c,
评论暂时关闭