Files
ystavakylaecard/sparks/assets/1.5.1/libraries/coffeescript/yy/Closure.php
Ismo Vuorinen 7e73994e40 Sparks: Assets, 1.5.1
http://getsparks.org/packages/assets/versions/HEAD/show

Creates our minified and combined .js and .css files
2013-07-11 07:46:29 +03:00

50 lines
1.2 KiB
PHP
Executable File

<?php
namespace CoffeeScript;
class yy_Closure
{
static function wrap($expressions, $statement = NULL, $no_return = FALSE)
{
if ($expressions->jumps())
{
return $expressions;
}
$func = yy('Code', array(), yy_Block::wrap(array($expressions)));
$args = array();
if (($mentions_args = $expressions->contains('yy_Closure::literal_args')) ||
$expressions->contains('yy_Closure::literal_this'))
{
$meth = yy('Literal', $mentions_args ? 'apply' : 'call');
$args = array(yy('Literal', 'this'));
if ($mentions_args)
{
$args[] = yy('Literal', 'arguments');
}
$func = yy('Value', $func, array(yy('Access', $meth)));
}
$func->no_return = $no_return;
$call = yy('Call', $func, $args);
return $statement ? yy_Block::wrap(array($call)) : $call;
}
static function literal_args($node)
{
return ($node instanceof yy_Literal) && (''.$node->value === 'arguments') && ! $node->as_key;
}
static function literal_this($node)
{
return (($node instanceof yy_Literal) && (''.$node->value === 'this') && ! $node->as_key) ||
($node instanceof yy_Code && $node->bound);
}
}
?>