mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-21 10:41:42 +00:00
Implement ternary using if, see AssemblyScript/assemblyscript#123
This commit is contained in:
@ -8,5 +8,14 @@
|
||||
"desc": "Print this message.",
|
||||
"type": "boolean",
|
||||
"aliases": [ "h" ]
|
||||
},
|
||||
"optimize": {
|
||||
"desc": "Optimize the module.",
|
||||
"type": "boolean",
|
||||
"aliases": [ "O" ]
|
||||
},
|
||||
"validate": {
|
||||
"desc": "Validate the module.",
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
|
25
bin/asc.ts
25
bin/asc.ts
@ -8,6 +8,7 @@ import * as as from "../src";
|
||||
|
||||
var conf: { [key: string]: { desc: string, type: string, aliases: string[], default: any } } = require("./asc.json");
|
||||
var opts: minimist.Opts = {};
|
||||
|
||||
Object.keys(conf).forEach(key => {
|
||||
var opt = conf[key];
|
||||
if (opt.aliases)
|
||||
@ -80,7 +81,7 @@ let diagnostic: as.DiagnosticMessage | null;
|
||||
let hasErrors: boolean = false;
|
||||
|
||||
while ((diagnostic = as.nextDiagnostic(parser)) != null) {
|
||||
console.error(as.formatDiagnostic(diagnostic, process.stdout.isTTY, true));
|
||||
console.error(as.formatDiagnostic(diagnostic, process.stderr.isTTY, true));
|
||||
if (as.isError(diagnostic))
|
||||
hasErrors = true;
|
||||
}
|
||||
@ -89,5 +90,27 @@ if (hasErrors)
|
||||
process.exit(1);
|
||||
|
||||
const module = as.compile(parser);
|
||||
|
||||
hasErrors = false;
|
||||
while ((diagnostic = as.nextDiagnostic(parser)) != null) {
|
||||
console.error(as.formatDiagnostic(diagnostic, process.stderr.isTTY, true));
|
||||
if (as.isError(diagnostic))
|
||||
hasErrors = true;
|
||||
}
|
||||
|
||||
if (hasErrors) {
|
||||
module.dispose();
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (args["validate"])
|
||||
if (!module.validate()) {
|
||||
module.dispose();
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (args["optimize"])
|
||||
module.optimize();
|
||||
|
||||
_BinaryenModulePrint(module.ref);
|
||||
module.dispose();
|
||||
|
Reference in New Issue
Block a user