Skip to content

Commit 15a045e

Browse files
Merge branch 'no-standalone-@'
2 parents eafd6b3 + 31ad76f commit 15a045e

11 files changed

+104
-118
lines changed

lib/parser.js

+63-77
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/compiler.coffee

+3-3
Original file line numberDiff line numberDiff line change
@@ -989,15 +989,15 @@ class exports.Compiler
989989
ancestry.unshift this
990990
children = {}
991991

992-
for childName in @childNodes when @[childName]?
992+
for childName in @childNodes when this[childName]?
993993
children[childName] =
994994
if childName in @listMembers
995-
for member in @[childName]
995+
for member in this[childName]
996996
jsNode = walk.call member, fn, inScope, ancestry
997997
inScope = union inScope, envEnrichments member, inScope
998998
jsNode
999999
else
1000-
child = @[childName]
1000+
child = this[childName]
10011001
jsNode = walk.call child, fn, inScope, ancestry
10021002
inScope = union inScope, envEnrichments child, inScope
10031003
jsNode

src/grammar.pegjs

+5-4
Original file line numberDiff line numberDiff line change
@@ -603,12 +603,15 @@ memberExpression
603603
return rp(new CS.NewOp(e, args));
604604
}
605605
memberAccess
606-
= e:( primaryExpression
606+
= e:
607+
( primaryExpression
607608
/ NEW __ e:memberExpression args:argumentList { return rp(new CS.NewOp(e, args.operands[0])); }
608609
) accesses:(argumentList MemberAccessOps / MemberAccessOps)+ {
609610
var acc = foldl(function(memo, a){ return memo.concat(a); }, [], accesses);
610611
return createMemberExpression(e, acc);
611612
}
613+
/ contextVar
614+
612615
MemberNames
613616
= identifierName
614617
MemberAccessOps
@@ -642,7 +645,7 @@ primaryExpression
642645
/ null
643646
/ undefined
644647
/ contextVar
645-
/ r:(THIS / "@") { return rp(new CS.This); }
648+
/ r:THIS { return rp(new CS.This); }
646649
/ identifier
647650
/ range
648651
/ arrayLiteral
@@ -1051,12 +1054,10 @@ unassignable = ("arguments" / "eval") !identifierPart
10511054
CompoundAssignable
10521055
= memberAccess
10531056
/ !unassignable i:identifier { return i; }
1054-
/ contextVar
10551057
ExistsAssignable = CompoundAssignable
10561058
Assignable
10571059
= memberAccess
10581060
/ !unassignable i:identifier { return i; }
1059-
/ contextVar
10601061
/ positionalDestructuring
10611062
/ namedDestructuring
10621063

src/helpers.coffee

+4-4
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,17 @@ envEnrichments_ = (inScope = []) ->
103103
nub concat [
104104
concatMap @childNodes, (child) =>
105105
if child in @listMembers
106-
then concatMap @[child], (m) -> envEnrichments m, inScope
107-
else envEnrichments @[child], inScope
106+
then concatMap this[child], (m) -> envEnrichments m, inScope
107+
else envEnrichments this[child], inScope
108108
beingDeclared @keyAssignee
109109
beingDeclared @valAssignee
110110
]
111111
when @instanceof CS.Functions then []
112112
else
113113
nub concatMap @childNodes, (child) =>
114114
if child in @listMembers
115-
then concatMap @[child], (m) -> envEnrichments m, inScope
116-
else envEnrichments @[child], inScope
115+
then concatMap this[child], (m) -> envEnrichments m, inScope
116+
else envEnrichments this[child], inScope
117117
difference possibilities, inScope
118118

119119
@envEnrichments = envEnrichments = (node, args...) ->

src/js-nodes.coffee

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exports = module?.exports ? this
44
createNode = (type, props) ->
55
class extends Nodes
66
constructor: ->
7-
@[prop] = arguments[i] for prop, i in props
7+
this[prop] = arguments[i] for prop, i in props
88
type: type
99
childNodes: props
1010

@@ -20,9 +20,9 @@ createNode = (type, props) ->
2020
obj.leadingComments = @leadingComments if @leadingComments?
2121
for child in @childNodes
2222
if child in @listMembers
23-
obj[child] = (p?.toBasicObject() for p in @[child])
23+
obj[child] = (p?.toBasicObject() for p in this[child])
2424
else
25-
obj[child] = @[child]?.toBasicObject()
25+
obj[child] = this[child]?.toBasicObject()
2626
if @line? and @column?
2727
obj.loc = start: {@line, @column}
2828
if @offset?
@@ -100,7 +100,7 @@ handlePrimitives = (ctor, primitives) ->
100100
ctor::toBasicObject = ->
101101
obj = Nodes::toBasicObject.call this
102102
for primitive in primitives
103-
obj[primitive] = @[primitive]
103+
obj[primitive] = this[primitive]
104104
obj
105105

106106
handlePrimitives AssignmentExpression, ['operator']

src/nodes.coffee

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ createNodes = (subclasses, superclasses = []) ->
2121
if isCategory then ->
2222
else ->
2323
for param, i in params
24-
@[param] = arguments[i]
24+
this[param] = arguments[i]
2525
if @initialise?
2626
@initialise.apply this, arguments
2727
this
@@ -222,16 +222,16 @@ Nodes::toBasicObject = ->
222222
]
223223
for child in @childNodes
224224
if child in @listMembers
225-
obj[child] = (p.toBasicObject() for p in @[child])
225+
obj[child] = (p.toBasicObject() for p in this[child])
226226
else
227-
obj[child] = if @[child]? then @[child].toBasicObject()
227+
obj[child] = if this[child]? then this[child].toBasicObject()
228228
obj
229229
Nodes::fold = (memo, fn) ->
230230
for child in @childNodes
231231
if child in @listMembers
232-
memo = (p.fold memo, fn for p in @[child])
232+
memo = (p.fold memo, fn for p in this[child])
233233
else
234-
memo = @[child].fold memo, fn
234+
memo = this[child].fold memo, fn
235235
fn memo, this
236236
Nodes::clone = ->
237237
ctor = ->
@@ -260,7 +260,7 @@ handlePrimitives = (ctor, primitives...) ->
260260
ctor::toBasicObject = ->
261261
obj = Nodes::toBasicObject.call this
262262
for primitive in primitives
263-
obj[primitive] = @[primitive]
263+
obj[primitive] = this[primitive]
264264
obj
265265

