Skip to content

Commit 9c127fe

Browse files
authored
Use node's builtin assert in the JS compiler. NFC (#17469)
Node's assert message are way nicer too.
1 parent 104a967 commit 9c127fe

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

src/compiler.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// LLVM => JavaScript compiler, main entry point
99

1010
const fs = require('fs');
11+
global.assert = require('assert');
1112
global.nodePath = require('path');
1213

1314
global.print = (x) => {

src/utility.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,6 @@ function dump(item) {
3939
}
4040
}
4141

42-
function assert(a, msg) {
43-
if (!a) {
44-
msg = 'Assertion failed' + (msg ? ': ' + msg : '');
45-
print(msg);
46-
printErr('Stack: ' + new Error().stack);
47-
throw msg;
48-
}
49-
}
50-
5142
global.warnings = false;
5243

5344
function warn(a, msg) {

tools/preprocessor.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ global.printErr = function(x) {
2727
process['stderr'].write(x + '\n');
2828
};
2929

30+
global.assert = require('assert');
31+
3032
function find(filename) {
3133
const prefixes = [process.cwd(), path.join(__dirname, '..', 'src')];
3234
for (let i = 0; i < prefixes.length; ++i) {

0 commit comments

Comments
 (0)