mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-17 19:11:22 -05:00
automatic conversion of arguments into arrays
This commit is contained in:
@@ -134,6 +134,10 @@ module CoffeeScript
|
||||
class LiteralNode < Node
|
||||
STATEMENTS = ['break', 'continue']
|
||||
|
||||
CONVERSIONS = {
|
||||
'arguments' => 'Array.prototype.slice.call(arguments, 0)'
|
||||
}
|
||||
|
||||
attr_reader :value
|
||||
|
||||
def initialize(value)
|
||||
@@ -146,9 +150,10 @@ module CoffeeScript
|
||||
alias_method :statement_only?, :statement?
|
||||
|
||||
def compile_node(o)
|
||||
val = CONVERSIONS[@value.to_s] || @value.to_s
|
||||
indent = statement? ? o[:indent] : ''
|
||||
ending = statement? ? ';' : ''
|
||||
write(indent + @value.to_s + ending)
|
||||
write("#{indent}#{val}#{ending}")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user