Skip to content

Commit

Permalink
Enable source information for getters and other special-named functions
Browse files Browse the repository at this point in the history
Excludes anonymous/lambda functions to prevent noise and significant binary increase.
  • Loading branch information
ShikaSD authored and Space Cloud committed Sep 25, 2024
1 parent 9fcd247 commit 38084f0
Show file tree
Hide file tree
Showing 19 changed files with 34 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ val bar: Int @Composable get() { return 123 }
val bar: Int
@Composable @JvmName(name = "getBar")
get() {
sourceInformationMarkerStart(%composer, <>, "C:Test.kt#2487m")
sourceInformationMarkerStart(%composer, <>, "C(<get-bar>):Test.kt#2487m")
if (isTraceInProgress()) {
traceEventStart(<>, %changed, -1, <>)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ val bar: Int @Composable get() { return 123 }
val bar: Int
@Composable @JvmName(name = "getBar")
get() {
sourceInformationMarkerStart(%composer, <>, "C:Test.kt#2487m")
sourceInformationMarkerStart(%composer, <>, "C(<get-bar>):Test.kt#2487m")
if (isTraceInProgress()) {
traceEventStart(<>, %changed, -1, <>)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Bar {
val foo: Foo = Foo()
@Composable @JvmName(name = "getFoo")
get() {
sourceInformationMarkerStart(%composer, <>, "C<Foo()>:Test.kt#2487m")
sourceInformationMarkerStart(%composer, <>, "C(<get-foo>)<Foo()>:Test.kt#2487m")
if (isTraceInProgress()) {
traceEventStart(<>, %changed, -1, <>)
}
Expand All @@ -107,7 +107,7 @@ fun test(%composer: Composer?, %changed: Int) {
val foo%delegate = Foo()
@Composable
get(%composer: Composer?, %changed: Int) {
sourceInformationMarkerStart(%composer, <>, "C<Foo()>:Test.kt#2487m")
sourceInformationMarkerStart(%composer, <>, "C(<get-foo>)<Foo()>:Test.kt#2487m")
if (isTraceInProgress()) {
traceEventStart(<>, %changed, -1, <>)
}
Expand All @@ -123,7 +123,7 @@ fun test(%composer: Composer?, %changed: Int) {
val fooDelegate%delegate = FooDelegate()
@Composable
get(%composer: Composer?, %changed: Int) {
sourceInformationMarkerStart(%composer, <>, "C<FooDel...>:Test.kt#2487m")
sourceInformationMarkerStart(%composer, <>, "C(<get-fooDelegate>)<FooDel...>:Test.kt#2487m")
if (isTraceInProgress()) {
traceEventStart(<>, %changed, -1, <>)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Bar {
val foo: Foo = Foo()
@Composable @JvmName(name = "getFoo")
get() {
sourceInformationMarkerStart(%composer, <>, "C<Foo()>:Test.kt#2487m")
sourceInformationMarkerStart(%composer, <>, "C(<get-foo>)<Foo()>:Test.kt#2487m")
if (isTraceInProgress()) {
traceEventStart(<>, %changed, -1, <>)
}
Expand All @@ -107,7 +107,7 @@ fun test(%composer: Composer?, %changed: Int) {
val foo%delegate = Foo()
@Composable
get(%composer: Composer?, %changed: Int) {
sourceInformationMarkerStart(%composer, <>, "C<Foo()>:Test.kt#2487m")
sourceInformationMarkerStart(%composer, <>, "C(<get-foo>)<Foo()>:Test.kt#2487m")
if (isTraceInProgress()) {
traceEventStart(<>, %changed, -1, <>)
}
Expand All @@ -123,7 +123,7 @@ fun test(%composer: Composer?, %changed: Int) {
val fooDelegate%delegate = FooDelegate()
@Composable
get(%composer: Composer?, %changed: Int) {
sourceInformationMarkerStart(%composer, <>, "C<FooDel...>:Test.kt#2487m")
sourceInformationMarkerStart(%composer, <>, "C(<get-fooDelegate>)<FooDel...>:Test.kt#2487m")
if (isTraceInProgress()) {
traceEventStart(<>, %changed, -1, <>)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ val myProperty: () -> Unit @Composable get() {
val myProperty: Function0<Unit>
@Composable @JvmName(name = "getMyProperty")
get() {
sourceInformationMarkerStart(%composer, <>, "C:Test.kt#2487m")
sourceInformationMarkerStart(%composer, <>, "C(<get-myProperty>):Test.kt#2487m")
if (isTraceInProgress()) {
traceEventStart(<>, %changed, -1, <>)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ val myProperty: () -> Unit @Composable get() {
val myProperty: Function0<Unit>
@Composable @JvmName(name = "getMyProperty")
get() {
sourceInformationMarkerStart(%composer, <>, "C<{>:Test.kt#2487m")
sourceInformationMarkerStart(%composer, <>, "C(<get-myProperty>)<{>:Test.kt#2487m")
if (isTraceInProgress()) {
traceEventStart(<>, %changed, -1, <>)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fun test(foo: Foo, %composer: Composer?, %changed: Int) {
val delegated%delegate = foo
@Composable
get(%composer: Composer?, %changed: Int) {
sourceInformationMarkerStart(%composer, <>, "C<foo>:Test.kt#2487m")
sourceInformationMarkerStart(%composer, <>, "C(<get-delegated>)<foo>:Test.kt#2487m")
if (isTraceInProgress()) {
traceEventStart(<>, %changed, -1, <>)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fun test(foo: Foo, %composer: Composer?, %changed: Int) {
val delegated%delegate = foo
@Composable
get(%composer: Composer?, %changed: Int) {
sourceInformationMarkerStart(%composer, <>, "C<foo>:Test.kt#2487m")
sourceInformationMarkerStart(%composer, <>, "C(<get-delegated>)<foo>:Test.kt#2487m")
if (isTraceInProgress()) {
traceEventStart(<>, %changed, -1, <>)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fun test(%composer: Composer?, %changed: Int) {
val foo%delegate = Foo()
@Composable
get(%composer: Composer?, %changed: Int) {
sourceInformationMarkerStart(%composer, <>, "C<Foo()>:Test.kt#2487m")
sourceInformationMarkerStart(%composer, <>, "C(<get-foo>)<Foo()>:Test.kt#2487m")
if (isTraceInProgress()) {
traceEventStart(<>, %changed, -1, <>)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fun test(%composer: Composer?, %changed: Int) {
val foo%delegate = Foo()
@Composable
get(%composer: Composer?, %changed: Int) {
sourceInformationMarkerStart(%composer, <>, "C<Foo()>:Test.kt#2487m")
sourceInformationMarkerStart(%composer, <>, "C(<get-foo>)<Foo()>:Test.kt#2487m")
if (isTraceInProgress()) {
traceEventStart(<>, %changed, -1, <>)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface B {
@Composable @JvmName(name = "getProperty")
get() {
%composer.startReplaceGroup(<>)
sourceInformation(%composer, "C:Test.kt")
sourceInformation(%composer, "C(<get-property>):Test.kt")
if (isTraceInProgress()) {
traceEventStart(<>, %changed, -1, <>)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface B {
@Composable @JvmName(name = "getProperty")
get() {
%composer.startReplaceGroup(<>)
sourceInformation(%composer, "C:Test.kt")
sourceInformation(%composer, "C(<get-property>):Test.kt")
if (isTraceInProgress()) {
traceEventStart(<>, %changed, -1, <>)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fun Test() {
val current: Int
@Composable @ReadOnlyComposable @JvmName(name = "getCurrent")
get() {
sourceInformationMarkerStart(%composer, <>, "C:Test.kt")
sourceInformationMarkerStart(%composer, <>, "C(<get-current>):Test.kt")
if (isTraceInProgress()) {
traceEventStart(<>, %changed, -1, "<get-current> (Test.kt:7)")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fun Test() {
val current: Int
@Composable @ReadOnlyComposable @JvmName(name = "getCurrent")
get() {
sourceInformationMarkerStart(%composer, <>, "C:Test.kt")
sourceInformationMarkerStart(%composer, <>, "C(<get-current>):Test.kt")
if (isTraceInProgress()) {
traceEventStart(<>, %changed, -1, "<get-current> (Test.kt:7)")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CurrentHolder {
val current: Int
@ReadOnlyComposable @Composable @JvmName(name = "getCurrent")
get() {
sourceInformationMarkerStart(%composer, <>, "CC:Test.kt")
sourceInformationMarkerStart(%composer, <>, "CC(<get-current>):Test.kt")
val tmp0 = 0
sourceInformationMarkerEnd(%composer)
return tmp0
Expand All @@ -59,7 +59,7 @@ class HolderHolder {
val current: Int
@ReadOnlyComposable @Composable @JvmName(name = "getCurrent")
get() {
sourceInformationMarkerStart(%composer, <>, "C<curren...>:Test.kt")
sourceInformationMarkerStart(%composer, <>, "C(<get-current>)<curren...>:Test.kt")
if (isTraceInProgress()) {
traceEventStart(<>, %changed, -1, "HolderHolder.<get-current> (Test.kt:16)")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CurrentHolder {
val current: Int
@ReadOnlyComposable @Composable @JvmName(name = "getCurrent")
get() {
sourceInformationMarkerStart(%composer, <>, "CC:Test.kt")
sourceInformationMarkerStart(%composer, <>, "CC(<get-current>):Test.kt")
val tmp0 = 0
sourceInformationMarkerEnd(%composer)
return tmp0
Expand All @@ -59,7 +59,7 @@ class HolderHolder {
val current: Int
@ReadOnlyComposable @Composable @JvmName(name = "getCurrent")
get() {
sourceInformationMarkerStart(%composer, <>, "C<curren...>:Test.kt")
sourceInformationMarkerStart(%composer, <>, "C(<get-current>)<curren...>:Test.kt")
if (isTraceInProgress()) {
traceEventStart(<>, %changed, -1, "HolderHolder.<get-current> (Test.kt:16)")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ open class Foo {
val current: Int
@Composable @ReadOnlyComposable @JvmName(name = "getCurrent")
get() {
sourceInformationMarkerStart(%composer, <>, "CC:Test.kt")
sourceInformationMarkerStart(%composer, <>, "CC(<get-current>):Test.kt")
val tmp0 = %composer.hashCode()
sourceInformationMarkerEnd(%composer)
return tmp0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ open class Foo {
val current: Int
@Composable @ReadOnlyComposable @JvmName(name = "getCurrent")
get() {
sourceInformationMarkerStart(%composer, <>, "CC:Test.kt")
sourceInformationMarkerStart(%composer, <>, "CC(<get-current>):Test.kt")
val tmp0 = %composer.hashCode()
sourceInformationMarkerEnd(%composer)
return tmp0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4761,12 +4761,16 @@ private fun mutableStatementContainer(context: IrPluginContext): IrContainerExpr
)
}

private fun IrFunction.callInformation(): String {
val inlineMarker = if (isInline) "C" else ""
return if (!name.isSpecial)
"${inlineMarker}C(${name.asString()})"
else "${inlineMarker}C"
}
private fun IrFunction.callInformation(): String =
buildString {
append('C')
if (isInline) append('C')
if (!isLambda()) {
append('(')
append(name.asString())
append(')')
}
}

// Parameter information is an index from the sorted order of the parameters to the
// actual order. This is used to reorder the fields of the lambda class generated for
Expand Down

0 comments on commit 38084f0

Please sign in to comment.