Skip to content

Commit

Permalink
Rename methods in passes
Browse files Browse the repository at this point in the history
  • Loading branch information
KuechA committed Nov 6, 2024
1 parent 58a150d commit f429e0e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class DFGPass(ctx: TranslationContext) : ComponentPass(ctx) {
is ForStatement -> handleForStatement(node)
is SwitchStatement -> handleSwitchStatement(node)
is IfStatement -> handleIfStatement(node)
is ThrowExpression -> handleThrowStatement(node)
is ThrowExpression -> handleThrowExpression(node)
// Declarations
is FieldDeclaration -> handleFieldDeclaration(node)
is FunctionDeclaration -> handleFunctionDeclaration(node, functionSummaries)
Expand Down Expand Up @@ -170,7 +170,7 @@ class DFGPass(ctx: TranslationContext) : ComponentPass(ctx) {
}

/** Handle a [ThrowExpression]. The exception and parent exception flow into the node. */
protected fun handleThrowStatement(node: ThrowExpression) {
protected fun handleThrowExpression(node: ThrowExpression) {
node.exception?.let { node.prevDFGEdges += it }
node.parentException?.let { node.prevDFGEdges += it }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ open class EvaluationOrderGraphPass(ctx: TranslationContext) : TranslationUnitPa
map[LookupScopeStatement::class.java] = {
handleLookupScopeStatement(it as LookupScopeStatement)
}
map[ThrowExpression::class.java] = { handleThrowStatement(it as ThrowExpression) }
map[ThrowExpression::class.java] = { handleThrowExpression(it as ThrowExpression) }
}

protected fun doNothing() {
Expand Down Expand Up @@ -1124,7 +1124,7 @@ open class EvaluationOrderGraphPass(ctx: TranslationContext) : TranslationUnitPa
}

/** Calls [handleThrowOperator]. */
protected fun handleThrowStatement(statement: ThrowExpression) {
protected fun handleThrowExpression(statement: ThrowExpression) {
handleThrowOperator(
statement,
statement.exception?.type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class CompressLLVMPass(ctx: TranslationContext) : ComponentPass(ctx) {
}
node.catchClauses = catchClauses

fixThrowStatementsForCatch(node.catchClauses[0])
fixThrowExpressionsForCatch(node.catchClauses[0])
}
node.catchClauses.size == 1 &&
node.catchClauses[0].body?.statements?.get(0) is Block -> {
Expand All @@ -171,22 +171,22 @@ class CompressLLVMPass(ctx: TranslationContext) : ComponentPass(ctx) {
// the compound statement the body of the catch clause.
val innerCompound = node.catchClauses[0].body?.statements?.get(0) as? Block
innerCompound?.statements?.let { node.catchClauses[0].body?.statements = it }
fixThrowStatementsForCatch(node.catchClauses[0])
fixThrowExpressionsForCatch(node.catchClauses[0])
}
node.catchClauses.isNotEmpty() -> {
for (catch in node.catchClauses) {
fixThrowStatementsForCatch(catch)
fixThrowExpressionsForCatch(catch)
}
}
}
}

/**
* Checks if a throw statement which is included in this catch block does not have a parameter.
* Those statements have been artificially added e.g. by a catchswitch and need to be filled
* Checks if a throw expression which is included in this catch block does not have a parameter.
* Those expressions have been artificially added e.g. by a catchswitch and need to be filled
* now.
*/
private fun fixThrowStatementsForCatch(catch: CatchClause) {
private fun fixThrowExpressionsForCatch(catch: CatchClause) {
val reachableThrowNodes =
getAllChildrenRecursively(catch).filterIsInstance<ThrowExpression>().filter { n ->
n.exception is ProblemExpression
Expand Down

0 comments on commit f429e0e

Please sign in to comment.