[IR] Hide constructors of implementation classes behind factory functions

This is a step towards generating those classes. The code generator
won't care about default values in parameters,
and secondly, it will reorder some constructor parameters.
To keep source compatibility, new factory functions are created,
with the same signature as the constructor.
They will resist the change in order of constructor parameters.
Eliminating direct calls to constructors should also make further
refactorings a bit easier.

This change omits classes deriving from IrMemberAccessExpression,
as they are a bit more complicated
and will require separate effort.

#KT-65773 In Progress
This commit is contained in:
Wojciech Litewka
2024-02-28 21:57:02 +01:00
committed by Space Team
parent b24d5390a8
commit 62f546ca0c
45 changed files with 1098 additions and 572 deletions
@@ -9,9 +9,9 @@ import org.jetbrains.kotlin.ir.IrImplementationDetail
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
class IrBlockBodyImpl @IrImplementationDetail constructor(
class IrBlockBodyImpl @IrImplementationDetail internal constructor(
override val startOffset: Int,
override val endOffset: Int
override val endOffset: Int,
) : IrBlockBody() {
override val statements: MutableList<IrStatement> = ArrayList(2)
}
@@ -1,46 +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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.IrBlock
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrBlockImpl(
class IrBlockImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var origin: IrStatementOrigin? = null,
override var origin: IrStatementOrigin?,
) : IrBlock() {
override val statements: MutableList<IrStatement> = ArrayList(2)
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
constructor(
startOffset: Int,
endOffset: Int,
type: IrType,
origin: IrStatementOrigin?,
statements: List<IrStatement>
) : this(startOffset, endOffset, type, origin) {
this.statements.addAll(statements)
}
fun IrBlockImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
origin: IrStatementOrigin? = null,
) = IrBlockImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
origin = origin,
)
fun IrBlockImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
origin: IrStatementOrigin? = null,
statements: List<IrStatement>,
) = IrBlockImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
origin = origin,
).apply {
this.statements.addAll(statements)
}
fun IrBlockImpl.addIfNotNull(statement: IrStatement?) {
@@ -7,13 +7,37 @@ package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.expressions.IrBranch
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
open class IrBranchImpl(
open class IrBranchImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var condition: IrExpression,
override var result: IrExpression
) : IrBranch() {
constructor(condition: IrExpression, result: IrExpression) :
this(condition.startOffset, result.endOffset, condition, result)
}
override var result: IrExpression,
) : IrBranch()
fun IrBranchImpl(
startOffset: Int,
endOffset: Int,
condition: IrExpression,
result: IrExpression,
) = IrBranchImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
condition = condition,
result = result,
)
fun IrBranchImpl(
condition: IrExpression,
result: IrExpression,
) = IrBranchImpl(
constructorIndicator = null,
startOffset = condition.startOffset,
endOffset = result.endOffset,
condition = condition,
result = result,
)
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -20,8 +9,11 @@ import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.IrBreak
import org.jetbrains.kotlin.ir.expressions.IrLoop
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrBreakImpl(
class IrBreakImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
@@ -32,3 +24,16 @@ class IrBreakImpl(
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
fun IrBreakImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
loop: IrLoop,
) = IrBreakImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
loop = loop,
)
@@ -8,20 +8,39 @@ package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.expressions.IrCatch
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrCatchImpl(
class IrCatchImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var catchParameter: IrVariable,
) : IrCatch() {
constructor(
startOffset: Int,
endOffset: Int,
catchParameter: IrVariable,
result: IrExpression
) : this(startOffset, endOffset, catchParameter) {
this.result = result
}
override lateinit var result: IrExpression
}
}
fun IrCatchImpl(
startOffset: Int,
endOffset: Int,
catchParameter: IrVariable,
) = IrCatchImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
catchParameter = catchParameter,
)
fun IrCatchImpl(
startOffset: Int,
endOffset: Int,
catchParameter: IrVariable,
result: IrExpression,
) = IrCatchImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
catchParameter = catchParameter,
).apply {
this.result = result
}
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -20,14 +9,32 @@ import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.IrClassReference
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrClassReferenceImpl(
class IrClassReferenceImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var symbol: IrClassifierSymbol,
override var classType: IrType
override var classType: IrType,
) : IrClassReference() {
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
}
fun IrClassReferenceImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
symbol: IrClassifierSymbol,
classType: IrType,
) = IrClassReferenceImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
symbol = symbol,
classType = classType,
)
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -21,25 +10,47 @@ import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.IrComposite
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrCompositeImpl(
class IrCompositeImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var origin: IrStatementOrigin? = null,
override var origin: IrStatementOrigin?,
) : IrComposite() {
override val statements: MutableList<IrStatement> = ArrayList(2)
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
constructor(
startOffset: Int,
endOffset: Int,
type: IrType,
origin: IrStatementOrigin?,
statements: List<IrStatement>
) : this(startOffset, endOffset, type, origin) {
this.statements.addAll(statements)
}
}
fun IrCompositeImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
origin: IrStatementOrigin? = null,
) = IrCompositeImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
origin = origin,
)
fun IrCompositeImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
origin: IrStatementOrigin?,
statements: List<IrStatement>,
) = IrCompositeImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
origin = origin,
).apply {
this.statements.addAll(statements)
}
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -24,13 +13,16 @@ import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.getPrimitiveType
import org.jetbrains.kotlin.ir.types.isMarkedNullable
import org.jetbrains.kotlin.ir.types.makeNullable
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrConstImpl<T>(
class IrConstImpl<T> internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var kind: IrConstKind<T>,
override var value: T
override var value: T,
) : IrConst<T>() {
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
@@ -91,3 +83,18 @@ class IrConstImpl<T>(
fun <T> IrConst<T>.copyWithOffsets(startOffset: Int, endOffset: Int) =
IrConstImpl(startOffset, endOffset, type, kind, value)
fun <T> IrConstImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
kind: IrConstKind<T>,
value: T,
) = IrConstImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
kind = kind,
value = value,
)
@@ -9,16 +9,32 @@ import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.IrConstantArray
import org.jetbrains.kotlin.ir.expressions.IrConstantValue
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
import org.jetbrains.kotlin.utils.SmartList
class IrConstantArrayImpl(
class IrConstantArrayImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
initElements: List<IrConstantValue>,
) : IrConstantArray() {
override val elements = SmartList(initElements)
override val elements = SmartList<IrConstantValue>()
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
fun IrConstantArrayImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
initElements: List<IrConstantValue>,
) = IrConstantArrayImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
).apply {
elements.addAll(initElements)
}
@@ -10,20 +10,39 @@ import org.jetbrains.kotlin.ir.expressions.IrConstantObject
import org.jetbrains.kotlin.ir.expressions.IrConstantValue
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
import org.jetbrains.kotlin.ir.util.constructedClassType
import org.jetbrains.kotlin.utils.SmartList
class IrConstantObjectImpl(
class IrConstantObjectImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var constructor: IrConstructorSymbol,
initValueArguments: List<IrConstantValue>,
initTypeArguments: List<IrType>,
override var type: IrType = constructor.owner.constructedClassType,
override var type: IrType,
) : IrConstantObject() {
override val valueArguments = SmartList(initValueArguments)
override val typeArguments = SmartList(initTypeArguments)
override val valueArguments = SmartList<IrConstantValue>()
override val typeArguments = SmartList<IrType>()
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
fun IrConstantObjectImpl(
startOffset: Int,
endOffset: Int,
constructor: IrConstructorSymbol,
initValueArguments: List<IrConstantValue>,
initTypeArguments: List<IrType>,
type: IrType = constructor.owner.constructedClassType,
) = IrConstantObjectImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
constructor = constructor,
type = type,
).apply {
valueArguments.addAll(initValueArguments)
typeArguments.addAll(initTypeArguments)
}
@@ -8,8 +8,11 @@ package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.IrConst
import org.jetbrains.kotlin.ir.expressions.IrConstantPrimitive
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrConstantPrimitiveImpl(
class IrConstantPrimitiveImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var value: IrConst<*>,
@@ -17,4 +20,15 @@ class IrConstantPrimitiveImpl(
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
override var type = value.type
}
}
fun IrConstantPrimitiveImpl(
startOffset: Int,
endOffset: Int,
value: IrConst<*>,
) = IrConstantPrimitiveImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
value = value,
)
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -20,8 +9,11 @@ import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.IrContinue
import org.jetbrains.kotlin.ir.expressions.IrLoop
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrContinueImpl(
class IrContinueImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
@@ -31,4 +23,17 @@ class IrContinueImpl(
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
}
fun IrContinueImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
loop: IrLoop,
) = IrContinueImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
loop = loop,
)
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -21,8 +10,11 @@ import org.jetbrains.kotlin.ir.expressions.IrDoWhileLoop
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrDoWhileLoopImpl(
class IrDoWhileLoopImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
@@ -35,3 +27,16 @@ class IrDoWhileLoopImpl(
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
fun IrDoWhileLoopImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
origin: IrStatementOrigin?,
) = IrDoWhileLoopImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
origin = origin,
)
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -9,14 +9,32 @@ import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.IrDynamicMemberExpression
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrDynamicMemberExpressionImpl(
class IrDynamicMemberExpressionImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var memberName: String,
override var receiver: IrExpression
override var receiver: IrExpression,
) : IrDynamicMemberExpression() {
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
}
fun IrDynamicMemberExpressionImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
memberName: String,
receiver: IrExpression,
) = IrDynamicMemberExpressionImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
memberName = memberName,
receiver = receiver,
)
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -10,13 +10,16 @@ import org.jetbrains.kotlin.ir.expressions.IrDynamicOperator
import org.jetbrains.kotlin.ir.expressions.IrDynamicOperatorExpression
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
import org.jetbrains.kotlin.utils.SmartList
class IrDynamicOperatorExpressionImpl(
class IrDynamicOperatorExpressionImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var operator: IrDynamicOperator
override var operator: IrDynamicOperator,
) : IrDynamicOperatorExpression() {
override lateinit var receiver: IrExpression
@@ -25,3 +28,16 @@ class IrDynamicOperatorExpressionImpl(
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
fun IrDynamicOperatorExpressionImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
operator: IrDynamicOperator,
) = IrDynamicOperatorExpressionImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
operator = operator,
)
@@ -7,13 +7,37 @@ package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.expressions.IrElseBranch
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrElseBranchImpl(
class IrElseBranchImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var condition: IrExpression,
override var result: IrExpression
) : IrElseBranch() {
constructor(condition: IrExpression, result: IrExpression) :
this(condition.startOffset, result.endOffset, condition, result)
}
override var result: IrExpression,
) : IrElseBranch()
fun IrElseBranchImpl(
startOffset: Int,
endOffset: Int,
condition: IrExpression,
result: IrExpression,
) = IrElseBranchImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
condition = condition,
result = result,
)
fun IrElseBranchImpl(
condition: IrExpression,
result: IrExpression,
) = IrElseBranchImpl(
constructorIndicator = null,
startOffset = condition.startOffset,
endOffset = result.endOffset,
condition = condition,
result = result,
)
@@ -9,13 +9,16 @@ import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.IrErrorCallExpression
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
import org.jetbrains.kotlin.utils.SmartList
class IrErrorCallExpressionImpl(
class IrErrorCallExpressionImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var description: String
override var description: String,
) : IrErrorCallExpression() {
override var explicitReceiver: IrExpression? = null
override val arguments: MutableList<IrExpression> = SmartList()
@@ -23,3 +26,16 @@ class IrErrorCallExpressionImpl(
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
fun IrErrorCallExpressionImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
description: String,
) = IrErrorCallExpressionImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
description = description,
)
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -19,13 +8,29 @@ package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.IrErrorExpression
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrErrorExpressionImpl(
class IrErrorExpressionImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var description: String
override var description: String,
) : IrErrorExpression() {
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
}
fun IrErrorExpressionImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
description: String,
) = IrErrorExpressionImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
description = description,
)
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.ir.IrImplementationDetail
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
class IrExpressionBodyImpl @IrImplementationDetail constructor(
class IrExpressionBodyImpl @IrImplementationDetail internal constructor(
override val startOffset: Int,
override val endOffset: Int,
override var expression: IrExpression,
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -10,14 +10,32 @@ import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
import org.jetbrains.kotlin.ir.expressions.IrFunctionExpression
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrFunctionExpressionImpl(
class IrFunctionExpressionImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var function: IrSimpleFunction,
override var origin: IrStatementOrigin
override var origin: IrStatementOrigin,
) : IrFunctionExpression() {
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
}
fun IrFunctionExpressionImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
function: IrSimpleFunction,
origin: IrStatementOrigin,
) = IrFunctionExpressionImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
function = function,
origin = origin,
)
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -20,8 +9,11 @@ import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrGetClass
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrGetClassImpl(
class IrGetClassImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
@@ -29,4 +21,17 @@ class IrGetClassImpl(
) : IrGetClass() {
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
}
fun IrGetClassImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
argument: IrExpression,
) = IrGetClassImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
argument = argument,
)
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -20,8 +9,11 @@ import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.IrGetEnumValue
import org.jetbrains.kotlin.ir.symbols.IrEnumEntrySymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrGetEnumValueImpl(
class IrGetEnumValueImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
@@ -29,4 +21,17 @@ class IrGetEnumValueImpl(
) : IrGetEnumValue() {
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
}
fun IrGetEnumValueImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
symbol: IrEnumEntrySymbol,
) = IrGetEnumValueImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
symbol = symbol,
)
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -23,28 +12,57 @@ import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrGetFieldImpl(
class IrGetFieldImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var symbol: IrFieldSymbol,
override var type: IrType,
override var origin: IrStatementOrigin? = null,
override var superQualifierSymbol: IrClassSymbol? = null,
override var origin: IrStatementOrigin?,
override var superQualifierSymbol: IrClassSymbol?,
) : IrGetField() {
override var receiver: IrExpression? = null
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
constructor(
startOffset: Int, endOffset: Int,
symbol: IrFieldSymbol,
type: IrType,
receiver: IrExpression?,
origin: IrStatementOrigin? = null,
superQualifierSymbol: IrClassSymbol? = null
) : this(startOffset, endOffset, symbol, type, origin, superQualifierSymbol) {
this.receiver = receiver
}
}
fun IrGetFieldImpl(
startOffset: Int,
endOffset: Int,
symbol: IrFieldSymbol,
type: IrType,
origin: IrStatementOrigin? = null,
superQualifierSymbol: IrClassSymbol? = null,
) = IrGetFieldImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
symbol = symbol,
type = type,
origin = origin,
superQualifierSymbol = superQualifierSymbol,
)
fun IrGetFieldImpl(
startOffset: Int,
endOffset: Int,
symbol: IrFieldSymbol,
type: IrType,
receiver: IrExpression?,
origin: IrStatementOrigin? = null,
superQualifierSymbol: IrClassSymbol? = null,
) = IrGetFieldImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
symbol = symbol,
type = type,
origin = origin,
superQualifierSymbol = superQualifierSymbol,
).apply {
this.receiver = receiver
}
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -20,13 +9,29 @@ import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.IrGetObjectValue
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrGetObjectValueImpl(
class IrGetObjectValueImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var symbol: IrClassSymbol
override var symbol: IrClassSymbol,
) : IrGetObjectValue() {
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
}
fun IrGetObjectValueImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
symbol: IrClassSymbol,
) = IrGetObjectValueImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
symbol = symbol,
)
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -10,24 +10,49 @@ import org.jetbrains.kotlin.ir.expressions.IrGetValue
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrGetValueImpl(
class IrGetValueImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var symbol: IrValueSymbol,
override var origin: IrStatementOrigin? = null
override var origin: IrStatementOrigin?,
) : IrGetValue() {
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
constructor(
startOffset: Int,
endOffset: Int,
symbol: IrValueSymbol,
origin: IrStatementOrigin? = null
) : this(startOffset, endOffset, symbol.owner.type, symbol, origin)
}
fun IrGetValue.copyWithOffsets(newStartOffset: Int, newEndOffset: Int): IrGetValue =
IrGetValueImpl(newStartOffset, newEndOffset, type, symbol, origin)
fun IrGetValueImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
symbol: IrValueSymbol,
origin: IrStatementOrigin? = null,
) = IrGetValueImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
symbol = symbol,
origin = origin,
)
fun IrGetValueImpl(
startOffset: Int,
endOffset: Int,
symbol: IrValueSymbol,
origin: IrStatementOrigin? = null,
) = IrGetValueImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = symbol.owner.type,
symbol = symbol,
origin = origin,
)
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -21,16 +10,32 @@ import org.jetbrains.kotlin.ir.expressions.IrBranch
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.expressions.IrWhen
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
import org.jetbrains.kotlin.utils.SmartList
class IrIfThenElseImpl(
class IrIfThenElseImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var origin: IrStatementOrigin? = null
override var origin: IrStatementOrigin?,
) : IrWhen() {
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
override val branches: MutableList<IrBranch> = SmartList()
}
fun IrIfThenElseImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
origin: IrStatementOrigin? = null,
) = IrIfThenElseImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
origin = origin,
)
@@ -12,29 +12,57 @@ import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression
import org.jetbrains.kotlin.ir.expressions.IrInlinedFunctionBlock
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrInlinedFunctionBlockImpl(
class IrInlinedFunctionBlockImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var inlineCall: IrFunctionAccessExpression,
override var inlinedElement: IrElement,
override var origin: IrStatementOrigin? = null,
override var origin: IrStatementOrigin?,
) : IrInlinedFunctionBlock() {
override val statements: MutableList<IrStatement> = ArrayList(2)
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
constructor(
startOffset: Int,
endOffset: Int,
type: IrType,
inlineCall: IrFunctionAccessExpression,
inlinedElement: IrElement,
origin: IrStatementOrigin?,
statements: List<IrStatement>,
) : this(startOffset, endOffset, type, inlineCall, inlinedElement, origin) {
this.statements.addAll(statements)
}
fun IrInlinedFunctionBlockImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
inlineCall: IrFunctionAccessExpression,
inlinedElement: IrElement,
origin: IrStatementOrigin? = null,
) = IrInlinedFunctionBlockImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
inlineCall = inlineCall,
inlinedElement = inlinedElement,
origin = origin,
)
fun IrInlinedFunctionBlockImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
inlineCall: IrFunctionAccessExpression,
inlinedElement: IrElement,
origin: IrStatementOrigin?,
statements: List<IrStatement>,
) = IrInlinedFunctionBlockImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
inlineCall = inlineCall,
inlinedElement = inlinedElement,
origin = origin,
).apply {
this.statements.addAll(statements)
}
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -20,8 +9,11 @@ import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.IrInstanceInitializerCall
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrInstanceInitializerCallImpl(
class IrInstanceInitializerCallImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var classSymbol: IrClassSymbol,
@@ -30,3 +22,16 @@ class IrInstanceInitializerCallImpl(
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
fun IrInstanceInitializerCallImpl(
startOffset: Int,
endOffset: Int,
classSymbol: IrClassSymbol,
type: IrType,
) = IrInstanceInitializerCallImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
classSymbol = classSymbol,
type = type,
)
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -20,8 +9,11 @@ import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.IrRawFunctionReference
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrRawFunctionReferenceImpl(
class IrRawFunctionReferenceImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
@@ -29,4 +21,17 @@ class IrRawFunctionReferenceImpl(
) : IrRawFunctionReference() {
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
}
fun IrRawFunctionReferenceImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
symbol: IrFunctionSymbol,
) = IrRawFunctionReferenceImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
symbol = symbol,
)
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -21,14 +10,32 @@ import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrReturn
import org.jetbrains.kotlin.ir.symbols.IrReturnTargetSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrReturnImpl(
class IrReturnImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var returnTargetSymbol: IrReturnTargetSymbol,
override var value: IrExpression
override var value: IrExpression,
) : IrReturn() {
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
}
fun IrReturnImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
returnTargetSymbol: IrReturnTargetSymbol,
value: IrExpression,
) = IrReturnImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
returnTargetSymbol = returnTargetSymbol,
value = value,
)
@@ -13,13 +13,16 @@ import org.jetbrains.kotlin.ir.expressions.IrReturnableBlock
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.symbols.IrReturnableBlockSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrReturnableBlockImpl(
class IrReturnableBlockImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override val symbol: IrReturnableBlockSymbol,
override var origin: IrStatementOrigin? = null,
override var origin: IrStatementOrigin?,
) : IrReturnableBlock() {
override val statements: MutableList<IrStatement> = ArrayList(2)
@@ -30,18 +33,40 @@ class IrReturnableBlockImpl(
override val descriptor: FunctionDescriptor
get() = symbol.descriptor
constructor(
startOffset: Int,
endOffset: Int,
type: IrType,
symbol: IrReturnableBlockSymbol,
origin: IrStatementOrigin?,
statements: List<IrStatement>,
) : this(startOffset, endOffset, type, symbol, origin) {
this.statements.addAll(statements)
}
init {
symbol.bind(this)
}
}
}
fun IrReturnableBlockImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
symbol: IrReturnableBlockSymbol,
origin: IrStatementOrigin? = null,
) = IrReturnableBlockImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
symbol = symbol,
origin = origin,
)
fun IrReturnableBlockImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
symbol: IrReturnableBlockSymbol,
origin: IrStatementOrigin?,
statements: List<IrStatement>,
) = IrReturnableBlockImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
symbol = symbol,
origin = origin,
).apply {
this.statements.addAll(statements)
}
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -23,32 +12,60 @@ import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrSetFieldImpl(
class IrSetFieldImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var symbol: IrFieldSymbol,
override var type: IrType,
override var origin: IrStatementOrigin? = null,
override var superQualifierSymbol: IrClassSymbol? = null,
override var origin: IrStatementOrigin?,
override var superQualifierSymbol: IrClassSymbol?,
) : IrSetField() {
override var receiver: IrExpression? = null
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
constructor(
startOffset: Int, endOffset: Int,
symbol: IrFieldSymbol,
receiver: IrExpression?,
value: IrExpression,
type: IrType,
origin: IrStatementOrigin? = null,
superQualifierSymbol: IrClassSymbol? = null
) : this(startOffset, endOffset, symbol, type, origin, superQualifierSymbol) {
this.receiver = receiver
this.value = value
}
override lateinit var value: IrExpression
}
fun IrSetFieldImpl(
startOffset: Int,
endOffset: Int,
symbol: IrFieldSymbol,
type: IrType,
origin: IrStatementOrigin? = null,
superQualifierSymbol: IrClassSymbol? = null,
) = IrSetFieldImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
symbol = symbol,
type = type,
origin = origin,
superQualifierSymbol = superQualifierSymbol,
)
fun IrSetFieldImpl(
startOffset: Int, endOffset: Int,
symbol: IrFieldSymbol,
receiver: IrExpression?,
value: IrExpression,
type: IrType,
origin: IrStatementOrigin? = null,
superQualifierSymbol: IrClassSymbol? = null,
) = IrSetFieldImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
symbol = symbol,
type = type,
origin = origin,
superQualifierSymbol = superQualifierSymbol,
).apply {
this.receiver = receiver
this.value = value
}
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -22,14 +11,17 @@ import org.jetbrains.kotlin.ir.expressions.IrSetValue
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrSetValueImpl(
class IrSetValueImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var symbol: IrValueSymbol,
override var value: IrExpression,
override var origin: IrStatementOrigin?
override var origin: IrStatementOrigin?,
) : IrSetValue() {
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
@@ -40,3 +32,20 @@ class IrSetValueImpl(
}
}
}
fun IrSetValueImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
symbol: IrValueSymbol,
value: IrExpression,
origin: IrStatementOrigin?,
) = IrSetValueImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
symbol = symbol,
value = value,
origin = origin,
)
@@ -1,26 +1,29 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrSpreadElement
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrSpreadElementImpl(
class IrSpreadElementImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var expression: IrExpression,
) : IrSpreadElement()
fun IrSpreadElementImpl(
startOffset: Int,
endOffset: Int,
expression: IrExpression,
) = IrSpreadElementImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
expression = expression,
)
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -20,24 +9,42 @@ import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrStringConcatenation
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.utils.SmartList
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrStringConcatenationImpl(
class IrStringConcatenationImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType
override var type: IrType,
) : IrStringConcatenation() {
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
constructor(
startOffset: Int,
endOffset: Int,
type: IrType,
arguments: Collection<IrExpression>
) : this(startOffset, endOffset, type) {
this.arguments.addAll(arguments)
}
override val arguments: MutableList<IrExpression> = ArrayList(2)
}
fun IrStringConcatenationImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
) = IrStringConcatenationImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
)
fun IrStringConcatenationImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
arguments: Collection<IrExpression>,
) = IrStringConcatenationImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
).apply {
this.arguments.addAll(arguments)
}
@@ -9,14 +9,32 @@ import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrSuspendableExpression
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrSuspendableExpressionImpl(
class IrSuspendableExpressionImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var suspensionPointId: IrExpression,
override var result: IrExpression
override var result: IrExpression,
) : IrSuspendableExpression() {
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
}
fun IrSuspendableExpressionImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
suspensionPointId: IrExpression,
result: IrExpression,
) = IrSuspendableExpressionImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
suspensionPointId = suspensionPointId,
result = result,
)
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -10,15 +10,35 @@ import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrSuspensionPoint
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrSuspensionPointImpl(
class IrSuspensionPointImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var suspensionPointIdParameter: IrVariable,
override var result: IrExpression,
override var resumeResult: IrExpression
override var resumeResult: IrExpression,
) : IrSuspensionPoint() {
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
}
fun IrSuspensionPointImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
suspensionPointIdParameter: IrVariable,
result: IrExpression,
resumeResult: IrExpression,
) = IrSuspensionPointImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
suspensionPointIdParameter = suspensionPointIdParameter,
result = result,
resumeResult = resumeResult,
)
@@ -7,9 +7,23 @@ package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.expressions.IrSyntheticBody
import org.jetbrains.kotlin.ir.expressions.IrSyntheticBodyKind
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrSyntheticBodyImpl(
class IrSyntheticBodyImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var kind: IrSyntheticBodyKind,
) : IrSyntheticBody()
fun IrSyntheticBodyImpl(
startOffset: Int,
endOffset: Int,
kind: IrSyntheticBodyKind,
) = IrSyntheticBodyImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
kind = kind,
)
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -20,8 +9,11 @@ import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrThrow
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrThrowImpl(
class IrThrowImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
@@ -29,4 +21,17 @@ class IrThrowImpl(
) : IrThrow() {
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
}
fun IrThrowImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
value: IrExpression,
) = IrThrowImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
value = value,
)
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -21,26 +10,16 @@ import org.jetbrains.kotlin.ir.expressions.IrCatch
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrTry
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
import org.jetbrains.kotlin.utils.SmartList
class IrTryImpl(
class IrTryImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
) : IrTry() {
constructor(
startOffset: Int,
endOffset: Int,
type: IrType,
tryResult: IrExpression,
catches: List<IrCatch>,
finallyExpression: IrExpression?
) : this(startOffset, endOffset, type) {
this.tryResult = tryResult
this.catches.addAll(catches)
this.finallyExpression = finallyExpression
}
override lateinit var tryResult: IrExpression
override val catches: MutableList<IrCatch> = SmartList()
@@ -50,3 +29,32 @@ class IrTryImpl(
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
fun IrTryImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
) = IrTryImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
)
fun IrTryImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
tryResult: IrExpression,
catches: List<IrCatch>,
finallyExpression: IrExpression?,
) = IrTryImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
).apply {
this.tryResult = tryResult
this.catches.addAll(catches)
this.finallyExpression = finallyExpression
}
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -21,8 +10,11 @@ import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrTypeOperator
import org.jetbrains.kotlin.ir.expressions.IrTypeOperatorCall
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrTypeOperatorCallImpl(
class IrTypeOperatorCallImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
@@ -33,3 +25,20 @@ class IrTypeOperatorCallImpl(
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
fun IrTypeOperatorCallImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
operator: IrTypeOperator,
typeOperand: IrType,
argument: IrExpression,
) = IrTypeOperatorCallImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
operator = operator,
typeOperand = typeOperand,
argument = argument,
)
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -20,26 +9,48 @@ import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.IrVararg
import org.jetbrains.kotlin.ir.expressions.IrVarargElement
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
import org.jetbrains.kotlin.utils.SmartList
class IrVarargImpl(
class IrVarargImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var varargElementType: IrType
override var varargElementType: IrType,
) : IrVararg() {
constructor(
startOffset: Int,
endOffset: Int,
type: IrType,
varargElementType: IrType,
elements: List<IrVarargElement>
) : this(startOffset, endOffset, type, varargElementType) {
this.elements.addAll(elements)
}
override val elements: MutableList<IrVarargElement> = SmartList()
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
fun IrVarargImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
varargElementType: IrType,
) = IrVarargImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
varargElementType = varargElementType,
)
fun IrVarargImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
varargElementType: IrType,
elements: List<IrVarargElement>,
) = IrVarargImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
varargElementType = varargElementType,
).apply {
this.elements.addAll(elements)
}
@@ -1,43 +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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.IrBranch
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.expressions.IrWhen
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrWhenImpl(
class IrWhenImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var origin: IrStatementOrigin? = null
override var origin: IrStatementOrigin?,
) : IrWhen() {
constructor(
startOffset: Int,
endOffset: Int,
type: IrType,
origin: IrStatementOrigin?,
branches: List<IrBranch>
) : this(startOffset, endOffset, type, origin) {
this.branches.addAll(branches)
}
override val branches: MutableList<IrBranch> = ArrayList(2)
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
fun IrWhenImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
origin: IrStatementOrigin? = null,
) = IrWhenImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
origin = origin,
)
fun IrWhenImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
origin: IrStatementOrigin?,
branches: List<IrBranch>,
) = IrWhenImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
origin = origin,
).apply {
this.branches.addAll(branches)
}
@@ -1,17 +1,6 @@
/*
* 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.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.expressions.impl
@@ -21,8 +10,11 @@ import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.expressions.IrWhileLoop
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrElementConstructorIndicator
class IrWhileLoopImpl(
class IrWhileLoopImpl internal constructor(
@Suppress("UNUSED_PARAMETER")
constructorIndicator: IrElementConstructorIndicator?,
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
@@ -35,3 +27,16 @@ class IrWhileLoopImpl(
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
}
fun IrWhileLoopImpl(
startOffset: Int,
endOffset: Int,
type: IrType,
origin: IrStatementOrigin?,
) = IrWhileLoopImpl(
constructorIndicator = null,
startOffset = startOffset,
endOffset = endOffset,
type = type,
origin = origin,
)
@@ -0,0 +1,13 @@
/*
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.util
/**
A hack used to force compiler to resolve calls to a
constructor, instead of builder function with the same name.
To be removed soon.
*/
internal object IrElementConstructorIndicator