Skip to content

Commit

Permalink
more jsdesugar bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Herman committed Oct 20, 2011
1 parent 82e14f6 commit 71b175c
Showing 1 changed file with 38 additions and 36 deletions.
74 changes: 38 additions & 36 deletions lib/jsdesugar.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ Narcissus.desugaring = (function() {

case ARRAY_INIT:
patt.children.forEach(function(patt) {
extractBindings(vars, patt);
if (patt)
extractBindings(vars, patt);
});
break;

Expand All @@ -177,7 +178,7 @@ Narcissus.desugaring = (function() {

function gensym(t) {
var name = "Narcissus desugaring: " + gensymCounter++;
return new parser.SyntheticNode(t, { type: IDENTIFIER, value: name });
return new parser.SyntheticNode(t, { type: IDENTIFIER, name: name, value: name });
}

function generateTemp(node) {
Expand Down Expand Up @@ -474,10 +475,10 @@ Narcissus.desugaring = (function() {
type: NOT,
value: "!",
children: [caught],
labels: new definitions.StringMap(),
thenPart: catchNode.block,
elsePart: null
labels: new definitions.StringMap()
}),
thenPart: catchNode.block,
elsePart: null
})],
varDecls: [],
labels: new definitions.StringMap()
Expand Down Expand Up @@ -518,28 +519,28 @@ Narcissus.desugaring = (function() {
type: NOT,
value: "!",
children: [caught],
labels: new definitions.StringMap(),
thenPart: new parser.SyntheticNode(t, {
type: BLOCK,
value: "{",
children: [new parser.SyntheticNode(t, {
type: SEMICOLON,
blockComments: [],
expression: new parser.SyntheticNode(t, {
type: ASSIGN,
children: [caught, new parser.SyntheticNode(t, {
type: TRUE,
value: "true"
})],
blockComment: null
})
}), catchNode.block],
varDecls: [],
labels: new definitions.StringMap()
}),
elsePart: null
labels: new definitions.StringMap()
}), catchNode.guard]
})
}),
thenPart: new parser.SyntheticNode(t, {
type: BLOCK,
value: "{",
children: [new parser.SyntheticNode(t, {
type: SEMICOLON,
blockComments: [],
expression: new parser.SyntheticNode(t, {
type: ASSIGN,
children: [caught, new parser.SyntheticNode(t, {
type: TRUE,
value: "true"
})],
blockComment: null
})
}), catchNode.block],
varDecls: [],
labels: new definitions.StringMap()
}),
elsePart: null
})],
varDecls: [],
labels: new definitions.StringMap()
Expand Down Expand Up @@ -576,15 +577,15 @@ Narcissus.desugaring = (function() {
type: NOT,
value: "!",
children: [caught],
labels: new definitions.StringMap(),
thenPart: new parser.SyntheticNode(t, {
type: THROW,
value: "throw",
exception: tmp,
blockComments: []
}),
elsePart: null
})
labels: new definitions.StringMap()
}),
thenPart: new parser.SyntheticNode(t, {
type: THROW,
value: "throw",
exception: tmp,
blockComments: []
}),
elsePart: null
}));
}

Expand Down Expand Up @@ -832,7 +833,8 @@ Narcissus.desugaring = (function() {
case COMMA:
case LIST:
node.children.forEach(function(child, i) {
node.children[i] = desugarExpression(child);
if (child)
node.children[i] = desugarExpression(child);
});
return node;

Expand Down

0 comments on commit 71b175c

Please sign in to comment.