diff --git a/lib/nodes.js b/lib/nodes.js index 9eb506bbb0..6f6736c70d 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -1,5 +1,5 @@ (function() { - var Access, Arr, Assign, Base, Block, Call, Class, Closure, Code, Comment, Existence, Extends, For, IDENTIFIER, IS_STRING, If, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, NEGATE, NO, Obj, Op, Param, Parens, Push, Range, Return, SIMPLENUM, Scope, Slice, Splat, Switch, TAB, THIS, Throw, Try, UTILITIES, Value, While, YES, compact, del, ends, extend, flatten, last, merge, multident, starts, unfoldSoak, utility, _ref; + var Access, Arr, Assign, Base, Block, Call, Class, Closure, Code, Comment, Existence, Extends, For, IDENTIFIER, IS_STRING, If, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, METHOD_DEF, NEGATE, NO, Obj, Op, Param, Parens, Push, Range, Return, SIMPLENUM, Scope, Slice, Splat, Switch, TAB, THIS, Throw, Try, UTILITIES, Value, While, YES, compact, del, ends, extend, flatten, last, merge, multident, starts, unfoldSoak, utility, _ref; var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } @@ -1132,7 +1132,6 @@ this.context = context; this.param = options && options.param; } - Assign.prototype.METHOD_DEF = /^(?:(\S+)\.prototype\.|\S+?)?\b([$A-Za-z_][$\w\x7f-\uffff]*)$/; Assign.prototype.children = ['variable', 'value']; Assign.prototype.assigns = function(name) { return this[this.context === 'object' ? 'value' : 'variable'].assigns(name); @@ -1164,7 +1163,7 @@ o.scope.find(name); } } - if (this.value instanceof Code && (match = this.METHOD_DEF.exec(name))) { + if (this.value instanceof Code && (match = METHOD_DEF.exec(name))) { this.value.name = match[2]; if (match[1]) { this.value.klass = match[1]; @@ -2258,6 +2257,7 @@ TAB = ' '; IDENTIFIER = /^[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*$/; SIMPLENUM = /^[+-]?\d+$/; + METHOD_DEF = /^(?:([$A-Za-z_][$\w\x7f-\uffff]*)\.prototype\.)?([$A-Za-z_][$\w\x7f-\uffff]*)$/; IS_STRING = /^['"]/; utility = function(name) { var ref; diff --git a/src/nodes.coffee b/src/nodes.coffee index 5dd8299e1b..9ab7d271e5 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -907,9 +907,6 @@ exports.Assign = class Assign extends Base constructor: (@variable, @value, @context, options) -> @param = options and options.param - # Matchers for detecting class/method names - METHOD_DEF: /^(?:(\S+)\.prototype\.|\S+?)?\b([$A-Za-z_][$\w\x7f-\uffff]*)$/ - children: ['variable', 'value'] assigns: (name) -> @@ -935,7 +932,7 @@ exports.Assign = class Assign extends Base o.scope.add name, 'var' else o.scope.find name - if @value instanceof Code and match = @METHOD_DEF.exec name + if @value instanceof Code and match = METHOD_DEF.exec name @value.name = match[2] @value.klass = match[1] if match[1] val = @value.compile o, LEVEL_LIST @@ -1802,6 +1799,7 @@ TAB = ' ' IDENTIFIER = /^[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*$/ SIMPLENUM = /^[+-]?\d+$/ +METHOD_DEF = /^(?:([$A-Za-z_][$\w\x7f-\uffff]*)\.prototype\.)?([$A-Za-z_][$\w\x7f-\uffff]*)$/ # Is a literal value a string? IS_STRING = /^['"]/