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

io.joern.swiftsrc2cpg.datastructures.PendingReference.scala Maven / Gradle / Ivy

There is a newer version: 4.0.78
Show newest version
package io.joern.swiftsrc2cpg.datastructures

import io.shiftleft.codepropertygraph.generated.nodes.NewNode

case class PendingReference(variableName: String, referenceNode: NewNode, stack: Option[ScopeElement]) {

  def tryResolve(): Option[ResolvedReference] = {
    var foundVariableOption = Option.empty[NewNode]
    val stackIterator       = new ScopeElementIterator(stack)

    while (stackIterator.hasNext && foundVariableOption.isEmpty) {
      val scopeElement = stackIterator.next()
      foundVariableOption = scopeElement.nameToVariableNode.get(variableName)
    }

    foundVariableOption.map { variableNodeId =>
      ResolvedReference(variableNodeId, this)
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy