Extract logical not expression

This commit is contained in:
Tamas Vajk
2022-10-03 10:23:40 +02:00
parent a2d0b38a6d
commit 54b210f176
5 changed files with 35 additions and 8 deletions

View File

@@ -1887,6 +1887,22 @@ open class KotlinFileExtractor(
}
}
fun unaryopReceiver(id: Label<out DbExpr>, receiver: IrExpression?, receiverDescription: String) {
val locId = tw.getLocation(c)
tw.writeHasLocation(id, locId)
tw.writeCallableEnclosingExpr(id, callable)
tw.writeStatementEnclosingExpr(id, enclosingStmt)
if(receiver == null) {
logger.errorElement("$receiverDescription not found", c)
} else {
extractExpressionExpr(receiver, callable, id, 0, enclosingStmt)
}
if(c.valueArgumentsCount > 0) {
logger.errorElement("Extra arguments found", c)
}
}
/**
* Populate the lhs of a binary op from this call's dispatch receiver, and the rhs from its sole argument.
*/
@@ -1894,6 +1910,10 @@ open class KotlinFileExtractor(
binopReceiver(id, c.dispatchReceiver, "Dispatch receiver")
}
fun unaryopDisp(id: Label<out DbExpr>) {
unaryopReceiver(id, c.dispatchReceiver, "Dispatch receiver")
}
/**
* Populate the lhs of a binary op from this call's extension receiver, and the rhs from its sole argument.
*/
@@ -2003,6 +2023,13 @@ open class KotlinFileExtractor(
tw.writeExprsKotlinType(id, type.kotlinResult.id)
binOp(id, dr, callable, enclosingStmt)
}
isFunction(target, "kotlin", "Boolean", "not") -> {
val id = tw.getFreshIdLabel<DbLognotexpr>()
val type = useType(c.type)
tw.writeExprs_lognotexpr(id, type.javaResult.id, parent, idx)
tw.writeExprsKotlinType(id, type.kotlinResult.id)
unaryopDisp(id)
}
// We need to handle all the builtin operators defines in BuiltInOperatorNames in
// compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/IrBuiltIns.kt
// as they can't be extracted as external dependencies.