use of com.oracle.truffle.llvm.runtime.debug.LLVMSourceArrayLikeType 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);
}
}
}
Aggregations