worker: can return listings with error result

This commit is contained in:
Steven Hugg 2022-02-19 11:43:40 -06:00
parent 38920c6dce
commit 600e62f0c6
2 changed files with 13 additions and 3 deletions

View File

@ -1,5 +1,5 @@
import { FileData, Dependency, SourceLine, SourceFile, CodeListing, CodeListingMap, WorkerError, Segment, WorkerResult, WorkerOutputResult, isUnchanged, isOutputResult, WorkerMessage, WorkerItemUpdate } from "../common/workertypes";
import { FileData, Dependency, SourceLine, SourceFile, CodeListing, CodeListingMap, WorkerError, Segment, WorkerResult, WorkerOutputResult, isUnchanged, isOutputResult, WorkerMessage, WorkerItemUpdate, WorkerErrorResult, isErrorResult } from "../common/workertypes";
import { getFilenamePrefix, getFolderForPath, isProbablyBinary, getBasePlatform, getWithBinary } from "../common/util";
import { Platform } from "../common/baseplatform";
import localforage from "localforage";
@ -129,6 +129,8 @@ export class CodeProject {
}
if (data && isOutputResult(data)) {
this.processBuildResult(data);
} else if (isErrorResult(data)) {
this.processBuildListings(data);
}
this.callbackBuildResult(data);
}
@ -376,7 +378,7 @@ export class CodeProject {
this.sendBuild();
}
processBuildResult(data: WorkerOutputResult<any>) {
processBuildListings(data: WorkerOutputResult<any> | WorkerErrorResult) {
// TODO: link listings with source files
if (data.listings) {
this.listings = data.listings;
@ -388,6 +390,14 @@ export class CodeProject {
lst.assemblyfile = new SourceFile(lst.asmlines, lst.text);
}
}
}
processBuildResult(data: WorkerOutputResult<any>) {
this.processBuildListings(data);
this.processBuildSegments(data);
}
processBuildSegments(data: WorkerOutputResult<any>) {
// save and sort segment list
var segs = (this.platform.getMemoryMap && this.platform.getMemoryMap()["main"]) || [];
if (data.segments) { segs = segs.concat(data.segments || []); }

View File

@ -323,7 +323,7 @@ function refreshWindowList() {
for (var lstfn in listings) {
var lst = listings[lstfn];
// add listing if source/assembly file exists and has text
if ((lst.assemblyfile && lst.assemblyfile.text) || (lst.sourcefile && lst.sourcefile.text)) {
if ((lst.assemblyfile && lst.assemblyfile.text) || (lst.sourcefile && lst.sourcefile.text) || lst.text) {
addWindowItem(lstfn, getFilenameForPath(lstfn), (path) => {
return new ListingView(path);
});