Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: kitakkun/back-in-time-plugin
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ded22b12c0231636d4e64a609c4e5afddbc26aa4
Choose a base ref
..
head repository: kitakkun/back-in-time-plugin
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: eee0c9fcd1a6fce1e1f765d97735478d03a1ce45
Choose a head ref
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.util.constructors
import org.jetbrains.kotlin.ir.util.isVararg
import org.jetbrains.kotlin.javac.resolve.classId
import org.jetbrains.kotlin.name.CallableId
@@ -38,11 +37,6 @@ class BackInTimePluginContext(
// capture utils
val captureThenReturnValueFunctionSymbol by lazy { backintimeNamedFunction(name = "captureThenReturnValue", subpackage = "core.runtime.internal") }

/**
* Used in [com.kitakkun.backintime.compiler.backend.transformer.BackInTimeDebuggableConstructorTransformer]
*/
val propertyInfoClass by lazy { backintimeIrClassSymbol(name = "PropertyInfo", subpackage = "tooling.model") }
val propertyInfoClassConstructor = propertyInfoClass.constructors.first { it.owner.isPrimary }
val listOfFunction by lazy { namedFunction("kotlin.collections", "listOf") { it.owner.valueParameters.size == 1 && it.owner.valueParameters.first().isVararg } }

// kotlinx-serialization
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.builders.IrBuilderWithScope
import org.jetbrains.kotlin.ir.builders.irBoolean
import org.jetbrains.kotlin.ir.builders.irCall
import org.jetbrains.kotlin.ir.builders.irCallConstructor
import org.jetbrains.kotlin.ir.builders.irConcat
import org.jetbrains.kotlin.ir.builders.irGet
import org.jetbrains.kotlin.ir.builders.irGetField
import org.jetbrains.kotlin.ir.builders.irString
@@ -20,9 +20,9 @@ import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrConstructor
import org.jetbrains.kotlin.ir.declarations.IrProperty
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
import org.jetbrains.kotlin.ir.expressions.addArgument
import org.jetbrains.kotlin.ir.types.IrSimpleType
import org.jetbrains.kotlin.ir.types.classOrNull
import org.jetbrains.kotlin.ir.types.defaultType
import org.jetbrains.kotlin.ir.util.hasAnnotation
import org.jetbrains.kotlin.ir.util.parentAsClass
import org.jetbrains.kotlin.ir.util.properties
@@ -76,7 +76,7 @@ class BackInTimeDebuggableConstructorTransformer : IrElementTransformerVoid() {
putValueArgument(
0,
irVararg(
propertyInfoClass.defaultType,
irBuiltIns.stringType,
properties
.filter { !it.isBackInTimeGenerated }
.map { irProperty ->
@@ -86,16 +86,20 @@ class BackInTimeDebuggableConstructorTransformer : IrElementTransformerVoid() {
// FIXME: 必ずしも正確な判定ではない
val isDebuggable = irProperty.isVar || propertyType?.classOrNull in valueContainerClassInfoList.map { it.classSymbol }
val isDebuggableStateHolder = propertyType?.classOrNull?.owner?.hasAnnotation(BackInTimeAnnotations.backInTimeAnnotationFqName) ?: false
irCallConstructor(propertyInfoClassConstructor, emptyList()).apply {
putValueArgument(0, irString(irProperty.signatureForBackInTimeDebugger()))
putValueArgument(1, irBoolean(isDebuggable || isDebuggableStateHolder))
putValueArgument(2, irBoolean(isDebuggableStateHolder))
putValueArgument(3, irString(propertyTypeName))
putValueArgument(4, irString(genericTypeCompletedName))
irConcat().apply {
addArgument(irString(irProperty.signatureForBackInTimeDebugger()))
addArgument(irString(","))
addArgument(irBoolean(isDebuggable || isDebuggableStateHolder))
addArgument(irString(","))
addArgument(irBoolean(isDebuggableStateHolder))
addArgument(irString(","))
addArgument(irString(propertyTypeName))
addArgument(irString(","))
addArgument(irString(genericTypeCompletedName))
}
}.toList(),
),
)
putTypeArgument(0, propertyInfoClass.defaultType)
putTypeArgument(0, irBuiltIns.stringType)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.kitakkun.backintime.core.runtime.event

import com.kitakkun.backintime.core.runtime.BackInTimeDebuggable
import com.kitakkun.backintime.tooling.model.PropertyInfo

/**
* events inside the BackInTimeDebuggable instance
@@ -18,7 +17,7 @@ sealed interface BackInTimeDebuggableInstanceEvent {
val instance: BackInTimeDebuggable,
val classSignature: String,
val superClassSignature: String,
val properties: List<PropertyInfo>,
val properties: List<String>,
) : BackInTimeDebuggableInstanceEvent

/**
Original file line number Diff line number Diff line change
@@ -6,15 +6,13 @@ import com.kitakkun.backintime.core.runtime.BackInTimeDebuggable
import com.kitakkun.backintime.core.runtime.backInTimeJson
import com.kitakkun.backintime.core.runtime.event.BackInTimeDebuggableInstanceEvent
import com.kitakkun.backintime.core.runtime.getBackInTimeDebugService
import com.kitakkun.backintime.tooling.model.PropertyInfo
import kotlinx.serialization.encodeToString

@BackInTimeCompilerInternalApi
internal fun reportInstanceRegistration(
instance: BackInTimeDebuggable,
classSignature: String,
superClassSignature: String,
properties: List<PropertyInfo>,
properties: List<String>,
) = getBackInTimeDebugService().processInstanceEvent(
BackInTimeDebuggableInstanceEvent.RegisterTarget(
instance = instance,
1 change: 0 additions & 1 deletion core/websocket/event/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -23,7 +23,6 @@ kotlin {

sourceSets {
commonMain.dependencies {
implementation(projects.tooling.model)
implementation(libs.kotlinx.serialization.json)
}
}
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@

package com.kitakkun.backintime.core.websocket.event

import com.kitakkun.backintime.tooling.model.PropertyInfo
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
import kotlin.js.ExperimentalJsExport
@@ -22,7 +21,7 @@ sealed class BackInTimeDebugServiceEvent : BackInTimeWebSocketEvent {
val instanceUUID: String,
val classSignature: String,
val superClassSignature: String,
val properties: List<PropertyInfo>,
val properties: List<String>,
val registeredAt: Int,
) : BackInTimeDebugServiceEvent()

Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ import com.kitakkun.backintime.tooling.model.ClassInfo
import com.kitakkun.backintime.tooling.model.DependencyInfo
import com.kitakkun.backintime.tooling.model.InstanceInfo
import com.kitakkun.backintime.tooling.model.MethodCallInfo
import com.kitakkun.backintime.tooling.model.PropertyInfo
import com.kitakkun.backintime.tooling.model.ValueChangeInfo
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
@@ -60,7 +61,23 @@ class FlipperAppStateOwnerImpl(
}

val newClassInfoList = if (appState.classInfoList.none { it.classSignature == event.classSignature }) {
appState.classInfoList + ClassInfo(classSignature = event.classSignature, superClassSignature = event.superClassSignature, properties = event.properties)
appState.classInfoList + ClassInfo(
classSignature = event.classSignature,
superClassSignature = event.superClassSignature,
properties = event.properties.map {
/**
* see [com.kitakkun.backintime.compiler.backend.transformer.capture.BackInTimeDebuggableConstructorTransformer] for details.
*/
val info = it.split(",")
PropertyInfo(
signature = info[0],
debuggable = info[1].toBoolean(),
isDebuggableStateHolder = info[2].toBoolean(),
propertyType = info[3],
valueType = info[4],
)
}
)
} else {
appState.classInfoList
}