1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-05-28 23:41:32 +00:00

error messages for LD65

This commit is contained in:
Steven Hugg 2018-07-02 21:55:38 -06:00
parent ffe373489e
commit 958fbe747f
2 changed files with 9 additions and 3 deletions

View File

@ -338,7 +338,7 @@ function makeErrorMatcher(errors, regex, iline, imsg) {
msg:matches[imsg]
});
} else {
console.log(s);
console.log("??? "+s);
}
}
}
@ -603,12 +603,13 @@ function linkLD65(step) {
var binpath = "main";
if (staleFiles(step, [binpath])) {
var errors = [];
var errmsg = '';
var LD65 = ld65({
wasmBinary: wasmBlob['ld65'],
noInitialRun:true,
//logReadFiles:true,
print:print_fn,
printErr:makeErrorMatcher(errors, /[(](\d+)[)]: (.+)/, 1, 2),
printErr:function(s) { errmsg += s + '\n'; }
});
var FS = LD65['FS'];
var cfgfile = '/' + platform + '.cfg';
@ -625,6 +626,8 @@ function linkLD65(step) {
'-o', 'main', '-m', 'main.map'].concat(step.args, libargs);
//console.log(args);
execMain(step, LD65, args);
if (errmsg.length)
errors.push({line:0, msg:errmsg});
if (errors.length)
return {errors:errors};
var aout = FS.readFile("main", {encoding:'binary'});

View File

@ -85,9 +85,12 @@ describe('Worker', function() {
it('should compile CC65', function(done) {
compile('cc65', 'int main() {\nint x=1;\nreturn x+2;\n}', 'nes-conio', done, 40976, 3);
});
it('should NOT compile CC65', function(done) {
it('should NOT compile CC65 (compile error)', function(done) {
compile('cc65', 'int main() {\nint x=1;\nprintf("%d",x);\nreturn x+2;\n}', 'nes-conio', done, 0, 0, 1);
});
it('should NOT compile CC65 (link error)', function(done) {
compile('cc65', 'extern void bad();\nint main() {\nbad();\nreturn 0;\n}', 'nes-conio', done, 0, 0, 1);
});
it('should assemble CA65', function(done) {
compile('ca65', '\t.segment "HEADER"\n\t.segment "STARTUP"\n\t.segment "CHARS"\n\t.segment "VECTORS"\n\tlda #0\n\tsta $1\n', 'nes-conio', done, 40976, 2);
});