1
0
Fork 0
arangodb/js/node/node_modules/iced-coffee-script/lib/coffee-script/iced.js

256 lines
6.9 KiB
JavaScript

// Generated by IcedCoffeeScript 1.7.1-a
(function() {
var generator,
__slice = [].slice;
exports.generator = generator = function(intern, compiletime, runtime) {
var C, Deferrals, Rendezvous, exceptionHandler, findDeferral, stackWalk;
compiletime.transform = function(x, options) {
return x.icedTransform(options);
};
compiletime["const"] = C = {
k: "__iced_k",
k_noop: "__iced_k_noop",
param: "__iced_p_",
ns: "iced",
runtime: "runtime",
Deferrals: "Deferrals",
deferrals: "__iced_deferrals",
fulfill: "_fulfill",
b_while: "_break",
t_while: "_while",
c_while: "_continue",
n_while: "_next",
n_arg: "__iced_next_arg",
context: "context",
defer_method: "defer",
slot: "__slot",
assign_fn: "assign_fn",
autocb: "autocb",
retslot: "ret",
trace: "__iced_trace",
passed_deferral: "__iced_passed_deferral",
findDeferral: "findDeferral",
lineno: "lineno",
parent: "parent",
filename: "filename",
funcname: "funcname",
catchExceptions: 'catchExceptions',
runtime_modes: ["node", "inline", "window", "none", "browserify"],
trampoline: "trampoline"
};
intern.makeDeferReturn = function(obj, defer_args, id, trace_template, multi) {
var k, ret, trace, v;
trace = {};
for (k in trace_template) {
v = trace_template[k];
trace[k] = v;
}
trace[C.lineno] = defer_args != null ? defer_args[C.lineno] : void 0;
ret = function() {
var inner_args, o, _ref;
inner_args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (defer_args != null) {
if ((_ref = defer_args.assign_fn) != null) {
_ref.apply(null, inner_args);
}
}
if (obj) {
o = obj;
if (!multi) {
obj = null;
}
return o._fulfill(id, trace);
} else {
return intern._warn("overused deferral at " + (intern._trace_to_string(trace)));
}
};
ret[C.trace] = trace;
return ret;
};
intern.__c = 0;
intern.tickCounter = function(mod) {
intern.__c++;
if ((intern.__c % mod) === 0) {
intern.__c = 0;
return true;
} else {
return false;
}
};
intern.__active_trace = null;
intern._trace_to_string = function(tr) {
var fn;
fn = tr[C.funcname] || "<anonymous>";
return "" + fn + " (" + tr[C.filename] + ":" + (tr[C.lineno] + 1) + ")";
};
intern._warn = function(m) {
return typeof console !== "undefined" && console !== null ? console.log("ICED warning: " + m) : void 0;
};
runtime.trampoline = function(fn) {
if (!intern.tickCounter(500)) {
return fn();
} else if (typeof process !== "undefined" && process !== null) {
return process.nextTick(fn);
} else {
return setTimeout(fn);
}
};
runtime.Deferrals = Deferrals = (function() {
function Deferrals(k, trace) {
this.trace = trace;
this.continuation = k;
this.count = 1;
this.ret = null;
}
Deferrals.prototype._call = function(trace) {
var c;
if (this.continuation) {
intern.__active_trace = trace;
c = this.continuation;
this.continuation = null;
return c(this.ret);
} else {
return intern._warn("Entered dead await at " + (intern._trace_to_string(trace)));
}
};
Deferrals.prototype._fulfill = function(id, trace) {
if (--this.count > 0) {
} else {
return runtime.trampoline(((function(_this) {
return function() {
return _this._call(trace);
};
})(this)));
}
};
Deferrals.prototype.defer = function(args) {
var self;
this.count++;
self = this;
return intern.makeDeferReturn(self, args, null, this.trace);
};
Deferrals.prototype._defer = function(args) {
return this["defer"](args);
};
return Deferrals;
})();
runtime.findDeferral = findDeferral = function(args) {
var a, _i, _len;
for (_i = 0, _len = args.length; _i < _len; _i++) {
a = args[_i];
if (a != null ? a[C.trace] : void 0) {
return a;
}
}
return null;
};
runtime.Rendezvous = Rendezvous = (function() {
var RvId;
function Rendezvous() {
this.completed = [];
this.waiters = [];
this.defer_id = 0;
}
RvId = (function() {
function RvId(rv, id, multi) {
this.rv = rv;
this.id = id;
this.multi = multi;
}
RvId.prototype.defer = function(defer_args) {
return this.rv._deferWithId(this.id, defer_args, this.multi);
};
return RvId;
})();
Rendezvous.prototype.wait = function(cb) {
var x;
if (this.completed.length) {
x = this.completed.shift();
return cb(x);
} else {
return this.waiters.push(cb);
}
};
Rendezvous.prototype.defer = function(defer_args) {
var id;
id = this.defer_id++;
return this.deferWithId(id, defer_args);
};
Rendezvous.prototype.id = function(i, multi) {
if (multi == null) {
multi = false;
}
return new RvId(this, i, multi);
};
Rendezvous.prototype._fulfill = function(id, trace) {
var cb;
if (this.waiters.length) {
cb = this.waiters.shift();
return cb(id);
} else {
return this.completed.push(id);
}
};
Rendezvous.prototype._deferWithId = function(id, defer_args, multi) {
this.count++;
return intern.makeDeferReturn(this, defer_args, id, {}, multi);
};
return Rendezvous;
})();
runtime.stackWalk = stackWalk = function(cb) {
var line, ret, tr, _ref;
ret = [];
tr = cb ? cb[C.trace] : intern.__active_trace;
while (tr) {
line = " at " + (intern._trace_to_string(tr));
ret.push(line);
tr = tr != null ? (_ref = tr[C.parent]) != null ? _ref[C.trace] : void 0 : void 0;
}
return ret;
};
runtime.exceptionHandler = exceptionHandler = function(err, logger) {
var stack;
if (!logger) {
logger = console.log;
}
logger(err.stack);
stack = stackWalk();
if (stack.length) {
logger("Iced callback trace:");
return logger(stack.join("\n"));
}
};
return runtime.catchExceptions = function(logger) {
return typeof process !== "undefined" && process !== null ? process.on('uncaughtException', function(err) {
exceptionHandler(err, logger);
return process.exit(1);
}) : void 0;
};
};
exports.runtime = {};
generator(this, exports, exports.runtime);
}).call(this);