QL code and tests for C#/C++/JavaScript.

This commit is contained in:
Pavel Avgustinov
2018-08-02 17:53:23 +01:00
commit b55526aa58
10684 changed files with 581163 additions and 0 deletions

View File

@@ -0,0 +1,796 @@
/**
* @externs
* Sources:
* * https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Introduction_to_the_JavaScript_shell
* * https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Shell_global_objects
* * http://mxr.mozilla.org/mozilla-central/source/js/src/shell/js.cpp
*/
/**
* @type {Object}
*/
var environment;
/**
* @type {Array.<string>}
*/
var arguments;
/**
* @type {Array.<string>}
*/
var scriptArgs;
/**
* @constructor
* @param {string=} name
* @see https://developer.mozilla.org/en-US/docs/Archive/Mozilla/SpiderMonkey/File_object
*/
function File(name) {}
/**
* @type {File}
*/
File.input;
/**
* @type {File}
*/
File.output;
/**
* @type {File}
*/
File.error;
/**
* @type {File}
*/
File.currentDir;
/**
* @type {string}
*/
File.separator;
/**
* @type {number}
*/
File.prototype.number;
/**
* @type {File}
*/
File.prototype.parent;
/**
* @type {string}
*/
File.prototype.path;
/**
* @type {string}
*/
File.prototype.name;
/**
* @type {boolean}
*/
File.prototype.isDirectory;
/**
* @type {boolean}
*/
File.prototype.isFile;
/**
* @type {boolean}
*/
File.prototype.exists;
/**
* @type {boolean}
*/
File.prototype.canRead;
/**
* @type {boolean}
*/
File.prototype.canWrite;
/**
* @type {boolean}
*/
File.prototype.canAppend;
/**
* @type {boolean}
*/
File.prototype.canReplace;
/**
* @type {boolean}
*/
File.prototype.isOpen;
/**
* @type {string}
*/
File.prototype.type;
/**
* @type {string}
*/
File.prototype.mode;
/**
* @type {Date}
*/
File.prototype.creationTime;
/**
* @type {Date}
*/
File.prototype.lastModified;
/**
* @type {number}
*/
File.prototype.size;
/**
* @type {boolean}
*/
File.prototype.hasRandomAccess;
/**
* @type {boolean}
*/
File.prototype.hasAutoFlush;
/**
* @type {number}
*/
File.prototype.position;
/**
* @type {boolean}
*/
File.prototype.isNative;
/**
* @param {string} mode
* @param {string} type
*/
File.prototype.open = function(mode, type) {};
/**
*/
File.prototype.close = function() {};
/**
*/
File.prototype.remove = function() {};
/**
* @param {string} destination
*/
File.prototype.copyTo = function(destination) {};
/**
* @param {string} newName
*/
File.prototype.renameTo = function(newName) {};
/**
*/
File.prototype.flush = function() {};
/**
* @param {number} offset
* @param {number} whence
* @return {number}
*/
File.prototype.seek = function(offset, whence) {};
/**
* @param {number} numBytes
* @return {string}
*/
File.prototype.read = function(numBytes) {};
/**
* @return {string}
*/
File.prototype.readln = function() {};
/**
* @return {Array.<string>}
*/
File.prototype.readAll = function() {};
/**
* @param {string} data
*/
File.prototype.write = function(data) {};
/**
* @param {string} data
*/
File.prototype.writeln = function(data) {};
/**
* @param {Array.<string>} lines
*/
File.prototype.writeAll = function(lines) {};
/**
* @param {RegExp=} filter
* @return {Array.<File>}
*/
File.prototype.list = function(filter) {};
/**
* @param {string} name
*/
File.prototype.mkdir = function(name) {};
/**
* @return {string}
*/
File.prototype.toURL = function() {};
/**
* @see https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Parser_API
*/
function Reflect() {}
/**
* @param {string} code
* @param {Object=} options
* @return {Object}
*/
Reflect.parse = function(code, options) {};
/**
* @param {number=} number
* @return {number}
*/
function version(number) {}
/**
*/
function revertVersion() {}
/**
* @param {...string} options
*/
function options(options) {}
/**
* @param {...string} files
*/
function load(files) {}
/**
* @param {...string} files
*/
function loadRelativeToScript(files) {}
/**
* @param {string} code
* @param {Object=} options
*/
function evaluate(code, options) {}
/**
* @param {string} file
* @return {number}
*/
function run(file) {}
/**
* @return {string}
*/
function readline() {}
/**
* @param {...*} exprs
*/
function print(exprs) {}
/**
* @param {...*} exprs
*/
function printErr(exprs) {}
/**
* @param {*} expr
*/
function putstr(expr) {}
/**
* @return {number}
*/
function dateNow() {}
/**
* @param {...string} names
* @return {string}
*/
function help(names) {}
/**
* @param {number=} status
*/
function quit(status) {}
/**
* @param {*} actual
* @param {*} expected
* @param {string=} msg
* @throws {Error}
*/
function assertEq(actual, expected, msg) {}
/**
* @throws {Error}
*/
function assertJit() {}
/**
*/
function gc() {}
/**
*/
function gcstats() {}
/**
* @param {string} name
* @param {number} value
*/
function gcparam(name, value) {}
/**
* @param {Object=} start
* @param {string} kind
*/
function countHeap(start, kind) {}
/**
* @return {Object}
*/
function makeFinalizeObserver() {}
/**
* @return {number}
*/
function finalizeCount() {}
/**
* @param {number} level
*/
function gczeal(level) {}
/**
* @param {boolean} debug
*/
function setDebug(debug) {}
/**
* @param {function} f
*/
function setDebuggerHandler(f) {}
/**
* @param {function} f
*/
function setThrowHook(f) {}
/**
* @param {function=} fun
* @param {number=} pc
* @param {*} exp
*/
function trap(fun, pc, exp) {}
/**
* @param {function} fun
* @param {number=} pc
*/
function untrap(fun, pc) {}
/**
* @param {function=} fun
* @param {number} line
*/
function line2pc(fun, line) {}
/**
* @param {function} fun
* @param {number=} pc
*/
function pc2line(fun, pc) {}
/**
* @param {number=} number
*/
function stackQuota(number) {}
/**
* @return {boolean}
*/
function stringsAreUTF8() {}
/**
* @param {number} mode
*/
function testUTF8(mode) {}
/**
* @param {string=} fileName
* @param {*=} start
* @param {*=} toFind
* @param {number=} maxDepth
* @param {*=} toIgnore
*/
function dumpHeap(fileName, start, toFind, maxDepth, toIgnore) {}
/**
*/
function dumpObject() {}
/**
* @param {string|boolean} mode
*/
function tracing(mode) {}
/**
* @param {...string} strings
*/
function stats(strings) {}
/**
*/
function build() {}
/**
* @param {Object=} obj
*/
function clear(obj) {}
/**
* @param {function} fun
* @param {Object=} scope
*/
function clone(fun, scope) {}
/**
* @param {Object} obj
*/
function getpda(obj) {}
/**
* @param {*} n
* @return {number}
*/
function toint32(n) {}
/**
* @param {number} n
* @param {string} str
* @param {boolean} save
*/
function evalInFrame(n, str, save) {}
/**
* @param {string} filename
* @param {string=} options
*/
function snarf(filename, options) {}
/**
* @param {string} filename
* @param {string=} options
*/
function read(filename, options) {}
/**
* @param {number=} seconds
*/
function timeout(seconds) {}
/**
* @param {Object} obj
*/
function parent(obj) {}
/**
* @param {Object} obj
*/
function wrap(obj) {}
/**
* @param {*} sd
*/
function serialize(sd) {}
/**
* @param {*} a
*/
function deserialize(a) {}
/**
*/
function mjitstats() {}
/**
*/
function stringstats() {}
/**
* @param {Object} callback
*/
function setGCCallback(callback) {}
/**
*/
function startTimingMutator() {}
/**
*/
function stopTimingMutator() {}
/**
* @throws {Error}
*/
function throwError() {}
/**
* @param {function} fun
*/
function disassemble(fun) {}
/**
* @param {function} fun
*/
function dis(fun) {}
/**
* @param {string} file
*/
function disfile(file) {}
/**
* @param {function} fun
*/
function dissrc(fun) {}
/**
* @param {function} fun
*/
function notes(fun) {}
/**
* @param {boolean} showArgs
* @param {boolean} showLocals
* @param {boolean} showThisProps
*/
function stackDump(showArgs, showLocals, showThisProps) {}
/**
* @param {string} str
* @return string
*/
function intern(str) {}
/**
* @param {Object} obj
*/
function getslx(obj) {}
/**
* @param {string} s
* @param {Object=} o
*/
function evalcx(s, o) {}
/**
* @param {string} str
*/
function evalInWorker(str) {}
/**
* @return {Object}
*/
function getSharedArrayBuffer() {}
/**
* @param {Object} buf
*/
function setSharedArrayBuffer(buf) {}
/**
* @param {Object} obj
* @return {*}
*/
function shapeOf(obj) {}
/**
* @param {...Array.<*>} arrays
*/
function arrayInfo(arrays) {}
/**
* @param {number} dt
*/
function sleep(dt) {}
/**
* @param {string} code
* @throws {Error}
*/
function compile(code) {}
/**
* @param {string} code
* @throws {Error}
*/
function parse(code) {}
/**
* @param {string} code
* @return {boolean}
*/
function syntaxParse(code) {}
/**
* @param {string} code
* @param {Object=} options
*/
function offThreadCompileScript(code, options) {}
/**
* @throws {Error}
*/
function runOffThreadScript() {}
/**
* @param {number=} seconds
* @param {function=} func
*/
function timeout(seconds, func) {}
/**
* @param {boolean} cond
*/
function interruptIf(cond) {}
/**
* @param {function} fun
*/
function invokeInterruptCallback(fun) {}
/**
* @param {function} fun
*/
function setInterruptCallback(fun) {}
/**
*/
function enableLastWarning() {}
/**
*/
function disableLastWarning() {}
/**
* @return {Object}
*/
function getLastWarning() {}
/**
*/
function clearLastWarning() {}
/**
* @return {number}
*/
function elapsed() {}
/**
* @param {function} func
* @return {string}
*/
function decompileFunction(func) {}
/**
* @param {function} func
* @return {string}
*/
function decompileBody(func) {}
/**
* @return {string}
*/
function decompileThis() {}
/**
* @return {string}
*/
function thisFilename() {}
/**
* @param {Object=} options
* @return {Object}
*/
function newGlobal(options) {}
/**
* @param {string} filename
* @param {number} offset
* @param {number} size
*/
function createMappedArrayBuffer(filename, offset, size) {}
/**
* @return {number}
*/
function getMaxArgs() {}
/**
* @return {Object}
*/
function objectEmulatingUndefined() {}
/**
* @return {boolean}
*/
function isCachingEnabled() {}
/**
* @param {boolean} b
*/
function setCachingEnabled(b) {}
/**
* @param {string} code
*/
function cacheEntry(code) {}
/**
*/
function printProfilerEvents() {}
/**
*/
function enableSingleStepProfiling() {}
/**
*/
function disableSingleStepProfiling() {}
/**
* @param {string} s
* @return {boolean}
*/
function isLatin1(s) {}
/**
* @return {number}
*/
function stackPointerInfo() {}
/**
* @param {Object} params
* @return {Array.<*>}
*/
function entryPoints(params) {}
/**
* @param {Object} object
* @param {boolean} deep
*/
function seal(object, deep) {}

View File

@@ -0,0 +1,100 @@
/**
* @externs
* Source: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Shell
*/
/**
* @type {Array.<string>}
*/
var arguments;
/**
* @type {Object}
*/
var environment;
/**
* @type {string}
*/
var history;
/**
*/
function help() {}
/**
* @param {string} className
*/
function defineClass(className) {}
/**
* @param {string} filename
*/
function deserialize(filename) {}
/**
*/
function gc() {}
/**
* @param {...string} files
*/
function load(files) {}
/**
* @param {string} className
*/
function loadClass(className) {}
/**
* @param {...*} exprs
*/
function print(exprs) {}
/**
* @param {string} path
* @param {string=} characterCoding
*/
function readFile(path, characterCoding) {}
/**
* @param {string} url
* @param {string=} characterCoding
*/
function readUrl(url, characterCoding) {}
/**
* @param {string} commandName
* @param {...*} args
*/
function runCommand(commandName, args) {}
/**
* @param {Object} object
*/
function seal(object) {}
/**
* @param {Object} object
* @param {string} filename
*/
function serialize(object, filename) {}
/**
* @param {string|function} functionOrScript
*/
function spawn(functionOrScript) {}
/**
* @param {function} fun
*/
function sync(fun) {}
/**
*/
function quit() {}
/**
* @param {number=} num
*/
function version(num) {}

View File

@@ -0,0 +1,24 @@
/**
* Externs for Spidermonkey-specific API.
*
* @externs
*/
/**
* @param {Object} object
* @param {*=} keyOnly
* @return {Object}
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator
*/
function Iterator(object, keyOnly) {}
/**
* @return {*}
*/
Iterator.prototype.next = function() {};
/**
* @type {Object}
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/StopIteration
*/
var StopIteration;

125
javascript/externs/vm/v8.js Normal file
View File

@@ -0,0 +1,125 @@
/*
* Copyright 2013 The Closure Compiler Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview This file describes the externs API for V8-specific objects.
* @externs
*/
/**
* Stack frame elements in V8.
* @constructor
*/
function CallSite() {}
/**
* Returns the value of this.
* @return {Object|undefined}
*/
CallSite.prototype.getThis = function() {};
/**
* Returns the type of this as a string. This is the name of the function stored
* in the constructor field of this, if available, otherwise the object's
* [[Class]] internal property.
* @return {string|undefined}
*/
CallSite.prototype.getTypeName = function() {};
/**
* Returns the current function.
* @return {!Function|undefined}
*/
CallSite.prototype.getFunction = function() {};
/**
* Returns the name of the current function, typically its name property. If a
* name property is not available an attempt will be made to try to infer a name
* from the function's context.
* @return {string|undefined}
*/
CallSite.prototype.getFunctionName = function() {};
/**
* Returns the name of the property of this or one of its prototypes that holds
* the current function.
* @return {string|undefined}
*/
CallSite.prototype.getMethodName = function() {};
/**
* If this function was defined in a script returns the name of the script
* @return {string|undefined}
*/
CallSite.prototype.getFileName = function() {};
/**
* If this function was defined in a script returns the current line number.
* @return {number|undefined}
*/
CallSite.prototype.getLineNumber = function() {};
/**
* If this function was defined in a script returns the current column number.
* @return {number|undefined}
*/
CallSite.prototype.getColumnNumber = function() {};
/**
* If this function was created using a call to eval, returns a CallSite object
* representing the location where eval was called
* @return {CallSite|undefined}
*/
CallSite.prototype.getEvalOrigin = function() {};
/**
* Is this a toplevel invocation, that is, is this the global object?
* @return {boolean}
*/
CallSite.prototype.isToplevel = function() {};
/**
* Does this call take place in code defined by a call to eval?
* @return {boolean}
*/
CallSite.prototype.isEval = function() {};
/**
* Is this call in native V8 code?
* @return {boolean}
*/
CallSite.prototype.isNative = function() {};
/**
* Is this a constructor call?
* @return {boolean}
*/
CallSite.prototype.isConstructor = function() {};