Same name in other branches
  1. 5.0.x advagg_js_minify/jsminplus.inc \JSParser::reduce()
  2. 6.0.x advagg_js_minify/jsminplus.inc \JSParser::reduce()
  3. 7.x-1.x advagg_js_compress/jsminplus.inc \JSParser::reduce()
  4. 8.x-2.x advagg_js_minify/jsminplus.inc \JSParser::reduce()
  5. 8.x-3.x advagg_js_minify/jsminplus.inc \JSParser::reduce()
  6. 8.x-4.x advagg_js_minify/jsminplus.inc \JSParser::reduce()
1 call to JSParser::reduce()
JSParser::Expression in advagg_js_compress/jsminplus.inc

File

advagg_js_compress/jsminplus.inc, line 1743

Class

JSParser

Code

private function reduce(&$operators, &$operands) {
    $n = array_pop($operators);
    $op = $n->type;
    $arity = $this->opArity[$op];
    $c = count($operands);
    if ($arity == -2) {
        // Flatten left-associative trees
        if ($c >= 2) {
            $left = $operands[$c - 2];
            if ($left->type == $op) {
                $right = array_pop($operands);
                $left->addNode($right);
                return $left;
            }
        }
        $arity = 2;
    }
    // Always use push to add operands to n, to update start and end
    $a = array_splice($operands, $c - $arity);
    for ($i = 0; $i < $arity; $i++) {
        $n->addNode($a[$i]);
    }
    // Include closing bracket or postfix operator in [start,end]
    $token_end = $this->t
        ->currentToken()->end;
    if ($n->end < $token_end) {
        $n->end = $token_end;
    }
    array_push($operands, $n);
    return $n;
}