-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack_dump.h
More file actions
36 lines (30 loc) · 1 KB
/
stack_dump.h
File metadata and controls
36 lines (30 loc) · 1 KB
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
#include <stdio.h>
#include <assert.h>
#include "lua.h"
#include <lualib.h>
#include <lauxlib.h>
static void stack_dump(lua_State* L, const char *head)
{
int i;
int top = lua_gettop(L);
printf("stackDump(num=%d) %s:\n", top, head);
for (i = 1; i <= top; i++) { /* repeat for each level */
int t = lua_type(L, i);
switch (t) {
case LUA_TSTRING: /* strings */
printf("'%s'", lua_tostring(L, i));
break;
case LUA_TBOOLEAN: /* booleans */
printf(lua_toboolean(L, i) ? "true" : "false");
break;
case LUA_TNUMBER: /* numbers */
printf("%g", lua_tonumber(L, i));
break;
default: /* other values */
printf("%s", lua_typename(L, t));
break;
}
printf(" "); /* put a separator */
}
printf("\n============\n"); /* end the listing */
}