mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 11:31:20 -05:00
merged in master branch again
This commit is contained in:
@@ -20,9 +20,7 @@ checkForErrors: coffeeProcess =>
|
|||||||
# Run a simple REPL, round-tripping to the CoffeeScript compiler for every
|
# Run a simple REPL, round-tripping to the CoffeeScript compiler for every
|
||||||
# command.
|
# command.
|
||||||
exports.run: args =>
|
exports.run: args =>
|
||||||
if args.length
|
return true if args.length
|
||||||
exports.evalCS(File.read(path)) for path in args
|
|
||||||
return true
|
|
||||||
|
|
||||||
while true
|
while true
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -18,15 +18,8 @@
|
|||||||
// Run a simple REPL, round-tripping to the CoffeeScript compiler for every
|
// Run a simple REPL, round-tripping to the CoffeeScript compiler for every
|
||||||
// command.
|
// command.
|
||||||
exports.run = function(args) {
|
exports.run = function(args) {
|
||||||
var __a, __b, __c, __d, path, result;
|
var result;
|
||||||
if (args.length) {
|
if (args.length) {
|
||||||
__a = args;
|
|
||||||
__d = [];
|
|
||||||
for (__b=0, __c=__a.length; __b<__c; __b++) {
|
|
||||||
path = __a[__b];
|
|
||||||
__d[__b] = exports.evalCS(File.read(path));
|
|
||||||
}
|
|
||||||
__d;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|||||||
@@ -390,22 +390,22 @@ module CoffeeScript
|
|||||||
# CoffeeScript operations into their JavaScript equivalents.
|
# CoffeeScript operations into their JavaScript equivalents.
|
||||||
class OpNode < Node
|
class OpNode < Node
|
||||||
CONVERSIONS = {
|
CONVERSIONS = {
|
||||||
"==" => "===",
|
:== => "===",
|
||||||
"!=" => "!==",
|
:'!=' => "!==",
|
||||||
'and' => '&&',
|
:and => '&&',
|
||||||
'or' => '||',
|
:or => '||',
|
||||||
'is' => '===',
|
:is => '===',
|
||||||
"isnt" => "!==",
|
:isnt => "!==",
|
||||||
'not' => '!'
|
:not => '!'
|
||||||
}
|
}
|
||||||
CONDITIONALS = ['||=', '&&=']
|
CONDITIONALS = [:'||=', :'&&=']
|
||||||
PREFIX_OPERATORS = ['typeof', 'delete']
|
PREFIX_OPERATORS = [:typeof, :delete]
|
||||||
|
|
||||||
attr_reader :operator, :first, :second
|
attr_reader :operator, :first, :second
|
||||||
|
|
||||||
def initialize(operator, first, second=nil, flip=false)
|
def initialize(operator, first, second=nil, flip=false)
|
||||||
@first, @second, @flip = first, second, flip
|
@first, @second, @flip = first, second, flip
|
||||||
@operator = CONVERSIONS[operator] || operator
|
@operator = CONVERSIONS[operator.to_sym] || operator
|
||||||
end
|
end
|
||||||
|
|
||||||
def unary?
|
def unary?
|
||||||
@@ -414,7 +414,7 @@ module CoffeeScript
|
|||||||
|
|
||||||
def compile(o={})
|
def compile(o={})
|
||||||
o = super(o)
|
o = super(o)
|
||||||
return write(compile_conditional(o)) if CONDITIONALS.include?(@operator)
|
return write(compile_conditional(o)) if CONDITIONALS.include?(@operator.to_sym)
|
||||||
return write(compile_unary(o)) if unary?
|
return write(compile_unary(o)) if unary?
|
||||||
write("#{@first.compile(o)} #{@operator} #{@second.compile(o)}")
|
write("#{@first.compile(o)} #{@operator} #{@second.compile(o)}")
|
||||||
end
|
end
|
||||||
@@ -426,7 +426,7 @@ module CoffeeScript
|
|||||||
end
|
end
|
||||||
|
|
||||||
def compile_unary(o)
|
def compile_unary(o)
|
||||||
space = PREFIX_OPERATORS.include?(@operator.to_s) ? ' ' : ''
|
space = PREFIX_OPERATORS.include?(@operator.to_sym) ? ' ' : ''
|
||||||
parts = [@operator.to_s, space, @first.compile(o)]
|
parts = [@operator.to_s, space, @first.compile(o)]
|
||||||
parts.reverse! if @flip
|
parts.reverse! if @flip
|
||||||
parts.join('')
|
parts.join('')
|
||||||
|
|||||||
Reference in New Issue
Block a user