shithub: libmujs

Download patch

ref: be3ed5250c8505b8d544587e92b31924b134e678
parent: e45115faeee4928b5fa103eaff55b6ed804899a8
author: Tor Andersson <[email protected]>
date: Mon Feb 10 18:51:34 EST 2014

Some cleanups.

--- a/jsbuiltin.c
+++ b/jsbuiltin.c
@@ -200,10 +200,10 @@
 	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);
--- a/jscompile.h
+++ b/jscompile.h
@@ -32,14 +32,15 @@
 	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 @@
 	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> */
--- a/jsdump.c
+++ b/jsdump.c
@@ -716,20 +716,14 @@
 	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 @@
 		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 @@
 			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 @@
 
 	for (i = 0; i < F->funlen; ++i) {
 		if (F->funtab[i] != F) {
+			printf("function %d ", i);
 			jsC_dumpfunction(J, F->funtab[i]);
 		}
 	}
--- a/jsrun.c
+++ b/jsrun.c
@@ -980,7 +980,7 @@
 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);