Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workaround example to support NodeJS less V10.11.0 and even less V8.13.0 #443

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ CORE_FILES=const.js config.js io.js main.js lib.js ide.js pci.js floppy.js \
cpu.js debug.js \
elf.js kernel.js
LIB_FILES=9p.js filesystem.js jor1k.js marshall.js utf8.js
BROWSER_FILES=screen.js keyboard.js mouse.js speaker.js serial.js \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the issue with speaker.js?

Copy link
Contributor Author

@proxy-m proxy-m Apr 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like version problem of Closure compiller, or Nodejs, or Reflect:

src/browser/speaker.js:487: ERROR - [JSC_UNDEFINED_VARIABLE] variable AudioWorkletProcessor is undeclared
            var self = Reflect.construct(AudioWorkletProcessor, [], DACProcessor);
                                         ^^^^^^^^^^^^^^^^^^^^^

src/browser/speaker.js:766: ERROR - [JSC_UNDEFINED_VARIABLE] variable AudioWorkletNode is undeclared
        this.node_processor = new AudioWorkletNode(this.audio_context, "dac-processor",
                                  ^^^^^^^^^^^^^^^^

2 error(s), 0 warning(s)
Makefile:100: recipe for target 'build/v86_all.js' failed

Similar compatibility problems links (I tried to search solution, but do not understand):

https://stackoverflow.com/questions/37787606/google-closure-compiler-gives-jsc-inexistent-property-for-new-web-audio-api-meth

https://developers.google.com/closure/compiler/docs/api-tutorial3#howto-app

github/babel-plugin-transform-custom-element-classes#8

https://stackoverflow.com/questions/50346328/what-is-javascript-reflect-construct-newtarget-doing
https://stackoverflow.com/questions/48341824/nodejs-what-does-reflect-function-do
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect (must be supported compatible by table)

https://developer.mozilla.org/en-US/docs/Web/API/AudioWorkletProcessor
emscripten-core/emscripten#6230 (may be similar problem with optimization options, uglifying, es6, context, modules, exporting in conjunction with wasm and closure)

https://stackoverflow.com/questions/36363849/error-when-compiling-code-with-google-closure-compiler (other error about needing externs file)
https://stackoverflow.com/questions/49971779/error-audioworkletnode-is-undefined-in-react-app (other error about react)

https://github.com/teppeis/closure-compiler-es-compat-table/blob/master/es6/latest/syntax/new.target/in_constructors/error.txt

google/closure-compiler#2899

https://kangax.github.io/compat-table/es6/ (errors table)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not priority.

BROWSER_FILES=screen.js keyboard.js mouse.js serial.js \
network.js lib.js starter.js worker_bus.js dummy_screen.js \
print_stats.js filestorage.js

Expand Down
2 changes: 1 addition & 1 deletion gen/generate_analyzer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
"use strict";

const assert = require("assert").strict;
const assert = require("assert").strict || require("assert"); // Strict mode added in: V8.13.0
const fs = require("fs");
const path = require("path");
const x86_table = require("./x86_table");
Expand Down
2 changes: 1 addition & 1 deletion gen/generate_interpreter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
"use strict";

const assert = require("assert").strict;
const assert = require("assert").strict || require("assert"); // Strict mode added in: V8.13.0
const fs = require("fs");
const path = require("path");
const x86_table = require("./x86_table");
Expand Down
2 changes: 1 addition & 1 deletion gen/generate_jit.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
"use strict";

const assert = require("assert").strict;
const assert = require("assert").strict || require("assert"); // Strict mode added in: V8.13.0
const fs = require("fs");
const path = require("path");
const x86_table = require("./x86_table");
Expand Down
2 changes: 1 addition & 1 deletion gen/rust_ast.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

const assert = require("assert").strict;
const assert = require("assert").strict || require("assert"); // Strict mode added in: V8.13.0

function repeat(s, n)
{
Expand Down
16 changes: 12 additions & 4 deletions gen/util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

const assert = require("assert");
const assert = require("assert").strict || require("assert"); // Strict mode added in: V8.13.0
const fs = require("fs");
const path = require("path");
const process = require("process");
Expand All @@ -16,9 +16,17 @@ function hex(n, pad)
return s;
}

function mkdirpSync(dir)
{
fs.mkdirSync(dir, { recursive: true });
function mkdirpSync(dir) {
dir = dir.split('\\').join('/'); // replace to standard delimiter
let dirParts = dir.split('/'); // split by folders delimiter
let dirTmp = '';
while (dirParts.length > 0) {
dirTmp += dirParts.shift() + '/';
if (!fs.existsSync(dirTmp)) {
fs.mkdirSync(dirTmp);
}
}
///fs.mkdirSync(dir, { recursive: true });
}

function get_switch_value(arg_switch)
Expand Down
2 changes: 1 addition & 1 deletion src/browser/starter.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ V86Starter.prototype.continue_init = async function(emulator, options)

if(!options["disable_speaker"])
{
this.speaker_adapter = new SpeakerAdapter(this.bus);
this.speaker_adapter = undefined; ///new SpeakerAdapter(this.bus);
}

// ugly, but required for closure compiler compilation
Expand Down
2 changes: 1 addition & 1 deletion tests/api/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ process.on("unhandledRejection", exn => { throw exn; });
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;

var V86 = require(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.js`).V86;
const assert = require("assert").strict;
const assert = require("assert").strict || require("assert"); // Strict mode added in: V8.13.0
var fs = require("fs");

const config_async_cdrom = {
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;

const assert = require("assert").strict;
const assert = require("assert").strict || require("assert"); // Strict mode added in: V8.13.0
const fs = require("fs");
const path = require("path");
const { spawnSync } = require("child_process");
Expand Down
2 changes: 1 addition & 1 deletion tests/full/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ catch(e)
process.exit(1);
}

const assert = require("assert").strict;
const assert = require("assert").strict || require("assert"); // Strict mode added in: V8.13.0
var cluster = require("cluster");
var os = require("os");
var fs = require("fs");
Expand Down
2 changes: 1 addition & 1 deletion tests/nasm/create_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// number of tests per instruction
const NO_TESTS = 1;

const assert = require("assert").strict;
const assert = require("assert").strict || require("assert"); // Strict mode added in: V8.13.0
const fs = require("fs");
const encodings = require("../../gen/x86_table.js");
const Prand = require("./prand.js");
Expand Down
2 changes: 1 addition & 1 deletion tests/nasm/gen_fixtures.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
"use strict";

const assert = require("assert").strict;
const assert = require("assert").strict || require("assert"); // Strict mode added in: V8.13.0
const fs = require("fs");
const os = require("os");
const path = require("path");
Expand Down
2 changes: 1 addition & 1 deletion tests/nasm/prand.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use strict";
const assert = require("assert");
const assert = require("assert").strict || require("assert"); // Strict mode added in: V8.13.0

/**
* Creates a pseudo-random value generator. The seed must be an integer.
Expand Down
2 changes: 1 addition & 1 deletion tests/nasm/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ process.on("unhandledRejection", exn => { throw exn; });

// A #UD might indicate a bug in the test generation

const assert = require("assert").strict;
const assert = require("assert").strict || require("assert"); // Strict mode added in: V8.13.0
const fs = require("fs");
const path = require("path");
const os = require("os");
Expand Down
2 changes: 1 addition & 1 deletion tests/qemu/run-qemu.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const QEMU = "qemu-system-x86_64";

const assert = require("assert").strict;
const assert = require("assert").strict || require("assert"); // Strict mode added in: V8.13.0
const fs = require("fs");
const { spawn, spawnSync } = require("child_process");
const path = require("path");
Expand Down
2 changes: 1 addition & 1 deletion tests/rust/verify-wasmgen-dummy-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

process.on("unhandledRejection", exn => { throw exn; });

const assert = require("assert").strict;
const assert = require("assert").strict || require("assert"); // Strict mode added in: V8.13.0
const fs = require("fs");
const path = require("path");

Expand Down