Some refactoring of prologue.js and preamble.js to use more consistent
names.
This commit is contained in:
parent
24eb803211
commit
e130a5b963
|
@ -67,7 +67,7 @@ public abstract class TestSimpleCallGraphShape extends TestJSCallGraphShape {
|
|||
new Object[] { "tests/simple.js/rubbish",
|
||||
new String[] { "tests/simple.js/weirder", "tests/simple.js/stranger", "tests/simple.js/rubbish" } },
|
||||
new Object[] { "tests/simple.js/fib", new String[] { "tests/simple.js/fib" } },
|
||||
new Object[] { "tests/simple.js/weirder", new String[] { "prologue.js/abs" } } };
|
||||
new Object[] { "tests/simple.js/weirder", new String[] { "prologue.js/Math_abs" } } };
|
||||
|
||||
@Test
|
||||
public void testSimple() throws IOException, IllegalArgumentException, CancelException {
|
||||
|
@ -241,7 +241,7 @@ public abstract class TestSimpleCallGraphShape extends TestJSCallGraphShape {
|
|||
|
||||
private static final Object[][] assertionsForStringPrims = new Object[][] {
|
||||
new Object[] { ROOT, new String[] { "tests/string-prims.js" } },
|
||||
new Object[] { "tests/string-prims.js", new String[] { "prologue.js/stringSplit", "prologue.js/toUpperCase" } } };
|
||||
new Object[] { "tests/string-prims.js", new String[] { "prologue.js/String_prototype_split", "prologue.js/String_prototype_toUpperCase" } } };
|
||||
|
||||
@Test
|
||||
public void testStringPrims() throws IOException, IllegalArgumentException, CancelException {
|
||||
|
@ -486,7 +486,7 @@ public abstract class TestSimpleCallGraphShape extends TestJSCallGraphShape {
|
|||
|
||||
private static final Object[][] assertionsForFunctionIsAFunction = new Object[][] {
|
||||
new Object[] { ROOT, new String[] { "tests/Function_is_a_function.js" } },
|
||||
new Object[] { "suffix:Function_is_a_function.js", new String[] { "suffix:functionCall" } } };
|
||||
new Object[] { "suffix:Function_is_a_function.js", new String[] { "suffix:Function_prototype_call" } } };
|
||||
|
||||
@Test
|
||||
public void testFunctionIsAFunction() throws IOException, IllegalArgumentException, CancelException {
|
||||
|
|
|
@ -44,9 +44,9 @@ public abstract class TestSimplePageCallGraphShape extends TestJSCallGraphShape
|
|||
new Object[] { ROOT, new String[] { "page1.html" } },
|
||||
new Object[] { "page1.html", new String[] { "page1.html/__WINDOW_MAIN__" } },
|
||||
new Object[] { "page1.html/__WINDOW_MAIN__",
|
||||
new String[] { "prologue.js/substring",
|
||||
"prologue.js/indexOf",
|
||||
"preamble.js/DOMDocument/write_to_dom",
|
||||
new String[] { "prologue.js/String_prototype_substring",
|
||||
"prologue.js/String_prototype_indexOf",
|
||||
"preamble.js/DOMDocument/Document_prototype_write",
|
||||
"prologue.js/encodeURI"
|
||||
}
|
||||
}
|
||||
|
@ -73,9 +73,9 @@ public abstract class TestSimplePageCallGraphShape extends TestJSCallGraphShape
|
|||
new Object[] { ROOT, new String[] { "page11.html" } },
|
||||
new Object[] { "page11.html", new String[] { "page11.html/__WINDOW_MAIN__" } },
|
||||
new Object[] { "page11.html/__WINDOW_MAIN__",
|
||||
new String[] { "preamble.js/DOMDocument/createElement",
|
||||
"preamble.js/DOMNode/appendChild",
|
||||
"preamble.js/DOMElement/setAttribute"
|
||||
new String[] { "preamble.js/DOMDocument/Document_prototype_createElement",
|
||||
"preamble.js/DOMNode/Node_prototype_appendChild",
|
||||
"preamble.js/DOMElement/Element_prototype_setAttribute"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -90,9 +90,9 @@ public abstract class TestSimplePageCallGraphShape extends TestJSCallGraphShape
|
|||
new Object[] { ROOT, new String[] { "page11b.html" } },
|
||||
new Object[] { "page11b.html", new String[] { "page11b.html/__WINDOW_MAIN__" } },
|
||||
new Object[] { "page11b.html/__WINDOW_MAIN__",
|
||||
new String[] { "preamble.js/DOMDocument/createElement",
|
||||
"preamble.js/DOMNode/appendChild",
|
||||
"preamble.js/DOMElement/setAttribute"
|
||||
new String[] { "preamble.js/DOMDocument/Document_prototype_createElement",
|
||||
"preamble.js/DOMNode/Node_prototype_appendChild",
|
||||
"preamble.js/DOMElement/Element_prototype_setAttribute"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -113,18 +113,18 @@ public abstract class TestSimplePageCallGraphShape extends TestJSCallGraphShape
|
|||
}
|
||||
},
|
||||
new Object[]{ "page12.html/__WINDOW_MAIN__/callXHR",
|
||||
new String[] { "preamble.js/DOMDocument/getElementById",
|
||||
"preamble.js/_XMLHttpRequest/xhr_open",
|
||||
"preamble.js/_XMLHttpRequest/xhr_send"
|
||||
new String[] { "preamble.js/DOMDocument/Document_prototype_getElementById",
|
||||
"preamble.js/XMLHttpRequest/xhr_open",
|
||||
"preamble.js/XMLHttpRequest/xhr_send"
|
||||
}
|
||||
},
|
||||
new Object[]{ "preamble.js/_XMLHttpRequest/xhr_open",
|
||||
new String[] { "preamble.js/_XMLHttpRequest/xhr_orsc_handler" }
|
||||
new Object[]{ "preamble.js/XMLHttpRequest/xhr_open",
|
||||
new String[] { "preamble.js/XMLHttpRequest/xhr_orsc_handler" }
|
||||
},
|
||||
new Object[]{ "preamble.js/_XMLHttpRequest/xhr_send",
|
||||
new String[] { "preamble.js/_XMLHttpRequest/xhr_orsc_handler" }
|
||||
new Object[]{ "preamble.js/XMLHttpRequest/xhr_send",
|
||||
new String[] { "preamble.js/XMLHttpRequest/xhr_orsc_handler" }
|
||||
},
|
||||
new Object[]{ "preamble.js/_XMLHttpRequest/xhr_orsc_handler",
|
||||
new Object[]{ "preamble.js/XMLHttpRequest/xhr_orsc_handler",
|
||||
new String[] { "page12.html/__WINDOW_MAIN__/handler" }
|
||||
},
|
||||
};
|
||||
|
@ -145,19 +145,19 @@ public abstract class TestSimplePageCallGraphShape extends TestJSCallGraphShape
|
|||
}
|
||||
},
|
||||
new Object[]{ "page13.html/__WINDOW_MAIN__/callXHR",
|
||||
new String[] { "preamble.js/DOMDocument/getElementById",
|
||||
"preamble.js/_XMLHttpRequest/xhr_open",
|
||||
"preamble.js/_XMLHttpRequest/xhr_setRequestHeader",
|
||||
"preamble.js/_XMLHttpRequest/xhr_send"
|
||||
new String[] { "preamble.js/DOMDocument/Document_prototype_getElementById",
|
||||
"preamble.js/XMLHttpRequest/xhr_open",
|
||||
"preamble.js/XMLHttpRequest/xhr_setRequestHeader",
|
||||
"preamble.js/XMLHttpRequest/xhr_send"
|
||||
}
|
||||
},
|
||||
new Object[]{ "preamble.js/_XMLHttpRequest/xhr_open",
|
||||
new String[] { "preamble.js/_XMLHttpRequest/xhr_orsc_handler" }
|
||||
new Object[]{ "preamble.js/XMLHttpRequest/xhr_open",
|
||||
new String[] { "preamble.js/XMLHttpRequest/xhr_orsc_handler" }
|
||||
},
|
||||
new Object[]{ "preamble.js/_XMLHttpRequest/xhr_send",
|
||||
new String[] { "preamble.js/_XMLHttpRequest/xhr_orsc_handler" }
|
||||
new Object[]{ "preamble.js/XMLHttpRequest/xhr_send",
|
||||
new String[] { "preamble.js/XMLHttpRequest/xhr_orsc_handler" }
|
||||
},
|
||||
new Object[]{ "preamble.js/_XMLHttpRequest/xhr_orsc_handler",
|
||||
new Object[]{ "preamble.js/XMLHttpRequest/xhr_orsc_handler",
|
||||
new String[] { "page13.html/__WINDOW_MAIN__/handler" }
|
||||
}
|
||||
};
|
||||
|
|
|
@ -90,20 +90,20 @@ NamedNodeList = function NamedNodeList() {
|
|||
|
||||
DOMNode = function DOMNode() { // An impostor for the Node class
|
||||
this.childNodes = new NamedNodeList();
|
||||
this.insertBefore = function insertBefore(newChild, refChild) {
|
||||
this.insertBefore = function Node_prototype_insertBefore(newChild, refChild) {
|
||||
this.childNodes.insertBefore(newChild, refChild);
|
||||
}
|
||||
this.replaceChild = function replaceChild(newChild, oldChild) {
|
||||
this.replaceChild = function Node_prototype_replaceChild(newChild, oldChild) {
|
||||
this.childNodes.replace(newChild, oldChild);
|
||||
}
|
||||
this.removeChild = function removeChild(oldChild) {
|
||||
this.removeChild = function Node_prototype_removeChild(oldChild) {
|
||||
this.childNodes.remove(oldChild);
|
||||
}
|
||||
this.appendChild = function appendChild(newChild) {
|
||||
this.appendChild = function Node_prototype_appendChild(newChild) {
|
||||
this.childNodes.add(newChild);
|
||||
newChild.parentNode = this;
|
||||
}
|
||||
this.hasChildNodes = function hasChildNodes() {
|
||||
this.hasChildNodes = function Node_prototype_hasChildNodes() {
|
||||
return this.childNodes.hasElements();
|
||||
}
|
||||
|
||||
|
@ -117,39 +117,77 @@ DOMNode = function DOMNode() { // An impostor for the Node class
|
|||
}
|
||||
this.childNodes.collect(predicate, result);
|
||||
}
|
||||
this.addEventListener = function(name, fn) {
|
||||
fn();
|
||||
};
|
||||
};
|
||||
|
||||
DOMNode.prototype.addEventListener = function Node_prototype_addEventListener(name, fn) { fn(); };
|
||||
|
||||
DOMNode.prototype.removeEventListener = function Node_prototype_removeEventListener(name) {};
|
||||
|
||||
DOMNode.prototype.cloneNode = function Node_prototype_cloneNode() {
|
||||
// TODO: model me
|
||||
};
|
||||
|
||||
DOMNode.prototype.compareDocumentPosition = function Node_prototype_compareDocumentPosition() {
|
||||
// TODO: model me
|
||||
};
|
||||
|
||||
DOMNode.prototype.contains = function Node_prototype_contains() {
|
||||
return true || false;
|
||||
}
|
||||
|
||||
DOMDocument = function DOMDocument() {
|
||||
this.temp = DOMNode;
|
||||
this.temp();
|
||||
this.DOMNode = DOMNode;
|
||||
this.DOMNode();
|
||||
delete this.DOMNode;
|
||||
|
||||
this.createElement = function createElement(name) {
|
||||
this.createElement = function Document_prototype_createElement(name) {
|
||||
// TODO : to be implemented accurately
|
||||
var toReturn = new DOMHTMLGenericElement(name);
|
||||
return toReturn;
|
||||
return new DOMHTMLGenericElement(name);
|
||||
}
|
||||
|
||||
this.getElementById = function getElementById(id) {
|
||||
var result = new Array();
|
||||
this.collect(function check_id(x) { return x.id == id; }, result);
|
||||
return result[0];
|
||||
}
|
||||
|
||||
this.write = function write_to_dom (stuff) {
|
||||
|
||||
this.getElementById = function Document_prototype_getElementById(id) {
|
||||
var result = new Array();
|
||||
this.collect(function check_id(x) { return x.id == id; }, result);
|
||||
return result[0];
|
||||
};
|
||||
}
|
||||
|
||||
this.getElementsByTagName = function Document_prototype_getElementsByTagName(name) {
|
||||
// TODO: implement
|
||||
};
|
||||
|
||||
this.createTextNode = function Document_prototype_createTextNode(txt) {
|
||||
// TODO: not very precise
|
||||
return new DOMHTMLGenericElement("text");
|
||||
};
|
||||
|
||||
this.write = function Document_prototype_write (stuff) {
|
||||
|
||||
};
|
||||
};
|
||||
DOMDocument.prototype.createDocumentFragment = function Document_prototype_createDocumentFragment() {
|
||||
// TODO: model me
|
||||
};
|
||||
DOMDocument.prototype.createComment = function Document_prototype_createComment() {
|
||||
// TODO: model me
|
||||
};
|
||||
DOMDocument.prototype.getElementsByClassName = function Document_prototype_getElementsByClassName() {
|
||||
// TODO: model me
|
||||
};
|
||||
DOMDocument.prototype.querySelectorAll = function Document_prototype_querySelectorAll() {
|
||||
// TODO: model me
|
||||
};
|
||||
|
||||
|
||||
|
||||
HTMLBody = function HTMLBody(){
|
||||
this.innerHTML = new String();
|
||||
}
|
||||
|
||||
DOMHTMLDocument = function DOMHTMLDocument() {
|
||||
this.temp = DOMDocument;
|
||||
this.temp();
|
||||
this.DOMDocument = DOMDocument;
|
||||
this.DOMDocument();
|
||||
delete this.DOMDocument;
|
||||
|
||||
this.URL = new String();
|
||||
this.body = new HTMLBody();
|
||||
this.forms = new Array();
|
||||
|
@ -168,16 +206,54 @@ Location = function Location(){
|
|||
}
|
||||
}
|
||||
|
||||
Image = function Image() {
|
||||
this.name = new String();
|
||||
this.src = new String();
|
||||
this.align = new String();
|
||||
this.alt = new String();
|
||||
this.border = new String();
|
||||
this.height = 1/2;
|
||||
this.hspace = 1/2;
|
||||
this.isMap = true || false;
|
||||
this.longDesc = new String();
|
||||
this.useMap = new String();
|
||||
this.vspace = 1/2;
|
||||
this.width = 1/2;
|
||||
};
|
||||
|
||||
|
||||
DOMWindow = function DOMWindow(){
|
||||
this.name = new String();
|
||||
this.open = function window_open(url, stuff) {
|
||||
note_url(url);
|
||||
};
|
||||
this.addEventListener = function(name, fn) {
|
||||
this.addEventListener = function Window_prototype_addEventListener(name, fn) {
|
||||
fn();
|
||||
};
|
||||
}
|
||||
this.alert = function Window_prototype_alert(msg) {
|
||||
// as everyone knows, alert is pure
|
||||
};
|
||||
this.setInterval = function Window_prototype_setInterval(fn, interval) {
|
||||
fn();
|
||||
};
|
||||
this.setTimeout = function Window_prototype_setTimeout(fn, timeout) {
|
||||
fn();
|
||||
};
|
||||
this.clearInterval = function Window_prototype_clearInterval(interval) {};
|
||||
this.clearTimeout = function Window_prototype_clearTimeout(timeout) {};
|
||||
};
|
||||
DOMWindow.prototype.getComputedStyle = function Window_prototype_getComputedStyle(elt, pseudoElt) {
|
||||
return new CSS2Properties();
|
||||
};
|
||||
DOMWindow.prototype.focus = function Window_prototype_focus() {
|
||||
// TODO: model me
|
||||
};
|
||||
DOMWindow.prototype.prompt = function Window_prototype_prompt() {
|
||||
};
|
||||
|
||||
CSS2Properties = function CSS2Properties() {
|
||||
this.cssText = new String();
|
||||
};
|
||||
|
||||
DOJOObj = function DOJOObj(){
|
||||
this.moduleUrl = function module_url(str1, str2){
|
||||
|
@ -201,40 +277,75 @@ window.document = document;
|
|||
document.defaultView = window;
|
||||
window.XMLHttpRequest = XMLHttpRequest;
|
||||
|
||||
setInterval = window.setInterval;
|
||||
setTimeout = window.setTimeout;
|
||||
clearInterval = window.clearInterval;
|
||||
|
||||
var dojo = new DOJOObj();
|
||||
|
||||
DOMElement = function DOMElement() { // An impostor for the Element class
|
||||
// inherits from Node
|
||||
this.temp = DOMNode;
|
||||
this.temp();
|
||||
this.DOMNode = DOMNode;
|
||||
this.DOMNode();
|
||||
delete this.DOMNode;
|
||||
|
||||
// The get/set/remove attribute methods cannot be run using 'onclick','onmouseover', 'on...' kind of arguments for name.
|
||||
// since that would be used as a workaround for eval
|
||||
|
||||
this.getAttribute = function getAttribute(name) {
|
||||
this.getAttribute = function Element_prototype_getAttribute(name) {
|
||||
return this[name];
|
||||
}
|
||||
this.setAttribute = function setAttribute(name, value) {
|
||||
};
|
||||
|
||||
this.setAttribute = function Element_prototype_setAttribute(name, value) {
|
||||
this[name] = value;
|
||||
}
|
||||
};
|
||||
|
||||
this.removeAttribute = function removeAttribute(name) {
|
||||
this[name] = undefined;
|
||||
}
|
||||
this.removeAttribute = function Element_prototype_removeAttribute(name) {
|
||||
delete this[name];
|
||||
};
|
||||
|
||||
this.getElementsByTagName = function _getElementsByTagName(tagName) {
|
||||
this.getElementsByTagName = function Element_prototype_getElementsByTagName(tagName) {
|
||||
var result = new Array();
|
||||
this.collect(function check_tag(x) { return x.name == tagName; }, result);
|
||||
return result;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
this.focus = function Element_prototype_focus() {};
|
||||
};
|
||||
|
||||
DOMElement.prototype.querySelectorAll = function Element_prototype_querySelectorAll() {
|
||||
// TODO: model me
|
||||
};
|
||||
|
||||
DOMElement.prototype.getElementsByClassName = function Element_prototype_getElementsByClassName() {
|
||||
// TODO: model me
|
||||
};
|
||||
|
||||
DOMElement.prototype.getBoundingClientRect = function Element_prototype_getBoundingClientRect() {
|
||||
// TODO: model me
|
||||
};
|
||||
|
||||
DOMElement.prototype.focus = function Element_prototype_focus() {
|
||||
};
|
||||
|
||||
Event = function Event() {
|
||||
// TODO: model me
|
||||
};
|
||||
|
||||
Event.prototype.stopPropagation = function Event_prototype_stopPropagation() {
|
||||
// TODO: model me
|
||||
};
|
||||
|
||||
Event.prototype.preventDefault = function Event_prototype_preventDefault() {
|
||||
// TODO: model me
|
||||
};
|
||||
|
||||
DOMHTMLElement = function DOMHTMLElement() { // An impostor for the HTMLElement class
|
||||
// inherits from Element
|
||||
this.temp = DOMElement;
|
||||
this.temp();
|
||||
this.DOMElement = DOMElement;
|
||||
this.DOMElement();
|
||||
delete this.DOMElement;
|
||||
|
||||
// Set HTML Attribute Defaults
|
||||
this.id = null;
|
||||
|
@ -253,8 +364,9 @@ DOMHTMLElement = function DOMHTMLElement() { // An impostor for the HTMLElement
|
|||
// Just a hack until all HTML elements have corresponding constructors
|
||||
DOMHTMLGenericElement = function DOMHTMLGenericElement(tagName) {
|
||||
// inherits from Element
|
||||
this.temp = DOMHTMLElement;
|
||||
this.temp();
|
||||
this.DOMHTMLElement = DOMHTMLElement;
|
||||
this.DOMHTMLElement();
|
||||
delete this.DOMHTMLElement;
|
||||
|
||||
// Set just the tag name
|
||||
this.nodeName = tagName;
|
||||
|
@ -263,14 +375,32 @@ DOMHTMLGenericElement = function DOMHTMLGenericElement(tagName) {
|
|||
// load 'src' if appropriate
|
||||
this.src.loadFile = String.prototype.loadFile;
|
||||
this.src.loadFile();
|
||||
}
|
||||
|
||||
// this property only exists on iframes; putting it here for now
|
||||
this.documentWindow = window;
|
||||
|
||||
this.getContext = function() { return new CanvasRenderingContext2D(); };
|
||||
};
|
||||
|
||||
CanvasRenderingContext2D = function CanvasRenderingContext2D() {};
|
||||
CanvasRenderingContext2D.prototype = {
|
||||
beginPath: function CanvasRenderingContext2D_prototype_beginPath() {},
|
||||
moveTo: function CanvasRenderingContext2D_prototype_moveTo() {},
|
||||
lineTo: function CanvasRenderingContext2D_prototype_lineTo() {},
|
||||
closePath: function CanvasRenderingContext2D_prototype_closePath() {},
|
||||
fill: function CanvasRenderingContext2D_prototype_fill() {},
|
||||
stroke: function CanvasRenderingContext2D_prototype_stroke() {},
|
||||
clearRect: function CanvasRenderingContext2D_prototype_clearRect() {},
|
||||
fillRect: function CanvasRenderingContext2D_prototype_fillRect() {}
|
||||
};
|
||||
|
||||
var formCount = 0;
|
||||
|
||||
DOMHTMLFormElement = function DOMHTMLFormElement() {
|
||||
// inherits from HTMLElement
|
||||
this.temp = DOMHTMLElement;
|
||||
this.temp();
|
||||
this.DOMHTMLElement = DOMHTMLElement;
|
||||
this.DOMHTMLElement();
|
||||
delete this.DOMHTMLElement;
|
||||
|
||||
// add to 'forms' property
|
||||
document.forms[formCount++] = this;
|
||||
|
@ -297,14 +427,15 @@ DOMHTMLFormElement = function DOMHTMLFormElement() {
|
|||
|
||||
DOMHTMLTableElement = function DOMHTMLTableElement () {
|
||||
// inherits from HTMLElement
|
||||
this.temp = DOMHTMLElement;
|
||||
this.temp();
|
||||
this.DOMHTMLElement = DOMHTMLElement;
|
||||
this.DOMHTMLElement();
|
||||
delete this.DOMHTMLElement;
|
||||
|
||||
this.rows = function table_elt_rows() {
|
||||
}
|
||||
}
|
||||
|
||||
XMLHttpRequest = function _XMLHttpRequest() {
|
||||
XMLHttpRequest = function XMLHttpRequest() {
|
||||
|
||||
this.UNSENT = 0;
|
||||
this.OPENED = 1;
|
||||
|
@ -345,6 +476,11 @@ XMLHttpRequest = function _XMLHttpRequest() {
|
|||
|
||||
};
|
||||
|
||||
XMLSerializer = function XMLSerializer() {};
|
||||
XMLSerializer.prototype.serializeToString = function XMLSerializer_prototype_serializeToString() {
|
||||
// TODO: model me
|
||||
};
|
||||
|
||||
for(var n = 0; n < dom_nodes.length; n++) {
|
||||
dom_nodes[n].onload();
|
||||
dom_nodes[n].onreadystatechange();
|
||||
|
|
|
@ -90,15 +90,15 @@ Object.prototype = {
|
|||
|
||||
valueOf: function valueOf() { return this },
|
||||
|
||||
hasOwnProperty: function hasOwnProperty (V) {
|
||||
hasOwnProperty: function Object_prototype_hasOwnProperty (V) {
|
||||
return primitive("ObjectHasOwnProperty", this, V);
|
||||
},
|
||||
|
||||
isPrototypeOf: function isPrototypeOf (V) {
|
||||
isPrototypeOf: function Object_prototype_isPrototypeOf (V) {
|
||||
return primitive("ObjectIsPrototypeOf", this, V);
|
||||
},
|
||||
|
||||
propertyIsEnumerable: function propertyIsEnumerable (V) {
|
||||
|
||||
propertyIsEnumerable: function Object_prototype_propertyIsEnumerable (V) {
|
||||
return primitive("ObjectPropertyIsEnumerable", this, V);
|
||||
}
|
||||
};
|
||||
|
@ -115,17 +115,22 @@ local_function.prototype = {
|
|||
|
||||
__proto__: Object.prototype,
|
||||
|
||||
toString: function functionToString() {
|
||||
toString: function Function_prototype_toString() {
|
||||
return primitive("FunctionToString", this);
|
||||
},
|
||||
|
||||
apply: function functionApply (thisArg, argArray) {
|
||||
apply: function Function_prototype_apply (thisArg, argArray) {
|
||||
return primitive("FunctionApply", this, thisArg, argArray);
|
||||
},
|
||||
|
||||
call: function functionCall (thisArg) {
|
||||
call: function Function_prototype_call (thisArg) {
|
||||
arguments.shift();
|
||||
return primitive("FunctionApply", this, thisArg, arguments);
|
||||
return primitive("FunctionCall", this, thisArg, arguments);
|
||||
},
|
||||
|
||||
bind: function Function_prototype_bind (thisArg) {
|
||||
arguments.shift();
|
||||
return primitive("FunctionBind", this, thisArg, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -143,11 +148,11 @@ local_array.prototype = {
|
|||
|
||||
constructor: Array,
|
||||
|
||||
toString: function arrayToString () {
|
||||
toString: function Array_prototype_toString () {
|
||||
return this.join(",");
|
||||
},
|
||||
|
||||
toLocaleString: function arrayToLocalString () {
|
||||
toLocaleString: function Array_prototype_toLocaleString () {
|
||||
var result = "";
|
||||
var limit = this.length;
|
||||
for(var k = 0; k < limit; k++) {
|
||||
|
@ -158,7 +163,7 @@ local_array.prototype = {
|
|||
return result;
|
||||
},
|
||||
|
||||
concat: function concat () {
|
||||
concat: function Array_prototype_concat () {
|
||||
var result = new Array();
|
||||
var n = 0;
|
||||
|
||||
|
@ -174,7 +179,7 @@ local_array.prototype = {
|
|||
return result;
|
||||
},
|
||||
|
||||
join: function join (separator) {
|
||||
join: function Array_prototype_join (separator) {
|
||||
var result = "";
|
||||
var limit = this.length;
|
||||
for(var k = 0; k < limit; k++) {
|
||||
|
@ -185,11 +190,11 @@ local_array.prototype = {
|
|||
return result;
|
||||
},
|
||||
|
||||
pop: function pop () {
|
||||
pop: function Array_prototype_pop () {
|
||||
return this[ --this.length ];
|
||||
},
|
||||
|
||||
push: function push () {
|
||||
push: function Array_prototype_push () {
|
||||
var n = this.length;
|
||||
for(var i = 0; i < arguments.length; i++) {
|
||||
this[ n++ ] = arguments[i];
|
||||
|
@ -199,7 +204,7 @@ local_array.prototype = {
|
|||
return n;
|
||||
},
|
||||
|
||||
reverse: function reverse () {
|
||||
reverse: function Array_prototype_reverse () {
|
||||
var n = this.length;
|
||||
for (var k = 0; k < (n/2); k++) {
|
||||
var tmp = this[k];
|
||||
|
@ -210,7 +215,7 @@ local_array.prototype = {
|
|||
return this;
|
||||
},
|
||||
|
||||
shift: function shift () {
|
||||
shift: function Array_prototype_shift () {
|
||||
var result = this[ 0 ];
|
||||
for(var i = 0; i < this.length-1; i++)
|
||||
this[i] = this[i+1];
|
||||
|
@ -220,7 +225,17 @@ local_array.prototype = {
|
|||
return result;
|
||||
},
|
||||
|
||||
slice: function slice (start, end) {
|
||||
unshift: function Array_prototype_unshift () {
|
||||
var n = arguments.length;
|
||||
for(var i=this.length+n-1;i>=n;--i)
|
||||
this[i] = this[i-n];
|
||||
for(;i>=0;--i)
|
||||
this[i] = arguments[i];
|
||||
this.length += n;
|
||||
return this.length;
|
||||
},
|
||||
|
||||
slice: function Array_prototype_slice (start, end) {
|
||||
var j = 0;
|
||||
if (start < 0) start = this.length + start;
|
||||
if (end < 0) end = this.length + end;
|
||||
|
@ -233,7 +248,7 @@ local_array.prototype = {
|
|||
return result;
|
||||
},
|
||||
|
||||
sort: function sort (fn) {
|
||||
sort: function Array_prototype_sort (fn) {
|
||||
for(var l = 0; i < this.length; l++) {
|
||||
var mindex = l;
|
||||
for(var i = l; i < this.length; i++) {
|
||||
|
@ -248,9 +263,59 @@ local_array.prototype = {
|
|||
this[mindex] = this[l];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
splice: function Array_prototype_splice(start, delete_count) {
|
||||
var old_len = arguments.length,
|
||||
new_count = arguments.length - 2;
|
||||
new_len = old_len - deleteCount + new_count;
|
||||
|
||||
var deleted = this.slice(start, start + delete_count),
|
||||
remainder = this.slice(start + delete_count, old_len);
|
||||
|
||||
for(var i=start;i<start+new_count;++i)
|
||||
this[i] = arguments[2+start-i];
|
||||
|
||||
for(var k=0;k<remainder.length;++k,++i)
|
||||
this[i] = remainder[k];
|
||||
|
||||
for(;i<old_len;++i)
|
||||
delete this[i];
|
||||
|
||||
this.length = new_len;
|
||||
|
||||
return deleted;
|
||||
},
|
||||
|
||||
indexOf: function Array_prototype_indexOf(elt, start) {
|
||||
if(arguments.length < 2)
|
||||
start = 0;
|
||||
if(start < 0) start += this.length;
|
||||
if(start < 0) start = 0;
|
||||
for(var i=start;i<this.length;++i)
|
||||
if(this[i] === elt)
|
||||
return i;
|
||||
return -1;
|
||||
},
|
||||
|
||||
forEach: function Array_prototype_forEach(callback, thisArg) {
|
||||
for(var i=0;i<this.length;++i)
|
||||
callback.call(thisArg, this[i], i, this);
|
||||
},
|
||||
|
||||
map: function Array_prototype_map(callback, thisArg) {
|
||||
var res = [];
|
||||
for(var i=0;i<this.length;++i)
|
||||
res[i] = callback.call(thisArg, this[i], i, this);
|
||||
res.length = this.length;
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
Array.isArray = function Array_isArray(a) {
|
||||
return true || false;
|
||||
};
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* String properties, see spec 15.4 */
|
||||
|
@ -266,7 +331,7 @@ local_string.prototype = {
|
|||
|
||||
$value: "",
|
||||
|
||||
toString: function stringToString() {
|
||||
toString: function String_prototype_toString() {
|
||||
return this.$value;
|
||||
},
|
||||
|
||||
|
@ -274,35 +339,35 @@ local_string.prototype = {
|
|||
return this.$value;
|
||||
},
|
||||
|
||||
charAt: function stringCharAt(pos) {
|
||||
charAt: function String_prototype_charAt(pos) {
|
||||
return new String(primitive("StringCharAt", pos));
|
||||
},
|
||||
|
||||
charCodeAt: function stringCharCodeAt(pos) {
|
||||
charCodeAt: function String_prototype_charCodeAt(pos) {
|
||||
return new Number(primitive("StringCharCodeAt", pos));
|
||||
},
|
||||
|
||||
toUpperCase: function toUpperCase() {
|
||||
toUpperCase: function String_prototype_toUpperCase() {
|
||||
return new String(primitive("StringToUpperCase", this));
|
||||
},
|
||||
|
||||
toLocaleUpperCase: function toLocaleUpperCase() {
|
||||
toLocaleUpperCase: function String_prototype_toLocaleUpperCase() {
|
||||
return new String(primitive("StringToLocaleUpperCase", this));
|
||||
},
|
||||
|
||||
toLowerCase: function toLowerCase() {
|
||||
toLowerCase: function String_prototype_toLowerCase() {
|
||||
return new String(primitive("StringToLowerCase", this));
|
||||
},
|
||||
|
||||
toLocaleLowerCase: function toLocaleLowerCase() {
|
||||
toLocaleLowerCase: function String_prototype_toLocaleLowerCase() {
|
||||
return new String(primitive("StringToLocaleLowerCase", this));
|
||||
},
|
||||
|
||||
indexOf: function indexOf(str) {
|
||||
indexOf: function String_prototype_indexOf(str) {
|
||||
return new Number(primitive("StringIndexOf", this, str));
|
||||
},
|
||||
|
||||
split: function stringSplit(separator, limit) {
|
||||
split: function String_prototype_split(separator, limit) {
|
||||
var y = primitive("splitCount", this, separator, limit);
|
||||
var x = new Array(y);
|
||||
for(var i = 0; i < y; i++) {
|
||||
|
@ -311,18 +376,32 @@ local_string.prototype = {
|
|||
return x;
|
||||
},
|
||||
|
||||
substring: function substring(from, to) {
|
||||
substring: function String_prototype_substring(from, to) {
|
||||
return new String(primitive("StringSubString", this, from, to));
|
||||
},
|
||||
|
||||
slice: function String_prototype_slice(from, to) {
|
||||
if(from < 0) from += this.length;
|
||||
if(to < 0) to += this.length;
|
||||
return this.substring(from, to);
|
||||
},
|
||||
|
||||
substr: function substr(from, to) {
|
||||
substr: function String_prototype_substr(from, to) {
|
||||
return new String(primitive("StringSubStr", this, from, to));
|
||||
},
|
||||
|
||||
replace: function replace(regex, withStr) {
|
||||
replace: function String_prototype_replace(regex, withStr) {
|
||||
return new String(primitive("StringReplace", this, regex, withStr));
|
||||
},
|
||||
|
||||
match: function String_prototype_match(regexp) {
|
||||
return new Array(primitive("StringMatch", this, regexp));
|
||||
},
|
||||
|
||||
trim: function String_prototype_trim() {
|
||||
return new String(primitive("StringTrim", this));
|
||||
},
|
||||
|
||||
loadFile: function loadFile() {
|
||||
// magic function body handled in analysis.
|
||||
}
|
||||
|
@ -342,7 +421,11 @@ local_number.prototype = {
|
|||
|
||||
constructor: Number,
|
||||
|
||||
$value: 0
|
||||
$value: 0,
|
||||
|
||||
toString: function Number_prototype_toString() {
|
||||
return primitive("NumberToString", this);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
@ -368,27 +451,27 @@ Math = {
|
|||
|
||||
SQRT2: primitive("MathSQRT2"),
|
||||
|
||||
abs: function abs (x) { return (x<0)? -x: x; },
|
||||
abs: function Math_abs (x) { return (x<0)? -x: x; },
|
||||
|
||||
acos: function acos (x) { return primitive("MathACos", x); },
|
||||
acos: function Math_acos (x) { return primitive("MathACos", x); },
|
||||
|
||||
asin: function asin (x) { return primitive("MathASin", x); },
|
||||
asin: function Math_asin (x) { return primitive("MathASin", x); },
|
||||
|
||||
atan: function atan (x) { return primitive("MathATan", x); },
|
||||
atan: function Math_atan (x) { return primitive("MathATan", x); },
|
||||
|
||||
atan2: function atan2 (y, x) { return primitive("MathATan2", y, x); },
|
||||
atan2: function Math_atan2 (y, x) { return primitive("MathATan2", y, x); },
|
||||
|
||||
ceil: function ceil (x) { return primitive("MathCeil", x); },
|
||||
ceil: function Math_ceil (x) { return primitive("MathCeil", x); },
|
||||
|
||||
cos: function cos (x) { return primitive("MathCos", x); },
|
||||
cos: function Math_cos (x) { return primitive("MathCos", x); },
|
||||
|
||||
exp: function exp (x) { return primitive("MathExp", x); },
|
||||
exp: function Math_exp (x) { return primitive("MathExp", x); },
|
||||
|
||||
floor: function floor (x) { return primitive("MathFloor", x); },
|
||||
floor: function Math_floor (x) { return primitive("MathFloor", x); },
|
||||
|
||||
log: function log (x) { return primitive("MathLog", x); },
|
||||
log: function Math_log (x) { return primitive("MathLog", x); },
|
||||
|
||||
max: function max () {
|
||||
max: function Math_max () {
|
||||
var i = -Infinity;
|
||||
for(var j = 0; j < arguments.length; j++)
|
||||
if (arguments[j] > i)
|
||||
|
@ -397,7 +480,7 @@ Math = {
|
|||
return i;
|
||||
},
|
||||
|
||||
min: function min () {
|
||||
min: function Math_min () {
|
||||
var i = Infinity;
|
||||
for(var j = 0; j < arguments.length; j++)
|
||||
if (arguments[j] < i)
|
||||
|
@ -406,17 +489,17 @@ Math = {
|
|||
return i;
|
||||
},
|
||||
|
||||
pow: function pow (x, y) { return primitive("MathPow", x, y); },
|
||||
pow: function Math_pow (x, y) { return primitive("MathPow", x, y); },
|
||||
|
||||
random: function random() { return primitive("MathRandom"); },
|
||||
random: function Math_random() { return primitive("MathRandom"); },
|
||||
|
||||
round: function round (x) { return primitive("MathRound", x); },
|
||||
round: function Math_round (x) { return primitive("MathRound", x); },
|
||||
|
||||
sin: function sin (x) { return primitive("MathSin", x); },
|
||||
sin: function Math_sin (x) { return primitive("MathSin", x); },
|
||||
|
||||
sqrt: function sqrt (x) { return primitive("MathSqrt", x);},
|
||||
sqrt: function Math_sqrt (x) { return primitive("MathSqrt", x);},
|
||||
|
||||
tan: function tan (x) { return primitive("MathTan", x); }
|
||||
tan: function Math_tan (x) { return primitive("MathTan", x); }
|
||||
};
|
||||
|
||||
|
||||
|
@ -430,8 +513,98 @@ local_regexp.prototype = {
|
|||
|
||||
__proto__: Object.prototype,
|
||||
|
||||
constructor: RegExp
|
||||
constructor: RegExp,
|
||||
|
||||
exec: function RegExp_prototype_exec(string) {
|
||||
return new Array(primitive("RegexpExec", this, string));
|
||||
},
|
||||
|
||||
test: function RegExp_prototype_test(string) {
|
||||
return true || false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* Date properties, see spec 15.9 */
|
||||
/************************************************************************/
|
||||
|
||||
Date = function Date() {};
|
||||
|
||||
Date.prototype = {
|
||||
|
||||
__proto__: Object.prototype,
|
||||
|
||||
constructor: Date,
|
||||
|
||||
getTime: function Date_prototype_getTime() {
|
||||
return primitive("DateGetTime", this);
|
||||
},
|
||||
|
||||
getDate: function Date_prototype_getDate() {
|
||||
// TODO: model me
|
||||
},
|
||||
|
||||
setDate: function Date_prototype_setDate() {
|
||||
// TODO: model me
|
||||
},
|
||||
|
||||
getDay: function Date_prototype_getDay() {
|
||||
// TODO: model me
|
||||
},
|
||||
|
||||
setDay: function Date_prototype_setDay() {
|
||||
// TODO: model me
|
||||
},
|
||||
|
||||
getMonth: function Date_prototype_getMonth() {
|
||||
// TODO: model me
|
||||
},
|
||||
|
||||
setMonth: function Date_prototype_setMonth() {
|
||||
// TODO: model me
|
||||
},
|
||||
|
||||
getHours: function Date_prototype_getHours() {
|
||||
// TODO: model me
|
||||
},
|
||||
|
||||
setHours: function Date_prototype_setHours() {
|
||||
// TODO: model me
|
||||
},
|
||||
|
||||
getMinutes: function Date_prototype_getMinutes() {
|
||||
// TODO: model me
|
||||
},
|
||||
|
||||
setMinutes: function Date_prototype_setMinutes() {
|
||||
// TODO: model me
|
||||
},
|
||||
|
||||
getSeconds: function Date_prototype_getSeconds() {
|
||||
// TODO: model me
|
||||
},
|
||||
|
||||
setSeconds: function Date_prototype_setSeconds() {
|
||||
// TODO: model me
|
||||
},
|
||||
|
||||
getMilliseconds: function Date_prototype_getMilliseconds() {
|
||||
// TODO: model me
|
||||
},
|
||||
|
||||
setMilliseconds: function Date_prototype_setMilliseconds() {
|
||||
// TODO: model me
|
||||
},
|
||||
|
||||
getFullYear: function Date_prototype_getFullYear() {
|
||||
// TODO: model me
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Date.now = function Date_now() {
|
||||
return new Date().valueOf();
|
||||
};
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import com.ibm.wala.types.TypeName;
|
|||
*/
|
||||
public class JavaScriptFunctionApplyContextInterpreter extends AstContextInsensitiveSSAContextInterpreter {
|
||||
|
||||
private static final TypeName APPLY_TYPE_NAME = TypeName.findOrCreate("Lprologue.js/functionApply");
|
||||
private static final TypeName APPLY_TYPE_NAME = TypeName.findOrCreate("Lprologue.js/Function_prototype_apply");
|
||||
|
||||
public JavaScriptFunctionApplyContextInterpreter(AnalysisOptions options, AnalysisCache cache) {
|
||||
super(options, cache);
|
||||
|
|
|
@ -26,9 +26,9 @@ public class JavaScriptFunctionApplyContextSelector implements ContextSelector {
|
|||
/* whether to use a one-level callstring context in addition to the apply context */
|
||||
private static final boolean USE_ONE_LEVEL = true;
|
||||
|
||||
private static final TypeName APPLY_TYPE_NAME = TypeName.findOrCreate("Lprologue.js/functionApply");
|
||||
private static final TypeName APPLY_TYPE_NAME = TypeName.findOrCreate("Lprologue.js/Function_prototype_apply");
|
||||
|
||||
private static final TypeName CALL_TYPE_NAME = TypeName.findOrCreate("Lprologue.js/functionCall");
|
||||
private static final TypeName CALL_TYPE_NAME = TypeName.findOrCreate("Lprologue.js/Function_prototype_call");
|
||||
|
||||
public static final ContextKey APPLY_NON_NULL_ARGS = new ContextKey() {
|
||||
};
|
||||
|
|
|
@ -16,8 +16,8 @@ import com.ibm.wala.util.strings.Atom;
|
|||
|
||||
/**
|
||||
* We need to generate synthetic methods for Function.apply() in the target
|
||||
* selector, so that the AstMethod for functionApply() in the prologue doesn't
|
||||
* actually get used in the CGNodes used for calls to Function.apply(). The
|
||||
* selector, so that the AstMethod for Function_prototype_apply() in the prologue doesn't
|
||||
* actually get used in the CGNodes used for calls to Function.prototype.apply(). The
|
||||
* generated dummy methods should <em>never</em> actually be used except as a
|
||||
* stub.
|
||||
*/
|
||||
|
@ -25,7 +25,7 @@ public class JavaScriptFunctionApplyTargetSelector implements MethodTargetSelect
|
|||
|
||||
private final MethodTargetSelector base;
|
||||
|
||||
private static final TypeName APPLY_TYPE_NAME = TypeName.findOrCreate("Lprologue.js/functionApply");
|
||||
private static final TypeName APPLY_TYPE_NAME = TypeName.findOrCreate("Lprologue.js/Function_prototype_apply");
|
||||
|
||||
private IMethod applyMethod;
|
||||
public JavaScriptFunctionApplyTargetSelector(MethodTargetSelector base) {
|
||||
|
|
|
@ -48,7 +48,7 @@ public class JavaScriptFunctionDotCallTargetSelector implements MethodTargetSele
|
|||
|
||||
public static final boolean DEBUG_SYNTHETIC_CALL_METHODS = false;
|
||||
|
||||
private static final TypeName CALL_TYPE_NAME = TypeName.findOrCreate("Lprologue.js/functionCall");
|
||||
private static final TypeName CALL_TYPE_NAME = TypeName.findOrCreate("Lprologue.js/Function_prototype_call");
|
||||
private final MethodTargetSelector base;
|
||||
|
||||
public JavaScriptFunctionDotCallTargetSelector(MethodTargetSelector base) {
|
||||
|
|
|
@ -77,7 +77,7 @@ public class CorrelationFinder {
|
|||
private final JavaScriptTranslatorFactory translatorFactory;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private CorrelationSummary findCorrelatedAccesses(IMethod method, IR ir) {
|
||||
public static CorrelationSummary findCorrelatedAccesses(IMethod method, IR ir) {
|
||||
AstMethod astMethod = (AstMethod)method;
|
||||
DefUse du = new DefUse(ir);
|
||||
OrdinalSetMapping<SSAInstruction> instrIndices = new ObjectArrayMapping<SSAInstruction>(ir.getInstructions());
|
||||
|
@ -160,7 +160,7 @@ public class CorrelationFinder {
|
|||
|
||||
// tries to determine which source level variable an SSA variable corresponds to
|
||||
// if it does not correspond to any variable, or to more than one, null is returned
|
||||
private String getSourceLevelName(AstMethod astMethod, int v) {
|
||||
private static String getSourceLevelName(AstMethod astMethod, int v) {
|
||||
String indexName = null;
|
||||
String[][] sourceNamesForValues = astMethod.debugInfo().getSourceNamesForValues();
|
||||
|
||||
|
@ -178,7 +178,7 @@ public class CorrelationFinder {
|
|||
return indexName;
|
||||
}
|
||||
|
||||
private Set<String> getSourceLevelNames(AstMethod astMethod, IntSet vs) {
|
||||
private static Set<String> getSourceLevelNames(AstMethod astMethod, IntSet vs) {
|
||||
Set<String> res = new HashSet<String>();
|
||||
for(IntIterator iter=vs.intIterator();iter.hasNext();) {
|
||||
String name = getSourceLevelName(astMethod, iter.next());
|
||||
|
@ -189,7 +189,7 @@ public class CorrelationFinder {
|
|||
}
|
||||
|
||||
// checks whether the given SSA variable must always be assigned a numeric value
|
||||
private boolean mustBeNumeric(IR ir, DefUse du, int v) {
|
||||
private static boolean mustBeNumeric(IR ir, DefUse du, int v) {
|
||||
LinkedList<Integer> worklist = new LinkedList<Integer>();
|
||||
MutableIntSet done = new BitVectorIntSet();
|
||||
worklist.add(v);
|
||||
|
|
|
@ -52,6 +52,10 @@ public final class CorrelationSummary {
|
|||
public Set<Correlation> getCorrelations() {
|
||||
return correlations;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return correlations.isEmpty();
|
||||
}
|
||||
|
||||
public SSASourcePositionMap getPositions() {
|
||||
return positions;
|
||||
|
|
|
@ -37,7 +37,7 @@ public class CorrelatedPairExtractorFactory implements CAstRewriterFactory<NodeP
|
|||
this.summaries = summaries;
|
||||
}
|
||||
|
||||
public CAstRewriter<NodePos, NoKey> createCAstRewriter(CAst ast) {
|
||||
public ClosureExtractor createCAstRewriter(CAst ast) {
|
||||
ExtractionPolicyFactory policyFactory = new ExtractionPolicyFactory() {
|
||||
@Override
|
||||
public ExtractionPolicy createPolicy(CAstEntity entity) {
|
||||
|
|
Loading…
Reference in New Issue