9 class Less_Tree_Operation extends Less_Tree{
14 public $type = 'Operation';
19 public function __construct($op, $operands, $isSpaced = false){
20 $this->op = trim($op);
21 $this->operands = $operands;
22 $this->isSpaced = $isSpaced;
25 public function accept($visitor) {
26 $this->operands = $visitor->visitArray($this->operands);
29 public function compile($env){
30 $a = $this->operands[0]->compile($env);
31 $b = $this->operands[1]->compile($env);
34 if( Less_Environment::isMathOn() ){
36 if( $a instanceof Less_Tree_Dimension && $b instanceof Less_Tree_Color ){
39 }elseif( $b instanceof Less_Tree_Dimension && $a instanceof Less_Tree_Color ){
44 if( !method_exists($a,'operate') ){
45 throw new Less_Exception_Compiler("Operation on an invalid type");
48 return $a->operate( $this->op, $b);
51 return new Less_Tree_Operation($this->op, array($a, $b), $this->isSpaced );
56 * @see Less_Tree::genCSS
58 public function genCSS( $output ){
59 $this->operands[0]->genCSS( $output );
60 if( $this->isSpaced ){
63 $output->add( $this->op );
64 if( $this->isSpaced ){
67 $this->operands[1]->genCSS( $output );