Skip to content

Commit

Permalink
integrate desugaring into jsexec
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Herman committed Aug 1, 2011
1 parent c49f7a6 commit 255ddd6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/jsdefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@
options: {
version: 185,
// Global variables to hide from the interpreter
hiddenHostGlobals: { Narcissus: true }
hiddenHostGlobals: { Narcissus: true },
// Desugar SpiderMonkey language extensions?
desugarExtensions: false
},
hostSupportsEvalConst: (function() {
try {
Expand Down
1 change: 1 addition & 0 deletions lib/jsdesugar.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
* - destructuring
* - array comprehensions
* - generator expressions
* - expression functions
*/


Expand Down
5 changes: 5 additions & 0 deletions lib/jsexec.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Narcissus.interpreter = (function() {
var definitions = Narcissus.definitions;
var resolver = Narcissus.resolver;
var hostGlobal = Narcissus.hostGlobal;
var desugaring = Narcissus.desugaring;

// Set constants in the local scope.
eval(definitions.consts);
Expand Down Expand Up @@ -1330,6 +1331,8 @@ Narcissus.interpreter = (function() {

var x = new ExecutionContext(GLOBAL_CODE, Narcissus.options.version);
var ast = parser.parse(s, f, l);
if (Narcissus.options.desugarExtensions)
ast = desugaring.desugar(ast);
if (x.version === "harmony") {
resolveGlobal(ast);
instantiateModules(ast, x.scope);
Expand Down Expand Up @@ -1434,6 +1437,8 @@ Narcissus.interpreter = (function() {

try {
var ast = parser.parseStdin(src, ln, "... ", isCommand);
if (Narcissus.options.desugarExtensions)
ast = desugaring.desugar(ast);
if (x.version === "harmony") {
resolveGlobal(ast);
instantiateModules(ast, x.scope);
Expand Down

0 comments on commit 255ddd6

Please sign in to comment.