From da4079bfe7c3cb8f6af0d0437a8e2b5bf9a09858 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Fri, 9 Sep 2016 10:22:03 +0300 Subject: [PATCH] Move implementation classes to 'impl' packages. --- .../org/jetbrains/kotlin/psi2ir/IrUtils.kt | 1 + .../psi2ir/builders/ExpressionHelpers.kt | 1 + .../kotlin/psi2ir/builders/IrBuilder.kt | 2 + .../builders/IrMemberFunctionBuilder.kt | 4 +- .../generators/ArgumentsGenerationUtils.kt | 7 +- .../psi2ir/generators/AssignmentGenerator.kt | 2 +- .../kotlin/psi2ir/generators/BodyGenerator.kt | 9 +- .../BranchingExpressionGenerator.kt | 3 +- .../kotlin/psi2ir/generators/CallGenerator.kt | 5 +- .../psi2ir/generators/ClassGenerator.kt | 8 +- .../generators/DataClassMembersGenerator.kt | 2 +- .../psi2ir/generators/DeclarationGenerator.kt | 7 +- .../generators/DelegatedPropertyGenerator.kt | 7 +- .../generators/EnumClassMembersGenerator.kt | 6 +- .../generators/ErrorExpressionGenerator.kt | 8 +- .../kotlin/psi2ir/generators/Generator.kt | 2 +- .../psi2ir/generators/LocalClassGenerator.kt | 4 +- .../generators/LocalFunctionGenerator.kt | 6 +- .../generators/LoopExpressionGenerator.kt | 9 +- .../psi2ir/generators/ModuleGenerator.kt | 2 + .../generators/OperatorExpressionGenerator.kt | 7 +- .../kotlin/psi2ir/generators/Primitives.kt | 9 +- .../ReflectionReferencesGenerator.kt | 12 +- .../kotlin/psi2ir/generators/Scope.kt | 2 +- .../psi2ir/generators/StatementGenerator.kt | 15 +- .../generators/TryCatchExpressionGenerator.kt | 2 +- .../ArrayAccessAssignmentReceiver.kt | 2 + .../psi2ir/intermediate/BackingFieldLValue.kt | 2 + .../DelegatedLocalPropertyLValue.kt | 2 +- .../intermediate/RematerializableValue.kt | 2 +- .../psi2ir/intermediate/SafeCallReceiver.kt | 12 +- .../intermediate/SimplePropertyLValue.kt | 5 +- .../psi2ir/intermediate/VariableLValue.kt | 6 +- .../FoldStringConcatenation.kt | 2 +- .../transformations/InlineDesugaredBlocks.kt | 2 +- .../transformations/InsertImplicitCasts.kt | 3 +- .../ir/declarations/IrAnonymousInitializer.kt | 39 ----- .../kotlin/ir/declarations/IrClass.kt | 36 ----- .../kotlin/ir/declarations/IrConstructor.kt | 22 --- .../kotlin/ir/declarations/IrDeclaration.kt | 6 - .../kotlin/ir/declarations/IrEnumEntry.kt | 51 ------ .../ir/declarations/IrErrorDeclaration.kt | 24 --- .../kotlin/ir/declarations/IrFile.kt | 44 +---- .../ir/declarations/IrGeneralFunction.kt | 86 ---------- .../declarations/IrLocalDelegatedProperty.kt | 94 ----------- .../kotlin/ir/declarations/IrModule.kt | 34 +--- .../kotlin/ir/declarations/IrProperty.kt | 126 --------------- .../ir/declarations/IrPropertyAccessor.kt | 47 ------ .../kotlin/ir/declarations/IrTypeAlias.kt | 23 --- .../kotlin/ir/declarations/IrVariable.kt | 49 +----- .../impl/IrAnonymousInitializerImpl.kt | 63 ++++++++ .../ir/declarations/impl/IrClassImpl.kt | 58 +++++++ .../ir/declarations/impl/IrConstructorImpl.kt | 45 ++++++ .../ir/declarations/impl/IrDeclarationBase.kt | 27 ++++ .../impl/IrDelegatedPropertyImpl.kt | 73 +++++++++ .../ir/declarations/impl/IrEnumEntryImpl.kt | 75 +++++++++ .../impl/IrErrorDeclarationImpl.kt | 45 ++++++ .../kotlin/ir/declarations/impl/IrFileImpl.kt | 65 ++++++++ .../ir/declarations/impl/IrFunctionBase.kt | 49 ++++++ .../ir/declarations/impl/IrFunctionImpl.kt | 42 +++++ .../impl/IrGeneralFunctionBase.kt | 64 ++++++++ .../impl/IrLocalDelegatedPropertyImpl.kt | 97 +++++++++++ .../impl/IrLocalPropertyAccessorImpl.kt | 44 +++++ .../ir/declarations/impl/IrModuleImpl.kt | 56 +++++++ .../impl/IrPropertyAccessorBase.kt | 26 +++ .../ir/declarations/impl/IrPropertyBase.kt | 63 ++++++++ .../declarations/impl/IrPropertyGetterImpl.kt | 43 +++++ .../declarations/impl/IrPropertySetterImpl.kt | 43 +++++ .../declarations/impl/IrSimplePropertyImpl.kt | 62 +++++++ .../ir/declarations/impl/IrTypeAliasImpl.kt | 46 ++++++ .../ir/declarations/impl/IrVariableImpl.kt | 71 ++++++++ .../expressions/IrBackingFieldExpression.kt | 121 -------------- .../kotlin/ir/expressions/IrBlock.kt | 82 +--------- .../jetbrains/kotlin/ir/expressions/IrBody.kt | 86 +--------- .../kotlin/ir/expressions/IrBreakContinue.kt | 31 +--- .../jetbrains/kotlin/ir/expressions/IrCall.kt | 14 -- .../ir/expressions/IrCallableReference.kt | 15 -- .../kotlin/ir/expressions/IrClassReference.kt | 13 -- .../kotlin/ir/expressions/IrConst.kt | 55 ------- .../ir/expressions/IrDeclarationReference.kt | 48 ------ .../IrDelegatingConstructorCall.kt | 10 -- .../ir/expressions/IrEnumConstructorCall.kt | 11 -- .../ir/expressions/IrErrorExpression.kt | 65 -------- .../kotlin/ir/expressions/IrExpression.kt | 25 --- .../kotlin/ir/expressions/IrGeneralCall.kt | 53 ------ .../kotlin/ir/expressions/IrGetClass.kt | 41 ----- .../ir/expressions/IrGetExtensionReceiver.kt | 12 -- .../expressions/IrInstanceInitializerCall.kt | 11 -- .../jetbrains/kotlin/ir/expressions/IrLoop.kt | 101 ------------ .../expressions/IrMemberAccessExpression.kt | 45 ------ .../kotlin/ir/expressions/IrReturn.kt | 49 ------ .../ir/expressions/IrStringConcatenation.kt | 37 ----- .../kotlin/ir/expressions/IrThisReference.kt | 14 -- .../kotlin/ir/expressions/IrThrow.kt | 50 ------ .../kotlin/ir/expressions/IrTryCatch.kt | 89 ---------- .../ir/expressions/IrTypeOperatorCall.kt | 52 ------ .../kotlin/ir/expressions/IrVararg.kt | 81 +--------- .../expressions/IrVariableAccessExpression.kt | 63 -------- .../jetbrains/kotlin/ir/expressions/IrWhen.kt | 153 ------------------ .../impl/IrBackingFieldExpressionBase.kt | 55 +++++++ .../ir/expressions/impl/IrBlockBodyImpl.kt | 52 ++++++ .../kotlin/ir/expressions/impl/IrBlockImpl.kt | 82 ++++++++++ .../expressions/impl/IrBreakContinueBase.kt | 31 ++++ .../kotlin/ir/expressions/impl/IrBreakImpl.kt | 32 ++++ .../kotlin/ir/expressions/impl/IrCallImpl.kt | 36 +++++ .../impl/IrCallableReferenceImpl.kt | 35 ++++ .../expressions/impl/IrClassReferenceImpl.kt | 34 ++++ .../kotlin/ir/expressions/impl/IrConstImpl.kt | 76 +++++++++ .../ir/expressions/impl/IrContinueImpl.kt | 32 ++++ .../impl/IrDeclarationReferenceBase.kt | 28 ++++ .../impl/IrDelegatingConstructorCallImpl.kt | 31 ++++ .../ir/expressions/impl/IrDoWhileLoopImpl.kt | 52 ++++++ .../ir/expressions/impl/IrEmptyBlockImpl.kt | 44 +++++ .../impl/IrEnumConstructorCallImpl.kt | 33 ++++ .../impl/IrErrorCallExpressionImpl.kt | 68 ++++++++ .../expressions/impl/IrErrorExpressionImpl.kt | 40 +++++ .../ir/expressions/impl/IrExpressionBase.kt | 27 ++++ .../expressions/impl/IrExpressionBodyImpl.kt | 58 +++++++ .../ir/expressions/impl/IrGeneralCallBase.kt | 75 +++++++++ .../expressions/impl/IrGetBackingFieldImpl.kt | 59 +++++++ .../ir/expressions/impl/IrGetClassImpl.kt | 62 +++++++ .../ir/expressions/impl/IrGetEnumValueImpl.kt | 33 ++++ .../impl/IrGetExtensionReceiverImpl.kt | 33 ++++ .../expressions/impl/IrGetObjectValueImpl.kt | 32 ++++ .../ir/expressions/impl/IrGetVariableImpl.kt | 36 +++++ .../ir/expressions/impl/IrIfThenElseImpl.kt | 111 +++++++++++++ .../impl/IrInstanceInitializerCallImpl.kt | 32 ++++ .../kotlin/ir/expressions/impl/IrLoopBase.kt | 66 ++++++++ .../impl/IrMemberAccessExpressionBase.kt | 66 ++++++++ .../expressions/{ => impl}/IrPrimitiveCall.kt | 5 +- .../{ => impl}/IrPropertyAccessorCall.kt | 6 +- .../ir/expressions/impl/IrReturnImpl.kt | 72 +++++++++ .../expressions/impl/IrSetBackingFieldImpl.kt | 80 +++++++++ .../ir/expressions/impl/IrSetVariableImpl.kt | 74 +++++++++ .../expressions/impl/IrSpreadElementImpl.kt | 65 ++++++++ .../impl/IrStringConcatenationImpl.kt | 58 +++++++ .../expressions/impl/IrSyntheticBodyImpl.kt | 40 +++++ .../IrTerminalDeclarationReferenceBase.kt | 41 +++++ .../impl/IrTerminalExpressionBase.kt | 39 +++++ .../expressions/impl/IrThisReferenceImpl.kt | 36 +++++ .../kotlin/ir/expressions/impl/IrThrowImpl.kt | 71 ++++++++ .../ir/expressions/impl/IrTryCatchImpl.kt | 112 +++++++++++++ .../impl/IrTypeOperatorCallImpl.kt | 76 +++++++++ .../ir/expressions/impl/IrVarargImpl.kt | 60 +++++++ .../kotlin/ir/expressions/impl/IrWhenImpl.kt | 89 ++++++++++ .../ir/expressions/impl/IrWhileLoopImpl.kt | 52 ++++++ 146 files changed, 3699 insertions(+), 2173 deletions(-) create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrAnonymousInitializerImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrClassImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrConstructorImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrDeclarationBase.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrDelegatedPropertyImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrEnumEntryImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrErrorDeclarationImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFileImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionBase.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrGeneralFunctionBase.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrLocalDelegatedPropertyImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrLocalPropertyAccessorImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrModuleImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertyAccessorBase.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertyBase.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertyGetterImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertySetterImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrSimplePropertyImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrTypeAliasImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrVariableImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBackingFieldExpressionBase.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBlockBodyImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBlockImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBreakContinueBase.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBreakImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCallImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCallableReferenceImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrClassReferenceImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrConstImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrContinueImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDeclarationReferenceBase.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDelegatingConstructorCallImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDoWhileLoopImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrEmptyBlockImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrEnumConstructorCallImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrErrorCallExpressionImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrErrorExpressionImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrExpressionBase.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrExpressionBodyImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGeneralCallBase.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetBackingFieldImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetClassImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetEnumValueImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetExtensionReceiverImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetObjectValueImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetVariableImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrIfThenElseImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrInstanceInitializerCallImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrLoopBase.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrMemberAccessExpressionBase.kt rename compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/{ => impl}/IrPrimitiveCall.kt (96%) rename compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/{ => impl}/IrPropertyAccessorCall.kt (93%) create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrReturnImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetBackingFieldImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetVariableImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSpreadElementImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrStringConcatenationImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSyntheticBodyImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTerminalDeclarationReferenceBase.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTerminalExpressionBase.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrThisReferenceImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrThrowImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTryCatchImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTypeOperatorCallImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrVarargImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhenImpl.kt create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhileLoopImpl.kt diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/IrUtils.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/IrUtils.kt index 4a705e171b5..53fa42e7131 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/IrUtils.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/IrUtils.kt @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.psi2ir import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.ir.declarations.IrVariable import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.expressions.impl.IrGetVariableImpl import org.jetbrains.kotlin.psi2ir.containsNull import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.checker.KotlinTypeChecker diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/builders/ExpressionHelpers.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/builders/ExpressionHelpers.kt index bcf09be70b7..db3576d802a 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/builders/ExpressionHelpers.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/builders/ExpressionHelpers.kt @@ -21,6 +21,7 @@ import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.descriptors.VariableDescriptor import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.psi2ir.generators.eqeqeq import org.jetbrains.kotlin.psi2ir.generators.primitiveOp1 import org.jetbrains.kotlin.psi2ir.generators.primitiveOp2 diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/builders/IrBuilder.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/builders/IrBuilder.kt index 652df12bc39..f3b7d074d67 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/builders/IrBuilder.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/builders/IrBuilder.kt @@ -21,6 +21,8 @@ import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/builders/IrMemberFunctionBuilder.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/builders/IrMemberFunctionBuilder.kt index 379bdada9eb..7f586b6c164 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/builders/IrMemberFunctionBuilder.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/builders/IrMemberFunctionBuilder.kt @@ -18,9 +18,9 @@ package org.jetbrains.kotlin.psi2ir.builders import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET -import org.jetbrains.kotlin.ir.declarations.IrClassImpl +import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin -import org.jetbrains.kotlin.ir.declarations.IrFunctionImpl +import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl import org.jetbrains.kotlin.psi2ir.generators.GeneratorContext import org.jetbrains.kotlin.psi2ir.generators.Scope diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ArgumentsGenerationUtils.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ArgumentsGenerationUtils.kt index 048c03838c7..b1e70f62b1f 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ArgumentsGenerationUtils.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ArgumentsGenerationUtils.kt @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset @@ -49,10 +50,10 @@ fun StatementGenerator.generateReceiver(ktDefaultElement: KtElement, receiver: R generateExpression(receiver.expression) is ClassValueReceiver -> IrGetObjectValueImpl(receiver.expression.startOffset, receiver.expression.endOffset, receiver.type, - receiver.classQualifier.descriptor) + receiver.classQualifier.descriptor) is ExtensionReceiver -> IrGetExtensionReceiverImpl(ktDefaultElement.startOffset, ktDefaultElement.startOffset, - receiver.declarationDescriptor.extensionReceiverParameter!!) + receiver.declarationDescriptor.extensionReceiverParameter!!) else -> TODO("Receiver: ${receiver.javaClass.simpleName}") } @@ -116,7 +117,7 @@ fun StatementGenerator.generateVarargExpression(varargArgument: VarargValueArgum val irVarargElement = if (argument.getSpreadElement() != null) IrSpreadElementImpl(ktArgumentExpression.startOffset, ktArgumentExpression.endOffset, - generateExpression(ktArgumentExpression)) + generateExpression(ktArgumentExpression)) else generateExpression(ktArgumentExpression) diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/AssignmentGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/AssignmentGenerator.kt index f43bf955bb3..6e45975e883 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/AssignmentGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/AssignmentGenerator.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor import org.jetbrains.kotlin.descriptors.impl.SyntheticFieldDescriptor import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrOperator -import org.jetbrains.kotlin.ir.expressions.IrThisReferenceImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrThisReferenceImpl import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BodyGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BodyGenerator.kt index 6bfb2a39e40..ddfe7020cd2 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BodyGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BodyGenerator.kt @@ -18,8 +18,9 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.ir.declarations.IrFunctionBase +import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionBase import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset @@ -62,7 +63,7 @@ class BodyGenerator(val scopeOwner: DeclarationDescriptor, override val context: fun generatePropertyInitializerBody(ktInitializer: KtExpression): IrExpressionBody = IrExpressionBodyImpl(ktInitializer.startOffset, ktInitializer.endOffset, - createStatementGenerator().generateExpression(ktInitializer)) + createStatementGenerator().generateExpression(ktInitializer)) fun generateLambdaBody(ktFun: KtFunctionLiteral): IrBody { val statementGenerator = createStatementGenerator() @@ -251,7 +252,7 @@ class BodyGenerator(val scopeOwner: DeclarationDescriptor, override val context: if (ktEnumEntry.declarations.isNotEmpty()) { val enumEntryConstructor = enumEntryDescriptor.unsubstitutedPrimaryConstructor!! return IrEnumConstructorCallImpl(ktEnumEntry.startOffset, ktEnumEntry.endOffset, - enumEntryConstructor, enumEntryDescriptor) + enumEntryConstructor, enumEntryDescriptor) } return generateEnumConstructorCallOrSuperCall(ktEnumEntry, enumEntryDescriptor.containingDeclaration as ClassDescriptor, enumEntryDescriptor) @@ -276,7 +277,7 @@ class BodyGenerator(val scopeOwner: DeclarationDescriptor, override val context: // No-argument enum entry constructor val enumClassConstructor = enumClassDescriptor.unsubstitutedPrimaryConstructor!! return IrEnumConstructorCallImpl(ktEnumEntry.startOffset, ktEnumEntry.endOffset, - enumClassConstructor, enumEntryOrNull) + enumClassConstructor, enumEntryOrNull) } } diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BranchingExpressionGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BranchingExpressionGenerator.kt index 79187894cb1..1b8b4dddfb0 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BranchingExpressionGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BranchingExpressionGenerator.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.ir.declarations.IrVariable import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset @@ -54,7 +55,7 @@ class BranchingExpressionGenerator(statementGenerator: StatementGenerator) : Sta return if (irBranches.size == 1) { val (irCondition, irThenBranch) = irBranches[0] IrIfThenElseImpl(expression.startOffset, expression.endOffset, resultType, - irCondition, irThenBranch, irElseBranch, IrOperator.IF) + irCondition, irThenBranch, irElseBranch, IrOperator.IF) } else { val irWhen = IrWhenImpl(expression.startOffset, expression.endOffset, resultType, IrOperator.WHEN) diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/CallGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/CallGenerator.kt index 00a3f4d8e49..863a6964fd4 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/CallGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/CallGenerator.kt @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset @@ -92,8 +93,8 @@ class CallGenerator(statementGenerator: StatementGenerator): StatementGeneratorE IrOperator.GET_PROPERTY, call.superQualifier) } ?: IrGetBackingFieldImpl(startOffset, endOffset, descriptor, - dispatchReceiverValue?.load(), - IrOperator.GET_PROPERTY, call.superQualifier) + dispatchReceiverValue?.load(), + IrOperator.GET_PROPERTY, call.superQualifier) } } diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt index a210ff4a7c2..1f130159f3b 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt @@ -19,8 +19,10 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.impl.* import org.jetbrains.kotlin.ir.descriptors.IrImplementingDelegateDescriptorImpl import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtDelegatedSuperTypeEntry import org.jetbrains.kotlin.psi.KtEnumEntry @@ -111,7 +113,7 @@ class ClassGenerator(val declarationGenerator: DeclarationGenerator) : Generator throw AssertionError("Unexpected supertype constructor for delegation: $superTypeConstructorDescriptor") val delegateDescriptor = IrImplementingDelegateDescriptorImpl(irClass.descriptor, delegateType, superType) val irDelegate = IrSimplePropertyImpl(ktDelegateExpression.startOffset, ktDelegateExpression.endOffset, IrDeclarationOrigin.DELEGATE, - delegateDescriptor) + delegateDescriptor) val bodyGenerator = BodyGenerator(irClass.descriptor, context) irDelegate.initializer = bodyGenerator.generatePropertyInitializerBody(ktDelegateExpression) irClass.addMember(irDelegate) @@ -193,7 +195,7 @@ class ClassGenerator(val declarationGenerator: DeclarationGenerator) : Generator val primaryConstructorDescriptor = classDescriptor.unsubstitutedPrimaryConstructor ?: return val irPrimaryConstructor = IrConstructorImpl(ktClassOrObject.startOffset, ktClassOrObject.endOffset, IrDeclarationOrigin.DEFINED, - primaryConstructorDescriptor) + primaryConstructorDescriptor) val bodyGenerator = BodyGenerator(primaryConstructorDescriptor, context) ktClassOrObject.getPrimaryConstructor()?.valueParameterList?.let { ktValueParameterList -> @@ -228,7 +230,7 @@ class ClassGenerator(val declarationGenerator: DeclarationGenerator) : Generator val propertyDescriptor = getOrFail(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, ktParameter) val irProperty = IrSimplePropertyImpl(ktParameter.startOffset, ktParameter.endOffset, IrDeclarationOrigin.DEFINED, propertyDescriptor) val irGetParameter = IrGetVariableImpl(ktParameter.startOffset, ktParameter.endOffset, - valueParameterDescriptor, IrOperator.INITIALIZE_PROPERTY_FROM_PARAMETER) + valueParameterDescriptor, IrOperator.INITIALIZE_PROPERTY_FROM_PARAMETER) irProperty.initializer = IrExpressionBodyImpl(ktParameter.startOffset, ktParameter.endOffset, irGetParameter) return irProperty } diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DataClassMembersGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DataClassMembersGenerator.kt index 134a365a322..4937b073b5a 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DataClassMembersGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DataClassMembersGenerator.kt @@ -20,7 +20,7 @@ import com.intellij.psi.PsiElement import org.jetbrains.kotlin.backend.common.DataClassMethodGenerator import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET -import org.jetbrains.kotlin.ir.declarations.IrClassImpl +import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.mapValueParameters diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DeclarationGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DeclarationGenerator.kt index 24d2ae04d25..ab17770d5fa 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DeclarationGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DeclarationGenerator.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.impl.* import org.jetbrains.kotlin.ir.expressions.IrBody import org.jetbrains.kotlin.ir.expressions.IrExpressionBody import org.jetbrains.kotlin.psi.* @@ -64,11 +65,11 @@ class DeclarationGenerator(override val context: GeneratorContext) : Generator { fun generateTypeAliasDeclaration(ktDeclaration: KtTypeAlias): IrDeclaration = IrTypeAliasImpl(ktDeclaration.startOffset, ktDeclaration.endOffset, IrDeclarationOrigin.DEFINED, - getOrFail(BindingContext.TYPE_ALIAS, ktDeclaration)) + getOrFail(BindingContext.TYPE_ALIAS, ktDeclaration)) fun generateAnonymousInitializerDeclaration(ktAnonymousInitializer: KtAnonymousInitializer, classDescriptor: ClassDescriptor): IrDeclaration { val irAnonymousInitializer = IrAnonymousInitializerImpl(ktAnonymousInitializer.startOffset, ktAnonymousInitializer.endOffset, - IrDeclarationOrigin.DEFINED, classDescriptor) + IrDeclarationOrigin.DEFINED, classDescriptor) irAnonymousInitializer.body = BodyGenerator(classDescriptor, context).generateAnonymousInitializerBody(ktAnonymousInitializer) return irAnonymousInitializer } @@ -122,7 +123,7 @@ class DeclarationGenerator(override val context: GeneratorContext) : Generator { private fun generateSimpleProperty(ktProperty: KtProperty, propertyDescriptor: PropertyDescriptor): IrSimplePropertyImpl { val initializer = ktProperty.initializer?.let { generateInitializerBody(propertyDescriptor, it) } val irProperty = IrSimplePropertyImpl(ktProperty.startOffset, ktProperty.endOffset, IrDeclarationOrigin.DEFINED, - propertyDescriptor, initializer) + propertyDescriptor, initializer) irProperty.getter = ktProperty.getter?.let { ktGetter -> val accessorDescriptor = getOrFail(BindingContext.PROPERTY_ACCESSOR, ktGetter) diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DelegatedPropertyGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DelegatedPropertyGenerator.kt index a1ed6b2d47d..4a242cbda22 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DelegatedPropertyGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DelegatedPropertyGenerator.kt @@ -19,11 +19,14 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.impl.* import org.jetbrains.kotlin.ir.descriptors.IrLocalDelegatedPropertyDelegateDescriptor import org.jetbrains.kotlin.ir.descriptors.IrLocalDelegatedPropertyDelegateDescriptorImpl import org.jetbrains.kotlin.ir.descriptors.IrPropertyDelegateDescriptor import org.jetbrains.kotlin.ir.descriptors.IrPropertyDelegateDescriptorImpl import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.expressions.impl.IrCallableReferenceImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrThisReferenceImpl import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtProperty import org.jetbrains.kotlin.psi.KtPropertyDelegate @@ -86,7 +89,7 @@ class DelegatedPropertyGenerator(override val context: GeneratorContext) : Gener private fun createCallableReference(ktElement: KtElement, type: KotlinType, referencedDescriptor: CallableDescriptor): IrCallableReference = IrCallableReferenceImpl(ktElement.startOffset, ktElement.endOffset, type, - referencedDescriptor, IrOperator.PROPERTY_REFERENCE_FOR_DELEGATE) + referencedDescriptor, IrOperator.PROPERTY_REFERENCE_FOR_DELEGATE) fun generateLocalDelegatedProperty( ktProperty: KtProperty, @@ -130,7 +133,7 @@ class DelegatedPropertyGenerator(override val context: GeneratorContext) : Gener private fun createLocalPropertyAccessor(getterDescriptor: VariableAccessorDescriptor, ktDelegate: KtPropertyDelegate, body: IrBody) = IrLocalPropertyAccessorImpl(ktDelegate.startOffset, ktDelegate.endOffset, IrDeclarationOrigin.DELEGATED_PROPERTY_ACCESSOR, - getterDescriptor, body) + getterDescriptor, body) private fun createLocalPropertyDelegatedDescriptor( ktDelegate: KtPropertyDelegate, diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/EnumClassMembersGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/EnumClassMembersGenerator.kt index 25486e4d586..612e1476ecf 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/EnumClassMembersGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/EnumClassMembersGenerator.kt @@ -17,10 +17,10 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET -import org.jetbrains.kotlin.ir.declarations.IrClassImpl +import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin -import org.jetbrains.kotlin.ir.declarations.IrFunctionImpl -import org.jetbrains.kotlin.ir.expressions.IrSyntheticBodyImpl +import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrSyntheticBodyImpl import org.jetbrains.kotlin.ir.expressions.IrSyntheticBodyKind import org.jetbrains.kotlin.psi2ir.findFirstFunction diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ErrorExpressionGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ErrorExpressionGenerator.kt index 5224119063b..d8c6eb10fff 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ErrorExpressionGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ErrorExpressionGenerator.kt @@ -16,8 +16,8 @@ package org.jetbrains.kotlin.psi2ir.generators -import org.jetbrains.kotlin.ir.expressions.IrErrorCallExpressionImpl -import org.jetbrains.kotlin.ir.expressions.IrErrorExpressionImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrErrorCallExpressionImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrErrorExpressionImpl import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.endOffset @@ -36,8 +36,8 @@ class ErrorExpressionGenerator(statementGenerator: StatementGenerator) : Stateme fun generateErrorExpression(ktElement: KtElement, e: Exception): IrExpression = generateErrorExpression(ktElement, e) { IrErrorExpressionImpl(ktElement.startOffset, ktElement.endOffset, - if (ktElement is KtExpression) getErrorExpressionType(ktElement) else ErrorUtils.createErrorType(""), - e.message ?: "") + if (ktElement is KtExpression) getErrorExpressionType(ktElement) else ErrorUtils.createErrorType(""), + e.message ?: "") } fun generateErrorCall(ktCall: KtCallExpression): IrExpression = generateErrorExpression(ktCall) { diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/Generator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/Generator.kt index 3715887578c..680c3b735ac 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/Generator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/Generator.kt @@ -17,7 +17,7 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.descriptors.CallableDescriptor -import org.jetbrains.kotlin.ir.expressions.IrErrorExpressionImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrErrorExpressionImpl import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.psiUtil.endOffset diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LocalClassGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LocalClassGenerator.kt index f3b0703bb29..4b77c63b6f8 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LocalClassGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LocalClassGenerator.kt @@ -17,8 +17,8 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.ir.IrStatement -import org.jetbrains.kotlin.ir.expressions.IrBlockImpl -import org.jetbrains.kotlin.ir.expressions.IrCallImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl import org.jetbrains.kotlin.ir.expressions.IrOperator import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtObjectLiteralExpression diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LocalFunctionGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LocalFunctionGenerator.kt index 5c7dbc49389..dd2c6d8c7ed 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LocalFunctionGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LocalFunctionGenerator.kt @@ -19,9 +19,9 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin import org.jetbrains.kotlin.ir.declarations.IrGeneralFunction -import org.jetbrains.kotlin.ir.declarations.IrFunctionImpl -import org.jetbrains.kotlin.ir.expressions.IrBlockImpl -import org.jetbrains.kotlin.ir.expressions.IrCallableReferenceImpl +import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrCallableReferenceImpl import org.jetbrains.kotlin.ir.expressions.IrOperator import org.jetbrains.kotlin.psi.KtLambdaExpression import org.jetbrains.kotlin.psi.KtNamedFunction diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LoopExpressionGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LoopExpressionGenerator.kt index 542787d2821..59f2e04b5f7 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LoopExpressionGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LoopExpressionGenerator.kt @@ -17,8 +17,9 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin -import org.jetbrains.kotlin.ir.declarations.IrVariableImpl +import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.getParentOfType @@ -31,12 +32,12 @@ class LoopExpressionGenerator(statementGenerator: StatementGenerator) : Statemen fun generateWhileLoop(ktWhile: KtWhileExpression): IrExpression = generateConditionalLoop(ktWhile, IrWhileLoopImpl(ktWhile.startOffset, ktWhile.endOffset, - context.builtIns.unitType, IrOperator.WHILE_LOOP)) + context.builtIns.unitType, IrOperator.WHILE_LOOP)) fun generateDoWhileLoop(ktDoWhile: KtDoWhileExpression): IrExpression = generateConditionalLoop(ktDoWhile, IrDoWhileLoopImpl(ktDoWhile.startOffset, ktDoWhile.endOffset, - context.builtIns.unitType, IrOperator.DO_WHILE_LOOP)) + context.builtIns.unitType, IrOperator.DO_WHILE_LOOP)) private fun generateConditionalLoop(ktLoop: KtWhileExpressionBase, irLoop: IrLoopBase): IrLoop { irLoop.condition = statementGenerator.generateExpression(ktLoop.condition!!) @@ -139,7 +140,7 @@ class LoopExpressionGenerator(statementGenerator: StatementGenerator) : Statemen val irLoopParameter = if (ktLoopParameter != null) { val loopParameterDescriptor = getOrFail(BindingContext.VALUE_PARAMETER, ktLoopParameter) IrVariableImpl(ktLoopParameter.startOffset, ktLoopParameter.endOffset, IrDeclarationOrigin.DEFINED, - loopParameterDescriptor, irNextCall) + loopParameterDescriptor, irNextCall) } else { scope.createTemporaryVariable(irNextCall, "loop_parameter") diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ModuleGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ModuleGenerator.kt index ae0a5ed5d44..eeb49bdad87 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ModuleGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ModuleGenerator.kt @@ -17,6 +17,8 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl +import org.jetbrains.kotlin.ir.declarations.impl.IrModuleImpl import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.resolve.BindingContext diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt index 878dee59a64..8f997ca3567 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt @@ -19,6 +19,9 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.expressions.impl.IrBinaryPrimitiveImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrTypeOperatorCallImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrUnaryPrimitiveImpl import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.endOffset @@ -72,7 +75,7 @@ class OperatorExpressionGenerator(statementGenerator: StatementGenerator) : Stat } return IrTypeOperatorCallImpl(expression.startOffset, expression.endOffset, resultType, irOperator, rhsType, - statementGenerator.generateExpression(expression.left)) + statementGenerator.generateExpression(expression.left)) } fun generateInstanceOfExpression(expression: KtIsExpression): IrStatement { @@ -81,7 +84,7 @@ class OperatorExpressionGenerator(statementGenerator: StatementGenerator) : Stat val againstType = getOrFail(BindingContext.TYPE, expression.typeReference) return IrTypeOperatorCallImpl(expression.startOffset, expression.endOffset, context.builtIns.booleanType, irOperator, - againstType, statementGenerator.generateExpression(expression.leftHandSide)) + againstType, statementGenerator.generateExpression(expression.leftHandSide)) } fun generateBinaryExpression(expression: KtBinaryExpression): IrExpression { diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/Primitives.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/Primitives.kt index c3be0f3e059..0bbeaa6eb10 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/Primitives.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/Primitives.kt @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.expressions.impl.* fun primitiveOp1(startOffset: Int, endOffset: Int, primitiveOpDescriptor: CallableDescriptor, irOperator: IrOperator, argument: IrExpression): IrExpression = @@ -44,8 +45,8 @@ fun GeneratorContext.throwNpe(startOffset: Int, endOffset: Int, operator: IrOper // a || b == if (a) true else b fun GeneratorContext.oror(startOffset: Int, endOffset: Int, a: IrExpression, b: IrExpression, operator: IrOperator = IrOperator.OROR): IrWhen = IrIfThenElseImpl(startOffset, endOffset, builtIns.booleanType, - a, IrConstImpl.constTrue(b.startOffset, b.endOffset, b.type), b, - operator) + a, IrConstImpl.constTrue(b.startOffset, b.endOffset, b.type), b, + operator) fun GeneratorContext.oror(a: IrExpression, b: IrExpression, operator: IrOperator = IrOperator.OROR): IrWhen = oror(b.startOffset, b.endOffset, a, b, operator) @@ -56,8 +57,8 @@ fun GeneratorContext.whenComma(a: IrExpression, b: IrExpression): IrWhen = // a && b == if (a) b else false fun GeneratorContext.andand(startOffset: Int, endOffset: Int, a: IrExpression, b: IrExpression, operator: IrOperator = IrOperator.ANDAND): IrWhen = IrIfThenElseImpl(startOffset, endOffset, builtIns.booleanType, - a, b, IrConstImpl.constFalse(b.startOffset, b.endOffset, b.type), - operator) + a, b, IrConstImpl.constFalse(b.startOffset, b.endOffset, b.type), + operator) fun GeneratorContext.andand(a: IrExpression, b: IrExpression, operator: IrOperator = IrOperator.ANDAND): IrWhen = andand(b.startOffset, b.endOffset, a, b, operator) \ No newline at end of file diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt index ed2856a23e0..51a4422097e 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt @@ -17,10 +17,10 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.descriptors.ClassifierDescriptor -import org.jetbrains.kotlin.ir.expressions.IrCallableReferenceImpl -import org.jetbrains.kotlin.ir.expressions.IrClassReferenceImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrCallableReferenceImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrClassReferenceImpl import org.jetbrains.kotlin.ir.expressions.IrExpression -import org.jetbrains.kotlin.ir.expressions.IrGetClassImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrGetClassImpl import org.jetbrains.kotlin.psi.KtCallableReferenceExpression import org.jetbrains.kotlin.psi.KtClassLiteralExpression import org.jetbrains.kotlin.psi.psiUtil.endOffset @@ -37,7 +37,7 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St return if (lhs is DoubleColonLHS.Expression && !lhs.isObject) { IrGetClassImpl(ktClassLiteral.startOffset, ktClassLiteral.endOffset, resultType, - statementGenerator.generateExpression(ktArgument)) + statementGenerator.generateExpression(ktArgument)) } else { val typeConstructorDeclaration = lhs.type.constructor.declarationDescriptor @@ -50,8 +50,8 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St fun generateCallableReference(ktCallableReference: KtCallableReferenceExpression): IrExpression { val resolvedCall = getResolvedCall(ktCallableReference.callableReference)!! val irCallableRef = IrCallableReferenceImpl(ktCallableReference.startOffset, ktCallableReference.endOffset, - getInferredTypeWithImplicitCastsOrFail(ktCallableReference), - resolvedCall.resultingDescriptor) + getInferredTypeWithImplicitCastsOrFail(ktCallableReference), + resolvedCall.resultingDescriptor) resolvedCall.dispatchReceiver?.let { dispatchReceiver -> if (dispatchReceiver !is TransientReceiver) { irCallableRef.dispatchReceiver = statementGenerator.generateReceiver(ktCallableReference, dispatchReceiver).load() diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/Scope.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/Scope.kt index 0c52cf160bb..d779f2c6ef9 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/Scope.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/Scope.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin import org.jetbrains.kotlin.ir.declarations.IrVariable -import org.jetbrains.kotlin.ir.declarations.IrVariableImpl +import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl import org.jetbrains.kotlin.ir.descriptors.IrTemporaryVariableDescriptor import org.jetbrains.kotlin.ir.descriptors.IrTemporaryVariableDescriptorImpl import org.jetbrains.kotlin.ir.expressions.IrExpression diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/StatementGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/StatementGenerator.kt index 54bf6cbf113..0fe4cbddeeb 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/StatementGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/StatementGenerator.kt @@ -20,9 +20,10 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.assertCast import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin -import org.jetbrains.kotlin.ir.declarations.IrTypeAliasImpl -import org.jetbrains.kotlin.ir.declarations.IrVariableImpl +import org.jetbrains.kotlin.ir.declarations.impl.IrTypeAliasImpl +import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset @@ -95,7 +96,7 @@ class StatementGenerator( // TODO use some special form that introduces multiple declarations into surrounding scope? val irBlock = IrBlockImpl(multiDeclaration.startOffset, multiDeclaration.endOffset, - context.builtIns.unitType, IrOperator.DESTRUCTURING_DECLARATION) + context.builtIns.unitType, IrOperator.DESTRUCTURING_DECLARATION) val ktInitializer = multiDeclaration.initializer!! val containerValue = scope.createTemporaryVariableInBlock(ktInitializer.genExpr(), irBlock, "container") @@ -116,7 +117,7 @@ class StatementGenerator( val irComponentCall = callGenerator.generateCall(ktEntry.startOffset, ktEntry.endOffset, componentSubstitutedCall, IrOperator.COMPONENT_N.withIndex(index + 1)) val irComponentVar = IrVariableImpl(ktEntry.startOffset, ktEntry.endOffset, IrDeclarationOrigin.DEFINED, - componentVariable, irComponentCall) + componentVariable, irComponentCall) irBlock.addStatement(irComponentVar) } } @@ -211,7 +212,7 @@ class StatementGenerator( } val irStringTemplate = IrStringConcatenationImpl(expression.startOffset, expression.endOffset, - getInferredTypeWithImplicitCastsOrFail(expression)) + getInferredTypeWithImplicitCastsOrFail(expression)) entries.forEach { irStringTemplate.addArgument(it.genExpr()) } @@ -268,7 +269,7 @@ class StatementGenerator( IrGetEnumValueImpl(expression.startOffset, expression.endOffset, classValueType, descriptor) else -> { IrGetObjectValueImpl(expression.startOffset, expression.endOffset, classValueType, - descriptor.companionObjectDescriptor ?: throw AssertionError("Class value without companion object: $descriptor")) + descriptor.companionObjectDescriptor ?: throw AssertionError("Class value without companion object: $descriptor")) } } } @@ -380,7 +381,7 @@ class StatementGenerator( override fun visitTypeAlias(typeAlias: KtTypeAlias, data: Nothing?): IrStatement = IrTypeAliasImpl(typeAlias.startOffset, typeAlias.endOffset, IrDeclarationOrigin.DEFINED, - getOrFail(BindingContext.TYPE_ALIAS, typeAlias)) + getOrFail(BindingContext.TYPE_ALIAS, typeAlias)) override fun visitClassLiteralExpression(expression: KtClassLiteralExpression, data: Nothing?): IrStatement = ReflectionReferencesGenerator(this).generateClassLiteral(expression) diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/TryCatchExpressionGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/TryCatchExpressionGenerator.kt index 00b72e9813d..15d9fc09918 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/TryCatchExpressionGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/TryCatchExpressionGenerator.kt @@ -17,7 +17,7 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.ir.expressions.IrExpression -import org.jetbrains.kotlin.ir.expressions.IrTryCatchImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrTryCatchImpl import org.jetbrains.kotlin.psi.KtTryExpression import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/ArrayAccessAssignmentReceiver.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/ArrayAccessAssignmentReceiver.kt index 1f53e3987fc..9a0309c32d1 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/ArrayAccessAssignmentReceiver.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/ArrayAccessAssignmentReceiver.kt @@ -17,6 +17,8 @@ package org.jetbrains.kotlin.psi2ir.intermediate import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl +import org.jetbrains.kotlin.ir.expressions.impl.inlineStatement import org.jetbrains.kotlin.psi2ir.generators.CallGenerator import org.jetbrains.kotlin.types.KotlinType import java.lang.AssertionError diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/BackingFieldLValue.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/BackingFieldLValue.kt index f9223309a4c..f18a7f086b5 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/BackingFieldLValue.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/BackingFieldLValue.kt @@ -18,6 +18,8 @@ package org.jetbrains.kotlin.psi2ir.intermediate import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.expressions.impl.IrGetBackingFieldImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrSetBackingFieldImpl import org.jetbrains.kotlin.types.KotlinType class BackingFieldLValue( diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/DelegatedLocalPropertyLValue.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/DelegatedLocalPropertyLValue.kt index 4dad1c65dde..362fd437b62 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/DelegatedLocalPropertyLValue.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/DelegatedLocalPropertyLValue.kt @@ -17,7 +17,7 @@ package org.jetbrains.kotlin.psi2ir.intermediate import org.jetbrains.kotlin.descriptors.VariableDescriptorWithAccessors -import org.jetbrains.kotlin.ir.expressions.IrCallImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrOperator import org.jetbrains.kotlin.types.KotlinType diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/RematerializableValue.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/RematerializableValue.kt index 50531a4df8f..f2559a526c4 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/RematerializableValue.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/RematerializableValue.kt @@ -16,7 +16,7 @@ package org.jetbrains.kotlin.psi2ir.intermediate -import org.jetbrains.kotlin.ir.expressions.IrBlockImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrExpressionWithCopy import org.jetbrains.kotlin.psi2ir.generators.Scope diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/SafeCallReceiver.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/SafeCallReceiver.kt index b9d079243d1..cf28db0d974 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/SafeCallReceiver.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/SafeCallReceiver.kt @@ -16,9 +16,9 @@ package org.jetbrains.kotlin.psi2ir.intermediate -import org.jetbrains.kotlin.ir.expressions.IrBlockImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl import org.jetbrains.kotlin.ir.expressions.IrExpression -import org.jetbrains.kotlin.ir.expressions.IrIfThenElseImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrIfThenElseImpl import org.jetbrains.kotlin.ir.expressions.IrOperator import org.jetbrains.kotlin.psi2ir.generators.GeneratorWithScope import org.jetbrains.kotlin.psi2ir.generators.constNull @@ -56,10 +56,10 @@ class SafeCallReceiver( irBlock.addStatement(irTmp) val irIfThenElse = IrIfThenElseImpl(startOffset, endOffset, resultType, - generator.context.equalsNull(startOffset, endOffset, safeReceiverValue.load()), - generator.context.constNull(startOffset, endOffset), - irResult, - IrOperator.SAFE_CALL) + generator.context.equalsNull(startOffset, endOffset, safeReceiverValue.load()), + generator.context.constNull(startOffset, endOffset), + irResult, + IrOperator.SAFE_CALL) irBlock.addStatement(irIfThenElse) return irBlock diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/SimplePropertyLValue.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/SimplePropertyLValue.kt index beead0f7173..4597b29c5c7 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/SimplePropertyLValue.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/SimplePropertyLValue.kt @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.psi2ir.intermediate import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.psi2ir.generators.GeneratorContext import org.jetbrains.kotlin.psi2ir.generators.Scope import org.jetbrains.kotlin.types.KotlinType @@ -44,7 +45,7 @@ class SimplePropertyLValue( irOperator, superQualifier) } ?: IrGetBackingFieldImpl(startOffset, endOffset, descriptor, - dispatchReceiverValue?.load(), irOperator, superQualifier) + dispatchReceiverValue?.load(), irOperator, superQualifier) } override fun store(irExpression: IrExpression) = @@ -57,7 +58,7 @@ class SimplePropertyLValue( irOperator, superQualifier) } ?: IrSetBackingFieldImpl(startOffset, endOffset, descriptor, - dispatchReceiverValue?.load(), irExpression, irOperator, superQualifier) + dispatchReceiverValue?.load(), irExpression, irOperator, superQualifier) } override fun assign(withLValue: (LValue) -> IrExpression) = diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/VariableLValue.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/VariableLValue.kt index f2b8f68fd4b..561177beca9 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/VariableLValue.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/VariableLValue.kt @@ -19,9 +19,9 @@ package org.jetbrains.kotlin.psi2ir.intermediate import org.jetbrains.kotlin.descriptors.VariableDescriptor import org.jetbrains.kotlin.ir.declarations.IrVariable import org.jetbrains.kotlin.ir.expressions.IrExpression -import org.jetbrains.kotlin.ir.expressions.IrGetVariableImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrGetVariableImpl import org.jetbrains.kotlin.ir.expressions.IrOperator -import org.jetbrains.kotlin.ir.expressions.IrSetVariableImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrSetVariableImpl import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.typeUtil.builtIns @@ -41,7 +41,7 @@ class VariableLValue( override fun store(irExpression: IrExpression): IrExpression = IrSetVariableImpl(startOffset, endOffset, descriptor, - irExpression, irOperator) + irExpression, irOperator) override fun assign(withLValue: (LValue) -> IrExpression): IrExpression = withLValue(this) diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/FoldStringConcatenation.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/FoldStringConcatenation.kt index c11be831df8..f2e59035452 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/FoldStringConcatenation.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/FoldStringConcatenation.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.ir.detach import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrGeneralCall import org.jetbrains.kotlin.ir.expressions.IrStringConcatenation -import org.jetbrains.kotlin.ir.expressions.IrStringConcatenationImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrStringConcatenationImpl import org.jetbrains.kotlin.ir.replaceWith import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InlineDesugaredBlocks.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InlineDesugaredBlocks.kt index 0791fe18493..256b3b6774a 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InlineDesugaredBlocks.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InlineDesugaredBlocks.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.psi2ir.transformations import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.detach import org.jetbrains.kotlin.ir.expressions.IrBlock -import org.jetbrains.kotlin.ir.expressions.IrBlockImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl import org.jetbrains.kotlin.ir.replaceWith import org.jetbrains.kotlin.ir.visitors.IrElementVisitor import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt index 20ee0ed0338..cb279f825c4 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt @@ -21,6 +21,7 @@ import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.declarations.IrVariable import org.jetbrains.kotlin.ir.detach import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.expressions.impl.IrTypeOperatorCallImpl import org.jetbrains.kotlin.ir.replaceWith import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid @@ -155,7 +156,7 @@ class InsertImplicitCasts(val builtIns: KotlinBuiltIns): IrElementVisitorVoid { if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(valueType.makeNotNullable(), expectedType)) { return IrTypeOperatorCallImpl(this.startOffset, this.endOffset, expectedType, - IrTypeOperator.IMPLICIT_CAST, expectedType, this.detach()) + IrTypeOperator.IMPLICIT_CAST, expectedType, this.detach()) } return this diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrAnonymousInitializer.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrAnonymousInitializer.kt index 0d9deb83076..693c87ba1da 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrAnonymousInitializer.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrAnonymousInitializer.kt @@ -17,9 +17,7 @@ package org.jetbrains.kotlin.ir.declarations import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.ir.* import org.jetbrains.kotlin.ir.expressions.IrBlockBody -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor interface IrAnonymousInitializer : IrDeclaration { override val descriptor: ClassDescriptor // TODO special descriptor for anonymous initializer blocks @@ -30,40 +28,3 @@ interface IrAnonymousInitializer : IrDeclaration { var body: IrBlockBody } -class IrAnonymousInitializerImpl( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - override val descriptor: ClassDescriptor -) : IrDeclarationBase(startOffset, endOffset, origin), IrAnonymousInitializer { - private var bodyImpl: IrBlockBody? = null - override var body: IrBlockBody - get() = bodyImpl!! - set(value) { - value.assertDetached() - bodyImpl?.detach() - bodyImpl = value - value.setTreeLocation(this, ANONYMOUS_INITIALIZER_BODY_SLOT) - } - - override fun getChild(slot: Int): IrElement? = - when (slot) { - ANONYMOUS_INITIALIZER_BODY_SLOT -> body - else -> null - } - - override fun replaceChild(slot: Int, newChild: IrElement) { - when (slot) { - ANONYMOUS_INITIALIZER_BODY_SLOT -> body = newChild.assertCast() - else -> throwNoSuchSlot(slot) - } - } - - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitAnonymousInitializer(this, data) - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - body.accept(visitor, data) - } -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrClass.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrClass.kt index 8659904ee55..6ae2b84a820 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrClass.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrClass.kt @@ -17,10 +17,6 @@ package org.jetbrains.kotlin.ir.declarations import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.ir.* -import org.jetbrains.kotlin.ir.expressions.IrBody -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import java.util.* interface IrClass : IrDeclaration { override val declarationKind: IrDeclarationKind @@ -44,35 +40,3 @@ fun IrClass.getInstanceInitializerMembers() = } } -class IrClassImpl( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - override val descriptor: ClassDescriptor -) : IrDeclarationBase(startOffset, endOffset, origin), IrClass { - override val members: MutableList = ArrayList() - - fun addMember(member: IrDeclaration) { - member.assertDetached() - member.setTreeLocation(this, members.size) - members.add(member) - } - - override fun getChild(slot: Int): IrElement? = - members.getOrNull(slot) - - - override fun replaceChild(slot: Int, newChild: IrElement) { - newChild.assertDetached() - members.getOrNull(slot)?.detach() ?: throwNoSuchSlot(slot) - members[slot] = newChild.assertCast() - newChild.setTreeLocation(this, slot) - } - - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitClass(this, data) - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - members.forEach { it.accept(visitor, data) } - } -} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrConstructor.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrConstructor.kt index 2e17b1ebd75..fdc847f0067 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrConstructor.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrConstructor.kt @@ -17,8 +17,6 @@ package org.jetbrains.kotlin.ir.declarations import org.jetbrains.kotlin.descriptors.ConstructorDescriptor -import org.jetbrains.kotlin.ir.expressions.IrBody -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor interface IrConstructor : IrFunction { @@ -28,23 +26,3 @@ interface IrConstructor : IrFunction { override val descriptor: ConstructorDescriptor } -class IrConstructorImpl( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - override val descriptor: ConstructorDescriptor -) : IrFunctionBase(startOffset, endOffset, origin), IrConstructor { - constructor( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - descriptor: ConstructorDescriptor, - body: IrBody - ) : this(startOffset, endOffset, origin, descriptor) { - this.body = body - } - - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitConstructor(this, data) - } -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclaration.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclaration.kt index 386c3212fc0..6737ffeb4bb 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclaration.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclaration.kt @@ -17,7 +17,6 @@ package org.jetbrains.kotlin.ir.declarations import org.jetbrains.kotlin.descriptors.DeclarationDescriptor -import org.jetbrains.kotlin.ir.IrElementBase import org.jetbrains.kotlin.ir.IrStatement interface IrDeclaration : IrStatement { @@ -55,8 +54,3 @@ enum class IrDeclarationOrigin { IR_TEMPORARY_VARIABLE, } -abstract class IrDeclarationBase( - startOffset: Int, - endOffset: Int, - override val origin: IrDeclarationOrigin -) : IrElementBase(startOffset, endOffset), IrDeclaration diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrEnumEntry.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrEnumEntry.kt index fd686f43237..55b9cae2337 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrEnumEntry.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrEnumEntry.kt @@ -17,9 +17,7 @@ package org.jetbrains.kotlin.ir.declarations import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.ir.* import org.jetbrains.kotlin.ir.expressions.IrExpression -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor interface IrEnumEntry : IrDeclaration { override val declarationKind: IrDeclarationKind get() = IrDeclarationKind.ENUM_ENTRY @@ -30,52 +28,3 @@ interface IrEnumEntry : IrDeclaration { var initializerExpression: IrExpression } -class IrEnumEntryImpl( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - override val descriptor: ClassDescriptor -) : IrDeclarationBase(startOffset, endOffset, origin), IrEnumEntry { - override var correspondingClass: IrClass? = null - set(value) { - value?.assertDetached() - field?.detach() - field = value - value?.setTreeLocation(this, ENUM_ENTRY_CLASS_SLOT) - } - - private var initializerExpressionImpl: IrExpression? = null - override var initializerExpression: IrExpression - get() = initializerExpressionImpl!! - set(value) { - value.assertDetached() - initializerExpressionImpl?.detach() - initializerExpressionImpl = value - value.setTreeLocation(this, ENUM_ENTRY_INITIALIZER_SLOT) - } - - override fun getChild(slot: Int): IrElement? { - return when (slot) { - ENUM_ENTRY_CLASS_SLOT -> correspondingClass - ENUM_ENTRY_INITIALIZER_SLOT -> initializerExpression - else -> null - } - } - - override fun replaceChild(slot: Int, newChild: IrElement) { - when (slot) { - ENUM_ENTRY_CLASS_SLOT -> correspondingClass = newChild.assertCast() - ENUM_ENTRY_INITIALIZER_SLOT -> initializerExpression = newChild.assertCast() - else -> throwNoSuchSlot(slot) - } - } - - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitEnumEntry(this, data) - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - initializerExpression.accept(visitor, data) - correspondingClass?.accept(visitor, data) - } -} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrErrorDeclaration.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrErrorDeclaration.kt index c12285343d1..b06ece242a2 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrErrorDeclaration.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrErrorDeclaration.kt @@ -16,29 +16,5 @@ package org.jetbrains.kotlin.ir.declarations -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor -import org.jetbrains.kotlin.ir.IrElement -import org.jetbrains.kotlin.ir.throwNoSuchSlot -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor - interface IrErrorDeclaration : IrDeclaration -class IrErrorDeclarationImpl( - startOffset: Int, - endOffset: Int, - override val descriptor: DeclarationDescriptor -) : IrDeclarationBase(startOffset, endOffset, IrDeclarationOrigin.DEFINED), IrErrorDeclaration { - override val declarationKind: IrDeclarationKind get() = IrDeclarationKind.DUMMY - - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitErrorDeclaration(this, data) - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - // no children - } - - override fun getChild(slot: Int): IrElement? = null - - override fun replaceChild(slot: Int, newChild: IrElement) = throwNoSuchSlot(slot) -} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrFile.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrFile.kt index 3f1a4511bfd..6802971268c 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrFile.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrFile.kt @@ -18,10 +18,8 @@ package org.jetbrains.kotlin.ir.declarations import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor -import org.jetbrains.kotlin.ir.* -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.utils.SmartList -import java.util.* +import org.jetbrains.kotlin.ir.IrElement +import org.jetbrains.kotlin.ir.SourceLocationManager interface IrFile : IrElement { val name: String @@ -31,41 +29,3 @@ interface IrFile : IrElement { val declarations: List } -class IrFileImpl( - override val fileEntry: SourceLocationManager.FileEntry, - override val name: String, - override val packageFragmentDescriptor: PackageFragmentDescriptor -) : IrElementBase(0, fileEntry.maxOffset), IrFile { - override val fileAnnotations: MutableList = SmartList() - - fun addAnnotation(annotation: AnnotationDescriptor) { - fileAnnotations.add(annotation) - } - - override val declarations: MutableList = ArrayList() - - fun addDeclaration(declaration: IrDeclaration) { - declaration.assertDetached() - declaration.setTreeLocation(this, declarations.size) - declarations.add(declaration) - } - - override fun getChild(slot: Int): IrElement? = - declarations.getOrNull(slot) - - override fun replaceChild(slot: Int, newChild: IrElement) { - newChild.assertDetached() - declarations.getOrNull(slot)?.detach() ?: throwNoSuchSlot(slot) - declarations[slot] = newChild.assertCast() - newChild.setTreeLocation(this, slot) - } - - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitFile(this, data) - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - declarations.forEach { it.accept(visitor, data) } - } - - -} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrGeneralFunction.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrGeneralFunction.kt index 5e651c795ae..672d77146ae 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrGeneralFunction.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrGeneralFunction.kt @@ -18,11 +18,8 @@ package org.jetbrains.kotlin.ir.declarations import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor -import org.jetbrains.kotlin.ir.* import org.jetbrains.kotlin.ir.expressions.IrBody import org.jetbrains.kotlin.ir.expressions.IrExpressionBody -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import java.util.* interface IrGeneralFunction : IrDeclaration { override val descriptor: FunctionDescriptor @@ -37,86 +34,3 @@ interface IrFunction : IrGeneralFunction { fun getDefault(parameter: ValueParameterDescriptor): IrExpressionBody? } -abstract class IrGeneralFunctionBase( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin -) : IrDeclarationBase(startOffset, endOffset, origin), IrGeneralFunction { - constructor( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - body: IrBody - ) : this(startOffset, endOffset, origin) { - this.body = body - } - - final override var body: IrBody? = null - set(newValue) { - newValue?.assertDetached() - field?.detach() - field = newValue - newValue?.setTreeLocation(this, FUNCTION_BODY_SLOT) - } - - override fun getChild(slot: Int): IrElement? = - when (slot) { - FUNCTION_BODY_SLOT -> body - else -> null - } - - override fun replaceChild(slot: Int, newChild: IrElement) { - when (slot) { - FUNCTION_BODY_SLOT -> body = newChild.assertCast() - else -> throwNoSuchSlot(slot) - } - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - body?.accept(visitor, data) - } -} - -abstract class IrFunctionBase( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin -) : IrGeneralFunctionBase(startOffset, endOffset, origin), IrFunction { - private val defaults = LinkedHashMap() - - override fun getDefault(parameter: ValueParameterDescriptor): IrExpressionBody? = - defaults[parameter] - - override fun putDefault(parameter: ValueParameterDescriptor, expressionBody: IrExpressionBody) { - expressionBody.assertDetached() - defaults[parameter]?.detach() - defaults[parameter] = expressionBody - expressionBody.setTreeLocation(this, parameter.index) - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - defaults.values.forEach { it.accept(visitor, data) } - body?.accept(visitor, data) - } -} - -class IrFunctionImpl( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - override val descriptor: FunctionDescriptor -) : IrFunctionBase(startOffset, endOffset, origin) { - constructor( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - descriptor: FunctionDescriptor, - body: IrBody? - ) : this(startOffset, endOffset, origin, descriptor) { - this.body = body - } - - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitFunction(this, data) -} - diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrLocalDelegatedProperty.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrLocalDelegatedProperty.kt index 5f483361d74..65556f84cab 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrLocalDelegatedProperty.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrLocalDelegatedProperty.kt @@ -18,9 +18,6 @@ package org.jetbrains.kotlin.ir.declarations import org.jetbrains.kotlin.descriptors.VariableAccessorDescriptor import org.jetbrains.kotlin.descriptors.VariableDescriptorWithAccessors -import org.jetbrains.kotlin.ir.* -import org.jetbrains.kotlin.ir.expressions.IrBody -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor interface IrLocalDelegatedProperty : IrDeclaration { override val descriptor: VariableDescriptorWithAccessors @@ -39,94 +36,3 @@ interface IrLocalPropertyAccessor : IrGeneralFunction { get() = IrDeclarationKind.LOCAL_PROPERTY_ACCESSOR } -class IrLocalDelegatedPropertyImpl( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - override val descriptor: VariableDescriptorWithAccessors -) : IrDeclarationBase(startOffset, endOffset, origin), IrLocalDelegatedProperty { - constructor( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - descriptor: VariableDescriptorWithAccessors, - delegate: IrVariable - ) : this(startOffset, endOffset, origin, descriptor) { - this.delegate = delegate - } - - private var delegateImpl: IrVariable? = null - override var delegate: IrVariable - get() = delegateImpl!! - set(value) { - value.assertDetached() - delegateImpl?.detach() - delegateImpl = value - value.setTreeLocation(this, DELEGATE_SLOT) - } - - private var getterImpl: IrLocalPropertyAccessor? = null - override var getter: IrLocalPropertyAccessor - get() = getterImpl!! - set(value) { - value.assertDetached() - getterImpl?.detach() - getterImpl = value - value.setTreeLocation(this, PROPERTY_GETTER_SLOT) - } - - override var setter: IrLocalPropertyAccessor? = null - set(value) { - value?.assertDetached() - field?.detach() - field = value - value?.setTreeLocation(this, PROPERTY_SETTER_SLOT) - } - - override fun getChild(slot: Int): IrElement? = - when (slot) { - DELEGATE_SLOT -> delegate - PROPERTY_GETTER_SLOT -> getter - PROPERTY_SETTER_SLOT -> setter - else -> null - } - - override fun replaceChild(slot: Int, newChild: IrElement) { - when (slot) { - DELEGATE_SLOT -> delegate = newChild.assertCast() - PROPERTY_GETTER_SLOT -> getter = newChild.assertCast() - PROPERTY_SETTER_SLOT -> setter = newChild.assertCast() - else -> throwNoSuchSlot(slot) - } - } - - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitLocalDelegatedProperty(this, data) - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - delegate.accept(visitor, data) - getter.accept(visitor, data) - setter?.accept(visitor, data) - } -} - -class IrLocalPropertyAccessorImpl( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - override val descriptor: VariableAccessorDescriptor -) : IrGeneralFunctionBase(startOffset, endOffset, origin), IrLocalPropertyAccessor { - constructor( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - descriptor: VariableAccessorDescriptor, - body: IrBody - ) : this(startOffset, endOffset, origin, descriptor) { - this.body = body - } - - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitLocalPropertyAccessor(this, data) - } -} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrModule.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrModule.kt index 0095a158f95..5e9c09b9b51 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrModule.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrModule.kt @@ -17,10 +17,11 @@ package org.jetbrains.kotlin.ir.declarations import org.jetbrains.kotlin.descriptors.ModuleDescriptor -import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.IrElement +import org.jetbrains.kotlin.ir.MODULE_SLOT +import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import java.util.* +import java.lang.AssertionError interface IrModule : IrElement { override val startOffset: Int get() = UNDEFINED_OFFSET @@ -37,30 +38,3 @@ interface IrModule : IrElement { val files: List } -class IrModuleImpl( - override val descriptor: ModuleDescriptor, - override val irBuiltins: IrBuiltIns -) : IrModule { - override val files: MutableList = ArrayList() - - fun addFile(file: IrFile) { - file.assertDetached() - file.setTreeLocation(this, files.size) - files.add(file) - } - - override fun getChild(slot: Int): IrElement? = - files.getOrNull(slot) - - override fun replaceChild(slot: Int, newChild: IrElement) { - newChild.assertDetached() - files.getOrNull(slot)?.detach() ?: throwNoSuchSlot(slot) - } - - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitModule(this, data) - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - files.forEach { it.accept(visitor, data) } - } -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrProperty.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrProperty.kt index 4d36991d3e3..81d7014b05b 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrProperty.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrProperty.kt @@ -17,9 +17,7 @@ package org.jetbrains.kotlin.ir.declarations import org.jetbrains.kotlin.descriptors.PropertyDescriptor -import org.jetbrains.kotlin.ir.* import org.jetbrains.kotlin.ir.expressions.IrBody -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor interface IrProperty : IrDeclaration { override val descriptor: PropertyDescriptor @@ -38,127 +36,3 @@ interface IrDelegatedProperty : IrProperty { var delegate: IrSimpleProperty } -abstract class IrPropertyBase( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - override val descriptor: PropertyDescriptor -) : IrDeclarationBase(startOffset, endOffset, origin), IrProperty { - override var getter: IrPropertyGetter? = null - set(newGetter) { - newGetter?.assertDetached() - field?.detach() - field = newGetter - newGetter?.setTreeLocation(this, PROPERTY_GETTER_SLOT) - } - - override var setter: IrPropertySetter? = null - set(newSetter) { - newSetter?.assertDetached() - field?.detach() - field = newSetter - newSetter?.setTreeLocation(this, PROPERTY_SETTER_SLOT) - } - - override fun getChild(slot: Int): IrElement? = - when (slot) { - PROPERTY_GETTER_SLOT -> getter - PROPERTY_SETTER_SLOT -> setter - else -> null - } - - override fun replaceChild(slot: Int, newChild: IrElement) { - when (slot) { - PROPERTY_GETTER_SLOT -> getter = newChild.assertCast() - PROPERTY_SETTER_SLOT -> setter = newChild.assertCast() - else -> throwNoSuchSlot(slot) - } - } -} - -class IrSimplePropertyImpl( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - descriptor: PropertyDescriptor, - valueInitializer: IrBody? = null -) : IrPropertyBase(startOffset, endOffset, origin, descriptor), IrSimpleProperty { - override var initializer: IrBody? = valueInitializer - set(value) { - value?.assertDetached() - field?.detach() - field = value - value?.setTreeLocation(this, INITIALIZER_SLOT) - } - - override fun getChild(slot: Int): IrElement? = - when (slot) { - INITIALIZER_SLOT -> initializer - else -> super.getChild(slot) - } - - override fun replaceChild(slot: Int, newChild: IrElement) { - when (slot) { - INITIALIZER_SLOT -> initializer = newChild.assertCast() - else -> super.replaceChild(slot, newChild) - } - } - - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitSimpleProperty(this, data) - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - initializer?.accept(visitor, data) - getter?.accept(visitor, data) - setter?.accept(visitor, data) - } -} - -class IrDelegatedPropertyImpl( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - descriptor: PropertyDescriptor -) : IrPropertyBase(startOffset, endOffset, origin, descriptor), IrDelegatedProperty { - constructor( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - descriptor: PropertyDescriptor, - delegate: IrSimpleProperty - ) : this(startOffset, endOffset, origin, descriptor) { - this.delegate = delegate - } - - private var delegateImpl: IrSimpleProperty? = null - override var delegate: IrSimpleProperty - get() = delegateImpl!! - set(value) { - value.assertDetached() - delegateImpl?.detach() - delegateImpl = value - value.setTreeLocation(this, DELEGATE_SLOT) - } - - override fun getChild(slot: Int): IrElement? = - when (slot) { - DELEGATE_SLOT -> delegate - else -> super.getChild(slot) - } - - override fun replaceChild(slot: Int, newChild: IrElement) { - when (slot) { - DELEGATE_SLOT -> delegate = newChild.assertCast() - else -> super.replaceChild(slot, newChild) - } - } - - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitDelegatedProperty(this, data) - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - delegate.accept(visitor, data) - getter?.accept(visitor, data) - setter?.accept(visitor, data) - } -} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrPropertyAccessor.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrPropertyAccessor.kt index 8d3a4001ab8..f18455216cb 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrPropertyAccessor.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrPropertyAccessor.kt @@ -19,8 +19,6 @@ package org.jetbrains.kotlin.ir.declarations import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor import org.jetbrains.kotlin.descriptors.PropertyGetterDescriptor import org.jetbrains.kotlin.descriptors.PropertySetterDescriptor -import org.jetbrains.kotlin.ir.expressions.IrBody -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor interface IrPropertyAccessor : IrGeneralFunction { override val descriptor: PropertyAccessorDescriptor @@ -39,48 +37,3 @@ interface IrPropertySetter : IrPropertyAccessor { override val descriptor: PropertySetterDescriptor } -abstract class IrPropertyAccessorBase( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin -) : IrGeneralFunctionBase(startOffset, endOffset, origin), IrPropertyAccessor - -class IrPropertyGetterImpl( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - override val descriptor: PropertyGetterDescriptor -) : IrPropertyAccessorBase(startOffset, endOffset, origin), IrPropertyGetter { - constructor( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - descriptor: PropertyGetterDescriptor, - body: IrBody - ) : this(startOffset, endOffset, origin, descriptor) { - this.body = body - } - - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitPropertyGetter(this, data) -} - -class IrPropertySetterImpl( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - override val descriptor: PropertySetterDescriptor -) : IrPropertyAccessorBase(startOffset, endOffset, origin), IrPropertySetter { - constructor( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - descriptor: PropertySetterDescriptor, - body: IrBody - ) : this(startOffset, endOffset, origin, descriptor) { - this.body = body - } - - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitPropertySetter(this, data) -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrTypeAlias.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrTypeAlias.kt index ac9e98d24e2..fb4ba11ca14 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrTypeAlias.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrTypeAlias.kt @@ -17,9 +17,6 @@ package org.jetbrains.kotlin.ir.declarations import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor -import org.jetbrains.kotlin.ir.IrElement -import org.jetbrains.kotlin.ir.throwNoSuchSlot -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor interface IrTypeAlias : IrDeclaration { override val descriptor: TypeAliasDescriptor @@ -28,23 +25,3 @@ interface IrTypeAlias : IrDeclaration { get() = IrDeclarationKind.TYPEALIAS } -class IrTypeAliasImpl( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - override val descriptor: TypeAliasDescriptor -) : IrDeclarationBase(startOffset, endOffset, origin), IrTypeAlias { - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitTypeAlias(this, data) - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - // no children - } - - override fun getChild(slot: Int): IrElement? = null - - override fun replaceChild(slot: Int, newChild: IrElement) { - throwNoSuchSlot(slot) - } -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrVariable.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrVariable.kt index 60a487ce551..dd97d035898 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrVariable.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrVariable.kt @@ -17,9 +17,7 @@ package org.jetbrains.kotlin.ir.declarations import org.jetbrains.kotlin.descriptors.VariableDescriptor -import org.jetbrains.kotlin.ir.* -import org.jetbrains.kotlin.ir.expressions.* -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.ir.expressions.IrExpression interface IrVariable : IrDeclaration { override val descriptor: VariableDescriptor @@ -30,48 +28,3 @@ interface IrVariable : IrDeclaration { var initializer: IrExpression? } -class IrVariableImpl( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - override val descriptor: VariableDescriptor -) : IrDeclarationBase(startOffset, endOffset, origin), IrVariable { - constructor( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - descriptor: VariableDescriptor, - initializer: IrExpression - ) : this(startOffset, endOffset, origin, descriptor) { - this.initializer = initializer - } - - override var initializer: IrExpression? = null - set(value) { - value?.assertDetached() - field?.detach() - field = value - value?.setTreeLocation(this, INITIALIZER_SLOT) - } - - override fun getChild(slot: Int): IrElement? = - when (slot) { - INITIALIZER_SLOT -> initializer - else -> null - } - - override fun replaceChild(slot: Int, newChild: IrElement) { - when (slot) { - INITIALIZER_SLOT -> initializer = newChild.assertCast() - else -> throwNoSuchSlot(slot) - } - } - - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitVariable(this, data) - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - initializer?.accept(visitor, data) - } -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrAnonymousInitializerImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrAnonymousInitializerImpl.kt new file mode 100644 index 00000000000..f4024f991d5 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrAnonymousInitializerImpl.kt @@ -0,0 +1,63 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.declarations.impl + +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.declarations.IrAnonymousInitializer +import org.jetbrains.kotlin.ir.declarations.impl.IrDeclarationBase +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.expressions.IrBlockBody +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +class IrAnonymousInitializerImpl( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + override val descriptor: ClassDescriptor +) : IrDeclarationBase(startOffset, endOffset, origin), IrAnonymousInitializer { + private var bodyImpl: IrBlockBody? = null + override var body: IrBlockBody + get() = bodyImpl!! + set(value) { + value.assertDetached() + bodyImpl?.detach() + bodyImpl = value + value.setTreeLocation(this, ANONYMOUS_INITIALIZER_BODY_SLOT) + } + + override fun getChild(slot: Int): IrElement? = + when (slot) { + ANONYMOUS_INITIALIZER_BODY_SLOT -> body + else -> null + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + when (slot) { + ANONYMOUS_INITIALIZER_BODY_SLOT -> body = newChild.assertCast() + else -> throwNoSuchSlot(slot) + } + } + + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitAnonymousInitializer(this, data) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + body.accept(visitor, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrClassImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrClassImpl.kt new file mode 100644 index 00000000000..62c569110e4 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrClassImpl.kt @@ -0,0 +1,58 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.declarations.impl + +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.declarations.IrClass +import org.jetbrains.kotlin.ir.declarations.IrDeclaration +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import java.util.* + +class IrClassImpl( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + override val descriptor: ClassDescriptor +) : IrDeclarationBase(startOffset, endOffset, origin), IrClass { + override val members: MutableList = ArrayList() + + fun addMember(member: IrDeclaration) { + member.assertDetached() + member.setTreeLocation(this, members.size) + members.add(member) + } + + override fun getChild(slot: Int): IrElement? = + members.getOrNull(slot) + + + override fun replaceChild(slot: Int, newChild: IrElement) { + newChild.assertDetached() + members.getOrNull(slot)?.detach() ?: throwNoSuchSlot(slot) + members[slot] = newChild.assertCast() + newChild.setTreeLocation(this, slot) + } + + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitClass(this, data) + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + members.forEach { it.accept(visitor, data) } + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrConstructorImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrConstructorImpl.kt new file mode 100644 index 00000000000..d1ef2c842a9 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrConstructorImpl.kt @@ -0,0 +1,45 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.declarations.impl + +import org.jetbrains.kotlin.descriptors.ConstructorDescriptor +import org.jetbrains.kotlin.ir.declarations.IrConstructor +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionBase +import org.jetbrains.kotlin.ir.expressions.IrBody +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +class IrConstructorImpl( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + override val descriptor: ConstructorDescriptor +) : IrFunctionBase(startOffset, endOffset, origin), IrConstructor { + constructor( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + descriptor: ConstructorDescriptor, + body: IrBody + ) : this(startOffset, endOffset, origin, descriptor) { + this.body = body + } + + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitConstructor(this, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrDeclarationBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrDeclarationBase.kt new file mode 100644 index 00000000000..da9439e13bf --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrDeclarationBase.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.declarations.impl + +import org.jetbrains.kotlin.ir.IrElementBase +import org.jetbrains.kotlin.ir.declarations.IrDeclaration +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin + +abstract class IrDeclarationBase( + startOffset: Int, + endOffset: Int, + override val origin: IrDeclarationOrigin +) : IrElementBase(startOffset, endOffset), IrDeclaration \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrDelegatedPropertyImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrDelegatedPropertyImpl.kt new file mode 100644 index 00000000000..cf025c0439c --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrDelegatedPropertyImpl.kt @@ -0,0 +1,73 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.declarations.impl + +import org.jetbrains.kotlin.descriptors.PropertyDescriptor +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrDelegatedProperty +import org.jetbrains.kotlin.ir.declarations.IrSimpleProperty +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +class IrDelegatedPropertyImpl( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + descriptor: PropertyDescriptor +) : IrPropertyBase(startOffset, endOffset, origin, descriptor), IrDelegatedProperty { + constructor( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + descriptor: PropertyDescriptor, + delegate: IrSimpleProperty + ) : this(startOffset, endOffset, origin, descriptor) { + this.delegate = delegate + } + + private var delegateImpl: IrSimpleProperty? = null + override var delegate: IrSimpleProperty + get() = delegateImpl!! + set(value) { + value.assertDetached() + delegateImpl?.detach() + delegateImpl = value + value.setTreeLocation(this, DELEGATE_SLOT) + } + + override fun getChild(slot: Int): IrElement? = + when (slot) { + DELEGATE_SLOT -> delegate + else -> super.getChild(slot) + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + when (slot) { + DELEGATE_SLOT -> delegate = newChild.assertCast() + else -> super.replaceChild(slot, newChild) + } + } + + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitDelegatedProperty(this, data) + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + delegate.accept(visitor, data) + getter?.accept(visitor, data) + setter?.accept(visitor, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrEnumEntryImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrEnumEntryImpl.kt new file mode 100644 index 00000000000..febcce1364f --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrEnumEntryImpl.kt @@ -0,0 +1,75 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.declarations.impl + +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.declarations.IrClass +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrEnumEntry +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +class IrEnumEntryImpl( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + override val descriptor: ClassDescriptor +) : IrDeclarationBase(startOffset, endOffset, origin), IrEnumEntry { + override var correspondingClass: IrClass? = null + set(value) { + value?.assertDetached() + field?.detach() + field = value + value?.setTreeLocation(this, ENUM_ENTRY_CLASS_SLOT) + } + + private var initializerExpressionImpl: IrExpression? = null + override var initializerExpression: IrExpression + get() = initializerExpressionImpl!! + set(value) { + value.assertDetached() + initializerExpressionImpl?.detach() + initializerExpressionImpl = value + value.setTreeLocation(this, ENUM_ENTRY_INITIALIZER_SLOT) + } + + override fun getChild(slot: Int): IrElement? { + return when (slot) { + ENUM_ENTRY_CLASS_SLOT -> correspondingClass + ENUM_ENTRY_INITIALIZER_SLOT -> initializerExpression + else -> null + } + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + when (slot) { + ENUM_ENTRY_CLASS_SLOT -> correspondingClass = newChild.assertCast() + ENUM_ENTRY_INITIALIZER_SLOT -> initializerExpression = newChild.assertCast() + else -> throwNoSuchSlot(slot) + } + } + + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitEnumEntry(this, data) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + initializerExpression.accept(visitor, data) + correspondingClass?.accept(visitor, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrErrorDeclarationImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrErrorDeclarationImpl.kt new file mode 100644 index 00000000000..50c927b7f13 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrErrorDeclarationImpl.kt @@ -0,0 +1,45 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.declarations.impl + +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.ir.IrElement +import org.jetbrains.kotlin.ir.declarations.IrDeclarationKind +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrErrorDeclaration +import org.jetbrains.kotlin.ir.throwNoSuchSlot +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +class IrErrorDeclarationImpl( + startOffset: Int, + endOffset: Int, + override val descriptor: DeclarationDescriptor +) : IrDeclarationBase(startOffset, endOffset, IrDeclarationOrigin.DEFINED), IrErrorDeclaration { + override val declarationKind: IrDeclarationKind get() = IrDeclarationKind.DUMMY + + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitErrorDeclaration(this, data) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + // no children + } + + override fun getChild(slot: Int): IrElement? = null + + override fun replaceChild(slot: Int, newChild: IrElement) = throwNoSuchSlot(slot) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFileImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFileImpl.kt new file mode 100644 index 00000000000..6db870741a8 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFileImpl.kt @@ -0,0 +1,65 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.declarations.impl + +import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor +import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.declarations.IrDeclaration +import org.jetbrains.kotlin.ir.declarations.IrFile +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.utils.SmartList +import java.util.* + +class IrFileImpl( + override val fileEntry: SourceLocationManager.FileEntry, + override val name: String, + override val packageFragmentDescriptor: PackageFragmentDescriptor +) : IrElementBase(0, fileEntry.maxOffset), IrFile { + override val fileAnnotations: MutableList = SmartList() + + fun addAnnotation(annotation: AnnotationDescriptor) { + fileAnnotations.add(annotation) + } + + override val declarations: MutableList = ArrayList() + + fun addDeclaration(declaration: IrDeclaration) { + declaration.assertDetached() + declaration.setTreeLocation(this, declarations.size) + declarations.add(declaration) + } + + override fun getChild(slot: Int): IrElement? = + declarations.getOrNull(slot) + + override fun replaceChild(slot: Int, newChild: IrElement) { + newChild.assertDetached() + declarations.getOrNull(slot)?.detach() ?: throwNoSuchSlot(slot) + declarations[slot] = newChild.assertCast() + newChild.setTreeLocation(this, slot) + } + + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitFile(this, data) + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + declarations.forEach { it.accept(visitor, data) } + } + + +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionBase.kt new file mode 100644 index 00000000000..0f8bacb6b25 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionBase.kt @@ -0,0 +1,49 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.declarations.impl + +import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor +import org.jetbrains.kotlin.ir.assertDetached +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrFunction +import org.jetbrains.kotlin.ir.detach +import org.jetbrains.kotlin.ir.expressions.IrExpressionBody +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import java.util.* + +abstract class IrFunctionBase( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin +) : IrGeneralFunctionBase(startOffset, endOffset, origin), IrFunction { + private val defaults = LinkedHashMap() + + override fun getDefault(parameter: ValueParameterDescriptor): IrExpressionBody? = + defaults[parameter] + + override fun putDefault(parameter: ValueParameterDescriptor, expressionBody: IrExpressionBody) { + expressionBody.assertDetached() + defaults[parameter]?.detach() + defaults[parameter] = expressionBody + expressionBody.setTreeLocation(this, parameter.index) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + defaults.values.forEach { it.accept(visitor, data) } + body?.accept(visitor, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionImpl.kt new file mode 100644 index 00000000000..608136c6e2a --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionImpl.kt @@ -0,0 +1,42 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.declarations.impl + +import org.jetbrains.kotlin.descriptors.FunctionDescriptor +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.expressions.IrBody +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +class IrFunctionImpl( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + override val descriptor: FunctionDescriptor +) : IrFunctionBase(startOffset, endOffset, origin) { + constructor( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + descriptor: FunctionDescriptor, + body: IrBody? + ) : this(startOffset, endOffset, origin, descriptor) { + this.body = body + } + + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitFunction(this, data) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrGeneralFunctionBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrGeneralFunctionBase.kt new file mode 100644 index 00000000000..63bc1baff65 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrGeneralFunctionBase.kt @@ -0,0 +1,64 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.declarations.impl + +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrGeneralFunction +import org.jetbrains.kotlin.ir.declarations.impl.IrDeclarationBase +import org.jetbrains.kotlin.ir.expressions.IrBody +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +abstract class IrGeneralFunctionBase( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin +) : IrDeclarationBase(startOffset, endOffset, origin), IrGeneralFunction { + constructor( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + body: IrBody + ) : this(startOffset, endOffset, origin) { + this.body = body + } + + final override var body: IrBody? = null + set(newValue) { + newValue?.assertDetached() + field?.detach() + field = newValue + newValue?.setTreeLocation(this, FUNCTION_BODY_SLOT) + } + + override fun getChild(slot: Int): IrElement? = + when (slot) { + FUNCTION_BODY_SLOT -> body + else -> null + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + when (slot) { + FUNCTION_BODY_SLOT -> body = newChild.assertCast() + else -> throwNoSuchSlot(slot) + } + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + body?.accept(visitor, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrLocalDelegatedPropertyImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrLocalDelegatedPropertyImpl.kt new file mode 100644 index 00000000000..f6a418731f8 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrLocalDelegatedPropertyImpl.kt @@ -0,0 +1,97 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.declarations.impl + +import org.jetbrains.kotlin.descriptors.VariableDescriptorWithAccessors +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrLocalDelegatedProperty +import org.jetbrains.kotlin.ir.declarations.IrLocalPropertyAccessor +import org.jetbrains.kotlin.ir.declarations.IrVariable +import org.jetbrains.kotlin.ir.declarations.impl.IrDeclarationBase +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +class IrLocalDelegatedPropertyImpl( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + override val descriptor: VariableDescriptorWithAccessors +) : IrDeclarationBase(startOffset, endOffset, origin), IrLocalDelegatedProperty { + constructor( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + descriptor: VariableDescriptorWithAccessors, + delegate: IrVariable + ) : this(startOffset, endOffset, origin, descriptor) { + this.delegate = delegate + } + + private var delegateImpl: IrVariable? = null + override var delegate: IrVariable + get() = delegateImpl!! + set(value) { + value.assertDetached() + delegateImpl?.detach() + delegateImpl = value + value.setTreeLocation(this, DELEGATE_SLOT) + } + + private var getterImpl: IrLocalPropertyAccessor? = null + override var getter: IrLocalPropertyAccessor + get() = getterImpl!! + set(value) { + value.assertDetached() + getterImpl?.detach() + getterImpl = value + value.setTreeLocation(this, PROPERTY_GETTER_SLOT) + } + + override var setter: IrLocalPropertyAccessor? = null + set(value) { + value?.assertDetached() + field?.detach() + field = value + value?.setTreeLocation(this, PROPERTY_SETTER_SLOT) + } + + override fun getChild(slot: Int): IrElement? = + when (slot) { + DELEGATE_SLOT -> delegate + PROPERTY_GETTER_SLOT -> getter + PROPERTY_SETTER_SLOT -> setter + else -> null + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + when (slot) { + DELEGATE_SLOT -> delegate = newChild.assertCast() + PROPERTY_GETTER_SLOT -> getter = newChild.assertCast() + PROPERTY_SETTER_SLOT -> setter = newChild.assertCast() + else -> throwNoSuchSlot(slot) + } + } + + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitLocalDelegatedProperty(this, data) + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + delegate.accept(visitor, data) + getter.accept(visitor, data) + setter?.accept(visitor, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrLocalPropertyAccessorImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrLocalPropertyAccessorImpl.kt new file mode 100644 index 00000000000..c60c629ac20 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrLocalPropertyAccessorImpl.kt @@ -0,0 +1,44 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.declarations.impl + +import org.jetbrains.kotlin.descriptors.VariableAccessorDescriptor +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrLocalPropertyAccessor +import org.jetbrains.kotlin.ir.expressions.IrBody +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +class IrLocalPropertyAccessorImpl( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + override val descriptor: VariableAccessorDescriptor +) : IrGeneralFunctionBase(startOffset, endOffset, origin), IrLocalPropertyAccessor { + constructor( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + descriptor: VariableAccessorDescriptor, + body: IrBody + ) : this(startOffset, endOffset, origin, descriptor) { + this.body = body + } + + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitLocalPropertyAccessor(this, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrModuleImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrModuleImpl.kt new file mode 100644 index 00000000000..f9219a80535 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrModuleImpl.kt @@ -0,0 +1,56 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.declarations.impl + +import org.jetbrains.kotlin.descriptors.ModuleDescriptor +import org.jetbrains.kotlin.ir.IrElement +import org.jetbrains.kotlin.ir.assertDetached +import org.jetbrains.kotlin.ir.declarations.IrFile +import org.jetbrains.kotlin.ir.declarations.IrModule +import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns +import org.jetbrains.kotlin.ir.detach +import org.jetbrains.kotlin.ir.throwNoSuchSlot +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import java.util.* + +class IrModuleImpl( + override val descriptor: ModuleDescriptor, + override val irBuiltins: IrBuiltIns +) : IrModule { + override val files: MutableList = ArrayList() + + fun addFile(file: IrFile) { + file.assertDetached() + file.setTreeLocation(this, files.size) + files.add(file) + } + + override fun getChild(slot: Int): IrElement? = + files.getOrNull(slot) + + override fun replaceChild(slot: Int, newChild: IrElement) { + newChild.assertDetached() + files.getOrNull(slot)?.detach() ?: throwNoSuchSlot(slot) + } + + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitModule(this, data) + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + files.forEach { it.accept(visitor, data) } + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertyAccessorBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertyAccessorBase.kt new file mode 100644 index 00000000000..c78f997adfe --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertyAccessorBase.kt @@ -0,0 +1,26 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.declarations.impl + +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrPropertyAccessor + +abstract class IrPropertyAccessorBase( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin +) : IrGeneralFunctionBase(startOffset, endOffset, origin), IrPropertyAccessor \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertyBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertyBase.kt new file mode 100644 index 00000000000..b0b0fdedd23 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertyBase.kt @@ -0,0 +1,63 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.declarations.impl + +import org.jetbrains.kotlin.descriptors.PropertyDescriptor +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrProperty +import org.jetbrains.kotlin.ir.declarations.IrPropertyGetter +import org.jetbrains.kotlin.ir.declarations.IrPropertySetter +import org.jetbrains.kotlin.ir.declarations.impl.IrDeclarationBase + +abstract class IrPropertyBase( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + override val descriptor: PropertyDescriptor +) : IrDeclarationBase(startOffset, endOffset, origin), IrProperty { + override var getter: IrPropertyGetter? = null + set(newGetter) { + newGetter?.assertDetached() + field?.detach() + field = newGetter + newGetter?.setTreeLocation(this, PROPERTY_GETTER_SLOT) + } + + override var setter: IrPropertySetter? = null + set(newSetter) { + newSetter?.assertDetached() + field?.detach() + field = newSetter + newSetter?.setTreeLocation(this, PROPERTY_SETTER_SLOT) + } + + override fun getChild(slot: Int): IrElement? = + when (slot) { + PROPERTY_GETTER_SLOT -> getter + PROPERTY_SETTER_SLOT -> setter + else -> null + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + when (slot) { + PROPERTY_GETTER_SLOT -> getter = newChild.assertCast() + PROPERTY_SETTER_SLOT -> setter = newChild.assertCast() + else -> throwNoSuchSlot(slot) + } + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertyGetterImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertyGetterImpl.kt new file mode 100644 index 00000000000..0c5e0efd7b4 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertyGetterImpl.kt @@ -0,0 +1,43 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.declarations.impl + +import org.jetbrains.kotlin.descriptors.PropertyGetterDescriptor +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrPropertyGetter +import org.jetbrains.kotlin.ir.expressions.IrBody +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +class IrPropertyGetterImpl( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + override val descriptor: PropertyGetterDescriptor +) : IrPropertyAccessorBase(startOffset, endOffset, origin), IrPropertyGetter { + constructor( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + descriptor: PropertyGetterDescriptor, + body: IrBody + ) : this(startOffset, endOffset, origin, descriptor) { + this.body = body + } + + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitPropertyGetter(this, data) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertySetterImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertySetterImpl.kt new file mode 100644 index 00000000000..1183a093b87 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertySetterImpl.kt @@ -0,0 +1,43 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.declarations.impl + +import org.jetbrains.kotlin.descriptors.PropertySetterDescriptor +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrPropertySetter +import org.jetbrains.kotlin.ir.expressions.IrBody +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +class IrPropertySetterImpl( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + override val descriptor: PropertySetterDescriptor +) : IrPropertyAccessorBase(startOffset, endOffset, origin), IrPropertySetter { + constructor( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + descriptor: PropertySetterDescriptor, + body: IrBody + ) : this(startOffset, endOffset, origin, descriptor) { + this.body = body + } + + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitPropertySetter(this, data) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrSimplePropertyImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrSimplePropertyImpl.kt new file mode 100644 index 00000000000..348340ac0d0 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrSimplePropertyImpl.kt @@ -0,0 +1,62 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.declarations.impl + +import org.jetbrains.kotlin.descriptors.PropertyDescriptor +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrSimpleProperty +import org.jetbrains.kotlin.ir.expressions.IrBody +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +class IrSimplePropertyImpl( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + descriptor: PropertyDescriptor, + valueInitializer: IrBody? = null +) : IrPropertyBase(startOffset, endOffset, origin, descriptor), IrSimpleProperty { + override var initializer: IrBody? = valueInitializer + set(value) { + value?.assertDetached() + field?.detach() + field = value + value?.setTreeLocation(this, INITIALIZER_SLOT) + } + + override fun getChild(slot: Int): IrElement? = + when (slot) { + INITIALIZER_SLOT -> initializer + else -> super.getChild(slot) + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + when (slot) { + INITIALIZER_SLOT -> initializer = newChild.assertCast() + else -> super.replaceChild(slot, newChild) + } + } + + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitSimpleProperty(this, data) + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + initializer?.accept(visitor, data) + getter?.accept(visitor, data) + setter?.accept(visitor, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrTypeAliasImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrTypeAliasImpl.kt new file mode 100644 index 00000000000..91a8dbda816 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrTypeAliasImpl.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.declarations.impl + +import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor +import org.jetbrains.kotlin.ir.IrElement +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrTypeAlias +import org.jetbrains.kotlin.ir.declarations.impl.IrDeclarationBase +import org.jetbrains.kotlin.ir.throwNoSuchSlot +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +class IrTypeAliasImpl( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + override val descriptor: TypeAliasDescriptor +) : IrDeclarationBase(startOffset, endOffset, origin), IrTypeAlias { + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitTypeAlias(this, data) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + // no children + } + + override fun getChild(slot: Int): IrElement? = null + + override fun replaceChild(slot: Int, newChild: IrElement) { + throwNoSuchSlot(slot) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrVariableImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrVariableImpl.kt new file mode 100644 index 00000000000..bbbed51cc34 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrVariableImpl.kt @@ -0,0 +1,71 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.declarations.impl + +import org.jetbrains.kotlin.descriptors.VariableDescriptor +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrVariable +import org.jetbrains.kotlin.ir.declarations.impl.IrDeclarationBase +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +class IrVariableImpl( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + override val descriptor: VariableDescriptor +) : IrDeclarationBase(startOffset, endOffset, origin), IrVariable { + constructor( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + descriptor: VariableDescriptor, + initializer: IrExpression + ) : this(startOffset, endOffset, origin, descriptor) { + this.initializer = initializer + } + + override var initializer: IrExpression? = null + set(value) { + value?.assertDetached() + field?.detach() + field = value + value?.setTreeLocation(this, INITIALIZER_SLOT) + } + + override fun getChild(slot: Int): IrElement? = + when (slot) { + INITIALIZER_SLOT -> initializer + else -> null + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + when (slot) { + INITIALIZER_SLOT -> initializer = newChild.assertCast() + else -> throwNoSuchSlot(slot) + } + } + + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitVariable(this, data) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + initializer?.accept(visitor, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBackingFieldExpression.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBackingFieldExpression.kt index 844330a0936..49daf9be601 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBackingFieldExpression.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBackingFieldExpression.kt @@ -18,10 +18,6 @@ package org.jetbrains.kotlin.ir.expressions import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.PropertyDescriptor -import org.jetbrains.kotlin.ir.* -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType -import org.jetbrains.kotlin.types.typeUtil.builtIns interface IrBackingFieldExpression : IrDeclarationReference { override val descriptor: PropertyDescriptor @@ -35,120 +31,3 @@ interface IrGetBackingField : IrBackingFieldExpression interface IrSetBackingField : IrBackingFieldExpression { var value: IrExpression } - -abstract class IrBackingFieldExpressionBase( - startOffset: Int, - endOffset: Int, - descriptor: PropertyDescriptor, - type: KotlinType, - override val operator: IrOperator? = null, - override val superQualifier: ClassDescriptor? = null -) : IrDeclarationReferenceBase(startOffset, endOffset, type, descriptor), IrBackingFieldExpression { - override final var receiver: IrExpression? = null - set(value) { - value?.assertDetached() - field?.detach() - field = value - value?.setTreeLocation(this, BACKING_FIELD_RECEIVER_SLOT) - } - - override fun getChild(slot: Int): IrElement? = - when (slot) { - BACKING_FIELD_RECEIVER_SLOT -> receiver - else -> null - } - - override fun replaceChild(slot: Int, newChild: IrElement) { - when (slot) { - BACKING_FIELD_RECEIVER_SLOT -> receiver = newChild.assertCast() - else -> throwNoSuchSlot(slot) - } - } -} - -class IrGetBackingFieldImpl( - startOffset: Int, - endOffset: Int, - descriptor: PropertyDescriptor, - operator: IrOperator? = null, - superQualifier: ClassDescriptor? = null -) : IrBackingFieldExpressionBase(startOffset, endOffset, descriptor, descriptor.type, operator, superQualifier), IrGetBackingField { - constructor( - startOffset: Int, - endOffset: Int, - descriptor: PropertyDescriptor, - receiver: IrExpression?, - operator: IrOperator? = null, - superQualifier: ClassDescriptor? = null - ) : this(startOffset, endOffset, descriptor, operator, superQualifier) { - this.receiver = receiver - } - - override fun getChild(slot: Int): IrElement? = - super.getChild(slot) - - override fun replaceChild(slot: Int, newChild: IrElement) { - super.replaceChild(slot, newChild) - } - - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitGetBackingField(this, data) - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - receiver?.accept(visitor, data) - } -} - -class IrSetBackingFieldImpl( - startOffset: Int, - endOffset: Int, - descriptor: PropertyDescriptor, - operator: IrOperator? = null, - superQualifier: ClassDescriptor? = null -) : IrBackingFieldExpressionBase(startOffset, endOffset, descriptor, descriptor.type.builtIns.unitType, operator, superQualifier), IrSetBackingField { - constructor( - startOffset: Int, - endOffset: Int, - descriptor: PropertyDescriptor, - receiver: IrExpression?, - value: IrExpression, - operator: IrOperator? = null, - superQualifier: ClassDescriptor? = null - ) : this(startOffset, endOffset, descriptor, operator, superQualifier) { - this.receiver = receiver - this.value = value - } - - private var valueImpl: IrExpression? = null - override var value: IrExpression - get() = valueImpl!! - set(value) { - value.assertDetached() - valueImpl?.detach() - valueImpl = value - value.setTreeLocation(this, CHILD_EXPRESSION_SLOT) - } - - override fun getChild(slot: Int): IrElement? = - when (slot) { - CHILD_EXPRESSION_SLOT -> value - else -> super.getChild(slot) - } - - override fun replaceChild(slot: Int, newChild: IrElement) { - when (slot) { - CHILD_EXPRESSION_SLOT -> value = newChild.assertCast() - else -> super.replaceChild(slot, newChild) - } - } - - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitSetBackingField(this, data) - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - receiver?.accept(visitor, data) - value.accept(visitor, data) - } -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBlock.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBlock.kt index ecb4036ba2b..327f4fd105d 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBlock.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBlock.kt @@ -16,10 +16,8 @@ package org.jetbrains.kotlin.ir.expressions -import org.jetbrains.kotlin.ir.* -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType -import java.util.* +import org.jetbrains.kotlin.ir.IrStatement +import org.jetbrains.kotlin.ir.detach interface IrBlock : IrExpression { @@ -28,79 +26,3 @@ interface IrBlock : IrExpression { val statements: List } -fun IrBlockImpl.addIfNotNull(statement: IrStatement?) { - if (statement != null) addStatement(statement) -} - -class IrEmptyBlockImpl(startOffset: Int, endOffset: Int, type: KotlinType, override val operator: IrOperator? = null) : - IrExpressionBase(startOffset, endOffset, type), IrBlock { - override val statements: List get() = emptyList() - - override fun getChild(slot: Int): IrElement? = null - - override fun replaceChild(slot: Int, newChild: IrElement) { - throwNoSuchSlot(slot) - } - - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitBlock(this, data) - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - // no children - } -} - -class IrBlockImpl(startOffset: Int, endOffset: Int, type: KotlinType, override val operator: IrOperator? = null): - IrExpressionBase(startOffset, endOffset, type), IrBlock { - constructor(startOffset: Int, endOffset: Int, type: KotlinType, operator: IrOperator?, statements: List) : - this(startOffset, endOffset, type, operator) { - addAll(statements) - } - - override val statements: MutableList = ArrayList(2) - - fun addStatement(statement: IrStatement) { - statement.assertDetached() - statement.setTreeLocation(this, statements.size) - statements.add(statement) - } - - fun addAll(newStatements: List) { - newStatements.forEach { it.assertDetached() } - val originalSize = this.statements.size - this.statements.addAll(newStatements) - newStatements.forEachIndexed { i, irStatement -> - irStatement.setTreeLocation(this, originalSize + i) - } - } - - override fun getChild(slot: Int): IrElement? = - statements.getOrNull(slot) - - override fun replaceChild(slot: Int, newChild: IrElement) { - if (slot < 0 || slot >= statements.size) throwNoSuchSlot(slot) - - newChild.assertDetached() - statements[slot].detach() - statements[slot] = newChild.assertCast() - newChild.setTreeLocation(this, slot) - } - - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitBlock(this, data) - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - statements.forEach { it.accept(visitor, data) } - } -} - -fun IrBlockImpl.inlineStatement(statement: IrStatement) { - if (statement is IrBlock) { - statement.statements.forEach { it.detach() } - addAll(statement.statements) - } - else { - addStatement(statement) - } -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBody.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBody.kt index 59a0e9492dd..67782216cf7 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBody.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBody.kt @@ -16,9 +16,8 @@ package org.jetbrains.kotlin.ir.expressions -import org.jetbrains.kotlin.ir.* -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import java.util.* +import org.jetbrains.kotlin.ir.IrElement +import org.jetbrains.kotlin.ir.IrStatement interface IrBody : IrElement @@ -39,84 +38,3 @@ enum class IrSyntheticBodyKind { ENUM_VALUEOF } -class IrExpressionBodyImpl(startOffset: Int, endOffset: Int) : IrElementBase(startOffset, endOffset), IrExpressionBody { - constructor(startOffset: Int, endOffset: Int, expression: IrExpression) : this(startOffset, endOffset) { - this.expression = expression - } - - private var expressionImpl: IrExpression? = null - override var expression: IrExpression - get() = expressionImpl!! - set(newValue) { - newValue.assertDetached() - expressionImpl?.detach() - expressionImpl = newValue - newValue.setTreeLocation(this, CHILD_EXPRESSION_SLOT) - } - - override fun getChild(slot: Int): IrElement? = - when (slot) { - CHILD_EXPRESSION_SLOT -> expression - else -> null - } - - override fun replaceChild(slot: Int, newChild: IrElement) { - when (slot) { - CHILD_EXPRESSION_SLOT -> expression = newChild.assertCast() - else -> throwNoSuchSlot(slot) - } - } - - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitExpressionBody(this, data) - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - expression.accept(visitor, data) - } -} - -class IrBlockBodyImpl(startOffset: Int, endOffset: Int) : IrElementBase(startOffset, endOffset), IrBlockBody { - override val statements: MutableList = ArrayList() - - fun addStatement(statement: IrStatement) { - statement.assertDetached() - statement.setTreeLocation(this, statements.size) - statements.add(statement) - } - - override fun getChild(slot: Int): IrElement? = - statements.getOrNull(slot) - - override fun replaceChild(slot: Int, newChild: IrElement) { - if (slot < 0 || slot >= statements.size) throwNoSuchSlot(slot) - - newChild.assertDetached() - statements[slot].detach() - statements[slot] = newChild.assertCast() - newChild.setTreeLocation(this, slot) - } - - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitBlockBody(this, data) - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - statements.forEach { it.accept(visitor, data) } - } -} - -class IrSyntheticBodyImpl(startOffset: Int, endOffset: Int, override val kind: IrSyntheticBodyKind) : IrElementBase(startOffset, endOffset), IrSyntheticBody { - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitSyntheticBody(this, data) - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - // no children - } - - override fun getChild(slot: Int): IrElement? = null - - override fun replaceChild(slot: Int, newChild: IrElement) { - throwNoSuchSlot(slot) - } -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBreakContinue.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBreakContinue.kt index 7c74453ad9a..3cdd5f1b80f 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBreakContinue.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBreakContinue.kt @@ -19,8 +19,7 @@ package org.jetbrains.kotlin.ir.expressions import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.util.dump import org.jetbrains.kotlin.ir.util.render -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType +import java.lang.AssertionError interface IrBreakContinue : IrExpression { var loop: IrLoop @@ -46,31 +45,3 @@ fun IrBreakContinue.getDepth(): Int { } } -abstract class IrBreakContinueBase( - startOffset: Int, - endOffset: Int, - type: KotlinType, - override var loop: IrLoop -) : IrTerminalExpressionBase(startOffset, endOffset, type), IrBreakContinue { - override var label: String? = null -} - -class IrBreakImpl( - startOffset: Int, - endOffset: Int, - type: KotlinType, - loop: IrLoop -) : IrBreakContinueBase(startOffset, endOffset, type, loop), IrBreak { - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitBreak(this, data) -} - -class IrContinueImpl( - startOffset: Int, - endOffset: Int, - type: KotlinType, - loop: IrLoop -) : IrBreakContinueBase(startOffset, endOffset, type, loop), IrContinue { - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitContinue(this, data) -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCall.kt index aaa0fb8dc0d..ceb0e9ac385 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCall.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCall.kt @@ -16,23 +16,9 @@ package org.jetbrains.kotlin.ir.expressions -import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType interface IrCall : IrGeneralCall { val superQualifier: ClassDescriptor? } -class IrCallImpl( - startOffset: Int, - endOffset: Int, - type: KotlinType, - override val descriptor: CallableDescriptor, - override val operator: IrOperator? = null, - override val superQualifier: ClassDescriptor? = null -) : IrGeneralCallBase(startOffset, endOffset, type, descriptor.valueParameters.size), IrCall { - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitCall(this, data) -} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCallableReference.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCallableReference.kt index 4b372a0f8d5..ef3d64bfc54 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCallableReference.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCallableReference.kt @@ -16,20 +16,5 @@ package org.jetbrains.kotlin.ir.expressions -import org.jetbrains.kotlin.descriptors.CallableDescriptor -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType - interface IrCallableReference : IrGeneralCall -class IrCallableReferenceImpl( - startOffset: Int, - endOffset: Int, - type: KotlinType, - override val descriptor: CallableDescriptor, - override val operator: IrOperator? = null -) : IrGeneralCallBase(startOffset, endOffset, type, descriptor.valueParameters.size, operator), IrCallableReference { - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitCallableReference(this, data) - } -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrClassReference.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrClassReference.kt index 37931ee9855..4c61efc9ccc 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrClassReference.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrClassReference.kt @@ -16,23 +16,10 @@ package org.jetbrains.kotlin.ir.expressions -import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassifierDescriptor -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType interface IrClassReference : IrDeclarationReference { override val descriptor: ClassifierDescriptor } -class IrClassReferenceImpl( - startOffset: Int, - endOffset: Int, - type: KotlinType, - descriptor: ClassifierDescriptor -) : IrTerminalDeclarationReferenceBase(startOffset, endOffset, type, descriptor), IrClassReference { - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitClassReference(this, data) - } -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrConst.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrConst.kt index 2b6c24bba97..0eb5bde9926 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrConst.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrConst.kt @@ -16,9 +16,6 @@ package org.jetbrains.kotlin.ir.expressions -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType - interface IrConst : IrExpression, IrExpressionWithCopy { val kind: IrConstKind val value: T @@ -45,55 +42,3 @@ sealed class IrConstKind(val asString: kotlin.String) { override fun toString() = asString } -class IrConstImpl ( - startOffset: Int, - endOffset: Int, - type: KotlinType, - override val kind: IrConstKind, - override val value: T -) : IrTerminalExpressionBase(startOffset, endOffset, type), IrConst { - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitConst(this, data) - - override fun copy(): IrConst = - IrConstImpl(startOffset, endOffset, type, kind, value) - - companion object { - fun string(startOffset: Int, endOffset: Int, type: KotlinType, value: String): IrConstImpl = - IrConstImpl(startOffset, endOffset, type, IrConstKind.String, value) - - fun int(startOffset: Int, endOffset: Int, type: KotlinType, value: Int): IrConstImpl = - IrConstImpl(startOffset, endOffset, type, IrConstKind.Int, value) - - fun constNull(startOffset: Int, endOffset: Int, type: KotlinType): IrConstImpl = - IrConstImpl(startOffset, endOffset, type, IrConstKind.Null, null) - - fun boolean(startOffset: Int, endOffset: Int, type: KotlinType, value: Boolean): IrConstImpl = - IrConstImpl(startOffset, endOffset, type, IrConstKind.Boolean, value) - - fun constTrue(startOffset: Int, endOffset: Int, type: KotlinType): IrConstImpl = - boolean(startOffset, endOffset, type, true) - - fun constFalse(startOffset: Int, endOffset: Int, type: KotlinType): IrConstImpl = - boolean(startOffset, endOffset, type, false) - - fun long(startOffset: Int, endOffset: Int, type: KotlinType, value: Long): IrExpression = - IrConstImpl(startOffset, endOffset, type, IrConstKind.Long, value) - - fun float(startOffset: Int, endOffset: Int, type: KotlinType, value: Float): IrExpression = - IrConstImpl(startOffset, endOffset, type, IrConstKind.Float, value) - - fun double(startOffset: Int, endOffset: Int, type: KotlinType, value: Double): IrExpression = - IrConstImpl(startOffset, endOffset, type, IrConstKind.Double, value) - - fun char(startOffset: Int, endOffset: Int, type: KotlinType, value: Char): IrExpression = - IrConstImpl(startOffset, endOffset, type, IrConstKind.Char, value) - - fun byte(startOffset: Int, endOffset: Int, type: KotlinType, value: Byte): IrExpression = - IrConstImpl(startOffset, endOffset, type, IrConstKind.Byte, value) - - fun short(startOffset: Int, endOffset: Int, type: KotlinType, value: Short): IrExpression = - IrConstImpl(startOffset, endOffset, type, IrConstKind.Short, value) - } -} - diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrDeclarationReference.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrDeclarationReference.kt index 2d32d5f8f1a..0122c111ba5 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrDeclarationReference.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrDeclarationReference.kt @@ -18,10 +18,6 @@ package org.jetbrains.kotlin.ir.expressions import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor -import org.jetbrains.kotlin.ir.IrElement -import org.jetbrains.kotlin.ir.throwNoSuchSlot -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType interface IrDeclarationReference : IrExpression { @@ -36,47 +32,3 @@ interface IrGetObjectValue : IrGetSingletonValue interface IrGetEnumValue : IrGetSingletonValue -abstract class IrDeclarationReferenceBase( - startOffset: Int, - endOffset: Int, - type: KotlinType, - override val descriptor: D -) : IrExpressionBase(startOffset, endOffset, type), IrDeclarationReference - -abstract class IrTerminalDeclarationReferenceBase( - startOffset: Int, - endOffset: Int, - type: KotlinType, - descriptor: D -) : IrDeclarationReferenceBase(startOffset, endOffset, type, descriptor) { - override fun getChild(slot: Int): IrElement? = null - - override fun replaceChild(slot: Int, newChild: IrElement) { - throwNoSuchSlot(slot) - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - // No children - } -} - -class IrGetObjectValueImpl( - startOffset: Int, - endOffset: Int, - type: KotlinType, - descriptor: ClassDescriptor -) : IrTerminalDeclarationReferenceBase(startOffset, endOffset, type, descriptor), IrGetObjectValue { - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitGetObjectValue(this, data) -} - -class IrGetEnumValueImpl( - startOffset: Int, - endOffset: Int, - type: KotlinType, - descriptor: ClassDescriptor -) : IrTerminalDeclarationReferenceBase(startOffset, endOffset, type, descriptor), IrGetEnumValue { - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitGetEnumValue(this, data) - } -} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrDelegatingConstructorCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrDelegatingConstructorCall.kt index 002c4441467..34a87abd117 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrDelegatingConstructorCall.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrDelegatingConstructorCall.kt @@ -17,18 +17,8 @@ package org.jetbrains.kotlin.ir.expressions import org.jetbrains.kotlin.descriptors.ConstructorDescriptor -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor interface IrDelegatingConstructorCall : IrGeneralCall { override val descriptor: ConstructorDescriptor } -class IrDelegatingConstructorCallImpl( - startOffset: Int, - endOffset: Int, - override val descriptor: ConstructorDescriptor -) : IrGeneralCallBase(startOffset, endOffset, descriptor.returnType, descriptor.valueParameters.size), IrDelegatingConstructorCall { - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitDelegatingConstructorCall(this, data) - } -} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrEnumConstructorCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrEnumConstructorCall.kt index b314aed6f94..b5ce2dd1248 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrEnumConstructorCall.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrEnumConstructorCall.kt @@ -18,7 +18,6 @@ package org.jetbrains.kotlin.ir.expressions import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ConstructorDescriptor -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor interface IrEnumConstructorCall : IrGeneralCall { @@ -29,13 +28,3 @@ interface IrEnumConstructorCall : IrGeneralCall { val IrEnumConstructorCall.isSuper: Boolean get() = enumEntryDescriptor == null -class IrEnumConstructorCallImpl( - startOffset: Int, - endOffset: Int, - override val descriptor: ConstructorDescriptor, - override val enumEntryDescriptor: ClassDescriptor? = null -) : IrGeneralCallBase(startOffset, endOffset, descriptor.returnType, descriptor.valueParameters.size), IrEnumConstructorCall { - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitEnumConstructorCall(this, data) - } -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrErrorExpression.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrErrorExpression.kt index d61c6cb1f6d..81bc6ecd765 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrErrorExpression.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrErrorExpression.kt @@ -16,11 +16,6 @@ package org.jetbrains.kotlin.ir.expressions -import org.jetbrains.kotlin.ir.* -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType -import org.jetbrains.kotlin.utils.SmartList - interface IrErrorExpression : IrExpression { val description: String } @@ -30,63 +25,3 @@ interface IrErrorCallExpression : IrErrorExpression { val arguments: List } -class IrErrorExpressionImpl( - startOffset: Int, - endOffset: Int, - type: KotlinType, - override val description: String -) : IrTerminalExpressionBase(startOffset, endOffset, type), IrExpressionWithCopy, IrErrorExpression { - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitErrorExpression(this, data) - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - // No children - } - - override fun copy(): IrErrorExpressionImpl = - IrErrorExpressionImpl(startOffset, endOffset, type, description) -} - -class IrErrorCallExpressionImpl( - startOffset: Int, - endOffset: Int, - type: KotlinType, - override val description: String -) : IrExpressionBase(startOffset, endOffset, type), IrErrorCallExpression { - override var explicitReceiver: IrExpression? = null - set(value) { - value?.assertDetached() - field?.detach() - field = value - value?.setTreeLocation(this, DISPATCH_RECEIVER_SLOT) - } - - override val arguments: MutableList = SmartList() - - fun addArgument(argument: IrExpression) { - argument.assertDetached() - argument.setTreeLocation(this, arguments.size) - arguments.add(argument) - } - - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitErrorCallExpression(this, data) - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - explicitReceiver?.accept(visitor, data) - arguments.forEach { it.accept(visitor, data) } - } - - override fun getChild(slot: Int): IrElement? = - arguments.getOrNull(slot) - - override fun replaceChild(slot: Int, newChild: IrElement) { - if (slot < 0 || slot >= arguments.size) throwNoSuchSlot(slot) - - newChild.assertDetached() - arguments[slot].detach() - arguments[slot] = newChild.assertCast() - newChild.setTreeLocation(this, slot) - } -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrExpression.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrExpression.kt index 72898318d1b..ee534f204fe 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrExpression.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrExpression.kt @@ -16,11 +16,7 @@ package org.jetbrains.kotlin.ir.expressions -import org.jetbrains.kotlin.ir.IrElement -import org.jetbrains.kotlin.ir.IrElementBase import org.jetbrains.kotlin.ir.IrStatement -import org.jetbrains.kotlin.ir.throwNoSuchSlot -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor import org.jetbrains.kotlin.types.KotlinType interface IrExpression : IrStatement, IrVarargElement { @@ -31,24 +27,3 @@ interface IrExpressionWithCopy : IrExpression { fun copy(): IrExpression } -abstract class IrExpressionBase( - startOffset: Int, - endOffset: Int, - override val type: KotlinType -) : IrElementBase(startOffset, endOffset), IrExpression - -abstract class IrTerminalExpressionBase( - startOffset: Int, - endOffset: Int, - type: KotlinType -) : IrExpressionBase(startOffset, endOffset, type) { - override fun getChild(slot: Int): IrElement? = null - - override fun replaceChild(slot: Int, newChild: IrElement) { - throwNoSuchSlot(slot) - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - // No children - } -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrGeneralCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrGeneralCall.kt index bb2705d5b97..9a262d935da 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrGeneralCall.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrGeneralCall.kt @@ -18,13 +18,6 @@ package org.jetbrains.kotlin.ir.expressions import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor -import org.jetbrains.kotlin.ir.IrElement -import org.jetbrains.kotlin.ir.assertCast -import org.jetbrains.kotlin.ir.assertDetached -import org.jetbrains.kotlin.ir.detach -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType -import java.lang.AssertionError interface IrGeneralCall : IrMemberAccessExpression { val operator: IrOperator? @@ -49,49 +42,3 @@ inline fun T.mapValueParameters(transform: (ValueParameterDe return this } -abstract class IrGeneralCallBase( - startOffset: Int, - endOffset: Int, - type: KotlinType, - numArguments: Int, - override val operator: IrOperator? = null -) : IrMemberAccessExpressionBase(startOffset, endOffset, type), IrGeneralCall { - protected val argumentsByParameterIndex = - arrayOfNulls(numArguments) - - override fun getArgument(index: Int): IrExpression? = - argumentsByParameterIndex[index] - - override fun putArgument(index: Int, valueArgument: IrExpression?) { - if (index >= argumentsByParameterIndex.size) { - throw AssertionError("$this: No such argument slot: $index") - } - valueArgument?.assertDetached() - argumentsByParameterIndex[index]?.detach() - argumentsByParameterIndex[index] = valueArgument - valueArgument?.setTreeLocation(this, index) - } - - override fun removeArgument(index: Int) { - argumentsByParameterIndex[index]?.detach() - argumentsByParameterIndex[index] = null - } - - override fun getChild(slot: Int): IrElement? = - if (0 <= slot) - argumentsByParameterIndex.getOrNull(slot) - else - super.getChild(slot) - - override fun replaceChild(slot: Int, newChild: IrElement) { - if (0 <= slot) - putArgument(slot, newChild.assertCast()) - else - super.replaceChild(slot, newChild) - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - super.acceptChildren(visitor, data) - argumentsByParameterIndex.forEach { it?.accept(visitor, data) } - } -} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrGetClass.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrGetClass.kt index c383af3286f..41f7d45d064 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrGetClass.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrGetClass.kt @@ -16,49 +16,8 @@ package org.jetbrains.kotlin.ir.expressions -import org.jetbrains.kotlin.ir.* -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType - interface IrGetClass : IrExpression { var argument : IrExpression } -class IrGetClassImpl(startOffset: Int, endOffset: Int, type: KotlinType) : IrExpressionBase(startOffset, endOffset, type), IrGetClass { - constructor(startOffset: Int, endOffset: Int, type: KotlinType, argument: IrExpression) : this(startOffset, endOffset, type) { - this.argument = argument - } - - private var argumentImpl: IrExpression? = null - override var argument: IrExpression - get() = argumentImpl!! - set(value) { - value.assertDetached() - argumentImpl?.detach() - argumentImpl = value - value.setTreeLocation(this, CHILD_EXPRESSION_SLOT) - } - - override fun getChild(slot: Int): IrElement? = - when (slot) { - CHILD_EXPRESSION_SLOT -> argument - else -> null - } - - override fun replaceChild(slot: Int, newChild: IrElement) { - when (slot) { - CHILD_EXPRESSION_SLOT -> argument = newChild.assertCast() - else -> throwNoSuchSlot(slot) - } - } - - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitGetClass(this, data) - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - argument.accept(visitor, data) - } - -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrGetExtensionReceiver.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrGetExtensionReceiver.kt index b6d1d6c29f9..a5c2eadd901 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrGetExtensionReceiver.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrGetExtensionReceiver.kt @@ -17,7 +17,6 @@ package org.jetbrains.kotlin.ir.expressions import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor interface IrGetExtensionReceiver : IrDeclarationReference, IrExpressionWithCopy { override val descriptor: ReceiverParameterDescriptor @@ -25,14 +24,3 @@ interface IrGetExtensionReceiver : IrDeclarationReference, IrExpressionWithCopy override fun copy(): IrGetExtensionReceiver } -class IrGetExtensionReceiverImpl( - startOffset: Int, - endOffset: Int, - descriptor: ReceiverParameterDescriptor -) : IrTerminalDeclarationReferenceBase(startOffset, endOffset, descriptor.type, descriptor), IrGetExtensionReceiver { - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitGetExtensionReceiver(this, data) - - override fun copy(): IrGetExtensionReceiver = - IrGetExtensionReceiverImpl(startOffset, endOffset, descriptor) -} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrInstanceInitializerCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrInstanceInitializerCall.kt index 683736f8fc6..9e5d3dedf27 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrInstanceInitializerCall.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrInstanceInitializerCall.kt @@ -17,19 +17,8 @@ package org.jetbrains.kotlin.ir.expressions import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns interface IrInstanceInitializerCall : IrExpression { val classDescriptor: ClassDescriptor } -class IrInstanceInitializerCallImpl( - startOffset: Int, - endOffset: Int, - override val classDescriptor: ClassDescriptor -) : IrTerminalExpressionBase(startOffset, endOffset, classDescriptor.builtIns.unitType), IrInstanceInitializerCall { - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitInstanceInitializerCall(this, data) - } -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrLoop.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrLoop.kt index f8f7e596adc..9a3c8acb97b 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrLoop.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrLoop.kt @@ -16,10 +16,6 @@ package org.jetbrains.kotlin.ir.expressions -import org.jetbrains.kotlin.ir.* -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType - interface IrLoop : IrExpression { val operator: IrOperator? var body: IrExpression? @@ -31,100 +27,3 @@ interface IrWhileLoop : IrLoop interface IrDoWhileLoop : IrLoop -abstract class IrLoopBase( - startOffset: Int, - endOffset: Int, - type: KotlinType, - override val operator: IrOperator? -) : IrExpressionBase(startOffset, endOffset, type), IrLoop { - override var label: String? = null - - private var conditionImpl: IrExpression? = null - override var condition: IrExpression - get() = conditionImpl!! - set(value) { - value.assertDetached() - conditionImpl?.detach() - conditionImpl = value - value.setTreeLocation(this, LOOP_CONDITION_SLOT) - } - - override var body: IrExpression? = null - set(value) { - value?.assertDetached() - field?.detach() - field = value - value?.setTreeLocation(this, LOOP_BODY_SLOT) - } - - override fun getChild(slot: Int): IrElement? = - when (slot) { - LOOP_BODY_SLOT -> body - LOOP_CONDITION_SLOT -> condition - else -> null - } - - override fun replaceChild(slot: Int, newChild: IrElement) { - when (slot) { - LOOP_BODY_SLOT -> body = newChild.assertCast() - LOOP_CONDITION_SLOT -> condition = newChild.assertCast() - else -> throwNoSuchSlot(slot) - } - } -} - -class IrWhileLoopImpl( - startOffset: Int, - endOffset: Int, - type: KotlinType, - operator: IrOperator? -) : IrLoopBase(startOffset, endOffset, type, operator), IrWhileLoop { - constructor( - startOffset: Int, - endOffset: Int, - type: KotlinType, - operator: IrOperator?, - condition: IrExpression, - body: IrExpression - ) : this(startOffset, endOffset, type, operator) { - this.condition = condition - this.body = body - } - - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitWhileLoop(this, data) - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - condition.accept(visitor, data) - body?.accept(visitor, data) - } -} - -class IrDoWhileLoopImpl( - startOffset: Int, - endOffset: Int, - type : KotlinType, - operator: IrOperator? -) : IrLoopBase(startOffset, endOffset, type, operator), IrDoWhileLoop { - constructor( - startOffset: Int, - endOffset: Int, - type: KotlinType, - operator: IrOperator?, - body: IrExpression, - condition: IrExpression - ) : this(startOffset, endOffset, type, operator) { - this.condition = condition - this.body = body - } - - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitDoWhileLoop(this, data) - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - body?.accept(visitor, data) - condition.accept(visitor, data) - } -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrMemberAccessExpression.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrMemberAccessExpression.kt index a9f7a4bf00f..95c3e122fa4 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrMemberAccessExpression.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrMemberAccessExpression.kt @@ -16,53 +16,8 @@ package org.jetbrains.kotlin.ir.expressions -import org.jetbrains.kotlin.ir.* -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType - interface IrMemberAccessExpression : IrDeclarationReference { var dispatchReceiver: IrExpression? var extensionReceiver: IrExpression? } -abstract class IrMemberAccessExpressionBase( - startOffset: Int, - endOffset: Int, - type: KotlinType -) : IrExpressionBase(startOffset, endOffset, type), IrMemberAccessExpression { - override var dispatchReceiver: IrExpression? = null - set(newReceiver) { - newReceiver?.assertDetached() - field?.detach() - field = newReceiver - newReceiver?.setTreeLocation(this, DISPATCH_RECEIVER_SLOT) - } - - override var extensionReceiver: IrExpression? = null - set(newReceiver) { - newReceiver?.assertDetached() - field?.detach() - field = newReceiver - newReceiver?.setTreeLocation(this, EXTENSION_RECEIVER_SLOT) - } - - override fun getChild(slot: Int): IrElement? = - when (slot) { - DISPATCH_RECEIVER_SLOT -> dispatchReceiver - EXTENSION_RECEIVER_SLOT -> extensionReceiver - else -> null - } - - override fun replaceChild(slot: Int, newChild: IrElement) { - when (slot) { - DISPATCH_RECEIVER_SLOT -> dispatchReceiver = newChild.assertCast() - EXTENSION_RECEIVER_SLOT -> extensionReceiver = newChild.assertCast() - else -> throwNoSuchSlot(slot) - } - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - dispatchReceiver?.accept(visitor, data) - extensionReceiver?.accept(visitor, data) - } -} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrReturn.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrReturn.kt index e68aef820bf..ab551dc893a 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrReturn.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrReturn.kt @@ -17,9 +17,6 @@ package org.jetbrains.kotlin.ir.expressions import org.jetbrains.kotlin.descriptors.CallableDescriptor -import org.jetbrains.kotlin.ir.* -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType interface IrReturn : IrExpression { @@ -27,49 +24,3 @@ interface IrReturn : IrExpression { val returnTarget: CallableDescriptor } -class IrReturnImpl( - startOffset: Int, - endOffset: Int, - type: KotlinType, - override val returnTarget: CallableDescriptor -) : IrExpressionBase(startOffset, endOffset, type), IrReturn { - constructor( - startOffset: Int, - endOffset: Int, - type: KotlinType, - returnTarget: CallableDescriptor, - value: IrExpression? - ) : this(startOffset, endOffset, type, returnTarget) { - this.value = value - } - - override var value: IrExpression? = null - set(newValue) { - newValue?.assertDetached() - field?.detach() - field = newValue - newValue?.setTreeLocation(this, CHILD_EXPRESSION_SLOT) - } - - override fun getChild(slot: Int): IrElement? = - when (slot) { - CHILD_EXPRESSION_SLOT -> value - else -> null - } - - override fun replaceChild(slot: Int, newChild: IrElement) { - when (slot) { - CHILD_EXPRESSION_SLOT -> value = newChild.assertCast() - else -> throwNoSuchSlot(slot) - } - } - - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitReturn(this, data) - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - value?.accept(visitor, data) - } - - -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrStringConcatenation.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrStringConcatenation.kt index 91764279050..2e745eeab6c 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrStringConcatenation.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrStringConcatenation.kt @@ -16,45 +16,8 @@ package org.jetbrains.kotlin.ir.expressions -import org.jetbrains.kotlin.ir.* -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType -import java.util.* - interface IrStringConcatenation : IrExpression { val arguments: List fun addArgument(argument: IrExpression) } -class IrStringConcatenationImpl( - startOffset: Int, - endOffset: Int, - type: KotlinType -) : IrExpressionBase(startOffset, endOffset, type), IrStringConcatenation { - override val arguments: MutableList = ArrayList() - - override fun addArgument(argument: IrExpression) { - argument.assertDetached() - argument.setTreeLocation(this, arguments.size) - arguments.add(argument) - } - - override fun getChild(slot: Int): IrElement? = - arguments.getOrNull(slot) - - override fun replaceChild(slot: Int, newChild: IrElement) { - if (slot < 0 || slot >= arguments.size) throwNoSuchSlot(slot) - - newChild.assertDetached() - arguments[slot].detach() - arguments[slot] = newChild.assertCast() - newChild.setTreeLocation(this, slot) - } - - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitStringConcatenation(this, data) - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - arguments.forEach { it.accept(visitor, data) } - } -} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrThisReference.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrThisReference.kt index bbaed5346f9..56cf09fa0de 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrThisReference.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrThisReference.kt @@ -18,8 +18,6 @@ package org.jetbrains.kotlin.ir.expressions import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType interface IrThisReference : IrExpression, IrExpressionWithCopy { val classDescriptor: ClassDescriptor @@ -29,15 +27,3 @@ interface IrThisReference : IrExpression, IrExpressionWithCopy { val IrThisReference.receiverParameter: ReceiverParameterDescriptor get() = classDescriptor.thisAsReceiverParameter -class IrThisReferenceImpl( - startOffset: Int, - endOffset: Int, - type: KotlinType, - override val classDescriptor: ClassDescriptor -) : IrTerminalExpressionBase(startOffset, endOffset, type), IrThisReference { - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitThisReference(this, data) - - override fun copy(): IrThisReference = - IrThisReferenceImpl(startOffset, endOffset, type, classDescriptor) -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrThrow.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrThrow.kt index 4bc18930f24..d59944d9135 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrThrow.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrThrow.kt @@ -16,58 +16,8 @@ package org.jetbrains.kotlin.ir.expressions -import org.jetbrains.kotlin.ir.* -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType - interface IrThrow : IrExpression { var value: IrExpression } -class IrThrowImpl( - startOffset: Int, - endOffset: Int, - type: KotlinType -) : IrExpressionBase(startOffset, endOffset, type), IrThrow { - constructor( - startOffset: Int, - endOffset: Int, - type: KotlinType, - value: IrExpression - ) : this(startOffset, endOffset, type) { - this.value = value - } - - private var valueImpl: IrExpression? = null - override var value: IrExpression - get() = valueImpl!! - set(newValue) { - newValue.assertDetached() - valueImpl?.detach() - valueImpl = newValue - newValue.setTreeLocation(this, CHILD_EXPRESSION_SLOT) - } - - override fun getChild(slot: Int): IrElement? = - when (slot) { - CHILD_EXPRESSION_SLOT -> value - else -> null - } - - override fun replaceChild(slot: Int, newChild: IrElement) { - when (slot) { - CHILD_EXPRESSION_SLOT -> value = newChild.assertCast() - else -> throwNoSuchSlot(slot) - } - } - - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitThrow(this, data) - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - value.accept(visitor, data) - } - - -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrTryCatch.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrTryCatch.kt index dad0970a1d3..02cad96c228 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrTryCatch.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrTryCatch.kt @@ -17,10 +17,6 @@ package org.jetbrains.kotlin.ir.expressions import org.jetbrains.kotlin.descriptors.VariableDescriptor -import org.jetbrains.kotlin.ir.* -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType -import org.jetbrains.kotlin.utils.SmartList interface IrTryCatch : IrExpression { var tryResult: IrExpression @@ -34,88 +30,3 @@ interface IrTryCatch : IrExpression { val IrTryCatch.catchClauseIndices: IntRange get() = 0 ..catchClausesCount - 1 -class IrTryCatchImpl( - startOffset: Int, - endOffset: Int, - type: KotlinType -) : IrExpressionBase(startOffset, endOffset, type), IrTryCatch { - private var tryResultImpl: IrExpression? = null - override var tryResult: IrExpression - get() = tryResultImpl!! - set(value) { - value.assertDetached() - tryResultImpl?.detach() - tryResultImpl = value - value.setTreeLocation(this, TRY_RESULT_SLOT) - } - - private val catchClauseParameters = SmartList() - private val catchClauseResults = SmartList() - - override val catchClausesCount: Int get() = catchClauseResults.size - - fun addCatchClause(parameter: VariableDescriptor, result: IrExpression) { - result.assertDetached() - result.setTreeLocation(this, catchClausesCount) - catchClauseParameters.add(parameter) - catchClauseResults.add(result) - } - - override fun getNthCatchParameter(n: Int): VariableDescriptor? = - catchClauseParameters.getOrNull(n) - - override fun getNthCatchResult(n: Int): IrExpression? = - catchClauseResults.getOrNull(n) - - override var finallyExpression: IrExpression? = null - set(value) { - value?.assertDetached() - field?.detach() - field = value - value?.setTreeLocation(this, FINALLY_EXPRESSION_SLOT) - } - - override fun getChild(slot: Int): IrElement? = - when { - slot == TRY_RESULT_SLOT -> - tryResult - slot >= 0 -> - catchClauseResults.getOrNull(slot) - slot == FINALLY_EXPRESSION_SLOT -> - finallyExpression - else -> null - } - - override fun replaceChild(slot: Int, newChild: IrElement) { - when { - slot == TRY_RESULT_SLOT -> - tryResult = newChild.assertCast() - slot >= 0 -> - putCatchClauseElement(catchClauseResults, newChild, slot) - slot == FINALLY_EXPRESSION_SLOT -> - finallyExpression = newChild.assertCast() - else -> - throwNoSuchSlot(slot) - } - } - - private inline fun putCatchClauseElement(list: MutableList, newChild: IrElement, slot: Int) { - if (slot < 0 || slot >= list.size) throwNoSuchSlot(slot) - - list[slot].detach() - list[slot] = newChild.assertCast() - newChild.setTreeLocation(this, slot) - } - - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitTryCatch(this, data) - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - tryResult.accept(visitor, data) - for (index in 0 ..catchClausesCount - 1) { - catchClauseResults[index].accept(visitor, data) - } - finallyExpression?.accept(visitor, data) - } -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrTypeOperatorCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrTypeOperatorCall.kt index c001c208ada..443149037b2 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrTypeOperatorCall.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrTypeOperatorCall.kt @@ -16,8 +16,6 @@ package org.jetbrains.kotlin.ir.expressions -import org.jetbrains.kotlin.ir.* -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor import org.jetbrains.kotlin.types.KotlinType enum class IrTypeOperator { @@ -35,53 +33,3 @@ interface IrTypeOperatorCall : IrExpression { val typeOperand: KotlinType } -class IrTypeOperatorCallImpl( - startOffset: Int, - endOffset: Int, - type: KotlinType, - override val operator: IrTypeOperator, - override val typeOperand: KotlinType -) : IrExpressionBase(startOffset, endOffset, type), IrTypeOperatorCall { - constructor( - startOffset: Int, - endOffset: Int, - type: KotlinType, - operator: IrTypeOperator, - typeOperand: KotlinType, - argument: IrExpression - ) : this(startOffset, endOffset, type, operator, typeOperand) { - this.argument = argument - } - - private var argumentImpl: IrExpression? = null - override var argument: IrExpression - get() = argumentImpl!! - set(value) { - value.assertDetached() - argumentImpl?.detach() - argumentImpl = value - value.setTreeLocation(this, ARGUMENT0_SLOT) - } - - override fun getChild(slot: Int): IrElement? = - when (slot) { - ARGUMENT0_SLOT -> argument - else -> null - } - - override fun replaceChild(slot: Int, newChild: IrElement) { - when (slot) { - ARGUMENT0_SLOT -> argument = newChild.assertCast() - else -> throwNoSuchSlot(slot) - } - } - - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitTypeOperator(this, data) - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - argument.accept(visitor, data) - } - - -} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrVararg.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrVararg.kt index ef4284232c8..f149bbb6951 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrVararg.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrVararg.kt @@ -16,10 +16,8 @@ package org.jetbrains.kotlin.ir.expressions -import org.jetbrains.kotlin.ir.* -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.types.KotlinType -import org.jetbrains.kotlin.utils.SmartList interface IrVarargElement : IrElement @@ -32,80 +30,3 @@ interface IrSpreadElement : IrVarargElement { var expression: IrExpression } -class IrVarargImpl( - startOffset: Int, - endOffset: Int, - type: KotlinType, - override val varargElementType: KotlinType -) : IrVararg, IrExpressionBase(startOffset, endOffset, type) { - override val elements: MutableList = SmartList() - - fun addElement(varargElement: IrVarargElement) { - varargElement.assertDetached() - varargElement.setTreeLocation(this, elements.size) - elements.add(varargElement) - } - - override fun getChild(slot: Int): IrElement? = - elements.getOrNull(slot) - - override fun replaceChild(slot: Int, newChild: IrElement) { - if (slot < 0 || slot >= elements.size) throwNoSuchSlot(slot) - - newChild.assertDetached() - elements[slot].detach() - elements[slot] = newChild.assertCast() - newChild.setTreeLocation(this, slot) - } - - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitVararg(this, data) - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - elements.forEach { it.accept(visitor, data) } - } -} - -class IrSpreadElementImpl( - startOffset: Int, - endOffset: Int -) : IrElementBase(startOffset, endOffset), IrSpreadElement { - constructor(startOffset: Int, endOffset: Int, expression: IrExpression) : this(startOffset, endOffset) { - this.expression = expression - } - - private var expressionImpl: IrExpression? = null - override var expression: IrExpression - get() = expressionImpl!! - set(value) { - value.assertDetached() - expressionImpl?.detach() - expressionImpl = value - value.setTreeLocation(this, CHILD_EXPRESSION_SLOT) - } - - - override fun getChild(slot: Int): IrElement? = - when (slot) { - CHILD_EXPRESSION_SLOT -> expression - else -> null - } - - override fun replaceChild(slot: Int, newChild: IrElement) { - when (slot) { - CHILD_EXPRESSION_SLOT -> expression = newChild.assertCast() - else -> throwNoSuchSlot(slot) - } - } - - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitSpreadElement(this, data) - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - expression.accept(visitor, data) - } - - -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrVariableAccessExpression.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrVariableAccessExpression.kt index 78f960347f6..3a2dae6487c 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrVariableAccessExpression.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrVariableAccessExpression.kt @@ -17,9 +17,6 @@ package org.jetbrains.kotlin.ir.expressions import org.jetbrains.kotlin.descriptors.VariableDescriptor -import org.jetbrains.kotlin.ir.* -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns interface IrVariableAccessExpression : IrDeclarationReference { override val descriptor: VariableDescriptor @@ -34,63 +31,3 @@ interface IrSetVariable : IrVariableAccessExpression { var value: IrExpression } -class IrGetVariableImpl( - startOffset: Int, - endOffset: Int, - descriptor: VariableDescriptor, - override val operator: IrOperator? = null -) : IrTerminalDeclarationReferenceBase(startOffset, endOffset, descriptor.type, descriptor), IrGetVariable { - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitGetVariable(this, data) - - override fun copy(): IrGetVariable = - IrGetVariableImpl(startOffset, endOffset, descriptor, operator) -} - -class IrSetVariableImpl( - startOffset: Int, - endOffset: Int, - override val descriptor: VariableDescriptor, - override val operator: IrOperator? -) : IrExpressionBase(startOffset, endOffset, descriptor.builtIns.unitType), IrSetVariable { - constructor( - startOffset: Int, - endOffset: Int, - descriptor: VariableDescriptor, - value: IrExpression, - operator: IrOperator? - ) : this(startOffset, endOffset, descriptor, operator) { - this.value = value - } - - private var valueImpl: IrExpression? = null - override var value: IrExpression - get() = valueImpl!! - set(value) { - value.assertDetached() - valueImpl?.detach() - valueImpl = value - value.setTreeLocation(this, ARGUMENT0_SLOT) - } - - override fun getChild(slot: Int): IrElement? = - when (slot) { - ARGUMENT0_SLOT -> value - else -> null - } - - override fun replaceChild(slot: Int, newChild: IrElement) { - when (slot) { - ARGUMENT0_SLOT -> value = newChild.assertCast() - else -> throwNoSuchSlot(slot) - } - } - - override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitSetVariable(this, data) - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - value.accept(visitor, data) - } -} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrWhen.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrWhen.kt index e0472bd94c7..3471268d1a8 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrWhen.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrWhen.kt @@ -16,11 +16,6 @@ package org.jetbrains.kotlin.ir.expressions -import org.jetbrains.kotlin.ir.* -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType -import java.util.* - interface IrWhen : IrExpression { val operator: IrOperator? val branchesCount: Int @@ -31,151 +26,3 @@ interface IrWhen : IrExpression { val IrWhen.branchIndices: IntRange get() = 0 ..branchesCount - 1 -class IrWhenImpl( - startOffset: Int, - endOffset: Int, - type: KotlinType, - override val operator: IrOperator? = null -) : IrExpressionBase(startOffset, endOffset, type), IrWhen { - private val branchParts = ArrayList() - - fun addBranch(condition: IrExpression, result: IrExpression) { - condition.assertDetached() - result.assertDetached() - condition.setTreeLocation(this, branchParts.size) - branchParts.add(condition) - result.setTreeLocation(this, branchParts.size) - branchParts.add(result) - } - - override var elseBranch: IrExpression? = null - set(value) { - value?.assertDetached() - value?.detach() - field = value - value?.setTreeLocation(this, IF_ELSE_SLOT) - } - - override fun getChild(slot: Int): IrElement? { - return when (slot) { - IF_ELSE_SLOT -> elseBranch - else -> branchParts.getOrNull(slot) - } - } - - override fun replaceChild(slot: Int, newChild: IrElement) { - when (slot) { - IF_ELSE_SLOT -> elseBranch = newChild.assertCast() - in branchParts.indices -> { - newChild.assertDetached() - branchParts[slot].detach() - branchParts[slot] = newChild.assertCast() - newChild.setTreeLocation(this, slot) - } - else -> - throwNoSuchSlot(slot) - } - } - - override val branchesCount: Int get() = branchParts.size / 2 - - override fun getNthCondition(n: Int): IrExpression? = - branchParts.getOrNull(n * 2) - - override fun getNthResult(n: Int): IrExpression? = - branchParts.getOrNull(n * 2 + 1) - - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitWhen(this, data) - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - branchParts.forEach { it.accept(visitor, data) } - elseBranch?.accept(visitor, data) - } -} - -class IrIfThenElseImpl( - startOffset: Int, - endOffset: Int, - type: KotlinType, - override val operator: IrOperator? = null -) : IrExpressionBase(startOffset, endOffset, type), IrWhen { - constructor( - startOffset: Int, - endOffset: Int, - type: KotlinType, - condition: IrExpression, - thenBranch: IrExpression, - elseBranch: IrExpression? = null, - operator: IrOperator? = null - ) : this(startOffset, endOffset, type, operator) { - this.condition = condition - this.thenBranch = thenBranch - this.elseBranch = elseBranch - } - - override val branchesCount: Int get() = 1 - - override fun getNthCondition(n: Int): IrExpression? = - if (n == 0) condition else null - - override fun getNthResult(n: Int): IrExpression? = - if (n == 0) thenBranch else null - - private var conditionImpl: IrExpression? = null - var condition: IrExpression - get() = conditionImpl!! - set(value) { - value.assertDetached() - value.detach() - conditionImpl = value - value.setTreeLocation(this, IF_CONDITION_SLOT) - } - - private var thenBranchImpl: IrExpression? = null - var thenBranch: IrExpression - get() = thenBranchImpl!! - set(value) { - value.assertDetached() - value.detach() - thenBranchImpl = value - value.setTreeLocation(this, IF_THEN_SLOT) - } - - override var elseBranch: IrExpression? = null - set(value) { - value?.assertDetached() - value?.detach() - field = value - value?.setTreeLocation(this, IF_ELSE_SLOT) - } - - override fun getChild(slot: Int): IrElement? = - when (slot) { - IF_CONDITION_SLOT -> condition - IF_THEN_SLOT -> thenBranch - IF_ELSE_SLOT -> elseBranch - else -> null - } - - override fun replaceChild(slot: Int, newChild: IrElement) { - newChild.assertDetached() - when (slot) { - IF_CONDITION_SLOT -> - condition = newChild.assertCast() - IF_THEN_SLOT -> - thenBranch = newChild.assertCast() - IF_ELSE_SLOT -> - elseBranch = newChild.assertCast() - } - } - - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitWhen(this, data) - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - condition.accept(visitor, data) - thenBranch.accept(visitor, data) - elseBranch?.accept(visitor, data) - } -} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBackingFieldExpressionBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBackingFieldExpressionBase.kt new file mode 100644 index 00000000000..0df15e43bc8 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBackingFieldExpressionBase.kt @@ -0,0 +1,55 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.PropertyDescriptor +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.expressions.IrBackingFieldExpression +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrOperator +import org.jetbrains.kotlin.types.KotlinType + +abstract class IrBackingFieldExpressionBase( + startOffset: Int, + endOffset: Int, + descriptor: PropertyDescriptor, + type: KotlinType, + override val operator: IrOperator? = null, + override val superQualifier: ClassDescriptor? = null +) : IrDeclarationReferenceBase(startOffset, endOffset, type, descriptor), IrBackingFieldExpression { + override final var receiver: IrExpression? = null + set(value) { + value?.assertDetached() + field?.detach() + field = value + value?.setTreeLocation(this, BACKING_FIELD_RECEIVER_SLOT) + } + + override fun getChild(slot: Int): IrElement? = + when (slot) { + BACKING_FIELD_RECEIVER_SLOT -> receiver + else -> null + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + when (slot) { + BACKING_FIELD_RECEIVER_SLOT -> receiver = newChild.assertCast() + else -> throwNoSuchSlot(slot) + } + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBlockBodyImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBlockBodyImpl.kt new file mode 100644 index 00000000000..7abab877499 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBlockBodyImpl.kt @@ -0,0 +1,52 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.expressions.IrBlockBody +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import java.util.* + +class IrBlockBodyImpl(startOffset: Int, endOffset: Int) : IrElementBase(startOffset, endOffset), IrBlockBody { + override val statements: MutableList = ArrayList() + + fun addStatement(statement: IrStatement) { + statement.assertDetached() + statement.setTreeLocation(this, statements.size) + statements.add(statement) + } + + override fun getChild(slot: Int): IrElement? = + statements.getOrNull(slot) + + override fun replaceChild(slot: Int, newChild: IrElement) { + if (slot < 0 || slot >= statements.size) throwNoSuchSlot(slot) + + newChild.assertDetached() + statements[slot].detach() + statements[slot] = newChild.assertCast() + newChild.setTreeLocation(this, slot) + } + + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitBlockBody(this, data) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + statements.forEach { it.accept(visitor, data) } + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBlockImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBlockImpl.kt new file mode 100644 index 00000000000..4d7fedea6a9 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBlockImpl.kt @@ -0,0 +1,82 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.expressions.IrBlock +import org.jetbrains.kotlin.ir.expressions.IrOperator +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType +import java.util.* + +class IrBlockImpl(startOffset: Int, endOffset: Int, type: KotlinType, override val operator: IrOperator? = null): + IrExpressionBase(startOffset, endOffset, type), IrBlock { + constructor(startOffset: Int, endOffset: Int, type: KotlinType, operator: IrOperator?, statements: List) : + this(startOffset, endOffset, type, operator) { + addAll(statements) + } + + override val statements: MutableList = ArrayList(2) + + fun addStatement(statement: IrStatement) { + statement.assertDetached() + statement.setTreeLocation(this, statements.size) + statements.add(statement) + } + + fun addAll(newStatements: List) { + newStatements.forEach { it.assertDetached() } + val originalSize = this.statements.size + this.statements.addAll(newStatements) + newStatements.forEachIndexed { i, irStatement -> + irStatement.setTreeLocation(this, originalSize + i) + } + } + + override fun getChild(slot: Int): IrElement? = + statements.getOrNull(slot) + + override fun replaceChild(slot: Int, newChild: IrElement) { + if (slot < 0 || slot >= statements.size) throwNoSuchSlot(slot) + + newChild.assertDetached() + statements[slot].detach() + statements[slot] = newChild.assertCast() + newChild.setTreeLocation(this, slot) + } + + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitBlock(this, data) + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + statements.forEach { it.accept(visitor, data) } + } +} + +fun IrBlockImpl.addIfNotNull(statement: IrStatement?) { + if (statement != null) addStatement(statement) +} + +fun IrBlockImpl.inlineStatement(statement: IrStatement) { + if (statement is IrBlock) { + statement.statements.forEach { it.detach() } + addAll(statement.statements) + } + else { + addStatement(statement) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBreakContinueBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBreakContinueBase.kt new file mode 100644 index 00000000000..a4d5e6b5291 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBreakContinueBase.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.expressions.IrBreakContinue +import org.jetbrains.kotlin.ir.expressions.IrLoop +import org.jetbrains.kotlin.ir.expressions.impl.IrTerminalExpressionBase +import org.jetbrains.kotlin.types.KotlinType + +abstract class IrBreakContinueBase( + startOffset: Int, + endOffset: Int, + type: KotlinType, + override var loop: IrLoop +) : IrTerminalExpressionBase(startOffset, endOffset, type), IrBreakContinue { + override var label: String? = null +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBreakImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBreakImpl.kt new file mode 100644 index 00000000000..01799bf4f75 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBreakImpl.kt @@ -0,0 +1,32 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.expressions.IrBreak +import org.jetbrains.kotlin.ir.expressions.IrLoop +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType + +class IrBreakImpl( + startOffset: Int, + endOffset: Int, + type: KotlinType, + loop: IrLoop +) : IrBreakContinueBase(startOffset, endOffset, type, loop), IrBreak { + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitBreak(this, data) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCallImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCallImpl.kt new file mode 100644 index 00000000000..61dd8d3c08f --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCallImpl.kt @@ -0,0 +1,36 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.descriptors.CallableDescriptor +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.ir.expressions.IrCall +import org.jetbrains.kotlin.ir.expressions.IrOperator +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType + +class IrCallImpl( + startOffset: Int, + endOffset: Int, + type: KotlinType, + override val descriptor: CallableDescriptor, + override val operator: IrOperator? = null, + override val superQualifier: ClassDescriptor? = null +) : IrGeneralCallBase(startOffset, endOffset, type, descriptor.valueParameters.size), IrCall { + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitCall(this, data) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCallableReferenceImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCallableReferenceImpl.kt new file mode 100644 index 00000000000..19827dea983 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCallableReferenceImpl.kt @@ -0,0 +1,35 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.descriptors.CallableDescriptor +import org.jetbrains.kotlin.ir.expressions.IrCallableReference +import org.jetbrains.kotlin.ir.expressions.IrOperator +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType + +class IrCallableReferenceImpl( + startOffset: Int, + endOffset: Int, + type: KotlinType, + override val descriptor: CallableDescriptor, + override val operator: IrOperator? = null +) : IrGeneralCallBase(startOffset, endOffset, type, descriptor.valueParameters.size, operator), IrCallableReference { + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitCallableReference(this, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrClassReferenceImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrClassReferenceImpl.kt new file mode 100644 index 00000000000..eb67c647f37 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrClassReferenceImpl.kt @@ -0,0 +1,34 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.descriptors.ClassifierDescriptor +import org.jetbrains.kotlin.ir.expressions.IrClassReference +import org.jetbrains.kotlin.ir.expressions.impl.IrTerminalDeclarationReferenceBase +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType + +class IrClassReferenceImpl( + startOffset: Int, + endOffset: Int, + type: KotlinType, + descriptor: ClassifierDescriptor +) : IrTerminalDeclarationReferenceBase(startOffset, endOffset, type, descriptor), IrClassReference { + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitClassReference(this, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrConstImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrConstImpl.kt new file mode 100644 index 00000000000..4b9963c21ff --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrConstImpl.kt @@ -0,0 +1,76 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.expressions.IrConst +import org.jetbrains.kotlin.ir.expressions.IrConstKind +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.impl.IrTerminalExpressionBase +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType + +class IrConstImpl ( + startOffset: Int, + endOffset: Int, + type: KotlinType, + override val kind: IrConstKind, + override val value: T +) : IrTerminalExpressionBase(startOffset, endOffset, type), IrConst { + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitConst(this, data) + + override fun copy(): IrConst = + IrConstImpl(startOffset, endOffset, type, kind, value) + + companion object { + fun string(startOffset: Int, endOffset: Int, type: KotlinType, value: String): IrConstImpl = + IrConstImpl(startOffset, endOffset, type, IrConstKind.String, value) + + fun int(startOffset: Int, endOffset: Int, type: KotlinType, value: Int): IrConstImpl = + IrConstImpl(startOffset, endOffset, type, IrConstKind.Int, value) + + fun constNull(startOffset: Int, endOffset: Int, type: KotlinType): IrConstImpl = + IrConstImpl(startOffset, endOffset, type, IrConstKind.Null, null) + + fun boolean(startOffset: Int, endOffset: Int, type: KotlinType, value: Boolean): IrConstImpl = + IrConstImpl(startOffset, endOffset, type, IrConstKind.Boolean, value) + + fun constTrue(startOffset: Int, endOffset: Int, type: KotlinType): IrConstImpl = + boolean(startOffset, endOffset, type, true) + + fun constFalse(startOffset: Int, endOffset: Int, type: KotlinType): IrConstImpl = + boolean(startOffset, endOffset, type, false) + + fun long(startOffset: Int, endOffset: Int, type: KotlinType, value: Long): IrExpression = + IrConstImpl(startOffset, endOffset, type, IrConstKind.Long, value) + + fun float(startOffset: Int, endOffset: Int, type: KotlinType, value: Float): IrExpression = + IrConstImpl(startOffset, endOffset, type, IrConstKind.Float, value) + + fun double(startOffset: Int, endOffset: Int, type: KotlinType, value: Double): IrExpression = + IrConstImpl(startOffset, endOffset, type, IrConstKind.Double, value) + + fun char(startOffset: Int, endOffset: Int, type: KotlinType, value: Char): IrExpression = + IrConstImpl(startOffset, endOffset, type, IrConstKind.Char, value) + + fun byte(startOffset: Int, endOffset: Int, type: KotlinType, value: Byte): IrExpression = + IrConstImpl(startOffset, endOffset, type, IrConstKind.Byte, value) + + fun short(startOffset: Int, endOffset: Int, type: KotlinType, value: Short): IrExpression = + IrConstImpl(startOffset, endOffset, type, IrConstKind.Short, value) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrContinueImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrContinueImpl.kt new file mode 100644 index 00000000000..70cfad2a956 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrContinueImpl.kt @@ -0,0 +1,32 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.expressions.IrContinue +import org.jetbrains.kotlin.ir.expressions.IrLoop +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType + +class IrContinueImpl( + startOffset: Int, + endOffset: Int, + type: KotlinType, + loop: IrLoop +) : IrBreakContinueBase(startOffset, endOffset, type, loop), IrContinue { + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitContinue(this, data) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDeclarationReferenceBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDeclarationReferenceBase.kt new file mode 100644 index 00000000000..640bccbe835 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDeclarationReferenceBase.kt @@ -0,0 +1,28 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.ir.expressions.IrDeclarationReference +import org.jetbrains.kotlin.types.KotlinType + +abstract class IrDeclarationReferenceBase( + startOffset: Int, + endOffset: Int, + type: KotlinType, + override val descriptor: D +) : IrExpressionBase(startOffset, endOffset, type), IrDeclarationReference \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDelegatingConstructorCallImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDelegatingConstructorCallImpl.kt new file mode 100644 index 00000000000..f42d3cbcd55 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDelegatingConstructorCallImpl.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.descriptors.ConstructorDescriptor +import org.jetbrains.kotlin.ir.expressions.IrDelegatingConstructorCall +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +class IrDelegatingConstructorCallImpl( + startOffset: Int, + endOffset: Int, + override val descriptor: ConstructorDescriptor +) : IrGeneralCallBase(startOffset, endOffset, descriptor.returnType, descriptor.valueParameters.size), IrDelegatingConstructorCall { + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitDelegatingConstructorCall(this, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDoWhileLoopImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDoWhileLoopImpl.kt new file mode 100644 index 00000000000..7be88fe672a --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDoWhileLoopImpl.kt @@ -0,0 +1,52 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.expressions.IrDoWhileLoop +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.impl.IrLoopBase +import org.jetbrains.kotlin.ir.expressions.IrOperator +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType + +class IrDoWhileLoopImpl( + startOffset: Int, + endOffset: Int, + type : KotlinType, + operator: IrOperator? +) : IrLoopBase(startOffset, endOffset, type, operator), IrDoWhileLoop { + constructor( + startOffset: Int, + endOffset: Int, + type: KotlinType, + operator: IrOperator?, + body: IrExpression, + condition: IrExpression + ) : this(startOffset, endOffset, type, operator) { + this.condition = condition + this.body = body + } + + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitDoWhileLoop(this, data) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + body?.accept(visitor, data) + condition.accept(visitor, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrEmptyBlockImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrEmptyBlockImpl.kt new file mode 100644 index 00000000000..2cfb2a958c9 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrEmptyBlockImpl.kt @@ -0,0 +1,44 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.IrElement +import org.jetbrains.kotlin.ir.IrStatement +import org.jetbrains.kotlin.ir.expressions.IrBlock +import org.jetbrains.kotlin.ir.expressions.IrOperator +import org.jetbrains.kotlin.ir.throwNoSuchSlot +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType + +class IrEmptyBlockImpl(startOffset: Int, endOffset: Int, type: KotlinType, override val operator: IrOperator? = null) : + IrExpressionBase(startOffset, endOffset, type), IrBlock { + override val statements: List get() = emptyList() + + override fun getChild(slot: Int): IrElement? = null + + override fun replaceChild(slot: Int, newChild: IrElement) { + throwNoSuchSlot(slot) + } + + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitBlock(this, data) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + // no children + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrEnumConstructorCallImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrEnumConstructorCallImpl.kt new file mode 100644 index 00000000000..7d49c203623 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrEnumConstructorCallImpl.kt @@ -0,0 +1,33 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.ConstructorDescriptor +import org.jetbrains.kotlin.ir.expressions.IrEnumConstructorCall +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +class IrEnumConstructorCallImpl( + startOffset: Int, + endOffset: Int, + override val descriptor: ConstructorDescriptor, + override val enumEntryDescriptor: ClassDescriptor? = null +) : IrGeneralCallBase(startOffset, endOffset, descriptor.returnType, descriptor.valueParameters.size), IrEnumConstructorCall { + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitEnumConstructorCall(this, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrErrorCallExpressionImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrErrorCallExpressionImpl.kt new file mode 100644 index 00000000000..4ffc869f8e9 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrErrorCallExpressionImpl.kt @@ -0,0 +1,68 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.expressions.IrErrorCallExpression +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.utils.SmartList + +class IrErrorCallExpressionImpl( + startOffset: Int, + endOffset: Int, + type: KotlinType, + override val description: String +) : IrExpressionBase(startOffset, endOffset, type), IrErrorCallExpression { + override var explicitReceiver: IrExpression? = null + set(value) { + value?.assertDetached() + field?.detach() + field = value + value?.setTreeLocation(this, DISPATCH_RECEIVER_SLOT) + } + + override val arguments: MutableList = SmartList() + + fun addArgument(argument: IrExpression) { + argument.assertDetached() + argument.setTreeLocation(this, arguments.size) + arguments.add(argument) + } + + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitErrorCallExpression(this, data) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + explicitReceiver?.accept(visitor, data) + arguments.forEach { it.accept(visitor, data) } + } + + override fun getChild(slot: Int): IrElement? = + arguments.getOrNull(slot) + + override fun replaceChild(slot: Int, newChild: IrElement) { + if (slot < 0 || slot >= arguments.size) throwNoSuchSlot(slot) + + newChild.assertDetached() + arguments[slot].detach() + arguments[slot] = newChild.assertCast() + newChild.setTreeLocation(this, slot) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrErrorExpressionImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrErrorExpressionImpl.kt new file mode 100644 index 00000000000..8151924b1d8 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrErrorExpressionImpl.kt @@ -0,0 +1,40 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.expressions.IrErrorExpression +import org.jetbrains.kotlin.ir.expressions.IrExpressionWithCopy +import org.jetbrains.kotlin.ir.expressions.impl.IrTerminalExpressionBase +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType + +class IrErrorExpressionImpl( + startOffset: Int, + endOffset: Int, + type: KotlinType, + override val description: String +) : IrTerminalExpressionBase(startOffset, endOffset, type), IrExpressionWithCopy, IrErrorExpression { + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitErrorExpression(this, data) + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + // No children + } + + override fun copy(): IrErrorExpressionImpl = + IrErrorExpressionImpl(startOffset, endOffset, type, description) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrExpressionBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrExpressionBase.kt new file mode 100644 index 00000000000..a913414f39e --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrExpressionBase.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.IrElementBase +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.types.KotlinType + +abstract class IrExpressionBase( + startOffset: Int, + endOffset: Int, + override val type: KotlinType +) : IrElementBase(startOffset, endOffset), IrExpression \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrExpressionBodyImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrExpressionBodyImpl.kt new file mode 100644 index 00000000000..76959147878 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrExpressionBodyImpl.kt @@ -0,0 +1,58 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrExpressionBody +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +class IrExpressionBodyImpl(startOffset: Int, endOffset: Int) : IrElementBase(startOffset, endOffset), IrExpressionBody { + constructor(startOffset: Int, endOffset: Int, expression: IrExpression) : this(startOffset, endOffset) { + this.expression = expression + } + + private var expressionImpl: IrExpression? = null + override var expression: IrExpression + get() = expressionImpl!! + set(newValue) { + newValue.assertDetached() + expressionImpl?.detach() + expressionImpl = newValue + newValue.setTreeLocation(this, CHILD_EXPRESSION_SLOT) + } + + override fun getChild(slot: Int): IrElement? = + when (slot) { + CHILD_EXPRESSION_SLOT -> expression + else -> null + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + when (slot) { + CHILD_EXPRESSION_SLOT -> expression = newChild.assertCast() + else -> throwNoSuchSlot(slot) + } + } + + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitExpressionBody(this, data) + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + expression.accept(visitor, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGeneralCallBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGeneralCallBase.kt new file mode 100644 index 00000000000..0564d0222e3 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGeneralCallBase.kt @@ -0,0 +1,75 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.IrElement +import org.jetbrains.kotlin.ir.assertCast +import org.jetbrains.kotlin.ir.assertDetached +import org.jetbrains.kotlin.ir.detach +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrGeneralCall +import org.jetbrains.kotlin.ir.expressions.impl.IrMemberAccessExpressionBase +import org.jetbrains.kotlin.ir.expressions.IrOperator +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType + +abstract class IrGeneralCallBase( + startOffset: Int, + endOffset: Int, + type: KotlinType, + numArguments: Int, + override val operator: IrOperator? = null +) : IrMemberAccessExpressionBase(startOffset, endOffset, type), IrGeneralCall { + protected val argumentsByParameterIndex = + arrayOfNulls(numArguments) + + override fun getArgument(index: Int): IrExpression? = + argumentsByParameterIndex[index] + + override fun putArgument(index: Int, valueArgument: IrExpression?) { + if (index >= argumentsByParameterIndex.size) { + throw AssertionError("$this: No such argument slot: $index") + } + valueArgument?.assertDetached() + argumentsByParameterIndex[index]?.detach() + argumentsByParameterIndex[index] = valueArgument + valueArgument?.setTreeLocation(this, index) + } + + override fun removeArgument(index: Int) { + argumentsByParameterIndex[index]?.detach() + argumentsByParameterIndex[index] = null + } + + override fun getChild(slot: Int): IrElement? = + if (0 <= slot) + argumentsByParameterIndex.getOrNull(slot) + else + super.getChild(slot) + + override fun replaceChild(slot: Int, newChild: IrElement) { + if (0 <= slot) + putArgument(slot, newChild.assertCast()) + else + super.replaceChild(slot, newChild) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + super.acceptChildren(visitor, data) + argumentsByParameterIndex.forEach { it?.accept(visitor, data) } + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetBackingFieldImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetBackingFieldImpl.kt new file mode 100644 index 00000000000..e59e7eb2b10 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetBackingFieldImpl.kt @@ -0,0 +1,59 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.PropertyDescriptor +import org.jetbrains.kotlin.ir.IrElement +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrGetBackingField +import org.jetbrains.kotlin.ir.expressions.IrOperator +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +class IrGetBackingFieldImpl( + startOffset: Int, + endOffset: Int, + descriptor: PropertyDescriptor, + operator: IrOperator? = null, + superQualifier: ClassDescriptor? = null +) : IrBackingFieldExpressionBase(startOffset, endOffset, descriptor, descriptor.type, operator, superQualifier), IrGetBackingField { + constructor( + startOffset: Int, + endOffset: Int, + descriptor: PropertyDescriptor, + receiver: IrExpression?, + operator: IrOperator? = null, + superQualifier: ClassDescriptor? = null + ) : this(startOffset, endOffset, descriptor, operator, superQualifier) { + this.receiver = receiver + } + + override fun getChild(slot: Int): IrElement? = + super.getChild(slot) + + override fun replaceChild(slot: Int, newChild: IrElement) { + super.replaceChild(slot, newChild) + } + + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitGetBackingField(this, data) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + receiver?.accept(visitor, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetClassImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetClassImpl.kt new file mode 100644 index 00000000000..4ba1ad2d6d1 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetClassImpl.kt @@ -0,0 +1,62 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrGetClass +import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBase +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType + +class IrGetClassImpl(startOffset: Int, endOffset: Int, type: KotlinType) : IrExpressionBase(startOffset, endOffset, type), IrGetClass { + constructor(startOffset: Int, endOffset: Int, type: KotlinType, argument: IrExpression) : this(startOffset, endOffset, type) { + this.argument = argument + } + + private var argumentImpl: IrExpression? = null + override var argument: IrExpression + get() = argumentImpl!! + set(value) { + value.assertDetached() + argumentImpl?.detach() + argumentImpl = value + value.setTreeLocation(this, CHILD_EXPRESSION_SLOT) + } + + override fun getChild(slot: Int): IrElement? = + when (slot) { + CHILD_EXPRESSION_SLOT -> argument + else -> null + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + when (slot) { + CHILD_EXPRESSION_SLOT -> argument = newChild.assertCast() + else -> throwNoSuchSlot(slot) + } + } + + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitGetClass(this, data) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + argument.accept(visitor, data) + } + +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetEnumValueImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetEnumValueImpl.kt new file mode 100644 index 00000000000..86857263360 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetEnumValueImpl.kt @@ -0,0 +1,33 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.ir.expressions.IrGetEnumValue +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType + +class IrGetEnumValueImpl( + startOffset: Int, + endOffset: Int, + type: KotlinType, + descriptor: ClassDescriptor +) : IrTerminalDeclarationReferenceBase(startOffset, endOffset, type, descriptor), IrGetEnumValue { + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitGetEnumValue(this, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetExtensionReceiverImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetExtensionReceiverImpl.kt new file mode 100644 index 00000000000..cea93b2637c --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetExtensionReceiverImpl.kt @@ -0,0 +1,33 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor +import org.jetbrains.kotlin.ir.expressions.IrGetExtensionReceiver +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +class IrGetExtensionReceiverImpl( + startOffset: Int, + endOffset: Int, + descriptor: ReceiverParameterDescriptor +) : IrTerminalDeclarationReferenceBase(startOffset, endOffset, descriptor.type, descriptor), IrGetExtensionReceiver { + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitGetExtensionReceiver(this, data) + + override fun copy(): IrGetExtensionReceiver = + IrGetExtensionReceiverImpl(startOffset, endOffset, descriptor) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetObjectValueImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetObjectValueImpl.kt new file mode 100644 index 00000000000..6ac9d2130f8 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetObjectValueImpl.kt @@ -0,0 +1,32 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.ir.expressions.IrGetObjectValue +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType + +class IrGetObjectValueImpl( + startOffset: Int, + endOffset: Int, + type: KotlinType, + descriptor: ClassDescriptor +) : IrTerminalDeclarationReferenceBase(startOffset, endOffset, type, descriptor), IrGetObjectValue { + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitGetObjectValue(this, data) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetVariableImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetVariableImpl.kt new file mode 100644 index 00000000000..beadf19f8fc --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetVariableImpl.kt @@ -0,0 +1,36 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.descriptors.VariableDescriptor +import org.jetbrains.kotlin.ir.expressions.IrGetVariable +import org.jetbrains.kotlin.ir.expressions.IrOperator +import org.jetbrains.kotlin.ir.expressions.impl.IrTerminalDeclarationReferenceBase +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +class IrGetVariableImpl( + startOffset: Int, + endOffset: Int, + descriptor: VariableDescriptor, + override val operator: IrOperator? = null +) : IrTerminalDeclarationReferenceBase(startOffset, endOffset, descriptor.type, descriptor), IrGetVariable { + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitGetVariable(this, data) + + override fun copy(): IrGetVariable = + IrGetVariableImpl(startOffset, endOffset, descriptor, operator) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrIfThenElseImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrIfThenElseImpl.kt new file mode 100644 index 00000000000..4c4f5e44187 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrIfThenElseImpl.kt @@ -0,0 +1,111 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrOperator +import org.jetbrains.kotlin.ir.expressions.IrWhen +import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBase +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType + +class IrIfThenElseImpl( + startOffset: Int, + endOffset: Int, + type: KotlinType, + override val operator: IrOperator? = null +) : IrExpressionBase(startOffset, endOffset, type), IrWhen { + constructor( + startOffset: Int, + endOffset: Int, + type: KotlinType, + condition: IrExpression, + thenBranch: IrExpression, + elseBranch: IrExpression? = null, + operator: IrOperator? = null + ) : this(startOffset, endOffset, type, operator) { + this.condition = condition + this.thenBranch = thenBranch + this.elseBranch = elseBranch + } + + override val branchesCount: Int get() = 1 + + override fun getNthCondition(n: Int): IrExpression? = + if (n == 0) condition else null + + override fun getNthResult(n: Int): IrExpression? = + if (n == 0) thenBranch else null + + private var conditionImpl: IrExpression? = null + var condition: IrExpression + get() = conditionImpl!! + set(value) { + value.assertDetached() + value.detach() + conditionImpl = value + value.setTreeLocation(this, IF_CONDITION_SLOT) + } + + private var thenBranchImpl: IrExpression? = null + var thenBranch: IrExpression + get() = thenBranchImpl!! + set(value) { + value.assertDetached() + value.detach() + thenBranchImpl = value + value.setTreeLocation(this, IF_THEN_SLOT) + } + + override var elseBranch: IrExpression? = null + set(value) { + value?.assertDetached() + value?.detach() + field = value + value?.setTreeLocation(this, IF_ELSE_SLOT) + } + + override fun getChild(slot: Int): IrElement? = + when (slot) { + IF_CONDITION_SLOT -> condition + IF_THEN_SLOT -> thenBranch + IF_ELSE_SLOT -> elseBranch + else -> null + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + newChild.assertDetached() + when (slot) { + IF_CONDITION_SLOT -> + condition = newChild.assertCast() + IF_THEN_SLOT -> + thenBranch = newChild.assertCast() + IF_ELSE_SLOT -> + elseBranch = newChild.assertCast() + } + } + + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitWhen(this, data) + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + condition.accept(visitor, data) + thenBranch.accept(visitor, data) + elseBranch?.accept(visitor, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrInstanceInitializerCallImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrInstanceInitializerCallImpl.kt new file mode 100644 index 00000000000..1e38cd5f4b5 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrInstanceInitializerCallImpl.kt @@ -0,0 +1,32 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.ir.expressions.IrInstanceInitializerCall +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns + +class IrInstanceInitializerCallImpl( + startOffset: Int, + endOffset: Int, + override val classDescriptor: ClassDescriptor +) : IrTerminalExpressionBase(startOffset, endOffset, classDescriptor.builtIns.unitType), IrInstanceInitializerCall { + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitInstanceInitializerCall(this, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrLoopBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrLoopBase.kt new file mode 100644 index 00000000000..bfa40f5c67d --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrLoopBase.kt @@ -0,0 +1,66 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrLoop +import org.jetbrains.kotlin.ir.expressions.IrOperator +import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBase +import org.jetbrains.kotlin.types.KotlinType + +abstract class IrLoopBase( + startOffset: Int, + endOffset: Int, + type: KotlinType, + override val operator: IrOperator? +) : IrExpressionBase(startOffset, endOffset, type), IrLoop { + override var label: String? = null + + private var conditionImpl: IrExpression? = null + override var condition: IrExpression + get() = conditionImpl!! + set(value) { + value.assertDetached() + conditionImpl?.detach() + conditionImpl = value + value.setTreeLocation(this, LOOP_CONDITION_SLOT) + } + + override var body: IrExpression? = null + set(value) { + value?.assertDetached() + field?.detach() + field = value + value?.setTreeLocation(this, LOOP_BODY_SLOT) + } + + override fun getChild(slot: Int): IrElement? = + when (slot) { + LOOP_BODY_SLOT -> body + LOOP_CONDITION_SLOT -> condition + else -> null + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + when (slot) { + LOOP_BODY_SLOT -> body = newChild.assertCast() + LOOP_CONDITION_SLOT -> condition = newChild.assertCast() + else -> throwNoSuchSlot(slot) + } + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrMemberAccessExpressionBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrMemberAccessExpressionBase.kt new file mode 100644 index 00000000000..13ef0c30faf --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrMemberAccessExpressionBase.kt @@ -0,0 +1,66 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression +import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBase +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType + +abstract class IrMemberAccessExpressionBase( + startOffset: Int, + endOffset: Int, + type: KotlinType +) : IrExpressionBase(startOffset, endOffset, type), IrMemberAccessExpression { + override var dispatchReceiver: IrExpression? = null + set(newReceiver) { + newReceiver?.assertDetached() + field?.detach() + field = newReceiver + newReceiver?.setTreeLocation(this, DISPATCH_RECEIVER_SLOT) + } + + override var extensionReceiver: IrExpression? = null + set(newReceiver) { + newReceiver?.assertDetached() + field?.detach() + field = newReceiver + newReceiver?.setTreeLocation(this, EXTENSION_RECEIVER_SLOT) + } + + override fun getChild(slot: Int): IrElement? = + when (slot) { + DISPATCH_RECEIVER_SLOT -> dispatchReceiver + EXTENSION_RECEIVER_SLOT -> extensionReceiver + else -> null + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + when (slot) { + DISPATCH_RECEIVER_SLOT -> dispatchReceiver = newChild.assertCast() + EXTENSION_RECEIVER_SLOT -> extensionReceiver = newChild.assertCast() + else -> throwNoSuchSlot(slot) + } + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + dispatchReceiver?.accept(visitor, data) + extensionReceiver?.accept(visitor, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrPrimitiveCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPrimitiveCall.kt similarity index 96% rename from compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrPrimitiveCall.kt rename to compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPrimitiveCall.kt index 013660cdf14..061c5dd7574 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrPrimitiveCall.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPrimitiveCall.kt @@ -14,11 +14,14 @@ * limitations under the License. */ -package org.jetbrains.kotlin.ir.expressions +package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.expressions.IrCall +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrOperator import org.jetbrains.kotlin.ir.visitors.IrElementVisitor import java.lang.AssertionError import java.lang.UnsupportedOperationException diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrPropertyAccessorCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPropertyAccessorCall.kt similarity index 93% rename from compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrPropertyAccessorCall.kt rename to compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPropertyAccessorCall.kt index d0dd51cbc30..ba999abaf6e 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrPropertyAccessorCall.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPropertyAccessorCall.kt @@ -14,11 +14,15 @@ * limitations under the License. */ -package org.jetbrains.kotlin.ir.expressions +package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.expressions.IrCall +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrOperator +import org.jetbrains.kotlin.ir.expressions.impl.IrMemberAccessExpressionBase import org.jetbrains.kotlin.ir.visitors.IrElementVisitor abstract class IrPropertyAccessorCallBase( diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrReturnImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrReturnImpl.kt new file mode 100644 index 00000000000..c8fdb3af06d --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrReturnImpl.kt @@ -0,0 +1,72 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.descriptors.CallableDescriptor +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrReturn +import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBase +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType + +class IrReturnImpl( + startOffset: Int, + endOffset: Int, + type: KotlinType, + override val returnTarget: CallableDescriptor +) : IrExpressionBase(startOffset, endOffset, type), IrReturn { + constructor( + startOffset: Int, + endOffset: Int, + type: KotlinType, + returnTarget: CallableDescriptor, + value: IrExpression? + ) : this(startOffset, endOffset, type, returnTarget) { + this.value = value + } + + override var value: IrExpression? = null + set(newValue) { + newValue?.assertDetached() + field?.detach() + field = newValue + newValue?.setTreeLocation(this, CHILD_EXPRESSION_SLOT) + } + + override fun getChild(slot: Int): IrElement? = + when (slot) { + CHILD_EXPRESSION_SLOT -> value + else -> null + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + when (slot) { + CHILD_EXPRESSION_SLOT -> value = newChild.assertCast() + else -> throwNoSuchSlot(slot) + } + } + + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitReturn(this, data) + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + value?.accept(visitor, data) + } + + +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetBackingFieldImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetBackingFieldImpl.kt new file mode 100644 index 00000000000..4ffcd98d7d9 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetBackingFieldImpl.kt @@ -0,0 +1,80 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.PropertyDescriptor +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrOperator +import org.jetbrains.kotlin.ir.expressions.IrSetBackingField +import org.jetbrains.kotlin.ir.expressions.impl.IrBackingFieldExpressionBase +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.typeUtil.builtIns + +class IrSetBackingFieldImpl( + startOffset: Int, + endOffset: Int, + descriptor: PropertyDescriptor, + operator: IrOperator? = null, + superQualifier: ClassDescriptor? = null +) : IrBackingFieldExpressionBase(startOffset, endOffset, descriptor, descriptor.type.builtIns.unitType, operator, superQualifier), IrSetBackingField { + constructor( + startOffset: Int, + endOffset: Int, + descriptor: PropertyDescriptor, + receiver: IrExpression?, + value: IrExpression, + operator: IrOperator? = null, + superQualifier: ClassDescriptor? = null + ) : this(startOffset, endOffset, descriptor, operator, superQualifier) { + this.receiver = receiver + this.value = value + } + + private var valueImpl: IrExpression? = null + override var value: IrExpression + get() = valueImpl!! + set(value) { + value.assertDetached() + valueImpl?.detach() + valueImpl = value + value.setTreeLocation(this, CHILD_EXPRESSION_SLOT) + } + + override fun getChild(slot: Int): IrElement? = + when (slot) { + CHILD_EXPRESSION_SLOT -> value + else -> super.getChild(slot) + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + when (slot) { + CHILD_EXPRESSION_SLOT -> value = newChild.assertCast() + else -> super.replaceChild(slot, newChild) + } + } + + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitSetBackingField(this, data) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + receiver?.accept(visitor, data) + value.accept(visitor, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetVariableImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetVariableImpl.kt new file mode 100644 index 00000000000..8253e7735c1 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetVariableImpl.kt @@ -0,0 +1,74 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.descriptors.VariableDescriptor +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrOperator +import org.jetbrains.kotlin.ir.expressions.IrSetVariable +import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBase +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns + +class IrSetVariableImpl( + startOffset: Int, + endOffset: Int, + override val descriptor: VariableDescriptor, + override val operator: IrOperator? +) : IrExpressionBase(startOffset, endOffset, descriptor.builtIns.unitType), IrSetVariable { + constructor( + startOffset: Int, + endOffset: Int, + descriptor: VariableDescriptor, + value: IrExpression, + operator: IrOperator? + ) : this(startOffset, endOffset, descriptor, operator) { + this.value = value + } + + private var valueImpl: IrExpression? = null + override var value: IrExpression + get() = valueImpl!! + set(value) { + value.assertDetached() + valueImpl?.detach() + valueImpl = value + value.setTreeLocation(this, ARGUMENT0_SLOT) + } + + override fun getChild(slot: Int): IrElement? = + when (slot) { + ARGUMENT0_SLOT -> value + else -> null + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + when (slot) { + ARGUMENT0_SLOT -> value = newChild.assertCast() + else -> throwNoSuchSlot(slot) + } + } + + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitSetVariable(this, data) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + value.accept(visitor, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSpreadElementImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSpreadElementImpl.kt new file mode 100644 index 00000000000..1d7f7812c8e --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSpreadElementImpl.kt @@ -0,0 +1,65 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrSpreadElement +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +class IrSpreadElementImpl( + startOffset: Int, + endOffset: Int +) : IrElementBase(startOffset, endOffset), IrSpreadElement { + constructor(startOffset: Int, endOffset: Int, expression: IrExpression) : this(startOffset, endOffset) { + this.expression = expression + } + + private var expressionImpl: IrExpression? = null + override var expression: IrExpression + get() = expressionImpl!! + set(value) { + value.assertDetached() + expressionImpl?.detach() + expressionImpl = value + value.setTreeLocation(this, CHILD_EXPRESSION_SLOT) + } + + + override fun getChild(slot: Int): IrElement? = + when (slot) { + CHILD_EXPRESSION_SLOT -> expression + else -> null + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + when (slot) { + CHILD_EXPRESSION_SLOT -> expression = newChild.assertCast() + else -> throwNoSuchSlot(slot) + } + } + + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitSpreadElement(this, data) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + expression.accept(visitor, data) + } + + +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrStringConcatenationImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrStringConcatenationImpl.kt new file mode 100644 index 00000000000..c76e0f77b22 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrStringConcatenationImpl.kt @@ -0,0 +1,58 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrStringConcatenation +import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBase +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType +import java.util.* + +class IrStringConcatenationImpl( + startOffset: Int, + endOffset: Int, + type: KotlinType +) : IrExpressionBase(startOffset, endOffset, type), IrStringConcatenation { + override val arguments: MutableList = ArrayList() + + override fun addArgument(argument: IrExpression) { + argument.assertDetached() + argument.setTreeLocation(this, arguments.size) + arguments.add(argument) + } + + override fun getChild(slot: Int): IrElement? = + arguments.getOrNull(slot) + + override fun replaceChild(slot: Int, newChild: IrElement) { + if (slot < 0 || slot >= arguments.size) throwNoSuchSlot(slot) + + newChild.assertDetached() + arguments[slot].detach() + arguments[slot] = newChild.assertCast() + newChild.setTreeLocation(this, slot) + } + + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitStringConcatenation(this, data) + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + arguments.forEach { it.accept(visitor, data) } + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSyntheticBodyImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSyntheticBodyImpl.kt new file mode 100644 index 00000000000..64fdacec2ca --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSyntheticBodyImpl.kt @@ -0,0 +1,40 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.IrElement +import org.jetbrains.kotlin.ir.IrElementBase +import org.jetbrains.kotlin.ir.expressions.IrSyntheticBody +import org.jetbrains.kotlin.ir.expressions.IrSyntheticBodyKind +import org.jetbrains.kotlin.ir.throwNoSuchSlot +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +class IrSyntheticBodyImpl(startOffset: Int, endOffset: Int, override val kind: IrSyntheticBodyKind) : IrElementBase(startOffset, endOffset), IrSyntheticBody { + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitSyntheticBody(this, data) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + // no children + } + + override fun getChild(slot: Int): IrElement? = null + + override fun replaceChild(slot: Int, newChild: IrElement) { + throwNoSuchSlot(slot) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTerminalDeclarationReferenceBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTerminalDeclarationReferenceBase.kt new file mode 100644 index 00000000000..d96adf7a603 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTerminalDeclarationReferenceBase.kt @@ -0,0 +1,41 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.ir.IrElement +import org.jetbrains.kotlin.ir.expressions.impl.IrDeclarationReferenceBase +import org.jetbrains.kotlin.ir.throwNoSuchSlot +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType + +abstract class IrTerminalDeclarationReferenceBase( + startOffset: Int, + endOffset: Int, + type: KotlinType, + descriptor: D +) : IrDeclarationReferenceBase(startOffset, endOffset, type, descriptor) { + override fun getChild(slot: Int): IrElement? = null + + override fun replaceChild(slot: Int, newChild: IrElement) { + throwNoSuchSlot(slot) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + // No children + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTerminalExpressionBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTerminalExpressionBase.kt new file mode 100644 index 00000000000..1ca486fb6c2 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTerminalExpressionBase.kt @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.IrElement +import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBase +import org.jetbrains.kotlin.ir.throwNoSuchSlot +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType + +abstract class IrTerminalExpressionBase( + startOffset: Int, + endOffset: Int, + type: KotlinType +) : IrExpressionBase(startOffset, endOffset, type) { + override fun getChild(slot: Int): IrElement? = null + + override fun replaceChild(slot: Int, newChild: IrElement) { + throwNoSuchSlot(slot) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + // No children + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrThisReferenceImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrThisReferenceImpl.kt new file mode 100644 index 00000000000..77fd1a40430 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrThisReferenceImpl.kt @@ -0,0 +1,36 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.ir.expressions.IrThisReference +import org.jetbrains.kotlin.ir.expressions.impl.IrTerminalExpressionBase +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType + +class IrThisReferenceImpl( + startOffset: Int, + endOffset: Int, + type: KotlinType, + override val classDescriptor: ClassDescriptor +) : IrTerminalExpressionBase(startOffset, endOffset, type), IrThisReference { + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitThisReference(this, data) + + override fun copy(): IrThisReference = + IrThisReferenceImpl(startOffset, endOffset, type, classDescriptor) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrThrowImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrThrowImpl.kt new file mode 100644 index 00000000000..7033ed26e39 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrThrowImpl.kt @@ -0,0 +1,71 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrThrow +import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBase +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType + +class IrThrowImpl( + startOffset: Int, + endOffset: Int, + type: KotlinType +) : IrExpressionBase(startOffset, endOffset, type), IrThrow { + constructor( + startOffset: Int, + endOffset: Int, + type: KotlinType, + value: IrExpression + ) : this(startOffset, endOffset, type) { + this.value = value + } + + private var valueImpl: IrExpression? = null + override var value: IrExpression + get() = valueImpl!! + set(newValue) { + newValue.assertDetached() + valueImpl?.detach() + valueImpl = newValue + newValue.setTreeLocation(this, CHILD_EXPRESSION_SLOT) + } + + override fun getChild(slot: Int): IrElement? = + when (slot) { + CHILD_EXPRESSION_SLOT -> value + else -> null + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + when (slot) { + CHILD_EXPRESSION_SLOT -> value = newChild.assertCast() + else -> throwNoSuchSlot(slot) + } + } + + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitThrow(this, data) + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + value.accept(visitor, data) + } + + +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTryCatchImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTryCatchImpl.kt new file mode 100644 index 00000000000..a4cfac61bf5 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTryCatchImpl.kt @@ -0,0 +1,112 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.descriptors.VariableDescriptor +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrTryCatch +import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBase +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.utils.SmartList + +class IrTryCatchImpl( + startOffset: Int, + endOffset: Int, + type: KotlinType +) : IrExpressionBase(startOffset, endOffset, type), IrTryCatch { + private var tryResultImpl: IrExpression? = null + override var tryResult: IrExpression + get() = tryResultImpl!! + set(value) { + value.assertDetached() + tryResultImpl?.detach() + tryResultImpl = value + value.setTreeLocation(this, TRY_RESULT_SLOT) + } + + private val catchClauseParameters = SmartList() + private val catchClauseResults = SmartList() + + override val catchClausesCount: Int get() = catchClauseResults.size + + fun addCatchClause(parameter: VariableDescriptor, result: IrExpression) { + result.assertDetached() + result.setTreeLocation(this, catchClausesCount) + catchClauseParameters.add(parameter) + catchClauseResults.add(result) + } + + override fun getNthCatchParameter(n: Int): VariableDescriptor? = + catchClauseParameters.getOrNull(n) + + override fun getNthCatchResult(n: Int): IrExpression? = + catchClauseResults.getOrNull(n) + + override var finallyExpression: IrExpression? = null + set(value) { + value?.assertDetached() + field?.detach() + field = value + value?.setTreeLocation(this, FINALLY_EXPRESSION_SLOT) + } + + override fun getChild(slot: Int): IrElement? = + when { + slot == TRY_RESULT_SLOT -> + tryResult + slot >= 0 -> + catchClauseResults.getOrNull(slot) + slot == FINALLY_EXPRESSION_SLOT -> + finallyExpression + else -> null + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + when { + slot == TRY_RESULT_SLOT -> + tryResult = newChild.assertCast() + slot >= 0 -> + putCatchClauseElement(catchClauseResults, newChild, slot) + slot == FINALLY_EXPRESSION_SLOT -> + finallyExpression = newChild.assertCast() + else -> + throwNoSuchSlot(slot) + } + } + + private inline fun putCatchClauseElement(list: MutableList, newChild: IrElement, slot: Int) { + if (slot < 0 || slot >= list.size) throwNoSuchSlot(slot) + + list[slot].detach() + list[slot] = newChild.assertCast() + newChild.setTreeLocation(this, slot) + } + + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitTryCatch(this, data) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + tryResult.accept(visitor, data) + for (index in 0 ..catchClausesCount - 1) { + catchClauseResults[index].accept(visitor, data) + } + finallyExpression?.accept(visitor, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTypeOperatorCallImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTypeOperatorCallImpl.kt new file mode 100644 index 00000000000..2cd3eb57994 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTypeOperatorCallImpl.kt @@ -0,0 +1,76 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrTypeOperator +import org.jetbrains.kotlin.ir.expressions.IrTypeOperatorCall +import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBase +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType + +class IrTypeOperatorCallImpl( + startOffset: Int, + endOffset: Int, + type: KotlinType, + override val operator: IrTypeOperator, + override val typeOperand: KotlinType +) : IrExpressionBase(startOffset, endOffset, type), IrTypeOperatorCall { + constructor( + startOffset: Int, + endOffset: Int, + type: KotlinType, + operator: IrTypeOperator, + typeOperand: KotlinType, + argument: IrExpression + ) : this(startOffset, endOffset, type, operator, typeOperand) { + this.argument = argument + } + + private var argumentImpl: IrExpression? = null + override var argument: IrExpression + get() = argumentImpl!! + set(value) { + value.assertDetached() + argumentImpl?.detach() + argumentImpl = value + value.setTreeLocation(this, ARGUMENT0_SLOT) + } + + override fun getChild(slot: Int): IrElement? = + when (slot) { + ARGUMENT0_SLOT -> argument + else -> null + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + when (slot) { + ARGUMENT0_SLOT -> argument = newChild.assertCast() + else -> throwNoSuchSlot(slot) + } + } + + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitTypeOperator(this, data) + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + argument.accept(visitor, data) + } + + +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrVarargImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrVarargImpl.kt new file mode 100644 index 00000000000..18435bc6cbe --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrVarargImpl.kt @@ -0,0 +1,60 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.expressions.IrVararg +import org.jetbrains.kotlin.ir.expressions.IrVarargElement +import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBase +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.utils.SmartList + +class IrVarargImpl( + startOffset: Int, + endOffset: Int, + type: KotlinType, + override val varargElementType: KotlinType +) : IrVararg, IrExpressionBase(startOffset, endOffset, type) { + override val elements: MutableList = SmartList() + + fun addElement(varargElement: IrVarargElement) { + varargElement.assertDetached() + varargElement.setTreeLocation(this, elements.size) + elements.add(varargElement) + } + + override fun getChild(slot: Int): IrElement? = + elements.getOrNull(slot) + + override fun replaceChild(slot: Int, newChild: IrElement) { + if (slot < 0 || slot >= elements.size) throwNoSuchSlot(slot) + + newChild.assertDetached() + elements[slot].detach() + elements[slot] = newChild.assertCast() + newChild.setTreeLocation(this, slot) + } + + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitVararg(this, data) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + elements.forEach { it.accept(visitor, data) } + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhenImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhenImpl.kt new file mode 100644 index 00000000000..226325c1b50 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhenImpl.kt @@ -0,0 +1,89 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrOperator +import org.jetbrains.kotlin.ir.expressions.IrWhen +import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBase +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType +import java.util.* + +class IrWhenImpl( + startOffset: Int, + endOffset: Int, + type: KotlinType, + override val operator: IrOperator? = null +) : IrExpressionBase(startOffset, endOffset, type), IrWhen { + private val branchParts = ArrayList() + + fun addBranch(condition: IrExpression, result: IrExpression) { + condition.assertDetached() + result.assertDetached() + condition.setTreeLocation(this, branchParts.size) + branchParts.add(condition) + result.setTreeLocation(this, branchParts.size) + branchParts.add(result) + } + + override var elseBranch: IrExpression? = null + set(value) { + value?.assertDetached() + value?.detach() + field = value + value?.setTreeLocation(this, IF_ELSE_SLOT) + } + + override fun getChild(slot: Int): IrElement? { + return when (slot) { + IF_ELSE_SLOT -> elseBranch + else -> branchParts.getOrNull(slot) + } + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + when (slot) { + IF_ELSE_SLOT -> elseBranch = newChild.assertCast() + in branchParts.indices -> { + newChild.assertDetached() + branchParts[slot].detach() + branchParts[slot] = newChild.assertCast() + newChild.setTreeLocation(this, slot) + } + else -> + throwNoSuchSlot(slot) + } + } + + override val branchesCount: Int get() = branchParts.size / 2 + + override fun getNthCondition(n: Int): IrExpression? = + branchParts.getOrNull(n * 2) + + override fun getNthResult(n: Int): IrExpression? = + branchParts.getOrNull(n * 2 + 1) + + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitWhen(this, data) + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + branchParts.forEach { it.accept(visitor, data) } + elseBranch?.accept(visitor, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhileLoopImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhileLoopImpl.kt new file mode 100644 index 00000000000..5f31a5db86e --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhileLoopImpl.kt @@ -0,0 +1,52 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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.ir.expressions.impl + +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrOperator +import org.jetbrains.kotlin.ir.expressions.IrWhileLoop +import org.jetbrains.kotlin.ir.expressions.impl.IrLoopBase +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import org.jetbrains.kotlin.types.KotlinType + +class IrWhileLoopImpl( + startOffset: Int, + endOffset: Int, + type: KotlinType, + operator: IrOperator? +) : IrLoopBase(startOffset, endOffset, type, operator), IrWhileLoop { + constructor( + startOffset: Int, + endOffset: Int, + type: KotlinType, + operator: IrOperator?, + condition: IrExpression, + body: IrExpression + ) : this(startOffset, endOffset, type, operator) { + this.condition = condition + this.body = body + } + + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitWhileLoop(this, data) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + condition.accept(visitor, data) + body?.accept(visitor, data) + } +} \ No newline at end of file