Skip to content

Commit

Permalink
Merge pull request #17664 from tamasvajk/ke2-extract-some-expr
Browse files Browse the repository at this point in the history
KE2: Extract some expr/stmt kinds
  • Loading branch information
tamasvajk authored Oct 8, 2024
2 parents b46be1b + aa5fa12 commit 7c3fb32
Show file tree
Hide file tree
Showing 2 changed files with 274 additions and 244 deletions.
69 changes: 0 additions & 69 deletions java/kotlin-extractor2/src/main/kotlin/KotlinFileExtractor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2542,75 +2542,6 @@ OLD: KE1
tw.writeHasLocation(it, locId)
}
private fun extractStatement(
s: IrStatement,
callable: Label<out DbCallable>,
parent: Label<out DbStmtparent>,
idx: Int
) {
with("statement", s) {
when (s) {
is IrExpression -> {
extractExpressionStmt(s, callable, parent, idx)
}
is IrVariable -> {
extractVariable(s, callable, parent, idx)
}
is IrClass -> {
extractLocalTypeDeclStmt(s, callable, parent, idx)
}
is IrFunction -> {
if (s.isLocalFunction()) {
val compilerGeneratedKindOverride =
if (s.origin == IrDeclarationOrigin.ADAPTER_FOR_CALLABLE_REFERENCE) {
CompilerGeneratedKinds.DECLARING_CLASSES_OF_ADAPTER_FUNCTIONS
} else {
null
}
val classId =
extractGeneratedClass(
s,
listOf(pluginContext.irBuiltIns.anyType),
compilerGeneratedKindOverride = compilerGeneratedKindOverride
)
extractLocalTypeDeclStmt(classId, s, callable, parent, idx)
val ids = getLocallyVisibleFunctionLabels(s)
tw.writeKtLocalFunction(ids.function)
} else {
logger.errorElement("Expected to find local function", s)
}
}
is IrLocalDelegatedProperty -> {
val blockId = tw.getFreshIdLabel<DbBlock>()
val locId = tw.getLocation(s)
tw.writeStmts_block(blockId, parent, idx, callable)
tw.writeHasLocation(blockId, locId)
extractVariable(s.delegate, callable, blockId, 0)
val propId = tw.getFreshIdLabel<DbKt_property>()
tw.writeKtProperties(propId, s.name.asString())
tw.writeHasLocation(propId, locId)
tw.writeKtPropertyDelegates(propId, useVariable(s.delegate))
// Getter:
extractStatement(s.getter, callable, blockId, 1)
val getterLabel = getLocallyVisibleFunctionLabels(s.getter).function
tw.writeKtPropertyGetters(propId, getterLabel)
val setter = s.setter
if (setter != null) {
extractStatement(setter, callable, blockId, 2)
val setterLabel = getLocallyVisibleFunctionLabels(setter).function
tw.writeKtPropertySetters(propId, setterLabel)
}
}
else -> {
logger.errorElement("Unrecognised IrStatement: " + s.javaClass, s)
}
}
}
}
/**
* Returns true iff `c` is a call to the function `fName` in the `kotlin.internal.ir` package.
* This is used to find calls to builtin functions, which need to be handled specially as they
Expand Down
Loading

0 comments on commit 7c3fb32

Please sign in to comment.