Beautify opcode dumping format.

This commit is contained in:
Tor Andersson
2014-01-16 20:48:43 +01:00
parent 7228ec51c4
commit e01b4d02c0
2 changed files with 6 additions and 4 deletions
+4 -2
View File
@@ -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) {
+2 -2
View File
@@ -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);