a but more javadoc; added accessor for getting all value numbers exposed to lexical scoping; allow scopes during translation to ask for parent scopes
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@1274 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
5af604fb12
commit
d958868f41
|
@ -297,6 +297,20 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
|
|||
return new AstInterestingVisitor(vn);
|
||||
}
|
||||
|
||||
public boolean hasNoInterestingUses(CGNode node, int vn, DefUse du) {
|
||||
if (node.getMethod() instanceof AstMethod) {
|
||||
int uses[] =
|
||||
((AstMethod)node.getMethod()).lexicalInfo.getAllExposedUses();
|
||||
for(int i = 0; i < uses.length; i++) {
|
||||
if (uses[i] == vn) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.hasNoInterestingUses(node, vn, du);
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IR visitor specialization for Ast-specific IR types
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/******************************************************************************
|
||||
* Copyright (c) 2002 - 2006 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*****************************************************************************/
|
||||
package com.ibm.wala.cast.ipa.callgraph;
|
||||
|
||||
import com.ibm.wala.cast.util.*;
|
||||
|
@ -14,6 +24,15 @@ import com.ibm.wala.util.warnings.*;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* A CallGraph implementation adapted to work for graphs that contain
|
||||
* code entities from multiple languages, and hence multiple specialized
|
||||
* forms of IR. The root node delegates to one of several language-specific
|
||||
* root nodes, allowing each language to use its own specialized IR
|
||||
* constructs for entry points.
|
||||
*
|
||||
* @author Julian Dolby (dolby@us.ibm.com)
|
||||
*/
|
||||
public class CrossLanguageCallGraph extends AstCallGraph {
|
||||
|
||||
public CrossLanguageCallGraph(
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/******************************************************************************
|
||||
* Copyright (c) 2002 - 2006 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*****************************************************************************/
|
||||
package com.ibm.wala.cast.ipa.callgraph;
|
||||
|
||||
import com.ibm.wala.classLoader.*;
|
||||
|
@ -7,6 +17,15 @@ import com.ibm.wala.util.Atom;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* A ClassTargetSelector implementation that delegates to one of several
|
||||
* child selectors based on the language of the type being allocated. This
|
||||
* selector uses the language associated with the TypeReference of the
|
||||
* allocated type to delagate t =o the appropriate language-specific
|
||||
* selector.
|
||||
*
|
||||
* @author Julian Dolby (dolby@us.ibm.com)
|
||||
*/
|
||||
public class CrossLanguageClassTargetSelector implements ClassTargetSelector {
|
||||
|
||||
private final Map languageSelectors;
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/******************************************************************************
|
||||
* Copyright (c) 2002 - 2006 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*****************************************************************************/
|
||||
package com.ibm.wala.cast.ipa.callgraph;
|
||||
|
||||
import com.ibm.wala.classLoader.*;
|
||||
|
@ -8,6 +18,18 @@ import com.ibm.wala.util.warnings.*;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* A ContextSelector implementation adapted to work for analysi across
|
||||
* multiple languages. This context selector delegates to one of several
|
||||
* child selectors based on the language of the code body for which a
|
||||
* context is being selected.
|
||||
*
|
||||
* This provides a convenient way to integrate multiple, lanuage-specific
|
||||
* specialized context policies---such as the ones used for clone() in
|
||||
* Java and runtime primitives in JavaScript.
|
||||
*
|
||||
* @author Julian Dolby (dolby@us.ibm.com)
|
||||
*/
|
||||
public class CrossLanguageContextSelector implements ContextSelector {
|
||||
|
||||
private final Map languageSelectors;
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/******************************************************************************
|
||||
* Copyright (c) 2002 - 2006 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*****************************************************************************/
|
||||
package com.ibm.wala.cast.ipa.callgraph;
|
||||
|
||||
import com.ibm.wala.classLoader.*;
|
||||
|
@ -9,6 +19,14 @@ import com.ibm.wala.util.warnings.*;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* An InstanceKeyFactory implementation that is designed to support
|
||||
* multiple languages. This implementation delegates to one of several
|
||||
* child instance key factories based on the language associated with
|
||||
* the IClass or TypeReference for which an instance key is being chosen.
|
||||
*
|
||||
* @author Julian Dolby (dolby@us.ibm.com)
|
||||
*/
|
||||
public class CrossLanguageInstanceKeys implements InstanceKeyFactory {
|
||||
|
||||
private final Map languageSelectors;
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/******************************************************************************
|
||||
* Copyright (c) 2002 - 2006 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*****************************************************************************/
|
||||
package com.ibm.wala.cast.ipa.callgraph;
|
||||
|
||||
import com.ibm.wala.classLoader.*;
|
||||
|
@ -7,6 +17,18 @@ import com.ibm.wala.util.Atom;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* A MethodTargetSelector implementation that supports multiple languages.
|
||||
* It works by delegating to a language-specific child selector based on
|
||||
* the language associated with the MethodReference for which a target is
|
||||
* being chosen.
|
||||
*
|
||||
* This provides a simple way to combine language-specific target
|
||||
* selection policies---such as those used for constructor calls in
|
||||
* JavaScript and for bean methods in J2EE.
|
||||
*
|
||||
* @author Julian Dolby (dolby@us.ibm.com)
|
||||
*/
|
||||
public class CrossLanguageMethodTargetSelector
|
||||
implements MethodTargetSelector
|
||||
{
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/******************************************************************************
|
||||
* Copyright (c) 2002 - 2006 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*****************************************************************************/
|
||||
package com.ibm.wala.cast.ipa.cha;
|
||||
|
||||
import com.ibm.wala.classLoader.*;
|
||||
|
@ -11,6 +21,23 @@ import com.ibm.wala.util.warnings.*;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* This class hierarchy represents a family of disjoint class hierarchies,
|
||||
* one for each of a selection of languages. The implementation creates a
|
||||
* separate ClassHierarchy object for each language, and this overall
|
||||
* IClassHierarchy implementation delegates to the appropriate language
|
||||
* class hierarchy based on the language associated with the class loader
|
||||
* of the given TypeReference or IClass object.
|
||||
*
|
||||
* Note that, because of this delegating structure and representation of
|
||||
* multiple languages, the getRootClass API call does not make sense for
|
||||
* this hierarchy. In general, any code that wants to use multiple
|
||||
* language must deal with the fact that there is no longer a single
|
||||
* root type. Each individual language is still expected to have a root
|
||||
* type, however.
|
||||
*
|
||||
* @author Julian Dolby (dolby@us.ibm.com)
|
||||
*/
|
||||
public class CrossLanguageClassHierarchy implements IClassHierarchy {
|
||||
|
||||
private final ClassLoaderFactory loaderFactory;
|
||||
|
|
|
@ -320,7 +320,7 @@ public abstract class AstTranslator extends CAstVisitor {
|
|||
|
||||
public static final boolean DEBUG_NAMES = DEBUG_ALL || true;
|
||||
|
||||
public static final boolean DEBUG_LEXICAL = DEBUG_ALL || false;
|
||||
public static final boolean DEBUG_LEXICAL = DEBUG_ALL || true;
|
||||
|
||||
protected final static class PreBasicBlock implements INodeWithNumber, IBasicBlock {
|
||||
private static final int NORMAL = 0;
|
||||
|
@ -919,15 +919,15 @@ public abstract class AstTranslator extends CAstVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
private final static int TYPE_LOCAL = 1;
|
||||
protected final static int TYPE_LOCAL = 1;
|
||||
|
||||
private final static int TYPE_GLOBAL = 2;
|
||||
protected final static int TYPE_GLOBAL = 2;
|
||||
|
||||
private final static int TYPE_SCRIPT = 3;
|
||||
protected final static int TYPE_SCRIPT = 3;
|
||||
|
||||
private final static int TYPE_FUNCTION = 4;
|
||||
protected final static int TYPE_FUNCTION = 4;
|
||||
|
||||
private final static int TYPE_TYPE = 5;
|
||||
protected final static int TYPE_TYPE = 5;
|
||||
|
||||
protected class FinalCAstSymbol implements CAstSymbol {
|
||||
private final String _name;
|
||||
|
@ -991,6 +991,8 @@ public abstract class AstTranslator extends CAstVisitor {
|
|||
boolean isLexicallyScoped(Symbol s);
|
||||
|
||||
CAstEntity getEntity();
|
||||
|
||||
Scope getParent();
|
||||
}
|
||||
|
||||
private static abstract class AbstractSymbol implements Symbol {
|
||||
|
@ -1038,6 +1040,10 @@ public abstract class AstTranslator extends CAstVisitor {
|
|||
|
||||
protected abstract SymbolTable getUnderlyingSymtab();
|
||||
|
||||
public Scope getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return getUnderlyingSymtab().getMaxValueNumber() + 1;
|
||||
}
|
||||
|
@ -1360,6 +1366,10 @@ public abstract class AstTranslator extends CAstVisitor {
|
|||
return (mappedName == null) ? nm : mappedName;
|
||||
}
|
||||
|
||||
public Scope getParent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isGlobal(Symbol s) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1466,6 +1476,10 @@ public abstract class AstTranslator extends CAstVisitor {
|
|||
return (mappedName == null) ? nm : mappedName;
|
||||
}
|
||||
|
||||
public Scope getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public boolean isGlobal(Symbol s) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1887,6 +1901,32 @@ public abstract class AstTranslator extends CAstVisitor {
|
|||
return instructionLexicalUses[instructionOffset];
|
||||
}
|
||||
|
||||
public int[] getAllExposedUses() {
|
||||
List uses = new ArrayList();
|
||||
if (exitLexicalUses != null) {
|
||||
for(int i = 0; i < exitLexicalUses.length; i++) {
|
||||
uses.add(new Integer(exitLexicalUses[i]));
|
||||
}
|
||||
}
|
||||
if (instructionLexicalUses != null) {
|
||||
for(int i = 0; i < instructionLexicalUses.length; i++) {
|
||||
if (instructionLexicalUses[i] != null) {
|
||||
for(int j = 0; j < instructionLexicalUses[i].length; j++) {
|
||||
uses.add(new Integer(instructionLexicalUses[i][j]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
int[] result = new int[ uses.size() ];
|
||||
for(Iterator x = uses.iterator(); x.hasNext(); ) {
|
||||
result[i++] = ((Integer)x.next()).intValue();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Pair[] getExposedNames() {
|
||||
return exposedNames;
|
||||
}
|
||||
|
|
|
@ -45,6 +45,8 @@ public abstract class AstMethod implements IMethod {
|
|||
|
||||
public int[] getExposedUses(int instructionOffset);
|
||||
|
||||
public int[] getAllExposedUses();
|
||||
|
||||
public Pair[] getExposedNames();
|
||||
|
||||
public String[] getScopingParents();
|
||||
|
|
Loading…
Reference in New Issue