Comparing version 0.1.3 to 0.1.4
@@ -122,9 +122,21 @@ var cfg = exports, | ||
block.predecessors.forEach(function(pred) { | ||
// Remove goto | ||
var last = pred.instructions.pop(); | ||
if (pred.successors.length < 2) { | ||
pred.successors = []; | ||
pred.ended = false; | ||
// Remove goto | ||
var last = pred.instructions.pop(); | ||
pred.ended = false; | ||
} else { | ||
// Replace one of the branches | ||
var index = pred.successors[0] === block ? 0 : 1, | ||
tmp = this.createBlock(); | ||
pred.successors[index] = tmp; | ||
tmp.addPredecessor(pred); | ||
pred = tmp; | ||
} | ||
pred.add('async-goto', [ pred.add('get', [ info.fn.name ]) ]); | ||
pred.end(); | ||
pred.successors = []; | ||
}, this); | ||
@@ -131,0 +143,0 @@ block.predecessors = []; |
{ | ||
"name": "spoon", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"main": "lib/spoon", | ||
"dependencies": { | ||
"esprima": "~0.9.9", | ||
"esprima": "~1.0.2", | ||
"uglify-js": "~1.3.3", | ||
"escodegen": "0.0.9" | ||
"escodegen": "~0.0.15" | ||
}, | ||
@@ -10,0 +10,0 @@ "devDependencies": { |
@@ -22,2 +22,3 @@ var spoon = require('..'), | ||
once = false; | ||
console.log(cfg.toString()); | ||
vm.runInNewContext(code + ';\nfn(callback)', { | ||
@@ -144,2 +145,35 @@ callback: function(err, r) { | ||
it('should asyncify call in while loop', function() { | ||
var r = test(function fn(__$callback) { | ||
"enable spoon"; | ||
function async(a, b, callback) { | ||
callback(null, a + b); | ||
} | ||
var x = 0, | ||
p = false, | ||
i; | ||
if (p) { | ||
i = 11; | ||
while (i) { | ||
i--; | ||
x = async(i, x); | ||
} | ||
} | ||
if (!p) { | ||
i = 11; | ||
while (i) { | ||
i--; | ||
x = async(i, x); | ||
} | ||
} | ||
return x + 1; | ||
}); | ||
r = assert.equal(r, 56); | ||
}); | ||
it('should asyncify call in do while loop', function() { | ||
@@ -146,0 +180,0 @@ var r = test(function fn(__$callback) { |
68363
2084
+ Addedescodegen@0.0.28(transitive)
+ Addedesprima@1.0.4(transitive)
+ Addedestraverse@1.3.2(transitive)
- Removedescodegen@0.0.9(transitive)
- Removedesprima@0.9.9(transitive)
Updatedescodegen@~0.0.15
Updatedesprima@~1.0.2