[FIR] Create additional nodes to replace operator call in some places

1. FirAssignmentOperatorStatement - represent assignment operations
such as =, +=, -=, /=, %=
2. FirEqualityOperatorCall - represent boolean operations such as ==,
!=, ===, !==

#KT-38333 In Progress
This commit is contained in:
Ivan Kylchik
2020-07-14 23:52:48 +03:00
parent 8c4930da2e
commit 708c8b8ef3
14 changed files with 343 additions and 16 deletions
@@ -86,6 +86,8 @@ object FirTreeBuilder : AbstractFirTreeBuilder() {
val operatorCall = element("OperatorCall", Expression, expression, call)
val comparisonExpression = element("ComparisonExpression", Expression, expression)
val typeOperatorCall = element("TypeOperatorCall", Expression, expression, call)
val assignmentOperatorStatement = element("AssignmentOperatorStatement", Expression, statement)
val equalityOperatorCall = element("EqualityOperatorCall", Expression, expression, call)
val whenExpression = element("WhenExpression", Expression, expression, resolvable)
val whenBranch = element("WhenBranch", Expression)
val qualifiedAccessWithoutCallee = element("QualifiedAccessWithoutCallee", Expression, statement)
@@ -226,15 +226,8 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
}
impl(operatorCall) {
default("typeRef", """
|if (operation in FirOperation.BOOLEANS) {
| FirImplicitBooleanTypeRef(null)
| } else {
| FirImplicitTypeRefImpl(null)
| }
""".trimMargin())
useTypes(implicitTypeRefType, implicitBooleanTypeRefType)
default("typeRef", "FirImplicitTypeRefImpl(null)")
useTypes(implicitTypeRefType)
}
impl(comparisonExpression) {
@@ -244,6 +237,13 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
impl(typeOperatorCall)
impl(assignmentOperatorStatement)
impl(equalityOperatorCall) {
default("typeRef", "FirImplicitBooleanTypeRef(null)")
useTypes(implicitBooleanTypeRefType)
}
impl(resolvedQualifier) {
isMutable("packageFqName", "relativeClassFqName", "isNullableLHSForCallableReference")
default("classId") {
@@ -222,6 +222,16 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
needTransformOtherChildren()
}
assignmentOperatorStatement.configure {
+field("operation", operationType)
+field("leftArgument", expression).withTransform()
+field("rightArgument", expression).withTransform()
}
equalityOperatorCall.configure {
+field("operation", operationType)
}
whenBranch.configure {
+field("condition", expression).withTransform()
+field("result", block).withTransform()