raising the precedence level of delete, instanceof, and typeof

This commit is contained in:
Jeremy Ashkenas
2010-02-09 22:20:04 -05:00
parent 8e3e06a6e9
commit 9339058fc3
7 changed files with 722 additions and 657 deletions

View File

@@ -742,7 +742,41 @@ WhileNode: exports.WhileNode: inherit Node, {
statement WhileNode
# Simple Arithmetic and logical operations. Performs some conversion from
# CoffeeScript operations into their JavaScript equivalents.
OpNode: exports.OpNode: inherit Node, {
CONVERSIONS: {
'==': '==='
'!=': '!=='
'and': '&&'
'or': '||'
'is': '==='
'isnt': '!=='
'not': '!'
}
CHAINABLE: ['<', '>', '>=', '<=', '===', '!==']
ASSIGNMENT: ['||=', '&&=', '?=']
PREFIX_OPERATORS: ['typeof', 'delete']
constructor: (operator, first, second, flip) ->
@children: [@first: first, @second: second]
@operator: @CONVERSIONS[operator] or operator
@flip: !!flip
this
is_unary: ->
not @second
is_chainable: ->
@CHAINABLE.indexOf(@operator) >= 0
compile_node: (o) ->
return @compile_chain(o) if @is_chainable() and (@first.unwrap() instanceof OpNode) and @first.unwrap().is_chainable()
}