[Pkg-mozext-commits] [adblock-plus] 68/464: Some update work. Should work with newest spidermonkeys.
David Prévot
taffit at moszumanska.debian.org
Tue Jul 22 20:44:04 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 95c105091ca5b0825725e04de374af2d0882eecb
Author: Joshua Cranmer <Pidgeot18 at gmail.com>
Date: Wed Mar 24 14:39:51 2010 -0400
Some update work. Should work with newest spidermonkeys.
---
jshydra.cpp | 20 ++++++++++++--------
jshydra_bridge.cpp | 10 ++++++++++
utils/cleanast.js | 2 +-
utils/dumpast.js | 3 ++-
4 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/jshydra.cpp b/jshydra.cpp
index 509d662..669a1e7 100644
--- a/jshydra.cpp
+++ b/jshydra.cpp
@@ -128,7 +128,7 @@ JSObject *makeNode(JSParseNode *node) {
// The object in the parse tree is not itself sufficient to really act as a
// parse node, so we clone the object to get the right prototype stuff.
JSObject *regex = js_CloneRegExpObject(cx, node->pn_objbox->object,
- globalObj);
+ jshydra_getRegexPrototype(cx));
setObjectProperty(object, "value", regex);
JSObject *array = JS_NewArrayObject(cx, 0, NULL);
setArrayElement(array, 0, makeNode(node->pn_expr));
@@ -155,17 +155,17 @@ JSObject *makeNode(JSParseNode *node) {
return object;
}
-void parseFile(FILE *file, char *filename, char *argstr) {
+bool parseFile(FILE *file, char *filename, char *argstr) {
JSCompiler compiler(cx, NULL, NULL);
if (!compiler.init(NULL, 0, file, filename, 1))
- return;
+ return false;
JSParseNode *root = compiler.parse(globalObj);
JSObject *ast = makeNode(root);
jshydra_rootObject(cx, ast);
jsval func = jshydra_getToplevelFunction(cx, "process_js");
if (JS_TypeOfValue(cx, func) != JSTYPE_FUNCTION) {
fprintf(stderr, "No function process_js!\n");
- return;
+ return false;
}
jsval rval, argv[3];
argv[0] = OBJECT_TO_JSVAL(ast);
@@ -173,11 +173,11 @@ void parseFile(FILE *file, char *filename, char *argstr) {
argv[1] = STRING_TO_JSVAL(newfname);
JSString *jsArgStr = JS_NewStringCopyZ(cx, argstr);
argv[2] = STRING_TO_JSVAL(jsArgStr);
- JS_CallFunctionValue(cx, globalObj, func, 3, argv, &rval);
+ return JS_CallFunctionValue(cx, globalObj, func, 3, argv, &rval);
}
int main(int argc, char **argv) {
- if (argc < 2) {
+ if (argc < 3) {
fprintf(stderr, "Usage: %s script filename...\n", argv[0]);
return -1;
}
@@ -186,6 +186,8 @@ int main(int argc, char **argv) {
argc--;
argv++;
char *argstr = NULL;
+
+ bool failure = false;
do {
argc--;
argv++;
@@ -200,8 +202,10 @@ int main(int argc, char **argv) {
fprintf(stderr, "No such file %s\n", argv[0]);
continue;
}
- parseFile(input, argv[0], argstr);
+ failure |= !parseFile(input, argv[0], argstr);
+ if (failure)
+ fprintf(stderr, "Failure happened on input %s\n", argv[0]);
} while (argc > 1);
- return 0;
+ return !!failure;
}
diff --git a/jshydra_bridge.cpp b/jshydra_bridge.cpp
index fbf8c19..3cebab0 100644
--- a/jshydra_bridge.cpp
+++ b/jshydra_bridge.cpp
@@ -273,3 +273,13 @@ void jshydra_rootObject(JSContext *cx, JSObject *obj) {
argv[0] = OBJECT_TO_JSVAL(obj);
JS_CallFunctionName(cx, rootArray, "push", 1, argv, &rval);
}
+
+JSObject *jshydra_getRegexPrototype(JSContext *cx) {
+ static JSObject *proto = NULL;
+ if (proto == NULL) {
+ char str[1];
+ JSObject *regex = JS_NewRegExpObject(cx, str, 0, 0);
+ proto = JS_GetPrototype(cx, regex);
+ }
+ return proto;
+}
diff --git a/utils/cleanast.js b/utils/cleanast.js
index be7d5af..3aac618 100644
--- a/utils/cleanast.js
+++ b/utils/cleanast.js
@@ -53,7 +53,7 @@ function visit(root_ast, func, to_expand) {
function v_r(ast, func) {
if (ast == null)
return;
- func(ast);
+ if (func(ast)) return;
for each (let child in ast.kids)
v_r(child, func);
}
diff --git a/utils/dumpast.js b/utils/dumpast.js
index 974ce2c..b2456da 100644
--- a/utils/dumpast.js
+++ b/utils/dumpast.js
@@ -11,7 +11,8 @@ function dump_ast(ast, prefix) {
if (key == 'column' || key == 'line' || key == 'kids')
continue;
let val = (key == 'op' ? decode_op(ast[key]) :
- key == 'type' ? decode_type(ast[key]) : ast[key]);
+ key == 'type' ? decode_type(ast[key]) :
+ key == 'flags' ? ('0x' + ast[key].toString(16)) : ast[key]);
str += key + ": " + val + "; ";
}
str += ast.line + ":" + ast.column;
--
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