Search in sources :

Example 1 with LLVMSourceEnumLikeType

use of com.oracle.truffle.llvm.runtime.debug.LLVMSourceEnumLikeType in project sulong by graalvm.

the class DITypeExtractor method visit.

@Override
public void visit(MDCompositeType mdType) {
    final long size = mdType.getSize();
    final long align = mdType.getAlign();
    final long offset = mdType.getOffset();
    final LLVMSourceLocation location = scopeBuilder.buildLocation(mdType);
    switch(mdType.getTag()) {
        case DW_TAG_VECTOR_TYPE:
        case DW_TAG_ARRAY_TYPE:
            {
                final boolean isVector = mdType.getTag() == MDType.DwarfTag.DW_TAG_VECTOR_TYPE;
                final LLVMSourceArrayLikeType type = new LLVMSourceArrayLikeType(size, align, offset, location);
                parsedTypes.put(mdType, type);
                LLVMSourceType baseType = resolve(mdType.getBaseType());
                final List<LLVMSourceType> members = new ArrayList<>(1);
                getElements(mdType.getMembers(), members, false);
                for (int i = members.size() - 1; i > 0; i--) {
                    final long length = extractLength(members.get(i));
                    final long tmpSize = length * baseType.getSize();
                    final LLVMSourceArrayLikeType tmp = new LLVMSourceArrayLikeType(tmpSize, align, 0L, location);
                    setAggregateProperties(isVector, tmp, length, baseType);
                    baseType = tmp;
                }
                setAggregateProperties(isVector, type, extractLength(members.get(0)), baseType);
                break;
            }
        case DW_TAG_CLASS_TYPE:
        case DW_TAG_UNION_TYPE:
        case DW_TAG_STRUCTURE_TYPE:
            {
                String name = MDNameExtractor.getName(mdType.getName());
                if (mdType.getTag() == MDType.DwarfTag.DW_TAG_STRUCTURE_TYPE) {
                    name = String.format("struct %s", name);
                } else if (mdType.getTag() == MDType.DwarfTag.DW_TAG_UNION_TYPE) {
                    name = String.format("union %s", name);
                }
                final LLVMSourceStructLikeType type = new LLVMSourceStructLikeType(name, size, align, offset, location);
                parsedTypes.put(mdType, type);
                final List<LLVMSourceType> members = new ArrayList<>();
                getElements(mdType.getMembers(), members, false);
                for (final LLVMSourceType member : members) {
                    if (member instanceof LLVMSourceMemberType) {
                        type.addDynamicMember((LLVMSourceMemberType) member);
                    } else if (member instanceof LLVMSourceStaticMemberType) {
                        type.addStaticMember((LLVMSourceStaticMemberType) member);
                    }
                }
                break;
            }
        case DW_TAG_ENUMERATION_TYPE:
            {
                final String name = String.format("enum %s", MDNameExtractor.getName(mdType.getName()));
                final LLVMSourceEnumLikeType type = new LLVMSourceEnumLikeType(() -> name, size, align, offset, location);
                parsedTypes.put(mdType, type);
                final List<LLVMSourceType> members = new ArrayList<>();
                getElements(mdType.getMembers(), members, false);
                for (final LLVMSourceType member : members) {
                    type.addValue((int) member.getOffset(), member.getName());
                }
                break;
            }
        default:
            {
                parsedTypes.put(mdType, LLVMSourceType.UNKNOWN);
            }
    }
}
Also used : LLVMSourceStructLikeType(com.oracle.truffle.llvm.runtime.debug.LLVMSourceStructLikeType) LLVMSourceEnumLikeType(com.oracle.truffle.llvm.runtime.debug.LLVMSourceEnumLikeType) LLVMSourceLocation(com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation) ArrayList(java.util.ArrayList) List(java.util.List) MetadataValueList(com.oracle.truffle.llvm.parser.metadata.MetadataValueList) LLVMSourceType(com.oracle.truffle.llvm.runtime.debug.LLVMSourceType) MDString(com.oracle.truffle.llvm.parser.metadata.MDString) LLVMSourceMemberType(com.oracle.truffle.llvm.runtime.debug.LLVMSourceMemberType) LLVMSourceStaticMemberType(com.oracle.truffle.llvm.runtime.debug.LLVMSourceStaticMemberType) LLVMSourceArrayLikeType(com.oracle.truffle.llvm.runtime.debug.LLVMSourceArrayLikeType)

Aggregations

MDString (com.oracle.truffle.llvm.parser.metadata.MDString)1 MetadataValueList (com.oracle.truffle.llvm.parser.metadata.MetadataValueList)1 LLVMSourceArrayLikeType (com.oracle.truffle.llvm.runtime.debug.LLVMSourceArrayLikeType)1 LLVMSourceEnumLikeType (com.oracle.truffle.llvm.runtime.debug.LLVMSourceEnumLikeType)1 LLVMSourceMemberType (com.oracle.truffle.llvm.runtime.debug.LLVMSourceMemberType)1 LLVMSourceStaticMemberType (com.oracle.truffle.llvm.runtime.debug.LLVMSourceStaticMemberType)1 LLVMSourceStructLikeType (com.oracle.truffle.llvm.runtime.debug.LLVMSourceStructLikeType)1 LLVMSourceType (com.oracle.truffle.llvm.runtime.debug.LLVMSourceType)1 LLVMSourceLocation (com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1