Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,48 @@ extends:
- google
parserOptions:
ecmaVersion: 12
ignorePatterns: "library_*.js"
ignorePatterns:
- "site/"
- "third_party/"
- "tests/"
- "src/library*.js"
- "src/runtime_*.js"
- "src/shell*.js"
- "src/preamble*.js"
- "src/postamble*.js"
- "src/closure-externs/"
- "src/embind/"
- "src/emrun_postjs.js"
- "src/worker.js"
- "src/wrtcp.js"
- "src/wasm2js.js"
- "src/webGLClient.js"
- "src/webGLWorker.js"
- "src/*_shell_read.js"
- "src/wasm_offset_converter.js"
- "src/threadprofiler.js"
- "src/cpuprofiler.js"
- "src/memoryprofiler.js"
- "src/support.js"
- "src/gl-matrix.js"
- "src/promise_polyfill.js"
- "src/headless.js"
- "src/headlessCanvas.js"
- "src/socket.io.js"
- "src/emscripten-source-map.min.js"
- "src/source_map_support.js"
- "src/Fetch.js"
- "src/settings.js"
- "src/settings_internal.js"
- "src/arrayUtils.js"
- "src/deterministic.js"
- "src/base64Utils.js"
- "src/base64Decode.js"
- "src/proxyWorker.js"
- "src/proxyClient.js"
- "src/IDBStore.js"
- "src/URIUtils.js"
- "tools/experimental"
rules:
#max-len: ["error", 100]
max-len: "off"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"wasm2c": "1.0.0"
},
"scripts": {
"lint": "eslint src/parseTools.js tools/acorn-optimizer.js tools/lz4-compress.js"
"lint": "eslint ."
}
}
53 changes: 27 additions & 26 deletions src/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@

// LLVM => JavaScript compiler, main entry point

var nodeFS = require('fs');
nodePath = require('path');
global.nodeFS = require('fs');
global.nodePath = require('path');

print = (x) => {
global.print = (x) => {
process['stdout'].write(x + '\n');
};

printErr = (x) => {
global.printErr = (x) => {
process['stderr'].write(x + '\n');
};

function find(filename) {
var prefixes = [__dirname, process.cwd()];
for (var i = 0; i < prefixes.length; ++i) {
var combined = nodePath.join(prefixes[i], filename);
const prefixes = [__dirname, process.cwd()];
for (let i = 0; i < prefixes.length; ++i) {
const combined = nodePath.join(prefixes[i], filename);
if (nodeFS.existsSync(combined)) {
return combined;
}
}
return filename;
}

read = (filename) => {
var absolute = find(filename);
global.read = (filename) => {
const absolute = find(filename);
return nodeFS.readFileSync(absolute).toString();
};

Expand All @@ -45,22 +45,23 @@ load('utility.js');
load('./settings.js');
load('./settings_internal.js');

var arguments_ = process['argv'].slice(2);
var settingsFile = arguments_[0];
const settingsFile = process['argv'][2];

if (settingsFile) {
var settings = JSON.parse(read(settingsFile));
for (var key in settings) {
var value = settings[key];
if (value[0] == '@') {
// response file type thing, workaround for large inputs: value is @path-to-file
try {
value = JSON.parse(read(value.substr(1)));
} catch(e) {
// continue normally; assume it is not a response file
const settings = JSON.parse(read(settingsFile));
for (const key in settings) {
if (Object.prototype.hasOwnProperty.call(settings, key)) {
let value = settings[key];
if (value[0] == '@') {
// response file type thing, workaround for large inputs: value is @path-to-file
try {
value = JSON.parse(read(value.substr(1)));
} catch (e) {
// continue normally; assume it is not a response file
}
}
global[key] = eval(JSON.stringify(value));
}
global[key] = eval(JSON.stringify(value));
}
}

Expand All @@ -72,7 +73,7 @@ INCOMING_MODULE_JS_API = new Set(INCOMING_MODULE_JS_API);
RUNTIME_DEBUG = LIBRARY_DEBUG || GL_DEBUG || DYLINK_DEBUG || PTHREADS_DEBUG;

// Side modules are pure wasm and have no JS
assert(!SIDE_MODULE, "JS compiler should not run on side modules");
assert(!SIDE_MODULE, 'JS compiler should not run on side modules');

// Output some info and warnings based on settings

Expand All @@ -87,17 +88,17 @@ load('parseTools.js');
load('jsifier.js');
load('runtime.js');

//===============================
// ===============================
// Main
//===============================
// ===============================

B = new Benchmarker();

try {
JSify();
runJSify();

B.print('glue');
} catch(err) {
} catch (err) {
if (err.toString().includes('Aborting compilation due to previous errors')) {
// Compiler failed on user error, don't print the stacktrace in this case.
printErr(err);
Expand Down
2 changes: 1 addition & 1 deletion src/emrun_prejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

// Route URL GET parameters to argc+argv
if (typeof window === "object") {
if (typeof window === 'object') {
Module['arguments'] = window.location.search.substr(1).trim().split('&');
// If no args were passed arguments = [''], in which case kill the single empty string.
if (!Module['arguments'][0]) {
Expand Down
Loading