diff --git a/core/src/main/java/org/teavm/model/text/InstructionStringifier.java b/core/src/main/java/org/teavm/model/text/InstructionStringifier.java index fd7502420..6fbd7598c 100644 --- a/core/src/main/java/org/teavm/model/text/InstructionStringifier.java +++ b/core/src/main/java/org/teavm/model/text/InstructionStringifier.java @@ -220,6 +220,7 @@ class InstructionStringifier implements InstructionReader { break; } append(" ").appendLocalVar(second); + append(" as ").append(type.name().toLowerCase()); } @Override @@ -242,7 +243,8 @@ class InstructionStringifier implements InstructionReader { public void cast(VariableReader receiver, VariableReader value, NumericOperandType sourceType, NumericOperandType targetType) { appendLocalVar(receiver).append(" := cast ").appendLocalVar(value) - .append(" from ").append(sourceType.toString()).append(" to ").append(targetType.toString()); + .append(" from ").append(sourceType.toString().toLowerCase(Locale.ROOT)).append(" to ") + .append(targetType.toString().toLowerCase(Locale.ROOT)); } @Override diff --git a/core/src/main/java/org/teavm/model/text/ListingParser.java b/core/src/main/java/org/teavm/model/text/ListingParser.java index a6bbf0b13..14d249024 100644 --- a/core/src/main/java/org/teavm/model/text/ListingParser.java +++ b/core/src/main/java/org/teavm/model/text/ListingParser.java @@ -58,6 +58,7 @@ import org.teavm.model.instructions.DoubleConstantInstruction; import org.teavm.model.instructions.EmptyInstruction; import org.teavm.model.instructions.ExitInstruction; import org.teavm.model.instructions.FloatConstantInstruction; +import org.teavm.model.instructions.GetElementInstruction; import org.teavm.model.instructions.GetFieldInstruction; import org.teavm.model.instructions.InitClassInstruction; import org.teavm.model.instructions.IntegerConstantInstruction; @@ -509,6 +510,9 @@ public class ListingParser { case SHIFT_RIGHT_UNSIGNED: parseBinary(receiver, variable, BinaryOperation.SHIFT_RIGHT_UNSIGNED); break; + case LEFT_SQUARE_BRACKET: + parseSubscript(receiver, variable); + break; case IDENTIFIER: switch ((String) lexer.getTokenValue()) { case "compareTo": @@ -549,6 +553,23 @@ public class ListingParser { addInstruction(insn); } + private void parseSubscript(Variable receiver, Variable array) throws IOException, ListingParseException { + lexer.nextToken(); + Variable index = expectVariable(); + expect(ListingToken.RIGHT_SQUARE_BRACKET); + lexer.nextToken(); + expectKeyword("as"); + + ArrayElementType type = expectArrayType(); + + GetElementInstruction insn = new GetElementInstruction(type); + insn.setReceiver(receiver); + insn.setArray(array); + insn.setIndex(index); + + addInstruction(insn); + } + private void parseArrayAssignment(Variable array) throws IOException, ListingParseException { Variable index = expectVariable(); expect(ListingToken.RIGHT_SQUARE_BRACKET);