automatic conversion of arguments into arrays

This commit is contained in:
Jeremy Ashkenas
2010-01-05 09:10:45 -05:00
parent 1ebc4d5f21
commit 5fe419b1ce
4 changed files with 16 additions and 1 deletions

View File

@@ -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