Files
ystavakylaecard/sparks/assets/1.5.1/libraries/coffeescript/yy/Slice.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
962 B
PHP
Executable File

<?php
namespace CoffeeScript;
class yy_Slice extends yy_Base
{
public $children = array('range');
function constructor($range)
{
parent::constructor();
$this->range = $range;
return $this;
}
function compile_node($options)
{
$to = $this->range->to;
$from = $this->range->from;
$from_str = $from ? $from->compile($options, LEVEL_PAREN) : '0';
$compiled = $to ? $to->compile($options, LEVEL_PAREN) : '';
if ($to && ! ( ! $this->range->exclusive && intval($compiled) === -1))
{
$to_str = ', ';
if ($this->range->exclusive)
{
$to_str .= $compiled;
}
else if (preg_match(SIMPLENUM, $compiled))
{
$to_str .= (intval($compiled) + 1);
}
else
{
$compiled = $to->compile($options, LEVEL_ACCESS);
$to_str .= "({$compiled} + 1) || 9e9";
}
}
return ".slice({$from_str}".(isset($to_str) ? $to_str : '').')';
}
}
?>