From e01b4d02c0312f6ddc5b03adb78ed806d1eb22bb Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 16 Jan 2014 17:10:13 +0100 Subject: [PATCH] Beautify opcode dumping format. --- jsdump.c | 6 ++++-- jsload.c | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/jsdump.c b/jsdump.c index 8ba943e..5044cb7 100644 --- a/jsdump.c +++ b/jsdump.c @@ -595,7 +595,7 @@ void jsC_dumpfunction(js_State *J, js_Function *F) short *end = F->code + F->codelen; int i; - printf("function %p %s(", F, F->name); + printf("function %p %s (", F, F->name); for (i = 0; i < F->numparams; ++i) printf("%s%s", i > 0 ? ", " : "", F->params[i]); printf(")\n"); @@ -608,10 +608,11 @@ void jsC_dumpfunction(js_State *J, js_Function *F) for (i = 0; i < F->numlen; ++i) printf("\tnumber %.9g\n", F->numtab[i]); + printf("{\n"); while (p < end) { int c = *p++; - printf("%04d: ", (int)(p - F->code) - 1); + printf("% 5d: ", (int)(p - F->code) - 1); ps(opname[c]); switch (c) { @@ -647,6 +648,7 @@ void jsC_dumpfunction(js_State *J, js_Function *F) nl(); } + printf("}\n"); for (i = 0; i < F->funlen; ++i) { if (F->funtab[i] != F) { diff --git a/jsload.c b/jsload.c index 906ea55..1dbf78f 100644 --- a/jsload.c +++ b/jsload.c @@ -9,9 +9,9 @@ static int jsP_loadstring(js_State *J, const char *filename, const char *source) js_Ast *prog = jsP_parse(J, filename, source); if (prog) { js_Function *fun; - //jsP_optimize(J, prog); + jsP_optimize(J, prog); //jsP_dumpsyntax(J, prog); - jsP_dumplist(J, prog); + //jsP_dumplist(J, prog); fun = jsC_compile(J, prog); if (fun) { jsC_dumpfunction(J, fun);