mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-09 00:14:10 -08:00
Fix bugs in textual IR parser and stringifier
This commit is contained in:
parent
1139c2bd6c
commit
812aa5a682
|
@ -220,6 +220,7 @@ class InstructionStringifier implements InstructionReader {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
append(" ").appendLocalVar(second);
|
append(" ").appendLocalVar(second);
|
||||||
|
append(" as ").append(type.name().toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -242,7 +243,8 @@ class InstructionStringifier implements InstructionReader {
|
||||||
public void cast(VariableReader receiver, VariableReader value, NumericOperandType sourceType,
|
public void cast(VariableReader receiver, VariableReader value, NumericOperandType sourceType,
|
||||||
NumericOperandType targetType) {
|
NumericOperandType targetType) {
|
||||||
appendLocalVar(receiver).append(" := cast ").appendLocalVar(value)
|
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
|
@Override
|
||||||
|
|
|
@ -58,6 +58,7 @@ import org.teavm.model.instructions.DoubleConstantInstruction;
|
||||||
import org.teavm.model.instructions.EmptyInstruction;
|
import org.teavm.model.instructions.EmptyInstruction;
|
||||||
import org.teavm.model.instructions.ExitInstruction;
|
import org.teavm.model.instructions.ExitInstruction;
|
||||||
import org.teavm.model.instructions.FloatConstantInstruction;
|
import org.teavm.model.instructions.FloatConstantInstruction;
|
||||||
|
import org.teavm.model.instructions.GetElementInstruction;
|
||||||
import org.teavm.model.instructions.GetFieldInstruction;
|
import org.teavm.model.instructions.GetFieldInstruction;
|
||||||
import org.teavm.model.instructions.InitClassInstruction;
|
import org.teavm.model.instructions.InitClassInstruction;
|
||||||
import org.teavm.model.instructions.IntegerConstantInstruction;
|
import org.teavm.model.instructions.IntegerConstantInstruction;
|
||||||
|
@ -509,6 +510,9 @@ public class ListingParser {
|
||||||
case SHIFT_RIGHT_UNSIGNED:
|
case SHIFT_RIGHT_UNSIGNED:
|
||||||
parseBinary(receiver, variable, BinaryOperation.SHIFT_RIGHT_UNSIGNED);
|
parseBinary(receiver, variable, BinaryOperation.SHIFT_RIGHT_UNSIGNED);
|
||||||
break;
|
break;
|
||||||
|
case LEFT_SQUARE_BRACKET:
|
||||||
|
parseSubscript(receiver, variable);
|
||||||
|
break;
|
||||||
case IDENTIFIER:
|
case IDENTIFIER:
|
||||||
switch ((String) lexer.getTokenValue()) {
|
switch ((String) lexer.getTokenValue()) {
|
||||||
case "compareTo":
|
case "compareTo":
|
||||||
|
@ -549,6 +553,23 @@ public class ListingParser {
|
||||||
addInstruction(insn);
|
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 {
|
private void parseArrayAssignment(Variable array) throws IOException, ListingParseException {
|
||||||
Variable index = expectVariable();
|
Variable index = expectVariable();
|
||||||
expect(ListingToken.RIGHT_SQUARE_BRACKET);
|
expect(ListingToken.RIGHT_SQUARE_BRACKET);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user