Move implementation classes to 'impl' packages.
This commit is contained in:
committed by
Dmitry Petrov
parent
d6a3246586
commit
da4079bfe7
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.psi2ir
|
|||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.impl.IrGetVariableImpl
|
||||||
import org.jetbrains.kotlin.psi2ir.containsNull
|
import org.jetbrains.kotlin.psi2ir.containsNull
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
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.eqeqeq
|
||||||
import org.jetbrains.kotlin.psi2ir.generators.primitiveOp1
|
import org.jetbrains.kotlin.psi2ir.generators.primitiveOp1
|
||||||
import org.jetbrains.kotlin.psi2ir.generators.primitiveOp2
|
import org.jetbrains.kotlin.psi2ir.generators.primitiveOp2
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ import org.jetbrains.kotlin.ir.IrElement
|
|||||||
import org.jetbrains.kotlin.ir.IrStatement
|
import org.jetbrains.kotlin.ir.IrStatement
|
||||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
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.KtElement
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||||
|
|||||||
+2
-2
@@ -18,9 +18,9 @@ package org.jetbrains.kotlin.psi2ir.builders
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
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.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.GeneratorContext
|
||||||
import org.jetbrains.kotlin.psi2ir.generators.Scope
|
import org.jetbrains.kotlin.psi2ir.generators.Scope
|
||||||
|
|
||||||
|
|||||||
+1
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.psi2ir.generators
|
|||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||||
import org.jetbrains.kotlin.psi.KtElement
|
import org.jetbrains.kotlin.psi.KtElement
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.impl.SyntheticFieldDescriptor
|
import org.jetbrains.kotlin.descriptors.impl.SyntheticFieldDescriptor
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrOperator
|
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.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||||
|
|||||||
@@ -18,8 +18,9 @@ package org.jetbrains.kotlin.psi2ir.generators
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
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.*
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||||
|
|||||||
+1
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.psi2ir.generators
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.psi2ir.generators
|
|||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
|
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||||
import org.jetbrains.kotlin.psi.KtElement
|
import org.jetbrains.kotlin.psi.KtElement
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||||
|
|||||||
@@ -19,8 +19,10 @@ package org.jetbrains.kotlin.psi2ir.generators
|
|||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
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.descriptors.IrImplementingDelegateDescriptorImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||||
import org.jetbrains.kotlin.psi.KtDelegatedSuperTypeEntry
|
import org.jetbrains.kotlin.psi.KtDelegatedSuperTypeEntry
|
||||||
import org.jetbrains.kotlin.psi.KtEnumEntry
|
import org.jetbrains.kotlin.psi.KtEnumEntry
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ import com.intellij.psi.PsiElement
|
|||||||
import org.jetbrains.kotlin.backend.common.DataClassMethodGenerator
|
import org.jetbrains.kotlin.backend.common.DataClassMethodGenerator
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
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.IrDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.mapValueParameters
|
import org.jetbrains.kotlin.ir.expressions.mapValueParameters
|
||||||
|
|||||||
+1
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.psi2ir.generators
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
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.IrBody
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
|
|||||||
+3
@@ -19,11 +19,14 @@ package org.jetbrains.kotlin.psi2ir.generators
|
|||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
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.IrLocalDelegatedPropertyDelegateDescriptor
|
||||||
import org.jetbrains.kotlin.ir.descriptors.IrLocalDelegatedPropertyDelegateDescriptorImpl
|
import org.jetbrains.kotlin.ir.descriptors.IrLocalDelegatedPropertyDelegateDescriptorImpl
|
||||||
import org.jetbrains.kotlin.ir.descriptors.IrPropertyDelegateDescriptor
|
import org.jetbrains.kotlin.ir.descriptors.IrPropertyDelegateDescriptor
|
||||||
import org.jetbrains.kotlin.ir.descriptors.IrPropertyDelegateDescriptorImpl
|
import org.jetbrains.kotlin.ir.descriptors.IrPropertyDelegateDescriptorImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
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.KtElement
|
||||||
import org.jetbrains.kotlin.psi.KtProperty
|
import org.jetbrains.kotlin.psi.KtProperty
|
||||||
import org.jetbrains.kotlin.psi.KtPropertyDelegate
|
import org.jetbrains.kotlin.psi.KtPropertyDelegate
|
||||||
|
|||||||
+3
-3
@@ -17,10 +17,10 @@
|
|||||||
package org.jetbrains.kotlin.psi2ir.generators
|
package org.jetbrains.kotlin.psi2ir.generators
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
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.IrDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFunctionImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrSyntheticBodyImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrSyntheticBodyImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrSyntheticBodyKind
|
import org.jetbrains.kotlin.ir.expressions.IrSyntheticBodyKind
|
||||||
import org.jetbrains.kotlin.psi2ir.findFirstFunction
|
import org.jetbrains.kotlin.psi2ir.findFirstFunction
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.psi2ir.generators
|
package org.jetbrains.kotlin.psi2ir.generators
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrErrorCallExpressionImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrErrorCallExpressionImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrErrorExpressionImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrErrorExpressionImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.psi2ir.generators
|
package org.jetbrains.kotlin.psi2ir.generators
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
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.KtElement
|
||||||
import org.jetbrains.kotlin.psi.KtExpression
|
import org.jetbrains.kotlin.psi.KtExpression
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||||
|
|||||||
+2
-2
@@ -17,8 +17,8 @@
|
|||||||
package org.jetbrains.kotlin.psi2ir.generators
|
package org.jetbrains.kotlin.psi2ir.generators
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ir.IrStatement
|
import org.jetbrains.kotlin.ir.IrStatement
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrBlockImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrCallImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrOperator
|
import org.jetbrains.kotlin.ir.expressions.IrOperator
|
||||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||||
import org.jetbrains.kotlin.psi.KtObjectLiteralExpression
|
import org.jetbrains.kotlin.psi.KtObjectLiteralExpression
|
||||||
|
|||||||
+3
-3
@@ -19,9 +19,9 @@ package org.jetbrains.kotlin.psi2ir.generators
|
|||||||
import org.jetbrains.kotlin.ir.IrStatement
|
import org.jetbrains.kotlin.ir.IrStatement
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrGeneralFunction
|
import org.jetbrains.kotlin.ir.declarations.IrGeneralFunction
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFunctionImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrBlockImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrCallableReferenceImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrCallableReferenceImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrOperator
|
import org.jetbrains.kotlin.ir.expressions.IrOperator
|
||||||
import org.jetbrains.kotlin.psi.KtLambdaExpression
|
import org.jetbrains.kotlin.psi.KtLambdaExpression
|
||||||
import org.jetbrains.kotlin.psi.KtNamedFunction
|
import org.jetbrains.kotlin.psi.KtNamedFunction
|
||||||
|
|||||||
+2
-1
@@ -17,8 +17,9 @@
|
|||||||
package org.jetbrains.kotlin.psi2ir.generators
|
package org.jetbrains.kotlin.psi2ir.generators
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
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.*
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
package org.jetbrains.kotlin.psi2ir.generators
|
package org.jetbrains.kotlin.psi2ir.generators
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
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.psi.KtFile
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
|
|
||||||
|
|||||||
+3
@@ -19,6 +19,9 @@ package org.jetbrains.kotlin.psi2ir.generators
|
|||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
import org.jetbrains.kotlin.ir.IrStatement
|
import org.jetbrains.kotlin.ir.IrStatement
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
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.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.psi2ir.generators
|
|||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||||
|
|
||||||
fun primitiveOp1(startOffset: Int, endOffset: Int, primitiveOpDescriptor: CallableDescriptor, irOperator: IrOperator,
|
fun primitiveOp1(startOffset: Int, endOffset: Int, primitiveOpDescriptor: CallableDescriptor, irOperator: IrOperator,
|
||||||
argument: IrExpression): IrExpression =
|
argument: IrExpression): IrExpression =
|
||||||
|
|||||||
+3
-3
@@ -17,10 +17,10 @@
|
|||||||
package org.jetbrains.kotlin.psi2ir.generators
|
package org.jetbrains.kotlin.psi2ir.generators
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrCallableReferenceImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrCallableReferenceImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrClassReferenceImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrClassReferenceImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
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.KtCallableReferenceExpression
|
||||||
import org.jetbrains.kotlin.psi.KtClassLiteralExpression
|
import org.jetbrains.kotlin.psi.KtClassLiteralExpression
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.psi2ir.generators
|
|||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
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.IrTemporaryVariableDescriptor
|
||||||
import org.jetbrains.kotlin.ir.descriptors.IrTemporaryVariableDescriptorImpl
|
import org.jetbrains.kotlin.ir.descriptors.IrTemporaryVariableDescriptorImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
|
|||||||
+3
-2
@@ -20,9 +20,10 @@ import org.jetbrains.kotlin.descriptors.*
|
|||||||
import org.jetbrains.kotlin.ir.IrStatement
|
import org.jetbrains.kotlin.ir.IrStatement
|
||||||
import org.jetbrains.kotlin.ir.assertCast
|
import org.jetbrains.kotlin.ir.assertCast
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrTypeAliasImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrTypeAliasImpl
|
||||||
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.*
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.psi2ir.generators
|
package org.jetbrains.kotlin.psi2ir.generators
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
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.KtTryExpression
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||||
|
|||||||
+2
@@ -17,6 +17,8 @@
|
|||||||
package org.jetbrains.kotlin.psi2ir.intermediate
|
package org.jetbrains.kotlin.psi2ir.intermediate
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
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.psi2ir.generators.CallGenerator
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import java.lang.AssertionError
|
import java.lang.AssertionError
|
||||||
|
|||||||
+2
@@ -18,6 +18,8 @@ package org.jetbrains.kotlin.psi2ir.intermediate
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
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
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
|
||||||
class BackingFieldLValue(
|
class BackingFieldLValue(
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.psi2ir.intermediate
|
package org.jetbrains.kotlin.psi2ir.intermediate
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.VariableDescriptorWithAccessors
|
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.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrOperator
|
import org.jetbrains.kotlin.ir.expressions.IrOperator
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.psi2ir.intermediate
|
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.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionWithCopy
|
import org.jetbrains.kotlin.ir.expressions.IrExpressionWithCopy
|
||||||
import org.jetbrains.kotlin.psi2ir.generators.Scope
|
import org.jetbrains.kotlin.psi2ir.generators.Scope
|
||||||
|
|||||||
+2
-2
@@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.psi2ir.intermediate
|
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.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.ir.expressions.IrOperator
|
||||||
import org.jetbrains.kotlin.psi2ir.generators.GeneratorWithScope
|
import org.jetbrains.kotlin.psi2ir.generators.GeneratorWithScope
|
||||||
import org.jetbrains.kotlin.psi2ir.generators.constNull
|
import org.jetbrains.kotlin.psi2ir.generators.constNull
|
||||||
|
|||||||
+1
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.psi2ir.intermediate
|
|||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
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.GeneratorContext
|
||||||
import org.jetbrains.kotlin.psi2ir.generators.Scope
|
import org.jetbrains.kotlin.psi2ir.generators.Scope
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
|||||||
+2
-2
@@ -19,9 +19,9 @@ package org.jetbrains.kotlin.psi2ir.intermediate
|
|||||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
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.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.KotlinType
|
||||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.ir.detach
|
|||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrGeneralCall
|
import org.jetbrains.kotlin.ir.expressions.IrGeneralCall
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrStringConcatenation
|
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.replaceWith
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
||||||
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.psi2ir.transformations
|
|||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.detach
|
import org.jetbrains.kotlin.ir.detach
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrBlock
|
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.replaceWith
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
||||||
|
|||||||
+1
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.ir.IrElement
|
|||||||
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
||||||
import org.jetbrains.kotlin.ir.detach
|
import org.jetbrains.kotlin.ir.detach
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
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.replaceWith
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
||||||
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
||||||
|
|||||||
-39
@@ -17,9 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.ir.declarations
|
package org.jetbrains.kotlin.ir.declarations
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.ir.*
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
|
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|
||||||
|
|
||||||
interface IrAnonymousInitializer : IrDeclaration {
|
interface IrAnonymousInitializer : IrDeclaration {
|
||||||
override val descriptor: ClassDescriptor // TODO special descriptor for anonymous initializer blocks
|
override val descriptor: ClassDescriptor // TODO special descriptor for anonymous initializer blocks
|
||||||
@@ -30,40 +28,3 @@ interface IrAnonymousInitializer : IrDeclaration {
|
|||||||
var body: IrBlockBody
|
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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitAnonymousInitializer(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
body.accept(visitor, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
package org.jetbrains.kotlin.ir.declarations
|
package org.jetbrains.kotlin.ir.declarations
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
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 {
|
interface IrClass : IrDeclaration {
|
||||||
override val declarationKind: IrDeclarationKind
|
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<IrDeclaration> = 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitClass(this, data)
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
members.forEach { it.accept(visitor, data) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -17,8 +17,6 @@
|
|||||||
package org.jetbrains.kotlin.ir.declarations
|
package org.jetbrains.kotlin.ir.declarations
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|
||||||
|
|
||||||
|
|
||||||
interface IrConstructor : IrFunction {
|
interface IrConstructor : IrFunction {
|
||||||
@@ -28,23 +26,3 @@ interface IrConstructor : IrFunction {
|
|||||||
override val descriptor: ConstructorDescriptor
|
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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitConstructor(this, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,7 +17,6 @@
|
|||||||
package org.jetbrains.kotlin.ir.declarations
|
package org.jetbrains.kotlin.ir.declarations
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.ir.IrElementBase
|
|
||||||
import org.jetbrains.kotlin.ir.IrStatement
|
import org.jetbrains.kotlin.ir.IrStatement
|
||||||
|
|
||||||
interface IrDeclaration : IrStatement {
|
interface IrDeclaration : IrStatement {
|
||||||
@@ -55,8 +54,3 @@ enum class IrDeclarationOrigin {
|
|||||||
IR_TEMPORARY_VARIABLE,
|
IR_TEMPORARY_VARIABLE,
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class IrDeclarationBase(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
override val origin: IrDeclarationOrigin
|
|
||||||
) : IrElementBase(startOffset, endOffset), IrDeclaration
|
|
||||||
|
|||||||
@@ -17,9 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.ir.declarations
|
package org.jetbrains.kotlin.ir.declarations
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.ir.*
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|
||||||
|
|
||||||
interface IrEnumEntry : IrDeclaration {
|
interface IrEnumEntry : IrDeclaration {
|
||||||
override val declarationKind: IrDeclarationKind get() = IrDeclarationKind.ENUM_ENTRY
|
override val declarationKind: IrDeclarationKind get() = IrDeclarationKind.ENUM_ENTRY
|
||||||
@@ -30,52 +28,3 @@ interface IrEnumEntry : IrDeclaration {
|
|||||||
var initializerExpression: IrExpression
|
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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitEnumEntry(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
initializerExpression.accept(visitor, data)
|
|
||||||
correspondingClass?.accept(visitor, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,29 +16,5 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.declarations
|
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
|
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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitErrorDeclaration(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
// no children
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getChild(slot: Int): IrElement? = null
|
|
||||||
|
|
||||||
override fun replaceChild(slot: Int, newChild: IrElement) = throwNoSuchSlot(slot)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -18,10 +18,8 @@ package org.jetbrains.kotlin.ir.declarations
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||||
import org.jetbrains.kotlin.ir.*
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
import org.jetbrains.kotlin.ir.SourceLocationManager
|
||||||
import org.jetbrains.kotlin.utils.SmartList
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
interface IrFile : IrElement {
|
interface IrFile : IrElement {
|
||||||
val name: String
|
val name: String
|
||||||
@@ -31,41 +29,3 @@ interface IrFile : IrElement {
|
|||||||
val declarations: List<IrDeclaration>
|
val declarations: List<IrDeclaration>
|
||||||
}
|
}
|
||||||
|
|
||||||
class IrFileImpl(
|
|
||||||
override val fileEntry: SourceLocationManager.FileEntry,
|
|
||||||
override val name: String,
|
|
||||||
override val packageFragmentDescriptor: PackageFragmentDescriptor
|
|
||||||
) : IrElementBase(0, fileEntry.maxOffset), IrFile {
|
|
||||||
override val fileAnnotations: MutableList<AnnotationDescriptor> = SmartList()
|
|
||||||
|
|
||||||
fun addAnnotation(annotation: AnnotationDescriptor) {
|
|
||||||
fileAnnotations.add(annotation)
|
|
||||||
}
|
|
||||||
|
|
||||||
override val declarations: MutableList<IrDeclaration> = 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitFile(this, data)
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
declarations.forEach { it.accept(visitor, data) }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -18,11 +18,8 @@ package org.jetbrains.kotlin.ir.declarations
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||||
import org.jetbrains.kotlin.ir.*
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
interface IrGeneralFunction : IrDeclaration {
|
interface IrGeneralFunction : IrDeclaration {
|
||||||
override val descriptor: FunctionDescriptor
|
override val descriptor: FunctionDescriptor
|
||||||
@@ -37,86 +34,3 @@ interface IrFunction : IrGeneralFunction {
|
|||||||
fun getDefault(parameter: ValueParameterDescriptor): IrExpressionBody?
|
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 <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
body?.accept(visitor, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class IrFunctionBase(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
origin: IrDeclarationOrigin
|
|
||||||
) : IrGeneralFunctionBase(startOffset, endOffset, origin), IrFunction {
|
|
||||||
private val defaults = LinkedHashMap<ValueParameterDescriptor, IrExpressionBody>()
|
|
||||||
|
|
||||||
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 <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitFunction(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
-94
@@ -18,9 +18,6 @@ package org.jetbrains.kotlin.ir.declarations
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.VariableAccessorDescriptor
|
import org.jetbrains.kotlin.descriptors.VariableAccessorDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.VariableDescriptorWithAccessors
|
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 {
|
interface IrLocalDelegatedProperty : IrDeclaration {
|
||||||
override val descriptor: VariableDescriptorWithAccessors
|
override val descriptor: VariableDescriptorWithAccessors
|
||||||
@@ -39,94 +36,3 @@ interface IrLocalPropertyAccessor : IrGeneralFunction {
|
|||||||
get() = IrDeclarationKind.LOCAL_PROPERTY_ACCESSOR
|
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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitLocalDelegatedProperty(this, data)
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitLocalPropertyAccessor(this, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -17,10 +17,11 @@
|
|||||||
package org.jetbrains.kotlin.ir.declarations
|
package org.jetbrains.kotlin.ir.declarations
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
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.descriptors.IrBuiltIns
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
import java.lang.AssertionError
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
interface IrModule : IrElement {
|
interface IrModule : IrElement {
|
||||||
override val startOffset: Int get() = UNDEFINED_OFFSET
|
override val startOffset: Int get() = UNDEFINED_OFFSET
|
||||||
@@ -37,30 +38,3 @@ interface IrModule : IrElement {
|
|||||||
val files: List<IrFile>
|
val files: List<IrFile>
|
||||||
}
|
}
|
||||||
|
|
||||||
class IrModuleImpl(
|
|
||||||
override val descriptor: ModuleDescriptor,
|
|
||||||
override val irBuiltins: IrBuiltIns
|
|
||||||
) : IrModule {
|
|
||||||
override val files: MutableList<IrFile> = 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitModule(this, data)
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
files.forEach { it.accept(visitor, data) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,9 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.ir.declarations
|
package org.jetbrains.kotlin.ir.declarations
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||||
import org.jetbrains.kotlin.ir.*
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|
||||||
|
|
||||||
interface IrProperty : IrDeclaration {
|
interface IrProperty : IrDeclaration {
|
||||||
override val descriptor: PropertyDescriptor
|
override val descriptor: PropertyDescriptor
|
||||||
@@ -38,127 +36,3 @@ interface IrDelegatedProperty : IrProperty {
|
|||||||
var delegate: IrSimpleProperty
|
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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitSimpleProperty(this, data)
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitDelegatedProperty(this, data)
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
delegate.accept(visitor, data)
|
|
||||||
getter?.accept(visitor, data)
|
|
||||||
setter?.accept(visitor, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ package org.jetbrains.kotlin.ir.declarations
|
|||||||
import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor
|
import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyGetterDescriptor
|
import org.jetbrains.kotlin.descriptors.PropertyGetterDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.PropertySetterDescriptor
|
import org.jetbrains.kotlin.descriptors.PropertySetterDescriptor
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|
||||||
|
|
||||||
interface IrPropertyAccessor : IrGeneralFunction {
|
interface IrPropertyAccessor : IrGeneralFunction {
|
||||||
override val descriptor: PropertyAccessorDescriptor
|
override val descriptor: PropertyAccessorDescriptor
|
||||||
@@ -39,48 +37,3 @@ interface IrPropertySetter : IrPropertyAccessor {
|
|||||||
override val descriptor: PropertySetterDescriptor
|
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 <R, D> accept(visitor: IrElementVisitor<R, D>, 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitPropertySetter(this, data)
|
|
||||||
}
|
|
||||||
@@ -17,9 +17,6 @@
|
|||||||
package org.jetbrains.kotlin.ir.declarations
|
package org.jetbrains.kotlin.ir.declarations
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
|
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 {
|
interface IrTypeAlias : IrDeclaration {
|
||||||
override val descriptor: TypeAliasDescriptor
|
override val descriptor: TypeAliasDescriptor
|
||||||
@@ -28,23 +25,3 @@ interface IrTypeAlias : IrDeclaration {
|
|||||||
get() = IrDeclarationKind.TYPEALIAS
|
get() = IrDeclarationKind.TYPEALIAS
|
||||||
}
|
}
|
||||||
|
|
||||||
class IrTypeAliasImpl(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
origin: IrDeclarationOrigin,
|
|
||||||
override val descriptor: TypeAliasDescriptor
|
|
||||||
) : IrDeclarationBase(startOffset, endOffset, origin), IrTypeAlias {
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitTypeAlias(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
// no children
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getChild(slot: Int): IrElement? = null
|
|
||||||
|
|
||||||
override fun replaceChild(slot: Int, newChild: IrElement) {
|
|
||||||
throwNoSuchSlot(slot)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,9 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.ir.declarations
|
package org.jetbrains.kotlin.ir.declarations
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||||
import org.jetbrains.kotlin.ir.*
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|
||||||
|
|
||||||
interface IrVariable : IrDeclaration {
|
interface IrVariable : IrDeclaration {
|
||||||
override val descriptor: VariableDescriptor
|
override val descriptor: VariableDescriptor
|
||||||
@@ -30,48 +28,3 @@ interface IrVariable : IrDeclaration {
|
|||||||
var initializer: IrExpression?
|
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<IrExpression>()
|
|
||||||
else -> throwNoSuchSlot(slot)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitVariable(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
initializer?.accept(visitor, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+63
@@ -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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||||
|
return visitor.visitAnonymousInitializer(this, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||||
|
body.accept(visitor, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<IrDeclaration> = 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||||
|
visitor.visitClass(this, data)
|
||||||
|
|
||||||
|
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||||
|
members.forEach { it.accept(visitor, data) }
|
||||||
|
}
|
||||||
|
}
|
||||||
+45
@@ -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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||||
|
return visitor.visitConstructor(this, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
+27
@@ -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
|
||||||
+73
@@ -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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||||
|
visitor.visitDelegatedProperty(this, data)
|
||||||
|
|
||||||
|
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||||
|
delegate.accept(visitor, data)
|
||||||
|
getter?.accept(visitor, data)
|
||||||
|
setter?.accept(visitor, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||||
|
return visitor.visitEnumEntry(this, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||||
|
initializerExpression.accept(visitor, data)
|
||||||
|
correspondingClass?.accept(visitor, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
+45
@@ -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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||||
|
return visitor.visitErrorDeclaration(this, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||||
|
// no children
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getChild(slot: Int): IrElement? = null
|
||||||
|
|
||||||
|
override fun replaceChild(slot: Int, newChild: IrElement) = throwNoSuchSlot(slot)
|
||||||
|
}
|
||||||
@@ -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<AnnotationDescriptor> = SmartList()
|
||||||
|
|
||||||
|
fun addAnnotation(annotation: AnnotationDescriptor) {
|
||||||
|
fileAnnotations.add(annotation)
|
||||||
|
}
|
||||||
|
|
||||||
|
override val declarations: MutableList<IrDeclaration> = 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||||
|
visitor.visitFile(this, data)
|
||||||
|
|
||||||
|
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||||
|
declarations.forEach { it.accept(visitor, data) }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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<ValueParameterDescriptor, IrExpressionBody>()
|
||||||
|
|
||||||
|
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 <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||||
|
defaults.values.forEach { it.accept(visitor, data) }
|
||||||
|
body?.accept(visitor, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||||
|
visitor.visitFunction(this, data)
|
||||||
|
}
|
||||||
+64
@@ -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 <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||||
|
body?.accept(visitor, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
+97
@@ -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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||||
|
visitor.visitLocalDelegatedProperty(this, data)
|
||||||
|
|
||||||
|
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||||
|
delegate.accept(visitor, data)
|
||||||
|
getter.accept(visitor, data)
|
||||||
|
setter?.accept(visitor, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
+44
@@ -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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||||
|
return visitor.visitLocalPropertyAccessor(this, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<IrFile> = 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||||
|
visitor.visitModule(this, data)
|
||||||
|
|
||||||
|
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||||
|
files.forEach { it.accept(visitor, data) }
|
||||||
|
}
|
||||||
|
}
|
||||||
+26
@@ -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
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+43
@@ -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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||||
|
visitor.visitPropertyGetter(this, data)
|
||||||
|
}
|
||||||
+43
@@ -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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||||
|
visitor.visitPropertySetter(this, data)
|
||||||
|
}
|
||||||
+62
@@ -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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||||
|
visitor.visitSimpleProperty(this, data)
|
||||||
|
|
||||||
|
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||||
|
initializer?.accept(visitor, data)
|
||||||
|
getter?.accept(visitor, data)
|
||||||
|
setter?.accept(visitor, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||||
|
return visitor.visitTypeAlias(this, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||||
|
// no children
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getChild(slot: Int): IrElement? = null
|
||||||
|
|
||||||
|
override fun replaceChild(slot: Int, newChild: IrElement) {
|
||||||
|
throwNoSuchSlot(slot)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<IrExpression>()
|
||||||
|
else -> throwNoSuchSlot(slot)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||||
|
return visitor.visitVariable(this, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||||
|
initializer?.accept(visitor, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
-121
@@ -18,10 +18,6 @@ package org.jetbrains.kotlin.ir.expressions
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
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 {
|
interface IrBackingFieldExpression : IrDeclarationReference {
|
||||||
override val descriptor: PropertyDescriptor
|
override val descriptor: PropertyDescriptor
|
||||||
@@ -35,120 +31,3 @@ interface IrGetBackingField : IrBackingFieldExpression
|
|||||||
interface IrSetBackingField : IrBackingFieldExpression {
|
interface IrSetBackingField : IrBackingFieldExpression {
|
||||||
var value: IrExpression
|
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<PropertyDescriptor>(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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitGetBackingField(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitSetBackingField(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
receiver?.accept(visitor, data)
|
|
||||||
value.accept(visitor, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,10 +16,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ir.*
|
import org.jetbrains.kotlin.ir.IrStatement
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
import org.jetbrains.kotlin.ir.detach
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
|
|
||||||
interface IrBlock : IrExpression {
|
interface IrBlock : IrExpression {
|
||||||
@@ -28,79 +26,3 @@ interface IrBlock : IrExpression {
|
|||||||
val statements: List<IrStatement>
|
val statements: List<IrStatement>
|
||||||
}
|
}
|
||||||
|
|
||||||
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<IrStatement> get() = emptyList()
|
|
||||||
|
|
||||||
override fun getChild(slot: Int): IrElement? = null
|
|
||||||
|
|
||||||
override fun replaceChild(slot: Int, newChild: IrElement) {
|
|
||||||
throwNoSuchSlot(slot)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitBlock(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, 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<IrStatement>) :
|
|
||||||
this(startOffset, endOffset, type, operator) {
|
|
||||||
addAll(statements)
|
|
||||||
}
|
|
||||||
|
|
||||||
override val statements: MutableList<IrStatement> = ArrayList(2)
|
|
||||||
|
|
||||||
fun addStatement(statement: IrStatement) {
|
|
||||||
statement.assertDetached()
|
|
||||||
statement.setTreeLocation(this, statements.size)
|
|
||||||
statements.add(statement)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun addAll(newStatements: List<IrStatement>) {
|
|
||||||
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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitBlock(this, data)
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, 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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,9 +16,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ir.*
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
import org.jetbrains.kotlin.ir.IrStatement
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
interface IrBody : IrElement
|
interface IrBody : IrElement
|
||||||
|
|
||||||
@@ -39,84 +38,3 @@ enum class IrSyntheticBodyKind {
|
|||||||
ENUM_VALUEOF
|
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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitExpressionBody(this, data)
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
expression.accept(visitor, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class IrBlockBodyImpl(startOffset: Int, endOffset: Int) : IrElementBase(startOffset, endOffset), IrBlockBody {
|
|
||||||
override val statements: MutableList<IrStatement> = 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitBlockBody(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
statements.forEach { it.accept(visitor, data) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class IrSyntheticBodyImpl(startOffset: Int, endOffset: Int, override val kind: IrSyntheticBodyKind) : IrElementBase(startOffset, endOffset), IrSyntheticBody {
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitSyntheticBody(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
// no children
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getChild(slot: Int): IrElement? = null
|
|
||||||
|
|
||||||
override fun replaceChild(slot: Int, newChild: IrElement) {
|
|
||||||
throwNoSuchSlot(slot)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -19,8 +19,7 @@ package org.jetbrains.kotlin.ir.expressions
|
|||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.util.dump
|
import org.jetbrains.kotlin.ir.util.dump
|
||||||
import org.jetbrains.kotlin.ir.util.render
|
import org.jetbrains.kotlin.ir.util.render
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
import java.lang.AssertionError
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
|
||||||
|
|
||||||
interface IrBreakContinue : IrExpression {
|
interface IrBreakContinue : IrExpression {
|
||||||
var loop: IrLoop
|
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 <R, D> accept(visitor: IrElementVisitor<R, D>, 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitContinue(this, data)
|
|
||||||
}
|
|
||||||
@@ -16,23 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
|
||||||
|
|
||||||
interface IrCall : IrGeneralCall {
|
interface IrCall : IrGeneralCall {
|
||||||
val superQualifier: ClassDescriptor?
|
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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitCall(this, data)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,20 +16,5 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
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
|
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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitCallableReference(this, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,23 +16,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
|
||||||
|
|
||||||
|
|
||||||
interface IrClassReference : IrDeclarationReference {
|
interface IrClassReference : IrDeclarationReference {
|
||||||
override val descriptor: ClassifierDescriptor
|
override val descriptor: ClassifierDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
class IrClassReferenceImpl(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
type: KotlinType,
|
|
||||||
descriptor: ClassifierDescriptor
|
|
||||||
) : IrTerminalDeclarationReferenceBase<ClassifierDescriptor>(startOffset, endOffset, type, descriptor), IrClassReference {
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitClassReference(this, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,9 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
|
||||||
|
|
||||||
interface IrConst<T> : IrExpression, IrExpressionWithCopy {
|
interface IrConst<T> : IrExpression, IrExpressionWithCopy {
|
||||||
val kind: IrConstKind<T>
|
val kind: IrConstKind<T>
|
||||||
val value: T
|
val value: T
|
||||||
@@ -45,55 +42,3 @@ sealed class IrConstKind<T>(val asString: kotlin.String) {
|
|||||||
override fun toString() = asString
|
override fun toString() = asString
|
||||||
}
|
}
|
||||||
|
|
||||||
class IrConstImpl<T> (
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
type: KotlinType,
|
|
||||||
override val kind: IrConstKind<T>,
|
|
||||||
override val value: T
|
|
||||||
) : IrTerminalExpressionBase(startOffset, endOffset, type), IrConst<T> {
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitConst(this, data)
|
|
||||||
|
|
||||||
override fun copy(): IrConst<T> =
|
|
||||||
IrConstImpl(startOffset, endOffset, type, kind, value)
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
fun string(startOffset: Int, endOffset: Int, type: KotlinType, value: String): IrConstImpl<String> =
|
|
||||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.String, value)
|
|
||||||
|
|
||||||
fun int(startOffset: Int, endOffset: Int, type: KotlinType, value: Int): IrConstImpl<Int> =
|
|
||||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.Int, value)
|
|
||||||
|
|
||||||
fun constNull(startOffset: Int, endOffset: Int, type: KotlinType): IrConstImpl<Nothing?> =
|
|
||||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.Null, null)
|
|
||||||
|
|
||||||
fun boolean(startOffset: Int, endOffset: Int, type: KotlinType, value: Boolean): IrConstImpl<Boolean> =
|
|
||||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.Boolean, value)
|
|
||||||
|
|
||||||
fun constTrue(startOffset: Int, endOffset: Int, type: KotlinType): IrConstImpl<Boolean> =
|
|
||||||
boolean(startOffset, endOffset, type, true)
|
|
||||||
|
|
||||||
fun constFalse(startOffset: Int, endOffset: Int, type: KotlinType): IrConstImpl<Boolean> =
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,10 +18,6 @@ package org.jetbrains.kotlin.ir.expressions
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
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 {
|
interface IrDeclarationReference : IrExpression {
|
||||||
@@ -36,47 +32,3 @@ interface IrGetObjectValue : IrGetSingletonValue
|
|||||||
|
|
||||||
interface IrGetEnumValue : IrGetSingletonValue
|
interface IrGetEnumValue : IrGetSingletonValue
|
||||||
|
|
||||||
abstract class IrDeclarationReferenceBase<out D : DeclarationDescriptor>(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
type: KotlinType,
|
|
||||||
override val descriptor: D
|
|
||||||
) : IrExpressionBase(startOffset, endOffset, type), IrDeclarationReference
|
|
||||||
|
|
||||||
abstract class IrTerminalDeclarationReferenceBase<out D : DeclarationDescriptor>(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
type: KotlinType,
|
|
||||||
descriptor: D
|
|
||||||
) : IrDeclarationReferenceBase<D>(startOffset, endOffset, type, descriptor) {
|
|
||||||
override fun getChild(slot: Int): IrElement? = null
|
|
||||||
|
|
||||||
override fun replaceChild(slot: Int, newChild: IrElement) {
|
|
||||||
throwNoSuchSlot(slot)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
// No children
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class IrGetObjectValueImpl(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
type: KotlinType,
|
|
||||||
descriptor: ClassDescriptor
|
|
||||||
) : IrTerminalDeclarationReferenceBase<ClassDescriptor>(startOffset, endOffset, type, descriptor), IrGetObjectValue {
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitGetObjectValue(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
class IrGetEnumValueImpl(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
type: KotlinType,
|
|
||||||
descriptor: ClassDescriptor
|
|
||||||
) : IrTerminalDeclarationReferenceBase<ClassDescriptor>(startOffset, endOffset, type, descriptor), IrGetEnumValue {
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitGetEnumValue(this, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
-10
@@ -17,18 +17,8 @@
|
|||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|
||||||
|
|
||||||
interface IrDelegatingConstructorCall : IrGeneralCall {
|
interface IrDelegatingConstructorCall : IrGeneralCall {
|
||||||
override val descriptor: ConstructorDescriptor
|
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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitDelegatingConstructorCall(this, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.ir.expressions
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|
||||||
|
|
||||||
|
|
||||||
interface IrEnumConstructorCall : IrGeneralCall {
|
interface IrEnumConstructorCall : IrGeneralCall {
|
||||||
@@ -29,13 +28,3 @@ interface IrEnumConstructorCall : IrGeneralCall {
|
|||||||
val IrEnumConstructorCall.isSuper: Boolean
|
val IrEnumConstructorCall.isSuper: Boolean
|
||||||
get() = enumEntryDescriptor == null
|
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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitEnumConstructorCall(this, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,11 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
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 {
|
interface IrErrorExpression : IrExpression {
|
||||||
val description: String
|
val description: String
|
||||||
}
|
}
|
||||||
@@ -30,63 +25,3 @@ interface IrErrorCallExpression : IrErrorExpression {
|
|||||||
val arguments: List<IrExpression>
|
val arguments: List<IrExpression>
|
||||||
}
|
}
|
||||||
|
|
||||||
class IrErrorExpressionImpl(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
type: KotlinType,
|
|
||||||
override val description: String
|
|
||||||
) : IrTerminalExpressionBase(startOffset, endOffset, type), IrExpressionWithCopy, IrErrorExpression {
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitErrorExpression(this, data)
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, 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<IrExpression> = SmartList()
|
|
||||||
|
|
||||||
fun addArgument(argument: IrExpression) {
|
|
||||||
argument.assertDetached()
|
|
||||||
argument.setTreeLocation(this, arguments.size)
|
|
||||||
arguments.add(argument)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitErrorCallExpression(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, 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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,11 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
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.IrStatement
|
||||||
import org.jetbrains.kotlin.ir.throwNoSuchSlot
|
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
|
||||||
interface IrExpression : IrStatement, IrVarargElement {
|
interface IrExpression : IrStatement, IrVarargElement {
|
||||||
@@ -31,24 +27,3 @@ interface IrExpressionWithCopy : IrExpression {
|
|||||||
fun copy(): 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 <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
// No children
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,13 +18,6 @@ package org.jetbrains.kotlin.ir.expressions
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
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 {
|
interface IrGeneralCall : IrMemberAccessExpression {
|
||||||
val operator: IrOperator?
|
val operator: IrOperator?
|
||||||
@@ -49,49 +42,3 @@ inline fun <T : IrGeneralCall> T.mapValueParameters(transform: (ValueParameterDe
|
|||||||
return this
|
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<IrExpression>(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 <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
super.acceptChildren(visitor, data)
|
|
||||||
argumentsByParameterIndex.forEach { it?.accept(visitor, data) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,49 +16,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
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 {
|
interface IrGetClass : IrExpression {
|
||||||
var argument : 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitGetClass(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
argument.accept(visitor, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -17,7 +17,6 @@
|
|||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|
||||||
|
|
||||||
interface IrGetExtensionReceiver : IrDeclarationReference, IrExpressionWithCopy {
|
interface IrGetExtensionReceiver : IrDeclarationReference, IrExpressionWithCopy {
|
||||||
override val descriptor: ReceiverParameterDescriptor
|
override val descriptor: ReceiverParameterDescriptor
|
||||||
@@ -25,14 +24,3 @@ interface IrGetExtensionReceiver : IrDeclarationReference, IrExpressionWithCopy
|
|||||||
override fun copy(): IrGetExtensionReceiver
|
override fun copy(): IrGetExtensionReceiver
|
||||||
}
|
}
|
||||||
|
|
||||||
class IrGetExtensionReceiverImpl(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
descriptor: ReceiverParameterDescriptor
|
|
||||||
) : IrTerminalDeclarationReferenceBase<ReceiverParameterDescriptor>(startOffset, endOffset, descriptor.type, descriptor), IrGetExtensionReceiver {
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitGetExtensionReceiver(this, data)
|
|
||||||
|
|
||||||
override fun copy(): IrGetExtensionReceiver =
|
|
||||||
IrGetExtensionReceiverImpl(startOffset, endOffset, descriptor)
|
|
||||||
}
|
|
||||||
|
|||||||
-11
@@ -17,19 +17,8 @@
|
|||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
|
||||||
|
|
||||||
interface IrInstanceInitializerCall : IrExpression {
|
interface IrInstanceInitializerCall : IrExpression {
|
||||||
val classDescriptor: ClassDescriptor
|
val classDescriptor: ClassDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
class IrInstanceInitializerCallImpl(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
override val classDescriptor: ClassDescriptor
|
|
||||||
) : IrTerminalExpressionBase(startOffset, endOffset, classDescriptor.builtIns.unitType), IrInstanceInitializerCall {
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitInstanceInitializerCall(this, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,10 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
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 {
|
interface IrLoop : IrExpression {
|
||||||
val operator: IrOperator?
|
val operator: IrOperator?
|
||||||
var body: IrExpression?
|
var body: IrExpression?
|
||||||
@@ -31,100 +27,3 @@ interface IrWhileLoop : IrLoop
|
|||||||
|
|
||||||
interface IrDoWhileLoop : 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitWhileLoop(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitDoWhileLoop(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
body?.accept(visitor, data)
|
|
||||||
condition.accept(visitor, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-45
@@ -16,53 +16,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
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 {
|
interface IrMemberAccessExpression : IrDeclarationReference {
|
||||||
var dispatchReceiver: IrExpression?
|
var dispatchReceiver: IrExpression?
|
||||||
var extensionReceiver: 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 <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
dispatchReceiver?.accept(visitor, data)
|
|
||||||
extensionReceiver?.accept(visitor, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -17,9 +17,6 @@
|
|||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
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 {
|
interface IrReturn : IrExpression {
|
||||||
@@ -27,49 +24,3 @@ interface IrReturn : IrExpression {
|
|||||||
val returnTarget: CallableDescriptor
|
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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitReturn(this, data)
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
value?.accept(visitor, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -16,45 +16,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
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 {
|
interface IrStringConcatenation : IrExpression {
|
||||||
val arguments: List<IrExpression>
|
val arguments: List<IrExpression>
|
||||||
fun addArgument(argument: IrExpression)
|
fun addArgument(argument: IrExpression)
|
||||||
}
|
}
|
||||||
|
|
||||||
class IrStringConcatenationImpl(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
type: KotlinType
|
|
||||||
) : IrExpressionBase(startOffset, endOffset, type), IrStringConcatenation {
|
|
||||||
override val arguments: MutableList<IrExpression> = 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitStringConcatenation(this, data)
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
arguments.forEach { it.accept(visitor, data) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ package org.jetbrains.kotlin.ir.expressions
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
|
||||||
|
|
||||||
interface IrThisReference : IrExpression, IrExpressionWithCopy {
|
interface IrThisReference : IrExpression, IrExpressionWithCopy {
|
||||||
val classDescriptor: ClassDescriptor
|
val classDescriptor: ClassDescriptor
|
||||||
@@ -29,15 +27,3 @@ interface IrThisReference : IrExpression, IrExpressionWithCopy {
|
|||||||
val IrThisReference.receiverParameter: ReceiverParameterDescriptor
|
val IrThisReference.receiverParameter: ReceiverParameterDescriptor
|
||||||
get() = classDescriptor.thisAsReceiverParameter
|
get() = classDescriptor.thisAsReceiverParameter
|
||||||
|
|
||||||
class IrThisReferenceImpl(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
type: KotlinType,
|
|
||||||
override val classDescriptor: ClassDescriptor
|
|
||||||
) : IrTerminalExpressionBase(startOffset, endOffset, type), IrThisReference {
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitThisReference(this, data)
|
|
||||||
|
|
||||||
override fun copy(): IrThisReference =
|
|
||||||
IrThisReferenceImpl(startOffset, endOffset, type, classDescriptor)
|
|
||||||
}
|
|
||||||
@@ -16,58 +16,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
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 {
|
interface IrThrow : IrExpression {
|
||||||
var value: 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitThrow(this, data)
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
value.accept(visitor, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
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 {
|
interface IrTryCatch : IrExpression {
|
||||||
var tryResult: IrExpression
|
var tryResult: IrExpression
|
||||||
@@ -34,88 +30,3 @@ interface IrTryCatch : IrExpression {
|
|||||||
|
|
||||||
val IrTryCatch.catchClauseIndices: IntRange get() = 0 ..catchClausesCount - 1
|
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<VariableDescriptor>()
|
|
||||||
private val catchClauseResults = SmartList<IrExpression>()
|
|
||||||
|
|
||||||
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 <reified T : IrElement> putCatchClauseElement(list: MutableList<T>, 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitTryCatch(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
tryResult.accept(visitor, data)
|
|
||||||
for (index in 0 ..catchClausesCount - 1) {
|
|
||||||
catchClauseResults[index].accept(visitor, data)
|
|
||||||
}
|
|
||||||
finallyExpression?.accept(visitor, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
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.types.KotlinType
|
||||||
|
|
||||||
enum class IrTypeOperator {
|
enum class IrTypeOperator {
|
||||||
@@ -35,53 +33,3 @@ interface IrTypeOperatorCall : IrExpression {
|
|||||||
val typeOperand: KotlinType
|
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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitTypeOperator(this, data)
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
argument.accept(visitor, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,10 +16,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ir.*
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.utils.SmartList
|
|
||||||
|
|
||||||
interface IrVarargElement : IrElement
|
interface IrVarargElement : IrElement
|
||||||
|
|
||||||
@@ -32,80 +30,3 @@ interface IrSpreadElement : IrVarargElement {
|
|||||||
var expression: IrExpression
|
var expression: IrExpression
|
||||||
}
|
}
|
||||||
|
|
||||||
class IrVarargImpl(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
type: KotlinType,
|
|
||||||
override val varargElementType: KotlinType
|
|
||||||
) : IrVararg, IrExpressionBase(startOffset, endOffset, type) {
|
|
||||||
override val elements: MutableList<IrVarargElement> = 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitVararg(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitSpreadElement(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
expression.accept(visitor, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
-63
@@ -17,9 +17,6 @@
|
|||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
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 {
|
interface IrVariableAccessExpression : IrDeclarationReference {
|
||||||
override val descriptor: VariableDescriptor
|
override val descriptor: VariableDescriptor
|
||||||
@@ -34,63 +31,3 @@ interface IrSetVariable : IrVariableAccessExpression {
|
|||||||
var value: IrExpression
|
var value: IrExpression
|
||||||
}
|
}
|
||||||
|
|
||||||
class IrGetVariableImpl(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
descriptor: VariableDescriptor,
|
|
||||||
override val operator: IrOperator? = null
|
|
||||||
) : IrTerminalDeclarationReferenceBase<VariableDescriptor>(startOffset, endOffset, descriptor.type, descriptor), IrGetVariable {
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
|
||||||
return visitor.visitSetVariable(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
value.accept(visitor, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,11 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
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 {
|
interface IrWhen : IrExpression {
|
||||||
val operator: IrOperator?
|
val operator: IrOperator?
|
||||||
val branchesCount: Int
|
val branchesCount: Int
|
||||||
@@ -31,151 +26,3 @@ interface IrWhen : IrExpression {
|
|||||||
|
|
||||||
val IrWhen.branchIndices: IntRange get() = 0 ..branchesCount - 1
|
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<IrExpression>()
|
|
||||||
|
|
||||||
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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitWhen(this, data)
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, 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 <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
|
||||||
visitor.visitWhen(this, data)
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
|
||||||
condition.accept(visitor, data)
|
|
||||||
thenBranch.accept(visitor, data)
|
|
||||||
elseBranch?.accept(visitor, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
+55
@@ -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<PropertyDescriptor>(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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user