Merging in heregexes

This commit is contained in:
Jeremy Ashkenas
2010-10-05 00:11:28 -04:00
13 changed files with 353 additions and 339 deletions

View File

@@ -216,16 +216,16 @@
o.scope = new Scope(null, this, null);
code = this.compileWithDeclarations(o);
code = code.replace(TRAILING_WHITESPACE, '');
return o.noWrap ? code : ("(function() {\n" + (code) + "\n}).call(this);\n");
return o.noWrap ? code : ("(function() {\n" + code + "\n}).call(this);\n");
};
Expressions.prototype.compileWithDeclarations = function(o) {
var code;
code = this.compileNode(o);
if (o.scope.hasAssignments(this)) {
code = ("" + (this.tab) + "var " + (o.scope.compiledAssignments()) + ";\n" + (code));
code = ("" + (this.tab) + "var " + (o.scope.compiledAssignments()) + ";\n" + code);
}
if (!o.globals && o.scope.hasDeclarations(this)) {
code = ("" + (this.tab) + "var " + (o.scope.compiledDeclarations()) + ";\n" + (code));
code = ("" + (this.tab) + "var " + (o.scope.compiledDeclarations()) + ";\n" + code);
}
return code;
};
@@ -235,7 +235,7 @@
compiledNode = node.compile(merge(o, {
top: true
}));
return node.isStatement(o) ? compiledNode : ("" + (this.idt()) + (compiledNode) + ";");
return node.isStatement(o) ? compiledNode : ("" + (this.idt()) + compiledNode + ";");
};
return Expressions;
})();
@@ -384,7 +384,7 @@
}
code = this.base.compile(o);
if (props[0] instanceof AccessorNode && this.isNumber() || o.top && this.base instanceof ObjectNode) {
code = ("(" + (code) + ")");
code = ("(" + code + ")");
}
for (_i = 0, _len = props.length; _i < _len; _i++) {
prop = props[_i];
@@ -487,7 +487,7 @@
if (!(name)) {
throw Error("cannot call super on an anonymous function.");
}
return method.klass ? ("" + (method.klass) + ".__super__." + (name)) : ("" + (name) + ".__super__.constructor");
return method.klass ? ("" + (method.klass) + ".__super__." + name) : ("" + name + ".__super__.constructor");
};
CallNode.prototype.unfoldSoak = function(o) {
var _i, _len, _ref2, call, list, node;
@@ -540,7 +540,7 @@
}
left = ("typeof " + (left.compile(o)) + " !== \"function\"");
rite = rite.compile(o);
return ("(" + (left) + " ? undefined : " + (rite) + ")");
return ("(" + left + " ? undefined : " + rite + ")");
}
_ref2 = this.args;
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
@@ -557,16 +557,16 @@
}
return _result;
}).call(this).join(', ');
return this.isSuper ? this.compileSuper(args, o) : ("" + (this.prefix()) + (this.variable.compile(o)) + "(" + (args) + ")");
return this.isSuper ? this.compileSuper(args, o) : ("" + (this.prefix()) + (this.variable.compile(o)) + "(" + args + ")");
};
CallNode.prototype.compileSuper = function(args, o) {
return "" + (this.superReference(o)) + ".call(this" + (args.length ? ', ' : '') + (args) + ")";
return "" + (this.superReference(o)) + ".call(this" + (args.length ? ', ' : '') + args + ")";
};
CallNode.prototype.compileSplat = function(o) {
var _i, _len, _ref2, a, arg, argvar, b, base, c, call, fun, idt, name, ref, splatargs;
splatargs = this.compileSplatArguments(o);
if (this.isSuper) {
return ("" + (this.superReference(o)) + ".apply(this, " + (splatargs) + ")");
return ("" + (this.superReference(o)) + ".apply(this, " + splatargs + ")");
}
if (!(this.isNew)) {
if (!((base = this.variable) instanceof ValueNode)) {
@@ -574,14 +574,14 @@
}
if ((name = base.properties.pop()) && base.isComplex()) {
ref = o.scope.freeVariable('this');
fun = ("(" + (ref) + " = " + (base.compile(o)) + ")" + (name.compile(o)));
fun = ("(" + ref + " = " + (base.compile(o)) + ")" + (name.compile(o)));
} else {
fun = (ref = base.compile(o));
if (name) {
fun += name.compile(o);
}
}
return ("" + (fun) + ".apply(" + (ref) + ", " + (splatargs) + ")");
return ("" + fun + ".apply(" + ref + ", " + splatargs + ")");
}
call = 'call(this)';
argvar = function(n) {
@@ -598,7 +598,7 @@
a = o.scope.freeVariable('ctor');
b = o.scope.freeVariable('ref');
c = o.scope.freeVariable('result');
return "(function() {\n" + (idt = this.idt(1)) + "var ctor = function() {};\n" + (idt) + (utility('extends')) + "(ctor, " + (a) + " = " + (this.variable.compile(o)) + ");\n" + (idt) + "return typeof (" + (c) + " = " + (a) + ".apply(" + (b) + " = new ctor, " + (splatargs) + ")) === \"object\" ? " + (c) + " : " + (b) + ";\n" + (this.tab) + "})." + (call);
return "(function() {\n" + (idt = this.idt(1)) + "var ctor = function() {};\n" + idt + (utility('extends')) + "(ctor, " + a + " = " + (this.variable.compile(o)) + ");\n" + idt + "return typeof (" + c + " = " + a + ".apply(" + b + " = new ctor, " + splatargs + ")) === \"object\" ? " + c + " : " + b + ";\n" + (this.tab) + "})." + call;
};
return CallNode;
})();
@@ -635,7 +635,7 @@
AccessorNode.prototype.compileNode = function(o) {
var name, namePart;
name = this.name.compile(o);
namePart = name.match(IS_STRING) ? ("[" + (name) + "]") : ("." + (name));
namePart = name.match(IS_STRING) ? ("[" + name + "]") : ("." + name);
return this.prototype + namePart;
};
AccessorNode.prototype.isComplex = NO;
@@ -655,7 +655,7 @@
var idx, prefix;
idx = this.index.compile(o);
prefix = this.proto ? '.prototype' : '';
return "" + (prefix) + "[" + (idx) + "]";
return "" + prefix + "[" + idx + "]";
};
IndexNode.prototype.isComplex = function() {
return this.index.isComplex();
@@ -706,20 +706,20 @@
}
idx = del(o, 'index');
step = del(o, 'step');
vars = ("" + (idx) + " = " + (this.fromVar));
intro = ("(" + (this.fromVar) + " <= " + (this.toVar) + " ? " + (idx));
compare = ("" + (intro) + " <" + (this.equals) + " " + (this.toVar) + " : " + (idx) + " >" + (this.equals) + " " + (this.toVar) + ")");
vars = ("" + idx + " = " + (this.fromVar));
intro = ("(" + (this.fromVar) + " <= " + (this.toVar) + " ? " + idx);
compare = ("" + intro + " <" + (this.equals) + " " + (this.toVar) + " : " + idx + " >" + (this.equals) + " " + (this.toVar) + ")");
stepPart = step ? step.compile(o) : '1';
incr = step ? ("" + (idx) + " += " + (stepPart)) : ("" + (intro) + " += " + (stepPart) + " : " + (idx) + " -= " + (stepPart) + ")");
return "" + (vars) + "; " + (compare) + "; " + (incr);
incr = step ? ("" + idx + " += " + stepPart) : ("" + intro + " += " + stepPart + " : " + idx + " -= " + stepPart + ")");
return "" + vars + "; " + compare + "; " + incr;
};
RangeNode.prototype.compileSimple = function(o) {
var _ref2, from, idx, step, to;
_ref2 = [+this.fromNum, +this.toNum], from = _ref2[0], to = _ref2[1];
idx = del(o, 'index');
step = del(o, 'step');
step && (step = ("" + (idx) + " += " + (step.compile(o))));
return from <= to ? ("" + (idx) + " = " + (from) + "; " + (idx) + " <" + (this.equals) + " " + (to) + "; " + (step || ("" + (idx) + "++"))) : ("" + (idx) + " = " + (from) + "; " + (idx) + " >" + (this.equals) + " " + (to) + "; " + (step || ("" + (idx) + "--")));
step && (step = ("" + idx + " += " + (step.compile(o))));
return from <= to ? ("" + idx + " = " + from + "; " + idx + " <" + (this.equals) + " " + to + "; " + (step || ("" + idx + "++"))) : ("" + idx + " = " + from + "; " + idx + " >" + (this.equals) + " " + to + "; " + (step || ("" + idx + "--")));
};
RangeNode.prototype.compileArray = function(o) {
var _i, _ref2, _ref3, _result, body, clause, i, idt, post, pre, range, result, vars;
@@ -740,16 +740,16 @@
}
i = o.scope.freeVariable('i');
result = o.scope.freeVariable('result');
pre = ("\n" + (idt) + (result) + " = []; " + (vars));
pre = ("\n" + idt + result + " = []; " + vars);
if (this.fromNum && this.toNum) {
o.index = i;
body = this.compileSimple(o);
} else {
clause = ("" + (this.fromVar) + " <= " + (this.toVar) + " ?");
body = ("var " + (i) + " = " + (this.fromVar) + "; " + (clause) + " " + (i) + " <" + (this.equals) + " " + (this.toVar) + " : " + (i) + " >" + (this.equals) + " " + (this.toVar) + "; " + (clause) + " " + (i) + " += 1 : " + (i) + " -= 1");
body = ("var " + i + " = " + (this.fromVar) + "; " + clause + " " + i + " <" + (this.equals) + " " + (this.toVar) + " : " + i + " >" + (this.equals) + " " + (this.toVar) + "; " + clause + " " + i + " += 1 : " + i + " -= 1");
}
post = ("{ " + (result) + ".push(" + (i) + "); }\n" + (idt) + "return " + (result) + ";\n" + (o.indent));
return "(function() {" + (pre) + "\n" + (idt) + "for (" + (body) + ")" + (post) + "}).call(this)";
post = ("{ " + result + ".push(" + i + "); }\n" + idt + "return " + result + ";\n" + (o.indent));
return "(function() {" + pre + "\n" + idt + "for (" + body + ")" + post + "}).call(this)";
};
return RangeNode;
})();
@@ -771,7 +771,7 @@
if (to) {
to = ', ' + to;
}
return ".slice(" + (from) + (to) + ")";
return ".slice(" + from + to + ")";
};
return SliceNode;
})();
@@ -826,7 +826,7 @@
}).call(this);
props = props.join('');
obj = '{' + (props ? '\n' + props + '\n' + this.idt() : '') + '}';
return top ? ("(" + (obj) + ")") : obj;
return top ? ("(" + obj + ")") : obj;
};
return ObjectNode;
})();
@@ -855,15 +855,15 @@
if (obj instanceof SplatNode) {
return this.compileSplatLiteral(o);
} else if (obj instanceof CommentNode) {
objects.push("\n" + (code) + "\n" + (o.indent));
objects.push("\n" + code + "\n" + (o.indent));
} else if (i === this.objects.length - 1) {
objects.push(code);
} else {
objects.push("" + (code) + ", ");
objects.push("" + code + ", ");
}
}
objects = objects.join('');
return indexOf(objects, '\n') >= 0 ? ("[\n" + (this.idt(1)) + (objects) + "\n" + (this.tab) + "]") : ("[" + (objects) + "]");
return indexOf(objects, '\n') >= 0 ? ("[\n" + (this.idt(1)) + objects + "\n" + (this.tab) + "]") : ("[" + objects + "]");
};
return ArrayNode;
})();
@@ -929,7 +929,7 @@
if (constructor.body.empty()) {
constructor.body.push(new ReturnNode(literal('this')));
}
constructor.body.unshift(literal("this." + (pname) + " = function(){ return " + (className) + ".prototype." + (pname) + ".apply(" + (me) + ", arguments); }"));
constructor.body.unshift(literal("this." + pname + " = function(){ return " + className + ".prototype." + pname + ".apply(" + me + ", arguments); }"));
}
}
if (pvar) {
@@ -941,7 +941,7 @@
}
constructor.className = className.match(/[\w\d\$_]+$/);
if (me) {
constructor.body.unshift(literal("" + (me) + " = this"));
constructor.body.unshift(literal("" + me + " = this"));
}
construct = this.idt() + (new AssignNode(this.variable, constructor)).compile(merge(o, {
sharedScope: constScope
@@ -992,16 +992,16 @@
}
val = this.value.compile(o);
if (this.context === 'object') {
return ("" + (name) + ": " + (val));
return ("" + name + ": " + val);
}
if (!(isValue && (this.variable.hasProperties() || this.variable.namespaced))) {
o.scope.find(name);
}
val = ("" + (name) + " = " + (val));
val = ("" + name + " = " + val);
if (stmt) {
return ("" + (this.tab) + (val) + ";");
return ("" + (this.tab) + val + ";");
}
return top || this.parenthetical ? val : ("(" + (val) + ")");
return top || this.parenthetical ? val : ("(" + val + ")");
};
AssignNode.prototype.compilePatternMatch = function(o) {
var _len, _ref2, accessClass, assigns, code, i, idx, isObject, obj, objects, olength, otop, splat, top, val, valVar, value;
@@ -1031,7 +1031,7 @@
top: true
});
valVar = o.scope.freeVariable('ref');
assigns = [("" + (valVar) + " = " + (value.compile(o)))];
assigns = [("" + valVar + " = " + (value.compile(o)))];
splat = false;
for (i = 0, _len = objects.length; i < _len; i++) {
obj = objects[i];
@@ -1052,7 +1052,7 @@
splat = true;
} else {
if (typeof idx !== 'object') {
idx = literal(splat ? ("" + (valVar) + ".length - " + (olength - idx)) : idx);
idx = literal(splat ? ("" + valVar + ".length - " + (olength - idx)) : idx);
}
val = new ValueNode(literal(valVar), [new accessClass(idx)]);
}
@@ -1062,7 +1062,7 @@
assigns.push(valVar);
}
code = assigns.join(', ');
return top || this.parenthetical ? code : ("(" + (code) + ")");
return top || this.parenthetical ? code : ("(" + code + ")");
};
AssignNode.prototype.compileSplice = function(o) {
var from, name, plus, range, ref, to, val;
@@ -1070,10 +1070,10 @@
name = this.variable.compile(o);
plus = range.exclusive ? '' : ' + 1';
from = range.from ? range.from.compile(o) : '0';
to = range.to ? range.to.compile(o) + ' - ' + from + plus : ("" + (name) + ".length");
to = range.to ? range.to.compile(o) + ' - ' + from + plus : ("" + name + ".length");
ref = o.scope.freeVariable('ref');
val = this.value.compile(o);
return "([].splice.apply(" + (name) + ", [" + (from) + ", " + (to) + "].concat(" + (ref) + " = " + (val) + ")), " + (ref) + ")";
return "([].splice.apply(" + name + ", [" + from + ", " + to + "].concat(" + ref + " = " + val + ")), " + ref + ")";
};
return AssignNode;
})();
@@ -1153,11 +1153,11 @@
code = this.body.expressions.length ? ("\n" + (this.body.compileWithDeclarations(o)) + "\n") : '';
open = this.className ? ("(function() {\n" + (this.idt(1)) + "return function " + (this.className) + "(") : "function(";
close = this.className ? ("" + (code && this.idt(1)) + "};\n" + (this.tab) + "})()") : ("" + (code && this.tab) + "}");
func = ("" + (open) + (params.join(', ')) + ") {" + (code) + (close));
func = ("" + open + (params.join(', ')) + ") {" + code + close);
if (this.bound) {
return ("" + (utility('bind')) + "(" + (func) + ", " + (this.context) + ")");
return ("" + (utility('bind')) + "(" + func + ", " + (this.context) + ")");
}
return top ? ("(" + (func) + ")") : func;
return top ? ("(" + func + ")") : func;
};
CodeNode.prototype.topSensitive = YES;
CodeNode.prototype.traverseChildren = function(crossScope, func) {
@@ -1220,7 +1220,7 @@
o.scope.assign(len, "arguments.length");
variadic = o.scope.freeVariable('result');
o.scope.assign(variadic, len + ' >= ' + this.arglength);
end = this.trailings.length ? (", " + (len) + " - " + (this.trailings.length)) : undefined;
end = this.trailings.length ? (", " + len + " - " + (this.trailings.length)) : undefined;
_ref2 = this.trailings;
for (idx = 0, _len = _ref2.length; idx < _len; idx++) {
trailing = _ref2[idx];
@@ -1230,15 +1230,15 @@
assign.value = trailing;
}
pos = this.trailings.length - idx;
o.scope.assign(trailing.compile(o), "arguments[" + (variadic) + " ? " + (len) + " - " + (pos) + " : " + (this.index + idx) + "]");
o.scope.assign(trailing.compile(o), "arguments[" + variadic + " ? " + len + " - " + pos + " : " + (this.index + idx) + "]");
}
}
return "" + (name) + " = " + (utility('slice')) + ".call(arguments, " + (this.index) + (end) + ")";
return "" + name + " = " + (utility('slice')) + ".call(arguments, " + (this.index) + end + ")";
};
SplatNode.prototype.compileValue = function(o, name, index, trailings) {
var trail;
trail = trailings ? (", " + (name) + ".length - " + (trailings)) : '';
return "" + (utility('slice')) + ".call(" + (name) + ", " + (index) + (trail) + ")";
trail = trailings ? (", " + name + ".length - " + trailings) : '';
return "" + (utility('slice')) + ".call(" + name + ", " + index + trail + ")";
};
SplatNode.compileSplattedArray = function(list, o) {
var _len, arg, args, code, end, i, prev;
@@ -1250,16 +1250,16 @@
prev = args[end];
if (!(arg instanceof SplatNode)) {
if (prev && starts(prev, '[') && ends(prev, ']')) {
args[end] = ("" + (prev.slice(0, -1)) + ", " + (code) + "]");
args[end] = ("" + (prev.slice(0, -1)) + ", " + code + "]");
continue;
}
if (prev && starts(prev, '.concat([') && ends(prev, '])')) {
args[end] = ("" + (prev.slice(0, -2)) + ", " + (code) + "])");
args[end] = ("" + (prev.slice(0, -2)) + ", " + code + "])");
continue;
}
code = ("[" + (code) + "]");
code = ("[" + code + "]");
}
args[++end] = i === 0 ? code : (".concat(" + (code) + ")");
args[++end] = i === 0 ? code : (".concat(" + code + ")");
}
return args.join('');
};
@@ -1302,12 +1302,12 @@
set = '';
if (!(top)) {
rvar = o.scope.freeVariable('result');
set = ("" + (this.tab) + (rvar) + " = [];\n");
set = ("" + (this.tab) + rvar + " = [];\n");
if (this.body) {
this.body = PushNode.wrap(rvar, this.body);
}
}
pre = ("" + (set) + (this.tab) + "while (" + (cond) + ")");
pre = ("" + set + (this.tab) + "while (" + cond + ")");
if (this.guard) {
this.body = Expressions.wrap([new IfNode(this.guard, this.body)]);
}
@@ -1318,7 +1318,7 @@
} else {
post = '';
}
return "" + (pre) + " {\n" + (this.body.compile(o)) + "\n" + (this.tab) + "}" + (post);
return "" + pre + " {\n" + (this.body.compile(o)) + "\n" + (this.tab) + "}" + post;
};
return WhileNode;
})();
@@ -1409,7 +1409,7 @@
shared = this.first.unwrap().second;
_ref2 = shared.compileReference(o), this.first.second = _ref2[0], shared = _ref2[1];
_ref2 = [this.first.compile(o), this.second.compile(o), shared.compile(o)], first = _ref2[0], second = _ref2[1], shared = _ref2[2];
return "(" + (first) + ") && (" + (shared) + " " + (this.operator) + " " + (second) + ")";
return "(" + first + ") && (" + shared + " " + (this.operator) + " " + second + ")";
};
OpNode.prototype.compileAssignment = function(o) {
var _ref2, left, rite;
@@ -1426,7 +1426,7 @@
fst = this.first;
ref = fst.compile(o);
}
return new ExistenceNode(fst).compile(o) + (" ? " + (ref) + " : " + (this.second.compile(o)));
return new ExistenceNode(fst).compile(o) + (" ? " + ref + " : " + (this.second.compile(o)));
};
OpNode.prototype.compileUnary = function(o) {
var parts, space;
@@ -1479,7 +1479,7 @@
}), this.arr1 = _ref2[0], this.arr2 = _ref2[1];
_ref2 = [o.scope.freeVariable('i'), o.scope.freeVariable('len')], i = _ref2[0], l = _ref2[1];
prefix = this.obj1 !== this.obj2 ? this.obj1 + '; ' : '';
return "(function(){ " + (prefix) + "for (var " + (i) + "=0, " + (l) + "=" + (this.arr1) + ".length; " + (i) + "<" + (l) + "; " + (i) + "++) { if (" + (this.arr2) + "[" + (i) + "] === " + (this.obj2) + ") return true; } return false; }).call(this)";
return "(function(){ " + prefix + "for (var " + i + "=0, " + l + "=" + (this.arr1) + ".length; " + i + "<" + l + "; " + i + "++) { if (" + (this.arr2) + "[" + i + "] === " + (this.obj2) + ") return true; } return false; }).call(this)";
};
return InNode;
})();
@@ -1512,9 +1512,9 @@
o.top = true;
attemptPart = this.attempt.compile(o);
errorPart = this.error ? (" (" + (this.error.compile(o)) + ") ") : ' ';
catchPart = this.recovery ? (" catch" + (errorPart) + "{\n" + (this.recovery.compile(o)) + "\n" + (this.tab) + "}") : (!(this.ensure || this.recovery) ? ' catch (_e) {}' : '');
catchPart = this.recovery ? (" catch" + errorPart + "{\n" + (this.recovery.compile(o)) + "\n" + (this.tab) + "}") : (!(this.ensure || this.recovery) ? ' catch (_e) {}' : '');
finallyPart = (this.ensure || '') && ' finally {\n' + this.ensure.compile(merge(o)) + ("\n" + (this.tab) + "}");
return "" + (this.tab) + "try {\n" + (attemptPart) + "\n" + (this.tab) + "}" + (catchPart) + (finallyPart);
return "" + (this.tab) + "try {\n" + attemptPart + "\n" + (this.tab) + "}" + catchPart + finallyPart;
};
return TryNode;
})();
@@ -1548,8 +1548,8 @@
ExistenceNode.prototype.compileNode = function(o) {
var code;
code = this.expression.compile(o);
code = IDENTIFIER.test(code) && !o.scope.check(code) ? ("typeof " + (code) + " !== \"undefined\" && " + (code) + " !== null") : ("" + (code) + " != null");
return this.parenthetical ? code : ("(" + (code) + ")");
code = IDENTIFIER.test(code) && !o.scope.check(code) ? ("typeof " + code + " !== \"undefined\" && " + code + " !== null") : ("" + code + " != null");
return this.parenthetical ? code : ("(" + code + ")");
};
return ExistenceNode;
})();
@@ -1584,7 +1584,7 @@
if (this.parenthetical || this.isStatement(o)) {
return top ? this.tab + code + ';' : code;
}
return "(" + (code) + ")";
return "(" + code + ")";
};
return ParentheticalNode;
})();
@@ -1676,20 +1676,20 @@
sourcePart = '';
} else {
ref = scope.freeVariable('ref');
sourcePart = ("" + (ref) + " = " + (svar) + ";");
sourcePart = ("" + ref + " = " + svar + ";");
svar = ref;
}
namePart = this.pattern ? new AssignNode(this.name, literal("" + (svar) + "[" + (ivar) + "]")).compile(merge(o, {
namePart = this.pattern ? new AssignNode(this.name, literal("" + svar + "[" + ivar + "]")).compile(merge(o, {
top: true
})) : (name ? ("" + (name) + " = " + (svar) + "[" + (ivar) + "]") : undefined);
})) : (name ? ("" + name + " = " + svar + "[" + ivar + "]") : undefined);
if (!(this.object)) {
lvar = scope.freeVariable('len');
stepPart = this.step ? ("" + (ivar) + " += " + (this.step.compile(o))) : ("" + (ivar) + "++");
forPart = ("" + (ivar) + " = 0, " + (lvar) + " = " + (svar) + ".length; " + (ivar) + " < " + (lvar) + "; " + (stepPart));
stepPart = this.step ? ("" + ivar + " += " + (this.step.compile(o))) : ("" + ivar + "++");
forPart = ("" + ivar + " = 0, " + lvar + " = " + svar + ".length; " + ivar + " < " + lvar + "; " + stepPart);
}
}
sourcePart = (rvar ? ("" + (rvar) + " = []; ") : '') + sourcePart;
sourcePart = sourcePart ? ("" + (this.tab) + (sourcePart) + "\n" + (this.tab)) : this.tab;
sourcePart = (rvar ? ("" + rvar + " = []; ") : '') + sourcePart;
sourcePart = sourcePart ? ("" + (this.tab) + sourcePart + "\n" + (this.tab)) : this.tab;
returnResult = this.compileReturnValue(rvar, o);
if (!(topLevel)) {
body = PushNode.wrap(rvar, body);
@@ -1699,32 +1699,32 @@
}
if (codeInBody) {
if (range) {
body.unshift(literal("var " + (name) + " = " + (ivar)));
body.unshift(literal("var " + name + " = " + ivar));
}
if (namePart) {
body.unshift(literal("var " + (namePart)));
body.unshift(literal("var " + namePart));
}
if (index) {
body.unshift(literal("var " + (index) + " = " + (ivar)));
body.unshift(literal("var " + index + " = " + ivar));
}
body = ClosureNode.wrap(body, true);
} else {
if (namePart) {
varPart = ("" + (idt1) + (namePart) + ";\n");
varPart = ("" + idt1 + namePart + ";\n");
}
}
if (this.object) {
forPart = ("" + (ivar) + " in " + (svar));
forPart = ("" + ivar + " in " + svar);
if (!(this.raw)) {
guardPart = ("\n" + (idt1) + "if (!" + (utility('hasProp')) + ".call(" + (svar) + ", " + (ivar) + ")) continue;");
guardPart = ("\n" + idt1 + "if (!" + (utility('hasProp')) + ".call(" + svar + ", " + ivar + ")) continue;");
}
}
body = body.compile(merge(o, {
indent: idt1,
top: true
}));
vars = range ? name : ("" + (name) + ", " + (ivar));
return "" + (sourcePart) + "for (" + (forPart) + ") {" + (guardPart) + "\n" + (varPart) + (body) + "\n" + (this.tab) + "}" + (returnResult);
vars = range ? name : ("" + name + ", " + ivar);
return "" + sourcePart + "for (" + forPart + ") {" + guardPart + "\n" + varPart + body + "\n" + (this.tab) + "}" + returnResult;
};
return ForNode;
})();
@@ -1775,7 +1775,7 @@
}
code += ("\n" + (block.compile(o)));
if (!(last(exprs) instanceof ReturnNode)) {
code += ("\n" + (idt) + "break;");
code += ("\n" + idt + "break;");
}
}
if (this.otherwise) {
@@ -1868,7 +1868,7 @@
ifDent = child || (top && !this.isStatement(o)) ? '' : this.idt();
comDent = child ? this.idt() : '';
body = this.body.compile(o);
ifPart = ("" + (ifDent) + "if (" + (this.compileCondition(condO)) + ") {\n" + (body) + "\n" + (this.tab) + "}");
ifPart = ("" + ifDent + "if (" + (this.compileCondition(condO)) + ") {\n" + body + "\n" + (this.tab) + "}");
if (!(this.elseBody)) {
return ifPart;
}
@@ -1876,7 +1876,7 @@
indent: this.idt(),
chainChild: true
})) : (" else {\n" + (this.elseBody.compile(o)) + "\n" + (this.tab) + "}");
return "" + (ifPart) + (elsePart);
return "" + ifPart + elsePart;
};
IfNode.prototype.compileTernary = function(o) {
var code, elsePart, ifPart;
@@ -1886,8 +1886,8 @@
}
ifPart = this.condition.compile(o) + ' ? ' + this.bodyNode().compile(o);
elsePart = this.elseBody ? this.elseBodyNode().compile(o) : 'undefined';
code = ("" + (ifPart) + " : " + (elsePart));
return this.tags.operation ? ("(" + (code) + ")") : code;
code = ("" + ifPart + " : " + elsePart);
return this.tags.operation ? ("(" + code + ")") : code;
};
return IfNode;
})();
@@ -1944,7 +1944,7 @@
};
utility = function(name) {
var ref;
ref = ("__" + (name));
ref = ("__" + name);
Scope.root.assign(ref, UTILITIES[name]);
return ref;
};