[FIR] Desugar increment/decrement in body resolve phase
The expression needs to be resolved first to determine if there is a receiver that needs to be extracted to a temporary variable. Also, the special case for prefix increment/decrement on local variable without delegates requires resolution to check if the variable is local. ^KT-56771 Fixed ^KT-56659 Fixed
This commit is contained in:
committed by
Space Team
parent
5ecf9cce25
commit
3b9724d20e
+1
-3
@@ -27,9 +27,7 @@ FILE: destructuring.kt
|
||||
lvar x: <implicit> = R|<local>/<destruct>|.component1#()
|
||||
lvar y: <implicit> = R|<local>/<destruct>|.component2#()
|
||||
lvar z: String = R|<local>/<destruct>|.component3#()
|
||||
lval <unary>: <implicit> = x#
|
||||
x# = R|<local>/<unary>|.inc#()
|
||||
R|<local>/<unary>|
|
||||
x#++
|
||||
*=(y#, Double(2.0))
|
||||
z# = String()
|
||||
}
|
||||
|
||||
Vendored
+8
-44
@@ -1,23 +1,8 @@
|
||||
FILE: safeCallsWithUnaryOperators.kt
|
||||
public? final? fun foo(): R|kotlin/Unit| {
|
||||
a#?.{ {
|
||||
lval <receiver>: <implicit> = $subj$
|
||||
lval <unary>: <implicit> = R|<local>/<receiver>|.b#
|
||||
R|<local>/<receiver>|.b# = R|<local>/<unary>|.inc#()
|
||||
R|<local>/<unary>|
|
||||
}
|
||||
}
|
||||
a#?.{ $subj$.b# }?.{ {
|
||||
lval <receiver>: <implicit> = $subj$
|
||||
lval <unary>: <implicit> = R|<local>/<receiver>|.c#
|
||||
R|<local>/<receiver>|.c# = R|<local>/<unary>|.inc#()
|
||||
R|<local>/<unary>|
|
||||
}
|
||||
}
|
||||
lval <receiver>: <implicit> = a#?.{ $subj$.b# }
|
||||
lval <unary>: <implicit> = R|<local>/<receiver>|.c#
|
||||
R|<local>/<receiver>|.c# = R|<local>/<unary>|.inc#()
|
||||
R|<local>/<unary>|
|
||||
a#?.{ $subj$.b# }++
|
||||
a#?.{ $subj$.b# }?.{ $subj$.c# }++
|
||||
a#?.{ $subj$.b# }.c#++
|
||||
a#?.{ {
|
||||
lval <array>: <implicit> = $subj$.b#
|
||||
lval <index_0>: <implicit> = IntegerLiteral(0)
|
||||
@@ -60,30 +45,12 @@ FILE: safeCallsWithUnaryOperators.kt
|
||||
lval <unary>: <implicit> = R|<local>/<array>|.get#(R|<local>/<index_0>|)
|
||||
R|<local>/<array>|.set#(R|<local>/<index_0>|, R|<local>/<unary>|.inc#())
|
||||
R|<local>/<unary>|
|
||||
lval <receiver>: <implicit> = a#?.{ $subj$.b# }
|
||||
lval <unary>: <implicit> = R|<local>/<receiver>|.d#()
|
||||
R|<local>/<receiver>|.d#() = R|<local>/<unary>|.inc#()
|
||||
R|<local>/<unary>|
|
||||
a#?.{ $subj$.b# }.d#()++
|
||||
}
|
||||
public? final? fun foo2(): R|kotlin/Unit| {
|
||||
a#?.{ {
|
||||
lval <receiver>: <implicit> = $subj$
|
||||
lval <unary-result>: <implicit> = R|<local>/<receiver>|.b#.inc#()
|
||||
R|<local>/<receiver>|.b# = R|<local>/<unary-result>|
|
||||
R|<local>/<unary-result>|
|
||||
}
|
||||
}
|
||||
a#?.{ $subj$.b# }?.{ {
|
||||
lval <receiver>: <implicit> = $subj$
|
||||
lval <unary-result>: <implicit> = R|<local>/<receiver>|.c#.inc#()
|
||||
R|<local>/<receiver>|.c# = R|<local>/<unary-result>|
|
||||
R|<local>/<unary-result>|
|
||||
}
|
||||
}
|
||||
lval <receiver>: <implicit> = a#?.{ $subj$.b# }
|
||||
lval <unary-result>: <implicit> = R|<local>/<receiver>|.c#.inc#()
|
||||
R|<local>/<receiver>|.c# = R|<local>/<unary-result>|
|
||||
R|<local>/<unary-result>|
|
||||
++a#?.{ $subj$.b# }
|
||||
++a#?.{ $subj$.b# }?.{ $subj$.c# }
|
||||
++a#?.{ $subj$.b# }.c#
|
||||
a#?.{ {
|
||||
lval <array>: <implicit> = $subj$.b#
|
||||
lval <index_0>: <implicit> = IntegerLiteral(0)
|
||||
@@ -126,8 +93,5 @@ FILE: safeCallsWithUnaryOperators.kt
|
||||
lval <unary-result>: <implicit> = R|<local>/<array>|.get#(R|<local>/<index_0>|).inc#()
|
||||
R|<local>/<array>|.set#(R|<local>/<index_0>|, R|<local>/<unary-result>|)
|
||||
R|<local>/<unary-result>|
|
||||
lval <receiver>: <implicit> = a#?.{ $subj$.b# }
|
||||
lval <unary-result>: <implicit> = R|<local>/<receiver>|.d#().inc#()
|
||||
R|<local>/<receiver>|.d#() = R|<local>/<unary-result>|
|
||||
R|<local>/<unary-result>|
|
||||
++a#?.{ $subj$.b# }.d#()
|
||||
}
|
||||
|
||||
@@ -1,28 +1,10 @@
|
||||
FILE: unary.kt
|
||||
public? final? fun test(): R|kotlin/Unit| {
|
||||
lvar x: <implicit> = IntegerLiteral(0)
|
||||
lval x1: <implicit> = {
|
||||
lval <unary>: <implicit> = x#
|
||||
x# = R|<local>/<unary>|.inc#()
|
||||
R|<local>/<unary>|
|
||||
}
|
||||
|
||||
lval x2: <implicit> = {
|
||||
x# = x#.inc#()
|
||||
x#
|
||||
}
|
||||
|
||||
lval x3: <implicit> = {
|
||||
x# = x#.dec#()
|
||||
x#
|
||||
}
|
||||
|
||||
lval x4: <implicit> = {
|
||||
lval <unary>: <implicit> = x#
|
||||
x# = R|<local>/<unary>|.dec#()
|
||||
R|<local>/<unary>|
|
||||
}
|
||||
|
||||
lval x1: <implicit> = x#++
|
||||
lval x2: <implicit> = ++x#
|
||||
lval x3: <implicit> = --x#
|
||||
lval x4: <implicit> = x#--
|
||||
when () {
|
||||
==(x#, IntegerLiteral(0)).not#() -> {
|
||||
println#(String(000))
|
||||
@@ -40,20 +22,8 @@ FILE: unary.kt
|
||||
|
||||
}
|
||||
public? final? fun test2(x: X): R|kotlin/Unit| {
|
||||
lval x1: <implicit> = {
|
||||
lval <receiver>: <implicit> = x#
|
||||
lval <unary>: <implicit> = R|<local>/<receiver>|.i#
|
||||
R|<local>/<receiver>|.i# = R|<local>/<unary>|.inc#()
|
||||
R|<local>/<unary>|
|
||||
}
|
||||
|
||||
lval x2: <implicit> = {
|
||||
lval <receiver>: <implicit> = x#
|
||||
lval <unary-result>: <implicit> = R|<local>/<receiver>|.i#.inc#()
|
||||
R|<local>/<receiver>|.i# = R|<local>/<unary-result>|
|
||||
R|<local>/<unary-result>|
|
||||
}
|
||||
|
||||
lval x1: <implicit> = x#.i#++
|
||||
lval x2: <implicit> = ++x#.i#
|
||||
}
|
||||
public? final? fun test3(arr: Array<Int>): R|kotlin/Unit| {
|
||||
lval x1: <implicit> = {
|
||||
|
||||
@@ -2,14 +2,10 @@ FILE: while.kt
|
||||
public? final? fun foo(limit: Int): R|kotlin/Unit| {
|
||||
lvar k: <implicit> = IntegerLiteral(0)
|
||||
some@while(CMP(<, k#.compareTo#(limit#))) {
|
||||
lval <unary>: <implicit> = k#
|
||||
k# = R|<local>/<unary>|.inc#()
|
||||
R|<local>/<unary>|
|
||||
k#++
|
||||
println#(k#)
|
||||
while(==(k#, IntegerLiteral(13))) {
|
||||
lval <unary>: <implicit> = k#
|
||||
k# = R|<local>/<unary>|.inc#()
|
||||
R|<local>/<unary>|
|
||||
k#++
|
||||
when () {
|
||||
CMP(<, k#.compareTo#(limit#)) -> {
|
||||
break@@@[CMP(<, k#.compareTo#(limit#))]
|
||||
@@ -30,9 +26,7 @@ FILE: while.kt
|
||||
public? final? fun bar(limit: Int): R|kotlin/Unit| {
|
||||
lvar k: <implicit> = limit#
|
||||
do {
|
||||
lval <unary>: <implicit> = k#
|
||||
k# = R|<local>/<unary>|.dec#()
|
||||
R|<local>/<unary>|
|
||||
k#--
|
||||
println#(k#)
|
||||
}
|
||||
while(CMP(>=, k#.compareTo#(IntegerLiteral(0))))
|
||||
|
||||
Reference in New Issue
Block a user