mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
parent
17098495f2
commit
d97dce4650
|
@ -23,6 +23,7 @@ import org.teavm.model.RuntimeConstant;
|
||||||
import org.teavm.model.ValueType;
|
import org.teavm.model.ValueType;
|
||||||
import org.teavm.model.emit.ProgramEmitter;
|
import org.teavm.model.emit.ProgramEmitter;
|
||||||
import org.teavm.model.emit.ValueEmitter;
|
import org.teavm.model.emit.ValueEmitter;
|
||||||
|
import org.teavm.model.instructions.IntegerSubtype;
|
||||||
|
|
||||||
public class StringConcatFactorySubstitutor implements BootstrapMethodSubstitutor {
|
public class StringConcatFactorySubstitutor implements BootstrapMethodSubstitutor {
|
||||||
private ReferenceCache referenceCache = new ReferenceCache();
|
private ReferenceCache referenceCache = new ReferenceCache();
|
||||||
|
@ -99,7 +100,20 @@ public class StringConcatFactorySubstitutor implements BootstrapMethodSubstituto
|
||||||
}
|
}
|
||||||
|
|
||||||
private ValueEmitter appendArgument(ValueEmitter sb, ValueType type, ValueEmitter argument) {
|
private ValueEmitter appendArgument(ValueEmitter sb, ValueType type, ValueEmitter argument) {
|
||||||
if (!(type instanceof ValueType.Primitive)) {
|
if (type instanceof ValueType.Primitive) {
|
||||||
|
switch (((ValueType.Primitive) type).getKind()) {
|
||||||
|
case BYTE:
|
||||||
|
argument = argument.castToInteger(IntegerSubtype.BYTE);
|
||||||
|
type = ValueType.INTEGER;
|
||||||
|
break;
|
||||||
|
case SHORT:
|
||||||
|
argument = argument.castToInteger(IntegerSubtype.SHORT);
|
||||||
|
type = ValueType.INTEGER;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
type = ValueType.object("java.lang.Object");
|
type = ValueType.object("java.lang.Object");
|
||||||
}
|
}
|
||||||
MethodReference method = referenceCache.getCached(new MethodReference(STRING_BUILDER, "append", type,
|
MethodReference method = referenceCache.getCached(new MethodReference(STRING_BUILDER, "append", type,
|
||||||
|
|
|
@ -181,12 +181,22 @@ public class VMTest {
|
||||||
public void stringConcat() {
|
public void stringConcat() {
|
||||||
assertEquals("(23)", surroundWithParentheses(23));
|
assertEquals("(23)", surroundWithParentheses(23));
|
||||||
assertEquals("(42)", surroundWithParentheses(42));
|
assertEquals("(42)", surroundWithParentheses(42));
|
||||||
|
assertEquals("(17)", surroundWithParentheses((byte) 17));
|
||||||
|
assertEquals("(19)", surroundWithParentheses((short) 19));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String surroundWithParentheses(int value) {
|
private String surroundWithParentheses(int value) {
|
||||||
return "(" + value + ")";
|
return "(" + value + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String surroundWithParentheses(byte value) {
|
||||||
|
return "(" + value + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String surroundWithParentheses(short value) {
|
||||||
|
return "(" + value + ")";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void variableReadInCatchBlock() {
|
public void variableReadInCatchBlock() {
|
||||||
int n = foo();
|
int n = foo();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user