merging master

This commit is contained in:
Jeremy Ashkenas 2010-02-05 22:02:11 -05:00
commit 96eb7e2339
6 changed files with 1390 additions and 1404 deletions

View File

@ -13,7 +13,6 @@ token FOR IN OF BY WHEN WHILE
token SWITCH LEADING_WHEN
token DELETE INSTANCEOF TYPEOF
token SUPER EXTENDS
token ARGUMENTS
token NEWLINE
token COMMENT
token JS
@ -98,7 +97,6 @@ rule
| REGEX { result = LiteralNode.new(val[0]) }
| BREAK { result = LiteralNode.new(val[0]) }
| CONTINUE { result = LiteralNode.new(val[0]) }
| ARGUMENTS { result = LiteralNode.new(val[0]) }
| TRUE { result = LiteralNode.new(Value.new(true)) }
| FALSE { result = LiteralNode.new(Value.new(false)) }
| YES { result = LiteralNode.new(Value.new(true)) }

View File

@ -15,8 +15,7 @@ module CoffeeScript
"for", "in", "of", "by", "where", "while",
"delete", "instanceof", "typeof",
"switch", "when",
"super", "extends",
"arguments"]
"super", "extends"]
# Token matching regexes.
IDENTIFIER = /\A([a-zA-Z$_](\w|\$)*)/

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

File diff suppressed because it is too large Load Diff

View File

@ -22,9 +22,9 @@ module CoffeeScript
IMPLICIT_FUNC = [:IDENTIFIER, :SUPER, ')', :CALL_END, ']', :INDEX_END]
IMPLICIT_END = [:IF, :UNLESS, :FOR, :WHILE, "\n", :OUTDENT]
IMPLICIT_CALL = [:IDENTIFIER, :NUMBER, :STRING, :JS, :REGEX, :NEW, :PARAM_START,
:TRY, :DELETE, :TYPEOF, :SWITCH, :ARGUMENTS,
:TRY, :DELETE, :TYPEOF, :SWITCH,
:TRUE, :FALSE, :YES, :NO, :ON, :OFF, '!', '!!', :NOT,
'->', '=>', '[', '(', '{']
'@', '->', '=>', '[', '(', '{']
# The inverse mappings of token pairs we're trying to fix up.
INVERSES = BALANCED_PAIRS.inject({}) do |memo, pair|

View File

@ -30,3 +30,8 @@ func: ->
arguments
puts func(100) is 25
# Arguments can be accessed as a property.
this.arguments: 10
puts @arguments is 10