When by enum:

Generate TABLESWITCH/LOOKUPSWITCH bytecode command in case of "when" by enum entries
This commit is contained in:
Denis Zharkov
2014-07-15 19:55:39 +04:00
committed by Evgeny Gerashchenko
parent b2aa249817
commit 5a1c995b5c
29 changed files with 1059 additions and 12 deletions
@@ -31,7 +31,7 @@ import org.jetbrains.jet.codegen.AbstractBytecodeTextTest;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler/testData/codegen/bytecodeText")
@InnerTestClasses({BytecodeTextTestGenerated.BoxingOptimization.class, BytecodeTextTestGenerated.Constants.class, BytecodeTextTestGenerated.DirectInvoke.class, BytecodeTextTestGenerated.Statements.class})
@InnerTestClasses({BytecodeTextTestGenerated.BoxingOptimization.class, BytecodeTextTestGenerated.Constants.class, BytecodeTextTestGenerated.DirectInvoke.class, BytecodeTextTestGenerated.Statements.class, BytecodeTextTestGenerated.WhenEnumOptimization.class})
public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
@TestMetadata("accessorForProtected.kt")
public void testAccessorForProtected() throws Exception {
@@ -304,6 +304,54 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
}
@TestMetadata("compiler/testData/codegen/bytecodeText/whenEnumOptimization")
public static class WhenEnumOptimization extends AbstractBytecodeTextTest {
public void testAllFilesPresentInWhenEnumOptimization() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/bytecodeText/whenEnumOptimization"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("bigEnum.kt")
public void testBigEnum() throws Exception {
doTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/bigEnum.kt");
}
@TestMetadata("duplicatingItems.kt")
public void testDuplicatingItems() throws Exception {
doTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/duplicatingItems.kt");
}
@TestMetadata("expression.kt")
public void testExpression() throws Exception {
doTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/expression.kt");
}
@TestMetadata("functionLiteralInTopLevel.kt")
public void testFunctionLiteralInTopLevel() throws Exception {
doTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/functionLiteralInTopLevel.kt");
}
@TestMetadata("manyWhensWithinClass.kt")
public void testManyWhensWithinClass() throws Exception {
doTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/manyWhensWithinClass.kt");
}
@TestMetadata("nonConstantEnum.kt")
public void testNonConstantEnum() throws Exception {
doTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/nonConstantEnum.kt");
}
@TestMetadata("subjectAny.kt")
public void testSubjectAny() throws Exception {
doTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/subjectAny.kt");
}
@TestMetadata("withoutElse.kt")
public void testWithoutElse() throws Exception {
doTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/withoutElse.kt");
}
}
public static Test suite() {
TestSuite suite = new TestSuite("BytecodeTextTestGenerated");
suite.addTestSuite(BytecodeTextTestGenerated.class);
@@ -311,6 +359,7 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
suite.addTestSuite(Constants.class);
suite.addTestSuite(DirectInvoke.class);
suite.addTestSuite(Statements.class);
suite.addTestSuite(WhenEnumOptimization.class);
return suite;
}
}
@@ -31,7 +31,7 @@ import org.jetbrains.jet.codegen.generated.AbstractBlackBoxCodegenTest;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler/testData/codegen/boxWithStdlib")
@InnerTestClasses({BlackBoxWithStdlibCodegenTestGenerated.Annotations.class, BlackBoxWithStdlibCodegenTestGenerated.Arrays.class, BlackBoxWithStdlibCodegenTestGenerated.BoxingOptimization.class, BlackBoxWithStdlibCodegenTestGenerated.CallableReference.class, BlackBoxWithStdlibCodegenTestGenerated.Casts.class, BlackBoxWithStdlibCodegenTestGenerated.DataClasses.class, BlackBoxWithStdlibCodegenTestGenerated.Evaluate.class, BlackBoxWithStdlibCodegenTestGenerated.FullJdk.class, BlackBoxWithStdlibCodegenTestGenerated.HashPMap.class, BlackBoxWithStdlibCodegenTestGenerated.JdkAnnotations.class, BlackBoxWithStdlibCodegenTestGenerated.PlatformNames.class, BlackBoxWithStdlibCodegenTestGenerated.Ranges.class, BlackBoxWithStdlibCodegenTestGenerated.Reflection.class, BlackBoxWithStdlibCodegenTestGenerated.Regressions.class, BlackBoxWithStdlibCodegenTestGenerated.Strings.class, BlackBoxWithStdlibCodegenTestGenerated.ToArray.class, BlackBoxWithStdlibCodegenTestGenerated.Vararg.class, BlackBoxWithStdlibCodegenTestGenerated.When.class})
@InnerTestClasses({BlackBoxWithStdlibCodegenTestGenerated.Annotations.class, BlackBoxWithStdlibCodegenTestGenerated.Arrays.class, BlackBoxWithStdlibCodegenTestGenerated.BoxingOptimization.class, BlackBoxWithStdlibCodegenTestGenerated.CallableReference.class, BlackBoxWithStdlibCodegenTestGenerated.Casts.class, BlackBoxWithStdlibCodegenTestGenerated.DataClasses.class, BlackBoxWithStdlibCodegenTestGenerated.Evaluate.class, BlackBoxWithStdlibCodegenTestGenerated.FullJdk.class, BlackBoxWithStdlibCodegenTestGenerated.HashPMap.class, BlackBoxWithStdlibCodegenTestGenerated.JdkAnnotations.class, BlackBoxWithStdlibCodegenTestGenerated.PlatformNames.class, BlackBoxWithStdlibCodegenTestGenerated.Ranges.class, BlackBoxWithStdlibCodegenTestGenerated.Reflection.class, BlackBoxWithStdlibCodegenTestGenerated.Regressions.class, BlackBoxWithStdlibCodegenTestGenerated.Strings.class, BlackBoxWithStdlibCodegenTestGenerated.ToArray.class, BlackBoxWithStdlibCodegenTestGenerated.Vararg.class, BlackBoxWithStdlibCodegenTestGenerated.When.class, BlackBoxWithStdlibCodegenTestGenerated.WhenEnumOptimization.class})
public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInBoxWithStdlib() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithStdlib"), Pattern.compile("^(.+)\\.kt$"), true);
@@ -1952,6 +1952,59 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
}
@TestMetadata("compiler/testData/codegen/boxWithStdlib/whenEnumOptimization")
public static class WhenEnumOptimization extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInWhenEnumOptimization() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithStdlib/whenEnumOptimization"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("bigEnum.kt")
public void testBigEnum() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/whenEnumOptimization/bigEnum.kt");
}
@TestMetadata("duplicatingItems.kt")
public void testDuplicatingItems() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/whenEnumOptimization/duplicatingItems.kt");
}
@TestMetadata("enumInsideClassObject.kt")
public void testEnumInsideClassObject() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/whenEnumOptimization/enumInsideClassObject.kt");
}
@TestMetadata("expression.kt")
public void testExpression() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/whenEnumOptimization/expression.kt");
}
@TestMetadata("functionLiteralInTopLevel.kt")
public void testFunctionLiteralInTopLevel() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/whenEnumOptimization/functionLiteralInTopLevel.kt");
}
@TestMetadata("manyWhensWithinClass.kt")
public void testManyWhensWithinClass() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/whenEnumOptimization/manyWhensWithinClass.kt");
}
@TestMetadata("nonConstantEnum.kt")
public void testNonConstantEnum() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/whenEnumOptimization/nonConstantEnum.kt");
}
@TestMetadata("subjectAny.kt")
public void testSubjectAny() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/whenEnumOptimization/subjectAny.kt");
}
@TestMetadata("withoutElse.kt")
public void testWithoutElse() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/whenEnumOptimization/withoutElse.kt");
}
}
public static Test suite() {
TestSuite suite = new TestSuite("BlackBoxWithStdlibCodegenTestGenerated");
suite.addTestSuite(BlackBoxWithStdlibCodegenTestGenerated.class);
@@ -1973,6 +2026,7 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
suite.addTestSuite(ToArray.class);
suite.addTestSuite(Vararg.class);
suite.addTestSuite(When.class);
suite.addTestSuite(WhenEnumOptimization.class);
return suite;
}
}