diff --git a/com.ibm.wala.cast.java.test.data/src/javaonepointfive/AnonymousGenerics.java b/com.ibm.wala.cast.java.test.data/src/javaonepointfive/AnonymousGenerics.java
index d518478d8..1ab55e264 100644
--- a/com.ibm.wala.cast.java.test.data/src/javaonepointfive/AnonymousGenerics.java
+++ b/com.ibm.wala.cast.java.test.data/src/javaonepointfive/AnonymousGenerics.java
@@ -83,5 +83,9 @@ public class AnonymousGenerics {
Ops hack = ops;
hack.unary("whatever");
+ hack.nullary();
+ hack = strQuadrupler;
+ hack.unary("whatever");
+ hack.nullary();
}
}
diff --git a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/vis/JsViewerDriver.java b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/vis/JsViewerDriver.java
index 370e1a562..58d527391 100644
--- a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/vis/JsViewerDriver.java
+++ b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/vis/JsViewerDriver.java
@@ -9,6 +9,7 @@ import com.ibm.wala.cast.js.html.DomLessSourceExtractor;
import com.ibm.wala.cast.js.html.IdentityUrlResolver;
import com.ibm.wala.cast.js.html.JSSourceExtractor;
import com.ibm.wala.cast.js.html.MappedSourceModule;
+import com.ibm.wala.cast.js.html.WebPageLoaderFactory;
import com.ibm.wala.cast.js.html.WebUtil;
import com.ibm.wala.cast.js.html.jericho.JerichoHtmlParser;
import com.ibm.wala.cast.js.ipa.callgraph.JSCFABuilder;
@@ -22,7 +23,7 @@ import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
import com.ibm.wala.ipa.cha.ClassHierarchyException;
import com.ibm.wala.util.CancelException;
-public class JsViewerDriver {
+public class JsViewerDriver extends Util {
public static void main(String args[]) throws ClassHierarchyException, IllegalArgumentException, IOException, CancelException {
if (args.length != 1){
@@ -39,7 +40,7 @@ public class JsViewerDriver {
SourceModule[] sources = getSources(domless, url);
- JSCFABuilder builder = Util.makeCGBuilder(sources, false);
+ JSCFABuilder builder = makeCGBuilder(new WebPageLoaderFactory(translatorFactory), sources, false);
builder.setBaseURL(url);
CallGraph cg = builder.makeCallGraph(builder.getOptions());
diff --git a/com.ibm.wala.cast.js.rhino.test/launchers/TestForInLoopHackRhino.launch b/com.ibm.wala.cast.js.rhino.test/launchers/TestForInLoopHackRhino.launch
new file mode 100644
index 000000000..79d51bc9d
--- /dev/null
+++ b/com.ibm.wala.cast.js.rhino.test/launchers/TestForInLoopHackRhino.launch
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.cast.js.rhino.test/launchers/TestMozillaBugPagesRhino.launch b/com.ibm.wala.cast.js.rhino.test/launchers/TestMozillaBugPagesRhino.launch
new file mode 100644
index 000000000..b3f21cb55
--- /dev/null
+++ b/com.ibm.wala.cast.js.rhino.test/launchers/TestMozillaBugPagesRhino.launch
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.cast.js.test/examples-src/pages/jquery.html b/com.ibm.wala.cast.js.test/examples-src/pages/jquery.html
new file mode 100644
index 000000000..2bae2851f
--- /dev/null
+++ b/com.ibm.wala.cast.js.test/examples-src/pages/jquery.html
@@ -0,0 +1,263 @@
+
+
+
+
+ Untitled Document
+
+
diff --git a/com.ibm.wala.cast.js.test/examples-src/pages/jquery_hacked.html b/com.ibm.wala.cast.js.test/examples-src/pages/jquery_hacked.html
new file mode 100644
index 000000000..a37b6e147
--- /dev/null
+++ b/com.ibm.wala.cast.js.test/examples-src/pages/jquery_hacked.html
@@ -0,0 +1,288 @@
+
+
+
+
+ Untitled Document
+
+
diff --git a/com.ibm.wala.cast.js.test/examples-src/pages/windowx.html b/com.ibm.wala.cast.js.test/examples-src/pages/windowx.html
new file mode 100644
index 000000000..3f508f7f3
--- /dev/null
+++ b/com.ibm.wala.cast.js.test/examples-src/pages/windowx.html
@@ -0,0 +1,33 @@
+
+
+Welcome!
+
+Hi
+
+
+
+
+Welcome to our system
+
+
diff --git a/com.ibm.wala.cast.js.test/examples-src/tests/simple-lexical.js b/com.ibm.wala.cast.js.test/examples-src/tests/simple-lexical.js
index 6fe192159..8eebe49af 100644
--- a/com.ibm.wala.cast.js.test/examples-src/tests/simple-lexical.js
+++ b/com.ibm.wala.cast.js.test/examples-src/tests/simple-lexical.js
@@ -69,4 +69,46 @@ function outer( x ) {
return x+z;
}
+function c2() {
+
+}
+
+function c3() {
+
+}
+
+function fa2(x) {
+ x();
+}
+
+function fa3(x) {
+ x();
+}
+
+function aa() {
+ var c1 = function _c1() {
+
+ }
+
+ var fa = function _fa1(x) {
+ x();
+ }
+
+ function bb(x) {
+ fa = x;
+ }
+
+ fa(c1);
+
+ bb(fa2);
+
+ fa(c2);
+
+ bb(fa3);
+
+ fa(c3);
+}
+
var result = outer( 5 );
+
+aa();
diff --git a/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/TestForInLoopHack.java b/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/TestForInLoopHack.java
index 20fe4c5a6..b916973bc 100644
--- a/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/TestForInLoopHack.java
+++ b/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/TestForInLoopHack.java
@@ -45,6 +45,24 @@ public class TestForInLoopHack extends TestJSCallGraphShape {
Util.dumpCG(builder.getPointerAnalysis(), CG);
}
+ @Test public void testJQueryWithHack() throws IOException, IllegalArgumentException, CancelException {
+ URL url = getClass().getClassLoader().getResource("pages/jquery_hacked.html");
+ JSCFABuilder builder = Util.makeHTMLCGBuilder(url);
+ addHackedForInLoopSensitivity(builder);
+ CallGraph CG = builder.makeCallGraph(builder.getOptions());
+ Util.dumpCG(builder.getPointerAnalysis(), CG);
+ }
+
+ /*
+ @Test public void testJQueryEx1WithHack() throws IOException, IllegalArgumentException, CancelException {
+ URL url = getClass().getClassLoader().getResource("pages/jquery/ex1.html");
+ JSCFABuilder builder = Util.makeHTMLCGBuilder(url);
+ addHackedForInLoopSensitivity(builder);
+ CallGraph CG = builder.makeCallGraph(builder.getOptions());
+ Util.dumpCG(builder.getPointerAnalysis(), CG);
+ }
+ */
+
private static final Object[][] assertionsForBadForin = new Object[][] {
new Object[] { ROOT,
new String[] { "tests/badforin.js" } },
diff --git a/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/TestMediawikiCallGraphShape.java b/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/TestMediawikiCallGraphShape.java
index 4370272a0..85eea6497 100644
--- a/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/TestMediawikiCallGraphShape.java
+++ b/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/TestMediawikiCallGraphShape.java
@@ -32,6 +32,7 @@ public abstract class TestMediawikiCallGraphShape extends TestJSCallGraphShape {
URL url = new URL("http://en.wikipedia.org/wiki/2009_swine_flu_outbreak");
CallGraph CG = Util.makeHTMLCG(url);
verifyGraphAssertions(CG, assertionsForSwineFlu);
+ System.err.println(CG);
}
}
diff --git a/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/TestSimplePageCallGraphShape.java b/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/TestSimplePageCallGraphShape.java
index 7488e368d..48e2e5eb4 100644
--- a/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/TestSimplePageCallGraphShape.java
+++ b/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/TestSimplePageCallGraphShape.java
@@ -281,12 +281,31 @@ public abstract class TestSimplePageCallGraphShape extends TestJSCallGraphShape
Util.makeHTMLCG(url);
}
+ private static final Object[][] assertionsForWindowx = new Object[][] {
+ new Object[] { ROOT, new String[] { "windowx.html" } },
+ new Object[] { "windowx.html", new String[] { "windowx.html/__WINDOW_MAIN__" } },
+ new Object[] { "windowx.html/__WINDOW_MAIN__", new String[] { "windowx.html/__WINDOW_MAIN__/_f2", "windowx.html/__WINDOW_MAIN__/_f4" } },
+ new Object[] { "windowx.html/__WINDOW_MAIN__/_f2", new String[] { "windowx.html/__WINDOW_MAIN__/_f1" } },
+ new Object[] { "windowx.html/__WINDOW_MAIN__/_f4", new String[] { "windowx.html/__WINDOW_MAIN__/_f3" } }
+
+ };
+
+ @Test public void testWindowx() throws IOException, IllegalArgumentException, CancelException {
+ URL url = getClass().getClassLoader().getResource("pages/windowx.html");
+ JSCFABuilder builder = Util.makeHTMLCGBuilder(url);
+ CallGraph CG = builder.makeCallGraph(builder.getOptions());
+ Util.dumpCG(builder.getPointerAnalysis(), CG);
+ verifyGraphAssertions(CG, assertionsForWindowx);
+ }
+
/*
@Test public void testJQuery() throws IOException, IllegalArgumentException, CancelException {
URL url = getClass().getClassLoader().getResource("pages/jquery.html");
CallGraph CG = Util.makeHTMLCG(url);
}
+ */
+ /*
@Test public void testDojoTest() throws IllegalArgumentException, IOException, CancelException {
URL url = getClass().getClassLoader().getResource("pages/dojo/test.html");
CallGraph CG = Util.makeHTMLCG(url);
diff --git a/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/Util.java b/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/Util.java
index f6a9edb81..cb7003674 100644
--- a/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/Util.java
+++ b/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/Util.java
@@ -19,6 +19,7 @@ import java.util.Set;
import junit.framework.Assert;
import com.ibm.wala.cast.js.html.MappedSourceModule;
+import com.ibm.wala.cast.js.html.WebPageLoaderFactory;
import com.ibm.wala.cast.js.html.WebUtil;
import com.ibm.wala.cast.js.ipa.callgraph.JSCFABuilder;
import com.ibm.wala.cast.js.ipa.callgraph.JSZeroOrOneXCFABuilder;
@@ -77,7 +78,7 @@ public class Util extends com.ibm.wala.cast.js.ipa.callgraph.Util {
public static CallGraph makeScriptCG(SourceModule[] scripts, boolean useOneCFA) throws IOException, IllegalArgumentException,
CancelException {
- PropagationCallGraphBuilder b = makeCGBuilder(scripts, useOneCFA);
+ PropagationCallGraphBuilder b = makeCGBuilder(makeLoaders(), scripts, useOneCFA);
CallGraph CG = b.makeCallGraph(b.getOptions());
dumpCG(b.getPointerAnalysis(), CG);
return CG;
@@ -86,7 +87,7 @@ public class Util extends com.ibm.wala.cast.js.ipa.callgraph.Util {
public static JSCFABuilder makeHTMLCGBuilder(URL url) throws IOException {
JavaScriptLoader.addBootstrapFile(WebUtil.preamble);
Set script = WebUtil.extractScriptFromHTML(url);
- JSCFABuilder builder = makeCGBuilder(script.toArray(new SourceModule[script.size()]), false);
+ JSCFABuilder builder = makeCGBuilder(new WebPageLoaderFactory(translatorFactory), script.toArray(new SourceModule[script.size()]), false);
builder.setBaseURL(url);
return builder;
}
@@ -105,8 +106,7 @@ public class Util extends com.ibm.wala.cast.js.ipa.callgraph.Util {
return CG;
}
- public static JSCFABuilder makeCGBuilder(SourceModule[] scripts, boolean useOneCFA) throws IOException {
- JavaScriptLoaderFactory loaders = makeLoaders();
+ public static JSCFABuilder makeCGBuilder(JavaScriptLoaderFactory loaders, SourceModule[] scripts, boolean useOneCFA) throws IOException {
AnalysisScope scope = makeScope(scripts, loaders, JavaScriptLoader.JS);
return makeCG(loaders, scope, useOneCFA);
}
diff --git a/com.ibm.wala.cast.js/dat/preamble.js b/com.ibm.wala.cast.js/dat/preamble.js
index 4f5923535..5d53c3f2c 100644
--- a/com.ibm.wala.cast.js/dat/preamble.js
+++ b/com.ibm.wala.cast.js/dat/preamble.js
@@ -15,7 +15,7 @@ note_post_parameters = function notePostParameters(url) {
// hook for analysis of Web pages
};
-function NamedNodeList() {
+NamedNodeList = function NamedNodeList() {
var maxLength = 10;
var local = new Array(10);
var counter = -1;
@@ -85,7 +85,7 @@ function NamedNodeList() {
}
}
-function DOMNode() { // An impostor for the Node class
+DOMNode = function DOMNode() { // An impostor for the Node class
this.childNodes = new NamedNodeList();
this.insertBefore = function insertBefore(newChild, refChild) {
this.childNodes.insertBefore(newChild, refChild);
@@ -116,7 +116,7 @@ function DOMNode() { // An impostor for the Node class
}
}
-function DOMDocument() {
+DOMDocument = function DOMDocument() {
this.temp = DOMNode;
this.temp();
@@ -137,11 +137,11 @@ function DOMDocument() {
};
}
-function HTMLBody(){
+HTMLBody = function HTMLBody(){
this.innerHTML = new String();
}
-function DOMHTMLDocument() {
+DOMHTMLDocument = function DOMHTMLDocument() {
this.temp = DOMDocument;
this.temp();
this.URL = new String();
@@ -150,7 +150,7 @@ function DOMHTMLDocument() {
}
-function Location(){
+Location = function Location(){
this.host = new String();
this.hostname = new String();
this.href = new String();
@@ -163,14 +163,14 @@ function Location(){
}
-function DOMWindow(){
+DOMWindow = function DOMWindow(){
this.name = new String();
this.open = function window_open(url, stuff) {
note_url(url);
};
}
-function DOJOObj(){
+DOJOObj = function DOJOObj(){
this.moduleUrl = function module_url(str1, str2){
return str1 + str2;
}
@@ -194,7 +194,7 @@ window.XMLHttpRequest = XMLHttpRequest;
var dojo = new DOJOObj();
-function DOMElement() { // An impostor for the Element class
+DOMElement = function DOMElement() { // An impostor for the Element class
// inherits from Node
this.temp = DOMNode;
this.temp();
@@ -215,7 +215,7 @@ function DOMElement() { // An impostor for the Element class
}
-function DOMHTMLElement() { // An impostor for the HTMLElement class
+DOMHTMLElement = function DOMHTMLElement() { // An impostor for the HTMLElement class
// inherits from Element
this.temp = DOMElement;
this.temp();
@@ -234,7 +234,7 @@ function DOMHTMLElement() { // An impostor for the HTMLElement class
var dynamic_node = 0;
// Just a hack until all HTML elements have corresponding constructors
-function DOMHTMLGenericElement(tagName) {
+DOMHTMLGenericElement = function DOMHTMLGenericElement(tagName) {
// inherits from Element
this.temp = DOMHTMLElement;
this.temp();
@@ -253,7 +253,7 @@ function DOMHTMLGenericElement(tagName) {
var formCount = 0;
-function DOMHTMLFormElement() {
+DOMHTMLFormElement = function DOMHTMLFormElement() {
// inherits from HTMLElement
this.temp = DOMHTMLElement;
this.temp();
@@ -281,7 +281,7 @@ function DOMHTMLFormElement() {
this.target = null;
}
-function DOMHTMLTableElement () {
+DOMHTMLTableElement = function DOMHTMLTableElement () {
// inherits from HTMLElement
this.temp = DOMHTMLElement;
this.temp();
diff --git a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/html/WebPageLoaderFactory.java b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/html/WebPageLoaderFactory.java
new file mode 100644
index 000000000..c42ba63fb
--- /dev/null
+++ b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/html/WebPageLoaderFactory.java
@@ -0,0 +1,91 @@
+package com.ibm.wala.cast.js.html;
+
+import com.ibm.wala.cast.ir.translator.TranslatorToIR;
+import com.ibm.wala.cast.js.loader.JavaScriptLoader;
+import com.ibm.wala.cast.js.loader.JavaScriptLoaderFactory;
+import com.ibm.wala.cast.js.ssa.JSInstructionFactory;
+import com.ibm.wala.cast.js.translator.JSAstTranslator;
+import com.ibm.wala.cast.js.translator.JavaScriptTranslatorFactory;
+import com.ibm.wala.cast.tree.CAst;
+import com.ibm.wala.cast.tree.CAstNode;
+import com.ibm.wala.cast.tree.impl.CAstImpl;
+import com.ibm.wala.cast.tree.impl.CAstOperator;
+import com.ibm.wala.classLoader.IClassLoader;
+import com.ibm.wala.ipa.cha.IClassHierarchy;
+
+public class WebPageLoaderFactory extends JavaScriptLoaderFactory {
+
+ public WebPageLoaderFactory(JavaScriptTranslatorFactory factory) {
+ super(factory);
+ }
+
+ @Override
+ protected IClassLoader makeTheLoader(IClassHierarchy cha) {
+ return new JavaScriptLoader( cha, translatorFactory ) {
+ @Override
+ protected TranslatorToIR initTranslator() {
+ return new JSAstTranslator(this) {
+ private final CAst Ast = new CAstImpl();
+
+ private boolean isScriptBody(WalkContext context) {
+ return context.top().getName().equals( "__WINDOW_MAIN__" );
+ }
+
+ @Override
+ protected int doGlobalRead(CAstNode n, WalkContext context, String name) {
+ int result = context.currentScope().allocateTempValue();
+ if (isScriptBody(context) && ! "$$undefined".equals(name) && ! "window".equals(name)) {
+
+ // check if field is defined on 'window'
+ int windowVal = super.doLocalRead(context, "this");
+ int isDefined = context.currentScope().allocateTempValue();
+ context.currentScope().getConstantValue(name);
+ doIsFieldDefined(context, isDefined, windowVal, Ast.makeConstant(name));
+ context.cfg().addInstruction(
+ insts.ConditionalBranchInstruction(
+ translateConditionOpcode(CAstOperator.OP_NE),
+ null,
+ isDefined,
+ context.currentScope().getConstantValue(new Integer(0))));
+ PreBasicBlock srcB = context.cfg().getCurrentBlock();
+
+ // field lookup of value
+ context.cfg().newBlock(true);
+ context.cfg().addInstruction(((JSInstructionFactory) insts).GetInstruction(result, windowVal, name));
+ context.cfg().addInstruction(insts.GotoInstruction());
+ PreBasicBlock trueB = context.cfg().getCurrentBlock();
+
+ // read global
+ context.cfg().newBlock(false);
+ PreBasicBlock falseB = context.cfg().getCurrentBlock();
+ int sr = super.doGlobalRead(n, context, name);
+ context.cfg().addInstruction(((JSInstructionFactory) insts).AssignInstruction(result, sr));
+
+ // end
+ context.cfg().newBlock(true);
+
+ context.cfg().addEdge(trueB, context.cfg().getCurrentBlock());
+ context.cfg().addEdge(srcB, falseB);
+
+ return result;
+
+ } else {
+ return super.doGlobalRead(n, context, name);
+ }
+ }
+
+ @Override
+ protected void doLocalWrite(WalkContext context, String nm, int rval) {
+ if (isScriptBody(context)) {
+ int windowVal = super.doLocalRead(context, "this");
+ context.currentScope().getConstantValue(nm);
+ context.cfg().addInstruction(((JSInstructionFactory) insts).PutInstruction(windowVal, rval, nm));
+ }
+
+ super.doLocalWrite(context, nm, rval);
+ }
+ };
+ }
+ };
+ }
+}
diff --git a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JSSSAPropagationCallGraphBuilder.java b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JSSSAPropagationCallGraphBuilder.java
index 44832c3e1..759ed06a9 100755
--- a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JSSSAPropagationCallGraphBuilder.java
+++ b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JSSSAPropagationCallGraphBuilder.java
@@ -482,7 +482,7 @@ public class JSSSAPropagationCallGraphBuilder extends AstSSAPropagationCallGraph
IR sourceIR = getCFAContextInterpreter().getIR(caller);
SymbolTable sourceST = sourceIR.getSymbolTable();
-
+
IR targetIR = getCFAContextInterpreter().getIR(target);
SymbolTable targetST = targetIR.getSymbolTable();
@@ -504,7 +504,7 @@ public class JSSSAPropagationCallGraphBuilder extends AstSSAPropagationCallGraph
// pass actual arguments to formals in the normal way
for (int i = 0; i < Math.min(paramCount, argCount); i++) {
- int fn = targetST.getConstant(i);
+ InstanceKey[] fn = new InstanceKey[]{ getInstanceKeyForConstant(JavaScriptTypes.Number, i) };
PointerKey F = getTargetPointerKey(target, i);
if (constParams != null && constParams[i] != null) {
@@ -528,7 +528,7 @@ public class JSSSAPropagationCallGraphBuilder extends AstSSAPropagationCallGraph
if (paramCount < argCount) {
if (av != -1) {
for (int i = paramCount; i < argCount; i++) {
- int fn = targetST.getConstant(i);
+ InstanceKey[] fn = new InstanceKey[]{ getInstanceKeyForConstant(JavaScriptTypes.Number, i) };
if (constParams != null && constParams[i] != null) {
targetVisitor.newFieldWrite(target, av, fn, constParams[i]);
} else {
@@ -554,8 +554,8 @@ public class JSSSAPropagationCallGraphBuilder extends AstSSAPropagationCallGraph
// write `length' in argument objects
if (av != -1) {
- int svn = targetST.getConstant(argCount);
- int lnv = targetST.getConstant("length");
+ InstanceKey[] svn = new InstanceKey[]{ getInstanceKeyForConstant(JavaScriptTypes.Number, argCount) };
+ InstanceKey[] lnv = new InstanceKey[]{ getInstanceKeyForConstant(JavaScriptTypes.String, "length") };
targetVisitor.newFieldWrite(target, av, lnv, svn);
}
diff --git a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JSZeroOrOneXCFABuilder.java b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JSZeroOrOneXCFABuilder.java
index 1c41d8200..8d7a407d2 100644
--- a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JSZeroOrOneXCFABuilder.java
+++ b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JSZeroOrOneXCFABuilder.java
@@ -10,6 +10,7 @@
*****************************************************************************/
package com.ibm.wala.cast.js.ipa.callgraph;
+import com.ibm.wala.cast.ipa.callgraph.LexicalScopingResolverContexts;
import com.ibm.wala.cast.ipa.callgraph.ScopeMappingKeysContextSelector;
import com.ibm.wala.ipa.callgraph.AnalysisCache;
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
@@ -42,6 +43,7 @@ public class JSZeroOrOneXCFABuilder extends JSCFABuilder {
ContextSelector contextSelector = appContextSelector == null ? def : new DelegatingContextSelector(appContextSelector, def);
contextSelector = new ScopeMappingKeysContextSelector(contextSelector);
contextSelector = new JavaScriptConstructorContextSelector(contextSelector);
+ contextSelector = new LexicalScopingResolverContexts(this, contextSelector);
if (doOneCFA) {
contextSelector = new nCFAContextSelector(1, contextSelector);
}
diff --git a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/Util.java b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/Util.java
index 6d4899821..34cf585ef 100755
--- a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/Util.java
+++ b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/Util.java
@@ -58,7 +58,7 @@ public class Util extends com.ibm.wala.cast.ipa.callgraph.Util {
* the translator factory to be used for analysis TODO: pass the factory where
* needed instead of using a global?
*/
- private static JavaScriptTranslatorFactory translatorFactory;
+ protected static JavaScriptTranslatorFactory translatorFactory;
/**
* Set up the translator factory. This method should be called before invoking
diff --git a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/loader/JavaScriptLoaderFactory.java b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/loader/JavaScriptLoaderFactory.java
index 2fad42b9d..f147b19cc 100755
--- a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/loader/JavaScriptLoaderFactory.java
+++ b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/loader/JavaScriptLoaderFactory.java
@@ -21,7 +21,7 @@ import com.ibm.wala.types.ClassLoaderReference;
* Creates the single {@link IClassLoader class loader} used for JavaScript.
*/
public class JavaScriptLoaderFactory extends SingleClassLoaderFactory {
- private final JavaScriptTranslatorFactory translatorFactory;
+ protected final JavaScriptTranslatorFactory translatorFactory;
public JavaScriptLoaderFactory(JavaScriptTranslatorFactory factory) {
this.translatorFactory = factory;
diff --git a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/translator/JSAstTranslator.java b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/translator/JSAstTranslator.java
index 53cf60b6e..a6d109a31 100644
--- a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/translator/JSAstTranslator.java
+++ b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/translator/JSAstTranslator.java
@@ -58,7 +58,7 @@ public class JSAstTranslator extends AstTranslator {
}
protected boolean treatGlobalsAsLexicallyScoped() {
- return true;
+ return false;
}
protected boolean useLocalValuesForLexicalVars() {
@@ -145,12 +145,7 @@ public class JSAstTranslator extends AstTranslator {
// force creation of these constants by calling the getter methods
symtab.getNullConstant();
- symtab.getConstant("arguments");
- symtab.getConstant("length");
- for (int i = 0; i < 20; i++) {
- symtab.getConstant(i);
- }
-
+
((JavaScriptLoader) loader).defineCodeBodyCode("L" + fnName, cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, LI,
debugInfo);
}
diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstSSAPropagationCallGraphBuilder.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstSSAPropagationCallGraphBuilder.java
index e9e8f25b6..af9b7454f 100644
--- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstSSAPropagationCallGraphBuilder.java
+++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstSSAPropagationCallGraphBuilder.java
@@ -17,6 +17,7 @@ import java.util.Set;
import com.ibm.wala.analysis.reflection.ReflectionContextInterpreter;
import com.ibm.wala.cast.ipa.callgraph.AstCallGraph.AstCGNode;
+import com.ibm.wala.cast.ipa.callgraph.LexicalScopingResolverContexts.Resolver;
import com.ibm.wala.cast.ipa.callgraph.ScopeMappingInstanceKeys.ScopeMappingInstanceKey;
import com.ibm.wala.cast.ir.ssa.AbstractLexicalInvoke;
import com.ibm.wala.cast.ir.ssa.AstAssertInstruction;
@@ -26,6 +27,7 @@ import com.ibm.wala.cast.ir.ssa.AstGlobalWrite;
import com.ibm.wala.cast.ir.ssa.AstIRFactory.AstIR;
import com.ibm.wala.cast.ir.ssa.AstInstructionVisitor;
import com.ibm.wala.cast.ir.ssa.AstIsDefinedInstruction;
+import com.ibm.wala.cast.ir.ssa.AstLexicalAccess;
import com.ibm.wala.cast.ir.ssa.AstLexicalAccess.Access;
import com.ibm.wala.cast.ir.ssa.AstLexicalRead;
import com.ibm.wala.cast.ir.ssa.AstLexicalWrite;
@@ -301,39 +303,30 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
return ((AstPointerKeyFactory) getBuilder().getPointerKeyFactory()).getPointerKeysForReflectedFieldWrite(I, F);
}
- private void visitLexical(final LexicalOperator op) {
- final PointerKey function = getPointerKeyForLocal(1);
- if (contentsAreInvariant(symbolTable, du, 1)) {
- op.doLexicalPointerKeys();
- } else {
- system.newSideEffect(op, function);
+ private void visitLexical(AstLexicalAccess instruction, final LexicalOperator op) {
+ op.doLexicalPointerKeys(false);
+ if (! checkLexicalInstruction(instruction)) {
+ system.newSideEffect(op, getPointerKeyForLocal(1));
}
-
- // when a new caller is added for node, re-process the lexical access
- class LexicalScopingCallback implements Function