Search in sources :

Example 1 with RawStructureInfo

use of com.oracle.svm.hosted.c.info.RawStructureInfo in project graal by oracle.

the class RawStructureLayoutPlanner method visitRawStructureInfo.

@Override
protected void visitRawStructureInfo(RawStructureInfo info) {
    if (info.isPlanned()) {
        return;
    }
    ResolvedJavaType type = (ResolvedJavaType) info.getAnnotatedElement();
    for (ResolvedJavaType t : type.getInterfaces()) {
        if (!nativeLibs.isPointerBase(t)) {
            throw UserError.abort("Type " + type + " must not implement " + t);
        }
        if (t.equals(nativeLibs.getPointerBaseType())) {
            continue;
        }
        ElementInfo einfo = nativeLibs.findElementInfo(t);
        if (!(einfo instanceof RawStructureInfo)) {
            throw UserError.abort(new CInterfaceError("Illegal super type " + t + " found", type).getMessage());
        }
        RawStructureInfo rinfo = (RawStructureInfo) einfo;
        rinfo.accept(this);
        assert rinfo.isPlanned();
        if (info.getParentInfo() != null) {
            throw UserError.abort(new CInterfaceError("Only single inheritance of RawStructure types is supported", type).getMessage());
        }
        info.setParentInfo(rinfo);
    }
    for (ElementInfo child : new ArrayList<>(info.getChildren())) {
        if (child instanceof StructFieldInfo) {
            StructFieldInfo fieldInfo = (StructFieldInfo) child;
            StructFieldInfo parentFieldInfo = findParentFieldInfo(fieldInfo, info.getParentInfo());
            if (parentFieldInfo != null) {
                fieldInfo.mergeChildrenAndDelete(parentFieldInfo);
            } else {
                computeSize(fieldInfo);
            }
        }
    }
    planLayout(info);
}
Also used : CInterfaceError(com.oracle.svm.hosted.c.CInterfaceError) RawStructureInfo(com.oracle.svm.hosted.c.info.RawStructureInfo) ElementInfo(com.oracle.svm.hosted.c.info.ElementInfo) ArrayList(java.util.ArrayList) StructFieldInfo(com.oracle.svm.hosted.c.info.StructFieldInfo) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Aggregations

CInterfaceError (com.oracle.svm.hosted.c.CInterfaceError)1 ElementInfo (com.oracle.svm.hosted.c.info.ElementInfo)1 RawStructureInfo (com.oracle.svm.hosted.c.info.RawStructureInfo)1 StructFieldInfo (com.oracle.svm.hosted.c.info.StructFieldInfo)1 ArrayList (java.util.ArrayList)1 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)1