fixed some worker types

This commit is contained in:
Steven Hugg 2019-12-27 16:31:24 -06:00
parent 59608b3a29
commit a05190da44
5 changed files with 27 additions and 18 deletions

View File

@ -15,7 +15,7 @@ export class SourceFile {
offset2line: Map<number,number>; //{[offset:number]:number};
line2offset: Map<number,number>; //{[line:number]:number};
constructor(lines:SourceLine[], text?:string) {
constructor(lines:SourceLine[], text:string) {
lines = lines || [];
this.lines = lines;
this.text = text;
@ -79,10 +79,10 @@ export interface WorkerError {
export interface CodeListing {
lines:SourceLine[],
asmlines:SourceLine[],
text:string,
sourcefile?:SourceFile,
assemblyfile?:SourceFile
asmlines?:SourceLine[],
text?:string,
sourcefile?:SourceFile, // not returned by worker
assemblyfile?:SourceFile // not returned by worker
}
export type CodeListingMap = {[path:string]:CodeListing};

View File

@ -25,6 +25,7 @@ export class CodeProject {
store : any;
callbackGetRemote : GetRemoteCallback;
isCompiling : boolean = false;
filename2path = {}; // map stripped paths to full paths
constructor(worker, platform_id:string, platform, store) {
this.worker = worker;
@ -156,11 +157,13 @@ export class CodeProject {
var maintext = this.getFile(this.mainpath);
var depfiles = [];
msg.updates.push({path:mainfilename, data:maintext});
this.filename2path[mainfilename] = this.mainpath;
for (var dep of depends) {
if (!dep.link) {
msg.updates.push({path:dep.filename, data:dep.data});
depfiles.push(dep.filename);
}
this.filename2path[dep.filename] = dep.path;
}
msg.buildsteps.push({path:mainfilename, files:[mainfilename].concat(depfiles), platform:this.platform_id, tool:this.platform.getToolForFilename(this.mainpath), mainfile:true});
for (var dep of depends) {
@ -311,6 +314,9 @@ export class CodeProject {
// returns first listing in format [prefix].lst (TODO: could be better)
getListingForFile(path) : CodeListing {
// ignore include files (TODO)
if (path.toLowerCase().endsWith('.h') || path.toLowerCase().endsWith('.inc'))
return;
var fnprefix = getFilenamePrefix(this.stripLocalPath(path));
var listings = this.getListings();
for (var lstfn in listings) {

View File

@ -1108,6 +1108,7 @@ function openRelevantListing(state: EmuState) {
if (projectWindows.isWindow(wndid)) {
var lst = listings[lstfn];
var file = lst.assemblyfile || lst.sourcefile;
// TODO: look for closest match, not just first match
var lineno = file && file.findLineForOffset(pc, 16); // TODO: const
console.log(hex(pc,4), wndid, lstfn, lineno);
if (lineno !== null) {
@ -1124,7 +1125,7 @@ function openRelevantListing(state: EmuState) {
function uiDebugCallback(state: EmuState) {
lastDebugState = state;
showDebugInfo(state);
// TODO: openRelevantListing(state);
//openRelevantListing(state);
projectWindows.refresh(true); // move cursor
debugTickPaused = true;
}

View File

@ -159,7 +159,9 @@ export class ProjectWindows {
findWindowWithFilePrefix(filename : string) : string {
filename = getFilenameForPath(getFilenamePrefix(filename));
for (var fileid in this.id2createfn) {
console.log(filename, getFilenamePrefix(fileid));
// ignore include files (TODO)
if (fileid.toLowerCase().endsWith('.h') || fileid.toLowerCase().endsWith('.inc'))
continue;
if (getFilenameForPath(getFilenamePrefix(fileid)) == filename) return fileid;
}
return null;

View File

@ -1,6 +1,6 @@
"use strict";
import { WorkerResult, WorkerFileUpdate, WorkerBuildStep, WorkerMessage, WorkerError, Dependency, SourceLine } from "../common/workertypes";
import { WorkerResult, WorkerFileUpdate, WorkerBuildStep, WorkerMessage, WorkerError, Dependency, SourceLine, CodeListing, CodeListingMap } from "../common/workertypes";
declare var WebAssembly;
declare function importScripts(path:string);
@ -640,7 +640,7 @@ function parseSourceLines(code:string, lineMatch, offsetMatch) {
return lines;
}
function parseDASMListing(code:string, listings:{}, errors:WorkerError[], unresolved:{}) {
function parseDASMListing(code:string, listings:CodeListingMap, errors:WorkerError[], unresolved:{}) {
// TODO: this gets very slow
// 4 08ee a9 00 start lda #01workermain.js:23:5
var lineMatch = /\s*(\d+)\s+(\S+)\s+([0-9a-f]+)\s+([?0-9a-f][?0-9a-f ]+)?\s+(.+)?/i;
@ -766,7 +766,7 @@ function assembleDASM(step:BuildStep) {
"-s"+sympath ]);
var alst = FS.readFile(lstpath, {'encoding':'utf8'});
// parse main listing, get errors and listings for each file
var listings = {};
var listings : CodeListingMap = {};
for (let path of step.files) {
listings[path] = {lines:[]};
}
@ -1005,7 +1005,7 @@ function linkLD65(step:BuildStep) {
}
}
// build listings
var listings = {};
var listings : CodeListingMap = {};
for (var fn of step.files) {
if (fn.endsWith('.lst')) {
var lstout = FS.readFile(fn, {encoding:'utf8'});
@ -1281,7 +1281,7 @@ function linkSDLDZ80(step:BuildStep)
return {errors:errors};
}
// parse listings
var listings = {};
var listings : CodeListingMap = {};
for (var fn of step.files) {
if (fn.endsWith('.lst')) {
var rstout = FS.readFile(fn.replace('.lst','.rst'), {encoding:'utf8'});
@ -1635,7 +1635,7 @@ function compileVerilator(step:BuildStep) {
return {errors:errors};
}
//rtn.intermediate = {listing:h_file + cpp_file}; // TODO
var listings = {};
var listings : CodeListingMap = {};
// TODO: what if found in non-top-module?
if (asmlines.length)
listings[step.path] = {lines:asmlines};
@ -1725,7 +1725,7 @@ error1.asm(11): warning: 'foobar' treated as label (instruction typo?)
return;
// 230: 1739+7+x 017A 1600 L017A: LD D,00h
var lines = parseListing(lstout, /\s*(\d+):\s*([0-9a-f]+)\s+([0-9a-f]+)\s+(.+)/i, 1, 2, 3);
var listings = {};
var listings : CodeListingMap = {};
listings[lstpath] = {lines:lines};
// parse symbol table
var symbolmap = {};
@ -1941,7 +1941,7 @@ function assembleXASM6809(step:BuildStep) {
//00005 W 0003 [ 8] A6890011 lda >PALETTE,x
//00012 0011 0C0203 fcb 12,2,3
var asmlines = parseListing(alst, /^\s*([0-9]+) .+ ([0-9A-F]+)\s+\[([0-9 ]+)\]\s+([0-9A-F]+) (.*)/i, 1, 2, 4, 3);
var listings = {};
var listings : CodeListingMap = {};
listings[step.prefix+'.lst'] = {lines:asmlines, text:alst};
return {
output:aout,
@ -1998,7 +1998,7 @@ function assembleNESASM(step:BuildStep) {
var sympath = step.prefix+'.fns';
execMain(step, Module, [step.path, '-s', "-l", "2" ]);
// parse main listing, get errors and listings for each file
var listings = {};
var listings : CodeListingMap = {};
try {
var alst = FS.readFile(lstpath, {'encoding':'utf8'});
// 16 00:C004 8E 17 40 STX $4017 ; disable APU frame IRQ
@ -2193,7 +2193,7 @@ function linkLWLINK(step:BuildStep) {
// TODO: build segment map
var segments = {};
// build listings
var listings = {};
var listings : CodeListingMap = {};
for (var fn of step.files) {
if (fn.endsWith('.lst')) {
// TODO
@ -2317,7 +2317,7 @@ function executeBuildSteps() {
}
// process with another tool?
if (step.result.nexttool) {
var asmstep = step.result;
var asmstep : BuildStep = step.result;
asmstep.tool = step.result.nexttool;
asmstep.platform = platform;
buildsteps.push(asmstep);