Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
lfunc.h File Reference
#include "lobject.h"

Go to the source code of this file.

Macros

#define sizeCclosure(n)
 
#define sizeLclosure(n)
 

Functions

LUAI_FUNC ProtoluaF_newproto (lua_State *L)
 
LUAI_FUNC ClosureluaF_newCclosure (lua_State *L, int nelems, Table *e)
 
LUAI_FUNC ClosureluaF_newLclosure (lua_State *L, int nelems, Table *e)
 
LUAI_FUNC UpValluaF_newupval (lua_State *L)
 
LUAI_FUNC UpValluaF_findupval (lua_State *L, StkId level)
 
LUAI_FUNC void luaF_close (lua_State *L, StkId level)
 
LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f)
 
LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c)
 
LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv)
 
LUAI_FUNC const char * luaF_getlocalname (const Proto *func, int local_number, int pc)
 

Macro Definition Documentation

◆ sizeCclosure

#define sizeCclosure ( n)
Value:
(cast(int, sizeof(CClosure)) + \
cast(int, sizeof(TValue)*((n)-1)))
#define cast(t, exp)

Definition at line 14 of file lua-5.1.5/src/lfunc.h.

14#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \
15 cast(int, sizeof(TValue)*((n)-1)))

Referenced by freeobj(), freeobj(), freeobj(), luaF_freeclosure(), luaF_newCclosure(), luaF_newCclosure(), luaF_newCclosure(), propagatemark(), traverseCclosure(), and traverseCclosure().

◆ sizeLclosure

#define sizeLclosure ( n)
Value:
(cast(int, sizeof(LClosure)) + \
cast(int, sizeof(TValue *)*((n)-1)))

Definition at line 17 of file lua-5.1.5/src/lfunc.h.

17#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \
18 cast(int, sizeof(TValue *)*((n)-1)))

Referenced by freeLclosure(), freeobj(), freeobj(), luaF_freeclosure(), luaF_newLclosure(), luaF_newLclosure(), luaF_newLclosure(), propagatemark(), traverseLclosure(), and traverseLclosure().

Function Documentation

◆ luaF_close()

LUAI_FUNC void luaF_close ( lua_State * L,
StkId level )

Definition at line 96 of file lua-5.1.5/src/lfunc.c.

96 {
97 UpVal *uv;
98 global_State *g = G(L);
99 while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) {
100 GCObject *o = obj2gco(uv);
101 lua_assert(!isblack(o) && uv->v != &uv->u.value);
102 L->openupval = uv->next; /* remove from `open' list */
103 if (isdead(g, o))
104 luaF_freeupval(L, uv); /* free upvalue */
105 else {
106 unlinkupval(uv);
107 setobj(L, &uv->u.value, uv->v);
108 uv->v = &uv->u.value; /* now current value lives here */
109 luaC_linkupval(L, uv); /* link upvalue into `gcroot' list */
110 }
111 }
112}
#define NULL
Definition gmacros.h:924
void luaF_freeupval(lua_State *L, UpVal *uv)
static void unlinkupval(UpVal *uv)
void luaC_linkupval(lua_State *L, UpVal *uv)
#define isblack(x)
#define isdead(g, v)
#define lua_assert(c)
#define setobj(L, obj1, obj2)
#define G(L)
#define obj2gco(v)
#define ngcotouv(o)
union UpVal::@48 u
struct UpVal * next
GCObject * openupval

◆ luaF_findupval()

LUAI_FUNC UpVal * luaF_findupval ( lua_State * L,
StkId level )

Definition at line 53 of file lua-5.1.5/src/lfunc.c.

53 {
54 global_State *g = G(L);
55 GCObject **pp = &L->openupval;
56 UpVal *p;
57 UpVal *uv;
58 while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) {
59 lua_assert(p->v != &p->u.value);
60 if (p->v == level) { /* found a corresponding upvalue? */
61 if (isdead(g, obj2gco(p))) /* is it dead? */
62 changewhite(obj2gco(p)); /* ressurect it */
63 return p;
64 }
65 pp = &p->next;
66 }
67 uv = luaM_new(L, UpVal); /* not found: create a new one */
68 uv->tt = LUA_TUPVAL;
69 uv->marked = luaC_white(g);
70 uv->v = level; /* current value lives in the stack */
71 uv->next = *pp; /* chain it in the proper position */
72 *pp = obj2gco(uv);
73 uv->u.l.prev = &g->uvhead; /* double link it in `uvhead' list */
74 uv->u.l.next = g->uvhead.u.l.next;
75 uv->u.l.next->u.l.prev = uv;
76 g->uvhead.u.l.next = uv;
77 lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
78 return uv;
79}
#define changewhite(x)
#define luaC_white(g)
#define luaM_new(L, t)
#define LUA_TUPVAL
struct UpVal * prev
struct UpVal::@48::@49 l

◆ luaF_freeclosure()

LUAI_FUNC void luaF_freeclosure ( lua_State * L,
Closure * c )

