forked from middlefeng/LuaVMRead
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lobject.h
124 lines (82 loc) · 3.17 KB
/
lobject.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
StkId --> TValue --> lua_TValue --> (contains) TValuefields
TValuefields
-----------------
value (Value) ---> (union) gc (GCObject)
tt_ (int) p (void)
b (int)
f (lua_CFunction)
n (ua_Number)
setnilvalue(obj)
==================
Assign *tt_* field as LUA_TNIL
GCObject
-----------------
"gclist" is the next node of the gray list if the object resides in one such list.
-------------------------------------------------
GCObject* next |
lu_byte tt | Common header
lu_byte marked |
-------------------------------------------------
lu_byte nupvalues | Closure header
GCObject* gclist |
-------------------------------------------------
-------------------------------------------------
GCObject* next |
lu_byte tt | Common header
lu_byte marked |
-------------------------------------------------
lu_byte extra |
unsigned int hash | tsv
size_t len |
-------------------------------------------------
UpVal
-----------------
-------------------------------------------------------------------------------------
GCObject* next | linked to "L->openupval" |
lu_byte tt | | Common header
lu_byte marked | |
-------------------------------------------------------------------------------------
TValue* v | linked to either in-stack value or to "value"
-------------------------------------------------------------------------------------
TValue value | UpVal* prev |
| UpVal* next | linked to "g->uphead"
Table
-----------------
-------------------------------------------------
GCObject* next |
lu_byte tt | Common header
lu_byte marked |
-------------------------------------------------
lu_byte flags | Presence of meta-method. "1" means absent. All "1" at initialized.
lu_byte lsizenode | Log(sizenode), so there is no "sizenode" field
... |
Node* node | Hashed key-value
... |
Proto
-----------------
-------------------------------------------------
GCObject* next |
lu_byte tt | Common header
lu_byte marked |
-------------------------------------------------
... |
--------------------------------------------------------------------------------------------------
LocVar* locvars | TString* varname | debug and parsing information for local-var,
| int startpc | used for var-seach in parsing. indexed by
| int endpc | "Dyndata::actvar.arr".
--------------------------------------------------------------------------------------------------
... |
int sizecode | size of "code"
int sizelineinfo | size of "lineinfo"
... |
lu_byte is_vararg | it has mere two possible values now, 0 or 1.
lu_byte upvalues | for the _description_ of upvalues. For example, if an upval shall be
| on the stack (locals of enclosing function).
Closure
-----------------
upvals: Reference to real upvals. Its initialization is made according to
Proto.upvalues specification.
setgcovalue(L,obj,x)
==================
Set TValue "obj" pointing to collectable object "x", including make "obj" and "x"
marked as the same type ("tt_" field of the former and "tt" field of the latter).