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

io.shiftleft.semanticcpg.language.operatorextension.nodemethods.TargetMethods.scala Maven / Gradle / Ivy

There is a newer version: 4.0.77
Show newest version
package io.shiftleft.semanticcpg.language.operatorextension.nodemethods

import io.shiftleft.codepropertygraph.generated.Operators
import io.shiftleft.codepropertygraph.generated.nodes.{Call, Expression}
import io.shiftleft.semanticcpg.language.*
import io.shiftleft.semanticcpg.language.operatorextension.{OpNodes, allArrayAccessTypes}

class TargetMethods(val expr: Expression) extends AnyVal {

  def arrayAccess: Option[OpNodes.ArrayAccess] =
    expr.ast.isCall
      .cast[OpNodes.ArrayAccess]
      .collectFirst { case x if allArrayAccessTypes.contains(x.name) => x }

  def pointer: Option[Expression] =
    Option(expr).collect {
      case call: Call if call.name == Operators.indirection => call.argument(1)
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy