added the typeof operater as an OpNode

This commit is contained in:
Jeremy Ashkenas
2009-12-24 11:50:44 -08:00
parent 5d1ec9d2a9
commit 7f502543d2
5 changed files with 12 additions and 10 deletions

View File

@@ -342,7 +342,8 @@ module CoffeeScript
"aint" => "!==",
'not' => '!',
}
CONDITIONALS = ['||:', '&&:']
CONDITIONALS = ['||:', '&&:']
PREFIX_OPERATORS = ['typeof', 'delete']
attr_reader :operator, :first, :second
@@ -369,7 +370,7 @@ module CoffeeScript
end
def compile_unary(o)
space = @operator.to_s == 'delete' ? ' ' : ''
space = PREFIX_OPERATORS.include?(@operator.to_s) ? ' ' : ''
parts = [@operator.to_s, space, @first.compile(o)]
parts.reverse! if @flip
parts.join('')