10 class Less_Tree_Call
extends Less_Tree
{
16 protected $currentFileInfo;
17 public $type = 'Call';
19 public function __construct($name, $args, $index, $currentFileInfo = null ){
22 $this->index
= $index;
23 $this->currentFileInfo
= $currentFileInfo;
26 public function accept( $visitor ){
27 $this->args
= $visitor->visitArray( $this->args
);
31 // When evaluating a function call,
32 // we either find the function in `tree.functions` [1],
33 // in which case we call it, passing the evaluated arguments,
34 // or we simply print it out as it appeared originally [2].
36 // The *functions.js* file contains the built-in functions.
38 // The reason why we evaluate the arguments, is in the case where
39 // we try to pass a variable to a function, like: `saturate(@color)`.
40 // The function should receive the value, not the variable.
42 public function compile($env=null){
44 foreach($this->args
as $a){
45 $args[] = $a->compile($env);
48 $nameLC = strtolower($this->name
);
63 $nameLC = 'svggradient';
68 if( $nameLC === 'default' ){
69 $result = Less_Tree_DefaultFunc
::compile();
73 if( method_exists('Less_Functions',$nameLC) ){ // 1.
76 $func = new Less_Functions($env, $this->currentFileInfo
);
77 $result = call_user_func_array( array($func,$nameLC),$args);
79 } catch (Exception
$e) {
80 throw new Less_Exception_Compiler('error evaluating function `' . $this->name
. '` '.$e->getMessage().' index: '. $this->index
);
82 } elseif( isset( $env->functions
[$nameLC] ) && is_callable( $env->functions
[$nameLC] ) ) {
84 $result = call_user_func_array( $env->functions
[$nameLC], $args );
85 } catch (Exception
$e) {
86 throw new Less_Exception_Compiler('error evaluating function `' . $this->name
. '` '.$e->getMessage().' index: '. $this->index
);
91 if( $result !== null ){
96 return new Less_Tree_Call( $this->name
, $args, $this->index
, $this->currentFileInfo
);
100 * @see Less_Tree::genCSS
102 public function genCSS( $output ){
104 $output->add( $this->name
. '(', $this->currentFileInfo
, $this->index
);
105 $args_len = count($this->args
);
106 for($i = 0; $i < $args_len; $i++
){
107 $this->args
[$i]->genCSS( $output );
108 if( $i +
1 < $args_len ){
109 $output->add( ', ' );
117 //public function toCSS(){
118 // return $this->compile()->toCSS();