mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-06 22:53:08 +00:00
bug 591572, r=shu: builder configuration parameter (CLOSED TREE)
This commit is contained in:
parent
2428c23fd9
commit
120596572d
@ -44,10 +44,36 @@
|
||||
* done by SpiderMonkey.
|
||||
*/
|
||||
|
||||
Narcissus = {
|
||||
options: { version: 185 },
|
||||
hostGlobal: this
|
||||
};
|
||||
(function() {
|
||||
var builderTypes = Object.create(null, {
|
||||
"default": { value: function() {
|
||||
return new narcissus.parser.DefaultBuilder;
|
||||
} },
|
||||
"ssa": { value: function() {
|
||||
return new narcissus.parser.SSABuilder;
|
||||
} }
|
||||
});
|
||||
|
||||
var builderType;
|
||||
|
||||
var narcissus = {
|
||||
options: {
|
||||
version: 185,
|
||||
get builderType() { return builderType },
|
||||
set builderType(type) {
|
||||
var ctor = builderTypes[type];
|
||||
|
||||
if (!ctor)
|
||||
throw new Error("expected builder type ('default' or 'ssa'), got " + type);
|
||||
|
||||
builderType = type;
|
||||
narcissus.definitions.Builder = ctor;
|
||||
}
|
||||
},
|
||||
hostGlobal: this
|
||||
};
|
||||
Narcissus = narcissus;
|
||||
})();
|
||||
|
||||
Narcissus.definitions = (function() {
|
||||
|
||||
@ -270,7 +296,11 @@ Narcissus.definitions = (function() {
|
||||
defineGetter: defineGetter,
|
||||
defineProperty: defineProperty,
|
||||
isNativeCode: isNativeCode,
|
||||
makePassthruHandler: makePassthruHandler
|
||||
makePassthruHandler: makePassthruHandler,
|
||||
Builder: function() {
|
||||
throw new Error("no Builder type selected");
|
||||
}
|
||||
};
|
||||
}());
|
||||
|
||||
Narcissus.options.builderType = "default";
|
||||
|
@ -85,7 +85,7 @@ Narcissus.interpreter = (function() {
|
||||
x2.callee = x.callee;
|
||||
x2.scope = x.scope;
|
||||
try {
|
||||
x2.execute(parser.parse(new parser.DefaultBuilder, s));
|
||||
x2.execute(parser.parse(new definitions.Builder, s));
|
||||
return x2.result;
|
||||
} catch (e if e instanceof SyntaxError || isStackOverflow(e)) {
|
||||
/*
|
||||
@ -119,7 +119,7 @@ Narcissus.interpreter = (function() {
|
||||
|
||||
// NB: Use the STATEMENT_FORM constant since we don't want to push this
|
||||
// function onto the fake compilation context.
|
||||
var x = { builder: new parser.DefaultBuilder };
|
||||
var x = { builder: new definitions.Builder };
|
||||
var f = parser.FunctionDefinition(t, x, false, parser.STATEMENT_FORM);
|
||||
var s = {object: global, parent: null};
|
||||
return newFunction(f,{scope:s});
|
||||
@ -1023,7 +1023,7 @@ Narcissus.interpreter = (function() {
|
||||
return s;
|
||||
|
||||
var x = new ExecutionContext(GLOBAL_CODE);
|
||||
x.execute(parser.parse(new parser.DefaultBuilder, s, f, l));
|
||||
x.execute(parser.parse(new definitions.Builder, s, f, l));
|
||||
return x.result;
|
||||
}
|
||||
|
||||
@ -1059,7 +1059,7 @@ Narcissus.interpreter = (function() {
|
||||
}
|
||||
}
|
||||
|
||||
var b = new parser.DefaultBuilder;
|
||||
var b = new definitions.Builder;
|
||||
var x = new ExecutionContext(GLOBAL_CODE);
|
||||
|
||||
ExecutionContext.current = x;
|
||||
|
@ -2328,6 +2328,9 @@ Narcissus.parser = (function() {
|
||||
parse: parse,
|
||||
Node: Node,
|
||||
DefaultBuilder: DefaultBuilder,
|
||||
get SSABuilder() {
|
||||
throw new Error("SSA builder not yet supported");
|
||||
},
|
||||
bindSubBuilders: bindSubBuilders,
|
||||
DECLARED_FORM: DECLARED_FORM,
|
||||
EXPRESSED_FORM: EXPRESSED_FORM,
|
||||
|
@ -35,13 +35,18 @@ if __name__ == '__main__':
|
||||
help='enable interactive shell')
|
||||
op.add_option('-H', '--harmony', dest='js_harmony', action='store_true',
|
||||
help='enable ECMAScript Harmony mode')
|
||||
op.add_option('-S', '--ssa', dest='js_ssa', action='store_true',
|
||||
help='enable parse-time SSA construction')
|
||||
|
||||
(options, args) = op.parse_args()
|
||||
|
||||
cmd = ""
|
||||
|
||||
if options.js_harmony:
|
||||
cmd += 'Narcissus.options={version:"harmony"}; '
|
||||
cmd += 'Narcissus.options.version = "harmony"; '
|
||||
|
||||
if options.js_ssa:
|
||||
cmd += 'Narcissus.options.builderType = "ssa"; '
|
||||
|
||||
if options.js_exps:
|
||||
for exp in options.js_exps:
|
||||
|
Loading…
x
Reference in New Issue
Block a user