Merge branch 'wala' into master

This commit is contained in:
Juergen Graf 2014-04-09 16:59:51 +02:00
commit b82d5dba90
1440 changed files with 146264 additions and 177207 deletions

4
.gitignore vendored
View File

@ -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.js.test/examples-src/ajaxslt/
com.ibm.wala.cast.java.polyglot/lib/ com.ibm.wala.cast.java.polyglot/lib/
.metadata/ .metadata/
*~
com.ibm.wala.cast.js.test/examples-src/ajaxslt/ com.ibm.wala.cast.js.test/examples-src/ajaxslt/
com.ibm.wala.core.testdata/@dot/ com.ibm.wala.core.testdata/@dot/
com.ibm.wala.core.testdata/lib/ com.ibm.wala.core.testdata/lib/
com.ibm.wala.cast.js.html.nu_validator/lib/ com.ibm.wala.cast.js.html.nu_validator/lib/
com.ibm.wala.cast.java.test/testdata/ com.ibm.wala.cast.java.test/testdata/
edu.kit.wala.smali.test/out/ edu.kit.wala.smali.test/out/
com.ibm.wala.core/@dot
com.ibm.wala.core/com.ibm.wala.core*.jar

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>com.ibm.wala-feature</name> <name>com.ibm.wala-feature</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>
<buildSpec> <buildSpec>
<buildCommand> <buildCommand>
<name>org.eclipse.pde.FeatureBuilder</name> <name>org.eclipse.pde.FeatureBuilder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.pde.FeatureNature</nature> <nature>org.eclipse.pde.FeatureNature</nature>
</natures> </natures>
</projectDescription> </projectDescription>

View File

@ -1,4 +1,4 @@
bin.includes = feature.xml,\ bin.includes = feature.xml,\
feature.properties,\ feature.properties,\
license.html,\ license.html,\
notice.html notice.html

View File

@ -1,9 +1,9 @@
# NLS_ENCODING=UTF-8 # NLS_ENCODING=UTF-8
# NLS_MESSAGEFORMAT_VAR # NLS_MESSAGEFORMAT_VAR
# #
# Feature details # Feature details
# #
featureName = WALA Bundles featureName = WALA Bundles
providerName = IBM providerName = IBM

View File

@ -1,51 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<feature <feature
id="com.ibm.wala" id="com.ibm.wala"
label="%featureName" label="%featureName"
version="1.1.3.qualifier" version="1.1.3.qualifier"
provider-name="%providerName"> provider-name="%providerName">
<copyright url="%copyrightURL"> <copyright url="%copyrightURL">
%copyright %copyright
</copyright> </copyright>
<license url="%licenseURL"> <license url="%licenseURL">
%license %license
</license> </license>
<plugin <plugin
id="com.ibm.wala.core" id="com.ibm.wala.core"
download-size="0" download-size="0"
install-size="0" install-size="0"
version="0.0.0" version="0.0.0"
unpack="false"/> unpack="false"/>
<plugin <plugin
id="com.ibm.wala.shrike" id="com.ibm.wala.shrike"
download-size="0" download-size="0"
install-size="0" install-size="0"
version="0.0.0" version="0.0.0"
unpack="false"/> unpack="false"/>
<plugin <plugin
id="com.ibm.wala.cast" id="com.ibm.wala.cast"
download-size="0" download-size="0"
install-size="0" install-size="0"
version="0.0.0" version="0.0.0"
unpack="false"/> unpack="false"/>
<plugin <plugin
id="com.ibm.wala.cast.java" id="com.ibm.wala.cast.java"
download-size="0" download-size="0"
install-size="0" install-size="0"
version="0.0.0" version="0.0.0"
unpack="false"/> unpack="false"/>
<plugin <plugin
id="com.ibm.wala.util" id="com.ibm.wala.util"
download-size="0" download-size="0"
install-size="0" install-size="0"
version="0.0.0" version="0.0.0"
unpack="false"/> unpack="false"/>
</feature> </feature>

View File

@ -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.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="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="source"/> <classpathentry kind="src" path="source"/>
<classpathentry kind="src" path="data"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>com.ibm.wala.cast.java.jdt.test</name> <name>com.ibm.wala.ide.jdt.test</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>

View File

@ -1,4 +1,4 @@
#Mon Apr 13 10:03:21 EDT 2009 #Mon Apr 13 10:03:21 EDT 2009
eclipse.preferences.version=1 eclipse.preferences.version=1
formatter_profile=_WALA formatter_profile=_WALA
formatter_settings_version=11 formatter_settings_version=11

View File

@ -1,7 +1,7 @@
Manifest-Version: 1.0 Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: WALA CAst Java JDT Test Plug-in 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-Version: 1.0.0
Bundle-Activator: com.ibm.wala.cast.java.jdt.test.Activator Bundle-Activator: com.ibm.wala.cast.java.jdt.test.Activator
Bundle-Vendor: IBM 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.cast.test;bundle-version="1.0.0",
com.ibm.wala.ide.tests;bundle-version="1.1.3", com.ibm.wala.ide.tests;bundle-version="1.1.3",
com.ibm.wala.core.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.java;bundle-version="1.0.0",
com.ibm.wala.cast;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.ide;bundle-version="1.1.3",
com.ibm.wala.core;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.core.resources;bundle-version="3.4.1",
org.eclipse.jdt.core;bundle-version="3.4.2", org.eclipse.jdt.core;bundle-version="3.4.2",
org.junit4;bundle-version="4.8.1", 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-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-RequiredExecutionEnvironment: J2SE-1.5

View File

@ -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

View File

@ -16,7 +16,7 @@
<booleanAttribute key="includeOptional" value="true"/> <booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/> <stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> <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>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/> <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.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.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.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.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="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dcom.ibm.wala.tracefile=/tmp/jdt15tests.txt -Xmx1024M -ea"/>
<stringAttribute key="pde.version" value="3.3"/> <stringAttribute key="pde.version" value="3.3"/>

File diff suppressed because one or more lines are too long

View File

@ -6,71 +6,14 @@
*****************************************************************************/ *****************************************************************************/
package com.ibm.wala.cast.java.test; 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 org.junit.Test;
import com.ibm.wala.cast.java.client.JDTJavaSourceAnalysisEngine; public class JDTJava15IRTests extends JDTJavaTest {
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 JDTJava15IRTests() { 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 @Test
public void testAnonGeneNullarySimple() { public void testAnonGeneNullarySimple() {
runTest(singlePkgTestSrc("javaonepointfive"), rtJar, simplePkgTestEntryPoint("javaonepointfive"), emptyList, true); runTest(singlePkgTestSrc("javaonepointfive"), rtJar, simplePkgTestEntryPoint("javaonepointfive"), emptyList, true);

View File

@ -37,28 +37,12 @@
*/ */
package com.ibm.wala.cast.java.test; package com.ibm.wala.cast.java.test;
import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import junit.framework.Assert; import com.ibm.wala.cast.java.jdt.test.Activator;
import com.ibm.wala.client.AbstractAnalysisEngine;
import org.eclipse.core.runtime.NullProgressMonitor; import com.ibm.wala.ide.tests.util.EclipseTestUtil.ZippedProjectData;
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;
public class JDTJavaIRTests extends JavaIRTests { 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 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() { public JDTJavaIRTests() {
super(PROJECT_NAME); this(PROJECT);
} }
private JDTJavaIRTests(ZippedProjectData project) {
super(project.projectName);
this.project = project;
}
@Override @Override
protected void populateScope(JavaSourceAnalysisEngine engine, Collection<String> sources, List<String> libs) throws IOException { protected AbstractAnalysisEngine getAnalysisEngine(final String[] mainClassDescriptors, Collection<String> sources, List<String> libs) {
IDEIRTestUtil.populateScope(projectName, (JDTJavaSourceAnalysisEngine)engine, sources, libs); return JDTJavaTest.makeAnalysisEngine(mainClassDescriptors, sources, libs, project);
}
@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;
} }
} }

View File

@ -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;
}
}
}

View File

@ -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);
}
}
}

View File

@ -1,305 +1,303 @@
/** /**
* Refinement Analysis Tools is Copyright (c) 2007 The Regents of the * Refinement Analysis Tools is Copyright (c) 2007 The Regents of the
* University of California (Regents). Provided that this notice and * University of California (Regents). Provided that this notice and
* the following two paragraphs are included in any distribution of * the following two paragraphs are included in any distribution of
* Refinement Analysis Tools or its derivative work, Regents agrees * Refinement Analysis Tools or its derivative work, Regents agrees
* not to assert any of Regents' copyright rights in Refinement * not to assert any of Regents' copyright rights in Refinement
* Analysis Tools against recipient for recipient's reproduction, * Analysis Tools against recipient for recipient's reproduction,
* preparation of derivative works, public display, public * preparation of derivative works, public display, public
* performance, distribution or sublicensing of Refinement Analysis * performance, distribution or sublicensing of Refinement Analysis
* Tools and derivative works, in source code and object code form. * Tools and derivative works, in source code and object code form.
* This agreement not to assert does not confer, by implication, * This agreement not to assert does not confer, by implication,
* estoppel, or otherwise any license or rights in any intellectual * estoppel, or otherwise any license or rights in any intellectual
* property of Regents, including, but not limited to, any patents * property of Regents, including, but not limited to, any patents
* of Regents or Regents' employees. * of Regents or Regents' employees.
* *
* IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, * IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT,
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
* INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE * INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE
* AND ITS DOCUMENTATION, EVEN IF REGENTS HAS BEEN ADVISED OF THE * AND ITS DOCUMENTATION, EVEN IF REGENTS HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT * REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE AND FURTHER DISCLAIMS ANY STATUTORY * FOR A PARTICULAR PURPOSE AND FURTHER DISCLAIMS ANY STATUTORY
* WARRANTY OF NON-INFRINGEMENT. THE SOFTWARE AND ACCOMPANYING * WARRANTY OF NON-INFRINGEMENT. THE SOFTWARE AND ACCOMPANYING
* DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS * DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS
* IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, * IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
* UPDATES, ENHANCEMENTS, OR MODIFICATIONS. * UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/ */
package com.ibm.wala.demandpa.driver; package com.ibm.wala.demandpa.driver;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Properties; 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.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.demandpa.alg.ContextSensitiveStateMachine;
import com.ibm.wala.core.tests.util.TestConstants; import com.ibm.wala.demandpa.alg.DemandRefinementPointsTo;
import com.ibm.wala.demandpa.alg.ContextSensitiveStateMachine; import com.ibm.wala.demandpa.alg.DemandRefinementPointsTo.PointsToResult;
import com.ibm.wala.demandpa.alg.DemandRefinementPointsTo; import com.ibm.wala.demandpa.alg.refinepolicy.FieldRefinePolicy;
import com.ibm.wala.demandpa.alg.DemandRefinementPointsTo.PointsToResult; import com.ibm.wala.demandpa.alg.refinepolicy.ManualFieldPolicy;
import com.ibm.wala.demandpa.alg.refinepolicy.FieldRefinePolicy; import com.ibm.wala.demandpa.alg.refinepolicy.ManualRefinementPolicy;
import com.ibm.wala.demandpa.alg.refinepolicy.ManualFieldPolicy; import com.ibm.wala.demandpa.alg.refinepolicy.RefinementPolicyFactory;
import com.ibm.wala.demandpa.alg.refinepolicy.ManualRefinementPolicy; import com.ibm.wala.demandpa.alg.refinepolicy.TunedRefinementPolicy;
import com.ibm.wala.demandpa.alg.refinepolicy.RefinementPolicyFactory; import com.ibm.wala.demandpa.alg.statemachine.StateMachineFactory;
import com.ibm.wala.demandpa.alg.refinepolicy.TunedRefinementPolicy; import com.ibm.wala.demandpa.flowgraph.IFlowLabel;
import com.ibm.wala.demandpa.alg.statemachine.StateMachineFactory; import com.ibm.wala.demandpa.util.MemoryAccessMap;
import com.ibm.wala.demandpa.flowgraph.IFlowLabel; import com.ibm.wala.demandpa.util.SimpleMemoryAccessMap;
import com.ibm.wala.demandpa.util.MemoryAccessMap; import com.ibm.wala.ipa.callgraph.AnalysisCache;
import com.ibm.wala.demandpa.util.SimpleMemoryAccessMap; import com.ibm.wala.ipa.callgraph.AnalysisOptions;
import com.ibm.wala.ide.util.ProgressMaster; import com.ibm.wala.ipa.callgraph.AnalysisScope;
import com.ibm.wala.ide.util.ProgressMonitorDelegate; import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.AnalysisCache; import com.ibm.wala.ipa.callgraph.CallGraph;
import com.ibm.wala.ipa.callgraph.AnalysisOptions; import com.ibm.wala.ipa.callgraph.CallGraphBuilder;
import com.ibm.wala.ipa.callgraph.AnalysisScope; import com.ibm.wala.ipa.callgraph.CallGraphBuilderCancelException;
import com.ibm.wala.ipa.callgraph.CGNode; import com.ibm.wala.ipa.callgraph.CallGraphStats;
import com.ibm.wala.ipa.callgraph.CallGraph; import com.ibm.wala.ipa.callgraph.Entrypoint;
import com.ibm.wala.ipa.callgraph.CallGraphBuilder; import com.ibm.wala.ipa.callgraph.impl.Util;
import com.ibm.wala.ipa.callgraph.CallGraphBuilderCancelException; import com.ibm.wala.ipa.callgraph.propagation.HeapModel;
import com.ibm.wala.ipa.callgraph.CallGraphStats; import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
import com.ibm.wala.ipa.callgraph.Entrypoint; import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
import com.ibm.wala.ipa.callgraph.impl.Util; import com.ibm.wala.ipa.callgraph.propagation.PointerKey;
import com.ibm.wala.ipa.callgraph.propagation.HeapModel; import com.ibm.wala.ipa.cha.ClassHierarchy;
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey; import com.ibm.wala.ipa.cha.ClassHierarchyException;
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis; import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.ipa.callgraph.propagation.PointerKey; import com.ibm.wala.properties.WalaProperties;
import com.ibm.wala.ipa.cha.ClassHierarchy; import com.ibm.wala.ssa.IR;
import com.ibm.wala.ipa.cha.ClassHierarchyException; import com.ibm.wala.ssa.SSACheckCastInstruction;
import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.properties.WalaProperties; import com.ibm.wala.types.ClassLoaderReference;
import com.ibm.wala.ssa.IR; import com.ibm.wala.types.TypeReference;
import com.ibm.wala.ssa.SSACheckCastInstruction; import com.ibm.wala.util.CancelException;
import com.ibm.wala.ssa.SSAInstruction; import com.ibm.wala.util.NullProgressMonitor;
import com.ibm.wala.types.ClassLoaderReference; import com.ibm.wala.util.Predicate;
import com.ibm.wala.types.TypeReference; import com.ibm.wala.util.ProgressMaster;
import com.ibm.wala.util.CancelException; import com.ibm.wala.util.WalaException;
import com.ibm.wala.util.Predicate; import com.ibm.wala.util.collections.Pair;
import com.ibm.wala.util.WalaException; import com.ibm.wala.util.debug.Assertions;
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.
/** *
* Uses a demand-driven points-to analysis to check the safety of downcasts. * @author Manu Sridharan
* *
* @author Manu Sridharan */
* public class DemandCastChecker {
*/
public class DemandCastChecker { // maximum number of casts to check
private static final int MAX_CASTS = Integer.MAX_VALUE;
// maximum number of casts to check
private static final int MAX_CASTS = Integer.MAX_VALUE; /**
* @param args
/** * @throws CancelException
* @param args * @throws IllegalArgumentException
* @throws CancelException * @throws IOException
* @throws IllegalArgumentException */
* @throws IOException public static void main(String[] args) throws IllegalArgumentException, CancelException, IOException {
*/ try {
public static void main(String[] args) throws IllegalArgumentException, CancelException, IOException { Properties p = new Properties();
try { p.putAll(WalaProperties.loadProperties());
Properties p = new Properties(); } catch (WalaException e) {
p.putAll(WalaProperties.loadProperties()); e.printStackTrace();
} catch (WalaException e) { Assertions.UNREACHABLE();
e.printStackTrace(); }
Assertions.UNREACHABLE();
} runTestCase(TestConstants.JLEX_MAIN, TestConstants.JLEX, "JLex");
// runTestCase(TestConstants.HELLO_MAIN, TestConstants.HELLO, "Hello");
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 {
public static void runTestCase(String mainClass, String scopeFile, String benchName) throws IllegalArgumentException, System.err.println("=====BENCHMARK " + benchName + "=====");
CancelException, IOException { System.err.println("analyzing " + benchName);
System.err.println("=====BENCHMARK " + benchName + "====="); DemandRefinementPointsTo dmp = null;
System.err.println("analyzing " + benchName); try {
DemandRefinementPointsTo dmp = null; dmp = makeDemandPointerAnalysis(scopeFile, mainClass, benchName);
try { findFailingCasts(dmp.getBaseCallGraph(), dmp);
dmp = makeDemandPointerAnalysis(scopeFile, mainClass, benchName); } catch (ClassHierarchyException e) {
findFailingCasts(dmp.getBaseCallGraph(), dmp); e.printStackTrace();
} catch (ClassHierarchyException e) { }
e.printStackTrace(); System.err.println("=*=*=*=*=*=*=*=*=*=*=*=*=*=*");
} System.err.println("");
System.err.println("=*=*=*=*=*=*=*=*=*=*=*=*=*=*"); System.err.println("");
System.err.println(""); }
System.err.println("");
} private static DemandRefinementPointsTo makeDemandPointerAnalysis(String scopeFile, String mainClass, String benchName)
throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
private static DemandRefinementPointsTo makeDemandPointerAnalysis(String scopeFile, String mainClass, String benchName) AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(scopeFile, getExclusions(benchName));
throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { // build a type hierarchy
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(scopeFile, getExclusions(benchName)); ClassHierarchy cha = ClassHierarchy.make(scope);
// build a type hierarchy
ClassHierarchy cha = ClassHierarchy.make(scope); // set up call graph construction options; mainly what should be considered
// entrypoints?
// set up call graph construction options; mainly what should be considered Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, mainClass);
// entrypoints? AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, 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);
System.err.print("constructing call graph..."); CallGraph cg = cgAndPA.fst;
final Pair<CallGraph, PointerAnalysis> cgAndPA = buildCallGraph(scope, cha, options); System.err.println("done");
CallGraph cg = cgAndPA.fst; System.err.println(CallGraphStats.getStats(cg));
System.err.println("done"); MemoryAccessMap fam = new SimpleMemoryAccessMap(cg, cgAndPA.snd.getHeapModel(), false);
System.err.println(CallGraphStats.getStats(cg)); DemandRefinementPointsTo fullDemandPointsTo = DemandRefinementPointsTo.makeWithDefaultFlowGraph(cg, heapModel, fam, cha, options, makeStateMachineFactory());
MemoryAccessMap fam = new SimpleMemoryAccessMap(cg, cgAndPA.snd.getHeapModel(), false); fullDemandPointsTo.setRefinementPolicyFactory(chooseRefinePolicyFactory(cha));
DemandRefinementPointsTo fullDemandPointsTo = DemandRefinementPointsTo.makeWithDefaultFlowGraph(cg, heapModel, fam, cha, options, makeStateMachineFactory()); return fullDemandPointsTo;
fullDemandPointsTo.setRefinementPolicyFactory(chooseRefinePolicyFactory(cha)); }
return fullDemandPointsTo;
} private static String getExclusions(String benchName) {
return CallGraphTestUtil.REGRESSION_EXCLUSIONS;
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;
// if true, construct up-front call graph cheaply (0-CFA)
private static final boolean CHEAP_CG = true; private static HeapModel heapModel;
private static HeapModel heapModel; /**
* builds a call graph, and sets the corresponding heap model for analysis
/** *
* builds a call graph, and sets the corresponding heap model for analysis * @param scope
* * @param cha
* @param scope * @param options
* @param cha * @return
* @param options * @throws CancelException
* @return * @throws IllegalArgumentException
* @throws CancelException */
* @throws IllegalArgumentException private static Pair<CallGraph, PointerAnalysis> buildCallGraph(AnalysisScope scope, ClassHierarchy cha, AnalysisOptions options)
*/ throws IllegalArgumentException, CancelException {
private static Pair<CallGraph, PointerAnalysis> buildCallGraph(AnalysisScope scope, ClassHierarchy cha, AnalysisOptions options) CallGraph retCG = null;
throws IllegalArgumentException, CancelException { PointerAnalysis retPA = null;
CallGraph retCG = null; final AnalysisCache cache = new AnalysisCache();
PointerAnalysis retPA = null; CallGraphBuilder builder;
final AnalysisCache cache = new AnalysisCache(); if (CHEAP_CG) {
CallGraphBuilder builder; builder = Util.makeZeroCFABuilder(options, cache, cha, scope);
if (CHEAP_CG) { // we want vanilla 0-1 CFA, which has one abstract loc per allocation
builder = Util.makeZeroCFABuilder(options, cache, cha, scope); heapModel = Util.makeVanillaZeroOneCFABuilder(options, cache, cha, scope);
// we want vanilla 0-1 CFA, which has one abstract loc per allocation } else {
heapModel = Util.makeVanillaZeroOneCFABuilder(options, cache, cha, scope); builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope);
} else { heapModel = (HeapModel) builder;
builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope); }
heapModel = (HeapModel) builder; ProgressMaster master = ProgressMaster.make(new NullProgressMonitor());
} master.setMillisPerWorkItem(360000);
ProgressMaster master = ProgressMaster.make(new NullProgressMonitor()); master.beginTask("runSolver", 1);
master.setMillisPerWorkItem(360000); try {
master.beginTask("runSolver", 1); retCG = builder.makeCallGraph(options, master);
try { retPA = builder.getPointerAnalysis();
retCG = builder.makeCallGraph(options, ProgressMonitorDelegate.createProgressMonitorDelegate(master)); } catch (CallGraphBuilderCancelException e) {
retPA = builder.getPointerAnalysis(); System.err.println("TIMED OUT!!");
} catch (CallGraphBuilderCancelException e) { retCG = e.getPartialCallGraph();
System.err.println("TIMED OUT!!"); retPA = e.getPartialPointerAnalysis();
retCG = e.getPartialCallGraph(); }
retPA = e.getPartialPointerAnalysis(); return Pair.make(retCG, retPA);
} }
return Pair.make(retCG, retPA);
} private static RefinementPolicyFactory chooseRefinePolicyFactory(ClassHierarchy cha) {
if (true) {
private static RefinementPolicyFactory chooseRefinePolicyFactory(ClassHierarchy cha) { return new TunedRefinementPolicy.Factory(cha);
if (true) { } else {
return new TunedRefinementPolicy.Factory(cha); return new ManualRefinementPolicy.Factory(cha);
} else { }
return new ManualRefinementPolicy.Factory(cha); }
}
} private static StateMachineFactory<IFlowLabel> makeStateMachineFactory() {
return new ContextSensitiveStateMachine.Factory();
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();
private static List<Pair<CGNode, SSACheckCastInstruction>> findFailingCasts(CallGraph cg, DemandRefinementPointsTo dmp) { List<Pair<CGNode, SSACheckCastInstruction>> failing = new ArrayList<Pair<CGNode, SSACheckCastInstruction>>();
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();) {
int numSafe = 0, numMightFail = 0; CGNode node = nodeIter.next();
outer: for (Iterator<? extends CGNode> nodeIter = cg.iterator(); nodeIter.hasNext();) { TypeReference declaringClass = node.getMethod().getReference().getDeclaringClass();
CGNode node = nodeIter.next(); // skip library classes
TypeReference declaringClass = node.getMethod().getReference().getDeclaringClass(); if (declaringClass.getClassLoader().equals(ClassLoaderReference.Primordial)) {
// skip library classes continue;
if (declaringClass.getClassLoader().equals(ClassLoaderReference.Primordial)) { }
continue; IR ir = node.getIR();
} if (ir == null)
IR ir = node.getIR(); continue;
if (ir == null) SSAInstruction[] instrs = ir.getInstructions();
continue; for (int i = 0; i < instrs.length; i++) {
SSAInstruction[] instrs = ir.getInstructions(); if (numSafe + numMightFail > MAX_CASTS)
for (int i = 0; i < instrs.length; i++) { break outer;
if (numSafe + numMightFail > MAX_CASTS) SSAInstruction instruction = instrs[i];
break outer; if (instruction instanceof SSACheckCastInstruction) {
SSAInstruction instruction = instrs[i]; SSACheckCastInstruction castInstr = (SSACheckCastInstruction) instruction;
if (instruction instanceof SSACheckCastInstruction) { final TypeReference[] declaredResultTypes = castInstr.getDeclaredResultTypes();
SSACheckCastInstruction castInstr = (SSACheckCastInstruction) instruction;
final TypeReference[] declaredResultTypes = castInstr.getDeclaredResultTypes(); boolean primOnly = true;
for (TypeReference t : declaredResultTypes) {
boolean primOnly = true; if (! t.isPrimitiveType()) {
for (TypeReference t : declaredResultTypes) { primOnly = false;
if (! t.isPrimitiveType()) { }
primOnly = false; }
} if (primOnly) {
} continue;
if (primOnly) { }
continue;
} System.err.println("CHECKING " + castInstr + " in " + node.getMethod());
PointerKey castedPk = heapModel.getPointerKeyForLocal(node, castInstr.getUse(0));
System.err.println("CHECKING " + castInstr + " in " + node.getMethod()); Predicate<InstanceKey> castPred = new Predicate<InstanceKey>() {
PointerKey castedPk = heapModel.getPointerKeyForLocal(node, castInstr.getUse(0));
Predicate<InstanceKey> castPred = new Predicate<InstanceKey>() { @Override
public boolean test(InstanceKey ik) {
@Override TypeReference ikTypeRef = ik.getConcreteType().getReference();
public boolean test(InstanceKey ik) { for (TypeReference t : declaredResultTypes) {
TypeReference ikTypeRef = ik.getConcreteType().getReference(); if (cha.isAssignableFrom(cha.lookupClass(t), cha.lookupClass(ikTypeRef))) {
for (TypeReference t : declaredResultTypes) { return true;
if (cha.isAssignableFrom(cha.lookupClass(t), cha.lookupClass(ikTypeRef))) { }
return true; }
} return false;
} }
return false;
} };
long startTime = System.currentTimeMillis();
}; Pair<PointsToResult, Collection<InstanceKey>> queryResult = dmp.getPointsTo(castedPk, castPred);
long startTime = System.currentTimeMillis(); long runningTime = System.currentTimeMillis() - startTime;
Pair<PointsToResult, Collection<InstanceKey>> queryResult = dmp.getPointsTo(castedPk, castPred); System.err.println("running time: " + runningTime + "ms");
long runningTime = System.currentTimeMillis() - startTime; final FieldRefinePolicy fieldRefinePolicy = dmp.getRefinementPolicy().getFieldRefinePolicy();
System.err.println("running time: " + runningTime + "ms"); switch (queryResult.fst) {
final FieldRefinePolicy fieldRefinePolicy = dmp.getRefinementPolicy().getFieldRefinePolicy(); case SUCCESS:
switch (queryResult.fst) { System.err.println("SAFE: " + castInstr + " in " + node.getMethod());
case SUCCESS: if (fieldRefinePolicy instanceof ManualFieldPolicy) {
System.err.println("SAFE: " + castInstr + " in " + node.getMethod()); ManualFieldPolicy hackedFieldPolicy = (ManualFieldPolicy) fieldRefinePolicy;
if (fieldRefinePolicy instanceof ManualFieldPolicy) { System.err.println(hackedFieldPolicy.getHistory());
ManualFieldPolicy hackedFieldPolicy = (ManualFieldPolicy) fieldRefinePolicy; }
System.err.println(hackedFieldPolicy.getHistory()); System.err.println("TRAVERSED " + dmp.getNumNodesTraversed() + " nodes");
} numSafe++;
System.err.println("TRAVERSED " + dmp.getNumNodesTraversed() + " nodes"); break;
numSafe++; case NOMOREREFINE:
break; if (queryResult.snd != null) {
case NOMOREREFINE: System.err.println("MIGHT FAIL: no more refinement possible for " + castInstr + " in " + node.getMethod());
if (queryResult.snd != null) { } else {
System.err.println("MIGHT FAIL: no more refinement possible for " + castInstr + " in " + node.getMethod()); System.err.println("MIGHT FAIL: exceeded budget 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++;
failing.add(Pair.make(node, castInstr)); break;
numMightFail++; case BUDGETEXCEEDED:
break; System.err.println("MIGHT FAIL: exceeded budget for " + castInstr + " in " + node.getMethod());
case BUDGETEXCEEDED: failing.add(Pair.make(node, castInstr));
System.err.println("MIGHT FAIL: exceeded budget for " + castInstr + " in " + node.getMethod()); numMightFail++;
failing.add(Pair.make(node, castInstr)); break;
numMightFail++; default:
break; Assertions.UNREACHABLE();
default: }
Assertions.UNREACHABLE(); }
} }
} // break outer;
} }
// break outer; System.err.println("TOTAL SAFE: " + numSafe);
} System.err.println("TOTAL MIGHT FAIL: " + numMightFail);
System.err.println("TOTAL SAFE: " + numSafe); return failing;
System.err.println("TOTAL MIGHT FAIL: " + numMightFail); }
return failing;
} }
}

Binary file not shown.

View File

@ -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

View File

@ -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

View File

@ -1,4 +1,4 @@
#Mon Apr 13 15:21:17 EDT 2009 #Mon Apr 13 15:21:17 EDT 2009
eclipse.preferences.version=1 eclipse.preferences.version=1
formatter_profile=_WALA formatter_profile=_WALA
formatter_settings_version=11 formatter_settings_version=11

View File

@ -6,6 +6,9 @@
*******************************************************************************/ *******************************************************************************/
package com.ibm.wala.cast.java.test; 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.client.JavaSourceAnalysisEngine;
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope; import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
import com.ibm.wala.cast.java.translator.polyglot.PolyglotJavaSourceAnalysisEngine; 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 { public class PolyglotJLexTest extends JLexTest {
@Override @Override
protected JavaSourceAnalysisEngine getAnalysisEngine(final String[] mainClassDescriptors) { protected JavaSourceAnalysisEngine getAnalysisEngine(final String[] mainClassDescriptors, Collection<String> sources, List<String> libs) {
JavaSourceAnalysisEngine engine = new PolyglotJavaSourceAnalysisEngine() { JavaSourceAnalysisEngine engine = new PolyglotJavaSourceAnalysisEngine() {
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) { protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha, new String[] { "LJLex/Main" }); return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha, new String[] { "LJLex/Main" });
} }
}; };
engine.setExclusionsFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS); engine.setExclusionsFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS);
populateScope(engine, sources, libs);
return engine; return engine;
} }

