assembler - Change to make use of improvements in Opter
This commit is contained in:
parent
9c1cf4abba
commit
e25723fcc9
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const fs = require('fs');
|
||||
|
||||
const argparser = require('./argparser/argparser.js');
|
||||
const Opter = require('./opter/opter.js');
|
||||
const { logMemory } = require('./logging.js');
|
||||
const { num2hex, hex2num, bin2num } = require('./conversions.js');
|
||||
const DBG = require('./dbg.js');
|
||||
|
|
@ -405,40 +405,26 @@ function stripWhitespaceFromEnds(line) {
|
|||
|
||||
/** MAIN **/
|
||||
|
||||
// Initialize debugger
|
||||
let dbg = new DBG('nitpick');
|
||||
|
||||
// Handle command-line options...
|
||||
const args = argparser(process.argv);
|
||||
dbg.d('args', args);
|
||||
const opts = new Opter(process.argv);
|
||||
opts.synonymize('-d', '--debug');
|
||||
opts.requireOption('-i', 'Input file required (-i prog.asm)');
|
||||
opts.requireOptionArgument('-i', 1, 1, 'Input file required (-i prog.asm)');
|
||||
opts.requireOptionArgument('-o', 1, 1, 'Missing output file name (-o prog.asm)');
|
||||
|
||||
if (typeof args.i === 'undefined' || args.i.length === 0) {
|
||||
console.error('Input file required (-i prog.asm)');
|
||||
process.exit();
|
||||
}
|
||||
const inputFilename = args.i[0];
|
||||
const inputFilename = opts.opts.i[0];
|
||||
const inputFile_str = fs.readFileSync(inputFilename, 'utf8');
|
||||
|
||||
if ('o' in args && args.o.length === 0) {
|
||||
console.error('Missing output file name (-o prog.asm)');
|
||||
process.exit();
|
||||
}
|
||||
let outputFileProvided = opts.contains('-o');
|
||||
let returnOnStdout = !outputFileProvided;
|
||||
let outputFilename = outputFileProvided ? opts.opts.o[0] : null;
|
||||
|
||||
let outputFilename = null;
|
||||
let returnOnStdout = 'o' in args ? false : true;
|
||||
if (!returnOnStdout) {
|
||||
outputFilename = args.o[0];
|
||||
} else {
|
||||
dbg = new DBG('none');
|
||||
}
|
||||
let outputWithMetadata = opts.contains('--debug');
|
||||
|
||||
let outputWithMetadata = false;
|
||||
if ('d' in args || 'debug' in args) {
|
||||
outputWithMetadata = true;
|
||||
}
|
||||
|
||||
// TODO: maybe check for too many args?
|
||||
// Initialize debugger...
|
||||
const dbg = returnOnStdout ? new DBG('none') : new DBG('nitpick');
|
||||
|
||||
// Assemble...!
|
||||
assemble(inputFile_str, outputFilename, outputWithMetadata);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit c2ea099bbfddada734b5fc6e4f1125658c8ba578
|
||||
Subproject commit 4dec08afbc0c96e454dd532ed9cfa16a4a1ddd51
|
||||
Loading…
Reference in New Issue