1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-10-21 17:24:39 +00:00

Fixed problem with size calculation of arrays inside structs. Closes #458

This commit is contained in:
jespergravgaard 2020-05-30 01:07:45 +02:00
parent c33d140628
commit a99256645a

View File

@ -63,10 +63,11 @@ public class SymbolTypeStruct implements SymbolType {
public static int getMemberSizeBytes(SymbolType memberType, ConstantValue arraySize, ProgramScope programScope) {
if(arraySize!=null) {
final SymbolType elementType = ((SymbolTypePointer) memberType).getElementType();
if(programScope != null) {
ConstantLiteral sizeLiteral = arraySize.calculateLiteral(programScope);
if(sizeLiteral instanceof ConstantInteger) {
return memberType.getSizeBytes() * ((ConstantInteger) sizeLiteral).getInteger().intValue();
return elementType.getSizeBytes() * ((ConstantInteger) sizeLiteral).getInteger().intValue();
}
} else {
return 5; // Add a token size