1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

merging tesco's branch for issue #535

This commit is contained in:
Jeremy Ashkenas 2010-07-28 07:34:28 -04:00
parent 9026069f79
commit a80d8d55c4
3 changed files with 19 additions and 9 deletions

View file

@ -971,7 +971,7 @@
_b = this.params;
for (i = 0, _c = _b.length; i < _c; i++) {
param = _b[i];
if (typeof splat !== "undefined" && splat !== null) {
if (splat) {
if (param.attach) {
param.assign = new AssignNode(new ValueNode(literal('this'), [new AccessorNode(param.value)]));
this.body.expressions.splice(splat.index + 1, 0, param.assign);

View file

@ -874,7 +874,7 @@ exports.CodeNode = class CodeNode extends BaseNode
splat = undefined
params = []
for param, i in @params
if splat?
if splat
if param.attach
param.assign = new AssignNode new ValueNode literal('this'), [new AccessorNode param.value]
@body.expressions.splice splat.index + 1, 0, param.assign
@ -922,9 +922,11 @@ exports.ParamNode = class ParamNode extends BaseNode
class: 'ParamNode'
children: ['name']
constructor: (@name, @attach, @splat) -> @value = literal @name
constructor: (@name, @attach, @splat) ->
@value = literal @name
compileNode: (o) -> @value.compile o
compileNode: (o) ->
@value.compile o
toString: (idt) ->
if @attach then (literal "@#@name").toString idt else @value.toString idt

View file

@ -33,3 +33,11 @@ ok context.arg is 3
((@arg...) ->).call context, 1, 2, 3
ok context.arg.join ' ' is '1 2 3'
class Klass
constructor: (@one, @two) ->
obj = new Klass 1, 2
ok obj.one is 1
ok obj.two is 2