Conflicts:
	com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/shrike/DynamicCallGraphTestBase.java
	com.ibm.wala.ide.jdt.test/launchers/JDTJava15IRTests.launch
This commit is contained in:
Julian Dolby 2014-10-06 15:43:42 -04:00
commit 6c47da8091
621 changed files with 69853 additions and 1115 deletions

42
.gitignore vendored
View File

@ -1,15 +1,37 @@
target/
*.DS_Store
*.class
*.out
*.swp
*/bin/
com.ibm.wala.cast.js.rhino/lib/
com.ibm.wala.cast.js/lib/
*/bin/*
*~
.metadata/
com.ibm.wala.cast.java.jdt.test/
com.ibm.wala.cast.java.polyglot/lib/
com.ibm.wala.cast.java.test.data/src/JLex/
.metadata/
*~
com.ibm.wala.cast.js.test.data/examples-src/ajaxslt/
com.ibm.wala.core.testdata/@dot/
com.ibm.wala.core.testdata/*.jar
com.ibm.wala.core/dat/wala.properties
com.ibm.wala.core.tests/dat/wala.examples.properties
com.ibm.wala.cast.java.test/testdata/
com.ibm.wala.cast.js.html.nu_validator/lib/
com.ibm.wala.cast.js.rhino.test/*.dump
com.ibm.wala.cast.js.rhino.test/*.html*
com.ibm.wala.cast.js.rhino.test/2009_swine_flu_outbreak
com.ibm.wala.cast.js.rhino.test/?game*
com.ibm.wala.cast.js.rhino.test/BunnyHunt
com.ibm.wala.cast.js.rhino.test/digg_attack
com.ibm.wala.cast.js.rhino.test/game.php*
com.ibm.wala.cast.js.rhino.test/xxxx
com.ibm.wala.cast.js.rhino/lib/
com.ibm.wala.cast.js.test.data/examples-src/ajaxslt/
com.ibm.wala.cast.js.test/examples-src/ajaxslt/
com.ibm.wala.cast.js/lib/
com.ibm.wala.core.testdata/*.jar
com.ibm.wala.core.testdata/@dot/
com.ibm.wala.core.testdata/lib/
com.ibm.wala.core.tests/dat/wala.examples.properties
com.ibm.wala.core.tests/report
com.ibm.wala.core/@dot
com.ibm.wala.core/com.ibm.wala.core*.jar
com.ibm.wala.core/dat/wala.properties
com.ibm.wala.dalvik/src/logback.xml
com.ibm.wala.ide.jdt.test/testdata/
edu.kit.wala.smali.test/out/
target/

View File

@ -1,2 +1,13 @@
This is the main source repository for WALA. For more details on WALA, see <a
href="http://wala.sourceforge.net">the WALA home page</a>.
# About WALA
This is a fork of the program analysis framework WALA. The original framework can be found at <a href="http://wala.sourceforge.net">wala.sourceforge.net</a> and <a href="https://github.com/wala/WALA">github.com/wala/WALA</a>.
This version is tailored for the information flow control framework JOANA. See <a href="http://joana.ipd.kit.edu">joana.ipd.kit.edu</a> and <a href="https://github.com/jgf/joana">github.com/jgf/joana</a> for details.
This fork includes some additional features:
- null-pointer detection that removes spurious CFG edges.
- it includes the code for a dalivk bytecode frontend copied and integrated from <a href="https://github.com/SCanDroid/SCanDroid">github.com/SCanDroid/SCanDroid</a>.
- configuration/property files are loaded from current directory, with an automatic fallback to load from .jar.
- SDG implementation that has different edge types for control and data dependencies.
- every SSAInstrution knows its index.
- many other minor changes.

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.ibm.wala.ide.jdt.test</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -15,5 +15,5 @@ Require-Bundle: com.ibm.wala.cast;bundle-version="1.0.0",
com.ibm.wala.cast.java.polyglot;bundle-version="1.0.0",
org.junit;bundle-version="4.0.0",
com.ibm.wala.cast.java.test.data;bundle-version="1.3.4"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy

View File

@ -7,6 +7,9 @@
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[run]" value="org.eclipse.jdt.junit.launchconfig"/>
</mapAttribute>
<stringAttribute key="org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE" value="/tmp/console.txt"/>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="source"/>
<classpathentry exported="true" kind="lib" path="lib/polyglot.jar"/>
<classpathentry exported="true" kind="lib" path="lib/java_cup.jar"/>
<classpathentry exported="true" kind="lib" path="lib/polyglot.jar"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -11,7 +11,7 @@ Require-Bundle: com.ibm.wala.cast.java,
com.ibm.wala.shrike,
org.eclipse.jdt.core,
org.eclipse.core.resources
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
Export-Package: com.ibm.wala.cast.java.translator.polyglot;
uses:="com.ibm.wala.types,

View File

@ -1,3 +1,14 @@
/******************************************************************************
* Copyright (c) 2002 - 2014 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
*****************************************************************************/
/**
*
*/

Binary file not shown.

View File

@ -4,5 +4,5 @@ Bundle-Name: Data Plug-in
Bundle-SymbolicName: com.ibm.wala.cast.java.test.data
Bundle-Version: 1.3.4.qualifier
Bundle-Vendor: IBM
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7

View File

@ -12,8 +12,8 @@
<property name="javacVerbose" value="false"/>
<property name="logExtension" value=".log"/>
<property name="compilerArg" value=""/>
<property name="javacSource" value="1.5"/>
<property name="javacTarget" value="1.5"/>
<property name="javacSource" value="1.7"/>
<property name="javacTarget" value="1.7"/>
<!-- This property has been updated to correspond to the paths used by the latest Java update
on Mac OS X 10.6 (Java version 1.6.0_22). If you are not using this version of Mac OS X or Java,
try changing the value of the property to "${java.home}/../../../Classes" -->
@ -78,7 +78,7 @@
</target>
<target name="jar" depends="compile,testdatadir">
<jar destfile="${basedir}/../com.ibm.wala.ide.jdt.test/testdata/test_project.zip" basedir="${basedir}"/>
<jar destfile="${basedir}/../com.ibm.wala.ide.jdt.test/testdata/test_project.zip" manifest="${basedir}/META-INF/MANIFEST.MF" basedir="${basedir}"/>
</target>
<target name="init" depends="properties">

View File

@ -2,6 +2,6 @@
<classpath>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -14,4 +14,4 @@ Require-Bundle: com.ibm.wala.core.tests,
org.junit;bundle-version="4.0.0"
Bundle-ActivationPolicy: lazy
Export-Package: com.ibm.wala.cast.java.test
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-RequiredExecutionEnvironment: JavaSE-1.7

View File

@ -40,6 +40,8 @@ import com.ibm.wala.classLoader.SourceFileModule;
import com.ibm.wala.client.AbstractAnalysisEngine;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.CallGraph;
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.properties.WalaProperties;
import com.ibm.wala.ssa.IR;
@ -344,8 +346,8 @@ public abstract class IRTests {
protected abstract AbstractAnalysisEngine getAnalysisEngine(String[] mainClassDescriptors, Collection<String> sources, List<String> libs);
public Pair runTest(Collection<String> sources, List<String> libs, String[] mainClassDescriptors, List<? extends IRAssertion> ca,
boolean assertReachable) {
public Pair<CallGraph, PointerAnalysis<InstanceKey>> runTest(Collection<String> sources, List<String> libs,
String[] mainClassDescriptors, List<? extends IRAssertion> ca, boolean assertReachable) {
AbstractAnalysisEngine engine = getAnalysisEngine(mainClassDescriptors, sources, libs);
CallGraph callGraph;

View File

@ -379,12 +379,13 @@ public abstract class JavaIRTests extends IRTests {
}
@Test public void testInnerClassA() {
Pair x = runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), new ArrayList<IRAssertion>(), true);
Pair<CallGraph, PointerAnalysis<InstanceKey>> x =
runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), new ArrayList<IRAssertion>(), true);
// can't do an IRAssertion() -- we need the pointer analysis
CallGraph cg = (CallGraph) x.fst;
PointerAnalysis pa = (PointerAnalysis) x.snd;
CallGraph cg = x.fst;
PointerAnalysis<InstanceKey> pa = x.snd;
Iterator<CGNode> iter = cg.iterator();
while ( iter.hasNext() ) {
@ -437,12 +438,13 @@ public abstract class JavaIRTests extends IRTests {
}
@Test public void testInnerClassSuper() {
Pair x = runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), new ArrayList<IRAssertion>(), true);
Pair<CallGraph, PointerAnalysis<InstanceKey>> x =
runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), new ArrayList<IRAssertion>(), true);
// can't do an IRAssertion() -- we need the pointer analysis
CallGraph cg = (CallGraph) x.fst;
PointerAnalysis pa = (PointerAnalysis) x.snd;
CallGraph cg = x.fst;
PointerAnalysis<InstanceKey> pa = x.snd;
Iterator<CGNode> iter = cg.iterator();
while ( iter.hasNext() ) {
@ -594,10 +596,10 @@ public abstract class JavaIRTests extends IRTests {
}
@Test public void testMiniaturSliceBug() throws IllegalArgumentException, CancelException {
Pair<?, ?> x = runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true);
Pair<CallGraph, PointerAnalysis<InstanceKey>> x = runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true);
PointerAnalysis pa = (PointerAnalysis) x.snd;
CallGraph cg = (CallGraph) x.fst;
PointerAnalysis<InstanceKey> pa = x.snd;
CallGraph cg = x.fst;
// test partial slice
MethodReference sliceRootRef = getSliceRootReference("MiniaturSliceBug", "validNonDispatchedCall", "(LIntWrapper;)V");

View File

@ -2,6 +2,6 @@
<classpath>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=ignore

View File

@ -23,4 +23,4 @@ Export-Package: com.ibm.wala.cast.java,
com.ibm.wala.cast.java.translator,
com.ibm.wala.cast.java.types
Bundle-ClassPath: .
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-RequiredExecutionEnvironment: JavaSE-1.7

View File

