Merge pull request #166 from github/update-v1-5bd2832b
Merge main into v1
This commit is contained in:
commit
b8f7e0ff0f
3426 changed files with 6458 additions and 444878 deletions
18
.github/workflows/cli.yml
vendored
18
.github/workflows/cli.yml
vendored
|
|
@ -1,18 +0,0 @@
|
|||
name: "CodeScanning CLI"
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
# Build the CLI
|
||||
- name: Build CLI
|
||||
run: npm run build-cli
|
||||
|
||||
# Upload an empty SARIF file
|
||||
- name: Upload with CLI
|
||||
run: node cli/code-scanning-cli.js upload --sarif-file src/testdata/empty-sarif.sarif --repository $GITHUB_REPOSITORY --commit $GITHUB_SHA --ref $GITHUB_REF --github-url $GITHUB_API_URL --github-auth ${{ github.token }}
|
||||
9
.github/workflows/pr-checks.yml
vendored
9
.github/workflows/pr-checks.yml
vendored
|
|
@ -24,6 +24,8 @@ jobs:
|
|||
>&2 echo "Failed: Repo should be clean before testing!"
|
||||
exit 1
|
||||
fi
|
||||
# Wipe the lib directory incase there are extra unnecessary files in there
|
||||
rm -rf lib
|
||||
# Generate the JavaScript files
|
||||
npm run-script build
|
||||
# Check that repo is still clean
|
||||
|
|
@ -63,9 +65,12 @@ jobs:
|
|||
echo "Success: node_modules are up to date"
|
||||
|
||||
npm-test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest,macos-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: npm run-script test
|
||||
run: npm run-script test
|
||||
run: npm run-script test
|
||||
|
|
|
|||
26
.github/workflows/runner.yml
vendored
Normal file
26
.github/workflows/runner.yml
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
name: "CodeQL runner"
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Build runner
|
||||
run: |
|
||||
cd runner
|
||||
npm install
|
||||
npm run build-runner
|
||||
|
||||
- name: Upload with runner
|
||||
run: |
|
||||
runner/dist/codeql-runner-linux upload \
|
||||
--sarif-file src/testdata/empty-sarif.sarif \
|
||||
--repository $GITHUB_REPOSITORY \
|
||||
--commit $GITHUB_SHA \
|
||||
--ref $GITHUB_REF \
|
||||
--github-url $GITHUB_API_URL \
|
||||
--github-auth ${{ github.token }}
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -1,2 +1,2 @@
|
|||
/cli/
|
||||
|
||||
/runner/dist/
|
||||
/runner/node_modules/
|
||||
|
|
|
|||
|
|
@ -49,6 +49,10 @@ Running locally will generate the CodeQL database and run all the queries, but i
|
|||
|
||||
As well as the unit tests (see _Common tasks_ above), there are integration tests, defined in `.github/workflows/integration-testing.yml`. These are run by a CI check. Depending on the change you’re making, you may want to add a test to this file or extend an existing one.
|
||||
|
||||
### Building the CodeQL runner
|
||||
|
||||
Navigate to the `runner` directory and run `npm install` to install dependencies needed only for compiling the CodeQL runner. Run `npm run build-runner` to output files to the `runner/dist` directory.
|
||||
|
||||
## Submitting a pull request
|
||||
|
||||
1. [Fork][fork] and clone the repository
|
||||
|
|
|
|||
|
|
@ -29,4 +29,4 @@ inputs:
|
|||
default: ${{ toJson(matrix) }}
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: '../lib/finalize-db.js'
|
||||
main: '../lib/analyze-action.js'
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@ inputs:
|
|||
default: ${{ toJson(matrix) }}
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: '../lib/autobuild.js'
|
||||
main: '../lib/autobuild-action.js'
|
||||
|
|
@ -16,6 +16,9 @@ inputs:
|
|||
config-file:
|
||||
description: Path of the config file to use
|
||||
required: false
|
||||
queries:
|
||||
description: Comma-separated list of additional queries to run. By default, this overrides the same setting in a configuration file
|
||||
required: false
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: '../lib/setup-tracer.js'
|
||||
main: '../lib/init-action.js'
|
||||
|
|
|
|||
26
lib/finalize-db.js → lib/analyze-action.js
generated
26
lib/finalize-db.js → lib/analyze-action.js
generated
|
|
@ -29,43 +29,44 @@ async function sendStatusReport(startedAt, queriesStats, uploadStats, error) {
|
|||
};
|
||||
await util.sendStatusReport(statusReport);
|
||||
}
|
||||
async function createdDBForScannedLanguages(databaseFolder, config) {
|
||||
async function createdDBForScannedLanguages(config) {
|
||||
const codeql = codeql_1.getCodeQL(config.codeQLCmd);
|
||||
for (const language of config.languages) {
|
||||
if (languages_1.isScannedLanguage(language)) {
|
||||
core.startGroup('Extracting ' + language);
|
||||
await codeql.extractScannedLanguage(path.join(databaseFolder, language), language);
|
||||
await codeql.extractScannedLanguage(util.getCodeQLDatabasePath(config.tempDir, language), language);
|
||||
core.endGroup();
|
||||
}
|
||||
}
|
||||
}
|
||||
async function finalizeDatabaseCreation(databaseFolder, config) {
|
||||
await createdDBForScannedLanguages(databaseFolder, config);
|
||||
async function finalizeDatabaseCreation(config) {
|
||||
await createdDBForScannedLanguages(config);
|
||||
const codeql = codeql_1.getCodeQL(config.codeQLCmd);
|
||||
for (const language of config.languages) {
|
||||
core.startGroup('Finalizing ' + language);
|
||||
await codeql.finalizeDatabase(path.join(databaseFolder, language));
|
||||
await codeql.finalizeDatabase(util.getCodeQLDatabasePath(config.tempDir, language));
|
||||
core.endGroup();
|
||||
}
|
||||
}
|
||||
// Runs queries and creates sarif files in the given folder
|
||||
async function runQueries(databaseFolder, sarifFolder, config) {
|
||||
async function runQueries(sarifFolder, config) {
|
||||
const codeql = codeql_1.getCodeQL(config.codeQLCmd);
|
||||
for (let language of fs.readdirSync(databaseFolder)) {
|
||||
for (let language of config.languages) {
|
||||
core.startGroup('Analyzing ' + language);
|
||||
const queries = config.queries[language] || [];
|
||||
if (queries.length === 0) {
|
||||
throw new Error('Unable to analyse ' + language + ' as no queries were selected for this language');
|
||||
}
|
||||
try {
|
||||
const databasePath = util.getCodeQLDatabasePath(config.tempDir, language);
|
||||
// Pass the queries to codeql using a file instead of using the command
|
||||
// line to avoid command line length restrictions, particularly on windows.
|
||||
const querySuite = path.join(databaseFolder, language + '-queries.qls');
|
||||
const querySuite = databasePath + '-queries.qls';
|
||||
const querySuiteContents = queries.map(q => '- query: ' + q).join('\n');
|
||||
fs.writeFileSync(querySuite, querySuiteContents);
|
||||
core.debug('Query suite file for ' + language + '...\n' + querySuiteContents);
|
||||
const sarifFile = path.join(sarifFolder, language + '.sarif');
|
||||
await codeql.databaseAnalyze(path.join(databaseFolder, language), sarifFile, querySuite);
|
||||
await codeql.databaseAnalyze(databasePath, sarifFile, querySuite);
|
||||
core.debug('SARIF results for database ' + language + ' created at "' + sarifFile + '"');
|
||||
core.endGroup();
|
||||
}
|
||||
|
|
@ -90,13 +91,12 @@ async function run() {
|
|||
const config = await configUtils.getConfig(util.getRequiredEnvParam('RUNNER_TEMP'));
|
||||
core.exportVariable(sharedEnv.ODASA_TRACER_CONFIGURATION, '');
|
||||
delete process.env[sharedEnv.ODASA_TRACER_CONFIGURATION];
|
||||
const databaseFolder = util.getCodeQLDatabasesDir(config.tempDir);
|
||||
const sarifFolder = core.getInput('output');
|
||||
fs.mkdirSync(sarifFolder, { recursive: true });
|
||||
core.info('Finalizing database creation');
|
||||
await finalizeDatabaseCreation(databaseFolder, config);
|
||||
await finalizeDatabaseCreation(config);
|
||||
core.info('Analyzing database');
|
||||
queriesStats = await runQueries(databaseFolder, sarifFolder, config);
|
||||
queriesStats = await runQueries(sarifFolder, config);
|
||||
if ('true' === core.getInput('upload')) {
|
||||
uploadStats = await upload_lib.upload(sarifFolder, repository_1.parseRepositoryNwo(util.getRequiredEnvParam('GITHUB_REPOSITORY')), await util.getCommitOid(), util.getRef(), await util.getAnalysisKey(), util.getRequiredEnvParam('GITHUB_WORKFLOW'), util.getWorkflowRunID(), core.getInput('checkout_path'), core.getInput('matrix'), core.getInput('token'), util.getRequiredEnvParam('GITHUB_API_URL'), 'actions', logging_1.getActionsLogger());
|
||||
}
|
||||
|
|
@ -113,4 +113,4 @@ run().catch(e => {
|
|||
core.setFailed("analyze action failed: " + e);
|
||||
console.log(e);
|
||||
});
|
||||
//# sourceMappingURL=finalize-db.js.map
|
||||
//# sourceMappingURL=analyze-action.js.map
|
||||
1
lib/analyze-action.js.map
Normal file
1
lib/analyze-action.js.map
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"analyze-action.js","sourceRoot":"","sources":["../src/analyze-action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AACtC,uCAAyB;AACzB,2CAA6B;AAE7B,qCAAqC;AACrC,4DAA8C;AAC9C,2CAAgD;AAChD,uCAA6C;AAC7C,6CAAkD;AAClD,gEAAkD;AAClD,yDAA2C;AAC3C,6CAA+B;AAiC/B,KAAK,UAAU,gBAAgB,CAC7B,SAAe,EACf,YAA6C,EAC7C,WAAsD,EACtD,KAAa;;IAEb,MAAM,MAAM,GAAG,OAAA,YAAY,0CAAE,wBAAwB,MAAK,SAAS,IAAI,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;IACnH,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,QAAE,KAAK,0CAAE,OAAO,QAAE,KAAK,0CAAE,KAAK,CAAC,CAAC;IACtH,MAAM,YAAY,GAAuB;QACvC,GAAG,gBAAgB;QACnB,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC;QACvB,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC;KACvB,CAAC;IACF,MAAM,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AAC5C,CAAC;AAED,KAAK,UAAU,4BAA4B,CAAC,MAA0B;IACpE,MAAM,MAAM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CAAC,OAAO,CAAC,EACtB,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAC1C,SAAS,EACT,0BAAgB,EAAE,CAAC,CAAC;SACvB;KAEF;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,gBAAgB,CAAC,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;QACpE,OAAO;KACR;IAED,MAAM,gBAAgB,CAAC,SAAS,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;AAC/D,CAAC;AAED,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;IACd,IAAI,CAAC,SAAS,CAAC,yBAAyB,GAAG,CAAC,CAAC,CAAC;IAC9C,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC,CAAC"}
|
||||
2
lib/autobuild.js → lib/autobuild-action.js
generated
2
lib/autobuild.js → lib/autobuild-action.js
generated
|
|
@ -63,4 +63,4 @@ run().catch(e => {
|
|||
core.setFailed("autobuild action failed. " + e);
|
||||
console.log(e);
|
||||
});
|
||||
//# sourceMappingURL=autobuild.js.map
|
||||
//# sourceMappingURL=autobuild-action.js.map
|
||||
1
lib/autobuild-action.js.map
Normal file
1
lib/autobuild-action.js.map
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"autobuild-action.js","sourceRoot":"","sources":["../src/autobuild-action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAEtC,qCAAqC;AACrC,6DAA+C;AAC/C,2CAA+C;AAC/C,6CAA+B;AAS/B,KAAK,UAAU,yBAAyB,CACtC,SAAe,EACf,YAAsB,EACtB,eAAwB,EACxB,KAAa;;IAEb,MAAM,MAAM,GAAG,eAAe,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,CAAC,CA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G,EACP,SAAS,EACT,SAAS,EACT,SAAS,EACT,GAAG,CAAC,YAAY,IAAI,OAAO,CAAC,GAAG,EAAE,EACjC,SAAS,EACT,GAAG,CAAC,UAAU,EACd,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,EAChC,KAAK,EACL,MAAM,CAAC,CAAC;KACX;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAC9B,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAChB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;KACtB;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
||||
4
lib/codeql.js
generated
4
lib/codeql.js
generated
|
|
@ -231,14 +231,12 @@ function getCodeQLForCmd(cmd) {
|
|||
'--format=json'
|
||||
]);
|
||||
},
|
||||
getTracerEnv: async function (databasePath, compilerSpec) {
|
||||
getTracerEnv: async function (databasePath) {
|
||||
let envFile = path.resolve(databasePath, 'working', 'env.tmp');
|
||||
const compilerSpecArg = compilerSpec ? ["--compiler-spec=" + compilerSpec] : [];
|
||||
await exec.exec(cmd, [
|
||||
'database',
|
||||
'trace-command',
|
||||
databasePath,
|
||||
...compilerSpecArg,
|
||||
...getExtraOptionsFromEnv(['database', 'trace-command']),
|
||||
process.execPath,
|
||||
path.resolve(__dirname, 'tracer-env.js'),
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
45
lib/config-utils.js
generated
45
lib/config-utils.js
generated
|
|
@ -89,7 +89,7 @@ const builtinSuites = ['security-extended', 'security-and-quality'];
|
|||
* Determine the set of queries associated with suiteName's suites and add them to resultMap.
|
||||
* Throws an error if suiteName is not a valid builtin suite.
|
||||
*/
|
||||
async function addBuiltinSuiteQueries(configFile, languages, codeQL, resultMap, suiteName) {
|
||||
async function addBuiltinSuiteQueries(languages, codeQL, resultMap, suiteName, configFile) {
|
||||
const suite = builtinSuites.find((suite) => suite === suiteName);
|
||||
if (!suite) {
|
||||
throw new Error(getQueryUsesInvalid(configFile, suiteName));
|
||||
|
|
@ -100,7 +100,7 @@ async function addBuiltinSuiteQueries(configFile, languages, codeQL, resultMap,
|
|||
/**
|
||||
* Retrieve the set of queries at localQueryPath and add them to resultMap.
|
||||
*/
|
||||
async function addLocalQueries(configFile, codeQL, resultMap, localQueryPath) {
|
||||
async function addLocalQueries(codeQL, resultMap, localQueryPath, configFile) {
|
||||
// Resolve the local path against the workspace so that when this is
|
||||
// passed to codeql it resolves to exactly the path we expect it to resolve to.
|
||||
const workspacePath = fs.realpathSync(util.getRequiredEnvParam('GITHUB_WORKSPACE'));
|
||||
|
|
@ -122,7 +122,7 @@ async function addLocalQueries(configFile, codeQL, resultMap, localQueryPath) {
|
|||
/**
|
||||
* Retrieve the set of queries at the referenced remote repo and add them to resultMap.
|
||||
*/
|
||||
async function addRemoteQueries(configFile, codeQL, resultMap, queryUses, tempDir) {
|
||||
async function addRemoteQueries(codeQL, resultMap, queryUses, tempDir, configFile) {
|
||||
let tok = queryUses.split('@');
|
||||
if (tok.length !== 2) {
|
||||
throw new Error(getQueryUsesInvalid(configFile, queryUses));
|
||||
|
|
@ -155,23 +155,23 @@ async function addRemoteQueries(configFile, codeQL, resultMap, queryUses, tempDi
|
|||
* local paths starting with './', or references to remote repos, or
|
||||
* a finite set of hardcoded terms for builtin suites.
|
||||
*/
|
||||
async function parseQueryUses(configFile, languages, codeQL, resultMap, queryUses, tempDir) {
|
||||
async function parseQueryUses(languages, codeQL, resultMap, queryUses, tempDir, configFile) {
|
||||
queryUses = queryUses.trim();
|
||||
if (queryUses === "") {
|
||||
throw new Error(getQueryUsesInvalid(configFile));
|
||||
}
|
||||
// Check for the local path case before we start trying to parse the repository name
|
||||
if (queryUses.startsWith("./")) {
|
||||
await addLocalQueries(configFile, codeQL, resultMap, queryUses.slice(2));
|
||||
await addLocalQueries(codeQL, resultMap, queryUses.slice(2), configFile);
|
||||
return;
|
||||
}
|
||||
// Check for one of the builtin suites
|
||||
if (queryUses.indexOf('/') === -1 && queryUses.indexOf('@') === -1) {
|
||||
await addBuiltinSuiteQueries(configFile, languages, codeQL, resultMap, queryUses);
|
||||
await addBuiltinSuiteQueries(languages, codeQL, resultMap, queryUses, configFile);
|
||||
return;
|
||||
}
|
||||
// Otherwise, must be a reference to another repo
|
||||
await addRemoteQueries(configFile, codeQL, resultMap, queryUses, tempDir);
|
||||
await addRemoteQueries(codeQL, resultMap, queryUses, tempDir, configFile);
|
||||
}
|
||||
// Regex validating stars in paths or paths-ignore entries.
|
||||
// The intention is to only allow ** to appear when immediately
|
||||
|
|
@ -219,6 +219,8 @@ function validateAndSanitisePath(originalPath, propertyName, configFile) {
|
|||
return path;
|
||||
}
|
||||
exports.validateAndSanitisePath = validateAndSanitisePath;
|
||||
// An undefined configFile in some of these functions indicates that
|
||||
// the property was in a workflow file, not a config file
|
||||
function getNameInvalid(configFile) {
|
||||
return getConfigFilePropertyError(configFile, NAME_PROPERTY, 'must be a non-empty string');
|
||||
}
|
||||
|
|
@ -276,7 +278,12 @@ function getConfigFileDirectoryGivenMessage(configFile) {
|
|||
}
|
||||
exports.getConfigFileDirectoryGivenMessage = getConfigFileDirectoryGivenMessage;
|
||||
function getConfigFilePropertyError(configFile, property, error) {
|
||||
return 'The configuration file "' + configFile + '" is invalid: property "' + property + '" ' + error;
|
||||
if (configFile === undefined) {
|
||||
return 'The workflow property "' + property + '" is invalid: ' + error;
|
||||
}
|
||||
else {
|
||||
return 'The configuration file "' + configFile + '" is invalid: property "' + property + '" ' + error;
|
||||
}
|
||||
}
|
||||
function getNoLanguagesError() {
|
||||
return "Did not detect any languages to analyze. " +
|
||||
|
|
@ -363,6 +370,20 @@ async function getLanguages() {
|
|||
}
|
||||
return parsedLanguages;
|
||||
}
|
||||
/**
|
||||
* Returns true if queries were provided in the workflow file
|
||||
* (and thus added), otherwise false
|
||||
*/
|
||||
async function addQueriesFromWorkflowIfRequired(codeQL, languages, resultMap, tempDir) {
|
||||
const queryUses = core.getInput('queries');
|
||||
if (queryUses) {
|
||||
for (const query of queryUses.split(',')) {
|
||||
await parseQueryUses(languages, codeQL, resultMap, query, tempDir);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Get the default config for when the user has not supplied one.
|
||||
*/
|
||||
|
|
@ -370,6 +391,7 @@ async function getDefaultConfig(tempDir, toolCacheDir, codeQL) {
|
|||
const languages = await getLanguages();
|
||||
const queries = {};
|
||||
await addDefaultQueries(codeQL, languages, queries);
|
||||
await addQueriesFromWorkflowIfRequired(codeQL, languages, queries, tempDir);
|
||||
return {
|
||||
languages: languages,
|
||||
queries: queries,
|
||||
|
|
@ -420,7 +442,10 @@ async function loadConfig(configFile, tempDir, toolCacheDir, codeQL) {
|
|||
if (!disableDefaultQueries) {
|
||||
await addDefaultQueries(codeQL, languages, queries);
|
||||
}
|
||||
if (QUERIES_PROPERTY in parsedYAML) {
|
||||
// If queries were provided using `with` in the action configuration,
|
||||
// they should take precedence over the queries in the config file
|
||||
const addedQueriesFromAction = await addQueriesFromWorkflowIfRequired(codeQL, languages, queries, tempDir);
|
||||
if (!addedQueriesFromAction && QUERIES_PROPERTY in parsedYAML) {
|
||||
if (!(parsedYAML[QUERIES_PROPERTY] instanceof Array)) {
|
||||
throw new Error(getQueriesInvalid(configFile));
|
||||
}
|
||||
|
|
@ -428,7 +453,7 @@ async function loadConfig(configFile, tempDir, toolCacheDir, codeQL) {
|
|||
if (!(QUERIES_USES_PROPERTY in query) || typeof query[QUERIES_USES_PROPERTY] !== "string") {
|
||||
throw new Error(getQueryUsesInvalid(configFile));
|
||||
}
|
||||
await parseQueryUses(configFile, languages, codeQL, queries, query[QUERIES_USES_PROPERTY], tempDir);
|
||||
await parseQueryUses(languages, codeQL, queries, query[QUERIES_USES_PROPERTY], tempDir, configFile);
|
||||
}
|
||||
}
|
||||
if (PATHS_IGNORE_PROPERTY in parsedYAML) {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
161
lib/config-utils.test.js
generated
161
lib/config-utils.test.js
generated
|
|
@ -242,6 +242,165 @@ ava_1.default("default queries are used", async (t) => {
|
|||
t.deepEqual(resolveQueriesArgs[0].extraSearchPath, undefined);
|
||||
});
|
||||
});
|
||||
ava_1.default("Queries can be specified in config file", async (t) => {
|
||||
return await util.withTmpDir(async (tmpDir) => {
|
||||
process.env['RUNNER_TEMP'] = tmpDir;
|
||||
process.env['GITHUB_WORKSPACE'] = tmpDir;
|
||||
const inputFileContents = `
|
||||
name: my config
|
||||
queries:
|
||||
- uses: ./foo`;
|
||||
fs.writeFileSync(path.join(tmpDir, 'input'), inputFileContents, 'utf8');
|
||||
setInput('config-file', 'input');
|
||||
fs.mkdirSync(path.join(tmpDir, 'foo'));
|
||||
const resolveQueriesArgs = [];
|
||||
const codeQL = codeql_1.setCodeQL({
|
||||
resolveQueries: async function (queries, extraSearchPath) {
|
||||
resolveQueriesArgs.push({ queries, extraSearchPath });
|
||||
// Return what we're given, just in the right format for a resolved query
|
||||
// This way we can test by seeing which returned items are in the final
|
||||
// configuration.
|
||||
const dummyResolvedQueries = {};
|
||||
queries.forEach(q => { dummyResolvedQueries[q] = {}; });
|
||||
return {
|
||||
byLanguage: {
|
||||
'javascript': dummyResolvedQueries,
|
||||
},
|
||||
noDeclaredLanguage: {},
|
||||
multipleDeclaredLanguages: {},
|
||||
};
|
||||
},
|
||||
});
|
||||
setInput('languages', 'javascript');
|
||||
const config = await configUtils.initConfig(tmpDir, tmpDir, codeQL);
|
||||
// Check resolveQueries was called correctly
|
||||
// It'll be called once for the default queries
|
||||
// and once for `./foo` from the config file.
|
||||
t.deepEqual(resolveQueriesArgs.length, 2);
|
||||
t.deepEqual(resolveQueriesArgs[1].queries.length, 1);
|
||||
t.regex(resolveQueriesArgs[1].queries[0], /.*\/foo$/);
|
||||
// Now check that the end result contains the default queries and the query from config
|
||||
t.deepEqual(config.queries['javascript'].length, 2);
|
||||
t.regex(config.queries['javascript'][0], /javascript-code-scanning.qls$/);
|
||||
t.regex(config.queries['javascript'][1], /.*\/foo$/);
|
||||
});
|
||||
});
|
||||
ava_1.default("Queries from config file can be overridden in workflow file", async (t) => {
|
||||
return await util.withTmpDir(async (tmpDir) => {
|
||||
process.env['RUNNER_TEMP'] = tmpDir;
|
||||
process.env['GITHUB_WORKSPACE'] = tmpDir;
|
||||
const inputFileContents = `
|
||||
name: my config
|
||||
queries:
|
||||
- uses: ./foo`;
|
||||
fs.writeFileSync(path.join(tmpDir, 'input'), inputFileContents, 'utf8');
|
||||
setInput('config-file', 'input');
|
||||
// This config item should take precedence over the config file but shouldn't affect the default queries.
|
||||
setInput('queries', './override');
|
||||
fs.mkdirSync(path.join(tmpDir, 'foo'));
|
||||
fs.mkdirSync(path.join(tmpDir, 'override'));
|
||||
const resolveQueriesArgs = [];
|
||||
const codeQL = codeql_1.setCodeQL({
|
||||
resolveQueries: async function (queries, extraSearchPath) {
|
||||
resolveQueriesArgs.push({ queries, extraSearchPath });
|
||||
// Return what we're given, just in the right format for a resolved query
|
||||
// This way we can test overriding by seeing which returned items are in
|
||||
// the final configuration.
|
||||
const dummyResolvedQueries = {};
|
||||
queries.forEach(q => { dummyResolvedQueries[q] = {}; });
|
||||
return {
|
||||
byLanguage: {
|
||||
'javascript': dummyResolvedQueries,
|
||||
},
|
||||
noDeclaredLanguage: {},
|
||||
multipleDeclaredLanguages: {},
|
||||
};
|
||||
},
|
||||
});
|
||||
setInput('languages', 'javascript');
|
||||
const config = await configUtils.initConfig(tmpDir, tmpDir, codeQL);
|
||||
// Check resolveQueries was called correctly
|
||||
// It'll be called once for the default queries and once for `./override`,
|
||||
// but won't be called for './foo' from the config file.
|
||||
t.deepEqual(resolveQueriesArgs.length, 2);
|
||||
t.deepEqual(resolveQueriesArgs[1].queries.length, 1);
|
||||
t.regex(resolveQueriesArgs[1].queries[0], /.*\/override$/);
|
||||
// Now check that the end result contains only the default queries and the override query
|
||||
t.deepEqual(config.queries['javascript'].length, 2);
|
||||
t.regex(config.queries['javascript'][0], /javascript-code-scanning.qls$/);
|
||||
t.regex(config.queries['javascript'][1], /.*\/override$/);
|
||||
});
|
||||
});
|
||||
ava_1.default("Multiple queries can be specified in workflow file, no config file required", async (t) => {
|
||||
return await util.withTmpDir(async (tmpDir) => {
|
||||
process.env['RUNNER_TEMP'] = tmpDir;
|
||||
process.env['GITHUB_WORKSPACE'] = tmpDir;
|
||||
fs.mkdirSync(path.join(tmpDir, 'override1'));
|
||||
fs.mkdirSync(path.join(tmpDir, 'override2'));
|
||||
setInput('queries', './override1,./override2');
|
||||
const resolveQueriesArgs = [];
|
||||
const codeQL = codeql_1.setCodeQL({
|
||||
resolveQueries: async function (queries, extraSearchPath) {
|
||||
resolveQueriesArgs.push({ queries, extraSearchPath });
|
||||
// Return what we're given, just in the right format for a resolved query
|
||||
// This way we can test overriding by seeing which returned items are in
|
||||
// the final configuration.
|
||||
const dummyResolvedQueries = {};
|
||||
queries.forEach(q => { dummyResolvedQueries[q] = {}; });
|
||||
return {
|
||||
byLanguage: {
|
||||
'javascript': dummyResolvedQueries,
|
||||
},
|
||||
noDeclaredLanguage: {},
|
||||
multipleDeclaredLanguages: {},
|
||||
};
|
||||
},
|
||||
});
|
||||
setInput('languages', 'javascript');
|
||||
const config = await configUtils.initConfig(tmpDir, tmpDir, codeQL);
|
||||
// Check resolveQueries was called correctly:
|
||||
// It'll be called once for the default queries,
|
||||
// and then once for each of the two queries from the workflow
|
||||
t.deepEqual(resolveQueriesArgs.length, 3);
|
||||
t.deepEqual(resolveQueriesArgs[1].queries.length, 1);
|
||||
t.deepEqual(resolveQueriesArgs[2].queries.length, 1);
|
||||
t.regex(resolveQueriesArgs[1].queries[0], /.*\/override1$/);
|
||||
t.regex(resolveQueriesArgs[2].queries[0], /.*\/override2$/);
|
||||
// Now check that the end result contains both the queries from the workflow, as well as the defaults
|
||||
t.deepEqual(config.queries['javascript'].length, 3);
|
||||
t.regex(config.queries['javascript'][0], /javascript-code-scanning.qls$/);
|
||||
t.regex(config.queries['javascript'][1], /.*\/override1$/);
|
||||
t.regex(config.queries['javascript'][2], /.*\/override2$/);
|
||||
});
|
||||
});
|
||||
ava_1.default("Invalid queries in workflow file handled correctly", async (t) => {
|
||||
return await util.withTmpDir(async (tmpDir) => {
|
||||
process.env['RUNNER_TEMP'] = tmpDir;
|
||||
process.env['GITHUB_WORKSPACE'] = tmpDir;
|
||||
setInput('queries', 'foo/bar@v1@v3');
|
||||
setInput('languages', 'javascript');
|
||||
// This function just needs to be type-correct; it doesn't need to do anything,
|
||||
// since we're deliberately passing in invalid data
|
||||
const codeQL = codeql_1.setCodeQL({
|
||||
resolveQueries: async function (_queries, _extraSearchPath) {
|
||||
return {
|
||||
byLanguage: {
|
||||
'javascript': {},
|
||||
},
|
||||
noDeclaredLanguage: {},
|
||||
multipleDeclaredLanguages: {},
|
||||
};
|
||||
},
|
||||
});
|
||||
try {
|
||||
await configUtils.initConfig(tmpDir, tmpDir, codeQL);
|
||||
t.fail('initConfig did not throw error');
|
||||
}
|
||||
catch (err) {
|
||||
t.deepEqual(err, new Error(configUtils.getQueryUsesInvalid(undefined, "foo/bar@v1@v3")));
|
||||
}
|
||||
});
|
||||
});
|
||||
ava_1.default("API client used when reading remote config", async (t) => {
|
||||
return await util.withTmpDir(async (tmpDir) => {
|
||||
process.env['RUNNER_TEMP'] = tmpDir;
|
||||
|
|
@ -276,7 +435,7 @@ ava_1.default("API client used when reading remote config", async (t) => {
|
|||
};
|
||||
const spyGetContents = mockGetContents(dummyResponse);
|
||||
// Create checkout directory for remote queries repository
|
||||
fs.mkdirSync(path.join(tmpDir, 'foo/bar'), { recursive: true });
|
||||
fs.mkdirSync(path.join(tmpDir, 'foo/bar/dev'), { recursive: true });
|
||||
setInput('config-file', 'octo-org/codeql-config/config.yaml@main');
|
||||
setInput('languages', 'javascript');
|
||||
await configUtils.initConfig(tmpDir, tmpDir, codeQL);
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"bundleVersion": "codeql-bundle-20200630"
|
||||
"bundleVersion": "codeql-bundle-20200826"
|
||||
}
|
||||
|
|
|
|||
6
lib/external-queries.js
generated
6
lib/external-queries.js
generated
|
|
@ -16,7 +16,11 @@ const path = __importStar(require("path"));
|
|||
*/
|
||||
async function checkoutExternalRepository(repository, ref, tempDir) {
|
||||
core.info('Checking out ' + repository);
|
||||
const checkoutLocation = path.join(tempDir, repository);
|
||||
const checkoutLocation = path.join(tempDir, repository, ref);
|
||||
if (!checkoutLocation.startsWith(tempDir)) {
|
||||
// this still permits locations that mess with sibling repositories in `tempDir`, but that is acceptable
|
||||
throw new Error(`'${repository}@${ref}' is not a valid repository and reference.`);
|
||||
}
|
||||
if (!fs.existsSync(checkoutLocation)) {
|
||||
const repoURL = 'https://github.com/' + repository + '.git';
|
||||
await exec.exec('git', ['clone', repoURL, checkoutLocation]);
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"external-queries.js","sourceRoot":"","sources":["../src/external-queries.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AACtC,oDAAsC;AACtC,uCAAyB;AACzB,2CAA6B;AAE7B;;GAEG;AACI,KAAK,UAAU,0BAA0B,CAAC,UAAkB,EAAE,GAAW,EAAE,OAAe;IAC/F,IAAI,CAAC,IAAI,CAAC,eAAe,GAAG,UAAU,CAAC,CAAC;IAExC,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IACxD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;QACpC,MAAM,OAAO,GAAG,qBAAqB,GAAG,UAAU,GAAG,MAAM,CAAC;QAC5D,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC;QAC7D,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACrB,cAAc,GAAG,gBAAgB;YACjC,YAAY,GAAG,gBAAgB,GAAG,OAAO;YACzC,UAAU,EAAE,GAAG;SAChB,CAAC,CAAC;KACJ;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAfD,gEAeC"}
|
||||
{"version":3,"file":"external-queries.js","sourceRoot":"","sources":["../src/external-queries.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AACtC,oDAAsC;AACtC,uCAAyB;AACzB,2CAA6B;AAE7B;;GAEG;AACI,KAAK,UAAU,0BAA0B,CAAC,UAAkB,EAAE,GAAW,EAAE,OAAe;IAC/F,IAAI,CAAC,IAAI,CAAC,eAAe,GAAG,UAAU,CAAC,CAAC;IAExC,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;IAE7D,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;QACzC,wGAAwG;QACxG,MAAM,IAAI,KAAK,CAAC,IAAI,UAAU,IAAI,GAAG,4CAA4C,CAAC,CAAC;KACpF;IAED,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;QACpC,MAAM,OAAO,GAAG,qBAAqB,GAAG,UAAU,GAAG,MAAM,CAAC;QAC5D,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC;QAC7D,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACrB,cAAc,GAAG,gBAAgB;YACjC,YAAY,GAAG,gBAAgB,GAAG,OAAO;YACzC,UAAU,EAAE,GAAG;SAChB,CAAC,CAAC;KACJ;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AArBD,gEAqBC"}
|
||||
5
lib/external-queries.test.js
generated
5
lib/external-queries.test.js
generated
|
|
@ -19,9 +19,10 @@ const util = __importStar(require("./util"));
|
|||
testing_utils_1.setupTests(ava_1.default);
|
||||
ava_1.default("checkoutExternalQueries", async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
await externalQueries.checkoutExternalRepository("github/codeql-go", "df4c6869212341b601005567381944ed90906b6b", tmpDir);
|
||||
const ref = "df4c6869212341b601005567381944ed90906b6b";
|
||||
await externalQueries.checkoutExternalRepository("github/codeql-go", ref, tmpDir);
|
||||
// COPYRIGHT file existed in df4c6869212341b601005567381944ed90906b6b but not in the default branch
|
||||
t.true(fs.existsSync(path.join(tmpDir, "github", "codeql-go", "COPYRIGHT")));
|
||||
t.true(fs.existsSync(path.join(tmpDir, "github", "codeql-go", ref, "COPYRIGHT")));
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=external-queries.test.js.map
|
||||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"external-queries.test.js","sourceRoot":"","sources":["../src/external-queries.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAAuB;AACvB,uCAAyB;AACzB,2CAA6B;AAE7B,oEAAsD;AACtD,mDAA2C;AAC3C,6CAA+B;AAE/B,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,yBAAyB,EAAE,KAAK,EAAC,CAAC,EAAC,EAAE;IACxC,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAC,MAAM,EAAC,EAAE;QACnC,MAAM,eAAe,CAAC,0BAA0B,CAC9C,kBAAkB,EAClB,0CAA0C,EAC1C,MAAM,CAAC,CAAC;QAEV,mGAAmG;QACnG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IAC/E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
||||
{"version":3,"file":"external-queries.test.js","sourceRoot":"","sources":["../src/external-que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{"version":3,"file":"finalize-db.test.js","sourceRoot":"","sources":["../src/finalize-db.test.ts"],"names":[],"mappings":""}
|
||||
6
lib/fingerprints.test.js
generated
6
lib/fingerprints.test.js
generated
|
|
@ -99,7 +99,7 @@ ava_1.default('hash', (t) => {
|
|||
function testResolveUriToFile(uri, index, artifactsURIs) {
|
||||
const location = { "uri": uri, "index": index };
|
||||
const artifacts = artifactsURIs.map(uri => ({ "location": { "uri": uri } }));
|
||||
return fingerprints.resolveUriToFile(location, artifacts, logging_1.getCLILogger());
|
||||
return fingerprints.resolveUriToFile(location, artifacts, logging_1.getRunnerLogger());
|
||||
}
|
||||
ava_1.default('resolveUriToFile', t => {
|
||||
// The resolveUriToFile method checks that the file exists and is in the right directory
|
||||
|
|
@ -144,7 +144,7 @@ ava_1.default('addFingerprints', t => {
|
|||
expected = JSON.stringify(JSON.parse(expected));
|
||||
// The URIs in the SARIF files resolve to files in the testdata directory
|
||||
process.env['GITHUB_WORKSPACE'] = path.normalize(__dirname + '/../src/testdata');
|
||||
t.deepEqual(fingerprints.addFingerprints(input, logging_1.getCLILogger()), expected);
|
||||
t.deepEqual(fingerprints.addFingerprints(input, logging_1.getRunnerLogger()), expected);
|
||||
});
|
||||
ava_1.default('missingRegions', t => {
|
||||
// Run an end-to-end test on a test file
|
||||
|
|
@ -155,6 +155,6 @@ ava_1.default('missingRegions', t => {
|
|||
expected = JSON.stringify(JSON.parse(expected));
|
||||
// The URIs in the SARIF files resolve to files in the testdata directory
|
||||
process.env['GITHUB_WORKSPACE'] = path.normalize(__dirname + '/../src/testdata');
|
||||
t.deepEqual(fingerprints.addFingerprints(input, logging_1.getCLILogger()), expected);
|
||||
t.deepEqual(fingerprints.addFingerprints(input, logging_1.getRunnerLogger()), expected);
|
||||
});
|
||||
//# sourceMappingURL=fingerprints.test.js.map
|
||||
File diff suppressed because one or more lines are too long
103
lib/init-action.js
generated
Normal file
103
lib/init-action.js
generated
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
"use strict";
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const exec = __importStar(require("@actions/exec"));
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const analysisPaths = __importStar(require("./analysis-paths"));
|
||||
const codeql_1 = require("./codeql");
|
||||
const configUtils = __importStar(require("./config-utils"));
|
||||
const tracer_config_1 = require("./tracer-config");
|
||||
const util = __importStar(require("./util"));
|
||||
async function sendSuccessStatusReport(startedAt, config) {
|
||||
const statusReportBase = await util.createStatusReportBase('init', 'success', startedAt);
|
||||
const languages = config.languages.join(',');
|
||||
const workflowLanguages = core.getInput('languages', { required: false });
|
||||
const paths = (config.originalUserInput.paths || []).join(',');
|
||||
const pathsIgnore = (config.originalUserInput['paths-ignore'] || []).join(',');
|
||||
const disableDefaultQueries = config.originalUserInput['disable-default-queries'] ? languages : '';
|
||||
const queries = (config.originalUserInput.queries || []).map(q => q.uses).join(',');
|
||||
const statusReport = {
|
||||
...statusReportBase,
|
||||
languages: languages,
|
||||
workflow_languages: workflowLanguages,
|
||||
paths: paths,
|
||||
paths_ignore: pathsIgnore,
|
||||
disable_default_queries: disableDefaultQueries,
|
||||
queries: queries,
|
||||
};
|
||||
await util.sendStatusReport(statusReport);
|
||||
}
|
||||
async function run() {
|
||||
const startedAt = new Date();
|
||||
let config;
|
||||
let codeql;
|
||||
try {
|
||||
util.prepareLocalRunEnvironment();
|
||||
if (!await util.sendStatusReport(await util.createStatusReportBase('init', 'starting', startedAt), true)) {
|
||||
return;
|
||||
}
|
||||
core.startGroup('Setup CodeQL tools');
|
||||
codeql = await codeql_1.setupCodeQL();
|
||||
await codeql.printVersion();
|
||||
core.endGroup();
|
||||
core.startGroup('Load language configuration');
|
||||
config = await configUtils.initConfig(util.getRequiredEnvParam('RUNNER_TEMP'), util.getRequiredEnvParam('RUNNER_TOOL_CACHE'), codeql);
|
||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||
core.endGroup();
|
||||
}
|
||||
catch (e) {
|
||||
core.setFailed(e.message);
|
||||
console.log(e);
|
||||
await util.sendStatusReport(await util.createStatusReportBase('init', 'aborted', startedAt, e.message));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const sourceRoot = path.resolve();
|
||||
// Forward Go flags
|
||||
const goFlags = process.env['GOFLAGS'];
|
||||
if (goFlags) {
|
||||
core.exportVariable('GOFLAGS', goFlags);
|
||||
core.warning("Passing the GOFLAGS env parameter to the init action is deprecated. Please move this to the analyze action.");
|
||||
}
|
||||
// Setup CODEQL_RAM flag (todo improve this https://github.com/github/dsp-code-scanning/issues/935)
|
||||
const codeqlRam = process.env['CODEQL_RAM'] || '6500';
|
||||
core.exportVariable('CODEQL_RAM', codeqlRam);
|
||||
fs.mkdirSync(util.getCodeQLDatabasesDir(config.tempDir), { recursive: true });
|
||||
// TODO: replace this code once CodeQL supports multi-language tracing
|
||||
for (let language of config.languages) {
|
||||
// Init language database
|
||||
await codeql.databaseInit(util.getCodeQLDatabasePath(config.tempDir, language), language, sourceRoot);
|
||||
}
|
||||
const tracerConfig = await tracer_config_1.getCombinedTracerConfig(config, codeql);
|
||||
if (tracerConfig !== undefined) {
|
||||
if (process.platform === 'win32') {
|
||||
await exec.exec('powershell', [
|
||||
path.resolve(__dirname, '..', 'src', 'inject-tracer.ps1'),
|
||||
path.resolve(path.dirname(codeql.getPath()), 'tools', 'win64', 'tracer.exe'),
|
||||
], { env: { 'ODASA_TRACER_CONFIGURATION': tracerConfig.spec } });
|
||||
}
|
||||
// NB: in CLI mode these will be output to a file rather than exported with core.exportVariable
|
||||
Object.entries(tracerConfig.env).forEach(([key, value]) => core.exportVariable(key, value));
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
console.log(error);
|
||||
await util.sendStatusReport(await util.createStatusReportBase('init', 'failure', startedAt, error.message, error.stack));
|
||||
return;
|
||||
}
|
||||
await sendSuccessStatusReport(startedAt, config);
|
||||
}
|
||||
run().catch(e => {
|
||||
core.setFailed("init action failed: " + e);
|
||||
console.log(e);
|
||||
});
|
||||
//# sourceMappingURL=init-action.js.map
|
||||
1
lib/init-action.js.map
Normal file
1
lib/init-action.js.map
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"init-action.js","sourceRoot":"","sources":["../src/init-action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AACtC,oDAAsC;AACtC,uCAAyB;AACzB,2CAA6B;AAE7B,gEAAkD;AAClD,qCAA+C;AAC/C,4DAA8C;AAC9C,mDAA0D;AAC1D,6CAA+B;AAkB/B,KAAK,UAAU,uBAAuB,CAAC,SAAe,EAAE,MAA0B;IAChF,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IAEzF,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7C,MAAM,iBAAiB,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1E,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/D,MAAM,WAAW,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/E,MAAM,qBAAqB,GAAG,MAAM,CAAC,iBAAiB,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,C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||||
4
lib/logging.js
generated
4
lib/logging.js
generated
|
|
@ -12,7 +12,7 @@ function getActionsLogger() {
|
|||
return core;
|
||||
}
|
||||
exports.getActionsLogger = getActionsLogger;
|
||||
function getCLILogger() {
|
||||
function getRunnerLogger() {
|
||||
return {
|
||||
debug: console.debug,
|
||||
info: console.info,
|
||||
|
|
@ -22,5 +22,5 @@ function getCLILogger() {
|
|||
endGroup: () => undefined,
|
||||
};
|
||||
}
|
||||
exports.getCLILogger = getCLILogger;
|
||||
exports.getRunnerLogger = getRunnerLogger;
|
||||
//# sourceMappingURL=logging.js.map
|
||||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAYtC,SAAgB,gBAAgB;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC;AAFD,4CAEC;AAED,SAAgB,YAAY;IAC1B,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,UAAU,EAAE,GAAG,EAAE,CAAC,SAAS;QAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS;KAC1B,CAAC;AACJ,CAAC;AATD,oCASC"}
|
||||
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAYtC,SAAgB,gBAAgB;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC;AAFD,4CAEC;AAED,SAAgB,eAAe;IAC7B,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,UAAU,EAAE,GAAG,EAAE,CAAC,SAAS;QAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS;KAC1B,CAAC;AACJ,CAAC;AATD,0CASC"}
|
||||
6
lib/cli.js → lib/runner.js
generated
6
lib/cli.js → lib/runner.js
generated
|
|
@ -32,7 +32,7 @@ function parseGithubApiUrl(inputUrl) {
|
|||
throw new Error(`"${inputUrl}" is not a valid URL`);
|
||||
}
|
||||
}
|
||||
const logger = logging_1.getCLILogger();
|
||||
const logger = logging_1.getRunnerLogger();
|
||||
program
|
||||
.command('upload')
|
||||
.description('Uploads a SARIF file, or all SARIF files from a directory, to code scanning')
|
||||
|
|
@ -45,7 +45,7 @@ program
|
|||
.option('--checkout-path <path>', 'Checkout path (default: current working directory)')
|
||||
.action(async (cmd) => {
|
||||
try {
|
||||
await upload_lib.upload(cmd.sarifFile, repository_1.parseRepositoryNwo(cmd.repository), cmd.commit, cmd.ref, undefined, undefined, undefined, cmd.checkoutPath || process.cwd(), undefined, cmd.githubAuth, parseGithubApiUrl(cmd.githubUrl), 'cli', logger);
|
||||
await upload_lib.upload(cmd.sarifFile, repository_1.parseRepositoryNwo(cmd.repository), cmd.commit, cmd.ref, undefined, undefined, undefined, cmd.checkoutPath || process.cwd(), undefined, cmd.githubAuth, parseGithubApiUrl(cmd.githubUrl), 'runner', logger);
|
||||
}
|
||||
catch (e) {
|
||||
logger.error('Upload failed');
|
||||
|
|
@ -54,4 +54,4 @@ program
|
|||
}
|
||||
});
|
||||
program.parse(process.argv);
|
||||
//# sourceMappingURL=cli.js.map
|
||||
//# sourceMappingURL=runner.js.map
|
||||
1
lib/runner.js.map
Normal file
1
lib/runner.js.map
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":";;;;;;;;;AAAA,yCAAoC;AACpC,2CAA6B;AAE7B,uCAA4C;AAC5C,6CAAkD;AAClD,yDAA2C;AAE3C,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAC9B,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AAS,EACb,+BAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,EAClC,GAAG,CAAC,MAAM,EACV,GAAG,CAAC,GAAG,EACP,SAAS,EACT,SAAS,EACT,SAAS,EACT,GAAG,CAAC,YAAY,IAAI,OAAO,CAAC,GAAG,EAAE,EACjC,SAAS,EACT,GAAG,CAAC,UAAU,EACd,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,EAChC,QAAQ,EACR,MAAM,CAAC,CAAC;KACX;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAC9B,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAChB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;KACtB;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
||||
76
lib/setup-tools.js
generated
76
lib/setup-tools.js
generated
|
|
@ -1,76 +0,0 @@
|
|||
"use strict";
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const toolcache = __importStar(require("@actions/tool-cache"));
|
||||
const path = __importStar(require("path"));
|
||||
const semver = __importStar(require("semver"));
|
||||
class CodeQLSetup {
|
||||
constructor(codeqlDist) {
|
||||
this.dist = codeqlDist;
|
||||
this.tools = path.join(this.dist, 'tools');
|
||||
this.cmd = path.join(codeqlDist, 'codeql');
|
||||
// TODO check process.arch ?
|
||||
if (process.platform === 'win32') {
|
||||
this.platform = 'win64';
|
||||
if (this.cmd.endsWith('codeql')) {
|
||||
this.cmd += ".exe";
|
||||
}
|
||||
}
|
||||
else if (process.platform === 'linux') {
|
||||
this.platform = 'linux64';
|
||||
}
|
||||
else if (process.platform === 'darwin') {
|
||||
this.platform = 'osx64';
|
||||
}
|
||||
else {
|
||||
throw new Error("Unsupported plaform: " + process.platform);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.CodeQLSetup = CodeQLSetup;
|
||||
async function setupCodeQL() {
|
||||
try {
|
||||
const codeqlURL = core.getInput('tools', { required: true });
|
||||
const codeqlURLVersion = getCodeQLURLVersion(codeqlURL);
|
||||
let codeqlFolder = toolcache.find('CodeQL', codeqlURLVersion);
|
||||
if (codeqlFolder) {
|
||||
core.debug(`CodeQL found in cache ${codeqlFolder}`);
|
||||
}
|
||||
else {
|
||||
const codeqlPath = await toolcache.downloadTool(codeqlURL);
|
||||
const codeqlExtracted = await toolcache.extractTar(codeqlPath);
|
||||
codeqlFolder = await toolcache.cacheDir(codeqlExtracted, 'CodeQL', codeqlURLVersion);
|
||||
}
|
||||
return new CodeQLSetup(path.join(codeqlFolder, 'codeql'));
|
||||
}
|
||||
catch (e) {
|
||||
core.error(e);
|
||||
throw new Error("Unable to download and extract CodeQL CLI");
|
||||
}
|
||||
}
|
||||
exports.setupCodeQL = setupCodeQL;
|
||||
function getCodeQLURLVersion(url) {
|
||||
const match = url.match(/\/codeql-bundle-(.*)\//);
|
||||
if (match === null || match.length < 2) {
|
||||
throw new Error(`Malformed tools url: ${url}. Version could not be inferred`);
|
||||
}
|
||||
let version = match[1];
|
||||
if (!semver.valid(version)) {
|
||||
core.debug(`Bundle version ${version} is not in SemVer format. Will treat it as pre-release 0.0.0-${version}.`);
|
||||
version = '0.0.0-' + version;
|
||||
}
|
||||
const s = semver.clean(version);
|
||||
if (!s) {
|
||||
throw new Error(`Malformed tools url ${url}. Version should be in SemVer format but have ${version} instead`);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
exports.getCodeQLURLVersion = getCodeQLURLVersion;
|
||||
//# sourceMappingURL=setup-tools.js.map
|
||||
|
|
@ -1 +0,0 @@
|
|||
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AAiD,OAAO,UAAU,CAAC,CAAC;KAC/G;IAED,OAAO,CAAC,CAAC;AACX,CAAC;AApBD,kDAoBC"}
|
||||
60
lib/setup-tools.test.js
generated
60
lib/setup-tools.test.js
generated
|
|
@ -1,60 +0,0 @@
|
|||
"use strict";
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const toolcache = __importStar(require("@actions/tool-cache"));
|
||||
const ava_1 = __importDefault(require("ava"));
|
||||
const nock_1 = __importDefault(require("nock"));
|
||||
const path = __importStar(require("path"));
|
||||
const setupTools = __importStar(require("./setup-tools"));
|
||||
const testing_utils_1 = require("./testing-utils");
|
||||
const util = __importStar(require("./util"));
|
||||
testing_utils_1.silenceDebugOutput(ava_1.default);
|
||||
ava_1.default('download codeql bundle cache', async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
process.env['GITHUB_WORKSPACE'] = tmpDir;
|
||||
process.env['RUNNER_TEMP'] = path.join(tmpDir, 'temp');
|
||||
process.env['RUNNER_TOOL_CACHE'] = path.join(tmpDir, 'cache');
|
||||
const versions = ['20200601', '20200610'];
|
||||
for (let i = 0; i < versions.length; i++) {
|
||||
const version = versions[i];
|
||||
nock_1.default('https://example.com')
|
||||
.get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`)
|
||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||
process.env['INPUT_TOOLS'] = `https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`;
|
||||
await setupTools.setupCodeQL();
|
||||
t.assert(toolcache.find('CodeQL', `0.0.0-${version}`));
|
||||
}
|
||||
const cachedVersions = toolcache.findAllVersions('CodeQL');
|
||||
t.is(cachedVersions.length, 2);
|
||||
});
|
||||
});
|
||||
ava_1.default('parse codeql bundle url version', t => {
|
||||
const tests = {
|
||||
'20200601': '0.0.0-20200601',
|
||||
'20200601.0': '0.0.0-20200601.0',
|
||||
'20200601.0.0': '20200601.0.0',
|
||||
'1.2.3': '1.2.3',
|
||||
'1.2.3-alpha': '1.2.3-alpha',
|
||||
'1.2.3-beta.1': '1.2.3-beta.1',
|
||||
};
|
||||
for (const [version, expectedVersion] of Object.entries(tests)) {
|
||||
const url = `https://github.com/.../codeql-bundle-${version}/...`;
|
||||
try {
|
||||
const parsedVersion = setupTools.getCodeQLURLVersion(url);
|
||||
t.deepEqual(parsedVersion, expectedVersion);
|
||||
}
|
||||
catch (e) {
|
||||
t.fail(e.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=setup-tools.test.js.map
|
||||
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"setup-tools.test.js","sourceRoot":"","sources":["../src/setup-tools.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAAiD;AACjD,8CAAuB;AACvB,gDAAwB;AACxB,2CAA6B;AAE7B,0DAA4C;AAC5C,mDAAmD;AACnD,6CAA+B;AAE/B,kCAAkB,CAAC,aAAI,CAAC,CAAC;AAEzB,aAAI,CAAC,8BAA8B,EAAE,KAAK,EAAC,CAAC,EAAC,EAAE;IAE7C,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAC,MAAM,EAAC,EAAE;QAEnC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,GAAG,MAAM,CAAC;QAEzC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACvD,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAAC,IAA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M,CAAC;QAElE,IAAI;YACF,MAAM,aAAa,GAAG,UAAU,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;YAC1D,CAAC,CAAC,SAAS,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;SAC7C;QAAC,OAAO,CAAC,EAAE;YACV,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;SACnB;KACF;AACH,CAAC,CAAC,CAAC"}
|
||||
225
lib/setup-tracer.js
generated
225
lib/setup-tracer.js
generated
|
|
@ -1,225 +0,0 @@
|
|||
"use strict";
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const exec = __importStar(require("@actions/exec"));
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const analysisPaths = __importStar(require("./analysis-paths"));
|
||||
const codeql_1 = require("./codeql");
|
||||
const configUtils = __importStar(require("./config-utils"));
|
||||
const languages_1 = require("./languages");
|
||||
const util = __importStar(require("./util"));
|
||||
const CRITICAL_TRACER_VARS = new Set(['SEMMLE_PRELOAD_libtrace',
|
||||
,
|
||||
'SEMMLE_RUNNER',
|
||||
,
|
||||
'SEMMLE_COPY_EXECUTABLES_ROOT',
|
||||
,
|
||||
'SEMMLE_DEPTRACE_SOCKET',
|
||||
,
|
||||
'SEMMLE_JAVA_TOOL_OPTIONS'
|
||||
]);
|
||||
async function tracerConfig(codeql, database, compilerSpec) {
|
||||
const env = await codeql.getTracerEnv(database, compilerSpec);
|
||||
const config = env['ODASA_TRACER_CONFIGURATION'];
|
||||
const info = { spec: config, env: {} };
|
||||
// Extract critical tracer variables from the environment
|
||||
for (let entry of Object.entries(env)) {
|
||||
const key = entry[0];
|
||||
const value = entry[1];
|
||||
// skip ODASA_TRACER_CONFIGURATION as it is handled separately
|
||||
if (key === 'ODASA_TRACER_CONFIGURATION') {
|
||||
continue;
|
||||
}
|
||||
// skip undefined values
|
||||
if (typeof value === 'undefined') {
|
||||
continue;
|
||||
}
|
||||
// Keep variables that do not exist in current environment. In addition always keep
|
||||
// critical and CODEQL_ variables
|
||||
if (typeof process.env[key] === 'undefined' || CRITICAL_TRACER_VARS.has(key) || key.startsWith('CODEQL_')) {
|
||||
info.env[key] = value;
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
function concatTracerConfigs(tracerConfigs, config) {
|
||||
// A tracer config is a map containing additional environment variables and a tracer 'spec' file.
|
||||
// A tracer 'spec' file has the following format [log_file, number_of_blocks, blocks_text]
|
||||
// Merge the environments
|
||||
const env = {};
|
||||
let copyExecutables = false;
|
||||
let envSize = 0;
|
||||
for (const v of tracerConfigs) {
|
||||
for (let e of Object.entries(v.env)) {
|
||||
const name = e[0];
|
||||
const value = e[1];
|
||||
// skip SEMMLE_COPY_EXECUTABLES_ROOT as it is handled separately
|
||||
if (name === 'SEMMLE_COPY_EXECUTABLES_ROOT') {
|
||||
copyExecutables = true;
|
||||
}
|
||||
else if (name in env) {
|
||||
if (env[name] !== value) {
|
||||
throw Error('Incompatible values in environment parameter ' +
|
||||
name + ': ' + env[name] + ' and ' + value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
env[name] = value;
|
||||
envSize += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Concatenate spec files into a new spec file
|
||||
let languages = Object.keys(tracerConfigs);
|
||||
const cppIndex = languages.indexOf('cpp');
|
||||
// Make sure cpp is the last language, if it's present since it must be concatenated last
|
||||
if (cppIndex !== -1) {
|
||||
let lastLang = languages[languages.length - 1];
|
||||
languages[languages.length - 1] = languages[cppIndex];
|
||||
languages[cppIndex] = lastLang;
|
||||
}
|
||||
let totalLines = [];
|
||||
let totalCount = 0;
|
||||
for (let lang of languages) {
|
||||
const lines = fs.readFileSync(tracerConfigs[lang].spec, 'utf8').split(/\r?\n/);
|
||||
const count = parseInt(lines[1], 10);
|
||||
totalCount += count;
|
||||
totalLines.push(...lines.slice(2));
|
||||
}
|
||||
const newLogFilePath = path.resolve(config.tempDir, 'compound-build-tracer.log');
|
||||
const spec = path.resolve(config.tempDir, 'compound-spec');
|
||||
const compoundTempFolder = path.resolve(config.tempDir, 'compound-temp');
|
||||
const newSpecContent = [newLogFilePath, totalCount.toString(10), ...totalLines];
|
||||
if (copyExecutables) {
|
||||
env['SEMMLE_COPY_EXECUTABLES_ROOT'] = compoundTempFolder;
|
||||
envSize += 1;
|
||||
}
|
||||
fs.writeFileSync(spec, newSpecContent.join('\n'));
|
||||
// Prepare the content of the compound environment file
|
||||
let buffer = Buffer.alloc(4);
|
||||
buffer.writeInt32LE(envSize, 0);
|
||||
for (let e of Object.entries(env)) {
|
||||
const key = e[0];
|
||||
const value = e[1];
|
||||
const lineBuffer = new Buffer(key + '=' + value + '\0', 'utf8');
|
||||
const sizeBuffer = Buffer.alloc(4);
|
||||
sizeBuffer.writeInt32LE(lineBuffer.length, 0);
|
||||
buffer = Buffer.concat([buffer, sizeBuffer, lineBuffer]);
|
||||
}
|
||||
// Write the compound environment
|
||||
const envPath = spec + '.environment';
|
||||
fs.writeFileSync(envPath, buffer);
|
||||
return { env, spec };
|
||||
}
|
||||
async function sendSuccessStatusReport(startedAt, config) {
|
||||
const statusReportBase = await util.createStatusReportBase('init', 'success', startedAt);
|
||||
const languages = config.languages.join(',');
|
||||
const workflowLanguages = core.getInput('languages', { required: false });
|
||||
const paths = (config.originalUserInput.paths || []).join(',');
|
||||
const pathsIgnore = (config.originalUserInput['paths-ignore'] || []).join(',');
|
||||
const disableDefaultQueries = config.originalUserInput['disable-default-queries'] ? languages : '';
|
||||
const queries = (config.originalUserInput.queries || []).map(q => q.uses).join(',');
|
||||
const statusReport = {
|
||||
...statusReportBase,
|
||||
languages: languages,
|
||||
workflow_languages: workflowLanguages,
|
||||
paths: paths,
|
||||
paths_ignore: pathsIgnore,
|
||||
disable_default_queries: disableDefaultQueries,
|
||||
queries: queries,
|
||||
};
|
||||
await util.sendStatusReport(statusReport);
|
||||
}
|
||||
async function run() {
|
||||
const startedAt = new Date();
|
||||
let config;
|
||||
let codeql;
|
||||
try {
|
||||
util.prepareLocalRunEnvironment();
|
||||
if (!await util.sendStatusReport(await util.createStatusReportBase('init', 'starting', startedAt), true)) {
|
||||
return;
|
||||
}
|
||||
core.startGroup('Setup CodeQL tools');
|
||||
codeql = await codeql_1.setupCodeQL();
|
||||
await codeql.printVersion();
|
||||
core.endGroup();
|
||||
core.startGroup('Load language configuration');
|
||||
config = await configUtils.initConfig(util.getRequiredEnvParam('RUNNER_TEMP'), util.getRequiredEnvParam('RUNNER_TOOL_CACHE'), codeql);
|
||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||
core.endGroup();
|
||||
}
|
||||
catch (e) {
|
||||
core.setFailed(e.message);
|
||||
console.log(e);
|
||||
await util.sendStatusReport(await util.createStatusReportBase('init', 'aborted', startedAt, e.message));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const sourceRoot = path.resolve();
|
||||
// Forward Go flags
|
||||
const goFlags = process.env['GOFLAGS'];
|
||||
if (goFlags) {
|
||||
core.exportVariable('GOFLAGS', goFlags);
|
||||
core.warning("Passing the GOFLAGS env parameter to the init action is deprecated. Please move this to the analyze action.");
|
||||
}
|
||||
// Setup CODEQL_RAM flag (todo improve this https://github.com/github/dsp-code-scanning/issues/935)
|
||||
const codeqlRam = process.env['CODEQL_RAM'] || '6500';
|
||||
core.exportVariable('CODEQL_RAM', codeqlRam);
|
||||
const databaseFolder = util.getCodeQLDatabasesDir(config.tempDir);
|
||||
fs.mkdirSync(databaseFolder, { recursive: true });
|
||||
let tracedLanguageConfigs = [];
|
||||
// TODO: replace this code once CodeQL supports multi-language tracing
|
||||
for (let language of config.languages) {
|
||||
const languageDatabase = path.join(databaseFolder, language);
|
||||
// Init language database
|
||||
await codeql.databaseInit(languageDatabase, language, sourceRoot);
|
||||
// TODO: add better detection of 'traced languages' instead of using a hard coded list
|
||||
if (languages_1.isTracedLanguage(language)) {
|
||||
const config = await tracerConfig(codeql, languageDatabase);
|
||||
tracedLanguageConfigs.push(config);
|
||||
}
|
||||
}
|
||||
if (tracedLanguageConfigs.length > 0) {
|
||||
const mainTracerConfig = concatTracerConfigs(tracedLanguageConfigs, config);
|
||||
if (mainTracerConfig.spec) {
|
||||
for (let entry of Object.entries(mainTracerConfig.env)) {
|
||||
core.exportVariable(entry[0], entry[1]);
|
||||
}
|
||||
core.exportVariable('ODASA_TRACER_CONFIGURATION', mainTracerConfig.spec);
|
||||
const codeQLDir = path.dirname(codeql.getPath());
|
||||
if (process.platform === 'darwin') {
|
||||
core.exportVariable('DYLD_INSERT_LIBRARIES', path.join(codeQLDir, 'tools', 'osx64', 'libtrace.dylib'));
|
||||
}
|
||||
else if (process.platform === 'win32') {
|
||||
await exec.exec('powershell', [
|
||||
path.resolve(__dirname, '..', 'src', 'inject-tracer.ps1'),
|
||||
path.resolve(codeQLDir, 'tools', 'win64', 'tracer.exe'),
|
||||
], { env: { 'ODASA_TRACER_CONFIGURATION': mainTracerConfig.spec } });
|
||||
}
|
||||
else {
|
||||
core.exportVariable('LD_PRELOAD', path.join(codeQLDir, 'tools', 'linux64', '${LIB}trace.so'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
console.log(error);
|
||||
await util.sendStatusReport(await util.createStatusReportBase('init', 'failure', startedAt, error.message, error.stack));
|
||||
return;
|
||||
}
|
||||
await sendSuccessStatusReport(startedAt, config);
|
||||
}
|
||||
run().catch(e => {
|
||||
core.setFailed("init action failed: " + e);
|
||||
console.log(e);
|
||||
});
|
||||
//# sourceMappingURL=setup-tracer.js.map
|
||||
File diff suppressed because one or more lines are too long
22
lib/test-utils.js
generated
22
lib/test-utils.js
generated
|
|
@ -1,22 +0,0 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function silenceDebugOutput(test) {
|
||||
const typedTest = test;
|
||||
typedTest.beforeEach(t => {
|
||||
const processStdoutWrite = process.stdout.write.bind(process.stdout);
|
||||
t.context.write = processStdoutWrite;
|
||||
process.stdout.write = (str, encoding, cb) => {
|
||||
// Core library will directly call process.stdout.write for commands
|
||||
// We don't want :: commands to be executed by the runner during tests
|
||||
if (!str.match(/^::/)) {
|
||||
processStdoutWrite(str, encoding, cb);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
});
|
||||
typedTest.afterEach(t => {
|
||||
process.stdout.write = t.context.write;
|
||||
});
|
||||
}
|
||||
exports.silenceDebugOutput = silenceDebugOutput;
|
||||
//# sourceMappingURL=test-utils.js.map
|
||||
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":";;AAEA,SAAgB,kBAAkB,CAAC,IAAwB;IACzD,MAAM,SAAS,GAAG,IAAmC,CAAC;IAEtD,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;QACrB,MAAM,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACrE,CAAC,CAAC,OAAO,CAAC,KAAK,GAAG,kBAAkB,CAAC;QACrC,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,GAAQ,EAAE,QAAc,EAAE,EAA0B,EAAE,EAAE;YAC5E,oEAAoE;YACpE,sEAAsE;YACtE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;gBACnB,kBAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;aACzC;YACD,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;QACpB,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IAC3C,CAAC,CAAC,CAAC;AACL,CAAC;AAnBD,gDAmBC"}
|
||||
143
lib/tracer-config.js
generated
Normal file
143
lib/tracer-config.js
generated
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
"use strict";
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const languages_1 = require("./languages");
|
||||
const util = __importStar(require("./util"));
|
||||
const CRITICAL_TRACER_VARS = new Set(['SEMMLE_PRELOAD_libtrace',
|
||||
,
|
||||
'SEMMLE_RUNNER',
|
||||
,
|
||||
'SEMMLE_COPY_EXECUTABLES_ROOT',
|
||||
,
|
||||
'SEMMLE_DEPTRACE_SOCKET',
|
||||
,
|
||||
'SEMMLE_JAVA_TOOL_OPTIONS'
|
||||
]);
|
||||
async function getTracerConfigForLanguage(codeql, config, language) {
|
||||
const env = await codeql.getTracerEnv(util.getCodeQLDatabasePath(config.tempDir, language));
|
||||
const spec = env['ODASA_TRACER_CONFIGURATION'];
|
||||
const info = { spec, env: {} };
|
||||
// Extract critical tracer variables from the environment
|
||||
for (let entry of Object.entries(env)) {
|
||||
const key = entry[0];
|
||||
const value = entry[1];
|
||||
// skip ODASA_TRACER_CONFIGURATION as it is handled separately
|
||||
if (key === 'ODASA_TRACER_CONFIGURATION') {
|
||||
continue;
|
||||
}
|
||||
// skip undefined values
|
||||
if (typeof value === 'undefined') {
|
||||
continue;
|
||||
}
|
||||
// Keep variables that do not exist in current environment. In addition always keep
|
||||
// critical and CODEQL_ variables
|
||||
if (typeof process.env[key] === 'undefined' || CRITICAL_TRACER_VARS.has(key) || key.startsWith('CODEQL_')) {
|
||||
info.env[key] = value;
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
exports.getTracerConfigForLanguage = getTracerConfigForLanguage;
|
||||
function concatTracerConfigs(tracerConfigs, config) {
|
||||
// A tracer config is a map containing additional environment variables and a tracer 'spec' file.
|
||||
// A tracer 'spec' file has the following format [log_file, number_of_blocks, blocks_text]
|
||||
// Merge the environments
|
||||
const env = {};
|
||||
let copyExecutables = false;
|
||||
let envSize = 0;
|
||||
for (const v of Object.values(tracerConfigs)) {
|
||||
for (let e of Object.entries(v.env)) {
|
||||
const name = e[0];
|
||||
const value = e[1];
|
||||
// skip SEMMLE_COPY_EXECUTABLES_ROOT as it is handled separately
|
||||
if (name === 'SEMMLE_COPY_EXECUTABLES_ROOT') {
|
||||
copyExecutables = true;
|
||||
}
|
||||
else if (name in env) {
|
||||
if (env[name] !== value) {
|
||||
throw Error('Incompatible values in environment parameter ' +
|
||||
name + ': ' + env[name] + ' and ' + value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
env[name] = value;
|
||||
envSize += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Concatenate spec files into a new spec file
|
||||
let languages = Object.keys(tracerConfigs);
|
||||
const cppIndex = languages.indexOf('cpp');
|
||||
// Make sure cpp is the last language, if it's present since it must be concatenated last
|
||||
if (cppIndex !== -1) {
|
||||
let lastLang = languages[languages.length - 1];
|
||||
languages[languages.length - 1] = languages[cppIndex];
|
||||
languages[cppIndex] = lastLang;
|
||||
}
|
||||
let totalLines = [];
|
||||
let totalCount = 0;
|
||||
for (let lang of languages) {
|
||||
const lines = fs.readFileSync(tracerConfigs[lang].spec, 'utf8').split(/\r?\n/);
|
||||
const count = parseInt(lines[1], 10);
|
||||
totalCount += count;
|
||||
totalLines.push(...lines.slice(2));
|
||||
}
|
||||
const newLogFilePath = path.resolve(config.tempDir, 'compound-build-tracer.log');
|
||||
const spec = path.resolve(config.tempDir, 'compound-spec');
|
||||
const compoundTempFolder = path.resolve(config.tempDir, 'compound-temp');
|
||||
const newSpecContent = [newLogFilePath, totalCount.toString(10), ...totalLines];
|
||||
if (copyExecutables) {
|
||||
env['SEMMLE_COPY_EXECUTABLES_ROOT'] = compoundTempFolder;
|
||||
envSize += 1;
|
||||
}
|
||||
fs.writeFileSync(spec, newSpecContent.join('\n'));
|
||||
// Prepare the content of the compound environment file
|
||||
let buffer = Buffer.alloc(4);
|
||||
buffer.writeInt32LE(envSize, 0);
|
||||
for (let e of Object.entries(env)) {
|
||||
const key = e[0];
|
||||
const value = e[1];
|
||||
const lineBuffer = new Buffer(key + '=' + value + '\0', 'utf8');
|
||||
const sizeBuffer = Buffer.alloc(4);
|
||||
sizeBuffer.writeInt32LE(lineBuffer.length, 0);
|
||||
buffer = Buffer.concat([buffer, sizeBuffer, lineBuffer]);
|
||||
}
|
||||
// Write the compound environment
|
||||
const envPath = spec + '.environment';
|
||||
fs.writeFileSync(envPath, buffer);
|
||||
return { env, spec };
|
||||
}
|
||||
exports.concatTracerConfigs = concatTracerConfigs;
|
||||
async function getCombinedTracerConfig(config, codeql) {
|
||||
// Abort if there are no traced languages as there's nothing to do
|
||||
const tracedLanguages = config.languages.filter(languages_1.isTracedLanguage);
|
||||
if (tracedLanguages.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
// Get all the tracer configs and combine them together
|
||||
const tracedLanguageConfigs = {};
|
||||
for (const language of tracedLanguages) {
|
||||
tracedLanguageConfigs[language] = await getTracerConfigForLanguage(codeql, config, language);
|
||||
}
|
||||
const mainTracerConfig = concatTracerConfigs(tracedLanguageConfigs, config);
|
||||
// Add a couple more variables
|
||||
mainTracerConfig.env['ODASA_TRACER_CONFIGURATION'] = mainTracerConfig.spec;
|
||||
const codeQLDir = path.dirname(codeql.getPath());
|
||||
if (process.platform === 'darwin') {
|
||||
mainTracerConfig.env['DYLD_INSERT_LIBRARIES'] = path.join(codeQLDir, 'tools', 'osx64', 'libtrace.dylib');
|
||||
}
|
||||
else if (process.platform !== 'win32') {
|
||||
mainTracerConfig.env['LD_PRELOAD'] = path.join(codeQLDir, 'tools', 'linux64', '${LIB}trace.so');
|
||||
}
|
||||
return mainTracerConfig;
|
||||
}
|
||||
exports.getCombinedTracerConfig = getCombinedTracerConfig;
|
||||
//# sourceMappingURL=tracer-config.js.map
|
||||
1
lib/tracer-config.js.map
Normal file
1
lib/tracer-config.js.map
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"tracer-config.js","sourceRoot":"","sources":["../src/tracer-config.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAI7B,2CAAyD;AACzD,6CAA+B;AAO/B,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAClC,CAAC,yBAAyB;IACxB,AADyB;IACvB,eAAe;IACjB,AADkB;IAChB,8BAA8B;IAChC,AADiC;IAC/B,wBAAwB;IAC1B,AAD2B;IACzB,0BAA0B;CAC7B,CAAC,CAAC;AAEE,KAAK,UAAU,0BAA0B,CAC9C,MAAc,EACd,MAA0B,EAC1B,QAAkB;IAElB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE5F,MAAM,IAAI,GAAG,GAAG,CAAC,4BAA4B,CAAC,CAAC;IAC/C,MAAM,IAAI,GAAiB,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;IAE7C,yDAAyD;IACzD,KAAK,IAAI,KAAK,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACrC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACrB,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACvB,8DAA8D;QAC9D,IAAI,GAAG,KAAK,4BAA4B,E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1B,MAAc;IAEd,kEAAkE;IAClE,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,4BAAgB,CAAC,CAAC;IAClE,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE;QAChC,OAAO,SAAS,CAAC;KAClB;IAED,uDAAuD;IACvD,MAAM,qBAAqB,GAAqC,EAAE,CAAC;IACnE,KAAK,MAAM,QAAQ,IAAI,eAAe,EAAE;QACtC,qBAAqB,CAAC,QAAQ,CAAC,GAAG,MAAM,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;KAC9F;IACD,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IAE5E,8BAA8B;IAC9B,gBAAgB,CAAC,GAAG,CAAC,4BAA4B,CAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC;IAC3E,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IACjD,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE;QACjC,gBAAgB,CAAC,GAAG,CAAC,uBAAuB,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC;KAC1G;SAAM,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;QACvC,gBAAgB,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC;KACjG;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AA3BD,0DA2BC"}
|
||||
278
lib/tracer-config.test.js
generated
Normal file
278
lib/tracer-config.test.js
generated
Normal file
|
|
@ -0,0 +1,278 @@
|
|||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const ava_1 = __importDefault(require("ava"));
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const codeql_1 = require("./codeql");
|
||||
const languages_1 = require("./languages");
|
||||
const testing_utils_1 = require("./testing-utils");
|
||||
const tracer_config_1 = require("./tracer-config");
|
||||
const util = __importStar(require("./util"));
|
||||
testing_utils_1.setupTests(ava_1.default);
|
||||
function getTestConfig(tmpDir) {
|
||||
return {
|
||||
languages: [languages_1.Language.java],
|
||||
queries: {},
|
||||
pathsIgnore: [],
|
||||
paths: [],
|
||||
originalUserInput: {},
|
||||
tempDir: tmpDir,
|
||||
toolCacheDir: tmpDir,
|
||||
codeQLCmd: '',
|
||||
};
|
||||
}
|
||||
// A very minimal setup
|
||||
ava_1.default('getTracerConfigForLanguage - minimal setup', async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
const config = getTestConfig(tmpDir);
|
||||
const codeQL = codeql_1.setCodeQL({
|
||||
getTracerEnv: async function () {
|
||||
return {
|
||||
'ODASA_TRACER_CONFIGURATION': 'abc',
|
||||
'foo': 'bar'
|
||||
};
|
||||
},
|
||||
});
|
||||
const result = await tracer_config_1.getTracerConfigForLanguage(codeQL, config, languages_1.Language.javascript);
|
||||
t.deepEqual(result, { spec: 'abc', env: { 'foo': 'bar' } });
|
||||
});
|
||||
});
|
||||
// Existing vars should not be overwritten, unless they are critical or prefixed with CODEQL_
|
||||
ava_1.default('getTracerConfigForLanguage - existing / critical vars', async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
const config = getTestConfig(tmpDir);
|
||||
// Set up some variables in the environment
|
||||
process.env['foo'] = 'abc';
|
||||
process.env['SEMMLE_PRELOAD_libtrace'] = 'abc';
|
||||
process.env['SEMMLE_RUNNER'] = 'abc';
|
||||
process.env['SEMMLE_COPY_EXECUTABLES_ROOT'] = 'abc';
|
||||
process.env['SEMMLE_DEPTRACE_SOCKET'] = 'abc';
|
||||
process.env['SEMMLE_JAVA_TOOL_OPTIONS'] = 'abc';
|
||||
process.env['SEMMLE_DEPTRACE_SOCKET'] = 'abc';
|
||||
process.env['CODEQL_VAR'] = 'abc';
|
||||
// Now CodeQL returns all these variables, and one more, with different values
|
||||
const codeQL = codeql_1.setCodeQL({
|
||||
getTracerEnv: async function () {
|
||||
return {
|
||||
'ODASA_TRACER_CONFIGURATION': 'abc',
|
||||
'foo': 'bar',
|
||||
'baz': 'qux',
|
||||
'SEMMLE_PRELOAD_libtrace': 'SEMMLE_PRELOAD_libtrace',
|
||||
'SEMMLE_RUNNER': 'SEMMLE_RUNNER',
|
||||
'SEMMLE_COPY_EXECUTABLES_ROOT': 'SEMMLE_COPY_EXECUTABLES_ROOT',
|
||||
'SEMMLE_DEPTRACE_SOCKET': 'SEMMLE_DEPTRACE_SOCKET',
|
||||
'SEMMLE_JAVA_TOOL_OPTIONS': 'SEMMLE_JAVA_TOOL_OPTIONS',
|
||||
'CODEQL_VAR': 'CODEQL_VAR',
|
||||
};
|
||||
},
|
||||
});
|
||||
const result = await tracer_config_1.getTracerConfigForLanguage(codeQL, config, languages_1.Language.javascript);
|
||||
t.deepEqual(result, {
|
||||
spec: 'abc',
|
||||
env: {
|
||||
// Should contain all variables except 'foo', because that already existed in the
|
||||
// environment with a different value, and is not deemed a "critical" variable.
|
||||
'baz': 'qux',
|
||||
'SEMMLE_PRELOAD_libtrace': 'SEMMLE_PRELOAD_libtrace',
|
||||
'SEMMLE_RUNNER': 'SEMMLE_RUNNER',
|
||||
'SEMMLE_COPY_EXECUTABLES_ROOT': 'SEMMLE_COPY_EXECUTABLES_ROOT',
|
||||
'SEMMLE_DEPTRACE_SOCKET': 'SEMMLE_DEPTRACE_SOCKET',
|
||||
'SEMMLE_JAVA_TOOL_OPTIONS': 'SEMMLE_JAVA_TOOL_OPTIONS',
|
||||
'CODEQL_VAR': 'CODEQL_VAR',
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
ava_1.default('concatTracerConfigs - minimal configs correctly combined', async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
const config = getTestConfig(tmpDir);
|
||||
const spec1 = path.join(tmpDir, 'spec1');
|
||||
fs.writeFileSync(spec1, 'foo.log\n2\nabc\ndef');
|
||||
const tc1 = {
|
||||
spec: spec1,
|
||||
env: {
|
||||
'a': 'a',
|
||||
'b': 'b',
|
||||
}
|
||||
};
|
||||
const spec2 = path.join(tmpDir, 'spec2');
|
||||
fs.writeFileSync(spec2, 'foo.log\n1\nghi');
|
||||
const tc2 = {
|
||||
spec: spec2,
|
||||
env: {
|
||||
'c': 'c',
|
||||
}
|
||||
};
|
||||
const result = tracer_config_1.concatTracerConfigs({ 'javascript': tc1, 'python': tc2 }, config);
|
||||
t.deepEqual(result, {
|
||||
spec: path.join(tmpDir, 'compound-spec'),
|
||||
env: {
|
||||
'a': 'a',
|
||||
'b': 'b',
|
||||
'c': 'c',
|
||||
}
|
||||
});
|
||||
t.true(fs.existsSync(result.spec));
|
||||
t.deepEqual(fs.readFileSync(result.spec, 'utf8'), path.join(tmpDir, 'compound-build-tracer.log') + '\n3\nabc\ndef\nghi');
|
||||
});
|
||||
});
|
||||
ava_1.default('concatTracerConfigs - conflicting env vars', async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
const config = getTestConfig(tmpDir);
|
||||
const spec = path.join(tmpDir, 'spec');
|
||||
fs.writeFileSync(spec, 'foo.log\n0');
|
||||
// Ok if env vars have the same name and the same value
|
||||
t.deepEqual(tracer_config_1.concatTracerConfigs({
|
||||
'javascript': { spec: spec, env: { 'a': 'a', 'b': 'b' } },
|
||||
'python': { spec: spec, env: { 'b': 'b', 'c': 'c' } },
|
||||
}, config).env, {
|
||||
'a': 'a',
|
||||
'b': 'b',
|
||||
'c': 'c',
|
||||
});
|
||||
// Throws if env vars have same name but different values
|
||||
const e = t.throws(() => tracer_config_1.concatTracerConfigs({
|
||||
'javascript': { spec: spec, env: { 'a': 'a', 'b': 'b' } },
|
||||
'python': { spec: spec, env: { 'b': 'c' } },
|
||||
}, config));
|
||||
t.deepEqual(e.message, 'Incompatible values in environment parameter b: b and c');
|
||||
});
|
||||
});
|
||||
ava_1.default('concatTracerConfigs - cpp spec lines come last if present', async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
const config = getTestConfig(tmpDir);
|
||||
const spec1 = path.join(tmpDir, 'spec1');
|
||||
fs.writeFileSync(spec1, 'foo.log\n2\nabc\ndef');
|
||||
const tc1 = {
|
||||
spec: spec1,
|
||||
env: {
|
||||
'a': 'a',
|
||||
'b': 'b',
|
||||
}
|
||||
};
|
||||
const spec2 = path.join(tmpDir, 'spec2');
|
||||
fs.writeFileSync(spec2, 'foo.log\n1\nghi');
|
||||
const tc2 = {
|
||||
spec: spec2,
|
||||
env: {
|
||||
'c': 'c',
|
||||
}
|
||||
};
|
||||
const result = tracer_config_1.concatTracerConfigs({ 'cpp': tc1, 'python': tc2 }, config);
|
||||
t.deepEqual(result, {
|
||||
spec: path.join(tmpDir, 'compound-spec'),
|
||||
env: {
|
||||
'a': 'a',
|
||||
'b': 'b',
|
||||
'c': 'c',
|
||||
}
|
||||
});
|
||||
t.true(fs.existsSync(result.spec));
|
||||
t.deepEqual(fs.readFileSync(result.spec, 'utf8'), path.join(tmpDir, 'compound-build-tracer.log') + '\n3\nghi\nabc\ndef');
|
||||
});
|
||||
});
|
||||
ava_1.default('concatTracerConfigs - SEMMLE_COPY_EXECUTABLES_ROOT is updated to point to compound spec', async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
const config = getTestConfig(tmpDir);
|
||||
const spec = path.join(tmpDir, 'spec');
|
||||
fs.writeFileSync(spec, 'foo.log\n0');
|
||||
const result = tracer_config_1.concatTracerConfigs({
|
||||
'javascript': { spec: spec, env: { 'a': 'a', 'b': 'b' } },
|
||||
'python': { spec: spec, env: { 'SEMMLE_COPY_EXECUTABLES_ROOT': 'foo' } },
|
||||
}, config);
|
||||
t.deepEqual(result.env, {
|
||||
'a': 'a',
|
||||
'b': 'b',
|
||||
'SEMMLE_COPY_EXECUTABLES_ROOT': path.join(tmpDir, 'compound-temp')
|
||||
});
|
||||
});
|
||||
});
|
||||
ava_1.default('concatTracerConfigs - compound environment file is created correctly', async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
const config = getTestConfig(tmpDir);
|
||||
const spec1 = path.join(tmpDir, 'spec1');
|
||||
fs.writeFileSync(spec1, 'foo.log\n2\nabc\ndef');
|
||||
const tc1 = {
|
||||
spec: spec1,
|
||||
env: {
|
||||
'a': 'a',
|
||||
}
|
||||
};
|
||||
const spec2 = path.join(tmpDir, 'spec2');
|
||||
fs.writeFileSync(spec2, 'foo.log\n1\nghi');
|
||||
const tc2 = {
|
||||
spec: spec2,
|
||||
env: {
|
||||
'foo': 'bar_baz',
|
||||
}
|
||||
};
|
||||
const result = tracer_config_1.concatTracerConfigs({ 'javascript': tc1, 'python': tc2 }, config);
|
||||
const envPath = result.spec + '.environment';
|
||||
t.true(fs.existsSync(envPath));
|
||||
const buffer = fs.readFileSync(envPath);
|
||||
// Contents is binary data
|
||||
t.deepEqual(buffer.length, 28);
|
||||
t.deepEqual(buffer.readInt32LE(0), 2); // number of env vars
|
||||
t.deepEqual(buffer.readInt32LE(4), 4); // length of env var definition
|
||||
t.deepEqual(buffer.toString('utf8', 8, 12), 'a=a\0'); // [key]=[value]\0
|
||||
t.deepEqual(buffer.readInt32LE(12), 12); // length of env var definition
|
||||
t.deepEqual(buffer.toString('utf8', 16, 28), 'foo=bar_baz\0'); // [key]=[value]\0
|
||||
});
|
||||
});
|
||||
ava_1.default('getCombinedTracerConfig - return undefined when no languages are traced languages', async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
const config = getTestConfig(tmpDir);
|
||||
// No traced languages
|
||||
config.languages = [languages_1.Language.javascript, languages_1.Language.python];
|
||||
const codeQL = codeql_1.setCodeQL({
|
||||
getTracerEnv: async function () {
|
||||
return {
|
||||
'ODASA_TRACER_CONFIGURATION': 'abc',
|
||||
'foo': 'bar'
|
||||
};
|
||||
},
|
||||
});
|
||||
t.deepEqual(await tracer_config_1.getCombinedTracerConfig(config, codeQL), undefined);
|
||||
});
|
||||
});
|
||||
ava_1.default('getCombinedTracerConfig - valid spec file', async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
const config = getTestConfig(tmpDir);
|
||||
const spec = path.join(tmpDir, 'spec');
|
||||
fs.writeFileSync(spec, 'foo.log\n2\nabc\ndef');
|
||||
const codeQL = codeql_1.setCodeQL({
|
||||
getTracerEnv: async function () {
|
||||
return {
|
||||
'ODASA_TRACER_CONFIGURATION': spec,
|
||||
'foo': 'bar',
|
||||
};
|
||||
},
|
||||
});
|
||||
const result = await tracer_config_1.getCombinedTracerConfig(config, codeQL);
|
||||
const expectedEnv = {
|
||||
'foo': 'bar',
|
||||
'ODASA_TRACER_CONFIGURATION': result.spec,
|
||||
};
|
||||
if (process.platform === 'darwin') {
|
||||
expectedEnv['DYLD_INSERT_LIBRARIES'] = path.join(path.dirname(codeQL.getPath()), 'tools', 'osx64', 'libtrace.dylib');
|
||||
}
|
||||
else if (process.platform !== 'win32') {
|
||||
expectedEnv['LD_PRELOAD'] = path.join(path.dirname(codeQL.getPath()), 'tools', 'linux64', '${LIB}trace.so');
|
||||
}
|
||||
t.deepEqual(result, {
|
||||
spec: path.join(tmpDir, 'compound-spec'),
|
||||
env: expectedEnv,
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=tracer-config.test.js.map
|
||||
1
lib/tracer-config.test.js.map
Normal file
1
lib/tracer-config.test.js.map
Normal file
File diff suppressed because one or more lines are too long
2
lib/upload-lib.js
generated
2
lib/upload-lib.js
generated
|
|
@ -154,7 +154,7 @@ exports.validateSarifFileSchema = validateSarifFileSchema;
|
|||
async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKey, analysisName, workflowRunID, checkoutPath, environment, githubAuth, githubApiUrl, mode, logger) {
|
||||
logger.info("Uploading sarif files: " + JSON.stringify(sarifFiles));
|
||||
if (mode === 'actions') {
|
||||
// This check only works on actions as env vars don't persist between calls to the CLI
|
||||
// This check only works on actions as env vars don't persist between calls to the runner
|
||||
const sentinelEnvVar = "CODEQL_UPLOAD_SARIF";
|
||||
if (process.env[sentinelEnvVar]) {
|
||||
throw new Error("Aborting upload: only one run of the codeql/analyze or codeql/upload-sarif actions is allowed per job");
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
4
lib/upload-lib.test.js
generated
4
lib/upload-lib.test.js
generated
|
|
@ -17,10 +17,10 @@ const uploadLib = __importStar(require("./upload-lib"));
|
|||
testing_utils_1.setupTests(ava_1.default);
|
||||
ava_1.default('validateSarifFileSchema - valid', t => {
|
||||
const inputFile = __dirname + '/../src/testdata/valid-sarif.sarif';
|
||||
t.notThrows(() => uploadLib.validateSarifFileSchema(inputFile, logging_1.getCLILogger()));
|
||||
t.notThrows(() => uploadLib.validateSarifFileSchema(inputFile, logging_1.getRunnerLogger()));
|
||||
});
|
||||
ava_1.default('validateSarifFileSchema - invalid', t => {
|
||||
const inputFile = __dirname + '/../src/testdata/invalid-sarif.sarif';
|
||||
t.throws(() => uploadLib.validateSarifFileSchema(inputFile, logging_1.getCLILogger()));
|
||||
t.throws(() => uploadLib.validateSarifFileSchema(inputFile, logging_1.getRunnerLogger()));
|
||||
});
|
||||
//# sourceMappingURL=upload-lib.test.js.map
|
||||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"upload-lib.test.js","sourceRoot":"","sources":["../src/upload-lib.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8C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,CAAC;AAClF,CAAC,CAAC,CAAC"}
|
||||
2
lib/upload-sarif.js → lib/upload-sarif-action.js
generated
2
lib/upload-sarif.js → lib/upload-sarif-action.js
generated
|
|
@ -40,4 +40,4 @@ run().catch(e => {
|
|||
core.setFailed("codeql/upload-sarif action failed: " + e);
|
||||
console.log(e);
|
||||
});
|
||||
//# sourceMappingURL=upload-sarif.js.map
|
||||
//# sourceMappingURL=upload-sarif-action.js.map
|
||||
1
lib/upload-sarif-action.js.map
Normal file
1
lib/upload-sarif-action.js.map
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"upload-sarif-action.js","sourceRoot":"","sources":["../src/upload-sarif-action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAEtC,uCAA6C;AAC7C,6CAAkD;AAClD,yDAA2C;AAC3C,6CAA+B;AAI/B,KAAK,UAAU,uBAAuB,CAAC,SAAe,EAAE,WAA0C;IAChG,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,cAAc,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IACjG,MAAM,YAAY,GAA4B;QAC5C,GAAG,gBAAgB;QACnB,GAAI,WAAW;KAChB,CAAC;IACF,MAAM,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AAC5C,CAAC;AAED,KAAK,UAAU,GAAG;IAChB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,IAAI,CAAC,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,IAAI,CAAC,sBAAsB,CAAC,cAAc,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE,IAAI,CAAC,EAAE;QAChH,OAAO;KACR;IAED,IAAI;QACF,MAAM,WAAW,GAAG,MAAM,UAAU,CAAC,MAAM,CACzC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,EAC3B,+BAAkB,CAAC,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,CAAC,EACjE,MA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C;QACnB,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,IAAI,CAAC,sBAAsB,CAC3D,cAAc,EACd,SAAS,EACT,SAAS,EACT,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QAChB,OAAO;KACR;AACH,CAAC;AAED,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;IACd,IAAI,CAAC,SAAS,CAAC,qCAAqC,GAAG,CAAC,CAAC,CAAC;IAC1D,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC,CAAC"}
|
||||
7
lib/util.js
generated
7
lib/util.js
generated
|
|
@ -378,4 +378,11 @@ function getCodeQLDatabasesDir(tempDir) {
|
|||
return path.resolve(tempDir, 'codeql_databases');
|
||||
}
|
||||
exports.getCodeQLDatabasesDir = getCodeQLDatabasesDir;
|
||||
/**
|
||||
* Get the path where the CodeQL database for the given language lives.
|
||||
*/
|
||||
function getCodeQLDatabasePath(tempDir, language) {
|
||||
return path.resolve(getCodeQLDatabasesDir(tempDir), language);
|
||||
}
|
||||
exports.getCodeQLDatabasePath = getCodeQLDatabasePath;
|
||||
//# sourceMappingURL=util.js.map
|
||||
File diff suppressed because one or more lines are too long
1
node_modules/.bin/atob
generated
vendored
1
node_modules/.bin/atob
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../atob/bin/atob.js
|
||||
1
node_modules/.bin/errno
generated
vendored
1
node_modules/.bin/errno
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../errno/cli.js
|
||||
1
node_modules/.bin/json5
generated
vendored
1
node_modules/.bin/json5
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../json5/lib/cli.js
|
||||
1
node_modules/.bin/miller-rabin
generated
vendored
1
node_modules/.bin/miller-rabin
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../miller-rabin/bin/miller-rabin
|
||||
1
node_modules/.bin/sha.js
generated
vendored
1
node_modules/.bin/sha.js
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../sha.js/bin.js
|
||||
1
node_modules/.bin/terser
generated
vendored
1
node_modules/.bin/terser
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../terser/bin/terser
|
||||
1
node_modules/.bin/webpack
generated
vendored
1
node_modules/.bin/webpack
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../webpack/bin/webpack.js
|
||||
1
node_modules/.bin/webpack-cli
generated
vendored
1
node_modules/.bin/webpack-cli
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../webpack-cli/bin/cli.js
|
||||
21
node_modules/@webassemblyjs/ast/LICENSE
generated
vendored
21
node_modules/@webassemblyjs/ast/LICENSE
generated
vendored
|
|
@ -1,21 +0,0 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2018 Sven Sauleau <sven@sauleau.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
167
node_modules/@webassemblyjs/ast/README.md
generated
vendored
167
node_modules/@webassemblyjs/ast/README.md
generated
vendored
|
|
@ -1,167 +0,0 @@
|
|||
# @webassemblyjs/ast
|
||||
|
||||
> AST utils for webassemblyjs
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
yarn add @webassemblyjs/ast
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Traverse
|
||||
|
||||
```js
|
||||
import { traverse } from "@webassemblyjs/ast";
|
||||
|
||||
traverse(ast, {
|
||||
Module(path) {
|
||||
console.log(path.node);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Instruction signatures
|
||||
|
||||
```js
|
||||
import { signatures } from "@webassemblyjs/ast";
|
||||
|
||||
console.log(signatures);
|
||||
```
|
||||
|
||||
### Path methods
|
||||
|
||||
- `findParent: NodeLocator`
|
||||
- `replaceWith: Node => void`
|
||||
- `remove: () => void`
|
||||
- `insertBefore: Node => void`
|
||||
- `insertAfter: Node => void`
|
||||
- `stop: () => void`
|
||||
|
||||
### AST utils
|
||||
|
||||
- function `module(id, fields, metadata)`
|
||||
- function `moduleMetadata(sections, functionNames, localNames)`
|
||||
- function `moduleNameMetadata(value)`
|
||||
- function `functionNameMetadata(value, index)`
|
||||
- function `localNameMetadata(value, localIndex, functionIndex)`
|
||||
- function `binaryModule(id, blob)`
|
||||
- function `quoteModule(id, string)`
|
||||
- function `sectionMetadata(section, startOffset, size, vectorOfSize)`
|
||||
- function `loopInstruction(label, resulttype, instr)`
|
||||
- function `instruction(id, args, namedArgs)`
|
||||
- function `objectInstruction(id, object, args, namedArgs)`
|
||||
- function `ifInstruction(testLabel, test, result, consequent, alternate)`
|
||||
- function `stringLiteral(value)`
|
||||
- function `numberLiteralFromRaw(value, raw)`
|
||||
- function `longNumberLiteral(value, raw)`
|
||||
- function `floatLiteral(value, nan, inf, raw)`
|
||||
- function `elem(table, offset, funcs)`
|
||||
- function `indexInFuncSection(index)`
|
||||
- function `valtypeLiteral(name)`
|
||||
- function `typeInstruction(id, functype)`
|
||||
- function `start(index)`
|
||||
- function `globalType(valtype, mutability)`
|
||||
- function `leadingComment(value)`
|
||||
- function `blockComment(value)`
|
||||
- function `data(memoryIndex, offset, init)`
|
||||
- function `global(globalType, init, name)`
|
||||
- function `table(elementType, limits, name, elements)`
|
||||
- function `memory(limits, id)`
|
||||
- function `funcImportDescr(id, signature)`
|
||||
- function `moduleImport(module, name, descr)`
|
||||
- function `moduleExportDescr(exportType, id)`
|
||||
- function `moduleExport(name, descr)`
|
||||
- function `limit(min, max)`
|
||||
- function `signature(params, results)`
|
||||
- function `program(body)`
|
||||
- function `identifier(value, raw)`
|
||||
- function `blockInstruction(label, instr, result)`
|
||||
- function `callInstruction(index, instrArgs)`
|
||||
- function `callIndirectInstruction(signature, intrs)`
|
||||
- function `byteArray(values)`
|
||||
- function `func(name, signature, body, isExternal, metadata)`
|
||||
- Constant`isModule`
|
||||
- Constant`isModuleMetadata`
|
||||
- Constant`isModuleNameMetadata`
|
||||
- Constant`isFunctionNameMetadata`
|
||||
- Constant`isLocalNameMetadata`
|
||||
- Constant`isBinaryModule`
|
||||
- Constant`isQuoteModule`
|
||||
- Constant`isSectionMetadata`
|
||||
- Constant`isLoopInstruction`
|
||||
- Constant`isInstruction`
|
||||
- Constant`isObjectInstruction`
|
||||
- Constant`isIfInstruction`
|
||||
- Constant`isStringLiteral`
|
||||
- Constant`isNumberLiteral`
|
||||
- Constant`isLongNumberLiteral`
|
||||
- Constant`isFloatLiteral`
|
||||
- Constant`isElem`
|
||||
- Constant`isIndexInFuncSection`
|
||||
- Constant`isValtypeLiteral`
|
||||
- Constant`isTypeInstruction`
|
||||
- Constant`isStart`
|
||||
- Constant`isGlobalType`
|
||||
- Constant`isLeadingComment`
|
||||
- Constant`isBlockComment`
|
||||
- Constant`isData`
|
||||
- Constant`isGlobal`
|
||||
- Constant`isTable`
|
||||
- Constant`isMemory`
|
||||
- Constant`isFuncImportDescr`
|
||||
- Constant`isModuleImport`
|
||||
- Constant`isModuleExportDescr`
|
||||
- Constant`isModuleExport`
|
||||
- Constant`isLimit`
|
||||
- Constant`isSignature`
|
||||
- Constant`isProgram`
|
||||
- Constant`isIdentifier`
|
||||
- Constant`isBlockInstruction`
|
||||
- Constant`isCallInstruction`
|
||||
- Constant`isCallIndirectInstruction`
|
||||
- Constant`isByteArray`
|
||||
- Constant`isFunc`
|
||||
- Constant`assertModule`
|
||||
- Constant`assertModuleMetadata`
|
||||
- Constant`assertModuleNameMetadata`
|
||||
- Constant`assertFunctionNameMetadata`
|
||||
- Constant`assertLocalNameMetadata`
|
||||
- Constant`assertBinaryModule`
|
||||
- Constant`assertQuoteModule`
|
||||
- Constant`assertSectionMetadata`
|
||||
- Constant`assertLoopInstruction`
|
||||
- Constant`assertInstruction`
|
||||
- Constant`assertObjectInstruction`
|
||||
- Constant`assertIfInstruction`
|
||||
- Constant`assertStringLiteral`
|
||||
- Constant`assertNumberLiteral`
|
||||
- Constant`assertLongNumberLiteral`
|
||||
- Constant`assertFloatLiteral`
|
||||
- Constant`assertElem`
|
||||
- Constant`assertIndexInFuncSection`
|
||||
- Constant`assertValtypeLiteral`
|
||||
- Constant`assertTypeInstruction`
|
||||
- Constant`assertStart`
|
||||
- Constant`assertGlobalType`
|
||||
- Constant`assertLeadingComment`
|
||||
- Constant`assertBlockComment`
|
||||
- Constant`assertData`
|
||||
- Constant`assertGlobal`
|
||||
- Constant`assertTable`
|
||||
- Constant`assertMemory`
|
||||
- Constant`assertFuncImportDescr`
|
||||
- Constant`assertModuleImport`
|
||||
- Constant`assertModuleExportDescr`
|
||||
- Constant`assertModuleExport`
|
||||
- Constant`assertLimit`
|
||||
- Constant`assertSignature`
|
||||
- Constant`assertProgram`
|
||||
- Constant`assertIdentifier`
|
||||
- Constant`assertBlockInstruction`
|
||||
- Constant`assertCallInstruction`
|
||||
- Constant`assertCallIndirectInstruction`
|
||||
- Constant`assertByteArray`
|
||||
- Constant`assertFunc`
|
||||
|
||||
10
node_modules/@webassemblyjs/ast/esm/clone.js
generated
vendored
10
node_modules/@webassemblyjs/ast/esm/clone.js
generated
vendored
|
|
@ -1,10 +0,0 @@
|
|||
export function cloneNode(n) {
|
||||
// $FlowIgnore
|
||||
var newObj = {};
|
||||
|
||||
for (var k in n) {
|
||||
newObj[k] = n[k];
|
||||
}
|
||||
|
||||
return newObj;
|
||||
}
|
||||
663
node_modules/@webassemblyjs/ast/esm/definitions.js
generated
vendored
663
node_modules/@webassemblyjs/ast/esm/definitions.js
generated
vendored
|
|
@ -1,663 +0,0 @@
|
|||
var definitions = {};
|
||||
|
||||
function defineType(typeName, metadata) {
|
||||
definitions[typeName] = metadata;
|
||||
}
|
||||
|
||||
defineType("Module", {
|
||||
spec: {
|
||||
wasm: "https://webassembly.github.io/spec/core/binary/modules.html#binary-module",
|
||||
wat: "https://webassembly.github.io/spec/core/text/modules.html#text-module"
|
||||
},
|
||||
doc: "A module consists of a sequence of sections (termed fields in the text format).",
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
id: {
|
||||
maybe: true,
|
||||
type: "string"
|
||||
},
|
||||
fields: {
|
||||
array: true,
|
||||
type: "Node"
|
||||
},
|
||||
metadata: {
|
||||
optional: true,
|
||||
type: "ModuleMetadata"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("ModuleMetadata", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
sections: {
|
||||
array: true,
|
||||
type: "SectionMetadata"
|
||||
},
|
||||
functionNames: {
|
||||
optional: true,
|
||||
array: true,
|
||||
type: "FunctionNameMetadata"
|
||||
},
|
||||
localNames: {
|
||||
optional: true,
|
||||
array: true,
|
||||
type: "ModuleMetadata"
|
||||
},
|
||||
producers: {
|
||||
optional: true,
|
||||
array: true,
|
||||
type: "ProducersSectionMetadata"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("ModuleNameMetadata", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
value: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("FunctionNameMetadata", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
value: {
|
||||
type: "string"
|
||||
},
|
||||
index: {
|
||||
type: "number"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("LocalNameMetadata", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
value: {
|
||||
type: "string"
|
||||
},
|
||||
localIndex: {
|
||||
type: "number"
|
||||
},
|
||||
functionIndex: {
|
||||
type: "number"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("BinaryModule", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
id: {
|
||||
maybe: true,
|
||||
type: "string"
|
||||
},
|
||||
blob: {
|
||||
array: true,
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("QuoteModule", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
id: {
|
||||
maybe: true,
|
||||
type: "string"
|
||||
},
|
||||
string: {
|
||||
array: true,
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("SectionMetadata", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
section: {
|
||||
type: "SectionName"
|
||||
},
|
||||
startOffset: {
|
||||
type: "number"
|
||||
},
|
||||
size: {
|
||||
type: "NumberLiteral"
|
||||
},
|
||||
vectorOfSize: {
|
||||
comment: "Size of the vector in the section (if any)",
|
||||
type: "NumberLiteral"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("ProducersSectionMetadata", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
producers: {
|
||||
array: true,
|
||||
type: "ProducerMetadata"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("ProducerMetadata", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
language: {
|
||||
type: "ProducerMetadataVersionedName",
|
||||
array: true
|
||||
},
|
||||
processedBy: {
|
||||
type: "ProducerMetadataVersionedName",
|
||||
array: true
|
||||
},
|
||||
sdk: {
|
||||
type: "ProducerMetadataVersionedName",
|
||||
array: true
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("ProducerMetadataVersionedName", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
name: {
|
||||
type: "string"
|
||||
},
|
||||
version: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
/*
|
||||
Instructions
|
||||
*/
|
||||
|
||||
defineType("LoopInstruction", {
|
||||
unionType: ["Node", "Block", "Instruction"],
|
||||
fields: {
|
||||
id: {
|
||||
constant: true,
|
||||
type: "string",
|
||||
value: "loop"
|
||||
},
|
||||
label: {
|
||||
maybe: true,
|
||||
type: "Identifier"
|
||||
},
|
||||
resulttype: {
|
||||
maybe: true,
|
||||
type: "Valtype"
|
||||
},
|
||||
instr: {
|
||||
array: true,
|
||||
type: "Instruction"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Instr", {
|
||||
unionType: ["Node", "Expression", "Instruction"],
|
||||
fields: {
|
||||
id: {
|
||||
type: "string"
|
||||
},
|
||||
object: {
|
||||
optional: true,
|
||||
type: "Valtype"
|
||||
},
|
||||
args: {
|
||||
array: true,
|
||||
type: "Expression"
|
||||
},
|
||||
namedArgs: {
|
||||
optional: true,
|
||||
type: "Object"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("IfInstruction", {
|
||||
unionType: ["Node", "Instruction"],
|
||||
fields: {
|
||||
id: {
|
||||
constant: true,
|
||||
type: "string",
|
||||
value: "if"
|
||||
},
|
||||
testLabel: {
|
||||
comment: "only for WAST",
|
||||
type: "Identifier"
|
||||
},
|
||||
test: {
|
||||
array: true,
|
||||
type: "Instruction"
|
||||
},
|
||||
result: {
|
||||
maybe: true,
|
||||
type: "Valtype"
|
||||
},
|
||||
consequent: {
|
||||
array: true,
|
||||
type: "Instruction"
|
||||
},
|
||||
alternate: {
|
||||
array: true,
|
||||
type: "Instruction"
|
||||
}
|
||||
}
|
||||
});
|
||||
/*
|
||||
Concrete value types
|
||||
*/
|
||||
|
||||
defineType("StringLiteral", {
|
||||
unionType: ["Node", "Expression"],
|
||||
fields: {
|
||||
value: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("NumberLiteral", {
|
||||
unionType: ["Node", "NumericLiteral", "Expression"],
|
||||
fields: {
|
||||
value: {
|
||||
type: "number"
|
||||
},
|
||||
raw: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("LongNumberLiteral", {
|
||||
unionType: ["Node", "NumericLiteral", "Expression"],
|
||||
fields: {
|
||||
value: {
|
||||
type: "LongNumber"
|
||||
},
|
||||
raw: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("FloatLiteral", {
|
||||
unionType: ["Node", "NumericLiteral", "Expression"],
|
||||
fields: {
|
||||
value: {
|
||||
type: "number"
|
||||
},
|
||||
nan: {
|
||||
optional: true,
|
||||
type: "boolean"
|
||||
},
|
||||
inf: {
|
||||
optional: true,
|
||||
type: "boolean"
|
||||
},
|
||||
raw: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Elem", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
table: {
|
||||
type: "Index"
|
||||
},
|
||||
offset: {
|
||||
array: true,
|
||||
type: "Instruction"
|
||||
},
|
||||
funcs: {
|
||||
array: true,
|
||||
type: "Index"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("IndexInFuncSection", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
index: {
|
||||
type: "Index"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("ValtypeLiteral", {
|
||||
unionType: ["Node", "Expression"],
|
||||
fields: {
|
||||
name: {
|
||||
type: "Valtype"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("TypeInstruction", {
|
||||
unionType: ["Node", "Instruction"],
|
||||
fields: {
|
||||
id: {
|
||||
maybe: true,
|
||||
type: "Index"
|
||||
},
|
||||
functype: {
|
||||
type: "Signature"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Start", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
index: {
|
||||
type: "Index"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("GlobalType", {
|
||||
unionType: ["Node", "ImportDescr"],
|
||||
fields: {
|
||||
valtype: {
|
||||
type: "Valtype"
|
||||
},
|
||||
mutability: {
|
||||
type: "Mutability"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("LeadingComment", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
value: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("BlockComment", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
value: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Data", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
memoryIndex: {
|
||||
type: "Memidx"
|
||||
},
|
||||
offset: {
|
||||
type: "Instruction"
|
||||
},
|
||||
init: {
|
||||
type: "ByteArray"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Global", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
globalType: {
|
||||
type: "GlobalType"
|
||||
},
|
||||
init: {
|
||||
array: true,
|
||||
type: "Instruction"
|
||||
},
|
||||
name: {
|
||||
maybe: true,
|
||||
type: "Identifier"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Table", {
|
||||
unionType: ["Node", "ImportDescr"],
|
||||
fields: {
|
||||
elementType: {
|
||||
type: "TableElementType"
|
||||
},
|
||||
limits: {
|
||||
assertNodeType: true,
|
||||
type: "Limit"
|
||||
},
|
||||
name: {
|
||||
maybe: true,
|
||||
type: "Identifier"
|
||||
},
|
||||
elements: {
|
||||
array: true,
|
||||
optional: true,
|
||||
type: "Index"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Memory", {
|
||||
unionType: ["Node", "ImportDescr"],
|
||||
fields: {
|
||||
limits: {
|
||||
type: "Limit"
|
||||
},
|
||||
id: {
|
||||
maybe: true,
|
||||
type: "Index"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("FuncImportDescr", {
|
||||
unionType: ["Node", "ImportDescr"],
|
||||
fields: {
|
||||
id: {
|
||||
type: "Identifier"
|
||||
},
|
||||
signature: {
|
||||
type: "Signature"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("ModuleImport", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
module: {
|
||||
type: "string"
|
||||
},
|
||||
name: {
|
||||
type: "string"
|
||||
},
|
||||
descr: {
|
||||
type: "ImportDescr"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("ModuleExportDescr", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
exportType: {
|
||||
type: "ExportDescrType"
|
||||
},
|
||||
id: {
|
||||
type: "Index"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("ModuleExport", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
name: {
|
||||
type: "string"
|
||||
},
|
||||
descr: {
|
||||
type: "ModuleExportDescr"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Limit", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
min: {
|
||||
type: "number"
|
||||
},
|
||||
max: {
|
||||
optional: true,
|
||||
type: "number"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Signature", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
params: {
|
||||
array: true,
|
||||
type: "FuncParam"
|
||||
},
|
||||
results: {
|
||||
array: true,
|
||||
type: "Valtype"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Program", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
body: {
|
||||
array: true,
|
||||
type: "Node"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Identifier", {
|
||||
unionType: ["Node", "Expression"],
|
||||
fields: {
|
||||
value: {
|
||||
type: "string"
|
||||
},
|
||||
raw: {
|
||||
optional: true,
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("BlockInstruction", {
|
||||
unionType: ["Node", "Block", "Instruction"],
|
||||
fields: {
|
||||
id: {
|
||||
constant: true,
|
||||
type: "string",
|
||||
value: "block"
|
||||
},
|
||||
label: {
|
||||
maybe: true,
|
||||
type: "Identifier"
|
||||
},
|
||||
instr: {
|
||||
array: true,
|
||||
type: "Instruction"
|
||||
},
|
||||
result: {
|
||||
maybe: true,
|
||||
type: "Valtype"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("CallInstruction", {
|
||||
unionType: ["Node", "Instruction"],
|
||||
fields: {
|
||||
id: {
|
||||
constant: true,
|
||||
type: "string",
|
||||
value: "call"
|
||||
},
|
||||
index: {
|
||||
type: "Index"
|
||||
},
|
||||
instrArgs: {
|
||||
array: true,
|
||||
optional: true,
|
||||
type: "Expression"
|
||||
},
|
||||
numeric: {
|
||||
type: "Index",
|
||||
optional: true
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("CallIndirectInstruction", {
|
||||
unionType: ["Node", "Instruction"],
|
||||
fields: {
|
||||
id: {
|
||||
constant: true,
|
||||
type: "string",
|
||||
value: "call_indirect"
|
||||
},
|
||||
signature: {
|
||||
type: "SignatureOrTypeRef"
|
||||
},
|
||||
intrs: {
|
||||
array: true,
|
||||
optional: true,
|
||||
type: "Expression"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("ByteArray", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
values: {
|
||||
array: true,
|
||||
type: "Byte"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Func", {
|
||||
unionType: ["Node", "Block"],
|
||||
fields: {
|
||||
name: {
|
||||
maybe: true,
|
||||
type: "Index"
|
||||
},
|
||||
signature: {
|
||||
type: "SignatureOrTypeRef"
|
||||
},
|
||||
body: {
|
||||
array: true,
|
||||
type: "Instruction"
|
||||
},
|
||||
isExternal: {
|
||||
comment: "means that it has been imported from the outside js",
|
||||
optional: true,
|
||||
type: "boolean"
|
||||
},
|
||||
metadata: {
|
||||
optional: true,
|
||||
type: "FuncMetadata"
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Intrinsics
|
||||
*/
|
||||
|
||||
defineType("InternalBrUnless", {
|
||||
unionType: ["Node", "Intrinsic"],
|
||||
fields: {
|
||||
target: {
|
||||
type: "number"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("InternalGoto", {
|
||||
unionType: ["Node", "Intrinsic"],
|
||||
fields: {
|
||||
target: {
|
||||
type: "number"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("InternalCallExtern", {
|
||||
unionType: ["Node", "Intrinsic"],
|
||||
fields: {
|
||||
target: {
|
||||
type: "number"
|
||||
}
|
||||
}
|
||||
}); // function bodies are terminated by an `end` instruction but are missing a
|
||||
// return instruction
|
||||
//
|
||||
// Since we can't inject a new instruction we are injecting a new instruction.
|
||||
|
||||
defineType("InternalEndAndReturn", {
|
||||
unionType: ["Node", "Intrinsic"],
|
||||
fields: {}
|
||||
});
|
||||
module.exports = definitions;
|
||||
6
node_modules/@webassemblyjs/ast/esm/index.js
generated
vendored
6
node_modules/@webassemblyjs/ast/esm/index.js
generated
vendored
|
|
@ -1,6 +0,0 @@
|
|||
export * from "./nodes";
|
||||
export { numberLiteralFromRaw, withLoc, withRaw, funcParam, indexLiteral, memIndexLiteral, instruction, objectInstruction } from "./node-helpers.js";
|
||||
export { traverse } from "./traverse";
|
||||
export { signatures } from "./signatures";
|
||||
export * from "./utils";
|
||||
export { cloneNode } from "./clone";
|
||||
84
node_modules/@webassemblyjs/ast/esm/node-helpers.js
generated
vendored
84
node_modules/@webassemblyjs/ast/esm/node-helpers.js
generated
vendored
|
|
@ -1,84 +0,0 @@
|
|||
import { parse32F, parse64F, parse32I, parse64I, parseU32, isNanLiteral, isInfLiteral } from "@webassemblyjs/wast-parser";
|
||||
import { longNumberLiteral, floatLiteral, numberLiteral, instr } from "./nodes";
|
||||
export function numberLiteralFromRaw(rawValue) {
|
||||
var instructionType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "i32";
|
||||
var original = rawValue; // Remove numeric separators _
|
||||
|
||||
if (typeof rawValue === "string") {
|
||||
rawValue = rawValue.replace(/_/g, "");
|
||||
}
|
||||
|
||||
if (typeof rawValue === "number") {
|
||||
return numberLiteral(rawValue, String(original));
|
||||
} else {
|
||||
switch (instructionType) {
|
||||
case "i32":
|
||||
{
|
||||
return numberLiteral(parse32I(rawValue), String(original));
|
||||
}
|
||||
|
||||
case "u32":
|
||||
{
|
||||
return numberLiteral(parseU32(rawValue), String(original));
|
||||
}
|
||||
|
||||
case "i64":
|
||||
{
|
||||
return longNumberLiteral(parse64I(rawValue), String(original));
|
||||
}
|
||||
|
||||
case "f32":
|
||||
{
|
||||
return floatLiteral(parse32F(rawValue), isNanLiteral(rawValue), isInfLiteral(rawValue), String(original));
|
||||
}
|
||||
// f64
|
||||
|
||||
default:
|
||||
{
|
||||
return floatLiteral(parse64F(rawValue), isNanLiteral(rawValue), isInfLiteral(rawValue), String(original));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
export function instruction(id) {
|
||||
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
||||
var namedArgs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
||||
return instr(id, undefined, args, namedArgs);
|
||||
}
|
||||
export function objectInstruction(id, object) {
|
||||
var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
||||
var namedArgs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
||||
return instr(id, object, args, namedArgs);
|
||||
}
|
||||
/**
|
||||
* Decorators
|
||||
*/
|
||||
|
||||
export function withLoc(n, end, start) {
|
||||
var loc = {
|
||||
start: start,
|
||||
end: end
|
||||
};
|
||||
n.loc = loc;
|
||||
return n;
|
||||
}
|
||||
export function withRaw(n, raw) {
|
||||
n.raw = raw;
|
||||
return n;
|
||||
}
|
||||
export function funcParam(valtype, id) {
|
||||
return {
|
||||
id: id,
|
||||
valtype: valtype
|
||||
};
|
||||
}
|
||||
export function indexLiteral(value) {
|
||||
// $FlowIgnore
|
||||
var x = numberLiteralFromRaw(value, "u32");
|
||||
return x;
|
||||
}
|
||||
export function memIndexLiteral(value) {
|
||||
// $FlowIgnore
|
||||
var x = numberLiteralFromRaw(value, "u32");
|
||||
return x;
|
||||
}
|
||||
137
node_modules/@webassemblyjs/ast/esm/node-path.js
generated
vendored
137
node_modules/@webassemblyjs/ast/esm/node-path.js
generated
vendored
|
|
@ -1,137 +0,0 @@
|
|||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
|
||||
function findParent(_ref, cb) {
|
||||
var parentPath = _ref.parentPath;
|
||||
|
||||
if (parentPath == null) {
|
||||
throw new Error("node is root");
|
||||
}
|
||||
|
||||
var currentPath = parentPath;
|
||||
|
||||
while (cb(currentPath) !== false) {
|
||||
// Hit the root node, stop
|
||||
// $FlowIgnore
|
||||
if (currentPath.parentPath == null) {
|
||||
return null;
|
||||
} // $FlowIgnore
|
||||
|
||||
|
||||
currentPath = currentPath.parentPath;
|
||||
}
|
||||
|
||||
return currentPath.node;
|
||||
}
|
||||
|
||||
function insertBefore(context, newNode) {
|
||||
return insert(context, newNode);
|
||||
}
|
||||
|
||||
function insertAfter(context, newNode) {
|
||||
return insert(context, newNode, 1);
|
||||
}
|
||||
|
||||
function insert(_ref2, newNode) {
|
||||
var node = _ref2.node,
|
||||
inList = _ref2.inList,
|
||||
parentPath = _ref2.parentPath,
|
||||
parentKey = _ref2.parentKey;
|
||||
var indexOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
||||
|
||||
if (!inList) {
|
||||
throw new Error('inList' + " error: " + ("insert can only be used for nodes that are within lists" || "unknown"));
|
||||
}
|
||||
|
||||
if (!(parentPath != null)) {
|
||||
throw new Error('parentPath != null' + " error: " + ("Can not remove root node" || "unknown"));
|
||||
}
|
||||
|
||||
// $FlowIgnore
|
||||
var parentList = parentPath.node[parentKey];
|
||||
var indexInList = parentList.findIndex(function (n) {
|
||||
return n === node;
|
||||
});
|
||||
parentList.splice(indexInList + indexOffset, 0, newNode);
|
||||
}
|
||||
|
||||
function remove(_ref3) {
|
||||
var node = _ref3.node,
|
||||
parentKey = _ref3.parentKey,
|
||||
parentPath = _ref3.parentPath;
|
||||
|
||||
if (!(parentPath != null)) {
|
||||
throw new Error('parentPath != null' + " error: " + ("Can not remove root node" || "unknown"));
|
||||
}
|
||||
|
||||
// $FlowIgnore
|
||||
var parentNode = parentPath.node; // $FlowIgnore
|
||||
|
||||
var parentProperty = parentNode[parentKey];
|
||||
|
||||
if (Array.isArray(parentProperty)) {
|
||||
// $FlowIgnore
|
||||
parentNode[parentKey] = parentProperty.filter(function (n) {
|
||||
return n !== node;
|
||||
});
|
||||
} else {
|
||||
// $FlowIgnore
|
||||
delete parentNode[parentKey];
|
||||
}
|
||||
|
||||
node._deleted = true;
|
||||
}
|
||||
|
||||
function stop(context) {
|
||||
context.shouldStop = true;
|
||||
}
|
||||
|
||||
function replaceWith(context, newNode) {
|
||||
// $FlowIgnore
|
||||
var parentNode = context.parentPath.node; // $FlowIgnore
|
||||
|
||||
var parentProperty = parentNode[context.parentKey];
|
||||
|
||||
if (Array.isArray(parentProperty)) {
|
||||
var indexInList = parentProperty.findIndex(function (n) {
|
||||
return n === context.node;
|
||||
});
|
||||
parentProperty.splice(indexInList, 1, newNode);
|
||||
} else {
|
||||
// $FlowIgnore
|
||||
parentNode[context.parentKey] = newNode;
|
||||
}
|
||||
|
||||
context.node._deleted = true;
|
||||
context.node = newNode;
|
||||
} // bind the context to the first argument of node operations
|
||||
|
||||
|
||||
function bindNodeOperations(operations, context) {
|
||||
var keys = Object.keys(operations);
|
||||
var boundOperations = {};
|
||||
keys.forEach(function (key) {
|
||||
boundOperations[key] = operations[key].bind(null, context);
|
||||
});
|
||||
return boundOperations;
|
||||
}
|
||||
|
||||
function createPathOperations(context) {
|
||||
// $FlowIgnore
|
||||
return bindNodeOperations({
|
||||
findParent: findParent,
|
||||
replaceWith: replaceWith,
|
||||
remove: remove,
|
||||
insertBefore: insertBefore,
|
||||
insertAfter: insertAfter,
|
||||
stop: stop
|
||||
}, context);
|
||||
}
|
||||
|
||||
export function createPath(context) {
|
||||
var path = _extends({}, context); // $FlowIgnore
|
||||
|
||||
|
||||
Object.assign(path, createPathOperations(path)); // $FlowIgnore
|
||||
|
||||
return path;
|
||||
}
|
||||
915
node_modules/@webassemblyjs/ast/esm/nodes.js
generated
vendored
915
node_modules/@webassemblyjs/ast/esm/nodes.js
generated
vendored
|
|
@ -1,915 +0,0 @@
|
|||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
// THIS FILE IS AUTOGENERATED
|
||||
// see scripts/generateNodeUtils.js
|
||||
function isTypeOf(t) {
|
||||
return function (n) {
|
||||
return n.type === t;
|
||||
};
|
||||
}
|
||||
|
||||
function assertTypeOf(t) {
|
||||
return function (n) {
|
||||
return function () {
|
||||
if (!(n.type === t)) {
|
||||
throw new Error('n.type === t' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
}();
|
||||
};
|
||||
}
|
||||
|
||||
export function module(id, fields, metadata) {
|
||||
if (id !== null && id !== undefined) {
|
||||
if (!(typeof id === "string")) {
|
||||
throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown"));
|
||||
}
|
||||
}
|
||||
|
||||
if (!(_typeof(fields) === "object" && typeof fields.length !== "undefined")) {
|
||||
throw new Error('typeof fields === "object" && typeof fields.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "Module",
|
||||
id: id,
|
||||
fields: fields
|
||||
};
|
||||
|
||||
if (typeof metadata !== "undefined") {
|
||||
node.metadata = metadata;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
export function moduleMetadata(sections, functionNames, localNames, producers) {
|
||||
if (!(_typeof(sections) === "object" && typeof sections.length !== "undefined")) {
|
||||
throw new Error('typeof sections === "object" && typeof sections.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
if (functionNames !== null && functionNames !== undefined) {
|
||||
if (!(_typeof(functionNames) === "object" && typeof functionNames.length !== "undefined")) {
|
||||
throw new Error('typeof functionNames === "object" && typeof functionNames.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
}
|
||||
|
||||
if (localNames !== null && localNames !== undefined) {
|
||||
if (!(_typeof(localNames) === "object" && typeof localNames.length !== "undefined")) {
|
||||
throw new Error('typeof localNames === "object" && typeof localNames.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
}
|
||||
|
||||
if (producers !== null && producers !== undefined) {
|
||||
if (!(_typeof(producers) === "object" && typeof producers.length !== "undefined")) {
|
||||
throw new Error('typeof producers === "object" && typeof producers.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "ModuleMetadata",
|
||||
sections: sections
|
||||
};
|
||||
|
||||
if (typeof functionNames !== "undefined" && functionNames.length > 0) {
|
||||
node.functionNames = functionNames;
|
||||
}
|
||||
|
||||
if (typeof localNames !== "undefined" && localNames.length > 0) {
|
||||
node.localNames = localNames;
|
||||
}
|
||||
|
||||
if (typeof producers !== "undefined" && producers.length > 0) {
|
||||
node.producers = producers;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
export function moduleNameMetadata(value) {
|
||||
if (!(typeof value === "string")) {
|
||||
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "ModuleNameMetadata",
|
||||
value: value
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function functionNameMetadata(value, index) {
|
||||
if (!(typeof value === "string")) {
|
||||
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
||||
}
|
||||
|
||||
if (!(typeof index === "number")) {
|
||||
throw new Error('typeof index === "number"' + " error: " + ("Argument index must be of type number, given: " + _typeof(index) || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "FunctionNameMetadata",
|
||||
value: value,
|
||||
index: index
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function localNameMetadata(value, localIndex, functionIndex) {
|
||||
if (!(typeof value === "string")) {
|
||||
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
||||
}
|
||||
|
||||
if (!(typeof localIndex === "number")) {
|
||||
throw new Error('typeof localIndex === "number"' + " error: " + ("Argument localIndex must be of type number, given: " + _typeof(localIndex) || "unknown"));
|
||||
}
|
||||
|
||||
if (!(typeof functionIndex === "number")) {
|
||||
throw new Error('typeof functionIndex === "number"' + " error: " + ("Argument functionIndex must be of type number, given: " + _typeof(functionIndex) || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "LocalNameMetadata",
|
||||
value: value,
|
||||
localIndex: localIndex,
|
||||
functionIndex: functionIndex
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function binaryModule(id, blob) {
|
||||
if (id !== null && id !== undefined) {
|
||||
if (!(typeof id === "string")) {
|
||||
throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown"));
|
||||
}
|
||||
}
|
||||
|
||||
if (!(_typeof(blob) === "object" && typeof blob.length !== "undefined")) {
|
||||
throw new Error('typeof blob === "object" && typeof blob.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "BinaryModule",
|
||||
id: id,
|
||||
blob: blob
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function quoteModule(id, string) {
|
||||
if (id !== null && id !== undefined) {
|
||||
if (!(typeof id === "string")) {
|
||||
throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown"));
|
||||
}
|
||||
}
|
||||
|
||||
if (!(_typeof(string) === "object" && typeof string.length !== "undefined")) {
|
||||
throw new Error('typeof string === "object" && typeof string.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "QuoteModule",
|
||||
id: id,
|
||||
string: string
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function sectionMetadata(section, startOffset, size, vectorOfSize) {
|
||||
if (!(typeof startOffset === "number")) {
|
||||
throw new Error('typeof startOffset === "number"' + " error: " + ("Argument startOffset must be of type number, given: " + _typeof(startOffset) || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "SectionMetadata",
|
||||
section: section,
|
||||
startOffset: startOffset,
|
||||
size: size,
|
||||
vectorOfSize: vectorOfSize
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function producersSectionMetadata(producers) {
|
||||
if (!(_typeof(producers) === "object" && typeof producers.length !== "undefined")) {
|
||||
throw new Error('typeof producers === "object" && typeof producers.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "ProducersSectionMetadata",
|
||||
producers: producers
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function producerMetadata(language, processedBy, sdk) {
|
||||
if (!(_typeof(language) === "object" && typeof language.length !== "undefined")) {
|
||||
throw new Error('typeof language === "object" && typeof language.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
if (!(_typeof(processedBy) === "object" && typeof processedBy.length !== "undefined")) {
|
||||
throw new Error('typeof processedBy === "object" && typeof processedBy.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
if (!(_typeof(sdk) === "object" && typeof sdk.length !== "undefined")) {
|
||||
throw new Error('typeof sdk === "object" && typeof sdk.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "ProducerMetadata",
|
||||
language: language,
|
||||
processedBy: processedBy,
|
||||
sdk: sdk
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function producerMetadataVersionedName(name, version) {
|
||||
if (!(typeof name === "string")) {
|
||||
throw new Error('typeof name === "string"' + " error: " + ("Argument name must be of type string, given: " + _typeof(name) || "unknown"));
|
||||
}
|
||||
|
||||
if (!(typeof version === "string")) {
|
||||
throw new Error('typeof version === "string"' + " error: " + ("Argument version must be of type string, given: " + _typeof(version) || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "ProducerMetadataVersionedName",
|
||||
name: name,
|
||||
version: version
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function loopInstruction(label, resulttype, instr) {
|
||||
if (!(_typeof(instr) === "object" && typeof instr.length !== "undefined")) {
|
||||
throw new Error('typeof instr === "object" && typeof instr.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "LoopInstruction",
|
||||
id: "loop",
|
||||
label: label,
|
||||
resulttype: resulttype,
|
||||
instr: instr
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function instr(id, object, args, namedArgs) {
|
||||
if (!(typeof id === "string")) {
|
||||
throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown"));
|
||||
}
|
||||
|
||||
if (!(_typeof(args) === "object" && typeof args.length !== "undefined")) {
|
||||
throw new Error('typeof args === "object" && typeof args.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "Instr",
|
||||
id: id,
|
||||
args: args
|
||||
};
|
||||
|
||||
if (typeof object !== "undefined") {
|
||||
node.object = object;
|
||||
}
|
||||
|
||||
if (typeof namedArgs !== "undefined" && Object.keys(namedArgs).length !== 0) {
|
||||
node.namedArgs = namedArgs;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
export function ifInstruction(testLabel, test, result, consequent, alternate) {
|
||||
if (!(_typeof(test) === "object" && typeof test.length !== "undefined")) {
|
||||
throw new Error('typeof test === "object" && typeof test.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
if (!(_typeof(consequent) === "object" && typeof consequent.length !== "undefined")) {
|
||||
throw new Error('typeof consequent === "object" && typeof consequent.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
if (!(_typeof(alternate) === "object" && typeof alternate.length !== "undefined")) {
|
||||
throw new Error('typeof alternate === "object" && typeof alternate.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "IfInstruction",
|
||||
id: "if",
|
||||
testLabel: testLabel,
|
||||
test: test,
|
||||
result: result,
|
||||
consequent: consequent,
|
||||
alternate: alternate
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function stringLiteral(value) {
|
||||
if (!(typeof value === "string")) {
|
||||
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "StringLiteral",
|
||||
value: value
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function numberLiteral(value, raw) {
|
||||
if (!(typeof value === "number")) {
|
||||
throw new Error('typeof value === "number"' + " error: " + ("Argument value must be of type number, given: " + _typeof(value) || "unknown"));
|
||||
}
|
||||
|
||||
if (!(typeof raw === "string")) {
|
||||
throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "NumberLiteral",
|
||||
value: value,
|
||||
raw: raw
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function longNumberLiteral(value, raw) {
|
||||
if (!(typeof raw === "string")) {
|
||||
throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "LongNumberLiteral",
|
||||
value: value,
|
||||
raw: raw
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function floatLiteral(value, nan, inf, raw) {
|
||||
if (!(typeof value === "number")) {
|
||||
throw new Error('typeof value === "number"' + " error: " + ("Argument value must be of type number, given: " + _typeof(value) || "unknown"));
|
||||
}
|
||||
|
||||
if (nan !== null && nan !== undefined) {
|
||||
if (!(typeof nan === "boolean")) {
|
||||
throw new Error('typeof nan === "boolean"' + " error: " + ("Argument nan must be of type boolean, given: " + _typeof(nan) || "unknown"));
|
||||
}
|
||||
}
|
||||
|
||||
if (inf !== null && inf !== undefined) {
|
||||
if (!(typeof inf === "boolean")) {
|
||||
throw new Error('typeof inf === "boolean"' + " error: " + ("Argument inf must be of type boolean, given: " + _typeof(inf) || "unknown"));
|
||||
}
|
||||
}
|
||||
|
||||
if (!(typeof raw === "string")) {
|
||||
throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "FloatLiteral",
|
||||
value: value,
|
||||
raw: raw
|
||||
};
|
||||
|
||||
if (nan === true) {
|
||||
node.nan = true;
|
||||
}
|
||||
|
||||
if (inf === true) {
|
||||
node.inf = true;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
export function elem(table, offset, funcs) {
|
||||
if (!(_typeof(offset) === "object" && typeof offset.length !== "undefined")) {
|
||||
throw new Error('typeof offset === "object" && typeof offset.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
if (!(_typeof(funcs) === "object" && typeof funcs.length !== "undefined")) {
|
||||
throw new Error('typeof funcs === "object" && typeof funcs.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "Elem",
|
||||
table: table,
|
||||
offset: offset,
|
||||
funcs: funcs
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function indexInFuncSection(index) {
|
||||
var node = {
|
||||
type: "IndexInFuncSection",
|
||||
index: index
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function valtypeLiteral(name) {
|
||||
var node = {
|
||||
type: "ValtypeLiteral",
|
||||
name: name
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function typeInstruction(id, functype) {
|
||||
var node = {
|
||||
type: "TypeInstruction",
|
||||
id: id,
|
||||
functype: functype
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function start(index) {
|
||||
var node = {
|
||||
type: "Start",
|
||||
index: index
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function globalType(valtype, mutability) {
|
||||
var node = {
|
||||
type: "GlobalType",
|
||||
valtype: valtype,
|
||||
mutability: mutability
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function leadingComment(value) {
|
||||
if (!(typeof value === "string")) {
|
||||
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "LeadingComment",
|
||||
value: value
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function blockComment(value) {
|
||||
if (!(typeof value === "string")) {
|
||||
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "BlockComment",
|
||||
value: value
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function data(memoryIndex, offset, init) {
|
||||
var node = {
|
||||
type: "Data",
|
||||
memoryIndex: memoryIndex,
|
||||
offset: offset,
|
||||
init: init
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function global(globalType, init, name) {
|
||||
if (!(_typeof(init) === "object" && typeof init.length !== "undefined")) {
|
||||
throw new Error('typeof init === "object" && typeof init.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "Global",
|
||||
globalType: globalType,
|
||||
init: init,
|
||||
name: name
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function table(elementType, limits, name, elements) {
|
||||
if (!(limits.type === "Limit")) {
|
||||
throw new Error('limits.type === "Limit"' + " error: " + ("Argument limits must be of type Limit, given: " + limits.type || "unknown"));
|
||||
}
|
||||
|
||||
if (elements !== null && elements !== undefined) {
|
||||
if (!(_typeof(elements) === "object" && typeof elements.length !== "undefined")) {
|
||||
throw new Error('typeof elements === "object" && typeof elements.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "Table",
|
||||
elementType: elementType,
|
||||
limits: limits,
|
||||
name: name
|
||||
};
|
||||
|
||||
if (typeof elements !== "undefined" && elements.length > 0) {
|
||||
node.elements = elements;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
export function memory(limits, id) {
|
||||
var node = {
|
||||
type: "Memory",
|
||||
limits: limits,
|
||||
id: id
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function funcImportDescr(id, signature) {
|
||||
var node = {
|
||||
type: "FuncImportDescr",
|
||||
id: id,
|
||||
signature: signature
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function moduleImport(module, name, descr) {
|
||||
if (!(typeof module === "string")) {
|
||||
throw new Error('typeof module === "string"' + " error: " + ("Argument module must be of type string, given: " + _typeof(module) || "unknown"));
|
||||
}
|
||||
|
||||
if (!(typeof name === "string")) {
|
||||
throw new Error('typeof name === "string"' + " error: " + ("Argument name must be of type string, given: " + _typeof(name) || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "ModuleImport",
|
||||
module: module,
|
||||
name: name,
|
||||
descr: descr
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function moduleExportDescr(exportType, id) {
|
||||
var node = {
|
||||
type: "ModuleExportDescr",
|
||||
exportType: exportType,
|
||||
id: id
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function moduleExport(name, descr) {
|
||||
if (!(typeof name === "string")) {
|
||||
throw new Error('typeof name === "string"' + " error: " + ("Argument name must be of type string, given: " + _typeof(name) || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "ModuleExport",
|
||||
name: name,
|
||||
descr: descr
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function limit(min, max) {
|
||||
if (!(typeof min === "number")) {
|
||||
throw new Error('typeof min === "number"' + " error: " + ("Argument min must be of type number, given: " + _typeof(min) || "unknown"));
|
||||
}
|
||||
|
||||
if (max !== null && max !== undefined) {
|
||||
if (!(typeof max === "number")) {
|
||||
throw new Error('typeof max === "number"' + " error: " + ("Argument max must be of type number, given: " + _typeof(max) || "unknown"));
|
||||
}
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "Limit",
|
||||
min: min
|
||||
};
|
||||
|
||||
if (typeof max !== "undefined") {
|
||||
node.max = max;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
export function signature(params, results) {
|
||||
if (!(_typeof(params) === "object" && typeof params.length !== "undefined")) {
|
||||
throw new Error('typeof params === "object" && typeof params.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
if (!(_typeof(results) === "object" && typeof results.length !== "undefined")) {
|
||||
throw new Error('typeof results === "object" && typeof results.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "Signature",
|
||||
params: params,
|
||||
results: results
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function program(body) {
|
||||
if (!(_typeof(body) === "object" && typeof body.length !== "undefined")) {
|
||||
throw new Error('typeof body === "object" && typeof body.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "Program",
|
||||
body: body
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function identifier(value, raw) {
|
||||
if (!(typeof value === "string")) {
|
||||
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
||||
}
|
||||
|
||||
if (raw !== null && raw !== undefined) {
|
||||
if (!(typeof raw === "string")) {
|
||||
throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown"));
|
||||
}
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "Identifier",
|
||||
value: value
|
||||
};
|
||||
|
||||
if (typeof raw !== "undefined") {
|
||||
node.raw = raw;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
export function blockInstruction(label, instr, result) {
|
||||
if (!(_typeof(instr) === "object" && typeof instr.length !== "undefined")) {
|
||||
throw new Error('typeof instr === "object" && typeof instr.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "BlockInstruction",
|
||||
id: "block",
|
||||
label: label,
|
||||
instr: instr,
|
||||
result: result
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function callInstruction(index, instrArgs, numeric) {
|
||||
if (instrArgs !== null && instrArgs !== undefined) {
|
||||
if (!(_typeof(instrArgs) === "object" && typeof instrArgs.length !== "undefined")) {
|
||||
throw new Error('typeof instrArgs === "object" && typeof instrArgs.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "CallInstruction",
|
||||
id: "call",
|
||||
index: index
|
||||
};
|
||||
|
||||
if (typeof instrArgs !== "undefined" && instrArgs.length > 0) {
|
||||
node.instrArgs = instrArgs;
|
||||
}
|
||||
|
||||
if (typeof numeric !== "undefined") {
|
||||
node.numeric = numeric;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
export function callIndirectInstruction(signature, intrs) {
|
||||
if (intrs !== null && intrs !== undefined) {
|
||||
if (!(_typeof(intrs) === "object" && typeof intrs.length !== "undefined")) {
|
||||
throw new Error('typeof intrs === "object" && typeof intrs.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "CallIndirectInstruction",
|
||||
id: "call_indirect",
|
||||
signature: signature
|
||||
};
|
||||
|
||||
if (typeof intrs !== "undefined" && intrs.length > 0) {
|
||||
node.intrs = intrs;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
export function byteArray(values) {
|
||||
if (!(_typeof(values) === "object" && typeof values.length !== "undefined")) {
|
||||
throw new Error('typeof values === "object" && typeof values.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "ByteArray",
|
||||
values: values
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function func(name, signature, body, isExternal, metadata) {
|
||||
if (!(_typeof(body) === "object" && typeof body.length !== "undefined")) {
|
||||
throw new Error('typeof body === "object" && typeof body.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
if (isExternal !== null && isExternal !== undefined) {
|
||||
if (!(typeof isExternal === "boolean")) {
|
||||
throw new Error('typeof isExternal === "boolean"' + " error: " + ("Argument isExternal must be of type boolean, given: " + _typeof(isExternal) || "unknown"));
|
||||
}
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "Func",
|
||||
name: name,
|
||||
signature: signature,
|
||||
body: body
|
||||
};
|
||||
|
||||
if (isExternal === true) {
|
||||
node.isExternal = true;
|
||||
}
|
||||
|
||||
if (typeof metadata !== "undefined") {
|
||||
node.metadata = metadata;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
export function internalBrUnless(target) {
|
||||
if (!(typeof target === "number")) {
|
||||
throw new Error('typeof target === "number"' + " error: " + ("Argument target must be of type number, given: " + _typeof(target) || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "InternalBrUnless",
|
||||
target: target
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function internalGoto(target) {
|
||||
if (!(typeof target === "number")) {
|
||||
throw new Error('typeof target === "number"' + " error: " + ("Argument target must be of type number, given: " + _typeof(target) || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "InternalGoto",
|
||||
target: target
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function internalCallExtern(target) {
|
||||
if (!(typeof target === "number")) {
|
||||
throw new Error('typeof target === "number"' + " error: " + ("Argument target must be of type number, given: " + _typeof(target) || "unknown"));
|
||||
}
|
||||
|
||||
var node = {
|
||||
type: "InternalCallExtern",
|
||||
target: target
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export function internalEndAndReturn() {
|
||||
var node = {
|
||||
type: "InternalEndAndReturn"
|
||||
};
|
||||
return node;
|
||||
}
|
||||
export var isModule = isTypeOf("Module");
|
||||
export var isModuleMetadata = isTypeOf("ModuleMetadata");
|
||||
export var isModuleNameMetadata = isTypeOf("ModuleNameMetadata");
|
||||
export var isFunctionNameMetadata = isTypeOf("FunctionNameMetadata");
|
||||
export var isLocalNameMetadata = isTypeOf("LocalNameMetadata");
|
||||
export var isBinaryModule = isTypeOf("BinaryModule");
|
||||
export var isQuoteModule = isTypeOf("QuoteModule");
|
||||
export var isSectionMetadata = isTypeOf("SectionMetadata");
|
||||
export var isProducersSectionMetadata = isTypeOf("ProducersSectionMetadata");
|
||||
export var isProducerMetadata = isTypeOf("ProducerMetadata");
|
||||
export var isProducerMetadataVersionedName = isTypeOf("ProducerMetadataVersionedName");
|
||||
export var isLoopInstruction = isTypeOf("LoopInstruction");
|
||||
export var isInstr = isTypeOf("Instr");
|
||||
export var isIfInstruction = isTypeOf("IfInstruction");
|
||||
export var isStringLiteral = isTypeOf("StringLiteral");
|
||||
export var isNumberLiteral = isTypeOf("NumberLiteral");
|
||||
export var isLongNumberLiteral = isTypeOf("LongNumberLiteral");
|
||||
export var isFloatLiteral = isTypeOf("FloatLiteral");
|
||||
export var isElem = isTypeOf("Elem");
|
||||
export var isIndexInFuncSection = isTypeOf("IndexInFuncSection");
|
||||
export var isValtypeLiteral = isTypeOf("ValtypeLiteral");
|
||||
export var isTypeInstruction = isTypeOf("TypeInstruction");
|
||||
export var isStart = isTypeOf("Start");
|
||||
export var isGlobalType = isTypeOf("GlobalType");
|
||||
export var isLeadingComment = isTypeOf("LeadingComment");
|
||||
export var isBlockComment = isTypeOf("BlockComment");
|
||||
export var isData = isTypeOf("Data");
|
||||
export var isGlobal = isTypeOf("Global");
|
||||
export var isTable = isTypeOf("Table");
|
||||
export var isMemory = isTypeOf("Memory");
|
||||
export var isFuncImportDescr = isTypeOf("FuncImportDescr");
|
||||
export var isModuleImport = isTypeOf("ModuleImport");
|
||||
export var isModuleExportDescr = isTypeOf("ModuleExportDescr");
|
||||
export var isModuleExport = isTypeOf("ModuleExport");
|
||||
export var isLimit = isTypeOf("Limit");
|
||||
export var isSignature = isTypeOf("Signature");
|
||||
export var isProgram = isTypeOf("Program");
|
||||
export var isIdentifier = isTypeOf("Identifier");
|
||||
export var isBlockInstruction = isTypeOf("BlockInstruction");
|
||||
export var isCallInstruction = isTypeOf("CallInstruction");
|
||||
export var isCallIndirectInstruction = isTypeOf("CallIndirectInstruction");
|
||||
export var isByteArray = isTypeOf("ByteArray");
|
||||
export var isFunc = isTypeOf("Func");
|
||||
export var isInternalBrUnless = isTypeOf("InternalBrUnless");
|
||||
export var isInternalGoto = isTypeOf("InternalGoto");
|
||||
export var isInternalCallExtern = isTypeOf("InternalCallExtern");
|
||||
export var isInternalEndAndReturn = isTypeOf("InternalEndAndReturn");
|
||||
export var isNode = function isNode(node) {
|
||||
return isModule(node) || isModuleMetadata(node) || isModuleNameMetadata(node) || isFunctionNameMetadata(node) || isLocalNameMetadata(node) || isBinaryModule(node) || isQuoteModule(node) || isSectionMetadata(node) || isProducersSectionMetadata(node) || isProducerMetadata(node) || isProducerMetadataVersionedName(node) || isLoopInstruction(node) || isInstr(node) || isIfInstruction(node) || isStringLiteral(node) || isNumberLiteral(node) || isLongNumberLiteral(node) || isFloatLiteral(node) || isElem(node) || isIndexInFuncSection(node) || isValtypeLiteral(node) || isTypeInstruction(node) || isStart(node) || isGlobalType(node) || isLeadingComment(node) || isBlockComment(node) || isData(node) || isGlobal(node) || isTable(node) || isMemory(node) || isFuncImportDescr(node) || isModuleImport(node) || isModuleExportDescr(node) || isModuleExport(node) || isLimit(node) || isSignature(node) || isProgram(node) || isIdentifier(node) || isBlockInstruction(node) || isCallInstruction(node) || isCallIndirectInstruction(node) || isByteArray(node) || isFunc(node) || isInternalBrUnless(node) || isInternalGoto(node) || isInternalCallExtern(node) || isInternalEndAndReturn(node);
|
||||
};
|
||||
export var isBlock = function isBlock(node) {
|
||||
return isLoopInstruction(node) || isBlockInstruction(node) || isFunc(node);
|
||||
};
|
||||
export var isInstruction = function isInstruction(node) {
|
||||
return isLoopInstruction(node) || isInstr(node) || isIfInstruction(node) || isTypeInstruction(node) || isBlockInstruction(node) || isCallInstruction(node) || isCallIndirectInstruction(node);
|
||||
};
|
||||
export var isExpression = function isExpression(node) {
|
||||
return isInstr(node) || isStringLiteral(node) || isNumberLiteral(node) || isLongNumberLiteral(node) || isFloatLiteral(node) || isValtypeLiteral(node) || isIdentifier(node);
|
||||
};
|
||||
export var isNumericLiteral = function isNumericLiteral(node) {
|
||||
return isNumberLiteral(node) || isLongNumberLiteral(node) || isFloatLiteral(node);
|
||||
};
|
||||
export var isImportDescr = function isImportDescr(node) {
|
||||
return isGlobalType(node) || isTable(node) || isMemory(node) || isFuncImportDescr(node);
|
||||
};
|
||||
export var isIntrinsic = function isIntrinsic(node) {
|
||||
return isInternalBrUnless(node) || isInternalGoto(node) || isInternalCallExtern(node) || isInternalEndAndReturn(node);
|
||||
};
|
||||
export var assertModule = assertTypeOf("Module");
|
||||
export var assertModuleMetadata = assertTypeOf("ModuleMetadata");
|
||||
export var assertModuleNameMetadata = assertTypeOf("ModuleNameMetadata");
|
||||
export var assertFunctionNameMetadata = assertTypeOf("FunctionNameMetadata");
|
||||
export var assertLocalNameMetadata = assertTypeOf("LocalNameMetadata");
|
||||
export var assertBinaryModule = assertTypeOf("BinaryModule");
|
||||
export var assertQuoteModule = assertTypeOf("QuoteModule");
|
||||
export var assertSectionMetadata = assertTypeOf("SectionMetadata");
|
||||
export var assertProducersSectionMetadata = assertTypeOf("ProducersSectionMetadata");
|
||||
export var assertProducerMetadata = assertTypeOf("ProducerMetadata");
|
||||
export var assertProducerMetadataVersionedName = assertTypeOf("ProducerMetadataVersionedName");
|
||||
export var assertLoopInstruction = assertTypeOf("LoopInstruction");
|
||||
export var assertInstr = assertTypeOf("Instr");
|
||||
export var assertIfInstruction = assertTypeOf("IfInstruction");
|
||||
export var assertStringLiteral = assertTypeOf("StringLiteral");
|
||||
export var assertNumberLiteral = assertTypeOf("NumberLiteral");
|
||||
export var assertLongNumberLiteral = assertTypeOf("LongNumberLiteral");
|
||||
export var assertFloatLiteral = assertTypeOf("FloatLiteral");
|
||||
export var assertElem = assertTypeOf("Elem");
|
||||
export var assertIndexInFuncSection = assertTypeOf("IndexInFuncSection");
|
||||
export var assertValtypeLiteral = assertTypeOf("ValtypeLiteral");
|
||||
export var assertTypeInstruction = assertTypeOf("TypeInstruction");
|
||||
export var assertStart = assertTypeOf("Start");
|
||||
export var assertGlobalType = assertTypeOf("GlobalType");
|
||||
export var assertLeadingComment = assertTypeOf("LeadingComment");
|
||||
export var assertBlockComment = assertTypeOf("BlockComment");
|
||||
export var assertData = assertTypeOf("Data");
|
||||
export var assertGlobal = assertTypeOf("Global");
|
||||
export var assertTable = assertTypeOf("Table");
|
||||
export var assertMemory = assertTypeOf("Memory");
|
||||
export var assertFuncImportDescr = assertTypeOf("FuncImportDescr");
|
||||
export var assertModuleImport = assertTypeOf("ModuleImport");
|
||||
export var assertModuleExportDescr = assertTypeOf("ModuleExportDescr");
|
||||
export var assertModuleExport = assertTypeOf("ModuleExport");
|
||||
export var assertLimit = assertTypeOf("Limit");
|
||||
export var assertSignature = assertTypeOf("Signature");
|
||||
export var assertProgram = assertTypeOf("Program");
|
||||
export var assertIdentifier = assertTypeOf("Identifier");
|
||||
export var assertBlockInstruction = assertTypeOf("BlockInstruction");
|
||||
export var assertCallInstruction = assertTypeOf("CallInstruction");
|
||||
export var assertCallIndirectInstruction = assertTypeOf("CallIndirectInstruction");
|
||||
export var assertByteArray = assertTypeOf("ByteArray");
|
||||
export var assertFunc = assertTypeOf("Func");
|
||||
export var assertInternalBrUnless = assertTypeOf("InternalBrUnless");
|
||||
export var assertInternalGoto = assertTypeOf("InternalGoto");
|
||||
export var assertInternalCallExtern = assertTypeOf("InternalCallExtern");
|
||||
export var assertInternalEndAndReturn = assertTypeOf("InternalEndAndReturn");
|
||||
export var unionTypesMap = {
|
||||
Module: ["Node"],
|
||||
ModuleMetadata: ["Node"],
|
||||
ModuleNameMetadata: ["Node"],
|
||||
FunctionNameMetadata: ["Node"],
|
||||
LocalNameMetadata: ["Node"],
|
||||
BinaryModule: ["Node"],
|
||||
QuoteModule: ["Node"],
|
||||
SectionMetadata: ["Node"],
|
||||
ProducersSectionMetadata: ["Node"],
|
||||
ProducerMetadata: ["Node"],
|
||||
ProducerMetadataVersionedName: ["Node"],
|
||||
LoopInstruction: ["Node", "Block", "Instruction"],
|
||||
Instr: ["Node", "Expression", "Instruction"],
|
||||
IfInstruction: ["Node", "Instruction"],
|
||||
StringLiteral: ["Node", "Expression"],
|
||||
NumberLiteral: ["Node", "NumericLiteral", "Expression"],
|
||||
LongNumberLiteral: ["Node", "NumericLiteral", "Expression"],
|
||||
FloatLiteral: ["Node", "NumericLiteral", "Expression"],
|
||||
Elem: ["Node"],
|
||||
IndexInFuncSection: ["Node"],
|
||||
ValtypeLiteral: ["Node", "Expression"],
|
||||
TypeInstruction: ["Node", "Instruction"],
|
||||
Start: ["Node"],
|
||||
GlobalType: ["Node", "ImportDescr"],
|
||||
LeadingComment: ["Node"],
|
||||
BlockComment: ["Node"],
|
||||
Data: ["Node"],
|
||||
Global: ["Node"],
|
||||
Table: ["Node", "ImportDescr"],
|
||||
Memory: ["Node", "ImportDescr"],
|
||||
FuncImportDescr: ["Node", "ImportDescr"],
|
||||
ModuleImport: ["Node"],
|
||||
ModuleExportDescr: ["Node"],
|
||||
ModuleExport: ["Node"],
|
||||
Limit: ["Node"],
|
||||
Signature: ["Node"],
|
||||
Program: ["Node"],
|
||||
Identifier: ["Node", "Expression"],
|
||||
BlockInstruction: ["Node", "Block", "Instruction"],
|
||||
CallInstruction: ["Node", "Instruction"],
|
||||
CallIndirectInstruction: ["Node", "Instruction"],
|
||||
ByteArray: ["Node"],
|
||||
Func: ["Node", "Block"],
|
||||
InternalBrUnless: ["Node", "Intrinsic"],
|
||||
InternalGoto: ["Node", "Intrinsic"],
|
||||
InternalCallExtern: ["Node", "Intrinsic"],
|
||||
InternalEndAndReturn: ["Node", "Intrinsic"]
|
||||
};
|
||||
export var nodeAndUnionTypes = ["Module", "ModuleMetadata", "ModuleNameMetadata", "FunctionNameMetadata", "LocalNameMetadata", "BinaryModule", "QuoteModule", "SectionMetadata", "ProducersSectionMetadata", "ProducerMetadata", "ProducerMetadataVersionedName", "LoopInstruction", "Instr", "IfInstruction", "StringLiteral", "NumberLiteral", "LongNumberLiteral", "FloatLiteral", "Elem", "IndexInFuncSection", "ValtypeLiteral", "TypeInstruction", "Start", "GlobalType", "LeadingComment", "BlockComment", "Data", "Global", "Table", "Memory", "FuncImportDescr", "ModuleImport", "ModuleExportDescr", "ModuleExport", "Limit", "Signature", "Program", "Identifier", "BlockInstruction", "CallInstruction", "CallIndirectInstruction", "ByteArray", "Func", "InternalBrUnless", "InternalGoto", "InternalCallExtern", "InternalEndAndReturn", "Node", "Block", "Instruction", "Expression", "NumericLiteral", "ImportDescr", "Intrinsic"];
|
||||
199
node_modules/@webassemblyjs/ast/esm/signatures.js
generated
vendored
199
node_modules/@webassemblyjs/ast/esm/signatures.js
generated
vendored
|
|
@ -1,199 +0,0 @@
|
|||
function sign(input, output) {
|
||||
return [input, output];
|
||||
}
|
||||
|
||||
var u32 = "u32";
|
||||
var i32 = "i32";
|
||||
var i64 = "i64";
|
||||
var f32 = "f32";
|
||||
var f64 = "f64";
|
||||
|
||||
var vector = function vector(t) {
|
||||
var vecType = [t]; // $FlowIgnore
|
||||
|
||||
vecType.vector = true;
|
||||
return vecType;
|
||||
};
|
||||
|
||||
var controlInstructions = {
|
||||
unreachable: sign([], []),
|
||||
nop: sign([], []),
|
||||
// block ?
|
||||
// loop ?
|
||||
// if ?
|
||||
// if else ?
|
||||
br: sign([u32], []),
|
||||
br_if: sign([u32], []),
|
||||
br_table: sign(vector(u32), []),
|
||||
return: sign([], []),
|
||||
call: sign([u32], []),
|
||||
call_indirect: sign([u32], [])
|
||||
};
|
||||
var parametricInstructions = {
|
||||
drop: sign([], []),
|
||||
select: sign([], [])
|
||||
};
|
||||
var variableInstructions = {
|
||||
get_local: sign([u32], []),
|
||||
set_local: sign([u32], []),
|
||||
tee_local: sign([u32], []),
|
||||
get_global: sign([u32], []),
|
||||
set_global: sign([u32], [])
|
||||
};
|
||||
var memoryInstructions = {
|
||||
"i32.load": sign([u32, u32], [i32]),
|
||||
"i64.load": sign([u32, u32], []),
|
||||
"f32.load": sign([u32, u32], []),
|
||||
"f64.load": sign([u32, u32], []),
|
||||
"i32.load8_s": sign([u32, u32], [i32]),
|
||||
"i32.load8_u": sign([u32, u32], [i32]),
|
||||
"i32.load16_s": sign([u32, u32], [i32]),
|
||||
"i32.load16_u": sign([u32, u32], [i32]),
|
||||
"i64.load8_s": sign([u32, u32], [i64]),
|
||||
"i64.load8_u": sign([u32, u32], [i64]),
|
||||
"i64.load16_s": sign([u32, u32], [i64]),
|
||||
"i64.load16_u": sign([u32, u32], [i64]),
|
||||
"i64.load32_s": sign([u32, u32], [i64]),
|
||||
"i64.load32_u": sign([u32, u32], [i64]),
|
||||
"i32.store": sign([u32, u32], []),
|
||||
"i64.store": sign([u32, u32], []),
|
||||
"f32.store": sign([u32, u32], []),
|
||||
"f64.store": sign([u32, u32], []),
|
||||
"i32.store8": sign([u32, u32], []),
|
||||
"i32.store16": sign([u32, u32], []),
|
||||
"i64.store8": sign([u32, u32], []),
|
||||
"i64.store16": sign([u32, u32], []),
|
||||
"i64.store32": sign([u32, u32], []),
|
||||
current_memory: sign([], []),
|
||||
grow_memory: sign([], [])
|
||||
};
|
||||
var numericInstructions = {
|
||||
"i32.const": sign([i32], [i32]),
|
||||
"i64.const": sign([i64], [i64]),
|
||||
"f32.const": sign([f32], [f32]),
|
||||
"f64.const": sign([f64], [f64]),
|
||||
"i32.eqz": sign([i32], [i32]),
|
||||
"i32.eq": sign([i32, i32], [i32]),
|
||||
"i32.ne": sign([i32, i32], [i32]),
|
||||
"i32.lt_s": sign([i32, i32], [i32]),
|
||||
"i32.lt_u": sign([i32, i32], [i32]),
|
||||
"i32.gt_s": sign([i32, i32], [i32]),
|
||||
"i32.gt_u": sign([i32, i32], [i32]),
|
||||
"i32.le_s": sign([i32, i32], [i32]),
|
||||
"i32.le_u": sign([i32, i32], [i32]),
|
||||
"i32.ge_s": sign([i32, i32], [i32]),
|
||||
"i32.ge_u": sign([i32, i32], [i32]),
|
||||
"i64.eqz": sign([i64], [i64]),
|
||||
"i64.eq": sign([i64, i64], [i32]),
|
||||
"i64.ne": sign([i64, i64], [i32]),
|
||||
"i64.lt_s": sign([i64, i64], [i32]),
|
||||
"i64.lt_u": sign([i64, i64], [i32]),
|
||||
"i64.gt_s": sign([i64, i64], [i32]),
|
||||
"i64.gt_u": sign([i64, i64], [i32]),
|
||||
"i64.le_s": sign([i64, i64], [i32]),
|
||||
"i64.le_u": sign([i64, i64], [i32]),
|
||||
"i64.ge_s": sign([i64, i64], [i32]),
|
||||
"i64.ge_u": sign([i64, i64], [i32]),
|
||||
"f32.eq": sign([f32, f32], [i32]),
|
||||
"f32.ne": sign([f32, f32], [i32]),
|
||||
"f32.lt": sign([f32, f32], [i32]),
|
||||
"f32.gt": sign([f32, f32], [i32]),
|
||||
"f32.le": sign([f32, f32], [i32]),
|
||||
"f32.ge": sign([f32, f32], [i32]),
|
||||
"f64.eq": sign([f64, f64], [i32]),
|
||||
"f64.ne": sign([f64, f64], [i32]),
|
||||
"f64.lt": sign([f64, f64], [i32]),
|
||||
"f64.gt": sign([f64, f64], [i32]),
|
||||
"f64.le": sign([f64, f64], [i32]),
|
||||
"f64.ge": sign([f64, f64], [i32]),
|
||||
"i32.clz": sign([i32], [i32]),
|
||||
"i32.ctz": sign([i32], [i32]),
|
||||
"i32.popcnt": sign([i32], [i32]),
|
||||
"i32.add": sign([i32, i32], [i32]),
|
||||
"i32.sub": sign([i32, i32], [i32]),
|
||||
"i32.mul": sign([i32, i32], [i32]),
|
||||
"i32.div_s": sign([i32, i32], [i32]),
|
||||
"i32.div_u": sign([i32, i32], [i32]),
|
||||
"i32.rem_s": sign([i32, i32], [i32]),
|
||||
"i32.rem_u": sign([i32, i32], [i32]),
|
||||
"i32.and": sign([i32, i32], [i32]),
|
||||
"i32.or": sign([i32, i32], [i32]),
|
||||
"i32.xor": sign([i32, i32], [i32]),
|
||||
"i32.shl": sign([i32, i32], [i32]),
|
||||
"i32.shr_s": sign([i32, i32], [i32]),
|
||||
"i32.shr_u": sign([i32, i32], [i32]),
|
||||
"i32.rotl": sign([i32, i32], [i32]),
|
||||
"i32.rotr": sign([i32, i32], [i32]),
|
||||
"i64.clz": sign([i64], [i64]),
|
||||
"i64.ctz": sign([i64], [i64]),
|
||||
"i64.popcnt": sign([i64], [i64]),
|
||||
"i64.add": sign([i64, i64], [i64]),
|
||||
"i64.sub": sign([i64, i64], [i64]),
|
||||
"i64.mul": sign([i64, i64], [i64]),
|
||||
"i64.div_s": sign([i64, i64], [i64]),
|
||||
"i64.div_u": sign([i64, i64], [i64]),
|
||||
"i64.rem_s": sign([i64, i64], [i64]),
|
||||
"i64.rem_u": sign([i64, i64], [i64]),
|
||||
"i64.and": sign([i64, i64], [i64]),
|
||||
"i64.or": sign([i64, i64], [i64]),
|
||||
"i64.xor": sign([i64, i64], [i64]),
|
||||
"i64.shl": sign([i64, i64], [i64]),
|
||||
"i64.shr_s": sign([i64, i64], [i64]),
|
||||
"i64.shr_u": sign([i64, i64], [i64]),
|
||||
"i64.rotl": sign([i64, i64], [i64]),
|
||||
"i64.rotr": sign([i64, i64], [i64]),
|
||||
"f32.abs": sign([f32], [f32]),
|
||||
"f32.neg": sign([f32], [f32]),
|
||||
"f32.ceil": sign([f32], [f32]),
|
||||
"f32.floor": sign([f32], [f32]),
|
||||
"f32.trunc": sign([f32], [f32]),
|
||||
"f32.nearest": sign([f32], [f32]),
|
||||
"f32.sqrt": sign([f32], [f32]),
|
||||
"f32.add": sign([f32, f32], [f32]),
|
||||
"f32.sub": sign([f32, f32], [f32]),
|
||||
"f32.mul": sign([f32, f32], [f32]),
|
||||
"f32.div": sign([f32, f32], [f32]),
|
||||
"f32.min": sign([f32, f32], [f32]),
|
||||
"f32.max": sign([f32, f32], [f32]),
|
||||
"f32.copysign": sign([f32, f32], [f32]),
|
||||
"f64.abs": sign([f64], [f64]),
|
||||
"f64.neg": sign([f64], [f64]),
|
||||
"f64.ceil": sign([f64], [f64]),
|
||||
"f64.floor": sign([f64], [f64]),
|
||||
"f64.trunc": sign([f64], [f64]),
|
||||
"f64.nearest": sign([f64], [f64]),
|
||||
"f64.sqrt": sign([f64], [f64]),
|
||||
"f64.add": sign([f64, f64], [f64]),
|
||||
"f64.sub": sign([f64, f64], [f64]),
|
||||
"f64.mul": sign([f64, f64], [f64]),
|
||||
"f64.div": sign([f64, f64], [f64]),
|
||||
"f64.min": sign([f64, f64], [f64]),
|
||||
"f64.max": sign([f64, f64], [f64]),
|
||||
"f64.copysign": sign([f64, f64], [f64]),
|
||||
"i32.wrap/i64": sign([i64], [i32]),
|
||||
"i32.trunc_s/f32": sign([f32], [i32]),
|
||||
"i32.trunc_u/f32": sign([f32], [i32]),
|
||||
"i32.trunc_s/f64": sign([f32], [i32]),
|
||||
"i32.trunc_u/f64": sign([f64], [i32]),
|
||||
"i64.extend_s/i32": sign([i32], [i64]),
|
||||
"i64.extend_u/i32": sign([i32], [i64]),
|
||||
"i64.trunc_s/f32": sign([f32], [i64]),
|
||||
"i64.trunc_u/f32": sign([f32], [i64]),
|
||||
"i64.trunc_s/f64": sign([f64], [i64]),
|
||||
"i64.trunc_u/f64": sign([f64], [i64]),
|
||||
"f32.convert_s/i32": sign([i32], [f32]),
|
||||
"f32.convert_u/i32": sign([i32], [f32]),
|
||||
"f32.convert_s/i64": sign([i64], [f32]),
|
||||
"f32.convert_u/i64": sign([i64], [f32]),
|
||||
"f32.demote/f64": sign([f64], [f32]),
|
||||
"f64.convert_s/i32": sign([i32], [f64]),
|
||||
"f64.convert_u/i32": sign([i32], [f64]),
|
||||
"f64.convert_s/i64": sign([i64], [f64]),
|
||||
"f64.convert_u/i64": sign([i64], [f64]),
|
||||
"f64.promote/f32": sign([f32], [f64]),
|
||||
"i32.reinterpret/f32": sign([f32], [i32]),
|
||||
"i64.reinterpret/f64": sign([f64], [i64]),
|
||||
"f32.reinterpret/i32": sign([i32], [f32]),
|
||||
"f64.reinterpret/i64": sign([i64], [f64])
|
||||
};
|
||||
export var signatures = Object.assign({}, controlInstructions, parametricInstructions, variableInstructions, memoryInstructions, numericInstructions);
|
||||
76
node_modules/@webassemblyjs/ast/esm/transform/denormalize-type-references/index.js
generated
vendored
76
node_modules/@webassemblyjs/ast/esm/transform/denormalize-type-references/index.js
generated
vendored
|
|
@ -1,76 +0,0 @@
|
|||
var t = require("../../index"); // func and call_indirect instructions can either define a signature inline, or
|
||||
// reference a signature, e.g.
|
||||
//
|
||||
// ;; inline signature
|
||||
// (func (result i64)
|
||||
// (i64.const 2)
|
||||
// )
|
||||
// ;; signature reference
|
||||
// (type (func (result i64)))
|
||||
// (func (type 0)
|
||||
// (i64.const 2))
|
||||
// )
|
||||
//
|
||||
// this AST transform denormalises the type references, making all signatures within the module
|
||||
// inline.
|
||||
|
||||
|
||||
export function transform(ast) {
|
||||
var typeInstructions = [];
|
||||
t.traverse(ast, {
|
||||
TypeInstruction: function TypeInstruction(_ref) {
|
||||
var node = _ref.node;
|
||||
typeInstructions.push(node);
|
||||
}
|
||||
});
|
||||
|
||||
if (!typeInstructions.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
function denormalizeSignature(signature) {
|
||||
// signature referenced by identifier
|
||||
if (signature.type === "Identifier") {
|
||||
var identifier = signature;
|
||||
var typeInstruction = typeInstructions.find(function (t) {
|
||||
return t.id.type === identifier.type && t.id.value === identifier.value;
|
||||
});
|
||||
|
||||
if (!typeInstruction) {
|
||||
throw new Error("A type instruction reference was not found ".concat(JSON.stringify(signature)));
|
||||
}
|
||||
|
||||
return typeInstruction.functype;
|
||||
} // signature referenced by index
|
||||
|
||||
|
||||
if (signature.type === "NumberLiteral") {
|
||||
var signatureRef = signature;
|
||||
var _typeInstruction = typeInstructions[signatureRef.value];
|
||||
return _typeInstruction.functype;
|
||||
}
|
||||
|
||||
return signature;
|
||||
}
|
||||
|
||||
t.traverse(ast, {
|
||||
Func: function (_Func) {
|
||||
function Func(_x) {
|
||||
return _Func.apply(this, arguments);
|
||||
}
|
||||
|
||||
Func.toString = function () {
|
||||
return _Func.toString();
|
||||
};
|
||||
|
||||
return Func;
|
||||
}(function (_ref2) {
|
||||
var node = _ref2.node;
|
||||
node.signature = denormalizeSignature(node.signature);
|
||||
}),
|
||||
CallIndirectInstruction: function CallIndirectInstruction(_ref3) {
|
||||
var node = _ref3.node;
|
||||
node.signature = denormalizeSignature(node.signature);
|
||||
}
|
||||
});
|
||||
}
|
||||
216
node_modules/@webassemblyjs/ast/esm/transform/wast-identifier-to-index/index.js
generated
vendored
216
node_modules/@webassemblyjs/ast/esm/transform/wast-identifier-to-index/index.js
generated
vendored
|
|
@ -1,216 +0,0 @@
|
|||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function _sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
||||
|
||||
function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return _sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }
|
||||
|
||||
import { isBlock, isFunc, isIdentifier, numberLiteralFromRaw, traverse } from "../../index";
|
||||
import { moduleContextFromModuleAST } from "@webassemblyjs/helper-module-context"; // FIXME(sven): do the same with all block instructions, must be more generic here
|
||||
|
||||
function newUnexpectedFunction(i) {
|
||||
return new Error("unknown function at offset: " + i);
|
||||
}
|
||||
|
||||
export function transform(ast) {
|
||||
var module;
|
||||
traverse(ast, {
|
||||
Module: function (_Module) {
|
||||
function Module(_x) {
|
||||
return _Module.apply(this, arguments);
|
||||
}
|
||||
|
||||
Module.toString = function () {
|
||||
return _Module.toString();
|
||||
};
|
||||
|
||||
return Module;
|
||||
}(function (path) {
|
||||
module = path.node;
|
||||
})
|
||||
});
|
||||
var moduleContext = moduleContextFromModuleAST(module); // Transform the actual instruction in function bodies
|
||||
|
||||
traverse(ast, {
|
||||
Func: function (_Func) {
|
||||
function Func(_x2) {
|
||||
return _Func.apply(this, arguments);
|
||||
}
|
||||
|
||||
Func.toString = function () {
|
||||
return _Func.toString();
|
||||
};
|
||||
|
||||
return Func;
|
||||
}(function (path) {
|
||||
transformFuncPath(path, moduleContext);
|
||||
}),
|
||||
Start: function (_Start) {
|
||||
function Start(_x3) {
|
||||
return _Start.apply(this, arguments);
|
||||
}
|
||||
|
||||
Start.toString = function () {
|
||||
return _Start.toString();
|
||||
};
|
||||
|
||||
return Start;
|
||||
}(function (path) {
|
||||
var index = path.node.index;
|
||||
|
||||
if (isIdentifier(index) === true) {
|
||||
var offsetInModule = moduleContext.getFunctionOffsetByIdentifier(index.value);
|
||||
|
||||
if (typeof offsetInModule === "undefined") {
|
||||
throw newUnexpectedFunction(index.value);
|
||||
} // Replace the index Identifier
|
||||
// $FlowIgnore: reference?
|
||||
|
||||
|
||||
path.node.index = numberLiteralFromRaw(offsetInModule);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function transformFuncPath(funcPath, moduleContext) {
|
||||
var funcNode = funcPath.node;
|
||||
var signature = funcNode.signature;
|
||||
|
||||
if (signature.type !== "Signature") {
|
||||
throw new Error("Function signatures must be denormalised before execution");
|
||||
}
|
||||
|
||||
var params = signature.params; // Add func locals in the context
|
||||
|
||||
params.forEach(function (p) {
|
||||
return moduleContext.addLocal(p.valtype);
|
||||
});
|
||||
traverse(funcNode, {
|
||||
Instr: function (_Instr) {
|
||||
function Instr(_x4) {
|
||||
return _Instr.apply(this, arguments);
|
||||
}
|
||||
|
||||
Instr.toString = function () {
|
||||
return _Instr.toString();
|
||||
};
|
||||
|
||||
return Instr;
|
||||
}(function (instrPath) {
|
||||
var instrNode = instrPath.node;
|
||||
/**
|
||||
* Local access
|
||||
*/
|
||||
|
||||
if (instrNode.id === "get_local" || instrNode.id === "set_local" || instrNode.id === "tee_local") {
|
||||
var _instrNode$args = _slicedToArray(instrNode.args, 1),
|
||||
firstArg = _instrNode$args[0];
|
||||
|
||||
if (firstArg.type === "Identifier") {
|
||||
var offsetInParams = params.findIndex(function (_ref) {
|
||||
var id = _ref.id;
|
||||
return id === firstArg.value;
|
||||
});
|
||||
|
||||
if (offsetInParams === -1) {
|
||||
throw new Error("".concat(firstArg.value, " not found in ").concat(instrNode.id, ": not declared in func params"));
|
||||
} // Replace the Identifer node by our new NumberLiteral node
|
||||
|
||||
|
||||
instrNode.args[0] = numberLiteralFromRaw(offsetInParams);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Global access
|
||||
*/
|
||||
|
||||
|
||||
if (instrNode.id === "get_global" || instrNode.id === "set_global") {
|
||||
var _instrNode$args2 = _slicedToArray(instrNode.args, 1),
|
||||
_firstArg = _instrNode$args2[0];
|
||||
|
||||
if (isIdentifier(_firstArg) === true) {
|
||||
var globalOffset = moduleContext.getGlobalOffsetByIdentifier( // $FlowIgnore: reference?
|
||||
_firstArg.value);
|
||||
|
||||
if (typeof globalOffset === "undefined") {
|
||||
// $FlowIgnore: reference?
|
||||
throw new Error("global ".concat(_firstArg.value, " not found in module"));
|
||||
} // Replace the Identifer node by our new NumberLiteral node
|
||||
|
||||
|
||||
instrNode.args[0] = numberLiteralFromRaw(globalOffset);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Labels lookup
|
||||
*/
|
||||
|
||||
|
||||
if (instrNode.id === "br") {
|
||||
var _instrNode$args3 = _slicedToArray(instrNode.args, 1),
|
||||
_firstArg2 = _instrNode$args3[0];
|
||||
|
||||
if (isIdentifier(_firstArg2) === true) {
|
||||
// if the labels is not found it is going to be replaced with -1
|
||||
// which is invalid.
|
||||
var relativeBlockCount = -1; // $FlowIgnore: reference?
|
||||
|
||||
instrPath.findParent(function (_ref2) {
|
||||
var node = _ref2.node;
|
||||
|
||||
if (isBlock(node)) {
|
||||
relativeBlockCount++; // $FlowIgnore: reference?
|
||||
|
||||
var name = node.label || node.name;
|
||||
|
||||
if (_typeof(name) === "object") {
|
||||
// $FlowIgnore: isIdentifier ensures that
|
||||
if (name.value === _firstArg2.value) {
|
||||
// Found it
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isFunc(node)) {
|
||||
return false;
|
||||
}
|
||||
}); // Replace the Identifer node by our new NumberLiteral node
|
||||
|
||||
instrNode.args[0] = numberLiteralFromRaw(relativeBlockCount);
|
||||
}
|
||||
}
|
||||
}),
|
||||
|
||||
/**
|
||||
* Func lookup
|
||||
*/
|
||||
CallInstruction: function (_CallInstruction) {
|
||||
function CallInstruction(_x5) {
|
||||
return _CallInstruction.apply(this, arguments);
|
||||
}
|
||||
|
||||
CallInstruction.toString = function () {
|
||||
return _CallInstruction.toString();
|
||||
};
|
||||
|
||||
return CallInstruction;
|
||||
}(function (_ref3) {
|
||||
var node = _ref3.node;
|
||||
var index = node.index;
|
||||
|
||||
if (isIdentifier(index) === true) {
|
||||
var offsetInModule = moduleContext.getFunctionOffsetByIdentifier(index.value);
|
||||
|
||||
if (typeof offsetInModule === "undefined") {
|
||||
throw newUnexpectedFunction(index.value);
|
||||
} // Replace the index Identifier
|
||||
// $FlowIgnore: reference?
|
||||
|
||||
|
||||
node.index = numberLiteralFromRaw(offsetInModule);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
96
node_modules/@webassemblyjs/ast/esm/traverse.js
generated
vendored
96
node_modules/@webassemblyjs/ast/esm/traverse.js
generated
vendored
|
|
@ -1,96 +0,0 @@
|
|||
import { createPath } from "./node-path";
|
||||
import { unionTypesMap, nodeAndUnionTypes } from "./nodes"; // recursively walks the AST starting at the given node. The callback is invoked for
|
||||
// and object that has a 'type' property.
|
||||
|
||||
function walk(context, callback) {
|
||||
var stop = false;
|
||||
|
||||
function innerWalk(context, callback) {
|
||||
if (stop) {
|
||||
return;
|
||||
}
|
||||
|
||||
var node = context.node;
|
||||
|
||||
if (node === undefined) {
|
||||
console.warn("traversing with an empty context");
|
||||
return;
|
||||
}
|
||||
|
||||
if (node._deleted === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
var path = createPath(context);
|
||||
callback(node.type, path);
|
||||
|
||||
if (path.shouldStop) {
|
||||
stop = true;
|
||||
return;
|
||||
}
|
||||
|
||||
Object.keys(node).forEach(function (prop) {
|
||||
var value = node[prop];
|
||||
|
||||
if (value === null || value === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
var valueAsArray = Array.isArray(value) ? value : [value];
|
||||
valueAsArray.forEach(function (childNode) {
|
||||
if (typeof childNode.type === "string") {
|
||||
var childContext = {
|
||||
node: childNode,
|
||||
parentKey: prop,
|
||||
parentPath: path,
|
||||
shouldStop: false,
|
||||
inList: Array.isArray(value)
|
||||
};
|
||||
innerWalk(childContext, callback);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
innerWalk(context, callback);
|
||||
}
|
||||
|
||||
var noop = function noop() {};
|
||||
|
||||
export function traverse(node, visitors) {
|
||||
var before = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : noop;
|
||||
var after = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : noop;
|
||||
Object.keys(visitors).forEach(function (visitor) {
|
||||
if (!nodeAndUnionTypes.includes(visitor)) {
|
||||
throw new Error("Unexpected visitor ".concat(visitor));
|
||||
}
|
||||
});
|
||||
var context = {
|
||||
node: node,
|
||||
inList: false,
|
||||
shouldStop: false,
|
||||
parentPath: null,
|
||||
parentKey: null
|
||||
};
|
||||
walk(context, function (type, path) {
|
||||
if (typeof visitors[type] === "function") {
|
||||
before(type, path);
|
||||
visitors[type](path);
|
||||
after(type, path);
|
||||
}
|
||||
|
||||
var unionTypes = unionTypesMap[type];
|
||||
|
||||
if (!unionTypes) {
|
||||
throw new Error("Unexpected node type ".concat(type));
|
||||
}
|
||||
|
||||
unionTypes.forEach(function (unionType) {
|
||||
if (typeof visitors[unionType] === "function") {
|
||||
before(unionType, path);
|
||||
visitors[unionType](path);
|
||||
after(unionType, path);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
0
node_modules/@webassemblyjs/ast/esm/types/basic.js
generated
vendored
0
node_modules/@webassemblyjs/ast/esm/types/basic.js
generated
vendored
0
node_modules/@webassemblyjs/ast/esm/types/nodes.js
generated
vendored
0
node_modules/@webassemblyjs/ast/esm/types/nodes.js
generated
vendored
0
node_modules/@webassemblyjs/ast/esm/types/traverse.js
generated
vendored
0
node_modules/@webassemblyjs/ast/esm/types/traverse.js
generated
vendored
265
node_modules/@webassemblyjs/ast/esm/utils.js
generated
vendored
265
node_modules/@webassemblyjs/ast/esm/utils.js
generated
vendored
|
|
@ -1,265 +0,0 @@
|
|||
function _sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
||||
|
||||
function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return _sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }
|
||||
|
||||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
import { signatures } from "./signatures";
|
||||
import { traverse } from "./traverse";
|
||||
import constants from "@webassemblyjs/helper-wasm-bytecode";
|
||||
import { getSectionForNode } from "@webassemblyjs/helper-wasm-bytecode";
|
||||
export function isAnonymous(ident) {
|
||||
return ident.raw === "";
|
||||
}
|
||||
export function getSectionMetadata(ast, name) {
|
||||
var section;
|
||||
traverse(ast, {
|
||||
SectionMetadata: function (_SectionMetadata) {
|
||||
function SectionMetadata(_x) {
|
||||
return _SectionMetadata.apply(this, arguments);
|
||||
}
|
||||
|
||||
SectionMetadata.toString = function () {
|
||||
return _SectionMetadata.toString();
|
||||
};
|
||||
|
||||
return SectionMetadata;
|
||||
}(function (_ref) {
|
||||
var node = _ref.node;
|
||||
|
||||
if (node.section === name) {
|
||||
section = node;
|
||||
}
|
||||
})
|
||||
});
|
||||
return section;
|
||||
}
|
||||
export function getSectionMetadatas(ast, name) {
|
||||
var sections = [];
|
||||
traverse(ast, {
|
||||
SectionMetadata: function (_SectionMetadata2) {
|
||||
function SectionMetadata(_x2) {
|
||||
return _SectionMetadata2.apply(this, arguments);
|
||||
}
|
||||
|
||||
SectionMetadata.toString = function () {
|
||||
return _SectionMetadata2.toString();
|
||||
};
|
||||
|
||||
return SectionMetadata;
|
||||
}(function (_ref2) {
|
||||
var node = _ref2.node;
|
||||
|
||||
if (node.section === name) {
|
||||
sections.push(node);
|
||||
}
|
||||
})
|
||||
});
|
||||
return sections;
|
||||
}
|
||||
export function sortSectionMetadata(m) {
|
||||
if (m.metadata == null) {
|
||||
console.warn("sortSectionMetadata: no metadata to sort");
|
||||
return;
|
||||
} // $FlowIgnore
|
||||
|
||||
|
||||
m.metadata.sections.sort(function (a, b) {
|
||||
var aId = constants.sections[a.section];
|
||||
var bId = constants.sections[b.section];
|
||||
|
||||
if (typeof aId !== "number" || typeof bId !== "number") {
|
||||
throw new Error("Section id not found");
|
||||
}
|
||||
|
||||
return aId - bId;
|
||||
});
|
||||
}
|
||||
export function orderedInsertNode(m, n) {
|
||||
assertHasLoc(n);
|
||||
var didInsert = false;
|
||||
|
||||
if (n.type === "ModuleExport") {
|
||||
m.fields.push(n);
|
||||
return;
|
||||
}
|
||||
|
||||
m.fields = m.fields.reduce(function (acc, field) {
|
||||
var fieldEndCol = Infinity;
|
||||
|
||||
if (field.loc != null) {
|
||||
// $FlowIgnore
|
||||
fieldEndCol = field.loc.end.column;
|
||||
} // $FlowIgnore: assertHasLoc ensures that
|
||||
|
||||
|
||||
if (didInsert === false && n.loc.start.column < fieldEndCol) {
|
||||
didInsert = true;
|
||||
acc.push(n);
|
||||
}
|
||||
|
||||
acc.push(field);
|
||||
return acc;
|
||||
}, []); // Handles empty modules or n is the last element
|
||||
|
||||
if (didInsert === false) {
|
||||
m.fields.push(n);
|
||||
}
|
||||
}
|
||||
export function assertHasLoc(n) {
|
||||
if (n.loc == null || n.loc.start == null || n.loc.end == null) {
|
||||
throw new Error("Internal failure: node (".concat(JSON.stringify(n.type), ") has no location information"));
|
||||
}
|
||||
}
|
||||
export function getEndOfSection(s) {
|
||||
assertHasLoc(s.size);
|
||||
return s.startOffset + s.size.value + ( // $FlowIgnore
|
||||
s.size.loc.end.column - s.size.loc.start.column);
|
||||
}
|
||||
export function shiftLoc(node, delta) {
|
||||
// $FlowIgnore
|
||||
node.loc.start.column += delta; // $FlowIgnore
|
||||
|
||||
node.loc.end.column += delta;
|
||||
}
|
||||
export function shiftSection(ast, node, delta) {
|
||||
if (node.type !== "SectionMetadata") {
|
||||
throw new Error("Can not shift node " + JSON.stringify(node.type));
|
||||
}
|
||||
|
||||
node.startOffset += delta;
|
||||
|
||||
if (_typeof(node.size.loc) === "object") {
|
||||
shiftLoc(node.size, delta);
|
||||
} // Custom sections doesn't have vectorOfSize
|
||||
|
||||
|
||||
if (_typeof(node.vectorOfSize) === "object" && _typeof(node.vectorOfSize.loc) === "object") {
|
||||
shiftLoc(node.vectorOfSize, delta);
|
||||
}
|
||||
|
||||
var sectionName = node.section; // shift node locations within that section
|
||||
|
||||
traverse(ast, {
|
||||
Node: function Node(_ref3) {
|
||||
var node = _ref3.node;
|
||||
var section = getSectionForNode(node);
|
||||
|
||||
if (section === sectionName && _typeof(node.loc) === "object") {
|
||||
shiftLoc(node, delta);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
export function signatureForOpcode(object, name) {
|
||||
var opcodeName = name;
|
||||
|
||||
if (object !== undefined && object !== "") {
|
||||
opcodeName = object + "." + name;
|
||||
}
|
||||
|
||||
var sign = signatures[opcodeName];
|
||||
|
||||
if (sign == undefined) {
|
||||
// TODO: Uncomment this when br_table and others has been done
|
||||
//throw new Error("Invalid opcode: "+opcodeName);
|
||||
return [object, object];
|
||||
}
|
||||
|
||||
return sign[0];
|
||||
}
|
||||
export function getUniqueNameGenerator() {
|
||||
var inc = {};
|
||||
return function () {
|
||||
var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "temp";
|
||||
|
||||
if (!(prefix in inc)) {
|
||||
inc[prefix] = 0;
|
||||
} else {
|
||||
inc[prefix] = inc[prefix] + 1;
|
||||
}
|
||||
|
||||
return prefix + "_" + inc[prefix];
|
||||
};
|
||||
}
|
||||
export function getStartByteOffset(n) {
|
||||
// $FlowIgnore
|
||||
if (typeof n.loc === "undefined" || typeof n.loc.start === "undefined") {
|
||||
throw new Error( // $FlowIgnore
|
||||
"Can not get byte offset without loc informations, node: " + String(n.id));
|
||||
}
|
||||
|
||||
return n.loc.start.column;
|
||||
}
|
||||
export function getEndByteOffset(n) {
|
||||
// $FlowIgnore
|
||||
if (typeof n.loc === "undefined" || typeof n.loc.end === "undefined") {
|
||||
throw new Error("Can not get byte offset without loc informations, node: " + n.type);
|
||||
}
|
||||
|
||||
return n.loc.end.column;
|
||||
}
|
||||
export function getFunctionBeginingByteOffset(n) {
|
||||
if (!(n.body.length > 0)) {
|
||||
throw new Error('n.body.length > 0' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
var _n$body = _slicedToArray(n.body, 1),
|
||||
firstInstruction = _n$body[0];
|
||||
|
||||
return getStartByteOffset(firstInstruction);
|
||||
}
|
||||
export function getEndBlockByteOffset(n) {
|
||||
// $FlowIgnore
|
||||
if (!(n.instr.length > 0 || n.body.length > 0)) {
|
||||
throw new Error('n.instr.length > 0 || n.body.length > 0' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
var lastInstruction;
|
||||
|
||||
if (n.instr) {
|
||||
// $FlowIgnore
|
||||
lastInstruction = n.instr[n.instr.length - 1];
|
||||
}
|
||||
|
||||
if (n.body) {
|
||||
// $FlowIgnore
|
||||
lastInstruction = n.body[n.body.length - 1];
|
||||
}
|
||||
|
||||
if (!(_typeof(lastInstruction) === "object")) {
|
||||
throw new Error('typeof lastInstruction === "object"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
// $FlowIgnore
|
||||
return getStartByteOffset(lastInstruction);
|
||||
}
|
||||
export function getStartBlockByteOffset(n) {
|
||||
// $FlowIgnore
|
||||
if (!(n.instr.length > 0 || n.body.length > 0)) {
|
||||
throw new Error('n.instr.length > 0 || n.body.length > 0' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
var fistInstruction;
|
||||
|
||||
if (n.instr) {
|
||||
// $FlowIgnore
|
||||
var _n$instr = _slicedToArray(n.instr, 1);
|
||||
|
||||
fistInstruction = _n$instr[0];
|
||||
}
|
||||
|
||||
if (n.body) {
|
||||
// $FlowIgnore
|
||||
var _n$body2 = _slicedToArray(n.body, 1);
|
||||
|
||||
fistInstruction = _n$body2[0];
|
||||
}
|
||||
|
||||
if (!(_typeof(fistInstruction) === "object")) {
|
||||
throw new Error('typeof fistInstruction === "object"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
// $FlowIgnore
|
||||
return getStartByteOffset(fistInstruction);
|
||||
}
|
||||
17
node_modules/@webassemblyjs/ast/lib/clone.js
generated
vendored
17
node_modules/@webassemblyjs/ast/lib/clone.js
generated
vendored
|
|
@ -1,17 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.cloneNode = cloneNode;
|
||||
|
||||
function cloneNode(n) {
|
||||
// $FlowIgnore
|
||||
var newObj = {};
|
||||
|
||||
for (var k in n) {
|
||||
newObj[k] = n[k];
|
||||
}
|
||||
|
||||
return newObj;
|
||||
}
|
||||
663
node_modules/@webassemblyjs/ast/lib/definitions.js
generated
vendored
663
node_modules/@webassemblyjs/ast/lib/definitions.js
generated
vendored
|
|
@ -1,663 +0,0 @@
|
|||
var definitions = {};
|
||||
|
||||
function defineType(typeName, metadata) {
|
||||
definitions[typeName] = metadata;
|
||||
}
|
||||
|
||||
defineType("Module", {
|
||||
spec: {
|
||||
wasm: "https://webassembly.github.io/spec/core/binary/modules.html#binary-module",
|
||||
wat: "https://webassembly.github.io/spec/core/text/modules.html#text-module"
|
||||
},
|
||||
doc: "A module consists of a sequence of sections (termed fields in the text format).",
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
id: {
|
||||
maybe: true,
|
||||
type: "string"
|
||||
},
|
||||
fields: {
|
||||
array: true,
|
||||
type: "Node"
|
||||
},
|
||||
metadata: {
|
||||
optional: true,
|
||||
type: "ModuleMetadata"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("ModuleMetadata", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
sections: {
|
||||
array: true,
|
||||
type: "SectionMetadata"
|
||||
},
|
||||
functionNames: {
|
||||
optional: true,
|
||||
array: true,
|
||||
type: "FunctionNameMetadata"
|
||||
},
|
||||
localNames: {
|
||||
optional: true,
|
||||
array: true,
|
||||
type: "ModuleMetadata"
|
||||
},
|
||||
producers: {
|
||||
optional: true,
|
||||
array: true,
|
||||
type: "ProducersSectionMetadata"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("ModuleNameMetadata", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
value: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("FunctionNameMetadata", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
value: {
|
||||
type: "string"
|
||||
},
|
||||
index: {
|
||||
type: "number"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("LocalNameMetadata", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
value: {
|
||||
type: "string"
|
||||
},
|
||||
localIndex: {
|
||||
type: "number"
|
||||
},
|
||||
functionIndex: {
|
||||
type: "number"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("BinaryModule", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
id: {
|
||||
maybe: true,
|
||||
type: "string"
|
||||
},
|
||||
blob: {
|
||||
array: true,
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("QuoteModule", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
id: {
|
||||
maybe: true,
|
||||
type: "string"
|
||||
},
|
||||
string: {
|
||||
array: true,
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("SectionMetadata", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
section: {
|
||||
type: "SectionName"
|
||||
},
|
||||
startOffset: {
|
||||
type: "number"
|
||||
},
|
||||
size: {
|
||||
type: "NumberLiteral"
|
||||
},
|
||||
vectorOfSize: {
|
||||
comment: "Size of the vector in the section (if any)",
|
||||
type: "NumberLiteral"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("ProducersSectionMetadata", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
producers: {
|
||||
array: true,
|
||||
type: "ProducerMetadata"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("ProducerMetadata", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
language: {
|
||||
type: "ProducerMetadataVersionedName",
|
||||
array: true
|
||||
},
|
||||
processedBy: {
|
||||
type: "ProducerMetadataVersionedName",
|
||||
array: true
|
||||
},
|
||||
sdk: {
|
||||
type: "ProducerMetadataVersionedName",
|
||||
array: true
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("ProducerMetadataVersionedName", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
name: {
|
||||
type: "string"
|
||||
},
|
||||
version: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
/*
|
||||
Instructions
|
||||
*/
|
||||
|
||||
defineType("LoopInstruction", {
|
||||
unionType: ["Node", "Block", "Instruction"],
|
||||
fields: {
|
||||
id: {
|
||||
constant: true,
|
||||
type: "string",
|
||||
value: "loop"
|
||||
},
|
||||
label: {
|
||||
maybe: true,
|
||||
type: "Identifier"
|
||||
},
|
||||
resulttype: {
|
||||
maybe: true,
|
||||
type: "Valtype"
|
||||
},
|
||||
instr: {
|
||||
array: true,
|
||||
type: "Instruction"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Instr", {
|
||||
unionType: ["Node", "Expression", "Instruction"],
|
||||
fields: {
|
||||
id: {
|
||||
type: "string"
|
||||
},
|
||||
object: {
|
||||
optional: true,
|
||||
type: "Valtype"
|
||||
},
|
||||
args: {
|
||||
array: true,
|
||||
type: "Expression"
|
||||
},
|
||||
namedArgs: {
|
||||
optional: true,
|
||||
type: "Object"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("IfInstruction", {
|
||||
unionType: ["Node", "Instruction"],
|
||||
fields: {
|
||||
id: {
|
||||
constant: true,
|
||||
type: "string",
|
||||
value: "if"
|
||||
},
|
||||
testLabel: {
|
||||
comment: "only for WAST",
|
||||
type: "Identifier"
|
||||
},
|
||||
test: {
|
||||
array: true,
|
||||
type: "Instruction"
|
||||
},
|
||||
result: {
|
||||
maybe: true,
|
||||
type: "Valtype"
|
||||
},
|
||||
consequent: {
|
||||
array: true,
|
||||
type: "Instruction"
|
||||
},
|
||||
alternate: {
|
||||
array: true,
|
||||
type: "Instruction"
|
||||
}
|
||||
}
|
||||
});
|
||||
/*
|
||||
Concrete value types
|
||||
*/
|
||||
|
||||
defineType("StringLiteral", {
|
||||
unionType: ["Node", "Expression"],
|
||||
fields: {
|
||||
value: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("NumberLiteral", {
|
||||
unionType: ["Node", "NumericLiteral", "Expression"],
|
||||
fields: {
|
||||
value: {
|
||||
type: "number"
|
||||
},
|
||||
raw: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("LongNumberLiteral", {
|
||||
unionType: ["Node", "NumericLiteral", "Expression"],
|
||||
fields: {
|
||||
value: {
|
||||
type: "LongNumber"
|
||||
},
|
||||
raw: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("FloatLiteral", {
|
||||
unionType: ["Node", "NumericLiteral", "Expression"],
|
||||
fields: {
|
||||
value: {
|
||||
type: "number"
|
||||
},
|
||||
nan: {
|
||||
optional: true,
|
||||
type: "boolean"
|
||||
},
|
||||
inf: {
|
||||
optional: true,
|
||||
type: "boolean"
|
||||
},
|
||||
raw: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Elem", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
table: {
|
||||
type: "Index"
|
||||
},
|
||||
offset: {
|
||||
array: true,
|
||||
type: "Instruction"
|
||||
},
|
||||
funcs: {
|
||||
array: true,
|
||||
type: "Index"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("IndexInFuncSection", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
index: {
|
||||
type: "Index"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("ValtypeLiteral", {
|
||||
unionType: ["Node", "Expression"],
|
||||
fields: {
|
||||
name: {
|
||||
type: "Valtype"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("TypeInstruction", {
|
||||
unionType: ["Node", "Instruction"],
|
||||
fields: {
|
||||
id: {
|
||||
maybe: true,
|
||||
type: "Index"
|
||||
},
|
||||
functype: {
|
||||
type: "Signature"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Start", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
index: {
|
||||
type: "Index"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("GlobalType", {
|
||||
unionType: ["Node", "ImportDescr"],
|
||||
fields: {
|
||||
valtype: {
|
||||
type: "Valtype"
|
||||
},
|
||||
mutability: {
|
||||
type: "Mutability"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("LeadingComment", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
value: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("BlockComment", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
value: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Data", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
memoryIndex: {
|
||||
type: "Memidx"
|
||||
},
|
||||
offset: {
|
||||
type: "Instruction"
|
||||
},
|
||||
init: {
|
||||
type: "ByteArray"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Global", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
globalType: {
|
||||
type: "GlobalType"
|
||||
},
|
||||
init: {
|
||||
array: true,
|
||||
type: "Instruction"
|
||||
},
|
||||
name: {
|
||||
maybe: true,
|
||||
type: "Identifier"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Table", {
|
||||
unionType: ["Node", "ImportDescr"],
|
||||
fields: {
|
||||
elementType: {
|
||||
type: "TableElementType"
|
||||
},
|
||||
limits: {
|
||||
assertNodeType: true,
|
||||
type: "Limit"
|
||||
},
|
||||
name: {
|
||||
maybe: true,
|
||||
type: "Identifier"
|
||||
},
|
||||
elements: {
|
||||
array: true,
|
||||
optional: true,
|
||||
type: "Index"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Memory", {
|
||||
unionType: ["Node", "ImportDescr"],
|
||||
fields: {
|
||||
limits: {
|
||||
type: "Limit"
|
||||
},
|
||||
id: {
|
||||
maybe: true,
|
||||
type: "Index"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("FuncImportDescr", {
|
||||
unionType: ["Node", "ImportDescr"],
|
||||
fields: {
|
||||
id: {
|
||||
type: "Identifier"
|
||||
},
|
||||
signature: {
|
||||
type: "Signature"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("ModuleImport", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
module: {
|
||||
type: "string"
|
||||
},
|
||||
name: {
|
||||
type: "string"
|
||||
},
|
||||
descr: {
|
||||
type: "ImportDescr"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("ModuleExportDescr", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
exportType: {
|
||||
type: "ExportDescrType"
|
||||
},
|
||||
id: {
|
||||
type: "Index"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("ModuleExport", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
name: {
|
||||
type: "string"
|
||||
},
|
||||
descr: {
|
||||
type: "ModuleExportDescr"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Limit", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
min: {
|
||||
type: "number"
|
||||
},
|
||||
max: {
|
||||
optional: true,
|
||||
type: "number"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Signature", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
params: {
|
||||
array: true,
|
||||
type: "FuncParam"
|
||||
},
|
||||
results: {
|
||||
array: true,
|
||||
type: "Valtype"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Program", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
body: {
|
||||
array: true,
|
||||
type: "Node"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Identifier", {
|
||||
unionType: ["Node", "Expression"],
|
||||
fields: {
|
||||
value: {
|
||||
type: "string"
|
||||
},
|
||||
raw: {
|
||||
optional: true,
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("BlockInstruction", {
|
||||
unionType: ["Node", "Block", "Instruction"],
|
||||
fields: {
|
||||
id: {
|
||||
constant: true,
|
||||
type: "string",
|
||||
value: "block"
|
||||
},
|
||||
label: {
|
||||
maybe: true,
|
||||
type: "Identifier"
|
||||
},
|
||||
instr: {
|
||||
array: true,
|
||||
type: "Instruction"
|
||||
},
|
||||
result: {
|
||||
maybe: true,
|
||||
type: "Valtype"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("CallInstruction", {
|
||||
unionType: ["Node", "Instruction"],
|
||||
fields: {
|
||||
id: {
|
||||
constant: true,
|
||||
type: "string",
|
||||
value: "call"
|
||||
},
|
||||
index: {
|
||||
type: "Index"
|
||||
},
|
||||
instrArgs: {
|
||||
array: true,
|
||||
optional: true,
|
||||
type: "Expression"
|
||||
},
|
||||
numeric: {
|
||||
type: "Index",
|
||||
optional: true
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("CallIndirectInstruction", {
|
||||
unionType: ["Node", "Instruction"],
|
||||
fields: {
|
||||
id: {
|
||||
constant: true,
|
||||
type: "string",
|
||||
value: "call_indirect"
|
||||
},
|
||||
signature: {
|
||||
type: "SignatureOrTypeRef"
|
||||
},
|
||||
intrs: {
|
||||
array: true,
|
||||
optional: true,
|
||||
type: "Expression"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("ByteArray", {
|
||||
unionType: ["Node"],
|
||||
fields: {
|
||||
values: {
|
||||
array: true,
|
||||
type: "Byte"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("Func", {
|
||||
unionType: ["Node", "Block"],
|
||||
fields: {
|
||||
name: {
|
||||
maybe: true,
|
||||
type: "Index"
|
||||
},
|
||||
signature: {
|
||||
type: "SignatureOrTypeRef"
|
||||
},
|
||||
body: {
|
||||
array: true,
|
||||
type: "Instruction"
|
||||
},
|
||||
isExternal: {
|
||||
comment: "means that it has been imported from the outside js",
|
||||
optional: true,
|
||||
type: "boolean"
|
||||
},
|
||||
metadata: {
|
||||
optional: true,
|
||||
type: "FuncMetadata"
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Intrinsics
|
||||
*/
|
||||
|
||||
defineType("InternalBrUnless", {
|
||||
unionType: ["Node", "Intrinsic"],
|
||||
fields: {
|
||||
target: {
|
||||
type: "number"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("InternalGoto", {
|
||||
unionType: ["Node", "Intrinsic"],
|
||||
fields: {
|
||||
target: {
|
||||
type: "number"
|
||||
}
|
||||
}
|
||||
});
|
||||
defineType("InternalCallExtern", {
|
||||
unionType: ["Node", "Intrinsic"],
|
||||
fields: {
|
||||
target: {
|
||||
type: "number"
|
||||
}
|
||||
}
|
||||
}); // function bodies are terminated by an `end` instruction but are missing a
|
||||
// return instruction
|
||||
//
|
||||
// Since we can't inject a new instruction we are injecting a new instruction.
|
||||
|
||||
defineType("InternalEndAndReturn", {
|
||||
unionType: ["Node", "Intrinsic"],
|
||||
fields: {}
|
||||
});
|
||||
module.exports = definitions;
|
||||
118
node_modules/@webassemblyjs/ast/lib/index.js
generated
vendored
118
node_modules/@webassemblyjs/ast/lib/index.js
generated
vendored
|
|
@ -1,118 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
var _exportNames = {
|
||||
numberLiteralFromRaw: true,
|
||||
withLoc: true,
|
||||
withRaw: true,
|
||||
funcParam: true,
|
||||
indexLiteral: true,
|
||||
memIndexLiteral: true,
|
||||
instruction: true,
|
||||
objectInstruction: true,
|
||||
traverse: true,
|
||||
signatures: true,
|
||||
cloneNode: true
|
||||
};
|
||||
Object.defineProperty(exports, "numberLiteralFromRaw", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _nodeHelpers.numberLiteralFromRaw;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "withLoc", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _nodeHelpers.withLoc;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "withRaw", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _nodeHelpers.withRaw;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "funcParam", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _nodeHelpers.funcParam;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "indexLiteral", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _nodeHelpers.indexLiteral;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "memIndexLiteral", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _nodeHelpers.memIndexLiteral;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "instruction", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _nodeHelpers.instruction;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "objectInstruction", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _nodeHelpers.objectInstruction;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "traverse", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _traverse.traverse;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "signatures", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _signatures.signatures;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "cloneNode", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _clone.cloneNode;
|
||||
}
|
||||
});
|
||||
|
||||
var _nodes = require("./nodes");
|
||||
|
||||
Object.keys(_nodes).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _nodes[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _nodeHelpers = require("./node-helpers.js");
|
||||
|
||||
var _traverse = require("./traverse");
|
||||
|
||||
var _signatures = require("./signatures");
|
||||
|
||||
var _utils = require("./utils");
|
||||
|
||||
Object.keys(_utils).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _utils[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _clone = require("./clone");
|
||||
107
node_modules/@webassemblyjs/ast/lib/node-helpers.js
generated
vendored
107
node_modules/@webassemblyjs/ast/lib/node-helpers.js
generated
vendored
|
|
@ -1,107 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.numberLiteralFromRaw = numberLiteralFromRaw;
|
||||
exports.instruction = instruction;
|
||||
exports.objectInstruction = objectInstruction;
|
||||
exports.withLoc = withLoc;
|
||||
exports.withRaw = withRaw;
|
||||
exports.funcParam = funcParam;
|
||||
exports.indexLiteral = indexLiteral;
|
||||
exports.memIndexLiteral = memIndexLiteral;
|
||||
|
||||
var _wastParser = require("@webassemblyjs/wast-parser");
|
||||
|
||||
var _nodes = require("./nodes");
|
||||
|
||||
function numberLiteralFromRaw(rawValue) {
|
||||
var instructionType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "i32";
|
||||
var original = rawValue; // Remove numeric separators _
|
||||
|
||||
if (typeof rawValue === "string") {
|
||||
rawValue = rawValue.replace(/_/g, "");
|
||||
}
|
||||
|
||||
if (typeof rawValue === "number") {
|
||||
return (0, _nodes.numberLiteral)(rawValue, String(original));
|
||||
} else {
|
||||
switch (instructionType) {
|
||||
case "i32":
|
||||
{
|
||||
return (0, _nodes.numberLiteral)((0, _wastParser.parse32I)(rawValue), String(original));
|
||||
}
|
||||
|
||||
case "u32":
|
||||
{
|
||||
return (0, _nodes.numberLiteral)((0, _wastParser.parseU32)(rawValue), String(original));
|
||||
}
|
||||
|
||||
case "i64":
|
||||
{
|
||||
return (0, _nodes.longNumberLiteral)((0, _wastParser.parse64I)(rawValue), String(original));
|
||||
}
|
||||
|
||||
case "f32":
|
||||
{
|
||||
return (0, _nodes.floatLiteral)((0, _wastParser.parse32F)(rawValue), (0, _wastParser.isNanLiteral)(rawValue), (0, _wastParser.isInfLiteral)(rawValue), String(original));
|
||||
}
|
||||
// f64
|
||||
|
||||
default:
|
||||
{
|
||||
return (0, _nodes.floatLiteral)((0, _wastParser.parse64F)(rawValue), (0, _wastParser.isNanLiteral)(rawValue), (0, _wastParser.isInfLiteral)(rawValue), String(original));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function instruction(id) {
|
||||
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
||||
var namedArgs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
||||
return (0, _nodes.instr)(id, undefined, args, namedArgs);
|
||||
}
|
||||
|
||||
function objectInstruction(id, object) {
|
||||
var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
||||
var namedArgs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
||||
return (0, _nodes.instr)(id, object, args, namedArgs);
|
||||
}
|
||||
/**
|
||||
* Decorators
|
||||
*/
|
||||
|
||||
|
||||
function withLoc(n, end, start) {
|
||||
var loc = {
|
||||
start: start,
|
||||
end: end
|
||||
};
|
||||
n.loc = loc;
|
||||
return n;
|
||||
}
|
||||
|
||||
function withRaw(n, raw) {
|
||||
n.raw = raw;
|
||||
return n;
|
||||
}
|
||||
|
||||
function funcParam(valtype, id) {
|
||||
return {
|
||||
id: id,
|
||||
valtype: valtype
|
||||
};
|
||||
}
|
||||
|
||||
function indexLiteral(value) {
|
||||
// $FlowIgnore
|
||||
var x = numberLiteralFromRaw(value, "u32");
|
||||
return x;
|
||||
}
|
||||
|
||||
function memIndexLiteral(value) {
|
||||
// $FlowIgnore
|
||||
var x = numberLiteralFromRaw(value, "u32");
|
||||
return x;
|
||||
}
|
||||
144
node_modules/@webassemblyjs/ast/lib/node-path.js
generated
vendored
144
node_modules/@webassemblyjs/ast/lib/node-path.js
generated
vendored
|
|
@ -1,144 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createPath = createPath;
|
||||
|
||||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
|
||||
function findParent(_ref, cb) {
|
||||
var parentPath = _ref.parentPath;
|
||||
|
||||
if (parentPath == null) {
|
||||
throw new Error("node is root");
|
||||
}
|
||||
|
||||
var currentPath = parentPath;
|
||||
|
||||
while (cb(currentPath) !== false) {
|
||||
// Hit the root node, stop
|
||||
// $FlowIgnore
|
||||
if (currentPath.parentPath == null) {
|
||||
return null;
|
||||
} // $FlowIgnore
|
||||
|
||||
|
||||
currentPath = currentPath.parentPath;
|
||||
}
|
||||
|
||||
return currentPath.node;
|
||||
}
|
||||
|
||||
function insertBefore(context, newNode) {
|
||||
return insert(context, newNode);
|
||||
}
|
||||
|
||||
function insertAfter(context, newNode) {
|
||||
return insert(context, newNode, 1);
|
||||
}
|
||||
|
||||
function insert(_ref2, newNode) {
|
||||
var node = _ref2.node,
|
||||
inList = _ref2.inList,
|
||||
parentPath = _ref2.parentPath,
|
||||
parentKey = _ref2.parentKey;
|
||||
var indexOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
||||
|
||||
if (!inList) {
|
||||
throw new Error('inList' + " error: " + ("insert can only be used for nodes that are within lists" || "unknown"));
|
||||
}
|
||||
|
||||
if (!(parentPath != null)) {
|
||||
throw new Error('parentPath != null' + " error: " + ("Can not remove root node" || "unknown"));
|
||||
}
|
||||
|
||||
// $FlowIgnore
|
||||
var parentList = parentPath.node[parentKey];
|
||||
var indexInList = parentList.findIndex(function (n) {
|
||||
return n === node;
|
||||
});
|
||||
parentList.splice(indexInList + indexOffset, 0, newNode);
|
||||
}
|
||||
|
||||
function remove(_ref3) {
|
||||
var node = _ref3.node,
|
||||
parentKey = _ref3.parentKey,
|
||||
parentPath = _ref3.parentPath;
|
||||
|
||||
if (!(parentPath != null)) {
|
||||
throw new Error('parentPath != null' + " error: " + ("Can not remove root node" || "unknown"));
|
||||
}
|
||||
|
||||
// $FlowIgnore
|
||||
var parentNode = parentPath.node; // $FlowIgnore
|
||||
|
||||
var parentProperty = parentNode[parentKey];
|
||||
|
||||
if (Array.isArray(parentProperty)) {
|
||||
// $FlowIgnore
|
||||
parentNode[parentKey] = parentProperty.filter(function (n) {
|
||||
return n !== node;
|
||||
});
|
||||
} else {
|
||||
// $FlowIgnore
|
||||
delete parentNode[parentKey];
|
||||
}
|
||||
|
||||
node._deleted = true;
|
||||
}
|
||||
|
||||
function stop(context) {
|
||||
context.shouldStop = true;
|
||||
}
|
||||
|
||||
function replaceWith(context, newNode) {
|
||||
// $FlowIgnore
|
||||
var parentNode = context.parentPath.node; // $FlowIgnore
|
||||
|
||||
var parentProperty = parentNode[context.parentKey];
|
||||
|
||||
if (Array.isArray(parentProperty)) {
|
||||
var indexInList = parentProperty.findIndex(function (n) {
|
||||
return n === context.node;
|
||||
});
|
||||
parentProperty.splice(indexInList, 1, newNode);
|
||||
} else {
|
||||
// $FlowIgnore
|
||||
parentNode[context.parentKey] = newNode;
|
||||
}
|
||||
|
||||
context.node._deleted = true;
|
||||
context.node = newNode;
|
||||
} // bind the context to the first argument of node operations
|
||||
|
||||
|
||||
function bindNodeOperations(operations, context) {
|
||||
var keys = Object.keys(operations);
|
||||
var boundOperations = {};
|
||||
keys.forEach(function (key) {
|
||||
boundOperations[key] = operations[key].bind(null, context);
|
||||
});
|
||||
return boundOperations;
|
||||
}
|
||||
|
||||
function createPathOperations(context) {
|
||||
// $FlowIgnore
|
||||
return bindNodeOperations({
|
||||
findParent: findParent,
|
||||
replaceWith: replaceWith,
|
||||
remove: remove,
|
||||
insertBefore: insertBefore,
|
||||
insertAfter: insertAfter,
|
||||
stop: stop
|
||||
}, context);
|
||||
}
|
||||
|
||||
function createPath(context) {
|
||||
var path = _extends({}, context); // $FlowIgnore
|
||||
|
||||
|
||||
Object.assign(path, createPathOperations(path)); // $FlowIgnore
|
||||
|
||||
return path;
|
||||
}
|
||||
1134
node_modules/@webassemblyjs/ast/lib/nodes.js
generated
vendored
1134
node_modules/@webassemblyjs/ast/lib/nodes.js
generated
vendored
File diff suppressed because it is too large
Load diff
207
node_modules/@webassemblyjs/ast/lib/signatures.js
generated
vendored
207
node_modules/@webassemblyjs/ast/lib/signatures.js
generated
vendored
|
|
@ -1,207 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.signatures = void 0;
|
||||
|
||||
function sign(input, output) {
|
||||
return [input, output];
|
||||
}
|
||||
|
||||
var u32 = "u32";
|
||||
var i32 = "i32";
|
||||
var i64 = "i64";
|
||||
var f32 = "f32";
|
||||
var f64 = "f64";
|
||||
|
||||
var vector = function vector(t) {
|
||||
var vecType = [t]; // $FlowIgnore
|
||||
|
||||
vecType.vector = true;
|
||||
return vecType;
|
||||
};
|
||||
|
||||
var controlInstructions = {
|
||||
unreachable: sign([], []),
|
||||
nop: sign([], []),
|
||||
// block ?
|
||||
// loop ?
|
||||
// if ?
|
||||
// if else ?
|
||||
br: sign([u32], []),
|
||||
br_if: sign([u32], []),
|
||||
br_table: sign(vector(u32), []),
|
||||
return: sign([], []),
|
||||
call: sign([u32], []),
|
||||
call_indirect: sign([u32], [])
|
||||
};
|
||||
var parametricInstructions = {
|
||||
drop: sign([], []),
|
||||
select: sign([], [])
|
||||
};
|
||||
var variableInstructions = {
|
||||
get_local: sign([u32], []),
|
||||
set_local: sign([u32], []),
|
||||
tee_local: sign([u32], []),
|
||||
get_global: sign([u32], []),
|
||||
set_global: sign([u32], [])
|
||||
};
|
||||
var memoryInstructions = {
|
||||
"i32.load": sign([u32, u32], [i32]),
|
||||
"i64.load": sign([u32, u32], []),
|
||||
"f32.load": sign([u32, u32], []),
|
||||
"f64.load": sign([u32, u32], []),
|
||||
"i32.load8_s": sign([u32, u32], [i32]),
|
||||
"i32.load8_u": sign([u32, u32], [i32]),
|
||||
"i32.load16_s": sign([u32, u32], [i32]),
|
||||
"i32.load16_u": sign([u32, u32], [i32]),
|
||||
"i64.load8_s": sign([u32, u32], [i64]),
|
||||
"i64.load8_u": sign([u32, u32], [i64]),
|
||||
"i64.load16_s": sign([u32, u32], [i64]),
|
||||
"i64.load16_u": sign([u32, u32], [i64]),
|
||||
"i64.load32_s": sign([u32, u32], [i64]),
|
||||
"i64.load32_u": sign([u32, u32], [i64]),
|
||||
"i32.store": sign([u32, u32], []),
|
||||
"i64.store": sign([u32, u32], []),
|
||||
"f32.store": sign([u32, u32], []),
|
||||
"f64.store": sign([u32, u32], []),
|
||||
"i32.store8": sign([u32, u32], []),
|
||||
"i32.store16": sign([u32, u32], []),
|
||||
"i64.store8": sign([u32, u32], []),
|
||||
"i64.store16": sign([u32, u32], []),
|
||||
"i64.store32": sign([u32, u32], []),
|
||||
current_memory: sign([], []),
|
||||
grow_memory: sign([], [])
|
||||
};
|
||||
var numericInstructions = {
|
||||
"i32.const": sign([i32], [i32]),
|
||||
"i64.const": sign([i64], [i64]),
|
||||
"f32.const": sign([f32], [f32]),
|
||||
"f64.const": sign([f64], [f64]),
|
||||
"i32.eqz": sign([i32], [i32]),
|
||||
"i32.eq": sign([i32, i32], [i32]),
|
||||
"i32.ne": sign([i32, i32], [i32]),
|
||||
"i32.lt_s": sign([i32, i32], [i32]),
|
||||
"i32.lt_u": sign([i32, i32], [i32]),
|
||||
"i32.gt_s": sign([i32, i32], [i32]),
|
||||
"i32.gt_u": sign([i32, i32], [i32]),
|
||||
"i32.le_s": sign([i32, i32], [i32]),
|
||||
"i32.le_u": sign([i32, i32], [i32]),
|
||||
"i32.ge_s": sign([i32, i32], [i32]),
|
||||
"i32.ge_u": sign([i32, i32], [i32]),
|
||||
"i64.eqz": sign([i64], [i64]),
|
||||
"i64.eq": sign([i64, i64], [i32]),
|
||||
"i64.ne": sign([i64, i64], [i32]),
|
||||
"i64.lt_s": sign([i64, i64], [i32]),
|
||||
"i64.lt_u": sign([i64, i64], [i32]),
|
||||
"i64.gt_s": sign([i64, i64], [i32]),
|
||||
"i64.gt_u": sign([i64, i64], [i32]),
|
||||
"i64.le_s": sign([i64, i64], [i32]),
|
||||
"i64.le_u": sign([i64, i64], [i32]),
|
||||
"i64.ge_s": sign([i64, i64], [i32]),
|
||||
"i64.ge_u": sign([i64, i64], [i32]),
|
||||
"f32.eq": sign([f32, f32], [i32]),
|
||||
"f32.ne": sign([f32, f32], [i32]),
|
||||
"f32.lt": sign([f32, f32], [i32]),
|
||||
"f32.gt": sign([f32, f32], [i32]),
|
||||
"f32.le": sign([f32, f32], [i32]),
|
||||
"f32.ge": sign([f32, f32], [i32]),
|
||||
"f64.eq": sign([f64, f64], [i32]),
|
||||
"f64.ne": sign([f64, f64], [i32]),
|
||||
"f64.lt": sign([f64, f64], [i32]),
|
||||
"f64.gt": sign([f64, f64], [i32]),
|
||||
"f64.le": sign([f64, f64], [i32]),
|
||||
"f64.ge": sign([f64, f64], [i32]),
|
||||
"i32.clz": sign([i32], [i32]),
|
||||
"i32.ctz": sign([i32], [i32]),
|
||||
"i32.popcnt": sign([i32], [i32]),
|
||||
"i32.add": sign([i32, i32], [i32]),
|
||||
"i32.sub": sign([i32, i32], [i32]),
|
||||
"i32.mul": sign([i32, i32], [i32]),
|
||||
"i32.div_s": sign([i32, i32], [i32]),
|
||||
"i32.div_u": sign([i32, i32], [i32]),
|
||||
"i32.rem_s": sign([i32, i32], [i32]),
|
||||
"i32.rem_u": sign([i32, i32], [i32]),
|
||||
"i32.and": sign([i32, i32], [i32]),
|
||||
"i32.or": sign([i32, i32], [i32]),
|
||||
"i32.xor": sign([i32, i32], [i32]),
|
||||
"i32.shl": sign([i32, i32], [i32]),
|
||||
"i32.shr_s": sign([i32, i32], [i32]),
|
||||
"i32.shr_u": sign([i32, i32], [i32]),
|
||||
"i32.rotl": sign([i32, i32], [i32]),
|
||||
"i32.rotr": sign([i32, i32], [i32]),
|
||||
"i64.clz": sign([i64], [i64]),
|
||||
"i64.ctz": sign([i64], [i64]),
|
||||
"i64.popcnt": sign([i64], [i64]),
|
||||
"i64.add": sign([i64, i64], [i64]),
|
||||
"i64.sub": sign([i64, i64], [i64]),
|
||||
"i64.mul": sign([i64, i64], [i64]),
|
||||
"i64.div_s": sign([i64, i64], [i64]),
|
||||
"i64.div_u": sign([i64, i64], [i64]),
|
||||
"i64.rem_s": sign([i64, i64], [i64]),
|
||||
"i64.rem_u": sign([i64, i64], [i64]),
|
||||
"i64.and": sign([i64, i64], [i64]),
|
||||
"i64.or": sign([i64, i64], [i64]),
|
||||
"i64.xor": sign([i64, i64], [i64]),
|
||||
"i64.shl": sign([i64, i64], [i64]),
|
||||
"i64.shr_s": sign([i64, i64], [i64]),
|
||||
"i64.shr_u": sign([i64, i64], [i64]),
|
||||
"i64.rotl": sign([i64, i64], [i64]),
|
||||
"i64.rotr": sign([i64, i64], [i64]),
|
||||
"f32.abs": sign([f32], [f32]),
|
||||
"f32.neg": sign([f32], [f32]),
|
||||
"f32.ceil": sign([f32], [f32]),
|
||||
"f32.floor": sign([f32], [f32]),
|
||||
"f32.trunc": sign([f32], [f32]),
|
||||
"f32.nearest": sign([f32], [f32]),
|
||||
"f32.sqrt": sign([f32], [f32]),
|
||||
"f32.add": sign([f32, f32], [f32]),
|
||||
"f32.sub": sign([f32, f32], [f32]),
|
||||
"f32.mul": sign([f32, f32], [f32]),
|
||||
"f32.div": sign([f32, f32], [f32]),
|
||||
"f32.min": sign([f32, f32], [f32]),
|
||||
"f32.max": sign([f32, f32], [f32]),
|
||||
"f32.copysign": sign([f32, f32], [f32]),
|
||||
"f64.abs": sign([f64], [f64]),
|
||||
"f64.neg": sign([f64], [f64]),
|
||||
"f64.ceil": sign([f64], [f64]),
|
||||
"f64.floor": sign([f64], [f64]),
|
||||
"f64.trunc": sign([f64], [f64]),
|
||||
"f64.nearest": sign([f64], [f64]),
|
||||
"f64.sqrt": sign([f64], [f64]),
|
||||
"f64.add": sign([f64, f64], [f64]),
|
||||
"f64.sub": sign([f64, f64], [f64]),
|
||||
"f64.mul": sign([f64, f64], [f64]),
|
||||
"f64.div": sign([f64, f64], [f64]),
|
||||
"f64.min": sign([f64, f64], [f64]),
|
||||
"f64.max": sign([f64, f64], [f64]),
|
||||
"f64.copysign": sign([f64, f64], [f64]),
|
||||
"i32.wrap/i64": sign([i64], [i32]),
|
||||
"i32.trunc_s/f32": sign([f32], [i32]),
|
||||
"i32.trunc_u/f32": sign([f32], [i32]),
|
||||
"i32.trunc_s/f64": sign([f32], [i32]),
|
||||
"i32.trunc_u/f64": sign([f64], [i32]),
|
||||
"i64.extend_s/i32": sign([i32], [i64]),
|
||||
"i64.extend_u/i32": sign([i32], [i64]),
|
||||
"i64.trunc_s/f32": sign([f32], [i64]),
|
||||
"i64.trunc_u/f32": sign([f32], [i64]),
|
||||
"i64.trunc_s/f64": sign([f64], [i64]),
|
||||
"i64.trunc_u/f64": sign([f64], [i64]),
|
||||
"f32.convert_s/i32": sign([i32], [f32]),
|
||||
"f32.convert_u/i32": sign([i32], [f32]),
|
||||
"f32.convert_s/i64": sign([i64], [f32]),
|
||||
"f32.convert_u/i64": sign([i64], [f32]),
|
||||
"f32.demote/f64": sign([f64], [f32]),
|
||||
"f64.convert_s/i32": sign([i32], [f64]),
|
||||
"f64.convert_u/i32": sign([i32], [f64]),
|
||||
"f64.convert_s/i64": sign([i64], [f64]),
|
||||
"f64.convert_u/i64": sign([i64], [f64]),
|
||||
"f64.promote/f32": sign([f32], [f64]),
|
||||
"i32.reinterpret/f32": sign([f32], [i32]),
|
||||
"i64.reinterpret/f64": sign([f64], [i64]),
|
||||
"f32.reinterpret/i32": sign([i32], [f32]),
|
||||
"f64.reinterpret/i64": sign([i64], [f64])
|
||||
};
|
||||
var signatures = Object.assign({}, controlInstructions, parametricInstructions, variableInstructions, memoryInstructions, numericInstructions);
|
||||
exports.signatures = signatures;
|
||||
83
node_modules/@webassemblyjs/ast/lib/transform/denormalize-type-references/index.js
generated
vendored
83
node_modules/@webassemblyjs/ast/lib/transform/denormalize-type-references/index.js
generated
vendored
|
|
@ -1,83 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.transform = transform;
|
||||
|
||||
var t = require("../../index"); // func and call_indirect instructions can either define a signature inline, or
|
||||
// reference a signature, e.g.
|
||||
//
|
||||
// ;; inline signature
|
||||
// (func (result i64)
|
||||
// (i64.const 2)
|
||||
// )
|
||||
// ;; signature reference
|
||||
// (type (func (result i64)))
|
||||
// (func (type 0)
|
||||
// (i64.const 2))
|
||||
// )
|
||||
//
|
||||
// this AST transform denormalises the type references, making all signatures within the module
|
||||
// inline.
|
||||
|
||||
|
||||
function transform(ast) {
|
||||
var typeInstructions = [];
|
||||
t.traverse(ast, {
|
||||
TypeInstruction: function TypeInstruction(_ref) {
|
||||
var node = _ref.node;
|
||||
typeInstructions.push(node);
|
||||
}
|
||||
});
|
||||
|
||||
if (!typeInstructions.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
function denormalizeSignature(signature) {
|
||||
// signature referenced by identifier
|
||||
if (signature.type === "Identifier") {
|
||||
var identifier = signature;
|
||||
var typeInstruction = typeInstructions.find(function (t) {
|
||||
return t.id.type === identifier.type && t.id.value === identifier.value;
|
||||
});
|
||||
|
||||
if (!typeInstruction) {
|
||||
throw new Error("A type instruction reference was not found ".concat(JSON.stringify(signature)));
|
||||
}
|
||||
|
||||
return typeInstruction.functype;
|
||||
} // signature referenced by index
|
||||
|
||||
|
||||
if (signature.type === "NumberLiteral") {
|
||||
var signatureRef = signature;
|
||||
var _typeInstruction = typeInstructions[signatureRef.value];
|
||||
return _typeInstruction.functype;
|
||||
}
|
||||
|
||||
return signature;
|
||||
}
|
||||
|
||||
t.traverse(ast, {
|
||||
Func: function (_Func) {
|
||||
function Func(_x) {
|
||||
return _Func.apply(this, arguments);
|
||||
}
|
||||
|
||||
Func.toString = function () {
|
||||
return _Func.toString();
|
||||
};
|
||||
|
||||
return Func;
|
||||
}(function (_ref2) {
|
||||
var node = _ref2.node;
|
||||
node.signature = denormalizeSignature(node.signature);
|
||||
}),
|
||||
CallIndirectInstruction: function CallIndirectInstruction(_ref3) {
|
||||
var node = _ref3.node;
|
||||
node.signature = denormalizeSignature(node.signature);
|
||||
}
|
||||
});
|
||||
}
|
||||
225
node_modules/@webassemblyjs/ast/lib/transform/wast-identifier-to-index/index.js
generated
vendored
225
node_modules/@webassemblyjs/ast/lib/transform/wast-identifier-to-index/index.js
generated
vendored
|
|
@ -1,225 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.transform = transform;
|
||||
|
||||
var _index = require("../../index");
|
||||
|
||||
var _helperModuleContext = require("@webassemblyjs/helper-module-context");
|
||||
|
||||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function _sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
||||
|
||||
function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return _sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }
|
||||
|
||||
// FIXME(sven): do the same with all block instructions, must be more generic here
|
||||
function newUnexpectedFunction(i) {
|
||||
return new Error("unknown function at offset: " + i);
|
||||
}
|
||||
|
||||
function transform(ast) {
|
||||
var module;
|
||||
(0, _index.traverse)(ast, {
|
||||
Module: function (_Module) {
|
||||
function Module(_x) {
|
||||
return _Module.apply(this, arguments);
|
||||
}
|
||||
|
||||
Module.toString = function () {
|
||||
return _Module.toString();
|
||||
};
|
||||
|
||||
return Module;
|
||||
}(function (path) {
|
||||
module = path.node;
|
||||
})
|
||||
});
|
||||
var moduleContext = (0, _helperModuleContext.moduleContextFromModuleAST)(module); // Transform the actual instruction in function bodies
|
||||
|
||||
(0, _index.traverse)(ast, {
|
||||
Func: function (_Func) {
|
||||
function Func(_x2) {
|
||||
return _Func.apply(this, arguments);
|
||||
}
|
||||
|
||||
Func.toString = function () {
|
||||
return _Func.toString();
|
||||
};
|
||||
|
||||
return Func;
|
||||
}(function (path) {
|
||||
transformFuncPath(path, moduleContext);
|
||||
}),
|
||||
Start: function (_Start) {
|
||||
function Start(_x3) {
|
||||
return _Start.apply(this, arguments);
|
||||
}
|
||||
|
||||
Start.toString = function () {
|
||||
return _Start.toString();
|
||||
};
|
||||
|
||||
return Start;
|
||||
}(function (path) {
|
||||
var index = path.node.index;
|
||||
|
||||
if ((0, _index.isIdentifier)(index) === true) {
|
||||
var offsetInModule = moduleContext.getFunctionOffsetByIdentifier(index.value);
|
||||
|
||||
if (typeof offsetInModule === "undefined") {
|
||||
throw newUnexpectedFunction(index.value);
|
||||
} // Replace the index Identifier
|
||||
// $FlowIgnore: reference?
|
||||
|
||||
|
||||
path.node.index = (0, _index.numberLiteralFromRaw)(offsetInModule);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function transformFuncPath(funcPath, moduleContext) {
|
||||
var funcNode = funcPath.node;
|
||||
var signature = funcNode.signature;
|
||||
|
||||
if (signature.type !== "Signature") {
|
||||
throw new Error("Function signatures must be denormalised before execution");
|
||||
}
|
||||
|
||||
var params = signature.params; // Add func locals in the context
|
||||
|
||||
params.forEach(function (p) {
|
||||
return moduleContext.addLocal(p.valtype);
|
||||
});
|
||||
(0, _index.traverse)(funcNode, {
|
||||
Instr: function (_Instr) {
|
||||
function Instr(_x4) {
|
||||
return _Instr.apply(this, arguments);
|
||||
}
|
||||
|
||||
Instr.toString = function () {
|
||||
return _Instr.toString();
|
||||
};
|
||||
|
||||
return Instr;
|
||||
}(function (instrPath) {
|
||||
var instrNode = instrPath.node;
|
||||
/**
|
||||
* Local access
|
||||
*/
|
||||
|
||||
if (instrNode.id === "get_local" || instrNode.id === "set_local" || instrNode.id === "tee_local") {
|
||||
var _instrNode$args = _slicedToArray(instrNode.args, 1),
|
||||
firstArg = _instrNode$args[0];
|
||||
|
||||
if (firstArg.type === "Identifier") {
|
||||
var offsetInParams = params.findIndex(function (_ref) {
|
||||
var id = _ref.id;
|
||||
return id === firstArg.value;
|
||||
});
|
||||
|
||||
if (offsetInParams === -1) {
|
||||
throw new Error("".concat(firstArg.value, " not found in ").concat(instrNode.id, ": not declared in func params"));
|
||||
} // Replace the Identifer node by our new NumberLiteral node
|
||||
|
||||
|
||||
instrNode.args[0] = (0, _index.numberLiteralFromRaw)(offsetInParams);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Global access
|
||||
*/
|
||||
|
||||
|
||||
if (instrNode.id === "get_global" || instrNode.id === "set_global") {
|
||||
var _instrNode$args2 = _slicedToArray(instrNode.args, 1),
|
||||
_firstArg = _instrNode$args2[0];
|
||||
|
||||
if ((0, _index.isIdentifier)(_firstArg) === true) {
|
||||
var globalOffset = moduleContext.getGlobalOffsetByIdentifier( // $FlowIgnore: reference?
|
||||
_firstArg.value);
|
||||
|
||||
if (typeof globalOffset === "undefined") {
|
||||
// $FlowIgnore: reference?
|
||||
throw new Error("global ".concat(_firstArg.value, " not found in module"));
|
||||
} // Replace the Identifer node by our new NumberLiteral node
|
||||
|
||||
|
||||
instrNode.args[0] = (0, _index.numberLiteralFromRaw)(globalOffset);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Labels lookup
|
||||
*/
|
||||
|
||||
|
||||
if (instrNode.id === "br") {
|
||||
var _instrNode$args3 = _slicedToArray(instrNode.args, 1),
|
||||
_firstArg2 = _instrNode$args3[0];
|
||||
|
||||
if ((0, _index.isIdentifier)(_firstArg2) === true) {
|
||||
// if the labels is not found it is going to be replaced with -1
|
||||
// which is invalid.
|
||||
var relativeBlockCount = -1; // $FlowIgnore: reference?
|
||||
|
||||
instrPath.findParent(function (_ref2) {
|
||||
var node = _ref2.node;
|
||||
|
||||
if ((0, _index.isBlock)(node)) {
|
||||
relativeBlockCount++; // $FlowIgnore: reference?
|
||||
|
||||
var name = node.label || node.name;
|
||||
|
||||
if (_typeof(name) === "object") {
|
||||
// $FlowIgnore: isIdentifier ensures that
|
||||
if (name.value === _firstArg2.value) {
|
||||
// Found it
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((0, _index.isFunc)(node)) {
|
||||
return false;
|
||||
}
|
||||
}); // Replace the Identifer node by our new NumberLiteral node
|
||||
|
||||
instrNode.args[0] = (0, _index.numberLiteralFromRaw)(relativeBlockCount);
|
||||
}
|
||||
}
|
||||
}),
|
||||
|
||||
/**
|
||||
* Func lookup
|
||||
*/
|
||||
CallInstruction: function (_CallInstruction) {
|
||||
function CallInstruction(_x5) {
|
||||
return _CallInstruction.apply(this, arguments);
|
||||
}
|
||||
|
||||
CallInstruction.toString = function () {
|
||||
return _CallInstruction.toString();
|
||||
};
|
||||
|
||||
return CallInstruction;
|
||||
}(function (_ref3) {
|
||||
var node = _ref3.node;
|
||||
var index = node.index;
|
||||
|
||||
if ((0, _index.isIdentifier)(index) === true) {
|
||||
var offsetInModule = moduleContext.getFunctionOffsetByIdentifier(index.value);
|
||||
|
||||
if (typeof offsetInModule === "undefined") {
|
||||
throw newUnexpectedFunction(index.value);
|
||||
} // Replace the index Identifier
|
||||
// $FlowIgnore: reference?
|
||||
|
||||
|
||||
node.index = (0, _index.numberLiteralFromRaw)(offsetInModule);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
105
node_modules/@webassemblyjs/ast/lib/traverse.js
generated
vendored
105
node_modules/@webassemblyjs/ast/lib/traverse.js
generated
vendored
|
|
@ -1,105 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.traverse = traverse;
|
||||
|
||||
var _nodePath = require("./node-path");
|
||||
|
||||
var _nodes = require("./nodes");
|
||||
|
||||
// recursively walks the AST starting at the given node. The callback is invoked for
|
||||
// and object that has a 'type' property.
|
||||
function walk(context, callback) {
|
||||
var stop = false;
|
||||
|
||||
function innerWalk(context, callback) {
|
||||
if (stop) {
|
||||
return;
|
||||
}
|
||||
|
||||
var node = context.node;
|
||||
|
||||
if (node === undefined) {
|
||||
console.warn("traversing with an empty context");
|
||||
return;
|
||||
}
|
||||
|
||||
if (node._deleted === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
var path = (0, _nodePath.createPath)(context);
|
||||
callback(node.type, path);
|
||||
|
||||
if (path.shouldStop) {
|
||||
stop = true;
|
||||
return;
|
||||
}
|
||||
|
||||
Object.keys(node).forEach(function (prop) {
|
||||
var value = node[prop];
|
||||
|
||||
if (value === null || value === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
var valueAsArray = Array.isArray(value) ? value : [value];
|
||||
valueAsArray.forEach(function (childNode) {
|
||||
if (typeof childNode.type === "string") {
|
||||
var childContext = {
|
||||
node: childNode,
|
||||
parentKey: prop,
|
||||
parentPath: path,
|
||||
shouldStop: false,
|
||||
inList: Array.isArray(value)
|
||||
};
|
||||
innerWalk(childContext, callback);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
innerWalk(context, callback);
|
||||
}
|
||||
|
||||
var noop = function noop() {};
|
||||
|
||||
function traverse(node, visitors) {
|
||||
var before = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : noop;
|
||||
var after = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : noop;
|
||||
Object.keys(visitors).forEach(function (visitor) {
|
||||
if (!_nodes.nodeAndUnionTypes.includes(visitor)) {
|
||||
throw new Error("Unexpected visitor ".concat(visitor));
|
||||
}
|
||||
});
|
||||
var context = {
|
||||
node: node,
|
||||
inList: false,
|
||||
shouldStop: false,
|
||||
parentPath: null,
|
||||
parentKey: null
|
||||
};
|
||||
walk(context, function (type, path) {
|
||||
if (typeof visitors[type] === "function") {
|
||||
before(type, path);
|
||||
visitors[type](path);
|
||||
after(type, path);
|
||||
}
|
||||
|
||||
var unionTypes = _nodes.unionTypesMap[type];
|
||||
|
||||
if (!unionTypes) {
|
||||
throw new Error("Unexpected node type ".concat(type));
|
||||
}
|
||||
|
||||
unionTypes.forEach(function (unionType) {
|
||||
if (typeof visitors[unionType] === "function") {
|
||||
before(unionType, path);
|
||||
visitors[unionType](path);
|
||||
after(unionType, path);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
0
node_modules/@webassemblyjs/ast/lib/types/basic.js
generated
vendored
0
node_modules/@webassemblyjs/ast/lib/types/basic.js
generated
vendored
0
node_modules/@webassemblyjs/ast/lib/types/nodes.js
generated
vendored
0
node_modules/@webassemblyjs/ast/lib/types/nodes.js
generated
vendored
0
node_modules/@webassemblyjs/ast/lib/types/traverse.js
generated
vendored
0
node_modules/@webassemblyjs/ast/lib/types/traverse.js
generated
vendored
306
node_modules/@webassemblyjs/ast/lib/utils.js
generated
vendored
306
node_modules/@webassemblyjs/ast/lib/utils.js
generated
vendored
|
|
@ -1,306 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.isAnonymous = isAnonymous;
|
||||
exports.getSectionMetadata = getSectionMetadata;
|
||||
exports.getSectionMetadatas = getSectionMetadatas;
|
||||
exports.sortSectionMetadata = sortSectionMetadata;
|
||||
exports.orderedInsertNode = orderedInsertNode;
|
||||
exports.assertHasLoc = assertHasLoc;
|
||||
exports.getEndOfSection = getEndOfSection;
|
||||
exports.shiftLoc = shiftLoc;
|
||||
exports.shiftSection = shiftSection;
|
||||
exports.signatureForOpcode = signatureForOpcode;
|
||||
exports.getUniqueNameGenerator = getUniqueNameGenerator;
|
||||
exports.getStartByteOffset = getStartByteOffset;
|
||||
exports.getEndByteOffset = getEndByteOffset;
|
||||
exports.getFunctionBeginingByteOffset = getFunctionBeginingByteOffset;
|
||||
exports.getEndBlockByteOffset = getEndBlockByteOffset;
|
||||
exports.getStartBlockByteOffset = getStartBlockByteOffset;
|
||||
|
||||
var _signatures = require("./signatures");
|
||||
|
||||
var _traverse = require("./traverse");
|
||||
|
||||
var _helperWasmBytecode = _interopRequireWildcard(require("@webassemblyjs/helper-wasm-bytecode"));
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||||
|
||||
function _sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
||||
|
||||
function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return _sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }
|
||||
|
||||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function isAnonymous(ident) {
|
||||
return ident.raw === "";
|
||||
}
|
||||
|
||||
function getSectionMetadata(ast, name) {
|
||||
var section;
|
||||
(0, _traverse.traverse)(ast, {
|
||||
SectionMetadata: function (_SectionMetadata) {
|
||||
function SectionMetadata(_x) {
|
||||
return _SectionMetadata.apply(this, arguments);
|
||||
}
|
||||
|
||||
SectionMetadata.toString = function () {
|
||||
return _SectionMetadata.toString();
|
||||
};
|
||||
|
||||
return SectionMetadata;
|
||||
}(function (_ref) {
|
||||
var node = _ref.node;
|
||||
|
||||
if (node.section === name) {
|
||||
section = node;
|
||||
}
|
||||
})
|
||||
});
|
||||
return section;
|
||||
}
|
||||
|
||||
function getSectionMetadatas(ast, name) {
|
||||
var sections = [];
|
||||
(0, _traverse.traverse)(ast, {
|
||||
SectionMetadata: function (_SectionMetadata2) {
|
||||
function SectionMetadata(_x2) {
|
||||
return _SectionMetadata2.apply(this, arguments);
|
||||
}
|
||||
|
||||
SectionMetadata.toString = function () {
|
||||
return _SectionMetadata2.toString();
|
||||
};
|
||||
|
||||
return SectionMetadata;
|
||||
}(function (_ref2) {
|
||||
var node = _ref2.node;
|
||||
|
||||
if (node.section === name) {
|
||||
sections.push(node);
|
||||
}
|
||||
})
|
||||
});
|
||||
return sections;
|
||||
}
|
||||
|
||||
function sortSectionMetadata(m) {
|
||||
if (m.metadata == null) {
|
||||
console.warn("sortSectionMetadata: no metadata to sort");
|
||||
return;
|
||||
} // $FlowIgnore
|
||||
|
||||
|
||||
m.metadata.sections.sort(function (a, b) {
|
||||
var aId = _helperWasmBytecode.default.sections[a.section];
|
||||
var bId = _helperWasmBytecode.default.sections[b.section];
|
||||
|
||||
if (typeof aId !== "number" || typeof bId !== "number") {
|
||||
throw new Error("Section id not found");
|
||||
}
|
||||
|
||||
return aId - bId;
|
||||
});
|
||||
}
|
||||
|
||||
function orderedInsertNode(m, n) {
|
||||
assertHasLoc(n);
|
||||
var didInsert = false;
|
||||
|
||||
if (n.type === "ModuleExport") {
|
||||
m.fields.push(n);
|
||||
return;
|
||||
}
|
||||
|
||||
m.fields = m.fields.reduce(function (acc, field) {
|
||||
var fieldEndCol = Infinity;
|
||||
|
||||
if (field.loc != null) {
|
||||
// $FlowIgnore
|
||||
fieldEndCol = field.loc.end.column;
|
||||
} // $FlowIgnore: assertHasLoc ensures that
|
||||
|
||||
|
||||
if (didInsert === false && n.loc.start.column < fieldEndCol) {
|
||||
didInsert = true;
|
||||
acc.push(n);
|
||||
}
|
||||
|
||||
acc.push(field);
|
||||
return acc;
|
||||
}, []); // Handles empty modules or n is the last element
|
||||
|
||||
if (didInsert === false) {
|
||||
m.fields.push(n);
|
||||
}
|
||||
}
|
||||
|
||||
function assertHasLoc(n) {
|
||||
if (n.loc == null || n.loc.start == null || n.loc.end == null) {
|
||||
throw new Error("Internal failure: node (".concat(JSON.stringify(n.type), ") has no location information"));
|
||||
}
|
||||
}
|
||||
|
||||
function getEndOfSection(s) {
|
||||
assertHasLoc(s.size);
|
||||
return s.startOffset + s.size.value + ( // $FlowIgnore
|
||||
s.size.loc.end.column - s.size.loc.start.column);
|
||||
}
|
||||
|
||||
function shiftLoc(node, delta) {
|
||||
// $FlowIgnore
|
||||
node.loc.start.column += delta; // $FlowIgnore
|
||||
|
||||
node.loc.end.column += delta;
|
||||
}
|
||||
|
||||
function shiftSection(ast, node, delta) {
|
||||
if (node.type !== "SectionMetadata") {
|
||||
throw new Error("Can not shift node " + JSON.stringify(node.type));
|
||||
}
|
||||
|
||||
node.startOffset += delta;
|
||||
|
||||
if (_typeof(node.size.loc) === "object") {
|
||||
shiftLoc(node.size, delta);
|
||||
} // Custom sections doesn't have vectorOfSize
|
||||
|
||||
|
||||
if (_typeof(node.vectorOfSize) === "object" && _typeof(node.vectorOfSize.loc) === "object") {
|
||||
shiftLoc(node.vectorOfSize, delta);
|
||||
}
|
||||
|
||||
var sectionName = node.section; // shift node locations within that section
|
||||
|
||||
(0, _traverse.traverse)(ast, {
|
||||
Node: function Node(_ref3) {
|
||||
var node = _ref3.node;
|
||||
var section = (0, _helperWasmBytecode.getSectionForNode)(node);
|
||||
|
||||
if (section === sectionName && _typeof(node.loc) === "object") {
|
||||
shiftLoc(node, delta);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function signatureForOpcode(object, name) {
|
||||
var opcodeName = name;
|
||||
|
||||
if (object !== undefined && object !== "") {
|
||||
opcodeName = object + "." + name;
|
||||
}
|
||||
|
||||
var sign = _signatures.signatures[opcodeName];
|
||||
|
||||
if (sign == undefined) {
|
||||
// TODO: Uncomment this when br_table and others has been done
|
||||
//throw new Error("Invalid opcode: "+opcodeName);
|
||||
return [object, object];
|
||||
}
|
||||
|
||||
return sign[0];
|
||||
}
|
||||
|
||||
function getUniqueNameGenerator() {
|
||||
var inc = {};
|
||||
return function () {
|
||||
var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "temp";
|
||||
|
||||
if (!(prefix in inc)) {
|
||||
inc[prefix] = 0;
|
||||
} else {
|
||||
inc[prefix] = inc[prefix] + 1;
|
||||
}
|
||||
|
||||
return prefix + "_" + inc[prefix];
|
||||
};
|
||||
}
|
||||
|
||||
function getStartByteOffset(n) {
|
||||
// $FlowIgnore
|
||||
if (typeof n.loc === "undefined" || typeof n.loc.start === "undefined") {
|
||||
throw new Error( // $FlowIgnore
|
||||
"Can not get byte offset without loc informations, node: " + String(n.id));
|
||||
}
|
||||
|
||||
return n.loc.start.column;
|
||||
}
|
||||
|
||||
function getEndByteOffset(n) {
|
||||
// $FlowIgnore
|
||||
if (typeof n.loc === "undefined" || typeof n.loc.end === "undefined") {
|
||||
throw new Error("Can not get byte offset without loc informations, node: " + n.type);
|
||||
}
|
||||
|
||||
return n.loc.end.column;
|
||||
}
|
||||
|
||||
function getFunctionBeginingByteOffset(n) {
|
||||
if (!(n.body.length > 0)) {
|
||||
throw new Error('n.body.length > 0' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
var _n$body = _slicedToArray(n.body, 1),
|
||||
firstInstruction = _n$body[0];
|
||||
|
||||
return getStartByteOffset(firstInstruction);
|
||||
}
|
||||
|
||||
function getEndBlockByteOffset(n) {
|
||||
// $FlowIgnore
|
||||
if (!(n.instr.length > 0 || n.body.length > 0)) {
|
||||
throw new Error('n.instr.length > 0 || n.body.length > 0' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
var lastInstruction;
|
||||
|
||||
if (n.instr) {
|
||||
// $FlowIgnore
|
||||
lastInstruction = n.instr[n.instr.length - 1];
|
||||
}
|
||||
|
||||
if (n.body) {
|
||||
// $FlowIgnore
|
||||
lastInstruction = n.body[n.body.length - 1];
|
||||
}
|
||||
|
||||
if (!(_typeof(lastInstruction) === "object")) {
|
||||
throw new Error('typeof lastInstruction === "object"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
// $FlowIgnore
|
||||
return getStartByteOffset(lastInstruction);
|
||||
}
|
||||
|
||||
function getStartBlockByteOffset(n) {
|
||||
// $FlowIgnore
|
||||
if (!(n.instr.length > 0 || n.body.length > 0)) {
|
||||
throw new Error('n.instr.length > 0 || n.body.length > 0' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
var fistInstruction;
|
||||
|
||||
if (n.instr) {
|
||||
// $FlowIgnore
|
||||
var _n$instr = _slicedToArray(n.instr, 1);
|
||||
|
||||
fistInstruction = _n$instr[0];
|
||||
}
|
||||
|
||||
if (n.body) {
|
||||
// $FlowIgnore
|
||||
var _n$body2 = _slicedToArray(n.body, 1);
|
||||
|
||||
fistInstruction = _n$body2[0];
|
||||
}
|
||||
|
||||
if (!(_typeof(fistInstruction) === "object")) {
|
||||
throw new Error('typeof fistInstruction === "object"' + " error: " + (undefined || "unknown"));
|
||||
}
|
||||
|
||||
// $FlowIgnore
|
||||
return getStartByteOffset(fistInstruction);
|
||||
}
|
||||
33
node_modules/@webassemblyjs/ast/package.json
generated
vendored
33
node_modules/@webassemblyjs/ast/package.json
generated
vendored
|
|
@ -1,33 +0,0 @@
|
|||
{
|
||||
"name": "@webassemblyjs/ast",
|
||||
"version": "1.9.0",
|
||||
"description": "AST utils for webassemblyjs",
|
||||
"keywords": [
|
||||
"webassembly",
|
||||
"javascript",
|
||||
"ast"
|
||||
],
|
||||
"main": "lib/index.js",
|
||||
"module": "esm/index.js",
|
||||
"author": "Sven Sauleau",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@webassemblyjs/helper-module-context": "1.9.0",
|
||||
"@webassemblyjs/helper-wasm-bytecode": "1.9.0",
|
||||
"@webassemblyjs/wast-parser": "1.9.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/xtuc/webassemblyjs.git"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@webassemblyjs/helper-test-framework": "1.9.0",
|
||||
"array.prototype.flatmap": "^1.2.1",
|
||||
"dump-exports": "^0.1.0",
|
||||
"mamacro": "^0.0.7"
|
||||
},
|
||||
"gitHead": "0440b420888c1f7701eb9762ec657775506b87d8"
|
||||
}
|
||||
219
node_modules/@webassemblyjs/ast/scripts/generateNodeUtils.js
generated
vendored
219
node_modules/@webassemblyjs/ast/scripts/generateNodeUtils.js
generated
vendored
|
|
@ -1,219 +0,0 @@
|
|||
const definitions = require("../src/definitions");
|
||||
const flatMap = require("array.prototype.flatmap");
|
||||
const {
|
||||
typeSignature,
|
||||
iterateProps,
|
||||
mapProps,
|
||||
filterProps,
|
||||
unique
|
||||
} = require("./util");
|
||||
|
||||
const stdout = process.stdout;
|
||||
|
||||
const jsTypes = ["string", "number", "boolean"];
|
||||
|
||||
const quote = value => `"${value}"`;
|
||||
|
||||
function params(fields) {
|
||||
const optionalDefault = field => (field.default ? ` = ${field.default}` : "");
|
||||
return mapProps(fields)
|
||||
.map(field => `${typeSignature(field)}${optionalDefault(field)}`)
|
||||
.join(",");
|
||||
}
|
||||
|
||||
function assertParamType({ assertNodeType, array, name, type }) {
|
||||
if (array) {
|
||||
// TODO - assert contents of array?
|
||||
return `assert(typeof ${name} === "object" && typeof ${name}.length !== "undefined")\n`;
|
||||
} else {
|
||||
if (jsTypes.includes(type)) {
|
||||
return `assert(
|
||||
typeof ${name} === "${type}",
|
||||
"Argument ${name} must be of type ${type}, given: " + typeof ${name}
|
||||
)`;
|
||||
}
|
||||
|
||||
if (assertNodeType === true) {
|
||||
return `assert(
|
||||
${name}.type === "${type}",
|
||||
"Argument ${name} must be of type ${type}, given: " + ${name}.type
|
||||
)`;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
function assertParam(meta) {
|
||||
const paramAssertion = assertParamType(meta);
|
||||
|
||||
if (paramAssertion === "") {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (meta.maybe || meta.optional) {
|
||||
return `
|
||||
if (${meta.name} !== null && ${meta.name} !== undefined) {
|
||||
${paramAssertion};
|
||||
}
|
||||
`;
|
||||
} else {
|
||||
return paramAssertion;
|
||||
}
|
||||
}
|
||||
|
||||
function assertParams(fields) {
|
||||
return mapProps(fields)
|
||||
.map(assertParam)
|
||||
.join("\n");
|
||||
}
|
||||
|
||||
function buildObject(typeDef) {
|
||||
const optionalField = meta => {
|
||||
if (meta.array) {
|
||||
// omit optional array properties if the constructor function was supplied
|
||||
// with an empty array
|
||||
return `
|
||||
if (typeof ${meta.name} !== "undefined" && ${meta.name}.length > 0) {
|
||||
node.${meta.name} = ${meta.name};
|
||||
}
|
||||
`;
|
||||
} else if (meta.type === "Object") {
|
||||
// omit optional object properties if they have no keys
|
||||
return `
|
||||
if (typeof ${meta.name} !== "undefined" && Object.keys(${
|
||||
meta.name
|
||||
}).length !== 0) {
|
||||
node.${meta.name} = ${meta.name};
|
||||
}
|
||||
`;
|
||||
} else if (meta.type === "boolean") {
|
||||
// omit optional boolean properties if they are not true
|
||||
return `
|
||||
if (${meta.name} === true) {
|
||||
node.${meta.name} = true;
|
||||
}
|
||||
`;
|
||||
} else {
|
||||
return `
|
||||
if (typeof ${meta.name} !== "undefined") {
|
||||
node.${meta.name} = ${meta.name};
|
||||
}
|
||||
`;
|
||||
}
|
||||
};
|
||||
|
||||
const fields = mapProps(typeDef.fields)
|
||||
.filter(f => !f.optional && !f.constant)
|
||||
.map(f => f.name);
|
||||
|
||||
const constants = mapProps(typeDef.fields)
|
||||
.filter(f => f.constant)
|
||||
.map(f => `${f.name}: "${f.value}"`);
|
||||
|
||||
return `
|
||||
const node: ${typeDef.flowTypeName || typeDef.name} = {
|
||||
type: "${typeDef.name}",
|
||||
${constants.concat(fields).join(",")}
|
||||
}
|
||||
|
||||
${mapProps(typeDef.fields)
|
||||
.filter(f => f.optional)
|
||||
.map(optionalField)
|
||||
.join("")}
|
||||
`;
|
||||
}
|
||||
|
||||
function lowerCamelCase(name) {
|
||||
return name.substring(0, 1).toLowerCase() + name.substring(1);
|
||||
}
|
||||
|
||||
function generate() {
|
||||
stdout.write(`
|
||||
// @flow
|
||||
|
||||
// THIS FILE IS AUTOGENERATED
|
||||
// see scripts/generateNodeUtils.js
|
||||
|
||||
import { assert } from "mamacro";
|
||||
|
||||
function isTypeOf(t: string) {
|
||||
return (n: Node) => n.type === t;
|
||||
}
|
||||
|
||||
function assertTypeOf(t: string) {
|
||||
return (n: Node) => assert(n.type === t);
|
||||
}
|
||||
`);
|
||||
|
||||
// Node builders
|
||||
iterateProps(definitions, typeDefinition => {
|
||||
stdout.write(`
|
||||
export function ${lowerCamelCase(typeDefinition.name)} (
|
||||
${params(filterProps(typeDefinition.fields, f => !f.constant))}
|
||||
): ${typeDefinition.name} {
|
||||
|
||||
${assertParams(filterProps(typeDefinition.fields, f => !f.constant))}
|
||||
${buildObject(typeDefinition)}
|
||||
|
||||
return node;
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
// Node testers
|
||||
iterateProps(definitions, typeDefinition => {
|
||||
stdout.write(`
|
||||
export const is${typeDefinition.name} =
|
||||
isTypeOf("${typeDefinition.name}");
|
||||
`);
|
||||
});
|
||||
|
||||
// Node union type testers
|
||||
const unionTypes = unique(
|
||||
flatMap(mapProps(definitions).filter(d => d.unionType), d => d.unionType)
|
||||
);
|
||||
unionTypes.forEach(unionType => {
|
||||
stdout.write(
|
||||
`
|
||||
export const is${unionType} = (node: Node) => ` +
|
||||
mapProps(definitions)
|
||||
.filter(d => d.unionType && d.unionType.includes(unionType))
|
||||
.map(d => `is${d.name}(node) `)
|
||||
.join("||") +
|
||||
";\n\n"
|
||||
);
|
||||
});
|
||||
|
||||
// Node assertion
|
||||
iterateProps(definitions, typeDefinition => {
|
||||
stdout.write(`
|
||||
export const assert${typeDefinition.name} =
|
||||
assertTypeOf("${typeDefinition.name}");
|
||||
`);
|
||||
});
|
||||
|
||||
// a map from node type to its set of union types
|
||||
stdout.write(
|
||||
`
|
||||
export const unionTypesMap = {` +
|
||||
mapProps(definitions)
|
||||
.filter(d => d.unionType)
|
||||
.map(t => `"${t.name}": [${t.unionType.map(quote).join(",")}]\n`) +
|
||||
`};
|
||||
`
|
||||
);
|
||||
|
||||
// an array of all node and union types
|
||||
stdout.write(
|
||||
`
|
||||
export const nodeAndUnionTypes = [` +
|
||||
mapProps(definitions)
|
||||
.map(t => `"${t.name}"`)
|
||||
.concat(unionTypes.map(quote))
|
||||
.join(",") +
|
||||
`];`
|
||||
);
|
||||
}
|
||||
|
||||
generate();
|
||||
47
node_modules/@webassemblyjs/ast/scripts/generateTypeDefinitions.js
generated
vendored
47
node_modules/@webassemblyjs/ast/scripts/generateTypeDefinitions.js
generated
vendored
|
|
@ -1,47 +0,0 @@
|
|||
const definitions = require("../src/definitions");
|
||||
const flatMap = require("array.prototype.flatmap");
|
||||
const { typeSignature, mapProps, iterateProps, unique } = require("./util");
|
||||
|
||||
const stdout = process.stdout;
|
||||
|
||||
function params(fields) {
|
||||
return mapProps(fields)
|
||||
.map(typeSignature)
|
||||
.join(",");
|
||||
}
|
||||
|
||||
function generate() {
|
||||
stdout.write(`
|
||||
// @flow
|
||||
/* eslint no-unused-vars: off */
|
||||
|
||||
// THIS FILE IS AUTOGENERATED
|
||||
// see scripts/generateTypeDefinitions.js
|
||||
`);
|
||||
|
||||
// generate union types
|
||||
const unionTypes = unique(
|
||||
flatMap(mapProps(definitions).filter(d => d.unionType), d => d.unionType)
|
||||
);
|
||||
unionTypes.forEach(unionType => {
|
||||
stdout.write(
|
||||
`type ${unionType} = ` +
|
||||
mapProps(definitions)
|
||||
.filter(d => d.unionType && d.unionType.includes(unionType))
|
||||
.map(d => d.name)
|
||||
.join("|") +
|
||||
";\n\n"
|
||||
);
|
||||
});
|
||||
|
||||
// generate the type definitions
|
||||
iterateProps(definitions, typeDef => {
|
||||
stdout.write(`type ${typeDef.name} = {
|
||||
...BaseNode,
|
||||
type: "${typeDef.name}",
|
||||
${params(typeDef.fields)}
|
||||
};\n\n`);
|
||||
});
|
||||
}
|
||||
|
||||
generate();
|
||||
38
node_modules/@webassemblyjs/ast/scripts/util.js
generated
vendored
38
node_modules/@webassemblyjs/ast/scripts/util.js
generated
vendored
|
|
@ -1,38 +0,0 @@
|
|||
function iterateProps(obj, iterator) {
|
||||
Object.keys(obj).forEach(key => iterator({ ...obj[key], name: key }));
|
||||
}
|
||||
|
||||
function mapProps(obj) {
|
||||
return Object.keys(obj).map(key => ({ ...obj[key], name: key }));
|
||||
}
|
||||
|
||||
function filterProps(obj, filter) {
|
||||
const ret = {};
|
||||
Object.keys(obj).forEach(key => {
|
||||
if (filter(obj[key])) {
|
||||
ret[key] = obj[key];
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
function typeSignature(meta) {
|
||||
const type = meta.array ? `Array<${meta.type}>` : meta.type;
|
||||
if (meta.optional) {
|
||||
return `${meta.name}?: ${type}`;
|
||||
} else if (meta.maybe) {
|
||||
return `${meta.name}: ?${type}`;
|
||||
} else {
|
||||
return `${meta.name}: ${type}`;
|
||||
}
|
||||
}
|
||||
|
||||
const unique = items => Array.from(new Set(items));
|
||||
|
||||
module.exports = {
|
||||
iterateProps,
|
||||
mapProps,
|
||||
filterProps,
|
||||
typeSignature,
|
||||
unique
|
||||
};
|
||||
21
node_modules/@webassemblyjs/floating-point-hex-parser/LICENSE
generated
vendored
21
node_modules/@webassemblyjs/floating-point-hex-parser/LICENSE
generated
vendored
|
|
@ -1,21 +0,0 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017 Mauro Bringolf
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue