lua5.3.3源码学习日志(1)--lstate.h
来源:互联网 发布:excel怎么复制所有数据 编辑:程序博客网 时间:2024/06/05 08:31
中文记录
可能,会很零碎,看到哪,写到哪。顺便学习markdown,不定期,慢慢更新。
- 一些关于gc对象的话,所有的对象objects在lua里面再被释放前,都应该有方法可以访问到。所以,所有的objects总是属于某个(也是唯一一个)列表,通过next字段来链接。
关键字
- stringtable
typedef struct stringtable { TString **hash; int nuse; /* number of elements */ int size; } stringtable;
- CallInfo
/*** Information about a call.** When a thread yields, 'func' is adjusted to pretend that the** top function has only the yielded values in its stack; in that** case, the actual 'func' value is saved in field 'extra'. ** When a function calls another with a continuation, 'extra' keeps** the function index so that, in case of errors, the continuation** function can be called with the correct top.*/typedef struct CallInfo { StkId func; /* function index in the stack */ StkId top; /* top for this function */ struct CallInfo *previous, *next; /* dynamic call link */ union { struct { /* only for Lua functions */ StkId base; /* base for this function */ const Instruction *savedpc; } l; struct { /* only for C functions */ lua_KFunction k; /* continuation in case of yields */ ptrdiff_t old_errfunc; lua_KContext ctx; /* context info. in case of yields */ } c; } u; ptrdiff_t extra; short nresults; /* expected number of results from this function */ lu_byte callstatus;} CallInfo;
这里我理解为,当调用在某个thread上的时候(yields),func 会被调整成一个顶层函数,在堆栈里拥有着唯一的值。emmmm,还是要去看实现调用。
callstatus,类型是 lu_byte(unsigned char),主要用于通过位与确定回调(call)的状态,类型如下:
/*** Bits in CallInfo status*/#define CIST_OAH (1<<0) /* original value of 'allowhook' */#define CIST_LUA (1<<1) /* call is running a Lua function */#define CIST_HOOKED (1<<2) /* call is running a debug hook */#define CIST_FRESH (1<<3) /* call is running on a fresh invocationof luaV_execute */#define CIST_YPCALL (1<<4) /* call is a yieldable protected call */#define CIST_TAIL (1<<5) /* call was tail called */#define CIST_HOOKYIELD (1<<6) /* last hook called yielded */#define CIST_LEQ (1<<7) /* using __lt for __le */
- 基础设置函数:设置callstatus
/* assume that CIST_OAH has offset 0 and that 'v' is strictly 0/1 */#define setoah(st,v) ((st) = ((st) & ~CIST_OAH) | (v))#define getoah(st) ((st) & CIST_OAH)
- global_State
/*** 'global state', shared by all threads of this state*/typedef struct global_State{···}
- lua_State ,
/*** 'per thread' state*/struct lua_State {CommonHeader;···}
- CommonHeader , 就通用头,所有可回收的objects。
/*** Common Header for all collectable objects (in macro form, to be** included in other objects)*/#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked
阅读全文
0 0
- lua5.3.3源码学习日志(1)--lstate.h
- Lua5.1代码阅读(二):llex.h/llex.c
- Lua5.1代码阅读(三):lcode.h/lcode.c
- Lua5.1代码阅读(四):lparser.h/lparser.c
- Lua5.1代码阅读(五):lundump.h/lundump.c
- Lua5.1代码阅读(六):ltm.h/ltm.c
- Lua5.1代码阅读(七):lvm.h/lvm.c
- Lua5.1代码阅读(八):ldo.h/ldo.c
- lua5.1学习笔记(二)
- lua5.1学习笔记(一)
- Lua5.2.3源码阅读(1)-TValue,TString
- Lua5.2.3源码阅读(1)-TValue,TString
- Lua5.1 源码注释(一) table.c
- 使用vs2010编译lua5.1源码生成lua.lib
- lua5.3模块学习
- h.264入门日志(1)
- lua5.2.3源码阅读笔记
- Lua基础语法学习(二)+Lua5.3参考手册
- HTML字符实体转换
- 徐汉彬:Web系统大规模并发——电商秒杀与抢购
- 一些ES使用事项
- div 仿 功能健全的textArea,实现监听
- 变量未初始化的可能性
- lua5.3.3源码学习日志(1)--lstate.h
- 图论一课(2)
- LeetCode【66】 Plus One
- sms_shelll
- 剑指offer—圆圈中最后剩下的数
- 7-10(图) 旅游规划
- scipy.spatial 距离计算模块
- python文件打开方式
- nfs和iscsi target