-
Notifications
You must be signed in to change notification settings - Fork 105
Open
Description
To get a grip on the BOT/TOP STACK stuff with the negative or positive indices I needed more readable output, like this:
STACK 0 (-6) [CFunction Object]
1 (-5) [Script [string]]
BOT> 2 (-4) undefined
3 (-3/+1) [CFunction print]
4 (-2/+2) undefined
5 (-1/+3) 'hello: VfL Bochum 1848'
TOP> 6
This function does this:
static void js_dumpstack_fp(js_State *J, FILE *fp)
{
int i;
int n;
for( i = 0; i < TOP; ++i)
{
fprintf( fp, i == BOT ? "BOT> " : (i == 0 ? "STACK " : " "));
n = fprintf( fp, "%d (-%d", i, TOP - i);
if( i > BOT)
n += fprintf( fp, "/+%d", i - BOT);
n += fprintf( fp, ")");
while( n < 16)
{
fputc( ' ', fp);
++n;
}
js_dumpvalue_fp(J, STACK[i], fp);
fputc('\n', fp);
}
fprintf( fp, "TOP> %d\n", TOP);
}
static void js_dumpstack(js_State *J)
{
js_dumpstack_fp( J, stderr);
}Metadata
Metadata
Assignees
Labels
No labels