mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-12-01 13:50:30 +00:00
UI no longer compares output with previous; worker handles it
This commit is contained in:
parent
ed46bb3665
commit
5c1fdbf832
@ -38,6 +38,9 @@ TODO:
|
|||||||
- show self-modifying code insns left of editor
|
- show self-modifying code insns left of editor
|
||||||
- facade/kbd shortcuts for emulators, focus
|
- facade/kbd shortcuts for emulators, focus
|
||||||
- checkmarks in pulldown menus
|
- 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
|
WEB WORKER FORMAT
|
||||||
|
93
src/ui.js
93
src/ui.js
@ -1,43 +1,17 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// catch errors
|
// 8bitworkshop IDE user interface
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// make sure VCS doesn't start
|
// make sure VCS doesn't start
|
||||||
if (window.Javatari) Javatari.AUTO_START = false;
|
if (window.Javatari) Javatari.AUTO_START = false;
|
||||||
|
|
||||||
// 8bitworkshop IDE user interface
|
|
||||||
|
|
||||||
var PRESETS; // presets array
|
var PRESETS; // presets array
|
||||||
var platform_id;
|
var platform_id; // platform ID string
|
||||||
var platform; // platform object
|
var platform; // platform object
|
||||||
|
|
||||||
var toolbar = $("#controls_top");
|
var toolbar = $("#controls_top");
|
||||||
|
|
||||||
var current_project;
|
var current_project; // current CodeProject object
|
||||||
|
|
||||||
// TODO: codemirror multiplex support?
|
// TODO: codemirror multiplex support?
|
||||||
var TOOL_TO_SOURCE_STYLE = {
|
var TOOL_TO_SOURCE_STYLE = {
|
||||||
@ -56,20 +30,19 @@ function newWorker() {
|
|||||||
return new Worker("./src/worker/workermain.js");
|
return new Worker("./src/worker/workermain.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
var userPaused;
|
var userPaused; // did user explicitly pause?
|
||||||
|
|
||||||
var current_output;
|
var current_output; // current ROM
|
||||||
var current_preset_entry;
|
var current_preset_entry; // current preset object (if selected)
|
||||||
var main_file_id;
|
var main_file_id; // main file ID
|
||||||
var symbolmap;
|
var symbolmap; // symbol map
|
||||||
var addr2symbol;
|
var addr2symbol; // address to symbol name map
|
||||||
var compparams;
|
var compparams; // received build params from worker
|
||||||
var trace_pending_at_pc;
|
var trace_pending_at_pc; // true if clock trace (vcs)
|
||||||
var store;
|
var store; // persistent store
|
||||||
|
|
||||||
var currentDebugLine;
|
var lastDebugInfo; // last debug info (CPU text)
|
||||||
var lastDebugInfo;
|
var lastDebugState; // last debug state (object)
|
||||||
var lastDebugState;
|
|
||||||
|
|
||||||
function inspectVariable(ed, name) {
|
function inspectVariable(ed, name) {
|
||||||
var val;
|
var val;
|
||||||
@ -116,6 +89,7 @@ function SourceEditor(path, mode) {
|
|||||||
var editor;
|
var editor;
|
||||||
var dirtylisting = true;
|
var dirtylisting = true;
|
||||||
var sourcefile;
|
var sourcefile;
|
||||||
|
var currentDebugLine;
|
||||||
|
|
||||||
self.createDiv = function(parent, text) {
|
self.createDiv = function(parent, text) {
|
||||||
var div = document.createElement('div');
|
var div = document.createElement('div');
|
||||||
@ -162,7 +136,6 @@ function SourceEditor(path, mode) {
|
|||||||
self.setText = function(text) {
|
self.setText = function(text) {
|
||||||
editor.setValue(text); // calls setCode()
|
editor.setValue(text); // calls setCode()
|
||||||
editor.clearHistory();
|
editor.clearHistory();
|
||||||
current_output = null; // TODO?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.getValue = function() {
|
self.getValue = function() {
|
||||||
@ -648,6 +621,7 @@ function ProjectWindows(containerdiv) {
|
|||||||
var activewnd;
|
var activewnd;
|
||||||
var activediv;
|
var activediv;
|
||||||
var lasterrors;
|
var lasterrors;
|
||||||
|
// TODO: delete windows ever?
|
||||||
|
|
||||||
this.setCreateFunc = function(id, createfn) {
|
this.setCreateFunc = function(id, createfn) {
|
||||||
id2createfn[id] = createfn;
|
id2createfn[id] = createfn;
|
||||||
@ -1008,14 +982,8 @@ function setCompileOutput(data) {
|
|||||||
addr2symbol[0x10000] = '__END__'; // needed for dump memory to work
|
addr2symbol[0x10000] = '__END__'; // needed for dump memory to work
|
||||||
compparams = data.params;
|
compparams = data.params;
|
||||||
// load ROM
|
// load ROM
|
||||||
// TODO: don't have to compare anymore; worker does it
|
|
||||||
var rom = data.output;
|
var rom = data.output;
|
||||||
var rom_changed = false;
|
if (rom) {
|
||||||
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) {
|
|
||||||
try {
|
try {
|
||||||
//console.log("Loading ROM length", rom.length);
|
//console.log("Loading ROM length", rom.length);
|
||||||
platform.loadROM(getCurrentPresetTitle(), rom);
|
platform.loadROM(getCurrentPresetTitle(), rom);
|
||||||
@ -1030,7 +998,6 @@ function setCompileOutput(data) {
|
|||||||
}
|
}
|
||||||
} else if (rom.program_rom_variable) { //TODO: a little wonky...
|
} else if (rom.program_rom_variable) { //TODO: a little wonky...
|
||||||
platform.loadROM(rom.program_rom_variable, rom.program_rom);
|
platform.loadROM(rom.program_rom_variable, rom.program_rom);
|
||||||
rom_changed = true;
|
|
||||||
}
|
}
|
||||||
// update all windows (listings)
|
// update all windows (listings)
|
||||||
projectWindows.refresh();
|
projectWindows.refresh();
|
||||||
@ -1388,6 +1355,32 @@ var qs = (function (a) {
|
|||||||
return b;
|
return b;
|
||||||
})(window.location.search.substr(1).split('&'));
|
})(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() {
|
function initPlatform() {
|
||||||
store = createNewPersistentStore(platform_id);
|
store = createNewPersistentStore(platform_id);
|
||||||
}
|
}
|
||||||
|
@ -477,13 +477,20 @@ function assembleDASM(step) {
|
|||||||
var lstpath = step.prefix+'.lst';
|
var lstpath = step.prefix+'.lst';
|
||||||
var sympath = step.prefix+'.sym';
|
var sympath = step.prefix+'.sym';
|
||||||
execMain(step, Module, [step.path, "-l"+lstpath, "-o"+binpath, "-s"+sympath ]);
|
execMain(step, Module, [step.path, "-l"+lstpath, "-o"+binpath, "-s"+sympath ]);
|
||||||
var aout = FS.readFile(binpath);
|
|
||||||
var alst = FS.readFile(lstpath, {'encoding':'utf8'});
|
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'});
|
var asym = FS.readFile(lstpath, {'encoding':'utf8'});
|
||||||
putWorkFile(binpath, aout);
|
putWorkFile(binpath, aout);
|
||||||
putWorkFile(lstpath, alst);
|
putWorkFile(lstpath, alst);
|
||||||
putWorkFile(sympath, asym);
|
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 = {};
|
var listings = {};
|
||||||
listings[lstpath] = {lines:listing.lines};
|
listings[lstpath] = {lines:listing.lines};
|
||||||
var symbolmap = {};
|
var symbolmap = {};
|
||||||
@ -1110,7 +1117,7 @@ function compileInlineASM(code, platform, options, errors, asmlines) {
|
|||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: make with multiple files
|
// TODO: make compliant with standard msg format
|
||||||
function compileVerilator(step) {
|
function compileVerilator(step) {
|
||||||
loadNative("verilator_bin");
|
loadNative("verilator_bin");
|
||||||
load("../verilator2js");
|
load("../verilator2js");
|
||||||
@ -1128,7 +1135,7 @@ function compileVerilator(step) {
|
|||||||
});
|
});
|
||||||
var topmod = detectTopModuleName(code);
|
var topmod = detectTopModuleName(code);
|
||||||
var FS = verilator_mod['FS'];
|
var FS = verilator_mod['FS'];
|
||||||
FS.writeFile(topmod+".v", code);
|
populateFiles(step, FS, {mainFilePath:topmod+".v"});
|
||||||
writeDependencies(step.dependencies, FS, errors, function(d, code) {
|
writeDependencies(step.dependencies, FS, errors, function(d, code) {
|
||||||
return compileInlineASM(code, platform, step, errors, null);
|
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 h_file = FS.readFile("obj_dir/V"+topmod+".h", {encoding:'utf8'});
|
||||||
var cpp_file = FS.readFile("obj_dir/V"+topmod+".cpp", {encoding:'utf8'});
|
var cpp_file = FS.readFile("obj_dir/V"+topmod+".cpp", {encoding:'utf8'});
|
||||||
var rtn = translateVerilatorOutputToJS(h_file, cpp_file);
|
var rtn = translateVerilatorOutputToJS(h_file, cpp_file);
|
||||||
|
putWorkFile("main.js", rtn.output.code);
|
||||||
|
if (!anyTargetChanged(step, ["main.js"]))
|
||||||
|
return;
|
||||||
rtn.errors = errors;
|
rtn.errors = errors;
|
||||||
rtn.intermediate = {listing:h_file + cpp_file}; // TODO
|
rtn.intermediate = {listing:h_file + cpp_file}; // TODO
|
||||||
rtn.listings = {};
|
rtn.listings = {};
|
||||||
|
Loading…
Reference in New Issue
Block a user