0804c6a0f3
This commit introduces several different things, in particular: - check type arguments in expressions - new TypeArgumentList node to deal with diagnostic source - ConeDiagnostic was moved to fir:cones - ConeIntermediateDiagnostic to use in inference (?) without reporting - detailed diagnostics on error type
41 lines
2.1 KiB
Kotlin
Vendored
41 lines
2.1 KiB
Kotlin
Vendored
package org.jetbrains.kotlin.codegen.range.inExpression
|
|
|
|
interface ExpressionCodegen
|
|
interface KtSimpleNameExpression
|
|
interface InExpressionGenerator
|
|
interface StackValue
|
|
open class BranchedValue
|
|
interface Type
|
|
interface KotlinType
|
|
interface Label
|
|
interface InstructionAdapter
|
|
|
|
class CallBasedInExpressionGenerator(
|
|
val codegen: ExpressionCodegen,
|
|
operatorReference: KtSimpleNameExpression
|
|
) : InExpressionGenerator {
|
|
private val resolvedCall = operatorReference.<!UNRESOLVED_REFERENCE!>getResolvedCallWithAssert<!>(codegen.<!UNRESOLVED_REFERENCE!>bindingContext<!>)
|
|
private val isInverted = operatorReference.<!UNRESOLVED_REFERENCE!>getReferencedNameElementType<!>() == <!UNRESOLVED_REFERENCE!>KtTokens<!>.<!UNRESOLVED_REFERENCE!>NOT_IN<!>
|
|
|
|
override fun generate(argument: StackValue): BranchedValue =
|
|
gen(argument).let { if (isInverted) <!UNRESOLVED_REFERENCE!>Invert<!>(it) else it }
|
|
|
|
private fun gen(argument: StackValue): BranchedValue =
|
|
object : <!INAPPLICABLE_CANDIDATE!>BranchedValue<!>(argument, null, argument.<!UNRESOLVED_REFERENCE!>type<!>, <!UNRESOLVED_REFERENCE!>Opcodes<!>.<!UNRESOLVED_REFERENCE!>IFEQ<!>) {
|
|
override fun putSelector(type: Type, kotlinType: KotlinType?, v: InstructionAdapter) {
|
|
invokeFunction(v)
|
|
<!UNRESOLVED_REFERENCE!>coerceTo<!>(type, kotlinType, v)
|
|
}
|
|
|
|
override fun condJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) {
|
|
invokeFunction(v)
|
|
v.<!UNRESOLVED_REFERENCE!>visitJumpInsn<!>(if (jumpIfFalse) <!UNRESOLVED_REFERENCE!>Opcodes<!>.<!UNRESOLVED_REFERENCE!>IFEQ<!> else <!UNRESOLVED_REFERENCE!>Opcodes<!>.<!UNRESOLVED_REFERENCE!>IFNE<!>, jumpLabel)
|
|
}
|
|
|
|
private fun invokeFunction(v: InstructionAdapter) {
|
|
val result = codegen.<!UNRESOLVED_REFERENCE!>invokeFunction<!>(resolvedCall.<!UNRESOLVED_REFERENCE!>call<!>, resolvedCall, <!UNRESOLVED_REFERENCE!>none<!>())
|
|
result.<!UNRESOLVED_REFERENCE!>put<!>(result.<!UNRESOLVED_REFERENCE!>type<!>, result.<!UNRESOLVED_REFERENCE!>kotlinType<!>, v)
|
|
}
|
|
}
|
|
}
|