View File

@ -6,9 +6,13 @@
*******************************************************************************/ *******************************************************************************/
package com.ibm.wala.cast.java.test; 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.client.JavaSourceAnalysisEngine;
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope; import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
import com.ibm.wala.cast.java.translator.polyglot.PolyglotJavaSourceAnalysisEngine; 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.core.tests.callGraph.CallGraphTestUtil;
import com.ibm.wala.ipa.callgraph.AnalysisScope; import com.ibm.wala.ipa.callgraph.AnalysisScope;
import com.ibm.wala.ipa.callgraph.Entrypoint; import com.ibm.wala.ipa.callgraph.Entrypoint;
@ -22,13 +26,14 @@ public class PolyglotJavaIRTests extends JavaIRTests {
} }
@Override @Override
protected JavaSourceAnalysisEngine getAnalysisEngine(final String[] mainClassDescriptors) { protected AbstractAnalysisEngine getAnalysisEngine(final String[] mainClassDescriptors, Collection<String> sources, List<String> libs) {
JavaSourceAnalysisEngine engine = new PolyglotJavaSourceAnalysisEngine() { JavaSourceAnalysisEngine engine = new PolyglotJavaSourceAnalysisEngine() {
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) { protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha, mainClassDescriptors); return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha, mainClassDescriptors);
} }
}; };
engine.setExclusionsFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS); engine.setExclusionsFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS);
populateScope(engine, sources, libs);
return engine; return engine;
} }

View File

@ -6,6 +6,9 @@
*******************************************************************************/ *******************************************************************************/
package com.ibm.wala.cast.java.test; 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.client.JavaSourceAnalysisEngine;
import com.ibm.wala.cast.java.examples.ast.SynchronizedBlockDuplicator; import com.ibm.wala.cast.java.examples.ast.SynchronizedBlockDuplicator;
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope; 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.JavaIRTranslatorExtension;
import com.ibm.wala.cast.java.translator.polyglot.PolyglotJavaSourceAnalysisEngine; import com.ibm.wala.cast.java.translator.polyglot.PolyglotJavaSourceAnalysisEngine;
import com.ibm.wala.cast.tree.CAst; import com.ibm.wala.cast.tree.CAst;
import com.ibm.wala.cast.tree.impl.CAstRewriter; import com.ibm.wala.cast.tree.rewrite.CAstRewriter;
import com.ibm.wala.cast.tree.impl.CAstRewriterFactory; import com.ibm.wala.cast.tree.rewrite.CAstRewriterFactory;
import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
import com.ibm.wala.ipa.callgraph.AnalysisScope; import com.ibm.wala.ipa.callgraph.AnalysisScope;
import com.ibm.wala.ipa.callgraph.Entrypoint; import com.ibm.wala.ipa.callgraph.Entrypoint;
@ -23,7 +26,7 @@ import com.ibm.wala.ipa.cha.IClassHierarchy;
public class PolyglotSyncDuplicatorTest extends SyncDuplicatorTest { 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() { JavaSourceAnalysisEngine engine = new PolyglotJavaSourceAnalysisEngine() {
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) { protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha, mainClassDescriptors); return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha, mainClassDescriptors);
@ -41,6 +44,7 @@ public class PolyglotSyncDuplicatorTest extends SyncDuplicatorTest {
}; };
engine.setExclusionsFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS); engine.setExclusionsFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS);
populateScope(engine, sources, libs);
return engine; return engine;
} }

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="source"/> <classpathentry kind="src" path="source"/>
<classpathentry kind="lib" path="lib/polyglot.jar"/> <classpathentry exported="true" kind="lib" path="lib/polyglot.jar"/>
<classpathentry kind="lib" path="lib/java_cup.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.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="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>

View File

@ -1,4 +1,4 @@
#Mon Apr 13 15:38:50 EDT 2009 #Mon Apr 13 15:38:50 EDT 2009
eclipse.preferences.version=1 eclipse.preferences.version=1
formatter_profile=_WALA formatter_profile=_WALA
formatter_settings_version=11 formatter_settings_version=11

View File

@ -3,7 +3,6 @@ Bundle-ManifestVersion: 2
Bundle-Name: WALA CAst Java Polyglot Plug-in Bundle-Name: WALA CAst Java Polyglot Plug-in
Bundle-SymbolicName: com.ibm.wala.cast.java.polyglot Bundle-SymbolicName: com.ibm.wala.cast.java.polyglot
Bundle-Version: 1.0.0 Bundle-Version: 1.0.0
Bundle-Activator: com.ibm.wala.cast.java.polyglot.Activator
Bundle-Vendor: IBM Bundle-Vendor: IBM
Require-Bundle: com.ibm.wala.cast.java, Require-Bundle: com.ibm.wala.cast.java,
com.ibm.wala.cast, com.ibm.wala.cast,
@ -11,13 +10,10 @@ Require-Bundle: com.ibm.wala.cast.java,
org.eclipse.core.runtime, org.eclipse.core.runtime,
com.ibm.wala.shrike, com.ibm.wala.shrike,
org.eclipse.jdt.core, org.eclipse.jdt.core,
org.eclipse.core.resources, org.eclipse.core.resources
com.ibm.wala.ide
Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Export-Package: com.ibm.wala.cast.java.client.polyglot, Export-Package: com.ibm.wala.cast.java.translator.polyglot;
com.ibm.wala.cast.java.polyglot;uses:="org.osgi.framework,org.eclipse.core.runtime",
com.ibm.wala.cast.java.translator.polyglot;
uses:="com.ibm.wala.types, uses:="com.ibm.wala.types,
polyglot.types, polyglot.types,
polyglot.util, polyglot.util,
@ -32,4 +28,21 @@ Export-Package: com.ibm.wala.cast.java.client.polyglot,
polyglot.frontend.goals, polyglot.frontend.goals,
com.ibm.wala.cast.tree.impl, com.ibm.wala.cast.tree.impl,
com.ibm.wala.cast.java.translator, 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,
.

View File

@ -1,4 +1,6 @@
source.. = source/ source.. = source/
output.. = bin/ output.. = bin/
bin.includes = META-INF/,\ bin.includes = META-INF/,\
. .,\
lib/java_cup.jar,\
lib/polyglot.jar

View File

