Permalink
Browse files

fixed coding style issues

  • Loading branch information...
1 parent 530bb83 commit df9f855af8ff3129dc2cf6032430a888501770b4 @bjouhier committed Oct 4, 2012
Showing with 23 additions and 7 deletions.
  1. +5 −2 lib/spoon/block.js
  2. +14 −4 lib/spoon/cfg.js
  3. +4 −1 lib/spoon/renderer.js
View
7 lib/spoon/block.js
@@ -121,8 +121,11 @@ Block.prototype.split = function split(at, root, asyncify, marker) {
this.ended = false;
if (asyncify) {
- if (marker) at.args[at.args.length - marker].args[0] = fn.name;
- else at.args.push(this.add('get', [ fn.name ]));
+ if (marker) {
+ at.args[at.args.length - marker].args[0] = fn.name;
+ } else {
+ at.args.push(this.add('get', [ fn.name ]));
+ }
this.instructions.push(at);
this.add('async-end', [ at ]);
View
18 lib/spoon/cfg.js
@@ -147,9 +147,19 @@ Cfg.prototype.asyncify = function asyncify(asts, options) {
function markerIndex(instr, marker) {
if (!marker) return -1;
- var args = (instr.type === 'call' && instr.args.slice(1)) || (instr.type === 'method' && instr.args.slice(2));
+ var args;
+ if (instr.type === 'call') {
+ args = instr.args.slice(1);
+ } else if (instr.type === 'method') {
+ args = instr.args.slice(2);
+ }
+ if (!args) return -1;
var found = -1;
- args && args.forEach(function(arg, i) { if (arg.type === 'get' && arg.args[0] === marker) found = args.length - i; });
+ args.forEach(function(arg, i) {
+ if (arg.type === 'get' && arg.args[0] === marker) {
+ found = args.length - i;
+ }
+ });
return found;
}
@@ -204,7 +214,7 @@ Cfg.prototype.asyncify = function asyncify(asts, options) {
return false;
}
if (options.marker && block.fn.root.instr) {
- var marker = block.fn.root.instr.params.indexOf('_');
+ var marker = block.fn.root.instr.params.indexOf(options.marker);
if (marker < 0) return false;
block.fn.root.instr.params[marker] = '__$callback';
}
@@ -1022,7 +1032,7 @@ Cfg.prototype.visitThis = function visitThis(ast) {
};
Cfg.prototype.visitFor = function visitFor(ast) {
- ast.init && this.visit(ast.init);
+ if (ast.init) this.visit(ast.init);
return this.enterLoop(function(end, loop) {
var start = this.current,
View
5 lib/spoon/renderer.js
@@ -410,7 +410,10 @@ Renderer.prototype.renderAsyncGoto = function renderAsyncGoto(args) {
};
Renderer.prototype.renderAsyncTestErr = function renderAsyncTestErr(args) {
- return ['if', ['name', '__$e'], ['block', [['return', ['call', ['dot', ['name', '__$callback'], 'call'], [['name', 'this'],['name', '__$e']]]]]]];
+ return ['if', ['name', '__$e'], ['block',
+ [['return', ['call',
+ ['dot', ['name', '__$callback'], 'call'],
+ [['name', 'this'],['name', '__$e']]]]]]];
};
Renderer.prototype.renderNop = function renderNop() {

0 comments on commit df9f855

Please sign in to comment.