removing arguments as a keyword -- we can detect its use at code-generation time.

This commit is contained in:
Jeremy Ashkenas
2010-02-05 22:01:11 -05:00
parent dc7d0f1568
commit b795ae7fe1
6 changed files with 1385 additions and 1400 deletions

View File

@@ -153,7 +153,7 @@ module CoffeeScript
# at the top.
def compile_with_declarations(o={})
code = compile_node(o)
args = self.contains? {|n| n.is_a?(LiteralNode) && n.arguments? }
args = self.contains? {|n| n.is_a?(ValueNode) && n.arguments? }
argv = args && o[:scope].check('arguments') ? '' : 'var '
code = "#{idt}#{argv}arguments = Array.prototype.slice.call(arguments, 0);\n#{code}" if args
code = "#{idt}var #{o[:scope].compiled_assignments};\n#{code}" if o[:scope].assignments?(self)
@@ -203,10 +203,6 @@ module CoffeeScript
end
alias_method :statement_only?, :statement?
def arguments?
@value.to_s == 'arguments'
end
def compile_node(o)
indent = statement? ? idt : ''
ending = statement? ? ';' : ''
@@ -361,6 +357,10 @@ module CoffeeScript
properties? && @properties.last.is_a?(SliceNode)
end
def arguments?
@base.to_s == 'arguments'
end
def unwrap
@properties.empty? ? @base : self
end