コード例 #1
0
 public function compile($env)
 {
     $doubleParen = false;
     if ($this->parens && !$this->parensInOp) {
         Less_Environment::$parensStack++;
     }
     $returnValue = null;
     if ($this->value) {
         $count = count($this->value);
         if ($count > 1) {
             $ret = array();
             foreach ($this->value as $e) {
                 $ret[] = $e->compile($env);
             }
             $returnValue = new Less_Tree_Expression($ret);
         } else {
             if ($this->value[0] instanceof Less_Tree_Expression && $this->value[0]->parens && !$this->value[0]->parensInOp) {
                 $doubleParen = true;
             }
             $returnValue = $this->value[0]->compile($env);
         }
     } else {
         $returnValue = $this;
     }
     if ($this->parens) {
         if (!$this->parensInOp) {
             Less_Environment::$parensStack--;
         } elseif (!Less_Environment::isMathOn() && !$doubleParen) {
             $returnValue = new Less_Tree_Paren($returnValue);
         }
     }
     return $returnValue;
 }
コード例 #2
0
ファイル: Negative.php プロジェクト: shomimn/builder
 public function compile($env)
 {
     if (Less_Environment::isMathOn()) {
         $ret = new Less_Tree_Operation('*', array(new Less_Tree_Dimension(-1), $this->value));
         return $ret->compile($env);
     }
     return new Less_Tree_Negative($this->value->compile($env));
 }
コード例 #3
0
ファイル: Operation.php プロジェクト: evltuma/moodle
 public function compile($env)
 {
     $a = $this->operands[0]->compile($env);
     $b = $this->operands[1]->compile($env);
     if (Less_Environment::isMathOn()) {
         if ($a instanceof Less_Tree_Dimension && $b instanceof Less_Tree_Color) {
             $a = $a->toColor();
         } elseif ($b instanceof Less_Tree_Dimension && $a instanceof Less_Tree_Color) {
             $b = $b->toColor();
         }
         if (!method_exists($a, 'operate')) {
             throw new Less_Exception_Compiler("Operation on an invalid type");
         }
         return $a->operate($this->op, $b);
     }
     return new Less_Tree_Operation($this->op, array($a, $b), $this->isSpaced);
 }