use of org.elasticsearch.painless.node.ENewArray in project elasticsearch by elastic.
the class Walker method visitConstructorfuncref.
@Override
public ANode visitConstructorfuncref(ConstructorfuncrefContext ctx) {
if (!ctx.decltype().LBRACE().isEmpty()) {
// array constructors are special: we need to make a synthetic method
// taking integer as argument and returning a new instance, and return a ref to that.
Location location = location(ctx);
String arrayType = ctx.decltype().getText();
SReturn code = new SReturn(location, new ENewArray(location, arrayType, Arrays.asList(new EVariable(location, "size")), false));
String name = nextLambda();
globals.addSyntheticMethod(new SFunction(new FunctionReserved(), location, arrayType, name, Arrays.asList("int"), Arrays.asList("size"), Arrays.asList(code), true));
return new EFunctionRef(location(ctx), "this", name);
}
return new EFunctionRef(location(ctx), ctx.decltype().getText(), ctx.NEW().getText());
}
use of org.elasticsearch.painless.node.ENewArray in project elasticsearch by elastic.
the class Walker method visitNewstandardarray.
@Override
public ANode visitNewstandardarray(NewstandardarrayContext ctx) {
String type = ctx.TYPE().getText();
List<AExpression> expressions = new ArrayList<>();
for (ExpressionContext expression : ctx.expression()) {
expressions.add((AExpression) visit(expression));
}
return buildPostfixChain(new ENewArray(location(ctx), type, expressions, false), ctx.postdot(), ctx.postfix());
}
use of org.elasticsearch.painless.node.ENewArray in project elasticsearch by elastic.
the class Walker method visitNewinitializedarray.
@Override
public ANode visitNewinitializedarray(NewinitializedarrayContext ctx) {
String type = ctx.TYPE().getText();
List<AExpression> expressions = new ArrayList<>();
for (ExpressionContext expression : ctx.expression()) {
expressions.add((AExpression) visit(expression));
}
return buildPostfixChain(new ENewArray(location(ctx), type, expressions, true), null, ctx.postfix());
}
Aggregations