All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.joern.x2cpg.layers.CallGraph.scala Maven / Gradle / Ivy

There is a newer version: 4.0.131
Show newest version
package io.joern.x2cpg.layers

import io.shiftleft.codepropertygraph.generated.Cpg
import io.shiftleft.passes.CpgPassBase
import io.shiftleft.semanticcpg.layers.{LayerCreator, LayerCreatorContext, LayerCreatorOptions}
import io.joern.x2cpg.passes.callgraph.{DynamicCallLinker, MethodRefLinker, StaticCallLinker}

object CallGraph {
  val overlayName: String = "callgraph"
  val description: String = "Call graph layer"
  def defaultOpts         = new LayerCreatorOptions()

  def passes(cpg: Cpg): Iterator[CpgPassBase] = {
    Iterator(new MethodRefLinker(cpg), new StaticCallLinker(cpg), new DynamicCallLinker(cpg))
  }

}

class CallGraph extends LayerCreator {
  override val overlayName: String     = CallGraph.overlayName
  override val description: String     = CallGraph.description
  override val dependsOn: List[String] = List(TypeRelations.overlayName)

  override def create(context: LayerCreatorContext): Unit = {
    CallGraph.passes(context.cpg).foreach(_.createAndApply())
  }

  // LayerCreators need one-arg constructor, because they're called by reflection from io.joern.console.Run
  def this(optionsUnused: LayerCreatorOptions) = this()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy