optimized cc65 files; new cc65 test

This commit is contained in:
Steven Hugg 2017-01-12 11:22:27 -05:00
parent a3c26ea1b4
commit ab89dd8b47
6 changed files with 69 additions and 211067 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -36,7 +36,7 @@ var fsMeta, fsBlob;
xhr.open("GET", "fs65.js.metadata", false); // synchronous request
xhr.send(null);
fsMeta = xhr.response;
console.log("Loaded filesystem", fsMeta.files.length, 'files', fsBlob.size||fsBlob.length, 'bytes');
console.log("Loaded filesystem", fsMeta.files.length, 'files', fsBlob.size, 'bytes');
}
// mount the filesystem at /share
@ -53,7 +53,10 @@ var DASM_MAIN_FILENAME = "main.a";
var DASM_PREAMBLE = "\tprocessor 6502\n";
var DASM_PREAMBLE_LINES = 1;
var print_fn = function(s) { console.log(s); }
var print_fn = function(s) {
console.log(s);
//console.log(new Error().stack);
}
function parseDASMListing(code, unresolved) {
var errorMatch = /main.a [(](\d+)[)]: error: (.+)/;

View File

@ -13,15 +13,36 @@ global.importScripts = function(path) {
includeInThisContext('src/worker/'+path);
}
function Blob(blob) {
this.size = blob.length;
this.length = blob.length;
this.slice = function(a,b) {
var data = blob.slice(a,b);
var b = new Blob(data);
//console.log(a, b, data.length, data.slice(0,64));
//console.log(new Error().stack);
return b;
}
this.asArrayBuffer = function() {
var buf = new ArrayBuffer(blob.length);
var arr = new Uint8Array(buf);
for (var i=0; i<blob.length; i++)
arr[i] = blob[i].charCodeAt(0);
return arr;
}
}
global.XMLHttpRequest = function() {
var txt;
this.open = function(a,b,c) {
txt = fs.readFileSync('src/worker/'+b);
if (this.responseType == 'json') {
var txt = fs.readFileSync('src/worker/'+b);
this.response = JSON.parse(txt);
} else if (this.responseType == 'blob') {
this.response = txt; //new Uint8Array(txt);
//console.log(this.response.slice(0,100));
var data = fs.readFileSync('src/worker/'+b, {encoding:'binary'});
//var buf = new ArrayBuffer(data.length);
//var blob = new Uint8Array(buf);
//blob.set(data);
this.response = new Blob(data);
}
}
this.send = function() { }
@ -29,7 +50,7 @@ global.XMLHttpRequest = function() {
global.FileReaderSync = function() {
this.readAsArrayBuffer = function(blob) {
return blob.slice(0);
return blob.asArrayBuffer();
}
}
@ -40,7 +61,7 @@ includeInThisContext("src/worker/workermain.js");
function compile(tool, code, callback, outlen) {
global.postMessage = function(msg) {
//console.log(msg);
if (msg.listing.errors.length) console.log(msg.listing.errors);
assert.ok(msg.listing.lines);
assert.equal(msg.listing.errors.length, msg.listing.errors);
assert.equal(msg.output.length, outlen);
@ -58,9 +79,7 @@ describe('Worker', function() {
it('should compile PLASMA', function(done) {
compile('plasm', 'word x = 0', done, 5);
});
/*
it('should compile CC65', function(done) {
compile('cc65', '#include <stdio.h>\nint main() {\nint x=1;\nreturn x+2;\n}', done, 5);
compile('cc65', '#include <stdio.h>\nint main() {\nint x=1;\nprintf("%d",x);\nreturn x+2;\n}', done, 2947);
});
*/
});