@ -1,77 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project name="com.ibm.wala.cast.java.polyglot" default="getJars" basedir="."> <project name="com.ibm.wala.cast.java.polyglot" default="getJars" basedir=".">
<property name="basews" value="${ws}"/> <property name="basews" value="${ws}"/>
<property name="baseos" value="${os}"/> <property name="baseos" value="${os}"/>
<property name="basearch" value="${arch}"/> <property name="basearch" value="${arch}"/>
<property name="basenl" value="${nl}"/> <property name="basenl" value="${nl}"/>
<!-- Compiler settings. --> <!-- Compiler settings. -->
<property name="javacFailOnError" value="true"/> <property name="javacFailOnError" value="true"/>
<property name="javacDebugInfo" value="on"/> <property name="javacDebugInfo" value="on"/>
<property name="javacVerbose" value="false"/> <property name="javacVerbose" value="false"/>
<property name="logExtension" value=".log"/> <property name="logExtension" value=".log"/>
<property name="compilerArg" value=""/> <property name="compilerArg" value=""/>
<property name="javacSource" value="1.5"/> <property name="javacSource" value="1.5"/>
<property name="javacTarget" 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 <!-- 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, 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" --> try changing the value of the property to "${java.home}/../../../Classes" -->
<condition property="dir_bootclasspath" value="${java.home}/../Classes"> <condition property="dir_bootclasspath" value="${java.home}/../Classes">
<os family="mac"/> <os family="mac"/>
</condition> </condition>
<property name="dir_bootclasspath" value="${java.home}/lib"/> <property name="dir_bootclasspath" value="${java.home}/lib"/>
<path id="path_bootclasspath"> <path id="path_bootclasspath">
<fileset dir="${dir_bootclasspath}"> <fileset dir="${dir_bootclasspath}">
<include name="*.jar"/> <include name="*.jar"/>
</fileset> </fileset>
</path> </path>
<property name="bootclasspath" refid="path_bootclasspath"/> <property name="bootclasspath" refid="path_bootclasspath"/>
<property name="bundleJavacSource" value="${javacSource}"/> <property name="bundleJavacSource" value="${javacSource}"/>
<property name="bundleJavacTarget" value="${javacTarget}"/> <property name="bundleJavacTarget" value="${javacTarget}"/>
<property name="bundleBootClasspath" value="${bootclasspath}"/> <property name="bundleBootClasspath" value="${bootclasspath}"/>
<target name="PolyglotPresent" depends="init"> <target name="PolyglotPresent" depends="init">
<available file="${plugin.destination}/lib/polyglot.jar" property="polyglot.present"/> <available file="${plugin.destination}/lib/polyglot.jar" property="polyglot.present"/>
</target> </target>
<target name="fetchPolyglot" depends="PolyglotPresent" unless="polyglot.present"> <target name="fetchPolyglot" depends="PolyglotPresent" unless="polyglot.present">
<delete dir="${temp.folder}"/> <delete dir="${temp.folder}"/>
<mkdir dir="${temp.folder}"/> <mkdir dir="${temp.folder}"/>
<echo message="Getting polyglot from svn; may take a few minutes"/> <echo message="Getting polyglot from svn; may take a few minutes"/>
<exec executable="svn" <exec executable="svn"
dir="${temp.folder}"> dir="${temp.folder}">
<arg value="--quiet"/> <arg value="--quiet"/>
<arg value="checkout"/> <arg value="checkout"/>
<arg value="http://polyglot-compiler.googlecode.com/svn/trunk/"/> <arg value="http://polyglot-compiler.googlecode.com/svn/trunk/"/>
<arg value="polyglot-compiler-read-only"/> <arg value="polyglot-compiler-read-only"/>
</exec> </exec>
<ant target="jar" inheritAll="false" dir="${temp.folder}/polyglot-compiler-read-only/polyglot/" /> <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/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" /> <copy file="${temp.folder}/polyglot-compiler-read-only/polyglot/lib/java_cup.jar" tofile="${plugin.destination}/lib/java_cup.jar" />
<delete dir="${temp.folder}"/> <delete dir="${temp.folder}"/>
</target> </target>
<target name="getJars" depends="fetchPolyglot" /> <target name="getJars" depends="fetchPolyglot" />
<target name="init" depends="properties"> <target name="init" depends="properties">
<condition property="pluginTemp" value="${buildTempFolder}/plugins"> <condition property="pluginTemp" value="${buildTempFolder}/plugins">
<isset property="buildTempFolder"/> <isset property="buildTempFolder"/>
</condition> </condition>
<property name="pluginTemp" value="${basedir}"/> <property name="pluginTemp" value="${basedir}"/>
<condition property="build.result.folder" value="${pluginTemp}/com.ibm.wala.core.testdata"> <condition property="build.result.folder" value="${pluginTemp}/com.ibm.wala.core.testdata">
<isset property="buildTempFolder"/> <isset property="buildTempFolder"/>
</condition> </condition>
<property name="build.result.folder" value="${basedir}"/> <property name="build.result.folder" value="${basedir}"/>
<property name="temp.folder" value="${basedir}/temp.folder"/> <property name="temp.folder" value="${basedir}/temp.folder"/>
<property name="plugin.destination" value="${basedir}"/> <property name="plugin.destination" value="${basedir}"/>
</target> </target>
<target name="properties" if="eclipse.running"> <target name="properties" if="eclipse.running">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/> <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
</target> </target>
</project> </project>

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -13,7 +13,7 @@
*/ */
package com.ibm.wala.cast.java.translator.polyglot; 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 { public interface IRTranslatorExtension {
void setSourceLoader(PolyglotSourceLoaderImpl jsli); void setSourceLoader(PolyglotSourceLoaderImpl jsli);

View File

@ -21,7 +21,7 @@ import polyglot.frontend.JLScheduler;
import polyglot.frontend.Job; import polyglot.frontend.Job;
import polyglot.frontend.Scheduler; 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 * A Polyglot extension descriptor for a test harness extension that generates WALA IR for

View File

@ -17,11 +17,11 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import com.ibm.wala.classLoader.SourceModule;
import polyglot.frontend.FileSource; import polyglot.frontend.FileSource;
import polyglot.frontend.Resource; import polyglot.frontend.Resource;
import com.ibm.wala.classLoader.SourceModule;
/** /**
* A Polyglot Source whose input comes from an InputStream.<br> * A Polyglot Source whose input comes from an InputStream.<br>
* Currently extends FileSource since that's all that the Polyglot Compiler class * Currently extends FileSource since that's all that the Polyglot Compiler class

View File

@ -1,229 +1,229 @@
/** /**
* *
*/ */
package com.ibm.wala.cast.java.translator.polyglot; package com.ibm.wala.cast.java.translator.polyglot;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import polyglot.types.ArrayType; import polyglot.types.ArrayType;
import polyglot.types.ClassType; import polyglot.types.ClassType;
import polyglot.types.CodeInstance; import polyglot.types.CodeInstance;
import polyglot.types.ConstructorInstance; import polyglot.types.ConstructorInstance;
import polyglot.types.FieldInstance; import polyglot.types.FieldInstance;
import polyglot.types.InitializerInstance; import polyglot.types.InitializerInstance;
import polyglot.types.MemberDef; import polyglot.types.MemberDef;
import polyglot.types.MethodInstance; import polyglot.types.MethodInstance;
import polyglot.types.PrimitiveType; import polyglot.types.PrimitiveType;
import polyglot.types.ProcedureInstance; import polyglot.types.ProcedureInstance;
import polyglot.types.Type; import polyglot.types.Type;
import com.ibm.wala.cast.java.translator.polyglot.PolyglotJava2CAstTranslator.IdentityMapper; import com.ibm.wala.cast.java.translator.polyglot.PolyglotJava2CAstTranslator.IdentityMapper;
import com.ibm.wala.cast.java.types.JavaPrimitiveTypeMap; import com.ibm.wala.cast.java.types.JavaPrimitiveTypeMap;
import com.ibm.wala.types.ClassLoaderReference; import com.ibm.wala.types.ClassLoaderReference;
import com.ibm.wala.types.Descriptor; import com.ibm.wala.types.Descriptor;
import com.ibm.wala.types.FieldReference; import com.ibm.wala.types.FieldReference;
import com.ibm.wala.types.MethodReference; import com.ibm.wala.types.MethodReference;
import com.ibm.wala.types.Selector; import com.ibm.wala.types.Selector;
import com.ibm.wala.types.TypeName; import com.ibm.wala.types.TypeName;
import com.ibm.wala.types.TypeReference; import com.ibm.wala.types.TypeReference;
import com.ibm.wala.util.collections.HashMapFactory; import com.ibm.wala.util.collections.HashMapFactory;
import com.ibm.wala.util.debug.Assertions; import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.strings.Atom; import com.ibm.wala.util.strings.Atom;
/** /**
* Class responsible for mapping Polyglot type system objects representing types, * Class responsible for mapping Polyglot type system objects representing types,
* methods and fields to the corresponding WALA TypeReferences, MethodReferences * methods and fields to the corresponding WALA TypeReferences, MethodReferences
* and FieldReferences. Used during translation and by clients to help correlate * and FieldReferences. Used during translation and by clients to help correlate
* WALA analysis results to the various AST nodes. * WALA analysis results to the various AST nodes.
* @author rfuhrer * @author rfuhrer
*/ */
public class PolyglotIdentityMapper implements IdentityMapper<Type, CodeInstance, FieldInstance> { public class PolyglotIdentityMapper implements IdentityMapper<Type, CodeInstance, FieldInstance> {
private final Map<Type, TypeReference> fTypeMap = HashMapFactory.make(); private final Map<Type, TypeReference> fTypeMap = HashMapFactory.make();
private final Map<FieldInstance, FieldReference> fFieldMap = HashMapFactory.make(); private final Map<FieldInstance, FieldReference> fFieldMap = HashMapFactory.make();
private final Map<CodeInstance, MethodReference> fMethodMap = HashMapFactory.make(); private final Map<CodeInstance, MethodReference> fMethodMap = HashMapFactory.make();
/** /**
* Map from Polyglot local ClassTypes to their enclosing methods. Used by localTypeToTypeID().<br> * 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 * 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 * 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 * 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.) * create back-pointers from Type objects in the TypeSystem to AST's.)
*/ */
protected Map<ClassType, CodeInstance> fLocalTypeMap = new LinkedHashMap<ClassType, CodeInstance>(); protected Map<ClassType, CodeInstance> fLocalTypeMap = new LinkedHashMap<ClassType, CodeInstance>();
protected final ClassLoaderReference fClassLoaderRef; protected final ClassLoaderReference fClassLoaderRef;
public PolyglotIdentityMapper(ClassLoaderReference clr) { public PolyglotIdentityMapper(ClassLoaderReference clr) {
fClassLoaderRef= clr; fClassLoaderRef= clr;
} }
public FieldReference getFieldRef(FieldInstance field) { public FieldReference getFieldRef(FieldInstance field) {
if (!fFieldMap.containsKey(field)) { if (!fFieldMap.containsKey(field)) {
FieldReference ref= referenceForField(field); FieldReference ref= referenceForField(field);
fFieldMap.put(field, ref); fFieldMap.put(field, ref);
return ref; return ref;
} }
return fFieldMap.get(field); return fFieldMap.get(field);
} }
public TypeReference getTypeRef(Type type) { public TypeReference getTypeRef(Type type) {
if (!fTypeMap.containsKey(type)) { if (!fTypeMap.containsKey(type)) {
TypeReference ref= referenceForType(type); TypeReference ref= referenceForType(type);
fTypeMap.put(type, ref); fTypeMap.put(type, ref);
return ref; return ref;
} }
return fTypeMap.get(type); return fTypeMap.get(type);
} }
public MethodReference getMethodRef(CodeInstance method) { public MethodReference getMethodRef(CodeInstance method) {
if (!fMethodMap.containsKey(method)) { if (!fMethodMap.containsKey(method)) {
MethodReference sel= referenceForMethod(method); MethodReference sel= referenceForMethod(method);
fMethodMap.put(method, sel); fMethodMap.put(method, sel);
return sel; return sel;
} }
return fMethodMap.get(method); return fMethodMap.get(method);
} }
public void mapLocalAnonTypeToMethod(ClassType anonLocalType, CodeInstance owningProc) { public void mapLocalAnonTypeToMethod(ClassType anonLocalType, CodeInstance owningProc) {
fLocalTypeMap.put(anonLocalType, owningProc); fLocalTypeMap.put(anonLocalType, owningProc);
} }
/** /**
* Create a FieldReference for the given Polyglot FieldInstance.<br> * Create a FieldReference for the given Polyglot FieldInstance.<br>
* N.B.: This method <b>does not canonicalize</b> the FieldReferences, * N.B.: This method <b>does not canonicalize</b> the FieldReferences,
* but rather creates a new one for each call. * but rather creates a new one for each call.
* You more likely want to call getFieldRef(). This method is exposed * You more likely want to call getFieldRef(). This method is exposed
* so that multiple Polyglot instances can use the translation services * so that multiple Polyglot instances can use the translation services
* without having FieldInstances collide (producing the dreaded "we are * without having FieldInstances collide (producing the dreaded "we are
* TypeSystem_c but type Foo is from TypeSystem_c" exception). * TypeSystem_c but type Foo is from TypeSystem_c" exception).
*/ */
public FieldReference referenceForField(FieldInstance field) { public FieldReference referenceForField(FieldInstance field) {
Type targetType= field.container(); Type targetType= field.container();
Type fieldType= field.type(); Type fieldType= field.type();
TypeReference targetTypeRef= TypeReference.findOrCreate(fClassLoaderRef, typeToTypeID(targetType)); TypeReference targetTypeRef= TypeReference.findOrCreate(fClassLoaderRef, typeToTypeID(targetType));
TypeReference fieldTypeRef= TypeReference.findOrCreate(fClassLoaderRef, typeToTypeID(fieldType)); TypeReference fieldTypeRef= TypeReference.findOrCreate(fClassLoaderRef, typeToTypeID(fieldType));
Atom fieldName= Atom.findOrCreateUnicodeAtom(field.name().toString()); Atom fieldName= Atom.findOrCreateUnicodeAtom(field.name().toString());
FieldReference fieldRef= FieldReference.findOrCreate(targetTypeRef, fieldName, fieldTypeRef); FieldReference fieldRef= FieldReference.findOrCreate(targetTypeRef, fieldName, fieldTypeRef);
return fieldRef; return fieldRef;
} }
/** /**
* Create a TypeReference for the given Polyglot Type.<br> * Create a TypeReference for the given Polyglot Type.<br>
* N.B.: This method <b>does not canonicalize</b> the TypeReferences, * N.B.: This method <b>does not canonicalize</b> the TypeReferences,
* but rather creates a new one for each call. * but rather creates a new one for each call.
* You more likely want to call getTypeRef(). This method is exposed * You more likely want to call getTypeRef(). This method is exposed
* so that multiple Polyglot instances can use the translation services * so that multiple Polyglot instances can use the translation services
* without having Types collide (producing the dreaded "we are * without having Types collide (producing the dreaded "we are
* TypeSystem_c but type Foo is from TypeSystem_c" exception). * TypeSystem_c but type Foo is from TypeSystem_c" exception).
*/ */
public TypeReference referenceForType(Type type) { public TypeReference referenceForType(Type type) {
TypeName typeName= TypeName.string2TypeName(typeToTypeID(type)); TypeName typeName= TypeName.string2TypeName(typeToTypeID(type));
TypeReference typeRef= TypeReference.findOrCreate(fClassLoaderRef, typeName); TypeReference typeRef= TypeReference.findOrCreate(fClassLoaderRef, typeName);
return typeRef; return typeRef;
} }
private Selector selectorForMethod(CodeInstance procInstance) { private Selector selectorForMethod(CodeInstance procInstance) {
Atom name= Atom name=
(procInstance instanceof ConstructorInstance) ? (procInstance instanceof ConstructorInstance) ?
MethodReference.initAtom : MethodReference.initAtom :
(procInstance instanceof InitializerInstance) ? (procInstance instanceof InitializerInstance) ?
MethodReference.clinitName : MethodReference.clinitName :
Atom.findOrCreateUnicodeAtom(((MethodInstance) procInstance).name().toString()); Atom.findOrCreateUnicodeAtom(((MethodInstance) procInstance).name().toString());
TypeName[] argTypeNames = null; TypeName[] argTypeNames = null;
if (! (procInstance instanceof InitializerInstance)) { if (! (procInstance instanceof InitializerInstance)) {
List formalTypes = ((ProcedureInstance)procInstance).formalTypes(); List formalTypes = ((ProcedureInstance)procInstance).formalTypes();
int numArgs = formalTypes.size(); int numArgs = formalTypes.size();
// Descriptor prefers null to an empty array // Descriptor prefers null to an empty array
if (numArgs > 0) { if (numArgs > 0) {
argTypeNames = new TypeName[numArgs]; argTypeNames = new TypeName[numArgs];
int i = 0; int i = 0;
for(Iterator iter = formalTypes.iterator(); iter.hasNext(); i++) { for(Iterator iter = formalTypes.iterator(); iter.hasNext(); i++) {
Type argType= (Type) iter.next(); Type argType= (Type) iter.next();
argTypeNames[i]= TypeName.string2TypeName(typeToTypeID(argType)); argTypeNames[i]= TypeName.string2TypeName(typeToTypeID(argType));
} }
} }
} }
Type retType= Type retType=
(procInstance instanceof MethodInstance) ? ((MethodInstance) procInstance).returnType() : procInstance.typeSystem().Void(); (procInstance instanceof MethodInstance) ? ((MethodInstance) procInstance).returnType() : procInstance.typeSystem().Void();
TypeName retTypeName= TypeName.string2TypeName(typeToTypeID(retType)); TypeName retTypeName= TypeName.string2TypeName(typeToTypeID(retType));
Descriptor desc= Descriptor.findOrCreate(argTypeNames, retTypeName); Descriptor desc= Descriptor.findOrCreate(argTypeNames, retTypeName);
return new Selector(name, desc); return new Selector(name, desc);
} }
/** /**
* Create a MethodReference for the given Polyglot MethodInstance.<br> * Create a MethodReference for the given Polyglot MethodInstance.<br>
* N.B.: This method <b>does not canonicalize</b> the MethodReferences, * N.B.: This method <b>does not canonicalize</b> the MethodReferences,
* but rather creates a new one for each call. * but rather creates a new one for each call.
* You more likely want to call getMethodRef(). This method is exposed * You more likely want to call getMethodRef(). This method is exposed
* so that multiple Polyglot instances can use the translation services * so that multiple Polyglot instances can use the translation services
* without having MethodInstances collide (producing the dreaded "we are * without having MethodInstances collide (producing the dreaded "we are
* TypeSystem_c but type Foo is from TypeSystem_c" exception). * TypeSystem_c but type Foo is from TypeSystem_c" exception).
*/ */
public MethodReference referenceForMethod(CodeInstance procInstance) { public MethodReference referenceForMethod(CodeInstance procInstance) {
// Handles both ConstructorInstance's and MethodInstance's // Handles both ConstructorInstance's and MethodInstance's
TypeName ownerType= TypeName.string2TypeName(typeToTypeID(((MemberDef) procInstance.def()).container().get())); TypeName ownerType= TypeName.string2TypeName(typeToTypeID(((MemberDef) procInstance.def()).container().get()));
TypeReference ownerTypeRef= TypeReference.findOrCreate(fClassLoaderRef, ownerType); TypeReference ownerTypeRef= TypeReference.findOrCreate(fClassLoaderRef, ownerType);
MethodReference methodRef= MethodReference.findOrCreate(ownerTypeRef, selectorForMethod(procInstance)); MethodReference methodRef= MethodReference.findOrCreate(ownerTypeRef, selectorForMethod(procInstance));
return methodRef; return methodRef;
} }
/** /**
* Translates the given Polyglot type to a name suitable for use in a WALA TypeReference * Translates the given Polyglot type to a name suitable for use in a WALA TypeReference
* (i.e. a bytecode-compliant type name). * (i.e. a bytecode-compliant type name).
*/ */
public String typeToTypeID(Type type) { public String typeToTypeID(Type type) {
if (type.isPrimitive()) { if (type.isPrimitive()) {
PrimitiveType ptype= (PrimitiveType) type; PrimitiveType ptype= (PrimitiveType) type;
return JavaPrimitiveTypeMap.getShortName(ptype.name().toString()); return JavaPrimitiveTypeMap.getShortName(ptype.name().toString());
} else if (type.isArray()) { } else if (type.isArray()) {
ArrayType atype= (ArrayType) type; ArrayType atype= (ArrayType) type;
return "[" + typeToTypeID(atype.base()); return "[" + typeToTypeID(atype.base());
} else if (type.isNull()) { } else if (type.isNull()) {
Assertions.UNREACHABLE("typeToTypeID() encountered a null type!"); Assertions.UNREACHABLE("typeToTypeID() encountered a null type!");
return null; return null;
} }
Assertions.productionAssertion(type.isClass(), "typeToTypeID() encountered the type " + type + " that is neither primitive, array, nor class!"); Assertions.productionAssertion(type.isClass(), "typeToTypeID() encountered the type " + type + " that is neither primitive, array, nor class!");
ClassType ctype= (ClassType) type; ClassType ctype= (ClassType) type;
return (ctype.isLocal() || ctype.isAnonymous()) ? anonLocalTypeToTypeID(ctype) : composeWALATypeDescriptor(ctype); return (ctype.isLocal() || ctype.isAnonymous()) ? anonLocalTypeToTypeID(ctype) : composeWALATypeDescriptor(ctype);
} }
public String anonLocalTypeToTypeID(ClassType ctype) { public String anonLocalTypeToTypeID(ClassType ctype) {
CodeInstance procInstance= (CodeInstance) fLocalTypeMap.get(ctype); CodeInstance procInstance= (CodeInstance) fLocalTypeMap.get(ctype);
String outerTypeID= typeToTypeID(ctype.outer()); String outerTypeID= typeToTypeID(ctype.outer());
String shortName= (ctype.isAnonymous()) ? PolyglotJava2CAstTranslator.anonTypeName(ctype) : ctype.fullName().name().toString(); String shortName= (ctype.isAnonymous()) ? PolyglotJava2CAstTranslator.anonTypeName(ctype) : ctype.fullName().name().toString();
return outerTypeID + '/' + getMethodRef(procInstance).getSelector() + '/' + shortName; return outerTypeID + '/' + getMethodRef(procInstance).getSelector() + '/' + shortName;
} }
public String composeWALATypeDescriptor(ClassType ctype) { public String composeWALATypeDescriptor(ClassType ctype) {
return "L" + composeWALATypeName(ctype); return "L" + composeWALATypeName(ctype);
} }
public String composeWALATypeName(ClassType ctype) { public String composeWALATypeName(ClassType ctype) {
if (ctype.package_() != null) { if (ctype.package_() != null) {
String packageName = ctype.package_().fullName().toString(); String packageName = ctype.package_().fullName().toString();
Assertions.productionAssertion(ctype.fullName().toString().startsWith(packageName)); Assertions.productionAssertion(ctype.fullName().toString().startsWith(packageName));
return packageName.replace('.','/') + "/" + ctype.fullName().toString().substring( packageName.length()+1 ).replace('.','$'); return packageName.replace('.','/') + "/" + ctype.fullName().toString().substring( packageName.length()+1 ).replace('.','$');
} else { } else {
return ctype.fullName().toString().replace('.', '$'); return ctype.fullName().toString().replace('.', '$');
} }
} }
} }

View File

@ -120,7 +120,6 @@ import polyglot.util.Position;
import com.ibm.wala.cast.ir.translator.AstTranslator.InternalCAstSymbol; 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;
import com.ibm.wala.cast.ir.translator.TranslatorToCAst.DoLoopTranslator; 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.loader.Util;
import com.ibm.wala.cast.java.translator.JavaProcedureEntity; import com.ibm.wala.cast.java.translator.JavaProcedureEntity;
import com.ibm.wala.cast.java.types.JavaType; import com.ibm.wala.cast.java.types.JavaType;

View File

@ -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);
}
};
}
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <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="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@ -1,6 +1,6 @@
java\/awt\/.* java\/awt\/.*
javax\/swing\/.* javax\/swing\/.*
sun\/awt\/.* sun\/awt\/.*
sun\/swing\/.* sun\/swing\/.*
com\/sun\/.* com\/sun\/.*
sun\/.* sun\/.*

View File

@ -3,8 +3,6 @@ Bundle-ManifestVersion: 2
Bundle-Name: Data Plug-in Bundle-Name: Data Plug-in
Bundle-SymbolicName: com.ibm.wala.cast.java.test.data Bundle-SymbolicName: com.ibm.wala.cast.java.test.data
Bundle-Version: 1.0.0 Bundle-Version: 1.0.0
Bundle-Activator: com.ibm.wala.cast.java.test.data.Activator
Bundle-Vendor: IBM Bundle-Vendor: IBM
Require-Bundle: org.eclipse.core.runtime
Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy

View File

@ -1,89 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project name="com.ibm.wala.cast.java.test.data" default="getSources" basedir="."> <project name="com.ibm.wala.cast.java.test.data" default="getSources" basedir=".">
<property name="basews" value="${ws}"/> <property name="basews" value="${ws}"/>
<property name="baseos" value="${os}"/> <property name="baseos" value="${os}"/>
<property name="basearch" value="${arch}"/> <property name="basearch" value="${arch}"/>
<property name="basenl" value="${nl}"/> <property name="basenl" value="${nl}"/>
<!-- Compiler settings. --> <!-- Compiler settings. -->
<property name="javacFailOnError" value="true"/> <property name="javacFailOnError" value="true"/>
<property name="javacDebugInfo" value="on"/> <property name="javacDebugInfo" value="on"/>
<property name="javacVerbose" value="false"/> <property name="javacVerbose" value="false"/>
<property name="logExtension" value=".log"/> <property name="logExtension" value=".log"/>
<property name="compilerArg" value=""/> <property name="compilerArg" value=""/>
<property name="javacSource" value="1.5"/> <property name="javacSource" value="1.5"/>
<property name="javacTarget" 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 <!-- 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, 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" --> try changing the value of the property to "${java.home}/../../../Classes" -->
<condition property="dir_bootclasspath" value="${java.home}/../Classes"> <condition property="dir_bootclasspath" value="${java.home}/../Classes">
<os family="mac"/> <os family="mac"/>
</condition> </condition>
<property name="dir_bootclasspath" value="${java.home}/lib"/> <property name="dir_bootclasspath" value="${java.home}/lib"/>
<path id="path_bootclasspath"> <path id="path_bootclasspath">
<fileset dir="${dir_bootclasspath}"> <fileset dir="${dir_bootclasspath}">
<include name="*.jar"/> <include name="*.jar"/>
</fileset> </fileset>
</path> </path>
<property name="bootclasspath" refid="path_bootclasspath"/> <property name="bootclasspath" refid="path_bootclasspath"/>
<property name="bundleJavacSource" value="${javacSource}"/> <property name="bundleJavacSource" value="${javacSource}"/>
<property name="bundleJavacTarget" value="${javacTarget}"/> <property name="bundleJavacTarget" value="${javacTarget}"/>
<property name="bundleBootClasspath" value="${bootclasspath}"/> <property name="bundleBootClasspath" value="${bootclasspath}"/>
<target name="JLexPresent" depends="init"> <target name="JLexPresent" depends="init">
<available file="${plugin.destination}/src/JLex/Main.java" property="jlex.present"/> <available file="${plugin.destination}/src/JLex/Main.java" property="jlex.present"/>
</target> </target>
<target name="fetchJLex" depends="JLexPresent" unless="jlex.present"> <target name="fetchJLex" depends="JLexPresent" unless="jlex.present">
<delete dir="${temp.folder}"/> <delete dir="${temp.folder}"/>
<mkdir dir="${temp.folder}/JLex"/> <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"/> <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"/> <delete dir="${plugin.destination}/src/JLex"/>
<mkdir 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"/> <copy file="${temp.folder}/JLex/Main.java" tofile="${plugin.destination}/src/JLex/Main.java"/>
<delete dir="${temp.folder}"/> <delete dir="${temp.folder}"/>
</target> </target>
<target name="getSources" depends="fetchJLex" /> <target name="getSources" depends="fetchJLex" />
<target name="testdatadir" depends="init,testdata.exists" unless="testdatadir.present"> <target name="testdatadir" depends="init,testdata.exists" unless="testdatadir.present">
<mkdir dir="${basedir}/../com.ibm.wala.cast.java.test/testdata"/> <mkdir dir="${basedir}/../com.ibm.wala.cast.java.test/testdata"/>
</target> </target>
<target name="testdata.exists" depends="init"> <target name="testdata.exists" depends="init">
<available file="${basedir}/../com.ibm.wala.cast.java.test/testdata" <available file="${basedir}/../com.ibm.wala.cast.java.test/testdata"
type="dir" type="dir"
property="testdatadir.present"/> property="testdatadir.present"/>
</target> </target>
<target name="compile" depends="getSources"> <target name="compile" depends="getSources">
<javac srcdir="${basedir}/src" <javac srcdir="${basedir}/src"
destdir="${basedir}/bin" destdir="${basedir}/bin"
excludes="**/Activator.java"/> excludes="**/Activator.java"/>
</target> </target>
<target name="jar" depends="compile,testdatadir"> <target name="jar" depends="compile,testdatadir">
<jar destfile="${basedir}/../com.ibm.wala.cast.java.test/testdata/test_project.zip" basedir="${basedir}"/> <jar destfile="${basedir}/../com.ibm.wala.cast.java.test/testdata/test_project.zip" basedir="${basedir}"/>
</target> </target>
<target name="init" depends="properties"> <target name="init" depends="properties">
<condition property="pluginTemp" value="${buildTempFolder}/plugins"> <condition property="pluginTemp" value="${buildTempFolder}/plugins">
<isset property="buildTempFolder"/> <isset property="buildTempFolder"/>
</condition> </condition>
<property name="pluginTemp" value="${basedir}"/> <property name="pluginTemp" value="${basedir}"/>
<condition property="build.result.folder" value="${pluginTemp}/com.ibm.wala.core.testdata"> <condition property="build.result.folder" value="${pluginTemp}/com.ibm.wala.core.testdata">
<isset property="buildTempFolder"/> <isset property="buildTempFolder"/>
</condition> </condition>
<property name="build.result.folder" value="${basedir}"/> <property name="build.result.folder" value="${basedir}"/>
<property name="temp.folder" value="${basedir}/temp.folder"/> <property name="temp.folder" value="${basedir}/temp.folder"/>
<property name="plugin.destination" value="${basedir}"/> <property name="plugin.destination" value="${basedir}"/>
</target> </target>
<target name="properties" if="eclipse.running"> <target name="properties" if="eclipse.running">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/> <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
</target> </target>
</project> </project>

