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

io.joern.pysrc2cpg.memop.AstNodeToMemoryOperationMap.scala Maven / Gradle / Ivy

There is a newer version: 1.2.44
Show newest version
package io.joern.pysrc2cpg.memop

import io.joern.pythonparser.ast

import scala.collection.mutable

class AstNodeToMemoryOperationMap {
  private class IdentityHashWrapper(private val astNode: ast.iast) {
    override def equals(o: Any): Boolean = {
      o match {
        case wrapper: IdentityHashWrapper =>
          astNode eq wrapper.astNode
        case _ =>
          false
      }
    }

    override def hashCode(): Int = {
      System.identityHashCode(astNode)
    }

    override def toString: String = astNode.toString
  }

  private val astNodeToMemOp = mutable.HashMap.empty[IdentityHashWrapper, MemoryOperation]

  def put(astNode: ast.iast, memOp: MemoryOperation): Unit = {
    astNodeToMemOp.put(new IdentityHashWrapper(astNode), memOp)
  }

  def get(astNode: ast.iast): Option[MemoryOperation] = {
    astNodeToMemOp.get(new IdentityHashWrapper(astNode))
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy