diff --git a/doc/notes.txt b/doc/notes.txt index 886ab25c..c4db12d6 100644 --- a/doc/notes.txt +++ b/doc/notes.txt @@ -38,6 +38,9 @@ TODO: - show self-modifying code insns left of editor - facade/kbd shortcuts for emulators, focus - checkmarks in pulldown menus +- update Javatari version? (and others?) +- WASM takes too long to load (esp. verilog) + (https://developers.google.com/web/updates/2018/04/loading-wasm) WEB WORKER FORMAT diff --git a/src/ui.js b/src/ui.js index c0719e04..1e5e65aa 100644 --- a/src/ui.js +++ b/src/ui.js @@ -1,43 +1,17 @@ "use strict"; -// catch errors -function installErrorHandler() { - if (typeof window.onerror == "object") { - window.onerror = function (msgevent, url, line, col, error) { - console.log(msgevent, url, line, col); - console.log(error); - if (window.location.host.endsWith('8bitworkshop.com')) { - ga('send', 'exception', { - 'exDescription': msgevent + " " + url + " " + " " + line + ":" + col + ", " + error, - 'exFatal': true - }); - } - alert(msgevent+""); - }; - } -} - -function uninstallErrorHandler() { - window.onerror = null; -} - -function gotoNewLocation() { - uninstallErrorHandler(); - window.location = "?" + $.param(qs); -} +// 8bitworkshop IDE user interface // make sure VCS doesn't start if (window.Javatari) Javatari.AUTO_START = false; -// 8bitworkshop IDE user interface - -var PRESETS; // presets array -var platform_id; -var platform; // platform object +var PRESETS; // presets array +var platform_id; // platform ID string +var platform; // platform object var toolbar = $("#controls_top"); -var current_project; +var current_project; // current CodeProject object // TODO: codemirror multiplex support? var TOOL_TO_SOURCE_STYLE = { @@ -56,20 +30,19 @@ function newWorker() { return new Worker("./src/worker/workermain.js"); } -var userPaused; +var userPaused; // did user explicitly pause? -var current_output; -var current_preset_entry; -var main_file_id; -var symbolmap; -var addr2symbol; -var compparams; -var trace_pending_at_pc; -var store; +var current_output; // current ROM +var current_preset_entry; // current preset object (if selected) +var main_file_id; // main file ID +var symbolmap; // symbol map +var addr2symbol; // address to symbol name map +var compparams; // received build params from worker +var trace_pending_at_pc; // true if clock trace (vcs) +var store; // persistent store -var currentDebugLine; -var lastDebugInfo; -var lastDebugState; +var lastDebugInfo; // last debug info (CPU text) +var lastDebugState; // last debug state (object) function inspectVariable(ed, name) { var val; @@ -116,6 +89,7 @@ function SourceEditor(path, mode) { var editor; var dirtylisting = true; var sourcefile; + var currentDebugLine; self.createDiv = function(parent, text) { var div = document.createElement('div'); @@ -162,7 +136,6 @@ function SourceEditor(path, mode) { self.setText = function(text) { editor.setValue(text); // calls setCode() editor.clearHistory(); - current_output = null; // TODO? } self.getValue = function() { @@ -648,6 +621,7 @@ function ProjectWindows(containerdiv) { var activewnd; var activediv; var lasterrors; + // TODO: delete windows ever? this.setCreateFunc = function(id, createfn) { id2createfn[id] = createfn; @@ -1008,14 +982,8 @@ function setCompileOutput(data) { addr2symbol[0x10000] = '__END__'; // needed for dump memory to work compparams = data.params; // load ROM - // TODO: don't have to compare anymore; worker does it var rom = data.output; - var rom_changed = false; - if (rom && rom.code) - rom_changed = !current_output || rom.code != current_output.code; - else if (rom) - rom_changed = !arrayCompare(rom, current_output); - if (rom_changed) { + if (rom) { try { //console.log("Loading ROM length", rom.length); platform.loadROM(getCurrentPresetTitle(), rom); @@ -1030,7 +998,6 @@ function setCompileOutput(data) { } } else if (rom.program_rom_variable) { //TODO: a little wonky... platform.loadROM(rom.program_rom_variable, rom.program_rom); - rom_changed = true; } // update all windows (listings) projectWindows.refresh(); @@ -1388,6 +1355,32 @@ var qs = (function (a) { return b; })(window.location.search.substr(1).split('&')); +// catch errors +function installErrorHandler() { + if (typeof window.onerror == "object") { + window.onerror = function (msgevent, url, line, col, error) { + console.log(msgevent, url, line, col); + console.log(error); + if (window.location.host.endsWith('8bitworkshop.com')) { + ga('send', 'exception', { + 'exDescription': msgevent + " " + url + " " + " " + line + ":" + col + ", " + error, + 'exFatal': true + }); + } + alert(msgevent+""); + }; + } +} + +function uninstallErrorHandler() { + window.onerror = null; +} + +function gotoNewLocation() { + uninstallErrorHandler(); + window.location = "?" + $.param(qs); +} + function initPlatform() { store = createNewPersistentStore(platform_id); } diff --git a/src/worker/workermain.js b/src/worker/workermain.js index 52c1d08a..63c9ae6b 100644 --- a/src/worker/workermain.js +++ b/src/worker/workermain.js @@ -477,13 +477,20 @@ function assembleDASM(step) { var lstpath = step.prefix+'.lst'; var sympath = step.prefix+'.sym'; execMain(step, Module, [step.path, "-l"+lstpath, "-o"+binpath, "-s"+sympath ]); - var aout = FS.readFile(binpath); var alst = FS.readFile(lstpath, {'encoding':'utf8'}); + var listing = parseDASMListing(alst, unresolved, step.path); + if (listing.errors.length) { + return {errors:listing.errors}; + } + var aout = FS.readFile(binpath); var asym = FS.readFile(lstpath, {'encoding':'utf8'}); putWorkFile(binpath, aout); putWorkFile(lstpath, alst); putWorkFile(sympath, asym); - var listing = parseDASMListing(alst, unresolved, step.path); + // return unchanged if no files changed + // TODO: what if listing or symbols change? + if (!anyTargetChanged(step, [binpath/*, lstpath, sympath*/])) + return; var listings = {}; listings[lstpath] = {lines:listing.lines}; var symbolmap = {}; @@ -1110,7 +1117,7 @@ function compileInlineASM(code, platform, options, errors, asmlines) { return code; } -// TODO: make with multiple files +// TODO: make compliant with standard msg format function compileVerilator(step) { loadNative("verilator_bin"); load("../verilator2js"); @@ -1128,7 +1135,7 @@ function compileVerilator(step) { }); var topmod = detectTopModuleName(code); var FS = verilator_mod['FS']; - FS.writeFile(topmod+".v", code); + populateFiles(step, FS, {mainFilePath:topmod+".v"}); writeDependencies(step.dependencies, FS, errors, function(d, code) { return compileInlineASM(code, platform, step, errors, null); }); @@ -1149,6 +1156,9 @@ function compileVerilator(step) { var h_file = FS.readFile("obj_dir/V"+topmod+".h", {encoding:'utf8'}); var cpp_file = FS.readFile("obj_dir/V"+topmod+".cpp", {encoding:'utf8'}); var rtn = translateVerilatorOutputToJS(h_file, cpp_file); + putWorkFile("main.js", rtn.output.code); + if (!anyTargetChanged(step, ["main.js"])) + return; rtn.errors = errors; rtn.intermediate = {listing:h_file + cpp_file}; // TODO rtn.listings = {};