mirror of
https://github.com/github/codeql.git
synced 2026-05-23 15:47:11 +02:00
KE2: Start extracting blocks
This commit is contained in:
@@ -2622,7 +2622,7 @@ OLD: KE1
|
||||
f
|
||||
)
|
||||
*/
|
||||
// extractBody(body, id)
|
||||
extractBody(body, id)
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2939,36 +2939,44 @@ OLD: KE1
|
||||
// TODO: extract annotations
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
private fun extractBody(b: IrBody, callable: Label<out DbCallable>) {
|
||||
private fun extractBody(b: KtExpression, callable: Label<out DbCallable>) {
|
||||
with("body", b) {
|
||||
when (b) {
|
||||
is IrBlockBody -> extractBlockBody(b, callable)
|
||||
is KtBlockExpression -> extractBlockBody(b, callable)
|
||||
/*
|
||||
OLD: KE1
|
||||
is IrSyntheticBody -> extractSyntheticBody(b, callable)
|
||||
is IrExpressionBody -> extractExpressionBody(b, callable)
|
||||
else -> {
|
||||
logger.errorElement("Unrecognised IrBody: " + b.javaClass, b)
|
||||
}
|
||||
else -> extractExpressionBody(b, callable)
|
||||
*/
|
||||
else -> TODO()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Can this be inlined?
|
||||
private fun extractBlockBody(callable: Label<out DbCallable>, locId: Label<DbLocation>) =
|
||||
tw.getFreshIdLabel<DbBlock>().also {
|
||||
tw.writeStmts_block(it, callable, 0, callable)
|
||||
tw.writeHasLocation(it, locId)
|
||||
}
|
||||
|
||||
private fun extractBlockBody(b: IrBlockBody, callable: Label<out DbCallable>) {
|
||||
private fun extractBlockBody(b: KtBlockExpression, callable: Label<out DbCallable>) {
|
||||
with("block body", b) {
|
||||
extractBlockBody(callable, tw.getLocation(b)).also {
|
||||
for ((sIdx, stmt) in b.statements.withIndex()) {
|
||||
extractStatement(stmt, callable, it, sIdx)
|
||||
/*
|
||||
OLD: KE1
|
||||
extractExpression(stmt, callable, it, sIdx)
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
OLD: KE1
|
||||
private fun extractSyntheticBody(b: IrSyntheticBody, callable: Label<out DbCallable>) {
|
||||
with("synthetic body", b) {
|
||||
val kind = b.kind
|
||||
|
||||
@@ -106,8 +106,6 @@ TODO: Inline this if it can remain private
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
OLD: KE1
|
||||
/** Returns a label for a fresh ID (i.e. a new label bound to `*`). */
|
||||
fun <T : AnyDbType> getFreshIdLabel(): Label<T> {
|
||||
val label: Label<T> = lm.getFreshLabel()
|
||||
@@ -115,6 +113,8 @@ OLD: KE1
|
||||
return label
|
||||
}
|
||||
|
||||
/*
|
||||
OLD: KE1
|
||||
/**
|
||||
* It is not easy to assign keys to local variables, so they get given `*` IDs. However, the
|
||||
* same variable may be referred to from distant places in the IR, so we need a way to find out
|
||||
|
||||
Reference in New Issue
Block a user