[Pkg-mozext-commits] [adblock-plus] 20/464: Updating to work with m-c tip.

David Prévot taffit at moszumanska.debian.org
Tue Jul 22 20:43:58 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository adblock-plus.

commit b266ede221d7e27a5b77b815f83ce52c8680636c
Author: Joshua Cranmer <Pidgeot18 at gmail.com>
Date:   Mon Apr 20 21:21:24 2009 -0400

    Updating to work with m-c tip.
    
    The new API has better locations!
---
 Makefile                          | 14 +++++++++-----
 autotest/test_globals.js          |  1 -
 autotest/test_globals.js.expected |  3 +--
 jshydra.cpp                       | 25 ++++++++++++++++++-------
 scripts/cleanast.js               |  6 +++++-
 5 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/Makefile b/Makefile
index 1a68bf1..5d9dba3 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,11 @@
-INCLUDE = -I/src/build/trunk/browser/dist/include/js/ \
-		  -I/src/build/trunk/browser/dist/include/nspr/ -DXP_UNIX \
-	  -I/src/trunk/mozilla/js/src/
-LINK := -L/src/build/trunk/browser/dist/lib -lnspr4 -lm
+# You'll need to change the below to match your setup
+MOZ_OBJDIR := /src/build/trunk/browser
+MOZ_SRCDIR := /src/trunk/mozilla
+
+INCLUDE := -I$(MOZ_OBJDIR)/dist/include/js/ \
+		   -I$(MOZ_OBJDIR)/dist/include/nspr/ -DXP_UNIX \
+		   -I$(MOZ_SRCDIR)/js/src/
+LINK := -L$(MOZ_OBJDIR)/dist/lib -lnspr4 -lm
 
 OBJS := jsapi.o jsarena.o jsarray.o jsatom.o jsbool.o jscntxt.o jsdate.o \
 	jsdbgapi.o jsdhash.o jsdtoa.o jsemit.o jsexn.o jsfun.o jsgc.o jshash.o \
@@ -10,7 +14,7 @@ OBJS := jsapi.o jsarena.o jsarray.o jsatom.o jsbool.o jscntxt.o jsdate.o \
 	jsscript.o jsstr.o jsutil.o jsxdrapi.o jsxml.o prmjtime.o jstracer.o \
 	Assembler.o Fragmento.o LIR.o RegAlloc.o avmplus.o Nativei386.o jsbuiltins.o
 
-OBJS := $(addprefix /src/build/trunk/browser/js/src/, $(OBJS))
+OBJS := $(addprefix $(MOZ_OBJDIR)/js/src/, $(OBJS))
 
 jshydra: jshydra.o jshydra_funcs.o jshydra_bridge.o
 	g++ -o jshydra jshydra.o jshydra_funcs.o jshydra_bridge.o $(OBJS) $(LINK)
diff --git a/autotest/test_globals.js b/autotest/test_globals.js
index 883b28b..4e2508e 100644
--- a/autotest/test_globals.js
+++ b/autotest/test_globals.js
@@ -19,6 +19,5 @@ function process_js(ast) {
 	_print("Global functions:");
 	for each (let v in toplevel.functions) {
 		_print("\t" + v.name + " at " + v.loc.line + ":" + v.loc.column);
-		_print(v.body.kids[0].column);
 	}
 }
diff --git a/autotest/test_globals.js.expected b/autotest/test_globals.js.expected
index bf9d6ed..8309145 100644
--- a/autotest/test_globals.js.expected
+++ b/autotest/test_globals.js.expected
@@ -3,5 +3,4 @@ Global variables:
 Global constants:
 	LS at 7:0
 Global functions:
-	process_js at 9:25
-1
+	process_js at 9:0
diff --git a/jshydra.cpp b/jshydra.cpp
index 7e75d8a..fd677e3 100644
--- a/jshydra.cpp
+++ b/jshydra.cpp
@@ -1,4 +1,7 @@
+#include <string.h> // Needed for jsparse.h
 #include "jsapi.h"
+#include "jsbit.h" // jsparse.h
+#include "jsscript.h" // jsparse.h
 #include "jsparse.h"
 #include "jscntxt.h"
 #include <stdio.h>