@ -18,6 +18,7 @@ import com.ibm.wala.cast.java.ssa.AstJavaInstructionVisitor;
import com.ibm.wala.cast.java.ssa.AstJavaInvokeInstruction;
import com.ibm.wala.cast.java.ssa.EnclosingObjectReference;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
import com.ibm.wala.ipa.callgraph.propagation.PointerKey;
import com.ibm.wala.ipa.modref.ExtendedHeapModel;
@ -29,7 +30,7 @@ public class AstJavaModRef extends AstModRef {
implements AstJavaInstructionVisitor
{
protected AstJavaRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis pa, ExtendedHeapModel h) {
protected AstJavaRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<InstanceKey> pa, ExtendedHeapModel h) {
super(n, result, pa, (AstHeapModel)h);
}
@ -46,7 +47,7 @@ public class AstJavaModRef extends AstModRef {
}
@Override
protected RefVisitor makeRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis pa, ExtendedHeapModel h) {
protected RefVisitor makeRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<InstanceKey> pa, ExtendedHeapModel h) {
return new AstJavaRefVisitor(n, result, pa, h);
}
@ -55,7 +56,7 @@ public class AstJavaModRef extends AstModRef {
implements AstJavaInstructionVisitor
{
protected AstJavaModVisitor(CGNode n, Collection<PointerKey> result, ExtendedHeapModel h, PointerAnalysis pa) {
protected AstJavaModVisitor(CGNode n, Collection<PointerKey> result, ExtendedHeapModel h, PointerAnalysis<InstanceKey> pa) {
super(n, result, (AstHeapModel)h, pa);
}
@ -72,7 +73,7 @@ public class AstJavaModRef extends AstModRef {
}
@Override
protected ModVisitor makeModVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis pa, ExtendedHeapModel h, boolean ignoreAllocHeapDefs) {
protected ModVisitor makeModVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<InstanceKey> pa, ExtendedHeapModel h, boolean ignoreAllocHeapDefs) {
return new AstJavaModVisitor(n, result, h, pa);
}

View File

@ -21,6 +21,7 @@ import com.ibm.wala.cast.java.ipa.modref.AstJavaModRef;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.CallGraph;
import com.ibm.wala.ipa.callgraph.impl.PartialCallGraph;
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
import com.ibm.wala.ipa.slicer.NormalStatement;
import com.ibm.wala.ipa.slicer.SDG;
@ -111,7 +112,7 @@ public class AstJavaSlicer extends Slicer {
});
}
public static Pair<Collection<Statement>, SDG> computeAssertionSlice(CallGraph CG, PointerAnalysis pa,
public static Pair<Collection<Statement>, SDG> computeAssertionSlice(CallGraph CG, PointerAnalysis<InstanceKey> pa,
Collection<CGNode> partialRoots, boolean multiThreadedCode) throws IllegalArgumentException, CancelException {
CallGraph pcg = PartialCallGraph.make(CG, new LinkedHashSet<CGNode>(partialRoots));
SDG sdg = new SDG(pcg, pa, new AstJavaModRef(), DataDependenceOptions.FULL, ControlDependenceOptions.FULL);

View File

@ -87,6 +87,9 @@ import com.ibm.wala.util.strings.Atom;
*/
public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
public Map<CAstEntity, IClass> fTypeMap = HashMapFactory.make();
/** BEGIN Custom change: Common superclass is optional */
private final boolean existsCommonSuperclass; // extension to deal with X10 that has no common superclass
/** END Custom change: Common superclass is optional */
/**
* WALA representation of a Java class residing in a source file
@ -135,7 +138,10 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
// The following test allows the root class to reside in source; without
// it, the assertion requires all classes represented by a JavaClass to
// have a superclass.
if (!getName().equals(JavaSourceLoaderImpl.this.getLanguage().getRootType().getName()) && !excludedSupertype) {
/** BEGIN Custom change: Common superclass is optional */
// Is no longer true in new X10 - no common object super class
if (existsCommonSuperclass && !getName().equals(JavaSourceLoaderImpl.this.getLanguage().getRootType().getName()) && !excludedSupertype) {
/** END Custom change: Common superclass is optional */
Assertions.UNREACHABLE("Cannot find super class for " + this + " in " + superTypeNames);
}
@ -477,9 +483,18 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
return result;
}
public JavaSourceLoaderImpl(ClassLoaderReference loaderRef, IClassLoader parent, SetOfClasses exclusions, IClassHierarchy cha) throws IOException {
/** BEGIN Custom change: Common superclass is optional */
public JavaSourceLoaderImpl(boolean existsCommonSuperClass, ClassLoaderReference loaderRef, IClassLoader parent,
SetOfClasses exclusions, IClassHierarchy cha) throws IOException {
super(loaderRef, cha.getScope().getArrayClassLoader(), parent, cha.getScope().getExclusions(), cha);
this.existsCommonSuperclass = existsCommonSuperClass;
}
public JavaSourceLoaderImpl(ClassLoaderReference loaderRef, IClassLoader parent, SetOfClasses exclusions, IClassHierarchy cha) throws IOException {
// standard case: we have a common super class
this(true, loaderRef, parent, exclusions, cha);
}
/** END Custom change: Common superclass is optional */
public IClassHierarchy getClassHierarchy() {
return cha;
@ -491,11 +506,19 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
}
protected abstract SourceModuleTranslator getTranslator();
/** BEGIN Custom change: Optional deletion of fTypeMap */
public static volatile boolean deleteTypeMapAfterInit = true;
/** END Custom change: Optional deletion of fTypeMap */
@Override
public void init(List<Module> modules) throws IOException {
super.init(modules);
fTypeMap = null;
/** BEGIN Custom change: Optional deletion of fTypeMap */
if (deleteTypeMapAfterInit) {
fTypeMap = null;
}
/** END Custom change: Optional deletion of fTypeMap */
}
public void defineFunction(CAstEntity n, IClass owner, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock,
@ -541,107 +564,107 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
public static class InstructionFactory extends JavaInstructionFactory implements AstJavaInstructionFactory {
@Override
public com.ibm.wala.cast.java.ssa.EnclosingObjectReference EnclosingObjectReference(int lval, TypeReference type) {
return new EnclosingObjectReference(lval, type);
public com.ibm.wala.cast.java.ssa.EnclosingObjectReference EnclosingObjectReference(int iindex, int lval, TypeReference type) {
return new EnclosingObjectReference(iindex, lval, type);
}
@Override
public AstJavaNewEnclosingInstruction JavaNewEnclosingInstruction(int result, NewSiteReference site, int enclosing) {
return new AstJavaNewEnclosingInstruction(result, site, enclosing);
public AstJavaNewEnclosingInstruction JavaNewEnclosingInstruction(int iindex, int result, NewSiteReference site, int enclosing) {
return new AstJavaNewEnclosingInstruction(iindex, result, site, enclosing);
}
@Override
public AstJavaInvokeInstruction JavaInvokeInstruction(int result[], int[] params, int exception, CallSiteReference site) {
return result == null ? new AstJavaInvokeInstruction(params, exception, site) : new AstJavaInvokeInstruction(result[0],
public AstJavaInvokeInstruction JavaInvokeInstruction(int iindex, int result[], int[] params, int exception, CallSiteReference site) {
return result == null ? new AstJavaInvokeInstruction(iindex, params, exception, site) : new AstJavaInvokeInstruction(iindex, result[0],
params, exception, site);
}
@Override
public AstAssertInstruction AssertInstruction(int value, boolean fromSpecification) {
return new AstAssertInstruction(value, fromSpecification);
public AstAssertInstruction AssertInstruction(int iindex, int value, boolean fromSpecification) {
return new AstAssertInstruction(iindex, value, fromSpecification);
}
@Override
public com.ibm.wala.cast.ir.ssa.AssignInstruction AssignInstruction(int result, int val) {
return new AssignInstruction(result, val);
public com.ibm.wala.cast.ir.ssa.AssignInstruction AssignInstruction(int iindex, int result, int val) {
return new AssignInstruction(iindex, result, val);
}
@Override
public com.ibm.wala.cast.ir.ssa.EachElementGetInstruction EachElementGetInstruction(int value, int objectRef) {
public com.ibm.wala.cast.ir.ssa.EachElementGetInstruction EachElementGetInstruction(int iindex, int value, int objectRef) {
throw new UnsupportedOperationException();
}
@Override
public com.ibm.wala.cast.ir.ssa.EachElementHasNextInstruction EachElementHasNextInstruction(int value, int objectRef) {
public com.ibm.wala.cast.ir.ssa.EachElementHasNextInstruction EachElementHasNextInstruction(int iindex, int value, int objectRef) {
throw new UnsupportedOperationException();
}
@Override
public AstEchoInstruction EchoInstruction(int[] rvals) {
public AstEchoInstruction EchoInstruction(int iindex, int[] rvals) {
throw new UnsupportedOperationException();
}
@Override
public AstGlobalRead GlobalRead(int lhs, FieldReference global) {
public AstGlobalRead GlobalRead(int iindex, int lhs, FieldReference global) {
throw new UnsupportedOperationException();
}
@Override
public AstGlobalWrite GlobalWrite(FieldReference global, int rhs) {
public AstGlobalWrite GlobalWrite(int iindex, FieldReference global, int rhs) {
throw new UnsupportedOperationException();
}
@Override
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, int fieldVal, FieldReference fieldRef) {
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, int fieldVal, FieldReference fieldRef) {
throw new UnsupportedOperationException();
}
@Override
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, FieldReference fieldRef) {
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, FieldReference fieldRef) {
throw new UnsupportedOperationException();
}
@Override
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, int fieldVal) {
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, int fieldVal) {
throw new UnsupportedOperationException();
}
@Override
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval) {
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval) {
throw new UnsupportedOperationException();
}
@Override
public AstLexicalRead LexicalRead(Access[] accesses) {
return new AstLexicalRead(accesses);
public AstLexicalRead LexicalRead(int iindex, Access[] accesses) {
return new AstLexicalRead(iindex, accesses);
}
@Override
public AstLexicalRead LexicalRead(Access access) {
return new AstLexicalRead(access);
public AstLexicalRead LexicalRead(int iindex, Access access) {
return new AstLexicalRead(iindex, access);
}
@Override
public AstLexicalRead LexicalRead(int lhs, String definer, String globalName, TypeReference type) {
return new AstLexicalRead(lhs, definer, globalName, type);
public AstLexicalRead LexicalRead(int iindex, int lhs, String definer, String globalName, TypeReference type) {
return new AstLexicalRead(iindex, lhs, definer, globalName, type);
}
@Override
public AstLexicalWrite LexicalWrite(Access[] accesses) {
return new AstLexicalWrite(accesses);
public AstLexicalWrite LexicalWrite(int iindex, Access[] accesses) {
return new AstLexicalWrite(iindex, accesses);
}
@Override
public AstLexicalWrite LexicalWrite(Access access) {
return new AstLexicalWrite(access);
public AstLexicalWrite LexicalWrite(int iindex, Access access) {
return new AstLexicalWrite(iindex, access);
}
@Override
public AstLexicalWrite LexicalWrite(String definer, String globalName, TypeReference type, int rhs) {
return new AstLexicalWrite(definer, globalName, type, rhs);
public AstLexicalWrite LexicalWrite(int iindex, String definer, String globalName, TypeReference type, int rhs) {
return new AstLexicalWrite(iindex, definer, globalName, type, rhs);
}
public SSAThrowInstruction NonExceptingThrowInstruction(int exception) {
public SSAThrowInstruction NonExceptingThrowInstruction(int iindex, int exception) {
throw new UnsupportedOperationException();
}
}

View File

@ -17,10 +17,10 @@ import com.ibm.wala.types.TypeReference;
public interface AstJavaInstructionFactory extends AstInstructionFactory {
AstJavaInvokeInstruction JavaInvokeInstruction(int result[], int[] params, int exception, CallSiteReference site);
AstJavaInvokeInstruction JavaInvokeInstruction(int iindex, int result[], int[] params, int exception, CallSiteReference site);
EnclosingObjectReference EnclosingObjectReference(int lval, TypeReference type);
EnclosingObjectReference EnclosingObjectReference(int iindex, int lval, TypeReference type);
AstJavaNewEnclosingInstruction JavaNewEnclosingInstruction(int result, NewSiteReference site, int enclosing);
AstJavaNewEnclosingInstruction JavaNewEnclosingInstruction(int iindex, int result, NewSiteReference site, int enclosing);
}

View File

@ -22,25 +22,25 @@ import com.ibm.wala.types.TypeReference;
public class AstJavaInvokeInstruction extends FixedParametersInvokeInstruction {
protected AstJavaInvokeInstruction(int results[], int[] params, int exception, CallSiteReference site) {
super(results, params, exception, site);
protected AstJavaInvokeInstruction(int iindex, int results[], int[] params, int exception, CallSiteReference site) {
super(iindex, results, params, exception, site);
}
public AstJavaInvokeInstruction(int result, int[] params, int exception, CallSiteReference site) {
this(new int[] { result }, params, exception, site);
public AstJavaInvokeInstruction(int iindex, int result, int[] params, int exception, CallSiteReference site) {
this(iindex, new int[] { result }, params, exception, site);
SSAInvokeInstruction.assertParamsKosher(result, params, site);
}
/**
* Constructor InvokeInstruction. This case for void return values
*/
public AstJavaInvokeInstruction(int[] params, int exception, CallSiteReference site) {
this(null, params, exception, site);
public AstJavaInvokeInstruction(int iindex, int[] params, int exception, CallSiteReference site) {
this(iindex, null, params, exception, site);
}
@Override
protected SSAInstruction copyInstruction(SSAInstructionFactory insts, int results[], int[] params, int exception) {
return ((AstJavaInstructionFactory) insts).JavaInvokeInstruction(results, params, exception, getCallSite());
return ((AstJavaInstructionFactory) insts).JavaInvokeInstruction(iindex, results, params, exception, getCallSite());
}
@Override

View File

@ -35,8 +35,8 @@ public class AstJavaNewEnclosingInstruction extends SSANewInstruction {
return enclosing;
}
public AstJavaNewEnclosingInstruction(int result, NewSiteReference site, int enclosing) throws IllegalArgumentException {
super(result, site);
public AstJavaNewEnclosingInstruction(int iindex, int result, NewSiteReference site, int enclosing) throws IllegalArgumentException {
super(iindex, result, site);
this.enclosing = enclosing;
}
@ -51,7 +51,7 @@ public class AstJavaNewEnclosingInstruction extends SSANewInstruction {
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((AstJavaInstructionFactory)insts).JavaNewEnclosingInstruction(defs==null? getDef(0): defs[0], getNewSite(), uses==null? enclosing: uses[0]);
return ((AstJavaInstructionFactory)insts).JavaNewEnclosingInstruction(iindex, defs==null? getDef(0): defs[0], getNewSite(), uses==null? enclosing: uses[0]);
}
@Override

View File

@ -30,7 +30,8 @@ public class EnclosingObjectReference extends SSAInstruction {
private final int lval;
public EnclosingObjectReference(int lval, TypeReference type) {
public EnclosingObjectReference(int iindex, int lval, TypeReference type) {
super(iindex);
this.lval = lval;
this.type = type;
}
@ -63,7 +64,7 @@ public class EnclosingObjectReference extends SSAInstruction {
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((AstJavaInstructionFactory) insts).EnclosingObjectReference(defs == null ? lval : defs[0], type);
return ((AstJavaInstructionFactory) insts).EnclosingObjectReference(iindex, defs == null ? lval : defs[0], type);
}
@Override

View File

@ -98,13 +98,13 @@ public class JavaCAst2IRTranslator extends AstTranslator {
@Override
protected void doThrow(WalkContext context, int exception) {
context.cfg().addInstruction(insts.ThrowInstruction(exception));
context.cfg().addInstruction(insts.ThrowInstruction(context.cfg().getCurrentInstruction(), exception));
}
@Override
public void doArrayRead(WalkContext context, int result, int arrayValue, CAstNode arrayRefNode, int[] dimValues) {
TypeReference arrayTypeRef = (TypeReference) arrayRefNode.getChild(1).getValue();
context.cfg().addInstruction(insts.ArrayLoadInstruction(result, arrayValue, dimValues[0], arrayTypeRef));
context.cfg().addInstruction(insts.ArrayLoadInstruction(context.cfg().getCurrentInstruction(), result, arrayValue, dimValues[0], arrayTypeRef));
processExceptions(arrayRefNode, context);
}
@ -113,7 +113,7 @@ public class JavaCAst2IRTranslator extends AstTranslator {
TypeReference arrayTypeRef = arrayRefNode.getKind() == CAstNode.ARRAY_LITERAL ? ((TypeReference) arrayRefNode.getChild(0)
.getChild(0).getValue()).getArrayElementType() : (TypeReference) arrayRefNode.getChild(1).getValue();
context.cfg().addInstruction(insts.ArrayStoreInstruction(arrayValue, dimValues[0], rval, arrayTypeRef));
context.cfg().addInstruction(insts.ArrayStoreInstruction(context.cfg().getCurrentInstruction(), arrayValue, dimValues[0], rval, arrayTypeRef));
processExceptions(arrayRefNode, context);
}
@ -125,9 +125,9 @@ public class JavaCAst2IRTranslator extends AstTranslator {
if (receiver == -1) { // a static field: AstTranslator.getValue() produces
// -1 for null, we hope
context.cfg().addInstruction(insts.GetInstruction(result, fieldRef));
context.cfg().addInstruction(insts.GetInstruction(context.cfg().getCurrentInstruction(), result, fieldRef));
} else {
context.cfg().addInstruction(insts.GetInstruction(result, receiver, fieldRef));
context.cfg().addInstruction(insts.GetInstruction(context.cfg().getCurrentInstruction(), result, receiver, fieldRef));
processExceptions(parent, context);
}
}
@ -138,9 +138,9 @@ public class JavaCAst2IRTranslator extends AstTranslator {
if (receiver == -1) { // a static field: AstTranslator.getValue() produces
// -1 for null, we hope
context.cfg().addInstruction(insts.PutInstruction(rval, fieldRef));
context.cfg().addInstruction(insts.PutInstruction(context.cfg().getCurrentInstruction(), rval, fieldRef));
} else {
context.cfg().addInstruction(insts.PutInstruction(receiver, rval, fieldRef));
context.cfg().addInstruction(insts.PutInstruction(context.cfg().getCurrentInstruction(), receiver, rval, fieldRef));
processExceptions(parent, context);
}
}
@ -158,10 +158,10 @@ public class JavaCAst2IRTranslator extends AstTranslator {
NewSiteReference site = NewSiteReference.make(context.cfg().getCurrentInstruction(), typeRef);
if (newNode.getKind() == CAstNode.NEW_ENCLOSING) {
context.cfg().addInstruction(new AstJavaNewEnclosingInstruction(result, site, arguments[0]));
context.cfg().addInstruction(new AstJavaNewEnclosingInstruction(context.cfg().getCurrentInstruction(), result, site, arguments[0]));
} else {
context.cfg().addInstruction(
(arguments == null) ? insts.NewInstruction(result, site) : insts.NewInstruction(result, site, arguments));
(arguments == null) ? insts.NewInstruction(context.cfg().getCurrentInstruction(), result, site) : insts.NewInstruction(context.cfg().getCurrentInstruction(), result, site, arguments));
}
processExceptions(newNode, context);
}
@ -197,9 +197,9 @@ public class JavaCAst2IRTranslator extends AstTranslator {
CallSiteReference realSiteRef = CallSiteReference.make(pc, dummySiteRef.getDeclaredTarget(), dummySiteRef.getInvocationCode());
if (realSiteRef.getDeclaredTarget().getReturnType().equals(TypeReference.Void))
context.cfg().addInstruction(new AstJavaInvokeInstruction(realArgs, exception, realSiteRef));
context.cfg().addInstruction(new AstJavaInvokeInstruction(context.cfg().getCurrentInstruction(), realArgs, exception, realSiteRef));
else
context.cfg().addInstruction(new AstJavaInvokeInstruction(result, realArgs, exception, realSiteRef));
context.cfg().addInstruction(new AstJavaInvokeInstruction(context.cfg().getCurrentInstruction(), result, realArgs, exception, realSiteRef));
processExceptions(call, context);
}
@ -330,7 +330,7 @@ public class JavaCAst2IRTranslator extends AstTranslator {
} else {
int result = c.currentScope().allocateTempValue();
c.setValue(n, result);
c.cfg().addInstruction(new EnclosingObjectReference(result, (TypeReference) n.getChild(0).getValue()));
c.cfg().addInstruction(new EnclosingObjectReference(c.cfg().getCurrentInstruction(), result, (TypeReference) n.getChild(0).getValue()));
}
}
@ -351,23 +351,24 @@ public class JavaCAst2IRTranslator extends AstTranslator {
TypeReference fromRef = makeType(fromType);
if (toRef.isPrimitiveType()) {
context.cfg().addInstruction(
insts.ConversionInstruction(
context.cfg().addInstruction(
insts.ConversionInstruction(
context.cfg().getCurrentInstruction(),
result,
context.getValue(n.getChild(1)),
fromRef,
toRef,
false));
} else {
context.cfg().addInstruction(
insts.CheckCastInstruction(
context.cfg().getCurrentInstruction(),
result,
context.getValue(n.getChild(1)),
toRef,
true));
processExceptions(n, context);
processExceptions(n, context);
}
}
@ -386,6 +387,7 @@ processExceptions(n, context);
TypeReference ref = makeType( type );
context.cfg().addInstruction(
insts.InstanceofInstruction(
context.cfg().getCurrentInstruction(),
result,
context.getValue(n.getChild(1)),
ref));
@ -395,13 +397,13 @@ processExceptions(n, context);
protected boolean doVisit(CAstNode n, WalkContext wc, CAstVisitor<WalkContext> visitor) {
if (n.getKind() == CAstNode.MONITOR_ENTER) {
visitor.visit(n.getChild(0), wc, visitor);
wc.cfg().addInstruction(insts.MonitorInstruction(wc.getValue(n.getChild(0)), true));
wc.cfg().addInstruction(insts.MonitorInstruction(wc.cfg().getCurrentInstruction(), wc.getValue(n.getChild(0)), true));
processExceptions(n, wc);
return true;
} else if (n.getKind() == CAstNode.MONITOR_EXIT) {
visitor.visit(n.getChild(0), wc, visitor);
wc.cfg().addInstruction(insts.MonitorInstruction(wc.getValue(n.getChild(0)), false));
wc.cfg().addInstruction(insts.MonitorInstruction(wc.cfg().getCurrentInstruction(), wc.getValue(n.getChild(0)), false));
processExceptions(n, wc);
return true;
} else {

View File

@ -3,7 +3,7 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="tests"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="lib" path="lib/htmlparser-1.4.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -12,6 +12,6 @@ Require-Bundle: com.ibm.wala.cast.js;bundle-version="1.0.0",
com.ibm.wala.core.tests;bundle-version="1.1.3",
com.ibm.wala.core;bundle-version="1.1.3",
org.junit;bundle-version="4.8.1"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ClassPath: .,
lib/htmlparser-1.4.jar

View File

@ -13,7 +13,7 @@ Require-Bundle: com.ibm.wala.cast.js.rhino;bundle-version="1.0.0",
com.ibm.wala.core.tests;bundle-version="1.1.3",
com.ibm.wala.cast.js.test.data;bundle-version="1.3.4",
org.junit;bundle-version="4.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
Export-Package: com.ibm.wala.cast.js.rhino.callgraph.fieldbased.test,
com.ibm.wala.cast.js.rhino.test,

View File

@ -28,6 +28,7 @@ import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.CallGraph;
import com.ibm.wala.ipa.callgraph.CallGraphBuilderCancelException;
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
import com.ibm.wala.ipa.cha.ClassHierarchyException;
import com.ibm.wala.util.NullProgressMonitor;
@ -59,7 +60,7 @@ public class HTMLCGBuilder {
public JSCFABuilder builder;
/** pointer analysis results; partial if {@link #construction_time} is {@code -1} */
public PointerAnalysis pa;
public PointerAnalysis<InstanceKey> pa;
/** call graph; partial if {@link #construction_time} is {@code -1} */
public CallGraph cg;

View File

@ -18,6 +18,7 @@ import org.junit.Test;
import com.ibm.wala.cast.js.ipa.callgraph.JSCFABuilder;
import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory;
import com.ibm.wala.cast.js.util.Util;
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
import com.ibm.wala.ipa.callgraph.propagation.PropagationCallGraphBuilder;
import com.ibm.wala.util.CancelException;
@ -39,7 +40,7 @@ public class TestSimpleCallGraphShapeRhino extends TestSimpleCallGraphShape {
public void test214631() throws IOException, IllegalArgumentException, CancelException, WalaException {
JSCFABuilder b = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "214631.js");
b.makeCallGraph(b.getOptions());
PointerAnalysis PA = b.getPointerAnalysis();
PointerAnalysis<InstanceKey> PA = b.getPointerAnalysis();
// just make sure this does not crash
}

View File

@ -31,6 +31,7 @@ import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory;
import com.ibm.wala.classLoader.SourceFileModule;
import com.ibm.wala.classLoader.SourceModule;
import com.ibm.wala.ipa.callgraph.CallGraph;
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
import com.ibm.wala.ipa.cha.ClassHierarchyException;
import com.ibm.wala.util.CancelException;
@ -57,7 +58,7 @@ public class JsViewerDriver extends JSCallGraphBuilderUtil {
builder.setBaseURL(url);
CallGraph cg = builder.makeCallGraph(builder.getOptions());
PointerAnalysis pa = builder.getPointerAnalysis();
PointerAnalysis<InstanceKey> pa = builder.getPointerAnalysis();
new JsViewer(cg, pa);
}

View File

@ -2,7 +2,7 @@
<classpath>
<classpathentry kind="src" path="source"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="lib" path="lib/rhino-1.7R3.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -9,7 +9,7 @@ Require-Bundle: org.eclipse.core.runtime,
com.ibm.wala.cast;bundle-version="1.0.0",
com.ibm.wala.cast.js;bundle-version="1.0.0",
com.ibm.wala.core;bundle-version="1.1.3"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
Export-Package: com.ibm.wala.cast.js.translator,
com.ibm.wala.js.rhino,

View File

@ -8,4 +8,4 @@ Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: examples-src/
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-RequiredExecutionEnvironment: JavaSE-1.7

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="harness-src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -15,4 +15,4 @@ Require-Bundle: com.ibm.wala.cast.js,
org.junit;bundle-version="4.0.0"
Bundle-ActivationPolicy: lazy
Export-Package: com.ibm.wala.cast.js.test
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-RequiredExecutionEnvironment: JavaSE-1.7

View File

@ -7,6 +7,9 @@
<listEntry value="1"/>
</listAttribute>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[run]" value="org.eclipse.jdt.junit.launchconfig"/>
</mapAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>

View File

@ -4,7 +4,6 @@
<classpathentry kind="src" path="dat"/>
<classpathentry kind="lib" path="lib/jericho-html-3.2.jar"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="lib" path="lib/commons-io-2.4.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -4,8 +4,7 @@ Bundle-Name: JavaScript Plug-in
Bundle-SymbolicName: com.ibm.wala.cast.js;singleton:=true
Bundle-Version: 1.3.4.qualifier
Bundle-ClassPath: .,
lib/jericho-html-3.2.jar,
lib/commons-io-2.4.jar
lib/jericho-html-3.2.jar
Bundle-Activator: com.ibm.wala.cast.js.JavaScriptPlugin
Bundle-Vendor: IBM
Export-Package: .,
@ -38,4 +37,4 @@ Require-Bundle: com.ibm.wala.cast,
org.eclipse.core.runtime;bundle-version="3.4.0",
org.apache.commons.logging
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-RequiredExecutionEnvironment: JavaSE-1.7

View File

@ -1,7 +1,6 @@
bin.includes = .,\
META-INF/,\
lib/,\
lib/commons-io-2.4.jar,\
lib/jericho-html-3.2.jar
source.. = source/,\
dat/

View File

@ -36,10 +36,6 @@
<available file="${plugin.destination}/lib/jericho-html-3.2.jar" property="jericho.present"/>
</target>
<target name="CommonsIoPresent" depends="init">
<available file="${plugin.destination}/lib/commons-io-2.4.jar" property="commons.io.present"/>
</target>
<target name="fetchJericho" depends="JerichoPresent" unless="jericho.present">
<delete dir="${temp.folder}"/>
<mkdir dir="${temp.folder}"/>
@ -47,19 +43,9 @@
<unzip src="${temp.folder}/jericho-html-3.2.zip" dest="${temp.folder}"/>
<copy file="${temp.folder}/jericho-html-3.2/dist/jericho-html-3.2.jar" tofile="${plugin.destination}/lib/jericho-html-3.2.jar" />
<delete dir="${temp.folder}"/>
</target>
</target>
<target name="fetchCommonsIo" depends="CommonsIoPresent" unless="commons.io.present">
<delete dir="${temp.folder}"/>
<mkdir dir="${temp.folder}"/>
<get src="http://apache.petsads.us/commons/io/binaries/commons-io-2.4-bin.zip" dest="${temp.folder}/commons-io-2.4.zip"/>
<unzip src="${temp.folder}/commons-io-2.4.zip" dest="${temp.folder}"/>
<copy file="${temp.folder}/commons-io-2.4/commons-io-2.4.jar" tofile="${plugin.destination}/lib/commons-io-2.4.jar" />
<delete dir="${temp.folder}"/>
</target>
<target name="getJars" depends="fetchJericho,fetchCommonsIo" />
<target name="getJars" depends="fetchJericho" />
<target name="init" depends="properties">
<condition property="pluginTemp" value="${buildTempFolder}/plugins">

View File

@ -22,13 +22,6 @@
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
<type>jar</type>
<overWrite>false</overWrite>
</artifactItem>
<artifactItem>
<groupId>net.htmlparser.jericho</groupId>
<artifactId>jericho-html</artifactId>

View File

@ -104,7 +104,7 @@ public abstract class FieldBasedCallGraphBuilder {
/**
* Main entry point: builds a flow graph, then extracts a call graph and returns it.
*/
public Pair<JSCallGraph,PointerAnalysis> buildCallGraph(Iterable<Entrypoint> eps, IProgressMonitor monitor) throws CancelException {
public Pair<JSCallGraph,PointerAnalysis<FuncVertex>> buildCallGraph(Iterable<Entrypoint> eps, IProgressMonitor monitor) throws CancelException {
long fgBegin, fgEnd, cgBegin, cgEnd;
if(LOG_TIMINGS) fgBegin = System.currentTimeMillis();

View File

@ -141,11 +141,11 @@ public class FlowGraph implements Iterable<Vertex> {
return graph.iterator();
}
public PointerAnalysis getPointerAnalysis(final IProgressMonitor monitor) {
return new PointerAnalysis() {
public PointerAnalysis<FuncVertex> getPointerAnalysis(final IProgressMonitor monitor) {
return new PointerAnalysis<FuncVertex>() {
@Override
public OrdinalSet<? extends InstanceKey> getPointsToSet(PointerKey key) {
public OrdinalSet<FuncVertex> getPointsToSet(PointerKey key) {
if (key instanceof LocalPointerKey) {
CGNode node = ((LocalPointerKey)key).getNode();
FuncVertex fn = factory.makeFuncVertex(node.getMethod().getDeclaringClass());

View File

@ -65,7 +65,7 @@ public class WebPageLoaderFactory extends JavaScriptLoaderFactory {
context.currentScope().getConstantValue(name);
doIsFieldDefined(context, isDefined, windowVal, Ast.makeConstant(name));
context.cfg().addInstruction(
insts.ConditionalBranchInstruction(
insts.ConditionalBranchInstruction(context.cfg().getCurrentInstruction(),
translateConditionOpcode(CAstOperator.OP_NE),
null,
isDefined,
@ -75,16 +75,16 @@ public class WebPageLoaderFactory extends JavaScriptLoaderFactory {
// field lookup of value
context.cfg().newBlock(true);
context.cfg().addInstruction(((JSInstructionFactory) insts).GetInstruction(result, windowVal, name));
context.cfg().addInstruction(((JSInstructionFactory) insts).GetInstruction(context.cfg().getCurrentInstruction(), result, windowVal, name));
context.cfg().newBlock(true);
context.cfg().addInstruction(insts.GotoInstruction(-1));
context.cfg().addInstruction(insts.GotoInstruction(context.cfg().getCurrentInstruction(), -1));
PreBasicBlock trueB = context.cfg().getCurrentBlock();
// read global
context.cfg().newBlock(false);
PreBasicBlock falseB = context.cfg().getCurrentBlock();
int sr = super.doGlobalRead(n, context, name, type);
context.cfg().addInstruction(((JSInstructionFactory) insts).AssignInstruction(result, sr));
context.cfg().addInstruction(((JSInstructionFactory) insts).AssignInstruction(context.cfg().getCurrentInstruction(), result, sr));
// end
context.cfg().newBlock(true);
@ -104,7 +104,7 @@ public class WebPageLoaderFactory extends JavaScriptLoaderFactory {
if (isNestedWithinScriptBody(context) && ! "$$undefined".equals(nm) && !"window".equals(nm) && !nm.startsWith("$$destructure")) {
int windowVal = super.doLocalRead(context, "this", type);
context.currentScope().getConstantValue(nm);
context.cfg().addInstruction(((JSInstructionFactory) insts).PutInstruction(windowVal, rval, nm));
context.cfg().addInstruction(((JSInstructionFactory) insts).PutInstruction(context.cfg().getCurrentInstruction(), windowVal, rval, nm));
}
super.doLocalWrite(context, nm, type, rval);
@ -118,7 +118,7 @@ public class WebPageLoaderFactory extends JavaScriptLoaderFactory {
int fnValue = context.currentScope().lookup(fn.getName()).valueNumber();
assert fnValue > 0;
int windowVal = super.doLocalRead(context, "this", JavaScriptTypes.Function);
context.cfg().addInstruction(((JSInstructionFactory) insts).PutInstruction(windowVal, fnValue, fn.getName()));
context.cfg().addInstruction(((JSInstructionFactory) insts).PutInstruction(context.cfg().getCurrentInstruction(), windowVal, fnValue, fn.getName()));
}
}
};

View File

@ -60,7 +60,7 @@ public class JSCallGraph extends AstCallGraph {
if (cha.isSubclassOf(cha.lookupClass(T), cha.lookupClass(JavaScriptTypes.Root))) {
int instance = nextLocal++;
NewSiteReference ref = NewSiteReference.make(statements.size(), T);
SSANewInstruction result = getDeclaringClass().getClassLoader().getInstructionFactory().NewInstruction(instance, ref);
SSANewInstruction result = getDeclaringClass().getClassLoader().getInstructionFactory().NewInstruction(statements.size(), instance, ref);
statements.add(result);
return result;
} else {
@ -72,7 +72,7 @@ public class JSCallGraph extends AstCallGraph {
public SSAAbstractInvokeInstruction addDirectCall(int function, int[] params, CallSiteReference site) {
CallSiteReference newSite = new JSCallSiteReference(statements.size());
JavaScriptInvoke s = new JavaScriptInvoke(function, nextLocal++, params, nextLocal++, newSite);
JavaScriptInvoke s = new JavaScriptInvoke(statements.size(), function, nextLocal++, params, nextLocal++, newSite);
statements.add(s);
return s;

View File

@ -381,7 +381,7 @@ public class JSSSAPropagationCallGraphBuilder extends AstSSAPropagationCallGraph
protected PropagationSystem makeSystem(AnalysisOptions options) {
return new PropagationSystem(callGraph, pointerKeyFactory, instanceKeyFactory) {
@Override
public PointerAnalysis makePointerAnalysis(PropagationCallGraphBuilder builder) {
public PointerAnalysis<InstanceKey> makePointerAnalysis(PropagationCallGraphBuilder builder) {
return new JSPointerAnalysisImpl(builder, cg, pointsToMap, instanceKeys, pointerKeyFactory, instanceKeyFactory);
}
};

View File

@ -110,10 +110,10 @@ public class JavaScriptFunctionApplyContextInterpreter extends AstContextInsensi
// function being invoked is in v2
int resultVal = curValNum++;
int excVal = curValNum++;
S.addStatement(insts.Invoke(2, resultVal, paramsToPassToInvoked, excVal, cs));
S.addStatement(insts.Invoke(S.getNumberOfStatements(), 2, resultVal, paramsToPassToInvoked, excVal, cs));
S.getNextProgramCounter();
S.addStatement(insts.ReturnInstruction(resultVal, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), resultVal, false));
S.getNextProgramCounter();
JavaScriptSummarizedFunction t = new JavaScriptSummarizedFunction(ref, S, declaringClass);
@ -125,11 +125,11 @@ public class JavaScriptFunctionApplyContextInterpreter extends AstContextInsensi
// read an arbitrary property name via EachElementGet
int curValNum = nargs + 2;
int eachElementGetResult = curValNum++;
S.addStatement(insts.EachElementGetInstruction(eachElementGetResult, 4));
S.addStatement(insts.EachElementGetInstruction(S.getNumberOfStatements(), eachElementGetResult, 4));
S.getNextProgramCounter();
// read value from the arbitrary property name
int propertyReadResult = curValNum++;
S.addStatement(insts.PropertyRead(propertyReadResult, 4, eachElementGetResult));
S.addStatement(insts.PropertyRead(S.getNumberOfStatements(), propertyReadResult, 4, eachElementGetResult));
S.getNextProgramCounter();
for (int i = 1; i < paramsToPassToInvoked.length; i++) {
paramsToPassToInvoked[i] = propertyReadResult;
@ -150,7 +150,7 @@ public class JavaScriptFunctionApplyContextInterpreter extends AstContextInsensi
S.addConstant(constVN, new ConstantValue(i-1));
int propertyReadResult = curValNum++;
// 4 is position of arguments array
S.addStatement(insts.PropertyRead(propertyReadResult, 4, constVN));
S.addStatement(insts.PropertyRead(S.getNumberOfStatements(), propertyReadResult, 4, constVN));
S.getNextProgramCounter();
paramsToPassToInvoked[i] = propertyReadResult;
}
@ -173,10 +173,10 @@ public class JavaScriptFunctionApplyContextInterpreter extends AstContextInsensi
int[] params = new int[1];
params[0] = 3;
// function being invoked is in v2
S.addStatement(insts.Invoke(2, resultVal, params, resultVal + 1, cs));
S.addStatement(insts.Invoke(S.getNumberOfStatements(), 2, resultVal, params, resultVal + 1, cs));
S.getNextProgramCounter();
S.addStatement(insts.ReturnInstruction(resultVal, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), resultVal, false));
S.getNextProgramCounter();
JavaScriptSummarizedFunction t = new JavaScriptSummarizedFunction(ref, S, declaringClass);

View File

@ -162,10 +162,10 @@ public class JavaScriptFunctionDotCallTargetSelector implements MethodTargetSele
params[i] = i + 3;
}
// function being invoked is in v2
S.addStatement(insts.Invoke(2, resultVal, params, resultVal + 1, cs));
S.addStatement(insts.Invoke(S.getNumberOfStatements(), 2, resultVal, params, resultVal + 1, cs));
S.getNextProgramCounter();
S.addStatement(insts.ReturnInstruction(resultVal, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), resultVal, false));
S.getNextProgramCounter();
JavaScriptSummarizedFunction t = new JavaScriptSummarizedFunction(ref, S, receiver);

View File

@ -56,7 +56,7 @@ public class LoadFileTargetSelector implements MethodTargetSelector {
Set<String> names = new HashSet<String>();
SSAInstruction call = caller.getIR().getInstructions()[caller.getIR().getCallInstructionIndices(site).intIterator().next()];
LocalPointerKey fileNameV = new LocalPointerKey(caller, call.getUse(1));
OrdinalSet<? extends InstanceKey> ptrs = builder.getPointerAnalysis().getPointsToSet(fileNameV);
OrdinalSet<InstanceKey> ptrs = builder.getPointerAnalysis().getPointsToSet(fileNameV);
for(InstanceKey k : ptrs) {
if (k instanceof ConstantKey) {
Object v = ((ConstantKey)k).getValue();

View File

@ -1,3 +1,14 @@
/******************************************************************************
* Copyright (c) 2002 - 2014 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.js.ipa.modref;
import java.util.Collection;
@ -25,7 +36,7 @@ public class JavaScriptModRef extends AstModRef {
protected static class JavaScriptRefVisitor extends AstRefVisitor implements JSInstructionVisitor {
protected JavaScriptRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis pa, ExtendedHeapModel h) {
protected JavaScriptRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<InstanceKey> pa, ExtendedHeapModel h) {
super(n, result, pa, (AstHeapModel)h);
}
@ -88,13 +99,13 @@ public class JavaScriptModRef extends AstModRef {
}
@Override
protected RefVisitor makeRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis pa, ExtendedHeapModel h) {
protected RefVisitor makeRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<InstanceKey> pa, ExtendedHeapModel h) {
return new JavaScriptRefVisitor(n, result, pa, h);
}
protected static class JavaScriptModVisitor extends AstModVisitor implements JSInstructionVisitor {
protected JavaScriptModVisitor(CGNode n, Collection<PointerKey> result, ExtendedHeapModel h, PointerAnalysis pa) {
protected JavaScriptModVisitor(CGNode n, Collection<PointerKey> result, ExtendedHeapModel h, PointerAnalysis<InstanceKey> pa) {
super(n, result, (AstHeapModel)h, pa);
}
@ -157,7 +168,7 @@ public class JavaScriptModRef extends AstModRef {
}
@Override
protected ModVisitor makeModVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis pa, ExtendedHeapModel h, boolean ignoreAllocHeapDefs) {
protected ModVisitor makeModVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<InstanceKey> pa, ExtendedHeapModel h, boolean ignoreAllocHeapDefs) {
return new JavaScriptModVisitor(n, result, h, pa);
}
}

View File

@ -1,3 +1,14 @@
/******************************************************************************
* Copyright (c) 2002 - 2014 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.js.ipa.summaries;
import java.io.File;
@ -75,20 +86,20 @@ public class JavaScriptConstructorFunctions {
MethodReference ref = JavaScriptMethods.makeCtorReference(cls.getReference());
JavaScriptSummary S = new JavaScriptSummary(ref, 1);
S.addStatement(insts.GetInstruction(4, 1, "prototype"));
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 4, 1, "prototype"));
S.getNextProgramCounter();
S.addStatement(insts.NewInstruction(5, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference())));
S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 5, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference())));
S.addStatement(insts.SetPrototype(5, 4));
S.addStatement(insts.SetPrototype(S.getNumberOfStatements(), 5, 4));
//S.addStatement(insts.PutInstruction(5, 4, "__proto__"));
S.getNextProgramCounter();
S.addConstant(new Integer(8), new ConstantValue(value));
S.addStatement(insts.PutInstruction(5, 8, "$value"));
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 5, 8, "$value"));
S.getNextProgramCounter();
S.addStatement(insts.ReturnInstruction(5, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
S.getNextProgramCounter();
//S.addConstant(9, new ConstantValue("__proto__"));
@ -101,19 +112,19 @@ public class JavaScriptConstructorFunctions {
MethodReference ref = JavaScriptMethods.makeCtorReference(cls.getReference());
JavaScriptSummary S = new JavaScriptSummary(ref, 2);
S.addStatement(insts.GetInstruction(5, 1, "prototype"));
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 5, 1, "prototype"));
S.getNextProgramCounter();
S.addStatement(insts.NewInstruction(6, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference())));
S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 6, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference())));
S.addStatement(insts.SetPrototype(6, 5));
S.addStatement(insts.SetPrototype(S.getNumberOfStatements(), 6, 5));
//S.addStatement(insts.PutInstruction(6, 5, "__proto__"));
S.getNextProgramCounter();
S.addStatement(insts.PutInstruction(6, 2, "$value"));
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 6, 2, "$value"));
S.getNextProgramCounter();
S.addStatement(insts.ReturnInstruction(6, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 6, false));
S.getNextProgramCounter();
//S.addConstant(7, new ConstantValue("__proto__"));
@ -144,16 +155,16 @@ public class JavaScriptConstructorFunctions {
MethodReference ref = JavaScriptMethods.makeCtorReference(JavaScriptTypes.Object);
JavaScriptSummary S = new JavaScriptSummary(ref, 1);
S.addStatement(insts.GetInstruction(4, 1, "prototype"));
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 4, 1, "prototype"));
S.getNextProgramCounter();
S.addStatement(insts.NewInstruction(5, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Object)));
S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 5, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Object)));
S.addStatement(insts.SetPrototype(5, 4));
S.addStatement(insts.SetPrototype(S.getNumberOfStatements(), 5, 4));
//S.addStatement(insts.PutInstruction(5, 4, "__proto__"));
S.getNextProgramCounter();
S.addStatement(insts.ReturnInstruction(5, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
S.getNextProgramCounter();
//S.addConstant(6, new ConstantValue("__proto__"));
@ -166,7 +177,7 @@ public class JavaScriptConstructorFunctions {
MethodReference ref = JavaScriptMethods.makeCtorReference(JavaScriptTypes.Object);
JavaScriptSummary S = new JavaScriptSummary(ref, 2);
S.addStatement(insts.ReturnInstruction(2, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 2, false));
S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls, cha.lookupClass(JavaScriptTypes.Object));
@ -204,19 +215,19 @@ public class JavaScriptConstructorFunctions {
MethodReference ref = JavaScriptMethods.makeCtorReference(JavaScriptTypes.Array);
JavaScriptSummary S = new JavaScriptSummary(ref, 2);
S.addStatement(insts.GetInstruction(5, 1, "prototype"));
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 5, 1, "prototype"));
S.getNextProgramCounter();
S.addStatement(insts.NewInstruction(6, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Array)));
S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 6, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Array)));
S.addStatement(insts.SetPrototype(6, 5));
S.addStatement(insts.SetPrototype(S.getNumberOfStatements(), 6, 5));
//S.addStatement(insts.PutInstruction(6, 5, "__proto__"));
S.getNextProgramCounter();
S.addStatement(insts.PutInstruction(6, 2, "length"));
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 6, 2, "length"));
S.getNextProgramCounter();
S.addStatement(insts.ReturnInstruction(6, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 6, false));
S.getNextProgramCounter();
//S.addConstant(7, new ConstantValue("__proto__"));
@ -230,29 +241,29 @@ public class JavaScriptConstructorFunctions {
JavaScriptSummary S = new JavaScriptSummary(ref, nargs + 1);
S.addConstant(new Integer(nargs + 3), new ConstantValue("prototype"));
S.addStatement(insts.PropertyRead(nargs + 4, 1, nargs + 3));
S.addStatement(insts.PropertyRead(S.getNumberOfStatements(), nargs + 4, 1, nargs + 3));
S.getNextProgramCounter();
S.addStatement(
insts.NewInstruction(nargs + 5, NewSiteReference.make(S.getNextProgramCounter(),
insts.NewInstruction(S.getNumberOfStatements(), nargs + 5, NewSiteReference.make(S.getNextProgramCounter(),
JavaScriptTypes.Array)));
S.addStatement(insts.SetPrototype(nargs + 5, nargs + 4));
S.addStatement(insts.SetPrototype(S.getNumberOfStatements(), nargs + 5, nargs + 4));
//S.addStatement(insts.PutInstruction(nargs + 5, nargs + 4, "__proto__"));
S.getNextProgramCounter();
S.addConstant(new Integer(nargs + 7), new ConstantValue(nargs));
S.addStatement(insts.PutInstruction(nargs + 5, nargs + 7, "length"));
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), nargs + 5, nargs + 7, "length"));
S.getNextProgramCounter();
int vn = nargs + 9;
for (int i = 0; i < nargs; i++, vn += 2) {
S.addConstant(new Integer(vn), new ConstantValue(i));
S.addStatement(insts.PropertyWrite(nargs + 5, vn, i + 1));
S.addStatement(insts.PropertyWrite(S.getNumberOfStatements(), nargs + 5, vn, i + 1));
S.getNextProgramCounter();
}
S.addStatement(insts.ReturnInstruction(5, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
S.getNextProgramCounter();
//S.addConstant(vn, new ConstantValue("__proto__"));
@ -275,7 +286,7 @@ public class JavaScriptConstructorFunctions {
JavaScriptSummary S = new JavaScriptSummary(ref, 1);
S.addConstant(new Integer(2), new ConstantValue(""));
S.addStatement(insts.ReturnInstruction(2, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 2, false));
S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls, cha.lookupClass(JavaScriptTypes.String));
@ -286,13 +297,13 @@ public class JavaScriptConstructorFunctions {
MethodReference ref = AstMethodReference.fnReference(JavaScriptTypes.String);
JavaScriptSummary S = new JavaScriptSummary(ref, 2);
S.addStatement(insts.GetInstruction(4, 2, "toString"));
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 4, 2, "toString"));
S.getNextProgramCounter();
CallSiteReference cs = new JSCallSiteReference(S.getNextProgramCounter());
S.addStatement(insts.Invoke(4, 5, new int[] { 2 }, 6, cs));
S.addStatement(insts.Invoke(S.getNumberOfStatements(), 4, 5, new int[] { 2 }, 6, cs));
S.addStatement(insts.ReturnInstruction(5, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls, cha.lookupClass(JavaScriptTypes.String));
@ -315,7 +326,7 @@ public class JavaScriptConstructorFunctions {
JavaScriptSummary S = new JavaScriptSummary(ref, 1);
S.addConstant(new Integer(2), new ConstantValue(0.0));
S.addStatement(insts.ReturnInstruction(2, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 2, false));
S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls, cha.lookupClass(JavaScriptTypes.Number));
@ -326,13 +337,13 @@ public class JavaScriptConstructorFunctions {
MethodReference ref = AstMethodReference.fnReference(JavaScriptTypes.Number);
JavaScriptSummary S = new JavaScriptSummary(ref, 2);
S.addStatement(insts.GetInstruction(4, 2, "toNumber"));
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 4, 2, "toNumber"));
S.getNextProgramCounter();
CallSiteReference cs = new JSCallSiteReference(S.getNextProgramCounter());
S.addStatement(insts.Invoke(4, 5, new int[] { 2 }, 6, cs));
S.addStatement(insts.Invoke(S.getNumberOfStatements(), 4, 5, new int[] { 2 }, 6, cs));
S.addStatement(insts.ReturnInstruction(5, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls, cha.lookupClass(JavaScriptTypes.Number));
@ -358,25 +369,25 @@ public class JavaScriptConstructorFunctions {
MethodReference ref = JavaScriptMethods.makeCtorReference(receiver.getReference());
JavaScriptSummary S = new JavaScriptSummary(ref, 1);
S.addStatement(insts.GetInstruction(4, 1, "prototype"));
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 4, 1, "prototype"));
S.getNextProgramCounter();
S.addStatement(insts.NewInstruction(5, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference())));
S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 5, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference())));
S.addStatement(insts.NewInstruction(7, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Object)));
S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 7, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Object)));
S.addStatement(insts.SetPrototype(5, 4));
S.addStatement(insts.SetPrototype(S.getNumberOfStatements(), 5, 4));
//S.addStatement(insts.PutInstruction(5, 4, "__proto__"));
S.getNextProgramCounter();
S.addStatement(insts.PutInstruction(5, 7, "prototype"));
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 5, 7, "prototype"));
S.getNextProgramCounter();
S.addStatement(insts.PutInstruction(7, 5, "constructor"));
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 7, 5, "constructor"));
S.getNextProgramCounter();
// TODO we need to set v7.__proto__ to Object.prototype
S.addStatement(insts.ReturnInstruction(5, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
S.getNextProgramCounter();
//S.addConstant(8, new ConstantValue("__proto__"));
@ -464,15 +475,15 @@ public class JavaScriptConstructorFunctions {
MethodReference ref = JavaScriptMethods.makeCtorReference(cls.getReference());
JavaScriptSummary S = new JavaScriptSummary(ref, nargs + 1);
S.addStatement(insts.GetInstruction(nargs + 4, 1, "prototype"));
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), nargs + 4, 1, "prototype"));
S.getNextProgramCounter();
S.addStatement(
insts.NewInstruction(nargs + 5,
insts.NewInstruction(S.getNumberOfStatements(), nargs + 5,
NewSiteReference.make(S.getNextProgramCounter(),
JavaScriptTypes.Object)));
S.addStatement(insts.SetPrototype(nargs + 5, nargs + 4));
S.addStatement(insts.SetPrototype(S.getNumberOfStatements(), nargs + 5, nargs + 4));
S.getNextProgramCounter();
CallSiteReference cs = new JSCallSiteReference(S.getNextProgramCounter());
@ -480,17 +491,17 @@ public class JavaScriptConstructorFunctions {
args[0] = nargs + 5;
for (int i = 0; i < nargs; i++)
args[i + 1] = i + 2;
S.addStatement(insts.Invoke(1, nargs + 7, args, nargs + 8, cs));
S.addStatement(insts.Invoke(S.getNumberOfStatements(), 1, nargs + 7, args, nargs + 8, cs));
int pc = S.getNextProgramCounter();
S.addConstant(nargs + 9, null);
S.addStatement(insts.ConditionalBranchInstruction(Operator.EQ, JavaScriptTypes.Root, nargs + 7, nargs + 9, pc+2));
S.addStatement(insts.ConditionalBranchInstruction(S.getNumberOfStatements(), Operator.EQ, JavaScriptTypes.Root, nargs + 7, nargs + 9, pc+2));
S.getNextProgramCounter();
S.addStatement(insts.ReturnInstruction(nargs + 7, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), nargs + 7, false));
S.getNextProgramCounter();
S.addStatement(insts.ReturnInstruction(nargs + 5, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), nargs + 5, false));
S.getNextProgramCounter();
return record(key, new JavaScriptConstructor(ref, S, cls, cls));

View File

@ -25,7 +25,7 @@ public class JavaScriptSummary extends MethodSummary {
super(ref);
this.declaredParameters = declaredParameters;
addStatement(
JavaScriptLoader.JS.instructionFactory().NewInstruction(
JavaScriptLoader.JS.instructionFactory().NewInstruction(getNumberOfStatements(),
declaredParameters+1,
NewSiteReference.make(
getNextProgramCounter(),

View File

@ -210,51 +210,51 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
return new JSInstructionFactory() {
@Override
public JavaScriptCheckReference CheckReference(int ref) {
return new JavaScriptCheckReference(ref);
public JavaScriptCheckReference CheckReference(int iindex, int ref) {
return new JavaScriptCheckReference(iindex, ref);
}
@Override
public SSAGetInstruction GetInstruction(int result, int ref, String field) {
return GetInstruction(result, ref,
public SSAGetInstruction GetInstruction(int iindex, int result, int ref, String field) {
return GetInstruction(iindex, result, ref,
FieldReference.findOrCreate(JavaScriptTypes.Root, Atom.findOrCreateUnicodeAtom(field), JavaScriptTypes.Root));
}
@Override
public JavaScriptInstanceOf InstanceOf(int result, int objVal, int typeVal) {
return new JavaScriptInstanceOf(result, objVal, typeVal);
public JavaScriptInstanceOf InstanceOf(int iindex, int result, int objVal, int typeVal) {
return new JavaScriptInstanceOf(iindex, result, objVal, typeVal);
}
@Override
public JavaScriptInvoke Invoke(int function, int[] results, int[] params, int exception, CallSiteReference site) {
return new JavaScriptInvoke(function, results, params, exception, site);
public JavaScriptInvoke Invoke(int iindex, int function, int[] results, int[] params, int exception, CallSiteReference site) {
return new JavaScriptInvoke(iindex, function, results, params, exception, site);
}
@Override
public JavaScriptInvoke Invoke(int function, int result, int[] params, int exception, CallSiteReference site) {
return new JavaScriptInvoke(function, result, params, exception, site);
public JavaScriptInvoke Invoke(int iindex, int function, int result, int[] params, int exception, CallSiteReference site) {
return new JavaScriptInvoke(iindex, function, result, params, exception, site);
}
@Override
public JavaScriptInvoke Invoke(int function, int[] params, int exception, CallSiteReference site) {
return new JavaScriptInvoke(function, params, exception, site);
public JavaScriptInvoke Invoke(int iindex, int function, int[] params, int exception, CallSiteReference site) {
return new JavaScriptInvoke(iindex, function, params, exception, site);
}
@Override
public JavaScriptPropertyRead PropertyRead(int result, int objectRef, int memberRef) {
return new JavaScriptPropertyRead(result, objectRef, memberRef);
public JavaScriptPropertyRead PropertyRead(int iindex, int result, int objectRef, int memberRef) {
return new JavaScriptPropertyRead(iindex, result, objectRef, memberRef);
}
@Override
public JavaScriptPropertyWrite PropertyWrite(int objectRef, int memberRef, int value) {
return new JavaScriptPropertyWrite(objectRef, memberRef, value);
public JavaScriptPropertyWrite PropertyWrite(int iindex, int objectRef, int memberRef, int value) {
return new JavaScriptPropertyWrite(iindex, objectRef, memberRef, value);
}
@Override
public SSAPutInstruction PutInstruction(int ref, int value, String field) {
public SSAPutInstruction PutInstruction(int iindex, int ref, int value, String field) {
try {
byte[] utf8 = field.getBytes("UTF-8");
return PutInstruction(ref, value,
return PutInstruction(iindex, ref, value,
FieldReference.findOrCreate(JavaScriptTypes.Root, Atom.findOrCreate(utf8, 0, utf8.length), JavaScriptTypes.Root));
} catch (UnsupportedEncodingException e) {
Assertions.UNREACHABLE();
@ -263,119 +263,119 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
}
@Override
public JavaScriptTypeOfInstruction TypeOfInstruction(int lval, int object) {
return new JavaScriptTypeOfInstruction(lval, object);
public JavaScriptTypeOfInstruction TypeOfInstruction(int iindex, int lval, int object) {
return new JavaScriptTypeOfInstruction(iindex, lval, object);
}
@Override
public JavaScriptWithRegion WithRegion(int expr, boolean isEnter) {
return new JavaScriptWithRegion(expr, isEnter);
public JavaScriptWithRegion WithRegion(int iindex, int expr, boolean isEnter) {
return new JavaScriptWithRegion(iindex, expr, isEnter);
}
@Override
public AstAssertInstruction AssertInstruction(int value, boolean fromSpecification) {
return new AstAssertInstruction(value, fromSpecification);
public AstAssertInstruction AssertInstruction(int iindex, int value, boolean fromSpecification) {
return new AstAssertInstruction(iindex, value, fromSpecification);
}
@Override
public com.ibm.wala.cast.ir.ssa.AssignInstruction AssignInstruction(int result, int val) {
return new AssignInstruction(result, val);
public com.ibm.wala.cast.ir.ssa.AssignInstruction AssignInstruction(int iindex, int result, int val) {
return new AssignInstruction(iindex, result, val);
}
@Override
public com.ibm.wala.cast.ir.ssa.EachElementGetInstruction EachElementGetInstruction(int value, int objectRef) {
return new EachElementGetInstruction(value, objectRef);
public com.ibm.wala.cast.ir.ssa.EachElementGetInstruction EachElementGetInstruction(int iindex, int value, int objectRef) {
return new EachElementGetInstruction(iindex, value, objectRef);
}
@Override
public com.ibm.wala.cast.ir.ssa.EachElementHasNextInstruction EachElementHasNextInstruction(int value, int objectRef) {
return new EachElementHasNextInstruction(value, objectRef);
public com.ibm.wala.cast.ir.ssa.EachElementHasNextInstruction EachElementHasNextInstruction(int iindex, int value, int objectRef) {
return new EachElementHasNextInstruction(iindex, value, objectRef);
}
@Override
public AstEchoInstruction EchoInstruction(int[] rvals) {
return new AstEchoInstruction(rvals);
public AstEchoInstruction EchoInstruction(int iindex, int[] rvals) {
return new AstEchoInstruction(iindex, rvals);
}
@Override
public AstGlobalRead GlobalRead(int lhs, FieldReference global) {
return new AstGlobalRead(lhs, global);
public AstGlobalRead GlobalRead(int iindex, int lhs, FieldReference global) {
return new AstGlobalRead(iindex, lhs, global);
}
@Override
public AstGlobalWrite GlobalWrite(FieldReference global, int rhs) {
return new AstGlobalWrite(global, rhs);
public AstGlobalWrite GlobalWrite(int iindex, FieldReference global, int rhs) {
return new AstGlobalWrite(iindex, global, rhs);
}
@Override
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, int fieldVal, FieldReference fieldRef) {
return new AstIsDefinedInstruction(lval, rval, fieldVal, fieldRef);
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, int fieldVal, FieldReference fieldRef) {
return new AstIsDefinedInstruction(iindex, lval, rval, fieldVal, fieldRef);
}
@Override
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, FieldReference fieldRef) {
return new AstIsDefinedInstruction(lval, rval, fieldRef);
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, FieldReference fieldRef) {
return new AstIsDefinedInstruction(iindex, lval, rval, fieldRef);
}
@Override
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, int fieldVal) {
return new AstIsDefinedInstruction(lval, rval, fieldVal);
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, int fieldVal) {
return new AstIsDefinedInstruction(iindex, lval, rval, fieldVal);
}
@Override
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval) {
return new AstIsDefinedInstruction(lval, rval);
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval) {
return new AstIsDefinedInstruction(iindex, lval, rval);
}
@Override
public AstLexicalRead LexicalRead(Access[] accesses) {
return new AstLexicalRead(accesses);
public AstLexicalRead LexicalRead(int iindex, Access[] accesses) {
return new AstLexicalRead(iindex, accesses);
}
@Override
public AstLexicalRead LexicalRead(Access access) {
return new AstLexicalRead(access);
public AstLexicalRead LexicalRead(int iindex, Access access) {
return new AstLexicalRead(iindex, access);
}
@Override
public AstLexicalRead LexicalRead(int lhs, String definer, String globalName, TypeReference type) {
return new AstLexicalRead(lhs, definer, globalName, type);
public AstLexicalRead LexicalRead(int iindex, int lhs, String definer, String globalName, TypeReference type) {
return new AstLexicalRead(iindex, lhs, definer, globalName, type);
}
@Override
public AstLexicalWrite LexicalWrite(Access[] accesses) {
return new AstLexicalWrite(accesses);
public AstLexicalWrite LexicalWrite(int iindex, Access[] accesses) {
return new AstLexicalWrite(iindex, accesses);
}
@Override
public AstLexicalWrite LexicalWrite(Access access) {
return new AstLexicalWrite(access);
public AstLexicalWrite LexicalWrite(int iindex, Access access) {
return new AstLexicalWrite(iindex, access);
}
@Override
public AstLexicalWrite LexicalWrite(String definer, String globalName, TypeReference type, int rhs) {
return new AstLexicalWrite(definer, globalName, type, rhs);
public AstLexicalWrite LexicalWrite(int iindex, String definer, String globalName, TypeReference type, int rhs) {
return new AstLexicalWrite(iindex, definer, globalName, type, rhs);
}
@Override
public SSAArrayLengthInstruction ArrayLengthInstruction(int result, int arrayref) {
public SSAArrayLengthInstruction ArrayLengthInstruction(int iindex, int result, int arrayref) {
throw new UnsupportedOperationException();
}
@Override
public SSAArrayLoadInstruction ArrayLoadInstruction(int result, int arrayref, int index, TypeReference declaredType) {
public SSAArrayLoadInstruction ArrayLoadInstruction(int iindex, int result, int arrayref, int index, TypeReference declaredType) {
throw new UnsupportedOperationException();
}
@Override
public SSAArrayStoreInstruction ArrayStoreInstruction(int arrayref, int index, int value, TypeReference declaredType) {
public SSAArrayStoreInstruction ArrayStoreInstruction(int iindex, int arrayref, int index, int value, TypeReference declaredType) {
throw new UnsupportedOperationException();
}
@Override
public SSABinaryOpInstruction BinaryOpInstruction(IOperator operator, boolean overflow, boolean unsigned, int result,
public SSABinaryOpInstruction BinaryOpInstruction(int iindex, IOperator operator, boolean overflow, boolean unsigned, int result,
int val1, int val2, boolean mayBeInteger) {
return new SSABinaryOpInstruction(operator, result, val1, val2, mayBeInteger) {
return new SSABinaryOpInstruction(iindex, operator, result, val1, val2, mayBeInteger) {
@Override
public boolean isPEI() {
return false;
@ -383,74 +383,74 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return insts.BinaryOpInstruction(getOperator(), false, false, defs == null || defs.length == 0 ? getDef(0) : defs[0],
return insts.BinaryOpInstruction(iindex, getOperator(), false, false, defs == null || defs.length == 0 ? getDef(0) : defs[0],
uses == null ? getUse(0) : uses[0], uses == null ? getUse(1) : uses[1], mayBeIntegerOp());
}
};
}
@Override
public SSACheckCastInstruction CheckCastInstruction(int result, int val, TypeReference[] types, boolean isPEI) {
public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, TypeReference[] types, boolean isPEI) {
throw new UnsupportedOperationException();
}
@Override
public SSACheckCastInstruction CheckCastInstruction(int result, int val, int[] typeValues, boolean isPEI) {
public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, int[] typeValues, boolean isPEI) {
throw new UnsupportedOperationException();
}
@Override
public SSACheckCastInstruction CheckCastInstruction(int result, int val, int typeValue, boolean isPEI) {
public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, int typeValue, boolean isPEI) {
assert isPEI;
return CheckCastInstruction(result, val, new int[]{ typeValue }, true);
return CheckCastInstruction(iindex, result, val, new int[]{ typeValue }, true);
}
@Override
public SSACheckCastInstruction CheckCastInstruction(int result, int val, TypeReference type, boolean isPEI) {
public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, TypeReference type, boolean isPEI) {
assert isPEI;
return CheckCastInstruction(result, val, new TypeReference[]{ type }, true);
return CheckCastInstruction(iindex, result, val, new TypeReference[]{ type }, true);
}
@Override
public SSAComparisonInstruction ComparisonInstruction(Operator operator, int result, int val1, int val2) {
return new SSAComparisonInstruction(operator, result, val1, val2);
public SSAComparisonInstruction ComparisonInstruction(int iindex, Operator operator, int result, int val1, int val2) {
return new SSAComparisonInstruction(iindex, operator, result, val1, val2);
}
@Override
public SSAConditionalBranchInstruction ConditionalBranchInstruction(
public SSAConditionalBranchInstruction ConditionalBranchInstruction(int iindex,
com.ibm.wala.shrikeBT.IConditionalBranchInstruction.IOperator operator, TypeReference type, int val1, int val2, int target) {
return new SSAConditionalBranchInstruction(operator, type, val1, val2, target);
return new SSAConditionalBranchInstruction(iindex, operator, type, val1, val2, target);
}
@Override
public SSAConversionInstruction ConversionInstruction(int result, int val, TypeReference fromType, TypeReference toType,
public SSAConversionInstruction ConversionInstruction(int iindex, int result, int val, TypeReference fromType, TypeReference toType,
boolean overflow) {
assert !overflow;
return new SSAConversionInstruction(result, val, fromType, toType) {
return new SSAConversionInstruction(iindex, result, val, fromType, toType) {
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) throws IllegalArgumentException {
if (uses != null && uses.length == 0) {
throw new IllegalArgumentException("(uses != null) and (uses.length == 0)");
}
return insts.ConversionInstruction(defs == null || defs.length == 0 ? getDef(0) : defs[0], uses == null ? getUse(0)
return insts.ConversionInstruction(iindex, defs == null || defs.length == 0 ? getDef(0) : defs[0], uses == null ? getUse(0)
: uses[0], getFromType(), getToType(), false);
}
};
}
@Override
public SSAGetCaughtExceptionInstruction GetCaughtExceptionInstruction(int bbNumber, int exceptionValueNumber) {
return new SSAGetCaughtExceptionInstruction(bbNumber, exceptionValueNumber);
public SSAGetCaughtExceptionInstruction GetCaughtExceptionInstruction(int iindex, int bbNumber, int exceptionValueNumber) {
return new SSAGetCaughtExceptionInstruction(iindex, bbNumber, exceptionValueNumber);
}
@Override
public SSAGetInstruction GetInstruction(int result, FieldReference field) {
public SSAGetInstruction GetInstruction(int iindex, int result, FieldReference field) {
throw new UnsupportedOperationException();
}
@Override
public SSAGetInstruction GetInstruction(int result, int ref, FieldReference field) {
return new SSAGetInstruction(result, ref, field) {
public SSAGetInstruction GetInstruction(int iindex, int result, int ref, FieldReference field) {
return new SSAGetInstruction(iindex, result, ref, field) {
@Override
public boolean isPEI() {
return false;
@ -459,38 +459,38 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
}
@Override
public SSAGotoInstruction GotoInstruction(int target) {
return new SSAGotoInstruction(target);
public SSAGotoInstruction GotoInstruction(int iindex, int target) {
return new SSAGotoInstruction(iindex, target);
}
@Override
public SSAInstanceofInstruction InstanceofInstruction(int result, int ref, TypeReference checkedType) {
public SSAInstanceofInstruction InstanceofInstruction(int iindex, int result, int ref, TypeReference checkedType) {
throw new UnsupportedOperationException();
}
@Override
public SSAInvokeInstruction InvokeInstruction(int result, int[] params, int exception, CallSiteReference site) {
public SSAInvokeInstruction InvokeInstruction(int iindex, int result, int[] params, int exception, CallSiteReference site) {
throw new UnsupportedOperationException();
}
@Override
public SSAInvokeInstruction InvokeInstruction(int[] params, int exception, CallSiteReference site) {
public SSAInvokeInstruction InvokeInstruction(int iindex, int[] params, int exception, CallSiteReference site) {
throw new UnsupportedOperationException();
}
@Override
public SSALoadMetadataInstruction LoadMetadataInstruction(int lval, TypeReference entityType, Object token) {
public SSALoadMetadataInstruction LoadMetadataInstruction(int iindex, int lval, TypeReference entityType, Object token) {
throw new UnsupportedOperationException();
}
@Override
public SSAMonitorInstruction MonitorInstruction(int ref, boolean isEnter) {
public SSAMonitorInstruction MonitorInstruction(int iindex, int ref, boolean isEnter) {
throw new UnsupportedOperationException();
}
@Override
public SSANewInstruction NewInstruction(int result, NewSiteReference site) {
return new SSANewInstruction(result, site) {
public SSANewInstruction NewInstruction(int iindex, int result, NewSiteReference site) {
return new SSANewInstruction(iindex, result, site) {
@Override
public boolean isPEI() {
return true;
@ -504,23 +504,23 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
}
@Override
public SSANewInstruction NewInstruction(int result, NewSiteReference site, int[] params) {
public SSANewInstruction NewInstruction(int iindex, int result, NewSiteReference site, int[] params) {
throw new UnsupportedOperationException();
}
@Override
public SSAPhiInstruction PhiInstruction(int result, int[] params) {
return new SSAPhiInstruction(result, params);
public SSAPhiInstruction PhiInstruction(int iindex, int result, int[] params) {
return new SSAPhiInstruction(iindex, result, params);
}
@Override
public SSAPiInstruction PiInstruction(int result, int val, int piBlock, int successorBlock, SSAInstruction cause) {
return new SSAPiInstruction(result, val, piBlock, successorBlock, cause);
public SSAPiInstruction PiInstruction(int iindex, int result, int val, int piBlock, int successorBlock, SSAInstruction cause) {
return new SSAPiInstruction(iindex, result, val, piBlock, successorBlock, cause);
}
@Override
public SSAPutInstruction PutInstruction(int ref, int value, FieldReference field) {
return new SSAPutInstruction(ref, value, field) {
public SSAPutInstruction PutInstruction(int iindex, int ref, int value, FieldReference field) {
return new SSAPutInstruction(iindex, ref, value, field) {
@Override
public boolean isPEI() {
return false;
@ -529,28 +529,28 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
}
@Override
public SSAPutInstruction PutInstruction(int value, FieldReference field) {
public SSAPutInstruction PutInstruction(int iindex, int value, FieldReference field) {
throw new UnsupportedOperationException();
}
@Override
public SSAReturnInstruction ReturnInstruction() {
return new SSAReturnInstruction();
public SSAReturnInstruction ReturnInstruction(int iindex) {
return new SSAReturnInstruction(iindex);
}
@Override
public SSAReturnInstruction ReturnInstruction(int result, boolean isPrimitive) {
return new SSAReturnInstruction(result, isPrimitive);
public SSAReturnInstruction ReturnInstruction(int iindex, int result, boolean isPrimitive) {
return new SSAReturnInstruction(iindex, result, isPrimitive);
}
@Override
public SSASwitchInstruction SwitchInstruction(int val, int defaultLabel, int[] casesAndLabels) {
return new SSASwitchInstruction(val, defaultLabel, casesAndLabels);
public SSASwitchInstruction SwitchInstruction(int iindex, int val, int defaultLabel, int[] casesAndLabels) {
return new SSASwitchInstruction(iindex, val, defaultLabel, casesAndLabels);
}
@Override
public SSAThrowInstruction ThrowInstruction(int exception) {
return new SSAThrowInstruction(exception) {
public SSAThrowInstruction ThrowInstruction(int iindex, int exception) {
return new SSAThrowInstruction(iindex, exception) {
@Override
public boolean isPEI() {
return true;
@ -564,44 +564,44 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
}
@Override
public SSAUnaryOpInstruction UnaryOpInstruction(com.ibm.wala.shrikeBT.IUnaryOpInstruction.IOperator operator, int result,
public SSAUnaryOpInstruction UnaryOpInstruction(int iindex, com.ibm.wala.shrikeBT.IUnaryOpInstruction.IOperator operator, int result,
int val) {
return new SSAUnaryOpInstruction(operator, result, val);
return new SSAUnaryOpInstruction(iindex, operator, result, val);
}
@Override
public SSAAddressOfInstruction AddressOfInstruction(int lval, int local, TypeReference pointeeType) {
public SSAAddressOfInstruction AddressOfInstruction(int iindex, int lval, int local, TypeReference pointeeType) {
throw new UnsupportedOperationException();
}
@Override
public SSAAddressOfInstruction AddressOfInstruction(int lval, int local, int indexVal, TypeReference pointeeType) {
public SSAAddressOfInstruction AddressOfInstruction(int iindex, int lval, int local, int indexVal, TypeReference pointeeType) {
throw new UnsupportedOperationException();
}
@Override
public SSAAddressOfInstruction AddressOfInstruction(int lval, int local, FieldReference field, TypeReference pointeeType) {
public SSAAddressOfInstruction AddressOfInstruction(int iindex, int lval, int local, FieldReference field, TypeReference pointeeType) {
throw new UnsupportedOperationException();
}
@Override
public SSALoadIndirectInstruction LoadIndirectInstruction(int lval, TypeReference t, int addressVal) {
public SSALoadIndirectInstruction LoadIndirectInstruction(int iindex, int lval, TypeReference t, int addressVal) {
throw new UnsupportedOperationException();
}
@Override
public SSAStoreIndirectInstruction StoreIndirectInstruction(int addressVal, int rval, TypeReference t) {
public SSAStoreIndirectInstruction StoreIndirectInstruction(int iindex, int addressVal, int rval, TypeReference t) {
throw new UnsupportedOperationException();
}
@Override
public PrototypeLookup PrototypeLookup(int lval, int object) {
return new PrototypeLookup(lval, object);
public PrototypeLookup PrototypeLookup(int iindex, int lval, int object) {
return new PrototypeLookup(iindex, lval, object);
}
@Override
public SetPrototype SetPrototype(int object, int prototype) {
return new SetPrototype(object, prototype);
public SetPrototype SetPrototype(int iindex, int object, int prototype) {
return new SetPrototype(iindex, object, prototype);
}
@Override
@ -655,7 +655,7 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
@SuppressWarnings("static-access")
@Override
public PrimitiveType getPrimitive(TypeReference reference) {
return JSPrimitiveType.getPrimitive(reference);
return PrimitiveType.getPrimitive(reference);
}
@Override

View File

@ -17,30 +17,30 @@ import com.ibm.wala.ssa.SSAPutInstruction;
public interface JSInstructionFactory extends AstInstructionFactory {
JavaScriptCheckReference CheckReference(int ref);
JavaScriptCheckReference CheckReference(int iindex, int ref);
SSAGetInstruction GetInstruction(int result, int ref, String field);
SSAGetInstruction GetInstruction(int iindex, int result, int ref, String field);
JavaScriptInstanceOf InstanceOf(int result, int objVal, int typeVal);
JavaScriptInstanceOf InstanceOf(int iindex, int result, int objVal, int typeVal);
JavaScriptInvoke Invoke(int function, int results[], int[] params, int exception, CallSiteReference site);
JavaScriptInvoke Invoke(int iindex, int function, int results[], int[] params, int exception, CallSiteReference site);
JavaScriptInvoke Invoke(int function, int result, int[] params, int exception, CallSiteReference site);
JavaScriptInvoke Invoke(int iindex, int function, int result, int[] params, int exception, CallSiteReference site);
JavaScriptInvoke Invoke(int function, int[] params, int exception, CallSiteReference site);
JavaScriptInvoke Invoke(int iindex, int function, int[] params, int exception, CallSiteReference site);
JavaScriptPropertyRead PropertyRead(int result, int objectRef, int memberRef);
JavaScriptPropertyRead PropertyRead(int iindex, int result, int objectRef, int memberRef);
JavaScriptPropertyWrite PropertyWrite(int objectRef, int memberRef, int value);
JavaScriptPropertyWrite PropertyWrite(int iindex, int objectRef, int memberRef, int value);
SSAPutInstruction PutInstruction(int ref, int value, String field);
SSAPutInstruction PutInstruction(int iindex, int ref, int value, String field);
JavaScriptTypeOfInstruction TypeOfInstruction(int lval, int object);
JavaScriptTypeOfInstruction TypeOfInstruction(int iindex, int lval, int object);
JavaScriptWithRegion WithRegion(int expr, boolean isEnter);
JavaScriptWithRegion WithRegion(int iindex, int expr, boolean isEnter);
PrototypeLookup PrototypeLookup(int lval, int object);
PrototypeLookup PrototypeLookup(int iindex, int lval, int object);
SetPrototype SetPrototype(int object, int prototype);
SetPrototype SetPrototype(int iindex, int object, int prototype);
}

View File

@ -26,13 +26,14 @@ import com.ibm.wala.types.TypeReference;
public class JavaScriptCheckReference extends SSAInstruction {
private final int ref;
public JavaScriptCheckReference(int ref) {
public JavaScriptCheckReference(int iindex, int ref) {
super(iindex);
this.ref = ref;
}
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((JSInstructionFactory)insts).CheckReference(uses==null? ref: uses[0]);
return ((JSInstructionFactory)insts).CheckReference(iindex, uses==null? ref: uses[0]);
}
@Override

View File

@ -25,7 +25,8 @@ public class JavaScriptInstanceOf extends SSAInstruction {
private final int typeVal;
private final int result;
public JavaScriptInstanceOf(int result, int objVal, int typeVal) {
public JavaScriptInstanceOf(int iindex, int result, int objVal, int typeVal) {
super(iindex);
this.objVal = objVal;
this.typeVal = typeVal;
this.result = result;
@ -34,7 +35,7 @@ public class JavaScriptInstanceOf extends SSAInstruction {
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return
((JSInstructionFactory)insts).InstanceOf(
((JSInstructionFactory)insts).InstanceOf(iindex,
defs==null? result: defs[0],
uses==null? objVal: uses[0],
uses==null? typeVal: uses[1]);

View File

@ -28,18 +28,18 @@ public class JavaScriptInvoke extends MultiReturnValueInvokeInstruction {
private int function;
public JavaScriptInvoke(int function, int results[], int[] params, int exception, CallSiteReference site) {
super(results, exception, site);
public JavaScriptInvoke(int iindex, int function, int results[], int[] params, int exception, CallSiteReference site) {
super(iindex, results, exception, site);
this.function = function;
this.params = params;
}
public JavaScriptInvoke(int function, int result, int[] params, int exception, CallSiteReference site) {
this(function, new int[] { result }, params, exception, site);
public JavaScriptInvoke(int iindex, int function, int result, int[] params, int exception, CallSiteReference site) {
this(iindex, function, new int[] { result }, params, exception, site);
}
public JavaScriptInvoke(int function, int[] params, int exception, CallSiteReference site) {
this(function, null, params, exception, site);
public JavaScriptInvoke(int iindex, int function, int[] params, int exception, CallSiteReference site) {
this(iindex, function, null, params, exception, site);
}
@Override
@ -74,7 +74,7 @@ public class JavaScriptInvoke extends MultiReturnValueInvokeInstruction {
}
return ((JSInstructionFactory)insts).Invoke(fn, newLvals, newParams, newExp, site);
return ((JSInstructionFactory)insts).Invoke(iindex, fn, newLvals, newParams, newExp, site);
}

View File

@ -18,14 +18,14 @@ import com.ibm.wala.ssa.SSAInstructionFactory;
import com.ibm.wala.types.TypeReference;
public class JavaScriptPropertyRead extends AbstractReflectiveGet {
public JavaScriptPropertyRead(int result, int objectRef, int memberRef) {
super(result, objectRef, memberRef);
public JavaScriptPropertyRead(int iindex, int result, int objectRef, int memberRef) {
super(iindex, result, objectRef, memberRef);
}
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return
((JSInstructionFactory)insts).PropertyRead(
((JSInstructionFactory)insts).PropertyRead(iindex,
defs==null? getDef(): defs[0],
uses==null? getObjectRef(): uses[0],
uses==null? getMemberRef(): uses[1]);

View File

@ -20,13 +20,13 @@ import com.ibm.wala.types.TypeReference;
public class JavaScriptPropertyWrite extends AbstractReflectivePut {
public JavaScriptPropertyWrite(int objectRef, int memberRef, int value) {
super(objectRef, memberRef, value);
public JavaScriptPropertyWrite(int iindex, int objectRef, int memberRef, int value) {
super(iindex, objectRef, memberRef, value);
}
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((JSInstructionFactory)insts).PropertyWrite(uses == null ? getObjectRef() : uses[0], uses == null ? getMemberRef() : uses[1],
return ((JSInstructionFactory)insts).PropertyWrite(iindex, uses == null ? getObjectRef() : uses[0], uses == null ? getMemberRef() : uses[1],
uses == null ? getValue() : uses[2]);
}

View File

@ -20,13 +20,13 @@ import com.ibm.wala.types.TypeReference;
public class JavaScriptTypeOfInstruction extends SSAAbstractUnaryInstruction {
public JavaScriptTypeOfInstruction(int lval, int object) {
super(lval, object);
public JavaScriptTypeOfInstruction(int iindex, int lval, int object) {
super(iindex, lval, object);
}
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((JSInstructionFactory)insts).TypeOfInstruction((defs != null ? defs[0] : getDef(0)), (uses != null ? uses[0] : getUse(0)));
return ((JSInstructionFactory)insts).TypeOfInstruction(iindex, (defs != null ? defs[0] : getDef(0)), (uses != null ? uses[0] : getUse(0)));
}
@Override

View File

@ -21,14 +21,15 @@ public class JavaScriptWithRegion extends SSAInstruction {
private final int expr;
private final boolean isEnter;
public JavaScriptWithRegion(int expr, boolean isEnter) {
public JavaScriptWithRegion(int iindex, int expr, boolean isEnter) {
super(iindex);
this.expr = expr;
this.isEnter = isEnter;
}
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((JSInstructionFactory)insts).WithRegion(uses==null? expr: uses[0], isEnter);
return ((JSInstructionFactory)insts).WithRegion(iindex, uses==null? expr: uses[0], isEnter);
}
@Override

View File

@ -21,13 +21,13 @@ import com.ibm.wala.ssa.SymbolTable;
*/
public class PrototypeLookup extends SSAAbstractUnaryInstruction {
public PrototypeLookup(int result, int val) {
super(result, val);
public PrototypeLookup(int iindex, int result, int val) {
super(iindex, result, val);
}
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((JSInstructionFactory)insts).PrototypeLookup((defs != null ? defs[0] : getDef(0)), (uses != null ? uses[0] : getUse(0)));
return ((JSInstructionFactory)insts).PrototypeLookup(iindex, (defs != null ? defs[0] : getDef(0)), (uses != null ? uses[0] : getUse(0)));
}
@Override

View File

@ -18,7 +18,8 @@ public class SetPrototype extends SSAInstruction {
private final int object;
private final int prototype;
public SetPrototype(int object, int prototype) {
public SetPrototype(int iindex, int object, int prototype) {
super(iindex);
this.object = object;
this.prototype = prototype;
}
@ -36,7 +37,7 @@ public class SetPrototype extends SSAInstruction {
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((JSInstructionFactory)insts).SetPrototype((uses != null ? uses[0] : object), (uses != null ? uses[1] : prototype));
return ((JSInstructionFactory)insts).SetPrototype(iindex, (uses != null ? uses[0] : object), (uses != null ? uses[1] : prototype));
}
@Override

View File

@ -108,8 +108,7 @@ public class JSAstTranslator extends AstTranslator {
*/
private void addDefinedCheck(CAstNode n, WalkContext context, int readVn) {
context.cfg().addPreNode(n);
context.cfg().addInstruction(((JSInstructionFactory) insts).CheckReference(readVn));
context.cfg().addInstruction(((JSInstructionFactory)insts).CheckReference(context.cfg().getCurrentInstruction(), readVn));
CAstNode target = context.getControlFlow().getTarget(n, JavaScriptTypes.ReferenceError);
if (target != null) {
context.cfg().addPreEdge(n, target, true);
@ -185,7 +184,7 @@ public class JSAstTranslator extends AstTranslator {
@Override
protected void doThrow(WalkContext context, int exception) {
context.cfg().addInstruction(insts.ThrowInstruction(exception));
context.cfg().addInstruction(insts.ThrowInstruction(context.cfg().getCurrentInstruction(), exception));
}
@Override
@ -196,7 +195,7 @@ public class JSAstTranslator extends AstTranslator {
: AstMethodReference.fnReference(JavaScriptTypes.CodeBody);
context.cfg().addInstruction(
((JSInstructionFactory) insts).Invoke(receiver, result, arguments, exception,
((JSInstructionFactory) insts).Invoke(context.cfg().getCurrentInstruction(), receiver, result, arguments, exception,
new JSCallSiteReference(ref, context.cfg().getCurrentInstruction())));
context.cfg().addPreNode(call, context.getUnwindState());
@ -216,8 +215,8 @@ public class JSAstTranslator extends AstTranslator {
assert arguments == null;
TypeReference typeRef = TypeReference.findOrCreate(JavaScriptTypes.jsLoader, TypeName.string2TypeName("L" + type));
context.cfg().addInstruction(
insts.NewInstruction(result, NewSiteReference.make(context.cfg().getCurrentInstruction(), typeRef)));
context.cfg().addInstruction(insts.NewInstruction(context.cfg().getCurrentInstruction(), result,
NewSiteReference.make(context.cfg().getCurrentInstruction(), typeRef)));
}
@Override
@ -226,8 +225,8 @@ public class JSAstTranslator extends AstTranslator {
// "Function" is the name we use to model the constructor of function values
int tmp = super.doGlobalRead(n, context, "Function", JavaScriptTypes.Function);
context.cfg().addInstruction(
((JSInstructionFactory) insts).Invoke(tmp, result, new int[] { nm }, exception, new JSCallSiteReference(
JavaScriptMethods.ctorReference, context.cfg().getCurrentInstruction())));
((JSInstructionFactory)insts).Invoke(context.cfg().getCurrentInstruction(), tmp, result, new int[]{ nm }, exception,
new JSCallSiteReference(JavaScriptMethods.ctorReference, context.cfg().getCurrentInstruction())));
}
@Override
@ -245,17 +244,18 @@ public class JSAstTranslator extends AstTranslator {
this.visit(elt, context, this);
int x = context.currentScope().allocateTempValue();
context.cfg().addInstruction(((JSInstructionFactory) insts).AssignInstruction(x, receiver));
context.cfg().addInstruction(((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(), x, receiver));
context.cfg().addInstruction(((JSInstructionFactory) insts).PrototypeLookup(x, x));
context.cfg().addInstruction(((JSInstructionFactory) insts).PrototypeLookup(context.cfg().getCurrentInstruction(), x, x));
if (elt.getKind() == CAstNode.CONSTANT && elt.getValue() instanceof String) {
String field = (String) elt.getValue();
// symtab needs to have this value
context.currentScope().getConstantValue(field);
context.cfg().addInstruction(((JSInstructionFactory) insts).GetInstruction(result, x, field));
context.cfg().addInstruction(
((JSInstructionFactory)insts).GetInstruction(context.cfg().getCurrentInstruction(), result, x, field));
} else {
context.cfg().addInstruction(((JSInstructionFactory) insts).PropertyRead(result, x, context.getValue(elt)));
context.cfg().addInstruction(((JSInstructionFactory) insts).PropertyRead(context.cfg().getCurrentInstruction(), result, x, context.getValue(elt)));
}
// generate code to handle read of property from null or undefined
@ -275,14 +275,14 @@ public class JSAstTranslator extends AstTranslator {
if (elt.getKind() == CAstNode.CONSTANT && elt.getValue() instanceof String) {
String field = (String) elt.getValue();
if (isPrologueScript(context) && "__proto__".equals(field)) {
context.cfg().addInstruction(((JSInstructionFactory) insts).SetPrototype(receiver, rval));
context.cfg().addInstruction(((JSInstructionFactory) insts).SetPrototype(context.cfg().getCurrentInstruction(), receiver, rval));
return;
}
}
/*
} else {
context.currentScope().getConstantValue(field);
SSAPutInstruction put = ((JSInstructionFactory) insts).PutInstruction(receiver, rval, field);
SSAPutInstruction put = ((JSInstructionFactory) insts).PutInstruction(context.cfg().getCurrentInstruction(), receiver, rval, field);
try {
assert field.equals(put.getDeclaredField().getName().toUnicodeString());
} catch (UTFDataFormatException e) {
@ -292,7 +292,7 @@ public class JSAstTranslator extends AstTranslator {
}
} else {
*/
context.cfg().addInstruction(((JSInstructionFactory) insts).PropertyWrite(receiver, context.getValue(elt), rval));
context.cfg().addInstruction(((JSInstructionFactory) insts).PropertyWrite(context.cfg().getCurrentInstruction(), receiver, context.getValue(elt), rval));
context.cfg().addPreNode(parent, context.getUnwindState());
// generate code to handle read of property from null or undefined
@ -310,45 +310,46 @@ public class JSAstTranslator extends AstTranslator {
// set the class property of the new object
int rval = context.currentScope().getConstantValue(typeName);
context.currentScope().getConstantValue("class");
context.cfg().addInstruction(((JSInstructionFactory) insts).PutInstruction(resultVal, rval, "class"));
}
context.cfg().addInstruction(
((JSInstructionFactory)insts).PutInstruction(context.cfg().getCurrentInstruction(), resultVal, rval, "class"));
}
@Override
protected void doPrimitive(int resultVal, WalkContext context, CAstNode primitiveCall) {
try {
String name = (String) primitiveCall.getChild(0).getValue();
if (name.equals("GlobalNaN")) {
context.cfg().addInstruction(
((JSInstructionFactory) insts).AssignInstruction(resultVal,
context.currentScope().getConstantValue(new Float(Float.NaN))));
context.cfg().addInstruction(
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal, context.currentScope().getConstantValue(new Float(Float.NaN))));
} else if (name.equals("GlobalInfinity")) {
context.cfg().addInstruction(
((JSInstructionFactory) insts).AssignInstruction(resultVal,
context.currentScope().getConstantValue(new Float(Float.POSITIVE_INFINITY))));
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal, context.currentScope().getConstantValue(new Float(Float.POSITIVE_INFINITY))));
} else if (name.equals("MathE")) {
context.cfg().addInstruction(
((JSInstructionFactory) insts)
.AssignInstruction(resultVal, context.currentScope().getConstantValue(new Double(Math.E))));
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal, context.currentScope().getConstantValue(new Double(Math.E))));
} else if (name.equals("MathPI")) {
context.cfg().addInstruction(
((JSInstructionFactory) insts).AssignInstruction(resultVal, context.currentScope()
.getConstantValue(new Double(Math.PI))));
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal, context.currentScope().getConstantValue(new Double(Math.PI))));
} else if (name.equals("MathSQRT1_2")) {
context.cfg().addInstruction(
((JSInstructionFactory) insts).AssignInstruction(resultVal,
context.currentScope().getConstantValue(new Double(Math.sqrt(.5)))));
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal, context.currentScope().getConstantValue(new Double(Math.sqrt(.5)))));
} else if (name.equals("MathSQRT2")) {
context.cfg().addInstruction(
((JSInstructionFactory) insts).AssignInstruction(resultVal,
context.currentScope().getConstantValue(new Double(Math.sqrt(2)))));
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal, context.currentScope().getConstantValue(new Double(Math.sqrt(2)))));
} else if (name.equals("MathLN2")) {
context.cfg().addInstruction(
((JSInstructionFactory) insts).AssignInstruction(resultVal,
context.currentScope().getConstantValue(new Double(Math.log(2)))));
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal, context.currentScope().getConstantValue(new Double(Math.log(2)))));
} else if (name.equals("MathLN10")) {
context.cfg().addInstruction(
((JSInstructionFactory) insts).AssignInstruction(resultVal,
context.currentScope().getConstantValue(new Double(Math.log(10)))));
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal, context.currentScope().getConstantValue(new Double(Math.log(10)))));
} else if (name.equals("NewObject")) {
doNewObject(context, null, resultVal, "Object", null);
@ -371,8 +372,9 @@ public class JSAstTranslator extends AstTranslator {
doNewObject(context, null, resultVal, "Undefined", null);
} else {
context.cfg().addInstruction(
((JSInstructionFactory) insts).AssignInstruction(resultVal, context.currentScope().getConstantValue(null)));
context.cfg().addInstruction(
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal, context.currentScope().getConstantValue( null )));
}
} catch (ClassCastException e) {
throw new RuntimeException("Cannot translate primitive " + primitiveCall.getChild(0).getValue());
@ -387,11 +389,11 @@ public class JSAstTranslator extends AstTranslator {
FieldReference fieldRef = FieldReference.findOrCreate(JavaScriptTypes.Root, Atom.findOrCreateUnicodeAtom(field),
JavaScriptTypes.Root);
context.cfg().addInstruction(((JSInstructionFactory) insts).IsDefinedInstruction(result, ref, fieldRef));
context.cfg().addInstruction(((JSInstructionFactory) insts).IsDefinedInstruction(context.cfg().getCurrentInstruction(), result, ref, fieldRef));
} else {
context.cfg().addInstruction(((JSInstructionFactory) insts).IsDefinedInstruction(result, ref, context.getValue(f)));
context.cfg().addInstruction(((JSInstructionFactory) insts).IsDefinedInstruction(context.cfg().getCurrentInstruction(), result, ref, context.getValue(f)));
}
}
@ -414,7 +416,7 @@ public class JSAstTranslator extends AstTranslator {
visit(n.getChild(1), context, visitor);
int type = context.getValue(n.getChild(1));
context.cfg().addInstruction(new JavaScriptInstanceOf(result, value, type));
context.cfg().addInstruction(new JavaScriptInstanceOf(context.cfg().getCurrentInstruction(), result, value, type));
}
@Override
@ -425,7 +427,7 @@ public class JSAstTranslator extends AstTranslator {
doNewObject(context, null, tempVal, "Array", null);
CAstSymbol args = new CAstSymbolImpl("arguments", Any);
context.currentScope().declare(args, tempVal);
//context.cfg().addInstruction(((JSInstructionFactory) insts).PutInstruction(1, tempVal, "arguments"));
//context.cfg().addInstruction(((JSInstructionFactory)insts).PutInstruction(context.cfg().getCurrentInstruction(), 1, tempVal, "arguments"));
}
@Override
@ -437,7 +439,7 @@ public class JSAstTranslator extends AstTranslator {
this.visit(n.getChild(0), context, this);
int ref = context.getValue(n.getChild(0));
context.cfg().addInstruction(((JSInstructionFactory) insts).TypeOfInstruction(result, ref));
context.cfg().addInstruction(((JSInstructionFactory)insts).TypeOfInstruction(context.cfg().getCurrentInstruction(), result, ref));
context.setValue(n, result);
return true;
@ -449,7 +451,8 @@ public class JSAstTranslator extends AstTranslator {
this.visit(n.getChild(0), context, this);
int ref = context.getValue(n.getChild(0));
context.cfg().addInstruction(((JSInstructionFactory) insts).WithRegion(ref, n.getKind() == JavaScriptCAstNode.ENTER_WITH));
context.cfg().addInstruction(((JSInstructionFactory)insts).WithRegion(context.cfg().getCurrentInstruction(), ref,
n.getKind() == JavaScriptCAstNode.ENTER_WITH));
return true;
}

View File

@ -37,12 +37,12 @@ public class JsPaPanel extends PaPanel {
private MutableMapping<List<ObjectPropertyCatalogKey>> instanceKeyIdToObjectPropertyCatalogKey = MutableMapping.<List<ObjectPropertyCatalogKey>> make();
private List<AstGlobalPointerKey> globalsPointerKeys = new ArrayList<AstGlobalPointerKey>();
public JsPaPanel(CallGraph cg, PointerAnalysis pa) {
public JsPaPanel(CallGraph cg, PointerAnalysis<InstanceKey> pa) {
super(cg, pa);
initDataStructures(pa);
}
private void initDataStructures(PointerAnalysis pa) {
private void initDataStructures(PointerAnalysis<InstanceKey> pa) {
HeapGraph heapGraph = pa.getHeapGraph();
OrdinalSetMapping<InstanceKey> instanceKeyMapping = pa.getInstanceKeyMapping();
for (Object n : heapGraph){

View File

@ -11,6 +11,7 @@
package com.ibm.wala.cast.js.vis;
import com.ibm.wala.ipa.callgraph.CallGraph;
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
import com.ibm.wala.viz.viewer.PaPanel;
import com.ibm.wala.viz.viewer.WalaViewer;
@ -19,12 +20,12 @@ public class JsViewer extends WalaViewer{
private static final long serialVersionUID = 1L;
public JsViewer(CallGraph cg, PointerAnalysis pa) {
public JsViewer(CallGraph cg, PointerAnalysis<InstanceKey> pa) {
super(cg, pa);
}
@Override
protected PaPanel createPaPanel(CallGraph cg, PointerAnalysis pa) {
protected PaPanel createPaPanel(CallGraph cg, PointerAnalysis<InstanceKey> pa) {
return new JsPaPanel(cg, pa);
}
}

View File

@ -2,6 +2,6 @@
<classpath>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="harness-src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -12,5 +12,5 @@ Require-Bundle:
com.ibm.wala.shrike,
org.eclipse.core.runtime
Export-Package: com.ibm.wala.cast.test
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-RequiredExecutionEnvironment: JavaSE-1.7

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="source/java"/>
<classpathentry exported="true" kind="lib" path="lib/commons-io-2.4.jar"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=ignore

View File

@ -9,6 +9,8 @@ Require-Bundle: com.ibm.wala.core,
com.ibm.wala.shrike,
org.eclipse.core.runtime
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .,
lib/commons-io-2.4.jar
Export-Package: com.ibm.wala.cast.analysis.typeInference,
com.ibm.wala.cast.ipa.callgraph,
com.ibm.wala.cast.ipa.cha,
@ -26,6 +28,8 @@ Export-Package: com.ibm.wala.cast.analysis.typeInference,
com.ibm.wala.cast.tree.rewrite,
com.ibm.wala.cast.tree.visit,
com.ibm.wala.cast.types,
com.ibm.wala.cast.util
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
com.ibm.wala.cast.util,
org.apache.commons.io,
org.apache.commons.io.input
Bundle-RequiredExecutionEnvironment: JavaSE-1.7

View File

@ -1,4 +1,5 @@
source.. = source/java/
output.. = bin/
bin.includes = META-INF/,\
lib/commons-io-2.4.jar,\
.

View File

@ -4,7 +4,7 @@
CAPA Domo build file
=======================================================================
-->
<project name="com.ibm.wala.cast" default="build-everything" basedir=".">
<project name="com.ibm.wala.cast" default="getJars" basedir=".">
<!-- Software version details -->
<property name="name" value="walacast" />
<property name="module_name" value="com.ibm.wala.cast" />
@ -36,6 +36,36 @@
<property name="mainlib" value="../mainlib" />
<property name="sharedlib" value="../sharedlib" />
<import file="${sharedlib}/scripts/common-targets.xml"/>
<target name="properties" if="eclipse.running">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
</target>
<target name="init" depends="properties">
<condition property="pluginTemp" value="${buildTempFolder}/plugins">
<isset property="buildTempFolder"/>
</condition>
<property name="pluginTemp" value="${basedir}"/>
<condition property="build.result.folder" value="${pluginTemp}/com.ibm.wala.core.testdata">
<isset property="buildTempFolder"/>
</condition>
<property name="build.result.folder" value="${basedir}"/>
<property name="temp.folder" value="${basedir}/temp.folder"/>
<property name="plugin.destination" value="${basedir}"/>
</target>
<target name="CommonsIoPresent" depends="init">
<available file="${plugin.destination}/lib/commons-io-2.4.jar" property="commons.io.present"/>
</target>
<target name="fetchCommonsIo" depends="CommonsIoPresent" unless="commons.io.present">
<delete dir="${temp.folder}"/>
<mkdir dir="${temp.folder}"/>
<get src="http://apache.petsads.us/commons/io/binaries/commons-io-2.4-bin.zip" dest="${temp.folder}/commons-io-2.4.zip"/>
<unzip src="${temp.folder}/commons-io-2.4.zip" dest="${temp.folder}"/>
<copy file="${temp.folder}/commons-io-2.4/commons-io-2.4.jar" tofile="${plugin.destination}/lib/commons-io-2.4.jar" />
<delete dir="${temp.folder}"/>
</target>
<target name="getJars" depends="fetchCommonsIo" />
</project>

View File

@ -9,4 +9,30 @@
</parent>
<artifactId>com.ibm.wala.cast</artifactId>
<packaging>eclipse-plugin</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
<type>jar</type>
<overWrite>false</overWrite>
</artifactItem>
</artifactItems>
<outputDirectory>${basedir}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -60,7 +60,7 @@ public class AstCallGraph extends ExplicitCallGraph {
}
public AstLexicalRead addGlobalRead(TypeReference type, String name) {
AstLexicalRead s = new AstLexicalRead(nextLocal++, null, name, type);
AstLexicalRead s = new AstLexicalRead(statements.size(), nextLocal++, null, name, type);
statements.add(s);
return s;
}

View File

@ -1,3 +1,14 @@
/******************************************************************************
* Copyright (c) 2002 - 2014 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.ipa.modref.ExtendedHeapModel;

View File

@ -141,7 +141,7 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
protected PropagationSystem makeSystem(AnalysisOptions options) {
return new PropagationSystem(callGraph, pointerKeyFactory, instanceKeyFactory) {
@Override
public PointerAnalysis makePointerAnalysis(PropagationCallGraphBuilder builder) {
public PointerAnalysis<InstanceKey> makePointerAnalysis(PropagationCallGraphBuilder builder) {
return new AstPointerAnalysisImpl(builder, cg, pointsToMap, instanceKeys, pointerKeyFactory, instanceKeyFactory);
}
};

View File

@ -12,11 +12,15 @@ package com.ibm.wala.cast.ipa.callgraph;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.Iterator;
import org.apache.commons.io.ByteOrderMark;
import org.apache.commons.io.input.BOMInputStream;
import com.ibm.wala.cast.loader.SingleClassLoaderFactory;
import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.classLoader.Language;
@ -26,6 +30,7 @@ import com.ibm.wala.ipa.callgraph.AnalysisCache;
import com.ibm.wala.ipa.callgraph.AnalysisScope;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.CallGraph;
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
import com.ibm.wala.ipa.callgraph.propagation.PointerKey;
import com.ibm.wala.ssa.IR;
@ -54,7 +59,23 @@ public class CAstCallGraphUtil {
assert hackedName.endsWith(scriptName) : scriptName + " does not match file " + script.getFile();
return new SourceFileModule(scriptFile, scriptName, null);
return new SourceFileModule(scriptFile, scriptName, null) {
@Override
public InputStream getInputStream() {
BOMInputStream bs = new BOMInputStream(super.getInputStream(), false,
ByteOrderMark.UTF_8,
ByteOrderMark.UTF_16LE, ByteOrderMark.UTF_16BE,
ByteOrderMark.UTF_32LE, ByteOrderMark.UTF_32BE);
try {
if (bs.hasBOM()) {
System.err.println("removing BOM " + bs.getBOM());
}
return bs;
} catch (IOException e) {
return super.getInputStream();
}
}
};
}
public static AnalysisScope makeScope(String[] files, SingleClassLoaderFactory loaders, Language language) throws IOException {
@ -98,7 +119,7 @@ public class CAstCallGraphUtil {
return result;
}
public static void dumpCG(PointerAnalysis PA, CallGraph CG) {
public static void dumpCG(PointerAnalysis<InstanceKey> PA, CallGraph CG) {
if (AVOID_DUMP)
return;
for (Iterator x = CG.iterator(); x.hasNext();) {

View File

@ -77,7 +77,7 @@ public abstract class CrossLanguageSSAPropagationCallGraphBuilder extends AstSSA
protected PropagationSystem makeSystem(AnalysisOptions options) {
return new PropagationSystem(callGraph, pointerKeyFactory, instanceKeyFactory) {
@Override
public PointerAnalysis makePointerAnalysis(PropagationCallGraphBuilder builder) {
public PointerAnalysis<InstanceKey> makePointerAnalysis(PropagationCallGraphBuilder builder) {
assert builder == CrossLanguageSSAPropagationCallGraphBuilder.this;
return new CrossLanguagePointerAnalysisImpl(CrossLanguageSSAPropagationCallGraphBuilder.this, cg, pointsToMap,
instanceKeys, pointerKeyFactory, instanceKeyFactory);

View File

@ -274,5 +274,10 @@ public class CrossLanguageClassHierarchy implements IClassHierarchy {
return new CrossLanguageClassHierarchy(scope, factory, hierarchies);
}
/** BEGIN Custom change: unresolved classes */
public Set<TypeReference> getUnresolvedClasses() {
return HashSetFactory.make();
}
/** END Custom change: unresolved classes */
}

View File

@ -36,15 +36,15 @@ import com.ibm.wala.util.intset.OrdinalSet;
*/
public class LexicalModRef {
public static LexicalModRef make(CallGraph cg, PointerAnalysis pa) {
public static LexicalModRef make(CallGraph cg, PointerAnalysis<InstanceKey> pa) {
return new LexicalModRef(cg, pa);
}
private final CallGraph cg;
private final PointerAnalysis pa;
private final PointerAnalysis<InstanceKey> pa;
protected LexicalModRef(CallGraph cg, PointerAnalysis pa) {
protected LexicalModRef(CallGraph cg, PointerAnalysis<InstanceKey> pa) {
this.cg = cg;
this.pa = pa;
}
@ -121,7 +121,7 @@ public class LexicalModRef {
Collection<Pair<CGNode, String>> result = HashSetFactory.make();
// use scope-mapping instance keys in pointer analysis. may need a different
// scheme for CG construction not based on pointer analysis
OrdinalSet<? extends InstanceKey> functionValues = pa.getPointsToSet(pa.getHeapModel().getPointerKeyForLocal(n, 1));
OrdinalSet<InstanceKey> functionValues = pa.getPointsToSet(pa.getHeapModel().getPointerKeyForLocal(n, 1));
for (InstanceKey ik : functionValues) {
if (ik instanceof ScopeMappingInstanceKey) {
ScopeMappingInstanceKey smik = (ScopeMappingInstanceKey) ik;

View File

@ -24,6 +24,7 @@ import com.ibm.wala.cast.ir.ssa.AstLexicalWrite;
import com.ibm.wala.cast.ir.ssa.EachElementGetInstruction;
import com.ibm.wala.cast.ir.ssa.EachElementHasNextInstruction;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
import com.ibm.wala.ipa.callgraph.propagation.PointerKey;
import com.ibm.wala.ipa.modref.ExtendedHeapModel;
@ -38,7 +39,7 @@ public class AstModRef extends ModRef {
protected static class AstRefVisitor extends RefVisitor<AstHeapModel> implements AstInstructionVisitor {
protected AstRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis pa, AstHeapModel h) {
protected AstRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<InstanceKey> pa, AstHeapModel h) {
super(n, result, pa, h);
}
@ -89,7 +90,7 @@ public class AstModRef extends ModRef {
}
@Override
protected RefVisitor makeRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis pa, ExtendedHeapModel h) {
protected RefVisitor makeRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<InstanceKey> pa, ExtendedHeapModel h) {
return new AstRefVisitor(n, result, pa, (AstHeapModel)h);
}
@ -98,7 +99,7 @@ public class AstModRef extends ModRef {
implements AstInstructionVisitor
{
protected AstModVisitor(CGNode n, Collection<PointerKey> result, AstHeapModel h, PointerAnalysis pa) {
protected AstModVisitor(CGNode n, Collection<PointerKey> result, AstHeapModel h, PointerAnalysis<InstanceKey> pa) {
super(n, result, h, pa, true);
}
@ -149,7 +150,7 @@ public class AstModRef extends ModRef {
}
@Override
protected ModVisitor makeModVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis pa, ExtendedHeapModel h, boolean ignoreAllocHeapDefs) {
protected ModVisitor makeModVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<InstanceKey> pa, ExtendedHeapModel h, boolean ignoreAllocHeapDefs) {
return new AstModVisitor(n, result, (AstHeapModel)h, pa);
}

View File

@ -23,8 +23,8 @@ import com.ibm.wala.ssa.SymbolTable;
public abstract class AbstractReflectiveGet extends ReflectiveMemberAccess {
private final int result;
public AbstractReflectiveGet(int result, int objectRef, int memberRef) {
super(objectRef, memberRef);
public AbstractReflectiveGet(int iindex, int result, int objectRef, int memberRef) {
super(iindex, objectRef, memberRef);
this.result = result;
}

View File

@ -23,8 +23,8 @@ import com.ibm.wala.ssa.SymbolTable;
public abstract class AbstractReflectivePut extends ReflectiveMemberAccess {
private final int value;
public AbstractReflectivePut(int objectRef, int memberRef, int value) {
super(objectRef, memberRef);
public AbstractReflectivePut(int iindex, int objectRef, int memberRef, int value) {
super(iindex, objectRef, memberRef);
this.value = value;
}

View File

@ -30,8 +30,8 @@ public class AssignInstruction extends SSAUnaryOpInstruction {
* @param result
* @param val
*/
public AssignInstruction(int result, int val) {
super(null, result, val);
public AssignInstruction(int iindex, int result, int val) {
super(iindex, null, result, val);
assert result != val;
assert result != -1;
assert val != -1;
@ -43,7 +43,7 @@ public class AssignInstruction extends SSAUnaryOpInstruction {
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((AstInstructionFactory) insts)
.AssignInstruction(defs == null ? getDef(0) : defs[0], uses == null ? getUse(0) : uses[0]);
.AssignInstruction(iindex, defs == null ? getDef(0) : defs[0], uses == null ? getUse(0) : uses[0]);
}
/*

View File

@ -32,7 +32,8 @@ public class AstAssertInstruction extends SSAInstruction {
private final boolean fromSpecification;
public AstAssertInstruction(int value, boolean fromSpecification) {
public AstAssertInstruction(int iindex, int value, boolean fromSpecification) {
super(iindex);
this.value = value;
this.fromSpecification = fromSpecification;
}
@ -50,7 +51,7 @@ public class AstAssertInstruction extends SSAInstruction {
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((AstInstructionFactory)insts).AssertInstruction(uses == null ? value : uses[0], fromSpecification);
return ((AstInstructionFactory)insts).AssertInstruction(iindex, uses == null ? value : uses[0], fromSpecification);
}
@Override

View File

@ -22,13 +22,14 @@ import com.ibm.wala.util.debug.Assertions;
public class AstEchoInstruction extends SSAInstruction {
private final int[] rvals;
public AstEchoInstruction(int[] rvals) {
public AstEchoInstruction(int iindex, int[] rvals) {
super(iindex);
this.rvals = rvals;
}
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((AstInstructionFactory)insts).EchoInstruction(uses==null? rvals: uses);
return ((AstInstructionFactory)insts).EchoInstruction(iindex, uses==null? rvals: uses);
}
@Override

View File

@ -26,13 +26,13 @@ import com.ibm.wala.types.TypeReference;
*/
public class AstGlobalRead extends SSAGetInstruction {
public AstGlobalRead(int lhs, FieldReference global) {
super(lhs, global);
public AstGlobalRead(int iindex, int lhs, FieldReference global) {
super(iindex, lhs, global);
}
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((AstInstructionFactory)insts).GlobalRead((defs==null)? getDef(): defs[0], getDeclaredField());
return ((AstInstructionFactory)insts).GlobalRead(iindex, (defs==null)? getDef(): defs[0], getDeclaredField());
}
@Override

View File

@ -26,13 +26,13 @@ import com.ibm.wala.types.TypeReference;
*/
public class AstGlobalWrite extends SSAPutInstruction {
public AstGlobalWrite(FieldReference global, int rhs) {
super(rhs, global);
public AstGlobalWrite(int iindex, FieldReference global, int rhs) {
super(iindex, rhs, global);
}
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((AstInstructionFactory)insts).GlobalWrite(getDeclaredField(), (uses==null)? getVal(): uses[0]);
return ((AstInstructionFactory)insts).GlobalWrite(iindex, getDeclaredField(), (uses==null)? getVal(): uses[0]);
}
@Override

View File

@ -17,38 +17,38 @@ import com.ibm.wala.types.TypeReference;
public interface AstInstructionFactory extends SSAInstructionFactory {
AssignInstruction AssignInstruction(int result, int val);
AssignInstruction AssignInstruction(int iindex, int result, int val);
AstAssertInstruction AssertInstruction(int value, boolean fromSpecification);
AstAssertInstruction AssertInstruction(int iindex, int value, boolean fromSpecification);
AstEchoInstruction EchoInstruction(int[] rvals);
AstEchoInstruction EchoInstruction(int iindex, int[] rvals);
AstGlobalRead GlobalRead(int lhs, FieldReference global);
AstGlobalRead GlobalRead(int iindex, int lhs, FieldReference global);
AstGlobalWrite GlobalWrite(FieldReference global, int rhs);
AstGlobalWrite GlobalWrite(int iindex, FieldReference global, int rhs);
AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, int fieldVal, FieldReference fieldRef);
AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, int fieldVal, FieldReference fieldRef);
AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, FieldReference fieldRef);
AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, FieldReference fieldRef);
AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, int fieldVal);
AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, int fieldVal);
AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval);
AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval);
AstLexicalRead LexicalRead(Access[] accesses);
AstLexicalRead LexicalRead(int iindex, Access[] accesses);
AstLexicalRead LexicalRead(Access access);
AstLexicalRead LexicalRead(int iindex, Access access);
AstLexicalRead LexicalRead(int lhs, String definer, String globalName, TypeReference type);
AstLexicalRead LexicalRead(int iindex, int lhs, String definer, String globalName, TypeReference type);
AstLexicalWrite LexicalWrite(Access[] accesses);
AstLexicalWrite LexicalWrite(int iindex, Access[] accesses);
AstLexicalWrite LexicalWrite(Access access);
AstLexicalWrite LexicalWrite(int iindex, Access access);
AstLexicalWrite LexicalWrite(String definer, String globalName, TypeReference type, int rhs);
AstLexicalWrite LexicalWrite(int iindex, String definer, String globalName, TypeReference type, int rhs);
EachElementGetInstruction EachElementGetInstruction(int lValue, int objectRef);
EachElementGetInstruction EachElementGetInstruction(int iindex, int lValue, int objectRef);
EachElementHasNextInstruction EachElementHasNextInstruction(int lValue, int objectRef);
EachElementHasNextInstruction EachElementHasNextInstruction(int iindex, int lValue, int objectRef);
}

View File

@ -49,28 +49,32 @@ public class AstIsDefinedInstruction extends SSAInstruction {
/**
* This constructor should only be used from {@link SSAInstruction#copyForSSA(SSAInstructionFactory, int[], int[])}
*/
public AstIsDefinedInstruction(int lval, int rval, int fieldVal, FieldReference fieldRef) {
public AstIsDefinedInstruction(int iindex, int lval, int rval, int fieldVal, FieldReference fieldRef) {
super(iindex);
this.lval = lval;
this.rval = rval;
this.fieldVal = fieldVal;
this.fieldRef = fieldRef;
}
public AstIsDefinedInstruction(int lval, int rval, FieldReference fieldRef) {
public AstIsDefinedInstruction(int iindex, int lval, int rval, FieldReference fieldRef) {
super(iindex);
this.lval = lval;
this.rval = rval;
this.fieldVal = -1;
this.fieldRef = fieldRef;
}
public AstIsDefinedInstruction(int lval, int rval, int fieldVal) {
public AstIsDefinedInstruction(int iindex, int lval, int rval, int fieldVal) {
super(iindex);
this.lval = lval;
this.rval = rval;
this.fieldVal = fieldVal;
this.fieldRef = null;
}
public AstIsDefinedInstruction(int lval, int rval) {
public AstIsDefinedInstruction(int iindex, int lval, int rval) {
super(iindex);
this.lval = lval;
this.rval = rval;
this.fieldVal = -1;
@ -81,7 +85,7 @@ public class AstIsDefinedInstruction extends SSAInstruction {
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
assert fieldVal == -1 || fieldRef == null;
return ((AstInstructionFactory) insts).IsDefinedInstruction((defs == null) ? lval : defs[0], (uses == null) ? rval : uses[0],
return ((AstInstructionFactory) insts).IsDefinedInstruction(iindex, (defs == null) ? lval : defs[0], (uses == null) ? rval : uses[0],
(uses == null || fieldVal == -1) ? fieldVal : uses[1], fieldRef);
}

View File

@ -82,7 +82,8 @@ public abstract class AstLexicalAccess extends SSAInstruction {
private Access[] accesses;
AstLexicalAccess(Access[] accesses) {
AstLexicalAccess(int iindex, Access[] accesses) {
super(iindex);
setAccesses( accesses );
}

View File

@ -25,22 +25,22 @@ import com.ibm.wala.types.TypeReference;
*/
public class AstLexicalRead extends AstLexicalAccess {
public AstLexicalRead(Access[] accesses) {
super(accesses);
public AstLexicalRead(int iindex, Access[] accesses) {
super(iindex, accesses);
}
public AstLexicalRead(Access access) {
this(new Access[] { access });
public AstLexicalRead(int iindex, Access access) {
this(iindex, new Access[] { access });
}
public AstLexicalRead(int lhs, String definer, String globalName, TypeReference type) {
this(new Access(globalName, definer, type, lhs));
public AstLexicalRead(int iindex, int lhs, String definer, String globalName, TypeReference type) {
this(iindex, new Access(globalName, definer, type, lhs));
}
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
if (defs == null) {
return new AstLexicalRead(getAccesses());
return new AstLexicalRead(iindex, getAccesses());
} else {
Access[] accesses = new Access[getAccessCount()];
for (int i = 0; i < accesses.length; i++) {
@ -48,7 +48,7 @@ public class AstLexicalRead extends AstLexicalAccess {
accesses[i] = new Access(oldAccess.variableName, oldAccess.variableDefiner, oldAccess.type, defs[i]);
}
return ((AstInstructionFactory)insts).LexicalRead(accesses);
return ((AstInstructionFactory)insts).LexicalRead(iindex, accesses);
}
}

View File

@ -25,22 +25,22 @@ import com.ibm.wala.types.TypeReference;
*/
public class AstLexicalWrite extends AstLexicalAccess {
public AstLexicalWrite(String definer, String globalName, TypeReference type, int rhs) {
this(new Access(globalName, definer, type, rhs));
public AstLexicalWrite(int iindex, String definer, String globalName, TypeReference type, int rhs) {
this(iindex, new Access(globalName, definer, type, rhs));
}
public AstLexicalWrite(Access access) {
this(new Access[] { access });
public AstLexicalWrite(int iindex, Access access) {
this(iindex, new Access[] { access });
}
public AstLexicalWrite(Access[] accesses) {
super(accesses);
public AstLexicalWrite(int iindex, Access[] accesses) {
super(iindex, accesses);
}
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
if (uses == null) {
return new AstLexicalWrite(getAccesses());
return new AstLexicalWrite(iindex, getAccesses());
} else {
Access[] accesses = new Access[getAccessCount()];
for (int i = 0; i < accesses.length; i++) {
@ -48,7 +48,7 @@ public class AstLexicalWrite extends AstLexicalAccess {
accesses[i] = new Access(oldAccess.variableName, oldAccess.variableDefiner, oldAccess.type, uses[i]);
}
return ((AstInstructionFactory)insts).LexicalWrite(accesses);
return ((AstInstructionFactory)insts).LexicalWrite(iindex, accesses);
}
}

View File

@ -31,13 +31,13 @@ import com.ibm.wala.types.TypeReference;
*/
public class EachElementGetInstruction extends SSAAbstractUnaryInstruction {
public EachElementGetInstruction(int lValue, int objectRef) {
super(lValue, objectRef);
public EachElementGetInstruction(int iindex, int lValue, int objectRef) {
super(iindex, lValue, objectRef);
}
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((AstInstructionFactory)insts).EachElementGetInstruction((defs == null) ? getDef(0) : defs[0], (uses == null) ? getUse(0) : uses[0]);
return ((AstInstructionFactory)insts).EachElementGetInstruction(iindex, (defs == null) ? getDef(0) : defs[0], (uses == null) ? getUse(0) : uses[0]);
}
@Override

View File

@ -31,13 +31,13 @@ import com.ibm.wala.types.TypeReference;
*/
public class EachElementHasNextInstruction extends SSAAbstractUnaryInstruction {
public EachElementHasNextInstruction(int lValue, int objectRef) {
super(lValue, objectRef);
public EachElementHasNextInstruction(int iindex, int lValue, int objectRef) {
super(iindex, lValue, objectRef);
}
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((AstInstructionFactory)insts).EachElementHasNextInstruction((defs == null) ? getDef(0) : defs[0], (uses == null) ? getUse(0) : uses[0]);
return ((AstInstructionFactory)insts).EachElementHasNextInstruction(iindex, (defs == null) ? getDef(0) : defs[0], (uses == null) ? getUse(0) : uses[0]);
}
@Override

View File

@ -34,13 +34,13 @@ public abstract class FixedParametersInvokeInstruction
*/
private final int[] params;
public FixedParametersInvokeInstruction(int results[], int[] params, int exception, CallSiteReference site) {
super(results, exception, site);
public FixedParametersInvokeInstruction(int iindex, int results[], int[] params, int exception, CallSiteReference site) {
super(iindex, results, exception, site);
this.params = params;
}
public FixedParametersInvokeInstruction(int result, int[] params, int exception, CallSiteReference site) {
this(new int[]{result}, params, exception, site);
public FixedParametersInvokeInstruction(int iindex, int result, int[] params, int exception, CallSiteReference site) {
this(iindex, new int[]{result}, params, exception, site);
}
/**
@ -49,8 +49,8 @@ public abstract class FixedParametersInvokeInstruction
* @param exception
* @param site
*/
public FixedParametersInvokeInstruction(int[] params, int exception, CallSiteReference site) {
this(null, params, exception, site);
public FixedParametersInvokeInstruction(int iindex, int[] params, int exception, CallSiteReference site) {
this(iindex, null, params, exception, site);
}
protected abstract SSAInstruction copyInstruction(SSAInstructionFactory insts, int result[], int[] params, int exception);

View File

@ -18,8 +18,8 @@ public abstract class MultiReturnValueInvokeInstruction
{
protected final int results[];
protected MultiReturnValueInvokeInstruction(int results[], int exception, CallSiteReference site) {
super(exception, site);
protected MultiReturnValueInvokeInstruction(int iindex, int results[], int exception, CallSiteReference site) {
super(iindex, exception, site);
this.results = results;
}

Some files were not shown because too many files have changed in this diff Show More