Merge branch 'wala' into master
This commit is contained in:
commit
b82d5dba90
|
@ -13,9 +13,13 @@ com.ibm.wala.cast.js.rhino.test/*.html
|
|||
com.ibm.wala.cast.js.test/examples-src/ajaxslt/
|
||||
com.ibm.wala.cast.java.polyglot/lib/
|
||||
.metadata/
|
||||
*~
|
||||
com.ibm.wala.cast.js.test/examples-src/ajaxslt/
|
||||
com.ibm.wala.core.testdata/@dot/
|
||||
com.ibm.wala.core.testdata/lib/
|
||||
com.ibm.wala.cast.js.html.nu_validator/lib/
|
||||
com.ibm.wala.cast.java.test/testdata/
|
||||
edu.kit.wala.smali.test/out/
|
||||
com.ibm.wala.core/@dot
|
||||
com.ibm.wala.core/com.ibm.wala.core*.jar
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.ibm.wala-feature</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.FeatureBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.FeatureNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.ibm.wala-feature</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.FeatureBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.FeatureNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
bin.includes = feature.xml,\
|
||||
feature.properties,\
|
||||
license.html,\
|
||||
notice.html
|
||||
bin.includes = feature.xml,\
|
||||
feature.properties,\
|
||||
license.html,\
|
||||
notice.html
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
# NLS_ENCODING=UTF-8
|
||||
# NLS_MESSAGEFORMAT_VAR
|
||||
|
||||
#
|
||||
# Feature details
|
||||
#
|
||||
featureName = WALA Bundles
|
||||
|
||||
# NLS_ENCODING=UTF-8
|
||||
# NLS_MESSAGEFORMAT_VAR
|
||||
|
||||
#
|
||||
# Feature details
|
||||
#
|
||||
featureName = WALA Bundles
|
||||
providerName = IBM
|
|
@ -1,51 +1,51 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<feature
|
||||
id="com.ibm.wala"
|
||||
label="%featureName"
|
||||
version="1.1.3.qualifier"
|
||||
provider-name="%providerName">
|
||||
|
||||
<copyright url="%copyrightURL">
|
||||
%copyright
|
||||
</copyright>
|
||||
|
||||
<license url="%licenseURL">
|
||||
%license
|
||||
</license>
|
||||
|
||||
<plugin
|
||||
id="com.ibm.wala.core"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.ibm.wala.shrike"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.ibm.wala.cast"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.ibm.wala.cast.java"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.ibm.wala.util"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
</feature>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<feature
|
||||
id="com.ibm.wala"
|
||||
label="%featureName"
|
||||
version="1.1.3.qualifier"
|
||||
provider-name="%providerName">
|
||||
|
||||
<copyright url="%copyrightURL">
|
||||
%copyright
|
||||
</copyright>
|
||||
|
||||
<license url="%licenseURL">
|
||||
%license
|
||||
</license>
|
||||
|
||||
<plugin
|
||||
id="com.ibm.wala.core"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.ibm.wala.shrike"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.ibm.wala.cast"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.ibm.wala.cast.java"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.ibm.wala.util"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
</feature>
|
||||
|
|
|
@ -3,5 +3,6 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="source"/>
|
||||
<classpathentry kind="src" path="data"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.ibm.wala.cast.java.jdt.test</name>
|
||||
<name>com.ibm.wala.ide.jdt.test</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Mon Apr 13 10:03:21 EDT 2009
|
||||
eclipse.preferences.version=1
|
||||
formatter_profile=_WALA
|
||||
formatter_settings_version=11
|
||||
#Mon Apr 13 10:03:21 EDT 2009
|
||||
eclipse.preferences.version=1
|
||||
formatter_profile=_WALA
|
||||
formatter_settings_version=11
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: WALA CAst Java JDT Test Plug-in
|
||||
Bundle-SymbolicName: com.ibm.wala.cast.java.jdt.test
|
||||
Bundle-SymbolicName: com.ibm.wala.ide.jdt.test
|
||||
Bundle-Version: 1.0.0
|
||||
Bundle-Activator: com.ibm.wala.cast.java.jdt.test.Activator
|
||||
Bundle-Vendor: IBM
|
||||
|
@ -9,14 +9,16 @@ Require-Bundle: com.ibm.wala.cast.java.test;bundle-version="1.0.0",
|
|||
com.ibm.wala.cast.test;bundle-version="1.0.0",
|
||||
com.ibm.wala.ide.tests;bundle-version="1.1.3",
|
||||
com.ibm.wala.core.tests;bundle-version="1.1.3",
|
||||
com.ibm.wala.cast.java.jdt;bundle-version="1.0.0",
|
||||
com.ibm.wala.ide.jdt;bundle-version="1.0.0",
|
||||
com.ibm.wala.cast.java;bundle-version="1.0.0",
|
||||
com.ibm.wala.cast;bundle-version="1.0.0",
|
||||
com.ibm.wala.ide;bundle-version="1.1.3",
|
||||
com.ibm.wala.core;bundle-version="1.1.3",
|
||||
com.ibm.wala.util;bundle-version="1.1.3",
|
||||
org.eclipse.core.resources;bundle-version="3.4.1",
|
||||
org.eclipse.jdt.core;bundle-version="3.4.2",
|
||||
org.junit4;bundle-version="4.8.1",
|
||||
org.eclipse.core.runtime
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.pde.core;bundle-version="3.6.0"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
java\/awt\/.*
|
||||
javax\/swing\/.*
|
||||
sun\/awt\/.*
|
||||
sun\/swing\/.*
|
||||
com\/sun\/.*
|
||||
sun\/.*
|
||||
org\/netbeans\/.*
|
||||
org\/openide\/.*
|
||||
com\/ibm\/crypto\/.*
|
||||
com\/ibm\/security\/.*
|
||||
org\/apache\/xerces\/.*
|
File diff suppressed because one or more lines are too long
|
@ -16,7 +16,7 @@
|
|||
<booleanAttribute key="includeOptional" value="true"/>
|
||||
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/com.ibm.wala.cast.java.jdt.test/source/com/ibm/wala/cast/java/test/JDTJavaIRTests.java"/>
|
||||
<listEntry value="/com.ibm.wala.ide.jdt.test/source/com/ibm/wala/cast/java/test/JDTJavaIRTests.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
|
@ -27,7 +27,7 @@
|
|||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.wala.cast.java.test.JDTJavaIRTests"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.cast.java.jdt.test"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.ide.jdt.test"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dcom.ibm.wala.tracefile=/tmp/jdt15tests.txt -Xmx1024M -ea"/>
|
||||
<stringAttribute key="pde.version" value="3.3"/>
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -6,71 +6,14 @@
|
|||
*****************************************************************************/
|
||||
package com.ibm.wala.cast.java.test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.cast.java.client.JDTJavaSourceAnalysisEngine;
|
||||
import com.ibm.wala.cast.java.client.JavaSourceAnalysisEngine;
|
||||
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
|
||||
import com.ibm.wala.cast.java.test.ide.IDEIRTestUtil;
|
||||
import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
|
||||
import com.ibm.wala.core.tests.plugin.CoreTestsPlugin;
|
||||
import com.ibm.wala.ide.tests.util.EclipseTestUtil;
|
||||
import com.ibm.wala.ide.util.EclipseFileProvider;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
||||
import com.ibm.wala.ipa.callgraph.Entrypoint;
|
||||
import com.ibm.wala.ipa.callgraph.impl.Util;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
|
||||
public class JDTJava15IRTests extends IRTests {
|
||||
public class JDTJava15IRTests extends JDTJavaTest {
|
||||
|
||||
public JDTJava15IRTests() {
|
||||
super(JDTJavaIRTests.PROJECT_NAME);
|
||||
super(JDTJavaIRTests.PROJECT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateScope(JavaSourceAnalysisEngine engine, Collection<String> sources, List<String> libs) throws IOException {
|
||||
IDEIRTestUtil.populateScope(projectName, (JDTJavaSourceAnalysisEngine)engine, sources, libs);
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() {
|
||||
EclipseTestUtil.importZippedProject(TestPlugin.getDefault(), JDTJavaIRTests.PROJECT_NAME, JDTJavaIRTests.PROJECT_ZIP, new NullProgressMonitor());
|
||||
System.err.println("finish importing project");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() {
|
||||
EclipseTestUtil.destroyProject(JDTJavaIRTests.PROJECT_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JavaSourceAnalysisEngine getAnalysisEngine(final String[] mainClassDescriptors) {
|
||||
JavaSourceAnalysisEngine engine = new JDTJavaSourceAnalysisEngine(JDTJavaIRTests.PROJECT_NAME) {
|
||||
@Override
|
||||
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
|
||||
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha, mainClassDescriptors);
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
engine.setExclusionsFile((new EclipseFileProvider())
|
||||
.getFileFromPlugin(CoreTestsPlugin.getDefault(), CallGraphTestUtil.REGRESSION_EXCLUSIONS).getAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
Assert.assertFalse("Cannot find exclusions file", true);
|
||||
}
|
||||
|
||||
return engine;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAnonGeneNullarySimple() {
|
||||
runTest(singlePkgTestSrc("javaonepointfive"), rtJar, simplePkgTestEntryPoint("javaonepointfive"), emptyList, true);
|
||||
|
|
|
@ -37,28 +37,12 @@
|
|||
*/
|
||||
package com.ibm.wala.cast.java.test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import com.ibm.wala.cast.java.client.JDTJavaSourceAnalysisEngine;
|
||||
import com.ibm.wala.cast.java.client.JavaSourceAnalysisEngine;
|
||||
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
|
||||
import com.ibm.wala.cast.java.test.ide.IDEIRTestUtil;
|
||||
import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
|
||||
import com.ibm.wala.core.tests.plugin.CoreTestsPlugin;
|
||||
import com.ibm.wala.ide.tests.util.EclipseTestUtil;
|
||||
import com.ibm.wala.ide.util.EclipseFileProvider;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
||||
import com.ibm.wala.ipa.callgraph.Entrypoint;
|
||||
import com.ibm.wala.ipa.callgraph.impl.Util;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
import com.ibm.wala.cast.java.jdt.test.Activator;
|
||||
import com.ibm.wala.client.AbstractAnalysisEngine;
|
||||
import com.ibm.wala.ide.tests.util.EclipseTestUtil.ZippedProjectData;
|
||||
|
||||
public class JDTJavaIRTests extends JavaIRTests {
|
||||
|
||||
|
@ -66,42 +50,21 @@ public class JDTJavaIRTests extends JavaIRTests {
|
|||
|
||||
public static final String PROJECT_ZIP = "test_project.zip";
|
||||
|
||||
public static final ZippedProjectData PROJECT = new ZippedProjectData(Activator.getDefault(), PROJECT_NAME, PROJECT_ZIP);
|
||||
|
||||
private final ZippedProjectData project;
|
||||
|
||||
public JDTJavaIRTests() {
|
||||
super(PROJECT_NAME);
|
||||
this(PROJECT);
|
||||
}
|
||||
|
||||
private JDTJavaIRTests(ZippedProjectData project) {
|
||||
super(project.projectName);
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateScope(JavaSourceAnalysisEngine engine, Collection<String> sources, List<String> libs) throws IOException {
|
||||
IDEIRTestUtil.populateScope(projectName, (JDTJavaSourceAnalysisEngine)engine, sources, libs);
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() {
|
||||
EclipseTestUtil.importZippedProject(TestPlugin.getDefault(), PROJECT_NAME, PROJECT_ZIP, new NullProgressMonitor());
|
||||
System.err.println("finish importing project");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() {
|
||||
EclipseTestUtil.destroyProject(PROJECT_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JavaSourceAnalysisEngine getAnalysisEngine(final String[] mainClassDescriptors) {
|
||||
JavaSourceAnalysisEngine engine = new JDTJavaSourceAnalysisEngine(PROJECT_NAME) {
|
||||
@Override
|
||||
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
|
||||
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha, mainClassDescriptors);
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
engine.setExclusionsFile((new EclipseFileProvider())
|
||||
.getFileFromPlugin(CoreTestsPlugin.getDefault(), CallGraphTestUtil.REGRESSION_EXCLUSIONS).getAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
Assert.assertFalse("Cannot find exclusions file", true);
|
||||
}
|
||||
|
||||
return engine;
|
||||
protected AbstractAnalysisEngine getAnalysisEngine(final String[] mainClassDescriptors, Collection<String> sources, List<String> libs) {
|
||||
return JDTJavaTest.makeAnalysisEngine(mainClassDescriptors, sources, libs, project);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
package com.ibm.wala.cast.java.test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
import com.ibm.wala.cast.java.client.JDTJavaSourceAnalysisEngine;
|
||||
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
|
||||
import com.ibm.wala.cast.java.jdt.test.Activator;
|
||||
import com.ibm.wala.client.AbstractAnalysisEngine;
|
||||
import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
|
||||
import com.ibm.wala.ide.tests.util.EclipseTestUtil.ZippedProjectData;
|
||||
import com.ibm.wala.ide.util.EclipseFileProvider;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
||||
import com.ibm.wala.ipa.callgraph.Entrypoint;
|
||||
import com.ibm.wala.ipa.callgraph.impl.Util;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
|
||||
public abstract class JDTJavaTest extends IRTests {
|
||||
|
||||
private final ZippedProjectData project;
|
||||
|
||||
public JDTJavaTest(ZippedProjectData project) {
|
||||
super(project.projectName);
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractAnalysisEngine getAnalysisEngine(final String[] mainClassDescriptors, Collection<String> sources, List<String> libs) {
|
||||
return makeAnalysisEngine(mainClassDescriptors, sources, libs, project);
|
||||
}
|
||||
|
||||
static AbstractAnalysisEngine makeAnalysisEngine(final String[] mainClassDescriptors, Collection<String> sources, List<String> libs, ZippedProjectData project) {
|
||||
AbstractAnalysisEngine engine;
|
||||
try {
|
||||
engine = new JDTJavaSourceAnalysisEngine(project.projectName) {
|
||||
@Override
|
||||
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
|
||||
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha, mainClassDescriptors);
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
engine.setExclusionsFile((new EclipseFileProvider())
|
||||
.getFileFromPlugin(Activator.getDefault(), CallGraphTestUtil.REGRESSION_EXCLUSIONS).getAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
Assert.assertFalse("Cannot find exclusions file", true);
|
||||
}
|
||||
|
||||
return engine;
|
||||
} catch (IOException e1) {
|
||||
Assert.fail(e1.getMessage());
|
||||
return null;
|
||||
} catch (CoreException e1) {
|
||||
Assert.fail(e1.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/******************************************************************************
|
||||
* Copyright (c) 2002 - 2006 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* Created on Oct 3, 2005
|
||||
*/
|
||||
package com.ibm.wala.cast.java.test.ide;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import com.ibm.wala.cast.java.client.JDTJavaSourceAnalysisEngine;
|
||||
import com.ibm.wala.classLoader.JarFileModule;
|
||||
|
||||
public class IDEIRTestUtil {
|
||||
|
||||
public static void populateScope(String projectName, JDTJavaSourceAnalysisEngine engine, Collection<String> sources, List<String> libs) throws IOException {
|
||||
|
||||
boolean foundLib = false;
|
||||
for (String lib : libs) {
|
||||
File libFile = new File(lib);
|
||||
if (libFile.exists()) {
|
||||
foundLib = true;
|
||||
engine.addSystemModule(new JarFileModule(new JarFile(libFile)));
|
||||
}
|
||||
}
|
||||
assert foundLib : "couldn't find library file from " + libs;
|
||||
|
||||
for (String srcFilePath : sources) {
|
||||
engine.addSourceModule(srcFilePath);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,305 +1,303 @@
|
|||
/**
|
||||
* Refinement Analysis Tools is Copyright (c) 2007 The Regents of the
|
||||
* University of California (Regents). Provided that this notice and
|
||||
* the following two paragraphs are included in any distribution of
|
||||
* Refinement Analysis Tools or its derivative work, Regents agrees
|
||||
* not to assert any of Regents' copyright rights in Refinement
|
||||
* Analysis Tools against recipient for recipient's reproduction,
|
||||
* preparation of derivative works, public display, public
|
||||
* performance, distribution or sublicensing of Refinement Analysis
|
||||
* Tools and derivative works, in source code and object code form.
|
||||
* This agreement not to assert does not confer, by implication,
|
||||
* estoppel, or otherwise any license or rights in any intellectual
|
||||
* property of Regents, including, but not limited to, any patents
|
||||
* of Regents or Regents' employees.
|
||||
*
|
||||
* IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT,
|
||||
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
|
||||
* INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE
|
||||
* AND ITS DOCUMENTATION, EVEN IF REGENTS HAS BEEN ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND FURTHER DISCLAIMS ANY STATUTORY
|
||||
* WARRANTY OF NON-INFRINGEMENT. THE SOFTWARE AND ACCOMPANYING
|
||||
* DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS
|
||||
* IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
|
||||
* UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*/
|
||||
package com.ibm.wala.demandpa.driver;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
|
||||
import com.ibm.wala.core.tests.util.TestConstants;
|
||||
import com.ibm.wala.demandpa.alg.ContextSensitiveStateMachine;
|
||||
import com.ibm.wala.demandpa.alg.DemandRefinementPointsTo;
|
||||
import com.ibm.wala.demandpa.alg.DemandRefinementPointsTo.PointsToResult;
|
||||
import com.ibm.wala.demandpa.alg.refinepolicy.FieldRefinePolicy;
|
||||
import com.ibm.wala.demandpa.alg.refinepolicy.ManualFieldPolicy;
|
||||
import com.ibm.wala.demandpa.alg.refinepolicy.ManualRefinementPolicy;
|
||||
import com.ibm.wala.demandpa.alg.refinepolicy.RefinementPolicyFactory;
|
||||
import com.ibm.wala.demandpa.alg.refinepolicy.TunedRefinementPolicy;
|
||||
import com.ibm.wala.demandpa.alg.statemachine.StateMachineFactory;
|
||||
import com.ibm.wala.demandpa.flowgraph.IFlowLabel;
|
||||
import com.ibm.wala.demandpa.util.MemoryAccessMap;
|
||||
import com.ibm.wala.demandpa.util.SimpleMemoryAccessMap;
|
||||
import com.ibm.wala.ide.util.ProgressMaster;
|
||||
import com.ibm.wala.ide.util.ProgressMonitorDelegate;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisCache;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
|
||||
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.CallGraphBuilder;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraphBuilderCancelException;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraphStats;
|
||||
import com.ibm.wala.ipa.callgraph.Entrypoint;
|
||||
import com.ibm.wala.ipa.callgraph.impl.Util;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.HeapModel;
|
||||
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.cha.ClassHierarchy;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchyException;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
import com.ibm.wala.properties.WalaProperties;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.SSACheckCastInstruction;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.types.ClassLoaderReference;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.Predicate;
|
||||
import com.ibm.wala.util.WalaException;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
|
||||
/**
|
||||
* Uses a demand-driven points-to analysis to check the safety of downcasts.
|
||||
*
|
||||
* @author Manu Sridharan
|
||||
*
|
||||
*/
|
||||
public class DemandCastChecker {
|
||||
|
||||
// maximum number of casts to check
|
||||
private static final int MAX_CASTS = Integer.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* @param args
|
||||
* @throws CancelException
|
||||
* @throws IllegalArgumentException
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void main(String[] args) throws IllegalArgumentException, CancelException, IOException {
|
||||
try {
|
||||
Properties p = new Properties();
|
||||
p.putAll(WalaProperties.loadProperties());
|
||||
} catch (WalaException e) {
|
||||
e.printStackTrace();
|
||||
Assertions.UNREACHABLE();
|
||||
}
|
||||
|
||||
runTestCase(TestConstants.JLEX_MAIN, TestConstants.JLEX, "JLex");
|
||||
// runTestCase(TestConstants.HELLO_MAIN, TestConstants.HELLO, "Hello");
|
||||
|
||||
}
|
||||
|
||||
public static void runTestCase(String mainClass, String scopeFile, String benchName) throws IllegalArgumentException,
|
||||
CancelException, IOException {
|
||||
System.err.println("=====BENCHMARK " + benchName + "=====");
|
||||
System.err.println("analyzing " + benchName);
|
||||
DemandRefinementPointsTo dmp = null;
|
||||
try {
|
||||
dmp = makeDemandPointerAnalysis(scopeFile, mainClass, benchName);
|
||||
findFailingCasts(dmp.getBaseCallGraph(), dmp);
|
||||
} catch (ClassHierarchyException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.err.println("=*=*=*=*=*=*=*=*=*=*=*=*=*=*");
|
||||
System.err.println("");
|
||||
System.err.println("");
|
||||
}
|
||||
|
||||
private static DemandRefinementPointsTo makeDemandPointerAnalysis(String scopeFile, String mainClass, String benchName)
|
||||
throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(scopeFile, getExclusions(benchName));
|
||||
// build a type hierarchy
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
|
||||
// set up call graph construction options; mainly what should be considered
|
||||
// entrypoints?
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, mainClass);
|
||||
AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
|
||||
|
||||
System.err.print("constructing call graph...");
|
||||
final Pair<CallGraph, PointerAnalysis> cgAndPA = buildCallGraph(scope, cha, options);
|
||||
CallGraph cg = cgAndPA.fst;
|
||||
System.err.println("done");
|
||||
System.err.println(CallGraphStats.getStats(cg));
|
||||
MemoryAccessMap fam = new SimpleMemoryAccessMap(cg, cgAndPA.snd.getHeapModel(), false);
|
||||
DemandRefinementPointsTo fullDemandPointsTo = DemandRefinementPointsTo.makeWithDefaultFlowGraph(cg, heapModel, fam, cha, options, makeStateMachineFactory());
|
||||
fullDemandPointsTo.setRefinementPolicyFactory(chooseRefinePolicyFactory(cha));
|
||||
return fullDemandPointsTo;
|
||||
}
|
||||
|
||||
private static String getExclusions(String benchName) {
|
||||
return CallGraphTestUtil.REGRESSION_EXCLUSIONS;
|
||||
}
|
||||
|
||||
// if true, construct up-front call graph cheaply (0-CFA)
|
||||
private static final boolean CHEAP_CG = true;
|
||||
|
||||
private static HeapModel heapModel;
|
||||
|
||||
/**
|
||||
* builds a call graph, and sets the corresponding heap model for analysis
|
||||
*
|
||||
* @param scope
|
||||
* @param cha
|
||||
* @param options
|
||||
* @return
|
||||
* @throws CancelException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
private static Pair<CallGraph, PointerAnalysis> buildCallGraph(AnalysisScope scope, ClassHierarchy cha, AnalysisOptions options)
|
||||
throws IllegalArgumentException, CancelException {
|
||||
CallGraph retCG = null;
|
||||
PointerAnalysis retPA = null;
|
||||
final AnalysisCache cache = new AnalysisCache();
|
||||
CallGraphBuilder builder;
|
||||
if (CHEAP_CG) {
|
||||
builder = Util.makeZeroCFABuilder(options, cache, cha, scope);
|
||||
// we want vanilla 0-1 CFA, which has one abstract loc per allocation
|
||||
heapModel = Util.makeVanillaZeroOneCFABuilder(options, cache, cha, scope);
|
||||
} else {
|
||||
builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope);
|
||||
heapModel = (HeapModel) builder;
|
||||
}
|
||||
ProgressMaster master = ProgressMaster.make(new NullProgressMonitor());
|
||||
master.setMillisPerWorkItem(360000);
|
||||
master.beginTask("runSolver", 1);
|
||||
try {
|
||||
retCG = builder.makeCallGraph(options, ProgressMonitorDelegate.createProgressMonitorDelegate(master));
|
||||
retPA = builder.getPointerAnalysis();
|
||||
} catch (CallGraphBuilderCancelException e) {
|
||||
System.err.println("TIMED OUT!!");
|
||||
retCG = e.getPartialCallGraph();
|
||||
retPA = e.getPartialPointerAnalysis();
|
||||
}
|
||||
return Pair.make(retCG, retPA);
|
||||
}
|
||||
|
||||
private static RefinementPolicyFactory chooseRefinePolicyFactory(ClassHierarchy cha) {
|
||||
if (true) {
|
||||
return new TunedRefinementPolicy.Factory(cha);
|
||||
} else {
|
||||
return new ManualRefinementPolicy.Factory(cha);
|
||||
}
|
||||
}
|
||||
|
||||
private static StateMachineFactory<IFlowLabel> makeStateMachineFactory() {
|
||||
return new ContextSensitiveStateMachine.Factory();
|
||||
}
|
||||
|
||||
private static List<Pair<CGNode, SSACheckCastInstruction>> findFailingCasts(CallGraph cg, DemandRefinementPointsTo dmp) {
|
||||
final IClassHierarchy cha = dmp.getClassHierarchy();
|
||||
List<Pair<CGNode, SSACheckCastInstruction>> failing = new ArrayList<Pair<CGNode, SSACheckCastInstruction>>();
|
||||
|
||||
int numSafe = 0, numMightFail = 0;
|
||||
outer: for (Iterator<? extends CGNode> nodeIter = cg.iterator(); nodeIter.hasNext();) {
|
||||
CGNode node = nodeIter.next();
|
||||
TypeReference declaringClass = node.getMethod().getReference().getDeclaringClass();
|
||||
// skip library classes
|
||||
if (declaringClass.getClassLoader().equals(ClassLoaderReference.Primordial)) {
|
||||
continue;
|
||||
}
|
||||
IR ir = node.getIR();
|
||||
if (ir == null)
|
||||
continue;
|
||||
SSAInstruction[] instrs = ir.getInstructions();
|
||||
for (int i = 0; i < instrs.length; i++) {
|
||||
if (numSafe + numMightFail > MAX_CASTS)
|
||||
break outer;
|
||||
SSAInstruction instruction = instrs[i];
|
||||
if (instruction instanceof SSACheckCastInstruction) {
|
||||
SSACheckCastInstruction castInstr = (SSACheckCastInstruction) instruction;
|
||||
final TypeReference[] declaredResultTypes = castInstr.getDeclaredResultTypes();
|
||||
|
||||
boolean primOnly = true;
|
||||
for (TypeReference t : declaredResultTypes) {
|
||||
if (! t.isPrimitiveType()) {
|
||||
primOnly = false;
|
||||
}
|
||||
}
|
||||
if (primOnly) {
|
||||
continue;
|
||||
}
|
||||
|
||||
System.err.println("CHECKING " + castInstr + " in " + node.getMethod());
|
||||
PointerKey castedPk = heapModel.getPointerKeyForLocal(node, castInstr.getUse(0));
|
||||
Predicate<InstanceKey> castPred = new Predicate<InstanceKey>() {
|
||||
|
||||
@Override
|
||||
public boolean test(InstanceKey ik) {
|
||||
TypeReference ikTypeRef = ik.getConcreteType().getReference();
|
||||
for (TypeReference t : declaredResultTypes) {
|
||||
if (cha.isAssignableFrom(cha.lookupClass(t), cha.lookupClass(ikTypeRef))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
long startTime = System.currentTimeMillis();
|
||||
Pair<PointsToResult, Collection<InstanceKey>> queryResult = dmp.getPointsTo(castedPk, castPred);
|
||||
long runningTime = System.currentTimeMillis() - startTime;
|
||||
System.err.println("running time: " + runningTime + "ms");
|
||||
final FieldRefinePolicy fieldRefinePolicy = dmp.getRefinementPolicy().getFieldRefinePolicy();
|
||||
switch (queryResult.fst) {
|
||||
case SUCCESS:
|
||||
System.err.println("SAFE: " + castInstr + " in " + node.getMethod());
|
||||
if (fieldRefinePolicy instanceof ManualFieldPolicy) {
|
||||
ManualFieldPolicy hackedFieldPolicy = (ManualFieldPolicy) fieldRefinePolicy;
|
||||
System.err.println(hackedFieldPolicy.getHistory());
|
||||
}
|
||||
System.err.println("TRAVERSED " + dmp.getNumNodesTraversed() + " nodes");
|
||||
numSafe++;
|
||||
break;
|
||||
case NOMOREREFINE:
|
||||
if (queryResult.snd != null) {
|
||||
System.err.println("MIGHT FAIL: no more refinement possible for " + castInstr + " in " + node.getMethod());
|
||||
} else {
|
||||
System.err.println("MIGHT FAIL: exceeded budget for " + castInstr + " in " + node.getMethod());
|
||||
}
|
||||
failing.add(Pair.make(node, castInstr));
|
||||
numMightFail++;
|
||||
break;
|
||||
case BUDGETEXCEEDED:
|
||||
System.err.println("MIGHT FAIL: exceeded budget for " + castInstr + " in " + node.getMethod());
|
||||
failing.add(Pair.make(node, castInstr));
|
||||
numMightFail++;
|
||||
break;
|
||||
default:
|
||||
Assertions.UNREACHABLE();
|
||||
}
|
||||
}
|
||||
}
|
||||
// break outer;
|
||||
}
|
||||
System.err.println("TOTAL SAFE: " + numSafe);
|
||||
System.err.println("TOTAL MIGHT FAIL: " + numMightFail);
|
||||
return failing;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Refinement Analysis Tools is Copyright (c) 2007 The Regents of the
|
||||
* University of California (Regents). Provided that this notice and
|
||||
* the following two paragraphs are included in any distribution of
|
||||
* Refinement Analysis Tools or its derivative work, Regents agrees
|
||||
* not to assert any of Regents' copyright rights in Refinement
|
||||
* Analysis Tools against recipient for recipient's reproduction,
|
||||
* preparation of derivative works, public display, public
|
||||
* performance, distribution or sublicensing of Refinement Analysis
|
||||
* Tools and derivative works, in source code and object code form.
|
||||
* This agreement not to assert does not confer, by implication,
|
||||
* estoppel, or otherwise any license or rights in any intellectual
|
||||
* property of Regents, including, but not limited to, any patents
|
||||
* of Regents or Regents' employees.
|
||||
*
|
||||
* IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT,
|
||||
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
|
||||
* INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE
|
||||
* AND ITS DOCUMENTATION, EVEN IF REGENTS HAS BEEN ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND FURTHER DISCLAIMS ANY STATUTORY
|
||||
* WARRANTY OF NON-INFRINGEMENT. THE SOFTWARE AND ACCOMPANYING
|
||||
* DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS
|
||||
* IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
|
||||
* UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*/
|
||||
package com.ibm.wala.demandpa.driver;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
|
||||
import com.ibm.wala.core.tests.util.TestConstants;
|
||||
import com.ibm.wala.demandpa.alg.ContextSensitiveStateMachine;
|
||||
import com.ibm.wala.demandpa.alg.DemandRefinementPointsTo;
|
||||
import com.ibm.wala.demandpa.alg.DemandRefinementPointsTo.PointsToResult;
|
||||
import com.ibm.wala.demandpa.alg.refinepolicy.FieldRefinePolicy;
|
||||
import com.ibm.wala.demandpa.alg.refinepolicy.ManualFieldPolicy;
|
||||
import com.ibm.wala.demandpa.alg.refinepolicy.ManualRefinementPolicy;
|
||||
import com.ibm.wala.demandpa.alg.refinepolicy.RefinementPolicyFactory;
|
||||
import com.ibm.wala.demandpa.alg.refinepolicy.TunedRefinementPolicy;
|
||||
import com.ibm.wala.demandpa.alg.statemachine.StateMachineFactory;
|
||||
import com.ibm.wala.demandpa.flowgraph.IFlowLabel;
|
||||
import com.ibm.wala.demandpa.util.MemoryAccessMap;
|
||||
import com.ibm.wala.demandpa.util.SimpleMemoryAccessMap;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisCache;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
|
||||
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.CallGraphBuilder;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraphBuilderCancelException;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraphStats;
|
||||
import com.ibm.wala.ipa.callgraph.Entrypoint;
|
||||
import com.ibm.wala.ipa.callgraph.impl.Util;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.HeapModel;
|
||||
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.cha.ClassHierarchy;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchyException;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
import com.ibm.wala.properties.WalaProperties;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.SSACheckCastInstruction;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.types.ClassLoaderReference;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.NullProgressMonitor;
|
||||
import com.ibm.wala.util.Predicate;
|
||||
import com.ibm.wala.util.ProgressMaster;
|
||||
import com.ibm.wala.util.WalaException;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
|
||||
/**
|
||||
* Uses a demand-driven points-to analysis to check the safety of downcasts.
|
||||
*
|
||||
* @author Manu Sridharan
|
||||
*
|
||||
*/
|
||||
public class DemandCastChecker {
|
||||
|
||||
// maximum number of casts to check
|
||||
private static final int MAX_CASTS = Integer.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* @param args
|
||||
* @throws CancelException
|
||||
* @throws IllegalArgumentException
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void main(String[] args) throws IllegalArgumentException, CancelException, IOException {
|
||||
try {
|
||||
Properties p = new Properties();
|
||||
p.putAll(WalaProperties.loadProperties());
|
||||
} catch (WalaException e) {
|
||||
e.printStackTrace();
|
||||
Assertions.UNREACHABLE();
|
||||
}
|
||||
|
||||
runTestCase(TestConstants.JLEX_MAIN, TestConstants.JLEX, "JLex");
|
||||
// runTestCase(TestConstants.HELLO_MAIN, TestConstants.HELLO, "Hello");
|
||||
|
||||
}
|
||||
|
||||
public static void runTestCase(String mainClass, String scopeFile, String benchName) throws IllegalArgumentException,
|
||||
CancelException, IOException {
|
||||
System.err.println("=====BENCHMARK " + benchName + "=====");
|
||||
System.err.println("analyzing " + benchName);
|
||||
DemandRefinementPointsTo dmp = null;
|
||||
try {
|
||||
dmp = makeDemandPointerAnalysis(scopeFile, mainClass, benchName);
|
||||
findFailingCasts(dmp.getBaseCallGraph(), dmp);
|
||||
} catch (ClassHierarchyException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.err.println("=*=*=*=*=*=*=*=*=*=*=*=*=*=*");
|
||||
System.err.println("");
|
||||
System.err.println("");
|
||||
}
|
||||
|
||||
private static DemandRefinementPointsTo makeDemandPointerAnalysis(String scopeFile, String mainClass, String benchName)
|
||||
throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(scopeFile, getExclusions(benchName));
|
||||
// build a type hierarchy
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
|
||||
// set up call graph construction options; mainly what should be considered
|
||||
// entrypoints?
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, mainClass);
|
||||
AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
|
||||
|
||||
System.err.print("constructing call graph...");
|
||||
final Pair<CallGraph, PointerAnalysis> cgAndPA = buildCallGraph(scope, cha, options);
|
||||
CallGraph cg = cgAndPA.fst;
|
||||
System.err.println("done");
|
||||
System.err.println(CallGraphStats.getStats(cg));
|
||||
MemoryAccessMap fam = new SimpleMemoryAccessMap(cg, cgAndPA.snd.getHeapModel(), false);
|
||||
DemandRefinementPointsTo fullDemandPointsTo = DemandRefinementPointsTo.makeWithDefaultFlowGraph(cg, heapModel, fam, cha, options, makeStateMachineFactory());
|
||||
fullDemandPointsTo.setRefinementPolicyFactory(chooseRefinePolicyFactory(cha));
|
||||
return fullDemandPointsTo;
|
||||
}
|
||||
|
||||
private static String getExclusions(String benchName) {
|
||||
return CallGraphTestUtil.REGRESSION_EXCLUSIONS;
|
||||
}
|
||||
|
||||
// if true, construct up-front call graph cheaply (0-CFA)
|
||||
private static final boolean CHEAP_CG = true;
|
||||
|
||||
private static HeapModel heapModel;
|
||||
|
||||
/**
|
||||
* builds a call graph, and sets the corresponding heap model for analysis
|
||||
*
|
||||
* @param scope
|
||||
* @param cha
|
||||
* @param options
|
||||
* @return
|
||||
* @throws CancelException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
private static Pair<CallGraph, PointerAnalysis> buildCallGraph(AnalysisScope scope, ClassHierarchy cha, AnalysisOptions options)
|
||||
throws IllegalArgumentException, CancelException {
|
||||
CallGraph retCG = null;
|
||||
PointerAnalysis retPA = null;
|
||||
final AnalysisCache cache = new AnalysisCache();
|
||||
CallGraphBuilder builder;
|
||||
if (CHEAP_CG) {
|
||||
builder = Util.makeZeroCFABuilder(options, cache, cha, scope);
|
||||
// we want vanilla 0-1 CFA, which has one abstract loc per allocation
|
||||
heapModel = Util.makeVanillaZeroOneCFABuilder(options, cache, cha, scope);
|
||||
} else {
|
||||
builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope);
|
||||
heapModel = (HeapModel) builder;
|
||||
}
|
||||
ProgressMaster master = ProgressMaster.make(new NullProgressMonitor());
|
||||
master.setMillisPerWorkItem(360000);
|
||||
master.beginTask("runSolver", 1);
|
||||
try {
|
||||
retCG = builder.makeCallGraph(options, master);
|
||||
retPA = builder.getPointerAnalysis();
|
||||
} catch (CallGraphBuilderCancelException e) {
|
||||
System.err.println("TIMED OUT!!");
|
||||
retCG = e.getPartialCallGraph();
|
||||
retPA = e.getPartialPointerAnalysis();
|
||||
}
|
||||
return Pair.make(retCG, retPA);
|
||||
}
|
||||
|
||||
private static RefinementPolicyFactory chooseRefinePolicyFactory(ClassHierarchy cha) {
|
||||
if (true) {
|
||||
return new TunedRefinementPolicy.Factory(cha);
|
||||
} else {
|
||||
return new ManualRefinementPolicy.Factory(cha);
|
||||
}
|
||||
}
|
||||
|
||||
private static StateMachineFactory<IFlowLabel> makeStateMachineFactory() {
|
||||
return new ContextSensitiveStateMachine.Factory();
|
||||
}
|
||||
|
||||
private static List<Pair<CGNode, SSACheckCastInstruction>> findFailingCasts(CallGraph cg, DemandRefinementPointsTo dmp) {
|
||||
final IClassHierarchy cha = dmp.getClassHierarchy();
|
||||
List<Pair<CGNode, SSACheckCastInstruction>> failing = new ArrayList<Pair<CGNode, SSACheckCastInstruction>>();
|
||||
|
||||
int numSafe = 0, numMightFail = 0;
|
||||
outer: for (Iterator<? extends CGNode> nodeIter = cg.iterator(); nodeIter.hasNext();) {
|
||||
CGNode node = nodeIter.next();
|
||||
TypeReference declaringClass = node.getMethod().getReference().getDeclaringClass();
|
||||
// skip library classes
|
||||
if (declaringClass.getClassLoader().equals(ClassLoaderReference.Primordial)) {
|
||||
continue;
|
||||
}
|
||||
IR ir = node.getIR();
|
||||
if (ir == null)
|
||||
continue;
|
||||
SSAInstruction[] instrs = ir.getInstructions();
|
||||
for (int i = 0; i < instrs.length; i++) {
|
||||
if (numSafe + numMightFail > MAX_CASTS)
|
||||
break outer;
|
||||
SSAInstruction instruction = instrs[i];
|
||||
if (instruction instanceof SSACheckCastInstruction) {
|
||||
SSACheckCastInstruction castInstr = (SSACheckCastInstruction) instruction;
|
||||
final TypeReference[] declaredResultTypes = castInstr.getDeclaredResultTypes();
|
||||
|
||||
boolean primOnly = true;
|
||||
for (TypeReference t : declaredResultTypes) {
|
||||
if (! t.isPrimitiveType()) {
|
||||
primOnly = false;
|
||||
}
|
||||
}
|
||||
if (primOnly) {
|
||||
continue;
|
||||
}
|
||||
|
||||
System.err.println("CHECKING " + castInstr + " in " + node.getMethod());
|
||||
PointerKey castedPk = heapModel.getPointerKeyForLocal(node, castInstr.getUse(0));
|
||||
Predicate<InstanceKey> castPred = new Predicate<InstanceKey>() {
|
||||
|
||||
@Override
|
||||
public boolean test(InstanceKey ik) {
|
||||
TypeReference ikTypeRef = ik.getConcreteType().getReference();
|
||||
for (TypeReference t : declaredResultTypes) {
|
||||
if (cha.isAssignableFrom(cha.lookupClass(t), cha.lookupClass(ikTypeRef))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
long startTime = System.currentTimeMillis();
|
||||
Pair<PointsToResult, Collection<InstanceKey>> queryResult = dmp.getPointsTo(castedPk, castPred);
|
||||
long runningTime = System.currentTimeMillis() - startTime;
|
||||
System.err.println("running time: " + runningTime + "ms");
|
||||
final FieldRefinePolicy fieldRefinePolicy = dmp.getRefinementPolicy().getFieldRefinePolicy();
|
||||
switch (queryResult.fst) {
|
||||
case SUCCESS:
|
||||
System.err.println("SAFE: " + castInstr + " in " + node.getMethod());
|
||||
if (fieldRefinePolicy instanceof ManualFieldPolicy) {
|
||||
ManualFieldPolicy hackedFieldPolicy = (ManualFieldPolicy) fieldRefinePolicy;
|
||||
System.err.println(hackedFieldPolicy.getHistory());
|
||||
}
|
||||
System.err.println("TRAVERSED " + dmp.getNumNodesTraversed() + " nodes");
|
||||
numSafe++;
|
||||
break;
|
||||
case NOMOREREFINE:
|
||||
if (queryResult.snd != null) {
|
||||
System.err.println("MIGHT FAIL: no more refinement possible for " + castInstr + " in " + node.getMethod());
|
||||
} else {
|
||||
System.err.println("MIGHT FAIL: exceeded budget for " + castInstr + " in " + node.getMethod());
|
||||
}
|
||||
failing.add(Pair.make(node, castInstr));
|
||||
numMightFail++;
|
||||
break;
|
||||
case BUDGETEXCEEDED:
|
||||
System.err.println("MIGHT FAIL: exceeded budget for " + castInstr + " in " + node.getMethod());
|
||||
failing.add(Pair.make(node, castInstr));
|
||||
numMightFail++;
|
||||
break;
|
||||
default:
|
||||
Assertions.UNREACHABLE();
|
||||
}
|
||||
}
|
||||
}
|
||||
// break outer;
|
||||
}
|
||||
System.err.println("TOTAL SAFE: " + numSafe);
|
||||
System.err.println("TOTAL MIGHT FAIL: " + numMightFail);
|
||||
return failing;
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
|
@ -1,278 +0,0 @@
|
|||
#Thu Feb 03 10:12:26 EST 2011
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.codeComplete.argumentPrefixes=
|
||||
org.eclipse.jdt.core.codeComplete.argumentSuffixes=
|
||||
org.eclipse.jdt.core.codeComplete.fieldPrefixes=
|
||||
org.eclipse.jdt.core.codeComplete.fieldSuffixes=
|
||||
org.eclipse.jdt.core.codeComplete.localPrefixes=
|
||||
org.eclipse.jdt.core.codeComplete.localSuffixes=
|
||||
org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
|
||||
org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
|
||||
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_field=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
|
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
|
||||
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_header=false
|
||||
org.eclipse.jdt.core.formatter.comment.format_html=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_line_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_source_code=true
|
||||
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
|
||||
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
|
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
|
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.comment.line_length=80
|
||||
org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
|
||||
org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
|
||||
org.eclipse.jdt.core.formatter.compact_else_if=true
|
||||
org.eclipse.jdt.core.formatter.continuation_indentation=2
|
||||
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
|
||||
org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
|
||||
org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
|
||||
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
|
||||
org.eclipse.jdt.core.formatter.indent_empty_lines=false
|
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
|
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
|
||||
org.eclipse.jdt.core.formatter.indentation.size=2
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.join_lines_in_comments=true
|
||||
org.eclipse.jdt.core.formatter.join_wrapped_lines=true
|
||||
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
|
||||
org.eclipse.jdt.core.formatter.lineSplit=132
|
||||
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
|
||||
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
|
||||
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
|
||||
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
|
||||
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
|
||||
org.eclipse.jdt.core.formatter.tabulation.char=space
|
||||
org.eclipse.jdt.core.formatter.tabulation.size=2
|
||||
org.eclipse.jdt.core.formatter.use_on_off_tags=false
|
||||
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
|
||||
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
|
||||
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
|
File diff suppressed because one or more lines are too long
|
@ -1,20 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Jdt Plug-in
|
||||
Bundle-SymbolicName: com.ibm.wala.cast.java.jdt
|
||||
Bundle-Version: 1.0.0
|
||||
Bundle-Activator: com.ibm.wala.cast.java.jdt.Activator
|
||||
Bundle-Vendor: IBM
|
||||
Require-Bundle: com.ibm.wala.cast,
|
||||
com.ibm.wala.cast.java,
|
||||
com.ibm.wala.core,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.jdt.core,
|
||||
org.eclipse.core.resources,
|
||||
com.ibm.wala.shrike,
|
||||
com.ibm.wala.ide
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.ibm.wala.cast.java.client,
|
||||
com.ibm.wala.cast.java.jdt,
|
||||
com.ibm.wala.cast.java.translator.jdt
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
|
@ -1,4 +1,4 @@
|
|||
#Mon Apr 13 15:21:17 EDT 2009
|
||||
eclipse.preferences.version=1
|
||||
formatter_profile=_WALA
|
||||
formatter_settings_version=11
|
||||
#Mon Apr 13 15:21:17 EDT 2009
|
||||
eclipse.preferences.version=1
|
||||
formatter_profile=_WALA
|
||||
formatter_settings_version=11
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.cast.java.test;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.ibm.wala.cast.java.client.JavaSourceAnalysisEngine;
|
||||
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
|
||||
import com.ibm.wala.cast.java.translator.polyglot.PolyglotJavaSourceAnalysisEngine;
|
||||
|
@ -18,13 +21,14 @@ import com.ibm.wala.ipa.cha.IClassHierarchy;
|
|||
public class PolyglotJLexTest extends JLexTest {
|
||||
|
||||
@Override
|
||||
protected JavaSourceAnalysisEngine getAnalysisEngine(final String[] mainClassDescriptors) {
|
||||
protected JavaSourceAnalysisEngine getAnalysisEngine(final String[] mainClassDescriptors, Collection<String> sources, List<String> libs) {
|
||||
JavaSourceAnalysisEngine engine = new PolyglotJavaSourceAnalysisEngine() {
|
||||
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
|
||||
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha, new String[] { "LJLex/Main" });
|
||||
}
|
||||
};
|
||||
engine.setExclusionsFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
populateScope(engine, sources, libs);
|
||||
return engine;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,13 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.cast.java.test;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.ibm.wala.cast.java.client.JavaSourceAnalysisEngine;
|
||||
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
|
||||
import com.ibm.wala.cast.java.translator.polyglot.PolyglotJavaSourceAnalysisEngine;
|
||||
import com.ibm.wala.client.AbstractAnalysisEngine;
|
||||
import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
||||
import com.ibm.wala.ipa.callgraph.Entrypoint;
|
||||
|
@ -22,13 +26,14 @@ public class PolyglotJavaIRTests extends JavaIRTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected JavaSourceAnalysisEngine getAnalysisEngine(final String[] mainClassDescriptors) {
|
||||
protected AbstractAnalysisEngine getAnalysisEngine(final String[] mainClassDescriptors, Collection<String> sources, List<String> libs) {
|
||||
JavaSourceAnalysisEngine engine = new PolyglotJavaSourceAnalysisEngine() {
|
||||
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
|
||||
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha, mainClassDescriptors);
|
||||
}
|
||||
};
|
||||
engine.setExclusionsFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
populateScope(engine, sources, libs);
|
||||
return engine;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.cast.java.test;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.ibm.wala.cast.java.client.JavaSourceAnalysisEngine;
|
||||
import com.ibm.wala.cast.java.examples.ast.SynchronizedBlockDuplicator;
|
||||
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
|
||||
|
@ -13,8 +16,8 @@ import com.ibm.wala.cast.java.translator.polyglot.IRTranslatorExtension;
|
|||
import com.ibm.wala.cast.java.translator.polyglot.JavaIRTranslatorExtension;
|
||||
import com.ibm.wala.cast.java.translator.polyglot.PolyglotJavaSourceAnalysisEngine;
|
||||
import com.ibm.wala.cast.tree.CAst;
|
||||
import com.ibm.wala.cast.tree.impl.CAstRewriter;
|
||||
import com.ibm.wala.cast.tree.impl.CAstRewriterFactory;
|
||||
import com.ibm.wala.cast.tree.rewrite.CAstRewriter;
|
||||
import com.ibm.wala.cast.tree.rewrite.CAstRewriterFactory;
|
||||
import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
||||
import com.ibm.wala.ipa.callgraph.Entrypoint;
|
||||
|
@ -23,7 +26,7 @@ import com.ibm.wala.ipa.cha.IClassHierarchy;
|
|||
|
||||
public class PolyglotSyncDuplicatorTest extends SyncDuplicatorTest {
|
||||
|
||||
protected JavaSourceAnalysisEngine getAnalysisEngine(final String[] mainClassDescriptors) {
|
||||
protected JavaSourceAnalysisEngine getAnalysisEngine(final String[] mainClassDescriptors, Collection<String> sources, List<String> libs) {
|
||||
JavaSourceAnalysisEngine engine = new PolyglotJavaSourceAnalysisEngine() {
|
||||
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
|
||||
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha, mainClassDescriptors);
|
||||
|
@ -41,6 +44,7 @@ public class PolyglotSyncDuplicatorTest extends SyncDuplicatorTest {
|
|||
|
||||
};
|
||||
engine.setExclusionsFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
populateScope(engine, sources, libs);
|
||||
return engine;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="source"/>
|
||||
<classpathentry kind="lib" path="lib/polyglot.jar"/>
|
||||
<classpathentry kind="lib" path="lib/java_cup.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/polyglot.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/java_cup.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/J2SE-1.5"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Mon Apr 13 15:38:50 EDT 2009
|
||||
eclipse.preferences.version=1
|
||||
formatter_profile=_WALA
|
||||
formatter_settings_version=11
|
||||
#Mon Apr 13 15:38:50 EDT 2009
|
||||
eclipse.preferences.version=1
|
||||
formatter_profile=_WALA
|
||||
formatter_settings_version=11
|
||||
|
|
|
@ -3,7 +3,6 @@ Bundle-ManifestVersion: 2
|
|||
Bundle-Name: WALA CAst Java Polyglot Plug-in
|
||||
Bundle-SymbolicName: com.ibm.wala.cast.java.polyglot
|
||||
Bundle-Version: 1.0.0
|
||||
Bundle-Activator: com.ibm.wala.cast.java.polyglot.Activator
|
||||
Bundle-Vendor: IBM
|
||||
Require-Bundle: com.ibm.wala.cast.java,
|
||||
com.ibm.wala.cast,
|
||||
|
@ -11,13 +10,10 @@ Require-Bundle: com.ibm.wala.cast.java,
|
|||
org.eclipse.core.runtime,
|
||||
com.ibm.wala.shrike,
|
||||
org.eclipse.jdt.core,
|
||||
org.eclipse.core.resources,
|
||||
com.ibm.wala.ide
|
||||
org.eclipse.core.resources
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.ibm.wala.cast.java.client.polyglot,
|
||||
com.ibm.wala.cast.java.polyglot;uses:="org.osgi.framework,org.eclipse.core.runtime",
|
||||
com.ibm.wala.cast.java.translator.polyglot;
|
||||
Export-Package: com.ibm.wala.cast.java.translator.polyglot;
|
||||
uses:="com.ibm.wala.types,
|
||||
polyglot.types,
|
||||
polyglot.util,
|
||||
|
@ -32,4 +28,21 @@ Export-Package: com.ibm.wala.cast.java.client.polyglot,
|
|||
polyglot.frontend.goals,
|
||||
com.ibm.wala.cast.tree.impl,
|
||||
com.ibm.wala.cast.java.translator,
|
||||
com.ibm.wala.cast.java.types"
|
||||
com.ibm.wala.cast.java.types",
|
||||
java_cup,
|
||||
java_cup.runtime,
|
||||
polyglot.ast,
|
||||
polyglot.dispatch,
|
||||
polyglot.frontend,
|
||||
polyglot.lex,
|
||||
polyglot.main,
|
||||
polyglot.parse,
|
||||
polyglot.qq,
|
||||
polyglot.types,
|
||||
polyglot.types.reflect,
|
||||
polyglot.util,
|
||||
polyglot.util.typedump,
|
||||
polyglot.visit
|
||||
Bundle-ClassPath: lib/java_cup.jar,
|
||||
lib/polyglot.jar,
|
||||
.
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
source.. = source/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
||||
.,\
|
||||
lib/java_cup.jar,\
|
||||
lib/polyglot.jar
|
||||
|
|
|
@ -1,77 +1,77 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="com.ibm.wala.cast.java.polyglot" default="getJars" basedir=".">
|
||||
|
||||
<property name="basews" value="${ws}"/>
|
||||
<property name="baseos" value="${os}"/>
|
||||
<property name="basearch" value="${arch}"/>
|
||||
<property name="basenl" value="${nl}"/>
|
||||
|
||||
<!-- Compiler settings. -->
|
||||
<property name="javacFailOnError" value="true"/>
|
||||
<property name="javacDebugInfo" value="on"/>
|
||||
<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"/>
|
||||
<!-- 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" -->
|
||||
<condition property="dir_bootclasspath" value="${java.home}/../Classes">
|
||||
<os family="mac"/>
|
||||
</condition>
|
||||
<property name="dir_bootclasspath" value="${java.home}/lib"/>
|
||||
<path id="path_bootclasspath">
|
||||
<fileset dir="${dir_bootclasspath}">
|
||||
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
<property name="bootclasspath" refid="path_bootclasspath"/>
|
||||
<property name="bundleJavacSource" value="${javacSource}"/>
|
||||
<property name="bundleJavacTarget" value="${javacTarget}"/>
|
||||
<property name="bundleBootClasspath" value="${bootclasspath}"/>
|
||||
|
||||
<target name="PolyglotPresent" depends="init">
|
||||
<available file="${plugin.destination}/lib/polyglot.jar" property="polyglot.present"/>
|
||||
</target>
|
||||
|
||||
<target name="fetchPolyglot" depends="PolyglotPresent" unless="polyglot.present">
|
||||
<delete dir="${temp.folder}"/>
|
||||
<mkdir dir="${temp.folder}"/>
|
||||
<echo message="Getting polyglot from svn; may take a few minutes"/>
|
||||
<exec executable="svn"
|
||||
dir="${temp.folder}">
|
||||
<arg value="--quiet"/>
|
||||
<arg value="checkout"/>
|
||||
<arg value="http://polyglot-compiler.googlecode.com/svn/trunk/"/>
|
||||
<arg value="polyglot-compiler-read-only"/>
|
||||
</exec>
|
||||
<ant target="jar" inheritAll="false" dir="${temp.folder}/polyglot-compiler-read-only/polyglot/" />
|
||||
<copy file="${temp.folder}/polyglot-compiler-read-only/polyglot/lib/polyglot.jar" tofile="${plugin.destination}/lib/polyglot.jar" />
|
||||
<copy file="${temp.folder}/polyglot-compiler-read-only/polyglot/lib/java_cup.jar" tofile="${plugin.destination}/lib/java_cup.jar" />
|
||||
<delete dir="${temp.folder}"/>
|
||||
</target>
|
||||
|
||||
<target name="getJars" depends="fetchPolyglot" />
|
||||
|
||||
|
||||
<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="properties" if="eclipse.running">
|
||||
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
|
||||
|
||||
</target>
|
||||
|
||||
</project>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="com.ibm.wala.cast.java.polyglot" default="getJars" basedir=".">
|
||||
|
||||
<property name="basews" value="${ws}"/>
|
||||
<property name="baseos" value="${os}"/>
|
||||
<property name="basearch" value="${arch}"/>
|
||||
<property name="basenl" value="${nl}"/>
|
||||
|
||||
<!-- Compiler settings. -->
|
||||
<property name="javacFailOnError" value="true"/>
|
||||
<property name="javacDebugInfo" value="on"/>
|
||||
<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"/>
|
||||
<!-- 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" -->
|
||||
<condition property="dir_bootclasspath" value="${java.home}/../Classes">
|
||||
<os family="mac"/>
|
||||
</condition>
|
||||
<property name="dir_bootclasspath" value="${java.home}/lib"/>
|
||||
<path id="path_bootclasspath">
|
||||
<fileset dir="${dir_bootclasspath}">
|
||||
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
<property name="bootclasspath" refid="path_bootclasspath"/>
|
||||
<property name="bundleJavacSource" value="${javacSource}"/>
|
||||
<property name="bundleJavacTarget" value="${javacTarget}"/>
|
||||
<property name="bundleBootClasspath" value="${bootclasspath}"/>
|
||||
|
||||
<target name="PolyglotPresent" depends="init">
|
||||
<available file="${plugin.destination}/lib/polyglot.jar" property="polyglot.present"/>
|
||||
</target>
|
||||
|
||||
<target name="fetchPolyglot" depends="PolyglotPresent" unless="polyglot.present">
|
||||
<delete dir="${temp.folder}"/>
|
||||
<mkdir dir="${temp.folder}"/>
|
||||
<echo message="Getting polyglot from svn; may take a few minutes"/>
|
||||
<exec executable="svn"
|
||||
dir="${temp.folder}">
|
||||
<arg value="--quiet"/>
|
||||
<arg value="checkout"/>
|
||||
<arg value="http://polyglot-compiler.googlecode.com/svn/trunk/"/>
|
||||
<arg value="polyglot-compiler-read-only"/>
|
||||
</exec>
|
||||
<ant target="jar" inheritAll="false" dir="${temp.folder}/polyglot-compiler-read-only/polyglot/" />
|
||||
<copy file="${temp.folder}/polyglot-compiler-read-only/polyglot/lib/polyglot.jar" tofile="${plugin.destination}/lib/polyglot.jar" />
|
||||
<copy file="${temp.folder}/polyglot-compiler-read-only/polyglot/lib/java_cup.jar" tofile="${plugin.destination}/lib/java_cup.jar" />
|
||||
<delete dir="${temp.folder}"/>
|
||||
</target>
|
||||
|
||||
<target name="getJars" depends="fetchPolyglot" />
|
||||
|
||||
|
||||
<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="properties" if="eclipse.running">
|
||||
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
|
||||
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -1,162 +0,0 @@
|
|||
/******************************************************************************
|
||||
* Copyright (c) 2002 - 2006 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*****************************************************************************/
|
||||
package com.ibm.wala.cast.java.client.polyglot;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.jdt.core.IJavaProject;
|
||||
|
||||
import com.ibm.wala.cast.ir.ssa.AstIRFactory;
|
||||
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
|
||||
import com.ibm.wala.cast.java.translator.polyglot.IRTranslatorExtension;
|
||||
import com.ibm.wala.cast.java.translator.polyglot.JavaIRTranslatorExtension;
|
||||
import com.ibm.wala.cast.java.translator.polyglot.PolyglotClassLoaderFactory;
|
||||
import com.ibm.wala.classLoader.BinaryDirectoryTreeModule;
|
||||
import com.ibm.wala.classLoader.ClassLoaderFactory;
|
||||
import com.ibm.wala.classLoader.Module;
|
||||
import com.ibm.wala.classLoader.SourceDirectoryTreeModule;
|
||||
import com.ibm.wala.ide.plugin.CorePlugin;
|
||||
import com.ibm.wala.ide.util.EclipseFileProvider;
|
||||
import com.ibm.wala.ide.util.EclipseProjectPath;
|
||||
import com.ibm.wala.ide.util.EclipseProjectPath.Loader;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisCache;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
||||
import com.ibm.wala.ipa.callgraph.Entrypoint;
|
||||
import com.ibm.wala.ipa.callgraph.impl.SetOfClasses;
|
||||
import com.ibm.wala.ipa.callgraph.impl.Util;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchy;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchyException;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
import com.ibm.wala.ssa.SSAOptions;
|
||||
import com.ibm.wala.ssa.SymbolTable;
|
||||
import com.ibm.wala.types.ClassLoaderReference;
|
||||
import com.ibm.wala.util.config.FileOfClasses;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.io.FileProvider;
|
||||
|
||||
/**
|
||||
* An {@link EclipseProjectAnalysisEngine} specialized for source code analysis with CAst
|
||||
*/
|
||||
public class EclipseProjectSourceAnalysisEngine extends EclipseProjectAnalysisEngine {
|
||||
|
||||
public static final String defaultFileExt = "java";
|
||||
|
||||
/**
|
||||
* file extension for source files in this Eclipse project
|
||||
*/
|
||||
final String fileExt;
|
||||
|
||||
public EclipseProjectSourceAnalysisEngine(IJavaProject project) throws IOException, CoreException {
|
||||
this(project, defaultFileExt);
|
||||
}
|
||||
|
||||
public EclipseProjectSourceAnalysisEngine(IJavaProject project, String fileExt) throws IOException, CoreException {
|
||||
super(project);
|
||||
this.fileExt = fileExt;
|
||||
try {
|
||||
setExclusionsFile((new EclipseFileProvider()).getFileFromPlugin(CorePlugin.getDefault(), "J2SEClassHierarchyExclusions.txt")
|
||||
.getAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
Assertions.UNREACHABLE("Cannot find exclusions file");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalysisCache makeDefaultCache() {
|
||||
return new AnalysisCache(AstIRFactory.makeDefaultFactory());
|
||||
}
|
||||
|
||||
protected AnalysisScope makeSourceAnalysisScope() {
|
||||
return new JavaSourceAnalysisScope();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildAnalysisScope() {
|
||||
try {
|
||||
scope = makeSourceAnalysisScope();
|
||||
if (getExclusionsFile() != null) {
|
||||
scope.setExclusions(FileOfClasses.createFileOfClasses(new File(getExclusionsFile())));
|
||||
}
|
||||
EclipseProjectPath epath = getEclipseProjectPath();
|
||||
|
||||
for (Module m : epath.getModules(Loader.PRIMORDIAL, true)) {
|
||||
scope.addToScope(scope.getPrimordialLoader(), m);
|
||||
}
|
||||
ClassLoaderReference app = scope.getApplicationLoader();
|
||||
ClassLoaderReference src = ((JavaSourceAnalysisScope) scope).getSourceLoader();
|
||||
for (Module m : epath.getModules(Loader.APPLICATION, true)) {
|
||||
if (m instanceof SourceDirectoryTreeModule) {
|
||||
scope.addToScope(src, m);
|
||||
} else {
|
||||
scope.addToScope(app, m);
|
||||
}
|
||||
}
|
||||
for (Module m : epath.getModules(Loader.EXTENSION, true)) {
|
||||
if (!(m instanceof BinaryDirectoryTreeModule))
|
||||
scope.addToScope(app, m);
|
||||
}
|
||||
/*
|
||||
* ClassLoaderReference src = ((JavaSourceAnalysisScope)scope).getSourceLoader(); for (Module m :
|
||||
* epath.getModules(Loader.APPLICATION, false)) { scope.addToScope(src, m); }
|
||||
*/
|
||||
|
||||
} catch (IOException e) {
|
||||
Assertions.UNREACHABLE(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public IRTranslatorExtension getTranslatorExtension() {
|
||||
return new JavaIRTranslatorExtension();
|
||||
}
|
||||
|
||||
protected ClassLoaderFactory getClassLoaderFactory(SetOfClasses exclusions, IRTranslatorExtension extInfo) {
|
||||
return new PolyglotClassLoaderFactory(exclusions, extInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClassHierarchy buildClassHierarchy() {
|
||||
IClassHierarchy cha = null;
|
||||
ClassLoaderFactory factory = getClassLoaderFactory(scope.getExclusions(), getTranslatorExtension());
|
||||
|
||||
try {
|
||||
cha = ClassHierarchy.make(getScope(), factory);
|
||||
} catch (ClassHierarchyException e) {
|
||||
System.err.println("Class Hierarchy construction failed");
|
||||
System.err.println(e.toString());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return cha;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
|
||||
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalysisOptions getDefaultOptions(Iterable<Entrypoint> entrypoints) {
|
||||
AnalysisOptions options = new AnalysisOptions(getScope(), entrypoints);
|
||||
|
||||
SSAOptions ssaOptions = new SSAOptions();
|
||||
ssaOptions.setDefaultValues(new SSAOptions.DefaultValues() {
|
||||
public int getDefaultValue(SymbolTable symtab, int valueNumber) {
|
||||
return symtab.getDefaultValue(valueNumber);
|
||||
}
|
||||
});
|
||||
|
||||
options.setSSAOptions(ssaOptions);
|
||||
|
||||
return options;
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package com.ibm.wala.cast.java.polyglot;
|
||||
|
||||
import org.eclipse.core.runtime.Plugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
* The activator class controls the plug-in life cycle
|
||||
*/
|
||||
public class Activator extends Plugin {
|
||||
|
||||
// The plug-in ID
|
||||
public static final String PLUGIN_ID = "com.ibm.wala.cast.java.polyglot";
|
||||
|
||||
// The shared instance
|
||||
private static Activator plugin;
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
public Activator() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
plugin = this;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
plugin = null;
|
||||
super.stop(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shared instance
|
||||
*
|
||||
* @return the shared instance
|
||||
*/
|
||||
public static Activator getDefault() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
}
|
|
@ -13,7 +13,7 @@
|
|||
*/
|
||||
package com.ibm.wala.cast.java.translator.polyglot;
|
||||
|
||||
import com.ibm.wala.cast.tree.impl.CAstRewriterFactory;
|
||||
import com.ibm.wala.cast.tree.rewrite.CAstRewriterFactory;
|
||||
|
||||
public interface IRTranslatorExtension {
|
||||
void setSourceLoader(PolyglotSourceLoaderImpl jsli);
|
||||
|
|
|
@ -21,7 +21,7 @@ import polyglot.frontend.JLScheduler;
|
|||
import polyglot.frontend.Job;
|
||||
import polyglot.frontend.Scheduler;
|
||||
|
||||
import com.ibm.wala.cast.tree.impl.CAstRewriterFactory;
|
||||
import com.ibm.wala.cast.tree.rewrite.CAstRewriterFactory;
|
||||
|
||||
/**
|
||||
* A Polyglot extension descriptor for a test harness extension that generates WALA IR for
|
||||
|
|
|
@ -17,11 +17,11 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import com.ibm.wala.classLoader.SourceModule;
|
||||
|
||||
import polyglot.frontend.FileSource;
|
||||
import polyglot.frontend.Resource;
|
||||
|
||||
import com.ibm.wala.classLoader.SourceModule;
|
||||
|
||||
/**
|
||||
* A Polyglot Source whose input comes from an InputStream.<br>
|
||||
* Currently extends FileSource since that's all that the Polyglot Compiler class
|
||||
|
|
|
@ -1,229 +1,229 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package com.ibm.wala.cast.java.translator.polyglot;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import polyglot.types.ArrayType;
|
||||
import polyglot.types.ClassType;
|
||||
import polyglot.types.CodeInstance;
|
||||
import polyglot.types.ConstructorInstance;
|
||||
import polyglot.types.FieldInstance;
|
||||
import polyglot.types.InitializerInstance;
|
||||
import polyglot.types.MemberDef;
|
||||
import polyglot.types.MethodInstance;
|
||||
import polyglot.types.PrimitiveType;
|
||||
import polyglot.types.ProcedureInstance;
|
||||
import polyglot.types.Type;
|
||||
|
||||
import com.ibm.wala.cast.java.translator.polyglot.PolyglotJava2CAstTranslator.IdentityMapper;
|
||||
import com.ibm.wala.cast.java.types.JavaPrimitiveTypeMap;
|
||||
import com.ibm.wala.types.ClassLoaderReference;
|
||||
import com.ibm.wala.types.Descriptor;
|
||||
import com.ibm.wala.types.FieldReference;
|
||||
import com.ibm.wala.types.MethodReference;
|
||||
import com.ibm.wala.types.Selector;
|
||||
import com.ibm.wala.types.TypeName;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.strings.Atom;
|
||||
|
||||
/**
|
||||
* Class responsible for mapping Polyglot type system objects representing types,
|
||||
* methods and fields to the corresponding WALA TypeReferences, MethodReferences
|
||||
* and FieldReferences. Used during translation and by clients to help correlate
|
||||
* WALA analysis results to the various AST nodes.
|
||||
* @author rfuhrer
|
||||
*/
|
||||
public class PolyglotIdentityMapper implements IdentityMapper<Type, CodeInstance, FieldInstance> {
|
||||
private final Map<Type, TypeReference> fTypeMap = HashMapFactory.make();
|
||||
|
||||
private final Map<FieldInstance, FieldReference> fFieldMap = HashMapFactory.make();
|
||||
|
||||
private final Map<CodeInstance, MethodReference> fMethodMap = HashMapFactory.make();
|
||||
|
||||
/**
|
||||
* Map from Polyglot local ClassTypes to their enclosing methods. Used by localTypeToTypeID().<br>
|
||||
* Needed since Polyglot doesn't provide this information. (It doesn't need to, since it
|
||||
* doesn't need to generate unambiguous names for such entities -- it hands the source
|
||||
* off to javac to generate bytecode. It probably also wouldn't want to, since that would
|
||||
* create back-pointers from Type objects in the TypeSystem to AST's.)
|
||||
*/
|
||||
protected Map<ClassType, CodeInstance> fLocalTypeMap = new LinkedHashMap<ClassType, CodeInstance>();
|
||||
|
||||
protected final ClassLoaderReference fClassLoaderRef;
|
||||
|
||||
public PolyglotIdentityMapper(ClassLoaderReference clr) {
|
||||
fClassLoaderRef= clr;
|
||||
}
|
||||
|
||||
public FieldReference getFieldRef(FieldInstance field) {
|
||||
if (!fFieldMap.containsKey(field)) {
|
||||
FieldReference ref= referenceForField(field);
|
||||
fFieldMap.put(field, ref);
|
||||
return ref;
|
||||
}
|
||||
return fFieldMap.get(field);
|
||||
}
|
||||
|
||||
public TypeReference getTypeRef(Type type) {
|
||||
if (!fTypeMap.containsKey(type)) {
|
||||
TypeReference ref= referenceForType(type);
|
||||
fTypeMap.put(type, ref);
|
||||
return ref;
|
||||
}
|
||||
return fTypeMap.get(type);
|
||||
}
|
||||
|
||||
public MethodReference getMethodRef(CodeInstance method) {
|
||||
if (!fMethodMap.containsKey(method)) {
|
||||
MethodReference sel= referenceForMethod(method);
|
||||
fMethodMap.put(method, sel);
|
||||
return sel;
|
||||
}
|
||||
return fMethodMap.get(method);
|
||||
}
|
||||
|
||||
public void mapLocalAnonTypeToMethod(ClassType anonLocalType, CodeInstance owningProc) {
|
||||
fLocalTypeMap.put(anonLocalType, owningProc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a FieldReference for the given Polyglot FieldInstance.<br>
|
||||
* N.B.: This method <b>does not canonicalize</b> the FieldReferences,
|
||||
* but rather creates a new one for each call.
|
||||
* You more likely want to call getFieldRef(). This method is exposed
|
||||
* so that multiple Polyglot instances can use the translation services
|
||||
* without having FieldInstances collide (producing the dreaded "we are
|
||||
* TypeSystem_c but type Foo is from TypeSystem_c" exception).
|
||||
*/
|
||||
public FieldReference referenceForField(FieldInstance field) {
|
||||
Type targetType= field.container();
|
||||
Type fieldType= field.type();
|
||||
TypeReference targetTypeRef= TypeReference.findOrCreate(fClassLoaderRef, typeToTypeID(targetType));
|
||||
TypeReference fieldTypeRef= TypeReference.findOrCreate(fClassLoaderRef, typeToTypeID(fieldType));
|
||||
Atom fieldName= Atom.findOrCreateUnicodeAtom(field.name().toString());
|
||||
FieldReference fieldRef= FieldReference.findOrCreate(targetTypeRef, fieldName, fieldTypeRef);
|
||||
|
||||
return fieldRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a TypeReference for the given Polyglot Type.<br>
|
||||
* N.B.: This method <b>does not canonicalize</b> the TypeReferences,
|
||||
* but rather creates a new one for each call.
|
||||
* You more likely want to call getTypeRef(). This method is exposed
|
||||
* so that multiple Polyglot instances can use the translation services
|
||||
* without having Types collide (producing the dreaded "we are
|
||||
* TypeSystem_c but type Foo is from TypeSystem_c" exception).
|
||||
*/
|
||||
public TypeReference referenceForType(Type type) {
|
||||
TypeName typeName= TypeName.string2TypeName(typeToTypeID(type));
|
||||
TypeReference typeRef= TypeReference.findOrCreate(fClassLoaderRef, typeName);
|
||||
|
||||
return typeRef;
|
||||
}
|
||||
|
||||
private Selector selectorForMethod(CodeInstance procInstance) {
|
||||
Atom name=
|
||||
(procInstance instanceof ConstructorInstance) ?
|
||||
MethodReference.initAtom :
|
||||
(procInstance instanceof InitializerInstance) ?
|
||||
MethodReference.clinitName :
|
||||
Atom.findOrCreateUnicodeAtom(((MethodInstance) procInstance).name().toString());
|
||||
|
||||
TypeName[] argTypeNames = null;
|
||||
if (! (procInstance instanceof InitializerInstance)) {
|
||||
List formalTypes = ((ProcedureInstance)procInstance).formalTypes();
|
||||
int numArgs = formalTypes.size();
|
||||
// Descriptor prefers null to an empty array
|
||||
if (numArgs > 0) {
|
||||
argTypeNames = new TypeName[numArgs];
|
||||
|
||||
int i = 0;
|
||||
for(Iterator iter = formalTypes.iterator(); iter.hasNext(); i++) {
|
||||
Type argType= (Type) iter.next();
|
||||
argTypeNames[i]= TypeName.string2TypeName(typeToTypeID(argType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Type retType=
|
||||
(procInstance instanceof MethodInstance) ? ((MethodInstance) procInstance).returnType() : procInstance.typeSystem().Void();
|
||||
TypeName retTypeName= TypeName.string2TypeName(typeToTypeID(retType));
|
||||
|
||||
Descriptor desc= Descriptor.findOrCreate(argTypeNames, retTypeName);
|
||||
|
||||
return new Selector(name, desc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a MethodReference for the given Polyglot MethodInstance.<br>
|
||||
* N.B.: This method <b>does not canonicalize</b> the MethodReferences,
|
||||
* but rather creates a new one for each call.
|
||||
* You more likely want to call getMethodRef(). This method is exposed
|
||||
* so that multiple Polyglot instances can use the translation services
|
||||
* without having MethodInstances collide (producing the dreaded "we are
|
||||
* TypeSystem_c but type Foo is from TypeSystem_c" exception).
|
||||
*/
|
||||
public MethodReference referenceForMethod(CodeInstance procInstance) {
|
||||
// Handles both ConstructorInstance's and MethodInstance's
|
||||
TypeName ownerType= TypeName.string2TypeName(typeToTypeID(((MemberDef) procInstance.def()).container().get()));
|
||||
TypeReference ownerTypeRef= TypeReference.findOrCreate(fClassLoaderRef, ownerType);
|
||||
MethodReference methodRef= MethodReference.findOrCreate(ownerTypeRef, selectorForMethod(procInstance));
|
||||
|
||||
return methodRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the given Polyglot type to a name suitable for use in a WALA TypeReference
|
||||
* (i.e. a bytecode-compliant type name).
|
||||
*/
|
||||
public String typeToTypeID(Type type) {
|
||||
if (type.isPrimitive()) {
|
||||
PrimitiveType ptype= (PrimitiveType) type;
|
||||
|
||||
return JavaPrimitiveTypeMap.getShortName(ptype.name().toString());
|
||||
} else if (type.isArray()) {
|
||||
ArrayType atype= (ArrayType) type;
|
||||
return "[" + typeToTypeID(atype.base());
|
||||
} else if (type.isNull()) {
|
||||
Assertions.UNREACHABLE("typeToTypeID() encountered a null type!");
|
||||
return null;
|
||||
}
|
||||
Assertions.productionAssertion(type.isClass(), "typeToTypeID() encountered the type " + type + " that is neither primitive, array, nor class!");
|
||||
|
||||
ClassType ctype= (ClassType) type;
|
||||
|
||||
return (ctype.isLocal() || ctype.isAnonymous()) ? anonLocalTypeToTypeID(ctype) : composeWALATypeDescriptor(ctype);
|
||||
}
|
||||
|
||||
public String anonLocalTypeToTypeID(ClassType ctype) {
|
||||
CodeInstance procInstance= (CodeInstance) fLocalTypeMap.get(ctype);
|
||||
|
||||
String outerTypeID= typeToTypeID(ctype.outer());
|
||||
String shortName= (ctype.isAnonymous()) ? PolyglotJava2CAstTranslator.anonTypeName(ctype) : ctype.fullName().name().toString();
|
||||
|
||||
return outerTypeID + '/' + getMethodRef(procInstance).getSelector() + '/' + shortName;
|
||||
}
|
||||
|
||||
public String composeWALATypeDescriptor(ClassType ctype) {
|
||||
return "L" + composeWALATypeName(ctype);
|
||||
}
|
||||
|
||||
public String composeWALATypeName(ClassType ctype) {
|
||||
if (ctype.package_() != null) {
|
||||
String packageName = ctype.package_().fullName().toString();
|
||||
|
||||
Assertions.productionAssertion(ctype.fullName().toString().startsWith(packageName));
|
||||
return packageName.replace('.','/') + "/" + ctype.fullName().toString().substring( packageName.length()+1 ).replace('.','$');
|
||||
} else {
|
||||
return ctype.fullName().toString().replace('.', '$');
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.ibm.wala.cast.java.translator.polyglot;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import polyglot.types.ArrayType;
|
||||
import polyglot.types.ClassType;
|
||||
import polyglot.types.CodeInstance;
|
||||
import polyglot.types.ConstructorInstance;
|
||||
import polyglot.types.FieldInstance;
|
||||
import polyglot.types.InitializerInstance;
|
||||
import polyglot.types.MemberDef;
|
||||
import polyglot.types.MethodInstance;
|
||||
import polyglot.types.PrimitiveType;
|
||||
import polyglot.types.ProcedureInstance;
|
||||
import polyglot.types.Type;
|
||||
|
||||
import com.ibm.wala.cast.java.translator.polyglot.PolyglotJava2CAstTranslator.IdentityMapper;
|
||||
import com.ibm.wala.cast.java.types.JavaPrimitiveTypeMap;
|
||||
import com.ibm.wala.types.ClassLoaderReference;
|
||||
import com.ibm.wala.types.Descriptor;
|
||||
import com.ibm.wala.types.FieldReference;
|
||||
import com.ibm.wala.types.MethodReference;
|
||||
import com.ibm.wala.types.Selector;
|
||||
import com.ibm.wala.types.TypeName;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.strings.Atom;
|
||||
|
||||
/**
|
||||
* Class responsible for mapping Polyglot type system objects representing types,
|
||||
* methods and fields to the corresponding WALA TypeReferences, MethodReferences
|
||||
* and FieldReferences. Used during translation and by clients to help correlate
|
||||
* WALA analysis results to the various AST nodes.
|
||||
* @author rfuhrer
|
||||
*/
|
||||
public class PolyglotIdentityMapper implements IdentityMapper<Type, CodeInstance, FieldInstance> {
|
||||
private final Map<Type, TypeReference> fTypeMap = HashMapFactory.make();
|
||||
|
||||
private final Map<FieldInstance, FieldReference> fFieldMap = HashMapFactory.make();
|
||||
|
||||
private final Map<CodeInstance, MethodReference> fMethodMap = HashMapFactory.make();
|
||||
|
||||
/**
|
||||
* Map from Polyglot local ClassTypes to their enclosing methods. Used by localTypeToTypeID().<br>
|
||||
* Needed since Polyglot doesn't provide this information. (It doesn't need to, since it
|
||||
* doesn't need to generate unambiguous names for such entities -- it hands the source
|
||||
* off to javac to generate bytecode. It probably also wouldn't want to, since that would
|
||||
* create back-pointers from Type objects in the TypeSystem to AST's.)
|
||||
*/
|
||||
protected Map<ClassType, CodeInstance> fLocalTypeMap = new LinkedHashMap<ClassType, CodeInstance>();
|
||||
|
||||
protected final ClassLoaderReference fClassLoaderRef;
|
||||
|
||||
public PolyglotIdentityMapper(ClassLoaderReference clr) {
|
||||
fClassLoaderRef= clr;
|
||||
}
|
||||
|
||||
public FieldReference getFieldRef(FieldInstance field) {
|
||||
if (!fFieldMap.containsKey(field)) {
|
||||
FieldReference ref= referenceForField(field);
|
||||
fFieldMap.put(field, ref);
|
||||
return ref;
|
||||
}
|
||||
return fFieldMap.get(field);
|
||||
}
|
||||
|
||||
public TypeReference getTypeRef(Type type) {
|
||||
if (!fTypeMap.containsKey(type)) {
|
||||
TypeReference ref= referenceForType(type);
|
||||
fTypeMap.put(type, ref);
|
||||
return ref;
|
||||
}
|
||||
return fTypeMap.get(type);
|
||||
}
|
||||
|
||||
public MethodReference getMethodRef(CodeInstance method) {
|
||||
if (!fMethodMap.containsKey(method)) {
|
||||
MethodReference sel= referenceForMethod(method);
|
||||
fMethodMap.put(method, sel);
|
||||
return sel;
|
||||
}
|
||||
return fMethodMap.get(method);
|
||||
}
|
||||
|
||||
public void mapLocalAnonTypeToMethod(ClassType anonLocalType, CodeInstance owningProc) {
|
||||
fLocalTypeMap.put(anonLocalType, owningProc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a FieldReference for the given Polyglot FieldInstance.<br>
|
||||
* N.B.: This method <b>does not canonicalize</b> the FieldReferences,
|
||||
* but rather creates a new one for each call.
|
||||
* You more likely want to call getFieldRef(). This method is exposed
|
||||
* so that multiple Polyglot instances can use the translation services
|
||||
* without having FieldInstances collide (producing the dreaded "we are
|
||||
* TypeSystem_c but type Foo is from TypeSystem_c" exception).
|
||||
*/
|
||||
public FieldReference referenceForField(FieldInstance field) {
|
||||
Type targetType= field.container();
|
||||
Type fieldType= field.type();
|
||||
TypeReference targetTypeRef= TypeReference.findOrCreate(fClassLoaderRef, typeToTypeID(targetType));
|
||||
TypeReference fieldTypeRef= TypeReference.findOrCreate(fClassLoaderRef, typeToTypeID(fieldType));
|
||||
Atom fieldName= Atom.findOrCreateUnicodeAtom(field.name().toString());
|
||||
FieldReference fieldRef= FieldReference.findOrCreate(targetTypeRef, fieldName, fieldTypeRef);
|
||||
|
||||
return fieldRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a TypeReference for the given Polyglot Type.<br>
|
||||
* N.B.: This method <b>does not canonicalize</b> the TypeReferences,
|
||||
* but rather creates a new one for each call.
|
||||
* You more likely want to call getTypeRef(). This method is exposed
|
||||
* so that multiple Polyglot instances can use the translation services
|
||||
* without having Types collide (producing the dreaded "we are
|
||||
* TypeSystem_c but type Foo is from TypeSystem_c" exception).
|
||||
*/
|
||||
public TypeReference referenceForType(Type type) {
|
||||
TypeName typeName= TypeName.string2TypeName(typeToTypeID(type));
|
||||
TypeReference typeRef= TypeReference.findOrCreate(fClassLoaderRef, typeName);
|
||||
|
||||
return typeRef;
|
||||
}
|
||||
|
||||
private Selector selectorForMethod(CodeInstance procInstance) {
|
||||
Atom name=
|
||||
(procInstance instanceof ConstructorInstance) ?
|
||||
MethodReference.initAtom :
|
||||
(procInstance instanceof InitializerInstance) ?
|
||||
MethodReference.clinitName :
|
||||
Atom.findOrCreateUnicodeAtom(((MethodInstance) procInstance).name().toString());
|
||||
|
||||
TypeName[] argTypeNames = null;
|
||||
if (! (procInstance instanceof InitializerInstance)) {
|
||||
List formalTypes = ((ProcedureInstance)procInstance).formalTypes();
|
||||
int numArgs = formalTypes.size();
|
||||
// Descriptor prefers null to an empty array
|
||||
if (numArgs > 0) {
|
||||
argTypeNames = new TypeName[numArgs];
|
||||
|
||||
int i = 0;
|
||||
for(Iterator iter = formalTypes.iterator(); iter.hasNext(); i++) {
|
||||
Type argType= (Type) iter.next();
|
||||
argTypeNames[i]= TypeName.string2TypeName(typeToTypeID(argType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Type retType=
|
||||
(procInstance instanceof MethodInstance) ? ((MethodInstance) procInstance).returnType() : procInstance.typeSystem().Void();
|
||||
TypeName retTypeName= TypeName.string2TypeName(typeToTypeID(retType));
|
||||
|
||||
Descriptor desc= Descriptor.findOrCreate(argTypeNames, retTypeName);
|
||||
|
||||
return new Selector(name, desc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a MethodReference for the given Polyglot MethodInstance.<br>
|
||||
* N.B.: This method <b>does not canonicalize</b> the MethodReferences,
|
||||
* but rather creates a new one for each call.
|
||||
* You more likely want to call getMethodRef(). This method is exposed
|
||||
* so that multiple Polyglot instances can use the translation services
|
||||
* without having MethodInstances collide (producing the dreaded "we are
|
||||
* TypeSystem_c but type Foo is from TypeSystem_c" exception).
|
||||
*/
|
||||
public MethodReference referenceForMethod(CodeInstance procInstance) {
|
||||
// Handles both ConstructorInstance's and MethodInstance's
|
||||
TypeName ownerType= TypeName.string2TypeName(typeToTypeID(((MemberDef) procInstance.def()).container().get()));
|
||||
TypeReference ownerTypeRef= TypeReference.findOrCreate(fClassLoaderRef, ownerType);
|
||||
MethodReference methodRef= MethodReference.findOrCreate(ownerTypeRef, selectorForMethod(procInstance));
|
||||
|
||||
return methodRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the given Polyglot type to a name suitable for use in a WALA TypeReference
|
||||
* (i.e. a bytecode-compliant type name).
|
||||
*/
|
||||
public String typeToTypeID(Type type) {
|
||||
if (type.isPrimitive()) {
|
||||
PrimitiveType ptype= (PrimitiveType) type;
|
||||
|
||||
return JavaPrimitiveTypeMap.getShortName(ptype.name().toString());
|
||||
} else if (type.isArray()) {
|
||||
ArrayType atype= (ArrayType) type;
|
||||
return "[" + typeToTypeID(atype.base());
|
||||
} else if (type.isNull()) {
|
||||
Assertions.UNREACHABLE("typeToTypeID() encountered a null type!");
|
||||
return null;
|
||||
}
|
||||
Assertions.productionAssertion(type.isClass(), "typeToTypeID() encountered the type " + type + " that is neither primitive, array, nor class!");
|
||||
|
||||
ClassType ctype= (ClassType) type;
|
||||
|
||||
return (ctype.isLocal() || ctype.isAnonymous()) ? anonLocalTypeToTypeID(ctype) : composeWALATypeDescriptor(ctype);
|
||||
}
|
||||
|
||||
public String anonLocalTypeToTypeID(ClassType ctype) {
|
||||
CodeInstance procInstance= (CodeInstance) fLocalTypeMap.get(ctype);
|
||||
|
||||
String outerTypeID= typeToTypeID(ctype.outer());
|
||||
String shortName= (ctype.isAnonymous()) ? PolyglotJava2CAstTranslator.anonTypeName(ctype) : ctype.fullName().name().toString();
|
||||
|
||||
return outerTypeID + '/' + getMethodRef(procInstance).getSelector() + '/' + shortName;
|
||||
}
|
||||
|
||||
public String composeWALATypeDescriptor(ClassType ctype) {
|
||||
return "L" + composeWALATypeName(ctype);
|
||||
}
|
||||
|
||||
public String composeWALATypeName(ClassType ctype) {
|
||||
if (ctype.package_() != null) {
|
||||
String packageName = ctype.package_().fullName().toString();
|
||||
|
||||
Assertions.productionAssertion(ctype.fullName().toString().startsWith(packageName));
|
||||
return packageName.replace('.','/') + "/" + ctype.fullName().toString().substring( packageName.length()+1 ).replace('.','$');
|
||||
} else {
|
||||
return ctype.fullName().toString().replace('.', '$');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,7 +120,6 @@ import polyglot.util.Position;
|
|||
import com.ibm.wala.cast.ir.translator.AstTranslator.InternalCAstSymbol;
|
||||
import com.ibm.wala.cast.ir.translator.TranslatorToCAst;
|
||||
import com.ibm.wala.cast.ir.translator.TranslatorToCAst.DoLoopTranslator;
|
||||
import com.ibm.wala.cast.ir.translator.TranslatorToCAst.WalkContext;
|
||||
import com.ibm.wala.cast.java.loader.Util;
|
||||
import com.ibm.wala.cast.java.translator.JavaProcedureEntity;
|
||||
import com.ibm.wala.cast.java.types.JavaType;
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package com.ibm.wala.cast.java.translator.polyglot;
|
||||
|
||||
import com.ibm.wala.cast.tree.CAst;
|
||||
import com.ibm.wala.cast.tree.rewrite.AstLoopUnwinder;
|
||||
import com.ibm.wala.cast.tree.rewrite.CAstRewriter;
|
||||
import com.ibm.wala.cast.tree.rewrite.CAstRewriterFactory;
|
||||
|
||||
public class PolyglotUnwoundIRTranslatorExtension
|
||||
extends JavaIRTranslatorExtension
|
||||
{
|
||||
private final int unrollDepth;
|
||||
|
||||
public PolyglotUnwoundIRTranslatorExtension(int unrollDepth) {
|
||||
this.unrollDepth = unrollDepth;
|
||||
}
|
||||
|
||||
public CAstRewriterFactory<CAstRewriter.RewriteContext<AstLoopUnwinder.UnwindKey>,AstLoopUnwinder.UnwindKey> getCAstRewriterFactory() {
|
||||
return new CAstRewriterFactory<CAstRewriter.RewriteContext<AstLoopUnwinder.UnwindKey>,AstLoopUnwinder.UnwindKey>() {
|
||||
public AstLoopUnwinder createCAstRewriter(CAst ast) {
|
||||
return new AstLoopUnwinder(ast, true, unrollDepth);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
|
@ -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/J2SE-1.5"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
java\/awt\/.*
|
||||
javax\/swing\/.*
|
||||
sun\/awt\/.*
|
||||
sun\/swing\/.*
|
||||
com\/sun\/.*
|
||||
sun\/.*
|
||||
java\/awt\/.*
|
||||
javax\/swing\/.*
|
||||
sun\/awt\/.*
|
||||
sun\/swing\/.*
|
||||
com\/sun\/.*
|
||||
sun\/.*
|
||||
|
|
|
@ -3,8 +3,6 @@ Bundle-ManifestVersion: 2
|
|||
Bundle-Name: Data Plug-in
|
||||
Bundle-SymbolicName: com.ibm.wala.cast.java.test.data
|
||||
Bundle-Version: 1.0.0
|
||||
Bundle-Activator: com.ibm.wala.cast.java.test.data.Activator
|
||||
Bundle-Vendor: IBM
|
||||
Require-Bundle: org.eclipse.core.runtime
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Bundle-ActivationPolicy: lazy
|
||||
|
|
|
@ -1,89 +1,89 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="com.ibm.wala.cast.java.test.data" default="getSources" basedir=".">
|
||||
|
||||
<property name="basews" value="${ws}"/>
|
||||
<property name="baseos" value="${os}"/>
|
||||
<property name="basearch" value="${arch}"/>
|
||||
<property name="basenl" value="${nl}"/>
|
||||
|
||||
<!-- Compiler settings. -->
|
||||
<property name="javacFailOnError" value="true"/>
|
||||
<property name="javacDebugInfo" value="on"/>
|
||||
<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"/>
|
||||
<!-- 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" -->
|
||||
<condition property="dir_bootclasspath" value="${java.home}/../Classes">
|
||||
<os family="mac"/>
|
||||
</condition>
|
||||
<property name="dir_bootclasspath" value="${java.home}/lib"/>
|
||||
<path id="path_bootclasspath">
|
||||
<fileset dir="${dir_bootclasspath}">
|
||||
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
<property name="bootclasspath" refid="path_bootclasspath"/>
|
||||
<property name="bundleJavacSource" value="${javacSource}"/>
|
||||
<property name="bundleJavacTarget" value="${javacTarget}"/>
|
||||
<property name="bundleBootClasspath" value="${bootclasspath}"/>
|
||||
|
||||
<target name="JLexPresent" depends="init">
|
||||
<available file="${plugin.destination}/src/JLex/Main.java" property="jlex.present"/>
|
||||
</target>
|
||||
|
||||
<target name="fetchJLex" depends="JLexPresent" unless="jlex.present">
|
||||
<delete dir="${temp.folder}"/>
|
||||
<mkdir dir="${temp.folder}/JLex"/>
|
||||
<get src="http://www.cs.princeton.edu/~appel/modern/java/JLex/current/Main.java" dest="${temp.folder}/JLex/Main.java"/>
|
||||
<delete dir="${plugin.destination}/src/JLex"/>
|
||||
<mkdir dir="${plugin.destination}/src/JLex"/>
|
||||
<copy file="${temp.folder}/JLex/Main.java" tofile="${plugin.destination}/src/JLex/Main.java"/>
|
||||
<delete dir="${temp.folder}"/>
|
||||
</target>
|
||||
|
||||
<target name="getSources" depends="fetchJLex" />
|
||||
|
||||
<target name="testdatadir" depends="init,testdata.exists" unless="testdatadir.present">
|
||||
<mkdir dir="${basedir}/../com.ibm.wala.cast.java.test/testdata"/>
|
||||
</target>
|
||||
|
||||
<target name="testdata.exists" depends="init">
|
||||
<available file="${basedir}/../com.ibm.wala.cast.java.test/testdata"
|
||||
type="dir"
|
||||
property="testdatadir.present"/>
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="getSources">
|
||||
<javac srcdir="${basedir}/src"
|
||||
destdir="${basedir}/bin"
|
||||
excludes="**/Activator.java"/>
|
||||
</target>
|
||||
|
||||
<target name="jar" depends="compile,testdatadir">
|
||||
<jar destfile="${basedir}/../com.ibm.wala.cast.java.test/testdata/test_project.zip" basedir="${basedir}"/>
|
||||
</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="properties" if="eclipse.running">
|
||||
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
|
||||
|
||||
</target>
|
||||
|
||||
</project>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="com.ibm.wala.cast.java.test.data" default="getSources" basedir=".">
|
||||
|
||||
<property name="basews" value="${ws}"/>
|
||||
<property name="baseos" value="${os}"/>
|
||||
<property name="basearch" value="${arch}"/>
|
||||
<property name="basenl" value="${nl}"/>
|
||||
|
||||
<!-- Compiler settings. -->
|
||||
<property name="javacFailOnError" value="true"/>
|
||||
<property name="javacDebugInfo" value="on"/>
|
||||
<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"/>
|
||||
<!-- 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" -->
|
||||
<condition property="dir_bootclasspath" value="${java.home}/../Classes">
|
||||
<os family="mac"/>
|
||||
</condition>
|
||||
<property name="dir_bootclasspath" value="${java.home}/lib"/>
|
||||
<path id="path_bootclasspath">
|
||||
<fileset dir="${dir_bootclasspath}">
|
||||
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
<property name="bootclasspath" refid="path_bootclasspath"/>
|
||||
<property name="bundleJavacSource" value="${javacSource}"/>
|
||||
<property name="bundleJavacTarget" value="${javacTarget}"/>
|
||||
<property name="bundleBootClasspath" value="${bootclasspath}"/>
|
||||
|
||||
<target name="JLexPresent" depends="init">
|
||||
<available file="${plugin.destination}/src/JLex/Main.java" property="jlex.present"/>
|
||||
</target>
|
||||
|
||||
<target name="fetchJLex" depends="JLexPresent" unless="jlex.present">
|
||||
<delete dir="${temp.folder}"/>
|
||||
<mkdir dir="${temp.folder}/JLex"/>
|
||||
<get src="http://www.cs.princeton.edu/~appel/modern/java/JLex/current/Main.java" dest="${temp.folder}/JLex/Main.java"/>
|
||||
<delete dir="${plugin.destination}/src/JLex"/>
|
||||
<mkdir dir="${plugin.destination}/src/JLex"/>
|
||||
<copy file="${temp.folder}/JLex/Main.java" tofile="${plugin.destination}/src/JLex/Main.java"/>
|
||||
<delete dir="${temp.folder}"/>
|
||||
</target>
|
||||
|
||||
<target name="getSources" depends="fetchJLex" />
|
||||
|
||||
<target name="testdatadir" depends="init,testdata.exists" unless="testdatadir.present">
|
||||
<mkdir dir="${basedir}/../com.ibm.wala.cast.java.test/testdata"/>
|
||||
</target>
|
||||
|
||||
<target name="testdata.exists" depends="init">
|
||||
<available file="${basedir}/../com.ibm.wala.cast.java.test/testdata"
|
||||
type="dir"
|
||||
property="testdatadir.present"/>
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="getSources">
|
||||
<javac srcdir="${basedir}/src"
|
||||
destdir="${basedir}/bin"
|
||||
excludes="**/Activator.java"/>
|
||||
</target>
|
||||
|
||||
<target name="jar" depends="compile,testdatadir">
|
||||
<jar destfile="${basedir}/../com.ibm.wala.cast.java.test/testdata/test_project.zip" basedir="${basedir}"/>
|
||||
</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="properties" if="eclipse.running">
|
||||
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
|
||||
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -47,17 +47,17 @@ package alreadywalaunittests;
|
|||
// invariants and non-invariants (immediate 'new' in that function)
|
||||
// subclasses
|
||||
|
||||
public class InnerClassA {
|
||||
public class InnerClassAA {
|
||||
int a_x;
|
||||
|
||||
public static void main(String args[]) {
|
||||
// prints out 5 5 9 7 5 5 7 5 7 5
|
||||
InnerClassA a = new InnerClassA();
|
||||
InnerClassAA a = new InnerClassAA();
|
||||
a.doAllThis();
|
||||
}
|
||||
|
||||
public void doAllThis() {
|
||||
InnerClassA a = this;
|
||||
InnerClassAA a = this;
|
||||
AA aa = new AA();
|
||||
aa = a.new AA();
|
||||
AB ab = aa.makeAB();
|
||||
|
@ -104,7 +104,7 @@ public class InnerClassA {
|
|||
doMoreWithABSubA(absuba);
|
||||
}
|
||||
|
||||
private void doMoreWithABSubA(InnerClassA.AB.ABSubA absuba) {
|
||||
private void doMoreWithABSubA(InnerClassAA.AB.ABSubA absuba) {
|
||||
System.out.println(absuba.getA_X()); // 5
|
||||
|
||||
AB.ABSubA.ABSubAA absubaa = absuba.new ABSubAA();
|
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
package alreadywalaunittests;
|
||||
|
||||
public class InnerClassSuper {
|
||||
public class InnerClassSuperA {
|
||||
int x = 5;
|
||||
class SuperOuter {
|
||||
public void test() {
|
||||
|
@ -48,10 +48,10 @@ public class InnerClassSuper {
|
|||
new Sub().new SubInner();
|
||||
}
|
||||
}
|
||||
class Sub extends InnerClassSuper {
|
||||
class Sub extends InnerClassSuperA {
|
||||
class SubInner {
|
||||
public SubInner() {
|
||||
InnerClassSuper.SuperOuter so = new InnerClassSuper.SuperOuter();
|
||||
InnerClassSuperA.SuperOuter so = new InnerClassSuperA.SuperOuter();
|
||||
so.test();
|
||||
}
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
* This file is a derivative of code released by the University of
|
||||
* California under the terms listed below.
|
||||
*
|
||||
* WALA JDT Frontend is Copyright (c) 2008 The Regents of the
|
||||
* University of California (Regents). Provided that this notice and
|
||||
* the following two paragraphs are included in any distribution of
|
||||
* Refinement Analysis Tools or its derivative work, Regents agrees
|
||||
* not to assert any of Regents' copyright rights in Refinement
|
||||
* Analysis Tools against recipient for recipient's reproduction,
|
||||
* preparation of derivative works, public display, public
|
||||
* performance, distribution or sublicensing of Refinement Analysis
|
||||
* Tools and derivative works, in source code and object code form.
|
||||
* This agreement not to assert does not confer, by implication,
|
||||
* estoppel, or otherwise any license or rights in any intellectual
|
||||
* property of Regents, including, but not limited to, any patents
|
||||
* of Regents or Regents' employees.
|
||||
*
|
||||
* IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT,
|
||||
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
|
||||
* INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE
|
||||
* AND ITS DOCUMENTATION, EVEN IF REGENTS HAS BEEN ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND FURTHER DISCLAIMS ANY STATUTORY
|
||||
* WARRANTY OF NON-INFRINGEMENT. THE SOFTWARE AND ACCOMPANYING
|
||||
* DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS
|
||||
* IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
|
||||
* UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*/
|
||||
package com.ibm.wala.cast.java.test.data;
|
||||
|
||||
import org.eclipse.core.runtime.Plugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
* The activator class controls the plug-in life cycle
|
||||
*/
|
||||
public class Activator extends Plugin {
|
||||
|
||||
// The plug-in ID
|
||||
public static final String PLUGIN_ID = "com.ibm.wala.cast.java.test.data";
|
||||
|
||||
// The shared instance
|
||||
private static Activator plugin;
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
public Activator() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
plugin = this;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
plugin = null;
|
||||
super.stop(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shared instance
|
||||
*
|
||||
* @return the shared instance
|
||||
*/
|
||||
public static Activator getDefault() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
}
|
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
package foo.bar.hello.world;
|
||||
|
||||
public class MiniaturList {
|
||||
public class MiniaturList2 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
int a;
|
|
@ -1,5 +1,5 @@
|
|||
#Thu Jan 03 11:24:43 EST 2008
|
||||
eclipse.preferences.version=1
|
||||
formatter_profile=_WALA
|
||||
formatter_settings_version=11
|
||||
instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
|
||||
#Thu Jan 03 11:24:43 EST 2008
|
||||
eclipse.preferences.version=1
|
||||
formatter_profile=_WALA
|
||||
formatter_settings_version=11
|
||||
instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Java AST WALA Test Plug-in
|
||||
Bundle-SymbolicName: com.ibm.wala.cast.java.test
|
||||
Bundle-Version: 1.0.0
|
||||
Bundle-Activator: com.ibm.wala.cast.java.test.TestPlugin
|
||||
Bundle-Vendor: IBM
|
||||
Require-Bundle: org.junit4,
|
||||
com.ibm.wala.core.tests,
|
||||
com.ibm.wala.cast.java,
|
||||
com.ibm.wala.cast,
|
||||
com.ibm.wala.core,
|
||||
com.ibm.wala.shrike,
|
||||
org.eclipse.core.runtime
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.ibm.wala.cast.java.test
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Java AST WALA Test Plug-in
|
||||
Bundle-SymbolicName: com.ibm.wala.cast.java.test
|
||||
Bundle-Version: 1.0.0
|
||||
Bundle-Activator: com.ibm.wala.cast.java.test.TestPlugin
|
||||
Bundle-Vendor: IBM
|
||||
Require-Bundle: org.junit4,
|
||||
com.ibm.wala.core.tests,
|
||||
com.ibm.wala.cast.java,
|
||||
com.ibm.wala.cast,
|
||||
com.ibm.wala.core,
|
||||
com.ibm.wala.shrike,
|
||||
org.eclipse.core.runtime
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.ibm.wala.cast.java.test
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
|
|
|
@ -1,424 +1,447 @@
|
|||
/******************************************************************************
|
||||
* Copyright (c) 2002 - 2006 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* Created on Oct 3, 2005
|
||||
*/
|
||||
package com.ibm.wala.cast.java.test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.ibm.wala.cast.java.client.JavaSourceAnalysisEngine;
|
||||
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.classLoader.IClassLoader;
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
import com.ibm.wala.classLoader.JarFileModule;
|
||||
import com.ibm.wala.classLoader.Language;
|
||||
import com.ibm.wala.classLoader.SourceDirectoryTreeModule;
|
||||
import com.ibm.wala.classLoader.SourceFileModule;
|
||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraph;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
import com.ibm.wala.properties.WalaProperties;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.types.ClassLoaderReference;
|
||||
import com.ibm.wala.types.MethodReference;
|
||||
import com.ibm.wala.types.TypeName;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.strings.Atom;
|
||||
|
||||
public abstract class IRTests {
|
||||
|
||||
protected IRTests(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
protected final String projectName;
|
||||
|
||||
protected static String javaHomePath;
|
||||
|
||||
private String testSrcPath = "." + File.separator + "src";
|
||||
|
||||
public static List<String> rtJar;
|
||||
|
||||
protected static List<IRAssertion> emptyList = Collections.emptyList();
|
||||
|
||||
static {
|
||||
boolean found = false;
|
||||
try {
|
||||
rtJar = new LinkedList<String>();
|
||||
|
||||
Properties p = WalaProperties.loadProperties();
|
||||
javaHomePath = p.getProperty(WalaProperties.J2SE_DIR);
|
||||
|
||||
if (new File(javaHomePath).isDirectory()) {
|
||||
if ("Mac OS X".equals(System.getProperty("os.name"))) { // nick
|
||||
/**
|
||||
* todo: {@link WalaProperties#getJ2SEJarFiles()}
|
||||
*/
|
||||
rtJar.add(javaHomePath + "/classes.jar");
|
||||
rtJar.add(javaHomePath + "/ui.jar");
|
||||
} else {
|
||||
rtJar.add(javaHomePath + File.separator + "classes.jar");
|
||||
rtJar.add(javaHomePath + File.separator + "rt.jar");
|
||||
rtJar.add(javaHomePath + File.separator + "core.jar");
|
||||
rtJar.add(javaHomePath + File.separator + "vm.jar");
|
||||
}
|
||||
found = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// no properties
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
javaHomePath = System.getProperty("java.home");
|
||||
if ("Mac OS X".equals(System.getProperty("os.name"))) { // nick
|
||||
rtJar.add(javaHomePath + "/../Classes/classes.jar");
|
||||
rtJar.add(javaHomePath + "/../Classes/ui.jar");
|
||||
} else {
|
||||
rtJar.add(javaHomePath + File.separator + "lib" + File.separator + "rt.jar");
|
||||
rtJar.add(javaHomePath + File.separator + "lib" + File.separator + "core.jar");
|
||||
rtJar.add(javaHomePath + File.separator + "lib" + File.separator + "vm.jar");
|
||||
rtJar.add(javaHomePath + File.separator + "lib" + File.separator + "classes.jar");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface IRAssertion {
|
||||
|
||||
void check(CallGraph cg) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
protected static class EdgeAssertions implements IRAssertion {
|
||||
public final String srcDescriptor;
|
||||
|
||||
public final List/* <String> */<String> tgtDescriptors = new ArrayList<String>();
|
||||
|
||||
public EdgeAssertions(String srcDescriptor) {
|
||||
this.srcDescriptor = srcDescriptor;
|
||||
}
|
||||
|
||||
public static EdgeAssertions make(String srcDescriptor, String tgtDescriptor) {
|
||||
EdgeAssertions ea = new EdgeAssertions(srcDescriptor);
|
||||
ea.tgtDescriptors.add(tgtDescriptor);
|
||||
return ea;
|
||||
}
|
||||
|
||||
public static EdgeAssertions make(String srcDescriptor, String tgtDescriptor1, String tgtDescriptor2) {
|
||||
EdgeAssertions ea = new EdgeAssertions(srcDescriptor);
|
||||
ea.tgtDescriptors.add(tgtDescriptor1);
|
||||
ea.tgtDescriptors.add(tgtDescriptor2);
|
||||
return ea;
|
||||
}
|
||||
|
||||
public static EdgeAssertions make(String srcDescriptor, String tgtDescriptor1, String tgtDescriptor2, String tgtDescriptor3) {
|
||||
EdgeAssertions ea = new EdgeAssertions(srcDescriptor);
|
||||
ea.tgtDescriptors.add(tgtDescriptor1);
|
||||
ea.tgtDescriptors.add(tgtDescriptor2);
|
||||
ea.tgtDescriptors.add(tgtDescriptor3);
|
||||
return ea;
|
||||
}
|
||||
|
||||
public static EdgeAssertions make(String srcDescriptor, String tgtDescriptor1, String tgtDescriptor2, String tgtDescriptor3,
|
||||
String tgtDescriptor4) {
|
||||
EdgeAssertions ea = new EdgeAssertions(srcDescriptor);
|
||||
ea.tgtDescriptors.add(tgtDescriptor1);
|
||||
ea.tgtDescriptors.add(tgtDescriptor2);
|
||||
ea.tgtDescriptors.add(tgtDescriptor3);
|
||||
ea.tgtDescriptors.add(tgtDescriptor4);
|
||||
return ea;
|
||||
}
|
||||
|
||||
public void check(CallGraph callGraph) {
|
||||
MethodReference srcMethod = descriptorToMethodRef(this.srcDescriptor, callGraph.getClassHierarchy());
|
||||
Set<CGNode> srcNodes = callGraph.getNodes(srcMethod);
|
||||
|
||||
if (srcNodes.size() == 0) {
|
||||
System.err.println(("Unreachable/non-existent method: " + srcMethod));
|
||||
return;
|
||||
}
|
||||
if (srcNodes.size() > 1) {
|
||||
System.err.println("Context-sensitive call graph?");
|
||||
}
|
||||
|
||||
// Assume only one node for src method
|
||||
CGNode srcNode = srcNodes.iterator().next();
|
||||
|
||||
for (String target : this.tgtDescriptors) {
|
||||
MethodReference tgtMethod = descriptorToMethodRef(target, callGraph.getClassHierarchy());
|
||||
// Assume only one node for target method
|
||||
Set<CGNode> tgtNodes = callGraph.getNodes(tgtMethod);
|
||||
if (tgtNodes.size() == 0) {
|
||||
System.err.println(("Unreachable/non-existent method: " + tgtMethod));
|
||||
continue;
|
||||
}
|
||||
CGNode tgtNode = tgtNodes.iterator().next();
|
||||
|
||||
boolean found = false;
|
||||
for (Iterator<? extends CGNode> succIter = callGraph.getSuccNodes(srcNode); succIter.hasNext();) {
|
||||
CGNode succ = succIter.next();
|
||||
|
||||
if (tgtNode == succ) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
System.err.println(("Missing edge: " + srcMethod + " -> " + tgtMethod));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static class SourceMapAssertion implements IRAssertion {
|
||||
private final String method;
|
||||
|
||||
private final String variableName;
|
||||
|
||||
private final int definingLineNumber;
|
||||
|
||||
protected SourceMapAssertion(String method, String variableName, int definingLineNumber) {
|
||||
this.method = method;
|
||||
this.variableName = variableName;
|
||||
this.definingLineNumber = definingLineNumber;
|
||||
}
|
||||
|
||||
public void check(CallGraph cg) {
|
||||
|
||||
MethodReference mref = descriptorToMethodRef(method, cg.getClassHierarchy());
|
||||
|
||||
for (CGNode cgNode : cg.getNodes(mref)) {
|
||||
Assert.assertTrue("failed for " + this.variableName + " in " + cgNode, this.check(cgNode.getMethod(), cgNode.getIR()));
|
||||
}
|
||||
}
|
||||
|
||||
boolean check(IMethod m, IR ir) {
|
||||
System.err.println(("check for " + variableName + " defined at " + definingLineNumber));
|
||||
SSAInstruction[] insts = ir.getInstructions();
|
||||
for (int i = 0; i < insts.length; i++) {
|
||||
if (insts[i] != null) {
|
||||
int ln = m.getLineNumber(i);
|
||||
if (ln == definingLineNumber) {
|
||||
System.err.println((" found " + insts[i] + " at " + ln));
|
||||
for (int j = 0; j < insts[i].getNumberOfDefs(); j++) {
|
||||
int def = insts[i].getDef(j);
|
||||
System.err.println((" looking at def " + j + ": " + def));
|
||||
String[] names = ir.getLocalNames(i, def);
|
||||
if (names != null) {
|
||||
for (String name : names) {
|
||||
System.err.println((" looking at name " + name));
|
||||
if (name.equals(variableName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected Collection<String> singleTestSrc() {
|
||||
return Collections.singletonList(getTestSrcPath() + File.separator + singleJavaInputForTest());
|
||||
}
|
||||
|
||||
protected Collection<String> singleTestSrc(final String folder) {
|
||||
return Collections.singletonList(getTestSrcPath() + File.separator + folder + File.separator + singleJavaInputForTest());
|
||||
}
|
||||
|
||||
protected Collection<String> singlePkgTestSrc(String pkgName) {
|
||||
return Collections.singletonList(getTestSrcPath() + File.separator + singleJavaPkgInputForTest(pkgName));
|
||||
}
|
||||
|
||||
protected String getTestName() {
|
||||
StackTraceElement stack[] = new Throwable().getStackTrace();
|
||||
for(int i = 0; i <= stack.length; i++) {
|
||||
if (stack[i].getMethodName().startsWith("test")) {
|
||||
return stack[i].getMethodName();
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error("test method not found");
|
||||
}
|
||||
|
||||
protected String[] simpleTestEntryPoint() {
|
||||
return new String[] { "L" + getTestName().substring(4) };
|
||||
}
|
||||
|
||||
protected String[] simplePkgTestEntryPoint(String pkgName) {
|
||||
return new String[] { "L" + pkgName + "/" + getTestName().substring(4) };
|
||||
}
|
||||
|
||||
protected abstract JavaSourceAnalysisEngine getAnalysisEngine(String[] mainClassDescriptors);
|
||||
|
||||
public Pair runTest(Collection<String> sources, List<String> libs, String[] mainClassDescriptors, List<? extends IRAssertion> ca,
|
||||
boolean assertReachable) {
|
||||
try {
|
||||
JavaSourceAnalysisEngine engine = getAnalysisEngine(mainClassDescriptors);
|
||||
|
||||
populateScope(engine, sources, libs);
|
||||
|
||||
CallGraph callGraph = engine.buildDefaultCallGraph();
|
||||
System.err.println(callGraph.toString());
|
||||
|
||||
// If we've gotten this far, IR has been produced.
|
||||
dumpIR(callGraph, assertReachable);
|
||||
|
||||
// Now check any assertions as to source mapping
|
||||
for (IRAssertion IRAssertion : ca) {
|
||||
IRAssertion.check(callGraph);
|
||||
}
|
||||
|
||||
return Pair.make(callGraph, engine.getPointerAnalysis());
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Assert.assertTrue(e.toString(), false);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected static void dumpIR(CallGraph cg, boolean assertReachable) throws IOException {
|
||||
Set<IMethod> unreachable = HashSetFactory.make();
|
||||
IClassHierarchy cha = cg.getClassHierarchy();
|
||||
IClassLoader sourceLoader = cha.getLoader(JavaSourceAnalysisScope.SOURCE);
|
||||
for (Iterator iter = sourceLoader.iterateAllClasses(); iter.hasNext();) {
|
||||
IClass clazz = (IClass) iter.next();
|
||||
|
||||
System.err.println(clazz);
|
||||
if (clazz.isInterface())
|
||||
continue;
|
||||
|
||||
for (IMethod m : clazz.getDeclaredMethods()) {
|
||||
if (m.isAbstract()) {
|
||||
System.err.println(m);
|
||||
} else {
|
||||
Iterator nodeIter = cg.getNodes(m.getReference()).iterator();
|
||||
if (!nodeIter.hasNext()) {
|
||||
System.err.println(("Method " + m.getReference() + " not reachable?"));
|
||||
unreachable.add(m);
|
||||
continue;
|
||||
}
|
||||
CGNode node = (CGNode) nodeIter.next();
|
||||
System.err.println(node.getIR());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (assertReachable) {
|
||||
Assert.assertTrue("unreachable methods: " + unreachable.toString(), unreachable.isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param srcMethodDescriptor a full method descriptor of the form ldr#type#methName#methSig example:
|
||||
* Source#Simple1#main#([Ljava/lang/String;)V
|
||||
* @param cha
|
||||
* @return
|
||||
*/
|
||||
public static MethodReference descriptorToMethodRef(String srcMethodDescriptor, IClassHierarchy cha) {
|
||||
String[] ldrTypeMeth = srcMethodDescriptor.split("\\#");
|
||||
|
||||
String loaderName = ldrTypeMeth[0];
|
||||
String typeStr = ldrTypeMeth[1];
|
||||
String methName = ldrTypeMeth[2];
|
||||
String methSig = ldrTypeMeth[3];
|
||||
|
||||
TypeReference typeRef = findOrCreateTypeReference(loaderName, typeStr, cha);
|
||||
|
||||
Language l = cha.getLoader(typeRef.getClassLoader()).getLanguage();
|
||||
return MethodReference.findOrCreate(l, typeRef, methName, methSig);
|
||||
}
|
||||
|
||||
static TypeReference findOrCreateTypeReference(String loaderName, String typeStr, IClassHierarchy cha) {
|
||||
ClassLoaderReference clr = findLoader(loaderName, cha);
|
||||
TypeName typeName = TypeName.string2TypeName("L" + typeStr);
|
||||
TypeReference typeRef = TypeReference.findOrCreate(clr, typeName);
|
||||
return typeRef;
|
||||
}
|
||||
|
||||
private static ClassLoaderReference findLoader(String loaderName, IClassHierarchy cha) {
|
||||
Atom loaderAtom = Atom.findOrCreateUnicodeAtom(loaderName);
|
||||
IClassLoader[] loaders = cha.getLoaders();
|
||||
for (IClassLoader loader : loaders) {
|
||||
if (loader.getName() == loaderAtom) {
|
||||
return loader.getReference();
|
||||
}
|
||||
}
|
||||
Assertions.UNREACHABLE();
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void populateScope(JavaSourceAnalysisEngine engine, Collection<String> sources, List<String> libs) throws IOException {
|
||||
boolean foundLib = false;
|
||||
for (String lib : libs) {
|
||||
File libFile = new File(lib);
|
||||
if (libFile.exists()) {
|
||||
foundLib = true;
|
||||
engine.addSystemModule(new JarFileModule(new JarFile(libFile)));
|
||||
}
|
||||
}
|
||||
assert foundLib : "couldn't find library file from " + libs;
|
||||
|
||||
for (String srcFilePath : sources) {
|
||||
String srcFileName = srcFilePath.substring(srcFilePath.lastIndexOf(File.separator) + 1);
|
||||
File f = new File(srcFilePath);
|
||||
Assert.assertTrue("couldn't find " + srcFilePath, f.exists());
|
||||
if (f.isDirectory()) {
|
||||
engine.addSourceModule(new SourceDirectoryTreeModule(f));
|
||||
} else {
|
||||
engine.addSourceModule(new SourceFileModule(f, srcFileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void setTestSrcPath(String testSrcPath) {
|
||||
this.testSrcPath = testSrcPath;
|
||||
}
|
||||
|
||||
protected String getTestSrcPath() {
|
||||
return testSrcPath;
|
||||
}
|
||||
|
||||
protected String singleJavaInputForTest() {
|
||||
return getTestName().substring(4) + ".java";
|
||||
}
|
||||
|
||||
protected String singleInputForTest() {
|
||||
return getTestName().substring(4);
|
||||
}
|
||||
|
||||
protected String singleJavaPkgInputForTest(String pkgName) {
|
||||
return pkgName + File.separator + getTestName().substring(4) + ".java";
|
||||
}
|
||||
|
||||
}
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2002 - 2006 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* Created on Oct 3, 2005
|
||||
*/
|
||||
package com.ibm.wala.cast.java.test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.ibm.wala.cast.java.client.JavaSourceAnalysisEngine;
|
||||
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
|
||||
import com.ibm.wala.cast.loader.AstClass;
|
||||
import com.ibm.wala.cast.loader.AstMethod;
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.classLoader.IClassLoader;
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
import com.ibm.wala.classLoader.JarFileModule;
|
||||
import com.ibm.wala.classLoader.Language;
|
||||
import com.ibm.wala.classLoader.SourceDirectoryTreeModule;
|
||||
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.cha.IClassHierarchy;
|
||||
import com.ibm.wala.properties.WalaProperties;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.types.ClassLoaderReference;
|
||||
import com.ibm.wala.types.MethodReference;
|
||||
import com.ibm.wala.types.TypeName;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.strings.Atom;
|
||||
|
||||
public abstract class IRTests {
|
||||
|
||||
protected IRTests(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
protected final String projectName;
|
||||
|
||||
protected static String javaHomePath;
|
||||
|
||||
private String testSrcPath = "." + File.separator + "src";
|
||||
|
||||
public static List<String> rtJar;
|
||||
|
||||
protected static List<IRAssertion> emptyList = Collections.emptyList();
|
||||
|
||||
static {
|
||||
boolean found = false;
|
||||
try {
|
||||
rtJar = new LinkedList<String>();
|
||||
|
||||
Properties p = WalaProperties.loadProperties();
|
||||
javaHomePath = p.getProperty(WalaProperties.J2SE_DIR);
|
||||
|
||||
if (new File(javaHomePath).isDirectory()) {
|
||||
if ("Mac OS X".equals(System.getProperty("os.name"))) { // nick
|
||||
/**
|
||||
* todo: {@link WalaProperties#getJ2SEJarFiles()}
|
||||
*/
|
||||
rtJar.add(javaHomePath + "/classes.jar");
|
||||
rtJar.add(javaHomePath + "/ui.jar");
|
||||
} else {
|
||||
rtJar.add(javaHomePath + File.separator + "classes.jar");
|
||||
rtJar.add(javaHomePath + File.separator + "rt.jar");
|
||||
rtJar.add(javaHomePath + File.separator + "core.jar");
|
||||
rtJar.add(javaHomePath + File.separator + "vm.jar");
|
||||
}
|
||||
found = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// no properties
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
javaHomePath = System.getProperty("java.home");
|
||||
if ("Mac OS X".equals(System.getProperty("os.name"))) { // nick
|
||||
rtJar.add(javaHomePath + "/../Classes/classes.jar");
|
||||
rtJar.add(javaHomePath + "/../Classes/ui.jar");
|
||||
} else {
|
||||
rtJar.add(javaHomePath + File.separator + "lib" + File.separator + "rt.jar");
|
||||
rtJar.add(javaHomePath + File.separator + "lib" + File.separator + "core.jar");
|
||||
rtJar.add(javaHomePath + File.separator + "lib" + File.separator + "vm.jar");
|
||||
rtJar.add(javaHomePath + File.separator + "lib" + File.separator + "classes.jar");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface IRAssertion {
|
||||
|
||||
void check(CallGraph cg);
|
||||
|
||||
}
|
||||
|
||||
protected static class EdgeAssertions implements IRAssertion {
|
||||
public final String srcDescriptor;
|
||||
|
||||
public final List/* <String> */<String> tgtDescriptors = new ArrayList<String>();
|
||||
|
||||
public EdgeAssertions(String srcDescriptor) {
|
||||
this.srcDescriptor = srcDescriptor;
|
||||
}
|
||||
|
||||
public static EdgeAssertions make(String srcDescriptor, String tgtDescriptor) {
|
||||
EdgeAssertions ea = new EdgeAssertions(srcDescriptor);
|
||||
ea.tgtDescriptors.add(tgtDescriptor);
|
||||
return ea;
|
||||
}
|
||||
|
||||
public static EdgeAssertions make(String srcDescriptor, String tgtDescriptor1, String tgtDescriptor2) {
|
||||
EdgeAssertions ea = new EdgeAssertions(srcDescriptor);
|
||||
ea.tgtDescriptors.add(tgtDescriptor1);
|
||||
ea.tgtDescriptors.add(tgtDescriptor2);
|
||||
return ea;
|
||||
}
|
||||
|
||||
public static EdgeAssertions make(String srcDescriptor, String tgtDescriptor1, String tgtDescriptor2, String tgtDescriptor3) {
|
||||
EdgeAssertions ea = new EdgeAssertions(srcDescriptor);
|
||||
ea.tgtDescriptors.add(tgtDescriptor1);
|
||||
ea.tgtDescriptors.add(tgtDescriptor2);
|
||||
ea.tgtDescriptors.add(tgtDescriptor3);
|
||||
return ea;
|
||||
}
|
||||
|
||||
public static EdgeAssertions make(String srcDescriptor, String tgtDescriptor1, String tgtDescriptor2, String tgtDescriptor3,
|
||||
String tgtDescriptor4) {
|
||||
EdgeAssertions ea = new EdgeAssertions(srcDescriptor);
|
||||
ea.tgtDescriptors.add(tgtDescriptor1);
|
||||
ea.tgtDescriptors.add(tgtDescriptor2);
|
||||
ea.tgtDescriptors.add(tgtDescriptor3);
|
||||
ea.tgtDescriptors.add(tgtDescriptor4);
|
||||
return ea;
|
||||
}
|
||||
|
||||
public void check(CallGraph callGraph) {
|
||||
MethodReference srcMethod = descriptorToMethodRef(this.srcDescriptor, callGraph.getClassHierarchy());
|
||||
Set<CGNode> srcNodes = callGraph.getNodes(srcMethod);
|
||||
|
||||
if (srcNodes.size() == 0) {
|
||||
System.err.println(("Unreachable/non-existent method: " + srcMethod));
|
||||
return;
|
||||
}
|
||||
if (srcNodes.size() > 1) {
|
||||
System.err.println("Context-sensitive call graph?");
|
||||
}
|
||||
|
||||
// Assume only one node for src method
|
||||
CGNode srcNode = srcNodes.iterator().next();
|
||||
|
||||
for (String target : this.tgtDescriptors) {
|
||||
MethodReference tgtMethod = descriptorToMethodRef(target, callGraph.getClassHierarchy());
|
||||
// Assume only one node for target method
|
||||
Set<CGNode> tgtNodes = callGraph.getNodes(tgtMethod);
|
||||
if (tgtNodes.size() == 0) {
|
||||
System.err.println(("Unreachable/non-existent method: " + tgtMethod));
|
||||
continue;
|
||||
}
|
||||
CGNode tgtNode = tgtNodes.iterator().next();
|
||||
|
||||
boolean found = false;
|
||||
for (Iterator<? extends CGNode> succIter = callGraph.getSuccNodes(srcNode); succIter.hasNext();) {
|
||||
CGNode succ = succIter.next();
|
||||
|
||||
if (tgtNode == succ) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
System.err.println(("Missing edge: " + srcMethod + " -> " + tgtMethod));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static class SourceMapAssertion implements IRAssertion {
|
||||
private final String method;
|
||||
|
||||
private final String variableName;
|
||||
|
||||
private final int definingLineNumber;
|
||||
|
||||
protected SourceMapAssertion(String method, String variableName, int definingLineNumber) {
|
||||
this.method = method;
|
||||
this.variableName = variableName;
|
||||
this.definingLineNumber = definingLineNumber;
|
||||
}
|
||||
|
||||
public void check(CallGraph cg) {
|
||||
|
||||
MethodReference mref = descriptorToMethodRef(method, cg.getClassHierarchy());
|
||||
|
||||
for (CGNode cgNode : cg.getNodes(mref)) {
|
||||
Assert.assertTrue("failed for " + this.variableName + " in " + cgNode, this.check(cgNode.getMethod(), cgNode.getIR()));
|
||||
}
|
||||
}
|
||||
|
||||
boolean check(IMethod m, IR ir) {
|
||||
System.err.println(("check for " + variableName + " defined at " + definingLineNumber));
|
||||
SSAInstruction[] insts = ir.getInstructions();
|
||||
for (int i = 0; i < insts.length; i++) {
|
||||
if (insts[i] != null) {
|
||||
int ln = m.getLineNumber(i);
|
||||
if (ln == definingLineNumber) {
|
||||
System.err.println((" found " + insts[i] + " at " + ln));
|
||||
for (int j = 0; j < insts[i].getNumberOfDefs(); j++) {
|
||||
int def = insts[i].getDef(j);
|
||||
System.err.println((" looking at def " + j + ": " + def));
|
||||
String[] names = ir.getLocalNames(i, def);
|
||||
if (names != null) {
|
||||
for (String name : names) {
|
||||
System.err.println((" looking at name " + name));
|
||||
if (name.equals(variableName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected Collection<String> singleTestSrc() {
|
||||
return Collections.singletonList(getTestSrcPath() + File.separator + singleJavaInputForTest());
|
||||
}
|
||||
|
||||
protected Collection<String> singleTestSrc(final String folder) {
|
||||
return Collections.singletonList(getTestSrcPath() + File.separator + folder + File.separator + singleJavaInputForTest());
|
||||
}
|
||||
|
||||
protected Collection<String> singlePkgTestSrc(String pkgName) {
|
||||
return Collections.singletonList(getTestSrcPath() + File.separator + singleJavaPkgInputForTest(pkgName));
|
||||
}
|
||||
|
||||
protected String getTestName() {
|
||||
StackTraceElement stack[] = new Throwable().getStackTrace();
|
||||
for(int i = 0; i <= stack.length; i++) {
|
||||
if (stack[i].getMethodName().startsWith("test")) {
|
||||
return stack[i].getMethodName();
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error("test method not found");
|
||||
}
|
||||
|
||||
protected String[] simpleTestEntryPoint() {
|
||||
return new String[] { "L" + getTestName().substring(4) };
|
||||
}
|
||||
|
||||
protected String[] simplePkgTestEntryPoint(String pkgName) {
|
||||
return new String[] { "L" + pkgName + "/" + getTestName().substring(4) };
|
||||
}
|
||||
|
||||
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) {
|
||||
AbstractAnalysisEngine engine = getAnalysisEngine(mainClassDescriptors, sources, libs);
|
||||
|
||||
CallGraph callGraph;
|
||||
try {
|
||||
callGraph = engine.buildDefaultCallGraph();
|
||||
System.err.println(callGraph.toString());
|
||||
|
||||
// If we've gotten this far, IR has been produced.
|
||||
dumpIR(callGraph, sources, assertReachable);
|
||||
|
||||
// Now check any assertions as to source mapping
|
||||
for (IRAssertion IRAssertion : ca) {
|
||||
IRAssertion.check(callGraph);
|
||||
}
|
||||
|
||||
return Pair.make(callGraph, engine.getPointerAnalysis());
|
||||
} catch (IllegalArgumentException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (CancelException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static void dumpIR(CallGraph cg, Collection<String> sources, boolean assertReachable) throws IOException {
|
||||
Set<String> sourcePaths = HashSetFactory.make();
|
||||
for(String src : sources) {
|
||||
sourcePaths.add(src.substring(src.lastIndexOf(File.separator)+1));
|
||||
}
|
||||
|
||||
Set<IMethod> unreachable = HashSetFactory.make();
|
||||
IClassHierarchy cha = cg.getClassHierarchy();
|
||||
IClassLoader sourceLoader = cha.getLoader(JavaSourceAnalysisScope.SOURCE);
|
||||
for (Iterator iter = sourceLoader.iterateAllClasses(); iter.hasNext();) {
|
||||
IClass clazz = (IClass) iter.next();
|
||||
|
||||
System.err.println(clazz);
|
||||
if (clazz.isInterface())
|
||||
continue;
|
||||
|
||||
for (IMethod m : clazz.getDeclaredMethods()) {
|
||||
if (m.isAbstract()) {
|
||||
System.err.println(m);
|
||||
} else {
|
||||
Iterator nodeIter = cg.getNodes(m.getReference()).iterator();
|
||||
if (!nodeIter.hasNext()) {
|
||||
if (m instanceof AstMethod) {
|
||||
String fn = ((AstClass)m.getDeclaringClass()).getSourcePosition().getURL().getFile();
|
||||
if (sourcePaths.contains(fn.substring(fn.lastIndexOf(File.separator)+1))) {
|
||||
System.err.println(("Method " + m.getReference() + " not reachable?"));
|
||||
unreachable.add(m);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
CGNode node = (CGNode) nodeIter.next();
|
||||
System.err.println(node.getIR());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (assertReachable) {
|
||||
Assert.assertTrue("unreachable methods: " + unreachable.toString(), unreachable.isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param srcMethodDescriptor a full method descriptor of the form ldr#type#methName#methSig example:
|
||||
* Source#Simple1#main#([Ljava/lang/String;)V
|
||||
* @param cha
|
||||
* @return
|
||||
*/
|
||||
public static MethodReference descriptorToMethodRef(String srcMethodDescriptor, IClassHierarchy cha) {
|
||||
String[] ldrTypeMeth = srcMethodDescriptor.split("\\#");
|
||||
|
||||
String loaderName = ldrTypeMeth[0];
|
||||
String typeStr = ldrTypeMeth[1];
|
||||
String methName = ldrTypeMeth[2];
|
||||
String methSig = ldrTypeMeth[3];
|
||||
|
||||
TypeReference typeRef = findOrCreateTypeReference(loaderName, typeStr, cha);
|
||||
|
||||
Language l = cha.getLoader(typeRef.getClassLoader()).getLanguage();
|
||||
return MethodReference.findOrCreate(l, typeRef, methName, methSig);
|
||||
}
|
||||
|
||||
static TypeReference findOrCreateTypeReference(String loaderName, String typeStr, IClassHierarchy cha) {
|
||||
ClassLoaderReference clr = findLoader(loaderName, cha);
|
||||
TypeName typeName = TypeName.string2TypeName("L" + typeStr);
|
||||
TypeReference typeRef = TypeReference.findOrCreate(clr, typeName);
|
||||
return typeRef;
|
||||
}
|
||||
|
||||
private static ClassLoaderReference findLoader(String loaderName, IClassHierarchy cha) {
|
||||
Atom loaderAtom = Atom.findOrCreateUnicodeAtom(loaderName);
|
||||
IClassLoader[] loaders = cha.getLoaders();
|
||||
for (IClassLoader loader : loaders) {
|
||||
if (loader.getName() == loaderAtom) {
|
||||
return loader.getReference();
|
||||
}
|
||||
}
|
||||
Assertions.UNREACHABLE();
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void populateScope(JavaSourceAnalysisEngine engine, Collection<String> sources, List<String> libs) {
|
||||
boolean foundLib = false;
|
||||
for (String lib : libs) {
|
||||
File libFile = new File(lib);
|
||||
if (libFile.exists()) {
|
||||
foundLib = true;
|
||||
try {
|
||||
engine.addSystemModule(new JarFileModule(new JarFile(libFile)));
|
||||
} catch (IOException e) {
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
assert foundLib : "couldn't find library file from " + libs;
|
||||
|
||||
for (String srcFilePath : sources) {
|
||||
String srcFileName = srcFilePath.substring(srcFilePath.lastIndexOf(File.separator) + 1);
|
||||
File f = new File(srcFilePath);
|
||||
Assert.assertTrue("couldn't find " + srcFilePath, f.exists());
|
||||
if (f.isDirectory()) {
|
||||
engine.addSourceModule(new SourceDirectoryTreeModule(f));
|
||||
} else {
|
||||
engine.addSourceModule(new SourceFileModule(f, srcFileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void setTestSrcPath(String testSrcPath) {
|
||||
this.testSrcPath = testSrcPath;
|
||||
}
|
||||
|
||||
protected String getTestSrcPath() {
|
||||
return testSrcPath;
|
||||
}
|
||||
|
||||
protected String singleJavaInputForTest() {
|
||||
return getTestName().substring(4) + ".java";
|
||||
}
|
||||
|
||||
protected String singleInputForTest() {
|
||||
return getTestName().substring(4);
|
||||
}
|
||||
|
||||
protected String singleJavaPkgInputForTest(String pkgName) {
|
||||
return pkgName + File.separator + getTestName().substring(4) + ".java";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
|||
#Thu Jan 03 11:24:43 EST 2008
|
||||
eclipse.preferences.version=1
|
||||
formatter_profile=_WALA
|
||||
formatter_settings_version=11
|
||||
instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
|
||||
#Thu Jan 03 11:24:43 EST 2008
|
||||
eclipse.preferences.version=1
|
||||
formatter_profile=_WALA
|
||||
formatter_settings_version=11
|
||||
instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Java Source WALA Front End
|
||||
Bundle-SymbolicName: com.ibm.wala.cast.java
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Activator: com.ibm.wala.cast.java.JavaSourcePlugin
|
||||
Bundle-Vendor: rfuhrer@watson.ibm.com
|
||||
Require-Bundle: com.ibm.wala.cast,
|
||||
com.ibm.wala.core,
|
||||
com.ibm.wala.shrike,
|
||||
org.eclipse.core.runtime
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.ibm.wala.cast.java,
|
||||
com.ibm.wala.cast.java.analysis.typeInference,
|
||||
com.ibm.wala.cast.java.client,
|
||||
com.ibm.wala.cast.java.client.impl,
|
||||
com.ibm.wala.cast.java.examples.ast,
|
||||
com.ibm.wala.cast.java.ipa.callgraph,
|
||||
com.ibm.wala.cast.java.ipa.modref,
|
||||
com.ibm.wala.cast.java.ipa.slicer,
|
||||
com.ibm.wala.cast.java.loader,
|
||||
com.ibm.wala.cast.java.ssa,
|
||||
com.ibm.wala.cast.java.translator,
|
||||
com.ibm.wala.cast.java.types
|
||||
Bundle-ClassPath: .
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Java Source WALA Front End
|
||||
Bundle-SymbolicName: com.ibm.wala.cast.java
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Activator: com.ibm.wala.cast.java.JavaSourcePlugin
|
||||
Bundle-Vendor: rfuhrer@watson.ibm.com
|
||||
Require-Bundle: com.ibm.wala.cast,
|
||||
com.ibm.wala.core,
|
||||
com.ibm.wala.shrike,
|
||||
org.eclipse.core.runtime
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.ibm.wala.cast.java,
|
||||
com.ibm.wala.cast.java.analysis.typeInference,
|
||||
com.ibm.wala.cast.java.client,
|
||||
com.ibm.wala.cast.java.client.impl,
|
||||
com.ibm.wala.cast.java.examples.ast,
|
||||
com.ibm.wala.cast.java.ipa.callgraph,
|
||||
com.ibm.wala.cast.java.ipa.modref,
|
||||
com.ibm.wala.cast.java.ipa.slicer,
|
||||
com.ibm.wala.cast.java.loader,
|
||||
com.ibm.wala.cast.java.ssa,
|
||||
com.ibm.wala.cast.java.translator,
|
||||
com.ibm.wala.cast.java.types
|
||||
Bundle-ClassPath: .
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
|
|
|
@ -1,165 +1,165 @@
|
|||
/******************************************************************************
|
||||
* Copyright (c) 2002 - 2006 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*****************************************************************************/
|
||||
package com.ibm.wala.cast.java.client;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ibm.wala.cast.ir.ssa.AstIRFactory;
|
||||
import com.ibm.wala.cast.java.client.impl.ZeroCFABuilderFactory;
|
||||
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
|
||||
import com.ibm.wala.classLoader.ClassLoaderFactory;
|
||||
import com.ibm.wala.classLoader.Module;
|
||||
import com.ibm.wala.client.AbstractAnalysisEngine;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisCache;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraphBuilder;
|
||||
import com.ibm.wala.ipa.callgraph.Entrypoint;
|
||||
import com.ibm.wala.ipa.callgraph.impl.SetOfClasses;
|
||||
import com.ibm.wala.ipa.callgraph.impl.Util;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchy;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchyException;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
import com.ibm.wala.ssa.SSAOptions;
|
||||
import com.ibm.wala.ssa.SymbolTable;
|
||||
import com.ibm.wala.types.ClassLoaderReference;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.config.FileOfClasses;
|
||||
|
||||
/**
|
||||
*/
|
||||
public abstract class JavaSourceAnalysisEngine extends AbstractAnalysisEngine {
|
||||
|
||||
/**
|
||||
* Modules which are user-space code
|
||||
*/
|
||||
private final Set<Module> userEntries = HashSetFactory.make();
|
||||
|
||||
/**
|
||||
* Modules which are source code
|
||||
*/
|
||||
private final Set<Module> sourceEntries = HashSetFactory.make();
|
||||
|
||||
/**
|
||||
* Modules which are system or library code TODO: what about extension loader?
|
||||
*/
|
||||
private final Set<Module> systemEntries = HashSetFactory.make();
|
||||
|
||||
public JavaSourceAnalysisEngine() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given source module to the source loader's module list. Clients
|
||||
* should/may call this method if they don't supply an IJavaProject to the
|
||||
* constructor.
|
||||
*/
|
||||
public void addSourceModule(Module M) {
|
||||
sourceEntries.add(M);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given compiled module to the application loader's module list.
|
||||
* Clients should/may call this method if they don't supply an IJavaProject to
|
||||
* the constructor.
|
||||
*/
|
||||
public void addCompiledModule(Module M) {
|
||||
userEntries.add(M);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given module to the primordial loader's module list. Clients
|
||||
* should/may call this method if they don't supply an IJavaProject to the
|
||||
* constructor.
|
||||
*/
|
||||
public void addSystemModule(Module M) {
|
||||
systemEntries.add(M);
|
||||
}
|
||||
|
||||
protected void addApplicationModulesToScope() {
|
||||
ClassLoaderReference app = scope.getApplicationLoader();
|
||||
for (Module M : userEntries) {
|
||||
scope.addToScope(app, M);
|
||||
}
|
||||
|
||||
ClassLoaderReference src = ((JavaSourceAnalysisScope) scope).getSourceLoader();
|
||||
|
||||
for (Module M : sourceEntries) {
|
||||
scope.addToScope(src, M);
|
||||
}
|
||||
}
|
||||
|
||||
public void buildAnalysisScope() throws IOException {
|
||||
scope = makeSourceAnalysisScope();
|
||||
|
||||
if (getExclusionsFile() != null) {
|
||||
scope.setExclusions(FileOfClasses.createFileOfClasses(new File(getExclusionsFile())));
|
||||
}
|
||||
|
||||
for (Module M : this.systemEntries) {
|
||||
scope.addToScope(scope.getPrimordialLoader(), M);
|
||||
}
|
||||
|
||||
// add user stuff
|
||||
addApplicationModulesToScope();
|
||||
}
|
||||
|
||||
protected AnalysisScope makeSourceAnalysisScope() {
|
||||
return new JavaSourceAnalysisScope();
|
||||
}
|
||||
|
||||
protected abstract ClassLoaderFactory getClassLoaderFactory(SetOfClasses exclusions);
|
||||
|
||||
public IClassHierarchy buildClassHierarchy() {
|
||||
IClassHierarchy cha = null;
|
||||
ClassLoaderFactory factory = getClassLoaderFactory(scope.getExclusions());
|
||||
|
||||
try {
|
||||
cha = ClassHierarchy.make(getScope(), factory);
|
||||
} catch (ClassHierarchyException e) {
|
||||
System.err.println("Class Hierarchy construction failed");
|
||||
System.err.println(e.toString());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return cha;
|
||||
}
|
||||
|
||||
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
|
||||
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalysisCache makeDefaultCache() {
|
||||
return new AnalysisCache(AstIRFactory.makeDefaultFactory());
|
||||
}
|
||||
|
||||
public AnalysisOptions getDefaultOptions(Iterable<Entrypoint> entrypoints) {
|
||||
AnalysisOptions options = new AnalysisOptions(getScope(), entrypoints);
|
||||
|
||||
SSAOptions ssaOptions = new SSAOptions();
|
||||
ssaOptions.setDefaultValues(new SSAOptions.DefaultValues() {
|
||||
public int getDefaultValue(SymbolTable symtab, int valueNumber) {
|
||||
return symtab.getDefaultValue(valueNumber);
|
||||
}
|
||||
});
|
||||
|
||||
options.setSSAOptions(ssaOptions);
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CallGraphBuilder getCallGraphBuilder(IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache) {
|
||||
return new ZeroCFABuilderFactory().make(options, cache, cha, scope, false);
|
||||
}
|
||||
}
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2002 - 2006 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*****************************************************************************/
|
||||
package com.ibm.wala.cast.java.client;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ibm.wala.cast.ir.ssa.AstIRFactory;
|
||||
import com.ibm.wala.cast.java.client.impl.ZeroCFABuilderFactory;
|
||||
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
|
||||
import com.ibm.wala.classLoader.ClassLoaderFactory;
|
||||
import com.ibm.wala.classLoader.Module;
|
||||
import com.ibm.wala.client.AbstractAnalysisEngine;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisCache;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraphBuilder;
|
||||
import com.ibm.wala.ipa.callgraph.Entrypoint;
|
||||
import com.ibm.wala.ipa.callgraph.impl.SetOfClasses;
|
||||
import com.ibm.wala.ipa.callgraph.impl.Util;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchy;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchyException;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
import com.ibm.wala.ssa.SSAOptions;
|
||||
import com.ibm.wala.ssa.SymbolTable;
|
||||
import com.ibm.wala.types.ClassLoaderReference;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.config.FileOfClasses;
|
||||
|
||||
/**
|
||||
*/
|
||||
public abstract class JavaSourceAnalysisEngine extends AbstractAnalysisEngine {
|
||||
|
||||
/**
|
||||
* Modules which are user-space code
|
||||
*/
|
||||
private final Set<Module> userEntries = HashSetFactory.make();
|
||||
|
||||
/**
|
||||
* Modules which are source code
|
||||
*/
|
||||
private final Set<Module> sourceEntries = HashSetFactory.make();
|
||||
|
||||
/**
|
||||
* Modules which are system or library code TODO: what about extension loader?
|
||||
*/
|
||||
private final Set<Module> systemEntries = HashSetFactory.make();
|
||||
|
||||
public JavaSourceAnalysisEngine() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given source module to the source loader's module list. Clients
|
||||
* should/may call this method if they don't supply an IJavaProject to the
|
||||
* constructor.
|
||||
*/
|
||||
public void addSourceModule(Module M) {
|
||||
sourceEntries.add(M);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given compiled module to the application loader's module list.
|
||||
* Clients should/may call this method if they don't supply an IJavaProject to
|
||||
* the constructor.
|
||||
*/
|
||||
public void addCompiledModule(Module M) {
|
||||
userEntries.add(M);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given module to the primordial loader's module list. Clients
|
||||
* should/may call this method if they don't supply an IJavaProject to the
|
||||
* constructor.
|
||||
*/
|
||||
public void addSystemModule(Module M) {
|
||||
systemEntries.add(M);
|
||||
}
|
||||
|
||||
protected void addApplicationModulesToScope() {
|
||||
ClassLoaderReference app = scope.getApplicationLoader();
|
||||
for (Module M : userEntries) {
|
||||
scope.addToScope(app, M);
|
||||
}
|
||||
|
||||
ClassLoaderReference src = ((JavaSourceAnalysisScope) scope).getSourceLoader();
|
||||
|
||||
for (Module M : sourceEntries) {
|
||||
scope.addToScope(src, M);
|
||||
}
|
||||
}
|
||||
|
||||
public void buildAnalysisScope() throws IOException {
|
||||
scope = makeSourceAnalysisScope();
|
||||
|
||||
if (getExclusionsFile() != null) {
|
||||
scope.setExclusions(FileOfClasses.createFileOfClasses(new File(getExclusionsFile())));
|
||||
}
|
||||
|
||||
for (Module M : this.systemEntries) {
|
||||
scope.addToScope(scope.getPrimordialLoader(), M);
|
||||
}
|
||||
|
||||
// add user stuff
|
||||
addApplicationModulesToScope();
|
||||
}
|
||||
|
||||
protected AnalysisScope makeSourceAnalysisScope() {
|
||||
return new JavaSourceAnalysisScope();
|
||||
}
|
||||
|
||||
protected abstract ClassLoaderFactory getClassLoaderFactory(SetOfClasses exclusions);
|
||||
|
||||
public IClassHierarchy buildClassHierarchy() {
|
||||
IClassHierarchy cha = null;
|
||||
ClassLoaderFactory factory = getClassLoaderFactory(scope.getExclusions());
|
||||
|
||||
try {
|
||||
cha = ClassHierarchy.make(getScope(), factory);
|
||||
} catch (ClassHierarchyException e) {
|
||||
System.err.println("Class Hierarchy construction failed");
|
||||
System.err.println(e.toString());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return cha;
|
||||
}
|
||||
|
||||
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
|
||||
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalysisCache makeDefaultCache() {
|
||||
return new AnalysisCache(AstIRFactory.makeDefaultFactory());
|
||||
}
|
||||
|
||||
public AnalysisOptions getDefaultOptions(Iterable<Entrypoint> entrypoints) {
|
||||
AnalysisOptions options = new AnalysisOptions(getScope(), entrypoints);
|
||||
|
||||
SSAOptions ssaOptions = new SSAOptions();
|
||||
ssaOptions.setDefaultValues(new SSAOptions.DefaultValues() {
|
||||
public int getDefaultValue(SymbolTable symtab, int valueNumber) {
|
||||
return symtab.getDefaultValue(valueNumber);
|
||||
}
|
||||
});
|
||||
|
||||
options.setSSAOptions(ssaOptions);
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CallGraphBuilder getCallGraphBuilder(IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache) {
|
||||
return new ZeroCFABuilderFactory().make(options, cache, cha, scope, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.ibm.wala.cast.tree.CAstEntity;
|
|||
import com.ibm.wala.cast.tree.CAstNode;
|
||||
import com.ibm.wala.cast.tree.CAstSourcePositionMap;
|
||||
import com.ibm.wala.cast.tree.impl.CAstOperator;
|
||||
import com.ibm.wala.cast.tree.impl.CAstRewriter;
|
||||
import com.ibm.wala.cast.tree.rewrite.CAstRewriter;
|
||||
import com.ibm.wala.classLoader.CallSiteReference;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
|
||||
|
|
|
@ -1,75 +1,75 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002 - 2006 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.ibm.wala.cast.java.ipa.callgraph;
|
||||
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisCache;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
|
||||
import com.ibm.wala.ipa.callgraph.ContextSelector;
|
||||
import com.ibm.wala.ipa.callgraph.impl.DefaultContextSelector;
|
||||
import com.ibm.wala.ipa.callgraph.impl.DelegatingContextSelector;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.cfa.ContainerContextSelector;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.cfa.ZeroXInstanceKeys;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
|
||||
/**
|
||||
*
|
||||
* 0-1-CFA Call graph builder which analyzes calls to "container methods" in a context which is defined by the receiver
|
||||
* instance.
|
||||
*
|
||||
* @author sfink
|
||||
*/
|
||||
public class AstJavaZeroOneContainerCFABuilder extends AstJavaCFABuilder {
|
||||
|
||||
/**
|
||||
* @param cha governing class hierarchy
|
||||
* @param warnings object to track analysis warnings
|
||||
* @param options call graph construction options
|
||||
* @param appContextSelector application-specific logic to choose contexts
|
||||
* @param appContextInterpreter application-specific logic to interpret a method in context
|
||||
* @param reflect reflection specification
|
||||
*/
|
||||
public AstJavaZeroOneContainerCFABuilder(IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache,
|
||||
ContextSelector appContextSelector, SSAContextInterpreter appContextInterpreter) {
|
||||
super(cha, options, cache);
|
||||
|
||||
ContextSelector def = new DefaultContextSelector(options, cha);
|
||||
ContextSelector contextSelector = appContextSelector == null ? def : new DelegatingContextSelector(appContextSelector, def);
|
||||
|
||||
SSAContextInterpreter contextInterpreter = makeDefaultContextInterpreters(appContextInterpreter, options, cha);
|
||||
setContextInterpreter(contextInterpreter);
|
||||
|
||||
ZeroXInstanceKeys zik = makeInstanceKeys(cha, options, contextInterpreter);
|
||||
setInstanceKeys(new JavaScopeMappingInstanceKeys(cha, this, zik));
|
||||
|
||||
ContextSelector CCS = makeContainerContextSelector(cha, zik);
|
||||
DelegatingContextSelector DCS = new DelegatingContextSelector(CCS, contextSelector);
|
||||
setContextSelector(DCS);
|
||||
}
|
||||
|
||||
protected ZeroXInstanceKeys makeInstanceKeys(IClassHierarchy cha, AnalysisOptions options,
|
||||
SSAContextInterpreter contextInterpreter) {
|
||||
ZeroXInstanceKeys zik = new ZeroXInstanceKeys(options, cha, contextInterpreter, ZeroXInstanceKeys.ALLOCATIONS
|
||||
| ZeroXInstanceKeys.SMUSH_PRIMITIVE_HOLDERS | ZeroXInstanceKeys.SMUSH_STRINGS | ZeroXInstanceKeys.SMUSH_MANY
|
||||
| ZeroXInstanceKeys.SMUSH_THROWABLES);
|
||||
return zik;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cha
|
||||
* @param keys
|
||||
* @return an object which creates contexts for call graph nodes based on the container disambiguation policy
|
||||
*/
|
||||
protected ContextSelector makeContainerContextSelector(IClassHierarchy cha, ZeroXInstanceKeys keys) {
|
||||
return new ContainerContextSelector(cha, keys);
|
||||
}
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2002 - 2006 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.ibm.wala.cast.java.ipa.callgraph;
|
||||
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisCache;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
|
||||
import com.ibm.wala.ipa.callgraph.ContextSelector;
|
||||
import com.ibm.wala.ipa.callgraph.impl.DefaultContextSelector;
|
||||
import com.ibm.wala.ipa.callgraph.impl.DelegatingContextSelector;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.cfa.ContainerContextSelector;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.cfa.ZeroXInstanceKeys;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
|
||||
/**
|
||||
*
|
||||
* 0-1-CFA Call graph builder which analyzes calls to "container methods" in a context which is defined by the receiver
|
||||
* instance.
|
||||
*
|
||||
* @author sfink
|
||||
*/
|
||||
public class AstJavaZeroOneContainerCFABuilder extends AstJavaCFABuilder {
|
||||
|
||||
/**
|
||||
* @param cha governing class hierarchy
|
||||
* @param warnings object to track analysis warnings
|
||||
* @param options call graph construction options
|
||||
* @param appContextSelector application-specific logic to choose contexts
|
||||
* @param appContextInterpreter application-specific logic to interpret a method in context
|
||||
* @param reflect reflection specification
|
||||
*/
|
||||
public AstJavaZeroOneContainerCFABuilder(IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache,
|
||||
ContextSelector appContextSelector, SSAContextInterpreter appContextInterpreter) {
|
||||
super(cha, options, cache);
|
||||
|
||||
ContextSelector def = new DefaultContextSelector(options, cha);
|
||||
ContextSelector contextSelector = appContextSelector == null ? def : new DelegatingContextSelector(appContextSelector, def);
|
||||
|
||||
SSAContextInterpreter contextInterpreter = makeDefaultContextInterpreters(appContextInterpreter, options, cha);
|
||||
setContextInterpreter(contextInterpreter);
|
||||
|
||||
ZeroXInstanceKeys zik = makeInstanceKeys(cha, options, contextInterpreter);
|
||||
setInstanceKeys(new JavaScopeMappingInstanceKeys(cha, this, zik));
|
||||
|
||||
ContextSelector CCS = makeContainerContextSelector(cha, zik);
|
||||
DelegatingContextSelector DCS = new DelegatingContextSelector(CCS, contextSelector);
|
||||
setContextSelector(DCS);
|
||||
}
|
||||
|
||||
protected ZeroXInstanceKeys makeInstanceKeys(IClassHierarchy cha, AnalysisOptions options,
|
||||
SSAContextInterpreter contextInterpreter) {
|
||||
ZeroXInstanceKeys zik = new ZeroXInstanceKeys(options, cha, contextInterpreter, ZeroXInstanceKeys.ALLOCATIONS
|
||||
| ZeroXInstanceKeys.SMUSH_PRIMITIVE_HOLDERS | ZeroXInstanceKeys.SMUSH_STRINGS | ZeroXInstanceKeys.SMUSH_MANY
|
||||
| ZeroXInstanceKeys.SMUSH_THROWABLES);
|
||||
return zik;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cha
|
||||
* @param keys
|
||||
* @return an object which creates contexts for call graph nodes based on the container disambiguation policy
|
||||
*/
|
||||
protected ContextSelector makeContainerContextSelector(IClassHierarchy cha, ZeroXInstanceKeys keys) {
|
||||
return new ContainerContextSelector(cha, keys);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import java.util.Iterator;
|
|||
import java.util.Set;
|
||||
|
||||
import com.ibm.wala.cast.ipa.callgraph.ScopeMappingInstanceKeys;
|
||||
import com.ibm.wala.cast.ipa.callgraph.ScopeMappingInstanceKeys.ScopeMappingInstanceKey;
|
||||
import com.ibm.wala.cast.ir.translator.AstTranslator;
|
||||
import com.ibm.wala.cast.java.loader.JavaSourceLoaderImpl.JavaClass;
|
||||
import com.ibm.wala.cast.loader.AstMethod;
|
||||
|
|
|
@ -1,115 +1,115 @@
|
|||
package com.ibm.wala.cast.java.ipa.slicer;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ibm.wala.cast.ir.ssa.AstAssertInstruction;
|
||||
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.PointerAnalysis;
|
||||
import com.ibm.wala.ipa.slicer.NormalStatement;
|
||||
import com.ibm.wala.ipa.slicer.SDG;
|
||||
import com.ibm.wala.ipa.slicer.Slicer;
|
||||
import com.ibm.wala.ipa.slicer.Statement;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.SSAArrayLoadInstruction;
|
||||
import com.ibm.wala.ssa.SSAArrayStoreInstruction;
|
||||
import com.ibm.wala.ssa.SSAGetInstruction;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SSAMonitorInstruction;
|
||||
import com.ibm.wala.ssa.SSAPutInstruction;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.collections.Filter;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.graph.traverse.DFS;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class AstJavaSlicer extends Slicer {
|
||||
|
||||
/*
|
||||
* Use the passed-in SDG
|
||||
*/
|
||||
public static Collection<Statement> computeBackwardSlice(SDG sdg, Collection<Statement> ss) throws IllegalArgumentException,
|
||||
CancelException {
|
||||
return computeSlice(sdg, ss, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ss a collection of statements of interest
|
||||
* @throws CancelException
|
||||
*/
|
||||
public static Collection<Statement> computeSlice(SDG sdg, Collection<Statement> ss, boolean backward) throws CancelException {
|
||||
return new AstJavaSlicer().slice(sdg, ss, backward);
|
||||
}
|
||||
|
||||
public static Set<Statement> gatherStatements(CallGraph CG, Collection<CGNode> partialRoots, Filter<SSAInstruction> filter) {
|
||||
Set<Statement> result = new HashSet<Statement>();
|
||||
for (Iterator<CGNode> ns = DFS.getReachableNodes(CG, partialRoots).iterator(); ns.hasNext();) {
|
||||
CGNode n = ns.next();
|
||||
IR nir = n.getIR();
|
||||
if (nir != null) {
|
||||
SSAInstruction insts[] = nir.getInstructions();
|
||||
for (int i = 0; i < insts.length; i++) {
|
||||
if (filter.accepts(insts[i])) {
|
||||
result.add(new NormalStatement(n, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Set<Statement> gatherAssertions(CallGraph CG, Collection<CGNode> partialRoots) {
|
||||
return gatherStatements(CG, partialRoots, new Filter<SSAInstruction>() {
|
||||
public boolean accepts(SSAInstruction o) {
|
||||
return o instanceof AstAssertInstruction;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Set<Statement> gatherMonitors(CallGraph CG, Collection<CGNode> partialRoots) {
|
||||
return gatherStatements(CG, partialRoots, new Filter<SSAInstruction>() {
|
||||
public boolean accepts(SSAInstruction o) {
|
||||
return o instanceof SSAMonitorInstruction;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Set<Statement> gatherWrites(CallGraph CG, Collection<CGNode> partialRoots) {
|
||||
return gatherStatements(CG, partialRoots, new Filter<SSAInstruction>() {
|
||||
public boolean accepts(SSAInstruction o) {
|
||||
return (o instanceof SSAPutInstruction) || (o instanceof SSAArrayStoreInstruction);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Set<Statement> gatherReads(CallGraph CG, Collection<CGNode> partialRoots) {
|
||||
return gatherStatements(CG, partialRoots, new Filter<SSAInstruction>() {
|
||||
public boolean accepts(SSAInstruction o) {
|
||||
return (o instanceof SSAGetInstruction) || (o instanceof SSAArrayLoadInstruction);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Pair<Collection<Statement>, SDG> computeAssertionSlice(CallGraph CG, PointerAnalysis 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);
|
||||
System.err.println(("SDG:\n" + sdg));
|
||||
Set<Statement> stmts = gatherAssertions(CG, partialRoots);
|
||||
if (multiThreadedCode) {
|
||||
// Grab anything that has "side effects" under JMM
|
||||
stmts.addAll(gatherReads(CG, partialRoots));
|
||||
stmts.addAll(gatherWrites(CG, partialRoots));
|
||||
stmts.addAll(gatherMonitors(CG, partialRoots));
|
||||
}
|
||||
return Pair.make(AstJavaSlicer.computeBackwardSlice(sdg, stmts), sdg);
|
||||
}
|
||||
|
||||
}
|
||||
package com.ibm.wala.cast.java.ipa.slicer;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ibm.wala.cast.ir.ssa.AstAssertInstruction;
|
||||
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.PointerAnalysis;
|
||||
import com.ibm.wala.ipa.slicer.NormalStatement;
|
||||
import com.ibm.wala.ipa.slicer.SDG;
|
||||
import com.ibm.wala.ipa.slicer.Slicer;
|
||||
import com.ibm.wala.ipa.slicer.Statement;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.SSAArrayLoadInstruction;
|
||||
import com.ibm.wala.ssa.SSAArrayStoreInstruction;
|
||||
import com.ibm.wala.ssa.SSAGetInstruction;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SSAMonitorInstruction;
|
||||
import com.ibm.wala.ssa.SSAPutInstruction;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.collections.Filter;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.graph.traverse.DFS;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class AstJavaSlicer extends Slicer {
|
||||
|
||||
/*
|
||||
* Use the passed-in SDG
|
||||
*/
|
||||
public static Collection<Statement> computeBackwardSlice(SDG sdg, Collection<Statement> ss) throws IllegalArgumentException,
|
||||
CancelException {
|
||||
return computeSlice(sdg, ss, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ss a collection of statements of interest
|
||||
* @throws CancelException
|
||||
*/
|
||||
public static Collection<Statement> computeSlice(SDG sdg, Collection<Statement> ss, boolean backward) throws CancelException {
|
||||
return new AstJavaSlicer().slice(sdg, ss, backward);
|
||||
}
|
||||
|
||||
public static Set<Statement> gatherStatements(CallGraph CG, Collection<CGNode> partialRoots, Filter<SSAInstruction> filter) {
|
||||
Set<Statement> result = new HashSet<Statement>();
|
||||
for (Iterator<CGNode> ns = DFS.getReachableNodes(CG, partialRoots).iterator(); ns.hasNext();) {
|
||||
CGNode n = ns.next();
|
||||
IR nir = n.getIR();
|
||||
if (nir != null) {
|
||||
SSAInstruction insts[] = nir.getInstructions();
|
||||
for (int i = 0; i < insts.length; i++) {
|
||||
if (filter.accepts(insts[i])) {
|
||||
result.add(new NormalStatement(n, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Set<Statement> gatherAssertions(CallGraph CG, Collection<CGNode> partialRoots) {
|
||||
return gatherStatements(CG, partialRoots, new Filter<SSAInstruction>() {
|
||||
public boolean accepts(SSAInstruction o) {
|
||||
return o instanceof AstAssertInstruction;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Set<Statement> gatherMonitors(CallGraph CG, Collection<CGNode> partialRoots) {
|
||||
return gatherStatements(CG, partialRoots, new Filter<SSAInstruction>() {
|
||||
public boolean accepts(SSAInstruction o) {
|
||||
return o instanceof SSAMonitorInstruction;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Set<Statement> gatherWrites(CallGraph CG, Collection<CGNode> partialRoots) {
|
||||
return gatherStatements(CG, partialRoots, new Filter<SSAInstruction>() {
|
||||
public boolean accepts(SSAInstruction o) {
|
||||
return (o instanceof SSAPutInstruction) || (o instanceof SSAArrayStoreInstruction);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Set<Statement> gatherReads(CallGraph CG, Collection<CGNode> partialRoots) {
|
||||
return gatherStatements(CG, partialRoots, new Filter<SSAInstruction>() {
|
||||
public boolean accepts(SSAInstruction o) {
|
||||
return (o instanceof SSAGetInstruction) || (o instanceof SSAArrayLoadInstruction);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Pair<Collection<Statement>, SDG> computeAssertionSlice(CallGraph CG, PointerAnalysis 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);
|
||||
System.err.println(("SDG:\n" + sdg));
|
||||
Set<Statement> stmts = gatherAssertions(CG, partialRoots);
|
||||
if (multiThreadedCode) {
|
||||
// Grab anything that has "side effects" under JMM
|
||||
stmts.addAll(gatherReads(CG, partialRoots));
|
||||
stmts.addAll(gatherWrites(CG, partialRoots));
|
||||
stmts.addAll(gatherMonitors(CG, partialRoots));
|
||||
}
|
||||
return Pair.make(AstJavaSlicer.computeBackwardSlice(sdg, stmts), sdg);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,9 +54,9 @@ import com.ibm.wala.classLoader.IClass;
|
|||
import com.ibm.wala.classLoader.IClassLoader;
|
||||
import com.ibm.wala.classLoader.IField;
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
import com.ibm.wala.classLoader.Module;
|
||||
import com.ibm.wala.classLoader.JavaLanguage.JavaInstructionFactory;
|
||||
import com.ibm.wala.classLoader.Language;
|
||||
import com.ibm.wala.classLoader.Module;
|
||||
import com.ibm.wala.classLoader.ModuleEntry;
|
||||
import com.ibm.wala.classLoader.NewSiteReference;
|
||||
import com.ibm.wala.ipa.callgraph.impl.SetOfClasses;
|
||||
|
@ -139,7 +139,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
|
|||
result.add(domoType);
|
||||
}
|
||||
if (domoType == null && !getClassHierarchy().getScope().getExclusions().contains(name.toString().substring(1))){
|
||||
assert false : "Failed to find all non-excluded interfaces.";
|
||||
assert false : "Failed to find non-excluded interface: " + name;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,75 +1,75 @@
|
|||
package com.ibm.wala.cast.java.ssa;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SSAInstructionFactory;
|
||||
import com.ibm.wala.ssa.SymbolTable;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
|
||||
/**
|
||||
* The CAst source language front end for Java has explicit support for lexically-enclosing objects, rather than compiling them
|
||||
* away into extra fields and access-control thwarting accessor methods as is done in bytecode. This instruction represents a read
|
||||
* of the object of the given type that lexically encloses its use value.
|
||||
*
|
||||
* @author Julian Dolby (dolby@us.ibm.com)
|
||||
*/
|
||||
public class EnclosingObjectReference extends SSAInstruction {
|
||||
private final TypeReference type;
|
||||
|
||||
private final int lval;
|
||||
|
||||
public EnclosingObjectReference(int iindex, int lval, TypeReference type) {
|
||||
super(iindex);
|
||||
this.lval = lval;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public boolean hasDef() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getDef() {
|
||||
return lval;
|
||||
}
|
||||
|
||||
public int getDef(int i) {
|
||||
assert i == 0;
|
||||
|
||||
return lval;
|
||||
}
|
||||
|
||||
public int getNumberOfDefs() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public TypeReference getEnclosingType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
return ((AstJavaInstructionFactory) insts).EnclosingObjectReference(iindex, defs == null ? lval : defs[0], type);
|
||||
}
|
||||
|
||||
public String toString(SymbolTable symbolTable) {
|
||||
return getValueString(symbolTable, lval) + " = enclosing " + type.getName();
|
||||
}
|
||||
|
||||
public void visit(IVisitor v) {
|
||||
((AstJavaInstructionVisitor) v).visitEnclosingObjectReference(this);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return lval * type.hashCode();
|
||||
}
|
||||
|
||||
public Collection<TypeReference> getExceptionTypes() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
public boolean isFallThrough() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
package com.ibm.wala.cast.java.ssa;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SSAInstructionFactory;
|
||||
import com.ibm.wala.ssa.SymbolTable;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
|
||||
/**
|
||||
* The CAst source language front end for Java has explicit support for lexically-enclosing objects, rather than compiling them
|
||||
* away into extra fields and access-control thwarting accessor methods as is done in bytecode. This instruction represents a read
|
||||
* of the object of the given type that lexically encloses its use value.
|
||||
*
|
||||
* @author Julian Dolby (dolby@us.ibm.com)
|
||||
*/
|
||||
public class EnclosingObjectReference extends SSAInstruction {
|
||||
private final TypeReference type;
|
||||
|
||||
private final int lval;
|
||||
|
||||
public EnclosingObjectReference(int iindex, int lval, TypeReference type) {
|
||||
super(iindex);
|
||||
this.lval = lval;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public boolean hasDef() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getDef() {
|
||||
return lval;
|
||||
}
|
||||
|
||||
public int getDef(int i) {
|
||||
assert i == 0;
|
||||
|
||||
return lval;
|
||||
}
|
||||
|
||||
public int getNumberOfDefs() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public TypeReference getEnclosingType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
return ((AstJavaInstructionFactory) insts).EnclosingObjectReference(iindex, defs == null ? lval : defs[0], type);
|
||||
}
|
||||
|
||||
public String toString(SymbolTable symbolTable) {
|
||||
return getValueString(symbolTable, lval) + " = enclosing " + type.getName();
|
||||
}
|
||||
|
||||
public void visit(IVisitor v) {
|
||||
((AstJavaInstructionVisitor) v).visitEnclosingObjectReference(this);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return lval * type.hashCode();
|
||||
}
|
||||
|
||||
public Collection<TypeReference> getExceptionTypes() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
public boolean isFallThrough() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,13 +15,12 @@ package com.ibm.wala.cast.java.translator;
|
|||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import com.ibm.wala.cast.ir.translator.TranslatorToCAst;
|
||||
import com.ibm.wala.cast.java.loader.JavaSourceLoaderImpl;
|
||||
import com.ibm.wala.cast.tree.CAst;
|
||||
import com.ibm.wala.cast.tree.CAstEntity;
|
||||
import com.ibm.wala.cast.tree.impl.CAstImpl;
|
||||
import com.ibm.wala.cast.tree.impl.CAstRewriter;
|
||||
import com.ibm.wala.cast.tree.impl.CAstRewriterFactory;
|
||||
import com.ibm.wala.cast.tree.rewrite.CAstRewriter;
|
||||
import com.ibm.wala.cast.tree.rewrite.CAstRewriterFactory;
|
||||
import com.ibm.wala.cast.util.CAstPrinter;
|
||||
import com.ibm.wala.classLoader.ModuleEntry;
|
||||
|
||||
|
|
|
@ -1,67 +1,67 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="com.ibm.wala.cast.java.polyglot" default="getJars" basedir=".">
|
||||
|
||||
<property name="basews" value="${ws}"/>
|
||||
<property name="baseos" value="${os}"/>
|
||||
<property name="basearch" value="${arch}"/>
|
||||
<property name="basenl" value="${nl}"/>
|
||||
|
||||
<!-- Compiler settings. -->
|
||||
<property name="javacFailOnError" value="true"/>
|
||||
<property name="javacDebugInfo" value="on"/>
|
||||
<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"/>
|
||||
<!-- 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" -->
|
||||
<condition property="dir_bootclasspath" value="${java.home}/../Classes">
|
||||
<os family="mac"/>
|
||||
</condition>
|
||||
<property name="dir_bootclasspath" value="${java.home}/lib"/>
|
||||
<path id="path_bootclasspath">
|
||||
<fileset dir="${dir_bootclasspath}">
|
||||
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
<property name="bootclasspath" refid="path_bootclasspath"/>
|
||||
<property name="bundleJavacSource" value="${javacSource}"/>
|
||||
<property name="bundleJavacTarget" value="${javacTarget}"/>
|
||||
<property name="bundleBootClasspath" value="${bootclasspath}"/>
|
||||
|
||||
<target name="NuPresent" depends="init">
|
||||
<available file="${plugin.destination}/lib/htmlparser-1.3.1.jar" property="nu.present"/>
|
||||
</target>
|
||||
|
||||
<target name="fetchNu" depends="NuPresent" unless="nu.present">
|
||||
<delete dir="${temp.folder}"/>
|
||||
<mkdir dir="${temp.folder}"/>
|
||||
<get src="http://about.validator.nu/htmlparser/htmlparser-1.3.1.zip" dest="${temp.folder}/htmlparser-1.3.1.zip"/>
|
||||
<unzip src="${temp.folder}/htmlparser-1.3.1.zip" dest="${temp.folder}"/>
|
||||
<copy file="${temp.folder}/htmlparser-1.3.1/htmlparser-1.3.1.jar" tofile="${plugin.destination}/lib/htmlparser-1.3.1.jar" />
|
||||
<delete dir="${temp.folder}"/>
|
||||
</target>
|
||||
|
||||
<target name="getJars" depends="fetchNu" />
|
||||
|
||||
<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="properties" if="eclipse.running">
|
||||
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="com.ibm.wala.cast.java.polyglot" default="getJars" basedir=".">
|
||||
|
||||
<property name="basews" value="${ws}"/>
|
||||
<property name="baseos" value="${os}"/>
|
||||
<property name="basearch" value="${arch}"/>
|
||||
<property name="basenl" value="${nl}"/>
|
||||
|
||||
<!-- Compiler settings. -->
|
||||
<property name="javacFailOnError" value="true"/>
|
||||
<property name="javacDebugInfo" value="on"/>
|
||||
<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"/>
|
||||
<!-- 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" -->
|
||||
<condition property="dir_bootclasspath" value="${java.home}/../Classes">
|
||||
<os family="mac"/>
|
||||
</condition>
|
||||
<property name="dir_bootclasspath" value="${java.home}/lib"/>
|
||||
<path id="path_bootclasspath">
|
||||
<fileset dir="${dir_bootclasspath}">
|
||||
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
<property name="bootclasspath" refid="path_bootclasspath"/>
|
||||
<property name="bundleJavacSource" value="${javacSource}"/>
|
||||
<property name="bundleJavacTarget" value="${javacTarget}"/>
|
||||
<property name="bundleBootClasspath" value="${bootclasspath}"/>
|
||||
|
||||
<target name="NuPresent" depends="init">
|
||||
<available file="${plugin.destination}/lib/htmlparser-1.3.1.jar" property="nu.present"/>
|
||||
</target>
|
||||
|
||||
<target name="fetchNu" depends="NuPresent" unless="nu.present">
|
||||
<delete dir="${temp.folder}"/>
|
||||
<mkdir dir="${temp.folder}"/>
|
||||
<get src="http://about.validator.nu/htmlparser/htmlparser-1.3.1.zip" dest="${temp.folder}/htmlparser-1.3.1.zip"/>
|
||||
<unzip src="${temp.folder}/htmlparser-1.3.1.zip" dest="${temp.folder}"/>
|
||||
<copy file="${temp.folder}/htmlparser-1.3.1/htmlparser-1.3.1.jar" tofile="${plugin.destination}/lib/htmlparser-1.3.1.jar" />
|
||||
<delete dir="${temp.folder}"/>
|
||||
</target>
|
||||
|
||||
<target name="getJars" depends="fetchNu" />
|
||||
|
||||
<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="properties" if="eclipse.running">
|
||||
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -3,5 +3,6 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="harness-src"/>
|
||||
<classpathentry kind="lib" path="/com.ibm.wala.cast.js.test.data/examples-src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -3,18 +3,16 @@ Bundle-ManifestVersion: 2
|
|||
Bundle-Name: Test Plug-in
|
||||
Bundle-SymbolicName: com.ibm.wala.cast.js.rhino.test
|
||||
Bundle-Version: 1.0.0
|
||||
Bundle-Activator: com.ibm.wala.cast.js.rhino.test.Activator
|
||||
Bundle-Vendor: IBM
|
||||
Require-Bundle: org.eclipse.core.runtime,
|
||||
com.ibm.wala.cast.js.rhino;bundle-version="1.0.0",
|
||||
Require-Bundle: com.ibm.wala.cast.js.rhino;bundle-version="1.0.0",
|
||||
com.ibm.wala.cast.js;bundle-version="1.0.0",
|
||||
com.ibm.wala.cast;bundle-version="1.0.0",
|
||||
com.ibm.wala.core;bundle-version="1.1.3",
|
||||
com.ibm.wala.cast.js.test;bundle-version="1.0.0",
|
||||
com.ibm.wala.cast.test;bundle-version="1.0.0",
|
||||
com.ibm.wala.core.tests;bundle-version="1.1.3",
|
||||
org.junit4;bundle-version="4.3.1",
|
||||
com.ibm.wala.ide;bundle-version="1.1.3"
|
||||
org.junit4;bundle-version="4.3.1"
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.ibm.wala.cast.js.test
|
||||
Export-Package: com.ibm.wala.cast.js.rhino.test,
|
||||
com.ibm.wala.cast.js.test
|
||||
|
|
|
@ -19,8 +19,6 @@ import java.util.Properties;
|
|||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
import com.ibm.wala.cast.ir.translator.AstTranslator;
|
||||
import com.ibm.wala.cast.js.ipa.callgraph.ForInContextSelector;
|
||||
import com.ibm.wala.cast.js.ipa.callgraph.JSCFABuilder;
|
||||
|
@ -30,16 +28,16 @@ import com.ibm.wala.cast.js.ipa.callgraph.correlations.extraction.CorrelatedPair
|
|||
import com.ibm.wala.cast.js.test.JSCallGraphBuilderUtil;
|
||||
import com.ibm.wala.cast.js.test.JSCallGraphBuilderUtil.CGBuilderType;
|
||||
import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory;
|
||||
import com.ibm.wala.ide.util.ProgressMaster;
|
||||
import com.ibm.wala.ide.util.ProgressMonitorDelegate;
|
||||
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.PointerAnalysis;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchyException;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.NullProgressMonitor;
|
||||
import com.ibm.wala.util.ProgressMaster;
|
||||
import com.ibm.wala.util.io.CommandLine;
|
||||
import com.ibm.wala.util.io.FileProvider;
|
||||
import com.ibm.wala.util.io.FileUtil;
|
||||
|
||||
/**
|
||||
* Utility class for building call graphs of HTML pages.
|
||||
|
@ -113,7 +111,7 @@ public class HTMLCGBuilder {
|
|||
}
|
||||
long start = System.currentTimeMillis();
|
||||
CallGraph cg = timeout > 0 ? builder.makeCallGraph(builder.getOptions(),
|
||||
ProgressMonitorDelegate.createProgressMonitorDelegate(master)) : builder.makeCallGraph(builder.getOptions());
|
||||
master) : builder.makeCallGraph(builder.getOptions());
|
||||
long end = System.currentTimeMillis();
|
||||
master.done();
|
||||
res.construction_time = (end - start);
|
||||
|
@ -155,34 +153,51 @@ public class HTMLCGBuilder {
|
|||
*/
|
||||
public static void main(String[] args) throws ClassHierarchyException, IOException {
|
||||
Properties parsedArgs = CommandLine.parse(args);
|
||||
|
||||
String src = parsedArgs.getProperty("src");
|
||||
if (src == null) {
|
||||
throw new IllegalArgumentException("-src argument is required");
|
||||
}
|
||||
|
||||
// if src is a JS file, build trivial wrapper HTML file
|
||||
if (src.endsWith(".js")) {
|
||||
File tmpFile = File.createTempFile("HTMLCGBuilder", ".html");
|
||||
tmpFile.deleteOnExit();
|
||||
FileUtil.writeFile(tmpFile,
|
||||
"<html>" +
|
||||
" <head>" +
|
||||
" <title></title>" +
|
||||
" <script src=\"" + src + "\" type='text/javascript'></script>" +
|
||||
" </head>" +
|
||||
"<body>" +
|
||||
"</body>" +
|
||||
"</html>");
|
||||
src = tmpFile.getAbsolutePath();
|
||||
}
|
||||
|
||||
int timeout;
|
||||
if (parsedArgs.containsKey("timeout")) {
|
||||
timeout = Integer.parseInt(parsedArgs.getProperty("timeout"));
|
||||
} else {
|
||||
timeout = DEFAULT_TIMEOUT;
|
||||
}
|
||||
|
||||
String reachableName = null;
|
||||
if (parsedArgs.containsKey("reachable")) {
|
||||
reachableName = parsedArgs.getProperty("reachable");
|
||||
}
|
||||
|
||||
String srcNode = null, dstNode = null;
|
||||
if (parsedArgs.containsKey("edgeExists")) {
|
||||
String[] nodes = parsedArgs.getProperty("edgeExists").split(":");
|
||||
srcNode = nodes[0];
|
||||
dstNode = nodes[1];
|
||||
}
|
||||
// suppress debug output
|
||||
JavaScriptFunctionDotCallTargetSelector.WARN_ABOUT_IMPRECISE_CALLGRAPH = false;
|
||||
|
||||
// build call graph
|
||||
CGBuilderResult res = buildHTMLCG(src, timeout, true, AstTranslator.NEW_LEXICAL ? CGBuilderType.ONE_CFA_PRECISE_LEXICAL : CGBuilderType.ZERO_ONE_CFA);
|
||||
|
||||
if(res.construction_time == -1)
|
||||
System.out.println("TIMED OUT");
|
||||
else
|
||||
System.out.println("Call graph construction took " + res.construction_time/1000.0 + " seconds");
|
||||
|
||||
if (reachableName != null) {
|
||||
for (CGNode node : res.cg) {
|
||||
if (node.getMethod().getDeclaringClass().getName().toString().contains(reachableName)) {
|
||||
|
@ -191,16 +206,5 @@ public class HTMLCGBuilder {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (srcNode != null) {
|
||||
for (CGNode node : res.cg) {
|
||||
if (node.getMethod().getDeclaringClass().getName().toString().endsWith(srcNode)) {
|
||||
for (CGNode callee : Iterator2Iterable.make(res.cg.getSuccNodes(node))) {
|
||||
if (callee.getMethod().getDeclaringClass().getName().toString().endsWith(dstNode)) {
|
||||
System.out.println("EDGE EXISTS");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ package com.ibm.wala.cast.js.test;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
import com.ibm.wala.cast.js.translator.RhinoToAstTranslator;
|
||||
import com.ibm.wala.cast.tree.CAstEntity;
|
||||
import com.ibm.wala.cast.tree.impl.CAstImpl;
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
package com.ibm.wala.cast.js.test;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory;
|
||||
|
||||
public class TestMozillaBugPagesRhino extends TestMozillaBugPages {
|
||||
|
||||
public static void main(String[] args) {
|
||||
justThisTest(TestMozillaBugPagesRhino.class);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory());
|
||||
}
|
||||
|
||||
}
|
|
@ -65,4 +65,9 @@ public class TestSimpleCallGraphShapeRhino extends TestSimpleCallGraphShape {
|
|||
public void testTranslateToCAstCrash3() throws IllegalArgumentException, IOException, CancelException {
|
||||
JSCallGraphBuilderUtil.makeScriptCG("tests", "rhino_crash3.js");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonLoopBreakLabel() throws IllegalArgumentException, IOException, CancelException {
|
||||
JSCallGraphBuilderUtil.makeScriptCG("tests", "non_loop_break.js");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.junit.Test;
|
|||
|
||||
import com.ibm.wala.cast.js.html.IHtmlParser;
|
||||
import com.ibm.wala.cast.js.html.IHtmlParserFactory;
|
||||
import com.ibm.wala.cast.js.html.JSSourceExtractor;
|
||||
import com.ibm.wala.cast.js.html.WebUtil;
|
||||
import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraph;
|
||||
|
@ -50,5 +51,7 @@ public abstract class TestSimplePageCallGraphShapeRhino extends TestSimplePageCa
|
|||
return TestSimplePageCallGraphShapeRhino.this.getParser();
|
||||
}
|
||||
});
|
||||
JSSourceExtractor.USE_TEMP_NAME = false;
|
||||
JSSourceExtractor.DELETE_UPON_EXIT = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,71 +1,71 @@
|
|||
package com.ibm.wala.cast.js.vis;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ibm.wala.cast.ir.ssa.AstIRFactory;
|
||||
import com.ibm.wala.cast.js.html.DefaultSourceExtractor;
|
||||
import com.ibm.wala.cast.js.html.DomLessSourceExtractor;
|
||||
import com.ibm.wala.cast.js.html.IdentityUrlResolver;
|
||||
import com.ibm.wala.cast.js.html.JSSourceExtractor;
|
||||
import com.ibm.wala.cast.js.html.MappedSourceModule;
|
||||
import com.ibm.wala.cast.js.html.WebPageLoaderFactory;
|
||||
import com.ibm.wala.cast.js.html.WebUtil;
|
||||
import com.ibm.wala.cast.js.html.jericho.JerichoHtmlParser;
|
||||
import com.ibm.wala.cast.js.ipa.callgraph.JSCFABuilder;
|
||||
import com.ibm.wala.cast.js.loader.JavaScriptLoader;
|
||||
import com.ibm.wala.cast.js.test.JSCallGraphBuilderUtil;
|
||||
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.PointerAnalysis;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchyException;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
|
||||
public class JsViewerDriver extends JSCallGraphBuilderUtil {
|
||||
public static void main(String args[]) throws ClassHierarchyException, IllegalArgumentException, IOException, CancelException {
|
||||
|
||||
if (args.length != 1){
|
||||
System.out.println("Usage: <URL of html page to analyze>");
|
||||
System.exit(1);
|
||||
}
|
||||
boolean domless = false;
|
||||
|
||||
URL url = new URL(args[0]);
|
||||
|
||||
// computing CG + PA
|
||||
JSCallGraphBuilderUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory());
|
||||
JavaScriptLoader.addBootstrapFile(WebUtil.preamble);
|
||||
|
||||
SourceModule[] sources = getSources(domless, url);
|
||||
|
||||
JSCFABuilder builder = makeCGBuilder(new WebPageLoaderFactory(translatorFactory), sources, CGBuilderType.ZERO_ONE_CFA, AstIRFactory.makeDefaultFactory());
|
||||
builder.setBaseURL(url);
|
||||
|
||||
CallGraph cg = builder.makeCallGraph(builder.getOptions());
|
||||
PointerAnalysis pa = builder.getPointerAnalysis();
|
||||
|
||||
new JsViewer(cg, pa);
|
||||
}
|
||||
|
||||
private static SourceModule[] getSources(boolean domless, URL url)
|
||||
throws IOException {
|
||||
JSSourceExtractor sourceExtractor;
|
||||
if (domless ){
|
||||
sourceExtractor = new DomLessSourceExtractor();
|
||||
} else {
|
||||
sourceExtractor = new DefaultSourceExtractor();
|
||||
}
|
||||
|
||||
Set<MappedSourceModule> sourcesMap = sourceExtractor.extractSources(url, new JerichoHtmlParser(), new IdentityUrlResolver());
|
||||
SourceModule[] sources = new SourceFileModule[sourcesMap.size()];
|
||||
int i = 0;
|
||||
for (SourceModule m : sourcesMap){
|
||||
sources[i++] = m;
|
||||
}
|
||||
return sources;
|
||||
}
|
||||
|
||||
}
|
||||
package com.ibm.wala.cast.js.vis;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ibm.wala.cast.ir.ssa.AstIRFactory;
|
||||
import com.ibm.wala.cast.js.html.DefaultSourceExtractor;
|
||||
import com.ibm.wala.cast.js.html.DomLessSourceExtractor;
|
||||
import com.ibm.wala.cast.js.html.IdentityUrlResolver;
|
||||
import com.ibm.wala.cast.js.html.JSSourceExtractor;
|
||||
import com.ibm.wala.cast.js.html.MappedSourceModule;
|
||||
import com.ibm.wala.cast.js.html.WebPageLoaderFactory;
|
||||
import com.ibm.wala.cast.js.html.WebUtil;
|
||||
import com.ibm.wala.cast.js.html.jericho.JerichoHtmlParser;
|
||||
import com.ibm.wala.cast.js.ipa.callgraph.JSCFABuilder;
|
||||
import com.ibm.wala.cast.js.loader.JavaScriptLoader;
|
||||
import com.ibm.wala.cast.js.test.JSCallGraphBuilderUtil;
|
||||
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.PointerAnalysis;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchyException;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
|
||||
public class JsViewerDriver extends JSCallGraphBuilderUtil {
|
||||
public static void main(String args[]) throws ClassHierarchyException, IllegalArgumentException, IOException, CancelException {
|
||||
|
||||
if (args.length != 1){
|
||||
System.out.println("Usage: <URL of html page to analyze>");
|
||||
System.exit(1);
|
||||
}
|
||||
boolean domless = false;
|
||||
|
||||
URL url = new URL(args[0]);
|
||||
|
||||
// computing CG + PA
|
||||
JSCallGraphBuilderUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory());
|
||||
JavaScriptLoader.addBootstrapFile(WebUtil.preamble);
|
||||
|
||||
SourceModule[] sources = getSources(domless, url);
|
||||
|
||||
JSCFABuilder builder = makeCGBuilder(new WebPageLoaderFactory(translatorFactory), sources, CGBuilderType.ZERO_ONE_CFA, AstIRFactory.makeDefaultFactory());
|
||||
builder.setBaseURL(url);
|
||||
|
||||
CallGraph cg = builder.makeCallGraph(builder.getOptions());
|
||||
PointerAnalysis pa = builder.getPointerAnalysis();
|
||||
|
||||
new JsViewer(cg, pa);
|
||||
}
|
||||
|
||||
private static SourceModule[] getSources(boolean domless, URL url)
|
||||
throws IOException {
|
||||
JSSourceExtractor sourceExtractor;
|
||||
if (domless ){
|
||||
sourceExtractor = new DomLessSourceExtractor();
|
||||
} else {
|
||||
sourceExtractor = new DefaultSourceExtractor();
|
||||
}
|
||||
|
||||
Set<MappedSourceModule> sourcesMap = sourceExtractor.extractSources(url, new JerichoHtmlParser(), new IdentityUrlResolver());
|
||||
SourceModule[] sources = new SourceFileModule[sourcesMap.size()];
|
||||
int i = 0;
|
||||
for (SourceModule m : sourcesMap){
|
||||
sources[i++] = m;
|
||||
}
|
||||
return sources;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,15 +7,18 @@
|
|||
<listEntry value="4"/>
|
||||
</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.debug.ui.ATTR_CAPTURE_IN_FILE" value="/tmp/console.txt"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=com.ibm.wala.cast.js.rhino.test"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
|
||||
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5" javaProject="com.ibm.wala.cast.js.rhino.test" path="1" type="4"/> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="com.ibm.wala.cast.js.rhino.test"/> </runtimeClasspathEntry> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/com.ibm.wala.cast.js.test/examples-src" path="3" type="2"/> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="com.ibm.wala.cast.js.rhino.test" path="1" type="4"/> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="com.ibm.wala.cast.js.rhino.test"/> </runtimeClasspathEntry> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/com.ibm.wala.cast.js.test.data/examples-src" path="3" type="2"/> "/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="source"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/js.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/J2SE-1.5"/>
|
||||
<classpathentry kind="lib" path="lib/js.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -12,4 +12,28 @@ Require-Bundle: org.eclipse.core.runtime,
|
|||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.ibm.wala.cast.js.translator,
|
||||
org.mozilla.javascript
|
||||
com.ibm.wala.js.rhino,
|
||||
org.mozilla.classfile,
|
||||
org.mozilla.javascript,
|
||||
org.mozilla.javascript.annotations,
|
||||
org.mozilla.javascript.ast,
|
||||
org.mozilla.javascript.commonjs.module,
|
||||
org.mozilla.javascript.commonjs.module.provider,
|
||||
org.mozilla.javascript.debug,
|
||||
org.mozilla.javascript.jdk13,
|
||||
org.mozilla.javascript.jdk15,
|
||||
org.mozilla.javascript.json,
|
||||
org.mozilla.javascript.optimizer,
|
||||
org.mozilla.javascript.regexp,
|
||||
org.mozilla.javascript.serialize,
|
||||
org.mozilla.javascript.tools,
|
||||
org.mozilla.javascript.tools.debugger,
|
||||
org.mozilla.javascript.tools.debugger.treetable,
|
||||
org.mozilla.javascript.tools.idswitch,
|
||||
org.mozilla.javascript.tools.jsc,
|
||||
org.mozilla.javascript.tools.shell,
|
||||
org.mozilla.javascript.xml,
|
||||
org.mozilla.javascript.xml.impl.xmlbeans,
|
||||
org.mozilla.javascript.xmlimpl
|
||||
Bundle-ClassPath: lib/js.jar,
|
||||
.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
source.. = source/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
||||
.,\
|
||||
lib/js.jar
|
||||
|
|
|
@ -1,69 +1,69 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="com.ibm.wala.cast.java.polyglot" default="getJars" basedir=".">
|
||||
|
||||
<property name="basews" value="${ws}"/>
|
||||
<property name="baseos" value="${os}"/>
|
||||
<property name="basearch" value="${arch}"/>
|
||||
<property name="basenl" value="${nl}"/>
|
||||
|
||||
<!-- Compiler settings. -->
|
||||
<property name="javacFailOnError" value="true"/>
|
||||
<property name="javacDebugInfo" value="on"/>
|
||||
<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"/>
|
||||
<!-- 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" -->
|
||||
<condition property="dir_bootclasspath" value="${java.home}/../Classes">
|
||||
<os family="mac"/>
|
||||
</condition>
|
||||
<property name="dir_bootclasspath" value="${java.home}/lib"/>
|
||||
<path id="path_bootclasspath">
|
||||
<fileset dir="${dir_bootclasspath}">
|
||||
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
<property name="bootclasspath" refid="path_bootclasspath"/>
|
||||
<property name="bundleJavacSource" value="${javacSource}"/>
|
||||
<property name="bundleJavacTarget" value="${javacTarget}"/>
|
||||
<property name="bundleBootClasspath" value="${bootclasspath}"/>
|
||||
|
||||
<target name="RhinoPresent" depends="init">
|
||||
<available file="${plugin.destination}/lib/js.jar" property="rhino.present"/>
|
||||
</target>
|
||||
|
||||
<target name="fetchRhino" depends="RhinoPresent" unless="rhino.present">
|
||||
<delete dir="${temp.folder}"/>
|
||||
<mkdir dir="${temp.folder}"/>
|
||||
<get src="http://ftp.mozilla.org/pub/mozilla.org/js/rhino1_7R3.zip" dest="${temp.folder}/rhino1_7R3.zip" />
|
||||
<unzip src="${temp.folder}/rhino1_7R3.zip" dest="${temp.folder}"/>
|
||||
<copy file="${temp.folder}/rhino1_7R3/js.jar" tofile="${plugin.destination}/lib/js.jar" />
|
||||
<delete dir="${temp.folder}"/>
|
||||
</target>
|
||||
|
||||
<target name="getJars" depends="fetchRhino" />
|
||||
|
||||
|
||||
<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="properties" if="eclipse.running">
|
||||
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
|
||||
|
||||
</target>
|
||||
|
||||
</project>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="com.ibm.wala.cast.java.polyglot" default="getJars" basedir=".">
|
||||
|
||||
<property name="basews" value="${ws}"/>
|
||||
<property name="baseos" value="${os}"/>
|
||||
<property name="basearch" value="${arch}"/>
|
||||
<property name="basenl" value="${nl}"/>
|
||||
|
||||
<!-- Compiler settings. -->
|
||||
<property name="javacFailOnError" value="true"/>
|
||||
<property name="javacDebugInfo" value="on"/>
|
||||
<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"/>
|
||||
<!-- 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" -->
|
||||
<condition property="dir_bootclasspath" value="${java.home}/../Classes">
|
||||
<os family="mac"/>
|
||||
</condition>
|
||||
<property name="dir_bootclasspath" value="${java.home}/lib"/>
|
||||
<path id="path_bootclasspath">
|
||||
<fileset dir="${dir_bootclasspath}">
|
||||
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
<property name="bootclasspath" refid="path_bootclasspath"/>
|
||||
<property name="bundleJavacSource" value="${javacSource}"/>
|
||||
<property name="bundleJavacTarget" value="${javacTarget}"/>
|
||||
<property name="bundleBootClasspath" value="${bootclasspath}"/>
|
||||
|
||||
<target name="RhinoPresent" depends="init">
|
||||
<available file="${plugin.destination}/lib/js.jar" property="rhino.present"/>
|
||||
</target>
|
||||
|
||||
<target name="fetchRhino" depends="RhinoPresent" unless="rhino.present">
|
||||
<delete dir="${temp.folder}"/>
|
||||
<mkdir dir="${temp.folder}"/>
|
||||
<get src="http://ftp.mozilla.org/pub/mozilla.org/js/rhino1_7R3.zip" dest="${temp.folder}/rhino1_7R3.zip" />
|
||||
<unzip src="${temp.folder}/rhino1_7R3.zip" dest="${temp.folder}"/>
|
||||
<copy file="${temp.folder}/rhino1_7R3/js.jar" tofile="${plugin.destination}/lib/js.jar" />
|
||||
<delete dir="${temp.folder}"/>
|
||||
</target>
|
||||
|
||||
<target name="getJars" depends="fetchRhino" />
|
||||
|
||||
|
||||
<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="properties" if="eclipse.running">
|
||||
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
|
||||
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.ibm.wala.cast.js.translator;
|
||||
|
||||
import com.ibm.wala.cast.ir.translator.TranslatorToCAst;
|
||||
import com.ibm.wala.cast.js.translator.JavaScriptLoopUnwindingTranslatorFactory;
|
||||
import com.ibm.wala.cast.tree.CAst;
|
||||
import com.ibm.wala.classLoader.SourceModule;
|
||||
|
||||
public class CAstRhinoLoopUnwindingTranslatorFactory
|
||||
extends JavaScriptLoopUnwindingTranslatorFactory
|
||||
{
|
||||
public CAstRhinoLoopUnwindingTranslatorFactory(int unwindFactor) {
|
||||
super(unwindFactor);
|
||||
}
|
||||
|
||||
public CAstRhinoLoopUnwindingTranslatorFactory() {
|
||||
this(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TranslatorToCAst translateInternal(CAst Ast, SourceModule M, String N) {
|
||||
return new CAstRhinoTranslator(M, true);
|
||||
}
|
||||
}
|
||||
|
|
@ -17,9 +17,9 @@ import java.util.List;
|
|||
import com.ibm.wala.cast.ir.translator.TranslatorToCAst;
|
||||
import com.ibm.wala.cast.tree.CAstEntity;
|
||||
import com.ibm.wala.cast.tree.impl.CAstImpl;
|
||||
import com.ibm.wala.cast.tree.impl.CAstRewriter.CopyKey;
|
||||
import com.ibm.wala.cast.tree.impl.CAstRewriter.RewriteContext;
|
||||
import com.ibm.wala.cast.tree.impl.CAstRewriterFactory;
|
||||
import com.ibm.wala.cast.tree.rewrite.CAstRewriterFactory;
|
||||
import com.ibm.wala.cast.tree.rewrite.CAstRewriter.CopyKey;
|
||||
import com.ibm.wala.cast.tree.rewrite.CAstRewriter.RewriteContext;
|
||||
import com.ibm.wala.classLoader.SourceFileModule;
|
||||
import com.ibm.wala.classLoader.SourceModule;
|
||||
|
||||
|
|
|
@ -1046,7 +1046,14 @@ public class RhinoToAstTranslator {
|
|||
|
||||
@Override
|
||||
public CAstNode visitLabeledStatement(LabeledStatement node, WalkContext arg) {
|
||||
CAstNode result = visit(node.getStatement(), arg);
|
||||
ExpressionStatement ex = new ExpressionStatement();
|
||||
ex.setExpression(new EmptyExpression());
|
||||
CAstNode exNode = visit(ex, arg);
|
||||
arg.cfg().map(ex, exNode);
|
||||
|
||||
WalkContext labelBodyContext = makeBreakContext(node, arg, ex);
|
||||
|
||||
CAstNode result = visit(node.getStatement(), labelBodyContext);
|
||||
|
||||
AstNode prev = node;
|
||||
for(Label label : node.getLabels()) {
|
||||
|
@ -1055,7 +1062,7 @@ public class RhinoToAstTranslator {
|
|||
prev = label;
|
||||
}
|
||||
|
||||
return result;
|
||||
return Ast.makeNode(CAstNode.BLOCK_STMT, result, exNode);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.ibm.wala.cast.js.test.data</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.jsdt.core.javascriptValidator</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.wst.jsdt.core.jsNature</nature>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="examples-src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.FireFoxBrowserLibrary"/>
|
||||
<classpathentry kind="output" path=""/>
|
||||
</classpath>
|
|
@ -0,0 +1 @@
|
|||
org.eclipse.wst.jsdt.launching.JRE_CONTAINER
|
|
@ -0,0 +1 @@
|
|||
Global
|
|
@ -0,0 +1,10 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Eclipse-LazyStart: true
|
||||
Bundle-Name: %pluginName
|
||||
Bundle-SymbolicName: com.ibm.wala.cast.js.test.data;singleton:=true
|
||||
Bundle-Version: 1.1.3.qualifier
|
||||
Bundle-Vendor: %providerName
|
||||
Bundle-Localization: plugin
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-ClassPath: examples-src/
|
|
@ -1,71 +1,71 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="com.ibm.wala.cast.java.polyglot" default="getJars" basedir=".">
|
||||
|
||||
<property name="basews" value="${ws}"/>
|
||||
<property name="baseos" value="${os}"/>
|
||||
<property name="basearch" value="${arch}"/>
|
||||
<property name="basenl" value="${nl}"/>
|
||||
|
||||
<!-- Compiler settings. -->
|
||||
<property name="javacFailOnError" value="true"/>
|
||||
<property name="javacDebugInfo" value="on"/>
|
||||
<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"/>
|
||||
<!-- 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" -->
|
||||
<condition property="dir_bootclasspath" value="${java.home}/../Classes">
|
||||
<os family="mac"/>
|
||||
</condition>
|
||||
<property name="dir_bootclasspath" value="${java.home}/lib"/>
|
||||
<path id="path_bootclasspath">
|
||||
<fileset dir="${dir_bootclasspath}">
|
||||
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
<property name="bootclasspath" refid="path_bootclasspath"/>
|
||||
<property name="bundleJavacSource" value="${javacSource}"/>
|
||||
<property name="bundleJavacTarget" value="${javacTarget}"/>
|
||||
<property name="bundleBootClasspath" value="${bootclasspath}"/>
|
||||
|
||||
<target name="ajaxsltPresent" depends="init">
|
||||
<available file="${plugin.destination}/examples-src/ajaxslt" property="ajaxslt.present"/>
|
||||
</target>
|
||||
|
||||
<target name="fetchAjaxslt" depends="ajaxsltPresent" unless="ajaxslt.present">
|
||||
<delete dir="${temp.folder}"/>
|
||||
<mkdir dir="${temp.folder}"/>
|
||||
<get src="http://ajaxslt.googlecode.com/files/ajaxslt-0-7.tar.gz" dest="${temp.folder}/ajaxslt-0-7.tar.gz" />
|
||||
<untar src="${temp.folder}/ajaxslt-0-7.tar.gz" dest="${temp.folder}" compression="gzip" />
|
||||
<copy todir="${plugin.destination}/examples-src/ajaxslt">
|
||||
<fileset dir="${temp.folder}/ajaxslt" />
|
||||
</copy>
|
||||
<delete dir="${temp.folder}"/>
|
||||
</target>
|
||||
|
||||
<target name="getJars" depends="fetchAjaxslt" />
|
||||
|
||||
|
||||
<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="properties" if="eclipse.running">
|
||||
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
|
||||
|
||||
</target>
|
||||
|
||||
</project>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="com.ibm.wala.cast.java.polyglot" default="getJars" basedir=".">
|
||||
|
||||
<property name="basews" value="${ws}"/>
|
||||
<property name="baseos" value="${os}"/>
|
||||
<property name="basearch" value="${arch}"/>
|
||||
<property name="basenl" value="${nl}"/>
|
||||
|
||||
<!-- Compiler settings. -->
|
||||
<property name="javacFailOnError" value="true"/>
|
||||
<property name="javacDebugInfo" value="on"/>
|
||||
<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"/>
|
||||
<!-- 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" -->
|
||||
<condition property="dir_bootclasspath" value="${java.home}/../Classes">
|
||||
<os family="mac"/>
|
||||
</condition>
|
||||
<property name="dir_bootclasspath" value="${java.home}/lib"/>
|
||||
<path id="path_bootclasspath">
|
||||
<fileset dir="${dir_bootclasspath}">
|
||||
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
<property name="bootclasspath" refid="path_bootclasspath"/>
|
||||
<property name="bundleJavacSource" value="${javacSource}"/>
|
||||
<property name="bundleJavacTarget" value="${javacTarget}"/>
|
||||
<property name="bundleBootClasspath" value="${bootclasspath}"/>
|
||||
|
||||
<target name="ajaxsltPresent" depends="init">
|
||||
<available file="${plugin.destination}/examples-src/ajaxslt" property="ajaxslt.present"/>
|
||||
</target>
|
||||
|
||||
<target name="fetchAjaxslt" depends="ajaxsltPresent" unless="ajaxslt.present">
|
||||
<delete dir="${temp.folder}"/>
|
||||
<mkdir dir="${temp.folder}"/>
|
||||
<get src="http://ajaxslt.googlecode.com/files/ajaxslt-0-7.tar.gz" dest="${temp.folder}/ajaxslt-0-7.tar.gz" />
|
||||
<untar src="${temp.folder}/ajaxslt-0-7.tar.gz" dest="${temp.folder}" compression="gzip" />
|
||||
<copy todir="${plugin.destination}/examples-src/ajaxslt">
|
||||
<fileset dir="${temp.folder}/ajaxslt" />
|
||||
</copy>
|
||||
<delete dir="${temp.folder}"/>
|
||||
</target>
|
||||
|
||||
<target name="getJars" depends="fetchAjaxslt" />
|
||||
|
||||
|
||||
<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="properties" if="eclipse.running">
|
||||
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
|
||||
|
||||
</target>
|
||||
|
||||
</project>
|
|
@ -1,63 +1,63 @@
|
|||
|
||||
|
||||
(function _top_level () {
|
||||
|
||||
|
||||
var jQuery = window.jQuery = window.$ = function (selector, context) {
|
||||
return new jQuery.fn.init(selector, context);
|
||||
};
|
||||
|
||||
|
||||
var undefined;
|
||||
|
||||
jQuery.extend = jQuery.fn.extend = function _extend () {
|
||||
var target = arguments[0] || {},
|
||||
i = 1,
|
||||
length = arguments.length,
|
||||
deep = false,
|
||||
options;
|
||||
if (target.constructor == Boolean) {
|
||||
deep = target;
|
||||
target = arguments[1] || {};
|
||||
i = 2;
|
||||
}
|
||||
if (typeof target != "object" && typeof target != "function") target = {};
|
||||
if (length == i) {
|
||||
target = this;
|
||||
--i;
|
||||
}
|
||||
for (; i < length; i++) if ((options = arguments[i]) != null)
|
||||
for (var name in options) {
|
||||
(function _forin_body (name) {
|
||||
var src = target[name],
|
||||
copy = options[name];
|
||||
if (target === copy) return;
|
||||
if (deep && copy && typeof copy == "object" && !copy.nodeType) {
|
||||
target[name] = jQuery.extend(deep, src || (copy.length != null ? [] : {}), copy);
|
||||
}
|
||||
else if (copy !== undefined) target[name] = copy;
|
||||
else target[name] = copy;
|
||||
})(name);
|
||||
}
|
||||
return target;
|
||||
};
|
||||
|
||||
jQuery.extend({
|
||||
speed: function _speed (speed, easing, fn) {
|
||||
var opt = speed && speed.constructor == Object ? speed : {
|
||||
complete: fn || !fn && easing || jQuery.isFunction(speed) && speed,
|
||||
duration: speed,
|
||||
easing: fn && easing || easing && easing.constructor != Function && easing
|
||||
};
|
||||
opt.duration = (opt.duration && opt.duration.constructor == Number ? opt.duration : jQuery.fx.speeds[opt.duration]) || jQuery.fx.speeds.def;
|
||||
opt.old = opt.complete;
|
||||
opt.complete = function _complete () {
|
||||
if (opt.queue !== false) jQuery(this).dequeue();
|
||||
if (jQuery.isFunction(opt.old)) opt.old.call(this);
|
||||
};
|
||||
return opt;
|
||||
},
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
|
||||
|
||||
(function _top_level () {
|
||||
|
||||
|
||||
var jQuery = window.jQuery = window.$ = function (selector, context) {
|
||||
return new jQuery.fn.init(selector, context);
|
||||
};
|
||||
|
||||
|
||||
var undefined;
|
||||
|
||||
jQuery.extend = jQuery.fn.extend = function _extend () {
|
||||
var target = arguments[0] || {},
|
||||
i = 1,
|
||||
length = arguments.length,
|
||||
deep = false,
|
||||
options;
|
||||
if (target.constructor == Boolean) {
|
||||
deep = target;
|
||||
target = arguments[1] || {};
|
||||
i = 2;
|
||||
}
|
||||
if (typeof target != "object" && typeof target != "function") target = {};
|
||||
if (length == i) {
|
||||
target = this;
|
||||
--i;
|
||||
}
|
||||
for (; i < length; i++) if ((options = arguments[i]) != null)
|
||||
for (var name in options) {
|
||||
(function _forin_body (name) {
|
||||
var src = target[name],
|
||||
copy = options[name];
|
||||
if (target === copy) return;
|
||||
if (deep && copy && typeof copy == "object" && !copy.nodeType) {
|
||||
target[name] = jQuery.extend(deep, src || (copy.length != null ? [] : {}), copy);
|
||||
}
|
||||
else if (copy !== undefined) target[name] = copy;
|
||||
else target[name] = copy;
|
||||
})(name);
|
||||
}
|
||||
return target;
|
||||
};
|
||||
|
||||
jQuery.extend({
|
||||
speed: function _speed (speed, easing, fn) {
|
||||
var opt = speed && speed.constructor == Object ? speed : {
|
||||
complete: fn || !fn && easing || jQuery.isFunction(speed) && speed,
|
||||
duration: speed,
|
||||
easing: fn && easing || easing && easing.constructor != Function && easing
|
||||
};
|
||||
opt.duration = (opt.duration && opt.duration.constructor == Number ? opt.duration : jQuery.fx.speeds[opt.duration]) || jQuery.fx.speeds.def;
|
||||
opt.old = opt.complete;
|
||||
opt.complete = function _complete () {
|
||||
if (opt.queue !== false) jQuery(this).dequeue();
|
||||
if (jQuery.isFunction(opt.old)) opt.old.call(this);
|
||||
};
|
||||
return opt;
|
||||
},
|
||||
});
|
||||
|
||||
})();
|
||||
|
|
@ -1,196 +1,196 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
||||
<title>Untitled Document</title>
|
||||
</head>
|
||||
<script>
|
||||
var g_image_number = 0;
|
||||
</script>
|
||||
<script>
|
||||
function test_function_base_crawling()
|
||||
{
|
||||
var href;
|
||||
href = "results.html?";
|
||||
href += "function_base_crawling_";
|
||||
href += (12*document.location.href.length) ? "worked" : "/strange_behaviour";
|
||||
document.location.href = href;
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
|
||||
function test_event_element()
|
||||
{
|
||||
var href;
|
||||
href = "results.html?";
|
||||
href += "event_element_";
|
||||
if (window.event == undefined) {
|
||||
href += (12*document.location.href.length) ? "unsupported" : "strange_behaviour";
|
||||
} else if (!isNaN(window.event.srcElement)) {
|
||||
href += (12*document.location.href.length) ? "srcElement_unsupported" : "strange_behaviour";
|
||||
} else if (!isNaN(window.event.srcElement)) {
|
||||
href += (12*document.location.href.length) ? "srcElement_attr_unsupported" : "strange_behaviour";
|
||||
} else {
|
||||
href += (12*document.location.href.length) ? "worked" : "strange_behaviour";
|
||||
}
|
||||
document.location.href = href;
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
|
||||
function test_isNaN()
|
||||
{
|
||||
var href;
|
||||
href = "results.html?";
|
||||
href += "isNaN_";
|
||||
if (!isNaN(window.asghdaa)) {
|
||||
href += (12*document.location.href.length) ? "unsupported" : "strange_behaviour";
|
||||
} else {
|
||||
href += (12*document.location.href.length) ? "worked" : "strange_behaviour";
|
||||
}
|
||||
document.location.href = href;
|
||||
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
|
||||
function test_first_phase()
|
||||
{
|
||||
var href;
|
||||
href = "results.html?";
|
||||
href += "first_phase_";
|
||||
href += (12*document.location.href.length) ? "worked" : "/strange_behaviour";
|
||||
document.location.href = href;
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
|
||||
function test_second_phase()
|
||||
{
|
||||
var button = document.createElement("button");
|
||||
button.innerText = "go to second phase html";
|
||||
document.body.appendChild(button);
|
||||
button.onclick = function () {
|
||||
var href;
|
||||
href = "results.html?";
|
||||
href += "second_phase_";
|
||||
href += (12*document.location.href.length) ? "worked" : "/strange_behaviour";
|
||||
document.location.href = href;
|
||||
};
|
||||
|
||||
var thirdButton = document.createElement("button");
|
||||
thirdButton.innerText = 'Test "Third Phase Competability"';
|
||||
thirdButton.onclick = test_third_phase;
|
||||
document.body.appendChild(thirdButton);
|
||||
}
|
||||
|
||||
</script>
|
||||
<script>
|
||||
function test_third_phase()
|
||||
{
|
||||
var button = document.createElement("button");
|
||||
button.innerText = "go to third phase html";
|
||||
document.body.appendChild(button);
|
||||
button.onclick = function () {
|
||||
var href;
|
||||
href = "results.html?";
|
||||
href += "third_phase_";
|
||||
href += (12*document.location.href.length) ? "worked" : "/strange_behaviour";
|
||||
document.location.href = href;
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<script>
|
||||
function test_n_phase()
|
||||
{
|
||||
var button = document.createElement("button");
|
||||
button.tag = isNaN(event.srcElement.tag) ? 1 : Number(event.srcElement.tag) + 1;
|
||||
button.innerText = "go to "+button.tag+" phase html";
|
||||
button.onclick = function () {
|
||||
var href;
|
||||
href = "results.html?";
|
||||
href += "n_phase_"+button.tag+"_";
|
||||
href += (12*document.location.href.length) ? "worked" : "/strange_behaviour";
|
||||
document.location.href = href;
|
||||
};
|
||||
|
||||
var linkButton = document.createElement("button");
|
||||
linkButton.tag = button.tag;
|
||||
linkButton.innerText = "create "+linkButton.tag+" phase button";
|
||||
linkButton.onclick = test_n_phase;
|
||||
document.body.appendChild(linkButton);
|
||||
document.body.appendChild(button);
|
||||
}
|
||||
|
||||
</script>
|
||||
<script>
|
||||
var differentOrder = "/differnet_order_";
|
||||
|
||||
</script>
|
||||
<script>
|
||||
function test_both_order2()
|
||||
{
|
||||
differentOrder += "2";
|
||||
test_both_order_button.innerText = 'Test "Different Order Competability 2"';
|
||||
}
|
||||
|
||||
</script>
|
||||
<script>
|
||||
function test_both_order()
|
||||
{
|
||||
var href;
|
||||
href = "results.html?";
|
||||
href += "both_order_";
|
||||
href += (test_both_order_button.innerText.substr(test_both_order_button.innerText.length-2,1));
|
||||
href += ".html";
|
||||
document.location.href = href;
|
||||
}
|
||||
|
||||
</script>
|
||||
<script>
|
||||
function send_unique_dom_request()
|
||||
{
|
||||
var href;
|
||||
href = "results.html?";
|
||||
href += "dom_unique";
|
||||
href += ".html";
|
||||
document.location.href = href;
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
<script>
|
||||
function send_same_dom_request()
|
||||
{
|
||||
var href;
|
||||
href = "results.html?";
|
||||
href += "dom_same";
|
||||
href += ".html";
|
||||
document.location.href = href;
|
||||
}
|
||||
|
||||
</script>
|
||||
<script>
|
||||
function test_unique_dom_button2()
|
||||
{
|
||||
test_unique_dom_button.onclick = send_same_dom_request;
|
||||
}
|
||||
</script>
|
||||
<body>
|
||||
|
||||
<BR><BR><BR><HR><BR><BR><BR>
|
||||
|
||||
<BR><button onclick = "test_event_element()">Test "Event Element"</button>
|
||||
<BR><button onclick = "test_isNaN()">Test "isNaN Competability"</button>
|
||||
<BR><button onclick = "test_first_phase()">Test "First Phase Competability"</button>
|
||||
<BR><button onclick = "test_second_phase()">Test "Second Phase Competability"</button>
|
||||
<BR><button onclick = "test_n_phase()">Test "N Phase Competability"</button>
|
||||
<BR><button id=test_both_order_button onclick = "test_both_order()">Test "Different Order Competability 1"</button>
|
||||
<button onclick = "test_both_order2()">Change Different Order Location</button>
|
||||
<BR><button onclick = "test_unique_dom_button2()">Change Next element onclick Method</button>
|
||||
<button id=test_unique_dom_button onclick = "send_unique_dom_request()">Test "Unique Dom Competability"</button>
|
||||
<BR>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
||||
<title>Untitled Document</title>
|
||||
</head>
|
||||
<script>
|
||||
var g_image_number = 0;
|
||||
</script>
|
||||
<script>
|
||||
function test_function_base_crawling()
|
||||
{
|
||||
var href;
|
||||
href = "results.html?";
|
||||
href += "function_base_crawling_";
|
||||
href += (12*document.location.href.length) ? "worked" : "/strange_behaviour";
|
||||
document.location.href = href;
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
|
||||
function test_event_element()
|
||||
{
|
||||
var href;
|
||||
href = "results.html?";
|
||||
href += "event_element_";
|
||||
if (window.event == undefined) {
|
||||
href += (12*document.location.href.length) ? "unsupported" : "strange_behaviour";
|
||||
} else if (!isNaN(window.event.srcElement)) {
|
||||
href += (12*document.location.href.length) ? "srcElement_unsupported" : "strange_behaviour";
|
||||
} else if (!isNaN(window.event.srcElement)) {
|
||||
href += (12*document.location.href.length) ? "srcElement_attr_unsupported" : "strange_behaviour";
|
||||
} else {
|
||||
href += (12*document.location.href.length) ? "worked" : "strange_behaviour";
|
||||
}
|
||||
document.location.href = href;
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
|
||||
function test_isNaN()
|
||||
{
|
||||
var href;
|
||||
href = "results.html?";
|
||||
href += "isNaN_";
|
||||
if (!isNaN(window.asghdaa)) {
|
||||
href += (12*document.location.href.length) ? "unsupported" : "strange_behaviour";
|
||||
} else {
|
||||
href += (12*document.location.href.length) ? "worked" : "strange_behaviour";
|
||||
}
|
||||
document.location.href = href;
|
||||
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
|
||||
function test_first_phase()
|
||||
{
|
||||
var href;
|
||||
href = "results.html?";
|
||||
href += "first_phase_";
|
||||
href += (12*document.location.href.length) ? "worked" : "/strange_behaviour";
|
||||
document.location.href = href;
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
|
||||
function test_second_phase()
|
||||
{
|
||||
var button = document.createElement("button");
|
||||
button.innerText = "go to second phase html";
|
||||
document.body.appendChild(button);
|
||||
button.onclick = function () {
|
||||
var href;
|
||||
href = "results.html?";
|
||||
href += "second_phase_";
|
||||
href += (12*document.location.href.length) ? "worked" : "/strange_behaviour";
|
||||
document.location.href = href;
|
||||
};
|
||||
|
||||
var thirdButton = document.createElement("button");
|
||||
thirdButton.innerText = 'Test "Third Phase Competability"';
|
||||
thirdButton.onclick = test_third_phase;
|
||||
document.body.appendChild(thirdButton);
|
||||
}
|
||||
|
||||
</script>
|
||||
<script>
|
||||
function test_third_phase()
|
||||
{
|
||||
var button = document.createElement("button");
|
||||
button.innerText = "go to third phase html";
|
||||
document.body.appendChild(button);
|
||||
button.onclick = function () {
|
||||
var href;
|
||||
href = "results.html?";
|
||||
href += "third_phase_";
|
||||
href += (12*document.location.href.length) ? "worked" : "/strange_behaviour";
|
||||
document.location.href = href;
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<script>
|
||||
function test_n_phase()
|
||||
{
|
||||
var button = document.createElement("button");
|
||||
button.tag = isNaN(event.srcElement.tag) ? 1 : Number(event.srcElement.tag) + 1;
|
||||
button.innerText = "go to "+button.tag+" phase html";
|
||||
button.onclick = function () {
|
||||
var href;
|
||||
href = "results.html?";
|
||||
href += "n_phase_"+button.tag+"_";
|
||||
href += (12*document.location.href.length) ? "worked" : "/strange_behaviour";
|
||||
document.location.href = href;
|
||||
};
|
||||
|
||||
var linkButton = document.createElement("button");
|
||||
linkButton.tag = button.tag;
|
||||
linkButton.innerText = "create "+linkButton.tag+" phase button";
|
||||
linkButton.onclick = test_n_phase;
|
||||
document.body.appendChild(linkButton);
|
||||
document.body.appendChild(button);
|
||||
}
|
||||
|
||||
</script>
|
||||
<script>
|
||||
var differentOrder = "/differnet_order_";
|
||||
|
||||
</script>
|
||||
<script>
|
||||
function test_both_order2()
|
||||
{
|
||||
differentOrder += "2";
|
||||
test_both_order_button.innerText = 'Test "Different Order Competability 2"';
|
||||
}
|
||||
|
||||
</script>
|
||||
<script>
|
||||
function test_both_order()
|
||||
{
|
||||
var href;
|
||||
href = "results.html?";
|
||||
href += "both_order_";
|
||||
href += (test_both_order_button.innerText.substr(test_both_order_button.innerText.length-2,1));
|
||||
href += ".html";
|
||||
document.location.href = href;
|
||||
}
|
||||
|
||||
</script>
|
||||
<script>
|
||||
function send_unique_dom_request()
|
||||
{
|
||||
var href;
|
||||
href = "results.html?";
|
||||
href += "dom_unique";
|
||||
href += ".html";
|
||||
document.location.href = href;
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
<script>
|
||||
function send_same_dom_request()
|
||||
{
|
||||
var href;
|
||||
href = "results.html?";
|
||||
href += "dom_same";
|
||||
href += ".html";
|
||||
document.location.href = href;
|
||||
}
|
||||
|
||||
</script>
|
||||
<script>
|
||||
function test_unique_dom_button2()
|
||||
{
|
||||
test_unique_dom_button.onclick = send_same_dom_request;
|
||||
}
|
||||
</script>
|
||||
<body>
|
||||
|
||||
<BR><BR><BR><HR><BR><BR><BR>
|
||||
|
||||
<BR><button onclick = "test_event_element()">Test "Event Element"</button>
|
||||
<BR><button onclick = "test_isNaN()">Test "isNaN Competability"</button>
|
||||
<BR><button onclick = "test_first_phase()">Test "First Phase Competability"</button>
|
||||
<BR><button onclick = "test_second_phase()">Test "Second Phase Competability"</button>
|
||||
<BR><button onclick = "test_n_phase()">Test "N Phase Competability"</button>
|
||||
<BR><button id=test_both_order_button onclick = "test_both_order()">Test "Different Order Competability 1"</button>
|
||||
<button onclick = "test_both_order2()">Change Different Order Location</button>
|
||||
<BR><button onclick = "test_unique_dom_button2()">Change Next element onclick Method</button>
|
||||
<button id=test_unique_dom_button onclick = "send_unique_dom_request()">Test "Unique Dom Competability"</button>
|
||||
<BR>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,4 +1,4 @@
|
|||
function changeUrls()
|
||||
{
|
||||
document.links[0].href = "page15.php?a=ok";
|
||||
function changeUrls()
|
||||
{
|
||||
document.links[0].href = "page15.php?a=ok";
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
function changeUrls()
|
||||
{
|
||||
document.links[0].href = "page16.php?a=ok";
|
||||
function changeUrls()
|
||||
{
|
||||
document.links[0].href = "page16.php?a=ok";
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
function changeUrls()
|
||||
{
|
||||
document.links[0].href = "page17.php?a=ok";
|
||||
function changeUrls()
|
||||
{
|
||||
document.links[0].href = "page17.php?a=ok";
|
||||
}
|
|
@ -1,25 +1,25 @@
|
|||
<html>
|
||||
<body>
|
||||
<script>
|
||||
var myForm = document.createElement("form");
|
||||
myForm.setAttribute("action","page11.php");
|
||||
myForm.setAttribute("method","GET");
|
||||
var myHiddenA = document.createElement("input");
|
||||
myHiddenA.setAttribute("type","hidden");
|
||||
myHiddenA.setAttribute("name","a");
|
||||
myHiddenA.setAttribute("value","ok");
|
||||
var myHiddenB = document.createElement("input");
|
||||
myHiddenB.setAttribute("type","hidden");
|
||||
myHiddenB.setAttribute("name","b");
|
||||
myHiddenB.setAttribute("value","ok");
|
||||
var mySubmit = document.createElement("input");
|
||||
mySubmit.setAttribute("type","submit");
|
||||
mySubmit.setAttribute("name","submit");
|
||||
mySubmit.setAttribute("value","submit");
|
||||
myForm.appendChild(myHiddenA);
|
||||
myForm.appendChild(myHiddenB);
|
||||
myForm.appendChild(mySubmit);
|
||||
document.body.appendChild(myForm);
|
||||
</script>
|
||||
</body>
|
||||
<html>
|
||||
<body>
|
||||
<script>
|
||||
var myForm = document.createElement("form");
|
||||
myForm.setAttribute("action","page11.php");
|
||||
myForm.setAttribute("method","GET");
|
||||
var myHiddenA = document.createElement("input");
|
||||
myHiddenA.setAttribute("type","hidden");
|
||||
myHiddenA.setAttribute("name","a");
|
||||
myHiddenA.setAttribute("value","ok");
|
||||
var myHiddenB = document.createElement("input");
|
||||
myHiddenB.setAttribute("type","hidden");
|
||||
myHiddenB.setAttribute("name","b");
|
||||
myHiddenB.setAttribute("value","ok");
|
||||
var mySubmit = document.createElement("input");
|
||||
mySubmit.setAttribute("type","submit");
|
||||
mySubmit.setAttribute("name","submit");
|
||||
mySubmit.setAttribute("value","submit");
|
||||
myForm.appendChild(myHiddenA);
|
||||
myForm.appendChild(myHiddenB);
|
||||
myForm.appendChild(mySubmit);
|
||||
document.body.appendChild(myForm);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,31 +1,31 @@
|
|||
<html>
|
||||
<head>
|
||||
<script>
|
||||
function handler()
|
||||
{
|
||||
if(this.readyState == 4)
|
||||
{
|
||||
var contents = this.responseText;
|
||||
document.getElementById("myDiv").innerHTML = contents;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
function callXHR()
|
||||
{
|
||||
var textBoxValue = document.getElementById("freeTextField").value;
|
||||
var client = new XMLHttpRequest();
|
||||
client.onreadystatechange = handler;
|
||||
client.open("GET", "page12.php?freeTextField="+textBoxValue, true);
|
||||
client.send(null);
|
||||
return;
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="myDiv" style="location: absolute; top: 100px; left: 100px; height: 400px; width: 400px; background-color: #ff0000;"></div>
|
||||
<input type="text" id="freeTextField" name="freeTextField" value="DEFAULT_SHOULD_BE_CHANGED"></input>
|
||||
<button onclick="return callXHR();">SUBMIT</button>
|
||||
</body>
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
function handler()
|
||||
{
|
||||
if(this.readyState == 4)
|
||||
{
|
||||
var contents = this.responseText;
|
||||
document.getElementById("myDiv").innerHTML = contents;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
function callXHR()
|
||||
{
|
||||
var textBoxValue = document.getElementById("freeTextField").value;
|
||||
var client = new XMLHttpRequest();
|
||||
client.onreadystatechange = handler;
|
||||
client.open("GET", "page12.php?freeTextField="+textBoxValue, true);
|
||||
client.send(null);
|
||||
return;
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="myDiv" style="location: absolute; top: 100px; left: 100px; height: 400px; width: 400px; background-color: #ff0000;"></div>
|
||||
<input type="text" id="freeTextField" name="freeTextField" value="DEFAULT_SHOULD_BE_CHANGED"></input>
|
||||
<button onclick="return callXHR();">SUBMIT</button>
|
||||
</body>
|
||||
</html>
|
|
@ -1,32 +1,32 @@
|
|||
<html>
|
||||
<head>
|
||||
<script>
|
||||
function handler()
|
||||
{
|
||||
if(this.readyState == 4)
|
||||
{
|
||||
var contents = this.responseText;
|
||||
document.getElementById("myDiv").innerHTML = contents;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
function callXHR()
|
||||
{
|
||||
var textBoxValue = document.getElementById("freeTextField").value;
|
||||
var client = new XMLHttpRequest();
|
||||
client.onreadystatechange = handler;
|
||||
client.open("POST", "page13.php", true);
|
||||
client.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
|
||||
client.send("freeTextField="+textBoxValue);
|
||||
return;
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="myDiv" style="location: absolute; top: 100px; left: 100px; height: 400px; width: 400px; background-color: #ff0000;"></div>
|
||||
<input type="text" id="freeTextField" name="freeTextField" value="DEFAULT_SHOULD_BE_CHANGED"></input>
|
||||
<button onclick="return callXHR();">SUBMIT</button>
|
||||
</body>
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
function handler()
|
||||
{
|
||||
if(this.readyState == 4)
|
||||
{
|
||||
var contents = this.responseText;
|
||||
document.getElementById("myDiv").innerHTML = contents;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
function callXHR()
|
||||
{
|
||||
var textBoxValue = document.getElementById("freeTextField").value;
|
||||
var client = new XMLHttpRequest();
|
||||
client.onreadystatechange = handler;
|
||||
client.open("POST", "page13.php", true);
|
||||
client.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
|
||||
client.send("freeTextField="+textBoxValue);
|
||||
return;
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="myDiv" style="location: absolute; top: 100px; left: 100px; height: 400px; width: 400px; background-color: #ff0000;"></div>
|
||||
<input type="text" id="freeTextField" name="freeTextField" value="DEFAULT_SHOULD_BE_CHANGED"></input>
|
||||
<button onclick="return callXHR();">SUBMIT</button>
|
||||
</body>
|
||||
</html>
|
|
@ -1,8 +1,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<script src="15.js"></script>
|
||||
</head>
|
||||
<body onload="return changeUrls();">
|
||||
<a href="#">Link to be changed onload</a>
|
||||
</body>
|
||||
</html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="15.js"></script>
|
||||
</head>
|
||||
<body onload="return changeUrls();">
|
||||
<a href="#">Link to be changed onload</a>
|
||||
</body>
|
||||
</html>
|
|
@ -1,8 +1,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<script src="16.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a href="#" onclick="return changeUrls();">Link to be changed onload</a>
|
||||
</body>
|
||||
<html>
|
||||
<head>
|
||||
<script src="16.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a href="#" onclick="return changeUrls();">Link to be changed onload</a>
|
||||
</body>
|
||||
</html>
|
|
@ -1,37 +1,37 @@
|
|||
<html>
|
||||
<head>
|
||||
<script>
|
||||
function loadScript(url, callback)
|
||||
{
|
||||
var head = document.getElementsByTagName("head")[0];
|
||||
var script = document.createElement("script");
|
||||
script.src = url;
|
||||
|
||||
var done = false;
|
||||
script.onload = script.onreadystatechange = function _page17_handler()
|
||||
{
|
||||
if( !done && ( !this.readyState || this.readyState == "loaded" || this.readyState == "complete"))
|
||||
{
|
||||
done = true;
|
||||
callback();
|
||||
script.onload = script.onreadystatechange = null;
|
||||
head.removeChild( script );
|
||||
}
|
||||
};
|
||||
|
||||
head.appendChild(script);
|
||||
}
|
||||
function callFunction()
|
||||
{
|
||||
changeUrls();
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a href="#">Test Link</a>
|
||||
<script>
|
||||
loadScript("17.js", callFunction);
|
||||
</script>
|
||||
</body>
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
function loadScript(url, callback)
|
||||
{
|
||||
var head = document.getElementsByTagName("head")[0];
|
||||
var script = document.createElement("script");
|
||||
script.src = url;
|
||||
|
||||
var done = false;
|
||||
script.onload = script.onreadystatechange = function _page17_handler()
|
||||
{
|
||||
if( !done && ( !this.readyState || this.readyState == "loaded" || this.readyState == "complete"))
|
||||
{
|
||||
done = true;
|
||||
callback();
|
||||
script.onload = script.onreadystatechange = null;
|
||||
head.removeChild( script );
|
||||
}
|
||||
};
|
||||
|
||||
head.appendChild(script);
|
||||
}
|
||||
function callFunction()
|
||||
{
|
||||
changeUrls();
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a href="#">Test Link</a>
|
||||
<script>
|
||||
loadScript("17.js", callFunction);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue