ASM is smart enough to put all kinds of constants on stack, no need for custom logic

This commit is contained in:
Dmitry Jemerov
2011-04-07 15:06:17 +02:00
parent 2781aa18ff
commit cd3ed17e25
2 changed files with 7 additions and 12 deletions
@@ -96,18 +96,7 @@ public abstract class StackValue {
@Override
public void put(Type type, InstructionAdapter v) {
if (type == Type.INT_TYPE) {
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);
}
v.aconst(value);
}
@Override
@@ -269,6 +269,12 @@ public class NamespaceGenTest extends LightCodeInsightFixtureTestCase {
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 {
loadText(text);
System.out.println(generateToText());