Skip to content

Commit

Permalink
s/BodyStatementsInfo/BodyControlInfo/
Browse files Browse the repository at this point in the history
  • Loading branch information
badly-drawn-wizards committed Nov 10, 2023
1 parent e56ced4 commit 9a04917
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import scala.util.{Failure, Success, Try}

import cats.syntax.all.*;
import scala.collection.mutable.ArrayBuffer
import io.joern.jimple2cpg.astcreation.statements.BodyStatementsInfo
import io.joern.jimple2cpg.astcreation.statements.BodyControlInfo

trait AstForMethodsCreator(implicit withSchemaValidation: ValidationMode) { this: AstCreator =>

Expand All @@ -29,7 +29,7 @@ trait AstForMethodsCreator(implicit withSchemaValidation: ValidationMode) { this
private val JVM_LANGS = HashSet("scala", "clojure", "groovy", "kotlin", "jython", "jruby")

protected def astForMethod(methodDeclaration: SootMethod, typeDecl: RefType): Ast = {
val bodyStatementsInfo = BodyStatementsInfo()
val bodyStatementsInfo = BodyControlInfo()
val methodNode = createMethodNode(methodDeclaration, typeDecl)
try {
if (!methodDeclaration.isConcrete) {
Expand Down Expand Up @@ -207,7 +207,7 @@ trait AstForMethodsCreator(implicit withSchemaValidation: ValidationMode) { this
}
}

private def astForMethodBody(body: Body, info: BodyStatementsInfo): Ast = {
private def astForMethodBody(body: Body, info: BodyControlInfo): Ast = {
val jimpleParams = body.getParameterLocals.asScala.toList
// Don't let parameters also become locals (avoiding duplication)
val jimpleLocals = body.getLocals.asScala.filterNot(l => jimpleParams.contains(l) || l.getName == "this").toList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ trait AstForStatementsCreator(implicit withSchemaValidation: ValidationMode) { t

private val logger = LoggerFactory.getLogger(getClass)

protected def astsForStatement(statement: soot.Unit, info: BodyStatementsInfo): Seq[Ast] = {
protected def astsForStatement(statement: soot.Unit, info: BodyControlInfo): Seq[Ast] = {
val stmt = statement match {
case x: AssignStmt => astsForDefinition(x)
case x: InvokeStmt => astsForExpression(x.getInvokeExpr, statement)
Expand Down Expand Up @@ -203,14 +203,14 @@ trait AstForStatementsCreator(implicit withSchemaValidation: ValidationMode) { t
)
}

private def astsForIfStmt(ifStmt: IfStmt, info: BodyStatementsInfo): Seq[Ast] = {
private def astsForIfStmt(ifStmt: IfStmt, info: BodyControlInfo): Seq[Ast] = {
// bytecode/jimple ASTs are flat so there will not be nested bodies
val condition = astsForValue(ifStmt.getCondition, ifStmt)
info.targets.put(condition, ifStmt.getTarget)
condition
}

private def astsForGotoStmt(gotoStmt: GotoStmt, info: BodyStatementsInfo): Seq[Ast] = {
private def astsForGotoStmt(gotoStmt: GotoStmt, info: BodyControlInfo): Seq[Ast] = {
// bytecode/jimple ASTs are flat so there will not be nested bodies
val gotoAst = Seq(
Ast(
Expand Down Expand Up @@ -249,7 +249,7 @@ trait AstForStatementsCreator(implicit withSchemaValidation: ValidationMode) { t

}

class BodyStatementsInfo(
class BodyControlInfo(
val unitToAsts: mutable.HashMap[soot.Unit, Seq[Ast]] = mutable.HashMap.empty,
val targets: mutable.HashMap[Seq[Ast], soot.Unit] = mutable.HashMap.empty,
val edges: ArrayBuffer[(soot.Unit, soot.Unit)] = mutable.ArrayBuffer.empty
Expand Down

0 comments on commit 9a04917

Please sign in to comment.