Back four commits ... Fixing named function expressions -> function declarations for IE. (grumble grumble)

This commit is contained in:
Jeremy Ashkenas 2010-10-11 12:13:01 -04:00
parent de0b93381c
commit acc06d772a
7 changed files with 71 additions and 38 deletions

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,8 @@
_ref = require('./helpers'), include = _ref.include, count = _ref.count, starts = _ref.starts, compact = _ref.compact, last = _ref.last;
exports.Lexer = (function() {
Lexer = (function() {
return function Lexer() {};
function Lexer() {};
return Lexer;
})();
Lexer.prototype.tokenize = function(code, options) {
var o;

View File

@ -21,10 +21,11 @@
};
exports.Base = (function() {
Base = (function() {
return function Base() {
function Base() {
this.tags = {};
return this;
};
return Base;
})();
Base.prototype.compile = function(o) {
var closure, code, top;
@ -157,11 +158,12 @@
})();
exports.Expressions = (function() {
Expressions = (function() {
return function Expressions(nodes) {
function Expressions(nodes) {
Expressions.__super__.constructor.call(this);
this.expressions = compact(flatten(nodes || []));
return this;
};
return Expressions;
})();
__extends(Expressions, Base);
Expressions.prototype.children = ['expressions'];
@ -244,11 +246,12 @@
};
exports.Literal = (function() {
Literal = (function() {
return function Literal(_arg) {
function Literal(_arg) {
this.value = _arg;
Literal.__super__.constructor.call(this);
return this;
};
return Literal;
})();
__extends(Literal, Base);
Literal.prototype.makeReturn = function() {
@ -277,11 +280,12 @@
})();
exports.Return = (function() {
Return = (function() {
return function Return(_arg) {
function Return(_arg) {
this.expression = _arg;
Return.__super__.constructor.call(this);
return this;
};
return Return;
})();
__extends(Return, Base);
Return.prototype.isStatement = YES;
@ -311,7 +315,7 @@
})();
exports.Value = (function() {
Value = (function() {
return function Value(_arg, _arg2, tag) {
function Value(_arg, _arg2, tag) {
this.properties = _arg2;
this.base = _arg;
Value.__super__.constructor.call(this);
@ -321,6 +325,7 @@
}
return this;
};
return Value;
})();
__extends(Value, Base);
Value.prototype.children = ['base', 'properties'];
@ -443,11 +448,12 @@
}).call(this);
exports.Comment = (function() {
Comment = (function() {
return function Comment(_arg) {
function Comment(_arg) {
this.comment = _arg;
Comment.__super__.constructor.call(this);
return this;
};
return Comment;
})();
__extends(Comment, Base);
Comment.prototype.isStatement = YES;
@ -459,7 +465,7 @@
})();
exports.Call = (function() {
Call = (function() {
return function Call(variable, _arg, _arg2) {
function Call(variable, _arg, _arg2) {
this.exist = _arg2;
this.args = _arg;
Call.__super__.constructor.call(this);
@ -469,6 +475,7 @@
this.args || (this.args = []);
return this;
};
return Call;
})();
__extends(Call, Base);
Call.prototype.children = ['variable', 'args'];
@ -606,12 +613,13 @@
})();
exports.Extends = (function() {
Extends = (function() {
return function Extends(_arg, _arg2) {
function Extends(_arg, _arg2) {
this.parent = _arg2;
this.child = _arg;
Extends.__super__.constructor.call(this);
return this;
};
return Extends;
})();
__extends(Extends, Base);
Extends.prototype.children = ['child', 'parent'];
@ -624,13 +632,14 @@
})();
exports.Accessor = (function() {
Accessor = (function() {
return function Accessor(_arg, tag) {
function Accessor(_arg, tag) {
this.name = _arg;
Accessor.__super__.constructor.call(this);
this.prototype = tag === 'prototype' ? '.prototype' : '';
this.soakNode = tag === 'soak';
return this;
};
return Accessor;
})();
__extends(Accessor, Base);
Accessor.prototype.children = ['name'];
@ -645,11 +654,12 @@
})();
exports.Index = (function() {
Index = (function() {
return function Index(_arg) {
function Index(_arg) {
this.index = _arg;
Index.__super__.constructor.call(this);
return this;
};
return Index;
})();
__extends(Index, Base);
Index.prototype.children = ['index'];
@ -666,7 +676,7 @@
})();
exports.Range = (function() {
Range = (function() {
return function Range(_arg, _arg2, tag) {
function Range(_arg, _arg2, tag) {
this.to = _arg2;
this.from = _arg;
Range.__super__.constructor.call(this);
@ -674,6 +684,7 @@
this.equals = this.exclusive ? '' : '=';
return this;
};
return Range;
})();
__extends(Range, Base);
Range.prototype.children = ['from', 'to'];
@ -753,11 +764,12 @@
})();
exports.Slice = (function() {
Slice = (function() {
return function Slice(_arg) {
function Slice(_arg) {
this.range = _arg;
Slice.__super__.constructor.call(this);
return this;
};
return Slice;
})();
__extends(Slice, Base);
Slice.prototype.children = ['range'];
@ -775,11 +787,12 @@
})();
exports.ObjectLiteral = (function() {
ObjectLiteral = (function() {
return function ObjectLiteral(props) {
function ObjectLiteral(props) {
ObjectLiteral.__super__.constructor.call(this);
this.objects = (this.properties = props || []);
return this;
};
return ObjectLiteral;
})();
__extends(ObjectLiteral, Base);
ObjectLiteral.prototype.children = ['properties'];
@ -830,12 +843,13 @@
})();
exports.ArrayLiteral = (function() {
ArrayLiteral = (function() {
return function ArrayLiteral(_arg) {
function ArrayLiteral(_arg) {
this.objects = _arg;
ArrayLiteral.__super__.constructor.call(this);
this.objects || (this.objects = []);
return this;
};
return ArrayLiteral;
})();
__extends(ArrayLiteral, Base);
ArrayLiteral.prototype.children = ['objects'];
@ -864,7 +878,7 @@
})();
exports.Class = (function() {
Class = (function() {
return function Class(variable, _arg, _arg2) {
function Class(variable, _arg, _arg2) {
this.properties = _arg2;
this.parent = _arg;
Class.__super__.constructor.call(this);
@ -873,6 +887,7 @@
this.returns = false;
return this;
};
return Class;
})();
__extends(Class, Base);
Class.prototype.children = ['variable', 'parent', 'properties'];
@ -958,13 +973,14 @@
})();
exports.Assign = (function() {
Assign = (function() {
return function Assign(_arg, _arg2, _arg3) {
function Assign(_arg, _arg2, _arg3) {
this.context = _arg3;
this.value = _arg2;
this.variable = _arg;
Assign.__super__.constructor.call(this);
return this;
};
return Assign;
})();
__extends(Assign, Base);
Assign.prototype.METHOD_DEF = /^(?:(\S+)\.prototype\.)?([$A-Za-z_][$\w]*)$/;
@ -1083,7 +1099,7 @@
})();
exports.Code = (function() {
Code = (function() {
return function Code(_arg, _arg2, tag) {
function Code(_arg, _arg2, tag) {
this.body = _arg2;
this.params = _arg;
Code.__super__.constructor.call(this);
@ -1095,6 +1111,7 @@
}
return this;
};
return Code;
})();
__extends(Code, Base);
Code.prototype.children = ['params', 'body'];
@ -1155,8 +1172,8 @@
o.indent = this.idt(2);
}
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) + "}");
open = this.className ? ("(function() {\n" + (this.idt(1)) + "function " + (this.className) + "(") : "function(";
close = this.className ? ("" + (code && this.idt(1)) + "};\n" + (this.idt(1)) + "return " + (this.className) + ";\n" + (this.tab) + "})()") : ("" + (code && this.tab) + "}");
func = ("" + open + (params.join(', ')) + ") {" + code + close);
o.scope.endLevel();
if (this.bound) {
@ -1172,7 +1189,7 @@
})();
exports.Param = (function() {
Param = (function() {
return function Param(_arg, _arg2, _arg3) {
function Param(_arg, _arg2, _arg3) {
this.splat = _arg3;
this.attach = _arg2;
this.name = _arg;
@ -1180,6 +1197,7 @@
this.value = new Literal(this.name);
return this;
};
return Param;
})();
__extends(Param, Base);
Param.prototype.children = ['name'];
@ -1201,7 +1219,7 @@
})();
exports.Splat = (function() {
Splat = (function() {
return function Splat(name) {
function Splat(name) {
Splat.__super__.constructor.call(this);
if (!name.compile) {
name = new Literal(name);
@ -1209,6 +1227,7 @@
this.name = name;
return this;
};
return Splat;
})();
__extends(Splat, Base);
Splat.prototype.children = ['name'];
@ -1271,12 +1290,13 @@
}).call(this);
exports.While = (function() {
While = (function() {
return function While(condition, opts) {
function While(condition, opts) {
While.__super__.constructor.call(this);
this.condition = ((opts != null) ? opts.invert : undefined) ? condition.invert() : condition;
this.guard = ((opts != null) ? opts.guard : undefined);
return this;
};
return While;
})();
__extends(While, Base);
While.prototype.children = ['condition', 'guard', 'body'];
@ -1322,7 +1342,7 @@
})();
exports.Op = (function() {
Op = (function() {
return function Op(_arg, _arg2, _arg3, flip) {
function Op(_arg, _arg2, _arg3, flip) {
this.second = _arg3;
this.first = _arg2;
this.operator = _arg;
@ -1340,6 +1360,7 @@
}
return this;
};
return Op;
})();
__extends(Op, Base);
Op.prototype.CONVERSIONS = {
@ -1433,12 +1454,13 @@
})();
exports.In = (function() {
In = (function() {
return function In(_arg, _arg2) {
function In(_arg, _arg2) {
this.array = _arg2;
this.object = _arg;
In.__super__.constructor.call(this);
return this;
};
return In;
})();
__extends(In, Base);
In.prototype.children = ['object', 'array'];
@ -1477,7 +1499,7 @@
})();
exports.Try = (function() {
Try = (function() {
return function Try(_arg, _arg2, _arg3, _arg4) {
function Try(_arg, _arg2, _arg3, _arg4) {
this.ensure = _arg4;
this.recovery = _arg3;
this.error = _arg2;
@ -1485,6 +1507,7 @@
Try.__super__.constructor.call(this);
return this;
};
return Try;
})();
__extends(Try, Base);
Try.prototype.children = ['attempt', 'recovery', 'ensure'];
@ -1512,11 +1535,12 @@
})();
exports.Throw = (function() {
Throw = (function() {
return function Throw(_arg) {
function Throw(_arg) {
this.expression = _arg;
Throw.__super__.constructor.call(this);
return this;
};
return Throw;
})();
__extends(Throw, Base);
Throw.prototype.children = ['expression'];
@ -1529,11 +1553,12 @@
})();
exports.Existence = (function() {
Existence = (function() {
return function Existence(_arg) {
function Existence(_arg) {
this.expression = _arg;
Existence.__super__.constructor.call(this);
return this;
};
return Existence;
})();
__extends(Existence, Base);
Existence.prototype.children = ['expression'];
@ -1547,11 +1572,12 @@
})();
exports.Parens = (function() {
Parens = (function() {
return function Parens(_arg) {
function Parens(_arg) {
this.expression = _arg;
Parens.__super__.constructor.call(this);
return this;
};
return Parens;
})();
__extends(Parens, Base);
Parens.prototype.children = ['expression'];
@ -1582,7 +1608,7 @@
})();
exports.For = (function() {
For = (function() {
return function For(_arg, source, _arg2, _arg3) {
function For(_arg, source, _arg2, _arg3) {
var _ref2, _ref3;
this.index = _arg3;
this.name = _arg2;
@ -1601,6 +1627,7 @@
this.returns = false;
return this;
};
return For;
})();
__extends(For, Base);
For.prototype.children = ['body', 'source', 'guard'];
@ -1717,7 +1744,7 @@
})();
exports.Switch = (function() {
Switch = (function() {
return function Switch(_arg, _arg2, _arg3) {
function Switch(_arg, _arg2, _arg3) {
this.otherwise = _arg3;
this.cases = _arg2;
this.subject = _arg;
@ -1726,6 +1753,7 @@
this.subject || (this.subject = new Literal('true'));
return this;
};
return Switch;
})();
__extends(Switch, Base);
Switch.prototype.children = ['subject', 'cases', 'otherwise'];
@ -1772,7 +1800,7 @@
})();
exports.If = (function() {
If = (function() {
return function If(condition, _arg, _arg2) {
function If(condition, _arg, _arg2) {
this.tags = _arg2;
this.body = _arg;
this.tags || (this.tags = {});
@ -1781,6 +1809,7 @@
this.isChain = false;
return this;
};
return If;
})();
__extends(If, Base);
If.prototype.children = ['condition', 'body', 'elseBody', 'assigner'];

View File

@ -2,11 +2,12 @@
var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments;
exports.OptionParser = (function() {
OptionParser = (function() {
return function OptionParser(rules, banner) {
function OptionParser(rules, banner) {
this.banner = banner;
this.rules = buildRules(rules);
return this;
};
return OptionParser;
})();
OptionParser.prototype.parse = function(args) {
var _i, _len, _len2, _ref, arg, i, isOption, matchedRule, options, rule, value;

View File

@ -2,7 +2,8 @@
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, _i, _len, _ref, include, left, rite;
include = require('./helpers').include;
exports.Rewriter = (function() {
return function Rewriter() {};
function Rewriter() {};
return Rewriter;
})();
exports.Rewriter.prototype.rewrite = function(_arg) {
this.tokens = _arg;

View File

@ -4,7 +4,7 @@
_ref = require('./helpers'), extend = _ref.extend, last = _ref.last;
exports.Scope = (function() {
Scope = (function() {
return function Scope(_arg, _arg2, _arg3) {
function Scope(_arg, _arg2, _arg3) {
this.method = _arg3;
this.expressions = _arg2;
this.parent = _arg;
@ -19,6 +19,7 @@
}
return this;
};
return Scope;
})();
Scope.root = null;
Scope.prototype.startLevel = function() {

View File

@ -998,8 +998,8 @@ exports.Code = class Code extends Base
(o.scope.parameter(param)) for param in params
o.indent = @idt 2 if @className
code = if @body.expressions.length then "\n#{ @body.compileWithDeclarations(o) }\n" else ''
open = if @className then "(function() {\n#{@idt(1)}return function #{@className}(" else "function("
close = if @className then "#{code and @idt(1)}};\n#{@tab}})()" else "#{code and @tab}}"
open = if @className then "(function() {\n#{@idt(1)}function #{@className}(" else "function("
close = if @className then "#{code and @idt(1)}};\n#{@idt(1)}return #{@className};\n#{@tab}})()" else "#{code and @tab}}"
func = "#{open}#{ params.join(', ') }) {#{code}#{close}"
o.scope.endLevel()
return "#{utility 'bind'}(#{func}, #{@context})" if @bound