Skip to content

Commit

Permalink
some chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
Swatinem committed May 3, 2013
1 parent 68a314c commit f17c255
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions lib/index.js
Expand Up @@ -29,8 +29,9 @@ function ControlFlowGraph(astNode) {
},
DoWhileStatement: function (recurse) {
mayThrow(this.test);
this.test.cfg.connect(getEntry(this.body), 'true');
this.test.cfg.connect(getSuccessor(this), 'false');
this.test.cfg
.connect(getEntry(this.body), 'true')
.connect(getSuccessor(this), 'false');
recurse(this.body);
},
ExpressionStatement: function () {
Expand All @@ -40,8 +41,9 @@ function ControlFlowGraph(astNode) {
ForStatement: function (recurse) {
if (this.test) {
mayThrow(this.test);
this.test.cfg.connect(getEntry(this.body), 'true');
this.test.cfg.connect(getSuccessor(this), 'false');
this.test.cfg
.connect(getEntry(this.body), 'true')
.connect(getSuccessor(this), 'false');
if (this.update)
this.update.cfg.connect(this.test.cfg);
} else if (this.update)
Expand All @@ -56,8 +58,9 @@ function ControlFlowGraph(astNode) {
},
ForInStatement: function (recurse) {
mayThrow(this)
this.cfg.connect(getEntry(this.body), 'true');
this.cfg.connect(getSuccessor(this), 'false');
this.cfg
.connect(getEntry(this.body), 'true')
.connect(getSuccessor(this), 'false');
recurse(this.body);
},
IfStatement: function (recurse) {
Expand Down Expand Up @@ -117,8 +120,9 @@ function ControlFlowGraph(astNode) {
VariableDeclaration: connectNext,
WhileStatement: function (recurse) {
mayThrow(this.test);
this.test.cfg.connect(getEntry(this.body), 'true');
this.test.cfg.connect(getSuccessor(this), 'false');
this.test.cfg
.connect(getEntry(this.body), 'true')
.connect(getSuccessor(this), 'false');
recurse(this.body);
}
});
Expand Down Expand Up @@ -209,7 +213,7 @@ function ControlFlowGraph(astNode) {
// unreached
case 'BlockStatement':
case 'Program':
return astNode.body[0] && getEntry(astNode.body[0]) || getSuccessor(astNode);
return astNode.body.length && getEntry(astNode.body[0]) || getSuccessor(astNode);
case 'DoWhileStatement':
return getEntry(astNode.body);
case 'EmptyStatement':
Expand Down Expand Up @@ -331,6 +335,7 @@ function FlowNode(astNode, parent, type) {
}
FlowNode.prototype.connect = function (next, type) {
this[type || 'normal'] = next;
return this;
};

var continueTargets = [
Expand Down

0 comments on commit f17c255

Please sign in to comment.