IrOperatorExpression -> IrPrimitiveCall
All "primitives" have their descriptors now.
This commit is contained in:
committed by
Dmitry Petrov
parent
c79b9c12d6
commit
ebd8f1266d
+3
-3
@@ -158,13 +158,13 @@ class BranchingExpressionGenerator(val statementGenerator: StatementGenerator) :
|
|||||||
return when (inOperator) {
|
return when (inOperator) {
|
||||||
IrOperator.IN -> irInCall
|
IrOperator.IN -> irInCall
|
||||||
IrOperator.NOT_IN ->
|
IrOperator.NOT_IN ->
|
||||||
IrUnaryOperatorImpl(ktCondition.startOffset, ktCondition.endOffset, IrOperator.EXCL, context.irBuiltIns.booleanNot, irInCall)
|
IrUnaryPrimitiveImpl(ktCondition.startOffset, ktCondition.endOffset, IrOperator.EXCL, context.irBuiltIns.booleanNot, irInCall)
|
||||||
else -> throw AssertionError("Expected 'in' or '!in', got $inOperator")
|
else -> throw AssertionError("Expected 'in' or '!in', got $inOperator")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun generateEqualsCondition(irSubject: IrVariable, ktCondition: KtWhenConditionWithExpression): IrBinaryOperatorImpl =
|
private fun generateEqualsCondition(irSubject: IrVariable, ktCondition: KtWhenConditionWithExpression): IrBinaryPrimitiveImpl =
|
||||||
IrBinaryOperatorImpl(
|
IrBinaryPrimitiveImpl(
|
||||||
ktCondition.startOffset, ktCondition.endOffset,
|
ktCondition.startOffset, ktCondition.endOffset,
|
||||||
IrOperator.EQEQ, context.irBuiltIns.eqeq,
|
IrOperator.EQEQ, context.irBuiltIns.eqeq,
|
||||||
irSubject.defaultLoad(), statementGenerator.generateExpression(ktCondition.expression!!)
|
irSubject.defaultLoad(), statementGenerator.generateExpression(ktCondition.expression!!)
|
||||||
|
|||||||
+11
-11
@@ -150,8 +150,8 @@ class OperatorExpressionGenerator(
|
|||||||
IrOperator.IN ->
|
IrOperator.IN ->
|
||||||
irContainsCall
|
irContainsCall
|
||||||
IrOperator.NOT_IN ->
|
IrOperator.NOT_IN ->
|
||||||
IrUnaryOperatorImpl(expression.startOffset, expression.endOffset, IrOperator.EXCL, context.irBuiltIns.booleanNot,
|
IrUnaryPrimitiveImpl(expression.startOffset, expression.endOffset, IrOperator.EXCL, context.irBuiltIns.booleanNot,
|
||||||
irContainsCall)
|
irContainsCall)
|
||||||
else ->
|
else ->
|
||||||
throw AssertionError("Unexpected in-operator $irOperator")
|
throw AssertionError("Unexpected in-operator $irOperator")
|
||||||
}
|
}
|
||||||
@@ -163,15 +163,15 @@ class OperatorExpressionGenerator(
|
|||||||
val irArgument1 = statementGenerator.generateExpression(expression.right!!)
|
val irArgument1 = statementGenerator.generateExpression(expression.right!!)
|
||||||
|
|
||||||
|
|
||||||
val irIdentityEquals = IrBinaryOperatorImpl(expression.startOffset, expression.endOffset, irOperator, context.irBuiltIns.eqeqeq,
|
val irIdentityEquals = IrBinaryPrimitiveImpl(expression.startOffset, expression.endOffset, irOperator, context.irBuiltIns.eqeqeq,
|
||||||
irArgument0, irArgument1)
|
irArgument0, irArgument1)
|
||||||
|
|
||||||
return when (irOperator) {
|
return when (irOperator) {
|
||||||
IrOperator.EQEQEQ ->
|
IrOperator.EQEQEQ ->
|
||||||
irIdentityEquals
|
irIdentityEquals
|
||||||
IrOperator.EXCLEQEQ ->
|
IrOperator.EXCLEQEQ ->
|
||||||
IrUnaryOperatorImpl(expression.startOffset, expression.endOffset, IrOperator.EXCL, context.irBuiltIns.booleanNot,
|
IrUnaryPrimitiveImpl(expression.startOffset, expression.endOffset, IrOperator.EXCL, context.irBuiltIns.booleanNot,
|
||||||
irIdentityEquals)
|
irIdentityEquals)
|
||||||
else ->
|
else ->
|
||||||
throw AssertionError("Unexpected identity operator $irOperator")
|
throw AssertionError("Unexpected identity operator $irOperator")
|
||||||
}
|
}
|
||||||
@@ -182,15 +182,15 @@ class OperatorExpressionGenerator(
|
|||||||
val irArgument0 = statementGenerator.generateExpression(expression.left!!)
|
val irArgument0 = statementGenerator.generateExpression(expression.left!!)
|
||||||
val irArgument1 = statementGenerator.generateExpression(expression.right!!)
|
val irArgument1 = statementGenerator.generateExpression(expression.right!!)
|
||||||
|
|
||||||
val irEquals = IrBinaryOperatorImpl(expression.startOffset, expression.endOffset,
|
val irEquals = IrBinaryPrimitiveImpl(expression.startOffset, expression.endOffset,
|
||||||
irOperator, context.irBuiltIns.eqeq, irArgument0, irArgument1)
|
irOperator, context.irBuiltIns.eqeq, irArgument0, irArgument1)
|
||||||
|
|
||||||
return when (irOperator) {
|
return when (irOperator) {
|
||||||
IrOperator.EQEQ ->
|
IrOperator.EQEQ ->
|
||||||
irEquals
|
irEquals
|
||||||
IrOperator.EXCLEQ ->
|
IrOperator.EXCLEQ ->
|
||||||
IrUnaryOperatorImpl(expression.startOffset, expression.endOffset, IrOperator.EXCLEQ,
|
IrUnaryPrimitiveImpl(expression.startOffset, expression.endOffset, IrOperator.EXCLEQ,
|
||||||
context.irBuiltIns.booleanNot, irEquals)
|
context.irBuiltIns.booleanNot, irEquals)
|
||||||
else ->
|
else ->
|
||||||
throw AssertionError("Unexpected equality operator $irOperator")
|
throw AssertionError("Unexpected equality operator $irOperator")
|
||||||
}
|
}
|
||||||
@@ -210,7 +210,7 @@ class OperatorExpressionGenerator(
|
|||||||
else -> throw AssertionError("Unexpected comparison operator: $irOperator")
|
else -> throw AssertionError("Unexpected comparison operator: $irOperator")
|
||||||
}
|
}
|
||||||
|
|
||||||
return IrUnaryOperatorImpl(expression.startOffset, expression.endOffset, irOperator, compareToZeroDescriptor, irCompareToCall)
|
return IrUnaryPrimitiveImpl(expression.startOffset, expression.endOffset, irOperator, compareToZeroDescriptor, irCompareToCall)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ import org.jetbrains.kotlin.ir.expressions.*
|
|||||||
|
|
||||||
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 =
|
||||||
IrUnaryOperatorImpl(startOffset, endOffset, irOperator, primitiveOpDescriptor, argument)
|
IrUnaryPrimitiveImpl(startOffset, endOffset, irOperator, primitiveOpDescriptor, argument)
|
||||||
|
|
||||||
fun primitiveOp2(startOffset: Int, endOffset: Int, primitiveOpDescriptor: CallableDescriptor, irOperator: IrOperator,
|
fun primitiveOp2(startOffset: Int, endOffset: Int, primitiveOpDescriptor: CallableDescriptor, irOperator: IrOperator,
|
||||||
argument1: IrExpression, argument2: IrExpression): IrExpression =
|
argument1: IrExpression, argument2: IrExpression): IrExpression =
|
||||||
IrBinaryOperatorImpl(startOffset, endOffset, irOperator, primitiveOpDescriptor, argument1, argument2)
|
IrBinaryPrimitiveImpl(startOffset, endOffset, irOperator, primitiveOpDescriptor, argument1, argument2)
|
||||||
|
|
||||||
fun Generator.constNull(startOffset: Int, endOffset: Int): IrExpression =
|
fun Generator.constNull(startOffset: Int, endOffset: Int): IrExpression =
|
||||||
IrConstImpl.constNull(startOffset, endOffset, context.builtIns.nullableNothingType)
|
IrConstImpl.constNull(startOffset, endOffset, context.builtIns.nullableNothingType)
|
||||||
|
|||||||
+7
-7
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.ir.*
|
|||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
|
||||||
abstract class IrOperatorCallBase(
|
abstract class IrPrimitiveCallBase(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
override val operator: IrOperator,
|
override val operator: IrOperator,
|
||||||
@@ -52,12 +52,12 @@ abstract class IrOperatorCallBase(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class IrNullaryOperatorImpl constructor(
|
class IrNullaryPrimitiveImpl constructor(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
operator: IrOperator,
|
operator: IrOperator,
|
||||||
descriptor: CallableDescriptor
|
descriptor: CallableDescriptor
|
||||||
) : IrOperatorCallBase(startOffset, endOffset, operator, descriptor) {
|
) : IrPrimitiveCallBase(startOffset, endOffset, operator, descriptor) {
|
||||||
override fun getChild(slot: Int): IrElement? = null
|
override fun getChild(slot: Int): IrElement? = null
|
||||||
|
|
||||||
override fun replaceChild(slot: Int, newChild: IrElement) {
|
override fun replaceChild(slot: Int, newChild: IrElement) {
|
||||||
@@ -69,12 +69,12 @@ class IrNullaryOperatorImpl constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class IrUnaryOperatorImpl private constructor(
|
class IrUnaryPrimitiveImpl private constructor(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
operator: IrOperator,
|
operator: IrOperator,
|
||||||
descriptor: CallableDescriptor
|
descriptor: CallableDescriptor
|
||||||
) : IrOperatorCallBase(startOffset, endOffset, operator, descriptor) {
|
) : IrPrimitiveCallBase(startOffset, endOffset, operator, descriptor) {
|
||||||
constructor(
|
constructor(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
@@ -113,12 +113,12 @@ class IrUnaryOperatorImpl private constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class IrBinaryOperatorImpl(
|
class IrBinaryPrimitiveImpl(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
operator: IrOperator,
|
operator: IrOperator,
|
||||||
descriptor: CallableDescriptor
|
descriptor: CallableDescriptor
|
||||||
) : IrOperatorCallBase(startOffset, endOffset, operator, descriptor) {
|
) : IrPrimitiveCallBase(startOffset, endOffset, operator, descriptor) {
|
||||||
constructor(
|
constructor(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
Reference in New Issue
Block a user