fixing mentionsArgs for accesses.

This commit is contained in:
Jeremy Ashkenas 2010-12-23 12:00:23 -08:00
parent 9395d58669
commit 97a29f9c50
3 changed files with 16 additions and 5 deletions

View File

@ -696,6 +696,7 @@
__extends(Access, Base);
function Access(name, tag) {
this.name = name;
this.name.accessed = true;
this.proto = tag === 'proto' ? '.prototype' : '';
this.soak = tag === 'soak';
}
@ -2121,10 +2122,10 @@
}
},
literalArgs: function(node) {
return node instanceof Literal && node.value === 'arguments';
return node instanceof Literal && node.value === 'arguments' && !node.accessed;
},
literalThis: function(node) {
return node instanceof Literal && node.value === 'this' || node instanceof Code && node.bound;
return (node instanceof Literal && node.value === 'this' && !node.accessed) || (node instanceof Code && node.bound);
}
};
unfoldSoak = function(o, parent, name) {

View File

@ -557,6 +557,7 @@ exports.Extends = class Extends extends Base
# an access into the object's prototype.
exports.Access = class Access extends Base
constructor: (@name, tag) ->
@name.accessed = yes
@proto = if tag is 'proto' then '.prototype' else ''
@soak = tag is 'soak'
@ -1671,9 +1672,11 @@ Closure =
call = new Call func, args
if statement then Expressions.wrap [call] else call
literalArgs: (node) -> node instanceof Literal and node.value is 'arguments'
literalThis: (node) -> node instanceof Literal and node.value is 'this' or
node instanceof Code and node.bound
literalArgs: (node) ->
node instanceof Literal and node.value is 'arguments' and not node.accessed
literalThis: (node) ->
(node instanceof Literal and node.value is 'this' and not node.accessed) or
(node instanceof Code and node.bound)
# Unfold a node's child if soak, then tuck the node under created `If`
unfoldSoak = (o, parent, name) ->

View File

@ -293,3 +293,10 @@ a = 0
for f in [-> a = 1] -> f()
eq a, 1
# Comprehensions that mention arguments.
list = [arguments: 10]
args = for f in list -> f.arguments
eq args[0], 10