mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-20 00:21:27 +00:00
Compare commits
136 Commits
rr/mitropo
...
rr/ir_inte
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0419d3056 | ||
|
|
9afda444a2 | ||
|
|
d4d47528a9 | ||
|
|
ba350ee38c | ||
|
|
63d263542e | ||
|
|
00fec35298 | ||
|
|
bf58d79256 | ||
|
|
fced9a3af8 | ||
|
|
854dcb0ccb | ||
|
|
0d75238a73 | ||
|
|
4baa67606a | ||
|
|
068805cf49 | ||
|
|
e623dcd595 | ||
|
|
51c12d14ad | ||
|
|
be22447d66 | ||
|
|
683ab3e7f4 | ||
|
|
39c87f0062 | ||
|
|
31ce659a77 | ||
|
|
3e234a8df9 | ||
|
|
39dae45924 | ||
|
|
eb78edf2c7 | ||
|
|
1a9370c7e8 | ||
|
|
b053d49d82 | ||
|
|
336f935f77 | ||
|
|
5035798bd2 | ||
|
|
245abde5fe | ||
|
|
f7cf1e0039 | ||
|
|
b477e11865 | ||
|
|
c6ad940faa | ||
|
|
3658701934 | ||
|
|
30000d0172 | ||
|
|
7bca7d1ce2 | ||
|
|
b3784cf81b | ||
|
|
4b375898c8 | ||
|
|
72cfcd94d5 | ||
|
|
53ccc4d76b | ||
|
|
47d5ea4e82 | ||
|
|
e5a453fdd5 | ||
|
|
7ed1f4749f | ||
|
|
47b5655b5f | ||
|
|
e57ee91eed | ||
|
|
65c8c6001b | ||
|
|
daa1717157 | ||
|
|
f8d10ce92e | ||
|
|
f783d91031 | ||
|
|
dfb72f08e4 | ||
|
|
a738173767 | ||
|
|
a285281447 | ||
|
|
43cbef8b7f | ||
|
|
d7aa0866f7 | ||
|
|
cea485b04a | ||
|
|
d11a004ec2 | ||
|
|
01e431f37e | ||
|
|
402330e9ce | ||
|
|
73833cf083 | ||
|
|
dd823fbccc | ||
|
|
6ffcb442f6 | ||
|
|
3bff5cbe03 | ||
|
|
533ec3069d | ||
|
|
8db03d05ea | ||
|
|
4b40f13c6e | ||
|
|
e306930a93 | ||
|
|
f5e2cddb8f | ||
|
|
2391658dab | ||
|
|
35994a7a6c | ||
|
|
969380dee7 | ||
|
|
1a5fa8e28b | ||
|
|
a2082dc897 | ||
|
|
d01615e6b8 | ||
|
|
12894e1d8b | ||
|
|
59e7a299b1 | ||
|
|
44449fea55 | ||
|
|
f4ecfacefa | ||
|
|
546220d6de | ||
|
|
b29f8c130a | ||
|
|
40dd9eaa84 | ||
|
|
6923960697 | ||
|
|
9725b4cb14 | ||
|
|
18ce7cd243 | ||
|
|
6e280cd33f | ||
|
|
43ce758bec | ||
|
|
6ef822b4a4 | ||
|
|
b4f4267fdd | ||
|
|
35042b0047 | ||
|
|
a9305a9880 | ||
|
|
aa4f3430f5 | ||
|
|
7a05bfce07 | ||
|
|
33ffcdae37 | ||
|
|
18cd6db015 | ||
|
|
409e73da6d | ||
|
|
7e018165d8 | ||
|
|
b9c382826e | ||
|
|
799e3a1815 | ||
|
|
500b818bc4 | ||
|
|
d697e57468 | ||
|
|
bda2aadf94 | ||
|
|
c70eb9a0b5 | ||
|
|
da95fcbbe6 | ||
|
|
cbbb3e30ac | ||
|
|
ac547399bc | ||
|
|
a52cc745b8 | ||
|
|
5543dd1822 | ||
|
|
e1162ce9b8 | ||
|
|
0cb8549af3 | ||
|
|
099ebbd119 | ||
|
|
8ecfa82714 | ||
|
|
dd1a6cd0ba | ||
|
|
9a66aabcba | ||
|
|
0c173ba1c1 | ||
|
|
8c02561f2d | ||
|
|
af0973f6f1 | ||
|
|
c383600f7a | ||
|
|
e73b83c4d1 | ||
|
|
109d51743c | ||
|
|
249aeac7dc | ||
|
|
d126bc0d11 | ||
|
|
a9bd43a115 | ||
|
|
0513066c71 | ||
|
|
911ed7eabe | ||
|
|
eb2c83bb87 | ||
|
|
38151cba10 | ||
|
|
2545a81ee7 | ||
|
|
f251b75e7f | ||
|
|
e81b666326 | ||
|
|
a0b9bef319 | ||
|
|
3656fab96b | ||
|
|
8a87741aed | ||
|
|
501dfa5f78 | ||
|
|
3294ef9904 | ||
|
|
8e9cc546c5 | ||
|
|
00f88d0de1 | ||
|
|
99e20a4d62 | ||
|
|
28b693746a | ||
|
|
64ee022ce9 | ||
|
|
e9c91d37f0 | ||
|
|
785c09d33e |
@@ -3561,6 +3561,39 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/constexpr")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Constexpr extends AbstractFirOldFrontendDiagnosticsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInConstexpr() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/constexpr"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("compileTimeMember.kt")
|
||||
public void testCompileTimeMember() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/constexpr/compileTimeMember.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constInitializer.kt")
|
||||
public void testConstInitializer() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/constexpr/constInitializer.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nonCompileTimeInDeclaration.kt")
|
||||
public void testNonCompileTimeInDeclaration() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/constexpr/nonCompileTimeInDeclaration.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nonConstInitializer.kt")
|
||||
public void testNonConstInitializer() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/constexpr/nonConstInitializer.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/constructorConsistency")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
@@ -287,6 +287,8 @@ public interface Errors {
|
||||
DiagnosticFactory1<PsiElement, KotlinType> TYPE_CANT_BE_USED_FOR_CONST_VAL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> CONST_VAL_WITHOUT_INITIALIZER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> CONST_VAL_WITH_NON_CONST_INITIALIZER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> NON_COMPILE_TIME_EXPRESSION_IN_COMPILE_TIME_DECLARATION = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory2<PsiElement, KtClassOrObject, KtNamedDeclaration> COMPILE_TIME_MEMBER_NOT_IMPLEMENTED = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<KtExpression> NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
|
||||
@@ -937,6 +937,8 @@ public class DefaultErrorMessages {
|
||||
MAP.put(TYPE_CANT_BE_USED_FOR_CONST_VAL, "Const ''val'' has type ''{0}''. Only primitives and String are allowed", RENDER_TYPE);
|
||||
MAP.put(CONST_VAL_WITHOUT_INITIALIZER, "Const 'val' should have an initializer");
|
||||
MAP.put(CONST_VAL_WITH_NON_CONST_INITIALIZER, "Const 'val' initializer should be a constant value");
|
||||
MAP.put(NON_COMPILE_TIME_EXPRESSION_IN_COMPILE_TIME_DECLARATION, "Compile time declaration must contains only compile time expressions");
|
||||
MAP.put(COMPILE_TIME_MEMBER_NOT_IMPLEMENTED, "{0} is marked as compile time and method ''{1}'' must be also compile time", RENDER_CLASS_OR_OBJECT, DECLARATION_NAME);
|
||||
MAP.put(NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION, "Only 'const val' can be used in constant expressions");
|
||||
|
||||
MAP.put(DEFAULT_VALUE_NOT_ALLOWED_IN_OVERRIDE, "An overriding function is not allowed to specify default values for its parameters");
|
||||
|
||||
@@ -36,7 +36,8 @@ private val DEFAULT_DECLARATION_CHECKERS = listOf(
|
||||
TailrecFunctionChecker,
|
||||
TrailingCommaDeclarationChecker,
|
||||
MissingDependencySupertypeChecker.ForDeclarations,
|
||||
FunInterfaceDeclarationChecker()
|
||||
FunInterfaceDeclarationChecker(),
|
||||
ConstexprDeclarationChecker
|
||||
)
|
||||
|
||||
private val DEFAULT_CALL_CHECKERS = listOf(
|
||||
@@ -49,7 +50,7 @@ private val DEFAULT_CALL_CHECKERS = listOf(
|
||||
PrimitiveNumericComparisonCallChecker, LambdaWithSuspendModifierCallChecker,
|
||||
UselessElvisCallChecker(), ResultTypeWithNullableOperatorsChecker(), NullableVarargArgumentCallChecker,
|
||||
NamedFunAsExpressionChecker, ContractNotAllowedCallChecker, ReifiedTypeParameterSubstitutionChecker(), TypeOfChecker,
|
||||
MissingDependencySupertypeChecker.ForCalls, AbstractClassInstantiationChecker,
|
||||
MissingDependencySupertypeChecker.ForCalls, AbstractClassInstantiationChecker, ConstexprCallChecker,
|
||||
)
|
||||
private val DEFAULT_TYPE_CHECKERS = emptyList<AdditionalTypeChecker>()
|
||||
private val DEFAULT_CLASSIFIER_USAGE_CHECKERS = listOf(
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptorWithAccessors
|
||||
import org.jetbrains.kotlin.descriptors.impl.VariableDescriptorWithInitializerImpl
|
||||
@@ -125,7 +126,8 @@ class VariableTypeAndInitializerResolver(
|
||||
val constant = constantExpressionEvaluator.evaluateExpression(initializer, trace, initializerType)
|
||||
?: return@computeInitializer null
|
||||
|
||||
if (constant.usesNonConstValAsConstant && variableDescriptor.isConst) {
|
||||
val supportsCompileTime = languageVersionSettings.supportsFeature(LanguageFeature.CompileTimeCalculations)
|
||||
if (!supportsCompileTime && constant.usesNonConstValAsConstant && variableDescriptor.isConst) {
|
||||
trace.report(Errors.NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION.on(initializer))
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.checkers
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.builtins.compileTimeAnnotationName
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||
import org.jetbrains.kotlin.psi.KtParameter
|
||||
import org.jetbrains.kotlin.psi.KtPrimaryConstructor
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isAnnotationConstructor
|
||||
import org.jetbrains.kotlin.resolve.findTopMostOverriddenDescriptors
|
||||
import org.jetbrains.kotlin.resolve.source.getPsi
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
object ConstexprCallChecker : CallChecker {
|
||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||
if (!context.languageVersionSettings.supportsFeature(LanguageFeature.CompileTimeCalculations)) return
|
||||
if (resolvedCall.call.callElement is KtAnnotationEntry || resolvedCall.candidateDescriptor.isAnnotationConstructor()) return
|
||||
if (hasEnclosingIntrinsicDeclaration(context)) return
|
||||
|
||||
val isConst = (context.scope.ownerDescriptor as? PropertyDescriptor)?.isConst == true
|
||||
val isInsideCompileTimeFun = hasEnclosingConstDeclaration(context)
|
||||
if (!isConst && !isInsideCompileTimeFun) return
|
||||
|
||||
val isCompileTime = isCompileTime(resolvedCall.resultingDescriptor, context)
|
||||
if (isConst && !isCompileTime) {
|
||||
context.trace.report(Errors.CONST_VAL_WITH_NON_CONST_INITIALIZER.on(resolvedCall.call.calleeExpression!!))
|
||||
} else if (isInsideCompileTimeFun && !isCompileTime) {
|
||||
context.trace.report(Errors.NON_COMPILE_TIME_EXPRESSION_IN_COMPILE_TIME_DECLARATION.on(resolvedCall.call.calleeExpression!!))
|
||||
}
|
||||
}
|
||||
|
||||
private fun isCompileTime(descriptor: CallableDescriptor, context: CallCheckerContext): Boolean {
|
||||
return when (descriptor) {
|
||||
is TypeAliasConstructorDescriptor -> descriptor.typeAliasDescriptor.isMarkedAsCompileTime()
|
||||
is PropertyAccessorDescriptor ->
|
||||
isCompileTime(descriptor.correspondingProperty, context) && (descriptor.isMarkedAsCompileTime() || descriptor.isDefault)
|
||||
is FunctionDescriptor ->
|
||||
descriptor.isMarkedAsCompileTime() || descriptor.isSpecial() || descriptor.overriddenDescriptors.any { it.isMarkedAsCompileTime() }
|
||||
is PropertyDescriptor ->
|
||||
descriptor.isMarkedAsCompileTime() || descriptor.isConst || descriptor.hasCompileTimePrimaryConstructor(context.trace.bindingContext)
|
||||
is ValueParameterDescriptor, is ReceiverParameterDescriptor, is VariableDescriptor ->
|
||||
context.scope.ownerDescriptor.isMarkedAsCompileTime()
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
private fun DeclarationDescriptor.isMarkedWith(annotation: FqName): Boolean {
|
||||
if (this.annotations.hasAnnotation(annotation)) return true
|
||||
if (this is ClassDescriptor && this.isCompanionObject) return false
|
||||
return (this.containingDeclaration as? ClassDescriptor)?.isMarkedWith(annotation) ?: false
|
||||
}
|
||||
|
||||
private fun DeclarationDescriptor.isMarkedAsCompileTime(): Boolean {
|
||||
if (this is AnonymousFunctionDescriptor) return this.containingDeclaration.isMarkedAsCompileTime()
|
||||
return this.isMarkedWith(compileTimeAnnotationName) || this.safeAs<PropertyDescriptor>()?.isConst == true
|
||||
}
|
||||
|
||||
private fun PropertyDescriptor.hasCompileTimePrimaryConstructor(bindingContext: BindingContext): Boolean {
|
||||
val property = this.findTopMostOverriddenDescriptors().single()
|
||||
val ktParameter = property.source.getPsi() as? KtParameter ?: return false
|
||||
val primaryConstructor = ktParameter.ownerFunction as? KtPrimaryConstructor ?: return false
|
||||
val classOwner = primaryConstructor.getContainingClassOrObject()
|
||||
val annotations = primaryConstructor.annotationEntries.mapNotNull { bindingContext[BindingContext.ANNOTATION, it] } +
|
||||
classOwner.annotationEntries.mapNotNull { bindingContext[BindingContext.ANNOTATION, it] }
|
||||
return annotations.any { it.fqName == compileTimeAnnotationName }
|
||||
}
|
||||
|
||||
private fun hasEnclosingConstDeclaration(context: CallCheckerContext): Boolean {
|
||||
return context.scope.ownerDescriptor.isMarkedAsCompileTime()
|
||||
}
|
||||
|
||||
private fun hasEnclosingIntrinsicDeclaration(context: CallCheckerContext): Boolean {
|
||||
return context.scope.ownerDescriptor.isMarkedWith(FqName("kotlin.EvaluateIntrinsic"))
|
||||
}
|
||||
|
||||
// TODO add annotation to special functions?
|
||||
private fun CallableDescriptor.isSpecial(): Boolean {
|
||||
return this.name.asString().contains("SPECIAL-FUNCTION")
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,9 @@
|
||||
package org.jetbrains.kotlin.resolve.checkers
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
@@ -31,7 +34,7 @@ object ConstModifierChecker : DeclarationChecker {
|
||||
|
||||
val constModifierPsiElement = declaration.modifierList!!.getModifier(KtTokens.CONST_KEYWORD)!!
|
||||
|
||||
val diagnostic = checkCanBeConst(declaration, constModifierPsiElement, descriptor).diagnostic
|
||||
val diagnostic = checkCanBeConst(declaration, constModifierPsiElement, descriptor, context.languageVersionSettings).diagnostic
|
||||
if (diagnostic != null) {
|
||||
context.trace.report(diagnostic)
|
||||
}
|
||||
@@ -43,12 +46,14 @@ object ConstModifierChecker : DeclarationChecker {
|
||||
private fun checkCanBeConst(
|
||||
declaration: KtDeclaration,
|
||||
constModifierPsiElement: PsiElement,
|
||||
descriptor: VariableDescriptor
|
||||
descriptor: VariableDescriptor,
|
||||
languageSettings: LanguageVersionSettings = LanguageVersionSettingsImpl.DEFAULT
|
||||
): ConstApplicability {
|
||||
if (descriptor.isVar) {
|
||||
return Errors.WRONG_MODIFIER_TARGET.on(constModifierPsiElement, KtTokens.CONST_KEYWORD, "vars").nonApplicable()
|
||||
}
|
||||
|
||||
// TODO remove the following check after introducing constexpr modifier
|
||||
val containingDeclaration = descriptor.containingDeclaration
|
||||
if (containingDeclaration is ClassDescriptor && containingDeclaration.kind != ClassKind.OBJECT) {
|
||||
return Errors.CONST_VAL_NOT_TOP_LEVEL_OR_OBJECT.on(constModifierPsiElement).nonApplicable()
|
||||
@@ -76,7 +81,7 @@ object ConstModifierChecker : DeclarationChecker {
|
||||
return Errors.CONST_VAL_WITHOUT_INITIALIZER.on(constModifierPsiElement).nonApplicable()
|
||||
}
|
||||
|
||||
if (descriptor.compileTimeInitializer == null) {
|
||||
if (!languageSettings.supportsFeature(LanguageFeature.CompileTimeCalculations) && descriptor.compileTimeInitializer == null) {
|
||||
return Errors.CONST_VAL_WITH_NON_CONST_INITIALIZER.on(declaration.initializer!!).nonApplicable()
|
||||
}
|
||||
|
||||
@@ -89,4 +94,4 @@ sealed class ConstApplicability(val canBeConst: Boolean, val diagnostic: Diagnos
|
||||
class NonApplicable(diagnostic: Diagnostic? = null) : ConstApplicability(false, diagnostic)
|
||||
}
|
||||
|
||||
private fun Diagnostic.nonApplicable() = ConstApplicability.NonApplicable(this)
|
||||
private fun Diagnostic.nonApplicable() = ConstApplicability.NonApplicable(this)
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.checkers
|
||||
|
||||
import org.jetbrains.kotlin.builtins.compileTimeAnnotationName
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.containingClass
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
|
||||
object ConstexprDeclarationChecker : DeclarationChecker {
|
||||
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
|
||||
if (!context.languageVersionSettings.supportsFeature(LanguageFeature.CompileTimeCalculations)) return
|
||||
if (!descriptor.annotations.hasAnnotation(compileTimeAnnotationName)) return
|
||||
|
||||
val ktClass = when (declaration) {
|
||||
is KtClass -> declaration
|
||||
is KtPrimaryConstructor -> declaration.getContainingClassOrObject()
|
||||
else -> return
|
||||
}
|
||||
|
||||
val overriddenDeclaration = ktClass.declarations
|
||||
.filterIsInstance<KtNamedDeclaration>()
|
||||
.filter { it.hasModifier(KtTokens.OVERRIDE_KEYWORD) }
|
||||
for (ktDeclaration in overriddenDeclaration) {
|
||||
val annotationEntries = ktDeclaration.annotationEntries
|
||||
val classAnnotationEntries = ktDeclaration.containingClass()?.annotationEntries
|
||||
|
||||
fun List<KtAnnotationEntry>?.containsCompileTimeAnnotation(): Boolean {
|
||||
this ?: return false
|
||||
return this.any { context.trace.bindingContext[BindingContext.ANNOTATION, it]?.fqName == compileTimeAnnotationName }
|
||||
}
|
||||
|
||||
if (!annotationEntries.containsCompileTimeAnnotation() && !classAnnotationEntries.containsCompileTimeAnnotation()) {
|
||||
context.trace.report(Errors.COMPILE_TIME_MEMBER_NOT_IMPLEMENTED.on(ktDeclaration, ktClass, ktDeclaration))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,15 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile(project(":core:descriptors.jvm")) //used to get java classes fq names by kotlin names
|
||||
compile(project(":compiler:util"))
|
||||
compile(project(":compiler:frontend"))
|
||||
compile(project(":compiler:backend-common"))
|
||||
compile(project(":compiler:ir.tree"))
|
||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||
compileOnly(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-core")) { // primary used in ir interpreter
|
||||
isTransitive = false
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
||||
@@ -0,0 +1,752 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.interpreter
|
||||
|
||||
import kotlinx.coroutines.*
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.builtins.*
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.exceptions.InterpreterException
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.exceptions.InterpreterMethodNotFoundException
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.exceptions.InterpreterTimeOutException
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.intrinsics.IntrinsicEvaluator
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.stack.*
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.state.*
|
||||
import org.jetbrains.kotlin.builtins.DefaultBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.UnsignedTypes
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrErrorExpressionImpl
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import java.lang.invoke.MethodHandle
|
||||
|
||||
private const val MAX_STACK_SIZE = 10_000
|
||||
private const val MAX_COMMANDS = 500_000
|
||||
|
||||
class IrInterpreter(irModule: IrModuleFragment) {
|
||||
private val irBuiltIns = irModule.irBuiltins
|
||||
private val irExceptions = irModule.files.flatMap { it.declarations }.filterIsInstance<IrClass>()
|
||||
.filter { it.isSubclassOf(irBuiltIns.throwableClass.owner) }
|
||||
|
||||
private val stack = StackImpl()
|
||||
private var commandCount = 0
|
||||
|
||||
companion object {
|
||||
private val mapOfEnums = mutableMapOf<String, Complex>()
|
||||
private val mapOfObjects = mutableMapOf<String, Complex>()
|
||||
}
|
||||
|
||||
private fun Any?.getType(defaultType: IrType): IrType {
|
||||
return when (this) {
|
||||
is Boolean -> irBuiltIns.booleanType
|
||||
is Char -> irBuiltIns.charType
|
||||
is Byte -> irBuiltIns.byteType
|
||||
is Short -> irBuiltIns.shortType
|
||||
is Int -> irBuiltIns.intType
|
||||
is Long -> irBuiltIns.longType
|
||||
is String -> irBuiltIns.stringType
|
||||
is Float -> irBuiltIns.floatType
|
||||
is Double -> irBuiltIns.doubleType
|
||||
null -> irBuiltIns.nothingType
|
||||
else -> defaultType
|
||||
}
|
||||
}
|
||||
|
||||
private fun incrementAndCheckCommands() {
|
||||
commandCount++
|
||||
if (commandCount >= MAX_COMMANDS) throw InterpreterTimeOutException()
|
||||
}
|
||||
|
||||
fun interpret(expression: IrExpression): IrExpression {
|
||||
stack.clean()
|
||||
return try {
|
||||
runBlocking {
|
||||
return@runBlocking when (val returnLabel = withContext(this.coroutineContext) { expression.interpret().returnLabel }) {
|
||||
ReturnLabel.NEXT -> stack.popReturnValue().toIrExpression(expression)
|
||||
ReturnLabel.EXCEPTION -> {
|
||||
val message = (stack.popReturnValue() as ExceptionState).getFullDescription()
|
||||
IrErrorExpressionImpl(expression.startOffset, expression.endOffset, expression.type, "\n" + message)
|
||||
}
|
||||
else -> TODO("$returnLabel not supported as result of interpretation")
|
||||
}
|
||||
}
|
||||
} catch (e: InterpreterException) {
|
||||
// TODO don't handle, throw to lowering
|
||||
IrErrorExpressionImpl(expression.startOffset, expression.endOffset, expression.type, "\n" + e.message)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun IrElement.interpret(): ExecutionResult {
|
||||
try {
|
||||
incrementAndCheckCommands()
|
||||
val executionResult = when (this) {
|
||||
is IrFunctionImpl -> interpretFunction(this)
|
||||
is IrCall -> interpretCall(this)
|
||||
is IrConstructorCall -> interpretConstructorCall(this)
|
||||
is IrEnumConstructorCall -> interpretEnumConstructorCall(this)
|
||||
is IrDelegatingConstructorCall -> interpretDelegatedConstructorCall(this)
|
||||
is IrInstanceInitializerCall -> interpretInstanceInitializerCall(this)
|
||||
is IrBody -> interpretBody(this)
|
||||
is IrBlock -> interpretBlock(this)
|
||||
is IrReturn -> interpretReturn(this)
|
||||
is IrSetField -> interpretSetField(this)
|
||||
is IrGetField -> interpretGetField(this)
|
||||
is IrGetValue -> interpretGetValue(this)
|
||||
is IrGetObjectValue -> interpretGetObjectValue(this)
|
||||
is IrGetEnumValue -> interpretGetEnumValue(this)
|
||||
is IrEnumEntry -> interpretEnumEntry(this)
|
||||
is IrConst<*> -> interpretConst(this)
|
||||
is IrVariable -> interpretVariable(this)
|
||||
is IrSetVariable -> interpretSetVariable(this)
|
||||
is IrTypeOperatorCall -> interpretTypeOperatorCall(this)
|
||||
is IrBranch -> interpretBranch(this)
|
||||
is IrWhileLoop -> interpretWhile(this)
|
||||
is IrDoWhileLoop -> interpretDoWhile(this)
|
||||
is IrWhen -> interpretWhen(this)
|
||||
is IrBreak -> interpretBreak(this)
|
||||
is IrContinue -> interpretContinue(this)
|
||||
is IrVararg -> interpretVararg(this)
|
||||
is IrSpreadElement -> interpretSpreadElement(this)
|
||||
is IrTry -> interpretTry(this)
|
||||
is IrCatch -> interpretCatch(this)
|
||||
is IrThrow -> interpretThrow(this)
|
||||
is IrStringConcatenation -> interpretStringConcatenation(this)
|
||||
is IrFunctionExpression -> interpretFunctionExpression(this)
|
||||
is IrFunctionReference -> interpretFunctionReference(this)
|
||||
is IrComposite -> interpretComposite(this)
|
||||
|
||||
else -> TODO("${this.javaClass} not supported")
|
||||
}
|
||||
|
||||
return executionResult.getNextLabel(this) { this@getNextLabel.interpret() }
|
||||
} catch (e: InterpreterException) {
|
||||
throw e
|
||||
} catch (e: Throwable) {
|
||||
// catch exception from JVM such as: ArithmeticException, StackOverflowError and others
|
||||
val exceptionName = e::class.java.simpleName
|
||||
val irExceptionClass = irExceptions.firstOrNull { it.name.asString() == exceptionName } ?: irBuiltIns.throwableClass.owner
|
||||
stack.pushReturnValue(ExceptionState(e, irExceptionClass, stack.getStackTrace()))
|
||||
return Exception
|
||||
}
|
||||
}
|
||||
|
||||
// this method is used to get stack trace after exception
|
||||
private suspend fun interpretFunction(irFunction: IrFunctionImpl): ExecutionResult {
|
||||
yield()
|
||||
|
||||
if (irFunction.fileOrNull != null) stack.setCurrentFrameName(irFunction)
|
||||
|
||||
if (stack.getStackTrace().size == MAX_STACK_SIZE) throw StackOverflowError("")
|
||||
|
||||
if (irFunction.body is IrSyntheticBody) return handleIntrinsicMethods(irFunction)
|
||||
return irFunction.body?.interpret() ?: throw InterpreterException("Ir function must be with body")
|
||||
}
|
||||
|
||||
private suspend fun MethodHandle?.invokeMethod(irFunction: IrFunction): ExecutionResult {
|
||||
this ?: return handleIntrinsicMethods(irFunction)
|
||||
val result = this.invokeWithArguments(irFunction.getArgsForMethodInvocation(stack.getAll()))
|
||||
stack.pushReturnValue(result.toState(result.getType(irFunction.returnType)))
|
||||
|
||||
return Next
|
||||
}
|
||||
|
||||
private suspend fun handleIntrinsicMethods(irFunction: IrFunction): ExecutionResult {
|
||||
return IntrinsicEvaluator().evaluate(irFunction, stack) { this.interpret() }
|
||||
}
|
||||
|
||||
private suspend fun calculateAbstract(irFunction: IrFunction): ExecutionResult {
|
||||
if (irFunction.body == null) {
|
||||
val receiver = stack.getVariableState(irFunction.getReceiver()!!) as Complex
|
||||
val instance = receiver.getOriginal()
|
||||
|
||||
val functionImplementation = instance.getIrFunction(irFunction.descriptor)
|
||||
if (functionImplementation?.body == null) throw InterpreterMethodNotFoundException("Method \"${irFunction.name}\" wasn't implemented")
|
||||
|
||||
val valueArguments = mutableListOf<Variable>()
|
||||
valueArguments.add(Variable(functionImplementation.getReceiver()!!, instance))
|
||||
functionImplementation.valueParameters
|
||||
.map { Variable(it.descriptor, stack.getVariableState(it.descriptor)) }
|
||||
.forEach { valueArguments.add(it) }
|
||||
return stack.newFrame(initPool = valueArguments) {
|
||||
functionImplementation.interpret()
|
||||
}
|
||||
}
|
||||
return irFunction.body!!.interpret()
|
||||
}
|
||||
|
||||
private suspend fun calculateOverridden(owner: IrSimpleFunction): ExecutionResult {
|
||||
val variableDescriptor = owner.getReceiver()!!
|
||||
val superQualifier = (stack.getVariableState(variableDescriptor) as? Complex)?.superClass
|
||||
if (superQualifier == null) {
|
||||
// superQualifier is null for exception state => find method in builtins
|
||||
return calculateBuiltIns(owner.getLastOverridden() as IrSimpleFunction)
|
||||
}
|
||||
val overridden = owner.overriddenSymbols.single()
|
||||
|
||||
val valueArguments = mutableListOf<Variable>()
|
||||
valueArguments.add(Variable(overridden.owner.getReceiver()!!, superQualifier))
|
||||
owner.valueParameters.zip(overridden.owner.valueParameters)
|
||||
.map { Variable(it.second.descriptor, stack.getVariableState(it.first.descriptor)) }
|
||||
.forEach { valueArguments.add(it) }
|
||||
|
||||
return stack.newFrame(initPool = valueArguments) {
|
||||
val overriddenOwner = overridden.owner
|
||||
return@newFrame when {
|
||||
overriddenOwner.body != null -> overriddenOwner.interpret()
|
||||
superQualifier.superClass == null -> calculateBuiltIns(overriddenOwner)
|
||||
else -> calculateOverridden(overriddenOwner)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun calculateBuiltIns(irFunction: IrFunction): ExecutionResult {
|
||||
val descriptor = irFunction.descriptor
|
||||
val methodName = when (val property = (irFunction as? IrSimpleFunction)?.correspondingPropertySymbol) {
|
||||
null -> descriptor.name.asString()
|
||||
else -> property.owner.name.asString()
|
||||
}
|
||||
val args = stack.getAll().map { it.state }
|
||||
|
||||
val receiverType = descriptor.dispatchReceiverParameter?.type ?: descriptor.extensionReceiverParameter?.type
|
||||
val argsType = listOfNotNull(receiverType) + descriptor.valueParameters.map { it.original.type }
|
||||
val argsValues = args.map { (it as? Complex)?.getOriginal() ?: (it as Primitive<*>).value }
|
||||
val signature = CompileTimeFunction(methodName, argsType.map { it.toString() })
|
||||
|
||||
val result = when (argsType.size) {
|
||||
1 -> {
|
||||
val function = unaryFunctions[signature]
|
||||
?: throw InterpreterMethodNotFoundException("For given function $signature there is no entry in unary map")
|
||||
function.invoke(argsValues.first())
|
||||
}
|
||||
2 -> {
|
||||
val function = binaryFunctions[signature]
|
||||
?: throw InterpreterMethodNotFoundException("For given function $signature there is no entry in binary map")
|
||||
when (methodName) {
|
||||
"rangeTo" -> return calculateRangeTo(irFunction.returnType)
|
||||
else -> function.invoke(argsValues[0], argsValues[1])
|
||||
}
|
||||
}
|
||||
3 -> {
|
||||
val function = ternaryFunctions[signature]
|
||||
?: throw InterpreterMethodNotFoundException("For given function $signature there is no entry in ternary map")
|
||||
function.invoke(argsValues[0], argsValues[1], argsValues[2])
|
||||
}
|
||||
else -> throw InterpreterException("Unsupported number of arguments")
|
||||
}
|
||||
|
||||
stack.pushReturnValue(result.toState(result.getType(irFunction.returnType)))
|
||||
return Next
|
||||
}
|
||||
|
||||
private suspend fun calculateRangeTo(type: IrType): ExecutionResult {
|
||||
val constructor = type.classOrNull!!.owner.constructors.first()
|
||||
val constructorCall = IrConstructorCallImpl.fromSymbolOwner(constructor.returnType, constructor.symbol)
|
||||
|
||||
val primitiveValueParameters = stack.getAll().map { it.state as Primitive<*> }
|
||||
primitiveValueParameters.forEachIndexed { index, primitive ->
|
||||
constructorCall.putValueArgument(index, primitive.value.toIrConst(primitive.type))
|
||||
}
|
||||
|
||||
val constructorValueParameters = constructor.valueParameters.map { it.descriptor }.zip(primitiveValueParameters)
|
||||
return stack.newFrame(initPool = constructorValueParameters.map { Variable(it.first, it.second) }) {
|
||||
constructorCall.interpret()
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun interpretValueParameters(
|
||||
expression: IrFunctionAccessExpression, irFunction: IrFunction, pool: MutableList<Variable>
|
||||
): ExecutionResult {
|
||||
// if irFunction is lambda and it has receiver, then first descriptor must be taken from extension receiver
|
||||
val receiverAsFirstArgument = when (expression.dispatchReceiver?.type?.isFunction()) {
|
||||
true -> listOfNotNull(irFunction.getExtensionReceiver())
|
||||
else -> listOf()
|
||||
}
|
||||
val valueParametersDescriptors = receiverAsFirstArgument + irFunction.descriptor.valueParameters
|
||||
|
||||
val valueArguments = (0 until expression.valueArgumentsCount).map { expression.getValueArgument(it) }
|
||||
val defaultValues = expression.symbol.owner.valueParameters.map { it.defaultValue?.expression }
|
||||
|
||||
return stack.newFrame(asSubFrame = true, initPool = pool) {
|
||||
for (i in valueArguments.indices) {
|
||||
(valueArguments[i] ?: defaultValues[i])?.interpret()?.check { return@newFrame it }
|
||||
?: stack.pushReturnValue(listOf<Any?>().toPrimitiveStateArray(expression.getVarargType(i)!!))
|
||||
|
||||
with(Variable(valueParametersDescriptors[i], stack.popReturnValue())) {
|
||||
stack.addVar(this) //must add value argument in current stack because it can be used later as default argument
|
||||
pool.add(this)
|
||||
}
|
||||
}
|
||||
Next
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun interpretCall(expression: IrCall): ExecutionResult {
|
||||
val valueArguments = mutableListOf<Variable>()
|
||||
// dispatch receiver processing
|
||||
val rawDispatchReceiver = expression.dispatchReceiver
|
||||
rawDispatchReceiver?.interpret()?.check { return it }
|
||||
val dispatchReceiver = rawDispatchReceiver?.let { stack.popReturnValue() }
|
||||
|
||||
// extension receiver processing
|
||||
val rawExtensionReceiver = expression.extensionReceiver
|
||||
rawExtensionReceiver?.interpret()?.check { return it }
|
||||
val extensionReceiver = rawExtensionReceiver?.let { stack.popReturnValue() }
|
||||
|
||||
// find correct ir function
|
||||
val functionReceiver = dispatchReceiver?.getFunctionReceiver(expression.superQualifierSymbol?.owner)
|
||||
val irFunction = functionReceiver?.getIrFunction(expression.symbol.descriptor) ?: expression.symbol.owner
|
||||
|
||||
// it is important firstly to add receiver, then arguments; this order is used in builtin method call
|
||||
irFunction.getDispatchReceiver()?.let { functionReceiver?.let { receiver -> valueArguments.add(Variable(it, receiver)) } }
|
||||
irFunction.getExtensionReceiver()?.let { extensionReceiver?.let { receiver -> valueArguments.add(Variable(it, receiver)) } }
|
||||
|
||||
interpretValueParameters(expression, irFunction, valueArguments).check { return it }
|
||||
|
||||
valueArguments.addAll(getTypeArguments(irFunction, expression) { stack.getVariableState(it) })
|
||||
if (dispatchReceiver is Common) valueArguments.addAll(dispatchReceiver.typeArguments)
|
||||
if (extensionReceiver is Common) valueArguments.addAll(extensionReceiver.typeArguments)
|
||||
|
||||
if (irFunction.isLocal) valueArguments.addAll(dispatchReceiver.extractNonLocalDeclarations())
|
||||
|
||||
return stack.newFrame(asSubFrame = irFunction.isInline || irFunction.isLocal, initPool = valueArguments) {
|
||||
val isWrapper = dispatchReceiver is Wrapper && rawExtensionReceiver == null
|
||||
val isInterfaceDefaultMethod = irFunction.body != null && (irFunction.parent as? IrClass)?.isInterface == true
|
||||
return@newFrame when {
|
||||
isWrapper && !isInterfaceDefaultMethod -> (dispatchReceiver as Wrapper).getMethod(irFunction).invokeMethod(irFunction)
|
||||
irFunction.hasAnnotation(evaluateIntrinsicAnnotation) -> Wrapper.getStaticMethod(irFunction).invokeMethod(irFunction)
|
||||
irFunction.isAbstract() -> calculateAbstract(irFunction) //abstract check must be before fake overridden check
|
||||
irFunction.isFakeOverridden() -> calculateOverridden(irFunction as IrSimpleFunction)
|
||||
irFunction.body == null || dispatchReceiver is Primitive<*> -> calculateBuiltIns(irFunction)
|
||||
else -> irFunction.interpret()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun interpretInstanceInitializerCall(call: IrInstanceInitializerCall): ExecutionResult {
|
||||
val irClass = call.classSymbol.owner
|
||||
|
||||
// properties processing
|
||||
val classProperties = irClass.declarations.filterIsInstance<IrProperty>()
|
||||
classProperties.forEach { property ->
|
||||
property.backingField?.initializer?.expression?.interpret()?.check { return it }
|
||||
val receiver = irClass.descriptor.thisAsReceiverParameter
|
||||
if (property.backingField?.initializer != null) {
|
||||
val receiverState = stack.getVariableState(receiver)
|
||||
val propertyState = Variable(property.backingField!!.descriptor, stack.popReturnValue())
|
||||
receiverState.setState(propertyState)
|
||||
}
|
||||
}
|
||||
|
||||
// init blocks processing
|
||||
val anonymousInitializer = irClass.declarations.filterIsInstance<IrAnonymousInitializer>().filter { !it.isStatic }
|
||||
anonymousInitializer.forEach { init -> init.body.interpret().check { return it } }
|
||||
|
||||
return Next
|
||||
}
|
||||
|
||||
private suspend fun interpretConstructor(constructorCall: IrFunctionAccessExpression): ExecutionResult {
|
||||
val owner = constructorCall.symbol.owner
|
||||
val valueArguments = mutableListOf<Variable>()
|
||||
|
||||
interpretValueParameters(constructorCall, owner, valueArguments).check { return it }
|
||||
|
||||
val parent = owner.parent as IrClass
|
||||
if (parent.hasAnnotation(evaluateIntrinsicAnnotation)) {
|
||||
return stack.newFrame(initPool = valueArguments) { Wrapper.getConstructorMethod(owner).invokeMethod(owner) }
|
||||
}
|
||||
|
||||
if (parent.defaultType.isArray() || parent.defaultType.isPrimitiveArray()) {
|
||||
// array constructor doesn't have body so must be treated separately
|
||||
return stack.newFrame(initPool = valueArguments) { handleIntrinsicMethods(owner) }
|
||||
}
|
||||
|
||||
val state = Common(parent)
|
||||
state.typeArguments.addAll(getTypeArguments(parent, constructorCall) { stack.getVariableState(it) } + stack.getAllTypeArguments())
|
||||
if (parent.isLocal) state.fields.addAll(stack.getAll()) // TODO save only necessary declarations
|
||||
valueArguments.add(Variable(constructorCall.getThisAsReceiver(), state)) //used to set up fields in body
|
||||
return stack.newFrame(initPool = valueArguments + state.typeArguments) {
|
||||
val statements = constructorCall.getBody()!!.statements
|
||||
// enum entry use IrTypeOperatorCall with IMPLICIT_COERCION_TO_UNIT as delegation call, but we need the value
|
||||
((statements[0] as? IrTypeOperatorCall)?.argument ?: statements[0]).interpret().check { return@newFrame it }
|
||||
val returnedState = stack.popReturnValue() as Complex
|
||||
|
||||
for (i in 1 until statements.size) statements[i].interpret().check { return@newFrame it }
|
||||
|
||||
stack.pushReturnValue(state.apply { this.setSuperClassInstance(returnedState) })
|
||||
Next
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun interpretConstructorCall(constructorCall: IrConstructorCall): ExecutionResult {
|
||||
return interpretConstructor(constructorCall)
|
||||
}
|
||||
|
||||
private suspend fun interpretEnumConstructorCall(enumConstructorCall: IrEnumConstructorCall): ExecutionResult {
|
||||
return interpretConstructor(enumConstructorCall)
|
||||
}
|
||||
|
||||
private suspend fun interpretDelegatedConstructorCall(delegatingConstructorCall: IrDelegatingConstructorCall): ExecutionResult {
|
||||
if (delegatingConstructorCall.symbol.descriptor.containingDeclaration.defaultType == DefaultBuiltIns.Instance.anyType) {
|
||||
val anyAsStateObject = Common(irBuiltIns.anyClass.owner)
|
||||
stack.pushReturnValue(anyAsStateObject)
|
||||
return Next
|
||||
}
|
||||
|
||||
return interpretConstructor(delegatingConstructorCall)
|
||||
}
|
||||
|
||||
private suspend fun interpretConst(expression: IrConst<*>): ExecutionResult {
|
||||
fun getSignedType(unsignedClassName: String): IrType {
|
||||
return when (unsignedClassName) {
|
||||
"UByte" -> irBuiltIns.byteType
|
||||
"UShort" -> irBuiltIns.shortType
|
||||
"UInt" -> irBuiltIns.intType
|
||||
"ULong" -> irBuiltIns.longType
|
||||
else -> throw InterpreterException("Unsupported unsigned class $unsignedClassName")
|
||||
}
|
||||
}
|
||||
|
||||
return if (UnsignedTypes.isUnsignedType(expression.type.toKotlinType())) {
|
||||
val unsignedClass = expression.type.classOrNull!!
|
||||
val constructor = unsignedClass.constructors.single().owner
|
||||
val constructorCall = IrConstructorCallImpl.fromSymbolOwner(constructor.returnType, constructor.symbol)
|
||||
constructorCall.putValueArgument(0, expression.value.toIrConst(getSignedType(unsignedClass.owner.name.asString())))
|
||||
|
||||
constructorCall.interpret()
|
||||
} else {
|
||||
stack.pushReturnValue(expression.toPrimitive())
|
||||
Next
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun interpretStatements(statements: List<IrStatement>): ExecutionResult {
|
||||
var executionResult: ExecutionResult = Next
|
||||
for (statement in statements) {
|
||||
when (statement) {
|
||||
is IrClass -> if (statement.isLocal) Next else TODO("Only local classes are supported")
|
||||
is IrFunction -> if (statement.isLocal) Next else TODO("Only local functions are supported")
|
||||
else -> executionResult = statement.interpret().check { return it }
|
||||
}
|
||||
}
|
||||
return executionResult
|
||||
}
|
||||
|
||||
private suspend fun interpretBlock(block: IrBlock): ExecutionResult {
|
||||
return stack.newFrame(asSubFrame = true) { interpretStatements(block.statements) }
|
||||
}
|
||||
|
||||
private suspend fun interpretBody(body: IrBody): ExecutionResult {
|
||||
return stack.newFrame(asSubFrame = true) { interpretStatements(body.statements) }
|
||||
}
|
||||
|
||||
private suspend fun interpretReturn(expression: IrReturn): ExecutionResult {
|
||||
expression.value.interpret().check { return it }
|
||||
return Return.addInfo(expression.returnTargetSymbol.descriptor.toString())
|
||||
}
|
||||
|
||||
private suspend fun interpretWhile(expression: IrWhileLoop): ExecutionResult {
|
||||
while (true) {
|
||||
expression.condition.interpret().check { return it }
|
||||
if (stack.popReturnValue().asBooleanOrNull() != true) break
|
||||
expression.body?.interpret()?.check { return it }
|
||||
}
|
||||
return Next
|
||||
}
|
||||
|
||||
private suspend fun interpretDoWhile(expression: IrDoWhileLoop): ExecutionResult {
|
||||
do {
|
||||
// pool from body must be seen to condition expression, so must create temp frame here
|
||||
stack.newFrame(asSubFrame = true) {
|
||||
expression.body?.interpret()?.check { return@newFrame it }
|
||||
expression.condition.interpret().check { return@newFrame it }
|
||||
Next
|
||||
}.check { return it }
|
||||
|
||||
if (stack.popReturnValue().asBooleanOrNull() != true) break
|
||||
} while (true)
|
||||
return Next
|
||||
}
|
||||
|
||||
private suspend fun interpretWhen(expression: IrWhen): ExecutionResult {
|
||||
var executionResult: ExecutionResult = Next
|
||||
for (branch in expression.branches) {
|
||||
executionResult = branch.interpret().check { return it }
|
||||
}
|
||||
return executionResult
|
||||
}
|
||||
|
||||
private suspend fun interpretBranch(expression: IrBranch): ExecutionResult {
|
||||
val executionResult = expression.condition.interpret().check { return it }
|
||||
if (stack.popReturnValue().asBooleanOrNull() == true) {
|
||||
expression.result.interpret().check { return it }
|
||||
return BreakWhen
|
||||
}
|
||||
return executionResult
|
||||
}
|
||||
|
||||
private fun interpretBreak(breakStatement: IrBreak): ExecutionResult {
|
||||
return BreakLoop.addInfo(breakStatement.label ?: "")
|
||||
}
|
||||
|
||||
private fun interpretContinue(continueStatement: IrContinue): ExecutionResult {
|
||||
return Continue.addInfo(continueStatement.label ?: "")
|
||||
}
|
||||
|
||||
private suspend fun interpretSetField(expression: IrSetField): ExecutionResult {
|
||||
expression.value.interpret().check { return it }
|
||||
|
||||
// receiver is null only for top level var, but it cannot be used in constexpr; corresponding check is on frontend
|
||||
val receiver = (expression.receiver as IrDeclarationReference).symbol.descriptor
|
||||
stack.getVariableState(receiver).setState(Variable(expression.symbol.owner.descriptor, stack.popReturnValue()))
|
||||
return Next
|
||||
}
|
||||
|
||||
private suspend fun interpretGetField(expression: IrGetField): ExecutionResult {
|
||||
val receiver = (expression.receiver as? IrDeclarationReference)?.symbol?.descriptor
|
||||
// receiver is null, for example, for top level fields
|
||||
val result = receiver?.let { stack.getVariableState(receiver).getState(expression.symbol.descriptor)?.copy() }
|
||||
?: return (expression.symbol.owner.initializer?.expression?.interpret() ?: Next)
|
||||
stack.pushReturnValue(result)
|
||||
return Next
|
||||
}
|
||||
|
||||
private fun interpretGetValue(expression: IrGetValue): ExecutionResult {
|
||||
stack.pushReturnValue(stack.getVariableState(expression.symbol.descriptor).copy())
|
||||
return Next
|
||||
}
|
||||
|
||||
private suspend fun interpretVariable(expression: IrVariable): ExecutionResult {
|
||||
expression.initializer?.interpret()?.check { return it } ?: return Next
|
||||
stack.addVar(Variable(expression.descriptor, stack.popReturnValue()))
|
||||
return Next
|
||||
}
|
||||
|
||||
private suspend fun interpretSetVariable(expression: IrSetVariable): ExecutionResult {
|
||||
expression.value.interpret().check { return it }
|
||||
|
||||
if (stack.contains(expression.symbol.descriptor)) {
|
||||
val variable = stack.getVariableState(expression.symbol.descriptor)
|
||||
variable.setState(Variable(expression.symbol.descriptor, stack.popReturnValue()))
|
||||
} else {
|
||||
stack.addVar(Variable(expression.symbol.descriptor, stack.popReturnValue()))
|
||||
}
|
||||
return Next
|
||||
}
|
||||
|
||||
private fun interpretGetObjectValue(expression: IrGetObjectValue): ExecutionResult {
|
||||
val owner = expression.symbol.owner
|
||||
val objectSignature = owner.fqNameWhenAvailable.toString()
|
||||
mapOfObjects[objectSignature]?.let { return Next.apply { stack.pushReturnValue(it) } }
|
||||
|
||||
val objectState = when {
|
||||
owner.hasAnnotation(evaluateIntrinsicAnnotation) -> Wrapper.getCompanionObject(owner)
|
||||
else -> Common(owner).apply { setSuperClassRecursive() } // TODO test type arguments
|
||||
}
|
||||
mapOfObjects[objectSignature] = objectState
|
||||
stack.pushReturnValue(objectState)
|
||||
return Next
|
||||
}
|
||||
|
||||
private suspend fun interpretGetEnumValue(expression: IrGetEnumValue): ExecutionResult {
|
||||
val enumEntry = expression.symbol.owner
|
||||
val enumSignature = enumEntry.fqNameWhenAvailable.toString()
|
||||
mapOfEnums[enumSignature]?.let { return Next.apply { stack.pushReturnValue(it) } }
|
||||
|
||||
val enumClass = enumEntry.symbol.owner.parentAsClass
|
||||
val valueOfFun = enumClass.declarations.single { it.nameForIrSerialization.asString() == "valueOf" } as IrFunction
|
||||
enumClass.declarations.filterIsInstance<IrEnumEntry>().forEach {
|
||||
val executionResult = when {
|
||||
enumClass.hasAnnotation(evaluateIntrinsicAnnotation) -> {
|
||||
val enumEntryName = it.name.asString().toState(irBuiltIns.stringType)
|
||||
val enumNameAsVariable = Variable(valueOfFun.valueParameters.first().descriptor, enumEntryName)
|
||||
stack.newFrame(initPool = listOf(enumNameAsVariable)) { Wrapper.getEnumEntry(enumClass)!!.invokeMethod(valueOfFun) }
|
||||
}
|
||||
else -> interpretEnumEntry(it)
|
||||
}
|
||||
executionResult.check { result -> return result }
|
||||
mapOfEnums[it.fqNameWhenAvailable.toString()] = stack.popReturnValue() as Complex
|
||||
}
|
||||
|
||||
stack.pushReturnValue(mapOfEnums[enumSignature]!!)
|
||||
return Next
|
||||
}
|
||||
|
||||
private suspend fun interpretEnumEntry(enumEntry: IrEnumEntry): ExecutionResult {
|
||||
val enumClass = enumEntry.symbol.owner.parentAsClass
|
||||
val enumEntries = enumClass.declarations.filterIsInstance<IrEnumEntry>()
|
||||
|
||||
val enumSuperCall = (enumClass.primaryConstructor?.body?.statements?.firstOrNull() as? IrEnumConstructorCall)
|
||||
if (enumEntries.isNotEmpty() && enumSuperCall != null) {
|
||||
val valueArguments = listOf(
|
||||
enumEntry.name.asString().toIrConst(irBuiltIns.stringType), enumEntries.indexOf(enumEntry).toIrConst(irBuiltIns.intType)
|
||||
)
|
||||
enumSuperCall.mapValueParameters { valueArguments[it.index] }
|
||||
}
|
||||
|
||||
val executionResult = enumEntry.initializerExpression?.interpret()?.check { return it }
|
||||
enumSuperCall?.mapValueParameters { null } // restore to null
|
||||
return executionResult ?: throw InterpreterException("Initializer at enum entry ${enumEntry.fqNameWhenAvailable} is null")
|
||||
}
|
||||
|
||||
private suspend fun interpretTypeOperatorCall(expression: IrTypeOperatorCall): ExecutionResult {
|
||||
val executionResult = expression.argument.interpret().check { return it }
|
||||
val typeOperandDescriptor = expression.typeOperand.classifierOrFail.descriptor
|
||||
val typeOperandClass = expression.typeOperand.classOrNull?.owner ?: stack.getVariableState(typeOperandDescriptor).irClass
|
||||
|
||||
when (expression.operator) {
|
||||
// coercion to unit means that return value isn't used
|
||||
IrTypeOperator.IMPLICIT_COERCION_TO_UNIT -> stack.popReturnValue()
|
||||
IrTypeOperator.CAST, IrTypeOperator.IMPLICIT_CAST -> {
|
||||
if (!stack.peekReturnValue().irClass.isSubclassOf(typeOperandClass)) {
|
||||
val convertibleClassName = stack.popReturnValue().irClass.fqNameWhenAvailable
|
||||
throw ClassCastException("$convertibleClassName cannot be cast to ${typeOperandClass.fqNameWhenAvailable}")
|
||||
}
|
||||
}
|
||||
IrTypeOperator.SAFE_CAST -> {
|
||||
if (!stack.peekReturnValue().irClass.isSubclassOf(typeOperandClass)) {
|
||||
stack.popReturnValue()
|
||||
stack.pushReturnValue(null.toState(irBuiltIns.nothingType))
|
||||
}
|
||||
}
|
||||
IrTypeOperator.INSTANCEOF -> {
|
||||
val isInstance = stack.popReturnValue().irClass.isSubclassOf(typeOperandClass)
|
||||
stack.pushReturnValue(isInstance.toState(irBuiltIns.nothingType))
|
||||
}
|
||||
IrTypeOperator.NOT_INSTANCEOF -> {
|
||||
val isInstance = stack.popReturnValue().irClass.isSubclassOf(typeOperandClass)
|
||||
stack.pushReturnValue((!isInstance).toState(irBuiltIns.nothingType))
|
||||
}
|
||||
else -> TODO("${expression.operator} not implemented")
|
||||
}
|
||||
return executionResult
|
||||
}
|
||||
|
||||
private suspend fun interpretVararg(expression: IrVararg): ExecutionResult {
|
||||
val args = expression.elements.flatMap {
|
||||
it.interpret().check { executionResult -> return executionResult }
|
||||
return@flatMap when (val result = stack.popReturnValue()) {
|
||||
is Wrapper -> listOf(result.value)
|
||||
is Primitive<*> ->
|
||||
when (val value = result.value) {
|
||||
is ByteArray -> value.toList()
|
||||
is CharArray -> value.toList()
|
||||
is ShortArray -> value.toList()
|
||||
is IntArray -> value.toList()
|
||||
is LongArray -> value.toList()
|
||||
is FloatArray -> value.toList()
|
||||
is DoubleArray -> value.toList()
|
||||
is BooleanArray -> value.toList()
|
||||
is Array<*> -> value.toList()
|
||||
else -> listOf(value)
|
||||
}
|
||||
else -> listOf(result)
|
||||
}
|
||||
}
|
||||
|
||||
val array = when (expression.type.classifierOrFail.descriptor.name.asString()) {
|
||||
"UByteArray", "UShortArray", "UIntArray", "ULongArray" -> {
|
||||
val owner = expression.type.classOrNull!!.owner
|
||||
val constructor = owner.primaryConstructor!!
|
||||
val storageParameter = constructor.valueParameters.single()
|
||||
val primitiveArray = args.map { ((it as Common).fields.single().state as Primitive<*>).value }
|
||||
val unsignedArray = primitiveArray.toPrimitiveStateArray(storageParameter.type)
|
||||
Common(owner).apply {
|
||||
setSuperClassRecursive()
|
||||
fields.add(Variable(storageParameter.descriptor, unsignedArray))
|
||||
}
|
||||
}
|
||||
else -> args.toPrimitiveStateArray(expression.type)
|
||||
}
|
||||
stack.pushReturnValue(array)
|
||||
return Next
|
||||
}
|
||||
|
||||
private suspend fun interpretSpreadElement(spreadElement: IrSpreadElement): ExecutionResult {
|
||||
return spreadElement.expression.interpret().check { return it }
|
||||
}
|
||||
|
||||
private suspend fun interpretTry(expression: IrTry): ExecutionResult {
|
||||
try {
|
||||
expression.tryResult.interpret().check(ReturnLabel.EXCEPTION) { return it } // if not exception -> return
|
||||
val exception = stack.peekReturnValue() as ExceptionState
|
||||
for (catchBlock in expression.catches) {
|
||||
if (exception.isSubtypeOf(catchBlock.catchParameter.type.classOrNull!!.owner)) {
|
||||
catchBlock.interpret().check { return it }
|
||||
break
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
expression.finallyExpression?.interpret()?.check { return it }
|
||||
}
|
||||
|
||||
return Next
|
||||
}
|
||||
|
||||
private suspend fun interpretCatch(expression: IrCatch): ExecutionResult {
|
||||
val catchParameter = Variable(expression.parameter, stack.popReturnValue())
|
||||
return stack.newFrame(asSubFrame = true, initPool = listOf(catchParameter)) {
|
||||
expression.result.interpret()
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun interpretThrow(expression: IrThrow): ExecutionResult {
|
||||
expression.value.interpret().check { return it }
|
||||
when (val exception = stack.popReturnValue()) {
|
||||
is Common -> stack.pushReturnValue(ExceptionState(exception, stack.getStackTrace()))
|
||||
is Wrapper -> stack.pushReturnValue(ExceptionState(exception, stack.getStackTrace()))
|
||||
is ExceptionState -> stack.pushReturnValue(exception)
|
||||
else -> throw InterpreterException("${exception::class} cannot be used as exception state")
|
||||
}
|
||||
return Exception
|
||||
}
|
||||
|
||||
private suspend fun interpretStringConcatenation(expression: IrStringConcatenation): ExecutionResult {
|
||||
val result = StringBuilder()
|
||||
expression.arguments.forEach {
|
||||
it.interpret().check { executionResult -> return executionResult }
|
||||
result.append(
|
||||
when (val returnValue = stack.popReturnValue()) {
|
||||
is Primitive<*> -> returnValue.value.toString()
|
||||
is Wrapper -> returnValue.value.toString()
|
||||
is Common -> {
|
||||
val toStringFun = returnValue.getToStringFunction()
|
||||
stack.newFrame(initPool = mutableListOf(Variable(toStringFun.getReceiver()!!, returnValue))) {
|
||||
toStringFun.body?.let { toStringFun.interpret() } ?: calculateOverridden(toStringFun)
|
||||
}.check { executionResult -> return executionResult }
|
||||
stack.popReturnValue().asString()
|
||||
}
|
||||
else -> throw InterpreterException("$returnValue cannot be used in StringConcatenation expression")
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
stack.pushReturnValue(result.toString().toState(expression.type))
|
||||
return Next
|
||||
}
|
||||
|
||||
private fun interpretFunctionExpression(expression: IrFunctionExpression): ExecutionResult {
|
||||
val lambda = Lambda(expression.function, expression.type.classOrNull!!.owner)
|
||||
if (expression.function.isLocal) lambda.fields.addAll(stack.getAll()) // TODO save only necessary declarations
|
||||
stack.pushReturnValue(lambda)
|
||||
return Next
|
||||
}
|
||||
|
||||
private fun interpretFunctionReference(reference: IrFunctionReference): ExecutionResult {
|
||||
stack.pushReturnValue(Lambda(reference.symbol.owner, reference.type.classOrNull!!.owner))
|
||||
return Next
|
||||
}
|
||||
|
||||
private suspend fun interpretComposite(expression: IrComposite): ExecutionResult {
|
||||
return when (expression.origin) {
|
||||
IrStatementOrigin.DESTRUCTURING_DECLARATION -> interpretStatements(expression.statements)
|
||||
null -> interpretStatements(expression.statements) // is null for body of do while loop
|
||||
else -> TODO("${expression.origin} not implemented")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.interpreter
|
||||
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.IrCall
|
||||
import org.jetbrains.kotlin.ir.expressions.IrReturnableBlock
|
||||
import org.jetbrains.kotlin.ir.expressions.IrWhen
|
||||
import org.jetbrains.kotlin.ir.expressions.IrWhileLoop
|
||||
|
||||
enum class ReturnLabel {
|
||||
NEXT, RETURN, BREAK_LOOP, BREAK_WHEN, CONTINUE, EXCEPTION
|
||||
}
|
||||
|
||||
interface ExecutionResult {
|
||||
val returnLabel: ReturnLabel
|
||||
|
||||
suspend fun getNextLabel(irElement: IrElement, interpret: suspend IrElement.() -> ExecutionResult): ExecutionResult
|
||||
}
|
||||
|
||||
inline fun ExecutionResult.check(toCheckLabel: ReturnLabel = ReturnLabel.NEXT, returnBlock: (ExecutionResult) -> Unit): ExecutionResult {
|
||||
if (this.returnLabel != toCheckLabel) returnBlock(this)
|
||||
return this
|
||||
}
|
||||
|
||||
open class ExecutionResultWithoutInfo(override val returnLabel: ReturnLabel) : ExecutionResult {
|
||||
override suspend fun getNextLabel(irElement: IrElement, interpret: suspend IrElement.() -> ExecutionResult): ExecutionResult {
|
||||
return when (returnLabel) {
|
||||
ReturnLabel.RETURN -> this
|
||||
ReturnLabel.BREAK_WHEN -> when (irElement) {
|
||||
is IrWhen -> Next
|
||||
else -> this
|
||||
}
|
||||
ReturnLabel.BREAK_LOOP -> this
|
||||
ReturnLabel.CONTINUE -> this
|
||||
ReturnLabel.EXCEPTION -> this
|
||||
ReturnLabel.NEXT -> this
|
||||
}
|
||||
}
|
||||
|
||||
fun addInfo(info: String): ExecutionResultWithInfo {
|
||||
return ExecutionResultWithInfo(returnLabel, info)
|
||||
}
|
||||
}
|
||||
|
||||
class ExecutionResultWithInfo(override val returnLabel: ReturnLabel, val info: String) : ExecutionResultWithoutInfo(returnLabel) {
|
||||
override suspend fun getNextLabel(irElement: IrElement, interpret: suspend IrElement.() -> ExecutionResult): ExecutionResult {
|
||||
return when (returnLabel) {
|
||||
ReturnLabel.RETURN -> when (irElement) {
|
||||
is IrCall -> if (info == irElement.symbol.descriptor.toString()) Next else this
|
||||
is IrReturnableBlock -> if (info == irElement.symbol.descriptor.toString()) Next else this
|
||||
is IrFunctionImpl -> if (info == irElement.descriptor.toString()) Next else this
|
||||
else -> this
|
||||
}
|
||||
ReturnLabel.BREAK_WHEN -> when (irElement) {
|
||||
is IrWhen -> Next
|
||||
else -> this
|
||||
}
|
||||
ReturnLabel.BREAK_LOOP -> when (irElement) {
|
||||
is IrWhileLoop -> if ((irElement.label ?: "") == info) Next else this
|
||||
else -> this
|
||||
}
|
||||
ReturnLabel.CONTINUE -> when (irElement) {
|
||||
is IrWhileLoop -> if ((irElement.label ?: "") == info) irElement.interpret() else this
|
||||
else -> this
|
||||
}
|
||||
ReturnLabel.EXCEPTION -> Exception
|
||||
ReturnLabel.NEXT -> Next
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object Next : ExecutionResultWithoutInfo(ReturnLabel.NEXT)
|
||||
object Return : ExecutionResultWithoutInfo(ReturnLabel.RETURN)
|
||||
object BreakLoop : ExecutionResultWithoutInfo(ReturnLabel.BREAK_LOOP)
|
||||
object BreakWhen : ExecutionResultWithoutInfo(ReturnLabel.BREAK_WHEN)
|
||||
object Continue : ExecutionResultWithoutInfo(ReturnLabel.CONTINUE)
|
||||
object Exception : ExecutionResultWithoutInfo(ReturnLabel.EXCEPTION)
|
||||
@@ -0,0 +1,259 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.interpreter
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.builtins.evaluateIntrinsicAnnotation
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.stack.Variable
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.state.*
|
||||
import org.jetbrains.kotlin.builtins.UnsignedTypes
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedReceiverParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.util.defaultType
|
||||
import org.jetbrains.kotlin.ir.util.fqNameForIrSerialization
|
||||
import org.jetbrains.kotlin.ir.util.isFakeOverride
|
||||
import org.jetbrains.kotlin.ir.util.isInterface
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitClassReceiver
|
||||
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
|
||||
|
||||
// main purpose is to get receiver from constructor call
|
||||
fun IrMemberAccessExpression.getThisAsReceiver(): DeclarationDescriptor {
|
||||
return (this.symbol.descriptor.containingDeclaration as ClassDescriptor).thisAsReceiverParameter
|
||||
}
|
||||
|
||||
fun IrFunction.getDispatchReceiver(): DeclarationDescriptor? {
|
||||
return (this.symbol.descriptor.containingDeclaration as? ClassDescriptor)?.thisAsReceiverParameter
|
||||
}
|
||||
|
||||
fun IrFunction.getExtensionReceiver(): DeclarationDescriptor? {
|
||||
return this.extensionReceiverParameter?.descriptor
|
||||
}
|
||||
|
||||
fun IrFunction.getReceiver(): DeclarationDescriptor? {
|
||||
return this.getDispatchReceiver() ?: this.getExtensionReceiver()
|
||||
}
|
||||
|
||||
fun IrFunctionAccessExpression.getBody(): IrBody? {
|
||||
return this.symbol.owner.body
|
||||
}
|
||||
|
||||
fun DeclarationDescriptor.equalTo(other: DeclarationDescriptor): Boolean {
|
||||
return this.isSubtypeOf(other) || this.hasSameNameAs(other) || this == other
|
||||
}
|
||||
|
||||
private fun WrappedReceiverParameterDescriptor.isEqualTo(other: DeclarationDescriptor): Boolean {
|
||||
return when (val container = this.containingDeclaration) {
|
||||
is FunctionDescriptor -> container.dispatchReceiverParameter == other || container.extensionReceiverParameter == other
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
private fun DeclarationDescriptor.isSubtypeOf(other: DeclarationDescriptor): Boolean {
|
||||
if (this !is ReceiverParameterDescriptor || other !is ReceiverParameterDescriptor) return false
|
||||
return when {
|
||||
this is WrappedReceiverParameterDescriptor && other is WrappedReceiverParameterDescriptor ->
|
||||
this.isEqualTo(other) || other.isEqualTo(this)
|
||||
this is WrappedReceiverParameterDescriptor -> this.isEqualTo(other)
|
||||
other is WrappedReceiverParameterDescriptor -> other.isEqualTo(this)
|
||||
this.value is ImplicitClassReceiver && other.value is ImplicitClassReceiver -> this.value.type.isSubtypeOf(other.value.type)
|
||||
this.value is ExtensionReceiver && other.value is ExtensionReceiver -> this.value == other.value
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
private fun DeclarationDescriptor.hasSameNameAs(other: DeclarationDescriptor): Boolean {
|
||||
return (this is VariableDescriptor && other is VariableDescriptor && this.name == other.name) ||
|
||||
(this is TypeParameterDescriptor && other is TypeParameterDescriptor && this.name == other.name) ||
|
||||
(this is FunctionDescriptor && other is FunctionDescriptor && //this == other
|
||||
this.valueParameters.map { it.type.toString() } == other.valueParameters.map { it.type.toString() } &&
|
||||
this.name == other.name)
|
||||
}
|
||||
|
||||
fun IrFunction.isAbstract(): Boolean {
|
||||
return (this as? IrSimpleFunction)?.modality == Modality.ABSTRACT
|
||||
}
|
||||
|
||||
fun IrFunction.isFakeOverridden(): Boolean {
|
||||
return this.isFakeOverride
|
||||
}
|
||||
|
||||
fun State.toIrExpression(expression: IrExpression): IrExpression {
|
||||
val start = expression.startOffset
|
||||
val end = expression.endOffset
|
||||
return when (this) {
|
||||
is Primitive<*> ->
|
||||
when (this.value) {
|
||||
// toIrConst call is necessary to replace ir offsets
|
||||
is Boolean, is Char, is Byte, is Short, is Int, is Long, is String, is Float, is Double ->
|
||||
this.value.toIrConst(this.type, start, end)
|
||||
null -> this.value.toIrConst(this.type, start, end)
|
||||
else -> expression // TODO support for arrays
|
||||
}
|
||||
is Complex -> {
|
||||
val type = this.irClass.defaultType.toKotlinType()
|
||||
when {
|
||||
UnsignedTypes.isUnsignedType(type) ->
|
||||
(this.fields.single().state as Primitive<*>).value.toIrConst(this.irClass.defaultType, start, end)
|
||||
else -> expression
|
||||
}
|
||||
}
|
||||
else -> expression // TODO support
|
||||
}
|
||||
}
|
||||
|
||||
fun Any?.toState(irType: IrType): State {
|
||||
return when (this) {
|
||||
is State -> this
|
||||
is Boolean, is Char, is Byte, is Short, is Int, is Long, is String, is Float, is Double, is Array<*>, is ByteArray,
|
||||
is CharArray, is ShortArray, is IntArray, is LongArray, is FloatArray, is DoubleArray, is BooleanArray -> Primitive(this, irType)
|
||||
null -> Primitive(this, irType)
|
||||
else -> Wrapper(this, irType.classOrNull!!.owner)
|
||||
}
|
||||
}
|
||||
|
||||
fun Any?.toIrConst(irType: IrType, startOffset: Int = UNDEFINED_OFFSET, endOffset: Int = UNDEFINED_OFFSET): IrConst<*> {
|
||||
return when (this) {
|
||||
is Boolean -> IrConstImpl(startOffset, endOffset, irType, IrConstKind.Boolean, this)
|
||||
is Char -> IrConstImpl(startOffset, endOffset, irType, IrConstKind.Char, this)
|
||||
is Byte -> IrConstImpl(startOffset, endOffset, irType, IrConstKind.Byte, this)
|
||||
is Short -> IrConstImpl(startOffset, endOffset, irType, IrConstKind.Short, this)
|
||||
is Int -> IrConstImpl(startOffset, endOffset, irType, IrConstKind.Int, this)
|
||||
is Long -> IrConstImpl(startOffset, endOffset, irType, IrConstKind.Long, this)
|
||||
is String -> IrConstImpl(startOffset, endOffset, irType, IrConstKind.String, this)
|
||||
is Float -> IrConstImpl(startOffset, endOffset, irType, IrConstKind.Float, this)
|
||||
is Double -> IrConstImpl(startOffset, endOffset, irType, IrConstKind.Double, this)
|
||||
null -> IrConstImpl(startOffset, endOffset, irType, IrConstKind.Null, this)
|
||||
else -> throw UnsupportedOperationException("Unsupported const element type ${this::class}")
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> IrConst<T>.toPrimitive(): Primitive<T> {
|
||||
return Primitive(this.value, this.type)
|
||||
}
|
||||
|
||||
fun IrAnnotationContainer?.hasAnnotation(annotation: FqName): Boolean {
|
||||
this ?: return false
|
||||
if (this.annotations.isNotEmpty()) {
|
||||
return this.annotations.any { it.symbol.descriptor.containingDeclaration.fqNameSafe == annotation }
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun IrAnnotationContainer.getAnnotation(annotation: FqName): IrConstructorCall {
|
||||
return this.annotations.firstOrNull { it.symbol.descriptor.containingDeclaration.fqNameSafe == annotation }
|
||||
?: ((this as IrFunction).parent as IrClass).annotations.first { it.symbol.descriptor.containingDeclaration.fqNameSafe == annotation }
|
||||
}
|
||||
|
||||
fun IrAnnotationContainer.getEvaluateIntrinsicValue(): String? {
|
||||
if (!this.hasAnnotation(evaluateIntrinsicAnnotation)) return null
|
||||
return (this.getAnnotation(evaluateIntrinsicAnnotation).getValueArgument(0) as IrConst<*>).value.toString()
|
||||
}
|
||||
|
||||
fun getPrimitiveClass(fqName: String, asObject: Boolean = false): Class<*>? {
|
||||
return when (fqName) {
|
||||
"kotlin.Boolean" -> if (asObject) Boolean::class.javaObjectType else Boolean::class.java
|
||||
"kotlin.Char" -> if (asObject) Char::class.javaObjectType else Char::class.java
|
||||
"kotlin.Byte" -> if (asObject) Byte::class.javaObjectType else Byte::class.java
|
||||
"kotlin.Short" -> if (asObject) Short::class.javaObjectType else Short::class.java
|
||||
"kotlin.Int" -> if (asObject) Int::class.javaObjectType else Int::class.java
|
||||
"kotlin.Long" -> if (asObject) Long::class.javaObjectType else Long::class.java
|
||||
"kotlin.String" -> if (asObject) String::class.javaObjectType else String::class.java
|
||||
"kotlin.Float" -> if (asObject) Float::class.javaObjectType else Float::class.java
|
||||
"kotlin.Double" -> if (asObject) Double::class.javaObjectType else Double::class.java
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
fun IrType.getFqName(): String? {
|
||||
return this.classOrNull?.owner?.fqNameForIrSerialization?.asString()
|
||||
}
|
||||
|
||||
fun IrFunction.getArgsForMethodInvocation(args: List<Variable>): List<Any?> {
|
||||
val argsValues = args.map {
|
||||
when (val state = it.state) {
|
||||
is ExceptionState -> state.getThisAsCauseForException()
|
||||
is Wrapper -> state.value
|
||||
is Primitive<*> -> state.value
|
||||
else -> throw AssertionError("${state::class} is unsupported as argument for wrapper method invocation")
|
||||
}
|
||||
}.toMutableList()
|
||||
|
||||
// TODO if vararg isn't last parameter
|
||||
// must convert vararg array into separated elements for correct invoke
|
||||
if (this.valueParameters.lastOrNull()?.varargElementType != null) {
|
||||
val varargValue = argsValues.last()
|
||||
argsValues.removeAt(argsValues.size - 1)
|
||||
argsValues.addAll(varargValue as Array<out Any?>)
|
||||
}
|
||||
|
||||
return argsValues
|
||||
}
|
||||
|
||||
fun IrFunction.getLastOverridden(): IrFunction {
|
||||
if (this !is IrFunctionImpl) return this
|
||||
|
||||
var function = this as IrFunctionImpl
|
||||
while (function.overriddenSymbols.isNotEmpty()) {
|
||||
function = function.overriddenSymbols.first().owner as IrFunctionImpl
|
||||
}
|
||||
return function
|
||||
}
|
||||
|
||||
fun List<Any?>.toPrimitiveStateArray(type: IrType): Primitive<*> {
|
||||
return when (type.getFqName()) {
|
||||
"kotlin.ByteArray" -> Primitive(ByteArray(size) { i -> (this[i] as Number).toByte() }, type)
|
||||
"kotlin.CharArray" -> Primitive(CharArray(size) { i -> this[i] as Char }, type)
|
||||
"kotlin.ShortArray" -> Primitive(ShortArray(size) { i -> (this[i] as Number).toShort() }, type)
|
||||
"kotlin.IntArray" -> Primitive(IntArray(size) { i -> (this[i] as Number).toInt() }, type)
|
||||
"kotlin.LongArray" -> Primitive(LongArray(size) { i -> (this[i] as Number).toLong() }, type)
|
||||
"kotlin.FloatArray" -> Primitive(FloatArray(size) { i -> (this[i] as Number).toFloat() }, type)
|
||||
"kotlin.DoubleArray" -> Primitive(DoubleArray(size) { i -> (this[i] as Number).toDouble() }, type)
|
||||
"kotlin.BooleanArray" -> Primitive(BooleanArray(size) { i -> this[i].toString().toBoolean() }, type)
|
||||
else -> Primitive<Array<*>>(this.toTypedArray(), type)
|
||||
}
|
||||
}
|
||||
|
||||
fun State?.getFunctionReceiver(superIrClass: IrClass?): State? {
|
||||
return when {
|
||||
superIrClass == null -> this
|
||||
superIrClass.isInterface -> {
|
||||
val interfaceState = Common(superIrClass)
|
||||
(this!!.copy() as Complex).setSuperClassInstance(interfaceState)
|
||||
interfaceState
|
||||
}
|
||||
else -> (this as Complex).superClass
|
||||
}
|
||||
}
|
||||
|
||||
fun IrFunctionAccessExpression.getVarargType(index: Int): IrType? {
|
||||
val varargType = this.symbol.owner.valueParameters[index].varargElementType ?: return null
|
||||
val typeParameter = varargType.classifierOrFail.owner as IrTypeParameter
|
||||
return this.getTypeArgument(typeParameter.index)
|
||||
}
|
||||
|
||||
fun getTypeArguments(
|
||||
container: IrTypeParametersContainer, expression: IrFunctionAccessExpression, mapper: (TypeParameterDescriptor) -> State
|
||||
): List<Variable> {
|
||||
return container.typeParameters.mapIndexed { index, typeParameter ->
|
||||
val typeArgument = expression.getTypeArgument(index)!!
|
||||
val argumentState = typeArgument.classOrNull?.owner?.let { Common(it) }
|
||||
?: mapper(typeArgument.classifierOrFail.descriptor as TypeParameterDescriptor)
|
||||
Variable(typeParameter.descriptor, argumentState)
|
||||
}
|
||||
}
|
||||
|
||||
fun State?.extractNonLocalDeclarations(): List<Variable> {
|
||||
this ?: return listOf()
|
||||
return this.fields.filterNot { it.descriptor.containingDeclaration == this.irClass.descriptor }
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.interpreter.builtins
|
||||
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
|
||||
val compileTimeAnnotation = FqName("kotlin.CompileTimeCalculation")
|
||||
val evaluateIntrinsicAnnotation = FqName("kotlin.EvaluateIntrinsic")
|
||||
val contractsDslAnnotation = FqName("kotlin.internal.ContractsDsl")
|
||||
|
||||
data class CompileTimeFunction(val methodName: String, val args: List<String>)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> unaryOperation(
|
||||
methodName: String, receiverType: String, function: (T) -> Any?
|
||||
): Pair<CompileTimeFunction, Function1<Any?, Any?>> {
|
||||
return CompileTimeFunction(methodName, listOf(receiverType)) to function as Function1<Any?, Any?>
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T, E> binaryOperation(
|
||||
methodName: String, receiverType: String, parameterType: String, function: (T, E) -> Any?
|
||||
): Pair<CompileTimeFunction, Function2<Any?, Any?, Any?>> {
|
||||
return CompileTimeFunction(methodName, listOfNotNull(receiverType, parameterType)) to function as Function2<Any?, Any?, Any?>
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T, E, R> ternaryOperation(
|
||||
methodName: String, receiverType: String, firstParameterType: String, secondParameterType: String, function: (T, E, R) -> Any?
|
||||
): Pair<CompileTimeFunction, Function3<Any?, Any?, Any?, Any?>> {
|
||||
return CompileTimeFunction(
|
||||
methodName, listOfNotNull(receiverType, firstParameterType, secondParameterType)
|
||||
) to function as Function3<Any?, Any?, Any?, Any?>
|
||||
}
|
||||
@@ -0,0 +1,477 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.interpreter.builtins
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.state.*
|
||||
|
||||
/** This file is generated by org.jetbrains.kotlin.backend.common.interpreter.builtins.GenerateBuiltInsMap.generateMap(). DO NOT MODIFY MANUALLY */
|
||||
|
||||
val unaryFunctions = mapOf<CompileTimeFunction, Function1<Any?, Any?>>(
|
||||
unaryOperation<Boolean>("hashCode", "Boolean") { a -> a.hashCode() },
|
||||
unaryOperation<Boolean>("not", "Boolean") { a -> a.not() },
|
||||
unaryOperation<Boolean>("toString", "Boolean") { a -> a.toString() },
|
||||
unaryOperation<Char>("dec", "Char") { a -> a.dec() },
|
||||
unaryOperation<Char>("hashCode", "Char") { a -> a.hashCode() },
|
||||
unaryOperation<Char>("inc", "Char") { a -> a.inc() },
|
||||
unaryOperation<Char>("toByte", "Char") { a -> a.toByte() },
|
||||
unaryOperation<Char>("toChar", "Char") { a -> a.toChar() },
|
||||
unaryOperation<Char>("toDouble", "Char") { a -> a.toDouble() },
|
||||
unaryOperation<Char>("toFloat", "Char") { a -> a.toFloat() },
|
||||
unaryOperation<Char>("toInt", "Char") { a -> a.toInt() },
|
||||
unaryOperation<Char>("toLong", "Char") { a -> a.toLong() },
|
||||
unaryOperation<Char>("toShort", "Char") { a -> a.toShort() },
|
||||
unaryOperation<Char>("toString", "Char") { a -> a.toString() },
|
||||
unaryOperation<Byte>("dec", "Byte") { a -> a.dec() },
|
||||
unaryOperation<Byte>("hashCode", "Byte") { a -> a.hashCode() },
|
||||
unaryOperation<Byte>("inc", "Byte") { a -> a.inc() },
|
||||
unaryOperation<Byte>("toByte", "Byte") { a -> a.toByte() },
|
||||
unaryOperation<Byte>("toChar", "Byte") { a -> a.toChar() },
|
||||
unaryOperation<Byte>("toDouble", "Byte") { a -> a.toDouble() },
|
||||
unaryOperation<Byte>("toFloat", "Byte") { a -> a.toFloat() },
|
||||
unaryOperation<Byte>("toInt", "Byte") { a -> a.toInt() },
|
||||
unaryOperation<Byte>("toLong", "Byte") { a -> a.toLong() },
|
||||
unaryOperation<Byte>("toShort", "Byte") { a -> a.toShort() },
|
||||
unaryOperation<Byte>("toString", "Byte") { a -> a.toString() },
|
||||
unaryOperation<Byte>("unaryMinus", "Byte") { a -> a.unaryMinus() },
|
||||
unaryOperation<Byte>("unaryPlus", "Byte") { a -> a.unaryPlus() },
|
||||
unaryOperation<Short>("dec", "Short") { a -> a.dec() },
|
||||
unaryOperation<Short>("hashCode", "Short") { a -> a.hashCode() },
|
||||
unaryOperation<Short>("inc", "Short") { a -> a.inc() },
|
||||
unaryOperation<Short>("toByte", "Short") { a -> a.toByte() },
|
||||
unaryOperation<Short>("toChar", "Short") { a -> a.toChar() },
|
||||
unaryOperation<Short>("toDouble", "Short") { a -> a.toDouble() },
|
||||
unaryOperation<Short>("toFloat", "Short") { a -> a.toFloat() },
|
||||
unaryOperation<Short>("toInt", "Short") { a -> a.toInt() },
|
||||
unaryOperation<Short>("toLong", "Short") { a -> a.toLong() },
|
||||
unaryOperation<Short>("toShort", "Short") { a -> a.toShort() },
|
||||
unaryOperation<Short>("toString", "Short") { a -> a.toString() },
|
||||
unaryOperation<Short>("unaryMinus", "Short") { a -> a.unaryMinus() },
|
||||
unaryOperation<Short>("unaryPlus", "Short") { a -> a.unaryPlus() },
|
||||
unaryOperation<Int>("dec", "Int") { a -> a.dec() },
|
||||
unaryOperation<Int>("hashCode", "Int") { a -> a.hashCode() },
|
||||
unaryOperation<Int>("inc", "Int") { a -> a.inc() },
|
||||
unaryOperation<Int>("inv", "Int") { a -> a.inv() },
|
||||
unaryOperation<Int>("toByte", "Int") { a -> a.toByte() },
|
||||
unaryOperation<Int>("toChar", "Int") { a -> a.toChar() },
|
||||
unaryOperation<Int>("toDouble", "Int") { a -> a.toDouble() },
|
||||
unaryOperation<Int>("toFloat", "Int") { a -> a.toFloat() },
|
||||
unaryOperation<Int>("toInt", "Int") { a -> a.toInt() },
|
||||
unaryOperation<Int>("toLong", "Int") { a -> a.toLong() },
|
||||
unaryOperation<Int>("toShort", "Int") { a -> a.toShort() },
|
||||
unaryOperation<Int>("toString", "Int") { a -> a.toString() },
|
||||
unaryOperation<Int>("unaryMinus", "Int") { a -> a.unaryMinus() },
|
||||
unaryOperation<Int>("unaryPlus", "Int") { a -> a.unaryPlus() },
|
||||
unaryOperation<Float>("dec", "Float") { a -> a.dec() },
|
||||
unaryOperation<Float>("hashCode", "Float") { a -> a.hashCode() },
|
||||
unaryOperation<Float>("inc", "Float") { a -> a.inc() },
|
||||
unaryOperation<Float>("toByte", "Float") { a -> a.toByte() },
|
||||
unaryOperation<Float>("toChar", "Float") { a -> a.toChar() },
|
||||
unaryOperation<Float>("toDouble", "Float") { a -> a.toDouble() },
|
||||
unaryOperation<Float>("toFloat", "Float") { a -> a.toFloat() },
|
||||
unaryOperation<Float>("toInt", "Float") { a -> a.toInt() },
|
||||
unaryOperation<Float>("toLong", "Float") { a -> a.toLong() },
|
||||
unaryOperation<Float>("toShort", "Float") { a -> a.toShort() },
|
||||
unaryOperation<Float>("toString", "Float") { a -> a.toString() },
|
||||
unaryOperation<Float>("unaryMinus", "Float") { a -> a.unaryMinus() },
|
||||
unaryOperation<Float>("unaryPlus", "Float") { a -> a.unaryPlus() },
|
||||
unaryOperation<Long>("dec", "Long") { a -> a.dec() },
|
||||
unaryOperation<Long>("hashCode", "Long") { a -> a.hashCode() },
|
||||
unaryOperation<Long>("inc", "Long") { a -> a.inc() },
|
||||
unaryOperation<Long>("inv", "Long") { a -> a.inv() },
|
||||
unaryOperation<Long>("toByte", "Long") { a -> a.toByte() },
|
||||
unaryOperation<Long>("toChar", "Long") { a -> a.toChar() },
|
||||
unaryOperation<Long>("toDouble", "Long") { a -> a.toDouble() },
|
||||
unaryOperation<Long>("toFloat", "Long") { a -> a.toFloat() },
|
||||
unaryOperation<Long>("toInt", "Long") { a -> a.toInt() },
|
||||
unaryOperation<Long>("toLong", "Long") { a -> a.toLong() },
|
||||
unaryOperation<Long>("toShort", "Long") { a -> a.toShort() },
|
||||
unaryOperation<Long>("toString", "Long") { a -> a.toString() },
|
||||
unaryOperation<Long>("unaryMinus", "Long") { a -> a.unaryMinus() },
|
||||
unaryOperation<Long>("unaryPlus", "Long") { a -> a.unaryPlus() },
|
||||
unaryOperation<Double>("dec", "Double") { a -> a.dec() },
|
||||
unaryOperation<Double>("hashCode", "Double") { a -> a.hashCode() },
|
||||
unaryOperation<Double>("inc", "Double") { a -> a.inc() },
|
||||
unaryOperation<Double>("toByte", "Double") { a -> a.toByte() },
|
||||
unaryOperation<Double>("toChar", "Double") { a -> a.toChar() },
|
||||
unaryOperation<Double>("toDouble", "Double") { a -> a.toDouble() },
|
||||
unaryOperation<Double>("toFloat", "Double") { a -> a.toFloat() },
|
||||
unaryOperation<Double>("toInt", "Double") { a -> a.toInt() },
|
||||
unaryOperation<Double>("toLong", "Double") { a -> a.toLong() },
|
||||
unaryOperation<Double>("toShort", "Double") { a -> a.toShort() },
|
||||
unaryOperation<Double>("toString", "Double") { a -> a.toString() },
|
||||
unaryOperation<Double>("unaryMinus", "Double") { a -> a.unaryMinus() },
|
||||
unaryOperation<Double>("unaryPlus", "Double") { a -> a.unaryPlus() },
|
||||
unaryOperation<String>("length", "String") { a -> a.length },
|
||||
unaryOperation<String>("hashCode", "String") { a -> a.hashCode() },
|
||||
unaryOperation<String>("toString", "String") { a -> a.toString() },
|
||||
unaryOperation<BooleanArray>("size", "BooleanArray") { a -> a.size },
|
||||
unaryOperation<BooleanArray>("iterator", "BooleanArray") { a -> a.iterator() },
|
||||
unaryOperation<CharArray>("size", "CharArray") { a -> a.size },
|
||||
unaryOperation<CharArray>("iterator", "CharArray") { a -> a.iterator() },
|
||||
unaryOperation<ByteArray>("size", "ByteArray") { a -> a.size },
|
||||
unaryOperation<ByteArray>("iterator", "ByteArray") { a -> a.iterator() },
|
||||
unaryOperation<ShortArray>("size", "ShortArray") { a -> a.size },
|
||||
unaryOperation<ShortArray>("iterator", "ShortArray") { a -> a.iterator() },
|
||||
unaryOperation<IntArray>("size", "IntArray") { a -> a.size },
|
||||
unaryOperation<IntArray>("iterator", "IntArray") { a -> a.iterator() },
|
||||
unaryOperation<FloatArray>("size", "FloatArray") { a -> a.size },
|
||||
unaryOperation<FloatArray>("iterator", "FloatArray") { a -> a.iterator() },
|
||||
unaryOperation<LongArray>("size", "LongArray") { a -> a.size },
|
||||
unaryOperation<LongArray>("iterator", "LongArray") { a -> a.iterator() },
|
||||
unaryOperation<DoubleArray>("size", "DoubleArray") { a -> a.size },
|
||||
unaryOperation<DoubleArray>("iterator", "DoubleArray") { a -> a.iterator() },
|
||||
unaryOperation<Array<Any?>>("size", "Array<T>") { a -> a.size },
|
||||
unaryOperation<Array<Any?>>("iterator", "Array<T>") { a -> a.iterator() },
|
||||
unaryOperation<Any>("hashCode", "Any") { a -> a.hashCode() },
|
||||
unaryOperation<Any>("toString", "Any") { a -> a.defaultToString() },
|
||||
unaryOperation<Any?>("CHECK_NOT_NULL", "T0?") { a -> a!! },
|
||||
unaryOperation<ExceptionState>("message", "Throwable") { a -> a.getMessage() },
|
||||
unaryOperation<ExceptionState>("cause", "Throwable") { a -> a.getCause() }
|
||||
)
|
||||
|
||||
val binaryFunctions = mapOf<CompileTimeFunction, Function2<Any?, Any?, Any?>>(
|
||||
binaryOperation<Boolean, Boolean>("and", "Boolean", "Boolean") { a, b -> a.and(b) },
|
||||
binaryOperation<Boolean, Boolean>("compareTo", "Boolean", "Boolean") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Boolean, Any?>("equals", "Boolean", "Any?") { a, b -> a.equals(b) },
|
||||
binaryOperation<Boolean, Boolean>("or", "Boolean", "Boolean") { a, b -> a.or(b) },
|
||||
binaryOperation<Boolean, Boolean>("xor", "Boolean", "Boolean") { a, b -> a.xor(b) },
|
||||
binaryOperation<Char, Char>("compareTo", "Char", "Char") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Char, Any?>("equals", "Char", "Any?") { a, b -> a.equals(b) },
|
||||
binaryOperation<Char, Char>("minus", "Char", "Char") { a, b -> a.minus(b) },
|
||||
binaryOperation<Char, Int>("minus", "Char", "Int") { a, b -> a.minus(b) },
|
||||
binaryOperation<Char, Int>("plus", "Char", "Int") { a, b -> a.plus(b) },
|
||||
binaryOperation<Char, Char>("rangeTo", "Char", "Char") { a, b -> a.rangeTo(b) },
|
||||
binaryOperation<Byte, Byte>("compareTo", "Byte", "Byte") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Byte, Double>("compareTo", "Byte", "Double") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Byte, Float>("compareTo", "Byte", "Float") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Byte, Int>("compareTo", "Byte", "Int") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Byte, Long>("compareTo", "Byte", "Long") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Byte, Short>("compareTo", "Byte", "Short") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Byte, Byte>("div", "Byte", "Byte") { a, b -> a.div(b) },
|
||||
binaryOperation<Byte, Double>("div", "Byte", "Double") { a, b -> a.div(b) },
|
||||
binaryOperation<Byte, Float>("div", "Byte", "Float") { a, b -> a.div(b) },
|
||||
binaryOperation<Byte, Int>("div", "Byte", "Int") { a, b -> a.div(b) },
|
||||
binaryOperation<Byte, Long>("div", "Byte", "Long") { a, b -> a.div(b) },
|
||||
binaryOperation<Byte, Short>("div", "Byte", "Short") { a, b -> a.div(b) },
|
||||
binaryOperation<Byte, Any?>("equals", "Byte", "Any?") { a, b -> a.equals(b) },
|
||||
binaryOperation<Byte, Byte>("minus", "Byte", "Byte") { a, b -> a.minus(b) },
|
||||
binaryOperation<Byte, Double>("minus", "Byte", "Double") { a, b -> a.minus(b) },
|
||||
binaryOperation<Byte, Float>("minus", "Byte", "Float") { a, b -> a.minus(b) },
|
||||
binaryOperation<Byte, Int>("minus", "Byte", "Int") { a, b -> a.minus(b) },
|
||||
binaryOperation<Byte, Long>("minus", "Byte", "Long") { a, b -> a.minus(b) },
|
||||
binaryOperation<Byte, Short>("minus", "Byte", "Short") { a, b -> a.minus(b) },
|
||||
binaryOperation<Byte, Byte>("plus", "Byte", "Byte") { a, b -> a.plus(b) },
|
||||
binaryOperation<Byte, Double>("plus", "Byte", "Double") { a, b -> a.plus(b) },
|
||||
binaryOperation<Byte, Float>("plus", "Byte", "Float") { a, b -> a.plus(b) },
|
||||
binaryOperation<Byte, Int>("plus", "Byte", "Int") { a, b -> a.plus(b) },
|
||||
binaryOperation<Byte, Long>("plus", "Byte", "Long") { a, b -> a.plus(b) },
|
||||
binaryOperation<Byte, Short>("plus", "Byte", "Short") { a, b -> a.plus(b) },
|
||||
binaryOperation<Byte, Byte>("rangeTo", "Byte", "Byte") { a, b -> a.rangeTo(b) },
|
||||
binaryOperation<Byte, Int>("rangeTo", "Byte", "Int") { a, b -> a.rangeTo(b) },
|
||||
binaryOperation<Byte, Long>("rangeTo", "Byte", "Long") { a, b -> a.rangeTo(b) },
|
||||
binaryOperation<Byte, Short>("rangeTo", "Byte", "Short") { a, b -> a.rangeTo(b) },
|
||||
binaryOperation<Byte, Byte>("rem", "Byte", "Byte") { a, b -> a.rem(b) },
|
||||
binaryOperation<Byte, Double>("rem", "Byte", "Double") { a, b -> a.rem(b) },
|
||||
binaryOperation<Byte, Float>("rem", "Byte", "Float") { a, b -> a.rem(b) },
|
||||
binaryOperation<Byte, Int>("rem", "Byte", "Int") { a, b -> a.rem(b) },
|
||||
binaryOperation<Byte, Long>("rem", "Byte", "Long") { a, b -> a.rem(b) },
|
||||
binaryOperation<Byte, Short>("rem", "Byte", "Short") { a, b -> a.rem(b) },
|
||||
binaryOperation<Byte, Byte>("times", "Byte", "Byte") { a, b -> a.times(b) },
|
||||
binaryOperation<Byte, Double>("times", "Byte", "Double") { a, b -> a.times(b) },
|
||||
binaryOperation<Byte, Float>("times", "Byte", "Float") { a, b -> a.times(b) },
|
||||
binaryOperation<Byte, Int>("times", "Byte", "Int") { a, b -> a.times(b) },
|
||||
binaryOperation<Byte, Long>("times", "Byte", "Long") { a, b -> a.times(b) },
|
||||
binaryOperation<Byte, Short>("times", "Byte", "Short") { a, b -> a.times(b) },
|
||||
binaryOperation<Short, Byte>("compareTo", "Short", "Byte") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Short, Double>("compareTo", "Short", "Double") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Short, Float>("compareTo", "Short", "Float") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Short, Int>("compareTo", "Short", "Int") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Short, Long>("compareTo", "Short", "Long") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Short, Short>("compareTo", "Short", "Short") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Short, Byte>("div", "Short", "Byte") { a, b -> a.div(b) },
|
||||
binaryOperation<Short, Double>("div", "Short", "Double") { a, b -> a.div(b) },
|
||||
binaryOperation<Short, Float>("div", "Short", "Float") { a, b -> a.div(b) },
|
||||
binaryOperation<Short, Int>("div", "Short", "Int") { a, b -> a.div(b) },
|
||||
binaryOperation<Short, Long>("div", "Short", "Long") { a, b -> a.div(b) },
|
||||
binaryOperation<Short, Short>("div", "Short", "Short") { a, b -> a.div(b) },
|
||||
binaryOperation<Short, Any?>("equals", "Short", "Any?") { a, b -> a.equals(b) },
|
||||
binaryOperation<Short, Byte>("minus", "Short", "Byte") { a, b -> a.minus(b) },
|
||||
binaryOperation<Short, Double>("minus", "Short", "Double") { a, b -> a.minus(b) },
|
||||
binaryOperation<Short, Float>("minus", "Short", "Float") { a, b -> a.minus(b) },
|
||||
binaryOperation<Short, Int>("minus", "Short", "Int") { a, b -> a.minus(b) },
|
||||
binaryOperation<Short, Long>("minus", "Short", "Long") { a, b -> a.minus(b) },
|
||||
binaryOperation<Short, Short>("minus", "Short", "Short") { a, b -> a.minus(b) },
|
||||
binaryOperation<Short, Byte>("plus", "Short", "Byte") { a, b -> a.plus(b) },
|
||||
binaryOperation<Short, Double>("plus", "Short", "Double") { a, b -> a.plus(b) },
|
||||
binaryOperation<Short, Float>("plus", "Short", "Float") { a, b -> a.plus(b) },
|
||||
binaryOperation<Short, Int>("plus", "Short", "Int") { a, b -> a.plus(b) },
|
||||
binaryOperation<Short, Long>("plus", "Short", "Long") { a, b -> a.plus(b) },
|
||||
binaryOperation<Short, Short>("plus", "Short", "Short") { a, b -> a.plus(b) },
|
||||
binaryOperation<Short, Byte>("rangeTo", "Short", "Byte") { a, b -> a.rangeTo(b) },
|
||||
binaryOperation<Short, Int>("rangeTo", "Short", "Int") { a, b -> a.rangeTo(b) },
|
||||
binaryOperation<Short, Long>("rangeTo", "Short", "Long") { a, b -> a.rangeTo(b) },
|
||||
binaryOperation<Short, Short>("rangeTo", "Short", "Short") { a, b -> a.rangeTo(b) },
|
||||
binaryOperation<Short, Byte>("rem", "Short", "Byte") { a, b -> a.rem(b) },
|
||||
binaryOperation<Short, Double>("rem", "Short", "Double") { a, b -> a.rem(b) },
|
||||
binaryOperation<Short, Float>("rem", "Short", "Float") { a, b -> a.rem(b) },
|
||||
binaryOperation<Short, Int>("rem", "Short", "Int") { a, b -> a.rem(b) },
|
||||
binaryOperation<Short, Long>("rem", "Short", "Long") { a, b -> a.rem(b) },
|
||||
binaryOperation<Short, Short>("rem", "Short", "Short") { a, b -> a.rem(b) },
|
||||
binaryOperation<Short, Byte>("times", "Short", "Byte") { a, b -> a.times(b) },
|
||||
binaryOperation<Short, Double>("times", "Short", "Double") { a, b -> a.times(b) },
|
||||
binaryOperation<Short, Float>("times", "Short", "Float") { a, b -> a.times(b) },
|
||||
binaryOperation<Short, Int>("times", "Short", "Int") { a, b -> a.times(b) },
|
||||
binaryOperation<Short, Long>("times", "Short", "Long") { a, b -> a.times(b) },
|
||||
binaryOperation<Short, Short>("times", "Short", "Short") { a, b -> a.times(b) },
|
||||
binaryOperation<Int, Int>("and", "Int", "Int") { a, b -> a.and(b) },
|
||||
binaryOperation<Int, Byte>("compareTo", "Int", "Byte") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Int, Double>("compareTo", "Int", "Double") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Int, Float>("compareTo", "Int", "Float") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Int, Int>("compareTo", "Int", "Int") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Int, Long>("compareTo", "Int", "Long") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Int, Short>("compareTo", "Int", "Short") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Int, Byte>("div", "Int", "Byte") { a, b -> a.div(b) },
|
||||
binaryOperation<Int, Double>("div", "Int", "Double") { a, b -> a.div(b) },
|
||||
binaryOperation<Int, Float>("div", "Int", "Float") { a, b -> a.div(b) },
|
||||
binaryOperation<Int, Int>("div", "Int", "Int") { a, b -> a.div(b) },
|
||||
binaryOperation<Int, Long>("div", "Int", "Long") { a, b -> a.div(b) },
|
||||
binaryOperation<Int, Short>("div", "Int", "Short") { a, b -> a.div(b) },
|
||||
binaryOperation<Int, Any?>("equals", "Int", "Any?") { a, b -> a.equals(b) },
|
||||
binaryOperation<Int, Byte>("minus", "Int", "Byte") { a, b -> a.minus(b) },
|
||||
binaryOperation<Int, Double>("minus", "Int", "Double") { a, b -> a.minus(b) },
|
||||
binaryOperation<Int, Float>("minus", "Int", "Float") { a, b -> a.minus(b) },
|
||||
binaryOperation<Int, Int>("minus", "Int", "Int") { a, b -> a.minus(b) },
|
||||
binaryOperation<Int, Long>("minus", "Int", "Long") { a, b -> a.minus(b) },
|
||||
binaryOperation<Int, Short>("minus", "Int", "Short") { a, b -> a.minus(b) },
|
||||
binaryOperation<Int, Int>("or", "Int", "Int") { a, b -> a.or(b) },
|
||||
binaryOperation<Int, Byte>("plus", "Int", "Byte") { a, b -> a.plus(b) },
|
||||
binaryOperation<Int, Double>("plus", "Int", "Double") { a, b -> a.plus(b) },
|
||||
binaryOperation<Int, Float>("plus", "Int", "Float") { a, b -> a.plus(b) },
|
||||
binaryOperation<Int, Int>("plus", "Int", "Int") { a, b -> a.plus(b) },
|
||||
binaryOperation<Int, Long>("plus", "Int", "Long") { a, b -> a.plus(b) },
|
||||
binaryOperation<Int, Short>("plus", "Int", "Short") { a, b -> a.plus(b) },
|
||||
binaryOperation<Int, Byte>("rangeTo", "Int", "Byte") { a, b -> a.rangeTo(b) },
|
||||
binaryOperation<Int, Int>("rangeTo", "Int", "Int") { a, b -> a.rangeTo(b) },
|
||||
binaryOperation<Int, Long>("rangeTo", "Int", "Long") { a, b -> a.rangeTo(b) },
|
||||
binaryOperation<Int, Short>("rangeTo", "Int", "Short") { a, b -> a.rangeTo(b) },
|
||||
binaryOperation<Int, Byte>("rem", "Int", "Byte") { a, b -> a.rem(b) },
|
||||
binaryOperation<Int, Double>("rem", "Int", "Double") { a, b -> a.rem(b) },
|
||||
binaryOperation<Int, Float>("rem", "Int", "Float") { a, b -> a.rem(b) },
|
||||
binaryOperation<Int, Int>("rem", "Int", "Int") { a, b -> a.rem(b) },
|
||||
binaryOperation<Int, Long>("rem", "Int", "Long") { a, b -> a.rem(b) },
|
||||
binaryOperation<Int, Short>("rem", "Int", "Short") { a, b -> a.rem(b) },
|
||||
binaryOperation<Int, Int>("shl", "Int", "Int") { a, b -> a.shl(b) },
|
||||
binaryOperation<Int, Int>("shr", "Int", "Int") { a, b -> a.shr(b) },
|
||||
binaryOperation<Int, Byte>("times", "Int", "Byte") { a, b -> a.times(b) },
|
||||
binaryOperation<Int, Double>("times", "Int", "Double") { a, b -> a.times(b) },
|
||||
binaryOperation<Int, Float>("times", "Int", "Float") { a, b -> a.times(b) },
|
||||
binaryOperation<Int, Int>("times", "Int", "Int") { a, b -> a.times(b) },
|
||||
binaryOperation<Int, Long>("times", "Int", "Long") { a, b -> a.times(b) },
|
||||
binaryOperation<Int, Short>("times", "Int", "Short") { a, b -> a.times(b) },
|
||||
binaryOperation<Int, Int>("ushr", "Int", "Int") { a, b -> a.ushr(b) },
|
||||
binaryOperation<Int, Int>("xor", "Int", "Int") { a, b -> a.xor(b) },
|
||||
binaryOperation<Float, Byte>("compareTo", "Float", "Byte") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Float, Double>("compareTo", "Float", "Double") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Float, Float>("compareTo", "Float", "Float") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Float, Int>("compareTo", "Float", "Int") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Float, Long>("compareTo", "Float", "Long") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Float, Short>("compareTo", "Float", "Short") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Float, Byte>("div", "Float", "Byte") { a, b -> a.div(b) },
|
||||
binaryOperation<Float, Double>("div", "Float", "Double") { a, b -> a.div(b) },
|
||||
binaryOperation<Float, Float>("div", "Float", "Float") { a, b -> a.div(b) },
|
||||
binaryOperation<Float, Int>("div", "Float", "Int") { a, b -> a.div(b) },
|
||||
binaryOperation<Float, Long>("div", "Float", "Long") { a, b -> a.div(b) },
|
||||
binaryOperation<Float, Short>("div", "Float", "Short") { a, b -> a.div(b) },
|
||||
binaryOperation<Float, Any?>("equals", "Float", "Any?") { a, b -> a.equals(b) },
|
||||
binaryOperation<Float, Byte>("minus", "Float", "Byte") { a, b -> a.minus(b) },
|
||||
binaryOperation<Float, Double>("minus", "Float", "Double") { a, b -> a.minus(b) },
|
||||
binaryOperation<Float, Float>("minus", "Float", "Float") { a, b -> a.minus(b) },
|
||||
binaryOperation<Float, Int>("minus", "Float", "Int") { a, b -> a.minus(b) },
|
||||
binaryOperation<Float, Long>("minus", "Float", "Long") { a, b -> a.minus(b) },
|
||||
binaryOperation<Float, Short>("minus", "Float", "Short") { a, b -> a.minus(b) },
|
||||
binaryOperation<Float, Byte>("plus", "Float", "Byte") { a, b -> a.plus(b) },
|
||||
binaryOperation<Float, Double>("plus", "Float", "Double") { a, b -> a.plus(b) },
|
||||
binaryOperation<Float, Float>("plus", "Float", "Float") { a, b -> a.plus(b) },
|
||||
binaryOperation<Float, Int>("plus", "Float", "Int") { a, b -> a.plus(b) },
|
||||
binaryOperation<Float, Long>("plus", "Float", "Long") { a, b -> a.plus(b) },
|
||||
binaryOperation<Float, Short>("plus", "Float", "Short") { a, b -> a.plus(b) },
|
||||
binaryOperation<Float, Byte>("rem", "Float", "Byte") { a, b -> a.rem(b) },
|
||||
binaryOperation<Float, Double>("rem", "Float", "Double") { a, b -> a.rem(b) },
|
||||
binaryOperation<Float, Float>("rem", "Float", "Float") { a, b -> a.rem(b) },
|
||||
binaryOperation<Float, Int>("rem", "Float", "Int") { a, b -> a.rem(b) },
|
||||
binaryOperation<Float, Long>("rem", "Float", "Long") { a, b -> a.rem(b) },
|
||||
binaryOperation<Float, Short>("rem", "Float", "Short") { a, b -> a.rem(b) },
|
||||
binaryOperation<Float, Byte>("times", "Float", "Byte") { a, b -> a.times(b) },
|
||||
binaryOperation<Float, Double>("times", "Float", "Double") { a, b -> a.times(b) },
|
||||
binaryOperation<Float, Float>("times", "Float", "Float") { a, b -> a.times(b) },
|
||||
binaryOperation<Float, Int>("times", "Float", "Int") { a, b -> a.times(b) },
|
||||
binaryOperation<Float, Long>("times", "Float", "Long") { a, b -> a.times(b) },
|
||||
binaryOperation<Float, Short>("times", "Float", "Short") { a, b -> a.times(b) },
|
||||
binaryOperation<Long, Long>("and", "Long", "Long") { a, b -> a.and(b) },
|
||||
binaryOperation<Long, Byte>("compareTo", "Long", "Byte") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Long, Double>("compareTo", "Long", "Double") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Long, Float>("compareTo", "Long", "Float") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Long, Int>("compareTo", "Long", "Int") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Long, Long>("compareTo", "Long", "Long") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Long, Short>("compareTo", "Long", "Short") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Long, Byte>("div", "Long", "Byte") { a, b -> a.div(b) },
|
||||
binaryOperation<Long, Double>("div", "Long", "Double") { a, b -> a.div(b) },
|
||||
binaryOperation<Long, Float>("div", "Long", "Float") { a, b -> a.div(b) },
|
||||
binaryOperation<Long, Int>("div", "Long", "Int") { a, b -> a.div(b) },
|
||||
binaryOperation<Long, Long>("div", "Long", "Long") { a, b -> a.div(b) },
|
||||
binaryOperation<Long, Short>("div", "Long", "Short") { a, b -> a.div(b) },
|
||||
binaryOperation<Long, Any?>("equals", "Long", "Any?") { a, b -> a.equals(b) },
|
||||
binaryOperation<Long, Byte>("minus", "Long", "Byte") { a, b -> a.minus(b) },
|
||||
binaryOperation<Long, Double>("minus", "Long", "Double") { a, b -> a.minus(b) },
|
||||
binaryOperation<Long, Float>("minus", "Long", "Float") { a, b -> a.minus(b) },
|
||||
binaryOperation<Long, Int>("minus", "Long", "Int") { a, b -> a.minus(b) },
|
||||
binaryOperation<Long, Long>("minus", "Long", "Long") { a, b -> a.minus(b) },
|
||||
binaryOperation<Long, Short>("minus", "Long", "Short") { a, b -> a.minus(b) },
|
||||
binaryOperation<Long, Long>("or", "Long", "Long") { a, b -> a.or(b) },
|
||||
binaryOperation<Long, Byte>("plus", "Long", "Byte") { a, b -> a.plus(b) },
|
||||
binaryOperation<Long, Double>("plus", "Long", "Double") { a, b -> a.plus(b) },
|
||||
binaryOperation<Long, Float>("plus", "Long", "Float") { a, b -> a.plus(b) },
|
||||
binaryOperation<Long, Int>("plus", "Long", "Int") { a, b -> a.plus(b) },
|
||||
binaryOperation<Long, Long>("plus", "Long", "Long") { a, b -> a.plus(b) },
|
||||
binaryOperation<Long, Short>("plus", "Long", "Short") { a, b -> a.plus(b) },
|
||||
binaryOperation<Long, Byte>("rangeTo", "Long", "Byte") { a, b -> a.rangeTo(b) },
|
||||
binaryOperation<Long, Int>("rangeTo", "Long", "Int") { a, b -> a.rangeTo(b) },
|
||||
binaryOperation<Long, Long>("rangeTo", "Long", "Long") { a, b -> a.rangeTo(b) },
|
||||
binaryOperation<Long, Short>("rangeTo", "Long", "Short") { a, b -> a.rangeTo(b) },
|
||||
binaryOperation<Long, Byte>("rem", "Long", "Byte") { a, b -> a.rem(b) },
|
||||
binaryOperation<Long, Double>("rem", "Long", "Double") { a, b -> a.rem(b) },
|
||||
binaryOperation<Long, Float>("rem", "Long", "Float") { a, b -> a.rem(b) },
|
||||
binaryOperation<Long, Int>("rem", "Long", "Int") { a, b -> a.rem(b) },
|
||||
binaryOperation<Long, Long>("rem", "Long", "Long") { a, b -> a.rem(b) },
|
||||
binaryOperation<Long, Short>("rem", "Long", "Short") { a, b -> a.rem(b) },
|
||||
binaryOperation<Long, Int>("shl", "Long", "Int") { a, b -> a.shl(b) },
|
||||
binaryOperation<Long, Int>("shr", "Long", "Int") { a, b -> a.shr(b) },
|
||||
binaryOperation<Long, Byte>("times", "Long", "Byte") { a, b -> a.times(b) },
|
||||
binaryOperation<Long, Double>("times", "Long", "Double") { a, b -> a.times(b) },
|
||||
binaryOperation<Long, Float>("times", "Long", "Float") { a, b -> a.times(b) },
|
||||
binaryOperation<Long, Int>("times", "Long", "Int") { a, b -> a.times(b) },
|
||||
binaryOperation<Long, Long>("times", "Long", "Long") { a, b -> a.times(b) },
|
||||
binaryOperation<Long, Short>("times", "Long", "Short") { a, b -> a.times(b) },
|
||||
binaryOperation<Long, Int>("ushr", "Long", "Int") { a, b -> a.ushr(b) },
|
||||
binaryOperation<Long, Long>("xor", "Long", "Long") { a, b -> a.xor(b) },
|
||||
binaryOperation<Double, Byte>("compareTo", "Double", "Byte") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Double, Double>("compareTo", "Double", "Double") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Double, Float>("compareTo", "Double", "Float") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Double, Int>("compareTo", "Double", "Int") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Double, Long>("compareTo", "Double", "Long") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Double, Short>("compareTo", "Double", "Short") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<Double, Byte>("div", "Double", "Byte") { a, b -> a.div(b) },
|
||||
binaryOperation<Double, Double>("div", "Double", "Double") { a, b -> a.div(b) },
|
||||
binaryOperation<Double, Float>("div", "Double", "Float") { a, b -> a.div(b) },
|
||||
binaryOperation<Double, Int>("div", "Double", "Int") { a, b -> a.div(b) },
|
||||
binaryOperation<Double, Long>("div", "Double", "Long") { a, b -> a.div(b) },
|
||||
binaryOperation<Double, Short>("div", "Double", "Short") { a, b -> a.div(b) },
|
||||
binaryOperation<Double, Any?>("equals", "Double", "Any?") { a, b -> a.equals(b) },
|
||||
binaryOperation<Double, Byte>("minus", "Double", "Byte") { a, b -> a.minus(b) },
|
||||
binaryOperation<Double, Double>("minus", "Double", "Double") { a, b -> a.minus(b) },
|
||||
binaryOperation<Double, Float>("minus", "Double", "Float") { a, b -> a.minus(b) },
|
||||
binaryOperation<Double, Int>("minus", "Double", "Int") { a, b -> a.minus(b) },
|
||||
binaryOperation<Double, Long>("minus", "Double", "Long") { a, b -> a.minus(b) },
|
||||
binaryOperation<Double, Short>("minus", "Double", "Short") { a, b -> a.minus(b) },
|
||||
binaryOperation<Double, Byte>("plus", "Double", "Byte") { a, b -> a.plus(b) },
|
||||
binaryOperation<Double, Double>("plus", "Double", "Double") { a, b -> a.plus(b) },
|
||||
binaryOperation<Double, Float>("plus", "Double", "Float") { a, b -> a.plus(b) },
|
||||
binaryOperation<Double, Int>("plus", "Double", "Int") { a, b -> a.plus(b) },
|
||||
binaryOperation<Double, Long>("plus", "Double", "Long") { a, b -> a.plus(b) },
|
||||
binaryOperation<Double, Short>("plus", "Double", "Short") { a, b -> a.plus(b) },
|
||||
binaryOperation<Double, Byte>("rem", "Double", "Byte") { a, b -> a.rem(b) },
|
||||
binaryOperation<Double, Double>("rem", "Double", "Double") { a, b -> a.rem(b) },
|
||||
binaryOperation<Double, Float>("rem", "Double", "Float") { a, b -> a.rem(b) },
|
||||
binaryOperation<Double, Int>("rem", "Double", "Int") { a, b -> a.rem(b) },
|
||||
binaryOperation<Double, Long>("rem", "Double", "Long") { a, b -> a.rem(b) },
|
||||
binaryOperation<Double, Short>("rem", "Double", "Short") { a, b -> a.rem(b) },
|
||||
binaryOperation<Double, Byte>("times", "Double", "Byte") { a, b -> a.times(b) },
|
||||
binaryOperation<Double, Double>("times", "Double", "Double") { a, b -> a.times(b) },
|
||||
binaryOperation<Double, Float>("times", "Double", "Float") { a, b -> a.times(b) },
|
||||
binaryOperation<Double, Int>("times", "Double", "Int") { a, b -> a.times(b) },
|
||||
binaryOperation<Double, Long>("times", "Double", "Long") { a, b -> a.times(b) },
|
||||
binaryOperation<Double, Short>("times", "Double", "Short") { a, b -> a.times(b) },
|
||||
binaryOperation<String, String>("compareTo", "String", "String") { a, b -> a.compareTo(b) },
|
||||
binaryOperation<String, Any?>("equals", "String", "Any?") { a, b -> a.equals(b) },
|
||||
binaryOperation<String, Int>("get", "String", "Int") { a, b -> a.get(b) },
|
||||
binaryOperation<String, Any?>("plus", "String", "Any?") { a, b -> a.plus(b) },
|
||||
binaryOperation<BooleanArray, Int>("get", "BooleanArray", "Int") { a, b -> a.get(b) },
|
||||
binaryOperation<CharArray, Int>("get", "CharArray", "Int") { a, b -> a.get(b) },
|
||||
binaryOperation<ByteArray, Int>("get", "ByteArray", "Int") { a, b -> a.get(b) },
|
||||
binaryOperation<ShortArray, Int>("get", "ShortArray", "Int") { a, b -> a.get(b) },
|
||||
binaryOperation<IntArray, Int>("get", "IntArray", "Int") { a, b -> a.get(b) },
|
||||
binaryOperation<FloatArray, Int>("get", "FloatArray", "Int") { a, b -> a.get(b) },
|
||||
binaryOperation<LongArray, Int>("get", "LongArray", "Int") { a, b -> a.get(b) },
|
||||
binaryOperation<DoubleArray, Int>("get", "DoubleArray", "Int") { a, b -> a.get(b) },
|
||||
binaryOperation<Array<Any?>, Int>("get", "Array<T>", "Int") { a, b -> a.get(b) },
|
||||
binaryOperation<Any, Any?>("equals", "Any", "Any?") { a, b -> a.equals(b) },
|
||||
binaryOperation<Char, Char>("less", "Char", "Char") { a, b -> a < b },
|
||||
binaryOperation<Byte, Byte>("less", "Byte", "Byte") { a, b -> a < b },
|
||||
binaryOperation<Short, Short>("less", "Short", "Short") { a, b -> a < b },
|
||||
binaryOperation<Int, Int>("less", "Int", "Int") { a, b -> a < b },
|
||||
binaryOperation<Float, Float>("less", "Float", "Float") { a, b -> a < b },
|
||||
binaryOperation<Long, Long>("less", "Long", "Long") { a, b -> a < b },
|
||||
binaryOperation<Double, Double>("less", "Double", "Double") { a, b -> a < b },
|
||||
binaryOperation<Char, Char>("lessOrEqual", "Char", "Char") { a, b -> a <= b },
|
||||
binaryOperation<Byte, Byte>("lessOrEqual", "Byte", "Byte") { a, b -> a <= b },
|
||||
binaryOperation<Short, Short>("lessOrEqual", "Short", "Short") { a, b -> a <= b },
|
||||
binaryOperation<Int, Int>("lessOrEqual", "Int", "Int") { a, b -> a <= b },
|
||||
binaryOperation<Float, Float>("lessOrEqual", "Float", "Float") { a, b -> a <= b },
|
||||
binaryOperation<Long, Long>("lessOrEqual", "Long", "Long") { a, b -> a <= b },
|
||||
binaryOperation<Double, Double>("lessOrEqual", "Double", "Double") { a, b -> a <= b },
|
||||
binaryOperation<Char, Char>("greater", "Char", "Char") { a, b -> a > b },
|
||||
binaryOperation<Byte, Byte>("greater", "Byte", "Byte") { a, b -> a > b },
|
||||
binaryOperation<Short, Short>("greater", "Short", "Short") { a, b -> a > b },
|
||||
binaryOperation<Int, Int>("greater", "Int", "Int") { a, b -> a > b },
|
||||
binaryOperation<Float, Float>("greater", "Float", "Float") { a, b -> a > b },
|
||||
binaryOperation<Long, Long>("greater", "Long", "Long") { a, b -> a > b },
|
||||
binaryOperation<Double, Double>("greater", "Double", "Double") { a, b -> a > b },
|
||||
binaryOperation<Char, Char>("greaterOrEqual", "Char", "Char") { a, b -> a >= b },
|
||||
binaryOperation<Byte, Byte>("greaterOrEqual", "Byte", "Byte") { a, b -> a >= b },
|
||||
binaryOperation<Short, Short>("greaterOrEqual", "Short", "Short") { a, b -> a >= b },
|
||||
binaryOperation<Int, Int>("greaterOrEqual", "Int", "Int") { a, b -> a >= b },
|
||||
binaryOperation<Float, Float>("greaterOrEqual", "Float", "Float") { a, b -> a >= b },
|
||||
binaryOperation<Long, Long>("greaterOrEqual", "Long", "Long") { a, b -> a >= b },
|
||||
binaryOperation<Double, Double>("greaterOrEqual", "Double", "Double") { a, b -> a >= b },
|
||||
binaryOperation<Any?, Any?>("EQEQ", "Any?", "Any?") { a, b -> a == b },
|
||||
binaryOperation<Any?, Any?>("EQEQEQ", "Any?", "Any?") { a, b -> a === b },
|
||||
binaryOperation<Float?, Float?>("ieee754equals", "Float?", "Float?") { a, b -> a == b },
|
||||
binaryOperation<Double?, Double?>("ieee754equals", "Double?", "Double?") { a, b -> a == b },
|
||||
binaryOperation<Boolean, Boolean>("ANDAND", "Boolean", "Boolean") { a, b -> a && b },
|
||||
binaryOperation<Boolean, Boolean>("OROR", "Boolean", "Boolean") { a, b -> a || b }
|
||||
)
|
||||
|
||||
val ternaryFunctions = mapOf<CompileTimeFunction, Function3<Any?, Any?, Any?, Any?>>(
|
||||
ternaryOperation<String, Int, Int>("subSequence", "String", "Int", "Int") { a, b, c -> a.subSequence(b, c) },
|
||||
ternaryOperation<BooleanArray, Int, Boolean>("set", "BooleanArray", "Int", "Boolean") { a, b, c -> a.set(b, c) },
|
||||
ternaryOperation<CharArray, Int, Char>("set", "CharArray", "Int", "Char") { a, b, c -> a.set(b, c) },
|
||||
ternaryOperation<ByteArray, Int, Byte>("set", "ByteArray", "Int", "Byte") { a, b, c -> a.set(b, c) },
|
||||
ternaryOperation<ShortArray, Int, Short>("set", "ShortArray", "Int", "Short") { a, b, c -> a.set(b, c) },
|
||||
ternaryOperation<IntArray, Int, Int>("set", "IntArray", "Int", "Int") { a, b, c -> a.set(b, c) },
|
||||
ternaryOperation<FloatArray, Int, Float>("set", "FloatArray", "Int", "Float") { a, b, c -> a.set(b, c) },
|
||||
ternaryOperation<LongArray, Int, Long>("set", "LongArray", "Int", "Long") { a, b, c -> a.set(b, c) },
|
||||
ternaryOperation<DoubleArray, Int, Double>("set", "DoubleArray", "Int", "Double") { a, b, c -> a.set(b, c) },
|
||||
ternaryOperation<Array<Any?>, Int, Any?>("set", "Array<T>", "Int", "T") { a, b, c -> a.set(b, c) }
|
||||
)
|
||||
|
||||
private fun Any.defaultToString(): String {
|
||||
return when (this) {
|
||||
is State -> "${this.irClass.name}@" + System.identityHashCode(this).toString(16).padStart(8, '0')
|
||||
else -> this.toString().replaceAfter("@", System.identityHashCode(this).toString(16).padStart(8, '0'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.interpreter.exceptions
|
||||
|
||||
open class InterpreterException(override val message: String) : Exception(message) {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.interpreter.exceptions
|
||||
|
||||
class InterpreterMethodNotFoundException(override val message: String): InterpreterException(message) {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.interpreter.exceptions
|
||||
|
||||
class InterpreterTimeOutException : InterpreterException("Exceeded execution limit of constexpr expression") {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.interpreter.intrinsics
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.ExecutionResult
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.exceptions.InterpreterMethodNotFoundException
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.stack.Stack
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
|
||||
class IntrinsicEvaluator {
|
||||
suspend fun evaluate(irFunction: IrFunction, stack: Stack, interpret: suspend IrElement.() -> ExecutionResult): ExecutionResult {
|
||||
return when {
|
||||
EmptyArray.equalTo(irFunction) -> EmptyArray.evaluate(irFunction, stack, interpret)
|
||||
ArrayOf.equalTo(irFunction) -> ArrayOf.evaluate(irFunction, stack, interpret)
|
||||
ArrayOfNulls.equalTo(irFunction) -> ArrayOfNulls.evaluate(irFunction, stack, interpret)
|
||||
EnumValues.equalTo(irFunction) -> EnumValues.evaluate(irFunction, stack, interpret)
|
||||
EnumValueOf.equalTo(irFunction) -> EnumValueOf.evaluate(irFunction, stack, interpret)
|
||||
RegexReplace.equalTo(irFunction) -> RegexReplace.evaluate(irFunction, stack, interpret)
|
||||
EnumHashCode.equalTo(irFunction) -> EnumHashCode.evaluate(irFunction, stack, interpret)
|
||||
JsPrimitives.equalTo(irFunction) -> JsPrimitives.evaluate(irFunction, stack, interpret)
|
||||
ArrayConstructor.equalTo(irFunction) -> ArrayConstructor.evaluate(irFunction, stack, interpret)
|
||||
else -> throw InterpreterMethodNotFoundException("Method ${irFunction.name} hasn't implemented")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.interpreter.intrinsics
|
||||
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.*
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.stack.Stack
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.stack.Variable
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.state.*
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrEnumEntry
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.types.classOrNull
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
|
||||
sealed class IntrinsicBase {
|
||||
abstract fun equalTo(irFunction: IrFunction): Boolean
|
||||
abstract suspend fun evaluate(irFunction: IrFunction, stack: Stack, interpret: suspend IrElement.() -> ExecutionResult): ExecutionResult
|
||||
}
|
||||
|
||||
object EmptyArray : IntrinsicBase() {
|
||||
override fun equalTo(irFunction: IrFunction): Boolean {
|
||||
val fqName = irFunction.fqNameWhenAvailable.toString()
|
||||
return fqName == "kotlin.emptyArray"
|
||||
}
|
||||
|
||||
override suspend fun evaluate(
|
||||
irFunction: IrFunction, stack: Stack, interpret: suspend IrElement.() -> ExecutionResult
|
||||
): ExecutionResult {
|
||||
stack.pushReturnValue(emptyArray<Any?>().toState(irFunction.returnType))
|
||||
return Next
|
||||
}
|
||||
}
|
||||
|
||||
object ArrayOf : IntrinsicBase() {
|
||||
override fun equalTo(irFunction: IrFunction): Boolean {
|
||||
val fqName = irFunction.fqNameWhenAvailable.toString()
|
||||
return fqName == "kotlin.arrayOf"
|
||||
}
|
||||
|
||||
override suspend fun evaluate(
|
||||
irFunction: IrFunction, stack: Stack, interpret: suspend IrElement.() -> ExecutionResult
|
||||
): ExecutionResult {
|
||||
val array = irFunction.getArgsForMethodInvocation(stack.getAll()).toTypedArray()
|
||||
stack.pushReturnValue(array.toState(irFunction.returnType))
|
||||
return Next
|
||||
}
|
||||
}
|
||||
|
||||
object ArrayOfNulls : IntrinsicBase() {
|
||||
override fun equalTo(irFunction: IrFunction): Boolean {
|
||||
val fqName = irFunction.fqNameWhenAvailable.toString()
|
||||
return fqName == "kotlin.arrayOfNulls"
|
||||
}
|
||||
|
||||
override suspend fun evaluate(
|
||||
irFunction: IrFunction, stack: Stack, interpret: suspend IrElement.() -> ExecutionResult
|
||||
): ExecutionResult {
|
||||
val size = stack.getVariableState(irFunction.valueParameters.first().descriptor).asInt()
|
||||
val array = arrayOfNulls<Any?>(size)
|
||||
stack.pushReturnValue(array.toState(irFunction.returnType))
|
||||
return Next
|
||||
}
|
||||
}
|
||||
|
||||
object EnumValues : IntrinsicBase() {
|
||||
override fun equalTo(irFunction: IrFunction): Boolean {
|
||||
val fqName = irFunction.fqNameWhenAvailable.toString()
|
||||
return (fqName == "kotlin.enumValues" || fqName.endsWith(".values")) && irFunction.valueParameters.isEmpty()
|
||||
}
|
||||
|
||||
override suspend fun evaluate(
|
||||
irFunction: IrFunction, stack: Stack, interpret: suspend IrElement.() -> ExecutionResult
|
||||
): ExecutionResult {
|
||||
val enumClass = when (irFunction.fqNameWhenAvailable.toString()) {
|
||||
"kotlin.enumValues" -> stack.getVariableState(irFunction.typeParameters.first().descriptor).irClass
|
||||
else -> irFunction.parent as IrClass
|
||||
}
|
||||
|
||||
val enumEntries = enumClass.declarations.filterIsInstance<IrEnumEntry>()
|
||||
.map { entry -> entry.interpret().check { return it }.let { stack.popReturnValue() as Common } }
|
||||
stack.pushReturnValue(enumEntries.toTypedArray().toState(irFunction.returnType))
|
||||
return Next
|
||||
}
|
||||
}
|
||||
|
||||
object EnumValueOf : IntrinsicBase() {
|
||||
override fun equalTo(irFunction: IrFunction): Boolean {
|
||||
val fqName = irFunction.fqNameWhenAvailable.toString()
|
||||
return (fqName == "kotlin.enumValueOf" || fqName.endsWith(".valueOf")) && irFunction.valueParameters.size == 1
|
||||
}
|
||||
|
||||
override suspend fun evaluate(
|
||||
irFunction: IrFunction, stack: Stack, interpret: suspend IrElement.() -> ExecutionResult
|
||||
): ExecutionResult {
|
||||
val enumClass = when (irFunction.fqNameWhenAvailable.toString()) {
|
||||
"kotlin.enumValueOf" -> stack.getVariableState(irFunction.typeParameters.first().descriptor).irClass
|
||||
else -> irFunction.parent as IrClass
|
||||
}
|
||||
val enumEntryName = stack.getVariableState(irFunction.valueParameters.first().descriptor).asString()
|
||||
val enumEntry = enumClass.declarations.filterIsInstance<IrEnumEntry>().singleOrNull { it.name.asString() == enumEntryName }
|
||||
enumEntry?.interpret()?.check { return it }
|
||||
?: throw IllegalArgumentException("No enum constant ${enumClass.fqNameWhenAvailable}.$enumEntryName")
|
||||
|
||||
return Next
|
||||
}
|
||||
}
|
||||
|
||||
object RegexReplace : IntrinsicBase() {
|
||||
override fun equalTo(irFunction: IrFunction): Boolean {
|
||||
val fqName = irFunction.fqNameWhenAvailable.toString()
|
||||
return fqName == "kotlin.text.Regex.replace" && irFunction.valueParameters.size == 2
|
||||
}
|
||||
|
||||
override suspend fun evaluate(
|
||||
irFunction: IrFunction, stack: Stack, interpret: suspend IrElement.() -> ExecutionResult
|
||||
): ExecutionResult {
|
||||
val states = stack.getAll().map { it.state }
|
||||
val regex = states.filterIsInstance<Wrapper>().single().value as Regex
|
||||
val input = states.filterIsInstance<Primitive<*>>().single().asString()
|
||||
val transform = states.filterIsInstance<Lambda>().single().irFunction
|
||||
val matchResultParameter = transform.valueParameters.single()
|
||||
val result = regex.replace(input) {
|
||||
val itAsState = Variable(matchResultParameter.descriptor, Wrapper(it, matchResultParameter.type.classOrNull!!.owner))
|
||||
runBlocking { stack.newFrame(initPool = listOf(itAsState)) { transform.interpret() } }//.check { return it }
|
||||
stack.popReturnValue().asString()
|
||||
}
|
||||
stack.pushReturnValue(result.toState(irFunction.returnType))
|
||||
return Next
|
||||
}
|
||||
}
|
||||
|
||||
object EnumHashCode : IntrinsicBase() {
|
||||
override fun equalTo(irFunction: IrFunction): Boolean {
|
||||
val fqName = irFunction.fqNameWhenAvailable.toString()
|
||||
return fqName.endsWith(".hashCode") && irFunction.parentAsClass.isEnumClass
|
||||
}
|
||||
|
||||
override suspend fun evaluate(
|
||||
irFunction: IrFunction, stack: Stack, interpret: suspend IrElement.() -> ExecutionResult
|
||||
): ExecutionResult {
|
||||
val hashCode = stack.getAll().single().state.hashCode()
|
||||
stack.pushReturnValue(hashCode.toState(irFunction.returnType))
|
||||
return Next
|
||||
}
|
||||
}
|
||||
|
||||
object JsPrimitives : IntrinsicBase() {
|
||||
override fun equalTo(irFunction: IrFunction): Boolean {
|
||||
val fqName = irFunction.fqNameWhenAvailable.toString()
|
||||
return fqName == "kotlin.Long.<init>" || fqName == "kotlin.Char.<init>"
|
||||
}
|
||||
|
||||
override suspend fun evaluate(
|
||||
irFunction: IrFunction, stack: Stack, interpret: suspend IrElement.() -> ExecutionResult
|
||||
): ExecutionResult {
|
||||
when (irFunction.fqNameWhenAvailable.toString()) {
|
||||
"kotlin.Long.<init>" -> {
|
||||
val low = stack.getVariableState(irFunction.valueParameters[0].descriptor).asInt()
|
||||
val high = stack.getVariableState(irFunction.valueParameters[1].descriptor).asInt()
|
||||
stack.pushReturnValue((high.toLong().shl(32) + low).toState(irFunction.returnType))
|
||||
}
|
||||
"kotlin.Char.<init>" -> {
|
||||
val value = stack.getVariableState(irFunction.valueParameters[0].descriptor).asInt()
|
||||
stack.pushReturnValue(value.toChar().toState(irFunction.returnType))
|
||||
}
|
||||
}
|
||||
return Next
|
||||
}
|
||||
}
|
||||
|
||||
object ArrayConstructor : IntrinsicBase() {
|
||||
override fun equalTo(irFunction: IrFunction): Boolean {
|
||||
val fqName = irFunction.fqNameWhenAvailable.toString()
|
||||
return fqName.matches("kotlin\\.(Byte|Char|Short|Int|Long|Float|Double|Boolean|)Array\\.<init>".toRegex())
|
||||
}
|
||||
|
||||
override suspend fun evaluate(
|
||||
irFunction: IrFunction, stack: Stack, interpret: suspend IrElement.() -> ExecutionResult
|
||||
): ExecutionResult {
|
||||
val sizeDescriptor = irFunction.valueParameters[0].descriptor
|
||||
val size = stack.getVariableState(sizeDescriptor).asInt()
|
||||
val arrayValue = MutableList<Any>(size) { 0 }
|
||||
|
||||
if (irFunction.valueParameters.size == 2) {
|
||||
val initDescriptor = irFunction.valueParameters[1].descriptor
|
||||
val initLambda = stack.getVariableState(initDescriptor) as Lambda
|
||||
val index = initLambda.irFunction.valueParameters.single()
|
||||
for (i in 0 until size) {
|
||||
val indexVar = listOf(Variable(index.descriptor, i.toState(index.type)))
|
||||
// TODO throw exception if label != RETURN
|
||||
stack.newFrame(asSubFrame = initLambda.irFunction.isLocal || initLambda.irFunction.isInline, initPool = indexVar) {
|
||||
initLambda.irFunction.body!!.interpret()
|
||||
}.check(ReturnLabel.RETURN) { return it }
|
||||
arrayValue[i] = stack.popReturnValue().let { (it as? Wrapper)?.value ?: (it as? Primitive<*>)?.value ?: it }
|
||||
}
|
||||
}
|
||||
|
||||
stack.pushReturnValue(arrayValue.toPrimitiveStateArray(irFunction.parentAsClass.defaultType))
|
||||
return Next
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.interpreter.stack
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.equalTo
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.state.State
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import kotlin.NoSuchElementException
|
||||
|
||||
interface Frame {
|
||||
fun addVar(variable: Variable)
|
||||
fun addAll(variables: List<Variable>)
|
||||
fun getVariableState(variableDescriptor: DeclarationDescriptor): State
|
||||
fun tryGetVariableState(variableDescriptor: DeclarationDescriptor): State?
|
||||
fun getAll(): List<Variable>
|
||||
fun getAllTypeArguments(): List<Variable> // TODO try to get rid of this method; possibly by finding all type arguments in local class
|
||||
fun contains(descriptor: DeclarationDescriptor): Boolean
|
||||
fun pushReturnValue(state: State)
|
||||
fun pushReturnValue(frame: Frame) // TODO rename to getReturnValueFrom
|
||||
fun peekReturnValue(): State
|
||||
fun popReturnValue(): State
|
||||
fun hasReturnValue(): Boolean
|
||||
}
|
||||
|
||||
// TODO replace exceptions with InterpreterException
|
||||
class InterpreterFrame(
|
||||
private val pool: MutableList<Variable> = mutableListOf(),
|
||||
private val typeArguments: List<Variable> = listOf()
|
||||
) : Frame {
|
||||
private val returnStack: MutableList<State> = mutableListOf()
|
||||
|
||||
override fun addVar(variable: Variable) {
|
||||
pool.add(variable)
|
||||
}
|
||||
|
||||
override fun addAll(variables: List<Variable>) {
|
||||
pool.addAll(variables)
|
||||
}
|
||||
|
||||
override fun tryGetVariableState(variableDescriptor: DeclarationDescriptor): State? {
|
||||
return (if (variableDescriptor is TypeParameterDescriptor) typeArguments else pool)
|
||||
.firstOrNull { it.descriptor.equalTo(variableDescriptor) }?.state
|
||||
}
|
||||
|
||||
override fun getVariableState(variableDescriptor: DeclarationDescriptor): State {
|
||||
return tryGetVariableState(variableDescriptor)
|
||||
?: throw NoSuchElementException("Frame pool doesn't contains variable with descriptor $variableDescriptor")
|
||||
}
|
||||
|
||||
override fun getAll(): List<Variable> {
|
||||
return pool
|
||||
}
|
||||
|
||||
override fun getAllTypeArguments(): List<Variable> {
|
||||
return typeArguments
|
||||
}
|
||||
|
||||
override fun contains(descriptor: DeclarationDescriptor): Boolean {
|
||||
return (typeArguments + pool).any { it.descriptor == descriptor }
|
||||
}
|
||||
|
||||
override fun pushReturnValue(state: State) {
|
||||
returnStack += state
|
||||
}
|
||||
|
||||
override fun pushReturnValue(frame: Frame) {
|
||||
if (frame.hasReturnValue()) this.pushReturnValue(frame.popReturnValue())
|
||||
}
|
||||
|
||||
override fun hasReturnValue(): Boolean {
|
||||
return returnStack.isNotEmpty()
|
||||
}
|
||||
|
||||
override fun peekReturnValue(): State {
|
||||
if (returnStack.isNotEmpty()) {
|
||||
return returnStack.last()
|
||||
}
|
||||
throw NoSuchElementException("Return values stack is empty")
|
||||
}
|
||||
|
||||
override fun popReturnValue(): State {
|
||||
if (returnStack.isNotEmpty()) {
|
||||
val item = returnStack.last()
|
||||
returnStack.removeAt(returnStack.size - 1)
|
||||
return item
|
||||
}
|
||||
throw NoSuchElementException("Return values stack is empty")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.interpreter.stack
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.ExecutionResult
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.exceptions.InterpreterException
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.state.State
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.name
|
||||
import org.jetbrains.kotlin.ir.util.file
|
||||
import org.jetbrains.kotlin.ir.util.fileEntry
|
||||
import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult
|
||||
|
||||
interface Stack {
|
||||
suspend fun newFrame(
|
||||
asSubFrame: Boolean = false, initPool: List<Variable> = listOf(), block: suspend () -> ExecutionResult
|
||||
): ExecutionResult
|
||||
|
||||
fun setCurrentFrameName(irFunction: IrFunction)
|
||||
fun getStackTrace(): List<String>
|
||||
|
||||
fun clean()
|
||||
fun addVar(variable: Variable)
|
||||
fun addAll(variables: List<Variable>)
|
||||
fun getVariableState(variableDescriptor: DeclarationDescriptor): State
|
||||
fun getAll(): List<Variable>
|
||||
fun getAllTypeArguments(): List<Variable>
|
||||
|
||||
fun contains(descriptor: DeclarationDescriptor): Boolean
|
||||
fun hasReturnValue(): Boolean
|
||||
fun pushReturnValue(state: State)
|
||||
fun popReturnValue(): State
|
||||
fun peekReturnValue(): State
|
||||
}
|
||||
|
||||
class StackImpl : Stack {
|
||||
private val frameList = mutableListOf(FrameContainer()) // first frame is default, it is easier to work when last() is not null
|
||||
private fun getCurrentFrame() = frameList.last()
|
||||
|
||||
override suspend fun newFrame(asSubFrame: Boolean, initPool: List<Variable>, block: suspend () -> ExecutionResult): ExecutionResult {
|
||||
val typeArgumentsPool = initPool.filter { it.descriptor is TypeParameterDescriptor }
|
||||
val valueArguments = initPool.filter { it.descriptor !is TypeParameterDescriptor }
|
||||
val newFrame = InterpreterFrame(valueArguments.toMutableList(), typeArgumentsPool)
|
||||
if (asSubFrame) getCurrentFrame().addSubFrame(newFrame) else frameList.add(FrameContainer(newFrame))
|
||||
|
||||
return try {
|
||||
block()
|
||||
} finally {
|
||||
if (asSubFrame) getCurrentFrame().removeSubFrame() else removeLastFrame()
|
||||
}
|
||||
}
|
||||
|
||||
private fun removeLastFrame() {
|
||||
if (frameList.size > 1 && getCurrentFrame().hasReturnValue()) frameList[frameList.lastIndex - 1].pushReturnValue(getCurrentFrame())
|
||||
frameList.removeAt(frameList.lastIndex)
|
||||
}
|
||||
|
||||
override fun setCurrentFrameName(irFunction: IrFunction) {
|
||||
val fileName = irFunction.file.name
|
||||
val fileNameCapitalized = fileName.replace(".kt", "Kt").capitalize()
|
||||
val lineNum = irFunction.fileEntry.getLineNumber(irFunction.startOffset) + 1
|
||||
getCurrentFrame().frameEntryPoint = "at $fileNameCapitalized.${irFunction.fqNameWhenAvailable}($fileName:$lineNum)"
|
||||
}
|
||||
|
||||
override fun getStackTrace(): List<String> {
|
||||
// TODO implement some sort of cache
|
||||
return frameList.mapNotNull { it.frameEntryPoint }
|
||||
}
|
||||
|
||||
override fun clean() {
|
||||
frameList.clear()
|
||||
frameList.add(FrameContainer())
|
||||
}
|
||||
|
||||
override fun addVar(variable: Variable) {
|
||||
getCurrentFrame().addVar(variable)
|
||||
}
|
||||
|
||||
override fun addAll(variables: List<Variable>) {
|
||||
getCurrentFrame().addAll(variables)
|
||||
}
|
||||
|
||||
override fun getVariableState(variableDescriptor: DeclarationDescriptor): State {
|
||||
return getCurrentFrame().getVariableState(variableDescriptor)
|
||||
}
|
||||
|
||||
override fun getAll(): List<Variable> {
|
||||
return getCurrentFrame().getAll()
|
||||
}
|
||||
|
||||
override fun getAllTypeArguments(): List<Variable> {
|
||||
return getCurrentFrame().getAllTypeArguments()
|
||||
}
|
||||
|
||||
override fun contains(descriptor: DeclarationDescriptor): Boolean {
|
||||
return getCurrentFrame().contains(descriptor)
|
||||
}
|
||||
|
||||
override fun hasReturnValue(): Boolean {
|
||||
return getCurrentFrame().hasReturnValue()
|
||||
}
|
||||
|
||||
override fun pushReturnValue(state: State) {
|
||||
getCurrentFrame().pushReturnValue(state)
|
||||
}
|
||||
|
||||
override fun popReturnValue(): State {
|
||||
return getCurrentFrame().popReturnValue()
|
||||
}
|
||||
|
||||
override fun peekReturnValue(): State {
|
||||
return getCurrentFrame().peekReturnValue()
|
||||
}
|
||||
}
|
||||
|
||||
private class FrameContainer(current: Frame = InterpreterFrame()) {
|
||||
var frameEntryPoint: String? = null
|
||||
private val innerStack = mutableListOf(current)
|
||||
private fun getTopFrame() = innerStack.first()
|
||||
|
||||
fun addSubFrame(frame: Frame) {
|
||||
innerStack.add(0, frame)
|
||||
}
|
||||
|
||||
fun removeSubFrame() {
|
||||
if (getTopFrame().hasReturnValue() && innerStack.size > 1) innerStack[1].pushReturnValue(getTopFrame())
|
||||
innerStack.removeAt(0)
|
||||
}
|
||||
|
||||
fun addVar(variable: Variable) = getTopFrame().addVar(variable)
|
||||
fun addAll(variables: List<Variable>) = getTopFrame().addAll(variables)
|
||||
fun getAll() = innerStack.flatMap { it.getAll() }
|
||||
fun getAllTypeArguments() = innerStack.flatMap { it.getAllTypeArguments() }
|
||||
fun getVariableState(variableDescriptor: DeclarationDescriptor): State {
|
||||
return innerStack.firstNotNullResult { it.tryGetVariableState(variableDescriptor) }
|
||||
?: throw InterpreterException("$variableDescriptor not found") // TODO better message
|
||||
}
|
||||
|
||||
fun contains(descriptor: DeclarationDescriptor) = innerStack.any { it.contains(descriptor) }
|
||||
fun hasReturnValue() = getTopFrame().hasReturnValue()
|
||||
fun pushReturnValue(container: FrameContainer) = getTopFrame().pushReturnValue(container.getTopFrame())
|
||||
fun pushReturnValue(state: State) = getTopFrame().pushReturnValue(state)
|
||||
fun popReturnValue() = getTopFrame().popReturnValue()
|
||||
fun peekReturnValue() = getTopFrame().peekReturnValue()
|
||||
|
||||
override fun toString() = frameEntryPoint ?: "Not defined"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.interpreter.stack
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.state.State
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
|
||||
|
||||
data class Variable(val descriptor: DeclarationDescriptor, val state: State) {
|
||||
override fun toString(): String {
|
||||
val descriptorName = when (descriptor) {
|
||||
is ReceiverParameterDescriptor -> descriptor.containingDeclaration.name.toString() + "::this"
|
||||
else -> descriptor.name
|
||||
}
|
||||
return "Variable(descriptor=$descriptorName, state=$state)"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.interpreter.state
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.stack.Variable
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||
import org.jetbrains.kotlin.ir.types.classOrNull
|
||||
import org.jetbrains.kotlin.ir.util.fqNameForIrSerialization
|
||||
import org.jetbrains.kotlin.ir.util.isInterface
|
||||
|
||||
class Common private constructor(
|
||||
override val irClass: IrClass, override val fields: MutableList<Variable>, val typeArguments: MutableList<Variable>,
|
||||
superClass: Complex?, subClass: Complex?
|
||||
) : Complex(irClass, fields, superClass, subClass) {
|
||||
|
||||
constructor(irClass: IrClass) : this(irClass, mutableListOf(), mutableListOf(), null, null)
|
||||
|
||||
fun setSuperClassRecursive() {
|
||||
var thisClass: Common? = this
|
||||
while (thisClass != null) {
|
||||
val superClass = thisClass.irClass.superTypes.filterNot { it.isInterface() }.singleOrNull()
|
||||
val superClassOwner = superClass?.classOrNull?.owner
|
||||
val superClassState = superClassOwner?.let { Common(it) }
|
||||
superClassState?.let { thisClass!!.setSuperClassInstance(it) }
|
||||
|
||||
if (superClass == null && thisClass.irClass.superTypes.isNotEmpty()) {
|
||||
// cover the case when super type implement an interface and so doesn't have explicit any as super class
|
||||
thisClass.setSuperClassInstance(Common(getAnyClassRecursive()))
|
||||
}
|
||||
thisClass = superClassState
|
||||
}
|
||||
}
|
||||
|
||||
private fun getAnyClassRecursive(): IrClass {
|
||||
var owner = irClass.superTypes.first().classOrNull!!.owner
|
||||
while (owner.superTypes.isNotEmpty()) owner = owner.superTypes.first().classOrNull!!.owner
|
||||
return owner
|
||||
}
|
||||
|
||||
fun getToStringFunction(): IrFunctionImpl {
|
||||
return irClass.declarations.filterIsInstance<IrFunction>()
|
||||
.filter { it.descriptor.name.asString() == "toString" }
|
||||
.first { it.descriptor.valueParameters.isEmpty() } as IrFunctionImpl
|
||||
}
|
||||
|
||||
override fun copy(): State {
|
||||
return Common(irClass, fields, typeArguments, superClass, subClass ?: this)
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "Common(obj='${irClass.fqNameForIrSerialization}', super=$superClass, values=$fields)"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.interpreter.state
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.equalTo
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.stack.Variable
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.IrProperty
|
||||
import org.jetbrains.kotlin.ir.util.fqNameForIrSerialization
|
||||
|
||||
abstract class Complex(
|
||||
override val irClass: IrClass, override val fields: MutableList<Variable>, var superClass: Complex?, var subClass: Complex?
|
||||
) : State {
|
||||
fun setSuperClassInstance(superClass: Complex) {
|
||||
if (this.irClass == superClass.irClass) {
|
||||
// if superClass is just secondary constructor instance, then copy properties that isn't already present in instance
|
||||
superClass.fields.forEach { if (!this.contains(it)) fields.add(it) }
|
||||
this.superClass = superClass.superClass
|
||||
superClass.superClass?.subClass = this
|
||||
} else {
|
||||
this.superClass = superClass
|
||||
superClass.subClass = this
|
||||
}
|
||||
}
|
||||
|
||||
fun getOriginal(): Complex {
|
||||
return subClass?.getOriginal() ?: this
|
||||
}
|
||||
|
||||
fun irClassFqName(): String {
|
||||
return irClass.fqNameForIrSerialization.toString()
|
||||
}
|
||||
|
||||
private fun contains(variable: Variable) = fields.any { it.descriptor == variable.descriptor }
|
||||
|
||||
override fun setState(newVar: Variable) {
|
||||
when (val oldState = fields.firstOrNull { it.descriptor == newVar.descriptor }) {
|
||||
null -> fields.add(newVar) // newVar isn't present in value list
|
||||
else -> fields[fields.indexOf(oldState)] = newVar // newVar already present
|
||||
}
|
||||
}
|
||||
|
||||
override fun getIrFunction(descriptor: FunctionDescriptor): IrFunction? {
|
||||
val propertyGetters = irClass.declarations.filterIsInstance<IrProperty>().mapNotNull { it.getter }
|
||||
val functions = irClass.declarations.filterIsInstance<IrFunction>()
|
||||
return (propertyGetters + functions).singleOrNull { it.descriptor.equalTo(descriptor) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.interpreter.state
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.equalTo
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.stack.Variable
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.toState
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrProperty
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||
import org.jetbrains.kotlin.ir.util.isSubclassOf
|
||||
import org.jetbrains.kotlin.ir.util.nameForIrSerialization
|
||||
import kotlin.math.min
|
||||
|
||||
class ExceptionState private constructor(
|
||||
override val irClass: IrClass, override val fields: MutableList<Variable>, stackTrace: List<String>, subClass: Complex? = null
|
||||
) : Complex(irClass, fields, null, subClass) {
|
||||
|
||||
private lateinit var exceptionFqName: String
|
||||
private val exceptionHierarchy = mutableListOf<String>()
|
||||
private val messageProperty = irClass.getPropertyByName("message")
|
||||
private val causeProperty = irClass.getPropertyByName("cause")
|
||||
|
||||
private val stackTrace: List<String> = stackTrace.reversed()
|
||||
|
||||
init {
|
||||
if (!this::exceptionFqName.isInitialized) this.exceptionFqName = irClassFqName()
|
||||
|
||||
if (fields.none { it.descriptor.equalTo(messageProperty.descriptor) }) {
|
||||
setMessage()
|
||||
}
|
||||
}
|
||||
|
||||
constructor(common: Common, stackTrace: List<String>) : this(common.irClass, common.fields, stackTrace) {
|
||||
var wrapperSuperType: Complex? = common
|
||||
while (wrapperSuperType != null && wrapperSuperType !is Wrapper) wrapperSuperType = (wrapperSuperType as Common).superClass
|
||||
setUpCauseIfNeeded(wrapperSuperType as? Wrapper)
|
||||
}
|
||||
|
||||
constructor(wrapper: Wrapper, stackTrace: List<String>) : this(wrapper.value as Throwable, wrapper.irClass, stackTrace) {
|
||||
setUpCauseIfNeeded(wrapper)
|
||||
}
|
||||
|
||||
constructor(
|
||||
exception: Throwable, irClass: IrClass, stackTrace: List<String>
|
||||
) : this(irClass, evaluateFields(exception, irClass, stackTrace), stackTrace + evaluateAdditionalStackTrace(exception)) {
|
||||
if (irClass.name.asString() != exception::class.java.simpleName) {
|
||||
// ir class wasn't found in classpath, a stub was passed => need to save java class hierarchy
|
||||
this.exceptionFqName = exception::class.java.name
|
||||
exceptionHierarchy += this.exceptionFqName
|
||||
generateSequence(exception::class.java.superclass) { it.superclass }.forEach { exceptionHierarchy += it.name }
|
||||
exceptionHierarchy.removeAt(exceptionHierarchy.lastIndex) // remove unnecessary java.lang.Object
|
||||
}
|
||||
}
|
||||
|
||||
data class ExceptionData(val state: ExceptionState) : Throwable() {
|
||||
override val message: String? = state.getMessage().value
|
||||
override fun fillInStackTrace() = this
|
||||
|
||||
override fun toString(): String = state.getMessageWithName()
|
||||
}
|
||||
|
||||
private fun setUpCauseIfNeeded(wrapper: Wrapper?) {
|
||||
val cause = (wrapper?.value as? Throwable)?.cause as? ExceptionData
|
||||
setCause(cause?.state)
|
||||
if (getMessage().value == null && cause != null) {
|
||||
val causeMessage = cause.state.exceptionFqName + (cause.state.getMessage().value?.let { ": $it" } ?: "")
|
||||
setMessage(causeMessage)
|
||||
}
|
||||
}
|
||||
|
||||
fun isSubtypeOf(ancestor: IrClass): Boolean {
|
||||
if (exceptionHierarchy.isNotEmpty()) {
|
||||
return exceptionHierarchy.any { it.contains(ancestor.name.asString()) }
|
||||
}
|
||||
return irClass.isSubclassOf(ancestor)
|
||||
}
|
||||
|
||||
private fun setMessage(messageValue: String? = null) {
|
||||
setState(Variable(messageProperty.descriptor, Primitive(messageValue, messageProperty.getter!!.returnType)))
|
||||
}
|
||||
|
||||
private fun setCause(causeValue: State?) {
|
||||
setState(Variable(causeProperty.descriptor, causeValue ?: Primitive<Throwable?>(null, causeProperty.getter!!.returnType)))
|
||||
}
|
||||
|
||||
fun getMessage(): Primitive<String?> = getState(messageProperty.descriptor) as Primitive<String?>
|
||||
private fun getMessageWithName(): String = getMessage().value?.let { "$exceptionFqName: $it" } ?: exceptionFqName
|
||||
|
||||
fun getCause(): ExceptionState? = getState(causeProperty.descriptor)?.let { if (it is ExceptionState) it else null }
|
||||
|
||||
fun getFullDescription(): String {
|
||||
// TODO remainder of the stack trace with "..."
|
||||
val message = getMessage().value.let { if (it?.isNotEmpty() == true) ": $it" else "" }
|
||||
val prefix = if (stackTrace.isNotEmpty()) "\n\t" else ""
|
||||
val postfix = if (stackTrace.size > 10) "\n\t..." else ""
|
||||
val causeMessage = getCause()?.getFullDescription()?.replaceFirst("Exception ", "\nCaused by: ") ?: ""
|
||||
return "Exception $exceptionFqName$message" +
|
||||
stackTrace.subList(0, min(stackTrace.size, 10)).joinToString(separator = "\n\t", prefix = prefix, postfix = postfix) +
|
||||
causeMessage
|
||||
}
|
||||
|
||||
fun getThisAsCauseForException() = ExceptionData(this)
|
||||
|
||||
override fun copy(): State {
|
||||
return ExceptionState(irClass, fields, stackTrace, subClass ?: this)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private fun IrClass.getPropertyByName(name: String): IrProperty {
|
||||
val getPropertyFun = this.declarations.firstOrNull { it.nameForIrSerialization.asString().contains("get-$name") }
|
||||
return (getPropertyFun as? IrFunctionImpl)?.correspondingPropertySymbol?.owner
|
||||
?: this.declarations.single { it.nameForIrSerialization.asString() == name } as IrProperty
|
||||
}
|
||||
|
||||
private fun evaluateFields(exception: Throwable, irClass: IrClass, stackTrace: List<String>): MutableList<Variable> {
|
||||
val messageProperty = irClass.getPropertyByName("message")
|
||||
val causeProperty = irClass.getPropertyByName("cause")
|
||||
|
||||
val messageVar = Variable(messageProperty.descriptor, exception.message.toState(messageProperty.getter!!.returnType))
|
||||
val causeVar = exception.cause?.let {
|
||||
Variable(causeProperty.descriptor, ExceptionState(it, irClass, stackTrace + it.stackTrace.reversed().map { "at $it" }))
|
||||
}
|
||||
return listOfNotNull(messageVar, causeVar).toMutableList()
|
||||
}
|
||||
|
||||
private fun evaluateAdditionalStackTrace(e: Throwable): List<String> {
|
||||
// TODO do we really need this?... It will point to JVM stdlib
|
||||
val additionalStack = mutableListOf<String>()
|
||||
if (e.stackTrace.any { it.className == "java.lang.invoke.MethodHandle" }) {
|
||||
for ((index, stackTraceElement) in e.stackTrace.withIndex()) {
|
||||
if (stackTraceElement.methodName == "invokeWithArguments") {
|
||||
additionalStack.addAll(e.stackTrace.slice(0 until index).reversed().map { "at $it" })
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
var cause = e.cause
|
||||
val lastNeededValue = e.stackTrace.first().let { it.className + "." + it.methodName }
|
||||
while (cause != null) {
|
||||
for ((causeStackIndex, causeStackTraceElement) in cause.stackTrace.withIndex()) {
|
||||
val currentStackTraceValue = causeStackTraceElement.let { it.className + "." + it.methodName }
|
||||
if (currentStackTraceValue == lastNeededValue) {
|
||||
cause.stackTrace = cause.stackTrace.sliceArray(0 until causeStackIndex).reversedArray()
|
||||
break
|
||||
}
|
||||
}
|
||||
cause = cause.cause
|
||||
}
|
||||
}
|
||||
return additionalStack
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.interpreter.state
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.equalTo
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.stack.Variable
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.util.fqNameForIrSerialization
|
||||
import org.jetbrains.kotlin.ir.util.nameForIrSerialization
|
||||
|
||||
class Lambda(val irFunction: IrFunction, override val irClass: IrClass) : State {
|
||||
override val fields: MutableList<Variable> = mutableListOf()
|
||||
|
||||
// irFunction is anonymous declaration, but irCall will contain descriptor of invoke method from Function interface
|
||||
private val invokeDescriptor = irClass.declarations.single { it.nameForIrSerialization.asString() == "invoke" }.descriptor
|
||||
|
||||
override fun setState(newVar: Variable) {
|
||||
throw UnsupportedOperationException("Method setState is not supported in Lambda class")
|
||||
}
|
||||
|
||||
override fun getIrFunction(descriptor: FunctionDescriptor): IrFunction? {
|
||||
return if (invokeDescriptor.equalTo(descriptor)) irFunction else null
|
||||
}
|
||||
|
||||
override fun copy(): State {
|
||||
return Lambda(irFunction, irClass).apply { this.fields.addAll(this@Lambda.fields) }
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "Lambda(${irClass.fqNameForIrSerialization})"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.interpreter.state
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.stack.Variable
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.IrProperty
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.classOrNull
|
||||
|
||||
class Primitive<T>(var value: T, val type: IrType) : State {
|
||||
override val fields: MutableList<Variable> = mutableListOf()
|
||||
override val irClass: IrClass = type.classOrNull!!.owner
|
||||
|
||||
override fun getState(descriptor: DeclarationDescriptor): State {
|
||||
return super.getState(descriptor) ?: this
|
||||
}
|
||||
|
||||
override fun setState(newVar: Variable) {
|
||||
newVar.state as? Primitive<T> ?: throw IllegalArgumentException("Cannot set $newVar in current $this")
|
||||
value = newVar.state.value
|
||||
}
|
||||
|
||||
override fun copy(): State {
|
||||
return Primitive(value, type)
|
||||
}
|
||||
|
||||
override fun getIrFunction(descriptor: FunctionDescriptor): IrFunction? {
|
||||
// must add property's getter to declaration's list because they are not present in ir class for primitives
|
||||
val declarations = irClass.declarations.map { if (it is IrProperty) it.getter else it }
|
||||
return declarations.filterIsInstance<IrFunction>()
|
||||
.filter { it.descriptor.name == descriptor.name }
|
||||
.firstOrNull { it.descriptor.valueParameters.map { it.type } == descriptor.valueParameters.map { it.type } }
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as Primitive<*>
|
||||
|
||||
if (value != other.value) return false
|
||||
if (type != other.type) return false
|
||||
if (fields != other.fields) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = value?.hashCode() ?: 0
|
||||
result = 31 * result + type.hashCode()
|
||||
result = 31 * result + fields.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "Primitive(value=$value, type=${irClass.descriptor.defaultType})"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.interpreter.state
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.equalTo
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.stack.Variable
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
|
||||
interface State {
|
||||
val fields: MutableList<Variable>
|
||||
val irClass: IrClass
|
||||
|
||||
fun getState(descriptor: DeclarationDescriptor): State? {
|
||||
return fields.firstOrNull { it.descriptor.equalTo(descriptor) }?.state
|
||||
}
|
||||
|
||||
fun setState(newVar: Variable)
|
||||
|
||||
/**
|
||||
* This method is used for passing a copy of a state.
|
||||
* It is necessary then copy change its state's value, but the original one must remain the same.
|
||||
*
|
||||
* @see copyReceivedValue.kt
|
||||
* @see tryFinally.kt
|
||||
*/
|
||||
fun copy(): State
|
||||
|
||||
fun getIrFunction(descriptor: FunctionDescriptor): IrFunction?
|
||||
}
|
||||
|
||||
fun State.asInt() = (this as Primitive<*>).value as Int
|
||||
fun State.asBoolean() = (this as Primitive<*>).value as Boolean
|
||||
fun State.asString() = (this as Primitive<*>).value.toString()
|
||||
|
||||
fun State.asBooleanOrNull() = (this as? Primitive<*>)?.value as? Boolean
|
||||
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.interpreter.state
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.builtins.evaluateIntrinsicAnnotation
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.getEvaluateIntrinsicValue
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.getFqName
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.getPrimitiveClass
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.hasAnnotation
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.stack.Variable
|
||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.util.defaultType
|
||||
import org.jetbrains.kotlin.ir.util.fqNameForIrSerialization
|
||||
import org.jetbrains.kotlin.ir.util.isTypeParameter
|
||||
import org.jetbrains.kotlin.ir.util.parentAsClass
|
||||
import org.jetbrains.kotlin.name.FqNameUnsafe
|
||||
import java.lang.invoke.MethodHandle
|
||||
import java.lang.invoke.MethodHandles
|
||||
import java.lang.invoke.MethodType
|
||||
|
||||
class Wrapper private constructor(
|
||||
val value: Any, override val irClass: IrClass, subClass: Complex?
|
||||
) : Complex(irClass, mutableListOf(), null, subClass) {
|
||||
|
||||
private val typeFqName = irClass.fqNameForIrSerialization.toUnsafe()
|
||||
private val receiverClass = irClass.defaultType.getClass(true)
|
||||
|
||||
constructor(value: Any, irClass: IrClass) : this(value, irClass, null)
|
||||
|
||||
fun getMethod(irFunction: IrFunction): MethodHandle? {
|
||||
// if function is actually a getter, then use "get${property.name.capitalize()}" as method name
|
||||
val propertyName = (irFunction as? IrFunctionImpl)?.correspondingPropertySymbol?.owner?.name?.asString()
|
||||
val propertyExplicitCall = propertyName?.takeIf { receiverClass.methods.map { it.name }.contains(it) }
|
||||
val propertyGetCall = "get${propertyName?.capitalize()}".takeIf { receiverClass.methods.map { it.name }.contains(it) }
|
||||
|
||||
// intrinsicName is used to get correct java method
|
||||
// for example: - method 'get' in kotlin StringBuilder is actually 'charAt' in java StringBuilder
|
||||
val intrinsicName = irFunction.getEvaluateIntrinsicValue()
|
||||
if (intrinsicName?.isEmpty() == true) return null
|
||||
var methodName = intrinsicName ?: propertyExplicitCall ?: propertyGetCall ?: irFunction.name.toString()
|
||||
|
||||
val methodType = irFunction.getMethodType()
|
||||
methodName = if (methodName == "<get-keys>") "keySet" else methodName // TODO fix this later
|
||||
return MethodHandles.lookup().findVirtual(receiverClass, methodName, methodType)
|
||||
}
|
||||
|
||||
override fun setState(newVar: Variable) {
|
||||
throw UnsupportedOperationException("Method setState is not supported in Wrapper class")
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val companionObjectValue = mapOf<String, Any>("kotlin.text.Regex\$Companion" to Regex.Companion)
|
||||
|
||||
fun getCompanionObject(irClass: IrClass): Wrapper {
|
||||
val objectName = irClass.getEvaluateIntrinsicValue()!!
|
||||
val objectValue = companionObjectValue[objectName] ?: throw AssertionError("Companion object $objectName cannot be interpreted")
|
||||
return Wrapper(objectValue, irClass)
|
||||
}
|
||||
|
||||
fun getConstructorMethod(irConstructor: IrFunction): MethodHandle? {
|
||||
val intrinsicValue = irConstructor.parentAsClass.getEvaluateIntrinsicValue()
|
||||
if (intrinsicValue == "kotlin.Char" || intrinsicValue == "kotlin.Long") return null
|
||||
|
||||
val methodType = irConstructor.getMethodType()
|
||||
return MethodHandles.lookup().findConstructor(irConstructor.returnType.getClass(true), methodType)
|
||||
}
|
||||
|
||||
fun getStaticMethod(irFunction: IrFunction): MethodHandle? {
|
||||
val intrinsicName = irFunction.getEvaluateIntrinsicValue()
|
||||
if (intrinsicName?.isEmpty() == true) return null
|
||||
val jvmClassName = Class.forName(intrinsicName!!)
|
||||
|
||||
val methodType = irFunction.getMethodType()
|
||||
return MethodHandles.lookup().findStatic(jvmClassName, irFunction.name.asString(), methodType)
|
||||
}
|
||||
|
||||
fun getEnumEntry(enumClass: IrClass): MethodHandle? {
|
||||
val intrinsicName = enumClass.getEvaluateIntrinsicValue()
|
||||
if (intrinsicName?.isEmpty() == true) return null
|
||||
val enumClassName = Class.forName(intrinsicName!!)
|
||||
|
||||
val methodType = MethodType.methodType(enumClassName, String::class.java)
|
||||
return MethodHandles.lookup().findStatic(enumClassName, "valueOf", methodType)
|
||||
}
|
||||
|
||||
private fun IrFunction.getMethodType(): MethodType {
|
||||
val argsClasses = this.valueParameters.map { it.type.getClass(this.isValueParameterPrimitiveAsObject(it.index)) }
|
||||
return if (this is IrFunctionImpl) {
|
||||
// for regular methods and functions
|
||||
val returnClass = this.returnType.getClass(this.isReturnTypePrimitiveAsObject())
|
||||
val extensionClass = this.extensionReceiverParameter?.type?.getClass(this.isExtensionReceiverPrimitive())
|
||||
|
||||
MethodType.methodType(returnClass, listOfNotNull(extensionClass) + argsClasses)
|
||||
} else {
|
||||
// for constructors
|
||||
MethodType.methodType(Void::class.javaPrimitiveType, argsClasses)
|
||||
}
|
||||
}
|
||||
|
||||
private fun IrType.getClass(asObject: Boolean): Class<out Any> {
|
||||
val fqName = this.getFqName()
|
||||
val owner = this.classOrNull?.owner
|
||||
return when {
|
||||
this.isPrimitiveType() -> getPrimitiveClass(fqName!!, asObject)
|
||||
this.isArray() -> if (asObject) Array<Any?>::class.javaObjectType else Array<Any?>::class.java
|
||||
owner.hasAnnotation(evaluateIntrinsicAnnotation) -> Class.forName(owner!!.getEvaluateIntrinsicValue())
|
||||
//TODO primitive array
|
||||
this.isTypeParameter() -> Any::class.java
|
||||
else -> JavaToKotlinClassMap.mapKotlinToJava(FqNameUnsafe(fqName!!))?.let { Class.forName(it.asSingleFqName().toString()) }
|
||||
} ?: Class.forName(fqName)
|
||||
}
|
||||
|
||||
private fun IrFunction.getOriginalOverriddenSymbols(): MutableList<IrFunctionSymbol> {
|
||||
val overriddenSymbols = mutableListOf<IrFunctionSymbol>()
|
||||
if (this is IrFunctionImpl) {
|
||||
val pool = this.overriddenSymbols.toMutableList()
|
||||
val iterator = pool.listIterator()
|
||||
for (symbol in iterator) {
|
||||
if (symbol.owner.overriddenSymbols.isEmpty()) {
|
||||
overriddenSymbols += symbol
|
||||
iterator.remove()
|
||||
} else {
|
||||
symbol.owner.overriddenSymbols.forEach { iterator.add(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (overriddenSymbols.isEmpty()) overriddenSymbols.add(this.symbol)
|
||||
return overriddenSymbols
|
||||
}
|
||||
|
||||
private fun IrFunction.isExtensionReceiverPrimitive(): Boolean {
|
||||
return this.extensionReceiverParameter?.type?.isPrimitiveType() == false
|
||||
}
|
||||
|
||||
private fun IrFunction.isReturnTypePrimitiveAsObject(): Boolean {
|
||||
for (symbol in getOriginalOverriddenSymbols()) {
|
||||
if (!symbol.owner.returnType.isTypeParameter() && !symbol.owner.returnType.isNullable()) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun IrFunction.isValueParameterPrimitiveAsObject(index: Int): Boolean {
|
||||
for (symbol in getOriginalOverriddenSymbols()) {
|
||||
if (!symbol.owner.valueParameters[index].type.isTypeParameter() && !symbol.owner.valueParameters[index].type.isNullable()) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
override fun copy(): State {
|
||||
return Wrapper(value, irClass, subClass ?: this)
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "Wrapper(obj='$typeFqName', value=$value)"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.lower
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.CommonBackendContext
|
||||
import org.jetbrains.kotlin.backend.common.FileLoweringPass
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.*
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.builtins.compileTimeAnnotation
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.builtins.contractsDslAnnotation
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.builtins.evaluateIntrinsicAnnotation
|
||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.util.isLocal
|
||||
import org.jetbrains.kotlin.ir.util.statements
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
|
||||
class CompileTimeCalculationLowering(val context: CommonBackendContext) : FileLoweringPass {
|
||||
private val isTest = context.configuration[CommonConfigurationKeys.MODULE_NAME] == "<test-module>"
|
||||
|
||||
override fun lower(irFile: IrFile) {
|
||||
if (!context.configuration.languageVersionSettings.supportsFeature(LanguageFeature.CompileTimeCalculations)) return
|
||||
if (irFile.fileEntry.name.contains("/kotlin/libraries/")) return
|
||||
irFile.transformChildren(Transformer(irFile), null)
|
||||
}
|
||||
|
||||
private inner class Transformer(private val irFile: IrFile) : IrElementTransformerVoid() {
|
||||
private fun IrExpression.report(original: IrExpression): IrExpression {
|
||||
if (isTest) return this
|
||||
val isError = this is IrErrorExpression
|
||||
val message = when (this) {
|
||||
is IrConst<*> -> this.value.toString()
|
||||
is IrErrorExpression -> this.description
|
||||
else -> TODO("unsupported type ${this::class.java}")
|
||||
}
|
||||
context.report(original, irFile, message, isError)
|
||||
return if (this !is IrErrorExpression) this else original
|
||||
}
|
||||
|
||||
override fun visitCall(expression: IrCall): IrExpression {
|
||||
if (expression.accept(BasicVisitor(), null)) {
|
||||
return IrInterpreter(context.ir.irModule).interpret(expression).report(expression)
|
||||
}
|
||||
return expression
|
||||
}
|
||||
|
||||
override fun visitField(declaration: IrField): IrStatement {
|
||||
val initializer = declaration.initializer
|
||||
val expression = initializer?.expression ?: return declaration
|
||||
val isCompileTimeComputable = expression.accept(BasicVisitor(declaration.descriptor.toString()), null)
|
||||
if (declaration.descriptor.isConst && !isCompileTimeComputable) {
|
||||
/*initializer.expression = IrErrorExpressionImpl(
|
||||
declaration.startOffset, declaration.endOffset, declaration.type,
|
||||
"Const property is used only with functions annotated as CompileTimeCalculation"
|
||||
)*/
|
||||
context.report(expression, irFile, "Const property is used only with functions annotated as CompileTimeCalculation", true)
|
||||
} else if (isCompileTimeComputable) {
|
||||
initializer.expression = IrInterpreter(context.ir.irModule).interpret(expression).report(expression)
|
||||
}
|
||||
return declaration
|
||||
}
|
||||
|
||||
//todo annotation call
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private open class BasicVisitor(containingDeclaration: String = "") : IrElementVisitor<Boolean, Nothing?> {
|
||||
private val callStack = mutableListOf<String>().apply { if (containingDeclaration.isNotEmpty()) add(containingDeclaration) }
|
||||
|
||||
private fun IrDeclaration.isContract() = isMarkedWith(contractsDslAnnotation)
|
||||
private fun IrDeclaration.isMarkedAsEvaluateIntrinsic() = isMarkedWith(evaluateIntrinsicAnnotation)
|
||||
private fun IrDeclaration.isMarkedAsCompileTime(): Boolean = isMarkedWith(compileTimeAnnotation) ||
|
||||
(this is IrSimpleFunction && this.isFakeOverride && this.overriddenSymbols.any { it.owner.isMarkedAsCompileTime() })
|
||||
|
||||
private fun IrDeclaration.isMarkedWith(annotation: FqName): Boolean {
|
||||
if (this is IrClass && this.isCompanion) return false
|
||||
// must check descriptor annotations too because ir builtins operators don't have annotation on ir element
|
||||
if (this.hasAnnotation(annotation) || this.descriptor.annotations.hasAnnotation(annotation)) return true
|
||||
return (this.parent as? IrClass)?.isMarkedWith(annotation) ?: false
|
||||
}
|
||||
|
||||
private fun IrProperty?.isCompileTime(): Boolean {
|
||||
if (this == null) return false
|
||||
if (this.isConst) return true
|
||||
if (this.isMarkedAsCompileTime()) return true
|
||||
|
||||
val backingField = this.backingField
|
||||
val backingFieldExpression = backingField?.initializer?.expression as? IrGetValue
|
||||
return backingFieldExpression?.origin == IrStatementOrigin.INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
}
|
||||
|
||||
private fun IrSymbol.withCallStack(block: () -> Boolean): Boolean {
|
||||
callStack += this.descriptor.toString()
|
||||
val result = block()
|
||||
callStack.removeAt(callStack.lastIndex)
|
||||
return result
|
||||
}
|
||||
|
||||
override fun visitElement(element: IrElement, data: Nothing?) = false
|
||||
|
||||
private fun visitStatements(statements: List<IrStatement>, data: Nothing?): Boolean {
|
||||
return statements.all { it.accept(this, data) }
|
||||
}
|
||||
|
||||
protected fun visitConstructor(expression: IrFunctionAccessExpression): Boolean {
|
||||
return when {
|
||||
expression.symbol.owner.isMarkedAsEvaluateIntrinsic() -> true
|
||||
!visitValueParameters(expression, null) -> false
|
||||
else -> expression.symbol.owner.isMarkedAsCompileTime()
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitCall(expression: IrCall, data: Nothing?): Boolean {
|
||||
if (expression.symbol.owner.isContract()) return false
|
||||
|
||||
val property = (expression.symbol.owner as? IrFunctionImpl)?.correspondingPropertySymbol?.owner
|
||||
if (expression.symbol.owner.isMarkedAsCompileTime() || property.isCompileTime()) {
|
||||
val dispatchReceiverComputable = expression.dispatchReceiver?.accept(this, null) ?: true
|
||||
val extensionReceiverComputable = expression.extensionReceiver?.accept(this, null) ?: true
|
||||
if (!visitValueParameters(expression, null)) return false
|
||||
val bodyComputable = if (expression.symbol.owner.isLocal) expression.symbol.owner.body?.accept(this, null) ?: true else true
|
||||
|
||||
return dispatchReceiverComputable && extensionReceiverComputable && bodyComputable
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
override fun visitVariable(declaration: IrVariable, data: Nothing?): Boolean {
|
||||
return declaration.initializer?.accept(this, data) ?: true
|
||||
}
|
||||
|
||||
private fun visitValueParameters(expression: IrFunctionAccessExpression, data: Nothing?): Boolean {
|
||||
return (0 until expression.valueArgumentsCount)
|
||||
.map { expression.getValueArgument(it) }
|
||||
.none { it?.accept(this, data) == false }
|
||||
}
|
||||
|
||||
override fun visitBody(body: IrBody, data: Nothing?): Boolean {
|
||||
return visitStatements(body.statements, data)
|
||||
}
|
||||
|
||||
override fun visitBlock(expression: IrBlock, data: Nothing?): Boolean {
|
||||
return visitStatements(expression.statements, data)
|
||||
}
|
||||
|
||||
override fun visitSyntheticBody(body: IrSyntheticBody, data: Nothing?): Boolean {
|
||||
return body.kind == IrSyntheticBodyKind.ENUM_VALUES || body.kind == IrSyntheticBodyKind.ENUM_VALUEOF
|
||||
}
|
||||
|
||||
override fun <T> visitConst(expression: IrConst<T>, data: Nothing?): Boolean = true
|
||||
|
||||
override fun visitVararg(expression: IrVararg, data: Nothing?): Boolean {
|
||||
return expression.elements.any { it.accept(this, data) }
|
||||
}
|
||||
|
||||
override fun visitSpreadElement(spread: IrSpreadElement, data: Nothing?): Boolean {
|
||||
return spread.expression.accept(this, data)
|
||||
}
|
||||
|
||||
override fun visitComposite(expression: IrComposite, data: Nothing?): Boolean {
|
||||
if (expression.origin == IrStatementOrigin.DESTRUCTURING_DECLARATION) {
|
||||
return visitStatements(expression.statements, data)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun visitStringConcatenation(expression: IrStringConcatenation, data: Nothing?): Boolean {
|
||||
return expression.arguments.all { it.accept(this, data) }
|
||||
}
|
||||
|
||||
override fun visitGetObjectValue(expression: IrGetObjectValue, data: Nothing?): Boolean {
|
||||
// to get object value we need nothing but it will contain only fields with compile time annotation
|
||||
return true
|
||||
}
|
||||
|
||||
override fun visitGetEnumValue(expression: IrGetEnumValue, data: Nothing?): Boolean {
|
||||
return expression.symbol.owner.initializerExpression?.accept(this, data) == true
|
||||
}
|
||||
|
||||
override fun visitGetValue(expression: IrGetValue, data: Nothing?): Boolean {
|
||||
return callStack.contains(expression.symbol.descriptor.containingDeclaration.toString())
|
||||
}
|
||||
|
||||
override fun visitSetVariable(expression: IrSetVariable, data: Nothing?): Boolean {
|
||||
return expression.value.accept(this, data)
|
||||
}
|
||||
|
||||
override fun visitGetField(expression: IrGetField, data: Nothing?): Boolean {
|
||||
return callStack.contains(expression.symbol.descriptor.containingDeclaration.toString())
|
||||
}
|
||||
|
||||
override fun visitSetField(expression: IrSetField, data: Nothing?): Boolean {
|
||||
//todo check receiver?
|
||||
return callStack.contains(expression.symbol.descriptor.containingDeclaration.toString()) && expression.value.accept(this, data)
|
||||
}
|
||||
|
||||
override fun visitConstructorCall(expression: IrConstructorCall, data: Nothing?): Boolean {
|
||||
return visitConstructor(expression)
|
||||
}
|
||||
|
||||
override fun visitEnumConstructorCall(expression: IrEnumConstructorCall, data: Nothing?): Boolean {
|
||||
return visitConstructor(expression)
|
||||
}
|
||||
|
||||
override fun visitFunctionReference(expression: IrFunctionReference, data: Nothing?): Boolean {
|
||||
return expression.symbol.withCallStack {
|
||||
expression.symbol.owner.isMarkedAsCompileTime() && expression.symbol.owner.body?.accept(this, data) == true
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitFunctionExpression(expression: IrFunctionExpression, data: Nothing?): Boolean {
|
||||
val isLambda = expression.origin == IrStatementOrigin.LAMBDA || expression.origin == IrStatementOrigin.ANONYMOUS_FUNCTION
|
||||
val isCompileTime = expression.function.isMarkedAsCompileTime()
|
||||
return expression.function.symbol.withCallStack {
|
||||
if (isLambda || isCompileTime) expression.function.body?.accept(this, data) == true else false
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitTypeOperator(expression: IrTypeOperatorCall, data: Nothing?): Boolean {
|
||||
return when (expression.operator) {
|
||||
IrTypeOperator.INSTANCEOF, IrTypeOperator.NOT_INSTANCEOF,
|
||||
IrTypeOperator.IMPLICIT_COERCION_TO_UNIT,
|
||||
IrTypeOperator.CAST, IrTypeOperator.IMPLICIT_CAST, IrTypeOperator.SAFE_CAST -> expression.argument.accept(this, data)
|
||||
IrTypeOperator.IMPLICIT_DYNAMIC_CAST -> false
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitWhen(expression: IrWhen, data: Nothing?): Boolean {
|
||||
return expression.branches.all { it.accept(this, data) }
|
||||
}
|
||||
|
||||
override fun visitBranch(branch: IrBranch, data: Nothing?): Boolean {
|
||||
return branch.condition.accept(this, data) && branch.result.accept(this, data)
|
||||
}
|
||||
|
||||
override fun visitWhileLoop(loop: IrWhileLoop, data: Nothing?): Boolean {
|
||||
return loop.condition.accept(this, data) && (loop.body?.accept(this, data) ?: true)
|
||||
}
|
||||
|
||||
override fun visitDoWhileLoop(loop: IrDoWhileLoop, data: Nothing?): Boolean {
|
||||
return loop.condition.accept(this, data) && (loop.body?.accept(this, data) ?: true)
|
||||
}
|
||||
|
||||
override fun visitTry(aTry: IrTry, data: Nothing?): Boolean {
|
||||
if (!aTry.tryResult.accept(this, data)) return false
|
||||
if (aTry.finallyExpression != null && aTry.finallyExpression?.accept(this, data) == false) return false
|
||||
return aTry.catches.all { it.result.accept(this, data) }
|
||||
}
|
||||
|
||||
override fun visitBreak(jump: IrBreak, data: Nothing?): Boolean = true
|
||||
|
||||
override fun visitContinue(jump: IrContinue, data: Nothing?): Boolean = true
|
||||
|
||||
override fun visitReturn(expression: IrReturn, data: Nothing?): Boolean {
|
||||
if (!callStack.contains(expression.returnTargetSymbol.descriptor.toString())) return false
|
||||
return expression.value.accept(this, data)
|
||||
}
|
||||
|
||||
override fun visitThrow(expression: IrThrow, data: Nothing?): Boolean {
|
||||
return expression.value.accept(this, data)
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ dependencies {
|
||||
compile(project(":compiler:ir.serialization.js"))
|
||||
compile(project(":js:js.ast"))
|
||||
compile(project(":js:js.frontend"))
|
||||
compile(project(":compiler:cli"))
|
||||
|
||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import org.jetbrains.kotlin.backend.common.ir.Ir
|
||||
import org.jetbrains.kotlin.backend.common.ir.Symbols
|
||||
import org.jetbrains.kotlin.backend.js.JsDeclarationFactory
|
||||
import org.jetbrains.kotlin.builtins.PrimitiveType
|
||||
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.impl.EmptyPackageFragmentDescriptor
|
||||
@@ -31,6 +33,9 @@ import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.psiUtil.isDotSelector
|
||||
import org.jetbrains.kotlin.psi2ir.PsiSourceManager
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
@@ -354,6 +359,19 @@ class JsIrBackendContext(
|
||||
|
||||
override fun report(element: IrElement?, irFile: IrFile?, message: String, isError: Boolean) {
|
||||
/*TODO*/
|
||||
val psiFileEntry = irFile?.fileEntry as? PsiSourceManager.PsiFileEntry
|
||||
val elementInfo = when {
|
||||
psiFileEntry != null && element != null -> {
|
||||
var psi = psiFileEntry.findPsiElement(element)
|
||||
while ((psi as? KtExpression)?.isDotSelector() == true) psi = psi.parent
|
||||
"${psi?.text} at ${psiFileEntry.getLineNumber(element.startOffset)} line"
|
||||
}
|
||||
else -> ""
|
||||
}
|
||||
val messageCollector = configuration[CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY]!!
|
||||
val severity = /*if (isError) CompilerMessageSeverity.ERROR else*/ CompilerMessageSeverity.INFO
|
||||
val textInTheMiddle = if (isError) "will produce exception:" else "will be replaced on:"
|
||||
messageCollector.report(severity, "$elementInfo $textInTheMiddle $message")
|
||||
print(message)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -598,6 +598,13 @@ private val objectUsageLoweringPhase = makeBodyLoweringPhase(
|
||||
description = "Transform IrGetObjectValue into instance generator call"
|
||||
)
|
||||
|
||||
val compileTimeEvaluationPhase = makeJsModulePhase(
|
||||
::CompileTimeCalculationLowering,
|
||||
name = "CompileTimeEvaluation",
|
||||
//TODO change annotation to modifier
|
||||
description = "Evaluate calls that are marked with @CompileTimeCalculation annotation",
|
||||
).toModuleLowering()
|
||||
|
||||
private val cleanupLoweringPhase = makeBodyLoweringPhase(
|
||||
{ CleanupLowering() },
|
||||
name = "CleanupLowering",
|
||||
@@ -609,6 +616,7 @@ val loweringList = listOf<Lowering>(
|
||||
validateIrBeforeLowering,
|
||||
testGenerationPhase,
|
||||
expectDeclarationsRemovingPhase,
|
||||
compileTimeEvaluationPhase,
|
||||
stripTypeAliasDeclarationsPhase,
|
||||
arrayConstructorPhase,
|
||||
lateinitNullableFieldsPhase,
|
||||
|
||||
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.ir.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.PrimitiveType
|
||||
import org.jetbrains.kotlin.builtins.compileTimeAnnotation
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
|
||||
@@ -52,8 +53,12 @@ class IrBuiltIns(
|
||||
private fun ClassDescriptor.toIrSymbol() = symbolTable.referenceClass(this)
|
||||
private fun KotlinType.toIrType() = typeTranslator.translateType(this)
|
||||
|
||||
fun defineOperator(name: String, returnType: IrType, valueParameterTypes: List<IrType>): IrSimpleFunctionSymbol {
|
||||
val operatorDescriptor = IrSimpleBuiltinOperatorDescriptorImpl(packageFragmentDescriptor, Name.identifier(name), returnType.originalKotlinType!!)
|
||||
fun defineOperator(
|
||||
name: String, returnType: IrType, valueParameterTypes: List<IrType>, isCompileTime: Boolean = false
|
||||
): IrSimpleFunctionSymbol {
|
||||
val operatorDescriptor = IrSimpleBuiltinOperatorDescriptorImpl(
|
||||
packageFragmentDescriptor, Name.identifier(name), returnType.originalKotlinType!!, isCompileTime
|
||||
)
|
||||
|
||||
for ((i, valueParameterType) in valueParameterTypes.withIndex()) {
|
||||
val valueParameterDescriptor =
|
||||
@@ -91,7 +96,7 @@ class IrBuiltIns(
|
||||
// Note: We still need a complete function descriptor here because `CHECK_NOT_NULL` is being substituted by psi2ir
|
||||
val operatorDescriptor = SimpleFunctionDescriptorImpl.create(
|
||||
packageFragmentDescriptor,
|
||||
Annotations.EMPTY,
|
||||
compileTimeAnnotation,
|
||||
name,
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
SourceElement.NO_SOURCE
|
||||
@@ -153,11 +158,11 @@ class IrBuiltIns(
|
||||
}.symbol
|
||||
}
|
||||
|
||||
private fun defineComparisonOperator(name: String, operandType: IrType) =
|
||||
defineOperator(name, booleanType, listOf(operandType, operandType))
|
||||
private fun defineComparisonOperator(name: String, operandType: IrType, isCompileTime: Boolean = false) =
|
||||
defineOperator(name, booleanType, listOf(operandType, operandType), isCompileTime)
|
||||
|
||||
private fun List<IrType>.defineComparisonOperatorForEachIrType(name: String) =
|
||||
associate { it.classifierOrFail to defineComparisonOperator(name, it) }
|
||||
private fun List<IrType>.defineComparisonOperatorForEachIrType(name: String, isCompileTime: Boolean = false) =
|
||||
associate { it.classifierOrFail to defineComparisonOperator(name, it, isCompileTime) }
|
||||
|
||||
val any = builtIns.anyType
|
||||
val anyN = builtIns.nullableAnyType
|
||||
@@ -263,25 +268,25 @@ class IrBuiltIns(
|
||||
PrimitiveType.DOUBLE to doubleType
|
||||
)
|
||||
|
||||
val lessFunByOperandType = primitiveIrTypesWithComparisons.defineComparisonOperatorForEachIrType(OperatorNames.LESS)
|
||||
val lessOrEqualFunByOperandType = primitiveIrTypesWithComparisons.defineComparisonOperatorForEachIrType(OperatorNames.LESS_OR_EQUAL)
|
||||
val greaterOrEqualFunByOperandType = primitiveIrTypesWithComparisons.defineComparisonOperatorForEachIrType(OperatorNames.GREATER_OR_EQUAL)
|
||||
val greaterFunByOperandType = primitiveIrTypesWithComparisons.defineComparisonOperatorForEachIrType(OperatorNames.GREATER)
|
||||
val lessFunByOperandType = primitiveIrTypesWithComparisons.defineComparisonOperatorForEachIrType(OperatorNames.LESS, true)
|
||||
val lessOrEqualFunByOperandType = primitiveIrTypesWithComparisons.defineComparisonOperatorForEachIrType(OperatorNames.LESS_OR_EQUAL, true)
|
||||
val greaterOrEqualFunByOperandType = primitiveIrTypesWithComparisons.defineComparisonOperatorForEachIrType(OperatorNames.GREATER_OR_EQUAL, true)
|
||||
val greaterFunByOperandType = primitiveIrTypesWithComparisons.defineComparisonOperatorForEachIrType(OperatorNames.GREATER, true)
|
||||
|
||||
val ieee754equalsFunByOperandType =
|
||||
primitiveFloatingPointIrTypes.map {
|
||||
it.classifierOrFail to defineOperator(OperatorNames.IEEE754_EQUALS, booleanType, listOf(it.makeNullable(), it.makeNullable()))
|
||||
it.classifierOrFail to defineOperator(OperatorNames.IEEE754_EQUALS, booleanType, listOf(it.makeNullable(), it.makeNullable()), true)
|
||||
}.toMap()
|
||||
|
||||
private val booleanNot = builtIns.boolean.unsubstitutedMemberScope.getContributedFunctions(Name.identifier("not"), NoLookupLocation.FROM_BACKEND).single()
|
||||
val booleanNotSymbol = symbolTable.referenceSimpleFunction(booleanNot)
|
||||
|
||||
val eqeqeqSymbol = defineOperator(OperatorNames.EQEQEQ, booleanType, listOf(anyNType, anyNType))
|
||||
val eqeqSymbol = defineOperator(OperatorNames.EQEQ, booleanType, listOf(anyNType, anyNType))
|
||||
val eqeqeqSymbol = defineOperator(OperatorNames.EQEQEQ, booleanType, listOf(anyNType, anyNType), true)
|
||||
val eqeqSymbol = defineOperator(OperatorNames.EQEQ, booleanType, listOf(anyNType, anyNType), true)
|
||||
val throwCceSymbol = defineOperator(OperatorNames.THROW_CCE, nothingType, listOf())
|
||||
val throwIseSymbol = defineOperator(OperatorNames.THROW_ISE, nothingType, listOf())
|
||||
val andandSymbol = defineOperator(OperatorNames.ANDAND, booleanType, listOf(booleanType, booleanType))
|
||||
val ororSymbol = defineOperator(OperatorNames.OROR, booleanType, listOf(booleanType, booleanType))
|
||||
val andandSymbol = defineOperator(OperatorNames.ANDAND, booleanType, listOf(booleanType, booleanType), true)
|
||||
val ororSymbol = defineOperator(OperatorNames.OROR, booleanType, listOf(booleanType, booleanType), true)
|
||||
val noWhenBranchMatchedExceptionSymbol = defineOperator(OperatorNames.NO_WHEN_BRANCH_MATCHED_EXCEPTION, nothingType, listOf())
|
||||
val illegalArgumentExceptionSymbol = defineOperator(OperatorNames.ILLEGAL_ARGUMENT_EXCEPTION, nothingType, listOf(stringType))
|
||||
|
||||
|
||||
@@ -16,10 +16,14 @@
|
||||
|
||||
package org.jetbrains.kotlin.ir.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.builtins.DefaultBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.getEmptyOrCompileTime
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorNonRootImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.VariableDescriptorImpl
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
@@ -30,8 +34,8 @@ interface IrBuiltinOperatorDescriptor : SimpleFunctionDescriptor
|
||||
|
||||
interface IrBuiltinValueParameterDescriptor : ValueParameterDescriptor
|
||||
|
||||
abstract class IrBuiltinOperatorDescriptorBase(containingDeclaration: DeclarationDescriptor, name: Name) :
|
||||
DeclarationDescriptorNonRootImpl(containingDeclaration, Annotations.EMPTY, name, SourceElement.NO_SOURCE),
|
||||
abstract class IrBuiltinOperatorDescriptorBase(containingDeclaration: DeclarationDescriptor, name: Name, isCompileTime: Boolean) :
|
||||
DeclarationDescriptorNonRootImpl(containingDeclaration, getEmptyOrCompileTime(isCompileTime), name, SourceElement.NO_SOURCE),
|
||||
IrBuiltinOperatorDescriptor {
|
||||
override fun getDispatchReceiverParameter(): ReceiverParameterDescriptor? = null
|
||||
override fun getExtensionReceiverParameter(): ReceiverParameterDescriptor? = null
|
||||
@@ -77,8 +81,9 @@ abstract class IrBuiltinOperatorDescriptorBase(containingDeclaration: Declaratio
|
||||
class IrSimpleBuiltinOperatorDescriptorImpl(
|
||||
containingDeclaration: DeclarationDescriptor,
|
||||
name: Name,
|
||||
private val returnType: KotlinType
|
||||
) : IrBuiltinOperatorDescriptorBase(containingDeclaration, name), IrBuiltinOperatorDescriptor {
|
||||
private val returnType: KotlinType,
|
||||
isCompileTime: Boolean
|
||||
) : IrBuiltinOperatorDescriptorBase(containingDeclaration, name, isCompileTime), IrBuiltinOperatorDescriptor {
|
||||
private val valueParameters: MutableList<IrBuiltinValueParameterDescriptor> = ArrayList()
|
||||
|
||||
fun addValueParameter(valueParameter: IrBuiltinValueParameterDescriptor) {
|
||||
|
||||
18
compiler/testData/diagnostics/tests/constexpr/compileTimeMember.fir.kt
vendored
Normal file
18
compiler/testData/diagnostics/tests/constexpr/compileTimeMember.fir.kt
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation
|
||||
abstract class ConstExprClass {
|
||||
abstract fun getSomeValue(): Int
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
class A(val a: Int): ConstExprClass() {
|
||||
override fun getSomeValue() = a
|
||||
}
|
||||
|
||||
class B @CompileTimeCalculation constructor(val b: Int): ConstExprClass() {
|
||||
override fun getSomeValue() = b
|
||||
}
|
||||
|
||||
const val a = A(1).getSomeValue()
|
||||
const val b = B(2).getSomeValue()
|
||||
18
compiler/testData/diagnostics/tests/constexpr/compileTimeMember.kt
vendored
Normal file
18
compiler/testData/diagnostics/tests/constexpr/compileTimeMember.kt
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation
|
||||
abstract class ConstExprClass {
|
||||
abstract fun getSomeValue(): Int
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
class A(val a: Int): ConstExprClass() {
|
||||
override fun getSomeValue() = a
|
||||
}
|
||||
|
||||
class B @CompileTimeCalculation constructor(val b: Int): ConstExprClass() {
|
||||
<!COMPILE_TIME_MEMBER_NOT_IMPLEMENTED!>override fun getSomeValue() = b<!>
|
||||
}
|
||||
|
||||
const val a = A(1).getSomeValue()
|
||||
const val b = B(2).getSomeValue()
|
||||
30
compiler/testData/diagnostics/tests/constexpr/compileTimeMember.txt
vendored
Normal file
30
compiler/testData/diagnostics/tests/constexpr/compileTimeMember.txt
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
package
|
||||
|
||||
public const val a: kotlin.Int
|
||||
public const val b: kotlin.Int
|
||||
|
||||
@kotlin.CompileTimeCalculation public final class A : ConstExprClass {
|
||||
public constructor A(/*0*/ a: kotlin.Int)
|
||||
public final val a: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ fun getSomeValue(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class B : ConstExprClass {
|
||||
@kotlin.CompileTimeCalculation public constructor B(/*0*/ b: kotlin.Int)
|
||||
public final val b: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ fun getSomeValue(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@kotlin.CompileTimeCalculation public abstract class ConstExprClass {
|
||||
public constructor ConstExprClass()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public abstract fun getSomeValue(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
36
compiler/testData/diagnostics/tests/constexpr/constInitializer.kt
vendored
Normal file
36
compiler/testData/diagnostics/tests/constexpr/constInitializer.kt
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun getInt() = 1
|
||||
const val a = getInt()
|
||||
|
||||
@CompileTimeCalculation
|
||||
open class A(val a: Int)
|
||||
const val get = A(10).a
|
||||
|
||||
class B @CompileTimeCalculation constructor(val b: Int): A(b + 1)
|
||||
const val getB = B(3).b
|
||||
const val getAFromB = B(3).a
|
||||
|
||||
@CompileTimeCalculation
|
||||
class C(val c: Int) {
|
||||
fun get() = c
|
||||
}
|
||||
const val getC = C(4).get()
|
||||
const val getCAsProperty = C(4).c
|
||||
const val equals = C(4).equals(C(5))
|
||||
const val toString = C(6).toString()
|
||||
|
||||
class D @CompileTimeCalculation constructor() {
|
||||
@CompileTimeCalculation
|
||||
override fun hashCode(): Int {
|
||||
return super.hashCode()
|
||||
}
|
||||
}
|
||||
const val hashCode = D().hashCode()
|
||||
|
||||
class E @CompileTimeCalculation constructor() {
|
||||
@CompileTimeCalculation val e: Int = 1
|
||||
}
|
||||
const val getE = E().e
|
||||
54
compiler/testData/diagnostics/tests/constexpr/constInitializer.txt
vendored
Normal file
54
compiler/testData/diagnostics/tests/constexpr/constInitializer.txt
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
package
|
||||
|
||||
public const val a: kotlin.Int
|
||||
public const val equals: kotlin.Boolean
|
||||
public const val get: kotlin.Int
|
||||
public const val getAFromB: kotlin.Int
|
||||
public const val getB: kotlin.Int
|
||||
public const val getC: kotlin.Int
|
||||
public const val getCAsProperty: kotlin.Int
|
||||
public const val getE: kotlin.Int = 1
|
||||
public const val hashCode: kotlin.Int
|
||||
public const val toString: kotlin.String
|
||||
@kotlin.CompileTimeCalculation public fun getInt(): kotlin.Int
|
||||
|
||||
@kotlin.CompileTimeCalculation public open class A {
|
||||
public constructor A(/*0*/ a: kotlin.Int)
|
||||
public final val a: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class B : A {
|
||||
@kotlin.CompileTimeCalculation public constructor B(/*0*/ b: kotlin.Int)
|
||||
public final override /*1*/ /*fake_override*/ val a: kotlin.Int
|
||||
public final val b: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@kotlin.CompileTimeCalculation public final class C {
|
||||
public constructor C(/*0*/ c: kotlin.Int)
|
||||
public final val c: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun get(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class D {
|
||||
@kotlin.CompileTimeCalculation public constructor D()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@kotlin.CompileTimeCalculation public open override /*1*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class E {
|
||||
@kotlin.CompileTimeCalculation public constructor E()
|
||||
@kotlin.CompileTimeCalculation public final val e: kotlin.Int = 1
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
18
compiler/testData/diagnostics/tests/constexpr/nonCompileTimeInDeclaration.fir.kt
vendored
Normal file
18
compiler/testData/diagnostics/tests/constexpr/nonCompileTimeInDeclaration.fir.kt
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
fun plus(a: Int, b: Int) = a + b
|
||||
|
||||
@CompileTimeCalculation
|
||||
class A(val a: Int) {
|
||||
fun inc() = plus(a, 1)
|
||||
}
|
||||
|
||||
class B(val b: Int) {
|
||||
@CompileTimeCalculation
|
||||
fun get() = b
|
||||
}
|
||||
|
||||
class c(val c: Int) {
|
||||
@CompileTimeCalculation
|
||||
constructor(): this(0)
|
||||
}
|
||||
18
compiler/testData/diagnostics/tests/constexpr/nonCompileTimeInDeclaration.kt
vendored
Normal file
18
compiler/testData/diagnostics/tests/constexpr/nonCompileTimeInDeclaration.kt
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
fun plus(a: Int, b: Int) = a + b
|
||||
|
||||
@CompileTimeCalculation
|
||||
class A(val a: Int) {
|
||||
fun inc() = <!NON_COMPILE_TIME_EXPRESSION_IN_COMPILE_TIME_DECLARATION!>plus<!>(a, 1)
|
||||
}
|
||||
|
||||
class B(val b: Int) {
|
||||
@CompileTimeCalculation
|
||||
fun get() = <!NON_COMPILE_TIME_EXPRESSION_IN_COMPILE_TIME_DECLARATION!>b<!>
|
||||
}
|
||||
|
||||
class c(val c: Int) {
|
||||
@CompileTimeCalculation
|
||||
constructor(): <!NON_COMPILE_TIME_EXPRESSION_IN_COMPILE_TIME_DECLARATION!>this<!>(0)
|
||||
}
|
||||
30
compiler/testData/diagnostics/tests/constexpr/nonCompileTimeInDeclaration.txt
vendored
Normal file
30
compiler/testData/diagnostics/tests/constexpr/nonCompileTimeInDeclaration.txt
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
package
|
||||
|
||||
public fun plus(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Int
|
||||
|
||||
@kotlin.CompileTimeCalculation public final class A {
|
||||
public constructor A(/*0*/ a: kotlin.Int)
|
||||
public final val a: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun inc(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class B {
|
||||
public constructor B(/*0*/ b: kotlin.Int)
|
||||
public final val b: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@kotlin.CompileTimeCalculation public final fun get(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class c {
|
||||
@kotlin.CompileTimeCalculation public constructor c()
|
||||
public constructor c(/*0*/ c: kotlin.Int)
|
||||
public final val c: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
29
compiler/testData/diagnostics/tests/constexpr/nonConstInitializer.fir.kt
vendored
Normal file
29
compiler/testData/diagnostics/tests/constexpr/nonConstInitializer.fir.kt
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
fun getNotConstExprInt() = 1
|
||||
const val a = getNotConstExprInt()
|
||||
|
||||
open class A(val a: Int)
|
||||
const val get = A(10).a
|
||||
|
||||
class B @CompileTimeCalculation constructor(val b: Int): A(b + 1)
|
||||
const val getAFromB = B(3).a
|
||||
|
||||
class C @CompileTimeCalculation constructor(val c: Int) {
|
||||
fun get() = c
|
||||
}
|
||||
const val getC = C(4).get()
|
||||
const val equals = C(4).equals(C(5))
|
||||
const val toString = C(6).toString()
|
||||
|
||||
class D @CompileTimeCalculation constructor() {
|
||||
override fun hashCode(): Int {
|
||||
return super.hashCode()
|
||||
}
|
||||
}
|
||||
const val hashCode = D().hashCode()
|
||||
|
||||
class E @CompileTimeCalculation constructor() {
|
||||
val e: Int = 1
|
||||
}
|
||||
const val getE = E().e
|
||||
29
compiler/testData/diagnostics/tests/constexpr/nonConstInitializer.kt
vendored
Normal file
29
compiler/testData/diagnostics/tests/constexpr/nonConstInitializer.kt
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
fun getNotConstExprInt() = 1
|
||||
const val a = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>getNotConstExprInt<!>()
|
||||
|
||||
open class A(val a: Int)
|
||||
const val get = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>A<!>(10).<!CONST_VAL_WITH_NON_CONST_INITIALIZER!>a<!>
|
||||
|
||||
class B @CompileTimeCalculation constructor(val b: Int): <!NON_COMPILE_TIME_EXPRESSION_IN_COMPILE_TIME_DECLARATION!>A<!>(b + 1)
|
||||
const val getAFromB = B(3).<!CONST_VAL_WITH_NON_CONST_INITIALIZER!>a<!>
|
||||
|
||||
class C @CompileTimeCalculation constructor(val c: Int) {
|
||||
fun get() = c
|
||||
}
|
||||
const val getC = C(4).<!CONST_VAL_WITH_NON_CONST_INITIALIZER!>get<!>()
|
||||
const val equals = C(4).equals(C(5))
|
||||
const val toString = C(6).toString()
|
||||
|
||||
class D @CompileTimeCalculation constructor() {
|
||||
<!COMPILE_TIME_MEMBER_NOT_IMPLEMENTED!>override fun hashCode(): Int {
|
||||
return super.hashCode()
|
||||
}<!>
|
||||
}
|
||||
const val hashCode = D().hashCode()
|
||||
|
||||
class E @CompileTimeCalculation constructor() {
|
||||
val e: Int = 1
|
||||
}
|
||||
const val getE = E().<!CONST_VAL_WITH_NON_CONST_INITIALIZER!>e<!>
|
||||
52
compiler/testData/diagnostics/tests/constexpr/nonConstInitializer.txt
vendored
Normal file
52
compiler/testData/diagnostics/tests/constexpr/nonConstInitializer.txt
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
package
|
||||
|
||||
public const val a: kotlin.Int
|
||||
public const val equals: kotlin.Boolean
|
||||
public const val get: kotlin.Int
|
||||
public const val getAFromB: kotlin.Int
|
||||
public const val getC: kotlin.Int
|
||||
public const val getE: kotlin.Int = 1
|
||||
public const val hashCode: kotlin.Int
|
||||
public const val toString: kotlin.String
|
||||
public fun getNotConstExprInt(): kotlin.Int
|
||||
|
||||
public open class A {
|
||||
public constructor A(/*0*/ a: kotlin.Int)
|
||||
public final val a: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class B : A {
|
||||
@kotlin.CompileTimeCalculation public constructor B(/*0*/ b: kotlin.Int)
|
||||
public final override /*1*/ /*fake_override*/ val a: kotlin.Int
|
||||
public final val b: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class C {
|
||||
@kotlin.CompileTimeCalculation public constructor C(/*0*/ c: kotlin.Int)
|
||||
public final val c: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun get(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class D {
|
||||
@kotlin.CompileTimeCalculation public constructor D()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class E {
|
||||
@kotlin.CompileTimeCalculation public constructor E()
|
||||
public final val e: kotlin.Int = 1
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
53
compiler/testData/ir/interpreter/abstract1.kt
vendored
Normal file
53
compiler/testData/ir/interpreter/abstract1.kt
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
abstract class A @CompileTimeCalculation constructor() {
|
||||
@CompileTimeCalculation
|
||||
abstract fun getIntNum(): Int
|
||||
}
|
||||
|
||||
open class B @CompileTimeCalculation constructor(@CompileTimeCalculation val b: Int) : A() {
|
||||
@CompileTimeCalculation
|
||||
override fun getIntNum(): Int {
|
||||
return b
|
||||
}
|
||||
}
|
||||
|
||||
class C @CompileTimeCalculation constructor(@CompileTimeCalculation val c: Int) : B(c + 1) {
|
||||
@CompileTimeCalculation
|
||||
override fun getIntNum(): Int {
|
||||
return c
|
||||
}
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun getAClassImplementation(num: Int): A {
|
||||
return B(num)
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun getBClassImplementation(num: Int): B {
|
||||
return B(num)
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun getClassCAsA(num: Int): A {
|
||||
return C(num)
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun getClassCAsB(num: Int): B {
|
||||
return C(num)
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun getClassCAsC(num: Int): C {
|
||||
return C(num)
|
||||
}
|
||||
|
||||
const val num1 = getAClassImplementation(1).getIntNum()
|
||||
const val num2 = getBClassImplementation(2).getIntNum()
|
||||
|
||||
// all `getIntNum` methods are from class C
|
||||
const val num3 = getClassCAsA(3).getIntNum()
|
||||
const val num4 = getClassCAsB(4).getIntNum()
|
||||
const val num5 = getClassCAsC(5).getIntNum()
|
||||
199
compiler/testData/ir/interpreter/abstract1.txt
vendored
Normal file
199
compiler/testData/ir/interpreter/abstract1.txt
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
FILE fqName:<root> fileName:/abstract1.kt
|
||||
CLASS CLASS name:A modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.A [primary]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
FUN name:getIntNum visibility:public modality:ABSTRACT <> ($this:<root>.A) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:B modality:OPEN visibility:public superTypes:[<root>.A]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.B
|
||||
CONSTRUCTOR visibility:public <> (b:kotlin.Int) returnType:<root>.B [primary]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:b index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.A'
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=INITIALIZE_FIELD
|
||||
receiver: GET_VAR '<this>: <root>.B declared in <root>.B' type=<root>.B origin=null
|
||||
value: GET_VAR 'b: kotlin.Int declared in <root>.B.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b> visibility:public modality:FINAL <> ($this:<root>.B) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:b visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b> (): kotlin.Int declared in <root>.B'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.B declared in <root>.B.<get-b>' type=<root>.B origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:private [final]
|
||||
FUN name:getIntNum visibility:public modality:OPEN <> ($this:<root>.B) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
overridden:
|
||||
public abstract fun getIntNum (): kotlin.Int declared in <root>.A
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun getIntNum (): kotlin.Int declared in <root>.B'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=GET_PROPERTY
|
||||
receiver: GET_VAR '<this>: <root>.B declared in <root>.B.getIntNum' type=<root>.B origin=null
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.A
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.A
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.A
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:C modality:FINAL visibility:public superTypes:[<root>.B]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C
|
||||
CONSTRUCTOR visibility:public <> (c:kotlin.Int) returnType:<root>.C [primary]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:c index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (b: kotlin.Int) [primary] declared in <root>.B'
|
||||
b: CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=PLUS
|
||||
arg0: GET_VAR 'c: kotlin.Int declared in <root>.C.<init>' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=1
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=INITIALIZE_FIELD
|
||||
receiver: GET_VAR '<this>: <root>.C declared in <root>.C' type=<root>.C origin=null
|
||||
value: GET_VAR 'c: kotlin.Int declared in <root>.C.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c> visibility:public modality:FINAL <> ($this:<root>.C) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.C
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c> (): kotlin.Int declared in <root>.C'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.C declared in <root>.C.<get-c>' type=<root>.C origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]
|
||||
FUN name:getIntNum visibility:public modality:OPEN <> ($this:<root>.C) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
overridden:
|
||||
public open fun getIntNum (): kotlin.Int declared in <root>.B
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.C
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun getIntNum (): kotlin.Int declared in <root>.C'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=GET_PROPERTY
|
||||
receiver: GET_VAR '<this>: <root>.C declared in <root>.C.getIntNum' type=<root>.C origin=null
|
||||
FUN FAKE_OVERRIDE name:<get-b> visibility:public modality:FINAL <> ($this:<root>.B) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:b visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-b> (): kotlin.Int declared in <root>.B
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.B
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.B
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.B
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN name:getAClassImplementation visibility:public modality:FINAL <> (num:kotlin.Int) returnType:<root>.A
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:num index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun getAClassImplementation (num: kotlin.Int): <root>.A declared in <root>'
|
||||
CONSTRUCTOR_CALL 'public constructor <init> (b: kotlin.Int) [primary] declared in <root>.B' type=<root>.B origin=null
|
||||
b: GET_VAR 'num: kotlin.Int declared in <root>.getAClassImplementation' type=kotlin.Int origin=null
|
||||
FUN name:getBClassImplementation visibility:public modality:FINAL <> (num:kotlin.Int) returnType:<root>.B
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:num index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun getBClassImplementation (num: kotlin.Int): <root>.B declared in <root>'
|
||||
CONSTRUCTOR_CALL 'public constructor <init> (b: kotlin.Int) [primary] declared in <root>.B' type=<root>.B origin=null
|
||||
b: GET_VAR 'num: kotlin.Int declared in <root>.getBClassImplementation' type=kotlin.Int origin=null
|
||||
FUN name:getClassCAsA visibility:public modality:FINAL <> (num:kotlin.Int) returnType:<root>.A
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:num index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun getClassCAsA (num: kotlin.Int): <root>.A declared in <root>'
|
||||
CONSTRUCTOR_CALL 'public constructor <init> (c: kotlin.Int) [primary] declared in <root>.C' type=<root>.C origin=null
|
||||
c: GET_VAR 'num: kotlin.Int declared in <root>.getClassCAsA' type=kotlin.Int origin=null
|
||||
FUN name:getClassCAsB visibility:public modality:FINAL <> (num:kotlin.Int) returnType:<root>.B
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:num index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun getClassCAsB (num: kotlin.Int): <root>.B declared in <root>'
|
||||
CONSTRUCTOR_CALL 'public constructor <init> (c: kotlin.Int) [primary] declared in <root>.C' type=<root>.C origin=null
|
||||
c: GET_VAR 'num: kotlin.Int declared in <root>.getClassCAsB' type=kotlin.Int origin=null
|
||||
FUN name:getClassCAsC visibility:public modality:FINAL <> (num:kotlin.Int) returnType:<root>.C
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:num index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun getClassCAsC (num: kotlin.Int): <root>.C declared in <root>'
|
||||
CONSTRUCTOR_CALL 'public constructor <init> (c: kotlin.Int) [primary] declared in <root>.C' type=<root>.C origin=null
|
||||
c: GET_VAR 'num: kotlin.Int declared in <root>.getClassCAsC' type=kotlin.Int origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-num1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:num1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-num1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:num1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:num1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=1
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-num2> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:num2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-num2> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:num2 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:num2 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=2
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-num3> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:num3 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-num3> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:num3 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:num3 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=3
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-num4> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:num4 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-num4> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:num4 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:num4 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=4
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-num5> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:num5 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-num5> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:num5 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:num5 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=5
|
||||
45
compiler/testData/ir/interpreter/abstract2.kt
vendored
Normal file
45
compiler/testData/ir/interpreter/abstract2.kt
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
abstract class A @CompileTimeCalculation constructor() {
|
||||
@CompileTimeCalculation
|
||||
abstract fun getIntNum(): Int
|
||||
|
||||
@CompileTimeCalculation
|
||||
abstract fun getIntNumInverse(): Int
|
||||
}
|
||||
|
||||
abstract class B @CompileTimeCalculation constructor(@CompileTimeCalculation val b: Int) : A() {
|
||||
@CompileTimeCalculation
|
||||
override fun getIntNum(): Int {
|
||||
return b
|
||||
}
|
||||
}
|
||||
|
||||
class C @CompileTimeCalculation constructor(@CompileTimeCalculation val c: Int) : B(c + 1) {
|
||||
@CompileTimeCalculation
|
||||
override fun getIntNum(): Int {
|
||||
return c
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
override fun getIntNumInverse(): Int {
|
||||
return -c
|
||||
}
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun getClassCAsA(num: Int): A {
|
||||
return C(num)
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun getClassCAsB(num: Int): B {
|
||||
return C(num)
|
||||
}
|
||||
|
||||
// all methods call from C
|
||||
const val num1 = getClassCAsA(1).getIntNum()
|
||||
const val num2 = getClassCAsB(2).getIntNum()
|
||||
|
||||
const val num3 = getClassCAsA(3).getIntNumInverse()
|
||||
const val num4 = getClassCAsB(4).getIntNumInverse()
|
||||
190
compiler/testData/ir/interpreter/abstract2.txt
vendored
Normal file
190
compiler/testData/ir/interpreter/abstract2.txt
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
FILE fqName:<root> fileName:/abstract2.kt
|
||||
CLASS CLASS name:A modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.A [primary]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
FUN name:getIntNum visibility:public modality:ABSTRACT <> ($this:<root>.A) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A
|
||||
FUN name:getIntNumInverse visibility:public modality:ABSTRACT <> ($this:<root>.A) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:B modality:ABSTRACT visibility:public superTypes:[<root>.A]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.B
|
||||
CONSTRUCTOR visibility:public <> (b:kotlin.Int) returnType:<root>.B [primary]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:b index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.A'
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=INITIALIZE_FIELD
|
||||
receiver: GET_VAR '<this>: <root>.B declared in <root>.B' type=<root>.B origin=null
|
||||
value: GET_VAR 'b: kotlin.Int declared in <root>.B.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b> visibility:public modality:FINAL <> ($this:<root>.B) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:b visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b> (): kotlin.Int declared in <root>.B'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.B declared in <root>.B.<get-b>' type=<root>.B origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:private [final]
|
||||
FUN name:getIntNum visibility:public modality:OPEN <> ($this:<root>.B) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
overridden:
|
||||
public abstract fun getIntNum (): kotlin.Int declared in <root>.A
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun getIntNum (): kotlin.Int declared in <root>.B'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=GET_PROPERTY
|
||||
receiver: GET_VAR '<this>: <root>.B declared in <root>.B.getIntNum' type=<root>.B origin=null
|
||||
FUN FAKE_OVERRIDE name:getIntNumInverse visibility:public modality:ABSTRACT <> ($this:<root>.A) returnType:kotlin.Int [fake_override]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
overridden:
|
||||
public abstract fun getIntNumInverse (): kotlin.Int declared in <root>.A
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.A
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.A
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.A
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:C modality:FINAL visibility:public superTypes:[<root>.B]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C
|
||||
CONSTRUCTOR visibility:public <> (c:kotlin.Int) returnType:<root>.C [primary]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:c index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (b: kotlin.Int) [primary] declared in <root>.B'
|
||||
b: CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=PLUS
|
||||
arg0: GET_VAR 'c: kotlin.Int declared in <root>.C.<init>' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=1
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=INITIALIZE_FIELD
|
||||
receiver: GET_VAR '<this>: <root>.C declared in <root>.C' type=<root>.C origin=null
|
||||
value: GET_VAR 'c: kotlin.Int declared in <root>.C.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c> visibility:public modality:FINAL <> ($this:<root>.C) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.C
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c> (): kotlin.Int declared in <root>.C'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.C declared in <root>.C.<get-c>' type=<root>.C origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]
|
||||
FUN name:getIntNum visibility:public modality:OPEN <> ($this:<root>.C) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
overridden:
|
||||
public open fun getIntNum (): kotlin.Int declared in <root>.B
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.C
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun getIntNum (): kotlin.Int declared in <root>.C'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=GET_PROPERTY
|
||||
receiver: GET_VAR '<this>: <root>.C declared in <root>.C.getIntNum' type=<root>.C origin=null
|
||||
FUN name:getIntNumInverse visibility:public modality:OPEN <> ($this:<root>.C) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
overridden:
|
||||
public abstract fun getIntNumInverse (): kotlin.Int [fake_override] declared in <root>.B
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.C
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun getIntNumInverse (): kotlin.Int declared in <root>.C'
|
||||
CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsUnaryMinus (arg0: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=UMINUS
|
||||
arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=GET_PROPERTY
|
||||
receiver: GET_VAR '<this>: <root>.C declared in <root>.C.getIntNumInverse' type=<root>.C origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
FUN FAKE_OVERRIDE name:<get-b> visibility:public modality:FINAL <> ($this:<root>.B) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:b visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-b> (): kotlin.Int declared in <root>.B
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.B
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.B
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.B
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN name:getClassCAsA visibility:public modality:FINAL <> (num:kotlin.Int) returnType:<root>.A
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:num index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun getClassCAsA (num: kotlin.Int): <root>.A declared in <root>'
|
||||
CONSTRUCTOR_CALL 'public constructor <init> (c: kotlin.Int) [primary] declared in <root>.C' type=<root>.C origin=null
|
||||
c: GET_VAR 'num: kotlin.Int declared in <root>.getClassCAsA' type=kotlin.Int origin=null
|
||||
FUN name:getClassCAsB visibility:public modality:FINAL <> (num:kotlin.Int) returnType:<root>.B
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:num index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun getClassCAsB (num: kotlin.Int): <root>.B declared in <root>'
|
||||
CONSTRUCTOR_CALL 'public constructor <init> (c: kotlin.Int) [primary] declared in <root>.C' type=<root>.C origin=null
|
||||
c: GET_VAR 'num: kotlin.Int declared in <root>.getClassCAsB' type=kotlin.Int origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-num1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:num1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-num1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:num1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:num1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=1
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-num2> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:num2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-num2> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:num2 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:num2 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=2
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-num3> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:num3 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-num3> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:num3 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:num3 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=-3
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-num4> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:num4 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-num4> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:num4 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:num4 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=-4
|
||||
51
compiler/testData/ir/interpreter/abstract3.kt
vendored
Normal file
51
compiler/testData/ir/interpreter/abstract3.kt
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
abstract class A @CompileTimeCalculation constructor() {
|
||||
@CompileTimeCalculation
|
||||
abstract fun getInt(): Int
|
||||
}
|
||||
|
||||
open class B @CompileTimeCalculation constructor(@CompileTimeCalculation val b: Int) : A() {
|
||||
@CompileTimeCalculation
|
||||
override fun getInt(): Int {
|
||||
return b
|
||||
}
|
||||
}
|
||||
|
||||
abstract class C @CompileTimeCalculation constructor(@CompileTimeCalculation val c: Int) : B(c + 1) {
|
||||
@CompileTimeCalculation
|
||||
abstract fun getString(): String
|
||||
}
|
||||
|
||||
class D @CompileTimeCalculation constructor(@CompileTimeCalculation val d: Int) : C(d + 1) {
|
||||
@CompileTimeCalculation
|
||||
override fun getString(): String {
|
||||
return d.toString()
|
||||
}
|
||||
}
|
||||
@CompileTimeCalculation
|
||||
fun getClassDAsA(num: Int): A {
|
||||
return D(num)
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun getClassDAsB(num: Int): B {
|
||||
return D(num)
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun getClassDAsC(num: Int): C {
|
||||
return D(num)
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun getClassDAsD(num: Int): D {
|
||||
return D(num)
|
||||
}
|
||||
|
||||
const val numA1 = getClassDAsA(1).getInt()
|
||||
const val numB1 = getClassDAsB(1).getInt()
|
||||
const val numC1 = getClassDAsC(1).getInt()
|
||||
const val numC2 = getClassDAsC(1).getString()
|
||||
const val numD1 = getClassDAsD(1).getInt()
|
||||
const val numD2 = getClassDAsD(1).getString()
|
||||
263
compiler/testData/ir/interpreter/abstract3.txt
vendored
Normal file
263
compiler/testData/ir/interpreter/abstract3.txt
vendored
Normal file
@@ -0,0 +1,263 @@
|
||||
FILE fqName:<root> fileName:/abstract3.kt
|
||||
CLASS CLASS name:A modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.A [primary]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
FUN name:getInt visibility:public modality:ABSTRACT <> ($this:<root>.A) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:B modality:OPEN visibility:public superTypes:[<root>.A]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.B
|
||||
CONSTRUCTOR visibility:public <> (b:kotlin.Int) returnType:<root>.B [primary]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:b index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.A'
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=INITIALIZE_FIELD
|
||||
receiver: GET_VAR '<this>: <root>.B declared in <root>.B' type=<root>.B origin=null
|
||||
value: GET_VAR 'b: kotlin.Int declared in <root>.B.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b> visibility:public modality:FINAL <> ($this:<root>.B) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:b visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b> (): kotlin.Int declared in <root>.B'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.B declared in <root>.B.<get-b>' type=<root>.B origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:private [final]
|
||||
FUN name:getInt visibility:public modality:OPEN <> ($this:<root>.B) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
overridden:
|
||||
public abstract fun getInt (): kotlin.Int declared in <root>.A
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun getInt (): kotlin.Int declared in <root>.B'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=GET_PROPERTY
|
||||
receiver: GET_VAR '<this>: <root>.B declared in <root>.B.getInt' type=<root>.B origin=null
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.A
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.A
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.A
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:C modality:ABSTRACT visibility:public superTypes:[<root>.B]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C
|
||||
CONSTRUCTOR visibility:public <> (c:kotlin.Int) returnType:<root>.C [primary]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:c index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (b: kotlin.Int) [primary] declared in <root>.B'
|
||||
b: CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=PLUS
|
||||
arg0: GET_VAR 'c: kotlin.Int declared in <root>.C.<init>' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=1
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=INITIALIZE_FIELD
|
||||
receiver: GET_VAR '<this>: <root>.C declared in <root>.C' type=<root>.C origin=null
|
||||
value: GET_VAR 'c: kotlin.Int declared in <root>.C.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c> visibility:public modality:FINAL <> ($this:<root>.C) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.C
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c> (): kotlin.Int declared in <root>.C'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.C declared in <root>.C.<get-c>' type=<root>.C origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]
|
||||
FUN name:getString visibility:public modality:ABSTRACT <> ($this:<root>.C) returnType:kotlin.String
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.C
|
||||
FUN FAKE_OVERRIDE name:<get-b> visibility:public modality:FINAL <> ($this:<root>.B) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:b visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-b> (): kotlin.Int declared in <root>.B
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
FUN FAKE_OVERRIDE name:getInt visibility:public modality:OPEN <> ($this:<root>.B) returnType:kotlin.Int [fake_override]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
overridden:
|
||||
public open fun getInt (): kotlin.Int declared in <root>.B
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.B
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.B
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.B
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:D modality:FINAL visibility:public superTypes:[<root>.C]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.D
|
||||
CONSTRUCTOR visibility:public <> (d:kotlin.Int) returnType:<root>.D [primary]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:d index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (c: kotlin.Int) [primary] declared in <root>.C'
|
||||
c: CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=PLUS
|
||||
arg0: GET_VAR 'd: kotlin.Int declared in <root>.D.<init>' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=1
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:d type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=INITIALIZE_FIELD
|
||||
receiver: GET_VAR '<this>: <root>.D declared in <root>.D' type=<root>.D origin=null
|
||||
value: GET_VAR 'd: kotlin.Int declared in <root>.D.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-d> visibility:public modality:FINAL <> ($this:<root>.D) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:d visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.D
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-d> (): kotlin.Int declared in <root>.D'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:d type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.D declared in <root>.D.<get-d>' type=<root>.D origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:d type:kotlin.Int visibility:private [final]
|
||||
FUN name:getString visibility:public modality:OPEN <> ($this:<root>.D) returnType:kotlin.String
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
overridden:
|
||||
public abstract fun getString (): kotlin.String declared in <root>.C
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.D
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun getString (): kotlin.String declared in <root>.D'
|
||||
CALL 'public open fun toString (): kotlin.String declared in kotlin.Int' type=kotlin.String origin=null
|
||||
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:d type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=GET_PROPERTY
|
||||
receiver: GET_VAR '<this>: <root>.D declared in <root>.D.getString' type=<root>.D origin=null
|
||||
FUN FAKE_OVERRIDE name:<get-b> visibility:public modality:FINAL <> ($this:<root>.B) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:b visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-b> (): kotlin.Int [fake_override] declared in <root>.C
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
FUN FAKE_OVERRIDE name:<get-c> visibility:public modality:FINAL <> ($this:<root>.C) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:c visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-c> (): kotlin.Int declared in <root>.C
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.C
|
||||
FUN FAKE_OVERRIDE name:getInt visibility:public modality:OPEN <> ($this:<root>.B) returnType:kotlin.Int [fake_override]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
overridden:
|
||||
public open fun getInt (): kotlin.Int [fake_override] declared in <root>.C
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.C
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.C
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.C
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN name:getClassDAsA visibility:public modality:FINAL <> (num:kotlin.Int) returnType:<root>.A
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:num index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun getClassDAsA (num: kotlin.Int): <root>.A declared in <root>'
|
||||
CONSTRUCTOR_CALL 'public constructor <init> (d: kotlin.Int) [primary] declared in <root>.D' type=<root>.D origin=null
|
||||
d: GET_VAR 'num: kotlin.Int declared in <root>.getClassDAsA' type=kotlin.Int origin=null
|
||||
FUN name:getClassDAsB visibility:public modality:FINAL <> (num:kotlin.Int) returnType:<root>.B
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:num index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun getClassDAsB (num: kotlin.Int): <root>.B declared in <root>'
|
||||
CONSTRUCTOR_CALL 'public constructor <init> (d: kotlin.Int) [primary] declared in <root>.D' type=<root>.D origin=null
|
||||
d: GET_VAR 'num: kotlin.Int declared in <root>.getClassDAsB' type=kotlin.Int origin=null
|
||||
FUN name:getClassDAsC visibility:public modality:FINAL <> (num:kotlin.Int) returnType:<root>.C
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:num index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun getClassDAsC (num: kotlin.Int): <root>.C declared in <root>'
|
||||
CONSTRUCTOR_CALL 'public constructor <init> (d: kotlin.Int) [primary] declared in <root>.D' type=<root>.D origin=null
|
||||
d: GET_VAR 'num: kotlin.Int declared in <root>.getClassDAsC' type=kotlin.Int origin=null
|
||||
FUN name:getClassDAsD visibility:public modality:FINAL <> (num:kotlin.Int) returnType:<root>.D
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:num index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun getClassDAsD (num: kotlin.Int): <root>.D declared in <root>'
|
||||
CONSTRUCTOR_CALL 'public constructor <init> (d: kotlin.Int) [primary] declared in <root>.D' type=<root>.D origin=null
|
||||
d: GET_VAR 'num: kotlin.Int declared in <root>.getClassDAsD' type=kotlin.Int origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-numA1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:numA1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-numA1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:numA1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:numA1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=3
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-numB1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:numB1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-numB1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:numB1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:numB1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=3
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-numC1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:numC1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-numC1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:numC1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:numC1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=3
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-numC2> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:numC2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-numC2> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:numC2 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:numC2 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="1"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-numD1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:numD1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-numD1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:numD1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:numD1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=3
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-numD2> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:numD2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-numD2> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:numD2 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:numD2 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="1"
|
||||
39
compiler/testData/ir/interpreter/abstract4.kt
vendored
Normal file
39
compiler/testData/ir/interpreter/abstract4.kt
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation
|
||||
abstract class BaseIterator(var baseStart: Int) {
|
||||
fun baseNext(): Int {
|
||||
baseStart += 1
|
||||
return base()
|
||||
}
|
||||
|
||||
abstract fun base(): Int
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
abstract class ComplexIterator(var complexStart: Int) : BaseIterator(complexStart) {
|
||||
fun complexNext() = abstractCall()
|
||||
|
||||
private fun abstractCall(): Int {
|
||||
complexStart *= 2
|
||||
return complex() + baseNext()
|
||||
}
|
||||
|
||||
abstract fun complex(): Int
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
class ImplementIterator constructor(val i: Int) : ComplexIterator(i) {
|
||||
override fun complex(): Int {
|
||||
return complexStart
|
||||
}
|
||||
|
||||
override fun base(): Int {
|
||||
return baseStart
|
||||
}
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun getIterator(i: Int): ComplexIterator = ImplementIterator(i)
|
||||
|
||||
const val next = getIterator(10).complexNext()
|
||||
241
compiler/testData/ir/interpreter/abstract4.txt
vendored
Normal file
241
compiler/testData/ir/interpreter/abstract4.txt
vendored
Normal file
@@ -0,0 +1,241 @@
|
||||
FILE fqName:<root> fileName:/abstract4.kt
|
||||
CLASS CLASS name:BaseIterator modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.BaseIterator
|
||||
CONSTRUCTOR visibility:public <> (baseStart:kotlin.Int) returnType:<root>.BaseIterator [primary]
|
||||
VALUE_PARAMETER name:baseStart index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:baseStart type:kotlin.Int visibility:private' type=kotlin.Unit origin=INITIALIZE_FIELD
|
||||
receiver: GET_VAR '<this>: <root>.BaseIterator declared in <root>.BaseIterator' type=<root>.BaseIterator origin=null
|
||||
value: GET_VAR 'baseStart: kotlin.Int declared in <root>.BaseIterator.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<set-baseStart> visibility:public modality:FINAL <> ($this:<root>.BaseIterator, <set-?>:kotlin.Int) returnType:kotlin.Unit
|
||||
correspondingProperty: PROPERTY name:baseStart visibility:public modality:FINAL [var]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.BaseIterator
|
||||
VALUE_PARAMETER name:<set-?> index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:baseStart type:kotlin.Int visibility:private' type=kotlin.Unit origin=null
|
||||
receiver: GET_VAR '<this>: <root>.BaseIterator declared in <root>.BaseIterator.<set-baseStart>' type=<root>.BaseIterator origin=null
|
||||
value: GET_VAR '<set-?>: kotlin.Int declared in <root>.BaseIterator.<set-baseStart>' type=kotlin.Int origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-baseStart> visibility:public modality:FINAL <> ($this:<root>.BaseIterator) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:baseStart visibility:public modality:FINAL [var]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.BaseIterator
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-baseStart> (): kotlin.Int declared in <root>.BaseIterator'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:baseStart type:kotlin.Int visibility:private' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.BaseIterator declared in <root>.BaseIterator.<get-baseStart>' type=<root>.BaseIterator origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:baseStart type:kotlin.Int visibility:private
|
||||
FUN name:baseNext visibility:public modality:FINAL <> ($this:<root>.BaseIterator) returnType:kotlin.Int
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.BaseIterator
|
||||
BLOCK_BODY
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp0_this type:<root>.BaseIterator [val]
|
||||
GET_VAR '<this>: <root>.BaseIterator declared in <root>.BaseIterator.baseNext' type=<root>.BaseIterator origin=null
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:baseStart type:kotlin.Int visibility:private' type=kotlin.Unit origin=PLUSEQ
|
||||
receiver: GET_VAR 'val tmp0_this: <root>.BaseIterator [val] declared in <root>.BaseIterator.baseNext' type=<root>.BaseIterator origin=null
|
||||
value: CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=PLUSEQ
|
||||
arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:baseStart type:kotlin.Int visibility:private' type=kotlin.Int origin=PLUSEQ
|
||||
receiver: GET_VAR 'val tmp0_this: <root>.BaseIterator [val] declared in <root>.BaseIterator.baseNext' type=<root>.BaseIterator origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=1
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
RETURN type=kotlin.Nothing from='public final fun baseNext (): kotlin.Int declared in <root>.BaseIterator'
|
||||
CALL 'public abstract fun base (): kotlin.Int declared in <root>.BaseIterator' type=kotlin.Int origin=null
|
||||
$this: GET_VAR '<this>: <root>.BaseIterator declared in <root>.BaseIterator.baseNext' type=<root>.BaseIterator origin=null
|
||||
FUN name:base visibility:public modality:ABSTRACT <> ($this:<root>.BaseIterator) returnType:kotlin.Int
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.BaseIterator
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:ComplexIterator modality:ABSTRACT visibility:public superTypes:[<root>.BaseIterator]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.ComplexIterator
|
||||
CONSTRUCTOR visibility:public <> (complexStart:kotlin.Int) returnType:<root>.ComplexIterator [primary]
|
||||
VALUE_PARAMETER name:complexStart index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (baseStart: kotlin.Int) [primary] declared in <root>.BaseIterator'
|
||||
baseStart: GET_VAR 'complexStart: kotlin.Int declared in <root>.ComplexIterator.<init>' type=kotlin.Int origin=null
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:complexStart type:kotlin.Int visibility:private' type=kotlin.Unit origin=INITIALIZE_FIELD
|
||||
receiver: GET_VAR '<this>: <root>.ComplexIterator declared in <root>.ComplexIterator' type=<root>.ComplexIterator origin=null
|
||||
value: GET_VAR 'complexStart: kotlin.Int declared in <root>.ComplexIterator.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<set-complexStart> visibility:public modality:FINAL <> ($this:<root>.ComplexIterator, <set-?>:kotlin.Int) returnType:kotlin.Unit
|
||||
correspondingProperty: PROPERTY name:complexStart visibility:public modality:FINAL [var]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.ComplexIterator
|
||||
VALUE_PARAMETER name:<set-?> index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:complexStart type:kotlin.Int visibility:private' type=kotlin.Unit origin=null
|
||||
receiver: GET_VAR '<this>: <root>.ComplexIterator declared in <root>.ComplexIterator.<set-complexStart>' type=<root>.ComplexIterator origin=null
|
||||
value: GET_VAR '<set-?>: kotlin.Int declared in <root>.ComplexIterator.<set-complexStart>' type=kotlin.Int origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-complexStart> visibility:public modality:FINAL <> ($this:<root>.ComplexIterator) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:complexStart visibility:public modality:FINAL [var]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.ComplexIterator
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-complexStart> (): kotlin.Int declared in <root>.ComplexIterator'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:complexStart type:kotlin.Int visibility:private' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.ComplexIterator declared in <root>.ComplexIterator.<get-complexStart>' type=<root>.ComplexIterator origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:complexStart type:kotlin.Int visibility:private
|
||||
FUN name:complexNext visibility:public modality:FINAL <> ($this:<root>.ComplexIterator) returnType:kotlin.Int
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.ComplexIterator
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun complexNext (): kotlin.Int declared in <root>.ComplexIterator'
|
||||
CALL 'private final fun abstractCall ($this: <root>.ComplexIterator): kotlin.Int declared in <root>.ComplexIterator' type=kotlin.Int origin=null
|
||||
$this: GET_VAR '<this>: <root>.ComplexIterator declared in <root>.ComplexIterator.complexNext' type=<root>.ComplexIterator origin=null
|
||||
FUN name:abstractCall visibility:private modality:FINAL <> ($this:<root>.ComplexIterator) returnType:kotlin.Int
|
||||
VALUE_PARAMETER STATIC_THIS_PARAMETER name:$this index:0 type:<root>.ComplexIterator
|
||||
BLOCK_BODY
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp0_this type:<root>.ComplexIterator [val]
|
||||
GET_VAR '$this: <root>.ComplexIterator declared in <root>.ComplexIterator.abstractCall' type=<root>.ComplexIterator origin=null
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:complexStart type:kotlin.Int visibility:private' type=kotlin.Unit origin=MULTEQ
|
||||
receiver: GET_VAR 'val tmp0_this: <root>.ComplexIterator [val] declared in <root>.ComplexIterator.abstractCall' type=<root>.ComplexIterator origin=null
|
||||
value: CALL 'internal final fun imul (a_local: kotlin.Int, b_local: kotlin.Int): kotlin.Int declared in kotlin.js' type=kotlin.Int origin=MULTEQ
|
||||
a_local: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:complexStart type:kotlin.Int visibility:private' type=kotlin.Int origin=MULTEQ
|
||||
receiver: GET_VAR 'val tmp0_this: <root>.ComplexIterator [val] declared in <root>.ComplexIterator.abstractCall' type=<root>.ComplexIterator origin=null
|
||||
b_local: CONST Int type=kotlin.Int value=2
|
||||
RETURN type=kotlin.Nothing from='private final fun abstractCall (): kotlin.Int declared in <root>.ComplexIterator'
|
||||
CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=PLUS
|
||||
arg0: CALL 'public abstract fun complex (): kotlin.Int declared in <root>.ComplexIterator' type=kotlin.Int origin=null
|
||||
$this: GET_VAR '$this: <root>.ComplexIterator declared in <root>.ComplexIterator.abstractCall' type=<root>.ComplexIterator origin=null
|
||||
arg1: CALL 'public final fun baseNext (): kotlin.Int [fake_override] declared in <root>.ComplexIterator' type=kotlin.Int origin=null
|
||||
$this: GET_VAR '$this: <root>.ComplexIterator declared in <root>.ComplexIterator.abstractCall' type=<root>.ComplexIterator origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
FUN name:complex visibility:public modality:ABSTRACT <> ($this:<root>.ComplexIterator) returnType:kotlin.Int
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.ComplexIterator
|
||||
FUN FAKE_OVERRIDE name:base visibility:public modality:ABSTRACT <> ($this:<root>.BaseIterator) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public abstract fun base (): kotlin.Int declared in <root>.BaseIterator
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.BaseIterator
|
||||
FUN FAKE_OVERRIDE name:baseNext visibility:public modality:FINAL <> ($this:<root>.BaseIterator) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public final fun baseNext (): kotlin.Int declared in <root>.BaseIterator
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.BaseIterator
|
||||
FUN FAKE_OVERRIDE name:<set-baseStart> visibility:public modality:FINAL <> ($this:<root>.BaseIterator, <set-?>:kotlin.Int) returnType:kotlin.Unit [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:baseStart visibility:public modality:FINAL [fake_override,var]
|
||||
overridden:
|
||||
public final fun <set-baseStart> (<set-?>: kotlin.Int): kotlin.Unit declared in <root>.BaseIterator
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.BaseIterator
|
||||
VALUE_PARAMETER name:<set-?> index:0 type:kotlin.Int
|
||||
FUN FAKE_OVERRIDE name:<get-baseStart> visibility:public modality:FINAL <> ($this:<root>.BaseIterator) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:baseStart visibility:public modality:FINAL [fake_override,var]
|
||||
overridden:
|
||||
public final fun <get-baseStart> (): kotlin.Int declared in <root>.BaseIterator
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.BaseIterator
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.BaseIterator
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.BaseIterator
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.BaseIterator
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:ImplementIterator modality:FINAL visibility:public superTypes:[<root>.ComplexIterator]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.ImplementIterator
|
||||
CONSTRUCTOR visibility:public <> (i:kotlin.Int) returnType:<root>.ImplementIterator [primary]
|
||||
VALUE_PARAMETER name:i index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (complexStart: kotlin.Int) [primary] declared in <root>.ComplexIterator'
|
||||
complexStart: GET_VAR 'i: kotlin.Int declared in <root>.ImplementIterator.<init>' type=kotlin.Int origin=null
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=INITIALIZE_FIELD
|
||||
receiver: GET_VAR '<this>: <root>.ImplementIterator declared in <root>.ImplementIterator' type=<root>.ImplementIterator origin=null
|
||||
value: GET_VAR 'i: kotlin.Int declared in <root>.ImplementIterator.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-i> visibility:public modality:FINAL <> ($this:<root>.ImplementIterator) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:i visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.ImplementIterator
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-i> (): kotlin.Int declared in <root>.ImplementIterator'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.ImplementIterator declared in <root>.ImplementIterator.<get-i>' type=<root>.ImplementIterator origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private [final]
|
||||
FUN name:complex visibility:public modality:OPEN <> ($this:<root>.ImplementIterator) returnType:kotlin.Int
|
||||
overridden:
|
||||
public abstract fun complex (): kotlin.Int declared in <root>.ComplexIterator
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.ImplementIterator
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun complex (): kotlin.Int declared in <root>.ImplementIterator'
|
||||
CALL 'public final fun <get-complexStart> (): kotlin.Int [fake_override] declared in <root>.ImplementIterator' type=kotlin.Int origin=GET_PROPERTY
|
||||
$this: GET_VAR '<this>: <root>.ImplementIterator declared in <root>.ImplementIterator.complex' type=<root>.ImplementIterator origin=null
|
||||
FUN name:base visibility:public modality:OPEN <> ($this:<root>.ImplementIterator) returnType:kotlin.Int
|
||||
overridden:
|
||||
public abstract fun base (): kotlin.Int [fake_override] declared in <root>.ComplexIterator
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.ImplementIterator
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun base (): kotlin.Int declared in <root>.ImplementIterator'
|
||||
CALL 'public final fun <get-baseStart> (): kotlin.Int [fake_override] declared in <root>.ImplementIterator' type=kotlin.Int origin=GET_PROPERTY
|
||||
$this: GET_VAR '<this>: <root>.ImplementIterator declared in <root>.ImplementIterator.base' type=<root>.ImplementIterator origin=null
|
||||
FUN FAKE_OVERRIDE name:baseNext visibility:public modality:FINAL <> ($this:<root>.BaseIterator) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public final fun baseNext (): kotlin.Int [fake_override] declared in <root>.ComplexIterator
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.BaseIterator
|
||||
FUN FAKE_OVERRIDE name:complexNext visibility:public modality:FINAL <> ($this:<root>.ComplexIterator) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public final fun complexNext (): kotlin.Int declared in <root>.ComplexIterator
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.ComplexIterator
|
||||
FUN FAKE_OVERRIDE name:<set-baseStart> visibility:public modality:FINAL <> ($this:<root>.BaseIterator, <set-?>:kotlin.Int) returnType:kotlin.Unit [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:baseStart visibility:public modality:FINAL [fake_override,var]
|
||||
overridden:
|
||||
public final fun <set-baseStart> (<set-?>: kotlin.Int): kotlin.Unit [fake_override] declared in <root>.ComplexIterator
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.BaseIterator
|
||||
VALUE_PARAMETER name:<set-?> index:0 type:kotlin.Int
|
||||
FUN FAKE_OVERRIDE name:<get-baseStart> visibility:public modality:FINAL <> ($this:<root>.BaseIterator) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:baseStart visibility:public modality:FINAL [fake_override,var]
|
||||
overridden:
|
||||
public final fun <get-baseStart> (): kotlin.Int [fake_override] declared in <root>.ComplexIterator
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.BaseIterator
|
||||
FUN FAKE_OVERRIDE name:<set-complexStart> visibility:public modality:FINAL <> ($this:<root>.ComplexIterator, <set-?>:kotlin.Int) returnType:kotlin.Unit [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:complexStart visibility:public modality:FINAL [fake_override,var]
|
||||
overridden:
|
||||
public final fun <set-complexStart> (<set-?>: kotlin.Int): kotlin.Unit declared in <root>.ComplexIterator
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.ComplexIterator
|
||||
VALUE_PARAMETER name:<set-?> index:0 type:kotlin.Int
|
||||
FUN FAKE_OVERRIDE name:<get-complexStart> visibility:public modality:FINAL <> ($this:<root>.ComplexIterator) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:complexStart visibility:public modality:FINAL [fake_override,var]
|
||||
overridden:
|
||||
public final fun <get-complexStart> (): kotlin.Int declared in <root>.ComplexIterator
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.ComplexIterator
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.ComplexIterator
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.ComplexIterator
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.ComplexIterator
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN name:getIterator visibility:public modality:FINAL <> (i:kotlin.Int) returnType:<root>.ComplexIterator
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:i index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun getIterator (i: kotlin.Int): <root>.ComplexIterator declared in <root>'
|
||||
CONSTRUCTOR_CALL 'public constructor <init> (i: kotlin.Int) [primary] declared in <root>.ImplementIterator' type=<root>.ImplementIterator origin=null
|
||||
i: GET_VAR 'i: kotlin.Int declared in <root>.getIterator' type=kotlin.Int origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-next> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:next visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-next> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:next type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:next type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=31
|
||||
21
compiler/testData/ir/interpreter/arrayConstructor.kt
vendored
Normal file
21
compiler/testData/ir/interpreter/arrayConstructor.kt
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
const val intArray1 = IntArray(42).size
|
||||
const val intArray2 = IntArray(42)[0]
|
||||
const val intArray3 = IntArray(10) { 42 }[0]
|
||||
const val intArray4 = IntArray(10) { it -> it }[7]
|
||||
|
||||
const val floatArray1 = FloatArray(42).size
|
||||
const val floatArray2 = FloatArray(42)[0]
|
||||
const val floatArray3 = FloatArray(10) { 42.5f }[0]
|
||||
const val floatArray4 = FloatArray(10) { it -> it.toFloat() }[7]
|
||||
|
||||
const val array = Array<Any?>(4) {
|
||||
when(it) {
|
||||
0 -> 1
|
||||
1 -> 2.0
|
||||
2 -> "3"
|
||||
3 -> null
|
||||
else -> throw IllegalArgumentException("$it is wrong")
|
||||
}
|
||||
}.let { it[0].toString() + " " + it[1] + " " + it[2] + " " + it[3] }
|
||||
73
compiler/testData/ir/interpreter/arrayConstructor.txt
vendored
Normal file
73
compiler/testData/ir/interpreter/arrayConstructor.txt
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
FILE fqName:<root> fileName:/arrayConstructor.kt
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-intArray1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:intArray1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-intArray1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:intArray1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:intArray1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=42
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-intArray2> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:intArray2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-intArray2> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:intArray2 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:intArray2 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=0
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-intArray3> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:intArray3 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-intArray3> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:intArray3 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:intArray3 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=42
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-intArray4> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:intArray4 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-intArray4> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:intArray4 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:intArray4 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=7
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-floatArray1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:floatArray1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-floatArray1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:floatArray1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:floatArray1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=42
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-floatArray2> visibility:public modality:FINAL <> () returnType:kotlin.Float
|
||||
correspondingProperty: PROPERTY name:floatArray2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-floatArray2> (): kotlin.Float declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:floatArray2 type:kotlin.Float visibility:public [final,static]' type=kotlin.Float origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:floatArray2 type:kotlin.Float visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Float type=kotlin.Float value=0.0
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-floatArray3> visibility:public modality:FINAL <> () returnType:kotlin.Float
|
||||
correspondingProperty: PROPERTY name:floatArray3 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-floatArray3> (): kotlin.Float declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:floatArray3 type:kotlin.Float visibility:public [final,static]' type=kotlin.Float origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:floatArray3 type:kotlin.Float visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Float type=kotlin.Float value=42.5
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-floatArray4> visibility:public modality:FINAL <> () returnType:kotlin.Float
|
||||
correspondingProperty: PROPERTY name:floatArray4 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-floatArray4> (): kotlin.Float declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:floatArray4 type:kotlin.Float visibility:public [final,static]' type=kotlin.Float origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:floatArray4 type:kotlin.Float visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Float type=kotlin.Float value=7.0
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-array> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:array visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-array> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:array type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:array type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="1 2.0 3 null"
|
||||
25
compiler/testData/ir/interpreter/arrayOf.kt
vendored
Normal file
25
compiler/testData/ir/interpreter/arrayOf.kt
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation
|
||||
class A(val value: Int)
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun changeAndReturnSum(intArray: IntArray, index: Int, newValue: Int): Int {
|
||||
intArray[index] = newValue
|
||||
var sum = 0
|
||||
for (i in intArray) sum += i
|
||||
return sum
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun changeAndReturnSumForObject(array: Array<A>, index: Int, newValue: A): Int {
|
||||
array[index] = newValue
|
||||
var sum = 0
|
||||
for (aObject in array) sum += aObject.value
|
||||
return sum
|
||||
}
|
||||
|
||||
const val a = arrayOf(1, 2, 3).size
|
||||
const val b = changeAndReturnSum(intArrayOf(1, 2, 3), 0, 10)
|
||||
const val c = emptyArray<Int>().size
|
||||
const val d = changeAndReturnSumForObject(arrayOf(A(1), A(2), A(3)), 0, A(10))
|
||||
156
compiler/testData/ir/interpreter/arrayOf.txt
vendored
Normal file
156
compiler/testData/ir/interpreter/arrayOf.txt
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
FILE fqName:<root> fileName:/arrayOf.kt
|
||||
CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A
|
||||
CONSTRUCTOR visibility:public <> (value:kotlin.Int) returnType:<root>.A [primary]
|
||||
VALUE_PARAMETER name:value index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:value type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=INITIALIZE_FIELD
|
||||
receiver: GET_VAR '<this>: <root>.A declared in <root>.A' type=<root>.A origin=null
|
||||
value: GET_VAR 'value: kotlin.Int declared in <root>.A.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-value> visibility:public modality:FINAL <> ($this:<root>.A) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:value visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-value> (): kotlin.Int declared in <root>.A'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:value type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-value>' type=<root>.A origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:value type:kotlin.Int visibility:private [final]
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN name:changeAndReturnSum visibility:public modality:FINAL <> (intArray:kotlin.IntArray, index:kotlin.Int, newValue:kotlin.Int) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:intArray index:0 type:kotlin.IntArray
|
||||
VALUE_PARAMETER name:index index:1 type:kotlin.Int
|
||||
VALUE_PARAMETER name:newValue index:2 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun jsArraySet (arg0: kotlin.Any?, arg1: kotlin.Any?, arg2: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Unit origin=EQ
|
||||
arg0: GET_VAR 'intArray: kotlin.IntArray declared in <root>.changeAndReturnSum' type=kotlin.IntArray origin=null
|
||||
arg1: GET_VAR 'index: kotlin.Int declared in <root>.changeAndReturnSum' type=kotlin.Int origin=null
|
||||
arg2: GET_VAR 'newValue: kotlin.Int declared in <root>.changeAndReturnSum' type=kotlin.Int origin=null
|
||||
VAR name:sum type:kotlin.Int [var]
|
||||
CONST Int type=kotlin.Int value=0
|
||||
VAR IR_TEMPORARY_VARIABLE name:indexedObject type:kotlin.IntArray [val]
|
||||
GET_VAR 'intArray: kotlin.IntArray declared in <root>.changeAndReturnSum' type=kotlin.IntArray origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp0_inductionVariable type:kotlin.Int [var]
|
||||
CONST Int type=kotlin.Int value=0
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp1_last type:kotlin.Int [val]
|
||||
CALL 'public final fun jsArrayLength (arg0: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=null
|
||||
arg0: GET_VAR 'val indexedObject: kotlin.IntArray [val] declared in <root>.changeAndReturnSum' type=kotlin.IntArray origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp2_step type:kotlin.Int [val]
|
||||
CONST Int type=kotlin.Int value=1
|
||||
WHILE label=null origin=FOR_LOOP_INNER_WHILE
|
||||
condition: CALL 'public final fun jsLt (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=null
|
||||
arg0: GET_VAR 'var tmp0_inductionVariable: kotlin.Int [var] declared in <root>.changeAndReturnSum' type=kotlin.Int origin=null
|
||||
arg1: GET_VAR 'val tmp1_last: kotlin.Int [val] declared in <root>.changeAndReturnSum' type=kotlin.Int origin=null
|
||||
body: COMPOSITE type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE
|
||||
VAR FOR_LOOP_VARIABLE name:i type:kotlin.Int [val]
|
||||
CALL 'public final fun jsArrayGet (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=null
|
||||
arg0: GET_VAR 'val indexedObject: kotlin.IntArray [val] declared in <root>.changeAndReturnSum' type=kotlin.IntArray origin=null
|
||||
arg1: GET_VAR 'var tmp0_inductionVariable: kotlin.Int [var] declared in <root>.changeAndReturnSum' type=kotlin.Int origin=null
|
||||
SET_VAR 'var tmp0_inductionVariable: kotlin.Int [var] declared in <root>.changeAndReturnSum' type=kotlin.Unit origin=EQ
|
||||
CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=null
|
||||
arg0: GET_VAR 'var tmp0_inductionVariable: kotlin.Int [var] declared in <root>.changeAndReturnSum' type=kotlin.Int origin=null
|
||||
arg1: GET_VAR 'val tmp2_step: kotlin.Int [val] declared in <root>.changeAndReturnSum' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
SET_VAR 'var sum: kotlin.Int [var] declared in <root>.changeAndReturnSum' type=kotlin.Unit origin=PLUSEQ
|
||||
CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=PLUSEQ
|
||||
arg0: GET_VAR 'var sum: kotlin.Int [var] declared in <root>.changeAndReturnSum' type=kotlin.Int origin=PLUSEQ
|
||||
arg1: GET_VAR 'val i: kotlin.Int [val] declared in <root>.changeAndReturnSum' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
RETURN type=kotlin.Nothing from='public final fun changeAndReturnSum (intArray: kotlin.IntArray, index: kotlin.Int, newValue: kotlin.Int): kotlin.Int declared in <root>'
|
||||
GET_VAR 'var sum: kotlin.Int [var] declared in <root>.changeAndReturnSum' type=kotlin.Int origin=null
|
||||
FUN name:changeAndReturnSumForObject visibility:public modality:FINAL <> (array:kotlin.Array<<root>.A>, index:kotlin.Int, newValue:<root>.A) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:array index:0 type:kotlin.Array<<root>.A>
|
||||
VALUE_PARAMETER name:index index:1 type:kotlin.Int
|
||||
VALUE_PARAMETER name:newValue index:2 type:<root>.A
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun jsArraySet (arg0: kotlin.Any?, arg1: kotlin.Any?, arg2: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Unit origin=EQ
|
||||
arg0: GET_VAR 'array: kotlin.Array<<root>.A> declared in <root>.changeAndReturnSumForObject' type=kotlin.Array<<root>.A> origin=null
|
||||
arg1: GET_VAR 'index: kotlin.Int declared in <root>.changeAndReturnSumForObject' type=kotlin.Int origin=null
|
||||
arg2: GET_VAR 'newValue: <root>.A declared in <root>.changeAndReturnSumForObject' type=<root>.A origin=null
|
||||
VAR name:sum type:kotlin.Int [var]
|
||||
CONST Int type=kotlin.Int value=0
|
||||
VAR IR_TEMPORARY_VARIABLE name:indexedObject type:kotlin.Array<<root>.A> [val]
|
||||
GET_VAR 'array: kotlin.Array<<root>.A> declared in <root>.changeAndReturnSumForObject' type=kotlin.Array<<root>.A> origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp0_inductionVariable type:kotlin.Int [var]
|
||||
CONST Int type=kotlin.Int value=0
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp1_last type:kotlin.Int [val]
|
||||
CALL 'public final fun jsArrayLength (arg0: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=null
|
||||
arg0: GET_VAR 'val indexedObject: kotlin.Array<<root>.A> [val] declared in <root>.changeAndReturnSumForObject' type=kotlin.Array<<root>.A> origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp2_step type:kotlin.Int [val]
|
||||
CONST Int type=kotlin.Int value=1
|
||||
WHILE label=null origin=FOR_LOOP_INNER_WHILE
|
||||
condition: CALL 'public final fun jsLt (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=null
|
||||
arg0: GET_VAR 'var tmp0_inductionVariable: kotlin.Int [var] declared in <root>.changeAndReturnSumForObject' type=kotlin.Int origin=null
|
||||
arg1: GET_VAR 'val tmp1_last: kotlin.Int [val] declared in <root>.changeAndReturnSumForObject' type=kotlin.Int origin=null
|
||||
body: COMPOSITE type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE
|
||||
VAR FOR_LOOP_VARIABLE name:aObject type:<root>.A [val]
|
||||
CALL 'public final fun jsArrayGet (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=T of kotlin.Array origin=null
|
||||
arg0: GET_VAR 'val indexedObject: kotlin.Array<<root>.A> [val] declared in <root>.changeAndReturnSumForObject' type=kotlin.Array<<root>.A> origin=null
|
||||
arg1: GET_VAR 'var tmp0_inductionVariable: kotlin.Int [var] declared in <root>.changeAndReturnSumForObject' type=kotlin.Int origin=null
|
||||
SET_VAR 'var tmp0_inductionVariable: kotlin.Int [var] declared in <root>.changeAndReturnSumForObject' type=kotlin.Unit origin=EQ
|
||||
CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=null
|
||||
arg0: GET_VAR 'var tmp0_inductionVariable: kotlin.Int [var] declared in <root>.changeAndReturnSumForObject' type=kotlin.Int origin=null
|
||||
arg1: GET_VAR 'val tmp2_step: kotlin.Int [val] declared in <root>.changeAndReturnSumForObject' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
SET_VAR 'var sum: kotlin.Int [var] declared in <root>.changeAndReturnSumForObject' type=kotlin.Unit origin=PLUSEQ
|
||||
CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=PLUSEQ
|
||||
arg0: GET_VAR 'var sum: kotlin.Int [var] declared in <root>.changeAndReturnSumForObject' type=kotlin.Int origin=PLUSEQ
|
||||
arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:value type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=GET_PROPERTY
|
||||
receiver: GET_VAR 'val aObject: <root>.A [val] declared in <root>.changeAndReturnSumForObject' type=<root>.A origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
RETURN type=kotlin.Nothing from='public final fun changeAndReturnSumForObject (array: kotlin.Array<<root>.A>, index: kotlin.Int, newValue: <root>.A): kotlin.Int declared in <root>'
|
||||
GET_VAR 'var sum: kotlin.Int [var] declared in <root>.changeAndReturnSumForObject' type=kotlin.Int origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=3
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:b visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=15
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=0
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-d> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:d visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-d> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:d type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:d type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=15
|
||||
67
compiler/testData/ir/interpreter/branches.kt
vendored
Normal file
67
compiler/testData/ir/interpreter/branches.kt
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation fun ifGreaterOrEqualToZero(a: Int): Boolean {
|
||||
return if (a >= 0) {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
@CompileTimeCalculation fun whenGreaterOrEqualToZero(a: Int): Boolean {
|
||||
return when {
|
||||
a >= 0 -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
@CompileTimeCalculation fun whenMultiBranch(a: Int): Int {
|
||||
return when (a) {
|
||||
1 -> -1
|
||||
2 -> -2
|
||||
3 -> -3
|
||||
4 -> -4
|
||||
else -> 0
|
||||
}
|
||||
}
|
||||
|
||||
class A @CompileTimeCalculation constructor(@CompileTimeCalculation var a: Int)
|
||||
|
||||
@CompileTimeCalculation fun whenWithoutReturn(aObj: A): Int {
|
||||
when (aObj.a) {
|
||||
1 -> aObj.a = -1
|
||||
2 -> aObj.a = -2
|
||||
3 -> aObj.a = -3
|
||||
4 -> aObj.a = -4
|
||||
else -> aObj.a = 0
|
||||
}
|
||||
|
||||
return aObj.a
|
||||
}
|
||||
|
||||
@CompileTimeCalculation fun whenWithoutElse(aObj: A): Int {
|
||||
when (aObj.a) {
|
||||
1 -> aObj.a = -1
|
||||
2 -> aObj.a = -2
|
||||
3 -> aObj.a = -3
|
||||
4 -> aObj.a = -4
|
||||
}
|
||||
|
||||
return aObj.a
|
||||
}
|
||||
|
||||
const val a = ifGreaterOrEqualToZero(10)
|
||||
const val b = whenGreaterOrEqualToZero(-10)
|
||||
const val constIf = if (a == true) "True" else "False"
|
||||
|
||||
const val multi1 = whenMultiBranch(2)
|
||||
const val multi2 = whenMultiBranch(4)
|
||||
const val multi3 = whenMultiBranch(10)
|
||||
|
||||
const val c1 = whenWithoutReturn(A(1))
|
||||
const val c2 = whenWithoutReturn(A(3))
|
||||
const val c3 = whenWithoutReturn(A(10))
|
||||
|
||||
const val d1 = whenWithoutElse(A(1))
|
||||
const val d2 = whenWithoutElse(A(4))
|
||||
const val d3 = whenWithoutElse(A(10))
|
||||
290
compiler/testData/ir/interpreter/branches.txt
vendored
Normal file
290
compiler/testData/ir/interpreter/branches.txt
vendored
Normal file
@@ -0,0 +1,290 @@
|
||||
FILE fqName:<root> fileName:/branches.kt
|
||||
FUN name:ifGreaterOrEqualToZero visibility:public modality:FINAL <> (a:kotlin.Int) returnType:kotlin.Boolean
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
VAR SYNTHESIZED_DECLARATION name:tmp type:kotlin.Boolean [var]
|
||||
WHEN type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsGtEq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GTEQ
|
||||
arg0: GET_VAR 'a: kotlin.Int declared in <root>.ifGreaterOrEqualToZero' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
SET_VAR 'var tmp: kotlin.Boolean [var] declared in <root>.ifGreaterOrEqualToZero' type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
SET_VAR 'var tmp: kotlin.Boolean [var] declared in <root>.ifGreaterOrEqualToZero' type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
CONST Boolean type=kotlin.Boolean value=false
|
||||
RETURN type=kotlin.Nothing from='public final fun ifGreaterOrEqualToZero (a: kotlin.Int): kotlin.Boolean declared in <root>'
|
||||
GET_VAR 'var tmp: kotlin.Boolean [var] declared in <root>.ifGreaterOrEqualToZero' type=kotlin.Boolean origin=SYNTHESIZED_STATEMENT
|
||||
FUN name:whenGreaterOrEqualToZero visibility:public modality:FINAL <> (a:kotlin.Int) returnType:kotlin.Boolean
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun whenGreaterOrEqualToZero (a: kotlin.Int): kotlin.Boolean declared in <root>'
|
||||
WHEN type=kotlin.Boolean origin=WHEN
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsGtEq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GTEQ
|
||||
arg0: GET_VAR 'a: kotlin.Int declared in <root>.whenGreaterOrEqualToZero' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
then: CONST Boolean type=kotlin.Boolean value=true
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CONST Boolean type=kotlin.Boolean value=false
|
||||
FUN name:whenMultiBranch visibility:public modality:FINAL <> (a:kotlin.Int) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp0_subject type:kotlin.Int [val]
|
||||
GET_VAR 'a: kotlin.Int declared in <root>.whenMultiBranch' type=kotlin.Int origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun whenMultiBranch (a: kotlin.Int): kotlin.Int declared in <root>'
|
||||
WHEN type=kotlin.Int origin=WHEN
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp0_subject: kotlin.Int [val] declared in <root>.whenMultiBranch' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=1
|
||||
then: CONST Int type=kotlin.Int value=-1
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp0_subject: kotlin.Int [val] declared in <root>.whenMultiBranch' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=2
|
||||
then: CONST Int type=kotlin.Int value=-2
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp0_subject: kotlin.Int [val] declared in <root>.whenMultiBranch' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=3
|
||||
then: CONST Int type=kotlin.Int value=-3
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp0_subject: kotlin.Int [val] declared in <root>.whenMultiBranch' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=4
|
||||
then: CONST Int type=kotlin.Int value=-4
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CONST Int type=kotlin.Int value=0
|
||||
CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A
|
||||
CONSTRUCTOR visibility:public <> (a:kotlin.Int) returnType:<root>.A [primary]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Unit origin=INITIALIZE_FIELD
|
||||
receiver: GET_VAR '<this>: <root>.A declared in <root>.A' type=<root>.A origin=null
|
||||
value: GET_VAR 'a: kotlin.Int declared in <root>.A.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<set-a> visibility:public modality:FINAL <> ($this:<root>.A, <set-?>:kotlin.Int) returnType:kotlin.Unit
|
||||
correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [var]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A
|
||||
VALUE_PARAMETER name:<set-?> index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Unit origin=null
|
||||
receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<set-a>' type=<root>.A origin=null
|
||||
value: GET_VAR '<set-?>: kotlin.Int declared in <root>.A.<set-a>' type=kotlin.Int origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a> visibility:public modality:FINAL <> ($this:<root>.A) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [var]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a> (): kotlin.Int declared in <root>.A'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-a>' type=<root>.A origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN name:whenWithoutReturn visibility:public modality:FINAL <> (aObj:<root>.A) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:aObj index:0 type:<root>.A
|
||||
BLOCK_BODY
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp0_subject type:kotlin.Int [val]
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Int origin=GET_PROPERTY
|
||||
receiver: GET_VAR 'aObj: <root>.A declared in <root>.whenWithoutReturn' type=<root>.A origin=null
|
||||
WHEN type=kotlin.Unit origin=WHEN
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp0_subject: kotlin.Int [val] declared in <root>.whenWithoutReturn' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=1
|
||||
then: SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Unit origin=EQ
|
||||
receiver: GET_VAR 'aObj: <root>.A declared in <root>.whenWithoutReturn' type=<root>.A origin=null
|
||||
value: CONST Int type=kotlin.Int value=-1
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp0_subject: kotlin.Int [val] declared in <root>.whenWithoutReturn' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=2
|
||||
then: SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Unit origin=EQ
|
||||
receiver: GET_VAR 'aObj: <root>.A declared in <root>.whenWithoutReturn' type=<root>.A origin=null
|
||||
value: CONST Int type=kotlin.Int value=-2
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp0_subject: kotlin.Int [val] declared in <root>.whenWithoutReturn' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=3
|
||||
then: SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Unit origin=EQ
|
||||
receiver: GET_VAR 'aObj: <root>.A declared in <root>.whenWithoutReturn' type=<root>.A origin=null
|
||||
value: CONST Int type=kotlin.Int value=-3
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp0_subject: kotlin.Int [val] declared in <root>.whenWithoutReturn' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=4
|
||||
then: SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Unit origin=EQ
|
||||
receiver: GET_VAR 'aObj: <root>.A declared in <root>.whenWithoutReturn' type=<root>.A origin=null
|
||||
value: CONST Int type=kotlin.Int value=-4
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Unit origin=EQ
|
||||
receiver: GET_VAR 'aObj: <root>.A declared in <root>.whenWithoutReturn' type=<root>.A origin=null
|
||||
value: CONST Int type=kotlin.Int value=0
|
||||
RETURN type=kotlin.Nothing from='public final fun whenWithoutReturn (aObj: <root>.A): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Int origin=GET_PROPERTY
|
||||
receiver: GET_VAR 'aObj: <root>.A declared in <root>.whenWithoutReturn' type=<root>.A origin=null
|
||||
FUN name:whenWithoutElse visibility:public modality:FINAL <> (aObj:<root>.A) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:aObj index:0 type:<root>.A
|
||||
BLOCK_BODY
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp0_subject type:kotlin.Int [val]
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Int origin=GET_PROPERTY
|
||||
receiver: GET_VAR 'aObj: <root>.A declared in <root>.whenWithoutElse' type=<root>.A origin=null
|
||||
WHEN type=kotlin.Unit origin=WHEN
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp0_subject: kotlin.Int [val] declared in <root>.whenWithoutElse' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=1
|
||||
then: SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Unit origin=EQ
|
||||
receiver: GET_VAR 'aObj: <root>.A declared in <root>.whenWithoutElse' type=<root>.A origin=null
|
||||
value: CONST Int type=kotlin.Int value=-1
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp0_subject: kotlin.Int [val] declared in <root>.whenWithoutElse' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=2
|
||||
then: SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Unit origin=EQ
|
||||
receiver: GET_VAR 'aObj: <root>.A declared in <root>.whenWithoutElse' type=<root>.A origin=null
|
||||
value: CONST Int type=kotlin.Int value=-2
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp0_subject: kotlin.Int [val] declared in <root>.whenWithoutElse' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=3
|
||||
then: SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Unit origin=EQ
|
||||
receiver: GET_VAR 'aObj: <root>.A declared in <root>.whenWithoutElse' type=<root>.A origin=null
|
||||
value: CONST Int type=kotlin.Int value=-3
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp0_subject: kotlin.Int [val] declared in <root>.whenWithoutElse' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=4
|
||||
then: SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Unit origin=EQ
|
||||
receiver: GET_VAR 'aObj: <root>.A declared in <root>.whenWithoutElse' type=<root>.A origin=null
|
||||
value: CONST Int type=kotlin.Int value=-4
|
||||
RETURN type=kotlin.Nothing from='public final fun whenWithoutElse (aObj: <root>.A): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Int origin=GET_PROPERTY
|
||||
receiver: GET_VAR 'aObj: <root>.A declared in <root>.whenWithoutElse' type=<root>.A origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:b visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=false
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-constIf> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:constIf visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-constIf> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:constIf type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:constIf type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="True"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-multi1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:multi1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-multi1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:multi1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:multi1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=-2
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-multi2> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:multi2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-multi2> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:multi2 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:multi2 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=-4
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-multi3> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:multi3 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-multi3> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:multi3 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:multi3 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=0
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=-1
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c2> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c2> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c2 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c2 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=-3
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c3> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c3 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c3> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c3 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c3 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=0
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-d1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:d1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-d1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:d1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:d1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=-1
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-d2> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:d2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-d2> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:d2 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:d2 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=-4
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-d3> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:d3 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-d3> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:d3 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:d3 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=10
|
||||
34
compiler/testData/ir/interpreter/companionOverride.kt
vendored
Normal file
34
compiler/testData/ir/interpreter/companionOverride.kt
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation
|
||||
interface Object {
|
||||
fun get(): String
|
||||
|
||||
//@CompileTimeCalculation
|
||||
fun defaultGet() = "Object"
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
open class A {
|
||||
companion object : Object {
|
||||
@CompileTimeCalculation
|
||||
override fun get() = "A"
|
||||
}
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
abstract class B : Object {
|
||||
fun str() = "B"
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
class C {
|
||||
companion object : B() {
|
||||
@CompileTimeCalculation
|
||||
override fun get() = "Default: " + super.defaultGet() + "; from super B: " + super.str() + "; from current: " + " companion C"
|
||||
}
|
||||
}
|
||||
|
||||
const val a = A.get()
|
||||
const val c1 = C.defaultGet()
|
||||
const val c2 = C.get()
|
||||
228
compiler/testData/ir/interpreter/companionOverride.txt
vendored
Normal file
228
compiler/testData/ir/interpreter/companionOverride.txt
vendored
Normal file
@@ -0,0 +1,228 @@
|
||||
FILE fqName:<root> fileName:/companionOverride.kt
|
||||
CLASS INTERFACE name:Object modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Object
|
||||
FUN name:get visibility:public modality:ABSTRACT <> ($this:<root>.Object) returnType:kotlin.String
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Object
|
||||
FUN name:defaultGet visibility:public modality:OPEN <> ($this:<root>.Object) returnType:kotlin.String
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Object
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun defaultGet (): kotlin.String declared in <root>.Object'
|
||||
CONST String type=kotlin.String value="Object"
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CONSTRUCTOR SYNTHETIC_PRIMARY_CONSTRUCTOR visibility:private <> () returnType:<root>.Object [primary]
|
||||
BLOCK_BODY
|
||||
CLASS CLASS name:A modality:OPEN visibility:public superTypes:[kotlin.Any]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.A [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
CLASS OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[<root>.Object]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A.Companion
|
||||
CONSTRUCTOR visibility:private <> () returnType:<root>.A.Companion [primary]
|
||||
BLOCK_BODY
|
||||
SET_FIELD 'FIELD name:Companion_instance type:<root>.A.Companion? visibility:public [static]' type=kotlin.Unit origin=null
|
||||
value: GET_VAR '<this>: <root>.A.Companion declared in <root>.A.Companion' type=<root>.A.Companion origin=null
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
FUN name:get visibility:public modality:OPEN <> ($this:<root>.A.Companion) returnType:kotlin.String
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
overridden:
|
||||
public abstract fun get (): kotlin.String declared in <root>.Object
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A.Companion
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun get (): kotlin.String declared in <root>.A.Companion'
|
||||
CONST String type=kotlin.String value="A"
|
||||
FUN FAKE_OVERRIDE name:defaultGet visibility:public modality:OPEN <> ($this:<root>.Object) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun defaultGet (): kotlin.String declared in <root>.Object
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Object
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.Object
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.Object
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.Object
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FIELD name:Companion_instance type:<root>.A.Companion? visibility:public [static]
|
||||
FUN SYNTHESIZED_DECLARATION name:Companion_getInstance visibility:public modality:FINAL <> () returnType:<root>.A.Companion
|
||||
BLOCK_BODY
|
||||
WHEN type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_FIELD 'FIELD name:Companion_instance type:<root>.A.Companion? visibility:public [static]' type=<root>.A.Companion? origin=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value=null
|
||||
then: CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.A.Companion' type=<root>.A.Companion origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun Companion_getInstance (): <root>.A.Companion declared in <root>.A'
|
||||
GET_FIELD 'FIELD name:Companion_instance type:<root>.A.Companion? visibility:public [static]' type=<root>.A.Companion? origin=null
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:B modality:ABSTRACT visibility:public superTypes:[<root>.Object]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.B
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.B [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
FUN name:str visibility:public modality:FINAL <> ($this:<root>.B) returnType:kotlin.String
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun str (): kotlin.String declared in <root>.B'
|
||||
CONST String type=kotlin.String value="B"
|
||||
FUN FAKE_OVERRIDE name:get visibility:public modality:ABSTRACT <> ($this:<root>.Object) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public abstract fun get (): kotlin.String declared in <root>.Object
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Object
|
||||
FUN FAKE_OVERRIDE name:defaultGet visibility:public modality:OPEN <> ($this:<root>.Object) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun defaultGet (): kotlin.String declared in <root>.Object
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Object
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.Object
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.Object
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.Object
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.C [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
CLASS OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[<root>.B]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C.Companion
|
||||
CONSTRUCTOR visibility:private <> () returnType:<root>.C.Companion [primary]
|
||||
BLOCK_BODY
|
||||
SET_FIELD 'FIELD name:Companion_instance type:<root>.C.Companion? visibility:public [static]' type=kotlin.Unit origin=null
|
||||
value: GET_VAR '<this>: <root>.C.Companion declared in <root>.C.Companion' type=<root>.C.Companion origin=null
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.B'
|
||||
FUN name:get visibility:public modality:OPEN <> ($this:<root>.C.Companion) returnType:kotlin.String
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
overridden:
|
||||
public abstract fun get (): kotlin.String [fake_override] declared in <root>.B
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.C.Companion
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun get (): kotlin.String declared in <root>.C.Companion'
|
||||
CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.String origin=PLUS
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.String origin=PLUS
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.String origin=PLUS
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.String origin=PLUS
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.String origin=PLUS
|
||||
arg0: CONST String type=kotlin.String value="Default: "
|
||||
arg1: CALL 'public open fun defaultGet (): kotlin.String [fake_override] declared in <root>.B' superQualifier='CLASS CLASS name:B modality:ABSTRACT visibility:public superTypes:[<root>.Object]' type=kotlin.String origin=null
|
||||
$this: GET_VAR '<this>: <root>.C.Companion declared in <root>.C.Companion.get' type=<root>.C.Companion origin=null
|
||||
arg1: CONST String type=kotlin.String value="; from super B: "
|
||||
arg1: CALL 'public final fun str (): kotlin.String declared in <root>.B' superQualifier='CLASS CLASS name:B modality:ABSTRACT visibility:public superTypes:[<root>.Object]' type=kotlin.String origin=null
|
||||
$this: GET_VAR '<this>: <root>.C.Companion declared in <root>.C.Companion.get' type=<root>.C.Companion origin=null
|
||||
arg1: CONST String type=kotlin.String value="; from current: "
|
||||
arg1: CONST String type=kotlin.String value=" companion C"
|
||||
FUN FAKE_OVERRIDE name:str visibility:public modality:FINAL <> ($this:<root>.B) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public final fun str (): kotlin.String declared in <root>.B
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
FUN FAKE_OVERRIDE name:defaultGet visibility:public modality:OPEN <> ($this:<root>.Object) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun defaultGet (): kotlin.String [fake_override] declared in <root>.B
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Object
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.B
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.B
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.B
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FIELD name:Companion_instance type:<root>.C.Companion? visibility:public [static]
|
||||
FUN SYNTHESIZED_DECLARATION name:Companion_getInstance visibility:public modality:FINAL <> () returnType:<root>.C.Companion
|
||||
BLOCK_BODY
|
||||
WHEN type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_FIELD 'FIELD name:Companion_instance type:<root>.C.Companion? visibility:public [static]' type=<root>.C.Companion? origin=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value=null
|
||||
then: CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.C.Companion' type=<root>.C.Companion origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun Companion_getInstance (): <root>.C.Companion declared in <root>.C'
|
||||
GET_FIELD 'FIELD name:Companion_instance type:<root>.C.Companion? visibility:public [static]' type=<root>.C.Companion? origin=null
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="A"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c1> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:c1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c1> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c1 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c1 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="Object"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c2> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:c2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c2> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c2 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c2 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="Default: Object; from super B: B; from current: companion C"
|
||||
16
compiler/testData/ir/interpreter/complexReturn.kt
vendored
Normal file
16
compiler/testData/ir/interpreter/complexReturn.kt
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun <T> firstNotNull(list: List<T?>): T {
|
||||
for (elem in list) {
|
||||
return (elem ?: continue)
|
||||
}
|
||||
|
||||
throw NoSuchElementException("All elements are null")
|
||||
}
|
||||
|
||||
const val a = firstNotNull(listOf(1, 2, 3))
|
||||
const val b = firstNotNull(listOf(1, null, 3))
|
||||
const val c = firstNotNull(listOf(null, 2, 3))
|
||||
const val d = firstNotNull(listOf(null, null, 3))
|
||||
const val e = firstNotNull(listOf<Int?>(null, null, null))
|
||||
79
compiler/testData/ir/interpreter/complexReturn.txt
vendored
Normal file
79
compiler/testData/ir/interpreter/complexReturn.txt
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
FILE fqName:<root> fileName:/complexReturn.kt
|
||||
FUN name:firstNotNull visibility:public modality:FINAL <T> (list:kotlin.collections.List<T of <root>.firstNotNull?>) returnType:T of <root>.firstNotNull
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
|
||||
VALUE_PARAMETER name:list index:0 type:kotlin.collections.List<T of <root>.firstNotNull?>
|
||||
BLOCK_BODY
|
||||
VAR FOR_LOOP_ITERATOR name:tmp0_iterator type:kotlin.collections.Iterator<T of <root>.firstNotNull?> [val]
|
||||
CALL 'public abstract fun iterator (): kotlin.collections.Iterator<E of kotlin.collections.List> [operator] declared in kotlin.collections.List' type=kotlin.collections.Iterator<T of <root>.firstNotNull?> origin=FOR_LOOP_ITERATOR
|
||||
$this: GET_VAR 'list: kotlin.collections.List<T of <root>.firstNotNull?> declared in <root>.firstNotNull' type=kotlin.collections.List<T of <root>.firstNotNull?> origin=null
|
||||
WHILE label=null origin=FOR_LOOP_INNER_WHILE
|
||||
condition: CALL 'public abstract fun hasNext (): kotlin.Boolean [operator] declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT
|
||||
$this: GET_VAR 'val tmp0_iterator: kotlin.collections.Iterator<T of <root>.firstNotNull?> [val] declared in <root>.firstNotNull' type=kotlin.collections.Iterator<T of <root>.firstNotNull?> origin=null
|
||||
body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE
|
||||
VAR FOR_LOOP_VARIABLE name:elem type:T of <root>.firstNotNull? [val]
|
||||
CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=T of <root>.firstNotNull? origin=FOR_LOOP_NEXT
|
||||
$this: GET_VAR 'val tmp0_iterator: kotlin.collections.Iterator<T of <root>.firstNotNull?> [val] declared in <root>.firstNotNull' type=kotlin.collections.Iterator<T of <root>.firstNotNull?> origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp1_elvis_lhs type:T of <root>.firstNotNull? [val]
|
||||
GET_VAR 'val elem: T of <root>.firstNotNull? [val] declared in <root>.firstNotNull' type=T of <root>.firstNotNull? origin=null
|
||||
VAR SYNTHESIZED_DECLARATION name:tmp type:T of <root>.firstNotNull [var]
|
||||
WHEN type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp1_elvis_lhs: T of <root>.firstNotNull? [val] declared in <root>.firstNotNull' type=T of <root>.firstNotNull? origin=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value=null
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
CONTINUE label=null loop.label=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
SET_VAR 'var tmp: T of <root>.firstNotNull [var] declared in <root>.firstNotNull' type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
GET_VAR 'val tmp1_elvis_lhs: T of <root>.firstNotNull? [val] declared in <root>.firstNotNull' type=T of <root>.firstNotNull? origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun firstNotNull <T> (list: kotlin.collections.List<T of <root>.firstNotNull?>): T of <root>.firstNotNull declared in <root>'
|
||||
GET_VAR 'var tmp: T of <root>.firstNotNull [var] declared in <root>.firstNotNull' type=T of <root>.firstNotNull origin=SYNTHESIZED_STATEMENT
|
||||
THROW type=kotlin.Nothing
|
||||
CALL 'public final fun NoSuchElementException_init_$Create$ (message: kotlin.String?): kotlin.NoSuchElementException declared in kotlin.NoSuchElementException' type=kotlin.NoSuchElementException origin=null
|
||||
message: CONST String type=kotlin.String value="All elements are null"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=1
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:b visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=1
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=2
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-d> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:d visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-d> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:d type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:d type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=3
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-e> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:e visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-e> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:e type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:e type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
ERROR_EXPR '
|
||||
Exception kotlin.NoSuchElementException: All elements are null
|
||||
at ComplexReturnKt.firstNotNull(complexReturn.kt:4)' type=kotlin.Int
|
||||
73
compiler/testData/ir/interpreter/composition.kt
vendored
Normal file
73
compiler/testData/ir/interpreter/composition.kt
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
open class A @CompileTimeCalculation constructor(@CompileTimeCalculation var a: Int) {
|
||||
@CompileTimeCalculation
|
||||
fun get(): Int {
|
||||
return a
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
open fun openGet(): Int {
|
||||
return a
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun setA(a: Int): A {
|
||||
this.a = a
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
open class B @CompileTimeCalculation constructor(@CompileTimeCalculation val b: Int) {
|
||||
@CompileTimeCalculation val aObj = A(b + 1)
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun getAFromB(): Int {
|
||||
return aObj.a
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun getFromProperty(): Int {
|
||||
return aObj.get()
|
||||
}
|
||||
}
|
||||
|
||||
open class C @CompileTimeCalculation constructor(@CompileTimeCalculation val c: Int) {
|
||||
@CompileTimeCalculation val aObj = A(c + 2)
|
||||
@CompileTimeCalculation val bObj = B(c + 1)
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun getAFromC(): Int {
|
||||
return aObj.a
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun getBFromC(): Int {
|
||||
return bObj.b
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun openGet(): Int {
|
||||
return aObj.openGet()
|
||||
}
|
||||
}
|
||||
|
||||
const val a1 = A(1).get()
|
||||
const val a2 = A(1).setA(2).get()
|
||||
const val a3 = A(1).openGet()
|
||||
|
||||
const val b1 = B(1).getAFromB()
|
||||
const val b2 = B(1).getFromProperty()
|
||||
const val b3 = B(1).aObj.get()
|
||||
const val b4 = B(1).aObj.setA(-1).get()
|
||||
const val b5 = B(1).aObj.a
|
||||
|
||||
const val c1 = C(1).getAFromC()
|
||||
const val c2 = C(1).getBFromC()
|
||||
const val c3 = C(1).aObj.get()
|
||||
const val c4 = C(1).openGet()
|
||||
const val c5 = C(1).bObj.getAFromB()
|
||||
const val c6 = C(1).bObj.getFromProperty()
|
||||
const val c7 = C(1).bObj.aObj.setA(-2).get()
|
||||
const val c8 = C(1).bObj.b
|
||||
const val c9 = C(1).aObj.a
|
||||
364
compiler/testData/ir/interpreter/composition.txt
vendored
Normal file
364
compiler/testData/ir/interpreter/composition.txt
vendored
Normal file
@@ -0,0 +1,364 @@
|
||||
FILE fqName:<root> fileName:/composition.kt
|
||||
CLASS CLASS name:A modality:OPEN visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A
|
||||
CONSTRUCTOR visibility:public <> (a:kotlin.Int) returnType:<root>.A [primary]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Unit origin=INITIALIZE_FIELD
|
||||
receiver: GET_VAR '<this>: <root>.A declared in <root>.A' type=<root>.A origin=null
|
||||
value: GET_VAR 'a: kotlin.Int declared in <root>.A.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<set-a> visibility:public modality:FINAL <> ($this:<root>.A, <set-?>:kotlin.Int) returnType:kotlin.Unit
|
||||
correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [var]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A
|
||||
VALUE_PARAMETER name:<set-?> index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Unit origin=null
|
||||
receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<set-a>' type=<root>.A origin=null
|
||||
value: GET_VAR '<set-?>: kotlin.Int declared in <root>.A.<set-a>' type=kotlin.Int origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a> visibility:public modality:FINAL <> ($this:<root>.A) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [var]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a> (): kotlin.Int declared in <root>.A'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-a>' type=<root>.A origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private
|
||||
FUN name:get visibility:public modality:FINAL <> ($this:<root>.A) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun get (): kotlin.Int declared in <root>.A'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Int origin=GET_PROPERTY
|
||||
receiver: GET_VAR '<this>: <root>.A declared in <root>.A.get' type=<root>.A origin=null
|
||||
FUN name:openGet visibility:public modality:OPEN <> ($this:<root>.A) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun openGet (): kotlin.Int declared in <root>.A'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Int origin=GET_PROPERTY
|
||||
receiver: GET_VAR '<this>: <root>.A declared in <root>.A.openGet' type=<root>.A origin=null
|
||||
FUN name:setA visibility:public modality:FINAL <> ($this:<root>.A, a:kotlin.Int) returnType:<root>.A
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Unit origin=EQ
|
||||
receiver: GET_VAR '<this>: <root>.A declared in <root>.A.setA' type=<root>.A origin=null
|
||||
value: GET_VAR 'a: kotlin.Int declared in <root>.A.setA' type=kotlin.Int origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun setA (a: kotlin.Int): <root>.A declared in <root>.A'
|
||||
GET_VAR '<this>: <root>.A declared in <root>.A.setA' type=<root>.A origin=null
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:B modality:OPEN visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.B
|
||||
CONSTRUCTOR visibility:public <> (b:kotlin.Int) returnType:<root>.B [primary]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:b index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=INITIALIZE_FIELD
|
||||
receiver: GET_VAR '<this>: <root>.B declared in <root>.B' type=<root>.B origin=null
|
||||
value: GET_VAR 'b: kotlin.Int declared in <root>.B.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:aObj type:<root>.A visibility:private [final]' type=kotlin.Unit origin=INITIALIZE_FIELD
|
||||
receiver: GET_VAR '<this>: <root>.B declared in <root>.B' type=<root>.B origin=null
|
||||
value: CONSTRUCTOR_CALL 'public constructor <init> (a: kotlin.Int) [primary] declared in <root>.A' type=<root>.A origin=null
|
||||
a: CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=PLUS
|
||||
arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=GET_PROPERTY
|
||||
receiver: GET_VAR '<this>: <root>.B declared in <root>.B' type=<root>.B origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=1
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b> visibility:public modality:FINAL <> ($this:<root>.B) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:b visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b> (): kotlin.Int declared in <root>.B'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.B declared in <root>.B.<get-b>' type=<root>.B origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:private [final]
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-aObj> visibility:public modality:FINAL <> ($this:<root>.B) returnType:<root>.A
|
||||
correspondingProperty: PROPERTY name:aObj visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-aObj> (): <root>.A declared in <root>.B'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:aObj type:<root>.A visibility:private [final]' type=<root>.A origin=null
|
||||
receiver: GET_VAR '<this>: <root>.B declared in <root>.B.<get-aObj>' type=<root>.B origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:aObj type:<root>.A visibility:private [final]
|
||||
FUN name:getAFromB visibility:public modality:FINAL <> ($this:<root>.B) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun getAFromB (): kotlin.Int declared in <root>.B'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Int origin=GET_PROPERTY
|
||||
receiver: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:aObj type:<root>.A visibility:private [final]' type=<root>.A origin=GET_PROPERTY
|
||||
receiver: GET_VAR '<this>: <root>.B declared in <root>.B.getAFromB' type=<root>.B origin=null
|
||||
FUN name:getFromProperty visibility:public modality:FINAL <> ($this:<root>.B) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun getFromProperty (): kotlin.Int declared in <root>.B'
|
||||
CALL 'public final fun get (): kotlin.Int declared in <root>.A' type=kotlin.Int origin=null
|
||||
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:aObj type:<root>.A visibility:private [final]' type=<root>.A origin=GET_PROPERTY
|
||||
receiver: GET_VAR '<this>: <root>.B declared in <root>.B.getFromProperty' type=<root>.B origin=null
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:C modality:OPEN visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C
|
||||
CONSTRUCTOR visibility:public <> (c:kotlin.Int) returnType:<root>.C [primary]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:c index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=INITIALIZE_FIELD
|
||||
receiver: GET_VAR '<this>: <root>.C declared in <root>.C' type=<root>.C origin=null
|
||||
value: GET_VAR 'c: kotlin.Int declared in <root>.C.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:aObj type:<root>.A visibility:private [final]' type=kotlin.Unit origin=INITIALIZE_FIELD
|
||||
receiver: GET_VAR '<this>: <root>.C declared in <root>.C' type=<root>.C origin=null
|
||||
value: CONSTRUCTOR_CALL 'public constructor <init> (a: kotlin.Int) [primary] declared in <root>.A' type=<root>.A origin=null
|
||||
a: CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=PLUS
|
||||
arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=GET_PROPERTY
|
||||
receiver: GET_VAR '<this>: <root>.C declared in <root>.C' type=<root>.C origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=2
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:bObj type:<root>.B visibility:private [final]' type=kotlin.Unit origin=INITIALIZE_FIELD
|
||||
receiver: GET_VAR '<this>: <root>.C declared in <root>.C' type=<root>.C origin=null
|
||||
value: CONSTRUCTOR_CALL 'public constructor <init> (b: kotlin.Int) [primary] declared in <root>.B' type=<root>.B origin=null
|
||||
b: CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=PLUS
|
||||
arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=GET_PROPERTY
|
||||
receiver: GET_VAR '<this>: <root>.C declared in <root>.C' type=<root>.C origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=1
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c> visibility:public modality:FINAL <> ($this:<root>.C) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.C
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c> (): kotlin.Int declared in <root>.C'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.C declared in <root>.C.<get-c>' type=<root>.C origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-aObj> visibility:public modality:FINAL <> ($this:<root>.C) returnType:<root>.A
|
||||
correspondingProperty: PROPERTY name:aObj visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.C
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-aObj> (): <root>.A declared in <root>.C'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:aObj type:<root>.A visibility:private [final]' type=<root>.A origin=null
|
||||
receiver: GET_VAR '<this>: <root>.C declared in <root>.C.<get-aObj>' type=<root>.C origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:aObj type:<root>.A visibility:private [final]
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-bObj> visibility:public modality:FINAL <> ($this:<root>.C) returnType:<root>.B
|
||||
correspondingProperty: PROPERTY name:bObj visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.C
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-bObj> (): <root>.B declared in <root>.C'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:bObj type:<root>.B visibility:private [final]' type=<root>.B origin=null
|
||||
receiver: GET_VAR '<this>: <root>.C declared in <root>.C.<get-bObj>' type=<root>.C origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:bObj type:<root>.B visibility:private [final]
|
||||
FUN name:getAFromC visibility:public modality:FINAL <> ($this:<root>.C) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.C
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun getAFromC (): kotlin.Int declared in <root>.C'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private' type=kotlin.Int origin=GET_PROPERTY
|
||||
receiver: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:aObj type:<root>.A visibility:private [final]' type=<root>.A origin=GET_PROPERTY
|
||||
receiver: GET_VAR '<this>: <root>.C declared in <root>.C.getAFromC' type=<root>.C origin=null
|
||||
FUN name:getBFromC visibility:public modality:FINAL <> ($this:<root>.C) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.C
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun getBFromC (): kotlin.Int declared in <root>.C'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=GET_PROPERTY
|
||||
receiver: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:bObj type:<root>.B visibility:private [final]' type=<root>.B origin=GET_PROPERTY
|
||||
receiver: GET_VAR '<this>: <root>.C declared in <root>.C.getBFromC' type=<root>.C origin=null
|
||||
FUN name:openGet visibility:public modality:FINAL <> ($this:<root>.C) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.C
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun openGet (): kotlin.Int declared in <root>.C'
|
||||
CALL 'public open fun openGet (): kotlin.Int declared in <root>.A' type=kotlin.Int origin=null
|
||||
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:aObj type:<root>.A visibility:private [final]' type=<root>.A origin=GET_PROPERTY
|
||||
receiver: GET_VAR '<this>: <root>.C declared in <root>.C.openGet' type=<root>.C origin=null
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:a1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=1
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a2> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:a2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a2> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a2 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a2 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=2
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a3> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:a3 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a3> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a3 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a3 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=1
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:b1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=2
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b2> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:b2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b2> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b2 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b2 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=2
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b3> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:b3 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b3> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b3 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b3 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=2
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b4> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:b4 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b4> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b4 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b4 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=-1
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b5> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:b5 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b5> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b5 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b5 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=2
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=3
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c2> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c2> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c2 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c2 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=2
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c3> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c3 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c3> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c3 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c3 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=3
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c4> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c4 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c4> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c4 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c4 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=3
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c5> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c5 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c5> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c5 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c5 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=3
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c6> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c6 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c6> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c6 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c6 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=3
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c7> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c7 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c7> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c7 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c7 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=-2
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c8> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c8 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c8> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c8 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c8 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=2
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c9> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c9 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c9> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c9 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c9 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=3
|
||||
10
compiler/testData/ir/interpreter/copyReceivedValue.kt
vendored
Normal file
10
compiler/testData/ir/interpreter/copyReceivedValue.kt
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun Int.minusOne(): Int {
|
||||
var value = this
|
||||
value = value - 1
|
||||
return this
|
||||
}
|
||||
|
||||
const val a = 5.minusOne()
|
||||
24
compiler/testData/ir/interpreter/copyReceivedValue.txt
vendored
Normal file
24
compiler/testData/ir/interpreter/copyReceivedValue.txt
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
FILE fqName:<root> fileName:/copyReceivedValue.kt
|
||||
FUN name:minusOne visibility:public modality:FINAL <> ($receiver:kotlin.Int) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$receiver: VALUE_PARAMETER name:<this> type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
VAR name:value type:kotlin.Int [var]
|
||||
GET_VAR '<this>: kotlin.Int declared in <root>.minusOne' type=kotlin.Int origin=null
|
||||
SET_VAR 'var value: kotlin.Int [var] declared in <root>.minusOne' type=kotlin.Unit origin=EQ
|
||||
CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsMinus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=MINUS
|
||||
arg0: GET_VAR 'var value: kotlin.Int [var] declared in <root>.minusOne' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=1
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
RETURN type=kotlin.Nothing from='public final fun minusOne (): kotlin.Int declared in <root>'
|
||||
GET_VAR '<this>: kotlin.Int declared in <root>.minusOne' type=kotlin.Int origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=5
|
||||
21
compiler/testData/ir/interpreter/dataClass.kt
vendored
Normal file
21
compiler/testData/ir/interpreter/dataClass.kt
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation
|
||||
data class Person(val name: String, val phone: Int)
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun Person.getAsString(): String {
|
||||
val (name, phone) = this
|
||||
return "Persom name is $name and his phone is $phone"
|
||||
}
|
||||
|
||||
const val a1 = Person("John", 123456).name
|
||||
const val a2 = Person("John", 123456).component1()
|
||||
const val a3 = Person("John", 123456).phone
|
||||
const val a4 = Person("John", 123456).component2()
|
||||
|
||||
const val b1 = Person("John", 789).copy("Adam").toString()
|
||||
const val b2 = Person("John", 789).copy("Adam", 123).toString()
|
||||
|
||||
const val c = Person("John", 123456).equals(Person("John", 123456))
|
||||
const val d = Person("John", 123456).getAsString()
|
||||
266
compiler/testData/ir/interpreter/dataClass.txt
vendored
Normal file
266
compiler/testData/ir/interpreter/dataClass.txt
vendored
Normal file
@@ -0,0 +1,266 @@
|
||||
FILE fqName:<root> fileName:/dataClass.kt
|
||||
CLASS CLASS name:Person modality:FINAL visibility:public [data] superTypes:[kotlin.Any]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Person
|
||||
CONSTRUCTOR visibility:public <> (name:kotlin.String, phone:kotlin.Int) returnType:<root>.Person [primary]
|
||||
VALUE_PARAMETER name:name index:0 type:kotlin.String
|
||||
VALUE_PARAMETER name:phone index:1 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:name type:kotlin.String visibility:private [final]' type=kotlin.Unit origin=INITIALIZE_FIELD
|
||||
receiver: GET_VAR '<this>: <root>.Person declared in <root>.Person' type=<root>.Person origin=null
|
||||
value: GET_VAR 'name: kotlin.String declared in <root>.Person.<init>' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:phone type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=INITIALIZE_FIELD
|
||||
receiver: GET_VAR '<this>: <root>.Person declared in <root>.Person' type=<root>.Person origin=null
|
||||
value: GET_VAR 'phone: kotlin.Int declared in <root>.Person.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-name> visibility:public modality:FINAL <> ($this:<root>.Person) returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:name visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Person
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-name> (): kotlin.String declared in <root>.Person'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:name type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Person declared in <root>.Person.<get-name>' type=<root>.Person origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:name type:kotlin.String visibility:private [final]
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-phone> visibility:public modality:FINAL <> ($this:<root>.Person) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:phone visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Person
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-phone> (): kotlin.Int declared in <root>.Person'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:phone type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Person declared in <root>.Person.<get-phone>' type=<root>.Person origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:phone type:kotlin.Int visibility:private [final]
|
||||
FUN GENERATED_DATA_CLASS_MEMBER name:component1 visibility:public modality:FINAL <> ($this:<root>.Person) returnType:kotlin.String [operator]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Person
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.String [operator] declared in <root>.Person'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:name type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Person declared in <root>.Person.component1' type=<root>.Person origin=null
|
||||
FUN GENERATED_DATA_CLASS_MEMBER name:component2 visibility:public modality:FINAL <> ($this:<root>.Person) returnType:kotlin.Int [operator]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Person
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun component2 (): kotlin.Int [operator] declared in <root>.Person'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:phone type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Person declared in <root>.Person.component2' type=<root>.Person origin=null
|
||||
FUN GENERATED_DATA_CLASS_MEMBER name:copy visibility:public modality:FINAL <> ($this:<root>.Person, name:kotlin.String, phone:kotlin.Int) returnType:<root>.Person
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Person
|
||||
VALUE_PARAMETER name:name index:0 type:kotlin.String
|
||||
VALUE_PARAMETER name:phone index:1 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun copy (name: kotlin.String, phone: kotlin.Int): <root>.Person declared in <root>.Person'
|
||||
CONSTRUCTOR_CALL 'public constructor <init> (name: kotlin.String, phone: kotlin.Int) [primary] declared in <root>.Person' type=<root>.Person origin=null
|
||||
name: GET_VAR 'name: kotlin.String declared in <root>.Person.copy' type=kotlin.String origin=null
|
||||
phone: GET_VAR 'phone: kotlin.Int declared in <root>.Person.copy' type=kotlin.Int origin=null
|
||||
FUN FUNCTION_FOR_DEFAULT_PARAMETER name:copy$default visibility:public modality:FINAL <> ($this:<root>.Person, name:kotlin.String?, phone:kotlin.Int, $mask0:kotlin.Int, $handler:kotlin.Any?) returnType:<root>.Person
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Person
|
||||
VALUE_PARAMETER name:name index:0 type:kotlin.String?
|
||||
VALUE_PARAMETER name:phone index:1 type:kotlin.Int
|
||||
VALUE_PARAMETER MASK_FOR_DEFAULT_FUNCTION name:$mask0 index:2 type:kotlin.Int
|
||||
VALUE_PARAMETER METHOD_HANDLER_IN_DEFAULT_FUNCTION name:$handler index:3 type:kotlin.Any?
|
||||
BLOCK_BODY
|
||||
VAR IR_TEMPORARY_VARIABLE name:name type:kotlin.String? [val]
|
||||
WHEN type=kotlin.String? origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsNot (arg0: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: CALL 'public final fun jsBitAnd (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=null
|
||||
arg0: GET_VAR '$mask0: kotlin.Int declared in <root>.Person.copy$default' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=1
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
then: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:name type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Person declared in <root>.Person.copy$default' type=<root>.Person origin=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: GET_VAR 'name: kotlin.String? declared in <root>.Person.copy$default' type=kotlin.String? origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:phone type:kotlin.Int [val]
|
||||
WHEN type=kotlin.Int origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsNot (arg0: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: CALL 'public final fun jsBitAnd (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=null
|
||||
arg0: GET_VAR '$mask0: kotlin.Int declared in <root>.Person.copy$default' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=2
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
then: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:phone type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Person declared in <root>.Person.copy$default' type=<root>.Person origin=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: GET_VAR 'phone: kotlin.Int declared in <root>.Person.copy$default' type=kotlin.Int origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun copy$default (name: kotlin.String?, phone: kotlin.Int, $mask0: kotlin.Int, $handler: kotlin.Any?): <root>.Person declared in <root>.Person'
|
||||
CALL 'public final fun copy (name: kotlin.String, phone: kotlin.Int): <root>.Person declared in <root>.Person' type=<root>.Person origin=null
|
||||
$this: GET_VAR '<this>: <root>.Person declared in <root>.Person.copy$default' type=<root>.Person origin=null
|
||||
name: TYPE_OP type=kotlin.String origin=REINTERPRET_CAST typeOperand=kotlin.String
|
||||
GET_VAR 'val name: kotlin.String? [val] declared in <root>.Person.copy$default' type=kotlin.String? origin=null
|
||||
phone: GET_VAR 'val phone: kotlin.Int [val] declared in <root>.Person.copy$default' type=kotlin.Int origin=null
|
||||
FUN GENERATED_DATA_CLASS_MEMBER name:toString visibility:public modality:OPEN <> ($this:<root>.Person) returnType:kotlin.String
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Person
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun toString (): kotlin.String declared in <root>.Person'
|
||||
STRING_CONCATENATION type=kotlin.String
|
||||
CONST String type=kotlin.String value="Person(name="
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:name type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Person declared in <root>.Person.toString' type=<root>.Person origin=null
|
||||
CONST String type=kotlin.String value=", phone="
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:phone type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Person declared in <root>.Person.toString' type=<root>.Person origin=null
|
||||
CONST String type=kotlin.String value=")"
|
||||
FUN GENERATED_DATA_CLASS_MEMBER name:hashCode visibility:public modality:OPEN <> ($this:<root>.Person) returnType:kotlin.Int
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Person
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in <root>.Person'
|
||||
CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=null
|
||||
arg0: CALL 'internal final fun imul (a_local: kotlin.Int, b_local: kotlin.Int): kotlin.Int declared in kotlin.js' type=kotlin.Int origin=null
|
||||
a_local: CALL 'public final fun getStringHashCode (str: kotlin.String): kotlin.Int declared in kotlin.js' type=kotlin.Int origin=null
|
||||
str: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:name type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Person declared in <root>.Person.hashCode' type=<root>.Person origin=null
|
||||
b_local: CONST Int type=kotlin.Int value=31
|
||||
arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:phone type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Person declared in <root>.Person.hashCode' type=<root>.Person origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:<root>.Person, other:kotlin.Any?) returnType:kotlin.Boolean [operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Person
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
BLOCK_BODY
|
||||
WHEN type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQEQ
|
||||
arg0: GET_VAR '<this>: <root>.Person declared in <root>.Person.equals' type=<root>.Person origin=null
|
||||
arg1: GET_VAR 'other: kotlin.Any? declared in <root>.Person.equals' type=kotlin.Any? origin=null
|
||||
then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in <root>.Person'
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
WHEN type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsNot (arg0: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsInstanceOf (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=SYNTHESIZED_STATEMENT
|
||||
arg0: GET_VAR 'other: kotlin.Any? declared in <root>.Person.equals' type=kotlin.Any? origin=null
|
||||
arg1: CALL 'public final fun jsClass <T> (): kotlin.js.JsClass<T of kotlin.js.jsClass> [external] declared in kotlin.js' type=kotlin.js.JsClass<T of kotlin.js.jsClass> origin=SYNTHESIZED_STATEMENT
|
||||
<T>: <root>.Person
|
||||
then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in <root>.Person'
|
||||
CONST Boolean type=kotlin.Boolean value=false
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: BLOCK type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp0_other_with_cast type:<root>.Person [val]
|
||||
WHEN type=<root>.Person origin=SYNTHESIZED_STATEMENT
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsInstanceOf (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=SYNTHESIZED_STATEMENT
|
||||
arg0: GET_VAR 'other: kotlin.Any? declared in <root>.Person.equals' type=kotlin.Any? origin=null
|
||||
arg1: CALL 'public final fun jsClass <T> (): kotlin.js.JsClass<T of kotlin.js.jsClass> [external] declared in kotlin.js' type=kotlin.js.JsClass<T of kotlin.js.jsClass> origin=SYNTHESIZED_STATEMENT
|
||||
<T>: <root>.Person
|
||||
then: TYPE_OP type=<root>.Person origin=REINTERPRET_CAST typeOperand=<root>.Person
|
||||
GET_VAR 'other: kotlin.Any? declared in <root>.Person.equals' type=kotlin.Any? origin=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CALL 'public final fun THROW_CCE (): kotlin.Nothing declared in kotlin' type=kotlin.Nothing origin=SYNTHESIZED_STATEMENT
|
||||
WHEN type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsNot (arg0: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:name type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Person declared in <root>.Person.equals' type=<root>.Person origin=null
|
||||
arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:name type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR 'val tmp0_other_with_cast: <root>.Person [val] declared in <root>.Person.equals' type=<root>.Person origin=null
|
||||
then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in <root>.Person'
|
||||
CONST Boolean type=kotlin.Boolean value=false
|
||||
WHEN type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsNot (arg0: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:phone type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Person declared in <root>.Person.equals' type=<root>.Person origin=null
|
||||
arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:phone type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR 'val tmp0_other_with_cast: <root>.Person [val] declared in <root>.Person.equals' type=<root>.Person origin=null
|
||||
then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in <root>.Person'
|
||||
CONST Boolean type=kotlin.Boolean value=false
|
||||
RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in <root>.Person'
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN name:getAsString visibility:public modality:FINAL <> ($receiver:<root>.Person) returnType:kotlin.String
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$receiver: VALUE_PARAMETER name:<this> type:<root>.Person
|
||||
BLOCK_BODY
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp0_container type:<root>.Person [val]
|
||||
GET_VAR '<this>: <root>.Person declared in <root>.getAsString' type=<root>.Person origin=null
|
||||
VAR name:name type:kotlin.String [val]
|
||||
CALL 'public final fun component1 (): kotlin.String [operator] declared in <root>.Person' type=kotlin.String origin=COMPONENT_N(index=1)
|
||||
$this: GET_VAR 'val tmp0_container: <root>.Person [val] declared in <root>.getAsString' type=<root>.Person origin=null
|
||||
VAR name:phone type:kotlin.Int [val]
|
||||
CALL 'public final fun component2 (): kotlin.Int [operator] declared in <root>.Person' type=kotlin.Int origin=COMPONENT_N(index=2)
|
||||
$this: GET_VAR 'val tmp0_container: <root>.Person [val] declared in <root>.getAsString' type=<root>.Person origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun getAsString (): kotlin.String declared in <root>'
|
||||
STRING_CONCATENATION type=kotlin.String
|
||||
CONST String type=kotlin.String value="Persom name is "
|
||||
GET_VAR 'val name: kotlin.String [val] declared in <root>.getAsString' type=kotlin.String origin=null
|
||||
CONST String type=kotlin.String value=" and his phone is "
|
||||
GET_VAR 'val phone: kotlin.Int [val] declared in <root>.getAsString' type=kotlin.Int origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a1> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:a1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a1> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a1 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a1 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="John"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a2> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:a2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a2> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a2 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a2 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="John"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a3> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:a3 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a3> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a3 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a3 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=123456
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a4> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:a4 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a4> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a4 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a4 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=123456
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b1> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:b1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b1> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b1 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b1 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="Person(name=Adam, phone=789)"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b2> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:b2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b2> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b2 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b2 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="Person(name=Adam, phone=123)"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-d> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:d visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-d> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:d type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:d type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="Persom name is John and his phone is 123456"
|
||||
14
compiler/testData/ir/interpreter/defaultArgs.kt
vendored
Normal file
14
compiler/testData/ir/interpreter/defaultArgs.kt
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun sum(a: Int = 1, b: Int = 2, c: Int = 3) = a + b + c
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun sumBasedOnPrevious(a: Int = 1, b: Int = a * 2, c: Int = b * 2) = a + b + c
|
||||
|
||||
const val sum1 = sum()
|
||||
const val sum2 = sum(b = -3)
|
||||
const val sum3 = sum(c = 1, a = 1, b = 1)
|
||||
|
||||
const val sumBasedOnPrevious1 = sumBasedOnPrevious()
|
||||
const val sumBasedOnPrevious2 = sumBasedOnPrevious(b = 1, c = 1)
|
||||
185
compiler/testData/ir/interpreter/defaultArgs.txt
vendored
Normal file
185
compiler/testData/ir/interpreter/defaultArgs.txt
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
FILE fqName:<root> fileName:/defaultArgs.kt
|
||||
FUN name:sum visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int, c:kotlin.Int) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Int
|
||||
VALUE_PARAMETER name:b index:1 type:kotlin.Int
|
||||
VALUE_PARAMETER name:c index:2 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun sum (a: kotlin.Int, b: kotlin.Int, c: kotlin.Int): kotlin.Int declared in <root>'
|
||||
CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=PLUS
|
||||
arg0: CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=PLUS
|
||||
arg0: GET_VAR 'a: kotlin.Int declared in <root>.sum' type=kotlin.Int origin=null
|
||||
arg1: GET_VAR 'b: kotlin.Int declared in <root>.sum' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
arg1: GET_VAR 'c: kotlin.Int declared in <root>.sum' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
FUN FUNCTION_FOR_DEFAULT_PARAMETER name:sum$default visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int, c:kotlin.Int, $mask0:kotlin.Int, $handler:kotlin.Any?) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Int
|
||||
VALUE_PARAMETER name:b index:1 type:kotlin.Int
|
||||
VALUE_PARAMETER name:c index:2 type:kotlin.Int
|
||||
VALUE_PARAMETER MASK_FOR_DEFAULT_FUNCTION name:$mask0 index:3 type:kotlin.Int
|
||||
VALUE_PARAMETER METHOD_HANDLER_IN_DEFAULT_FUNCTION name:$handler index:4 type:kotlin.Any?
|
||||
BLOCK_BODY
|
||||
VAR IR_TEMPORARY_VARIABLE name:a type:kotlin.Int [val]
|
||||
WHEN type=kotlin.Int origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsNot (arg0: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: CALL 'public final fun jsBitAnd (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=null
|
||||
arg0: GET_VAR '$mask0: kotlin.Int declared in <root>.sum$default' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=1
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
then: CONST Int type=kotlin.Int value=1
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: GET_VAR 'a: kotlin.Int declared in <root>.sum$default' type=kotlin.Int origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:b type:kotlin.Int [val]
|
||||
WHEN type=kotlin.Int origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsNot (arg0: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: CALL 'public final fun jsBitAnd (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=null
|
||||
arg0: GET_VAR '$mask0: kotlin.Int declared in <root>.sum$default' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=2
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
then: CONST Int type=kotlin.Int value=2
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: GET_VAR 'b: kotlin.Int declared in <root>.sum$default' type=kotlin.Int origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:c type:kotlin.Int [val]
|
||||
WHEN type=kotlin.Int origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsNot (arg0: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: CALL 'public final fun jsBitAnd (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=null
|
||||
arg0: GET_VAR '$mask0: kotlin.Int declared in <root>.sum$default' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=4
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
then: CONST Int type=kotlin.Int value=3
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: GET_VAR 'c: kotlin.Int declared in <root>.sum$default' type=kotlin.Int origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun sum$default (a: kotlin.Int, b: kotlin.Int, c: kotlin.Int, $mask0: kotlin.Int, $handler: kotlin.Any?): kotlin.Int declared in <root>'
|
||||
CALL 'public final fun sum (a: kotlin.Int, b: kotlin.Int, c: kotlin.Int): kotlin.Int declared in <root>' type=kotlin.Int origin=null
|
||||
a: GET_VAR 'val a: kotlin.Int [val] declared in <root>.sum$default' type=kotlin.Int origin=null
|
||||
b: GET_VAR 'val b: kotlin.Int [val] declared in <root>.sum$default' type=kotlin.Int origin=null
|
||||
c: GET_VAR 'val c: kotlin.Int [val] declared in <root>.sum$default' type=kotlin.Int origin=null
|
||||
FUN name:sumBasedOnPrevious visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int, c:kotlin.Int) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Int
|
||||
VALUE_PARAMETER name:b index:1 type:kotlin.Int
|
||||
VALUE_PARAMETER name:c index:2 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun sumBasedOnPrevious (a: kotlin.Int, b: kotlin.Int, c: kotlin.Int): kotlin.Int declared in <root>'
|
||||
CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=PLUS
|
||||
arg0: CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=PLUS
|
||||
arg0: GET_VAR 'a: kotlin.Int declared in <root>.sumBasedOnPrevious' type=kotlin.Int origin=null
|
||||
arg1: GET_VAR 'b: kotlin.Int declared in <root>.sumBasedOnPrevious' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
arg1: GET_VAR 'c: kotlin.Int declared in <root>.sumBasedOnPrevious' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
FUN FUNCTION_FOR_DEFAULT_PARAMETER name:sumBasedOnPrevious$default visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int, c:kotlin.Int, $mask0:kotlin.Int, $handler:kotlin.Any?) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Int
|
||||
VALUE_PARAMETER name:b index:1 type:kotlin.Int
|
||||
VALUE_PARAMETER name:c index:2 type:kotlin.Int
|
||||
VALUE_PARAMETER MASK_FOR_DEFAULT_FUNCTION name:$mask0 index:3 type:kotlin.Int
|
||||
VALUE_PARAMETER METHOD_HANDLER_IN_DEFAULT_FUNCTION name:$handler index:4 type:kotlin.Any?
|
||||
BLOCK_BODY
|
||||
VAR IR_TEMPORARY_VARIABLE name:a type:kotlin.Int [val]
|
||||
WHEN type=kotlin.Int origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsNot (arg0: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: CALL 'public final fun jsBitAnd (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=null
|
||||
arg0: GET_VAR '$mask0: kotlin.Int declared in <root>.sumBasedOnPrevious$default' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=1
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
then: CONST Int type=kotlin.Int value=1
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: GET_VAR 'a: kotlin.Int declared in <root>.sumBasedOnPrevious$default' type=kotlin.Int origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:b type:kotlin.Int [val]
|
||||
WHEN type=kotlin.Int origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsNot (arg0: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: CALL 'public final fun jsBitAnd (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=null
|
||||
arg0: GET_VAR '$mask0: kotlin.Int declared in <root>.sumBasedOnPrevious$default' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=2
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
then: CALL 'internal final fun imul (a_local: kotlin.Int, b_local: kotlin.Int): kotlin.Int declared in kotlin.js' type=kotlin.Int origin=MUL
|
||||
a_local: GET_VAR 'val a: kotlin.Int [val] declared in <root>.sumBasedOnPrevious$default' type=kotlin.Int origin=null
|
||||
b_local: CONST Int type=kotlin.Int value=2
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: GET_VAR 'b: kotlin.Int declared in <root>.sumBasedOnPrevious$default' type=kotlin.Int origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:c type:kotlin.Int [val]
|
||||
WHEN type=kotlin.Int origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsNot (arg0: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: CALL 'public final fun jsBitAnd (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=null
|
||||
arg0: GET_VAR '$mask0: kotlin.Int declared in <root>.sumBasedOnPrevious$default' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=4
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
then: CALL 'internal final fun imul (a_local: kotlin.Int, b_local: kotlin.Int): kotlin.Int declared in kotlin.js' type=kotlin.Int origin=MUL
|
||||
a_local: GET_VAR 'val b: kotlin.Int [val] declared in <root>.sumBasedOnPrevious$default' type=kotlin.Int origin=null
|
||||
b_local: CONST Int type=kotlin.Int value=2
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: GET_VAR 'c: kotlin.Int declared in <root>.sumBasedOnPrevious$default' type=kotlin.Int origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun sumBasedOnPrevious$default (a: kotlin.Int, b: kotlin.Int, c: kotlin.Int, $mask0: kotlin.Int, $handler: kotlin.Any?): kotlin.Int declared in <root>'
|
||||
CALL 'public final fun sumBasedOnPrevious (a: kotlin.Int, b: kotlin.Int, c: kotlin.Int): kotlin.Int declared in <root>' type=kotlin.Int origin=null
|
||||
a: GET_VAR 'val a: kotlin.Int [val] declared in <root>.sumBasedOnPrevious$default' type=kotlin.Int origin=null
|
||||
b: GET_VAR 'val b: kotlin.Int [val] declared in <root>.sumBasedOnPrevious$default' type=kotlin.Int origin=null
|
||||
c: GET_VAR 'val c: kotlin.Int [val] declared in <root>.sumBasedOnPrevious$default' type=kotlin.Int origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-sum1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:sum1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-sum1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:sum1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:sum1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=6
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-sum2> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:sum2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-sum2> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:sum2 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:sum2 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=1
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-sum3> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:sum3 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-sum3> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:sum3 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:sum3 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=3
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-sumBasedOnPrevious1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:sumBasedOnPrevious1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-sumBasedOnPrevious1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:sumBasedOnPrevious1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:sumBasedOnPrevious1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=7
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-sumBasedOnPrevious2> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:sumBasedOnPrevious2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-sumBasedOnPrevious2> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:sumBasedOnPrevious2 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:sumBasedOnPrevious2 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=3
|
||||
15
compiler/testData/ir/interpreter/defaultEquals.kt
vendored
Normal file
15
compiler/testData/ir/interpreter/defaultEquals.kt
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation
|
||||
class A
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun getTheSameValue(a: Any): Any = a
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun theSameObjectEquals(value: Any): Boolean {
|
||||
return value == getTheSameValue(value) && value === getTheSameValue(value)
|
||||
}
|
||||
|
||||
const val equals1 = A().equals(A())
|
||||
const val equals2 = theSameObjectEquals(A())
|
||||
63
compiler/testData/ir/interpreter/defaultEquals.txt
vendored
Normal file
63
compiler/testData/ir/interpreter/defaultEquals.txt
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
FILE fqName:<root> fileName:/defaultEquals.kt
|
||||
CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.A [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN name:getTheSameValue visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Any
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun getTheSameValue (a: kotlin.Any): kotlin.Any declared in <root>'
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.getTheSameValue' type=kotlin.Any origin=null
|
||||
FUN name:theSameObjectEquals visibility:public modality:FINAL <> (value:kotlin.Any) returnType:kotlin.Boolean
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:value index:0 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun theSameObjectEquals (value: kotlin.Any): kotlin.Boolean declared in <root>'
|
||||
WHEN type=kotlin.Boolean origin=ANDAND
|
||||
BRANCH
|
||||
if: CALL 'public final fun equals (obj1: dynamic, obj2: dynamic): kotlin.Boolean declared in kotlin.js' type=kotlin.Boolean origin=EQEQ
|
||||
obj1: GET_VAR 'value: kotlin.Any declared in <root>.theSameObjectEquals' type=kotlin.Any origin=null
|
||||
obj2: CALL 'public final fun getTheSameValue (a: kotlin.Any): kotlin.Any declared in <root>' type=kotlin.Any origin=null
|
||||
a: GET_VAR 'value: kotlin.Any declared in <root>.theSameObjectEquals' type=kotlin.Any origin=null
|
||||
then: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQEQ
|
||||
arg0: GET_VAR 'value: kotlin.Any declared in <root>.theSameObjectEquals' type=kotlin.Any origin=null
|
||||
arg1: CALL 'public final fun getTheSameValue (a: kotlin.Any): kotlin.Any declared in <root>' type=kotlin.Any origin=null
|
||||
a: GET_VAR 'value: kotlin.Any declared in <root>.theSameObjectEquals' type=kotlin.Any origin=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CONST Boolean type=kotlin.Boolean value=false
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-equals1> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:equals1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-equals1> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:equals1 type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:equals1 type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=false
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-equals2> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:equals2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-equals2> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:equals2 type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:equals2 type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
61
compiler/testData/ir/interpreter/defaultHashCode.kt
vendored
Normal file
61
compiler/testData/ir/interpreter/defaultHashCode.kt
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation
|
||||
open class A
|
||||
|
||||
class B @CompileTimeCalculation constructor() {
|
||||
@CompileTimeCalculation
|
||||
override fun hashCode(): Int {
|
||||
return super.hashCode()
|
||||
}
|
||||
}
|
||||
|
||||
class C
|
||||
|
||||
class D : A()
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun checkHashCodeCorrectness(value: Any): Boolean {
|
||||
val hashCode = value.hashCode()
|
||||
return hashCode.toHex().length == 8 && hashCode == value.hashCode()
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun getTheSameValue(a: Any): Any = a
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun theSameObjectHashCode(value: Any): Boolean {
|
||||
return value.hashCode() == getTheSameValue(value).hashCode()
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun Int.toHex(): String {
|
||||
val sb = StringBuilder()
|
||||
val hexDigits = charArrayOf(
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
|
||||
)
|
||||
var value = this
|
||||
|
||||
var i = 8
|
||||
while (i > 0) {
|
||||
i -= 1
|
||||
val j = value.and(0x0F)
|
||||
sb.append(hexDigits[j])
|
||||
value = value.shr(4)
|
||||
}
|
||||
|
||||
return sb.reverse().toString()
|
||||
}
|
||||
|
||||
const val aHashCode = checkHashCodeCorrectness(A())
|
||||
const val bHashCode = checkHashCodeCorrectness(B())
|
||||
val cHashCode = C().hashCode() // will not calculate
|
||||
val dHashCode = D().hashCode() // will not calculate
|
||||
|
||||
const val arrayHashCode = checkHashCodeCorrectness(arrayOf(A(), B()))
|
||||
const val intArrayHashCode = checkHashCodeCorrectness(arrayOf(1, 2, 3))
|
||||
|
||||
const val checkA = theSameObjectHashCode(A())
|
||||
const val checkStringBuilder1 = theSameObjectHashCode(StringBuilder())
|
||||
const val checkStringBuilder2 = theSameObjectHashCode(StringBuilder("Some Builder"))
|
||||
276
compiler/testData/ir/interpreter/defaultHashCode.txt
vendored
Normal file
276
compiler/testData/ir/interpreter/defaultHashCode.txt
vendored
Normal file
@@ -0,0 +1,276 @@
|
||||
FILE fqName:<root> fileName:/defaultHashCode.kt
|
||||
CLASS CLASS name:A modality:OPEN visibility:public superTypes:[kotlin.Any]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.A [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:B modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.B
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.B [primary]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
FUN name:hashCode visibility:public modality:OPEN <> ($this:<root>.B) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in <root>.B'
|
||||
CALL 'public final fun getObjectHashCode (obj: dynamic): kotlin.Int declared in kotlin.js' type=kotlin.Int origin=null
|
||||
obj: GET_VAR '<this>: <root>.B declared in <root>.B.hashCode' type=<root>.B origin=null
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.C [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:D modality:FINAL visibility:public superTypes:[<root>.A]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.D
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.D [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.A'
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.A
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.A
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.A
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN name:checkHashCodeCorrectness visibility:public modality:FINAL <> (value:kotlin.Any) returnType:kotlin.Boolean
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:value index:0 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
VAR name:hashCode type:kotlin.Int [val]
|
||||
CALL 'public final fun hashCode (obj: dynamic): kotlin.Int declared in kotlin.js' type=kotlin.Int origin=null
|
||||
obj: GET_VAR 'value: kotlin.Any declared in <root>.checkHashCodeCorrectness' type=kotlin.Any origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun checkHashCodeCorrectness (value: kotlin.Any): kotlin.Boolean declared in <root>'
|
||||
WHEN type=kotlin.Boolean origin=ANDAND
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: CALL 'public final fun jsArrayLength (arg0: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=GET_PROPERTY
|
||||
arg0: CALL 'public final fun toHex (): kotlin.String declared in <root>' type=kotlin.String origin=null
|
||||
$receiver: GET_VAR 'val hashCode: kotlin.Int [val] declared in <root>.checkHashCodeCorrectness' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=8
|
||||
then: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val hashCode: kotlin.Int [val] declared in <root>.checkHashCodeCorrectness' type=kotlin.Int origin=null
|
||||
arg1: CALL 'public final fun hashCode (obj: dynamic): kotlin.Int declared in kotlin.js' type=kotlin.Int origin=null
|
||||
obj: GET_VAR 'value: kotlin.Any declared in <root>.checkHashCodeCorrectness' type=kotlin.Any origin=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CONST Boolean type=kotlin.Boolean value=false
|
||||
FUN name:getTheSameValue visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Any
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun getTheSameValue (a: kotlin.Any): kotlin.Any declared in <root>'
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.getTheSameValue' type=kotlin.Any origin=null
|
||||
FUN name:theSameObjectHashCode visibility:public modality:FINAL <> (value:kotlin.Any) returnType:kotlin.Boolean
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:value index:0 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun theSameObjectHashCode (value: kotlin.Any): kotlin.Boolean declared in <root>'
|
||||
CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: CALL 'public final fun hashCode (obj: dynamic): kotlin.Int declared in kotlin.js' type=kotlin.Int origin=null
|
||||
obj: GET_VAR 'value: kotlin.Any declared in <root>.theSameObjectHashCode' type=kotlin.Any origin=null
|
||||
arg1: CALL 'public final fun hashCode (obj: dynamic): kotlin.Int declared in kotlin.js' type=kotlin.Int origin=null
|
||||
obj: CALL 'public final fun getTheSameValue (a: kotlin.Any): kotlin.Any declared in <root>' type=kotlin.Any origin=null
|
||||
a: GET_VAR 'value: kotlin.Any declared in <root>.theSameObjectHashCode' type=kotlin.Any origin=null
|
||||
FUN name:toHex visibility:public modality:FINAL <> ($receiver:kotlin.Int) returnType:kotlin.String
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$receiver: VALUE_PARAMETER name:<this> type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
VAR name:sb type:kotlin.text.StringBuilder [val]
|
||||
CALL 'public final fun StringBuilder_init_$Create$ (): kotlin.text.StringBuilder declared in kotlin.text.StringBuilder' type=kotlin.text.StringBuilder origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp0_charArrayOf_0 type:kotlin.CharArray [val]
|
||||
CALL 'internal final fun charArrayOf (arr: kotlin.Array<kotlin.Char>): kotlin.CharArray declared in kotlin.js' type=kotlin.CharArray origin=null
|
||||
arr: VARARG type=kotlin.CharArray varargElementType=kotlin.Char
|
||||
CONSTRUCTOR_CALL 'internal constructor <init> (value: kotlin.Int) [primary] declared in kotlin.Char' type=kotlin.Char origin=null
|
||||
value: CONST Int type=kotlin.Int value=48
|
||||
CONSTRUCTOR_CALL 'internal constructor <init> (value: kotlin.Int) [primary] declared in kotlin.Char' type=kotlin.Char origin=null
|
||||
value: CONST Int type=kotlin.Int value=49
|
||||
CONSTRUCTOR_CALL 'internal constructor <init> (value: kotlin.Int) [primary] declared in kotlin.Char' type=kotlin.Char origin=null
|
||||
value: CONST Int type=kotlin.Int value=50
|
||||
CONSTRUCTOR_CALL 'internal constructor <init> (value: kotlin.Int) [primary] declared in kotlin.Char' type=kotlin.Char origin=null
|
||||
value: CONST Int type=kotlin.Int value=51
|
||||
CONSTRUCTOR_CALL 'internal constructor <init> (value: kotlin.Int) [primary] declared in kotlin.Char' type=kotlin.Char origin=null
|
||||
value: CONST Int type=kotlin.Int value=52
|
||||
CONSTRUCTOR_CALL 'internal constructor <init> (value: kotlin.Int) [primary] declared in kotlin.Char' type=kotlin.Char origin=null
|
||||
value: CONST Int type=kotlin.Int value=53
|
||||
CONSTRUCTOR_CALL 'internal constructor <init> (value: kotlin.Int) [primary] declared in kotlin.Char' type=kotlin.Char origin=null
|
||||
value: CONST Int type=kotlin.Int value=54
|
||||
CONSTRUCTOR_CALL 'internal constructor <init> (value: kotlin.Int) [primary] declared in kotlin.Char' type=kotlin.Char origin=null
|
||||
value: CONST Int type=kotlin.Int value=55
|
||||
CONSTRUCTOR_CALL 'internal constructor <init> (value: kotlin.Int) [primary] declared in kotlin.Char' type=kotlin.Char origin=null
|
||||
value: CONST Int type=kotlin.Int value=56
|
||||
CONSTRUCTOR_CALL 'internal constructor <init> (value: kotlin.Int) [primary] declared in kotlin.Char' type=kotlin.Char origin=null
|
||||
value: CONST Int type=kotlin.Int value=57
|
||||
CONSTRUCTOR_CALL 'internal constructor <init> (value: kotlin.Int) [primary] declared in kotlin.Char' type=kotlin.Char origin=null
|
||||
value: CONST Int type=kotlin.Int value=65
|
||||
CONSTRUCTOR_CALL 'internal constructor <init> (value: kotlin.Int) [primary] declared in kotlin.Char' type=kotlin.Char origin=null
|
||||
value: CONST Int type=kotlin.Int value=66
|
||||
CONSTRUCTOR_CALL 'internal constructor <init> (value: kotlin.Int) [primary] declared in kotlin.Char' type=kotlin.Char origin=null
|
||||
value: CONST Int type=kotlin.Int value=67
|
||||
CONSTRUCTOR_CALL 'internal constructor <init> (value: kotlin.Int) [primary] declared in kotlin.Char' type=kotlin.Char origin=null
|
||||
value: CONST Int type=kotlin.Int value=68
|
||||
CONSTRUCTOR_CALL 'internal constructor <init> (value: kotlin.Int) [primary] declared in kotlin.Char' type=kotlin.Char origin=null
|
||||
value: CONST Int type=kotlin.Int value=69
|
||||
CONSTRUCTOR_CALL 'internal constructor <init> (value: kotlin.Int) [primary] declared in kotlin.Char' type=kotlin.Char origin=null
|
||||
value: CONST Int type=kotlin.Int value=70
|
||||
VAR name:hexDigits type:kotlin.CharArray [val]
|
||||
GET_VAR 'val tmp0_charArrayOf_0: kotlin.CharArray [val] declared in <root>.toHex' type=kotlin.CharArray origin=null
|
||||
VAR name:value type:kotlin.Int [var]
|
||||
GET_VAR '<this>: kotlin.Int declared in <root>.toHex' type=kotlin.Int origin=null
|
||||
VAR name:i type:kotlin.Int [var]
|
||||
CONST Int type=kotlin.Int value=8
|
||||
WHILE label=null origin=WHILE_LOOP
|
||||
condition: CALL 'public final fun jsGt (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT
|
||||
arg0: GET_VAR 'var i: kotlin.Int [var] declared in <root>.toHex' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
body: BLOCK type=kotlin.Unit origin=null
|
||||
SET_VAR 'var i: kotlin.Int [var] declared in <root>.toHex' type=kotlin.Unit origin=MINUSEQ
|
||||
CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsMinus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=MINUSEQ
|
||||
arg0: GET_VAR 'var i: kotlin.Int [var] declared in <root>.toHex' type=kotlin.Int origin=MINUSEQ
|
||||
arg1: CONST Int type=kotlin.Int value=1
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
VAR name:j type:kotlin.Int [val]
|
||||
CALL 'public final fun jsBitAnd (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=null
|
||||
arg0: GET_VAR 'var value: kotlin.Int [var] declared in <root>.toHex' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=15
|
||||
CALL 'public open fun append (value: kotlin.Char): kotlin.text.StringBuilder declared in kotlin.text.StringBuilder' type=kotlin.text.StringBuilder origin=null
|
||||
$this: GET_VAR 'val sb: kotlin.text.StringBuilder [val] declared in <root>.toHex' type=kotlin.text.StringBuilder origin=null
|
||||
value: CALL 'public final fun jsArrayGet (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Char origin=GET_ARRAY_ELEMENT
|
||||
arg0: GET_VAR 'val hexDigits: kotlin.CharArray [val] declared in <root>.toHex' type=kotlin.CharArray origin=null
|
||||
arg1: GET_VAR 'val j: kotlin.Int [val] declared in <root>.toHex' type=kotlin.Int origin=null
|
||||
CALL 'public final fun Unit_getInstance (): kotlin.Unit declared in kotlin' type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
SET_VAR 'var value: kotlin.Int [var] declared in <root>.toHex' type=kotlin.Unit origin=EQ
|
||||
CALL 'public final fun jsBitShiftR (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=null
|
||||
arg0: GET_VAR 'var value: kotlin.Int [var] declared in <root>.toHex' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=4
|
||||
RETURN type=kotlin.Nothing from='public final fun toHex (): kotlin.String declared in <root>'
|
||||
CALL 'public open fun toString (): kotlin.String declared in kotlin.text.StringBuilder' type=kotlin.String origin=null
|
||||
$this: CALL 'public final fun reverse (): kotlin.text.StringBuilder declared in kotlin.text.StringBuilder' type=kotlin.text.StringBuilder origin=null
|
||||
$this: GET_VAR 'val sb: kotlin.text.StringBuilder [val] declared in <root>.toHex' type=kotlin.text.StringBuilder origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-aHashCode> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:aHashCode visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-aHashCode> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:aHashCode type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:aHashCode type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-bHashCode> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:bHashCode visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-bHashCode> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:bHashCode type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:bHashCode type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-cHashCode> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:cHashCode visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-cHashCode> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:cHashCode type:kotlin.Int visibility:private [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:cHashCode type:kotlin.Int visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
CALL 'public final fun hashCode (obj: dynamic): kotlin.Int declared in kotlin.js' type=kotlin.Int origin=null
|
||||
obj: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.C' type=<root>.C origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-dHashCode> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:dHashCode visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-dHashCode> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:dHashCode type:kotlin.Int visibility:private [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:dHashCode type:kotlin.Int visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
CALL 'public final fun hashCode (obj: dynamic): kotlin.Int declared in kotlin.js' type=kotlin.Int origin=null
|
||||
obj: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.D' type=<root>.D origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-arrayHashCode> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:arrayHashCode visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-arrayHashCode> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:arrayHashCode type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:arrayHashCode type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-intArrayHashCode> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:intArrayHashCode visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-intArrayHashCode> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:intArrayHashCode type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:intArrayHashCode type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-checkA> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:checkA visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-checkA> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:checkA type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:checkA type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-checkStringBuilder1> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:checkStringBuilder1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-checkStringBuilder1> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:checkStringBuilder1 type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:checkStringBuilder1 type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-checkStringBuilder2> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:checkStringBuilder2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-checkStringBuilder2> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:checkStringBuilder2 type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:checkStringBuilder2 type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
41
compiler/testData/ir/interpreter/defaultToString.kt
vendored
Normal file
41
compiler/testData/ir/interpreter/defaultToString.kt
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation
|
||||
open class A
|
||||
|
||||
class B @CompileTimeCalculation constructor() {
|
||||
@CompileTimeCalculation
|
||||
override fun toString(): String {
|
||||
return super.toString()
|
||||
}
|
||||
}
|
||||
|
||||
class C
|
||||
|
||||
class D : A()
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun checkToStringCorrectness(value: Any, startStr: String): Boolean {
|
||||
val string = value.toString()
|
||||
return string.subSequence(0, startStr.length) == startStr && string.get(startStr.length) == '@' && string.length == startStr.length + 9
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun getTheSameValue(a: Any): Any = a
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun theSameObjectToString(value: Any): Boolean {
|
||||
return value.toString() == getTheSameValue(value).toString()
|
||||
}
|
||||
|
||||
const val aString = checkToStringCorrectness(A(), "A")
|
||||
const val bString = checkToStringCorrectness(B(), "B")
|
||||
val cString = C().toString() // will not calculate
|
||||
val dString = D().toString() // will not calculate
|
||||
|
||||
const val arrayString = checkToStringCorrectness(arrayOf(A(), B()).toString(), "[Ljava.lang.Object;")
|
||||
const val intArrayString = checkToStringCorrectness(intArrayOf(1, 2, 3).toString(), "[I")
|
||||
|
||||
const val checkA = theSameObjectToString(A())
|
||||
const val checkStringBuilder1 = theSameObjectToString(StringBuilder())
|
||||
const val checkStringBuilder2 = theSameObjectToString(StringBuilder("Some Builder"))
|
||||
219
compiler/testData/ir/interpreter/defaultToString.txt
vendored
Normal file
219
compiler/testData/ir/interpreter/defaultToString.txt
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
FILE fqName:<root> fileName:/defaultToString.kt
|
||||
CLASS CLASS name:A modality:OPEN visibility:public superTypes:[kotlin.Any]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.A [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:B modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.B
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.B [primary]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
FUN name:toString visibility:public modality:OPEN <> ($this:<root>.B) returnType:kotlin.String
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun toString (): kotlin.String declared in <root>.B'
|
||||
CALL 'public final fun anyToString (o: dynamic): kotlin.String declared in kotlin.js' type=kotlin.String origin=null
|
||||
o: GET_VAR '<this>: <root>.B declared in <root>.B.toString' type=<root>.B origin=null
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.C [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:D modality:FINAL visibility:public superTypes:[<root>.A]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.D
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.D [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.A'
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.A
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.A
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.A
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN name:checkToStringCorrectness visibility:public modality:FINAL <> (value:kotlin.Any, startStr:kotlin.String) returnType:kotlin.Boolean
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:value index:0 type:kotlin.Any
|
||||
VALUE_PARAMETER name:startStr index:1 type:kotlin.String
|
||||
BLOCK_BODY
|
||||
VAR name:string type:kotlin.String [val]
|
||||
CALL 'public final fun toString (o: dynamic): kotlin.String declared in kotlin.js' type=kotlin.String origin=null
|
||||
o: GET_VAR 'value: kotlin.Any declared in <root>.checkToStringCorrectness' type=kotlin.Any origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun checkToStringCorrectness (value: kotlin.Any, startStr: kotlin.String): kotlin.Boolean declared in <root>'
|
||||
WHEN type=kotlin.Boolean origin=ANDAND
|
||||
BRANCH
|
||||
if: WHEN type=kotlin.Boolean origin=ANDAND
|
||||
BRANCH
|
||||
if: CALL 'public final fun equals (obj1: dynamic, obj2: dynamic): kotlin.Boolean declared in kotlin.js' type=kotlin.Boolean origin=EQEQ
|
||||
obj1: CALL 'internal final fun charSequenceSubSequence (a: kotlin.CharSequence, startIndex: kotlin.Int, endIndex: kotlin.Int): kotlin.CharSequence declared in kotlin.js' type=kotlin.CharSequence origin=null
|
||||
a: GET_VAR 'val string: kotlin.String [val] declared in <root>.checkToStringCorrectness' type=kotlin.String origin=null
|
||||
startIndex: CONST Int type=kotlin.Int value=0
|
||||
endIndex: CALL 'public final fun jsArrayLength (arg0: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=GET_PROPERTY
|
||||
arg0: GET_VAR 'startStr: kotlin.String declared in <root>.checkToStringCorrectness' type=kotlin.String origin=null
|
||||
obj2: GET_VAR 'startStr: kotlin.String declared in <root>.checkToStringCorrectness' type=kotlin.String origin=null
|
||||
then: CALL 'public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Char' type=kotlin.Boolean origin=EQEQ
|
||||
$this: CALL 'internal final fun charSequenceGet (a: kotlin.CharSequence, index: kotlin.Int): kotlin.Char declared in kotlin.js' type=kotlin.Char origin=null
|
||||
a: GET_VAR 'val string: kotlin.String [val] declared in <root>.checkToStringCorrectness' type=kotlin.String origin=null
|
||||
index: CALL 'public final fun jsArrayLength (arg0: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=GET_PROPERTY
|
||||
arg0: GET_VAR 'startStr: kotlin.String declared in <root>.checkToStringCorrectness' type=kotlin.String origin=null
|
||||
other: CONSTRUCTOR_CALL 'internal constructor <init> (value: kotlin.Int) [primary] declared in kotlin.Char' type=kotlin.Char origin=null
|
||||
value: CONST Int type=kotlin.Int value=64
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CONST Boolean type=kotlin.Boolean value=false
|
||||
then: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: CALL 'public final fun jsArrayLength (arg0: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=GET_PROPERTY
|
||||
arg0: GET_VAR 'val string: kotlin.String [val] declared in <root>.checkToStringCorrectness' type=kotlin.String origin=null
|
||||
arg1: CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=PLUS
|
||||
arg0: CALL 'public final fun jsArrayLength (arg0: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=GET_PROPERTY
|
||||
arg0: GET_VAR 'startStr: kotlin.String declared in <root>.checkToStringCorrectness' type=kotlin.String origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=9
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CONST Boolean type=kotlin.Boolean value=false
|
||||
FUN name:getTheSameValue visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Any
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun getTheSameValue (a: kotlin.Any): kotlin.Any declared in <root>'
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.getTheSameValue' type=kotlin.Any origin=null
|
||||
FUN name:theSameObjectToString visibility:public modality:FINAL <> (value:kotlin.Any) returnType:kotlin.Boolean
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:value index:0 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun theSameObjectToString (value: kotlin.Any): kotlin.Boolean declared in <root>'
|
||||
CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: CALL 'public final fun toString (o: dynamic): kotlin.String declared in kotlin.js' type=kotlin.String origin=null
|
||||
o: GET_VAR 'value: kotlin.Any declared in <root>.theSameObjectToString' type=kotlin.Any origin=null
|
||||
arg1: CALL 'public final fun toString (o: dynamic): kotlin.String declared in kotlin.js' type=kotlin.String origin=null
|
||||
o: CALL 'public final fun getTheSameValue (a: kotlin.Any): kotlin.Any declared in <root>' type=kotlin.Any origin=null
|
||||
a: GET_VAR 'value: kotlin.Any declared in <root>.theSameObjectToString' type=kotlin.Any origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-aString> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:aString visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-aString> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:aString type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:aString type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-bString> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:bString visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-bString> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:bString type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:bString type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-cString> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:cString visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-cString> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:cString type:kotlin.String visibility:private [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:cString type:kotlin.String visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
CALL 'public final fun toString (o: dynamic): kotlin.String declared in kotlin.js' type=kotlin.String origin=null
|
||||
o: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.C' type=<root>.C origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-dString> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:dString visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-dString> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:dString type:kotlin.String visibility:private [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:dString type:kotlin.String visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
CALL 'public final fun toString (o: dynamic): kotlin.String declared in kotlin.js' type=kotlin.String origin=null
|
||||
o: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.D' type=<root>.D origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-arrayString> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:arrayString visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-arrayString> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:arrayString type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:arrayString type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-intArrayString> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:intArrayString visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-intArrayString> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:intArrayString type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:intArrayString type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-checkA> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:checkA visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-checkA> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:checkA type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:checkA type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-checkStringBuilder1> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:checkStringBuilder1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-checkStringBuilder1> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:checkStringBuilder1 type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:checkStringBuilder1 type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-checkStringBuilder2> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:checkStringBuilder2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-checkStringBuilder2> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:checkStringBuilder2 type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:checkStringBuilder2 type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
36
compiler/testData/ir/interpreter/doWhileLoop.kt
vendored
Normal file
36
compiler/testData/ir/interpreter/doWhileLoop.kt
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun factorialDoWhile(num: Int): Int {
|
||||
var number = num
|
||||
var factorial = 1
|
||||
|
||||
do {
|
||||
factorial *= number
|
||||
number--
|
||||
} while (number > 0)
|
||||
|
||||
return factorial
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun firstNotNull(array: Array<Int?>): Int {
|
||||
var i = 0
|
||||
|
||||
do {
|
||||
val y = array[i++]
|
||||
} while (y == null)
|
||||
|
||||
return array[i - 1]!!
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun singleExpressionLoop(incrementTo: Int): Int {
|
||||
var i = 0
|
||||
do i++ while (i < incrementTo)
|
||||
return i
|
||||
}
|
||||
|
||||
const val a = factorialDoWhile(6)
|
||||
const val b = firstNotNull(arrayOf<Int?>(null, null, 1, 2, null))
|
||||
const val c = singleExpressionLoop(10)
|
||||
111
compiler/testData/ir/interpreter/doWhileLoop.txt
vendored
Normal file
111
compiler/testData/ir/interpreter/doWhileLoop.txt
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
FILE fqName:<root> fileName:/doWhileLoop.kt
|
||||
FUN name:factorialDoWhile visibility:public modality:FINAL <> (num:kotlin.Int) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:num index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
VAR name:number type:kotlin.Int [var]
|
||||
GET_VAR 'num: kotlin.Int declared in <root>.factorialDoWhile' type=kotlin.Int origin=null
|
||||
VAR name:factorial type:kotlin.Int [var]
|
||||
CONST Int type=kotlin.Int value=1
|
||||
DO_WHILE label=null origin=DO_WHILE_LOOP
|
||||
body: COMPOSITE type=kotlin.Unit origin=null
|
||||
SET_VAR 'var factorial: kotlin.Int [var] declared in <root>.factorialDoWhile' type=kotlin.Unit origin=MULTEQ
|
||||
CALL 'internal final fun imul (a_local: kotlin.Int, b_local: kotlin.Int): kotlin.Int declared in kotlin.js' type=kotlin.Int origin=MULTEQ
|
||||
a_local: GET_VAR 'var factorial: kotlin.Int [var] declared in <root>.factorialDoWhile' type=kotlin.Int origin=MULTEQ
|
||||
b_local: GET_VAR 'var number: kotlin.Int [var] declared in <root>.factorialDoWhile' type=kotlin.Int origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp0 type:kotlin.Int [val]
|
||||
GET_VAR 'var number: kotlin.Int [var] declared in <root>.factorialDoWhile' type=kotlin.Int origin=POSTFIX_DECR
|
||||
SET_VAR 'var number: kotlin.Int [var] declared in <root>.factorialDoWhile' type=kotlin.Unit origin=POSTFIX_DECR
|
||||
CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsMinus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=POSTFIX_DECR
|
||||
arg0: GET_VAR 'val tmp0: kotlin.Int [val] declared in <root>.factorialDoWhile' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=1
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
CALL 'public final fun Unit_getInstance (): kotlin.Unit declared in kotlin' type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
condition: CALL 'public final fun jsGt (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT
|
||||
arg0: GET_VAR 'var number: kotlin.Int [var] declared in <root>.factorialDoWhile' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
RETURN type=kotlin.Nothing from='public final fun factorialDoWhile (num: kotlin.Int): kotlin.Int declared in <root>'
|
||||
GET_VAR 'var factorial: kotlin.Int [var] declared in <root>.factorialDoWhile' type=kotlin.Int origin=null
|
||||
FUN name:firstNotNull visibility:public modality:FINAL <> (array:kotlin.Array<kotlin.Int?>) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:array index:0 type:kotlin.Array<kotlin.Int?>
|
||||
BLOCK_BODY
|
||||
VAR name:i type:kotlin.Int [var]
|
||||
CONST Int type=kotlin.Int value=0
|
||||
DO_WHILE label=null origin=DO_WHILE_LOOP
|
||||
body: COMPOSITE type=kotlin.Unit origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp0 type:kotlin.Int [val]
|
||||
GET_VAR 'var i: kotlin.Int [var] declared in <root>.firstNotNull' type=kotlin.Int origin=POSTFIX_INCR
|
||||
SET_VAR 'var i: kotlin.Int [var] declared in <root>.firstNotNull' type=kotlin.Unit origin=POSTFIX_INCR
|
||||
CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=POSTFIX_INCR
|
||||
arg0: GET_VAR 'val tmp0: kotlin.Int [val] declared in <root>.firstNotNull' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=1
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
VAR name:y type:kotlin.Int? [val]
|
||||
CALL 'public final fun jsArrayGet (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int? origin=GET_ARRAY_ELEMENT
|
||||
arg0: GET_VAR 'array: kotlin.Array<kotlin.Int?> declared in <root>.firstNotNull' type=kotlin.Array<kotlin.Int?> origin=null
|
||||
arg1: GET_VAR 'val tmp0: kotlin.Int [val] declared in <root>.firstNotNull' type=kotlin.Int origin=null
|
||||
condition: CALL 'public final fun jsEqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val y: kotlin.Int? [val] declared in <root>.firstNotNull' type=kotlin.Int? origin=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value=null
|
||||
RETURN type=kotlin.Nothing from='public final fun firstNotNull (array: kotlin.Array<kotlin.Int?>): kotlin.Int declared in <root>'
|
||||
CALL 'public final fun ensureNotNull <T> (v: T of kotlin.ensureNotNull?): T of kotlin.ensureNotNull declared in kotlin' type=kotlin.Int origin=EXCLEXCL
|
||||
<T>: kotlin.Int
|
||||
v: CALL 'public final fun jsArrayGet (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int? origin=GET_ARRAY_ELEMENT
|
||||
arg0: GET_VAR 'array: kotlin.Array<kotlin.Int?> declared in <root>.firstNotNull' type=kotlin.Array<kotlin.Int?> origin=null
|
||||
arg1: CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsMinus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=MINUS
|
||||
arg0: GET_VAR 'var i: kotlin.Int [var] declared in <root>.firstNotNull' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=1
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
FUN name:singleExpressionLoop visibility:public modality:FINAL <> (incrementTo:kotlin.Int) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:incrementTo index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
VAR name:i type:kotlin.Int [var]
|
||||
CONST Int type=kotlin.Int value=0
|
||||
DO_WHILE label=null origin=DO_WHILE_LOOP
|
||||
body: COMPOSITE type=kotlin.Unit origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp0 type:kotlin.Int [val]
|
||||
GET_VAR 'var i: kotlin.Int [var] declared in <root>.singleExpressionLoop' type=kotlin.Int origin=POSTFIX_INCR
|
||||
SET_VAR 'var i: kotlin.Int [var] declared in <root>.singleExpressionLoop' type=kotlin.Unit origin=POSTFIX_INCR
|
||||
CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=POSTFIX_INCR
|
||||
arg0: GET_VAR 'val tmp0: kotlin.Int [val] declared in <root>.singleExpressionLoop' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=1
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
CALL 'public final fun Unit_getInstance (): kotlin.Unit declared in kotlin' type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
condition: CALL 'public final fun jsLt (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT
|
||||
arg0: GET_VAR 'var i: kotlin.Int [var] declared in <root>.singleExpressionLoop' type=kotlin.Int origin=null
|
||||
arg1: GET_VAR 'incrementTo: kotlin.Int declared in <root>.singleExpressionLoop' type=kotlin.Int origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun singleExpressionLoop (incrementTo: kotlin.Int): kotlin.Int declared in <root>'
|
||||
GET_VAR 'var i: kotlin.Int [var] declared in <root>.singleExpressionLoop' type=kotlin.Int origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=720
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:b visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=1
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=10
|
||||
7
compiler/testData/ir/interpreter/elvis.kt
vendored
Normal file
7
compiler/testData/ir/interpreter/elvis.kt
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun getLenght(value: String?): Int = value?.length ?: -1
|
||||
|
||||
const val a1 = getLenght("Elvis")
|
||||
const val a2 = getLenght(null)
|
||||
45
compiler/testData/ir/interpreter/elvis.txt
vendored
Normal file
45
compiler/testData/ir/interpreter/elvis.txt
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
FILE fqName:<root> fileName:/elvis.kt
|
||||
FUN name:getLenght visibility:public modality:FINAL <> (value:kotlin.String?) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:value index:0 type:kotlin.String?
|
||||
BLOCK_BODY
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp0_safe_receiver type:kotlin.String? [val]
|
||||
GET_VAR 'value: kotlin.String? declared in <root>.getLenght' type=kotlin.String? origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp1_elvis_lhs type:kotlin.Int? [val]
|
||||
WHEN type=kotlin.Int? origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp0_safe_receiver: kotlin.String? [val] declared in <root>.getLenght' type=kotlin.String? origin=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value=null
|
||||
then: CONST Null type=kotlin.Nothing? value=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CALL 'public final fun jsArrayLength (arg0: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=GET_PROPERTY
|
||||
arg0: GET_VAR 'val tmp0_safe_receiver: kotlin.String? [val] declared in <root>.getLenght' type=kotlin.String? origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun getLenght (value: kotlin.String?): kotlin.Int declared in <root>'
|
||||
WHEN type=kotlin.Int origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp1_elvis_lhs: kotlin.Int? [val] declared in <root>.getLenght' type=kotlin.Int? origin=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value=null
|
||||
then: CONST Int type=kotlin.Int value=-1
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: GET_VAR 'val tmp1_elvis_lhs: kotlin.Int? [val] declared in <root>.getLenght' type=kotlin.Int? origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:a1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=5
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a2> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:a2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a2> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a2 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a2 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=-1
|
||||
19
compiler/testData/ir/interpreter/enums1.kt
vendored
Normal file
19
compiler/testData/ir/interpreter/enums1.kt
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation
|
||||
enum class EnumClass {
|
||||
VALUE1, VALUE2
|
||||
}
|
||||
|
||||
const val a = EnumClass.VALUE1.name
|
||||
const val b = EnumClass.values().size
|
||||
const val c = EnumClass.valueOf("VALUE1").ordinal
|
||||
const val d = EnumClass.valueOf("VALUE3").ordinal
|
||||
|
||||
const val e1 = EnumClass.VALUE1.hashCode().let { it is Int && it > 0 && it == EnumClass.VALUE1.hashCode() }
|
||||
const val e2 = EnumClass.VALUE1.toString()
|
||||
const val e3 = EnumClass.VALUE1 == EnumClass.VALUE1
|
||||
const val e4 = EnumClass.VALUE1 == EnumClass.VALUE2
|
||||
|
||||
const val f1 = enumValues<EnumClass>().size
|
||||
const val f2 = enumValueOf<EnumClass>("VALUE1").name
|
||||
181
compiler/testData/ir/interpreter/enums1.txt
vendored
Normal file
181
compiler/testData/ir/interpreter/enums1.txt
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
FILE fqName:<root> fileName:/enums1.kt
|
||||
CLASS ENUM_CLASS name:EnumClass modality:FINAL visibility:public superTypes:[kotlin.Enum<<root>.EnumClass>]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.EnumClass
|
||||
CONSTRUCTOR visibility:private <> (name:kotlin.String, ordinal:kotlin.Int) returnType:<root>.EnumClass [primary]
|
||||
VALUE_PARAMETER SYNTHESIZED_DECLARATION name:name index:0 type:kotlin.String
|
||||
VALUE_PARAMETER SYNTHESIZED_DECLARATION name:ordinal index:1 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum'
|
||||
<E>: <none>
|
||||
name: GET_VAR 'name: kotlin.String declared in <root>.EnumClass.<init>' type=kotlin.String origin=null
|
||||
ordinal: GET_VAR 'ordinal: kotlin.Int declared in <root>.EnumClass.<init>' type=kotlin.Int origin=null
|
||||
FIELD name:EnumClass_VALUE1_instance type:<root>.EnumClass? visibility:public [static]
|
||||
FIELD name:EnumClass_VALUE2_instance type:<root>.EnumClass? visibility:public [static]
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.EnumClass>) returnType:kotlin.Int [fake_override]
|
||||
annotations:
|
||||
EvaluateIntrinsic(file = '')
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.EnumClass>
|
||||
FUN FAKE_OVERRIDE name:<get-name> visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.EnumClass>) returnType:kotlin.String [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-name> (): kotlin.String declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.EnumClass>
|
||||
FUN FAKE_OVERRIDE name:<get-ordinal> visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.EnumClass>) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-ordinal> (): kotlin.Int declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.EnumClass>
|
||||
FUN FAKE_OVERRIDE name:compareTo visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.EnumClass>, other:<root>.EnumClass) returnType:kotlin.Int [fake_override,operator]
|
||||
overridden:
|
||||
public open fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.EnumClass>
|
||||
VALUE_PARAMETER name:other index:0 type:<root>.EnumClass
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.EnumClass>, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.EnumClass>
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.EnumClass>) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.EnumClass>
|
||||
FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:kotlin.Array<<root>.EnumClass>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun values (): kotlin.Array<<root>.EnumClass> declared in <root>.EnumClass'
|
||||
CALL 'public final fun arrayLiteral (arg0: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Array<<root>.EnumClass> origin=null
|
||||
arg0: CALL 'public final fun arrayLiteral (arg0: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Array<<root>.EnumClass> origin=null
|
||||
arg0: VARARG type=kotlin.Array<<root>.EnumClass> varargElementType=<root>.EnumClass
|
||||
CALL 'public final fun EnumClass_VALUE1_getInstance (): <root>.EnumClass declared in <root>' type=<root>.EnumClass origin=null
|
||||
CALL 'public final fun EnumClass_VALUE2_getInstance (): <root>.EnumClass declared in <root>' type=<root>.EnumClass origin=null
|
||||
FUN ENUM_CLASS_SPECIAL_MEMBER name:valueOf visibility:public modality:FINAL <> (value:kotlin.String) returnType:<root>.EnumClass
|
||||
VALUE_PARAMETER name:value index:0 type:kotlin.String
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun valueOf (value: kotlin.String): <root>.EnumClass declared in <root>.EnumClass'
|
||||
WHEN type=<root>.EnumClass origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: CONST String type=kotlin.String value="VALUE1"
|
||||
arg1: GET_VAR 'value: kotlin.String declared in <root>.EnumClass.valueOf' type=kotlin.String origin=null
|
||||
then: CALL 'public final fun EnumClass_VALUE1_getInstance (): <root>.EnumClass declared in <root>' type=<root>.EnumClass origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: CONST String type=kotlin.String value="VALUE2"
|
||||
arg1: GET_VAR 'value: kotlin.String declared in <root>.EnumClass.valueOf' type=kotlin.String origin=null
|
||||
then: CALL 'public final fun EnumClass_VALUE2_getInstance (): <root>.EnumClass declared in <root>' type=<root>.EnumClass origin=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CALL 'public final fun THROW_ISE (): kotlin.Nothing declared in kotlin' type=kotlin.Nothing origin=null
|
||||
FIELD name:EnumClass_entriesInitialized type:kotlin.Boolean visibility:public [static]
|
||||
FUN SYNTHESIZED_DECLARATION name:EnumClass_initEntries visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
WHEN type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: GET_FIELD 'FIELD name:EnumClass_entriesInitialized type:kotlin.Boolean visibility:public [static]' type=kotlin.Boolean origin=null
|
||||
then: RETURN type=kotlin.Nothing from='public final fun EnumClass_initEntries (): kotlin.Unit declared in <root>.EnumClass'
|
||||
CALL 'public final fun Unit_getInstance (): kotlin.Unit declared in kotlin' type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
SET_FIELD 'FIELD name:EnumClass_entriesInitialized type:kotlin.Boolean visibility:public [static]' type=kotlin.Unit origin=null
|
||||
value: CONST Boolean type=kotlin.Boolean value=true
|
||||
SET_FIELD 'FIELD name:EnumClass_VALUE1_instance type:<root>.EnumClass? visibility:public [static]' type=kotlin.Unit origin=null
|
||||
value: CONSTRUCTOR_CALL 'private constructor <init> (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in <root>.EnumClass' type=<root>.EnumClass origin=null
|
||||
name: CONST String type=kotlin.String value="VALUE1"
|
||||
ordinal: CONST Int type=kotlin.Int value=0
|
||||
SET_FIELD 'FIELD name:EnumClass_VALUE2_instance type:<root>.EnumClass? visibility:public [static]' type=kotlin.Unit origin=null
|
||||
value: CONSTRUCTOR_CALL 'private constructor <init> (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in <root>.EnumClass' type=<root>.EnumClass origin=null
|
||||
name: CONST String type=kotlin.String value="VALUE2"
|
||||
ordinal: CONST Int type=kotlin.Int value=1
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="VALUE1"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:b visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=2
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=0
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-d> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:d visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-d> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:d type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:d type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
ERROR_EXPR '
|
||||
Exception kotlin.IllegalArgumentException: No enum constant EnumClass.VALUE3
|
||||
at Enums1Kt.EnumClass.valueOf(enums1.kt:3)' type=kotlin.Int
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-e1> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:e1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-e1> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:e1 type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:e1 type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-e2> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:e2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-e2> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:e2 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:e2 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="VALUE1"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-e3> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:e3 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-e3> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:e3 type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:e3 type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-e4> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:e4 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-e4> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:e4 type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:e4 type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=false
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-f1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:f1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-f1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:f1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:f1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=2
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-f2> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:f2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-f2> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:f2 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:f2 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="VALUE1"
|
||||
FUN SYNTHESIZED_DECLARATION name:EnumClass_VALUE1_getInstance visibility:public modality:FINAL <> () returnType:<root>.EnumClass
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun EnumClass_initEntries (): kotlin.Unit declared in <root>.EnumClass' type=kotlin.Unit origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun EnumClass_VALUE1_getInstance (): <root>.EnumClass declared in <root>'
|
||||
GET_FIELD 'FIELD name:EnumClass_VALUE1_instance type:<root>.EnumClass? visibility:public [static]' type=<root>.EnumClass? origin=null
|
||||
FUN SYNTHESIZED_DECLARATION name:EnumClass_VALUE2_getInstance visibility:public modality:FINAL <> () returnType:<root>.EnumClass
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun EnumClass_initEntries (): kotlin.Unit declared in <root>.EnumClass' type=kotlin.Unit origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun EnumClass_VALUE2_getInstance (): <root>.EnumClass declared in <root>'
|
||||
GET_FIELD 'FIELD name:EnumClass_VALUE2_instance type:<root>.EnumClass? visibility:public [static]' type=<root>.EnumClass? origin=null
|
||||
28
compiler/testData/ir/interpreter/enums2.kt
vendored
Normal file
28
compiler/testData/ir/interpreter/enums2.kt
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation
|
||||
enum class Empty
|
||||
|
||||
@CompileTimeCalculation
|
||||
enum class Color(val rgb: Int) {
|
||||
BLACK() { override fun getColorAsString() = "0x000000" },
|
||||
RED(0xFF0000) { override fun getColorAsString() = "0xFF0000" },
|
||||
GREEN(0x00FF00) { override fun getColorAsString() = "0x00FF00" },
|
||||
BLUE(0x0000FF) { override fun getColorAsString() = "0x0000FF" };
|
||||
|
||||
constructor() : this(0x000000) {}
|
||||
|
||||
abstract fun getColorAsString(): String
|
||||
|
||||
fun getColorAsInt(): Int = rgb
|
||||
}
|
||||
|
||||
const val a1 = Empty.values().size
|
||||
const val a2 = enumValues<Empty>().size
|
||||
|
||||
const val b1 = Color.BLACK.name
|
||||
const val b2 = Color.BLACK.getColorAsString()
|
||||
const val b3 = Color.RED.getColorAsString()
|
||||
|
||||
const val c1 = Color.BLACK.getColorAsInt()
|
||||
const val c2 = Color.RED.getColorAsInt()
|
||||
514
compiler/testData/ir/interpreter/enums2.txt
vendored
Normal file
514
compiler/testData/ir/interpreter/enums2.txt
vendored
Normal file
@@ -0,0 +1,514 @@
|
||||
FILE fqName:<root> fileName:/enums2.kt
|
||||
CLASS ENUM_CLASS name:Empty modality:FINAL visibility:public superTypes:[kotlin.Enum<<root>.Empty>]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Empty
|
||||
CONSTRUCTOR visibility:private <> (name:kotlin.String, ordinal:kotlin.Int) returnType:<root>.Empty [primary]
|
||||
VALUE_PARAMETER SYNTHESIZED_DECLARATION name:name index:0 type:kotlin.String
|
||||
VALUE_PARAMETER SYNTHESIZED_DECLARATION name:ordinal index:1 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum'
|
||||
<E>: <none>
|
||||
name: GET_VAR 'name: kotlin.String declared in <root>.Empty.<init>' type=kotlin.String origin=null
|
||||
ordinal: GET_VAR 'ordinal: kotlin.Int declared in <root>.Empty.<init>' type=kotlin.Int origin=null
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Empty>) returnType:kotlin.Int [fake_override]
|
||||
annotations:
|
||||
EvaluateIntrinsic(file = '')
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Empty>
|
||||
FUN FAKE_OVERRIDE name:<get-name> visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.Empty>) returnType:kotlin.String [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-name> (): kotlin.String declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Empty>
|
||||
FUN FAKE_OVERRIDE name:<get-ordinal> visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.Empty>) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-ordinal> (): kotlin.Int declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Empty>
|
||||
FUN FAKE_OVERRIDE name:compareTo visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Empty>, other:<root>.Empty) returnType:kotlin.Int [fake_override,operator]
|
||||
overridden:
|
||||
public open fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Empty>
|
||||
VALUE_PARAMETER name:other index:0 type:<root>.Empty
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Empty>, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Empty>
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Empty>) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Empty>
|
||||
FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:kotlin.Array<<root>.Empty>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun values (): kotlin.Array<<root>.Empty> declared in <root>.Empty'
|
||||
CALL 'public final fun arrayLiteral (arg0: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Array<<root>.Empty> origin=null
|
||||
arg0: CALL 'public final fun arrayLiteral (arg0: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Array<<root>.Empty> origin=null
|
||||
arg0: VARARG type=kotlin.Array<<root>.Empty> varargElementType=<root>.Empty
|
||||
FUN ENUM_CLASS_SPECIAL_MEMBER name:valueOf visibility:public modality:FINAL <> (value:kotlin.String) returnType:<root>.Empty
|
||||
VALUE_PARAMETER name:value index:0 type:kotlin.String
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun valueOf (value: kotlin.String): <root>.Empty declared in <root>.Empty'
|
||||
WHEN type=<root>.Empty origin=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CALL 'public final fun THROW_ISE (): kotlin.Nothing declared in kotlin' type=kotlin.Nothing origin=null
|
||||
FIELD name:Empty_entriesInitialized type:kotlin.Boolean visibility:public [static]
|
||||
FUN SYNTHESIZED_DECLARATION name:Empty_initEntries visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
WHEN type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: GET_FIELD 'FIELD name:Empty_entriesInitialized type:kotlin.Boolean visibility:public [static]' type=kotlin.Boolean origin=null
|
||||
then: RETURN type=kotlin.Nothing from='public final fun Empty_initEntries (): kotlin.Unit declared in <root>.Empty'
|
||||
CALL 'public final fun Unit_getInstance (): kotlin.Unit declared in kotlin' type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
SET_FIELD 'FIELD name:Empty_entriesInitialized type:kotlin.Boolean visibility:public [static]' type=kotlin.Unit origin=null
|
||||
value: CONST Boolean type=kotlin.Boolean value=true
|
||||
CLASS ENUM_CLASS name:Color modality:ABSTRACT visibility:public superTypes:[kotlin.Enum<<root>.Color>]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Color
|
||||
CONSTRUCTOR visibility:private <> (name:kotlin.String, ordinal:kotlin.Int, rgb:kotlin.Int) returnType:<root>.Color [primary]
|
||||
VALUE_PARAMETER SYNTHESIZED_DECLARATION name:name index:0 type:kotlin.String
|
||||
VALUE_PARAMETER SYNTHESIZED_DECLARATION name:ordinal index:1 type:kotlin.Int
|
||||
VALUE_PARAMETER name:rgb index:2 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum'
|
||||
<E>: <none>
|
||||
name: GET_VAR 'name: kotlin.String declared in <root>.Color.<init>' type=kotlin.String origin=null
|
||||
ordinal: GET_VAR 'ordinal: kotlin.Int declared in <root>.Color.<init>' type=kotlin.Int origin=null
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:rgb type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=INITIALIZE_FIELD
|
||||
receiver: GET_VAR '<this>: <root>.Color declared in <root>.Color' type=<root>.Color origin=null
|
||||
value: GET_VAR 'rgb: kotlin.Int declared in <root>.Color.<init>' type=kotlin.Int origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-rgb> visibility:public modality:FINAL <> ($this:<root>.Color) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:rgb visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Color
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-rgb> (): kotlin.Int declared in <root>.Color'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:rgb type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Color declared in <root>.Color.<get-rgb>' type=<root>.Color origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:rgb type:kotlin.Int visibility:private [final]
|
||||
CLASS ENUM_ENTRY name:BLACK modality:FINAL visibility:private superTypes:[<root>.Color]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Color.BLACK
|
||||
CONSTRUCTOR visibility:private <> () returnType:<root>.Color.BLACK [primary]
|
||||
BLOCK_BODY
|
||||
SET_FIELD 'FIELD name:Color_BLACK_instance type:<root>.Color.BLACK? visibility:public [static]' type=kotlin.Unit origin=null
|
||||
value: GET_VAR '<this>: <root>.Color.BLACK declared in <root>.Color.BLACK' type=<root>.Color.BLACK origin=null
|
||||
CALL 'internal final fun Color_init_$Init$ (name: kotlin.String, ordinal: kotlin.Int, $this: <root>.Color): <root>.Color declared in <root>.Color' type=kotlin.Unit origin=null
|
||||
name: CONST String type=kotlin.String value="BLACK"
|
||||
ordinal: CONST Int type=kotlin.Int value=-1
|
||||
$this: GET_VAR '<this>: <root>.Color declared in <root>.Color' type=<root>.Color origin=null
|
||||
CALL 'public final fun Unit_getInstance (): kotlin.Unit declared in kotlin' type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
FUN name:getColorAsString visibility:public modality:OPEN <> ($this:<root>.Color.BLACK) returnType:kotlin.String
|
||||
overridden:
|
||||
public abstract fun getColorAsString (): kotlin.String declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Color.BLACK
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun getColorAsString (): kotlin.String declared in <root>.Color.BLACK'
|
||||
CONST String type=kotlin.String value="0x000000"
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Color>) returnType:kotlin.Int [fake_override]
|
||||
annotations:
|
||||
EvaluateIntrinsic(file = '')
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
FUN FAKE_OVERRIDE name:getColorAsInt visibility:public modality:FINAL <> ($this:<root>.Color) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public final fun getColorAsInt (): kotlin.Int declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Color
|
||||
FUN FAKE_OVERRIDE name:<get-name> visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.Color>) returnType:kotlin.String [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-name> (): kotlin.String [fake_override] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
FUN FAKE_OVERRIDE name:<get-ordinal> visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.Color>) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-ordinal> (): kotlin.Int [fake_override] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
FUN FAKE_OVERRIDE name:<get-rgb> visibility:public modality:FINAL <> ($this:<root>.Color) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:rgb visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-rgb> (): kotlin.Int declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Color
|
||||
FUN FAKE_OVERRIDE name:compareTo visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Color>, other:<root>.Color) returnType:kotlin.Int [fake_override,operator]
|
||||
overridden:
|
||||
public open fun compareTo (other: <root>.Color): kotlin.Int [fake_override,operator] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
VALUE_PARAMETER name:other index:0 type:<root>.Color
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Color>, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Color>) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
FIELD name:Color_BLACK_instance type:<root>.Color.BLACK? visibility:public [static]
|
||||
CLASS ENUM_ENTRY name:RED modality:FINAL visibility:private superTypes:[<root>.Color]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Color.RED
|
||||
CONSTRUCTOR visibility:private <> () returnType:<root>.Color.RED [primary]
|
||||
BLOCK_BODY
|
||||
SET_FIELD 'FIELD name:Color_RED_instance type:<root>.Color.RED? visibility:public [static]' type=kotlin.Unit origin=null
|
||||
value: GET_VAR '<this>: <root>.Color.RED declared in <root>.Color.RED' type=<root>.Color.RED origin=null
|
||||
DELEGATING_CONSTRUCTOR_CALL 'private constructor <init> (name: kotlin.String, ordinal: kotlin.Int, rgb: kotlin.Int) [primary] declared in <root>.Color'
|
||||
name: CONST String type=kotlin.String value="RED"
|
||||
ordinal: CONST Int type=kotlin.Int value=-1
|
||||
rgb: CONST Int type=kotlin.Int value=16711680
|
||||
CALL 'public final fun Unit_getInstance (): kotlin.Unit declared in kotlin' type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
FUN name:getColorAsString visibility:public modality:OPEN <> ($this:<root>.Color.RED) returnType:kotlin.String
|
||||
overridden:
|
||||
public abstract fun getColorAsString (): kotlin.String declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Color.RED
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun getColorAsString (): kotlin.String declared in <root>.Color.RED'
|
||||
CONST String type=kotlin.String value="0xFF0000"
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Color>) returnType:kotlin.Int [fake_override]
|
||||
annotations:
|
||||
EvaluateIntrinsic(file = '')
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
FUN FAKE_OVERRIDE name:getColorAsInt visibility:public modality:FINAL <> ($this:<root>.Color) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public final fun getColorAsInt (): kotlin.Int declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Color
|
||||
FUN FAKE_OVERRIDE name:<get-name> visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.Color>) returnType:kotlin.String [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-name> (): kotlin.String [fake_override] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
FUN FAKE_OVERRIDE name:<get-ordinal> visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.Color>) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-ordinal> (): kotlin.Int [fake_override] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
FUN FAKE_OVERRIDE name:<get-rgb> visibility:public modality:FINAL <> ($this:<root>.Color) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:rgb visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-rgb> (): kotlin.Int declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Color
|
||||
FUN FAKE_OVERRIDE name:compareTo visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Color>, other:<root>.Color) returnType:kotlin.Int [fake_override,operator]
|
||||
overridden:
|
||||
public open fun compareTo (other: <root>.Color): kotlin.Int [fake_override,operator] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
VALUE_PARAMETER name:other index:0 type:<root>.Color
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Color>, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Color>) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
FIELD name:Color_RED_instance type:<root>.Color.RED? visibility:public [static]
|
||||
CLASS ENUM_ENTRY name:GREEN modality:FINAL visibility:private superTypes:[<root>.Color]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Color.GREEN
|
||||
CONSTRUCTOR visibility:private <> () returnType:<root>.Color.GREEN [primary]
|
||||
BLOCK_BODY
|
||||
SET_FIELD 'FIELD name:Color_GREEN_instance type:<root>.Color.GREEN? visibility:public [static]' type=kotlin.Unit origin=null
|
||||
value: GET_VAR '<this>: <root>.Color.GREEN declared in <root>.Color.GREEN' type=<root>.Color.GREEN origin=null
|
||||
DELEGATING_CONSTRUCTOR_CALL 'private constructor <init> (name: kotlin.String, ordinal: kotlin.Int, rgb: kotlin.Int) [primary] declared in <root>.Color'
|
||||
name: CONST String type=kotlin.String value="GREEN"
|
||||
ordinal: CONST Int type=kotlin.Int value=-1
|
||||
rgb: CONST Int type=kotlin.Int value=65280
|
||||
CALL 'public final fun Unit_getInstance (): kotlin.Unit declared in kotlin' type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
FUN name:getColorAsString visibility:public modality:OPEN <> ($this:<root>.Color.GREEN) returnType:kotlin.String
|
||||
overridden:
|
||||
public abstract fun getColorAsString (): kotlin.String declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Color.GREEN
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun getColorAsString (): kotlin.String declared in <root>.Color.GREEN'
|
||||
CONST String type=kotlin.String value="0x00FF00"
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Color>) returnType:kotlin.Int [fake_override]
|
||||
annotations:
|
||||
EvaluateIntrinsic(file = '')
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
FUN FAKE_OVERRIDE name:getColorAsInt visibility:public modality:FINAL <> ($this:<root>.Color) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public final fun getColorAsInt (): kotlin.Int declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Color
|
||||
FUN FAKE_OVERRIDE name:<get-name> visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.Color>) returnType:kotlin.String [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-name> (): kotlin.String [fake_override] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
FUN FAKE_OVERRIDE name:<get-ordinal> visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.Color>) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-ordinal> (): kotlin.Int [fake_override] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
FUN FAKE_OVERRIDE name:<get-rgb> visibility:public modality:FINAL <> ($this:<root>.Color) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:rgb visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-rgb> (): kotlin.Int declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Color
|
||||
FUN FAKE_OVERRIDE name:compareTo visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Color>, other:<root>.Color) returnType:kotlin.Int [fake_override,operator]
|
||||
overridden:
|
||||
public open fun compareTo (other: <root>.Color): kotlin.Int [fake_override,operator] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
VALUE_PARAMETER name:other index:0 type:<root>.Color
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Color>, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Color>) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
FIELD name:Color_GREEN_instance type:<root>.Color.GREEN? visibility:public [static]
|
||||
CLASS ENUM_ENTRY name:BLUE modality:FINAL visibility:private superTypes:[<root>.Color]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Color.BLUE
|
||||
CONSTRUCTOR visibility:private <> () returnType:<root>.Color.BLUE [primary]
|
||||
BLOCK_BODY
|
||||
SET_FIELD 'FIELD name:Color_BLUE_instance type:<root>.Color.BLUE? visibility:public [static]' type=kotlin.Unit origin=null
|
||||
value: GET_VAR '<this>: <root>.Color.BLUE declared in <root>.Color.BLUE' type=<root>.Color.BLUE origin=null
|
||||
DELEGATING_CONSTRUCTOR_CALL 'private constructor <init> (name: kotlin.String, ordinal: kotlin.Int, rgb: kotlin.Int) [primary] declared in <root>.Color'
|
||||
name: CONST String type=kotlin.String value="BLUE"
|
||||
ordinal: CONST Int type=kotlin.Int value=-1
|
||||
rgb: CONST Int type=kotlin.Int value=255
|
||||
CALL 'public final fun Unit_getInstance (): kotlin.Unit declared in kotlin' type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
FUN name:getColorAsString visibility:public modality:OPEN <> ($this:<root>.Color.BLUE) returnType:kotlin.String
|
||||
overridden:
|
||||
public abstract fun getColorAsString (): kotlin.String declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Color.BLUE
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun getColorAsString (): kotlin.String declared in <root>.Color.BLUE'
|
||||
CONST String type=kotlin.String value="0x0000FF"
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Color>) returnType:kotlin.Int [fake_override]
|
||||
annotations:
|
||||
EvaluateIntrinsic(file = '')
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
FUN FAKE_OVERRIDE name:getColorAsInt visibility:public modality:FINAL <> ($this:<root>.Color) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public final fun getColorAsInt (): kotlin.Int declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Color
|
||||
FUN FAKE_OVERRIDE name:<get-name> visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.Color>) returnType:kotlin.String [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-name> (): kotlin.String [fake_override] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
FUN FAKE_OVERRIDE name:<get-ordinal> visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.Color>) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-ordinal> (): kotlin.Int [fake_override] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
FUN FAKE_OVERRIDE name:<get-rgb> visibility:public modality:FINAL <> ($this:<root>.Color) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:rgb visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-rgb> (): kotlin.Int declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Color
|
||||
FUN FAKE_OVERRIDE name:compareTo visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Color>, other:<root>.Color) returnType:kotlin.Int [fake_override,operator]
|
||||
overridden:
|
||||
public open fun compareTo (other: <root>.Color): kotlin.Int [fake_override,operator] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
VALUE_PARAMETER name:other index:0 type:<root>.Color
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Color>, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Color>) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.Color
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
FIELD name:Color_BLUE_instance type:<root>.Color.BLUE? visibility:public [static]
|
||||
FUN SYNTHESIZED_DECLARATION name:Color_init_$Init$ visibility:internal modality:FINAL <> (name:kotlin.String, ordinal:kotlin.Int, $this:<root>.Color) returnType:<root>.Color
|
||||
VALUE_PARAMETER SYNTHESIZED_DECLARATION name:name index:0 type:kotlin.String
|
||||
VALUE_PARAMETER SYNTHESIZED_DECLARATION name:ordinal index:1 type:kotlin.Int
|
||||
VALUE_PARAMETER SYNTHESIZED_DECLARATION name:$this index:2 type:<root>.Color
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'private constructor <init> (name: kotlin.String, ordinal: kotlin.Int, rgb: kotlin.Int) [primary] declared in <root>.Color'
|
||||
name: GET_VAR 'name: kotlin.String declared in <root>.Color.Color_init_$Init$' type=kotlin.String origin=null
|
||||
ordinal: GET_VAR 'ordinal: kotlin.Int declared in <root>.Color.Color_init_$Init$' type=kotlin.Int origin=null
|
||||
rgb: CONST Int type=kotlin.Int value=0
|
||||
RETURN type=kotlin.Nothing from='internal final fun Color_init_$Init$ (name: kotlin.String, ordinal: kotlin.Int, $this: <root>.Color): <root>.Color declared in <root>.Color'
|
||||
GET_VAR '$this: <root>.Color declared in <root>.Color.Color_init_$Init$' type=<root>.Color origin=null
|
||||
FUN SYNTHESIZED_DECLARATION name:Color_init_$Create$ visibility:private modality:FINAL <> (name:kotlin.String, ordinal:kotlin.Int) returnType:<root>.Color
|
||||
VALUE_PARAMETER SYNTHESIZED_DECLARATION name:name index:0 type:kotlin.String
|
||||
VALUE_PARAMETER SYNTHESIZED_DECLARATION name:ordinal index:1 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='private final fun Color_init_$Create$ (name: kotlin.String, ordinal: kotlin.Int): <root>.Color declared in <root>.Color'
|
||||
CALL 'internal final fun Color_init_$Init$ (name: kotlin.String, ordinal: kotlin.Int, $this: <root>.Color): <root>.Color declared in <root>.Color' type=<root>.Color origin=SYNTHESIZED_STATEMENT
|
||||
name: GET_VAR 'name: kotlin.String declared in <root>.Color.Color_init_$Create$' type=kotlin.String origin=SYNTHESIZED_STATEMENT
|
||||
ordinal: GET_VAR 'ordinal: kotlin.Int declared in <root>.Color.Color_init_$Create$' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
$this: CALL 'public final fun Object$create <T> (): T of kotlin.js.internal.Object$create declared in kotlin.js.internal' type=<root>.Color origin=SYNTHESIZED_STATEMENT
|
||||
<T>: <root>.Color
|
||||
FUN name:getColorAsString visibility:public modality:ABSTRACT <> ($this:<root>.Color) returnType:kotlin.String
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Color
|
||||
FUN name:getColorAsInt visibility:public modality:FINAL <> ($this:<root>.Color) returnType:kotlin.Int
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Color
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun getColorAsInt (): kotlin.Int declared in <root>.Color'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:rgb type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=GET_PROPERTY
|
||||
receiver: GET_VAR '<this>: <root>.Color declared in <root>.Color.getColorAsInt' type=<root>.Color origin=null
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Color>) returnType:kotlin.Int [fake_override]
|
||||
annotations:
|
||||
EvaluateIntrinsic(file = '')
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
FUN FAKE_OVERRIDE name:<get-name> visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.Color>) returnType:kotlin.String [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-name> (): kotlin.String declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
FUN FAKE_OVERRIDE name:<get-ordinal> visibility:public modality:FINAL <> ($this:kotlin.Enum<<root>.Color>) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val]
|
||||
overridden:
|
||||
public final fun <get-ordinal> (): kotlin.Int declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
FUN FAKE_OVERRIDE name:compareTo visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Color>, other:<root>.Color) returnType:kotlin.Int [fake_override,operator]
|
||||
overridden:
|
||||
public open fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
VALUE_PARAMETER name:other index:0 type:<root>.Color
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Color>, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum<<root>.Color>) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Enum
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<<root>.Color>
|
||||
FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:kotlin.Array<<root>.Color>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun values (): kotlin.Array<<root>.Color> declared in <root>.Color'
|
||||
CALL 'public final fun arrayLiteral (arg0: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Array<<root>.Color> origin=null
|
||||
arg0: CALL 'public final fun arrayLiteral (arg0: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Array<<root>.Color> origin=null
|
||||
arg0: VARARG type=kotlin.Array<<root>.Color> varargElementType=<root>.Color
|
||||
CALL 'public final fun Color_BLACK_getInstance (): <root>.Color.BLACK declared in <root>' type=<root>.Color.BLACK origin=null
|
||||
CALL 'public final fun Color_RED_getInstance (): <root>.Color.RED declared in <root>' type=<root>.Color.RED origin=null
|
||||
CALL 'public final fun Color_GREEN_getInstance (): <root>.Color.GREEN declared in <root>' type=<root>.Color.GREEN origin=null
|
||||
CALL 'public final fun Color_BLUE_getInstance (): <root>.Color.BLUE declared in <root>' type=<root>.Color.BLUE origin=null
|
||||
FUN ENUM_CLASS_SPECIAL_MEMBER name:valueOf visibility:public modality:FINAL <> (value:kotlin.String) returnType:<root>.Color
|
||||
VALUE_PARAMETER name:value index:0 type:kotlin.String
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun valueOf (value: kotlin.String): <root>.Color declared in <root>.Color'
|
||||
WHEN type=<root>.Color origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: CONST String type=kotlin.String value="BLACK"
|
||||
arg1: GET_VAR 'value: kotlin.String declared in <root>.Color.valueOf' type=kotlin.String origin=null
|
||||
then: CALL 'public final fun Color_BLACK_getInstance (): <root>.Color.BLACK declared in <root>' type=<root>.Color.BLACK origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: CONST String type=kotlin.String value="RED"
|
||||
arg1: GET_VAR 'value: kotlin.String declared in <root>.Color.valueOf' type=kotlin.String origin=null
|
||||
then: CALL 'public final fun Color_RED_getInstance (): <root>.Color.RED declared in <root>' type=<root>.Color.RED origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: CONST String type=kotlin.String value="GREEN"
|
||||
arg1: GET_VAR 'value: kotlin.String declared in <root>.Color.valueOf' type=kotlin.String origin=null
|
||||
then: CALL 'public final fun Color_GREEN_getInstance (): <root>.Color.GREEN declared in <root>' type=<root>.Color.GREEN origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: CONST String type=kotlin.String value="BLUE"
|
||||
arg1: GET_VAR 'value: kotlin.String declared in <root>.Color.valueOf' type=kotlin.String origin=null
|
||||
then: CALL 'public final fun Color_BLUE_getInstance (): <root>.Color.BLUE declared in <root>' type=<root>.Color.BLUE origin=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CALL 'public final fun THROW_ISE (): kotlin.Nothing declared in kotlin' type=kotlin.Nothing origin=null
|
||||
FIELD name:Color_entriesInitialized type:kotlin.Boolean visibility:public [static]
|
||||
FUN SYNTHESIZED_DECLARATION name:Color_initEntries visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
WHEN type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: GET_FIELD 'FIELD name:Color_entriesInitialized type:kotlin.Boolean visibility:public [static]' type=kotlin.Boolean origin=null
|
||||
then: RETURN type=kotlin.Nothing from='public final fun Color_initEntries (): kotlin.Unit declared in <root>.Color'
|
||||
CALL 'public final fun Unit_getInstance (): kotlin.Unit declared in kotlin' type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
SET_FIELD 'FIELD name:Color_entriesInitialized type:kotlin.Boolean visibility:public [static]' type=kotlin.Unit origin=null
|
||||
value: CONST Boolean type=kotlin.Boolean value=true
|
||||
SET_FIELD 'FIELD name:Color_BLACK_instance type:<root>.Color.BLACK? visibility:public [static]' type=kotlin.Unit origin=null
|
||||
value: CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.Color.BLACK' type=<root>.Color.BLACK origin=null
|
||||
SET_FIELD 'FIELD name:Color_RED_instance type:<root>.Color.RED? visibility:public [static]' type=kotlin.Unit origin=null
|
||||
value: CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.Color.RED' type=<root>.Color.RED origin=null
|
||||
SET_FIELD 'FIELD name:Color_GREEN_instance type:<root>.Color.GREEN? visibility:public [static]' type=kotlin.Unit origin=null
|
||||
value: CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.Color.GREEN' type=<root>.Color.GREEN origin=null
|
||||
SET_FIELD 'FIELD name:Color_BLUE_instance type:<root>.Color.BLUE? visibility:public [static]' type=kotlin.Unit origin=null
|
||||
value: CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.Color.BLUE' type=<root>.Color.BLUE origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:a1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=0
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a2> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:a2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a2> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a2 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a2 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=0
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b1> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:b1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b1> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b1 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b1 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="BLACK"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b2> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:b2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b2> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b2 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b2 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="0x000000"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b3> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:b3 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b3> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b3 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b3 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="0xFF0000"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=0
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c2> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c2> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c2 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c2 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=16711680
|
||||
FUN SYNTHESIZED_DECLARATION name:Color_BLACK_getInstance visibility:public modality:FINAL <> () returnType:<root>.Color.BLACK
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun Color_initEntries (): kotlin.Unit declared in <root>.Color' type=kotlin.Unit origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun Color_BLACK_getInstance (): <root>.Color.BLACK declared in <root>'
|
||||
GET_FIELD 'FIELD name:Color_BLACK_instance type:<root>.Color.BLACK? visibility:public [static]' type=<root>.Color.BLACK? origin=null
|
||||
FUN SYNTHESIZED_DECLARATION name:Color_RED_getInstance visibility:public modality:FINAL <> () returnType:<root>.Color.RED
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun Color_initEntries (): kotlin.Unit declared in <root>.Color' type=kotlin.Unit origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun Color_RED_getInstance (): <root>.Color.RED declared in <root>'
|
||||
GET_FIELD 'FIELD name:Color_RED_instance type:<root>.Color.RED? visibility:public [static]' type=<root>.Color.RED? origin=null
|
||||
FUN SYNTHESIZED_DECLARATION name:Color_GREEN_getInstance visibility:public modality:FINAL <> () returnType:<root>.Color.GREEN
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun Color_initEntries (): kotlin.Unit declared in <root>.Color' type=kotlin.Unit origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun Color_GREEN_getInstance (): <root>.Color.GREEN declared in <root>'
|
||||
GET_FIELD 'FIELD name:Color_GREEN_instance type:<root>.Color.GREEN? visibility:public [static]' type=<root>.Color.GREEN? origin=null
|
||||
FUN SYNTHESIZED_DECLARATION name:Color_BLUE_getInstance visibility:public modality:FINAL <> () returnType:<root>.Color.BLUE
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun Color_initEntries (): kotlin.Unit declared in <root>.Color' type=kotlin.Unit origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun Color_BLUE_getInstance (): <root>.Color.BLUE declared in <root>'
|
||||
GET_FIELD 'FIELD name:Color_BLUE_instance type:<root>.Color.BLUE? visibility:public [static]' type=<root>.Color.BLUE? origin=null
|
||||
9
compiler/testData/ir/interpreter/enums3.kt
vendored
Normal file
9
compiler/testData/ir/interpreter/enums3.kt
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
const val a = RegexOption.IGNORE_CASE.name
|
||||
const val b = RegexOption.IGNORE_CASE.ordinal
|
||||
const val c = RegexOption.MULTILINE.name
|
||||
const val d = RegexOption.MULTILINE.ordinal
|
||||
const val e = RegexOption.IGNORE_CASE == RegexOption.IGNORE_CASE
|
||||
const val f = RegexOption.IGNORE_CASE != RegexOption.MULTILINE
|
||||
const val g = RegexOption.IGNORE_CASE.toString()
|
||||
57
compiler/testData/ir/interpreter/enums3.txt
vendored
Normal file
57
compiler/testData/ir/interpreter/enums3.txt
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
FILE fqName:<root> fileName:/enums3.kt
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="IGNORE_CASE"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:b visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=0
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="MULTILINE"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-d> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:d visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-d> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:d type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:d type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=1
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-e> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:e visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-e> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:e type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:e type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-f> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:f visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-f> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:f type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:f type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-g> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:g visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-g> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:g type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:g type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="IGNORE_CASE"
|
||||
90
compiler/testData/ir/interpreter/exceptions/arithmeticExceptionThrow.kt
vendored
Normal file
90
compiler/testData/ir/interpreter/exceptions/arithmeticExceptionThrow.kt
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun throwExample(a: Int, b: Int): Int {
|
||||
if (b == 0) throw ArithmeticException("Divide by zero")
|
||||
return a / b
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun throwNullMessage(a: Int, b: Int): Int {
|
||||
if (b == 0) throw ArithmeticException(null)
|
||||
return a / b
|
||||
}
|
||||
|
||||
const val a1 = try {
|
||||
throwExample(10, 0)
|
||||
true
|
||||
} catch (e: ArithmeticException) {
|
||||
false
|
||||
}
|
||||
const val a2 = try {
|
||||
throwExample(10, 1)
|
||||
true
|
||||
} catch (e: ArithmeticException) {
|
||||
false
|
||||
}
|
||||
|
||||
const val b1 = try {
|
||||
throwExample(10, 0)
|
||||
true
|
||||
} catch (e: Exception) {
|
||||
false
|
||||
}
|
||||
const val b2 = try {
|
||||
throwExample(10, 1)
|
||||
true
|
||||
} catch (e: Exception) {
|
||||
false
|
||||
}
|
||||
const val b3 = try {
|
||||
throwExample(10, 0)
|
||||
true
|
||||
} catch (e: Throwable) {
|
||||
false
|
||||
}
|
||||
|
||||
const val c1 = try {
|
||||
throwExample(10, 0)
|
||||
0
|
||||
} catch (e: ArithmeticException) {
|
||||
1
|
||||
} catch (e: Exception) {
|
||||
2
|
||||
}
|
||||
const val c2 = try {
|
||||
throwExample(10, 0)
|
||||
0
|
||||
} catch (e: Exception) {
|
||||
1
|
||||
} catch (e: ArithmeticException) {
|
||||
2
|
||||
}
|
||||
const val c3 = try {
|
||||
throwExample(10, 0)
|
||||
0
|
||||
} catch (e: NullPointerException) {
|
||||
1
|
||||
} catch (e: ArithmeticException) {
|
||||
2
|
||||
}
|
||||
|
||||
const val d1 = try {
|
||||
throwExample(10, 0)
|
||||
"Without exception"
|
||||
} catch (e: ArithmeticException) {
|
||||
e.message ?: "Exception without message"
|
||||
}
|
||||
const val d2 = try {
|
||||
throwExample(10, 1)
|
||||
"Without exception"
|
||||
} catch (e: ArithmeticException) {
|
||||
e.message ?: "Exception without message"
|
||||
}
|
||||
|
||||
const val nullMessage = try {
|
||||
throwNullMessage(10, 0)
|
||||
"Without exception"
|
||||
} catch (e: ArithmeticException) {
|
||||
e.message ?: "Exception without message"
|
||||
}
|
||||
129
compiler/testData/ir/interpreter/exceptions/arithmeticExceptionThrow.txt
vendored
Normal file
129
compiler/testData/ir/interpreter/exceptions/arithmeticExceptionThrow.txt
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
FILE fqName:<root> fileName:/arithmeticExceptionThrow.kt
|
||||
FUN name:throwExample visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Int
|
||||
VALUE_PARAMETER name:b index:1 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
WHEN type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'b: kotlin.Int declared in <root>.throwExample' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
then: THROW type=kotlin.Nothing
|
||||
CALL 'public final fun ArithmeticException_init_$Create$ (message: kotlin.String?): kotlin.ArithmeticException declared in kotlin.ArithmeticException' type=kotlin.ArithmeticException origin=null
|
||||
message: CONST String type=kotlin.String value="Divide by zero"
|
||||
RETURN type=kotlin.Nothing from='public final fun throwExample (a: kotlin.Int, b: kotlin.Int): kotlin.Int declared in <root>'
|
||||
CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsDiv (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=DIV
|
||||
arg0: GET_VAR 'a: kotlin.Int declared in <root>.throwExample' type=kotlin.Int origin=null
|
||||
arg1: GET_VAR 'b: kotlin.Int declared in <root>.throwExample' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
FUN name:throwNullMessage visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Int
|
||||
VALUE_PARAMETER name:b index:1 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
WHEN type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'b: kotlin.Int declared in <root>.throwNullMessage' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
then: THROW type=kotlin.Nothing
|
||||
CALL 'public final fun ArithmeticException_init_$Create$ (message: kotlin.String?): kotlin.ArithmeticException declared in kotlin.ArithmeticException' type=kotlin.ArithmeticException origin=null
|
||||
message: CONST Null type=kotlin.Nothing? value=null
|
||||
RETURN type=kotlin.Nothing from='public final fun throwNullMessage (a: kotlin.Int, b: kotlin.Int): kotlin.Int declared in <root>'
|
||||
CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsDiv (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=DIV
|
||||
arg0: GET_VAR 'a: kotlin.Int declared in <root>.throwNullMessage' type=kotlin.Int origin=null
|
||||
arg1: GET_VAR 'b: kotlin.Int declared in <root>.throwNullMessage' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a1> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:a1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a1> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a1 type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a1 type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=false
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a2> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:a2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a2> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a2 type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a2 type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b1> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:b1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b1> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b1 type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b1 type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=false
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b2> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:b2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b2> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b2 type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b2 type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b3> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:b3 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b3> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b3 type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b3 type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=false
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=1
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c2> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c2> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c2 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c2 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=1
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c3> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c3 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c3> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c3 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c3 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=2
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-d1> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:d1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-d1> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:d1 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:d1 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String? value="Divide by zero"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-d2> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:d2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-d2> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:d2 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:d2 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="Without exception"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-nullMessage> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:nullMessage visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-nullMessage> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:nullMessage type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:nullMessage type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="Exception without message"
|
||||
30
compiler/testData/ir/interpreter/exceptions/arithmeticExceptionTryBlock.kt
vendored
Normal file
30
compiler/testData/ir/interpreter/exceptions/arithmeticExceptionTryBlock.kt
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun tryCatch(integer: Int): Boolean {
|
||||
try {
|
||||
val a = 10 / integer
|
||||
return true
|
||||
} catch (e: ArithmeticException) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const val a1 = tryCatch(0)
|
||||
const val a2 = tryCatch(1)
|
||||
const val a3 = tryCatch(100)
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun multiTryCatch(integer: Int): String {
|
||||
return try {
|
||||
val a = 10 / integer
|
||||
"Normal"
|
||||
} catch (e: AssertionError) {
|
||||
"AssertionError"
|
||||
} catch (e: ArithmeticException) {
|
||||
"ArithmeticException"
|
||||
}
|
||||
}
|
||||
|
||||
const val b1 = multiTryCatch(0)
|
||||
const val b2 = multiTryCatch(1)
|
||||
131
compiler/testData/ir/interpreter/exceptions/arithmeticExceptionTryBlock.txt
vendored
Normal file
131
compiler/testData/ir/interpreter/exceptions/arithmeticExceptionTryBlock.txt
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
FILE fqName:<root> fileName:/arithmeticExceptionTryBlock.kt
|
||||
FUN name:tryCatch visibility:public modality:FINAL <> (integer:kotlin.Int) returnType:kotlin.Boolean
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:integer index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
TRY type=kotlin.Unit
|
||||
try: BLOCK type=kotlin.Unit origin=null
|
||||
VAR name:a type:kotlin.Int [val]
|
||||
CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsDiv (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=DIV
|
||||
arg0: CONST Int type=kotlin.Int value=10
|
||||
arg1: GET_VAR 'integer: kotlin.Int declared in <root>.tryCatch' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
RETURN type=kotlin.Nothing from='public final fun tryCatch (integer: kotlin.Int): kotlin.Boolean declared in <root>'
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
CATCH parameter=val $p: dynamic [val] declared in <root>.tryCatch
|
||||
VAR SYNTHESIZED_DECLARATION name:$p type:dynamic [val]
|
||||
BLOCK type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
WHEN type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsInstanceOf (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=SYNTHESIZED_STATEMENT
|
||||
arg0: GET_VAR 'val $p: dynamic [val] declared in <root>.tryCatch' type=dynamic origin=SYNTHESIZED_STATEMENT
|
||||
arg1: CALL 'public final fun jsClass <T> (): kotlin.js.JsClass<T of kotlin.js.jsClass> [external] declared in kotlin.js' type=kotlin.js.JsClass<T of kotlin.js.jsClass> origin=SYNTHESIZED_STATEMENT
|
||||
<T>: kotlin.ArithmeticException
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun tryCatch (integer: kotlin.Int): kotlin.Boolean declared in <root>'
|
||||
CONST Boolean type=kotlin.Boolean value=false
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: BLOCK type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
WHEN type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: BLOCK type=kotlin.Nothing origin=SYNTHESIZED_STATEMENT
|
||||
THROW type=kotlin.Nothing
|
||||
GET_VAR 'val $p: dynamic [val] declared in <root>.tryCatch' type=dynamic origin=SYNTHESIZED_STATEMENT
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a1> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:a1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a1> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a1 type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a1 type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=false
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a2> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:a2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a2> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a2 type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a2 type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a3> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
|
||||
correspondingProperty: PROPERTY name:a3 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a3> (): kotlin.Boolean declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a3 type:kotlin.Boolean visibility:public [final,static]' type=kotlin.Boolean origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a3 type:kotlin.Boolean visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN name:multiTryCatch visibility:public modality:FINAL <> (integer:kotlin.Int) returnType:kotlin.String
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:integer index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
VAR SYNTHESIZED_DECLARATION name:tmp type:kotlin.String [var]
|
||||
TRY type=kotlin.Unit
|
||||
try: BLOCK type=kotlin.Unit origin=null
|
||||
VAR name:a type:kotlin.Int [val]
|
||||
CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsDiv (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=DIV
|
||||
arg0: CONST Int type=kotlin.Int value=10
|
||||
arg1: GET_VAR 'integer: kotlin.Int declared in <root>.multiTryCatch' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
SET_VAR 'var tmp: kotlin.String [var] declared in <root>.multiTryCatch' type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
CONST String type=kotlin.String value="Normal"
|
||||
CATCH parameter=val $p: dynamic [val] declared in <root>.multiTryCatch
|
||||
VAR SYNTHESIZED_DECLARATION name:$p type:dynamic [val]
|
||||
BLOCK type=kotlin.Unit origin=null
|
||||
VAR SYNTHESIZED_DECLARATION name:tmp type:kotlin.String [var]
|
||||
WHEN type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsInstanceOf (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=SYNTHESIZED_STATEMENT
|
||||
arg0: GET_VAR 'val $p: dynamic [val] declared in <root>.multiTryCatch' type=dynamic origin=SYNTHESIZED_STATEMENT
|
||||
arg1: CALL 'public final fun jsClass <T> (): kotlin.js.JsClass<T of kotlin.js.jsClass> [external] declared in kotlin.js' type=kotlin.js.JsClass<T of kotlin.js.jsClass> origin=SYNTHESIZED_STATEMENT
|
||||
<T>: kotlin.AssertionError
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
SET_VAR 'var tmp: kotlin.String [var] declared in <root>.multiTryCatch' type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
CONST String type=kotlin.String value="AssertionError"
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: BLOCK type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
WHEN type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsInstanceOf (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=SYNTHESIZED_STATEMENT
|
||||
arg0: GET_VAR 'val $p: dynamic [val] declared in <root>.multiTryCatch' type=dynamic origin=SYNTHESIZED_STATEMENT
|
||||
arg1: CALL 'public final fun jsClass <T> (): kotlin.js.JsClass<T of kotlin.js.jsClass> [external] declared in kotlin.js' type=kotlin.js.JsClass<T of kotlin.js.jsClass> origin=SYNTHESIZED_STATEMENT
|
||||
<T>: kotlin.ArithmeticException
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
SET_VAR 'var tmp: kotlin.String [var] declared in <root>.multiTryCatch' type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
CONST String type=kotlin.String value="ArithmeticException"
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: BLOCK type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
WHEN type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
THROW type=kotlin.Nothing
|
||||
GET_VAR 'val $p: dynamic [val] declared in <root>.multiTryCatch' type=dynamic origin=SYNTHESIZED_STATEMENT
|
||||
SET_VAR 'var tmp: kotlin.String [var] declared in <root>.multiTryCatch' type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
GET_VAR 'var tmp: kotlin.String [var] declared in <root>.multiTryCatch' type=kotlin.String origin=SYNTHESIZED_STATEMENT
|
||||
RETURN type=kotlin.Nothing from='public final fun multiTryCatch (integer: kotlin.Int): kotlin.String declared in <root>'
|
||||
GET_VAR 'var tmp: kotlin.String [var] declared in <root>.multiTryCatch' type=kotlin.String origin=SYNTHESIZED_STATEMENT
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b1> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:b1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b1> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b1 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b1 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="ArithmeticException"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b2> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:b2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b2> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b2 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b2 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="Normal"
|
||||
20
compiler/testData/ir/interpreter/exceptions/arithmeticExceptionTryCatchFinally.kt
vendored
Normal file
20
compiler/testData/ir/interpreter/exceptions/arithmeticExceptionTryCatchFinally.kt
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun tryCatch(integer: Int): String {
|
||||
var str = ""
|
||||
try {
|
||||
str += "Start dividing\n"
|
||||
val a = 10 / integer
|
||||
str += "Without exception\n"
|
||||
} catch (e: ArithmeticException) {
|
||||
str += "Exception\n"
|
||||
} finally {
|
||||
str += "Finally\n"
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
||||
const val a1 = tryCatch(0)
|
||||
const val a2 = tryCatch(1)
|
||||
const val a3 = tryCatch(100)
|
||||
78
compiler/testData/ir/interpreter/exceptions/arithmeticExceptionTryCatchFinally.txt
vendored
Normal file
78
compiler/testData/ir/interpreter/exceptions/arithmeticExceptionTryCatchFinally.txt
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
FILE fqName:<root> fileName:/arithmeticExceptionTryCatchFinally.kt
|
||||
FUN name:tryCatch visibility:public modality:FINAL <> (integer:kotlin.Int) returnType:kotlin.String
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:integer index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
VAR name:str type:kotlin.String [var]
|
||||
CONST String type=kotlin.String value=""
|
||||
TRY type=kotlin.Unit
|
||||
try: BLOCK type=kotlin.Unit origin=null
|
||||
SET_VAR 'var str: kotlin.String [var] declared in <root>.tryCatch' type=kotlin.Unit origin=PLUSEQ
|
||||
CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.String origin=PLUSEQ
|
||||
arg0: GET_VAR 'var str: kotlin.String [var] declared in <root>.tryCatch' type=kotlin.String origin=PLUSEQ
|
||||
arg1: CONST String type=kotlin.String value="Start dividing\n"
|
||||
VAR name:a type:kotlin.Int [val]
|
||||
CALL 'public final fun jsBitOr (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Int declared in kotlin.internal.ir' type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsDiv (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=DIV
|
||||
arg0: CONST Int type=kotlin.Int value=10
|
||||
arg1: GET_VAR 'integer: kotlin.Int declared in <root>.tryCatch' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
SET_VAR 'var str: kotlin.String [var] declared in <root>.tryCatch' type=kotlin.Unit origin=PLUSEQ
|
||||
CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.String origin=PLUSEQ
|
||||
arg0: GET_VAR 'var str: kotlin.String [var] declared in <root>.tryCatch' type=kotlin.String origin=PLUSEQ
|
||||
arg1: CONST String type=kotlin.String value="Without exception\n"
|
||||
CATCH parameter=val $p: dynamic [val] declared in <root>.tryCatch
|
||||
VAR SYNTHESIZED_DECLARATION name:$p type:dynamic [val]
|
||||
BLOCK type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
WHEN type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsInstanceOf (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=SYNTHESIZED_STATEMENT
|
||||
arg0: GET_VAR 'val $p: dynamic [val] declared in <root>.tryCatch' type=dynamic origin=SYNTHESIZED_STATEMENT
|
||||
arg1: CALL 'public final fun jsClass <T> (): kotlin.js.JsClass<T of kotlin.js.jsClass> [external] declared in kotlin.js' type=kotlin.js.JsClass<T of kotlin.js.jsClass> origin=SYNTHESIZED_STATEMENT
|
||||
<T>: kotlin.ArithmeticException
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
SET_VAR 'var str: kotlin.String [var] declared in <root>.tryCatch' type=kotlin.Unit origin=PLUSEQ
|
||||
CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.String origin=PLUSEQ
|
||||
arg0: GET_VAR 'var str: kotlin.String [var] declared in <root>.tryCatch' type=kotlin.String origin=PLUSEQ
|
||||
arg1: CONST String type=kotlin.String value="Exception\n"
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: BLOCK type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
WHEN type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: BLOCK type=kotlin.Nothing origin=SYNTHESIZED_STATEMENT
|
||||
THROW type=kotlin.Nothing
|
||||
GET_VAR 'val $p: dynamic [val] declared in <root>.tryCatch' type=dynamic origin=SYNTHESIZED_STATEMENT
|
||||
finally: BLOCK type=kotlin.Unit origin=null
|
||||
SET_VAR 'var str: kotlin.String [var] declared in <root>.tryCatch' type=kotlin.Unit origin=PLUSEQ
|
||||
CALL 'public final fun jsPlus (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.String origin=PLUSEQ
|
||||
arg0: GET_VAR 'var str: kotlin.String [var] declared in <root>.tryCatch' type=kotlin.String origin=PLUSEQ
|
||||
arg1: CONST String type=kotlin.String value="Finally\n"
|
||||
RETURN type=kotlin.Nothing from='public final fun tryCatch (integer: kotlin.Int): kotlin.String declared in <root>'
|
||||
GET_VAR 'var str: kotlin.String [var] declared in <root>.tryCatch' type=kotlin.String origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a1> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:a1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a1> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a1 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a1 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="Start dividing\nException\nFinally\n"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a2> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:a2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a2> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a2 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a2 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="Start dividing\nWithout exception\nFinally\n"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a3> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:a3 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a3> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a3 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a3 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="Start dividing\nWithout exception\nFinally\n"
|
||||
40
compiler/testData/ir/interpreter/exceptions/classCastException.kt
vendored
Normal file
40
compiler/testData/ir/interpreter/exceptions/classCastException.kt
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun classCastWithException(a: Any): String {
|
||||
return try {
|
||||
a as Int
|
||||
"Given value is $a and its doubled value is ${2 * a}"
|
||||
} catch (e: ClassCastException) {
|
||||
"Given value isnt't Int; Exception message: \"${e.message}\""
|
||||
}
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun safeClassCast(a: Any): Int {
|
||||
return (a as? String)?.length ?: -1
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun <T> unsafeClassCast(): T {
|
||||
return 1 as T
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
class A<T>() {
|
||||
fun unsafeCast(): T {
|
||||
return 1 as T
|
||||
}
|
||||
}
|
||||
|
||||
const val a1 = classCastWithException(10)
|
||||
const val a2 = classCastWithException("10")
|
||||
|
||||
const val b1 = safeClassCast(10)
|
||||
const val b2 = safeClassCast("10")
|
||||
|
||||
const val c1 = unsafeClassCast<Int>()
|
||||
const val c2 = unsafeClassCast<String>()
|
||||
|
||||
const val d1 = A<Int>().unsafeCast()
|
||||
const val d2 = A<String>().unsafeCast()
|
||||
216
compiler/testData/ir/interpreter/exceptions/classCastException.txt
vendored
Normal file
216
compiler/testData/ir/interpreter/exceptions/classCastException.txt
vendored
Normal file
@@ -0,0 +1,216 @@
|
||||
FILE fqName:<root> fileName:/classCastException.kt
|
||||
FUN name:classCastWithException visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.String
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
VAR SYNTHESIZED_DECLARATION name:tmp type:kotlin.String [var]
|
||||
TRY type=kotlin.Unit
|
||||
try: BLOCK type=kotlin.Unit origin=null
|
||||
WHEN type=kotlin.Int origin=SYNTHESIZED_STATEMENT
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsTypeOf (value_hack: kotlin.Any?): kotlin.String declared in kotlin.js' type=kotlin.String origin=SYNTHESIZED_STATEMENT
|
||||
value_hack: GET_VAR 'a: kotlin.Any declared in <root>.classCastWithException' type=kotlin.Any origin=null
|
||||
arg1: CONST String type=kotlin.String value="number"
|
||||
then: TYPE_OP type=kotlin.Int origin=REINTERPRET_CAST typeOperand=kotlin.Int
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.classCastWithException' type=kotlin.Any origin=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CALL 'public final fun THROW_CCE (): kotlin.Nothing declared in kotlin' type=kotlin.Nothing origin=SYNTHESIZED_STATEMENT
|
||||
CALL 'public final fun Unit_getInstance (): kotlin.Unit declared in kotlin' type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
SET_VAR 'var tmp: kotlin.String [var] declared in <root>.classCastWithException' type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
STRING_CONCATENATION type=kotlin.String
|
||||
CONST String type=kotlin.String value="Given value is "
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.classCastWithException' type=kotlin.Any origin=null
|
||||
CONST String type=kotlin.String value=" and its doubled value is "
|
||||
CALL 'internal final fun imul (a_local: kotlin.Int, b_local: kotlin.Int): kotlin.Int declared in kotlin.js' type=kotlin.Int origin=MUL
|
||||
a_local: CONST Int type=kotlin.Int value=2
|
||||
b_local: TYPE_OP type=kotlin.Int origin=REINTERPRET_CAST typeOperand=kotlin.Int
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.classCastWithException' type=kotlin.Any origin=null
|
||||
CATCH parameter=val $p: dynamic [val] declared in <root>.classCastWithException
|
||||
VAR SYNTHESIZED_DECLARATION name:$p type:dynamic [val]
|
||||
BLOCK type=kotlin.Unit origin=null
|
||||
VAR SYNTHESIZED_DECLARATION name:tmp type:kotlin.String [var]
|
||||
WHEN type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsInstanceOf (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=SYNTHESIZED_STATEMENT
|
||||
arg0: GET_VAR 'val $p: dynamic [val] declared in <root>.classCastWithException' type=dynamic origin=SYNTHESIZED_STATEMENT
|
||||
arg1: CALL 'public final fun jsClass <T> (): kotlin.js.JsClass<T of kotlin.js.jsClass> [external] declared in kotlin.js' type=kotlin.js.JsClass<T of kotlin.js.jsClass> origin=SYNTHESIZED_STATEMENT
|
||||
<T>: kotlin.ClassCastException
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
SET_VAR 'var tmp: kotlin.String [var] declared in <root>.classCastWithException' type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
STRING_CONCATENATION type=kotlin.String
|
||||
CONST String type=kotlin.String value="Given value isnt't Int; Exception message: \""
|
||||
CALL 'public open fun <get-message> (): kotlin.String? [fake_override] declared in kotlin.ClassCastException' type=kotlin.String? origin=GET_PROPERTY
|
||||
$this: TYPE_OP type=kotlin.ClassCastException origin=REINTERPRET_CAST typeOperand=kotlin.ClassCastException
|
||||
GET_VAR 'val $p: dynamic [val] declared in <root>.classCastWithException' type=dynamic origin=SYNTHESIZED_STATEMENT
|
||||
CONST String type=kotlin.String value="\""
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: BLOCK type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
WHEN type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
THROW type=kotlin.Nothing
|
||||
GET_VAR 'val $p: dynamic [val] declared in <root>.classCastWithException' type=dynamic origin=SYNTHESIZED_STATEMENT
|
||||
SET_VAR 'var tmp: kotlin.String [var] declared in <root>.classCastWithException' type=kotlin.Unit origin=SYNTHESIZED_STATEMENT
|
||||
GET_VAR 'var tmp: kotlin.String [var] declared in <root>.classCastWithException' type=kotlin.String origin=SYNTHESIZED_STATEMENT
|
||||
RETURN type=kotlin.Nothing from='public final fun classCastWithException (a: kotlin.Any): kotlin.String declared in <root>'
|
||||
GET_VAR 'var tmp: kotlin.String [var] declared in <root>.classCastWithException' type=kotlin.String origin=SYNTHESIZED_STATEMENT
|
||||
FUN name:safeClassCast visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp0_safe_receiver type:kotlin.String? [val]
|
||||
WHEN type=kotlin.String? origin=SYNTHESIZED_STATEMENT
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=SYNTHESIZED_STATEMENT
|
||||
arg0: CALL 'public final fun jsTypeOf (value_hack: kotlin.Any?): kotlin.String declared in kotlin.js' type=kotlin.String origin=SYNTHESIZED_STATEMENT
|
||||
value_hack: GET_VAR 'a: kotlin.Any declared in <root>.safeClassCast' type=kotlin.Any origin=null
|
||||
arg1: CONST String type=kotlin.String value="string"
|
||||
then: TYPE_OP type=kotlin.String? origin=REINTERPRET_CAST typeOperand=kotlin.String
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.safeClassCast' type=kotlin.Any origin=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CONST Null type=kotlin.Nothing? value=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp1_elvis_lhs type:kotlin.Int? [val]
|
||||
WHEN type=kotlin.Int? origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp0_safe_receiver: kotlin.String? [val] declared in <root>.safeClassCast' type=kotlin.String? origin=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value=null
|
||||
then: CONST Null type=kotlin.Nothing? value=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CALL 'public final fun jsArrayLength (arg0: kotlin.Any?): kotlin.Any? declared in kotlin.internal.ir' type=kotlin.Int origin=GET_PROPERTY
|
||||
arg0: GET_VAR 'val tmp0_safe_receiver: kotlin.String? [val] declared in <root>.safeClassCast' type=kotlin.String? origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun safeClassCast (a: kotlin.Any): kotlin.Int declared in <root>'
|
||||
WHEN type=kotlin.Int origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun jsEqeq (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp1_elvis_lhs: kotlin.Int? [val] declared in <root>.safeClassCast' type=kotlin.Int? origin=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value=null
|
||||
then: CONST Int type=kotlin.Int value=-1
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: GET_VAR 'val tmp1_elvis_lhs: kotlin.Int? [val] declared in <root>.safeClassCast' type=kotlin.Int? origin=null
|
||||
FUN name:unsafeClassCast visibility:public modality:FINAL <T> () returnType:T of <root>.unsafeClassCast
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun unsafeClassCast <T> (): T of <root>.unsafeClassCast declared in <root>'
|
||||
WHEN type=T of <root>.unsafeClassCast origin=SYNTHESIZED_STATEMENT
|
||||
BRANCH
|
||||
if: CALL 'public final fun isObject (obj: dynamic): kotlin.Boolean declared in kotlin.js' type=kotlin.Boolean origin=SYNTHESIZED_STATEMENT
|
||||
obj: CONST Int type=kotlin.Int value=1
|
||||
then: TYPE_OP type=T of <root>.unsafeClassCast origin=REINTERPRET_CAST typeOperand=T of <root>.unsafeClassCast
|
||||
CONST Int type=kotlin.Int value=1
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CALL 'public final fun THROW_CCE (): kotlin.Nothing declared in kotlin' type=kotlin.Nothing origin=SYNTHESIZED_STATEMENT
|
||||
CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A<T of <root>.A>
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.A<T of <root>.A> [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
FUN name:unsafeCast visibility:public modality:FINAL <> ($this:<root>.A<T of <root>.A>) returnType:T of <root>.A
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A<T of <root>.A>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun unsafeCast (): T of <root>.A declared in <root>.A'
|
||||
WHEN type=T of <root>.A origin=SYNTHESIZED_STATEMENT
|
||||
BRANCH
|
||||
if: CALL 'public final fun isObject (obj: dynamic): kotlin.Boolean declared in kotlin.js' type=kotlin.Boolean origin=SYNTHESIZED_STATEMENT
|
||||
obj: CONST Int type=kotlin.Int value=1
|
||||
then: TYPE_OP type=T of <root>.A origin=REINTERPRET_CAST typeOperand=T of <root>.A
|
||||
CONST Int type=kotlin.Int value=1
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CALL 'public final fun THROW_CCE (): kotlin.Nothing declared in kotlin' type=kotlin.Nothing origin=SYNTHESIZED_STATEMENT
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a1> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:a1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a1> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a1 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a1 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="Given value is 10 and its doubled value is 20"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a2> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:a2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a2> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a2 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a2 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="Given value isnt't Int; Exception message: \"kotlin.String cannot be cast to kotlin.Int\""
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:b1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=-1
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b2> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:b2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b2> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b2 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b2 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=2
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=1
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c2> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:c2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-c2> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c2 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:c2 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
ERROR_EXPR '
|
||||
Exception kotlin.ClassCastException: kotlin.Int cannot be cast to kotlin.String
|
||||
at ClassCastExceptionKt.unsafeClassCast(classCastException.kt:19)' type=kotlin.String
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-d1> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:d1 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-d1> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:d1 type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:d1 type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=1
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-d2> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:d2 visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-d2> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:d2 type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:d2 type:kotlin.String visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
ERROR_EXPR '
|
||||
Exception kotlin.ClassCastException: kotlin.Int cannot be cast to kotlin.String
|
||||
at ClassCastExceptionKt.A.unsafeCast(classCastException.kt:25)' type=kotlin.String
|
||||
9
compiler/testData/ir/interpreter/exceptions/commandsOutException.kt
vendored
Normal file
9
compiler/testData/ir/interpreter/exceptions/commandsOutException.kt
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun infinityWhile(): Int {
|
||||
while (true) {}
|
||||
return 0
|
||||
}
|
||||
|
||||
const val a = infinityWhile()
|
||||
19
compiler/testData/ir/interpreter/exceptions/commandsOutException.txt
vendored
Normal file
19
compiler/testData/ir/interpreter/exceptions/commandsOutException.txt
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
FILE fqName:<root> fileName:/commandsOutException.kt
|
||||
FUN name:infinityWhile visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
annotations:
|
||||
CompileTimeCalculation
|
||||
BLOCK_BODY
|
||||
WHILE label=null origin=WHILE_LOOP
|
||||
condition: CONST Boolean type=kotlin.Boolean value=true
|
||||
body: BLOCK type=kotlin.Unit origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun infinityWhile (): kotlin.Int declared in <root>'
|
||||
CONST Int type=kotlin.Int value=0
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
ERROR_EXPR '
|
||||
Exceeded execution limit of constexpr expression' type=kotlin.Int
|
||||
14
compiler/testData/ir/interpreter/exceptions/divideByZero.kt
vendored
Normal file
14
compiler/testData/ir/interpreter/exceptions/divideByZero.kt
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
// !LANGUAGE: +CompileTimeCalculations
|
||||
|
||||
const val a = try {
|
||||
10 / 0
|
||||
0
|
||||
} catch (e: RuntimeException) {
|
||||
1
|
||||
}
|
||||
|
||||
const val b = 10 / 0
|
||||
|
||||
fun someFunWithCompileTimeInside() {
|
||||
val exceptionExpected = 1 / 0
|
||||
}
|
||||
23
compiler/testData/ir/interpreter/exceptions/divideByZero.txt
vendored
Normal file
23
compiler/testData/ir/interpreter/exceptions/divideByZero.txt
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
FILE fqName:<root> fileName:/divideByZero.kt
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=1
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:b visibility:public modality:FINAL [const,val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null
|
||||
FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:public [final,static]
|
||||
EXPRESSION_BODY
|
||||
ERROR_EXPR '
|
||||
Exception java.lang.ArithmeticException: / by zero' type=kotlin.Int
|
||||
FUN name:someFunWithCompileTimeInside visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
VAR name:exceptionExpected type:kotlin.Int [val]
|
||||
ERROR_EXPR '
|
||||
Exception java.lang.ArithmeticException: / by zero' type=kotlin.Int
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user