首页 > 其他 > 详细

lua源码:Tvalue

时间:2019-04-09 10:50:06      阅读:161      评论:0      收藏:0      [点我收藏+]

typedef TValue *StkId; /* 堆栈中的元素 */
typedef struct lua_TValue TValue;

struct lua_TValue {
TValuefields; /* 堆栈中的元素 */
};

// 定义了双精度浮点或者通用类型定义
#define TValuefields \
union { struct { Value v__; int tt__; } i; double d__; } u

#define LUA_NUMBER double
typedef LUA_NUMBER lua_Number;
#define numfield lua_Number n; /* 双精度浮点数 */
#define numfield /* no such field; numbers are the entire struct(另外一种定义) */

// Value包括可回收对象和不可回收对象两种类型
// 不可回收对象包括:bool、
union Value {
GCObject *gc; /* collectable objects */
void *p; /* light userdata */
int b; /* booleans */
lua_CFunction f; /* light C functions */
numfield /* 双精度浮点数,实际上可能为空 */
};

/*
** Union of all collectable objects
*/
union GCObject {
GCheader gch; /* common header */
union TString ts; /* 字符串 */
union Udata u; /* 用户自定义数据 */
union Closure cl; /* 函数闭包,其实似乎Proto的一个实例 */
struct Table h; /* 表结构 */
struct Proto p; /* 函数原型,被闭包共享同一个定义 */
struct UpVal uv; /* 闭包所引用的变量 */
struct lua_State th; /* thread */
};

lua源码:Tvalue

原文:https://www.cnblogs.com/losophy/p/10674960.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!