<commit_before>package wala
import com.ibm.wala.ssa.SSAPutInstruction
import scala.collection.JavaConversions._

// "Pointer Local" - equivalent of LocalPointerKey
trait WALAConversionsForP { self: WALAConversions =>
  object P {
    def apply(n: N, v: Int) = {
      new P(n, v)
    }
    def unapply(p: P): Option[(N, Int)] = {
      Some((p.getNode(), p.getValueNumber()))
    }
  }

  class EnhancedP(p: P) {
    def n = p.getNode()
    def v = p.getValueNumber()
    def getDef() = n.getDU().getDef(v)
    def getUses(): Iterable[I] = n.getDU().getUses(v).toIterable

    /**
     * Gets all uses of this pointer that write to a field of it
     */
    def getPuts(): Iterable[SSAPutInstruction] =
      (for (i <- getUses() if i.isInstanceOf[PutI] && i.asInstanceOf[PutI].getRef() == v)
        yield i.asInstanceOf[SSAPutInstruction])

    def variableNames(): Iterable[String] =
      n.instructions.toIterable.map(i => S(n, i).variableNames(v)).flatten.toSet

    def prettyPrint(): String =
      n.prettyPrint + " v" + v + "(" + (if (!variableNames().isEmpty) variableNames.reduce(_ + "," + _) else "") + ")"
  }

  implicit def enhanceP(p: P): EnhancedP = new EnhancedP(p)
}<commit_msg>prettyPrint for instanceField pointerKey<commit_after>package wala
import com.ibm.wala.ssa.SSAPutInstruction
import scala.collection.JavaConversions._
import com.ibm.wala.ipa.callgraph.propagation.InstanceFieldPointerKey

// "Pointer Local" - equivalent of LocalPointerKey
trait WALAConversionsForP { self: WALAConversions =>
  object P {
    def apply(n: N, v: Int) = {
      new P(n, v)
    }
    def unapply(p: P): Option[(N, Int)] = {
      Some((p.getNode(), p.getValueNumber()))
    }
  }

  class EnhancedP(p: P) {
    def n = p.getNode()
    def v = p.getValueNumber()
    def getDef() = n.getDU().getDef(v)
    def getUses(): Iterable[I] = n.getDU().getUses(v).toIterable

    /**
     * Gets all uses of this pointer that write to a field of it
     */
    def getPuts(): Iterable[SSAPutInstruction] =
      (for (i <- getUses() if i.isInstanceOf[PutI] && i.asInstanceOf[PutI].getRef() == v)
        yield i.asInstanceOf[SSAPutInstruction])

    def variableNames(): Iterable[String] =
      n.instructions.toIterable.map(i => S(n, i).variableNames(v)).flatten.toSet

    def prettyPrint(): String =
      n.prettyPrint + " v" + v + "(" + (if (!variableNames().isEmpty) variableNames.reduce(_ + "," + _) else "") + ")"
  }
 
  implicit def enhanceP(p: P): EnhancedP = new EnhancedP(p)
  
  implicit def enhancePK(p: InstanceFieldPointerKey) = new {
    def prettyPrint(): String = "PT:"+p.getInstanceKey().prettyPrint
  }
}
{'fraction_non_alphanumeric': 0.15431394906879514, 'fraction_numerical': 0.0, 'mean_word_length': 3.32183908045977, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5517639', 'n_tokens_mistral': 933, 'n_tokens_neox': 925, 'n_words': 206}