Package com.ibm.wala.cast.js.util
Class CallGraph2JSON
- java.lang.Object
-
- com.ibm.wala.cast.js.util.CallGraph2JSON
-
public class CallGraph2JSON extends java.lang.ObjectUtility class to serialize call graphs as JSON objects.The serialised objects have the form
{ "<callsite1>": [ "<callee1>", "<callee2>", ... ], "<callsite2>": ... }where both call sites and callees are encoded as strings of the form"<filename>@<lineno>:<beginoff>-<endoff>"
Here,filenameis the name of the containing JavaScript file (not including its directory), andlineno,beginoffandendoffencode the source position of the call expression (for call sites) or the function declaration/expression (for callees) inside the file in terms of its starting line, its starting offset (in characters from the beginning of the file), and its end offset.
-
-
Constructor Summary
Constructors Constructor Description CallGraph2JSON()CallGraph2JSON(boolean ignoreHarness)CallGraph2JSON(boolean ignoreHarness, boolean exposeContexts)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.Set<java.lang.String>>>extractEdges(com.ibm.wala.ipa.callgraph.CallGraph cg)Extract the edges of the given callgraph as a map over strings that is easy to serialize.java.lang.Stringserialize(com.ibm.wala.ipa.callgraph.CallGraph cg)voidserializeCallSite(com.ibm.wala.ipa.callgraph.CGNode nd, com.ibm.wala.classLoader.CallSiteReference callsite, java.util.Set<com.ibm.wala.ipa.callgraph.CGNode> targets, java.util.Map<java.lang.String,java.util.Set<java.lang.String>> edges)static java.lang.StringtoJSON(java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.Set<java.lang.String>>> map)Converts a call graph map produced byextractEdges(CallGraph)to JSON, eliding call sites with no targets.
-
-
-
Method Detail
-
serialize
public java.lang.String serialize(com.ibm.wala.ipa.callgraph.CallGraph cg)
-
extractEdges
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.Set<java.lang.String>>> extractEdges(com.ibm.wala.ipa.callgraph.CallGraph cg)
Extract the edges of the given callgraph as a map over strings that is easy to serialize. The map keys are locations of methods. The map values are themselves maps, from call site locations within a method to the (locations of) potential target methods for the call sites.
-
serializeCallSite
public void serializeCallSite(com.ibm.wala.ipa.callgraph.CGNode nd, com.ibm.wala.classLoader.CallSiteReference callsite, java.util.Set<com.ibm.wala.ipa.callgraph.CGNode> targets, java.util.Map<java.lang.String,java.util.Set<java.lang.String>> edges)
-
toJSON
public static java.lang.String toJSON(java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.Set<java.lang.String>>> map)
Converts a call graph map produced byextractEdges(CallGraph)to JSON, eliding call sites with no targets.
-
-