266266
handlePrimitives Class, 'boundMembers'

src/optimiser.coffee

+9-9
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ mayHaveSideEffects =
141141
], (inScope) ->
142142
any @childNodes, (child) =>
143143
if child in @listMembers
144-
then any @[child], (m) -> mayHaveSideEffects m, inScope
145-
else mayHaveSideEffects @[child], inScope
144+
then any this[child], (m) -> mayHaveSideEffects m, inScope
145+
else mayHaveSideEffects this[child], inScope
146146

147147

148148

@@ -355,19 +355,19 @@ class exports.Optimiser
355355

356356
walk = (fn, inScope = [], ancestry = []) ->
357357
ancestry.unshift this
358-
for childName in @childNodes when @[childName]?
358+
for childName in @childNodes when this[childName]?
359359
if childName in @listMembers
360-
for member, n in @[childName]
361-
while @[childName][n] isnt walk.call (@[childName][n] = fn.call @[childName][n], {inScope, ancestry}), fn, inScope, ancestry then
362-
inScope = union inScope, envEnrichments @[childName][n], inScope
360+
for member, n in this[childName]
361+
while this[childName][n] isnt walk.call (this[childName][n] = fn.call this[childName][n], {inScope, ancestry}), fn, inScope, ancestry then
362+
inScope = union inScope, envEnrichments this[childName][n], inScope
363363
else
364-
while @[childName] isnt walk.call (@[childName] = fn.call @[childName], {inScope, ancestry}), fn, inScope, ancestry then
365-
inScope = union inScope, envEnrichments @[childName], inScope
364+
while this[childName] isnt walk.call (this[childName] = fn.call this[childName], {inScope, ancestry}), fn, inScope, ancestry then
365+
inScope = union inScope, envEnrichments this[childName], inScope
366366
do ancestry.shift
367367
replacementNode = fn.call this, {inScope, ancestry}
368368
if this isnt replacementNode
369369
while replacementNode isnt walk.call (replacementNode = fn.call replacementNode, {inScope, ancestry}), fn, inScope, ancestry then
370-
replacementNode[p] = @[p] for p in ['raw', 'line', 'column', 'offset']
370+
replacementNode[p] = this[p] for p in ['raw', 'line', 'column', 'offset']
371371
replacementNode
372372

373373
(ast) ->

test/classes.coffee

+4-4
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,11 @@ suite 'Classes', ->
165165

166166
class Base
167167
@attr = (name) ->
168-
@::[name] = (val) ->
168+
this::[name] = (val) ->
169169
if arguments.length > 0
170-
@["_#{name}"] = val
170+
this["_#{name}"] = val
171171
else
172-
@["_#{name}"]
172+
this["_#{name}"]
173173

174174
class Robot extends Base
175175
@attr 'power'
@@ -406,7 +406,7 @@ suite 'Classes', ->
406406

407407
class ClassName
408408
amI: ->
409-
@ instanceof ClassName
409+
this instanceof ClassName
410410

411411
obj = new ClassName
412412
ok obj.amI()

0 commit comments

Comments
 (0)