From f3a1f466793ede9da1fe164111d482831392270c Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Wed, 11 Apr 2012 12:14:44 -0400 Subject: [PATCH] fixes #2052: don't manually assign constructors' `name` property I'm not sure how we would test this, so... no tests. --- lib/coffee-script/lexer.js | 2 -- lib/coffee-script/nodes.js | 61 ----------------------------------- lib/coffee-script/optparse.js | 2 -- lib/coffee-script/rewriter.js | 2 -- lib/coffee-script/scope.js | 2 -- src/nodes.coffee | 2 -- 6 files changed, 71 deletions(-) diff --git a/lib/coffee-script/lexer.js b/lib/coffee-script/lexer.js index 8aa30db7..e5fb6f40 100644 --- a/lib/coffee-script/lexer.js +++ b/lib/coffee-script/lexer.js @@ -9,8 +9,6 @@ exports.Lexer = Lexer = (function() { - Lexer.name = 'Lexer'; - function Lexer() {} Lexer.prototype.tokenize = function(code, opts) { diff --git a/lib/coffee-script/nodes.js b/lib/coffee-script/nodes.js index ba27f9bb..e339b7ae 100644 --- a/lib/coffee-script/nodes.js +++ b/lib/coffee-script/nodes.js @@ -32,8 +32,6 @@ exports.Base = Base = (function() { - Base.name = 'Base'; - function Base() {} Base.prototype.compile = function(o, lvl) { @@ -210,8 +208,6 @@ __extends(Block, _super); - Block.name = 'Block'; - function Block(nodes) { this.expressions = compact(flatten(nodes || [])); } @@ -432,8 +428,6 @@ __extends(Literal, _super); - Literal.name = 'Literal'; - function Literal(value) { this.value = value; } @@ -492,8 +486,6 @@ __extends(Return, _super); - Return.name = 'Return'; - function Return(expr) { if (expr && !expr.unwrap().isUndefined) { this.expression = expr; @@ -530,8 +522,6 @@ __extends(Value, _super); - Value.name = 'Value'; - function Value(base, props, tag) { if (!props && base instanceof Value) { return base; @@ -698,8 +688,6 @@ __extends(Comment, _super); - Comment.name = 'Comment'; - function Comment(comment) { this.comment = comment; } @@ -725,8 +713,6 @@ __extends(Call, _super); - Call.name = 'Call'; - function Call(variable, args, soak) { this.args = args != null ? args : []; this.soak = soak; @@ -912,8 +898,6 @@ __extends(Extends, _super); - Extends.name = 'Extends'; - function Extends(child, parent) { this.child = child; this.parent = parent; @@ -933,8 +917,6 @@ __extends(Access, _super); - Access.name = 'Access'; - function Access(name, tag) { this.name = name; this.name.asKey = true; @@ -963,8 +945,6 @@ __extends(Index, _super); - Index.name = 'Index'; - function Index(index) { this.index = index; } @@ -987,8 +967,6 @@ __extends(Range, _super); - Range.name = 'Range'; - Range.prototype.children = ['from', 'to']; function Range(from, to, tag) { @@ -1090,8 +1068,6 @@ __extends(Slice, _super); - Slice.name = 'Slice'; - Slice.prototype.children = ['range']; function Slice(range) { @@ -1118,8 +1094,6 @@ __extends(Obj, _super); - Obj.name = 'Obj'; - function Obj(props, generated) { this.generated = generated != null ? generated : false; this.objects = this.properties = props || []; @@ -1207,8 +1181,6 @@ __extends(Arr, _super); - Arr.name = 'Arr'; - function Arr(objs) { this.objects = objs || []; } @@ -1263,8 +1235,6 @@ __extends(Class, _super); - Class.name = 'Class'; - function Class(variable, parent, body) { this.variable = variable; this.parent = parent; @@ -1426,9 +1396,6 @@ if (!(this.ctor instanceof Code)) { this.body.expressions.unshift(this.ctor); } - if (decl) { - this.body.expressions.unshift(new Assign(new Value(new Literal(name), [new Access(new Literal('name'))]), new Literal("'" + name + "'"))); - } this.body.expressions.push(lname); (_ref2 = this.body.expressions).unshift.apply(_ref2, this.directives); this.addBoundFunctions(o); @@ -1455,8 +1422,6 @@ __extends(Assign, _super); - Assign.name = 'Assign'; - function Assign(variable, value, context, options) { var forbidden, name, _ref2; this.variable = variable; @@ -1677,8 +1642,6 @@ __extends(Code, _super); - Code.name = 'Code'; - function Code(params, body, tag) { this.params = params || []; this.body = body || new Block; @@ -1835,8 +1798,6 @@ __extends(Param, _super); - Param.name = 'Param'; - function Param(name, value, splat) { var _ref2; this.name = name; @@ -1923,8 +1884,6 @@ __extends(Splat, _super); - Splat.name = 'Splat'; - Splat.prototype.children = ['name']; Splat.prototype.isAssignable = YES; @@ -1995,8 +1954,6 @@ __extends(While, _super); - While.name = 'While'; - function While(condition, options) { this.condition = (options != null ? options.invert : void 0) ? condition.invert() : condition; this.guard = options != null ? options.guard : void 0; @@ -2078,8 +2035,6 @@ __extends(Op, _super); - Op.name = 'Op'; - function Op(op, first, second, flip) { if (op === 'in') { return new In(first, second); @@ -2272,8 +2227,6 @@ __extends(In, _super); - In.name = 'In'; - function In(object, array) { this.object = object; this.array = array; @@ -2354,8 +2307,6 @@ __extends(Try, _super); - Try.name = 'Try'; - function Try(attempt, error, recovery, ensure) { this.attempt = attempt; this.error = error; @@ -2413,8 +2364,6 @@ __extends(Throw, _super); - Throw.name = 'Throw'; - function Throw(expression) { this.expression = expression; } @@ -2439,8 +2388,6 @@ __extends(Existence, _super); - Existence.name = 'Existence'; - function Existence(expression) { this.expression = expression; } @@ -2474,8 +2421,6 @@ __extends(Parens, _super); - Parens.name = 'Parens'; - function Parens(body) { this.body = body; } @@ -2514,8 +2459,6 @@ __extends(For, _super); - For.name = 'For'; - function For(body, source) { var _ref2; this.source = source.source, this.guard = source.guard, this.step = source.step, this.name = source.name, this.index = source.index; @@ -2673,8 +2616,6 @@ __extends(Switch, _super); - Switch.name = 'Switch'; - function Switch(subject, cases, otherwise) { this.subject = subject; this.cases = cases; @@ -2760,8 +2701,6 @@ __extends(If, _super); - If.name = 'If'; - function If(condition, body, options) { this.body = body; if (options == null) { diff --git a/lib/coffee-script/optparse.js b/lib/coffee-script/optparse.js index 468b061a..288cffb5 100644 --- a/lib/coffee-script/optparse.js +++ b/lib/coffee-script/optparse.js @@ -4,8 +4,6 @@ exports.OptionParser = OptionParser = (function() { - OptionParser.name = 'OptionParser'; - function OptionParser(rules, banner) { this.banner = banner; this.rules = buildRules(rules); diff --git a/lib/coffee-script/rewriter.js b/lib/coffee-script/rewriter.js index 2a0c5504..0ec21052 100644 --- a/lib/coffee-script/rewriter.js +++ b/lib/coffee-script/rewriter.js @@ -6,8 +6,6 @@ exports.Rewriter = (function() { - Rewriter.name = 'Rewriter'; - function Rewriter() {} Rewriter.prototype.rewrite = function(tokens) { diff --git a/lib/coffee-script/scope.js b/lib/coffee-script/scope.js index 8837f41b..8b135437 100644 --- a/lib/coffee-script/scope.js +++ b/lib/coffee-script/scope.js @@ -6,8 +6,6 @@ exports.Scope = Scope = (function() { - Scope.name = 'Scope'; - Scope.root = null; function Scope(parent, expressions, method) { diff --git a/src/nodes.coffee b/src/nodes.coffee index c30db3d4..9e90ddf7 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -966,8 +966,6 @@ exports.Class = class Class extends Base @ensureConstructor name @body.spaced = yes @body.expressions.unshift @ctor unless @ctor instanceof Code - if decl - @body.expressions.unshift new Assign (new Value (new Literal name), [new Access new Literal 'name']), (new Literal "'#{name}'") @body.expressions.push lname @body.expressions.unshift @directives... @addBoundFunctions o