use of de.mirkosertic.bytecoder.api.opencl.OpenCLFunction in project Bytecoder by mirkosertic.
the class OpenCLWriter method printInvokeStatic.
private void printInvokeStatic(InvokeStaticMethodExpression aValue) {
BytecodeLinkedClass theLinkedClass = linkerContext.resolveClass(aValue.getClassName());
BytecodeResolvedMethods theMethods = theLinkedClass.resolvedMethods();
AtomicBoolean theFound = new AtomicBoolean(false);
theMethods.stream().forEach(aMethodMapsEntry -> {
BytecodeMethod theMethod = aMethodMapsEntry.getValue();
if (Objects.equals(theMethod.getName().stringValue(), aValue.getMethodName()) && theMethod.getSignature().metchesExactlyTo(aValue.getSignature())) {
BytecodeAnnotation theAnnotation = theMethod.getAttributes().getAnnotationByType(OpenCLFunction.class.getName());
if (theAnnotation == null) {
throw new IllegalArgumentException("Annotation @OpenCLFunction required for static method " + aValue.getMethodName());
}
String theMethodName = theAnnotation.getElementValueByName("value").stringValue();
BytecodeMethodSignature theSignature = aValue.getSignature();
print(theMethodName);
print("(");
List<Value> theArguments = aValue.incomingDataFlows();
for (int i = 0; i < theArguments.size(); i++) {
if (i > 0) {
print(",");
}
if (!theSignature.getArguments()[i].isPrimitive()) {
print("*");
}
printValue(theArguments.get(i));
}
print(")");
theFound.set(true);
}
});
if (!theFound.get()) {
throw new IllegalArgumentException("Not supported method : " + aValue.getMethodName());
}
}
Aggregations