View File

@ -47,17 +47,17 @@ package alreadywalaunittests;
// invariants and non-invariants (immediate 'new' in that function) // invariants and non-invariants (immediate 'new' in that function)
// subclasses // subclasses
public class InnerClassA { public class InnerClassAA {
int a_x; int a_x;
public static void main(String args[]) { public static void main(String args[]) {
// prints out 5 5 9 7 5 5 7 5 7 5 // prints out 5 5 9 7 5 5 7 5 7 5
InnerClassA a = new InnerClassA(); InnerClassAA a = new InnerClassAA();
a.doAllThis(); a.doAllThis();
} }
public void doAllThis() { public void doAllThis() {
InnerClassA a = this; InnerClassAA a = this;
AA aa = new AA(); AA aa = new AA();
aa = a.new AA(); aa = a.new AA();
AB ab = aa.makeAB(); AB ab = aa.makeAB();
@ -104,7 +104,7 @@ public class InnerClassA {
doMoreWithABSubA(absuba); doMoreWithABSubA(absuba);
} }
private void doMoreWithABSubA(InnerClassA.AB.ABSubA absuba) { private void doMoreWithABSubA(InnerClassAA.AB.ABSubA absuba) {
System.out.println(absuba.getA_X()); // 5 System.out.println(absuba.getA_X()); // 5
AB.ABSubA.ABSubAA absubaa = absuba.new ABSubAA(); AB.ABSubA.ABSubAA absubaa = absuba.new ABSubAA();

View File

@ -37,7 +37,7 @@
*/ */
package alreadywalaunittests; package alreadywalaunittests;
public class InnerClassSuper { public class InnerClassSuperA {
int x = 5; int x = 5;
class SuperOuter { class SuperOuter {
public void test() { public void test() {
@ -48,10 +48,10 @@ public class InnerClassSuper {
new Sub().new SubInner(); new Sub().new SubInner();
} }
} }
class Sub extends InnerClassSuper { class Sub extends InnerClassSuperA {
class SubInner { class SubInner {
public SubInner() { public SubInner() {
InnerClassSuper.SuperOuter so = new InnerClassSuper.SuperOuter(); InnerClassSuperA.SuperOuter so = new InnerClassSuperA.SuperOuter();
so.test(); so.test();
} }
} }

View File

@ -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;
}
}

View File

@ -37,7 +37,7 @@
*/ */
package foo.bar.hello.world; package foo.bar.hello.world;
public class MiniaturList { public class MiniaturList2 {
public static void main(String[] args) { public static void main(String[] args) {
int a; int a;

View File

@ -1,5 +1,5 @@
#Thu Jan 03 11:24:43 EST 2008 #Thu Jan 03 11:24:43 EST 2008
eclipse.preferences.version=1 eclipse.preferences.version=1
formatter_profile=_WALA formatter_profile=_WALA
formatter_settings_version=11 formatter_settings_version=11
instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true

View File

@ -1,17 +1,17 @@
Manifest-Version: 1.0 Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: Java AST WALA Test Plug-in Bundle-Name: Java AST WALA Test Plug-in
Bundle-SymbolicName: com.ibm.wala.cast.java.test Bundle-SymbolicName: com.ibm.wala.cast.java.test
Bundle-Version: 1.0.0 Bundle-Version: 1.0.0
Bundle-Activator: com.ibm.wala.cast.java.test.TestPlugin Bundle-Activator: com.ibm.wala.cast.java.test.TestPlugin
Bundle-Vendor: IBM Bundle-Vendor: IBM
Require-Bundle: org.junit4, Require-Bundle: org.junit4,
com.ibm.wala.core.tests, com.ibm.wala.core.tests,
com.ibm.wala.cast.java, com.ibm.wala.cast.java,
com.ibm.wala.cast, com.ibm.wala.cast,
com.ibm.wala.core, com.ibm.wala.core,
com.ibm.wala.shrike, com.ibm.wala.shrike,
org.eclipse.core.runtime org.eclipse.core.runtime
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Export-Package: com.ibm.wala.cast.java.test Export-Package: com.ibm.wala.cast.java.test
Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-RequiredExecutionEnvironment: J2SE-1.5

View File

@ -1,424 +1,447 @@
/****************************************************************************** /******************************************************************************
* Copyright (c) 2002 - 2006 IBM Corporation. * Copyright (c) 2002 - 2006 IBM Corporation.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
*****************************************************************************/ *****************************************************************************/
/* /*
* Created on Oct 3, 2005 * Created on Oct 3, 2005
*/ */
package com.ibm.wala.cast.java.test; package com.ibm.wala.cast.java.test;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import org.junit.Assert; import org.junit.Assert;
import com.ibm.wala.cast.java.client.JavaSourceAnalysisEngine; import com.ibm.wala.cast.java.client.JavaSourceAnalysisEngine;
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope; import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
import com.ibm.wala.classLoader.IClass; import com.ibm.wala.cast.loader.AstClass;
import com.ibm.wala.classLoader.IClassLoader; import com.ibm.wala.cast.loader.AstMethod;
import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.JarFileModule; import com.ibm.wala.classLoader.IClassLoader;
import com.ibm.wala.classLoader.Language; import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.classLoader.SourceDirectoryTreeModule; import com.ibm.wala.classLoader.JarFileModule;
import com.ibm.wala.classLoader.SourceFileModule; import com.ibm.wala.classLoader.Language;
import com.ibm.wala.ipa.callgraph.CGNode; import com.ibm.wala.classLoader.SourceDirectoryTreeModule;
import com.ibm.wala.ipa.callgraph.CallGraph; import com.ibm.wala.classLoader.SourceFileModule;
import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.client.AbstractAnalysisEngine;
import com.ibm.wala.properties.WalaProperties; import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ssa.IR; import com.ibm.wala.ipa.callgraph.CallGraph;
import com.ibm.wala.ssa.SSAInstruction; import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.types.ClassLoaderReference; import com.ibm.wala.properties.WalaProperties;
import com.ibm.wala.types.MethodReference; import com.ibm.wala.ssa.IR;
import com.ibm.wala.types.TypeName; import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.types.TypeReference; import com.ibm.wala.types.ClassLoaderReference;
import com.ibm.wala.util.collections.HashSetFactory; import com.ibm.wala.types.MethodReference;
import com.ibm.wala.util.collections.Pair; import com.ibm.wala.types.TypeName;
import com.ibm.wala.util.debug.Assertions; import com.ibm.wala.types.TypeReference;
import com.ibm.wala.util.strings.Atom; import com.ibm.wala.util.CancelException;
import com.ibm.wala.util.collections.HashSetFactory;
public abstract class IRTests { import com.ibm.wala.util.collections.Pair;
import com.ibm.wala.util.debug.Assertions;
protected IRTests(String projectName) { import com.ibm.wala.util.strings.Atom;
this.projectName = projectName;
} public abstract class IRTests {
protected final String projectName; protected IRTests(String projectName) {
this.projectName = projectName;
protected static String javaHomePath; }
private String testSrcPath = "." + File.separator + "src"; protected final String projectName;
public static List<String> rtJar; protected static String javaHomePath;
protected static List<IRAssertion> emptyList = Collections.emptyList(); private String testSrcPath = "." + File.separator + "src";
static { public static List<String> rtJar;
boolean found = false;
try { protected static List<IRAssertion> emptyList = Collections.emptyList();
rtJar = new LinkedList<String>();
static {
Properties p = WalaProperties.loadProperties(); boolean found = false;
javaHomePath = p.getProperty(WalaProperties.J2SE_DIR); try {
rtJar = new LinkedList<String>();
if (new File(javaHomePath).isDirectory()) {
if ("Mac OS X".equals(System.getProperty("os.name"))) { // nick Properties p = WalaProperties.loadProperties();
/** javaHomePath = p.getProperty(WalaProperties.J2SE_DIR);
* todo: {@link WalaProperties#getJ2SEJarFiles()}
*/ if (new File(javaHomePath).isDirectory()) {
rtJar.add(javaHomePath + "/classes.jar"); if ("Mac OS X".equals(System.getProperty("os.name"))) { // nick
rtJar.add(javaHomePath + "/ui.jar"); /**
} else { * todo: {@link WalaProperties#getJ2SEJarFiles()}
rtJar.add(javaHomePath + File.separator + "classes.jar"); */
rtJar.add(javaHomePath + File.separator + "rt.jar"); rtJar.add(javaHomePath + "/classes.jar");
rtJar.add(javaHomePath + File.separator + "core.jar"); rtJar.add(javaHomePath + "/ui.jar");
rtJar.add(javaHomePath + File.separator + "vm.jar"); } else {
} rtJar.add(javaHomePath + File.separator + "classes.jar");
found = true; rtJar.add(javaHomePath + File.separator + "rt.jar");
} rtJar.add(javaHomePath + File.separator + "core.jar");
} catch (Exception e) { rtJar.add(javaHomePath + File.separator + "vm.jar");
// no properties }
} found = true;
}
if (!found) { } catch (Exception e) {
javaHomePath = System.getProperty("java.home"); // no properties
if ("Mac OS X".equals(System.getProperty("os.name"))) { // nick }
rtJar.add(javaHomePath + "/../Classes/classes.jar");
rtJar.add(javaHomePath + "/../Classes/ui.jar"); if (!found) {
} else { javaHomePath = System.getProperty("java.home");
rtJar.add(javaHomePath + File.separator + "lib" + File.separator + "rt.jar"); if ("Mac OS X".equals(System.getProperty("os.name"))) { // nick
rtJar.add(javaHomePath + File.separator + "lib" + File.separator + "core.jar"); rtJar.add(javaHomePath + "/../Classes/classes.jar");
rtJar.add(javaHomePath + File.separator + "lib" + File.separator + "vm.jar"); rtJar.add(javaHomePath + "/../Classes/ui.jar");
rtJar.add(javaHomePath + File.separator + "lib" + File.separator + "classes.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; }
} public interface IRAssertion {
protected static class EdgeAssertions implements IRAssertion { void check(CallGraph cg);
public final String srcDescriptor;
}
public final List/* <String> */<String> tgtDescriptors = new ArrayList<String>();
protected static class EdgeAssertions implements IRAssertion {
public EdgeAssertions(String srcDescriptor) { public final String srcDescriptor;
this.srcDescriptor = srcDescriptor;
} public final List/* <String> */<String> tgtDescriptors = new ArrayList<String>();
public static EdgeAssertions make(String srcDescriptor, String tgtDescriptor) { public EdgeAssertions(String srcDescriptor) {
EdgeAssertions ea = new EdgeAssertions(srcDescriptor); this.srcDescriptor = srcDescriptor;
ea.tgtDescriptors.add(tgtDescriptor); }
return ea;
} public static EdgeAssertions make(String srcDescriptor, String tgtDescriptor) {
EdgeAssertions ea = new EdgeAssertions(srcDescriptor);
public static EdgeAssertions make(String srcDescriptor, String tgtDescriptor1, String tgtDescriptor2) { ea.tgtDescriptors.add(tgtDescriptor);
EdgeAssertions ea = new EdgeAssertions(srcDescriptor); return ea;
ea.tgtDescriptors.add(tgtDescriptor1); }
ea.tgtDescriptors.add(tgtDescriptor2);
return ea; public static EdgeAssertions make(String srcDescriptor, String tgtDescriptor1, String tgtDescriptor2) {
} EdgeAssertions ea = new EdgeAssertions(srcDescriptor);
ea.tgtDescriptors.add(tgtDescriptor1);
public static EdgeAssertions make(String srcDescriptor, String tgtDescriptor1, String tgtDescriptor2, String tgtDescriptor3) { ea.tgtDescriptors.add(tgtDescriptor2);
EdgeAssertions ea = new EdgeAssertions(srcDescriptor); return ea;
ea.tgtDescriptors.add(tgtDescriptor1); }
ea.tgtDescriptors.add(tgtDescriptor2);
ea.tgtDescriptors.add(tgtDescriptor3); public static EdgeAssertions make(String srcDescriptor, String tgtDescriptor1, String tgtDescriptor2, String tgtDescriptor3) {
return ea; EdgeAssertions ea = new EdgeAssertions(srcDescriptor);
} ea.tgtDescriptors.add(tgtDescriptor1);
ea.tgtDescriptors.add(tgtDescriptor2);
public static EdgeAssertions make(String srcDescriptor, String tgtDescriptor1, String tgtDescriptor2, String tgtDescriptor3, ea.tgtDescriptors.add(tgtDescriptor3);
String tgtDescriptor4) { return ea;
EdgeAssertions ea = new EdgeAssertions(srcDescriptor); }
ea.tgtDescriptors.add(tgtDescriptor1);
ea.tgtDescriptors.add(tgtDescriptor2); public static EdgeAssertions make(String srcDescriptor, String tgtDescriptor1, String tgtDescriptor2, String tgtDescriptor3,
ea.tgtDescriptors.add(tgtDescriptor3); String tgtDescriptor4) {
ea.tgtDescriptors.add(tgtDescriptor4); EdgeAssertions ea = new EdgeAssertions(srcDescriptor);
return ea; ea.tgtDescriptors.add(tgtDescriptor1);
} ea.tgtDescriptors.add(tgtDescriptor2);
ea.tgtDescriptors.add(tgtDescriptor3);
public void check(CallGraph callGraph) { ea.tgtDescriptors.add(tgtDescriptor4);
MethodReference srcMethod = descriptorToMethodRef(this.srcDescriptor, callGraph.getClassHierarchy()); return ea;
Set<CGNode> srcNodes = callGraph.getNodes(srcMethod); }
if (srcNodes.size() == 0) { public void check(CallGraph callGraph) {
System.err.println(("Unreachable/non-existent method: " + srcMethod)); MethodReference srcMethod = descriptorToMethodRef(this.srcDescriptor, callGraph.getClassHierarchy());
return; Set<CGNode> srcNodes = callGraph.getNodes(srcMethod);
}
if (srcNodes.size() > 1) { if (srcNodes.size() == 0) {
System.err.println("Context-sensitive call graph?"); System.err.println(("Unreachable/non-existent method: " + srcMethod));
} return;
}
// Assume only one node for src method if (srcNodes.size() > 1) {
CGNode srcNode = srcNodes.iterator().next(); System.err.println("Context-sensitive call graph?");
}
for (String target : this.tgtDescriptors) {
MethodReference tgtMethod = descriptorToMethodRef(target, callGraph.getClassHierarchy()); // Assume only one node for src method
// Assume only one node for target method CGNode srcNode = srcNodes.iterator().next();
Set<CGNode> tgtNodes = callGraph.getNodes(tgtMethod);
if (tgtNodes.size() == 0) { for (String target : this.tgtDescriptors) {
System.err.println(("Unreachable/non-existent method: " + tgtMethod)); MethodReference tgtMethod = descriptorToMethodRef(target, callGraph.getClassHierarchy());
continue; // Assume only one node for target method
} Set<CGNode> tgtNodes = callGraph.getNodes(tgtMethod);
CGNode tgtNode = tgtNodes.iterator().next(); if (tgtNodes.size() == 0) {
System.err.println(("Unreachable/non-existent method: " + tgtMethod));
boolean found = false; continue;
for (Iterator<? extends CGNode> succIter = callGraph.getSuccNodes(srcNode); succIter.hasNext();) { }
CGNode succ = succIter.next(); CGNode tgtNode = tgtNodes.iterator().next();
if (tgtNode == succ) { boolean found = false;
found = true; for (Iterator<? extends CGNode> succIter = callGraph.getSuccNodes(srcNode); succIter.hasNext();) {
break; CGNode succ = succIter.next();
}
} if (tgtNode == succ) {
if (!found) { found = true;
System.err.println(("Missing edge: " + srcMethod + " -> " + tgtMethod)); break;
} }
} }
} if (!found) {
} System.err.println(("Missing edge: " + srcMethod + " -> " + tgtMethod));
}
protected static class SourceMapAssertion implements IRAssertion { }
private final String method; }
}
private final String variableName;
protected static class SourceMapAssertion implements IRAssertion {
private final int definingLineNumber; private final String method;
protected SourceMapAssertion(String method, String variableName, int definingLineNumber) { private final String variableName;
this.method = method;
this.variableName = variableName; private final int definingLineNumber;
this.definingLineNumber = definingLineNumber;
} protected SourceMapAssertion(String method, String variableName, int definingLineNumber) {
this.method = method;
public void check(CallGraph cg) { this.variableName = variableName;
this.definingLineNumber = definingLineNumber;
MethodReference mref = descriptorToMethodRef(method, cg.getClassHierarchy()); }
for (CGNode cgNode : cg.getNodes(mref)) { public void check(CallGraph cg) {
Assert.assertTrue("failed for " + this.variableName + " in " + cgNode, this.check(cgNode.getMethod(), cgNode.getIR()));
} MethodReference mref = descriptorToMethodRef(method, cg.getClassHierarchy());
}
for (CGNode cgNode : cg.getNodes(mref)) {
boolean check(IMethod m, IR ir) { Assert.assertTrue("failed for " + this.variableName + " in " + cgNode, this.check(cgNode.getMethod(), cgNode.getIR()));
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) { boolean check(IMethod m, IR ir) {
int ln = m.getLineNumber(i); System.err.println(("check for " + variableName + " defined at " + definingLineNumber));
if (ln == definingLineNumber) { SSAInstruction[] insts = ir.getInstructions();
System.err.println((" found " + insts[i] + " at " + ln)); for (int i = 0; i < insts.length; i++) {
for (int j = 0; j < insts[i].getNumberOfDefs(); j++) { if (insts[i] != null) {
int def = insts[i].getDef(j); int ln = m.getLineNumber(i);
System.err.println((" looking at def " + j + ": " + def)); if (ln == definingLineNumber) {
String[] names = ir.getLocalNames(i, def); System.err.println((" found " + insts[i] + " at " + ln));
if (names != null) { for (int j = 0; j < insts[i].getNumberOfDefs(); j++) {
for (String name : names) { int def = insts[i].getDef(j);
System.err.println((" looking at name " + name)); System.err.println((" looking at def " + j + ": " + def));
if (name.equals(variableName)) { String[] names = ir.getLocalNames(i, def);
return true; 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 false;
return Collections.singletonList(getTestSrcPath() + File.separator + singleJavaInputForTest()); }
} }
protected Collection<String> singleTestSrc(final String folder) { protected Collection<String> singleTestSrc() {
return Collections.singletonList(getTestSrcPath() + File.separator + folder + File.separator + singleJavaInputForTest()); return Collections.singletonList(getTestSrcPath() + File.separator + singleJavaInputForTest());
} }
protected Collection<String> singlePkgTestSrc(String pkgName) { protected Collection<String> singleTestSrc(final String folder) {
return Collections.singletonList(getTestSrcPath() + File.separator + singleJavaPkgInputForTest(pkgName)); return Collections.singletonList(getTestSrcPath() + File.separator + folder + File.separator + singleJavaInputForTest());
} }
protected String getTestName() { protected Collection<String> singlePkgTestSrc(String pkgName) {
StackTraceElement stack[] = new Throwable().getStackTrace(); return Collections.singletonList(getTestSrcPath() + File.separator + singleJavaPkgInputForTest(pkgName));
for(int i = 0; i <= stack.length; i++) { }
if (stack[i].getMethodName().startsWith("test")) {
return stack[i].getMethodName(); protected String getTestName() {
} StackTraceElement stack[] = new Throwable().getStackTrace();
} for(int i = 0; i <= stack.length; i++) {
if (stack[i].getMethodName().startsWith("test")) {
throw new Error("test method not found"); return stack[i].getMethodName();
} }
}
protected String[] simpleTestEntryPoint() {
return new String[] { "L" + getTestName().substring(4) }; throw new Error("test method not found");
} }
protected String[] simplePkgTestEntryPoint(String pkgName) { protected String[] simpleTestEntryPoint() {
return new String[] { "L" + pkgName + "/" + getTestName().substring(4) }; return new String[] { "L" + getTestName().substring(4) };
} }
protected abstract JavaSourceAnalysisEngine getAnalysisEngine(String[] mainClassDescriptors); protected String[] simplePkgTestEntryPoint(String pkgName) {
return new String[] { "L" + pkgName + "/" + getTestName().substring(4) };
public Pair runTest(Collection<String> sources, List<String> libs, String[] mainClassDescriptors, List<? extends IRAssertion> ca, }
boolean assertReachable) {
try { protected abstract AbstractAnalysisEngine getAnalysisEngine(String[] mainClassDescriptors, Collection<String> sources, List<String> libs);
JavaSourceAnalysisEngine engine = getAnalysisEngine(mainClassDescriptors);
public Pair runTest(Collection<String> sources, List<String> libs, String[] mainClassDescriptors, List<? extends IRAssertion> ca,
populateScope(engine, sources, libs); boolean assertReachable) {
AbstractAnalysisEngine engine = getAnalysisEngine(mainClassDescriptors, sources, libs);
CallGraph callGraph = engine.buildDefaultCallGraph();
System.err.println(callGraph.toString()); CallGraph callGraph;
try {
// If we've gotten this far, IR has been produced. callGraph = engine.buildDefaultCallGraph();
dumpIR(callGraph, assertReachable); System.err.println(callGraph.toString());
// Now check any assertions as to source mapping // If we've gotten this far, IR has been produced.
for (IRAssertion IRAssertion : ca) { dumpIR(callGraph, sources, assertReachable);
IRAssertion.check(callGraph);
} // Now check any assertions as to source mapping
for (IRAssertion IRAssertion : ca) {
return Pair.make(callGraph, engine.getPointerAnalysis()); IRAssertion.check(callGraph);
}
} catch (Exception e) {
e.printStackTrace(); return Pair.make(callGraph, engine.getPointerAnalysis());
Assert.assertTrue(e.toString(), false); } catch (IllegalArgumentException e) {
return null; // TODO Auto-generated catch block
} e.printStackTrace();
} } catch (CancelException e) {
// TODO Auto-generated catch block
protected static void dumpIR(CallGraph cg, boolean assertReachable) throws IOException { e.printStackTrace();
Set<IMethod> unreachable = HashSetFactory.make(); } catch (IOException e) {
IClassHierarchy cha = cg.getClassHierarchy(); // TODO Auto-generated catch block
IClassLoader sourceLoader = cha.getLoader(JavaSourceAnalysisScope.SOURCE); e.printStackTrace();
for (Iterator iter = sourceLoader.iterateAllClasses(); iter.hasNext();) { }
IClass clazz = (IClass) iter.next();
return null;
System.err.println(clazz); }
if (clazz.isInterface())
continue; protected static void dumpIR(CallGraph cg, Collection<String> sources, boolean assertReachable) throws IOException {
Set<String> sourcePaths = HashSetFactory.make();
for (IMethod m : clazz.getDeclaredMethods()) { for(String src : sources) {
if (m.isAbstract()) { sourcePaths.add(src.substring(src.lastIndexOf(File.separator)+1));
System.err.println(m); }
} else {
Iterator nodeIter = cg.getNodes(m.getReference()).iterator(); Set<IMethod> unreachable = HashSetFactory.make();
if (!nodeIter.hasNext()) { IClassHierarchy cha = cg.getClassHierarchy();
System.err.println(("Method " + m.getReference() + " not reachable?")); IClassLoader sourceLoader = cha.getLoader(JavaSourceAnalysisScope.SOURCE);
unreachable.add(m); for (Iterator iter = sourceLoader.iterateAllClasses(); iter.hasNext();) {
continue; IClass clazz = (IClass) iter.next();
}
CGNode node = (CGNode) nodeIter.next(); System.err.println(clazz);
System.err.println(node.getIR()); if (clazz.isInterface())
} continue;
}
} for (IMethod m : clazz.getDeclaredMethods()) {
if (m.isAbstract()) {
if (assertReachable) { System.err.println(m);
Assert.assertTrue("unreachable methods: " + unreachable.toString(), unreachable.isEmpty()); } 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))) {
* @param srcMethodDescriptor a full method descriptor of the form ldr#type#methName#methSig example: System.err.println(("Method " + m.getReference() + " not reachable?"));
* Source#Simple1#main#([Ljava/lang/String;)V unreachable.add(m);
* @param cha }
* @return }
*/ continue;
public static MethodReference descriptorToMethodRef(String srcMethodDescriptor, IClassHierarchy cha) { }
String[] ldrTypeMeth = srcMethodDescriptor.split("\\#"); CGNode node = (CGNode) nodeIter.next();
System.err.println(node.getIR());
String loaderName = ldrTypeMeth[0]; }
String typeStr = ldrTypeMeth[1]; }
String methName = ldrTypeMeth[2]; }
String methSig = ldrTypeMeth[3];
if (assertReachable) {
TypeReference typeRef = findOrCreateTypeReference(loaderName, typeStr, cha); Assert.assertTrue("unreachable methods: " + unreachable.toString(), unreachable.isEmpty());
}
Language l = cha.getLoader(typeRef.getClassLoader()).getLanguage(); }
return MethodReference.findOrCreate(l, typeRef, methName, methSig);
} /**
*
static TypeReference findOrCreateTypeReference(String loaderName, String typeStr, IClassHierarchy cha) { * @param srcMethodDescriptor a full method descriptor of the form ldr#type#methName#methSig example:
ClassLoaderReference clr = findLoader(loaderName, cha); * Source#Simple1#main#([Ljava/lang/String;)V
TypeName typeName = TypeName.string2TypeName("L" + typeStr); * @param cha
TypeReference typeRef = TypeReference.findOrCreate(clr, typeName); * @return
return typeRef; */
} public static MethodReference descriptorToMethodRef(String srcMethodDescriptor, IClassHierarchy cha) {
String[] ldrTypeMeth = srcMethodDescriptor.split("\\#");
private static ClassLoaderReference findLoader(String loaderName, IClassHierarchy cha) {
Atom loaderAtom = Atom.findOrCreateUnicodeAtom(loaderName); String loaderName = ldrTypeMeth[0];
IClassLoader[] loaders = cha.getLoaders(); String typeStr = ldrTypeMeth[1];
for (IClassLoader loader : loaders) { String methName = ldrTypeMeth[2];
if (loader.getName() == loaderAtom) { String methSig = ldrTypeMeth[3];
return loader.getReference();
} TypeReference typeRef = findOrCreateTypeReference(loaderName, typeStr, cha);
}
Assertions.UNREACHABLE(); Language l = cha.getLoader(typeRef.getClassLoader()).getLanguage();
return null; return MethodReference.findOrCreate(l, typeRef, methName, methSig);
} }
protected void populateScope(JavaSourceAnalysisEngine engine, Collection<String> sources, List<String> libs) throws IOException { static TypeReference findOrCreateTypeReference(String loaderName, String typeStr, IClassHierarchy cha) {
boolean foundLib = false; ClassLoaderReference clr = findLoader(loaderName, cha);
for (String lib : libs) { TypeName typeName = TypeName.string2TypeName("L" + typeStr);
File libFile = new File(lib); TypeReference typeRef = TypeReference.findOrCreate(clr, typeName);
if (libFile.exists()) { return typeRef;
foundLib = true; }
engine.addSystemModule(new JarFileModule(new JarFile(libFile)));
} private static ClassLoaderReference findLoader(String loaderName, IClassHierarchy cha) {
} Atom loaderAtom = Atom.findOrCreateUnicodeAtom(loaderName);
assert foundLib : "couldn't find library file from " + libs; IClassLoader[] loaders = cha.getLoaders();
for (IClassLoader loader : loaders) {
for (String srcFilePath : sources) { if (loader.getName() == loaderAtom) {
String srcFileName = srcFilePath.substring(srcFilePath.lastIndexOf(File.separator) + 1); return loader.getReference();
File f = new File(srcFilePath); }
Assert.assertTrue("couldn't find " + srcFilePath, f.exists()); }
if (f.isDirectory()) { Assertions.UNREACHABLE();
engine.addSourceModule(new SourceDirectoryTreeModule(f)); return null;
} else { }
engine.addSourceModule(new SourceFileModule(f, srcFileName));
} protected void populateScope(JavaSourceAnalysisEngine engine, Collection<String> sources, List<String> libs) {
} boolean foundLib = false;
} for (String lib : libs) {
File libFile = new File(lib);
protected void setTestSrcPath(String testSrcPath) { if (libFile.exists()) {
this.testSrcPath = testSrcPath; foundLib = true;
} try {
engine.addSystemModule(new JarFileModule(new JarFile(libFile)));
protected String getTestSrcPath() { } catch (IOException e) {
return testSrcPath; Assert.fail(e.getMessage());
} }
}
protected String singleJavaInputForTest() { }
return getTestName().substring(4) + ".java"; assert foundLib : "couldn't find library file from " + libs;
}
for (String srcFilePath : sources) {
protected String singleInputForTest() { String srcFileName = srcFilePath.substring(srcFilePath.lastIndexOf(File.separator) + 1);
return getTestName().substring(4); File f = new File(srcFilePath);
} Assert.assertTrue("couldn't find " + srcFilePath, f.exists());
if (f.isDirectory()) {
protected String singleJavaPkgInputForTest(String pkgName) { engine.addSourceModule(new SourceDirectoryTreeModule(f));
return pkgName + File.separator + getTestName().substring(4) + ".java"; } 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";
}
}

View File

@ -1,5 +1,5 @@
#Thu Jan 03 11:24:43 EST 2008 #Thu Jan 03 11:24:43 EST 2008
eclipse.preferences.version=1 eclipse.preferences.version=1
formatter_profile=_WALA formatter_profile=_WALA
formatter_settings_version=11 formatter_settings_version=11
instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true

View File

@ -1,26 +1,26 @@
Manifest-Version: 1.0 Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: Java Source WALA Front End Bundle-Name: Java Source WALA Front End
Bundle-SymbolicName: com.ibm.wala.cast.java Bundle-SymbolicName: com.ibm.wala.cast.java
Bundle-Version: 1.0.0.qualifier Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.ibm.wala.cast.java.JavaSourcePlugin Bundle-Activator: com.ibm.wala.cast.java.JavaSourcePlugin
Bundle-Vendor: rfuhrer@watson.ibm.com Bundle-Vendor: rfuhrer@watson.ibm.com
Require-Bundle: com.ibm.wala.cast, Require-Bundle: com.ibm.wala.cast,
com.ibm.wala.core, com.ibm.wala.core,
com.ibm.wala.shrike, com.ibm.wala.shrike,
org.eclipse.core.runtime org.eclipse.core.runtime
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Export-Package: com.ibm.wala.cast.java, Export-Package: com.ibm.wala.cast.java,
com.ibm.wala.cast.java.analysis.typeInference, com.ibm.wala.cast.java.analysis.typeInference,
com.ibm.wala.cast.java.client, com.ibm.wala.cast.java.client,
com.ibm.wala.cast.java.client.impl, com.ibm.wala.cast.java.client.impl,
com.ibm.wala.cast.java.examples.ast, com.ibm.wala.cast.java.examples.ast,
com.ibm.wala.cast.java.ipa.callgraph, com.ibm.wala.cast.java.ipa.callgraph,
com.ibm.wala.cast.java.ipa.modref, com.ibm.wala.cast.java.ipa.modref,
com.ibm.wala.cast.java.ipa.slicer, com.ibm.wala.cast.java.ipa.slicer,
com.ibm.wala.cast.java.loader, com.ibm.wala.cast.java.loader,
com.ibm.wala.cast.java.ssa, com.ibm.wala.cast.java.ssa,
com.ibm.wala.cast.java.translator, com.ibm.wala.cast.java.translator,
com.ibm.wala.cast.java.types com.ibm.wala.cast.java.types
Bundle-ClassPath: . Bundle-ClassPath: .
Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-RequiredExecutionEnvironment: J2SE-1.5

View File

@ -1,165 +1,165 @@
/****************************************************************************** /******************************************************************************
* Copyright (c) 2002 - 2006 IBM Corporation. * Copyright (c) 2002 - 2006 IBM Corporation.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
*****************************************************************************/ *****************************************************************************/
package com.ibm.wala.cast.java.client; package com.ibm.wala.cast.java.client;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Set; import java.util.Set;
import com.ibm.wala.cast.ir.ssa.AstIRFactory; import com.ibm.wala.cast.ir.ssa.AstIRFactory;
import com.ibm.wala.cast.java.client.impl.ZeroCFABuilderFactory; import com.ibm.wala.cast.java.client.impl.ZeroCFABuilderFactory;
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope; import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
import com.ibm.wala.classLoader.ClassLoaderFactory; import com.ibm.wala.classLoader.ClassLoaderFactory;
import com.ibm.wala.classLoader.Module; import com.ibm.wala.classLoader.Module;
import com.ibm.wala.client.AbstractAnalysisEngine; import com.ibm.wala.client.AbstractAnalysisEngine;
import com.ibm.wala.ipa.callgraph.AnalysisCache; import com.ibm.wala.ipa.callgraph.AnalysisCache;
import com.ibm.wala.ipa.callgraph.AnalysisOptions; import com.ibm.wala.ipa.callgraph.AnalysisOptions;
import com.ibm.wala.ipa.callgraph.AnalysisScope; import com.ibm.wala.ipa.callgraph.AnalysisScope;
import com.ibm.wala.ipa.callgraph.CallGraphBuilder; import com.ibm.wala.ipa.callgraph.CallGraphBuilder;
import com.ibm.wala.ipa.callgraph.Entrypoint; import com.ibm.wala.ipa.callgraph.Entrypoint;
import com.ibm.wala.ipa.callgraph.impl.SetOfClasses; import com.ibm.wala.ipa.callgraph.impl.SetOfClasses;
import com.ibm.wala.ipa.callgraph.impl.Util; import com.ibm.wala.ipa.callgraph.impl.Util;
import com.ibm.wala.ipa.cha.ClassHierarchy; import com.ibm.wala.ipa.cha.ClassHierarchy;
import com.ibm.wala.ipa.cha.ClassHierarchyException; import com.ibm.wala.ipa.cha.ClassHierarchyException;
import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.ssa.SSAOptions; import com.ibm.wala.ssa.SSAOptions;
import com.ibm.wala.ssa.SymbolTable; import com.ibm.wala.ssa.SymbolTable;
import com.ibm.wala.types.ClassLoaderReference; import com.ibm.wala.types.ClassLoaderReference;
import com.ibm.wala.util.collections.HashSetFactory; import com.ibm.wala.util.collections.HashSetFactory;
import com.ibm.wala.util.config.FileOfClasses; import com.ibm.wala.util.config.FileOfClasses;
/** /**
*/ */
public abstract class JavaSourceAnalysisEngine extends AbstractAnalysisEngine { public abstract class JavaSourceAnalysisEngine extends AbstractAnalysisEngine {
/** /**
* Modules which are user-space code * Modules which are user-space code
*/ */
private final Set<Module> userEntries = HashSetFactory.make(); private final Set<Module> userEntries = HashSetFactory.make();
/** /**
* Modules which are source code * Modules which are source code
*/ */
private final Set<Module> sourceEntries = HashSetFactory.make(); private final Set<Module> sourceEntries = HashSetFactory.make();
/** /**
* Modules which are system or library code TODO: what about extension loader? * Modules which are system or library code TODO: what about extension loader?
*/ */
private final Set<Module> systemEntries = HashSetFactory.make(); private final Set<Module> systemEntries = HashSetFactory.make();
public JavaSourceAnalysisEngine() { public JavaSourceAnalysisEngine() {
super(); super();
} }
/** /**
* Adds the given source module to the source loader's module list. Clients * 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 * should/may call this method if they don't supply an IJavaProject to the
* constructor. * constructor.
*/ */
public void addSourceModule(Module M) { public void addSourceModule(Module M) {
sourceEntries.add(M); sourceEntries.add(M);
} }
/** /**
* Adds the given compiled module to the application loader's module list. * 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 * Clients should/may call this method if they don't supply an IJavaProject to
* the constructor. * the constructor.
*/ */
public void addCompiledModule(Module M) { public void addCompiledModule(Module M) {
userEntries.add(M); userEntries.add(M);
} }
/** /**
* Adds the given module to the primordial loader's module list. Clients * 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 * should/may call this method if they don't supply an IJavaProject to the
* constructor. * constructor.
*/ */
public void addSystemModule(Module M) { public void addSystemModule(Module M) {
systemEntries.add(M); systemEntries.add(M);
} }
protected void addApplicationModulesToScope() { protected void addApplicationModulesToScope() {
ClassLoaderReference app = scope.getApplicationLoader(); ClassLoaderReference app = scope.getApplicationLoader();
for (Module M : userEntries) { for (Module M : userEntries) {
scope.addToScope(app, M); scope.addToScope(app, M);
} }
ClassLoaderReference src = ((JavaSourceAnalysisScope) scope).getSourceLoader(); ClassLoaderReference src = ((JavaSourceAnalysisScope) scope).getSourceLoader();
for (Module M : sourceEntries) { for (Module M : sourceEntries) {
scope.addToScope(src, M); scope.addToScope(src, M);
} }
} }
public void buildAnalysisScope() throws IOException { public void buildAnalysisScope() throws IOException {
scope = makeSourceAnalysisScope(); scope = makeSourceAnalysisScope();
if (getExclusionsFile() != null) { if (getExclusionsFile() != null) {
scope.setExclusions(FileOfClasses.createFileOfClasses(new File(getExclusionsFile()))); scope.setExclusions(FileOfClasses.createFileOfClasses(new File(getExclusionsFile())));
} }
for (Module M : this.systemEntries) { for (Module M : this.systemEntries) {
scope.addToScope(scope.getPrimordialLoader(), M); scope.addToScope(scope.getPrimordialLoader(), M);
} }
// add user stuff // add user stuff
addApplicationModulesToScope(); addApplicationModulesToScope();
} }
protected AnalysisScope makeSourceAnalysisScope() { protected AnalysisScope makeSourceAnalysisScope() {
return new JavaSourceAnalysisScope(); return new JavaSourceAnalysisScope();
} }
protected abstract ClassLoaderFactory getClassLoaderFactory(SetOfClasses exclusions); protected abstract ClassLoaderFactory getClassLoaderFactory(SetOfClasses exclusions);
public IClassHierarchy buildClassHierarchy() { public IClassHierarchy buildClassHierarchy() {
IClassHierarchy cha = null; IClassHierarchy cha = null;
ClassLoaderFactory factory = getClassLoaderFactory(scope.getExclusions()); ClassLoaderFactory factory = getClassLoaderFactory(scope.getExclusions());
try { try {
cha = ClassHierarchy.make(getScope(), factory); cha = ClassHierarchy.make(getScope(), factory);
} catch (ClassHierarchyException e) { } catch (ClassHierarchyException e) {
System.err.println("Class Hierarchy construction failed"); System.err.println("Class Hierarchy construction failed");
System.err.println(e.toString()); System.err.println(e.toString());
e.printStackTrace(); e.printStackTrace();
} }
return cha; return cha;
} }
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) { protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha); return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha);
} }
@Override @Override
public AnalysisCache makeDefaultCache() { public AnalysisCache makeDefaultCache() {
return new AnalysisCache(AstIRFactory.makeDefaultFactory()); return new AnalysisCache(AstIRFactory.makeDefaultFactory());
} }
public AnalysisOptions getDefaultOptions(Iterable<Entrypoint> entrypoints) { public AnalysisOptions getDefaultOptions(Iterable<Entrypoint> entrypoints) {
AnalysisOptions options = new AnalysisOptions(getScope(), entrypoints); AnalysisOptions options = new AnalysisOptions(getScope(), entrypoints);
SSAOptions ssaOptions = new SSAOptions(); SSAOptions ssaOptions = new SSAOptions();
ssaOptions.setDefaultValues(new SSAOptions.DefaultValues() { ssaOptions.setDefaultValues(new SSAOptions.DefaultValues() {
public int getDefaultValue(SymbolTable symtab, int valueNumber) { public int getDefaultValue(SymbolTable symtab, int valueNumber) {
return symtab.getDefaultValue(valueNumber); return symtab.getDefaultValue(valueNumber);
} }
}); });
options.setSSAOptions(ssaOptions); options.setSSAOptions(ssaOptions);
return options; return options;
} }
@Override @Override
protected CallGraphBuilder getCallGraphBuilder(IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache) { protected CallGraphBuilder getCallGraphBuilder(IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache) {
return new ZeroCFABuilderFactory().make(options, cache, cha, scope, false); return new ZeroCFABuilderFactory().make(options, cache, cha, scope, false);
} }
} }

View File

@ -8,7 +8,7 @@ import com.ibm.wala.cast.tree.CAstEntity;
import com.ibm.wala.cast.tree.CAstNode; import com.ibm.wala.cast.tree.CAstNode;
import com.ibm.wala.cast.tree.CAstSourcePositionMap; import com.ibm.wala.cast.tree.CAstSourcePositionMap;
import com.ibm.wala.cast.tree.impl.CAstOperator; 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.classLoader.CallSiteReference;
import com.ibm.wala.util.collections.Pair; import com.ibm.wala.util.collections.Pair;

View File

@ -1,75 +1,75 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002 - 2006 IBM Corporation. * Copyright (c) 2002 - 2006 IBM Corporation.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package com.ibm.wala.cast.java.ipa.callgraph; package com.ibm.wala.cast.java.ipa.callgraph;
import com.ibm.wala.ipa.callgraph.AnalysisCache; import com.ibm.wala.ipa.callgraph.AnalysisCache;
import com.ibm.wala.ipa.callgraph.AnalysisOptions; import com.ibm.wala.ipa.callgraph.AnalysisOptions;
import com.ibm.wala.ipa.callgraph.ContextSelector; import com.ibm.wala.ipa.callgraph.ContextSelector;
import com.ibm.wala.ipa.callgraph.impl.DefaultContextSelector; import com.ibm.wala.ipa.callgraph.impl.DefaultContextSelector;
import com.ibm.wala.ipa.callgraph.impl.DelegatingContextSelector; import com.ibm.wala.ipa.callgraph.impl.DelegatingContextSelector;
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter; 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.ContainerContextSelector;
import com.ibm.wala.ipa.callgraph.propagation.cfa.ZeroXInstanceKeys; import com.ibm.wala.ipa.callgraph.propagation.cfa.ZeroXInstanceKeys;
import com.ibm.wala.ipa.cha.IClassHierarchy; 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 * 0-1-CFA Call graph builder which analyzes calls to "container methods" in a context which is defined by the receiver
* instance. * instance.
* *
* @author sfink * @author sfink
*/ */
public class AstJavaZeroOneContainerCFABuilder extends AstJavaCFABuilder { public class AstJavaZeroOneContainerCFABuilder extends AstJavaCFABuilder {
/** /**
* @param cha governing class hierarchy * @param cha governing class hierarchy
* @param warnings object to track analysis warnings * @param warnings object to track analysis warnings
* @param options call graph construction options * @param options call graph construction options
* @param appContextSelector application-specific logic to choose contexts * @param appContextSelector application-specific logic to choose contexts
* @param appContextInterpreter application-specific logic to interpret a method in context * @param appContextInterpreter application-specific logic to interpret a method in context
* @param reflect reflection specification * @param reflect reflection specification
*/ */
public AstJavaZeroOneContainerCFABuilder(IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache, public AstJavaZeroOneContainerCFABuilder(IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache,
ContextSelector appContextSelector, SSAContextInterpreter appContextInterpreter) { ContextSelector appContextSelector, SSAContextInterpreter appContextInterpreter) {
super(cha, options, cache); super(cha, options, cache);
ContextSelector def = new DefaultContextSelector(options, cha); ContextSelector def = new DefaultContextSelector(options, cha);
ContextSelector contextSelector = appContextSelector == null ? def : new DelegatingContextSelector(appContextSelector, def); ContextSelector contextSelector = appContextSelector == null ? def : new DelegatingContextSelector(appContextSelector, def);
SSAContextInterpreter contextInterpreter = makeDefaultContextInterpreters(appContextInterpreter, options, cha); SSAContextInterpreter contextInterpreter = makeDefaultContextInterpreters(appContextInterpreter, options, cha);
setContextInterpreter(contextInterpreter); setContextInterpreter(contextInterpreter);
ZeroXInstanceKeys zik = makeInstanceKeys(cha, options, contextInterpreter); ZeroXInstanceKeys zik = makeInstanceKeys(cha, options, contextInterpreter);
setInstanceKeys(new JavaScopeMappingInstanceKeys(cha, this, zik)); setInstanceKeys(new JavaScopeMappingInstanceKeys(cha, this, zik));
ContextSelector CCS = makeContainerContextSelector(cha, zik); ContextSelector CCS = makeContainerContextSelector(cha, zik);
DelegatingContextSelector DCS = new DelegatingContextSelector(CCS, contextSelector); DelegatingContextSelector DCS = new DelegatingContextSelector(CCS, contextSelector);
setContextSelector(DCS); setContextSelector(DCS);
} }
protected ZeroXInstanceKeys makeInstanceKeys(IClassHierarchy cha, AnalysisOptions options, protected ZeroXInstanceKeys makeInstanceKeys(IClassHierarchy cha, AnalysisOptions options,
SSAContextInterpreter contextInterpreter) { SSAContextInterpreter contextInterpreter) {
ZeroXInstanceKeys zik = new ZeroXInstanceKeys(options, cha, contextInterpreter, ZeroXInstanceKeys.ALLOCATIONS ZeroXInstanceKeys zik = new ZeroXInstanceKeys(options, cha, contextInterpreter, ZeroXInstanceKeys.ALLOCATIONS
| ZeroXInstanceKeys.SMUSH_PRIMITIVE_HOLDERS | ZeroXInstanceKeys.SMUSH_STRINGS | ZeroXInstanceKeys.SMUSH_MANY | ZeroXInstanceKeys.SMUSH_PRIMITIVE_HOLDERS | ZeroXInstanceKeys.SMUSH_STRINGS | ZeroXInstanceKeys.SMUSH_MANY
| ZeroXInstanceKeys.SMUSH_THROWABLES); | ZeroXInstanceKeys.SMUSH_THROWABLES);
return zik; return zik;
} }
/** /**
* @param cha * @param cha
* @param keys * @param keys
* @return an object which creates contexts for call graph nodes based on the container disambiguation policy * @return an object which creates contexts for call graph nodes based on the container disambiguation policy
*/ */
protected ContextSelector makeContainerContextSelector(IClassHierarchy cha, ZeroXInstanceKeys keys) { protected ContextSelector makeContainerContextSelector(IClassHierarchy cha, ZeroXInstanceKeys keys) {
return new ContainerContextSelector(cha, keys); return new ContainerContextSelector(cha, keys);
} }
} }

View File

@ -16,7 +16,6 @@ import java.util.Iterator;
import java.util.Set; import java.util.Set;
import com.ibm.wala.cast.ipa.callgraph.ScopeMappingInstanceKeys; 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.ir.translator.AstTranslator;
import com.ibm.wala.cast.java.loader.JavaSourceLoaderImpl.JavaClass; import com.ibm.wala.cast.java.loader.JavaSourceLoaderImpl.JavaClass;
import com.ibm.wala.cast.loader.AstMethod; import com.ibm.wala.cast.loader.AstMethod;

View File

@ -1,115 +1,115 @@
package com.ibm.wala.cast.java.ipa.slicer; package com.ibm.wala.cast.java.ipa.slicer;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
import com.ibm.wala.cast.ir.ssa.AstAssertInstruction; import com.ibm.wala.cast.ir.ssa.AstAssertInstruction;
import com.ibm.wala.cast.java.ipa.modref.AstJavaModRef; import com.ibm.wala.cast.java.ipa.modref.AstJavaModRef;
import com.ibm.wala.ipa.callgraph.CGNode; import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.CallGraph; import com.ibm.wala.ipa.callgraph.CallGraph;
import com.ibm.wala.ipa.callgraph.impl.PartialCallGraph; import com.ibm.wala.ipa.callgraph.impl.PartialCallGraph;
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis; import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
import com.ibm.wala.ipa.slicer.NormalStatement; import com.ibm.wala.ipa.slicer.NormalStatement;
import com.ibm.wala.ipa.slicer.SDG; import com.ibm.wala.ipa.slicer.SDG;
import com.ibm.wala.ipa.slicer.Slicer; import com.ibm.wala.ipa.slicer.Slicer;
import com.ibm.wala.ipa.slicer.Statement; import com.ibm.wala.ipa.slicer.Statement;
import com.ibm.wala.ssa.IR; import com.ibm.wala.ssa.IR;
import com.ibm.wala.ssa.SSAArrayLoadInstruction; import com.ibm.wala.ssa.SSAArrayLoadInstruction;
import com.ibm.wala.ssa.SSAArrayStoreInstruction; import com.ibm.wala.ssa.SSAArrayStoreInstruction;
import com.ibm.wala.ssa.SSAGetInstruction; import com.ibm.wala.ssa.SSAGetInstruction;
import com.ibm.wala.ssa.SSAInstruction; import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.ssa.SSAMonitorInstruction; import com.ibm.wala.ssa.SSAMonitorInstruction;
import com.ibm.wala.ssa.SSAPutInstruction; import com.ibm.wala.ssa.SSAPutInstruction;
import com.ibm.wala.util.CancelException; import com.ibm.wala.util.CancelException;
import com.ibm.wala.util.collections.Filter; import com.ibm.wala.util.collections.Filter;
import com.ibm.wala.util.collections.Pair; import com.ibm.wala.util.collections.Pair;
import com.ibm.wala.util.graph.traverse.DFS; import com.ibm.wala.util.graph.traverse.DFS;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class AstJavaSlicer extends Slicer { public class AstJavaSlicer extends Slicer {
/* /*
* Use the passed-in SDG * Use the passed-in SDG
*/ */
public static Collection<Statement> computeBackwardSlice(SDG sdg, Collection<Statement> ss) throws IllegalArgumentException, public static Collection<Statement> computeBackwardSlice(SDG sdg, Collection<Statement> ss) throws IllegalArgumentException,
CancelException { CancelException {
return computeSlice(sdg, ss, true); return computeSlice(sdg, ss, true);
} }
/** /**
* @param ss a collection of statements of interest * @param ss a collection of statements of interest
* @throws CancelException * @throws CancelException
*/ */
public static Collection<Statement> computeSlice(SDG sdg, Collection<Statement> ss, boolean backward) throws CancelException { public static Collection<Statement> computeSlice(SDG sdg, Collection<Statement> ss, boolean backward) throws CancelException {
return new AstJavaSlicer().slice(sdg, ss, backward); return new AstJavaSlicer().slice(sdg, ss, backward);
} }
public static Set<Statement> gatherStatements(CallGraph CG, Collection<CGNode> partialRoots, Filter<SSAInstruction> filter) { public static Set<Statement> gatherStatements(CallGraph CG, Collection<CGNode> partialRoots, Filter<SSAInstruction> filter) {
Set<Statement> result = new HashSet<Statement>(); Set<Statement> result = new HashSet<Statement>();
for (Iterator<CGNode> ns = DFS.getReachableNodes(CG, partialRoots).iterator(); ns.hasNext();) { for (Iterator<CGNode> ns = DFS.getReachableNodes(CG, partialRoots).iterator(); ns.hasNext();) {
CGNode n = ns.next(); CGNode n = ns.next();
IR nir = n.getIR(); IR nir = n.getIR();
if (nir != null) { if (nir != null) {
SSAInstruction insts[] = nir.getInstructions(); SSAInstruction insts[] = nir.getInstructions();
for (int i = 0; i < insts.length; i++) { for (int i = 0; i < insts.length; i++) {
if (filter.accepts(insts[i])) { if (filter.accepts(insts[i])) {
result.add(new NormalStatement(n, i)); result.add(new NormalStatement(n, i));
} }
} }
} }
} }
return result; return result;
} }
public static Set<Statement> gatherAssertions(CallGraph CG, Collection<CGNode> partialRoots) { public static Set<Statement> gatherAssertions(CallGraph CG, Collection<CGNode> partialRoots) {
return gatherStatements(CG, partialRoots, new Filter<SSAInstruction>() { return gatherStatements(CG, partialRoots, new Filter<SSAInstruction>() {
public boolean accepts(SSAInstruction o) { public boolean accepts(SSAInstruction o) {
return o instanceof AstAssertInstruction; return o instanceof AstAssertInstruction;
} }
}); });
} }
public static Set<Statement> gatherMonitors(CallGraph CG, Collection<CGNode> partialRoots) { public static Set<Statement> gatherMonitors(CallGraph CG, Collection<CGNode> partialRoots) {
return gatherStatements(CG, partialRoots, new Filter<SSAInstruction>() { return gatherStatements(CG, partialRoots, new Filter<SSAInstruction>() {
public boolean accepts(SSAInstruction o) { public boolean accepts(SSAInstruction o) {
return o instanceof SSAMonitorInstruction; return o instanceof SSAMonitorInstruction;
} }
}); });
} }
public static Set<Statement> gatherWrites(CallGraph CG, Collection<CGNode> partialRoots) { public static Set<Statement> gatherWrites(CallGraph CG, Collection<CGNode> partialRoots) {
return gatherStatements(CG, partialRoots, new Filter<SSAInstruction>() { return gatherStatements(CG, partialRoots, new Filter<SSAInstruction>() {
public boolean accepts(SSAInstruction o) { public boolean accepts(SSAInstruction o) {
return (o instanceof SSAPutInstruction) || (o instanceof SSAArrayStoreInstruction); return (o instanceof SSAPutInstruction) || (o instanceof SSAArrayStoreInstruction);
} }
}); });
} }
public static Set<Statement> gatherReads(CallGraph CG, Collection<CGNode> partialRoots) { public static Set<Statement> gatherReads(CallGraph CG, Collection<CGNode> partialRoots) {
return gatherStatements(CG, partialRoots, new Filter<SSAInstruction>() { return gatherStatements(CG, partialRoots, new Filter<SSAInstruction>() {
public boolean accepts(SSAInstruction o) { public boolean accepts(SSAInstruction o) {
return (o instanceof SSAGetInstruction) || (o instanceof SSAArrayLoadInstruction); return (o instanceof SSAGetInstruction) || (o instanceof SSAArrayLoadInstruction);
} }
}); });
} }
public static Pair<Collection<Statement>, SDG> computeAssertionSlice(CallGraph CG, PointerAnalysis pa, public static Pair<Collection<Statement>, SDG> computeAssertionSlice(CallGraph CG, PointerAnalysis pa,
Collection<CGNode> partialRoots, boolean multiThreadedCode) throws IllegalArgumentException, CancelException { Collection<CGNode> partialRoots, boolean multiThreadedCode) throws IllegalArgumentException, CancelException {
CallGraph pcg = PartialCallGraph.make(CG, new LinkedHashSet<CGNode>(partialRoots)); CallGraph pcg = PartialCallGraph.make(CG, new LinkedHashSet<CGNode>(partialRoots));
SDG sdg = new SDG(pcg, pa, new AstJavaModRef(), DataDependenceOptions.FULL, ControlDependenceOptions.FULL); SDG sdg = new SDG(pcg, pa, new AstJavaModRef(), DataDependenceOptions.FULL, ControlDependenceOptions.FULL);
System.err.println(("SDG:\n" + sdg)); System.err.println(("SDG:\n" + sdg));
Set<Statement> stmts = gatherAssertions(CG, partialRoots); Set<Statement> stmts = gatherAssertions(CG, partialRoots);
if (multiThreadedCode) { if (multiThreadedCode) {
// Grab anything that has "side effects" under JMM // Grab anything that has "side effects" under JMM
stmts.addAll(gatherReads(CG, partialRoots)); stmts.addAll(gatherReads(CG, partialRoots));
stmts.addAll(gatherWrites(CG, partialRoots)); stmts.addAll(gatherWrites(CG, partialRoots));
stmts.addAll(gatherMonitors(CG, partialRoots)); stmts.addAll(gatherMonitors(CG, partialRoots));
} }
return Pair.make(AstJavaSlicer.computeBackwardSlice(sdg, stmts), sdg); return Pair.make(AstJavaSlicer.computeBackwardSlice(sdg, stmts), sdg);
} }
} }

View File

@ -54,9 +54,9 @@ import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IClassLoader; import com.ibm.wala.classLoader.IClassLoader;
import com.ibm.wala.classLoader.IField; import com.ibm.wala.classLoader.IField;
import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.classLoader.Module;
import com.ibm.wala.classLoader.JavaLanguage.JavaInstructionFactory; import com.ibm.wala.classLoader.JavaLanguage.JavaInstructionFactory;
import com.ibm.wala.classLoader.Language; import com.ibm.wala.classLoader.Language;
import com.ibm.wala.classLoader.Module;
import com.ibm.wala.classLoader.ModuleEntry; import com.ibm.wala.classLoader.ModuleEntry;
import com.ibm.wala.classLoader.NewSiteReference; import com.ibm.wala.classLoader.NewSiteReference;
import com.ibm.wala.ipa.callgraph.impl.SetOfClasses; import com.ibm.wala.ipa.callgraph.impl.SetOfClasses;
@ -139,7 +139,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
result.add(domoType); result.add(domoType);
} }
if (domoType == null && !getClassHierarchy().getScope().getExclusions().contains(name.toString().substring(1))){ 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;
} }
} }

View File

@ -1,75 +1,75 @@
package com.ibm.wala.cast.java.ssa; package com.ibm.wala.cast.java.ssa;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import com.ibm.wala.ssa.SSAInstruction; import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.ssa.SSAInstructionFactory; import com.ibm.wala.ssa.SSAInstructionFactory;
import com.ibm.wala.ssa.SymbolTable; import com.ibm.wala.ssa.SymbolTable;
import com.ibm.wala.types.TypeReference; 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 * 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 * 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. * of the object of the given type that lexically encloses its use value.
* *
* @author Julian Dolby (dolby@us.ibm.com) * @author Julian Dolby (dolby@us.ibm.com)
*/ */
public class EnclosingObjectReference extends SSAInstruction { public class EnclosingObjectReference extends SSAInstruction {
private final TypeReference type; private final TypeReference type;
private final int lval; private final int lval;
public EnclosingObjectReference(int iindex, int lval, TypeReference type) { public EnclosingObjectReference(int iindex, int lval, TypeReference type) {
super(iindex); super(iindex);
this.lval = lval; this.lval = lval;
this.type = type; this.type = type;
} }
public boolean hasDef() { public boolean hasDef() {
return true; return true;
} }
public int getDef() { public int getDef() {
return lval; return lval;
} }
public int getDef(int i) { public int getDef(int i) {
assert i == 0; assert i == 0;
return lval; return lval;
} }
public int getNumberOfDefs() { public int getNumberOfDefs() {
return 1; return 1;
} }
public TypeReference getEnclosingType() { public TypeReference getEnclosingType() {
return type; return type;
} }
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((AstJavaInstructionFactory) insts).EnclosingObjectReference(iindex, defs == null ? lval : defs[0], type); return ((AstJavaInstructionFactory) insts).EnclosingObjectReference(iindex, defs == null ? lval : defs[0], type);
} }
public String toString(SymbolTable symbolTable) { public String toString(SymbolTable symbolTable) {
return getValueString(symbolTable, lval) + " = enclosing " + type.getName(); return getValueString(symbolTable, lval) + " = enclosing " + type.getName();
} }
public void visit(IVisitor v) { public void visit(IVisitor v) {
((AstJavaInstructionVisitor) v).visitEnclosingObjectReference(this); ((AstJavaInstructionVisitor) v).visitEnclosingObjectReference(this);
} }
public int hashCode() { public int hashCode() {
return lval * type.hashCode(); return lval * type.hashCode();
} }
public Collection<TypeReference> getExceptionTypes() { public Collection<TypeReference> getExceptionTypes() {
return Collections.emptySet(); return Collections.emptySet();
} }
public boolean isFallThrough() { public boolean isFallThrough() {
return true; return true;
} }
} }

View File

@ -15,13 +15,12 @@ package com.ibm.wala.cast.java.translator;
import java.io.PrintWriter; 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.java.loader.JavaSourceLoaderImpl;
import com.ibm.wala.cast.tree.CAst; import com.ibm.wala.cast.tree.CAst;
import com.ibm.wala.cast.tree.CAstEntity; import com.ibm.wala.cast.tree.CAstEntity;
import com.ibm.wala.cast.tree.impl.CAstImpl; import com.ibm.wala.cast.tree.impl.CAstImpl;
import com.ibm.wala.cast.tree.impl.CAstRewriter; import com.ibm.wala.cast.tree.rewrite.CAstRewriter;
import com.ibm.wala.cast.tree.impl.CAstRewriterFactory; import com.ibm.wala.cast.tree.rewrite.CAstRewriterFactory;
import com.ibm.wala.cast.util.CAstPrinter; import com.ibm.wala.cast.util.CAstPrinter;
import com.ibm.wala.classLoader.ModuleEntry; import com.ibm.wala.classLoader.ModuleEntry;

View File

@ -1,67 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project name="com.ibm.wala.cast.java.polyglot" default="getJars" basedir="."> <project name="com.ibm.wala.cast.java.polyglot" default="getJars" basedir=".">
<property name="basews" value="${ws}"/> <property name="basews" value="${ws}"/>
<property name="baseos" value="${os}"/> <property name="baseos" value="${os}"/>
<property name="basearch" value="${arch}"/> <property name="basearch" value="${arch}"/>
<property name="basenl" value="${nl}"/> <property name="basenl" value="${nl}"/>
<!-- Compiler settings. --> <!-- Compiler settings. -->
<property name="javacFailOnError" value="true"/> <property name="javacFailOnError" value="true"/>
<property name="javacDebugInfo" value="on"/> <property name="javacDebugInfo" value="on"/>
<property name="javacVerbose" value="false"/> <property name="javacVerbose" value="false"/>
<property name="logExtension" value=".log"/> <property name="logExtension" value=".log"/>
<property name="compilerArg" value=""/> <property name="compilerArg" value=""/>
<property name="javacSource" value="1.5"/> <property name="javacSource" value="1.5"/>
<property name="javacTarget" 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 <!-- 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, 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" --> try changing the value of the property to "${java.home}/../../../Classes" -->
<condition property="dir_bootclasspath" value="${java.home}/../Classes"> <condition property="dir_bootclasspath" value="${java.home}/../Classes">
<os family="mac"/> <os family="mac"/>
</condition> </condition>
<property name="dir_bootclasspath" value="${java.home}/lib"/> <property name="dir_bootclasspath" value="${java.home}/lib"/>
<path id="path_bootclasspath"> <path id="path_bootclasspath">
<fileset dir="${dir_bootclasspath}"> <fileset dir="${dir_bootclasspath}">
<include name="*.jar"/> <include name="*.jar"/>
</fileset> </fileset>
</path> </path>
<property name="bootclasspath" refid="path_bootclasspath"/> <property name="bootclasspath" refid="path_bootclasspath"/>
<property name="bundleJavacSource" value="${javacSource}"/> <property name="bundleJavacSource" value="${javacSource}"/>
<property name="bundleJavacTarget" value="${javacTarget}"/> <property name="bundleJavacTarget" value="${javacTarget}"/>
<property name="bundleBootClasspath" value="${bootclasspath}"/> <property name="bundleBootClasspath" value="${bootclasspath}"/>
<target name="NuPresent" depends="init"> <target name="NuPresent" depends="init">
<available file="${plugin.destination}/lib/htmlparser-1.3.1.jar" property="nu.present"/> <available file="${plugin.destination}/lib/htmlparser-1.3.1.jar" property="nu.present"/>
</target> </target>
<target name="fetchNu" depends="NuPresent" unless="nu.present"> <target name="fetchNu" depends="NuPresent" unless="nu.present">
<delete dir="${temp.folder}"/> <delete dir="${temp.folder}"/>
<mkdir 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"/> <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}"/> <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" /> <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}"/> <delete dir="${temp.folder}"/>
</target> </target>
<target name="getJars" depends="fetchNu" /> <target name="getJars" depends="fetchNu" />
<target name="init" depends="properties"> <target name="init" depends="properties">
<condition property="pluginTemp" value="${buildTempFolder}/plugins"> <condition property="pluginTemp" value="${buildTempFolder}/plugins">
<isset property="buildTempFolder"/> <isset property="buildTempFolder"/>
</condition> </condition>
<property name="pluginTemp" value="${basedir}"/> <property name="pluginTemp" value="${basedir}"/>
<condition property="build.result.folder" value="${pluginTemp}/com.ibm.wala.core.testdata"> <condition property="build.result.folder" value="${pluginTemp}/com.ibm.wala.core.testdata">
<isset property="buildTempFolder"/> <isset property="buildTempFolder"/>
</condition> </condition>
<property name="build.result.folder" value="${basedir}"/> <property name="build.result.folder" value="${basedir}"/>
<property name="temp.folder" value="${basedir}/temp.folder"/> <property name="temp.folder" value="${basedir}/temp.folder"/>
<property name="plugin.destination" value="${basedir}"/> <property name="plugin.destination" value="${basedir}"/>
</target> </target>
<target name="properties" if="eclipse.running"> <target name="properties" if="eclipse.running">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/> <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
</target> </target>
</project> </project>

View File

@ -3,5 +3,6 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="harness-src"/> <classpathentry kind="src" path="harness-src"/>
<classpathentry kind="lib" path="/com.ibm.wala.cast.js.test.data/examples-src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@ -3,18 +3,16 @@ Bundle-ManifestVersion: 2
Bundle-Name: Test Plug-in Bundle-Name: Test Plug-in
Bundle-SymbolicName: com.ibm.wala.cast.js.rhino.test Bundle-SymbolicName: com.ibm.wala.cast.js.rhino.test
Bundle-Version: 1.0.0 Bundle-Version: 1.0.0
Bundle-Activator: com.ibm.wala.cast.js.rhino.test.Activator
Bundle-Vendor: IBM Bundle-Vendor: IBM
Require-Bundle: org.eclipse.core.runtime, Require-Bundle: com.ibm.wala.cast.js.rhino;bundle-version="1.0.0",
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.js;bundle-version="1.0.0",
com.ibm.wala.cast;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.core;bundle-version="1.1.3",
com.ibm.wala.cast.js.test;bundle-version="1.0.0", com.ibm.wala.cast.js.test;bundle-version="1.0.0",
com.ibm.wala.cast.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", com.ibm.wala.core.tests;bundle-version="1.1.3",
org.junit4;bundle-version="4.3.1", org.junit4;bundle-version="4.3.1"
com.ibm.wala.ide;bundle-version="1.1.3"
Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy 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

View File

@ -19,8 +19,6 @@ import java.util.Properties;
import junit.framework.Assert; import junit.framework.Assert;
import org.eclipse.core.runtime.NullProgressMonitor;
import com.ibm.wala.cast.ir.translator.AstTranslator; 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.ForInContextSelector;
import com.ibm.wala.cast.js.ipa.callgraph.JSCFABuilder; 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;
import com.ibm.wala.cast.js.test.JSCallGraphBuilderUtil.CGBuilderType; import com.ibm.wala.cast.js.test.JSCallGraphBuilderUtil.CGBuilderType;
import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory; 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.CGNode;
import com.ibm.wala.ipa.callgraph.CallGraph; import com.ibm.wala.ipa.callgraph.CallGraph;
import com.ibm.wala.ipa.callgraph.CallGraphBuilderCancelException; import com.ibm.wala.ipa.callgraph.CallGraphBuilderCancelException;
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis; import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
import com.ibm.wala.ipa.cha.ClassHierarchyException; 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.CommandLine;
import com.ibm.wala.util.io.FileProvider; import com.ibm.wala.util.io.FileProvider;
import com.ibm.wala.util.io.FileUtil;
/** /**
* Utility class for building call graphs of HTML pages. * Utility class for building call graphs of HTML pages.
@ -113,7 +111,7 @@ public class HTMLCGBuilder {
} }
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
CallGraph cg = timeout > 0 ? builder.makeCallGraph(builder.getOptions(), CallGraph cg = timeout > 0 ? builder.makeCallGraph(builder.getOptions(),
ProgressMonitorDelegate.createProgressMonitorDelegate(master)) : builder.makeCallGraph(builder.getOptions()); master) : builder.makeCallGraph(builder.getOptions());
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
master.done(); master.done();
res.construction_time = (end - start); res.construction_time = (end - start);
@ -155,34 +153,51 @@ public class HTMLCGBuilder {
*/ */
public static void main(String[] args) throws ClassHierarchyException, IOException { public static void main(String[] args) throws ClassHierarchyException, IOException {
Properties parsedArgs = CommandLine.parse(args); Properties parsedArgs = CommandLine.parse(args);
String src = parsedArgs.getProperty("src"); String src = parsedArgs.getProperty("src");
if (src == null) { if (src == null) {
throw new IllegalArgumentException("-src argument is required"); 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; int timeout;
if (parsedArgs.containsKey("timeout")) { if (parsedArgs.containsKey("timeout")) {
timeout = Integer.parseInt(parsedArgs.getProperty("timeout")); timeout = Integer.parseInt(parsedArgs.getProperty("timeout"));
} else { } else {
timeout = DEFAULT_TIMEOUT; timeout = DEFAULT_TIMEOUT;
} }
String reachableName = null; String reachableName = null;
if (parsedArgs.containsKey("reachable")) { if (parsedArgs.containsKey("reachable")) {
reachableName = parsedArgs.getProperty("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 // suppress debug output
JavaScriptFunctionDotCallTargetSelector.WARN_ABOUT_IMPRECISE_CALLGRAPH = false; 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); CGBuilderResult res = buildHTMLCG(src, timeout, true, AstTranslator.NEW_LEXICAL ? CGBuilderType.ONE_CFA_PRECISE_LEXICAL : CGBuilderType.ZERO_ONE_CFA);
if(res.construction_time == -1) if(res.construction_time == -1)
System.out.println("TIMED OUT"); System.out.println("TIMED OUT");
else else
System.out.println("Call graph construction took " + res.construction_time/1000.0 + " seconds"); System.out.println("Call graph construction took " + res.construction_time/1000.0 + " seconds");
if (reachableName != null) { if (reachableName != null) {
for (CGNode node : res.cg) { for (CGNode node : res.cg) {
if (node.getMethod().getDeclaringClass().getName().toString().contains(reachableName)) { 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");
}
}
}
}
}
} }
} }

View File

@ -13,7 +13,6 @@ package com.ibm.wala.cast.js.test;
import java.io.IOException; import java.io.IOException;
import com.ibm.wala.cast.js.translator.RhinoToAstTranslator; import com.ibm.wala.cast.js.translator.RhinoToAstTranslator;
import com.ibm.wala.cast.tree.CAstEntity; import com.ibm.wala.cast.tree.CAstEntity;
import com.ibm.wala.cast.tree.impl.CAstImpl; import com.ibm.wala.cast.tree.impl.CAstImpl;

View File

@ -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());
}
}

View File

@ -65,4 +65,9 @@ public class TestSimpleCallGraphShapeRhino extends TestSimpleCallGraphShape {
public void testTranslateToCAstCrash3() throws IllegalArgumentException, IOException, CancelException { public void testTranslateToCAstCrash3() throws IllegalArgumentException, IOException, CancelException {
JSCallGraphBuilderUtil.makeScriptCG("tests", "rhino_crash3.js"); JSCallGraphBuilderUtil.makeScriptCG("tests", "rhino_crash3.js");
} }
@Test
public void testNonLoopBreakLabel() throws IllegalArgumentException, IOException, CancelException {
JSCallGraphBuilderUtil.makeScriptCG("tests", "non_loop_break.js");
}
} }

View File

@ -18,6 +18,7 @@ import org.junit.Test;
import com.ibm.wala.cast.js.html.IHtmlParser; import com.ibm.wala.cast.js.html.IHtmlParser;
import com.ibm.wala.cast.js.html.IHtmlParserFactory; 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.html.WebUtil;
import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory; import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory;
import com.ibm.wala.ipa.callgraph.CallGraph; import com.ibm.wala.ipa.callgraph.CallGraph;
@ -50,5 +51,7 @@ public abstract class TestSimplePageCallGraphShapeRhino extends TestSimplePageCa
return TestSimplePageCallGraphShapeRhino.this.getParser(); return TestSimplePageCallGraphShapeRhino.this.getParser();
} }
}); });
JSSourceExtractor.USE_TEMP_NAME = false;
JSSourceExtractor.DELETE_UPON_EXIT = false;
} }
} }

View File

@ -1,71 +1,71 @@
package com.ibm.wala.cast.js.vis; package com.ibm.wala.cast.js.vis;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.util.Set; import java.util.Set;
import com.ibm.wala.cast.ir.ssa.AstIRFactory; import com.ibm.wala.cast.ir.ssa.AstIRFactory;
import com.ibm.wala.cast.js.html.DefaultSourceExtractor; import com.ibm.wala.cast.js.html.DefaultSourceExtractor;
import com.ibm.wala.cast.js.html.DomLessSourceExtractor; import com.ibm.wala.cast.js.html.DomLessSourceExtractor;
import com.ibm.wala.cast.js.html.IdentityUrlResolver; import com.ibm.wala.cast.js.html.IdentityUrlResolver;
import com.ibm.wala.cast.js.html.JSSourceExtractor; import com.ibm.wala.cast.js.html.JSSourceExtractor;
import com.ibm.wala.cast.js.html.MappedSourceModule; import com.ibm.wala.cast.js.html.MappedSourceModule;
import com.ibm.wala.cast.js.html.WebPageLoaderFactory; import com.ibm.wala.cast.js.html.WebPageLoaderFactory;
import com.ibm.wala.cast.js.html.WebUtil; import com.ibm.wala.cast.js.html.WebUtil;
import com.ibm.wala.cast.js.html.jericho.JerichoHtmlParser; import com.ibm.wala.cast.js.html.jericho.JerichoHtmlParser;
import com.ibm.wala.cast.js.ipa.callgraph.JSCFABuilder; import com.ibm.wala.cast.js.ipa.callgraph.JSCFABuilder;
import com.ibm.wala.cast.js.loader.JavaScriptLoader; import com.ibm.wala.cast.js.loader.JavaScriptLoader;
import com.ibm.wala.cast.js.test.JSCallGraphBuilderUtil; import com.ibm.wala.cast.js.test.JSCallGraphBuilderUtil;
import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory; import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory;
import com.ibm.wala.classLoader.SourceFileModule; import com.ibm.wala.classLoader.SourceFileModule;
import com.ibm.wala.classLoader.SourceModule; import com.ibm.wala.classLoader.SourceModule;
import com.ibm.wala.ipa.callgraph.CallGraph; import com.ibm.wala.ipa.callgraph.CallGraph;
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis; import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
import com.ibm.wala.ipa.cha.ClassHierarchyException; import com.ibm.wala.ipa.cha.ClassHierarchyException;
import com.ibm.wala.util.CancelException; import com.ibm.wala.util.CancelException;
public class JsViewerDriver extends JSCallGraphBuilderUtil { public class JsViewerDriver extends JSCallGraphBuilderUtil {
public static void main(String args[]) throws ClassHierarchyException, IllegalArgumentException, IOException, CancelException { public static void main(String args[]) throws ClassHierarchyException, IllegalArgumentException, IOException, CancelException {
if (args.length != 1){ if (args.length != 1){
System.out.println("Usage: <URL of html page to analyze>"); System.out.println("Usage: <URL of html page to analyze>");
System.exit(1); System.exit(1);
} }
boolean domless = false; boolean domless = false;
URL url = new URL(args[0]); URL url = new URL(args[0]);
// computing CG + PA // computing CG + PA
JSCallGraphBuilderUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory()); JSCallGraphBuilderUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory());
JavaScriptLoader.addBootstrapFile(WebUtil.preamble); JavaScriptLoader.addBootstrapFile(WebUtil.preamble);
SourceModule[] sources = getSources(domless, url); SourceModule[] sources = getSources(domless, url);
JSCFABuilder builder = makeCGBuilder(new WebPageLoaderFactory(translatorFactory), sources, CGBuilderType.ZERO_ONE_CFA, AstIRFactory.makeDefaultFactory()); JSCFABuilder builder = makeCGBuilder(new WebPageLoaderFactory(translatorFactory), sources, CGBuilderType.ZERO_ONE_CFA, AstIRFactory.makeDefaultFactory());
builder.setBaseURL(url); builder.setBaseURL(url);
CallGraph cg = builder.makeCallGraph(builder.getOptions()); CallGraph cg = builder.makeCallGraph(builder.getOptions());
PointerAnalysis pa = builder.getPointerAnalysis(); PointerAnalysis pa = builder.getPointerAnalysis();
new JsViewer(cg, pa); new JsViewer(cg, pa);
} }
private static SourceModule[] getSources(boolean domless, URL url) private static SourceModule[] getSources(boolean domless, URL url)
throws IOException { throws IOException {
JSSourceExtractor sourceExtractor; JSSourceExtractor sourceExtractor;
if (domless ){ if (domless ){
sourceExtractor = new DomLessSourceExtractor(); sourceExtractor = new DomLessSourceExtractor();
} else { } else {
sourceExtractor = new DefaultSourceExtractor(); sourceExtractor = new DefaultSourceExtractor();
} }
Set<MappedSourceModule> sourcesMap = sourceExtractor.extractSources(url, new JerichoHtmlParser(), new IdentityUrlResolver()); Set<MappedSourceModule> sourcesMap = sourceExtractor.extractSources(url, new JerichoHtmlParser(), new IdentityUrlResolver());
SourceModule[] sources = new SourceFileModule[sourcesMap.size()]; SourceModule[] sources = new SourceFileModule[sourcesMap.size()];
int i = 0; int i = 0;
for (SourceModule m : sourcesMap){ for (SourceModule m : sourcesMap){
sources[i++] = m; sources[i++] = m;
} }
return sources; return sources;
} }
} }

View File

@ -7,15 +7,18 @@
<listEntry value="4"/> <listEntry value="4"/>
</listAttribute> </listAttribute>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> <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.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"/> <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"/> <booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/> <stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/> <stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH"> <listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5&quot; javaProject=&quot;com.ibm.wala.cast.js.rhino.test&quot; path=&quot;1&quot; type=&quot;4&quot;/&gt;&#10;"/> <listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER&quot; javaProject=&quot;com.ibm.wala.cast.js.rhino.test&quot; path=&quot;1&quot; type=&quot;4&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;runtimeClasspathEntry id=&quot;org.eclipse.jdt.launching.classpathentry.defaultClasspath&quot;&gt;&#10;&lt;memento exportedEntriesOnly=&quot;false&quot; project=&quot;com.ibm.wala.cast.js.rhino.test&quot;/&gt;&#10;&lt;/runtimeClasspathEntry&gt;&#10;"/> <listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry id=&quot;org.eclipse.jdt.launching.classpathentry.defaultClasspath&quot;&gt;&#10;&lt;memento exportedEntriesOnly=&quot;false&quot; project=&quot;com.ibm.wala.cast.js.rhino.test&quot;/&gt;&#10;&lt;/runtimeClasspathEntry&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/com.ibm.wala.cast.js.test/examples-src&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/> <listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/com.ibm.wala.cast.js.test.data/examples-src&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
</listAttribute> </listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/> <booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/> <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="source"/> <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.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="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"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@ -12,4 +12,28 @@ Require-Bundle: org.eclipse.core.runtime,
Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Export-Package: com.ibm.wala.cast.js.translator, 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,
.

View File

@ -1,4 +1,5 @@
source.. = source/ source.. = source/
output.. = bin/ output.. = bin/
bin.includes = META-INF/,\ bin.includes = META-INF/,\
. .,\
lib/js.jar

View File

@ -1,69 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project name="com.ibm.wala.cast.java.polyglot" default="getJars" basedir="."> <project name="com.ibm.wala.cast.java.polyglot" default="getJars" basedir=".">
<property name="basews" value="${ws}"/> <property name="basews" value="${ws}"/>
<property name="baseos" value="${os}"/> <property name="baseos" value="${os}"/>
<property name="basearch" value="${arch}"/> <property name="basearch" value="${arch}"/>
<property name="basenl" value="${nl}"/> <property name="basenl" value="${nl}"/>
<!-- Compiler settings. --> <!-- Compiler settings. -->
<property name="javacFailOnError" value="true"/> <property name="javacFailOnError" value="true"/>
<property name="javacDebugInfo" value="on"/> <property name="javacDebugInfo" value="on"/>
<property name="javacVerbose" value="false"/> <property name="javacVerbose" value="false"/>
<property name="logExtension" value=".log"/> <property name="logExtension" value=".log"/>
<property name="compilerArg" value=""/> <property name="compilerArg" value=""/>
<property name="javacSource" value="1.5"/> <property name="javacSource" value="1.5"/>
<property name="javacTarget" 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 <!-- 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, 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" --> try changing the value of the property to "${java.home}/../../../Classes" -->
<condition property="dir_bootclasspath" value="${java.home}/../Classes"> <condition property="dir_bootclasspath" value="${java.home}/../Classes">
<os family="mac"/> <os family="mac"/>
</condition> </condition>
<property name="dir_bootclasspath" value="${java.home}/lib"/> <property name="dir_bootclasspath" value="${java.home}/lib"/>
<path id="path_bootclasspath"> <path id="path_bootclasspath">
<fileset dir="${dir_bootclasspath}"> <fileset dir="${dir_bootclasspath}">
<include name="*.jar"/> <include name="*.jar"/>
</fileset> </fileset>
</path> </path>
<property name="bootclasspath" refid="path_bootclasspath"/> <property name="bootclasspath" refid="path_bootclasspath"/>
<property name="bundleJavacSource" value="${javacSource}"/> <property name="bundleJavacSource" value="${javacSource}"/>
<property name="bundleJavacTarget" value="${javacTarget}"/> <property name="bundleJavacTarget" value="${javacTarget}"/>
<property name="bundleBootClasspath" value="${bootclasspath}"/> <property name="bundleBootClasspath" value="${bootclasspath}"/>
<target name="RhinoPresent" depends="init"> <target name="RhinoPresent" depends="init">
<available file="${plugin.destination}/lib/js.jar" property="rhino.present"/> <available file="${plugin.destination}/lib/js.jar" property="rhino.present"/>
</target> </target>
<target name="fetchRhino" depends="RhinoPresent" unless="rhino.present"> <target name="fetchRhino" depends="RhinoPresent" unless="rhino.present">
<delete dir="${temp.folder}"/> <delete dir="${temp.folder}"/>
<mkdir 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" /> <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}"/> <unzip src="${temp.folder}/rhino1_7R3.zip" dest="${temp.folder}"/>
<copy file="${temp.folder}/rhino1_7R3/js.jar" tofile="${plugin.destination}/lib/js.jar" /> <copy file="${temp.folder}/rhino1_7R3/js.jar" tofile="${plugin.destination}/lib/js.jar" />
<delete dir="${temp.folder}"/> <delete dir="${temp.folder}"/>
</target> </target>
<target name="getJars" depends="fetchRhino" /> <target name="getJars" depends="fetchRhino" />
<target name="init" depends="properties"> <target name="init" depends="properties">
<condition property="pluginTemp" value="${buildTempFolder}/plugins"> <condition property="pluginTemp" value="${buildTempFolder}/plugins">
<isset property="buildTempFolder"/> <isset property="buildTempFolder"/>
</condition> </condition>
<property name="pluginTemp" value="${basedir}"/> <property name="pluginTemp" value="${basedir}"/>
<condition property="build.result.folder" value="${pluginTemp}/com.ibm.wala.core.testdata"> <condition property="build.result.folder" value="${pluginTemp}/com.ibm.wala.core.testdata">
<isset property="buildTempFolder"/> <isset property="buildTempFolder"/>
</condition> </condition>
<property name="build.result.folder" value="${basedir}"/> <property name="build.result.folder" value="${basedir}"/>
<property name="temp.folder" value="${basedir}/temp.folder"/> <property name="temp.folder" value="${basedir}/temp.folder"/>
<property name="plugin.destination" value="${basedir}"/> <property name="plugin.destination" value="${basedir}"/>
</target> </target>
<target name="properties" if="eclipse.running"> <target name="properties" if="eclipse.running">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/> <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
</target> </target>
</project> </project>

View File

@ -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);
}
}

View File

@ -17,9 +17,9 @@ import java.util.List;
import com.ibm.wala.cast.ir.translator.TranslatorToCAst; import com.ibm.wala.cast.ir.translator.TranslatorToCAst;
import com.ibm.wala.cast.tree.CAstEntity; import com.ibm.wala.cast.tree.CAstEntity;
import com.ibm.wala.cast.tree.impl.CAstImpl; import com.ibm.wala.cast.tree.impl.CAstImpl;
import com.ibm.wala.cast.tree.impl.CAstRewriter.CopyKey; import com.ibm.wala.cast.tree.rewrite.CAstRewriterFactory;
import com.ibm.wala.cast.tree.impl.CAstRewriter.RewriteContext; import com.ibm.wala.cast.tree.rewrite.CAstRewriter.CopyKey;
import com.ibm.wala.cast.tree.impl.CAstRewriterFactory; import com.ibm.wala.cast.tree.rewrite.CAstRewriter.RewriteContext;
import com.ibm.wala.classLoader.SourceFileModule; import com.ibm.wala.classLoader.SourceFileModule;
import com.ibm.wala.classLoader.SourceModule; import com.ibm.wala.classLoader.SourceModule;

View File

@ -1046,7 +1046,14 @@ public class RhinoToAstTranslator {
@Override @Override
public CAstNode visitLabeledStatement(LabeledStatement node, WalkContext arg) { 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; AstNode prev = node;
for(Label label : node.getLabels()) { for(Label label : node.getLabels()) {
@ -1055,7 +1062,7 @@ public class RhinoToAstTranslator {
prev = label; prev = label;
} }
return result; return Ast.makeNode(CAstNode.BLOCK_STMT, result, exNode);
} }
@Override @Override

View File

@ -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>

View File

@ -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>

View File

@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.JRE_CONTAINER

View File

@ -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/

View File

@ -1,71 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project name="com.ibm.wala.cast.java.polyglot" default="getJars" basedir="."> <project name="com.ibm.wala.cast.java.polyglot" default="getJars" basedir=".">
<property name="basews" value="${ws}"/> <property name="basews" value="${ws}"/>
<property name="baseos" value="${os}"/> <property name="baseos" value="${os}"/>
<property name="basearch" value="${arch}"/> <property name="basearch" value="${arch}"/>
<property name="basenl" value="${nl}"/> <property name="basenl" value="${nl}"/>
<!-- Compiler settings. --> <!-- Compiler settings. -->
<property name="javacFailOnError" value="true"/> <property name="javacFailOnError" value="true"/>
<property name="javacDebugInfo" value="on"/> <property name="javacDebugInfo" value="on"/>
<property name="javacVerbose" value="false"/> <property name="javacVerbose" value="false"/>
<property name="logExtension" value=".log"/> <property name="logExtension" value=".log"/>
<property name="compilerArg" value=""/> <property name="compilerArg" value=""/>
<property name="javacSource" value="1.5"/> <property name="javacSource" value="1.5"/>
<property name="javacTarget" 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 <!-- 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, 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" --> try changing the value of the property to "${java.home}/../../../Classes" -->
<condition property="dir_bootclasspath" value="${java.home}/../Classes"> <condition property="dir_bootclasspath" value="${java.home}/../Classes">
<os family="mac"/> <os family="mac"/>
</condition> </condition>
<property name="dir_bootclasspath" value="${java.home}/lib"/> <property name="dir_bootclasspath" value="${java.home}/lib"/>
<path id="path_bootclasspath"> <path id="path_bootclasspath">
<fileset dir="${dir_bootclasspath}"> <fileset dir="${dir_bootclasspath}">
<include name="*.jar"/> <include name="*.jar"/>
</fileset> </fileset>
</path> </path>
<property name="bootclasspath" refid="path_bootclasspath"/> <property name="bootclasspath" refid="path_bootclasspath"/>
<property name="bundleJavacSource" value="${javacSource}"/> <property name="bundleJavacSource" value="${javacSource}"/>
<property name="bundleJavacTarget" value="${javacTarget}"/> <property name="bundleJavacTarget" value="${javacTarget}"/>
<property name="bundleBootClasspath" value="${bootclasspath}"/> <property name="bundleBootClasspath" value="${bootclasspath}"/>
<target name="ajaxsltPresent" depends="init"> <target name="ajaxsltPresent" depends="init">
<available file="${plugin.destination}/examples-src/ajaxslt" property="ajaxslt.present"/> <available file="${plugin.destination}/examples-src/ajaxslt" property="ajaxslt.present"/>
</target> </target>
<target name="fetchAjaxslt" depends="ajaxsltPresent" unless="ajaxslt.present"> <target name="fetchAjaxslt" depends="ajaxsltPresent" unless="ajaxslt.present">
<delete dir="${temp.folder}"/> <delete dir="${temp.folder}"/>
<mkdir 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" /> <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" /> <untar src="${temp.folder}/ajaxslt-0-7.tar.gz" dest="${temp.folder}" compression="gzip" />
<copy todir="${plugin.destination}/examples-src/ajaxslt"> <copy todir="${plugin.destination}/examples-src/ajaxslt">
<fileset dir="${temp.folder}/ajaxslt" /> <fileset dir="${temp.folder}/ajaxslt" />
</copy> </copy>
<delete dir="${temp.folder}"/> <delete dir="${temp.folder}"/>
</target> </target>
<target name="getJars" depends="fetchAjaxslt" /> <target name="getJars" depends="fetchAjaxslt" />
<target name="init" depends="properties"> <target name="init" depends="properties">
<condition property="pluginTemp" value="${buildTempFolder}/plugins"> <condition property="pluginTemp" value="${buildTempFolder}/plugins">
<isset property="buildTempFolder"/> <isset property="buildTempFolder"/>
</condition> </condition>
<property name="pluginTemp" value="${basedir}"/> <property name="pluginTemp" value="${basedir}"/>
<condition property="build.result.folder" value="${pluginTemp}/com.ibm.wala.core.testdata"> <condition property="build.result.folder" value="${pluginTemp}/com.ibm.wala.core.testdata">
<isset property="buildTempFolder"/> <isset property="buildTempFolder"/>
</condition> </condition>
<property name="build.result.folder" value="${basedir}"/> <property name="build.result.folder" value="${basedir}"/>
<property name="temp.folder" value="${basedir}/temp.folder"/> <property name="temp.folder" value="${basedir}/temp.folder"/>
<property name="plugin.destination" value="${basedir}"/> <property name="plugin.destination" value="${basedir}"/>
</target> </target>
<target name="properties" if="eclipse.running"> <target name="properties" if="eclipse.running">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/> <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
</target> </target>
</project> </project>

View File

@ -1,63 +1,63 @@
(function _top_level () { (function _top_level () {
var jQuery = window.jQuery = window.$ = function (selector, context) { var jQuery = window.jQuery = window.$ = function (selector, context) {
return new jQuery.fn.init(selector, context); return new jQuery.fn.init(selector, context);
}; };
var undefined; var undefined;
jQuery.extend = jQuery.fn.extend = function _extend () { jQuery.extend = jQuery.fn.extend = function _extend () {
var target = arguments[0] || {}, var target = arguments[0] || {},
i = 1, i = 1,
length = arguments.length, length = arguments.length,
deep = false, deep = false,
options; options;
if (target.constructor == Boolean) { if (target.constructor == Boolean) {
deep = target; deep = target;
target = arguments[1] || {}; target = arguments[1] || {};
i = 2; i = 2;
} }
if (typeof target != "object" && typeof target != "function") target = {}; if (typeof target != "object" && typeof target != "function") target = {};
if (length == i) { if (length == i) {
target = this; target = this;
--i; --i;
} }
for (; i < length; i++) if ((options = arguments[i]) != null) for (; i < length; i++) if ((options = arguments[i]) != null)
for (var name in options) { for (var name in options) {
(function _forin_body (name) { (function _forin_body (name) {
var src = target[name], var src = target[name],
copy = options[name]; copy = options[name];
if (target === copy) return; if (target === copy) return;
if (deep && copy && typeof copy == "object" && !copy.nodeType) { if (deep && copy && typeof copy == "object" && !copy.nodeType) {
target[name] = jQuery.extend(deep, src || (copy.length != null ? [] : {}), copy); target[name] = jQuery.extend(deep, src || (copy.length != null ? [] : {}), copy);
} }
else if (copy !== undefined) target[name] = copy; else if (copy !== undefined) target[name] = copy;
else target[name] = copy; else target[name] = copy;
})(name); })(name);
} }
return target; return target;
}; };
jQuery.extend({ jQuery.extend({
speed: function _speed (speed, easing, fn) { speed: function _speed (speed, easing, fn) {
var opt = speed && speed.constructor == Object ? speed : { var opt = speed && speed.constructor == Object ? speed : {
complete: fn || !fn && easing || jQuery.isFunction(speed) && speed, complete: fn || !fn && easing || jQuery.isFunction(speed) && speed,
duration: speed, duration: speed,
easing: fn && easing || easing && easing.constructor != Function && easing 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.duration = (opt.duration && opt.duration.constructor == Number ? opt.duration : jQuery.fx.speeds[opt.duration]) || jQuery.fx.speeds.def;
opt.old = opt.complete; opt.old = opt.complete;
opt.complete = function _complete () { opt.complete = function _complete () {
if (opt.queue !== false) jQuery(this).dequeue(); if (opt.queue !== false) jQuery(this).dequeue();
if (jQuery.isFunction(opt.old)) opt.old.call(this); if (jQuery.isFunction(opt.old)) opt.old.call(this);
}; };
return opt; return opt;
}, },
}); });
})(); })();

View File

@ -1,196 +1,196 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title> <title>Untitled Document</title>
</head> </head>
<script> <script>
var g_image_number = 0; var g_image_number = 0;
</script> </script>
<script> <script>
function test_function_base_crawling() function test_function_base_crawling()
{ {
var href; var href;
href = "results.html?"; href = "results.html?";
href += "function_base_crawling_"; href += "function_base_crawling_";
href += (12*document.location.href.length) ? "worked" : "/strange_behaviour"; href += (12*document.location.href.length) ? "worked" : "/strange_behaviour";
document.location.href = href; document.location.href = href;
} }
</script> </script>
<script> <script>
function test_event_element() function test_event_element()
{ {
var href; var href;
href = "results.html?"; href = "results.html?";
href += "event_element_"; href += "event_element_";
if (window.event == undefined) { if (window.event == undefined) {
href += (12*document.location.href.length) ? "unsupported" : "strange_behaviour"; href += (12*document.location.href.length) ? "unsupported" : "strange_behaviour";
} else if (!isNaN(window.event.srcElement)) { } else if (!isNaN(window.event.srcElement)) {
href += (12*document.location.href.length) ? "srcElement_unsupported" : "strange_behaviour"; href += (12*document.location.href.length) ? "srcElement_unsupported" : "strange_behaviour";
} else if (!isNaN(window.event.srcElement)) { } else if (!isNaN(window.event.srcElement)) {
href += (12*document.location.href.length) ? "srcElement_attr_unsupported" : "strange_behaviour"; href += (12*document.location.href.length) ? "srcElement_attr_unsupported" : "strange_behaviour";
} else { } else {
href += (12*document.location.href.length) ? "worked" : "strange_behaviour"; href += (12*document.location.href.length) ? "worked" : "strange_behaviour";
} }
document.location.href = href; document.location.href = href;
} }
</script> </script>
<script> <script>
function test_isNaN() function test_isNaN()
{ {
var href; var href;
href = "results.html?"; href = "results.html?";
href += "isNaN_"; href += "isNaN_";
if (!isNaN(window.asghdaa)) { if (!isNaN(window.asghdaa)) {
href += (12*document.location.href.length) ? "unsupported" : "strange_behaviour"; href += (12*document.location.href.length) ? "unsupported" : "strange_behaviour";
} else { } else {
href += (12*document.location.href.length) ? "worked" : "strange_behaviour"; href += (12*document.location.href.length) ? "worked" : "strange_behaviour";
} }
document.location.href = href; document.location.href = href;
} }
</script> </script>
<script> <script>
function test_first_phase() function test_first_phase()
{ {
var href; var href;
href = "results.html?"; href = "results.html?";
href += "first_phase_"; href += "first_phase_";
href += (12*document.location.href.length) ? "worked" : "/strange_behaviour"; href += (12*document.location.href.length) ? "worked" : "/strange_behaviour";
document.location.href = href; document.location.href = href;
} }
</script> </script>
<script> <script>
function test_second_phase() function test_second_phase()
{ {
var button = document.createElement("button"); var button = document.createElement("button");
button.innerText = "go to second phase html"; button.innerText = "go to second phase html";
document.body.appendChild(button); document.body.appendChild(button);
button.onclick = function () { button.onclick = function () {
var href; var href;
href = "results.html?"; href = "results.html?";
href += "second_phase_"; href += "second_phase_";
href += (12*document.location.href.length) ? "worked" : "/strange_behaviour"; href += (12*document.location.href.length) ? "worked" : "/strange_behaviour";
document.location.href = href; document.location.href = href;
}; };
var thirdButton = document.createElement("button"); var thirdButton = document.createElement("button");
thirdButton.innerText = 'Test "Third Phase Competability"'; thirdButton.innerText = 'Test "Third Phase Competability"';
thirdButton.onclick = test_third_phase; thirdButton.onclick = test_third_phase;
document.body.appendChild(thirdButton); document.body.appendChild(thirdButton);
} }
</script> </script>
<script> <script>
function test_third_phase() function test_third_phase()
{ {
var button = document.createElement("button"); var button = document.createElement("button");
button.innerText = "go to third phase html"; button.innerText = "go to third phase html";
document.body.appendChild(button); document.body.appendChild(button);
button.onclick = function () { button.onclick = function () {
var href; var href;
href = "results.html?"; href = "results.html?";
href += "third_phase_"; href += "third_phase_";
href += (12*document.location.href.length) ? "worked" : "/strange_behaviour"; href += (12*document.location.href.length) ? "worked" : "/strange_behaviour";
document.location.href = href; document.location.href = href;
} }
} }
</script> </script>
<script> <script>
function test_n_phase() function test_n_phase()
{ {
var button = document.createElement("button"); var button = document.createElement("button");
button.tag = isNaN(event.srcElement.tag) ? 1 : Number(event.srcElement.tag) + 1; button.tag = isNaN(event.srcElement.tag) ? 1 : Number(event.srcElement.tag) + 1;
button.innerText = "go to "+button.tag+" phase html"; button.innerText = "go to "+button.tag+" phase html";
button.onclick = function () { button.onclick = function () {
var href; var href;
href = "results.html?"; href = "results.html?";
href += "n_phase_"+button.tag+"_"; href += "n_phase_"+button.tag+"_";
href += (12*document.location.href.length) ? "worked" : "/strange_behaviour"; href += (12*document.location.href.length) ? "worked" : "/strange_behaviour";
document.location.href = href; document.location.href = href;
}; };
var linkButton = document.createElement("button"); var linkButton = document.createElement("button");
linkButton.tag = button.tag; linkButton.tag = button.tag;
linkButton.innerText = "create "+linkButton.tag+" phase button"; linkButton.innerText = "create "+linkButton.tag+" phase button";
linkButton.onclick = test_n_phase; linkButton.onclick = test_n_phase;
document.body.appendChild(linkButton); document.body.appendChild(linkButton);
document.body.appendChild(button); document.body.appendChild(button);
} }
</script> </script>
<script> <script>
var differentOrder = "/differnet_order_"; var differentOrder = "/differnet_order_";
</script> </script>
<script> <script>
function test_both_order2() function test_both_order2()
{ {
differentOrder += "2"; differentOrder += "2";
test_both_order_button.innerText = 'Test "Different Order Competability 2"'; test_both_order_button.innerText = 'Test "Different Order Competability 2"';
} }
</script> </script>
<script> <script>
function test_both_order() function test_both_order()
{ {
var href; var href;
href = "results.html?"; href = "results.html?";
href += "both_order_"; href += "both_order_";
href += (test_both_order_button.innerText.substr(test_both_order_button.innerText.length-2,1)); href += (test_both_order_button.innerText.substr(test_both_order_button.innerText.length-2,1));
href += ".html"; href += ".html";
document.location.href = href; document.location.href = href;
} }
</script> </script>
<script> <script>
function send_unique_dom_request() function send_unique_dom_request()
{ {
var href; var href;
href = "results.html?"; href = "results.html?";
href += "dom_unique"; href += "dom_unique";
href += ".html"; href += ".html";
document.location.href = href; document.location.href = href;
} }
</script> </script>
<script> <script>
function send_same_dom_request() function send_same_dom_request()
{ {
var href; var href;
href = "results.html?"; href = "results.html?";
href += "dom_same"; href += "dom_same";
href += ".html"; href += ".html";
document.location.href = href; document.location.href = href;
} }
</script> </script>
<script> <script>
function test_unique_dom_button2() function test_unique_dom_button2()
{ {
test_unique_dom_button.onclick = send_same_dom_request; test_unique_dom_button.onclick = send_same_dom_request;
} }
</script> </script>
<body> <body>
<BR><BR><BR><HR><BR><BR><BR> <BR><BR><BR><HR><BR><BR><BR>
<BR><button onclick = "test_event_element()">Test "Event Element"</button> <BR><button onclick = "test_event_element()">Test "Event Element"</button>
<BR><button onclick = "test_isNaN()">Test "isNaN Competability"</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_first_phase()">Test "First Phase Competability"</button>
<BR><button onclick = "test_second_phase()">Test "Second 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 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> <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> <button onclick = "test_both_order2()">Change Different Order Location</button>
<BR><button onclick = "test_unique_dom_button2()">Change Next element onclick Method</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> <button id=test_unique_dom_button onclick = "send_unique_dom_request()">Test "Unique Dom Competability"</button>
<BR> <BR>
</body> </body>
</html> </html>

View File

@ -1,4 +1,4 @@
function changeUrls() function changeUrls()
{ {
document.links[0].href = "page15.php?a=ok"; document.links[0].href = "page15.php?a=ok";
} }

View File

@ -1,4 +1,4 @@
function changeUrls() function changeUrls()
{ {
document.links[0].href = "page16.php?a=ok"; document.links[0].href = "page16.php?a=ok";
} }

View File

@ -1,4 +1,4 @@
function changeUrls() function changeUrls()
{ {
document.links[0].href = "page17.php?a=ok"; document.links[0].href = "page17.php?a=ok";
} }

View File

@ -1,25 +1,25 @@
<html> <html>
<body> <body>
<script> <script>
var myForm = document.createElement("form"); var myForm = document.createElement("form");
myForm.setAttribute("action","page11.php"); myForm.setAttribute("action","page11.php");
myForm.setAttribute("method","GET"); myForm.setAttribute("method","GET");
var myHiddenA = document.createElement("input"); var myHiddenA = document.createElement("input");
myHiddenA.setAttribute("type","hidden"); myHiddenA.setAttribute("type","hidden");
myHiddenA.setAttribute("name","a"); myHiddenA.setAttribute("name","a");
myHiddenA.setAttribute("value","ok"); myHiddenA.setAttribute("value","ok");
var myHiddenB = document.createElement("input"); var myHiddenB = document.createElement("input");
myHiddenB.setAttribute("type","hidden"); myHiddenB.setAttribute("type","hidden");
myHiddenB.setAttribute("name","b"); myHiddenB.setAttribute("name","b");
myHiddenB.setAttribute("value","ok"); myHiddenB.setAttribute("value","ok");
var mySubmit = document.createElement("input"); var mySubmit = document.createElement("input");
mySubmit.setAttribute("type","submit"); mySubmit.setAttribute("type","submit");
mySubmit.setAttribute("name","submit"); mySubmit.setAttribute("name","submit");
mySubmit.setAttribute("value","submit"); mySubmit.setAttribute("value","submit");
myForm.appendChild(myHiddenA); myForm.appendChild(myHiddenA);
myForm.appendChild(myHiddenB); myForm.appendChild(myHiddenB);
myForm.appendChild(mySubmit); myForm.appendChild(mySubmit);
document.body.appendChild(myForm); document.body.appendChild(myForm);
</script> </script>
</body> </body>
</html> </html>

View File

@ -1,31 +1,31 @@
<html> <html>
<head> <head>
<script> <script>
function handler() function handler()
{ {
if(this.readyState == 4) if(this.readyState == 4)
{ {
var contents = this.responseText; var contents = this.responseText;
document.getElementById("myDiv").innerHTML = contents; document.getElementById("myDiv").innerHTML = contents;
} }
return; return;
} }
function callXHR() function callXHR()
{ {
var textBoxValue = document.getElementById("freeTextField").value; var textBoxValue = document.getElementById("freeTextField").value;
var client = new XMLHttpRequest(); var client = new XMLHttpRequest();
client.onreadystatechange = handler; client.onreadystatechange = handler;
client.open("GET", "page12.php?freeTextField="+textBoxValue, true); client.open("GET", "page12.php?freeTextField="+textBoxValue, true);
client.send(null); client.send(null);
return; return;
} }
</script> </script>
</head> </head>
<body> <body>
<div id="myDiv" style="location: absolute; top: 100px; left: 100px; height: 400px; width: 400px; background-color: #ff0000;"></div> <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> <input type="text" id="freeTextField" name="freeTextField" value="DEFAULT_SHOULD_BE_CHANGED"></input>
<button onclick="return callXHR();">SUBMIT</button> <button onclick="return callXHR();">SUBMIT</button>
</body> </body>
</html> </html>

View File

@ -1,32 +1,32 @@
<html> <html>
<head> <head>
<script> <script>
function handler() function handler()
{ {
if(this.readyState == 4) if(this.readyState == 4)
{ {
var contents = this.responseText; var contents = this.responseText;
document.getElementById("myDiv").innerHTML = contents; document.getElementById("myDiv").innerHTML = contents;
} }
return; return;
} }
function callXHR() function callXHR()
{ {
var textBoxValue = document.getElementById("freeTextField").value; var textBoxValue = document.getElementById("freeTextField").value;
var client = new XMLHttpRequest(); var client = new XMLHttpRequest();
client.onreadystatechange = handler; client.onreadystatechange = handler;
client.open("POST", "page13.php", true); client.open("POST", "page13.php", true);
client.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); client.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
client.send("freeTextField="+textBoxValue); client.send("freeTextField="+textBoxValue);
return; return;
} }
</script> </script>
</head> </head>
<body> <body>
<div id="myDiv" style="location: absolute; top: 100px; left: 100px; height: 400px; width: 400px; background-color: #ff0000;"></div> <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> <input type="text" id="freeTextField" name="freeTextField" value="DEFAULT_SHOULD_BE_CHANGED"></input>
<button onclick="return callXHR();">SUBMIT</button> <button onclick="return callXHR();">SUBMIT</button>
</body> </body>
</html> </html>

View File

@ -1,8 +1,8 @@
<html> <html>
<head> <head>
<script src="15.js"></script> <script src="15.js"></script>
</head> </head>
<body onload="return changeUrls();"> <body onload="return changeUrls();">
<a href="#">Link to be changed onload</a> <a href="#">Link to be changed onload</a>
</body> </body>
</html> </html>

View File

@ -1,8 +1,8 @@
<html> <html>
<head> <head>
<script src="16.js"></script> <script src="16.js"></script>
</head> </head>
<body> <body>
<a href="#" onclick="return changeUrls();">Link to be changed onload</a> <a href="#" onclick="return changeUrls();">Link to be changed onload</a>
</body> </body>
</html> </html>

View File

@ -1,37 +1,37 @@
<html> <html>
<head> <head>
<script> <script>
function loadScript(url, callback) function loadScript(url, callback)
{ {
var head = document.getElementsByTagName("head")[0]; var head = document.getElementsByTagName("head")[0];
var script = document.createElement("script"); var script = document.createElement("script");
script.src = url; script.src = url;
var done = false; var done = false;
script.onload = script.onreadystatechange = function _page17_handler() script.onload = script.onreadystatechange = function _page17_handler()
{ {
if( !done && ( !this.readyState || this.readyState == "loaded" || this.readyState == "complete")) if( !done && ( !this.readyState || this.readyState == "loaded" || this.readyState == "complete"))
{ {
done = true; done = true;
callback(); callback();
script.onload = script.onreadystatechange = null; script.onload = script.onreadystatechange = null;
head.removeChild( script ); head.removeChild( script );
} }
}; };
head.appendChild(script); head.appendChild(script);
} }
function callFunction() function callFunction()
{ {
changeUrls(); changeUrls();
} }
</script> </script>
</head> </head>
<body> <body>
<a href="#">Test Link</a> <a href="#">Test Link</a>
<script> <script>
loadScript("17.js", callFunction); loadScript("17.js", callFunction);
</script> </script>
</body> </body>
</html> </html>

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