@@ -21,7 +24,7 @@ void setArrayElement(JSObject *array, jsint index, JSObject *value) {
 }
 
 typedef enum TokenValue {
-	FUNCTION, LIST, TERNARY, BINARY, UNARY, NAME, LEXICAL, APAIR, OBJLITERAL, DOUBLELITERAL, NULLARY, ERROR
+	FUNCTION, LIST, TERNARY, BINARY, UNARY, NAME, LEXICAL, APAIR, OBJLITERAL, DOUBLELITERAL, NULLARY, NAMESET, ERROR
 } TokenValue;
 
 TokenValue tokens[] = {
@@ -109,12 +112,14 @@ TokenValue tokens[] = {
     LIST, /*TOK_LET*/
     ERROR, /*TOK_SEQ*/
     TERNARY, /*TOK_FORHEAD*/
+	LIST, /*TOK_ARGSBODY */
+	NAMESET, /*TOK_UPVARS */
     LIST, /*TOK_RESERVED [I don't understand this...] */
     //TOK_LIMIT
 	ERROR
 };
 
-TokenValue arityFix[] = {FUNCTION, LIST, TERNARY, BINARY, UNARY, NAME, NULLARY};
+TokenValue arityFix[] = {NULLARY, UNARY, BINARY, TERNARY, FUNCTION, LIST, NAME};
 
 JSObject *makeNode(JSParseNode *node) {
 	if (!node)
@@ -134,8 +139,8 @@ JSObject *makeNode(JSParseNode *node) {
 
 	switch (value) {
 	case FUNCTION: {
-		setIntProperty(object, "flags", node->pn_flags);
-		JSFunction *func = (JSFunction *) node->pn_funpob->object;
+		setIntProperty(object, "flags", node->pn_dflags);
+		JSFunction *func = (JSFunction *) node->pn_funbox->object;
 		if (func->atom)
 			jshydra_defineProperty(cx, object, "name", ATOM_KEY(func->atom));
 
@@ -183,6 +188,12 @@ JSObject *makeNode(JSParseNode *node) {
 		setObjectProperty(object, "kids", array);
 		break;
 	}
+	case NAMESET: {
+		JSObject *array = JS_NewArrayObject(cx, 0, NULL);
+		setArrayElement(array, 0, makeNode(node->pn_tree));
+		setObjectProperty(object, "kids", array);
+		break;
+	}
 	case LEXICAL: {
 		JSObject *array = JS_NewArrayObject(cx, 0, NULL);
 		setArrayElement(array, 0, makeNode(node->pn_expr));
@@ -212,10 +223,10 @@ JSObject *makeNode(JSParseNode *node) {
 }
 
 void parseFile(FILE *file, char *filename) {
-	JSParseContext pc;
-	if (!js_InitParseContext(cx, &pc, NULL, NULL, NULL, 0, file, filename, 1))
+	JSCompiler compiler(cx, NULL, NULL);
+	if (!compiler.init(NULL, 0, file, filename, 1))
 		return;
-	JSParseNode *root = js_ParseScript(cx, globalObj, &pc);
+	JSParseNode *root = compiler.parse(globalObj);
 	JSObject *ast = makeNode(root);
 	jshydra_rootObject(cx, ast);
 	jsval func = jshydra_getToplevelFunction(cx, "process_js");
diff --git a/scripts/cleanast.js b/scripts/cleanast.js
index ad09b01..db53750 100644
--- a/scripts/cleanast.js
+++ b/scripts/cleanast.js
@@ -49,7 +49,11 @@ function make_variables(var_root) {
 function make_function(func_root) {
 	assert(func_root.type == 34); // TOK_FUNCTION
 	let stmts = func_root.kids[0];
-	assert(stmts.type == 25); // TOK_LC
+	if (stmts.type == 85) // TOK_UPVARS
+		stmts = stmts.kids[0];
+	if (stmts.type == 84) // TOK_ARGSBODY
+		stmts = stmts.kids[stmts.kids.length - 1];
+	assert(stmts.type == 25);
 	return { name: func_root.name, body: stmts, loc: get_location(func_root)};
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git



More information about the Pkg-mozext-commits mailing list