Search in sources :

Example 1 with DecltypeContext

use of org.elasticsearch.painless.antlr.PainlessParser.DecltypeContext in project elasticsearch by elastic.

the class Walker method visitFunction.

@Override
public ANode visitFunction(FunctionContext ctx) {
    reserved.push(new FunctionReserved());
    String rtnType = ctx.decltype().getText();
    String name = ctx.ID().getText();
    List<String> paramTypes = new ArrayList<>();
    List<String> paramNames = new ArrayList<>();
    List<AStatement> statements = new ArrayList<>();
    for (DecltypeContext decltype : ctx.parameters().decltype()) {
        paramTypes.add(decltype.getText());
    }
    for (TerminalNode id : ctx.parameters().ID()) {
        paramNames.add(id.getText());
    }
    for (StatementContext statement : ctx.block().statement()) {
        statements.add((AStatement) visit(statement));
    }
    return new SFunction((FunctionReserved) reserved.pop(), location(ctx), rtnType, name, paramTypes, paramNames, statements, false);
}
Also used : AStatement(org.elasticsearch.painless.node.AStatement) SFunction(org.elasticsearch.painless.node.SFunction) FunctionReserved(org.elasticsearch.painless.node.SFunction.FunctionReserved) ArrayList(java.util.ArrayList) EString(org.elasticsearch.painless.node.EString) TerminalNode(org.antlr.v4.runtime.tree.TerminalNode) DecltypeContext(org.elasticsearch.painless.antlr.PainlessParser.DecltypeContext) StatementContext(org.elasticsearch.painless.antlr.PainlessParser.StatementContext)

Aggregations

ArrayList (java.util.ArrayList)1 TerminalNode (org.antlr.v4.runtime.tree.TerminalNode)1 DecltypeContext (org.elasticsearch.painless.antlr.PainlessParser.DecltypeContext)1 StatementContext (org.elasticsearch.painless.antlr.PainlessParser.StatementContext)1 AStatement (org.elasticsearch.painless.node.AStatement)1 EString (org.elasticsearch.painless.node.EString)1 SFunction (org.elasticsearch.painless.node.SFunction)1 FunctionReserved (org.elasticsearch.painless.node.SFunction.FunctionReserved)1