diff --git a/src/main/java/dk/camelot64/kickc/passes/VariableReplacer.java b/src/main/java/dk/camelot64/kickc/passes/VariableReplacer.java index 406ff34ad..17ba18b3c 100644 --- a/src/main/java/dk/camelot64/kickc/passes/VariableReplacer.java +++ b/src/main/java/dk/camelot64/kickc/passes/VariableReplacer.java @@ -107,6 +107,22 @@ public class VariableReplacer { } return new ConstantBinary(aliasLeft, constantBinary.getOperator(), aliasRight); } + } else if(rValue instanceof ConstantArray) { + ConstantArray constantArray = (ConstantArray) rValue; + ArrayList replacementList = new ArrayList<>(); + boolean any = false; + for (ConstantValue elemValue : constantArray.getElements()) { + RValue elemReplacement = getReplacement(elemValue); + if(elemReplacement!=null) { + replacementList.add((ConstantValue) elemReplacement); + any = true; + } else{ + replacementList.add(elemValue); + } + } + if(any) { + return new ConstantArray(replacementList, constantArray.getElementType()); + } } // No replacement found - return null