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.

View File

@@ -1,5 +1,3 @@
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Boolean.not in java.lang.Boolean |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Boolean.not in java.lang.Boolean |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Byte.toInt in java.lang.Byte |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Byte.toInt in java.lang.Byte |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Byte.toInt in java.lang.Byte |

View File

@@ -2025,8 +2025,8 @@ exprs.kt:
# 31| 0: [VarAccess] x
# 32| 21: [LocalVariableDeclStmt] var ...;
# 32| 1: [LocalVariableDeclExpr] i22
# 32| 0: [MethodAccess] not(...)
# 32| -1: [MethodAccess] contains(...)
# 32| 0: [LogNotExpr] !...
# 32| 0: [MethodAccess] contains(...)
# 32| -1: [MethodAccess] rangeTo(...)
# 32| -1: [VarAccess] x
# 32| 0: [VarAccess] y
@@ -2422,8 +2422,8 @@ exprs.kt:
# 114| 1: [VarAccess] b2
# 115| 98: [LocalVariableDeclStmt] var ...;
# 115| 1: [LocalVariableDeclExpr] b5
# 115| 0: [MethodAccess] not(...)
# 115| -1: [VarAccess] b1
# 115| 0: [LogNotExpr] !...
# 115| 0: [VarAccess] b1
# 117| 99: [LocalVariableDeclStmt] var ...;
# 117| 1: [LocalVariableDeclExpr] c
# 117| 0: [CharacterLiteral] x

View File

@@ -989,8 +989,8 @@
| exprs.kt:31:25:31:25 | y | exprs.kt:4:1:136:1 | topLevelMethod | VarAccess |
| exprs.kt:32:5:32:26 | i22 | exprs.kt:4:1:136:1 | topLevelMethod | LocalVariableDeclExpr |
| exprs.kt:32:15:32:15 | x | exprs.kt:4:1:136:1 | topLevelMethod | VarAccess |
| exprs.kt:32:15:32:26 | !... | exprs.kt:4:1:136:1 | topLevelMethod | LogNotExpr |
| exprs.kt:32:15:32:26 | contains(...) | exprs.kt:4:1:136:1 | topLevelMethod | MethodAccess |
| exprs.kt:32:15:32:26 | not(...) | exprs.kt:4:1:136:1 | topLevelMethod | MethodAccess |
| exprs.kt:32:21:32:21 | x | exprs.kt:4:1:136:1 | topLevelMethod | VarAccess |
| exprs.kt:32:21:32:26 | rangeTo(...) | exprs.kt:4:1:136:1 | topLevelMethod | MethodAccess |
| exprs.kt:32:26:32:26 | y | exprs.kt:4:1:136:1 | topLevelMethod | VarAccess |
@@ -1308,7 +1308,7 @@
| exprs.kt:114:14:114:21 | ... \|\| ... | exprs.kt:4:1:136:1 | topLevelMethod | OrLogicalExpr |
| exprs.kt:114:20:114:21 | b2 | exprs.kt:4:1:136:1 | topLevelMethod | VarAccess |
| exprs.kt:115:5:115:16 | b5 | exprs.kt:4:1:136:1 | topLevelMethod | LocalVariableDeclExpr |
| exprs.kt:115:14:115:16 | not(...) | exprs.kt:4:1:136:1 | topLevelMethod | MethodAccess |
| exprs.kt:115:14:115:16 | !... | exprs.kt:4:1:136:1 | topLevelMethod | LogNotExpr |
| exprs.kt:115:15:115:16 | b1 | exprs.kt:4:1:136:1 | topLevelMethod | VarAccess |
| exprs.kt:117:5:117:15 | c | exprs.kt:4:1:136:1 | topLevelMethod | LocalVariableDeclExpr |
| exprs.kt:117:13:117:15 | x | exprs.kt:4:1:136:1 | topLevelMethod | CharacterLiteral |

View File

@@ -1,3 +1,5 @@
| exprs.kt:32:15:32:26 | !... | exprs.kt:32:15:32:26 | contains(...) |
| exprs.kt:115:14:115:16 | !... | exprs.kt:115:15:115:16 | b1 |
| exprs.kt:196:19:196:20 | ...!! | exprs.kt:196:18:196:18 | x |
| exprs.kt:205:20:205:21 | ...!! | exprs.kt:205:19:205:19 | s |
| exprs.kt:206:20:206:21 | ...!! | exprs.kt:206:19:206:19 | s |