Some cleanups.

This commit is contained in:
Tor Andersson
2014-02-10 23:51:34 +01:00
parent e45115faee
commit be3ed5250c
4 changed files with 15 additions and 25 deletions

View File

@@ -200,10 +200,10 @@ void jsB_init(js_State *J)
jsB_initnumber(J);
jsB_initstring(J);
jsB_initregexp(J);
jsB_initdate(J);
jsB_initerror(J);
jsB_initmath(J);
jsB_initjson(J);
jsB_initdate(J);
/* Initialize the global object */
js_pushnumber(J, NAN);

View File

@@ -32,14 +32,15 @@ enum js_OpCode
OP_NULL,
OP_TRUE,
OP_FALSE,
OP_THIS,
OP_GLOBAL,
OP_CURRENT, /* currently executing function object */
OP_INITLOCAL, /* <value> -N- */
OP_GETLOCAL, /* -N- <value> */
OP_SETLOCAL, /* <value> -N- <value> */
OP_DELLOCAL, /* -N- false */
OP_INITLOCAL, /* <value> -K- */
OP_GETLOCAL, /* -K- <value> */
OP_SETLOCAL, /* <value> -K- <value> */
OP_DELLOCAL, /* -K- false */
OP_INITVAR, /* <value> -S- */
OP_DEFVAR, /* -S- */
@@ -64,7 +65,7 @@ enum js_OpCode
OP_DELPROP_S, /* <obj> -S- <success> */
OP_ITERATOR, /* <obj> -- <iobj> */
OP_NEXTITER, /* <iobj> -- <iobj> <name> true || false */
OP_NEXTITER, /* <iobj> -- ( <iobj> <name> true | false ) */
OP_CALL, /* <closure> <this> <args...> -(numargs)- <returnvalue> */
OP_NEW, /* <closure> <args...> -(numargs)- <returnvalue> */

View File

@@ -716,20 +716,14 @@ void jsC_dumpfunction(js_State *J, js_Function *F)
short *end = F->code + F->codelen;
int i;
printf("function %p %s\n", F, F->name);
printf("%s(%d)\n", F->name, F->numparams);
if (F->lightweight) printf("\tlightweight\n");
if (F->arguments) printf("\targuments\n");
printf("\tsource %s:%d\n", F->filename, F->line);
printf("\tlightweight:%d\n", F->lightweight);
printf("\tparameters:%d\n", F->numparams);
printf("\targuments:%d\n", F->arguments);
for (i = 0; i < F->funlen; ++i)
printf("\tfunction %d %s\n", i, F->funtab[i]->name);
for (i = 0; i < F->varlen; ++i)
printf("\tlocal %d %s\n", i + 1, F->vartab[i]);
for (i = 0; i < F->funlen; ++i)
printf("\tfunction %p %s\n", F->funtab[i], F->funtab[i]->name);
for (i = 0; i < F->strlen; ++i) {
ps("\tstring "); pstr(F->strtab[i]); ps("\n");
}
for (i = 0; i < F->numlen; ++i)
printf("\tnumber %.9g\n", F->numtab[i]);
printf("{\n");
while (p < end) {
@@ -739,9 +733,6 @@ void jsC_dumpfunction(js_State *J, js_Function *F)
ps(opname[c]);
switch (c) {
case OP_CLOSURE:
printf(" %p", F->funtab[*p++]);
break;
case OP_NUMBER:
printf(" %.9g", F->numtab[*p++]);
break;
@@ -769,14 +760,11 @@ void jsC_dumpfunction(js_State *J, js_Function *F)
ps(F->strtab[*p++]);
break;
case OP_CLOSURE:
case OP_INITLOCAL:
case OP_GETLOCAL:
case OP_SETLOCAL:
case OP_DELLOCAL:
printf(" %d (%s)", *p, F->vartab[*p-1]);
++p;
break;
case OP_NUMBER_N:
case OP_INITPROP_N:
case OP_CALL:
@@ -796,6 +784,7 @@ void jsC_dumpfunction(js_State *J, js_Function *F)
for (i = 0; i < F->funlen; ++i) {
if (F->funtab[i] != F) {
printf("function %d ", i);
jsC_dumpfunction(J, F->funtab[i]);
}
}

View File

@@ -980,7 +980,7 @@ void jsR_dumpenvironment(js_State *J, js_Environment *E, int d)
void js_trap(js_State *J, int pc)
{
js_Function *F = STACK[BOT-1].u.object->u.f.function;
printf("trap at %d in ", pc);
printf("trap at %d in function ", pc);
jsC_dumpfunction(J, F);
jsR_dumpstack(J);
jsR_dumpenvironment(J, J->E, 0);