Definition at line 152 of file lua-5.1.5/src/lfunc.c.

152 {
153 int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) :
154 sizeLclosure(c->l.nupvalues);
155 luaM_freemem(L, c, size);
156}
#define sizeLclosure(n)
#define sizeCclosure(n)
#define luaM_freemem(L, b, s)

References Closure::c, Closure::l, luaM_freemem, sizeCclosure, and sizeLclosure.

Referenced by freeobj().

◆ luaF_freeproto()

LUAI_FUNC void luaF_freeproto ( lua_State * L,
Proto * f )

Definition at line 141 of file lua-5.1.5/src/lfunc.c.

141 {
143 luaM_freearray(L, f->p, f->sizep, Proto *);
144 luaM_freearray(L, f->k, f->sizek, TValue);
145 luaM_freearray(L, f->lineinfo, f->sizelineinfo, int);
146 luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar);
148 luaM_free(L, f);
149}
lu_int32 Instruction
#define luaM_freearray(L, b, n, t)
#define luaM_free(L, b)
Instruction * code
struct LocVar * locvars
struct Proto ** p
TString ** upvalues

◆ luaF_freeupval()

LUAI_FUNC void luaF_freeupval ( lua_State * L,
UpVal * uv )

Definition at line 89 of file lua-5.1.5/src/lfunc.c.

89 {
90 if (uv->v != &uv->u.value) /* is it open? */
91 unlinkupval(uv); /* remove from open list */
92 luaM_free(L, uv); /* free upvalue */
93}

◆ luaF_getlocalname()

LUAI_FUNC const char * luaF_getlocalname ( const Proto * func,
int local_number,
int pc )

Definition at line 163 of file lua-5.1.5/src/lfunc.c.

163 {
164 int i;
165 for (i = 0; i<f->sizelocvars && f->locvars[i].startpc <= pc; i++) {
166 if (pc < f->locvars[i].endpc) { /* is variable active? */
167 local_number--;
168 if (local_number == 0)
169 return getstr(f->locvars[i].varname);
170 }
171 }
172 return NULL; /* not found */
173}
#define getstr(ts)

◆ luaF_newCclosure()

LUAI_FUNC Closure * luaF_newCclosure ( lua_State * L,
int nelems,
Table * e )

Definition at line 23 of file lua-5.1.5/src/lfunc.c.

23 {
24 Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems)));
26 c->c.isC = 1;
27 c->c.env = e;
28 c->c.nupvalues = cast_byte(nelems);
29 return c;
30}
void luaC_link(lua_State *L, GCObject *o, lu_byte tt)
#define cast_byte(i)
#define luaM_malloc(L, t)
#define LUA_TFUNCTION

References Closure::c, cast, cast_byte, LUA_TFUNCTION, luaC_link(), luaM_malloc, obj2gco, and sizeCclosure.

Referenced by f_Ccall(), and lua_pushcclosure().

◆ luaF_newLclosure()

LUAI_FUNC Closure * luaF_newLclosure ( lua_State * L,
int nelems,
Table * e )

Definition at line 33 of file lua-5.1.5/src/lfunc.c.

33 {
34 Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems)));
36 c->l.isC = 0;
37 c->l.env = e;
38 c->l.nupvalues = cast_byte(nelems);
39 while (nelems--) c->l.upvals[nelems] = NULL;
40 return c;
41}

References cast, cast_byte, Closure::l, LUA_TFUNCTION, luaC_link(), luaM_malloc, NULL, obj2gco, sizeLclosure, and LClosure::upvals.

Referenced by f_parser(), luaU_undump(), luaU_undump(), luaV_execute(), luaY_parser(), pushclosure(), pushclosure(), and pushclosure().

◆ luaF_newproto()

LUAI_FUNC Proto * luaF_newproto ( lua_State * L)

Definition at line 115 of file lua-5.1.5/src/lfunc.c.

115 {
116 Proto *f = luaM_new(L, Proto);
118 f->k = NULL;
119 f->sizek = 0;
120 f->p = NULL;
121 f->sizep = 0;
122 f->code = NULL;
123 f->sizecode = 0;
124 f->sizelineinfo = 0;
125 f->sizeupvalues = 0;
126 f->nups = 0;
127 f->upvalues = NULL;
128 f->numparams = 0;
129 f->is_vararg = 0;
130 f->maxstacksize = 0;
131 f->lineinfo = NULL;
132 f->sizelocvars = 0;
133 f->locvars = NULL;
134 f->linedefined = 0;
135 f->lastlinedefined = 0;
136 f->source = NULL;
137 return f;
138}
#define LUA_TPROTO
lu_byte maxstacksize
TString * source

◆ luaF_newupval()

LUAI_FUNC UpVal * luaF_newupval ( lua_State * L)

Definition at line 44 of file lua-5.1.5/src/lfunc.c.

44 {
45 UpVal *uv = luaM_new(L, UpVal);
47 uv->v = &uv->u.value;
48 setnilvalue(uv->v);
49 return uv;
50}
#define setnilvalue(obj)