mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-25 18:33:11 +00:00
fixed some worker types
This commit is contained in:
parent
59608b3a29
commit
a05190da44
@ -15,7 +15,7 @@ export class SourceFile {
|
|||||||
offset2line: Map<number,number>; //{[offset:number]:number};
|
offset2line: Map<number,number>; //{[offset:number]:number};
|
||||||
line2offset: Map<number,number>; //{[line:number]:number};
|
line2offset: Map<number,number>; //{[line:number]:number};
|
||||||
|
|
||||||
constructor(lines:SourceLine[], text?:string) {
|
constructor(lines:SourceLine[], text:string) {
|
||||||
lines = lines || [];
|
lines = lines || [];
|
||||||
this.lines = lines;
|
this.lines = lines;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
@ -79,10 +79,10 @@ export interface WorkerError {
|
|||||||
|
|
||||||
export interface CodeListing {
|
export interface CodeListing {
|
||||||
lines:SourceLine[],
|
lines:SourceLine[],
|
||||||
asmlines:SourceLine[],
|
asmlines?:SourceLine[],
|
||||||
text:string,
|
text?:string,
|
||||||
sourcefile?:SourceFile,
|
sourcefile?:SourceFile, // not returned by worker
|
||||||
assemblyfile?:SourceFile
|
assemblyfile?:SourceFile // not returned by worker
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CodeListingMap = {[path:string]:CodeListing};
|
export type CodeListingMap = {[path:string]:CodeListing};
|
||||||
|
@ -25,6 +25,7 @@ export class CodeProject {
|
|||||||
store : any;
|
store : any;
|
||||||
callbackGetRemote : GetRemoteCallback;
|
callbackGetRemote : GetRemoteCallback;
|
||||||
isCompiling : boolean = false;
|
isCompiling : boolean = false;
|
||||||
|
filename2path = {}; // map stripped paths to full paths
|
||||||
|
|
||||||
constructor(worker, platform_id:string, platform, store) {
|
constructor(worker, platform_id:string, platform, store) {
|
||||||
this.worker = worker;
|
this.worker = worker;
|
||||||
@ -156,11 +157,13 @@ export class CodeProject {
|
|||||||
var maintext = this.getFile(this.mainpath);
|
var maintext = this.getFile(this.mainpath);
|
||||||
var depfiles = [];
|
var depfiles = [];
|
||||||
msg.updates.push({path:mainfilename, data:maintext});
|
msg.updates.push({path:mainfilename, data:maintext});
|
||||||
|
this.filename2path[mainfilename] = this.mainpath;
|
||||||
for (var dep of depends) {
|
for (var dep of depends) {
|
||||||
if (!dep.link) {
|
if (!dep.link) {
|
||||||
msg.updates.push({path:dep.filename, data:dep.data});
|
msg.updates.push({path:dep.filename, data:dep.data});
|
||||||
depfiles.push(dep.filename);
|
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});
|
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) {
|
for (var dep of depends) {
|
||||||
@ -311,6 +314,9 @@ export class CodeProject {
|
|||||||
|
|
||||||
// returns first listing in format [prefix].lst (TODO: could be better)
|
// returns first listing in format [prefix].lst (TODO: could be better)
|
||||||
getListingForFile(path) : CodeListing {
|
getListingForFile(path) : CodeListing {
|
||||||
|
// ignore include files (TODO)
|
||||||
|
if (path.toLowerCase().endsWith('.h') || path.toLowerCase().endsWith('.inc'))
|
||||||
|
return;
|
||||||
var fnprefix = getFilenamePrefix(this.stripLocalPath(path));
|
var fnprefix = getFilenamePrefix(this.stripLocalPath(path));
|
||||||
var listings = this.getListings();
|
var listings = this.getListings();
|
||||||
for (var lstfn in listings) {
|
for (var lstfn in listings) {
|
||||||
|
@ -1108,6 +1108,7 @@ function openRelevantListing(state: EmuState) {
|
|||||||
if (projectWindows.isWindow(wndid)) {
|
if (projectWindows.isWindow(wndid)) {
|
||||||
var lst = listings[lstfn];
|
var lst = listings[lstfn];
|
||||||
var file = lst.assemblyfile || lst.sourcefile;
|
var file = lst.assemblyfile || lst.sourcefile;
|
||||||
|
// TODO: look for closest match, not just first match
|
||||||
var lineno = file && file.findLineForOffset(pc, 16); // TODO: const
|
var lineno = file && file.findLineForOffset(pc, 16); // TODO: const
|
||||||
console.log(hex(pc,4), wndid, lstfn, lineno);
|
console.log(hex(pc,4), wndid, lstfn, lineno);
|
||||||
if (lineno !== null) {
|
if (lineno !== null) {
|
||||||
@ -1124,7 +1125,7 @@ function openRelevantListing(state: EmuState) {
|
|||||||
function uiDebugCallback(state: EmuState) {
|
function uiDebugCallback(state: EmuState) {
|
||||||
lastDebugState = state;
|
lastDebugState = state;
|
||||||
showDebugInfo(state);
|
showDebugInfo(state);
|
||||||
// TODO: openRelevantListing(state);
|
//openRelevantListing(state);
|
||||||
projectWindows.refresh(true); // move cursor
|
projectWindows.refresh(true); // move cursor
|
||||||
debugTickPaused = true;
|
debugTickPaused = true;
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,9 @@ export class ProjectWindows {
|
|||||||
findWindowWithFilePrefix(filename : string) : string {
|
findWindowWithFilePrefix(filename : string) : string {
|
||||||
filename = getFilenameForPath(getFilenamePrefix(filename));
|
filename = getFilenameForPath(getFilenamePrefix(filename));
|
||||||
for (var fileid in this.id2createfn) {
|
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;
|
if (getFilenameForPath(getFilenamePrefix(fileid)) == filename) return fileid;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"use strict";
|
"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 var WebAssembly;
|
||||||
declare function importScripts(path:string);
|
declare function importScripts(path:string);
|
||||||
@ -640,7 +640,7 @@ function parseSourceLines(code:string, lineMatch, offsetMatch) {
|
|||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseDASMListing(code:string, listings:{}, errors:WorkerError[], unresolved:{}) {
|
function parseDASMListing(code:string, listings:CodeListingMap, errors:WorkerError[], unresolved:{}) {
|
||||||
// TODO: this gets very slow
|
// TODO: this gets very slow
|
||||||
// 4 08ee a9 00 start lda #01workermain.js:23:5
|
// 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;
|
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 ]);
|
"-s"+sympath ]);
|
||||||
var alst = FS.readFile(lstpath, {'encoding':'utf8'});
|
var alst = FS.readFile(lstpath, {'encoding':'utf8'});
|
||||||
// parse main listing, get errors and listings for each file
|
// parse main listing, get errors and listings for each file
|
||||||
var listings = {};
|
var listings : CodeListingMap = {};
|
||||||
for (let path of step.files) {
|
for (let path of step.files) {
|
||||||
listings[path] = {lines:[]};
|
listings[path] = {lines:[]};
|
||||||
}
|
}
|
||||||
@ -1005,7 +1005,7 @@ function linkLD65(step:BuildStep) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// build listings
|
// build listings
|
||||||
var listings = {};
|
var listings : CodeListingMap = {};
|
||||||
for (var fn of step.files) {
|
for (var fn of step.files) {
|
||||||
if (fn.endsWith('.lst')) {
|
if (fn.endsWith('.lst')) {
|
||||||
var lstout = FS.readFile(fn, {encoding:'utf8'});
|
var lstout = FS.readFile(fn, {encoding:'utf8'});
|
||||||
@ -1281,7 +1281,7 @@ function linkSDLDZ80(step:BuildStep)
|
|||||||
return {errors:errors};
|
return {errors:errors};
|
||||||
}
|
}
|
||||||
// parse listings
|
// parse listings
|
||||||
var listings = {};
|
var listings : CodeListingMap = {};
|
||||||
for (var fn of step.files) {
|
for (var fn of step.files) {
|
||||||
if (fn.endsWith('.lst')) {
|
if (fn.endsWith('.lst')) {
|
||||||
var rstout = FS.readFile(fn.replace('.lst','.rst'), {encoding:'utf8'});
|
var rstout = FS.readFile(fn.replace('.lst','.rst'), {encoding:'utf8'});
|
||||||
@ -1635,7 +1635,7 @@ function compileVerilator(step:BuildStep) {
|
|||||||
return {errors:errors};
|
return {errors:errors};
|
||||||
}
|
}
|
||||||
//rtn.intermediate = {listing:h_file + cpp_file}; // TODO
|
//rtn.intermediate = {listing:h_file + cpp_file}; // TODO
|
||||||
var listings = {};
|
var listings : CodeListingMap = {};
|
||||||
// TODO: what if found in non-top-module?
|
// TODO: what if found in non-top-module?
|
||||||
if (asmlines.length)
|
if (asmlines.length)
|
||||||
listings[step.path] = {lines:asmlines};
|
listings[step.path] = {lines:asmlines};
|
||||||
@ -1725,7 +1725,7 @@ error1.asm(11): warning: 'foobar' treated as label (instruction typo?)
|
|||||||
return;
|
return;
|
||||||
// 230: 1739+7+x 017A 1600 L017A: LD D,00h
|
// 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 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};
|
listings[lstpath] = {lines:lines};
|
||||||
// parse symbol table
|
// parse symbol table
|
||||||
var symbolmap = {};
|
var symbolmap = {};
|
||||||
@ -1941,7 +1941,7 @@ function assembleXASM6809(step:BuildStep) {
|
|||||||
//00005 W 0003 [ 8] A6890011 lda >PALETTE,x
|
//00005 W 0003 [ 8] A6890011 lda >PALETTE,x
|
||||||
//00012 0011 0C0203 fcb 12,2,3
|
//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 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};
|
listings[step.prefix+'.lst'] = {lines:asmlines, text:alst};
|
||||||
return {
|
return {
|
||||||
output:aout,
|
output:aout,
|
||||||
@ -1998,7 +1998,7 @@ function assembleNESASM(step:BuildStep) {
|
|||||||
var sympath = step.prefix+'.fns';
|
var sympath = step.prefix+'.fns';
|
||||||
execMain(step, Module, [step.path, '-s', "-l", "2" ]);
|
execMain(step, Module, [step.path, '-s', "-l", "2" ]);
|
||||||
// parse main listing, get errors and listings for each file
|
// parse main listing, get errors and listings for each file
|
||||||
var listings = {};
|
var listings : CodeListingMap = {};
|
||||||
try {
|
try {
|
||||||
var alst = FS.readFile(lstpath, {'encoding':'utf8'});
|
var alst = FS.readFile(lstpath, {'encoding':'utf8'});
|
||||||
// 16 00:C004 8E 17 40 STX $4017 ; disable APU frame IRQ
|
// 16 00:C004 8E 17 40 STX $4017 ; disable APU frame IRQ
|
||||||
@ -2193,7 +2193,7 @@ function linkLWLINK(step:BuildStep) {
|
|||||||
// TODO: build segment map
|
// TODO: build segment map
|
||||||
var segments = {};
|
var segments = {};
|
||||||
// build listings
|
// build listings
|
||||||
var listings = {};
|
var listings : CodeListingMap = {};
|
||||||
for (var fn of step.files) {
|
for (var fn of step.files) {
|
||||||
if (fn.endsWith('.lst')) {
|
if (fn.endsWith('.lst')) {
|
||||||
// TODO
|
// TODO
|
||||||
@ -2317,7 +2317,7 @@ function executeBuildSteps() {
|
|||||||
}
|
}
|
||||||
// process with another tool?
|
// process with another tool?
|
||||||
if (step.result.nexttool) {
|
if (step.result.nexttool) {
|
||||||
var asmstep = step.result;
|
var asmstep : BuildStep = step.result;
|
||||||
asmstep.tool = step.result.nexttool;
|
asmstep.tool = step.result.nexttool;
|
||||||
asmstep.platform = platform;
|
asmstep.platform = platform;
|
||||||
buildsteps.push(asmstep);
|
buildsteps.push(asmstep);
|
||||||
|
Loading…
Reference in New Issue
Block a user