mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-01-06 00:33:42 +00:00
Fixed problem with size calculation of arrays inside structs. Closes #458
This commit is contained in:
parent
c33d140628
commit
a99256645a
@ -63,10 +63,11 @@ public class SymbolTypeStruct implements SymbolType {
|
|||||||
|
|
||||||
public static int getMemberSizeBytes(SymbolType memberType, ConstantValue arraySize, ProgramScope programScope) {
|
public static int getMemberSizeBytes(SymbolType memberType, ConstantValue arraySize, ProgramScope programScope) {
|
||||||
if(arraySize!=null) {
|
if(arraySize!=null) {
|
||||||
|
final SymbolType elementType = ((SymbolTypePointer) memberType).getElementType();
|
||||||
if(programScope != null) {
|
if(programScope != null) {
|
||||||
ConstantLiteral sizeLiteral = arraySize.calculateLiteral(programScope);
|
ConstantLiteral sizeLiteral = arraySize.calculateLiteral(programScope);
|
||||||
if(sizeLiteral instanceof ConstantInteger) {
|
if(sizeLiteral instanceof ConstantInteger) {
|
||||||
return memberType.getSizeBytes() * ((ConstantInteger) sizeLiteral).getInteger().intValue();
|
return elementType.getSizeBytes() * ((ConstantInteger) sizeLiteral).getInteger().intValue();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return 5; // Add a token size
|
return 5; // Add a token size
|
||||||
|
Loading…
Reference in New Issue
Block a user