Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KE2: Extract some expr/stmt kinds #17664

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading