mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-04 23:08:39 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
13
devtools/client/sourceeditor/tern/README
Normal file
13
devtools/client/sourceeditor/tern/README
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
This is the Tern code-analysis engine packaged for the Mozilla Project.
|
||||
|
||||
Tern is a stand-alone code-analysis engine for JavaScript. It is intended to be used with a code editor plugin to enhance the editor's support for intelligent JavaScript editing
|
||||
|
||||
|
||||
# Upgrade
|
||||
|
||||
Currently used version is 0.6.2. To upgrade, download the latest release from http://ternjs.net/, and copy the files from lib/ into this directory.
|
||||
|
||||
You may also need to update the CodeMirror plugin found in devtools/client/sourceeditor/codemirror/addon/tern, but it will most likely work without updating.
|
||||
|
||||
Replace instances of `require("acorn")` with `require("acorn/acorn")`
|
||||
Replace instances of `acorn/dist/` with `acorn/`
|
||||
2921
devtools/client/sourceeditor/tern/browser.js
Normal file
2921
devtools/client/sourceeditor/tern/browser.js
Normal file
File diff suppressed because it is too large
Load diff
87
devtools/client/sourceeditor/tern/comment.js
Normal file
87
devtools/client/sourceeditor/tern/comment.js
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
return mod(exports);
|
||||
if (typeof define == "function" && define.amd) // AMD
|
||||
return define(["exports"], mod);
|
||||
mod(tern.comment || (tern.comment = {}));
|
||||
})(function(exports) {
|
||||
function isSpace(ch) {
|
||||
return (ch < 14 && ch > 8) || ch === 32 || ch === 160;
|
||||
}
|
||||
|
||||
function onOwnLine(text, pos) {
|
||||
for (; pos > 0; --pos) {
|
||||
var ch = text.charCodeAt(pos - 1);
|
||||
if (ch == 10) break;
|
||||
if (!isSpace(ch)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Gather comments directly before a function
|
||||
exports.commentsBefore = function(text, pos) {
|
||||
var found = null, emptyLines = 0, topIsLineComment;
|
||||
out: while (pos > 0) {
|
||||
var prev = text.charCodeAt(pos - 1);
|
||||
if (prev == 10) {
|
||||
for (var scan = --pos, sawNonWS = false; scan > 0; --scan) {
|
||||
prev = text.charCodeAt(scan - 1);
|
||||
if (prev == 47 && text.charCodeAt(scan - 2) == 47) {
|
||||
if (!onOwnLine(text, scan - 2)) break out;
|
||||
var content = text.slice(scan, pos);
|
||||
if (!emptyLines && topIsLineComment) found[0] = content + "\n" + found[0];
|
||||
else (found || (found = [])).unshift(content);
|
||||
topIsLineComment = true;
|
||||
emptyLines = 0;
|
||||
pos = scan - 2;
|
||||
break;
|
||||
} else if (prev == 10) {
|
||||
if (!sawNonWS && ++emptyLines > 1) break out;
|
||||
break;
|
||||
} else if (!sawNonWS && !isSpace(prev)) {
|
||||
sawNonWS = true;
|
||||
}
|
||||
}
|
||||
} else if (prev == 47 && text.charCodeAt(pos - 2) == 42) {
|
||||
for (var scan = pos - 2; scan > 1; --scan) {
|
||||
if (text.charCodeAt(scan - 1) == 42 && text.charCodeAt(scan - 2) == 47) {
|
||||
if (!onOwnLine(text, scan - 2)) break out;
|
||||
(found || (found = [])).unshift(text.slice(scan, pos - 2));
|
||||
topIsLineComment = false;
|
||||
emptyLines = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
pos = scan - 2;
|
||||
} else if (isSpace(prev)) {
|
||||
--pos;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return found;
|
||||
};
|
||||
|
||||
exports.commentAfter = function(text, pos) {
|
||||
while (pos < text.length) {
|
||||
var next = text.charCodeAt(pos);
|
||||
if (next == 47) {
|
||||
var after = text.charCodeAt(pos + 1), end;
|
||||
if (after == 47) // line comment
|
||||
end = text.indexOf("\n", pos + 2);
|
||||
else if (after == 42) // block comment
|
||||
end = text.indexOf("*/", pos + 2);
|
||||
else
|
||||
return;
|
||||
return text.slice(pos + 2, end < 0 ? text.length : end);
|
||||
} else if (isSpace(next)) {
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.ensureCommentsBefore = function(text, node) {
|
||||
if (node.hasOwnProperty("commentsBefore")) return node.commentsBefore;
|
||||
return node.commentsBefore = exports.commentsBefore(text, node.start);
|
||||
};
|
||||
});
|
||||
304
devtools/client/sourceeditor/tern/condense.js
Normal file
304
devtools/client/sourceeditor/tern/condense.js
Normal file
|
|
@ -0,0 +1,304 @@
|
|||
// Condensing an inferred set of types to a JSON description document.
|
||||
|
||||
// This code can be used to, after a library has been analyzed,
|
||||
// extract the types defined in that library and dump them as a JSON
|
||||
// structure (as parsed by def.js).
|
||||
|
||||
// The idea being that big libraries can be analyzed once, dumped, and
|
||||
// then cheaply included in later analysis.
|
||||
|
||||
(function(root, mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
return mod(exports, require("./infer"));
|
||||
if (typeof define == "function" && define.amd) // AMD
|
||||
return define(["exports", "./infer"], mod);
|
||||
mod(root.tern || (root.tern = {}), tern); // Plain browser env
|
||||
})(this, function(exports, infer) {
|
||||
"use strict";
|
||||
|
||||
exports.condense = function(origins, name, options) {
|
||||
if (typeof origins == "string") origins = [origins];
|
||||
var state = new State(origins, name || origins[0], options || {});
|
||||
|
||||
state.server.signal("preCondenseReach", state)
|
||||
|
||||
state.cx.topScope.path = "<top>";
|
||||
state.cx.topScope.reached("", state);
|
||||
for (var path in state.roots)
|
||||
reach(state.roots[path], null, path, state);
|
||||
for (var i = 0; i < state.patchUp.length; ++i)
|
||||
patchUpSimpleInstance(state.patchUp[i], state);
|
||||
|
||||
state.server.signal("postCondenseReach", state)
|
||||
|
||||
for (var path in state.types)
|
||||
store(createPath(path.split("."), state), state.types[path], state);
|
||||
for (var path in state.altPaths)
|
||||
storeAlt(path, state.altPaths[path], state);
|
||||
var hasDef = false;
|
||||
for (var _def in state.output["!define"]) { hasDef = true; break; }
|
||||
if (!hasDef) delete state.output["!define"];
|
||||
|
||||
state.server.signal("postCondense", state)
|
||||
|
||||
return simplify(state.output, state.options.sortOutput);
|
||||
};
|
||||
|
||||
function State(origins, name, options) {
|
||||
this.origins = origins;
|
||||
this.cx = infer.cx();
|
||||
this.server = options.server || this.cx.parent || {signal: function() {}}
|
||||
this.maxOrigin = -Infinity;
|
||||
for (var i = 0; i < origins.length; ++i)
|
||||
this.maxOrigin = Math.max(this.maxOrigin, this.cx.origins.indexOf(origins[i]));
|
||||
this.output = {"!name": name, "!define": {}};
|
||||
this.options = options;
|
||||
this.types = Object.create(null);
|
||||
this.altPaths = Object.create(null);
|
||||
this.patchUp = [];
|
||||
this.roots = Object.create(null);
|
||||
}
|
||||
|
||||
State.prototype.isTarget = function(origin) {
|
||||
return this.origins.indexOf(origin) > -1;
|
||||
};
|
||||
|
||||
State.prototype.getSpan = function(node) {
|
||||
if (this.options.spans == false || !this.isTarget(node.origin)) return null;
|
||||
if (node.span) return node.span;
|
||||
var srv = this.cx.parent, file;
|
||||
if (!srv || !node.originNode || !(file = srv.findFile(node.origin))) return null;
|
||||
var start = node.originNode.start, end = node.originNode.end;
|
||||
var pStart = file.asLineChar(start), pEnd = file.asLineChar(end);
|
||||
return start + "[" + pStart.line + ":" + pStart.ch + "]-" +
|
||||
end + "[" + pEnd.line + ":" + pEnd.ch + "]";
|
||||
};
|
||||
|
||||
function pathLen(path) {
|
||||
var len = 1, pos = 0, dot;
|
||||
while ((dot = path.indexOf(".", pos)) != -1) {
|
||||
pos = dot + 1;
|
||||
len += path.charAt(pos) == "!" ? 10 : 1;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
function hop(obj, prop) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, prop);
|
||||
}
|
||||
|
||||
function isSimpleInstance(o) {
|
||||
return o.proto && !(o instanceof infer.Fn) && o.proto != infer.cx().protos.Object &&
|
||||
o.proto.hasCtor && !o.hasCtor;
|
||||
}
|
||||
|
||||
function reach(type, path, id, state, byName) {
|
||||
var actual = type.getType(false);
|
||||
if (!actual) return;
|
||||
var orig = type.origin || actual.origin, relevant = false;
|
||||
if (orig) {
|
||||
var origPos = state.cx.origins.indexOf(orig);
|
||||
// This is a path that is newer than the code we are interested in.
|
||||
if (origPos > state.maxOrigin) return;
|
||||
relevant = state.isTarget(orig);
|
||||
}
|
||||
var newPath = path ? path + "." + id : id, oldPath = actual.path;
|
||||
var shorter = !oldPath || pathLen(oldPath) > pathLen(newPath);
|
||||
if (shorter) {
|
||||
if (!(actual instanceof infer.Prim)) actual.path = newPath;
|
||||
if (actual.reached(newPath, state, !relevant) && relevant) {
|
||||
var data = state.types[oldPath];
|
||||
if (data) {
|
||||
delete state.types[oldPath];
|
||||
state.altPaths[oldPath] = actual;
|
||||
} else data = {type: actual};
|
||||
data.span = state.getSpan(type) || (actual != type && state.isTarget(actual.origin) && state.getSpan(actual)) || data.span;
|
||||
data.doc = type.doc || (actual != type && state.isTarget(actual.origin) && actual.doc) || data.doc;
|
||||
data.data = actual.metaData;
|
||||
data.byName = data.byName == null ? !!byName : data.byName && byName;
|
||||
state.types[newPath] = data;
|
||||
}
|
||||
} else {
|
||||
if (relevant) state.altPaths[newPath] = actual;
|
||||
}
|
||||
}
|
||||
function reachByName(aval, path, id, state) {
|
||||
var type = aval.getType();
|
||||
if (type) reach(type, path, id, state, true);
|
||||
}
|
||||
|
||||
infer.Prim.prototype.reached = function() {return true;};
|
||||
|
||||
infer.Arr.prototype.reached = function(path, state, concrete) {
|
||||
if (concrete) return true
|
||||
if (this.tuple) {
|
||||
for (var i = 0; i < this.tuple; i++)
|
||||
reachByName(this.getProp(String(i)), path, String(i), state)
|
||||
} else {
|
||||
reachByName(this.getProp("<i>"), path, "<i>", state)
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
infer.Fn.prototype.reached = function(path, state, concrete) {
|
||||
infer.Obj.prototype.reached.call(this, path, state, concrete);
|
||||
if (!concrete) {
|
||||
for (var i = 0; i < this.args.length; ++i)
|
||||
reachByName(this.args[i], path, "!" + i, state);
|
||||
reachByName(this.retval, path, "!ret", state);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
infer.Obj.prototype.reached = function(path, state, concrete) {
|
||||
if (isSimpleInstance(this) && !this.condenseForceInclude) {
|
||||
if (state.patchUp.indexOf(this) == -1) state.patchUp.push(this);
|
||||
return true;
|
||||
} else if (this.proto && !concrete) {
|
||||
reach(this.proto, path, "!proto", state);
|
||||
}
|
||||
var hasProps = false;
|
||||
for (var prop in this.props) {
|
||||
reach(this.props[prop], path, prop, state);
|
||||
hasProps = true;
|
||||
}
|
||||
if (!hasProps && !this.condenseForceInclude && !(this instanceof infer.Fn)) {
|
||||
this.nameOverride = "?";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
function patchUpSimpleInstance(obj, state) {
|
||||
var path = obj.proto.hasCtor.path;
|
||||
if (path) {
|
||||
obj.nameOverride = "+" + path;
|
||||
} else {
|
||||
path = obj.path;
|
||||
}
|
||||
for (var prop in obj.props)
|
||||
reach(obj.props[prop], path, prop, state);
|
||||
}
|
||||
|
||||
function createPath(parts, state) {
|
||||
var base = state.output, defs = state.output["!define"];
|
||||
for (var i = 0, path; i < parts.length; ++i) {
|
||||
var part = parts[i];
|
||||
path = path ? path + "." + part : part;
|
||||
var me = state.types[path];
|
||||
if (part.charAt(0) == "!" || me && me.byName) {
|
||||
if (hop(defs, path)) base = defs[path];
|
||||
else defs[path] = base = {};
|
||||
} else {
|
||||
if (hop(base, parts[i])) base = base[part];
|
||||
else base = base[part] = {};
|
||||
}
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
function store(out, info, state) {
|
||||
var name = typeName(info.type);
|
||||
if (name != info.type.path && name != "?") {
|
||||
out["!type"] = name;
|
||||
} else if (info.type.proto && info.type.proto != state.cx.protos.Object) {
|
||||
var protoName = typeName(info.type.proto);
|
||||
if (protoName != "?") out["!proto"] = protoName;
|
||||
}
|
||||
if (info.span) out["!span"] = info.span;
|
||||
if (info.doc) out["!doc"] = info.doc;
|
||||
if (info.data) out["!data"] = info.data;
|
||||
}
|
||||
|
||||
function storeAlt(path, type, state) {
|
||||
var parts = path.split("."), last = parts.pop();
|
||||
if (last[0] == "!") return;
|
||||
var known = state.types[parts.join(".")];
|
||||
var base = createPath(parts, state);
|
||||
if (known && known.type.constructor != infer.Obj) return;
|
||||
if (!hop(base, last)) base[last] = type.nameOverride || type.path;
|
||||
}
|
||||
|
||||
var typeNameStack = [];
|
||||
function typeName(value) {
|
||||
var isType = value instanceof infer.Type;
|
||||
if (isType) {
|
||||
if (typeNameStack.indexOf(value) > -1)
|
||||
return value.path || "?";
|
||||
typeNameStack.push(value);
|
||||
}
|
||||
var name = value.typeName();
|
||||
if (isType) typeNameStack.pop();
|
||||
return name;
|
||||
}
|
||||
|
||||
infer.AVal.prototype.typeName = function() {
|
||||
if (this.types.length == 0) return "?";
|
||||
if (this.types.length == 1) return typeName(this.types[0]);
|
||||
var simplified = infer.simplifyTypes(this.types);
|
||||
if (simplified.length > 2) return "?";
|
||||
for (var strs = [], i = 0; i < simplified.length; i++)
|
||||
strs.push(typeName(simplified[i]));
|
||||
return strs.join("|");
|
||||
};
|
||||
|
||||
infer.ANull.typeName = function() { return "?"; };
|
||||
|
||||
infer.Prim.prototype.typeName = function() { return this.name; };
|
||||
|
||||
infer.Sym.prototype.typeName = function() { return this.asPropName }
|
||||
|
||||
infer.Arr.prototype.typeName = function() {
|
||||
if (!this.tuple) return "[" + typeName(this.getProp("<i>")) + "]"
|
||||
var content = []
|
||||
for (var i = 0; i < this.tuple; i++)
|
||||
content.push(typeName(this.getProp(String(i))))
|
||||
return "[" + content.join(", ") + "]"
|
||||
};
|
||||
|
||||
infer.Fn.prototype.typeName = function() {
|
||||
var out = this.generator ? "fn*(" : "fn(";
|
||||
for (var i = 0; i < this.args.length; ++i) {
|
||||
if (i) out += ", ";
|
||||
var name = this.argNames[i];
|
||||
if (name && name != "?") out += name + ": ";
|
||||
out += typeName(this.args[i]);
|
||||
}
|
||||
out += ")";
|
||||
if (this.computeRetSource)
|
||||
out += " -> " + this.computeRetSource;
|
||||
else if (!this.retval.isEmpty())
|
||||
out += " -> " + typeName(this.retval);
|
||||
return out;
|
||||
};
|
||||
|
||||
infer.Obj.prototype.typeName = function() {
|
||||
if (this.nameOverride) return this.nameOverride;
|
||||
if (!this.path) return "?";
|
||||
return this.path;
|
||||
};
|
||||
|
||||
function simplify(data, sort) {
|
||||
if (typeof data != "object") return data;
|
||||
var sawType = false, sawOther = false;
|
||||
for (var prop in data) {
|
||||
if (prop == "!type") sawType = true;
|
||||
else sawOther = true;
|
||||
if (prop != "!data")
|
||||
data[prop] = simplify(data[prop], sort);
|
||||
}
|
||||
if (sawType && !sawOther) return data["!type"];
|
||||
return sort ? sortObject(data) : data;
|
||||
}
|
||||
|
||||
function sortObject(obj) {
|
||||
var props = [], out = {};
|
||||
for (var prop in obj) props.push(prop);
|
||||
props.sort();
|
||||
for (var i = 0; i < props.length; ++i) {
|
||||
var prop = props[i];
|
||||
out[prop] = obj[prop];
|
||||
}
|
||||
return out;
|
||||
}
|
||||
});
|
||||
656
devtools/client/sourceeditor/tern/def.js
Normal file
656
devtools/client/sourceeditor/tern/def.js
Normal file
|
|
@ -0,0 +1,656 @@
|
|||
// Type description parser
|
||||
//
|
||||
// Type description JSON files (such as ecma5.json and browser.json)
|
||||
// are used to
|
||||
//
|
||||
// A) describe types that come from native code
|
||||
//
|
||||
// B) to cheaply load the types for big libraries, or libraries that
|
||||
// can't be inferred well
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
return exports.init = mod;
|
||||
if (typeof define == "function" && define.amd) // AMD
|
||||
return define({init: mod});
|
||||
tern.def = {init: mod};
|
||||
})(function(exports, infer) {
|
||||
"use strict";
|
||||
|
||||
function hop(obj, prop) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, prop);
|
||||
}
|
||||
|
||||
var TypeParser = exports.TypeParser = function(spec, start, base, forceNew) {
|
||||
this.pos = start || 0;
|
||||
this.spec = spec;
|
||||
this.base = base;
|
||||
this.forceNew = forceNew;
|
||||
};
|
||||
|
||||
function unwrapType(type, self, args) {
|
||||
return type.call ? type(self, args) : type;
|
||||
}
|
||||
|
||||
function extractProp(type, prop) {
|
||||
if (prop == "!ret") {
|
||||
if (type.retval) return type.retval;
|
||||
var rv = new infer.AVal;
|
||||
type.propagate(new infer.IsCallee(infer.ANull, [], null, rv));
|
||||
return rv;
|
||||
} else {
|
||||
return type.getProp(prop);
|
||||
}
|
||||
}
|
||||
|
||||
function computedFunc(name, args, retType, generator) {
|
||||
return function(self, cArgs) {
|
||||
var realArgs = [];
|
||||
for (var i = 0; i < args.length; i++) realArgs.push(unwrapType(args[i], self, cArgs));
|
||||
return new infer.Fn(name, infer.ANull, realArgs, unwrapType(retType, self, cArgs), generator);
|
||||
};
|
||||
}
|
||||
function computedUnion(types) {
|
||||
return function(self, args) {
|
||||
var union = new infer.AVal;
|
||||
for (var i = 0; i < types.length; i++) unwrapType(types[i], self, args).propagate(union);
|
||||
union.maxWeight = 1e5;
|
||||
return union;
|
||||
};
|
||||
}
|
||||
function computedArray(inner) {
|
||||
return function(self, args) {
|
||||
return new infer.Arr(inner(self, args));
|
||||
};
|
||||
}
|
||||
function computedTuple(types) {
|
||||
return function(self, args) {
|
||||
return new infer.Arr(types.map(function(tp) { return unwrapType(tp, self, args) }))
|
||||
}
|
||||
}
|
||||
|
||||
TypeParser.prototype = {
|
||||
eat: function(str) {
|
||||
if (str.length == 1 ? this.spec.charAt(this.pos) == str : this.spec.indexOf(str, this.pos) == this.pos) {
|
||||
this.pos += str.length;
|
||||
return true;
|
||||
}
|
||||
},
|
||||
word: function(re) {
|
||||
var word = "", ch, re = re || /[\w$]/;
|
||||
while ((ch = this.spec.charAt(this.pos)) && re.test(ch)) { word += ch; ++this.pos; }
|
||||
return word;
|
||||
},
|
||||
error: function() {
|
||||
throw new Error("Unrecognized type spec: " + this.spec + " (at " + this.pos + ")");
|
||||
},
|
||||
parseFnType: function(comp, name, top, generator) {
|
||||
var args = [], names = [], computed = false;
|
||||
if (!this.eat(")")) for (var i = 0; ; ++i) {
|
||||
var colon = this.spec.indexOf(": ", this.pos), argname;
|
||||
if (colon != -1) {
|
||||
argname = this.spec.slice(this.pos, colon);
|
||||
if (/^[$\w?]+$/.test(argname))
|
||||
this.pos = colon + 2;
|
||||
else
|
||||
argname = null;
|
||||
}
|
||||
names.push(argname);
|
||||
var argType = this.parseType(comp);
|
||||
if (argType.call) computed = true;
|
||||
args.push(argType);
|
||||
if (!this.eat(", ")) {
|
||||
this.eat(")") || this.error();
|
||||
break;
|
||||
}
|
||||
}
|
||||
var retType, computeRet, computeRetStart, fn;
|
||||
if (this.eat(" -> ")) {
|
||||
var retStart = this.pos;
|
||||
retType = this.parseType(true);
|
||||
if (retType.call && !computed) {
|
||||
computeRet = retType;
|
||||
retType = infer.ANull;
|
||||
computeRetStart = retStart;
|
||||
}
|
||||
} else {
|
||||
retType = infer.ANull;
|
||||
}
|
||||
if (computed) return computedFunc(name, args, retType, generator);
|
||||
|
||||
if (top && (fn = this.base))
|
||||
infer.Fn.call(this.base, name, infer.ANull, args, names, retType, generator);
|
||||
else
|
||||
fn = new infer.Fn(name, infer.ANull, args, names, retType, generator);
|
||||
if (computeRet) fn.computeRet = computeRet;
|
||||
if (computeRetStart != null) fn.computeRetSource = this.spec.slice(computeRetStart, this.pos);
|
||||
return fn;
|
||||
},
|
||||
parseType: function(comp, name, top) {
|
||||
var main = this.parseTypeMaybeProp(comp, name, top);
|
||||
if (!this.eat("|")) return main;
|
||||
var types = [main], computed = main.call;
|
||||
for (;;) {
|
||||
var next = this.parseTypeMaybeProp(comp, name, top);
|
||||
types.push(next);
|
||||
if (next.call) computed = true;
|
||||
if (!this.eat("|")) break;
|
||||
}
|
||||
if (computed) return computedUnion(types);
|
||||
var union = new infer.AVal;
|
||||
for (var i = 0; i < types.length; i++) types[i].propagate(union);
|
||||
union.maxWeight = 1e5;
|
||||
return union;
|
||||
},
|
||||
parseTypeMaybeProp: function(comp, name, top) {
|
||||
var result = this.parseTypeInner(comp, name, top);
|
||||
while (comp && this.eat(".")) result = this.extendWithProp(result);
|
||||
return result;
|
||||
},
|
||||
extendWithProp: function(base) {
|
||||
var propName = this.word(/[\w<>$!:]/) || this.error();
|
||||
if (base.apply) return function(self, args) {
|
||||
return extractProp(base(self, args), propName);
|
||||
};
|
||||
return extractProp(base, propName);
|
||||
},
|
||||
parseTypeInner: function(comp, name, top) {
|
||||
var gen
|
||||
if (this.eat("fn(") || (gen = this.eat("fn*("))) {
|
||||
return this.parseFnType(comp, name, top, gen);
|
||||
} else if (this.eat("[")) {
|
||||
var inner = this.parseType(comp), types, computed = inner.call
|
||||
while (this.eat(", ")) {
|
||||
if (!types) types = [inner]
|
||||
var next = this.parseType(comp)
|
||||
types.push(next)
|
||||
computed = computed || next.call
|
||||
}
|
||||
this.eat("]") || this.error()
|
||||
if (computed) return types ? computedTuple(types) : computedArray(inner)
|
||||
if (top && this.base) {
|
||||
infer.Arr.call(this.base, types || inner)
|
||||
return this.base
|
||||
}
|
||||
return new infer.Arr(types || inner)
|
||||
} else if (this.eat("+")) {
|
||||
var path = this.word(/[\w$<>\.:!]/)
|
||||
var base = infer.cx().localDefs[path + ".prototype"]
|
||||
if (!base) {
|
||||
var base = parsePath(path);
|
||||
if (!(base instanceof infer.Obj)) return base;
|
||||
var proto = descendProps(base, ["prototype"])
|
||||
if (proto && (proto = proto.getObjType()))
|
||||
base = proto
|
||||
}
|
||||
if (comp && this.eat("[")) return this.parsePoly(base);
|
||||
if (top && this.forceNew) return new infer.Obj(base);
|
||||
return infer.getInstance(base);
|
||||
} else if (this.eat(":")) {
|
||||
var name = this.word(/[\w$\.]/)
|
||||
return infer.getSymbol(name)
|
||||
} else if (comp && this.eat("!")) {
|
||||
var arg = this.word(/\d/);
|
||||
if (arg) {
|
||||
arg = Number(arg);
|
||||
return function(_self, args) {return args[arg] || infer.ANull;};
|
||||
} else if (this.eat("this")) {
|
||||
return function(self) {return self;};
|
||||
} else if (this.eat("custom:")) {
|
||||
var fname = this.word(/[\w$]/);
|
||||
return customFunctions[fname] || function() { return infer.ANull; };
|
||||
} else {
|
||||
return this.fromWord("!" + this.word(/[\w$<>\.!:]/));
|
||||
}
|
||||
} else if (this.eat("?")) {
|
||||
return infer.ANull;
|
||||
} else {
|
||||
return this.fromWord(this.word(/[\w$<>\.!:`]/));
|
||||
}
|
||||
},
|
||||
fromWord: function(spec) {
|
||||
var cx = infer.cx();
|
||||
switch (spec) {
|
||||
case "number": return cx.num;
|
||||
case "string": return cx.str;
|
||||
case "bool": return cx.bool;
|
||||
case "<top>": return cx.topScope;
|
||||
}
|
||||
if (cx.localDefs && spec in cx.localDefs) return cx.localDefs[spec];
|
||||
return parsePath(spec);
|
||||
},
|
||||
parsePoly: function(base) {
|
||||
var propName = "<i>", match;
|
||||
if (match = this.spec.slice(this.pos).match(/^\s*([\w$:]+)\s*=\s*/)) {
|
||||
propName = match[1];
|
||||
this.pos += match[0].length;
|
||||
}
|
||||
var value = this.parseType(true);
|
||||
if (!this.eat("]")) this.error();
|
||||
if (value.call) return function(self, args) {
|
||||
var instance = new infer.Obj(base);
|
||||
value(self, args).propagate(instance.defProp(propName));
|
||||
return instance;
|
||||
};
|
||||
var instance = new infer.Obj(base);
|
||||
value.propagate(instance.defProp(propName));
|
||||
return instance;
|
||||
}
|
||||
};
|
||||
|
||||
function parseType(spec, name, base, forceNew) {
|
||||
var type = new TypeParser(spec, null, base, forceNew).parseType(false, name, true);
|
||||
if (/^fn\(/.test(spec)) for (var i = 0; i < type.args.length; ++i) (function(i) {
|
||||
var arg = type.args[i];
|
||||
if (arg instanceof infer.Fn && arg.args && arg.args.length) addEffect(type, function(_self, fArgs) {
|
||||
var fArg = fArgs[i];
|
||||
if (fArg) fArg.propagate(new infer.IsCallee(infer.cx().topScope, arg.args, null, infer.ANull));
|
||||
});
|
||||
})(i);
|
||||
return type;
|
||||
}
|
||||
|
||||
function addEffect(fn, handler, replaceRet) {
|
||||
var oldCmp = fn.computeRet, rv = fn.retval;
|
||||
fn.computeRet = function(self, args, argNodes) {
|
||||
var handled = handler(self, args, argNodes);
|
||||
var old = oldCmp ? oldCmp(self, args, argNodes) : rv;
|
||||
return replaceRet ? handled : old;
|
||||
};
|
||||
}
|
||||
|
||||
var parseEffect = exports.parseEffect = function(effect, fn) {
|
||||
var m;
|
||||
if (effect.indexOf("propagate ") == 0) {
|
||||
var p = new TypeParser(effect, 10);
|
||||
var origin = p.parseType(true);
|
||||
if (!p.eat(" ")) p.error();
|
||||
var target = p.parseType(true);
|
||||
addEffect(fn, function(self, args) {
|
||||
unwrapType(origin, self, args).propagate(unwrapType(target, self, args));
|
||||
});
|
||||
} else if (effect.indexOf("call ") == 0) {
|
||||
var andRet = effect.indexOf("and return ", 5) == 5;
|
||||
var p = new TypeParser(effect, andRet ? 16 : 5);
|
||||
var getCallee = p.parseType(true), getSelf = null, getArgs = [];
|
||||
if (p.eat(" this=")) getSelf = p.parseType(true);
|
||||
while (p.eat(" ")) getArgs.push(p.parseType(true));
|
||||
addEffect(fn, function(self, args) {
|
||||
var callee = unwrapType(getCallee, self, args);
|
||||
var slf = getSelf ? unwrapType(getSelf, self, args) : infer.ANull, as = [];
|
||||
for (var i = 0; i < getArgs.length; ++i) as.push(unwrapType(getArgs[i], self, args));
|
||||
var result = andRet ? new infer.AVal : infer.ANull;
|
||||
callee.propagate(new infer.IsCallee(slf, as, null, result));
|
||||
return result;
|
||||
}, andRet);
|
||||
} else if (m = effect.match(/^custom (\S+)\s*(.*)/)) {
|
||||
var customFunc = customFunctions[m[1]];
|
||||
if (customFunc) addEffect(fn, m[2] ? customFunc(m[2]) : customFunc);
|
||||
} else if (effect.indexOf("copy ") == 0) {
|
||||
var p = new TypeParser(effect, 5);
|
||||
var getFrom = p.parseType(true);
|
||||
p.eat(" ");
|
||||
var getTo = p.parseType(true);
|
||||
addEffect(fn, function(self, args) {
|
||||
var from = unwrapType(getFrom, self, args), to = unwrapType(getTo, self, args);
|
||||
from.forAllProps(function(prop, val, local) {
|
||||
if (local && prop != "<i>")
|
||||
to.propagate(new infer.DefProp(prop, val));
|
||||
});
|
||||
});
|
||||
} else {
|
||||
throw new Error("Unknown effect type: " + effect);
|
||||
}
|
||||
};
|
||||
|
||||
var currentTopScope;
|
||||
|
||||
var parsePath = exports.parsePath = function(path, scope) {
|
||||
var cx = infer.cx(), cached = cx.paths[path], origPath = path;
|
||||
if (cached != null) return cached;
|
||||
cx.paths[path] = infer.ANull;
|
||||
|
||||
var base = scope || currentTopScope || cx.topScope;
|
||||
|
||||
if (cx.localDefs) for (var name in cx.localDefs) {
|
||||
if (path.indexOf(name) == 0) {
|
||||
if (path == name) return cx.paths[path] = cx.localDefs[path];
|
||||
if (path.charAt(name.length) == ".") {
|
||||
base = cx.localDefs[name];
|
||||
path = path.slice(name.length + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var result = descendProps(base, path.split("."))
|
||||
// Uncomment this to get feedback on your poorly written .json files
|
||||
// if (result == infer.ANull) console.error("bad path: " + origPath + " (" + cx.curOrigin + ")")
|
||||
cx.paths[origPath] = result == infer.ANull ? null : result
|
||||
return result
|
||||
}
|
||||
|
||||
function descendProps(base, parts) {
|
||||
for (var i = 0; i < parts.length && base != infer.ANull; ++i) {
|
||||
var prop = parts[i];
|
||||
if (prop.charAt(0) == "!") {
|
||||
if (prop == "!proto") {
|
||||
base = (base instanceof infer.Obj && base.proto) || infer.ANull;
|
||||
} else {
|
||||
var fn = base.getFunctionType();
|
||||
if (!fn) {
|
||||
base = infer.ANull;
|
||||
} else if (prop == "!ret") {
|
||||
base = fn.retval && fn.retval.getType(false) || infer.ANull;
|
||||
} else {
|
||||
var arg = fn.args && fn.args[Number(prop.slice(1))];
|
||||
base = (arg && arg.getType(false)) || infer.ANull;
|
||||
}
|
||||
}
|
||||
} else if (base instanceof infer.Obj) {
|
||||
var propVal = (prop == "prototype" && base instanceof infer.Fn) ? base.getProp(prop) : base.props[prop];
|
||||
if (!propVal || propVal.isEmpty())
|
||||
base = infer.ANull;
|
||||
else
|
||||
base = propVal.types[0];
|
||||
}
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
function emptyObj(ctor) {
|
||||
var empty = Object.create(ctor.prototype);
|
||||
empty.props = Object.create(null);
|
||||
empty.isShell = true;
|
||||
return empty;
|
||||
}
|
||||
|
||||
function isSimpleAnnotation(spec) {
|
||||
if (!spec["!type"] || /^(fn\(|\[)/.test(spec["!type"])) return false;
|
||||
for (var prop in spec)
|
||||
if (prop != "!type" && prop != "!doc" && prop != "!url" && prop != "!span" && prop != "!data")
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function passOne(base, spec, path) {
|
||||
if (!base) {
|
||||
var tp = spec["!type"];
|
||||
if (tp) {
|
||||
if (/^fn\(/.test(tp)) base = emptyObj(infer.Fn);
|
||||
else if (tp.charAt(0) == "[") base = emptyObj(infer.Arr);
|
||||
else throw new Error("Invalid !type spec: " + tp);
|
||||
} else if (spec["!stdProto"]) {
|
||||
base = infer.cx().protos[spec["!stdProto"]];
|
||||
} else {
|
||||
base = emptyObj(infer.Obj);
|
||||
}
|
||||
base.name = path;
|
||||
}
|
||||
|
||||
for (var name in spec) if (hop(spec, name) && name.charCodeAt(0) != 33) {
|
||||
var inner = spec[name];
|
||||
if (typeof inner == "string" || isSimpleAnnotation(inner)) continue;
|
||||
var prop = base.defProp(name);
|
||||
passOne(prop.getObjType(), inner, path ? path + "." + name : name).propagate(prop);
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
function passTwo(base, spec, path) {
|
||||
if (base.isShell) {
|
||||
delete base.isShell;
|
||||
var tp = spec["!type"];
|
||||
if (tp) {
|
||||
parseType(tp, path, base);
|
||||
} else {
|
||||
var proto = spec["!proto"] && parseType(spec["!proto"]);
|
||||
infer.Obj.call(base, proto instanceof infer.Obj ? proto : true, path);
|
||||
}
|
||||
}
|
||||
|
||||
var effects = spec["!effects"];
|
||||
if (effects && base instanceof infer.Fn) for (var i = 0; i < effects.length; ++i)
|
||||
parseEffect(effects[i], base);
|
||||
copyInfo(spec, base);
|
||||
|
||||
for (var name in spec) if (hop(spec, name) && name.charCodeAt(0) != 33) {
|
||||
var inner = spec[name], known = base.defProp(name), innerPath = path ? path + "." + name : name;
|
||||
if (typeof inner == "string") {
|
||||
if (known.isEmpty()) parseType(inner, innerPath).propagate(known);
|
||||
} else {
|
||||
if (!isSimpleAnnotation(inner))
|
||||
passTwo(known.getObjType(), inner, innerPath);
|
||||
else if (known.isEmpty())
|
||||
parseType(inner["!type"], innerPath, null, true).propagate(known);
|
||||
else
|
||||
continue;
|
||||
if (inner["!doc"]) known.doc = inner["!doc"];
|
||||
if (inner["!url"]) known.url = inner["!url"];
|
||||
if (inner["!span"]) known.span = inner["!span"];
|
||||
}
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
function copyInfo(spec, type) {
|
||||
if (spec["!doc"]) type.doc = spec["!doc"];
|
||||
if (spec["!url"]) type.url = spec["!url"];
|
||||
if (spec["!span"]) type.span = spec["!span"];
|
||||
if (spec["!data"]) type.metaData = spec["!data"];
|
||||
}
|
||||
|
||||
function doLoadEnvironment(data, scope) {
|
||||
var cx = infer.cx(), server = cx.parent
|
||||
|
||||
infer.addOrigin(cx.curOrigin = data["!name"] || "env#" + cx.origins.length);
|
||||
cx.localDefs = cx.definitions[cx.curOrigin] = Object.create(null);
|
||||
|
||||
if (server) server.signal("preLoadDef", data)
|
||||
|
||||
passOne(scope, data);
|
||||
|
||||
var def = data["!define"];
|
||||
if (def) {
|
||||
for (var name in def) {
|
||||
var spec = def[name];
|
||||
cx.localDefs[name] = typeof spec == "string" ? parsePath(spec) : passOne(null, spec, name);
|
||||
}
|
||||
for (var name in def) {
|
||||
var spec = def[name];
|
||||
if (typeof spec != "string") passTwo(cx.localDefs[name], def[name], name);
|
||||
}
|
||||
}
|
||||
|
||||
passTwo(scope, data);
|
||||
|
||||
if (server) server.signal("postLoadDef", data)
|
||||
|
||||
cx.curOrigin = cx.localDefs = null;
|
||||
}
|
||||
|
||||
exports.load = function(data, scope) {
|
||||
if (!scope) scope = infer.cx().topScope;
|
||||
var oldScope = currentTopScope;
|
||||
currentTopScope = scope;
|
||||
try {
|
||||
doLoadEnvironment(data, scope);
|
||||
} finally {
|
||||
currentTopScope = oldScope;
|
||||
}
|
||||
};
|
||||
|
||||
exports.parse = function(data, origin, path) {
|
||||
var cx = infer.cx();
|
||||
if (origin) {
|
||||
cx.origin = origin;
|
||||
cx.localDefs = cx.definitions[origin];
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof data == "string")
|
||||
return parseType(data, path);
|
||||
else
|
||||
return passTwo(passOne(null, data, path), data, path);
|
||||
} finally {
|
||||
if (origin) cx.origin = cx.localDefs = null;
|
||||
}
|
||||
};
|
||||
|
||||
// Used to register custom logic for more involved effect or type
|
||||
// computation.
|
||||
var customFunctions = Object.create(null);
|
||||
infer.registerFunction = function(name, f) { customFunctions[name] = f; };
|
||||
|
||||
var IsCreated = infer.constraint({
|
||||
construct: function(created, target, spec) {
|
||||
this.created = created;
|
||||
this.target = target;
|
||||
this.spec = spec;
|
||||
},
|
||||
addType: function(tp) {
|
||||
if (tp instanceof infer.Obj && this.created++ < 5) {
|
||||
var derived = new infer.Obj(tp), spec = this.spec;
|
||||
if (spec instanceof infer.AVal) spec = spec.getObjType(false);
|
||||
if (spec instanceof infer.Obj) for (var prop in spec.props) {
|
||||
var cur = spec.props[prop].types[0];
|
||||
var p = derived.defProp(prop);
|
||||
if (cur && cur instanceof infer.Obj && cur.props.value) {
|
||||
var vtp = cur.props.value.getType(false);
|
||||
if (vtp) p.addType(vtp);
|
||||
}
|
||||
}
|
||||
this.target.addType(derived);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
infer.registerFunction("Object_create", function(_self, args, argNodes) {
|
||||
if (argNodes && argNodes.length && argNodes[0].type == "Literal" && argNodes[0].value == null)
|
||||
return new infer.Obj();
|
||||
|
||||
var result = new infer.AVal;
|
||||
if (args[0]) args[0].propagate(new IsCreated(0, result, args[1]));
|
||||
return result;
|
||||
});
|
||||
|
||||
var PropSpec = infer.constraint({
|
||||
construct: function(target) { this.target = target; },
|
||||
addType: function(tp) {
|
||||
if (!(tp instanceof infer.Obj)) return;
|
||||
if (tp.hasProp("value"))
|
||||
tp.getProp("value").propagate(this.target);
|
||||
else if (tp.hasProp("get"))
|
||||
tp.getProp("get").propagate(new infer.IsCallee(infer.ANull, [], null, this.target));
|
||||
}
|
||||
});
|
||||
|
||||
infer.registerFunction("Object_defineProperty", function(_self, args, argNodes) {
|
||||
if (argNodes && argNodes.length >= 3 && argNodes[1].type == "Literal" &&
|
||||
typeof argNodes[1].value == "string") {
|
||||
var obj = args[0], connect = new infer.AVal;
|
||||
obj.propagate(new infer.DefProp(argNodes[1].value, connect, argNodes[1]));
|
||||
args[2].propagate(new PropSpec(connect));
|
||||
}
|
||||
return infer.ANull;
|
||||
});
|
||||
|
||||
infer.registerFunction("Object_defineProperties", function(_self, args, argNodes) {
|
||||
if (args.length >= 2) {
|
||||
var obj = args[0];
|
||||
args[1].forAllProps(function(prop, val, local) {
|
||||
if (!local) return;
|
||||
var connect = new infer.AVal;
|
||||
obj.propagate(new infer.DefProp(prop, connect, argNodes && argNodes[1]));
|
||||
val.propagate(new PropSpec(connect));
|
||||
});
|
||||
}
|
||||
return infer.ANull;
|
||||
});
|
||||
|
||||
var IsBound = infer.constraint({
|
||||
construct: function(self, args, target) {
|
||||
this.self = self; this.args = args; this.target = target;
|
||||
},
|
||||
addType: function(tp) {
|
||||
if (!(tp instanceof infer.Fn)) return;
|
||||
this.target.addType(new infer.Fn(tp.name, infer.ANull, tp.args.slice(this.args.length),
|
||||
tp.argNames.slice(this.args.length), tp.retval, tp.generator));
|
||||
this.self.propagate(tp.self);
|
||||
for (var i = 0; i < Math.min(tp.args.length, this.args.length); ++i)
|
||||
this.args[i].propagate(tp.args[i]);
|
||||
}
|
||||
});
|
||||
|
||||
infer.registerFunction("Function_bind", function(self, args) {
|
||||
if (!args.length) return infer.ANull;
|
||||
var result = new infer.AVal;
|
||||
self.propagate(new IsBound(args[0], args.slice(1), result));
|
||||
return result;
|
||||
});
|
||||
|
||||
infer.registerFunction("Array_ctor", function(_self, args) {
|
||||
var arr = new infer.Arr;
|
||||
if (args.length != 1 || !args[0].hasType(infer.cx().num)) {
|
||||
var content = arr.getProp("<i>");
|
||||
for (var i = 0; i < args.length; ++i) args[i].propagate(content);
|
||||
}
|
||||
return arr;
|
||||
});
|
||||
|
||||
infer.registerFunction("Promise_ctor", function(_self, args, argNodes) {
|
||||
var defs6 = infer.cx().definitions.ecma6
|
||||
if (!defs6 || args.length < 1) return infer.ANull;
|
||||
var self = new infer.Obj(defs6["Promise.prototype"]);
|
||||
var valProp = self.defProp(":t", argNodes && argNodes[0]);
|
||||
var valArg = new infer.AVal;
|
||||
valArg.propagate(valProp);
|
||||
var exec = new infer.Fn("execute", infer.ANull, [valArg], ["value"], infer.ANull);
|
||||
var reject = defs6.Promise_reject;
|
||||
args[0].propagate(new infer.IsCallee(infer.ANull, [exec, reject], null, infer.ANull));
|
||||
return self;
|
||||
});
|
||||
|
||||
var PromiseResolvesTo = infer.constraint({
|
||||
construct: function(output) { this.output = output; },
|
||||
addType: function(tp) {
|
||||
if (tp.constructor == infer.Obj && tp.name == "Promise" && tp.hasProp(":t"))
|
||||
tp.getProp(":t").propagate(this.output);
|
||||
else
|
||||
tp.propagate(this.output);
|
||||
}
|
||||
});
|
||||
|
||||
var WG_PROMISE_KEEP_VALUE = 50;
|
||||
|
||||
infer.registerFunction("Promise_then", function(self, args, argNodes) {
|
||||
var fn = args.length && args[0].getFunctionType();
|
||||
var defs6 = infer.cx().definitions.ecma6
|
||||
if (!fn || !defs6) return self;
|
||||
|
||||
var result = new infer.Obj(defs6["Promise.prototype"]);
|
||||
var value = result.defProp(":t", argNodes && argNodes[0]), ty;
|
||||
if (fn.retval.isEmpty() && (ty = self.getType()) instanceof infer.Obj && ty.hasProp(":t"))
|
||||
ty.getProp(":t").propagate(value, WG_PROMISE_KEEP_VALUE);
|
||||
fn.retval.propagate(new PromiseResolvesTo(value));
|
||||
return result;
|
||||
});
|
||||
|
||||
infer.registerFunction("getOwnPropertySymbols", function(_self, args) {
|
||||
if (!args.length) return infer.ANull
|
||||
var result = new infer.AVal
|
||||
args[0].forAllProps(function(prop, _val, local) {
|
||||
if (local && prop.charAt(0) == ":") result.addType(infer.getSymbol(prop.slice(1)))
|
||||
})
|
||||
return result
|
||||
})
|
||||
|
||||
infer.registerFunction("getSymbol", function(_self, _args, argNodes) {
|
||||
if (argNodes.length && argNodes[0].type == "Literal" && typeof argNodes[0].value == "string")
|
||||
return infer.getSymbol(argNodes[0].value)
|
||||
else
|
||||
return infer.ANull
|
||||
})
|
||||
|
||||
return exports;
|
||||
});
|
||||
950
devtools/client/sourceeditor/tern/ecma5.js
Normal file
950
devtools/client/sourceeditor/tern/ecma5.js
Normal file
|
|
@ -0,0 +1,950 @@
|
|||
module.exports = {
|
||||
"!name": "ecma5",
|
||||
"!define": {"Error.prototype": "Error.prototype"},
|
||||
"Infinity": {
|
||||
"!type": "number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Infinity",
|
||||
"!doc": "A numeric value representing infinity."
|
||||
},
|
||||
"undefined": {
|
||||
"!type": "?",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/undefined",
|
||||
"!doc": "The value undefined."
|
||||
},
|
||||
"NaN": {
|
||||
"!type": "number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/NaN",
|
||||
"!doc": "A value representing Not-A-Number."
|
||||
},
|
||||
"Object": {
|
||||
"!type": "fn()",
|
||||
"getPrototypeOf": {
|
||||
"!type": "fn(obj: ?) -> ?",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/getPrototypeOf",
|
||||
"!doc": "Returns the prototype (i.e. the internal prototype) of the specified object."
|
||||
},
|
||||
"create": {
|
||||
"!type": "fn(proto: ?) -> !custom:Object_create",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/create",
|
||||
"!doc": "Creates a new object with the specified prototype object and properties."
|
||||
},
|
||||
"defineProperty": {
|
||||
"!type": "fn(obj: ?, prop: string, desc: ?)",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty",
|
||||
"!doc": "Defines a new property directly on an object, or modifies an existing property on an object, and returns the object. If you want to see how to use the Object.defineProperty method with a binary-flags-like syntax, see this article."
|
||||
},
|
||||
"defineProperties": {
|
||||
"!type": "fn(obj: ?, props: ?)",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty",
|
||||
"!doc": "Defines a new property directly on an object, or modifies an existing property on an object, and returns the object. If you want to see how to use the Object.defineProperty method with a binary-flags-like syntax, see this article."
|
||||
},
|
||||
"getOwnPropertyDescriptor": {
|
||||
"!type": "fn(obj: ?, prop: string) -> ?",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor",
|
||||
"!doc": "Returns a property descriptor for an own property (that is, one directly present on an object, not present by dint of being along an object's prototype chain) of a given object."
|
||||
},
|
||||
"keys": {
|
||||
"!type": "fn(obj: ?) -> [string]",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/keys",
|
||||
"!doc": "Returns an array of a given object's own enumerable properties, in the same order as that provided by a for-in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well)."
|
||||
},
|
||||
"getOwnPropertyNames": {
|
||||
"!type": "fn(obj: ?) -> [string]",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames",
|
||||
"!doc": "Returns an array of all properties (enumerable or not) found directly upon a given object."
|
||||
},
|
||||
"seal": {
|
||||
"!type": "fn(obj: ?)",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/seal",
|
||||
"!doc": "Seals an object, preventing new properties from being added to it and marking all existing properties as non-configurable. Values of present properties can still be changed as long as they are writable."
|
||||
},
|
||||
"isSealed": {
|
||||
"!type": "fn(obj: ?) -> bool",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/isSealed",
|
||||
"!doc": "Determine if an object is sealed."
|
||||
},
|
||||
"freeze": {
|
||||
"!type": "fn(obj: ?)",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/freeze",
|
||||
"!doc": "Freezes an object: that is, prevents new properties from being added to it; prevents existing properties from being removed; and prevents existing properties, or their enumerability, configurability, or writability, from being changed. In essence the object is made effectively immutable. The method returns the object being frozen."
|
||||
},
|
||||
"isFrozen": {
|
||||
"!type": "fn(obj: ?) -> bool",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/isFrozen",
|
||||
"!doc": "Determine if an object is frozen."
|
||||
},
|
||||
"prototype": {
|
||||
"!stdProto": "Object",
|
||||
"toString": {
|
||||
"!type": "fn() -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/toString",
|
||||
"!doc": "Returns a string representing the object."
|
||||
},
|
||||
"toLocaleString": {
|
||||
"!type": "fn() -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/toLocaleString",
|
||||
"!doc": "Returns a string representing the object. This method is meant to be overriden by derived objects for locale-specific purposes."
|
||||
},
|
||||
"valueOf": {
|
||||
"!type": "fn() -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/valueOf",
|
||||
"!doc": "Returns the primitive value of the specified object"
|
||||
},
|
||||
"hasOwnProperty": {
|
||||
"!type": "fn(prop: string) -> bool",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/hasOwnProperty",
|
||||
"!doc": "Returns a boolean indicating whether the object has the specified property."
|
||||
},
|
||||
"propertyIsEnumerable": {
|
||||
"!type": "fn(prop: string) -> bool",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable",
|
||||
"!doc": "Returns a Boolean indicating whether the specified property is enumerable."
|
||||
}
|
||||
},
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object",
|
||||
"!doc": "Creates an object wrapper."
|
||||
},
|
||||
"Function": {
|
||||
"!type": "fn(body: string) -> fn()",
|
||||
"prototype": {
|
||||
"!stdProto": "Function",
|
||||
"apply": {
|
||||
"!type": "fn(this: ?, args: [?])",
|
||||
"!effects": [
|
||||
"call and return !this this=!0 !1.<i> !1.<i> !1.<i>"
|
||||
],
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/apply",
|
||||
"!doc": "Calls a function with a given this value and arguments provided as an array (or an array like object)."
|
||||
},
|
||||
"call": {
|
||||
"!type": "fn(this: ?, args?: ?) -> !this.!ret",
|
||||
"!effects": [
|
||||
"call and return !this this=!0 !1 !2 !3 !4"
|
||||
],
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/call",
|
||||
"!doc": "Calls a function with a given this value and arguments provided individually."
|
||||
},
|
||||
"bind": {
|
||||
"!type": "fn(this: ?, args?: ?) -> !custom:Function_bind",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind",
|
||||
"!doc": "Creates a new function that, when called, has its this keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function was called."
|
||||
},
|
||||
"prototype": "?"
|
||||
},
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function",
|
||||
"!doc": "Every function in JavaScript is actually a Function object."
|
||||
},
|
||||
"Array": {
|
||||
"!type": "fn(size: number) -> !custom:Array_ctor",
|
||||
"isArray": {
|
||||
"!type": "fn(value: ?) -> bool",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/isArray",
|
||||
"!doc": "Returns true if an object is an array, false if it is not."
|
||||
},
|
||||
"prototype": {
|
||||
"!stdProto": "Array",
|
||||
"length": {
|
||||
"!type": "number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/length",
|
||||
"!doc": "An unsigned, 32-bit integer that specifies the number of elements in an array."
|
||||
},
|
||||
"concat": {
|
||||
"!type": "fn(other: [?]) -> !this",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/concat",
|
||||
"!doc": "Returns a new array comprised of this array joined with other array(s) and/or value(s)."
|
||||
},
|
||||
"join": {
|
||||
"!type": "fn(separator?: string) -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/join",
|
||||
"!doc": "Joins all elements of an array into a string."
|
||||
},
|
||||
"splice": {
|
||||
"!type": "fn(pos: number, amount: number)",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/splice",
|
||||
"!doc": "Changes the content of an array, adding new elements while removing old elements."
|
||||
},
|
||||
"pop": {
|
||||
"!type": "fn() -> !this.<i>",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/pop",
|
||||
"!doc": "Removes the last element from an array and returns that element."
|
||||
},
|
||||
"push": {
|
||||
"!type": "fn(newelt: ?) -> number",
|
||||
"!effects": [
|
||||
"propagate !0 !this.<i>"
|
||||
],
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/push",
|
||||
"!doc": "Mutates an array by appending the given elements and returning the new length of the array."
|
||||
},
|
||||
"shift": {
|
||||
"!type": "fn() -> !this.<i>",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/shift",
|
||||
"!doc": "Removes the first element from an array and returns that element. This method changes the length of the array."
|
||||
},
|
||||
"unshift": {
|
||||
"!type": "fn(newelt: ?) -> number",
|
||||
"!effects": [
|
||||
"propagate !0 !this.<i>"
|
||||
],
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/unshift",
|
||||
"!doc": "Adds one or more elements to the beginning of an array and returns the new length of the array."
|
||||
},
|
||||
"slice": {
|
||||
"!type": "fn(from: number, to?: number) -> !this",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/slice",
|
||||
"!doc": "Returns a shallow copy of a portion of an array."
|
||||
},
|
||||
"reverse": {
|
||||
"!type": "fn()",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/reverse",
|
||||
"!doc": "Reverses an array in place. The first array element becomes the last and the last becomes the first."
|
||||
},
|
||||
"sort": {
|
||||
"!type": "fn(compare?: fn(a: ?, b: ?) -> number)",
|
||||
"!effects": [
|
||||
"call !0 !this.<i> !this.<i>"
|
||||
],
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/sort",
|
||||
"!doc": "Sorts the elements of an array in place and returns the array."
|
||||
},
|
||||
"indexOf": {
|
||||
"!type": "fn(elt: ?, from?: number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/indexOf",
|
||||
"!doc": "Returns the first index at which a given element can be found in the array, or -1 if it is not present."
|
||||
},
|
||||
"lastIndexOf": {
|
||||
"!type": "fn(elt: ?, from?: number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/lastIndexOf",
|
||||
"!doc": "Returns the last index at which a given element can be found in the array, or -1 if it is not present. The array is searched backwards, starting at fromIndex."
|
||||
},
|
||||
"every": {
|
||||
"!type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> bool",
|
||||
"!effects": [
|
||||
"call !0 this=!1 !this.<i> number"
|
||||
],
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/every",
|
||||
"!doc": "Tests whether all elements in the array pass the test implemented by the provided function."
|
||||
},
|
||||
"some": {
|
||||
"!type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> bool",
|
||||
"!effects": [
|
||||
"call !0 this=!1 !this.<i> number"
|
||||
],
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/some",
|
||||
"!doc": "Tests whether some element in the array passes the test implemented by the provided function."
|
||||
},
|
||||
"filter": {
|
||||
"!type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> !this",
|
||||
"!effects": [
|
||||
"call !0 this=!1 !this.<i> number"
|
||||
],
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/filter",
|
||||
"!doc": "Creates a new array with all elements that pass the test implemented by the provided function."
|
||||
},
|
||||
"forEach": {
|
||||
"!type": "fn(f: fn(elt: ?, i: number), context?: ?)",
|
||||
"!effects": [
|
||||
"call !0 this=!1 !this.<i> number"
|
||||
],
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/forEach",
|
||||
"!doc": "Executes a provided function once per array element."
|
||||
},
|
||||
"map": {
|
||||
"!type": "fn(f: fn(elt: ?, i: number) -> ?, context?: ?) -> [!0.!ret]",
|
||||
"!effects": [
|
||||
"call !0 this=!1 !this.<i> number"
|
||||
],
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/map",
|
||||
"!doc": "Creates a new array with the results of calling a provided function on every element in this array."
|
||||
},
|
||||
"reduce": {
|
||||
"!type": "fn(combine: fn(sum: ?, elt: ?, i: number) -> ?, init?: ?) -> !0.!ret",
|
||||
"!effects": [
|
||||
"call !0 !1 !this.<i> number"
|
||||
],
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/Reduce",
|
||||
"!doc": "Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value."
|
||||
},
|
||||
"reduceRight": {
|
||||
"!type": "fn(combine: fn(sum: ?, elt: ?, i: number) -> ?, init?: ?) -> !0.!ret",
|
||||
"!effects": [
|
||||
"call !0 !1 !this.<i> number"
|
||||
],
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/ReduceRight",
|
||||
"!doc": "Apply a function simultaneously against two values of the array (from right-to-left) as to reduce it to a single value."
|
||||
}
|
||||
},
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array",
|
||||
"!doc": "The JavaScript Array global object is a constructor for arrays, which are high-level, list-like objects."
|
||||
},
|
||||
"String": {
|
||||
"!type": "fn(value: ?) -> string",
|
||||
"fromCharCode": {
|
||||
"!type": "fn(code: number) -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/fromCharCode",
|
||||
"!doc": "Returns a string created by using the specified sequence of Unicode values."
|
||||
},
|
||||
"prototype": {
|
||||
"!stdProto": "String",
|
||||
"length": {
|
||||
"!type": "number",
|
||||
"!url": "https://developer.mozilla.org/en/docs/JavaScript/Reference/Global_Objects/String/length",
|
||||
"!doc": "Represents the length of a string."
|
||||
},
|
||||
"<i>": "string",
|
||||
"charAt": {
|
||||
"!type": "fn(i: number) -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/charAt",
|
||||
"!doc": "Returns the specified character from a string."
|
||||
},
|
||||
"charCodeAt": {
|
||||
"!type": "fn(i: number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/charCodeAt",
|
||||
"!doc": "Returns the numeric Unicode value of the character at the given index (except for unicode codepoints > 0x10000)."
|
||||
},
|
||||
"indexOf": {
|
||||
"!type": "fn(char: string, from?: number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/indexOf",
|
||||
"!doc": "Returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex,\nreturns -1 if the value is not found."
|
||||
},
|
||||
"lastIndexOf": {
|
||||
"!type": "fn(char: string, from?: number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/lastIndexOf",
|
||||
"!doc": "Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found. The calling string is searched backward, starting at fromIndex."
|
||||
},
|
||||
"substring": {
|
||||
"!type": "fn(from: number, to?: number) -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/substring",
|
||||
"!doc": "Returns a subset of a string between one index and another, or through the end of the string."
|
||||
},
|
||||
"substr": {
|
||||
"!type": "fn(from: number, length?: number) -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/substr",
|
||||
"!doc": "Returns the characters in a string beginning at the specified location through the specified number of characters."
|
||||
},
|
||||
"slice": {
|
||||
"!type": "fn(from: number, to?: number) -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/slice",
|
||||
"!doc": "Extracts a section of a string and returns a new string."
|
||||
},
|
||||
"trim": {
|
||||
"!type": "fn() -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/Trim",
|
||||
"!doc": "Removes whitespace from both ends of the string."
|
||||
},
|
||||
"trimLeft": {
|
||||
"!type": "fn() -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/TrimLeft",
|
||||
"!doc": "Removes whitespace from the left end of the string."
|
||||
},
|
||||
"trimRight": {
|
||||
"!type": "fn() -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/TrimRight",
|
||||
"!doc": "Removes whitespace from the right end of the string."
|
||||
},
|
||||
"toUpperCase": {
|
||||
"!type": "fn() -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toUpperCase",
|
||||
"!doc": "Returns the calling string value converted to uppercase."
|
||||
},
|
||||
"toLowerCase": {
|
||||
"!type": "fn() -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toLowerCase",
|
||||
"!doc": "Returns the calling string value converted to lowercase."
|
||||
},
|
||||
"toLocaleUpperCase": {
|
||||
"!type": "fn() -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase",
|
||||
"!doc": "Returns the calling string value converted to upper case, according to any locale-specific case mappings."
|
||||
},
|
||||
"toLocaleLowerCase": {
|
||||
"!type": "fn() -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase",
|
||||
"!doc": "Returns the calling string value converted to lower case, according to any locale-specific case mappings."
|
||||
},
|
||||
"split": {
|
||||
"!type": "fn(pattern: string) -> [string]",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/split",
|
||||
"!doc": "Splits a String object into an array of strings by separating the string into substrings."
|
||||
},
|
||||
"concat": {
|
||||
"!type": "fn(other: string) -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/concat",
|
||||
"!doc": "Combines the text of two or more strings and returns a new string."
|
||||
},
|
||||
"localeCompare": {
|
||||
"!type": "fn(other: string) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/localeCompare",
|
||||
"!doc": "Returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order."
|
||||
},
|
||||
"match": {
|
||||
"!type": "fn(pattern: +RegExp) -> [string]",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/match",
|
||||
"!doc": "Used to retrieve the matches when matching a string against a regular expression."
|
||||
},
|
||||
"replace": {
|
||||
"!type": "fn(pattern: +RegExp, replacement: string) -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/replace",
|
||||
"!doc": "Returns a new string with some or all matches of a pattern replaced by a replacement. The pattern can be a string or a RegExp, and the replacement can be a string or a function to be called for each match."
|
||||
},
|
||||
"search": {
|
||||
"!type": "fn(pattern: +RegExp) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/search",
|
||||
"!doc": "Executes the search for a match between a regular expression and this String object."
|
||||
}
|
||||
},
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String",
|
||||
"!doc": "The String global object is a constructor for strings, or a sequence of characters."
|
||||
},
|
||||
"Number": {
|
||||
"!type": "fn(value: ?) -> number",
|
||||
"MAX_VALUE": {
|
||||
"!type": "number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/MAX_VALUE",
|
||||
"!doc": "The maximum numeric value representable in JavaScript."
|
||||
},
|
||||
"MIN_VALUE": {
|
||||
"!type": "number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/MIN_VALUE",
|
||||
"!doc": "The smallest positive numeric value representable in JavaScript."
|
||||
},
|
||||
"POSITIVE_INFINITY": {
|
||||
"!type": "number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY",
|
||||
"!doc": "A value representing the positive Infinity value."
|
||||
},
|
||||
"NEGATIVE_INFINITY": {
|
||||
"!type": "number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY",
|
||||
"!doc": "A value representing the negative Infinity value."
|
||||
},
|
||||
"prototype": {
|
||||
"!stdProto": "Number",
|
||||
"toString": {
|
||||
"!type": "fn(radix?: number) -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toString",
|
||||
"!doc": "Returns a string representing the specified Number object"
|
||||
},
|
||||
"toFixed": {
|
||||
"!type": "fn(digits: number) -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toFixed",
|
||||
"!doc": "Formats a number using fixed-point notation"
|
||||
},
|
||||
"toExponential": {
|
||||
"!type": "fn(digits: number) -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toExponential",
|
||||
"!doc": "Returns a string representing the Number object in exponential notation"
|
||||
}
|
||||
},
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number",
|
||||
"!doc": "The Number JavaScript object is a wrapper object allowing you to work with numerical values. A Number object is created using the Number() constructor."
|
||||
},
|
||||
"Boolean": {
|
||||
"!type": "fn(value: ?) -> bool",
|
||||
"prototype": {
|
||||
"!stdProto": "Boolean"
|
||||
},
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean",
|
||||
"!doc": "The Boolean object is an object wrapper for a boolean value."
|
||||
},
|
||||
"RegExp": {
|
||||
"!type": "fn(source: string, flags?: string)",
|
||||
"prototype": {
|
||||
"!stdProto": "RegExp",
|
||||
"exec": {
|
||||
"!type": "fn(input: string) -> [string]",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/exec",
|
||||
"!doc": "Executes a search for a match in a specified string. Returns a result array, or null."
|
||||
},
|
||||
"compile": {
|
||||
"!type": "fn(source: string, flags?: string)",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp",
|
||||
"!doc": "Creates a regular expression object for matching text with a pattern."
|
||||
},
|
||||
"test": {
|
||||
"!type": "fn(input: string) -> bool",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/test",
|
||||
"!doc": "Executes the search for a match between a regular expression and a specified string. Returns true or false."
|
||||
},
|
||||
"global": {
|
||||
"!type": "bool",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp",
|
||||
"!doc": "Creates a regular expression object for matching text with a pattern."
|
||||
},
|
||||
"ignoreCase": {
|
||||
"!type": "bool",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp",
|
||||
"!doc": "Creates a regular expression object for matching text with a pattern."
|
||||
},
|
||||
"multiline": {
|
||||
"!type": "bool",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/multiline",
|
||||
"!doc": "Reflects whether or not to search in strings across multiple lines.\n"
|
||||
},
|
||||
"source": {
|
||||
"!type": "string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/source",
|
||||
"!doc": "A read-only property that contains the text of the pattern, excluding the forward slashes.\n"
|
||||
},
|
||||
"lastIndex": {
|
||||
"!type": "number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/lastIndex",
|
||||
"!doc": "A read/write integer property that specifies the index at which to start the next match."
|
||||
}
|
||||
},
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp",
|
||||
"!doc": "Creates a regular expression object for matching text with a pattern."
|
||||
},
|
||||
"Date": {
|
||||
"!type": "fn(ms: number)",
|
||||
"parse": {
|
||||
"!type": "fn(source: string) -> +Date",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/parse",
|
||||
"!doc": "Parses a string representation of a date, and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC."
|
||||
},
|
||||
"UTC": {
|
||||
"!type": "fn(year: number, month: number, date: number, hour?: number, min?: number, sec?: number, ms?: number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/UTC",
|
||||
"!doc": "Accepts the same parameters as the longest form of the constructor, and returns the number of milliseconds in a Date object since January 1, 1970, 00:00:00, universal time."
|
||||
},
|
||||
"now": {
|
||||
"!type": "fn() -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/now",
|
||||
"!doc": "Returns the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC."
|
||||
},
|
||||
"prototype": {
|
||||
"toUTCString": {
|
||||
"!type": "fn() -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toUTCString",
|
||||
"!doc": "Converts a date to a string, using the universal time convention."
|
||||
},
|
||||
"toISOString": {
|
||||
"!type": "fn() -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toISOString",
|
||||
"!doc": "JavaScript provides a direct way to convert a date object into a string in ISO format, the ISO 8601 Extended Format."
|
||||
},
|
||||
"toDateString": {
|
||||
"!type": "fn() -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toDateString",
|
||||
"!doc": "Returns the date portion of a Date object in human readable form in American English."
|
||||
},
|
||||
"toTimeString": {
|
||||
"!type": "fn() -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toTimeString",
|
||||
"!doc": "Returns the time portion of a Date object in human readable form in American English."
|
||||
},
|
||||
"toLocaleDateString": {
|
||||
"!type": "fn() -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toLocaleDateString",
|
||||
"!doc": "Converts a date to a string, returning the \"date\" portion using the operating system's locale's conventions.\n"
|
||||
},
|
||||
"toLocaleTimeString": {
|
||||
"!type": "fn() -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString",
|
||||
"!doc": "Converts a date to a string, returning the \"time\" portion using the current locale's conventions."
|
||||
},
|
||||
"getTime": {
|
||||
"!type": "fn() -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getTime",
|
||||
"!doc": "Returns the numeric value corresponding to the time for the specified date according to universal time."
|
||||
},
|
||||
"getFullYear": {
|
||||
"!type": "fn() -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getFullYear",
|
||||
"!doc": "Returns the year of the specified date according to local time."
|
||||
},
|
||||
"getYear": {
|
||||
"!type": "fn() -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getYear",
|
||||
"!doc": "Returns the year in the specified date according to local time."
|
||||
},
|
||||
"getMonth": {
|
||||
"!type": "fn() -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getMonth",
|
||||
"!doc": "Returns the month in the specified date according to local time."
|
||||
},
|
||||
"getUTCMonth": {
|
||||
"!type": "fn() -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCMonth",
|
||||
"!doc": "Returns the month of the specified date according to universal time.\n"
|
||||
},
|
||||
"getDate": {
|
||||
"!type": "fn() -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getDate",
|
||||
"!doc": "Returns the day of the month for the specified date according to local time."
|
||||
},
|
||||
"getUTCDate": {
|
||||
"!type": "fn() -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCDate",
|
||||
"!doc": "Returns the day (date) of the month in the specified date according to universal time.\n"
|
||||
},
|
||||
"getDay": {
|
||||
"!type": "fn() -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getDay",
|
||||
"!doc": "Returns the day of the week for the specified date according to local time."
|
||||
},
|
||||
"getUTCDay": {
|
||||
"!type": "fn() -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCDay",
|
||||
"!doc": "Returns the day of the week in the specified date according to universal time.\n"
|
||||
},
|
||||
"getHours": {
|
||||
"!type": "fn() -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getHours",
|
||||
"!doc": "Returns the hour for the specified date according to local time."
|
||||
},
|
||||
"getUTCHours": {
|
||||
"!type": "fn() -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCHours",
|
||||
"!doc": "Returns the hours in the specified date according to universal time.\n"
|
||||
},
|
||||
"getMinutes": {
|
||||
"!type": "fn() -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getMinutes",
|
||||
"!doc": "Returns the minutes in the specified date according to local time."
|
||||
},
|
||||
"getUTCMinutes": {
|
||||
"!type": "fn() -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date",
|
||||
"!doc": "Creates JavaScript Date instances which let you work with dates and times."
|
||||
},
|
||||
"getSeconds": {
|
||||
"!type": "fn() -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getSeconds",
|
||||
"!doc": "Returns the seconds in the specified date according to local time."
|
||||
},
|
||||
"getUTCSeconds": {
|
||||
"!type": "fn() -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCSeconds",
|
||||
"!doc": "Returns the seconds in the specified date according to universal time.\n"
|
||||
},
|
||||
"getMilliseconds": {
|
||||
"!type": "fn() -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getMilliseconds",
|
||||
"!doc": "Returns the milliseconds in the specified date according to local time."
|
||||
},
|
||||
"getUTCMilliseconds": {
|
||||
"!type": "fn() -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds",
|
||||
"!doc": "Returns the milliseconds in the specified date according to universal time.\n"
|
||||
},
|
||||
"getTimezoneOffset": {
|
||||
"!type": "fn() -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset",
|
||||
"!doc": "Returns the time-zone offset from UTC, in minutes, for the current locale."
|
||||
},
|
||||
"setTime": {
|
||||
"!type": "fn(date: +Date) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setTime",
|
||||
"!doc": "Sets the Date object to the time represented by a number of milliseconds since January 1, 1970, 00:00:00 UTC.\n"
|
||||
},
|
||||
"setFullYear": {
|
||||
"!type": "fn(year: number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setFullYear",
|
||||
"!doc": "Sets the full year for a specified date according to local time.\n"
|
||||
},
|
||||
"setUTCFullYear": {
|
||||
"!type": "fn(year: number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCFullYear",
|
||||
"!doc": "Sets the full year for a specified date according to universal time.\n"
|
||||
},
|
||||
"setMonth": {
|
||||
"!type": "fn(month: number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setMonth",
|
||||
"!doc": "Set the month for a specified date according to local time."
|
||||
},
|
||||
"setUTCMonth": {
|
||||
"!type": "fn(month: number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCMonth",
|
||||
"!doc": "Sets the month for a specified date according to universal time.\n"
|
||||
},
|
||||
"setDate": {
|
||||
"!type": "fn(day: number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setDate",
|
||||
"!doc": "Sets the day of the month for a specified date according to local time."
|
||||
},
|
||||
"setUTCDate": {
|
||||
"!type": "fn(day: number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCDate",
|
||||
"!doc": "Sets the day of the month for a specified date according to universal time.\n"
|
||||
},
|
||||
"setHours": {
|
||||
"!type": "fn(hour: number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setHours",
|
||||
"!doc": "Sets the hours for a specified date according to local time, and returns the number of milliseconds since 1 January 1970 00:00:00 UTC until the time represented by the updated Date instance."
|
||||
},
|
||||
"setUTCHours": {
|
||||
"!type": "fn(hour: number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCHours",
|
||||
"!doc": "Sets the hour for a specified date according to universal time.\n"
|
||||
},
|
||||
"setMinutes": {
|
||||
"!type": "fn(min: number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setMinutes",
|
||||
"!doc": "Sets the minutes for a specified date according to local time."
|
||||
},
|
||||
"setUTCMinutes": {
|
||||
"!type": "fn(min: number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCMinutes",
|
||||
"!doc": "Sets the minutes for a specified date according to universal time.\n"
|
||||
},
|
||||
"setSeconds": {
|
||||
"!type": "fn(sec: number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setSeconds",
|
||||
"!doc": "Sets the seconds for a specified date according to local time."
|
||||
},
|
||||
"setUTCSeconds": {
|
||||
"!type": "fn(sec: number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCSeconds",
|
||||
"!doc": "Sets the seconds for a specified date according to universal time.\n"
|
||||
},
|
||||
"setMilliseconds": {
|
||||
"!type": "fn(ms: number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setMilliseconds",
|
||||
"!doc": "Sets the milliseconds for a specified date according to local time.\n"
|
||||
},
|
||||
"setUTCMilliseconds": {
|
||||
"!type": "fn(ms: number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds",
|
||||
"!doc": "Sets the milliseconds for a specified date according to universal time.\n"
|
||||
}
|
||||
},
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date",
|
||||
"!doc": "Creates JavaScript Date instances which let you work with dates and times."
|
||||
},
|
||||
"Error": {
|
||||
"!type": "fn(message: string)",
|
||||
"prototype": {
|
||||
"name": {
|
||||
"!type": "string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error/name",
|
||||
"!doc": "A name for the type of error."
|
||||
},
|
||||
"message": {
|
||||
"!type": "string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error/message",
|
||||
"!doc": "A human-readable description of the error."
|
||||
}
|
||||
},
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error",
|
||||
"!doc": "Creates an error object."
|
||||
},
|
||||
"SyntaxError": {
|
||||
"!type": "fn(message: string)",
|
||||
"prototype": "Error.prototype",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/SyntaxError",
|
||||
"!doc": "Represents an error when trying to interpret syntactically invalid code."
|
||||
},
|
||||
"ReferenceError": {
|
||||
"!type": "fn(message: string)",
|
||||
"prototype": "Error.prototype",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/ReferenceError",
|
||||
"!doc": "Represents an error when a non-existent variable is referenced."
|
||||
},
|
||||
"URIError": {
|
||||
"!type": "fn(message: string)",
|
||||
"prototype": "Error.prototype",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/URIError",
|
||||
"!doc": "Represents an error when a malformed URI is encountered."
|
||||
},
|
||||
"EvalError": {
|
||||
"!type": "fn(message: string)",
|
||||
"prototype": "Error.prototype",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/EvalError",
|
||||
"!doc": "Represents an error regarding the eval function."
|
||||
},
|
||||
"RangeError": {
|
||||
"!type": "fn(message: string)",
|
||||
"prototype": "Error.prototype",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RangeError",
|
||||
"!doc": "Represents an error when a number is not within the correct range allowed."
|
||||
},
|
||||
"parseInt": {
|
||||
"!type": "fn(string: string, radix?: number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/parseInt",
|
||||
"!doc": "Parses a string argument and returns an integer of the specified radix or base."
|
||||
},
|
||||
"parseFloat": {
|
||||
"!type": "fn(string: string) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/parseFloat",
|
||||
"!doc": "Parses a string argument and returns a floating point number."
|
||||
},
|
||||
"isNaN": {
|
||||
"!type": "fn(value: number) -> bool",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/isNaN",
|
||||
"!doc": "Determines whether a value is NaN or not. Be careful, this function is broken. You may be interested in ECMAScript 6 Number.isNaN."
|
||||
},
|
||||
"eval": {
|
||||
"!type": "fn(code: string) -> ?",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/eval",
|
||||
"!doc": "Evaluates JavaScript code represented as a string."
|
||||
},
|
||||
"encodeURI": {
|
||||
"!type": "fn(uri: string) -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURI",
|
||||
"!doc": "Encodes a Uniform Resource Identifier (URI) by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two \"surrogate\" characters)."
|
||||
},
|
||||
"encodeURIComponent": {
|
||||
"!type": "fn(uri: string) -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURIComponent",
|
||||
"!doc": "Encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two \"surrogate\" characters)."
|
||||
},
|
||||
"decodeURI": {
|
||||
"!type": "fn(uri: string) -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/decodeURI",
|
||||
"!doc": "Decodes a Uniform Resource Identifier (URI) previously created by encodeURI or by a similar routine."
|
||||
},
|
||||
"decodeURIComponent": {
|
||||
"!type": "fn(uri: string) -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/decodeURIComponent",
|
||||
"!doc": "Decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent or by a similar routine."
|
||||
},
|
||||
"Math": {
|
||||
"E": {
|
||||
"!type": "number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/E",
|
||||
"!doc": "The base of natural logarithms, e, approximately 2.718."
|
||||
},
|
||||
"LN2": {
|
||||
"!type": "number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LN2",
|
||||
"!doc": "The natural logarithm of 2, approximately 0.693."
|
||||
},
|
||||
"LN10": {
|
||||
"!type": "number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LN10",
|
||||
"!doc": "The natural logarithm of 10, approximately 2.302."
|
||||
},
|
||||
"LOG2E": {
|
||||
"!type": "number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LOG2E",
|
||||
"!doc": "The base 2 logarithm of E (approximately 1.442)."
|
||||
},
|
||||
"LOG10E": {
|
||||
"!type": "number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LOG10E",
|
||||
"!doc": "The base 10 logarithm of E (approximately 0.434)."
|
||||
},
|
||||
"SQRT1_2": {
|
||||
"!type": "number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/SQRT1_2",
|
||||
"!doc": "The square root of 1/2; equivalently, 1 over the square root of 2, approximately 0.707."
|
||||
},
|
||||
"SQRT2": {
|
||||
"!type": "number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/SQRT2",
|
||||
"!doc": "The square root of 2, approximately 1.414."
|
||||
},
|
||||
"PI": {
|
||||
"!type": "number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/PI",
|
||||
"!doc": "The ratio of the circumference of a circle to its diameter, approximately 3.14159."
|
||||
},
|
||||
"abs": {
|
||||
"!type": "fn(number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/abs",
|
||||
"!doc": "Returns the absolute value of a number."
|
||||
},
|
||||
"cos": {
|
||||
"!type": "fn(number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/cos",
|
||||
"!doc": "Returns the cosine of a number."
|
||||
},
|
||||
"sin": {
|
||||
"!type": "fn(number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/sin",
|
||||
"!doc": "Returns the sine of a number."
|
||||
},
|
||||
"tan": {
|
||||
"!type": "fn(number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/tan",
|
||||
"!doc": "Returns the tangent of a number."
|
||||
},
|
||||
"acos": {
|
||||
"!type": "fn(number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/acos",
|
||||
"!doc": "Returns the arccosine (in radians) of a number."
|
||||
},
|
||||
"asin": {
|
||||
"!type": "fn(number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/asin",
|
||||
"!doc": "Returns the arcsine (in radians) of a number."
|
||||
},
|
||||
"atan": {
|
||||
"!type": "fn(number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/atan",
|
||||
"!doc": "Returns the arctangent (in radians) of a number."
|
||||
},
|
||||
"atan2": {
|
||||
"!type": "fn(number, number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/atan2",
|
||||
"!doc": "Returns the arctangent of the quotient of its arguments."
|
||||
},
|
||||
"ceil": {
|
||||
"!type": "fn(number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/ceil",
|
||||
"!doc": "Returns the smallest integer greater than or equal to a number."
|
||||
},
|
||||
"floor": {
|
||||
"!type": "fn(number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/floor",
|
||||
"!doc": "Returns the largest integer less than or equal to a number."
|
||||
},
|
||||
"round": {
|
||||
"!type": "fn(number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/round",
|
||||
"!doc": "Returns the value of a number rounded to the nearest integer."
|
||||
},
|
||||
"exp": {
|
||||
"!type": "fn(number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/exp",
|
||||
"!doc": "Returns Ex, where x is the argument, and E is Euler's constant, the base of the natural logarithms."
|
||||
},
|
||||
"log": {
|
||||
"!type": "fn(number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/log",
|
||||
"!doc": "Returns the natural logarithm (base E) of a number."
|
||||
},
|
||||
"sqrt": {
|
||||
"!type": "fn(number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/sqrt",
|
||||
"!doc": "Returns the square root of a number."
|
||||
},
|
||||
"pow": {
|
||||
"!type": "fn(number, number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/pow",
|
||||
"!doc": "Returns base to the exponent power, that is, baseexponent."
|
||||
},
|
||||
"max": {
|
||||
"!type": "fn(number, number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/max",
|
||||
"!doc": "Returns the largest of zero or more numbers."
|
||||
},
|
||||
"min": {
|
||||
"!type": "fn(number, number) -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/min",
|
||||
"!doc": "Returns the smallest of zero or more numbers."
|
||||
},
|
||||
"random": {
|
||||
"!type": "fn() -> number",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/random",
|
||||
"!doc": "Returns a floating-point, pseudo-random number in the range [0, 1) that is, from 0 (inclusive) up to but not including 1 (exclusive), which you can then scale to your desired range."
|
||||
},
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math",
|
||||
"!doc": "A built-in object that has properties and methods for mathematical constants and functions."
|
||||
},
|
||||
"JSON": {
|
||||
"parse": {
|
||||
"!type": "fn(json: string) -> ?",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/JSON/parse",
|
||||
"!doc": "Parse a string as JSON, optionally transforming the value produced by parsing."
|
||||
},
|
||||
"stringify": {
|
||||
"!type": "fn(value: ?) -> string",
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/JSON/stringify",
|
||||
"!doc": "Convert a value to JSON, optionally replacing values if a replacer function is specified, or optionally including only the specified properties if a replacer array is specified."
|
||||
},
|
||||
"!url": "https://developer.mozilla.org/en-US/docs/JSON",
|
||||
"!doc": "JSON (JavaScript Object Notation) is a data-interchange format. It closely resembles a subset of JavaScript syntax, although it is not a strict subset. (See JSON in the JavaScript Reference for full details.) It is useful when writing any kind of JavaScript-based application, including websites and browser extensions. For example, you might store user information in JSON format in a cookie, or you might store extension preferences in JSON in a string-valued browser preference."
|
||||
}
|
||||
}
|
||||
2119
devtools/client/sourceeditor/tern/infer.js
Normal file
2119
devtools/client/sourceeditor/tern/infer.js
Normal file
File diff suppressed because it is too large
Load diff
18
devtools/client/sourceeditor/tern/moz.build
Normal file
18
devtools/client/sourceeditor/tern/moz.build
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini']
|
||||
|
||||
DevToolsModules(
|
||||
'browser.js',
|
||||
'comment.js',
|
||||
'condense.js',
|
||||
'def.js',
|
||||
'ecma5.js',
|
||||
'infer.js',
|
||||
'signal.js',
|
||||
'tern.js',
|
||||
)
|
||||
51
devtools/client/sourceeditor/tern/signal.js
Normal file
51
devtools/client/sourceeditor/tern/signal.js
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
(function(root, mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
return mod(exports);
|
||||
if (typeof define == "function" && define.amd) // AMD
|
||||
return define(["exports"], mod);
|
||||
mod((root.tern || (root.tern = {})).signal = {}); // Plain browser env
|
||||
})(this, function(exports) {
|
||||
|
||||
function on(type, f) {
|
||||
var handlers = this._handlers || (this._handlers = Object.create(null));
|
||||
(handlers[type] || (handlers[type] = [])).push(f);
|
||||
}
|
||||
|
||||
function off(type, f) {
|
||||
var arr = this._handlers && this._handlers[type];
|
||||
if (arr) for (var i = 0; i < arr.length; ++i)
|
||||
if (arr[i] == f) { arr.splice(i, 1); break; }
|
||||
}
|
||||
|
||||
var noHandlers = []
|
||||
function getHandlers(emitter, type) {
|
||||
var arr = emitter._handlers && emitter._handlers[type];
|
||||
return arr && arr.length ? arr.slice() : noHandlers
|
||||
}
|
||||
|
||||
function signal(type, a1, a2, a3, a4) {
|
||||
var arr = getHandlers(this, type)
|
||||
for (var i = 0; i < arr.length; ++i) arr[i].call(this, a1, a2, a3, a4)
|
||||
}
|
||||
|
||||
function signalReturnFirst(type, a1, a2, a3, a4) {
|
||||
var arr = getHandlers(this, type)
|
||||
for (var i = 0; i < arr.length; ++i) {
|
||||
var result = arr[i].call(this, a1, a2, a3, a4)
|
||||
if (result) return result
|
||||
}
|
||||
}
|
||||
|
||||
function hasHandler(type) {
|
||||
var arr = this._handlers && this._handlers[type]
|
||||
return arr && arr.length > 0 && arr
|
||||
}
|
||||
|
||||
exports.mixin = function(obj) {
|
||||
obj.on = on; obj.off = off;
|
||||
obj.signal = signal;
|
||||
obj.signalReturnFirst = signalReturnFirst;
|
||||
obj.hasHandler = hasHandler;
|
||||
return obj;
|
||||
};
|
||||
});
|
||||
1056
devtools/client/sourceeditor/tern/tern.js
Normal file
1056
devtools/client/sourceeditor/tern/tern.js
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,3 @@
|
|||
"use strict";
|
||||
var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
|
||||
const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Test that tern autocompletions work.
|
||||
*/
|
||||
|
||||
const tern = require("devtools/client/sourceeditor/tern/tern");
|
||||
const ecma5 = require("devtools/client/sourceeditor/tern/ecma5");
|
||||
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
|
||||
const server = new tern.Server({ defs: [ecma5] });
|
||||
const code = "[].";
|
||||
const query = { type: "completions", file: "test", end: code.length };
|
||||
const files = [{ type: "full", name: "test", text: code }];
|
||||
|
||||
server.request({ query: query, files: files }, (error, response) => {
|
||||
do_check_eq(error, null);
|
||||
do_check_true(!!response);
|
||||
do_check_true(Array.isArray(response.completions));
|
||||
do_check_true(response.completions.indexOf("concat") != -1);
|
||||
do_test_finished();
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Test that we can require tern.
|
||||
*/
|
||||
|
||||
function run_test() {
|
||||
const tern = require("devtools/client/sourceeditor/tern/tern");
|
||||
const ecma5 = require("devtools/client/sourceeditor/tern/ecma5");
|
||||
const browser = require("devtools/client/sourceeditor/tern/browser");
|
||||
do_check_true(!!tern);
|
||||
do_check_true(!!ecma5);
|
||||
do_check_true(!!browser);
|
||||
do_check_eq(typeof tern.Server, "function");
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
[DEFAULT]
|
||||
tags = devtools
|
||||
head = head_tern.js
|
||||
tail =
|
||||
firefox-appdir = browser
|
||||
|
||||
[test_autocompletion.js]
|
||||
[test_import_tern.js]
|
||||
Loading…
Add table
Add a link
Reference in a new issue