[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/lib/lessphp/Tree/ -> Variable.php (source)

   1  <?php
   2  
   3  /**
   4   * Variable
   5   *
   6   * @package Less
   7   * @subpackage tree
   8   */
   9  class Less_Tree_Variable extends Less_Tree{
  10  
  11      public $name;
  12      public $index;
  13      public $currentFileInfo;
  14      public $evaluating = false;
  15      public $type = 'Variable';
  16  
  17      /**
  18       * @param string $name
  19       */
  20      public function __construct($name, $index = null, $currentFileInfo = null) {
  21          $this->name = $name;
  22          $this->index = $index;
  23          $this->currentFileInfo = $currentFileInfo;
  24      }
  25  
  26  	public function compile($env) {
  27  
  28          if( $this->name[1] === '@' ){
  29              $v = new Less_Tree_Variable(substr($this->name, 1), $this->index + 1);
  30              $name = '@' . $v->compile($env)->value;
  31          }else{
  32              $name = $this->name;
  33          }
  34  
  35          if ($this->evaluating) {
  36              throw new Less_Exception_Compiler("Recursive variable definition for " . $name, null, $this->index, $this->currentFileInfo);
  37          }
  38  
  39          $this->evaluating = true;
  40  
  41          foreach($env->frames as $frame){
  42              if( $v = $frame->variable($name) ){
  43                  $this->evaluating = false;
  44                  return $v->value->compile($env);
  45              }
  46          }
  47  
  48          throw new Less_Exception_Compiler("variable " . $name . " is undefined", null, $this->index );
  49      }
  50  
  51  }


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1