Search in sources :

Example 1 with FunctionSpec

use of boa.functions.FunctionSpec in project compiler by boalang.

the class SymbolTable method importFunction.

private static void importFunction(final Method m) {
    final FunctionSpec annotation = m.getAnnotation(FunctionSpec.class);
    if (annotation == null)
        return;
    final String[] formalParameters = annotation.formalParameters();
    final BoaType[] formalParameterTypes = new BoaType[formalParameters.length];
    for (int i = 0; i < formalParameters.length; i++) {
        final String id = formalParameters[i];
        // check for varargs
        if (id.endsWith("..."))
            formalParameterTypes[i] = new BoaVarargs(getType(id.substring(0, id.indexOf('.'))));
        else
            formalParameterTypes[i] = getType(id);
    }
    globalFunctions.addFunction(annotation.name(), new BoaFunction(m.getDeclaringClass().getCanonicalName() + '.' + m.getName(), getType(annotation.returnType()), formalParameterTypes));
}
Also used : FunctionSpec(boa.functions.FunctionSpec)

Aggregations

FunctionSpec (boa.functions.FunctionSpec)1