shithub: libmujs

Download patch

ref: 50d5cb95abc045d219fa80e9b1f41470e2d86a89
parent: fb30504592710ea1f629d04a2254732821dabf82
author: Tor Andersson <tor.andersson@artifex.com>
date: Sun Jan 12 07:50:39 EST 2014

Auto-generate list of operator names.

--- a/Makefile
+++ b/Makefile
@@ -15,6 +15,11 @@
 build/libjs.a: $(OBJS)
 	ar cru $@ $^
 
+opnames.h : jscompile.h
+	grep 'OP_' jscompile.h | sed 's/OP_/"/;s/,/",/' | tr A-Z a-z > opnames.h
+
+jsdump.c : opnames.h
+
 js: build/main.o build/libjs.a
 	$(CC) -o $@ $^ -lm
 
--- a/jsdump.c
+++ b/jsdump.c
@@ -22,16 +22,7 @@
 };
 
 static const char *opname[] = {
-	"const", "undef", "null", "true", "false", "this",
-	"array", "arrayput",
-	"object", "objectput",
-	"defvar", "var", "index", "member", "load", "dupload", "store", "call", "new",
-	"closure", "delete", "void", "typeof", "preinc", "postinc", "predec",
-	"postdec", "pos", "neg", "bitnot", "lognot", "logor", "logand",
-	"bitor", "bitxor", "bitand", "eq", "ne", "eq3", "ne3", "lt", "gt",
-	"le", "ge", "instanceof", "in", "shl", "shr", "ushr", "add", "sub",
-	"mul", "div", "mod", "jump", "jtrue", "jfalse", "try", "throw",
-	"return", "pushwith", "popwith", "debugger", "pop",
+#include "opnames.h"
 };
 
 static void pstmlist(int d, js_Ast *list);