Files
ystavakylaecard/sparks/assets/1.5.1/libraries/coffeescript/yy/Splat.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

101 lines
1.7 KiB
PHP
Executable File

<?php
namespace CoffeeScript;
class yy_Splat extends yy_Base
{
public $children = array('name');
static function compile_splatted_array($options, $list, $apply = FALSE)
{
$index = -1;
while (isset($list[++$index]) && ($node = $list[$index]) && ! ($node instanceof yy_Splat))
{
continue;
}
if ($index >= count($list))
{
return '';
}
if (count($list) === 1)
{
$code = $list[0]->compile($options, LEVEL_LIST);
if ($apply)
{
return $code;
}
return utility('slice').".call({$code})";
}
$args = array_slice($list, $index);
foreach ($args as $i => $node)
{
$code = $node->compile($options, LEVEL_LIST);
$args[$i] = ($node instanceof yy_Splat) ? utility('slice').".call({$code})" : "[{$code}]";
}
if ($index === 0)
{
return $args[0].'.concat('.implode(', ', array_slice($args, 1)).')';
}
$base = array();
foreach (array_slice($list, 0, $index) as $node)
{
$base[] = $node->compile($options, LEVEL_LIST);
}
return '['.implode(', ', $base).'].concat('.implode(', ', $args).')';
}
function constructor($name)
{
if (is_object($name))
{
$this->name = $name;
}
else
{
$this->name = yy('Literal', $name);
}
return $this;
}
function assigns($name)
{
return $this->name->assigns($name);
}
function compile($options)
{
if (isset($this->index) && $this->index)
{
return $this->compile_param($options);
}
else
{
return $this->name->compile($options);
}
}
function is_assignable()
{
return TRUE;
}
function unwrap()
{
return $this->name;
}
}
?>