diff --git a/src/main/java/dk/camelot64/kickc/model/Registers.java b/src/main/java/dk/camelot64/kickc/model/Registers.java index caf716ad3..53899e07e 100644 --- a/src/main/java/dk/camelot64/kickc/model/Registers.java +++ b/src/main/java/dk/camelot64/kickc/model/Registers.java @@ -3,6 +3,8 @@ package dk.camelot64.kickc.model; import dk.camelot64.kickc.model.values.ConstantValue; import dk.camelot64.kickc.model.values.Value; +import java.util.Locale; + /** The different registers available for a program */ public class Registers { @@ -24,7 +26,7 @@ public class Registers { } public static Register getRegister(String name) { - switch(name.toUpperCase()) { + switch(name.toUpperCase(Locale.ENGLISH)) { case "A": return getRegisterA(); case "X": diff --git a/src/main/java/dk/camelot64/kickc/model/operators/OperatorSizeOf.java b/src/main/java/dk/camelot64/kickc/model/operators/OperatorSizeOf.java index 69f0cbd59..69ee3ff15 100644 --- a/src/main/java/dk/camelot64/kickc/model/operators/OperatorSizeOf.java +++ b/src/main/java/dk/camelot64/kickc/model/operators/OperatorSizeOf.java @@ -9,6 +9,8 @@ import dk.camelot64.kickc.model.values.ConstantInteger; import dk.camelot64.kickc.model.values.ConstantLiteral; import dk.camelot64.kickc.model.values.ConstantRef; +import java.util.Locale; + /** SizeOf operator sizeof(expr). Will be resolved into a constant as soon as the expression has been resolved enough. */ public class OperatorSizeOf extends OperatorUnary { @@ -56,7 +58,7 @@ public class OperatorSizeOf extends OperatorUnary { if(type instanceof SymbolTypePointer) { return "SIZEOF_POINTER"; } else { - return "SIZEOF_" + type.getTypeName().toUpperCase().replace(" ", "_"); + return "SIZEOF_" + type.getTypeName().toUpperCase(Locale.ENGLISH).replace(" ", "_"); } } diff --git a/src/main/java/dk/camelot64/kickc/model/operators/OperatorTypeId.java b/src/main/java/dk/camelot64/kickc/model/operators/OperatorTypeId.java index c36abea37..900a562c4 100644 --- a/src/main/java/dk/camelot64/kickc/model/operators/OperatorTypeId.java +++ b/src/main/java/dk/camelot64/kickc/model/operators/OperatorTypeId.java @@ -8,6 +8,8 @@ import dk.camelot64.kickc.model.values.ConstantInteger; import dk.camelot64.kickc.model.values.ConstantLiteral; import dk.camelot64.kickc.model.values.ConstantRef; +import java.util.Locale; + /** * TypeId operator typeid(expr) returns byte value representing the type of the expression. * Will be resolved into a constant as soon as the expression has been resolved enough. @@ -60,7 +62,7 @@ public class OperatorTypeId extends OperatorUnary { } else if(type instanceof SymbolTypePointer) { return "POINTER_" + getTypeIdConstantName(((SymbolTypePointer) type).getElementType()); } else { - return type.getTypeName().toUpperCase().replace(" ", "_"); + return type.getTypeName().toUpperCase(Locale.ENGLISH).replace(" ", "_"); } } diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java b/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java index 2f798dc76..e8662e9e2 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java @@ -135,7 +135,7 @@ public class Pass0GenerateStatementSequence extends KickCBaseVisitor { @Override public Object visitGlobalDirectiveEncoding(KickCParser.GlobalDirectiveEncodingContext ctx) { try { - this.currentEncoding = ConstantString.Encoding.valueOf(ctx.NAME().getText().toUpperCase()); + this.currentEncoding = ConstantString.Encoding.valueOf(ctx.NAME().getText().toUpperCase(Locale.ENGLISH)); } catch(IllegalArgumentException e) { throw new CompileError("Unknown string encoding " + ctx.NAME().getText(), new StatementSource(ctx)); } @@ -474,7 +474,7 @@ public class Pass0GenerateStatementSequence extends KickCBaseVisitor { @Override public AsmDirectiveClobber visitAsmDirectiveClobber(KickCParser.AsmDirectiveClobberContext ctx) { - String clobberString = ctx.STRING().getText().toUpperCase(); + String clobberString = ctx.STRING().getText().toUpperCase(Locale.ENGLISH); clobberString = clobberString.substring(1, clobberString.length() - 1); if(!clobberString.matches("[AXY]*")) { throw new CompileError("Error! Illegal clobber value " + clobberString, new StatementSource(ctx)); @@ -761,7 +761,7 @@ public class Pass0GenerateStatementSequence extends KickCBaseVisitor { public Object visitDirectiveInterrupt(KickCParser.DirectiveInterruptContext ctx) { String interruptType; if(ctx.getChildCount() > 1) { - interruptType = ctx.getChild(2).getText().toUpperCase(); + interruptType = ctx.getChild(2).getText().toUpperCase(Locale.ENGLISH); } else { // The default interrupt type interruptType = Procedure.InterruptType.DEFAULT.name(); diff --git a/src/main/java/dk/camelot64/kickc/passes/PassNStructPointerRewriting.java b/src/main/java/dk/camelot64/kickc/passes/PassNStructPointerRewriting.java index 6fb13f681..e648a44f5 100644 --- a/src/main/java/dk/camelot64/kickc/passes/PassNStructPointerRewriting.java +++ b/src/main/java/dk/camelot64/kickc/passes/PassNStructPointerRewriting.java @@ -12,6 +12,7 @@ import dk.camelot64.kickc.model.types.SymbolTypePointer; import dk.camelot64.kickc.model.types.SymbolTypeStruct; import dk.camelot64.kickc.model.values.*; +import java.util.Locale; import java.util.concurrent.atomic.AtomicBoolean; /** @@ -113,7 +114,7 @@ public class PassNStructPointerRewriting extends Pass2SsaOptimization { * @return The name of the constant */ private static String getMemberOffsetConstantName(StructDefinition structDefinition, String memberName) { - return "OFFSET_" + structDefinition.getType().getTypeName().toUpperCase().replace(" ", "_") + "_" + memberName.toUpperCase(); + return "OFFSET_" + structDefinition.getType().getTypeName().toUpperCase(Locale.ENGLISH).replace(" ", "_") + "_" + memberName.toUpperCase(); }