1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
<?php
/**
* @private
* @see less-3.13.1.js#tree.Property
*/
class Less_Tree_Property extends Less_Tree {
public $name;
public $index;
public $currentFileInfo;
public $evaluating = false;
/**
* @param string $name
*/
public function __construct( $name, $index = null, $currentFileInfo = null ) {
$this->name = $name;
$this->index = $index;
$this->currentFileInfo = $currentFileInfo;
}
public function compile( $env ) {
$name = $this->name;
if ( $this->evaluating ) {
throw new Less_Exception_Compiler( "Recursive property reference for " . $name, null,
$this->index, $this->currentFileInfo );
}
$property = null;
$this->evaluating = true;
/** @var Less_Tree_Ruleset $frame */
foreach ( $env->frames as $frame ) {
$vArr = $frame->property( $name );
if ( $vArr ) {
$size = count( $vArr );
for ( $i = 0; $i < $size; $i++ ) {
$v = $vArr[$i];
$vArr[$i] = new Less_Tree_Declaration(
$v->name,
$v->value,
$v->important,
$v->merge,
$v->index,
$v->currentFileInfo,
$v->inline,
$v->variable
);
}
Less_Visitor_toCSS::_mergeRules( $vArr );
$v = $vArr[ count( $vArr ) - 1 ];
if ( isset( $v->important ) && $v->important ) {
$importantScopeLength = count( $env->importantScope );
$env->importantScope[ $importantScopeLength - 1 ]['important'] = $v->important;
}
$property = $v->value->compile( $env );
break;
}
}
if ( $property ) {
$this->evaluating = false;
return $property;
} else {
throw new Less_Exception_Compiler( "property '" . $name . "' is undefined in file " .
$this->currentFileInfo["filename"], null, $this->index, $this->currentFileInfo );
}
}
}
|