Search in sources :

Example 1 with Parameter

use of org.elasticsearch.painless.Locals.Parameter in project elasticsearch by elastic.

the class SFunction method generateSignature.

void generateSignature() {
    try {
        rtnType = Definition.getType(rtnTypeStr);
    } catch (IllegalArgumentException exception) {
        throw createError(new IllegalArgumentException("Illegal return type [" + rtnTypeStr + "] for function [" + name + "]."));
    }
    if (paramTypeStrs.size() != paramNameStrs.size()) {
        throw createError(new IllegalStateException("Illegal tree structure."));
    }
    Class<?>[] paramClasses = new Class<?>[this.paramTypeStrs.size()];
    List<Type> paramTypes = new ArrayList<>();
    for (int param = 0; param < this.paramTypeStrs.size(); ++param) {
        try {
            Type paramType = Definition.getType(this.paramTypeStrs.get(param));
            paramClasses[param] = paramType.clazz;
            paramTypes.add(paramType);
            parameters.add(new Parameter(location, paramNameStrs.get(param), paramType));
        } catch (IllegalArgumentException exception) {
            throw createError(new IllegalArgumentException("Illegal parameter type [" + this.paramTypeStrs.get(param) + "] for function [" + name + "]."));
        }
    }
    org.objectweb.asm.commons.Method method = new org.objectweb.asm.commons.Method(name, MethodType.methodType(rtnType.clazz, paramClasses).toMethodDescriptorString());
    this.method = new Method(name, null, false, rtnType, paramTypes, method, Modifier.STATIC | Modifier.PRIVATE, null);
}
Also used : ArrayList(java.util.ArrayList) Method(org.elasticsearch.painless.Definition.Method) Type(org.elasticsearch.painless.Definition.Type) MethodType(java.lang.invoke.MethodType) Parameter(org.elasticsearch.painless.Locals.Parameter)

Aggregations

MethodType (java.lang.invoke.MethodType)1 ArrayList (java.util.ArrayList)1 Method (org.elasticsearch.painless.Definition.Method)1 Type (org.elasticsearch.painless.Definition.Type)1 Parameter (org.elasticsearch.painless.Locals.Parameter)1