-
Notifications
You must be signed in to change notification settings - Fork 1
/
auxgetinfo.c
92 lines (86 loc) · 2.11 KB
/
auxgetinfo.c
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
#include <time.h>
#include <setjmp.h>
#include <ctype.h>
#include "lapi.h"
#include "lauxlib.h"
#include "lcode.h"
#include "lctype.h"
#include "ldebug.h"
#include "ldo.h"
#include "lfunc.h"
#include "lgc.h"
#include "llex.h"
#include "llimits.h"
#include "lmem.h"
#include "lobject.h"
#include "lopcodes.h"
#include "lopnames.h"
#include "lparser.h"
#include "lprefix.h"
#include "lstate.h"
#include "lstring.h"
#include "ltable.h"
#include "ltm.h"
#include "luaconf.h"
#include "lua.h"
#include "lualib.h"
#include "lundump.h"
#include "lvm.h"
#include "lzio.h"
extern const char * getfuncname(lua_State *, CallInfo *, const char **);
extern int getcurrentline(CallInfo *);
extern void funcinfo(lua_Debug *, Closure *);
extern int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
Closure *f, CallInfo *ci) {
int status = 1;
for (; *what; what++) {
switch (*what) {
case 'S': {
funcinfo(ar, f);
break;
}
case 'l': {
ar->currentline = (ci && (!((ci)->callstatus & (1<<1)))) ? getcurrentline(ci) : -1;
break;
}
case 'u': {
ar->nups = (f == ((void*)0)) ? 0 : f->c.nupvalues;
if (((f) == ((void*)0) || (f)->c.tt == ((6) | ((2) << 4)))) {
ar->isvararg = 1;
ar->nparams = 0;
}
else {
ar->isvararg = f->l.p->is_vararg;
ar->nparams = f->l.p->numparams;
}
break;
}
case 't': {
ar->istailcall = (ci) ? ci->callstatus & (1<<5) : 0;
break;
}
case 'n': {
ar->namewhat = getfuncname(L, ci, &ar->name);
if (ar->namewhat == ((void*)0)) {
ar->namewhat = "";
ar->name = ((void*)0);
}
break;
}
case 'r': {
if (ci == ((void*)0) || !(ci->callstatus & (1<<8)))
ar->ftransfer = ar->ntransfer = 0;
else {
ar->ftransfer = ci->u2.transferinfo.ftransfer;
ar->ntransfer = ci->u2.transferinfo.ntransfer;
}
break;
}
case 'L':
case 'f':
break;
default: status = 0;
}
}
return status;
}