ASM is smart enough to put all kinds of constants on stack, no need for custom logic
This commit is contained in:
@@ -96,18 +96,7 @@ public abstract class StackValue {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void put(Type type, InstructionAdapter v) {
|
public void put(Type type, InstructionAdapter v) {
|
||||||
if (type == Type.INT_TYPE) {
|
v.aconst(value);
|
||||||
if (value instanceof Number) {
|
|
||||||
v.iconst(((Number) value).intValue());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new UnsupportedOperationException("don't know how to put this value");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO other primitive types
|
|
||||||
else {
|
|
||||||
v.aconst(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -269,6 +269,12 @@ public class NamespaceGenTest extends LightCodeInsightFixtureTestCase {
|
|||||||
Byte.valueOf((byte) 126), Byte.valueOf((byte) 127), 1);
|
Byte.valueOf((byte) 126), Byte.valueOf((byte) 127), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testBooleanConstant() throws Exception {
|
||||||
|
loadText("fun foo(): Boolean = true");
|
||||||
|
final Method main = generateFunction();
|
||||||
|
assertEquals(true, main.invoke(null));
|
||||||
|
}
|
||||||
|
|
||||||
private void binOpTest(final String text, final Object arg1, final Object arg2, final Object expected) throws Exception {
|
private void binOpTest(final String text, final Object arg1, final Object arg2, final Object expected) throws Exception {
|
||||||
loadText(text);
|
loadText(text);
|
||||||
System.out.println(generateToText());
|
System.out.println(generateToText());
|
||||||
|
|||||||
Reference in New Issue
Block a user