Search in sources :

Example 1 with Parameter

use of jdk.vm.ci.meta.ResolvedJavaMethod.Parameter in project graal by oracle.

the class NativeBootImage method writeMethodHeader.

private void writeMethodHeader(HostedMethod m, CSourceCodeWriter writer, boolean dynamic) {
    assert Modifier.isStatic(m.getModifiers()) : "Published methods that go into the header must be static.";
    CEntryPointData cEntryPointData = (CEntryPointData) m.getWrapped().getEntryPointData();
    String docComment = cEntryPointData.getDocumentation();
    if (docComment != null && !docComment.isEmpty()) {
        writer.appendln("/*");
        Arrays.stream(docComment.split("\n")).forEach(l -> writer.appendln(" * " + l));
        writer.appendln(" */");
    }
    if (dynamic) {
        writer.append("typedef ");
    }
    writer.append(CSourceCodeWriter.findCTypeName(metaAccess, nativeLibs, (ResolvedJavaType) m.getSignature().getReturnType(m.getDeclaringClass())));
    writer.append(" ");
    assert !cEntryPointData.getSymbolName().isEmpty();
    if (dynamic) {
        writer.append("(*").append(cEntryPointData.getSymbolName()).append("_fn_t)");
    } else {
        writer.append(cEntryPointData.getSymbolName());
    }
    writer.append("(");
    String sep = "";
    for (int i = 0; i < m.getSignature().getParameterCount(false); i++) {
        writer.append(sep);
        sep = ", ";
        writer.append(CSourceCodeWriter.findCTypeName(metaAccess, nativeLibs, (ResolvedJavaType) m.getSignature().getParameterType(i, m.getDeclaringClass())));
        Parameter param = m.getParameters()[i];
        if (param.isNamePresent()) {
            writer.append(" ");
            writer.append(param.getName());
        }
    }
    writer.appendln(");");
    writer.appendln();
}
Also used : CEntryPointData(com.oracle.svm.hosted.code.CEntryPointData) Parameter(jdk.vm.ci.meta.ResolvedJavaMethod.Parameter) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Aggregations

CEntryPointData (com.oracle.svm.hosted.code.CEntryPointData)1 Parameter (jdk.vm.ci.meta.ResolvedJavaMethod.Parameter)1 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)1