mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 11:31:20 -05:00
adding @property for this.property
This commit is contained in:
@@ -72,6 +72,12 @@
|
|||||||
<key>name</key>
|
<key>name</key>
|
||||||
<string>constant.numeric.coffee</string>
|
<string>constant.numeric.coffee</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>match</key>
|
||||||
|
<string>(@)[a-zA-Z_$]\w*</string>
|
||||||
|
<key>name</key>
|
||||||
|
<string>variable.other.readwrite.instance.coffee</string>
|
||||||
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
<key>name</key>
|
<key>name</key>
|
||||||
<string>string.quoted.heredoc.coffee</string>
|
<string>string.quoted.heredoc.coffee</string>
|
||||||
|
|||||||
@@ -238,6 +238,7 @@ rule
|
|||||||
| Object { result = ValueNode.new(val[0]) }
|
| Object { result = ValueNode.new(val[0]) }
|
||||||
| Parenthetical { result = ValueNode.new(val[0]) }
|
| Parenthetical { result = ValueNode.new(val[0]) }
|
||||||
| Range { result = ValueNode.new(val[0]) }
|
| Range { result = ValueNode.new(val[0]) }
|
||||||
|
| This { result = ValueNode.new(val[0]) }
|
||||||
| Value Accessor { result = val[0] << val[1] }
|
| Value Accessor { result = val[0] << val[1] }
|
||||||
| Invocation Accessor { result = ValueNode.new(val[0], [val[1]]) }
|
| Invocation Accessor { result = ValueNode.new(val[0], [val[1]]) }
|
||||||
;
|
;
|
||||||
@@ -300,6 +301,12 @@ rule
|
|||||||
SUPER CALL_START ArgList CALL_END { result = CallNode.new(Value.new('super'), val[2]) }
|
SUPER CALL_START ArgList CALL_END { result = CallNode.new(Value.new('super'), val[2]) }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
# This references, either naked or to a property.
|
||||||
|
This:
|
||||||
|
'@' { result = ThisNode.new }
|
||||||
|
| '@' IDENTIFIER { result = ThisNode.new(val[1]) }
|
||||||
|
;
|
||||||
|
|
||||||
# The range literal.
|
# The range literal.
|
||||||
Range:
|
Range:
|
||||||
"[" Expression
|
"[" Expression
|
||||||
|
|||||||
@@ -429,6 +429,18 @@ module CoffeeScript
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# A this-reference, using '@'.
|
||||||
|
class ThisNode < Node
|
||||||
|
def initialize(property=nil)
|
||||||
|
@property = property
|
||||||
|
end
|
||||||
|
|
||||||
|
def compile_node(o)
|
||||||
|
prop = @property ? ".#{@property}" : ''
|
||||||
|
write("this#{prop}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# A range literal. Ranges can be used to extract portions (slices) of arrays,
|
# A range literal. Ranges can be used to extract portions (slices) of arrays,
|
||||||
# or to specify a range for array comprehensions.
|
# or to specify a range for array comprehensions.
|
||||||
class RangeNode < Node
|
class RangeNode < Node
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
13
test/fixtures/execution/test_literals.coffee
vendored
13
test/fixtures/execution/test_literals.coffee
vendored
@@ -34,4 +34,15 @@ print i is 0
|
|||||||
|
|
||||||
money$: 'dollars'
|
money$: 'dollars'
|
||||||
|
|
||||||
print money$ is 'dollars'
|
print money$ is 'dollars'
|
||||||
|
|
||||||
|
|
||||||
|
bob: {
|
||||||
|
name: 'Bob'
|
||||||
|
greet: (salutation) ->
|
||||||
|
salutation + " " + @name
|
||||||
|
hello: ->
|
||||||
|
@greet("Hello")
|
||||||
|
}
|
||||||
|
|
||||||
|
print bob.hello() is "Hello Bob"
|
||||||
|
|||||||
Reference in New Issue
Block a user