Fix size calc for ArrayType in structs

This commit is contained in:
Pragyansh Chaturvedi
2025-09-30 01:56:05 +05:30
parent 715442d7bf
commit 3ded17bf8b

View File

@ -22,8 +22,10 @@ class StructType:
def field_size(self, field_name):
fld = self.fields[field_name]
if isinstance(fld, ir.ArrayType):
return fld.element.count * (fld.element.width // 8)
return fld.count * (fld.element.width // 8)
elif isinstance(fld, ir.IntType):
return fld.width // 8
elif isinstance(fld, ir.PointerType):
return 8
raise TypeError(f"Unsupported field type: {fld}")