mirror of
https://github.com/ccxvii/mujs.git
synced 2026-02-06 01:41:37 +08:00
Some cleanups.
This commit is contained in:
@@ -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);
|
||||
|
||||
11
jscompile.h
11
jscompile.h
@@ -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> */
|
||||
|
||||
25
jsdump.c
25
jsdump.c
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
2
jsrun.c
2
jsrun.c
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user