1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-12-28 05:29:33 +00:00

openRelevantListing() not ready until listings are fixed, "folder/file.ext" normalized

This commit is contained in:
Steven Hugg 2019-12-27 13:19:11 -06:00
parent acc05564a1
commit 5c4b2b0ca4
4 changed files with 37 additions and 13 deletions

View File

@ -312,7 +312,7 @@ export abstract class BaseDebugPlatform extends BasePlatform {
runUntilReturn() {
var SP0 = this.getSP();
this.runEval( (c:CpuState) : boolean => {
return c.SP > SP0;
return c.SP > SP0; // TODO: check for RTS/RET opcode
});
}
runToFrameClock(clock : number) : void {

View File

@ -12,7 +12,9 @@ export class CodeProject {
filedata : {[path:string]:FileData} = {};
listings : CodeListingMap;
segments : Segment[];
// TODO: mainpath and mainPath !??!!?
mainpath : string;
mainPath : string;
pendingWorkerMessages = 0;
tools_preloaded = {};
callbackBuildResult : BuildResultCallback;
@ -22,7 +24,6 @@ export class CodeProject {
platform : Platform;
store : any;
callbackGetRemote : GetRemoteCallback;
mainPath : string;
isCompiling : boolean = false;
constructor(worker, platform_id:string, platform, store) {
@ -328,5 +329,5 @@ export class CodeProject {
}
return path;
}
}

View File

@ -230,8 +230,9 @@ function refreshWindowList() {
// add other source files
current_project.iterateFiles( (id, text) => {
if (text && id != current_project.mainPath)
if (text && id != current_project.mainPath) {
addEditorItem(id);
}
});
// add listings
@ -301,7 +302,7 @@ function loadMainWindow(preset_id:string) {
async function loadProject(preset_id:string) {
// set current file ID
// TODO: this is done twice
// TODO: this is done twice (mainPath and mainpath!)
current_project.mainPath = preset_id;
setLastPreset(preset_id);
// load files from storage or web URLs
@ -1095,27 +1096,35 @@ function checkRunReady() {
}
function openRelevantListing(state: EmuState) {
// if already on disassembly window, retain it
if (projectWindows.getActive() instanceof Views.DisassemblerView) return;
// search through listings
var listings = current_project.getListings();
if (listings) {
var pc = state.c ? (state.c.EPC || state.c.PC) : 0;
for (var lstfn in listings) {
var lst = listings[lstfn];
var file = lst.assemblyfile || lst.sourcefile;
var lineno = file && file.findLineForOffset(pc, 16); // TODO: const
console.log(pc,lstfn,lineno);
if (lineno !== null) {
projectWindows.createOrShow(lstfn, true);
return;
var wndid = projectWindows.findWindowWithFilePrefix(lstfn);
console.log(lstfn,wndid);
if (projectWindows.isWindow(wndid)) {
var lst = listings[lstfn];
var file = lst.assemblyfile || lst.sourcefile;
var lineno = file && file.findLineForOffset(pc, 16); // TODO: const
console.log(hex(pc,4), wndid, lstfn, lineno);
if (lineno !== null) {
projectWindows.createOrShow(wndid, true);
return;
}
}
}
}
// if no appropriate listing found, use disassembly view
projectWindows.createOrShow("#disasm", true);
}
function uiDebugCallback(state: EmuState) {
lastDebugState = state;
showDebugInfo(state);
//openRelevantListing(state);
// TODO: openRelevantListing(state);
projectWindows.refresh(true); // move cursor
debugTickPaused = true;
}

View File

@ -4,6 +4,7 @@ import $ = require("jquery");
import { CodeProject } from "./project";
import { WorkerError, FileData } from "../common/workertypes";
import { ProjectView } from "./views";
import { getFilenamePrefix, getFilenameForPath } from "../common/util";
type WindowCreateFunction = (id:string) => ProjectView;
type WindowShowFunction = (id:string, view:ProjectView) => void;
@ -28,6 +29,10 @@ export class ProjectWindows {
}
// TODO: delete windows ever?
isWindow(id:string) : boolean {
return this.id2createfn[id] != null;
}
setCreateFunc(id:string, createfn:WindowCreateFunction) : void {
this.id2createfn[id] = createfn;
}
@ -150,4 +155,13 @@ export class ProjectWindows {
}
}
}
findWindowWithFilePrefix(filename : string) : string {
filename = getFilenameForPath(getFilenamePrefix(filename));
for (var fileid in this.id2createfn) {
console.log(filename, getFilenamePrefix(fileid));
if (getFilenameForPath(getFilenamePrefix(fileid)) == filename) return fileid;
}
return null;
}
};