delete CallGraph.getInterpreter() and CFGProvider
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@1345 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
04e7807ce5
commit
e34aa83beb
|
@ -47,7 +47,7 @@ public class Util {
|
||||||
for (Iterator x = CG.iterator(); x.hasNext();) {
|
for (Iterator x = CG.iterator(); x.hasNext();) {
|
||||||
CGNode N = (CGNode) x.next();
|
CGNode N = (CGNode) x.next();
|
||||||
Trace.println("\nIR of node " + N);
|
Trace.println("\nIR of node " + N);
|
||||||
IR ir = ((SSAContextInterpreter) CG.getInterpreter(N)).getIR(N, builder.getWarnings());
|
IR ir = N.getIR(builder.getWarnings());
|
||||||
if (ir != null) {
|
if (ir != null) {
|
||||||
Trace.println(ir);
|
Trace.println(ir);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -10,10 +10,17 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package com.ibm.wala.cast.tree.impl;
|
package com.ibm.wala.cast.tree.impl;
|
||||||
|
|
||||||
import com.ibm.wala.cast.tree.*;
|
import java.util.Collection;
|
||||||
import com.ibm.wala.util.debug.Assertions;
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import java.util.*;
|
import com.ibm.wala.cast.tree.CAstControlFlowMap;
|
||||||
|
import com.ibm.wala.cast.tree.CAstNode;
|
||||||
|
import com.ibm.wala.cast.tree.CAstSourcePositionMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An implementation of a CAstControlFlowMap that is designed to be used by
|
* An implementation of a CAstControlFlowMap that is designed to be used by
|
||||||
|
|
|
@ -23,8 +23,7 @@ public abstract class CAstRewriter<RewriteContext> {
|
||||||
|
|
||||||
protected final RewriteContext rootContext;
|
protected final RewriteContext rootContext;
|
||||||
|
|
||||||
public CAstRewriter(CAst Ast, boolean recursive, RewriteContext rootContext)
|
public CAstRewriter(CAst Ast, boolean recursive, RewriteContext rootContext) {
|
||||||
{
|
|
||||||
this.Ast = Ast;
|
this.Ast = Ast;
|
||||||
this.recursive = recursive;
|
this.recursive = recursive;
|
||||||
this.rootContext = rootContext;
|
this.rootContext = rootContext;
|
||||||
|
@ -46,18 +45,13 @@ public abstract class CAstRewriter<RewriteContext> {
|
||||||
|
|
||||||
protected abstract CAstNode copyNodes(CAstNode root, RewriteContext context, Map<CAstNode, CAstNode> nodeMap);
|
protected abstract CAstNode copyNodes(CAstNode root, RewriteContext context, Map<CAstNode, CAstNode> nodeMap);
|
||||||
|
|
||||||
protected CAstNode flowOutTo(Map<CAstNode, CAstNode> nodeMap,
|
protected CAstNode flowOutTo(Map<CAstNode, CAstNode> nodeMap, CAstNode oldSource, Object label, CAstNode oldTarget,
|
||||||
CAstNode oldSource,
|
CAstControlFlowMap orig, CAstSourcePositionMap src) {
|
||||||
Object label,
|
|
||||||
CAstNode oldTarget,
|
|
||||||
CAstControlFlowMap orig,
|
|
||||||
CAstSourcePositionMap src)
|
|
||||||
{
|
|
||||||
return oldTarget;
|
return oldTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CAstControlFlowMap copyFlow(Map<CAstNode, CAstNode> nodeMap, CAstControlFlowMap orig, CAstSourcePositionMap src) {
|
private CAstControlFlowMap copyFlow(Map<CAstNode, CAstNode> nodeMap, CAstControlFlowMap orig, CAstSourcePositionMap src) {
|
||||||
Set mappedOutsideNodes = new HashSet(1);
|
Set<CAstNode> mappedOutsideNodes = new HashSet<CAstNode>(1);
|
||||||
Collection<CAstNode> oldSources = orig.getMappedNodes();
|
Collection<CAstNode> oldSources = orig.getMappedNodes();
|
||||||
CAstControlFlowRecorder newMap = new CAstControlFlowRecorder(src);
|
CAstControlFlowRecorder newMap = new CAstControlFlowRecorder(src);
|
||||||
for (Iterator<CAstNode> NS = nodeMap.keySet().iterator(); NS.hasNext();) {
|
for (Iterator<CAstNode> NS = nodeMap.keySet().iterator(); NS.hasNext();) {
|
||||||
|
@ -72,10 +66,7 @@ public abstract class CAstRewriter<RewriteContext> {
|
||||||
} else {
|
} else {
|
||||||
CAstNode tgt = flowOutTo(nodeMap, old, null, oldTarget, orig, src);
|
CAstNode tgt = flowOutTo(nodeMap, old, null, oldTarget, orig, src);
|
||||||
newMap.add(newNode, tgt, null);
|
newMap.add(newNode, tgt, null);
|
||||||
if (tgt != CAstControlFlowMap.EXCEPTION_TO_EXIT
|
if (tgt != CAstControlFlowMap.EXCEPTION_TO_EXIT && !mappedOutsideNodes.contains(tgt)) {
|
||||||
&&
|
|
||||||
!mappedOutsideNodes.contains(tgt))
|
|
||||||
{
|
|
||||||
mappedOutsideNodes.add(tgt);
|
mappedOutsideNodes.add(tgt);
|
||||||
newMap.map(tgt, tgt);
|
newMap.map(tgt, tgt);
|
||||||
}
|
}
|
||||||
|
@ -90,10 +81,7 @@ public abstract class CAstRewriter<RewriteContext> {
|
||||||
} else {
|
} else {
|
||||||
CAstNode tgt = flowOutTo(nodeMap, old, null, oldTarget, orig, src);
|
CAstNode tgt = flowOutTo(nodeMap, old, null, oldTarget, orig, src);
|
||||||
newMap.add(newNode, tgt, label);
|
newMap.add(newNode, tgt, label);
|
||||||
if (tgt != CAstControlFlowMap.EXCEPTION_TO_EXIT
|
if (tgt != CAstControlFlowMap.EXCEPTION_TO_EXIT && !mappedOutsideNodes.contains(tgt)) {
|
||||||
&&
|
|
||||||
!mappedOutsideNodes.contains(tgt))
|
|
||||||
{
|
|
||||||
mappedOutsideNodes.add(tgt);
|
mappedOutsideNodes.add(tgt);
|
||||||
newMap.map(tgt, tgt);
|
newMap.map(tgt, tgt);
|
||||||
}
|
}
|
||||||
|
@ -153,7 +141,7 @@ public abstract class CAstRewriter<RewriteContext> {
|
||||||
if (children.containsKey(oldNode)) {
|
if (children.containsKey(oldNode)) {
|
||||||
Set<CAstEntity> newEntities = new LinkedHashSet<CAstEntity>();
|
Set<CAstEntity> newEntities = new LinkedHashSet<CAstEntity>();
|
||||||
newChildren.put(newNode, newEntities);
|
newChildren.put(newNode, newEntities);
|
||||||
for (Iterator oldEntities = ((Collection) children.get(oldNode)).iterator(); oldEntities.hasNext();) {
|
for (Iterator oldEntities = children.get(oldNode).iterator(); oldEntities.hasNext();) {
|
||||||
CAstEntity oldE = (CAstEntity) oldEntities.next();
|
CAstEntity oldE = (CAstEntity) oldEntities.next();
|
||||||
newEntities.add(recursive ? rewrite(oldE) : oldE);
|
newEntities.add(recursive ? rewrite(oldE) : oldE);
|
||||||
}
|
}
|
||||||
|
@ -166,7 +154,7 @@ public abstract class CAstRewriter<RewriteContext> {
|
||||||
if (!(key instanceof CAstNode)) {
|
if (!(key instanceof CAstNode)) {
|
||||||
Set<CAstEntity> newEntities = new LinkedHashSet<CAstEntity>();
|
Set<CAstEntity> newEntities = new LinkedHashSet<CAstEntity>();
|
||||||
newChildren.put(key, newEntities);
|
newChildren.put(key, newEntities);
|
||||||
for (Iterator oldEntities = ((Collection) entry.getValue()).iterator(); oldEntities.hasNext();) {
|
for (Iterator oldEntities = entry.getValue().iterator(); oldEntities.hasNext();) {
|
||||||
CAstEntity oldE = (CAstEntity) oldEntities.next();
|
CAstEntity oldE = (CAstEntity) oldEntities.next();
|
||||||
newEntities.add(recursive ? rewrite(oldE) : oldE);
|
newEntities.add(recursive ? rewrite(oldE) : oldE);
|
||||||
}
|
}
|
||||||
|
@ -268,7 +256,7 @@ public abstract class CAstRewriter<RewriteContext> {
|
||||||
CAstNode key = entry.getKey();
|
CAstNode key = entry.getKey();
|
||||||
Set<CAstEntity> newValues = new LinkedHashSet<CAstEntity>();
|
Set<CAstEntity> newValues = new LinkedHashSet<CAstEntity>();
|
||||||
newChildren.put(key, newValues);
|
newChildren.put(key, newValues);
|
||||||
for (Iterator es = ((Collection) entry.getValue()).iterator(); es.hasNext();) {
|
for (Iterator es = entry.getValue().iterator(); es.hasNext();) {
|
||||||
newValues.add(rewrite((CAstEntity) es.next()));
|
newValues.add(rewrite((CAstEntity) es.next()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -280,7 +268,7 @@ public abstract class CAstRewriter<RewriteContext> {
|
||||||
|
|
||||||
public Iterator getScopedEntities(CAstNode construct) {
|
public Iterator getScopedEntities(CAstNode construct) {
|
||||||
if (newChildren.containsKey(construct)) {
|
if (newChildren.containsKey(construct)) {
|
||||||
return ((Collection) newChildren.get(construct)).iterator();
|
return newChildren.get(construct).iterator();
|
||||||
} else {
|
} else {
|
||||||
return EmptyIterator.instance();
|
return EmptyIterator.instance();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue