mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-17 11:01:25 -05:00
raising the precedence level of delete, instanceof, and typeof
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
(function(){
|
||||
var AccessorNode, ArrayNode, AssignNode, CallNode, ClosureNode, CodeNode, CommentNode, Expressions, ExtendsNode, IndexNode, LiteralNode, Node, ObjectNode, PushNode, RangeNode, ReturnNode, SliceNode, SplatNode, TAB, TRAILING_WHITESPACE, ThisNode, ValueNode, WhileNode, any, compact, del, dup, flatten, inherit, merge, statement;
|
||||
var AccessorNode, ArrayNode, AssignNode, CallNode, ClosureNode, CodeNode, CommentNode, Expressions, ExtendsNode, IndexNode, LiteralNode, Node, ObjectNode, OpNode, PushNode, RangeNode, ReturnNode, SliceNode, SplatNode, TAB, TRAILING_WHITESPACE, ThisNode, ValueNode, WhileNode, any, compact, del, dup, flatten, inherit, merge, statement;
|
||||
var __hasProp = Object.prototype.hasOwnProperty;
|
||||
process.mixin(require('./scope'));
|
||||
// The abstract base class for all CoffeeScript nodes.
|
||||
@@ -1030,4 +1030,37 @@
|
||||
}
|
||||
}));
|
||||
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: function constructor(operator, first, second, flip) {
|
||||
this.children = [(this.first = first), (this.second = second)];
|
||||
this.operator = this.CONVERSIONS[operator] || operator;
|
||||
this.flip = !!flip;
|
||||
return this;
|
||||
},
|
||||
is_unary: function is_unary() {
|
||||
return !this.second;
|
||||
},
|
||||
is_chainable: function is_chainable() {
|
||||
return this.CHAINABLE.indexOf(this.operator) >= 0;
|
||||
},
|
||||
compile_node: function compile_node(o) {
|
||||
if (this.is_chainable() && (this.first.unwrap() instanceof OpNode) && this.first.unwrap().is_chainable()) {
|
||||
return this.compile_chain(o);
|
||||
}
|
||||
}
|
||||
}));
|
||||
})();
|
||||
Reference in New Issue
Block a user