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

Fichier

advagg_js_compress/jsminplus.inc, line 1233

Classe

JSParser

Code

private function FunctionDefinition($x, $requireName, $functionForm) {
    $f = new JSNode($this->t);
    if ($f->type != KEYWORD_FUNCTION) {
        $f->type = $f->value == 'get' ? JS_GETTER : JS_SETTER;
    }
    if ($this->t
        ->match(TOKEN_IDENTIFIER)) {
        $f->name = $this->t
            ->currentToken()->value;
    }
    elseif ($requireName) {
        throw $this->t
            ->newSyntaxError('Missing function identifier');
    }
    $this->t
        ->mustMatch(OP_LEFT_PAREN);
    $f->params = array();
    while (($tt = $this->t
        ->get()) != OP_RIGHT_PAREN) {
        if ($tt != TOKEN_IDENTIFIER) {
            throw $this->t
                ->newSyntaxError('Missing formal parameter');
        }
        array_push($f->params, $this->t
            ->currentToken()->value);
        if ($this->t
            ->peek() != OP_RIGHT_PAREN) {
            $this->t
                ->mustMatch(OP_COMMA);
        }
    }
    $this->t
        ->mustMatch(OP_LEFT_CURLY);
    $x2 = new JSCompilerContext(true);
    $f->body = $this->Script($x2);
    $this->t
        ->mustMatch(OP_RIGHT_CURLY);
    $f->end = $this->t
        ->currentToken()->end;
    $f->functionForm = $functionForm;
    if ($functionForm == DECLARED_FORM) {
        array_push($x->funDecls, $f);
    }
    return $f;
}