Skip to content

Commit

Permalink
updates for upstream changes, modernized Atlas API usage
Browse files Browse the repository at this point in the history
  • Loading branch information
benjholla committed Oct 7, 2018
1 parent d8794db commit 63eee10
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion com.ensoftcorp.open.c.commons.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="com.ensoftcorp.open.c.commons.feature"
label="C Commons Toolbox"
version="3.3.0.qualifier"
version="3.3.7.qualifier"
provider-name="EnSoft Corp.">

<description url="https://ensoftcorp.github.io/c-commons-toolbox/">
Expand Down
17 changes: 9 additions & 8 deletions com.ensoftcorp.open.c.commons/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.ensoftcorp.open.c.commons;singleton:=true
Bundle-Version: 3.3.0.qualifier
Bundle-Version: 3.3.7.qualifier
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
com.ensoftcorp.atlas.c.core;bundle-version="3.3.0";visibility:=reexport,
com.ensoftcorp.atlas.c.ui;bundle-version="3.3.0";visibility:=reexport,
com.ensoftcorp.atlas.core;bundle-version="3.3.0",
com.ensoftcorp.atlas.ui.shell;bundle-version="3.3.0",
com.ensoftcorp.atlas.ui;bundle-version="3.3.0",
com.ensoftcorp.atlas.scala-lang;bundle-version="3.3.0",
com.ensoftcorp.open.commons;bundle-version="3.3.0"
com.ensoftcorp.atlas.c.core;bundle-version="3.3.7";visibility:=reexport,
com.ensoftcorp.atlas.c.ui;bundle-version="3.3.7";visibility:=reexport,
com.ensoftcorp.atlas.core;bundle-version="3.3.7",
com.ensoftcorp.atlas.ui.shell;bundle-version="3.3.7",
com.ensoftcorp.atlas.ui;bundle-version="3.3.7",
com.ensoftcorp.atlas.scala-lang;bundle-version="3.3.7",
com.ensoftcorp.open.commons;bundle-version="3.3.7",
com.ensoftcorp.open.commons.ui;bundle-version="3.3.7"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: com.ensoftcorp.open.c.commons,
com.ensoftcorp.open.c.commons.analysis,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.ensoftcorp.atlas.core.db.set.AtlasHashSet;
import com.ensoftcorp.atlas.core.db.set.AtlasSet;
import com.ensoftcorp.atlas.core.query.Q;
import com.ensoftcorp.atlas.core.query.Query;
import com.ensoftcorp.atlas.core.script.Common;
import com.ensoftcorp.atlas.core.xcsg.XCSG;
import com.ensoftcorp.open.commons.analysis.CallSiteAnalysis.LanguageSpecificCallSiteAnalysis;
Expand Down Expand Up @@ -44,7 +45,7 @@ public static AtlasSet<Node> getInvokedFunction(AtlasSet<Node> callsites) {
* @return
*/
public static AtlasSet<Node> getInvokedFunction(Node callsite) {
return Common.universe().edgesTaggedWithAny(XCSG.InvokedFunction).successors(Common.toQ(callsite)).eval().nodes();
return Query.universe().edges(XCSG.InvokedFunction).successors(Common.toQ(callsite)).eval().nodes();
}

/**
Expand Down Expand Up @@ -75,7 +76,7 @@ public static AtlasSet<Node> getFunctionInvocations(AtlasSet<Node> functions) {
* @return
*/
public static AtlasSet<Node> getFunctionInvocations(Node function) {
return Common.universe().edgesTaggedWithAny(XCSG.InvokedFunction).predecessors(Common.toQ(function)).eval().nodes();
return Query.universe().edges(XCSG.InvokedFunction).predecessors(Common.toQ(function)).eval().nodes();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.ensoftcorp.atlas.core.db.set.IntersectionSet;
import com.ensoftcorp.atlas.core.index.common.SourceCorrespondence;
import com.ensoftcorp.atlas.core.query.Q;
import com.ensoftcorp.atlas.core.query.Query;
import com.ensoftcorp.atlas.core.script.Common;
import com.ensoftcorp.atlas.core.script.CommonQueries.TraversalDirection;
import com.ensoftcorp.atlas.core.xcsg.XCSG;
Expand Down Expand Up @@ -1092,7 +1093,7 @@ public static Q mpg(Q e1Functions, Q e2Functions, Q object){
* @return intra-procedural data-flow graph
*/
public static Q projectDFG(Q dfg, Q func){
Q functionBody = func.contained().induce(Common.universe());
Q functionBody = func.contained().induce(Query.universe());
return functionBody.intersection(dfg);
}

Expand Down Expand Up @@ -1191,12 +1192,12 @@ public static Q file(String path) {

private static Q findByName(String functionName, String tag) {
if(functionName.indexOf("*") >= 0){
Q nodes = Common.universe().nodes(tag);
Q nodes = Query.universe().nodes(tag);
Q result = getMatches(functionName, nodes);
return result;
}
// Atlas has an index over literal attribute values, so it's faster to query directly
return Common.universe().nodes(tag).selectNode(XCSG.name, functionName);
return Query.universe().nodes(tag).selectNode(XCSG.name, functionName);
}

/**
Expand Down Expand Up @@ -1325,7 +1326,7 @@ public static Graph reverseDF(AtlasSet<Node> origin) {
}

public static Graph reverseDF(AtlasSet<Node> origin, AtlasSet<Node> stop) {
Graph context = Common.universe().edgesTaggedWithAny(XCSG.DataFlow_Edge).eval();
Graph context = Query.universe().edges(XCSG.DataFlow_Edge).eval();
return traverse(context, TraversalDirection.REVERSE, origin, stop);
}

Expand All @@ -1335,7 +1336,7 @@ public static Graph forwardDF(AtlasSet<Node> origin) {
}

public static Graph forwardDF(AtlasSet<Node> origin, AtlasSet<Node> stop) {
Graph context = Common.universe().edgesTaggedWithAny(XCSG.DataFlow_Edge).eval();
Graph context = Query.universe().edges(XCSG.DataFlow_Edge).eval();
return traverse(context, TraversalDirection.FORWARD, origin, stop);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
import com.ensoftcorp.atlas.core.db.set.AtlasHashSet;
import com.ensoftcorp.atlas.core.db.set.AtlasSet;
import com.ensoftcorp.atlas.core.query.Q;
import com.ensoftcorp.atlas.core.query.Query;
import com.ensoftcorp.atlas.core.script.Common;
import com.ensoftcorp.atlas.core.script.CommonQueries;
import com.ensoftcorp.atlas.core.xcsg.XCSG;
import com.ensoftcorp.open.c.commons.log.Log;
import com.ensoftcorp.open.commons.algorithms.UniqueEntryExitControlFlowGraph;
import com.ensoftcorp.open.commons.algorithms.UniqueEntryExitGraph;
import com.ensoftcorp.open.commons.algorithms.dominance.DominatorTree;
import com.ensoftcorp.open.commons.log.Log;
import com.ensoftcorp.open.commons.preferences.CommonsPreferences;

/**
Expand All @@ -24,9 +25,12 @@
*/
public class GotoLoopDetection {
public static String recoverGotoLoops() {
return recoverGotoLoops(Common.universe());
return recoverGotoLoops(Query.universe());
}

// TODO: Where does this constant come from?? XCSG?? I can't find it... ~BH
private static final String IS_LABEL = "isLabel";

public static String recoverGotoLoops(Q app) {
String message = "Total number of Goto Loops = ";
long totalLoops = 0l;
Expand All @@ -35,7 +39,7 @@ public static String recoverGotoLoops(Q app) {
AtlasSet<Edge> allEdges = new AtlasHashSet<Edge>();
Q cfg = CommonQueries.cfg(Common.toQ(function));
allEdges.addAll(cfg.eval().edges());
Q labelNodesQ = cfg.contained().nodesTaggedWithAny("isLabel");
Q labelNodesQ = cfg.contained().nodes(IS_LABEL);
AtlasSet<Node> labelNodes = labelNodesQ.eval().nodes();

if (!CommonQueries.isEmpty(labelNodesQ)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static Q getAllowedLeafNodes() {
* @param f1
*/
public static void setAllowedLeafNodes(Q leaves) {
MatchingPairSearchModelSmartView.leaves = leaves.nodesTaggedWithAny(XCSG.Function);
MatchingPairSearchModelSmartView.leaves = leaves.nodes(XCSG.Function);
}

@Override
Expand Down

0 comments on commit 63eee10

Please sign in to comment.