Search in sources :

Example 1 with SDeclBlock

use of org.elasticsearch.painless.node.SDeclBlock in project elasticsearch by elastic.

the class Walker method visitDeclaration.

@Override
public ANode visitDeclaration(DeclarationContext ctx) {
    String type = ctx.decltype().getText();
    List<SDeclaration> declarations = new ArrayList<>();
    for (DeclvarContext declvar : ctx.declvar()) {
        String name = declvar.ID().getText();
        AExpression expression = declvar.expression() == null ? null : (AExpression) visit(declvar.expression());
        declarations.add(new SDeclaration(location(declvar), type, name, expression));
    }
    return new SDeclBlock(location(ctx), declarations);
}
Also used : DeclvarContext(org.elasticsearch.painless.antlr.PainlessParser.DeclvarContext) AExpression(org.elasticsearch.painless.node.AExpression) ArrayList(java.util.ArrayList) EString(org.elasticsearch.painless.node.EString) SDeclBlock(org.elasticsearch.painless.node.SDeclBlock) SDeclaration(org.elasticsearch.painless.node.SDeclaration)

Aggregations

ArrayList (java.util.ArrayList)1 DeclvarContext (org.elasticsearch.painless.antlr.PainlessParser.DeclvarContext)1 AExpression (org.elasticsearch.painless.node.AExpression)1 EString (org.elasticsearch.painless.node.EString)1 SDeclBlock (org.elasticsearch.painless.node.SDeclBlock)1 SDeclaration (org.elasticsearch.painless.node.SDeclaration)1