Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
21 changes: 13 additions & 8 deletions cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ export async function main(argv, options) {
stats.parseTime += stats.end(begin);
}
}
const numErrors = checkDiagnostics(program, stderr, options.reportDiagnostic, stderrColors.enabled);
const numErrors = checkDiagnostics(program, stderr, opts.disableWarning, options.reportDiagnostic, stderrColors.enabled);
if (numErrors) {
const err = Error(`${numErrors} parse error(s)`);
err.stack = err.message; // omit stack
Expand Down Expand Up @@ -724,7 +724,7 @@ export async function main(argv, options) {
? assemblyscript.getBinaryenModuleRef(module)
: module.ref
);
var numErrors = checkDiagnostics(program, stderr, options.reportDiagnostic, stderrColors.enabled);
var numErrors = checkDiagnostics(program, stderr, opts.disableWarning, options.reportDiagnostic, stderrColors.enabled);
if (numErrors) {
const err = Error(`${numErrors} compile error(s)`);
err.stack = err.message; // omit stack
Expand All @@ -737,7 +737,7 @@ export async function main(argv, options) {
if (error) return prepareResult(error);
}

numErrors = checkDiagnostics(program, stderr, options.reportDiagnostic, stderrColors.enabled);
numErrors = checkDiagnostics(program, stderr, opts.disableWarning, options.reportDiagnostic, stderrColors.enabled);
if (numErrors) {
const err = Error(`${numErrors} afterCompile error(s)`);
err.stack = err.message; // omit stack
Expand Down Expand Up @@ -1117,17 +1117,22 @@ async function getConfig(file, baseDir, readFile) {
}

/** Checks diagnostics emitted so far for errors. */
export function checkDiagnostics(program, stderr, reportDiagnostic, useColors) {
export function checkDiagnostics(program, stderr, disableWarning, reportDiagnostic, useColors) {
if (typeof useColors === "undefined" && stderr) useColors = stderr.isTTY;
var numErrors = 0;
do {
let diagnostic = assemblyscript.nextDiagnostic(program);
if (!diagnostic) break;
if (stderr) {
stderr.write(
assemblyscript.formatDiagnostic(diagnostic, useColors, true) +
EOL + EOL
);
const checkWarningPrint = (diagnostic) => {
if (disableWarning == null) return true;
if (!disableWarning.length) return false;
const code = assemblyscript.getDiagnosticCode(diagnostic);
return !disableWarning.includes(code);
};
if (assemblyscript.isError(diagnostic) || checkWarningPrint(diagnostic)) {
stderr.write(assemblyscript.formatDiagnostic(diagnostic, useColors, true) + EOL + EOL);
}
}
if (reportDiagnostic) {
function wrapRange(range) {
Expand Down
9 changes: 8 additions & 1 deletion cli/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
},
"runPasses": {
"category": "Binaryen",
"description": [
"description": [
"Specifies additional Binaryen passes to run after other",
"optimizations, if any. See: Binaryen/src/passes/pass.cpp"
],
Expand Down Expand Up @@ -313,6 +313,13 @@
"type": "b",
"default": false
},
"disableWarning": {
"description": [
"Disables specified warning output",
"not define specified warning number will disable all kinds of warning"
],
"type": "I"
},
"noEmit": {
"description": "Performs compilation as usual but does not emit code.",
"type": "b",
Expand Down