mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
not-or to is-and ... positive side.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
return eval(CoffeeScript.compile(code, options));
|
||||
};
|
||||
CoffeeScript.run = function(code, options) {
|
||||
options != null || (options = {});
|
||||
options == null && (options = {});
|
||||
options.bare = true;
|
||||
return Function(CoffeeScript.compile(code, options))();
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
exports.VERSION = '0.9.4';
|
||||
exports.helpers = require('./helpers');
|
||||
exports.compile = compile = function(code, options) {
|
||||
options != null || (options = {});
|
||||
options == null && (options = {});
|
||||
try {
|
||||
return (parser.parse(lexer.tokenize(code))).compile(options);
|
||||
} catch (err) {
|
||||
|
||||
@@ -438,7 +438,7 @@
|
||||
};
|
||||
Lexer.prototype.balancedString = function(str, delimited, options) {
|
||||
var _i, _len, close, i, levels, open, pair, slen;
|
||||
options != null || (options = {});
|
||||
options == null && (options = {});
|
||||
levels = [];
|
||||
i = 0;
|
||||
slen = str.length;
|
||||
@@ -476,7 +476,7 @@
|
||||
};
|
||||
Lexer.prototype.interpolateString = function(str, options) {
|
||||
var _len, _ref2, _this, expr, heredoc, i, inner, interpolated, letter, nested, pi, regex, tag, tokens, value;
|
||||
options != null || (options = {});
|
||||
options == null && (options = {});
|
||||
heredoc = options.heredoc, regex = options.regex;
|
||||
tokens = [];
|
||||
pi = 0;
|
||||
|
||||
17
lib/nodes.js
17
lib/nodes.js
@@ -96,7 +96,7 @@
|
||||
};
|
||||
Base.prototype.toString = function(idt, override) {
|
||||
var _i, _len, _ref2, _result, child, children, klass;
|
||||
idt != null || (idt = '');
|
||||
idt == null && (idt = '');
|
||||
children = ((function() {
|
||||
_ref2 = this.collectChildren();
|
||||
_result = [];
|
||||
@@ -209,7 +209,7 @@
|
||||
return this;
|
||||
};
|
||||
Expressions.prototype.compile = function(o, level) {
|
||||
o != null || (o = {});
|
||||
o == null && (o = {});
|
||||
return o.scope ? Expressions.__super__.compile.call(this, o, level) : this.compileRoot(o);
|
||||
};
|
||||
Expressions.prototype.compileNode = function(o) {
|
||||
@@ -1036,7 +1036,7 @@
|
||||
__extends(Code, Base);
|
||||
Code.prototype.children = ['params', 'body'];
|
||||
Code.prototype.compileNode = function(o) {
|
||||
var _i, _j, _len, _len2, _len3, _ref2, _ref3, _result, _this, close, code, comm, exprs, func, i, idt, open, p, param, ref, scope, sharedScope, splats, v, vars, wasEmpty;
|
||||
var _i, _j, _len, _len2, _len3, _ref2, _ref3, _result, _this, close, code, comm, exprs, func, i, idt, lit, open, p, param, ref, scope, sharedScope, splats, v, val, vars, wasEmpty;
|
||||
sharedScope = del(o, 'sharedScope');
|
||||
o.scope = scope = sharedScope || new Scope(o.scope, this.body, this);
|
||||
o.indent = this.idt(1);
|
||||
@@ -1064,12 +1064,17 @@
|
||||
for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) {
|
||||
param = _ref3[_j];
|
||||
if (param.isComplex()) {
|
||||
ref = param.asReference(o);
|
||||
exprs.push(new Assign(new Value(param.name), param.value ? new Op('?', ref, param.value) : ref));
|
||||
val = ref = param.asReference(o);
|
||||
if (param.value) {
|
||||
val = new Op('?', ref, param.value);
|
||||
}
|
||||
exprs.push(new Assign(new Value(param.name), val, '='));
|
||||
} else {
|
||||
ref = param;
|
||||
if (param.value) {
|
||||
exprs.push(new Op('||', new Literal("" + param.name.value + " != null"), new Assign(param.name, param.value)));
|
||||
lit = new Literal(ref.name.value + ' == null');
|
||||
val = new Assign(new Value(param.name), param.value, '=');
|
||||
exprs.push(new Op('&&', lit, val));
|
||||
}
|
||||
}
|
||||
if (!splats) {
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
};
|
||||
buildRule = function(shortFlag, longFlag, description, options) {
|
||||
var match;
|
||||
options != null || (options = {});
|
||||
options == null && (options = {});
|
||||
match = longFlag.match(OPTIONAL);
|
||||
longFlag = longFlag.match(LONG_FLAG)[1];
|
||||
return {
|
||||
|
||||
@@ -877,16 +877,15 @@ exports.Code = class Code extends Base
|
||||
break
|
||||
for param in @params
|
||||
if param.isComplex()
|
||||
ref = param.asReference o
|
||||
exprs.push new Assign new Value(param.name),
|
||||
if param.value then new Op '?', ref, param.value else ref
|
||||
val = ref = param.asReference o
|
||||
val = new Op '?', ref, param.value if param.value
|
||||
exprs.push new Assign new Value(param.name), val, '='
|
||||
else
|
||||
ref = param
|
||||
if param.value
|
||||
exprs.push new Op('||',
|
||||
new Literal("#{param.name.value} != null"),
|
||||
new Assign(param.name, param.value)
|
||||
)
|
||||
lit = new Literal ref.name.value + ' == null'
|
||||
val = new Assign new Value(param.name), param.value, '='
|
||||
exprs.push new Op '&&', lit, val
|
||||
vars.push ref unless splats
|
||||
scope.startLevel()
|
||||
wasEmpty = @body.isEmpty()
|
||||
|
||||
Reference in New Issue
Block a user