diff --git a/lib/fibers-fast/flows.js b/lib/fibers-fast/flows.js index 647a0b4b..976863d5 100644 --- a/lib/fibers-fast/flows.js +++ b/lib/fibers-fast/flows.js @@ -109,7 +109,7 @@ function() { var funnel = exports.funnel(max); this.collect = function(_, count, trim) { - return fstreamline__.invoke((function(callback) { + return fstreamline__.invoke(function(callback) { if (typeof(callback) != "function") throw new Error("invalid call to collect: no callback") var results = trim ? [] : new Array(fns.length); count = count < 0 ? fns.length : Math.min(count, fns.length); diff --git a/lib/fibers-fast/transform.js b/lib/fibers-fast/transform.js index 0470eb9a..7b421478 100644 --- a/lib/fibers-fast/transform.js +++ b/lib/fibers-fast/transform.js @@ -178,6 +178,7 @@ function transform(source, options) { function walkExpr() { skipTo(expr.range[0]); if (expr.type === 'MemberExpression') { + skipTo(expr.object.range[0]); if (!expr.computed) { // Method call: foo.bar(_) walk(expr.object); diff --git a/lib/generators/runtime-all.js b/lib/generators/runtime-all.js index 5dfe54ee..c4536ac0 100644 --- a/lib/generators/runtime-all.js +++ b/lib/generators/runtime-all.js @@ -30,8 +30,6 @@ function require(str) { /// `var galaxy = require('galaxy');` /// - var resume; - function link(src, name, dst) { Object.defineProperty(src, name, { configurable: false, @@ -57,6 +55,9 @@ function require(str) { return gl[secret] || link(gl, secret, { context: {} }); })(); + if (typeof glob.yielded === "undefined") glob.yielded = true; + glob.PENDING = glob.PENDING || {}; + var stackHelper, stackHelperError; try { stackHelper = require('galaxy-stack'); @@ -92,8 +93,6 @@ function require(str) { return Object.prototype.toString.call(val) === "[object Generator]"; } - var PENDING = {}; - function Frame(g) { this.g = g; this.prev = glob.frame; @@ -132,20 +131,18 @@ function require(str) { glob.frame = glob.frame.prev; } - var yielded = true; - function run(g, cb, options) { - var rsm = resume; + var rsm = glob.resume; var emit = glob.emitter && stackHelper && function(ev, g) { g.frame = g.frame || new Frame(g); glob.emitter.emit(ev, g.frame); } try { - resume = function(err, val) { - if (emit && yielded) { + glob.resume = function(err, val) { + if (emit && glob.yielded) { emit("resume", g); - yielded = false; + glob.yielded = false; } while (g) { if (options && options.interrupt && options.interrupt()) return; @@ -157,19 +154,19 @@ function require(str) { err = null; // if we get PENDING, the current call completed with a pending I/O // resume will be called again when the I/O completes. So just save the context and return here. - if (val === PENDING) { - if (emit && !yielded) { + if (val === glob.PENDING) { + if (emit && !glob.yielded) { emit("yield", g); - yielded = true; + glob.yielded = true; } return; } // if we get [PENDING, e, r], the current call invoked its callback synchronously // we just loop to send/throw what the callback gave us. - if (val && val[0] === PENDING) { + if (val && val[0] === glob.PENDING) { err = val[1]; val = val[2]; - if (err) err = wrapError(err, g, resume); + if (err) err = wrapError(err, g, glob.resume); } // else, if g is done we unwind it we send val to the parent generator (or through cb if we are at the top) else if (v.done) { @@ -198,7 +195,7 @@ function require(str) { // the send/throw call failed. // we unwind the current generator and we rethrow into the parent generator (or through cb if at the top) //g.close(); - err = wrapError(ex, g, resume); + err = wrapError(ex, g, glob.resume); if (emit) popFrame(g); g = g.prev; val = undefined; @@ -210,10 +207,10 @@ function require(str) { } // start the resume loop - resume(); + glob.resume(); } finally { // restore resume global - resume = rsm; + glob.resume = rsm; } } @@ -241,28 +238,28 @@ function require(str) { // Set things up so that call returns: // * PENDING if it completes with a pending I/O (and cb will be called later) // * [PENDING, e, r] if the callback is called synchronously. - var result = PENDING, + var result = glob.PENDING, sync = true; - var rsm = resume; + var rsm = glob.resume; // convert args to array so that args.length gets correctly set if idx is args.length args = Array.prototype.slice.call(args, 0); var cx = glob.context; args[idx == null ? args.length : idx] = function(e, r) { var oldContext = glob.context; - var oldResume = resume; + var oldResume = glob.resume; try { if (options) r = mapResults(options, Array.prototype.slice.call(arguments, 1)); glob.context = cx; - resume = rsm; + glob.resume = rsm; if (sync) { - result = [PENDING, e, r]; + result = [glob.PENDING, e, r]; } else { - resume(e, r); + glob.resume(e, r); } } finally { glob.context = oldContext; - resume = oldResume; + glob.resume = oldResume; } } fn.apply(that, args); diff --git a/lib/generators/transform-all.js b/lib/generators/transform-all.js index 3031da79..0d4d901f 100644 --- a/lib/generators/transform-all.js +++ b/lib/generators/transform-all.js @@ -8752,8 +8752,6 @@ if (typeof exports !== 'undefined') { /// `var galaxy = require('galaxy');` /// - var resume; - function link(src, name, dst) { Object.defineProperty(src, name, { configurable: false, @@ -8779,6 +8777,9 @@ if (typeof exports !== 'undefined') { return gl[secret] || link(gl, secret, { context: {} }); })(); + if (typeof glob.yielded === "undefined") glob.yielded = true; + glob.PENDING = glob.PENDING || {}; + var stackHelper, stackHelperError; try { stackHelper = require('galaxy-stack'); @@ -8814,8 +8815,6 @@ if (typeof exports !== 'undefined') { return Object.prototype.toString.call(val) === "[object Generator]"; } - var PENDING = {}; - function Frame(g) { this.g = g; this.prev = glob.frame; @@ -8854,20 +8853,18 @@ if (typeof exports !== 'undefined') { glob.frame = glob.frame.prev; } - var yielded = true; - function run(g, cb, options) { - var rsm = resume; + var rsm = glob.resume; var emit = glob.emitter && stackHelper && function(ev, g) { g.frame = g.frame || new Frame(g); glob.emitter.emit(ev, g.frame); } try { - resume = function(err, val) { - if (emit && yielded) { + glob.resume = function(err, val) { + if (emit && glob.yielded) { emit("resume", g); - yielded = false; + glob.yielded = false; } while (g) { if (options && options.interrupt && options.interrupt()) return; @@ -8879,19 +8876,19 @@ if (typeof exports !== 'undefined') { err = null; // if we get PENDING, the current call completed with a pending I/O // resume will be called again when the I/O completes. So just save the context and return here. - if (val === PENDING) { - if (emit && !yielded) { + if (val === glob.PENDING) { + if (emit && !glob.yielded) { emit("yield", g); - yielded = true; + glob.yielded = true; } return; } // if we get [PENDING, e, r], the current call invoked its callback synchronously // we just loop to send/throw what the callback gave us. - if (val && val[0] === PENDING) { + if (val && val[0] === glob.PENDING) { err = val[1]; val = val[2]; - if (err) err = wrapError(err, g, resume); + if (err) err = wrapError(err, g, glob.resume); } // else, if g is done we unwind it we send val to the parent generator (or through cb if we are at the top) else if (v.done) { @@ -8920,7 +8917,7 @@ if (typeof exports !== 'undefined') { // the send/throw call failed. // we unwind the current generator and we rethrow into the parent generator (or through cb if at the top) //g.close(); - err = wrapError(ex, g, resume); + err = wrapError(ex, g, glob.resume); if (emit) popFrame(g); g = g.prev; val = undefined; @@ -8932,10 +8929,10 @@ if (typeof exports !== 'undefined') { } // start the resume loop - resume(); + glob.resume(); } finally { // restore resume global - resume = rsm; + glob.resume = rsm; } } @@ -8963,28 +8960,28 @@ if (typeof exports !== 'undefined') { // Set things up so that call returns: // * PENDING if it completes with a pending I/O (and cb will be called later) // * [PENDING, e, r] if the callback is called synchronously. - var result = PENDING, + var result = glob.PENDING, sync = true; - var rsm = resume; + var rsm = glob.resume; // convert args to array so that args.length gets correctly set if idx is args.length args = Array.prototype.slice.call(args, 0); var cx = glob.context; args[idx == null ? args.length : idx] = function(e, r) { var oldContext = glob.context; - var oldResume = resume; + var oldResume = glob.resume; try { if (options) r = mapResults(options, Array.prototype.slice.call(arguments, 1)); glob.context = cx; - resume = rsm; + glob.resume = rsm; if (sync) { - result = [PENDING, e, r]; + result = [glob.PENDING, e, r]; } else { - resume(e, r); + glob.resume(e, r); } } finally { glob.context = oldContext; - resume = oldResume; + glob.resume = oldResume; } } fn.apply(that, args);