1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-09-26 01:55:00 +00:00
8bitworkshop/src/common/workertypes.ts

114 lines
2.6 KiB
TypeScript
Raw Normal View History

2018-07-08 14:07:19 +00:00
export type FileData = string | Uint8Array;
2020-08-05 04:48:29 +00:00
export interface SourceLocation {
line: number;
label?: string;
path?: string; // TODO: make mandatory?
2020-08-05 04:48:29 +00:00
start?: number;
end?: number;
}
// actually it's a kind of SourceSnippet .. can have multiple per line
export interface SourceLine extends SourceLocation {
2018-07-08 14:07:19 +00:00
offset:number;
insns?:string;
iscode?:boolean;
2019-06-11 13:39:45 +00:00
cycles?:number;
2018-07-08 14:07:19 +00:00
}
export class SourceFile {
lines: SourceLine[];
text: string;
offset2loc: Map<number,SourceLine>; //{[offset:number]:number};
2019-06-02 01:14:52 +00:00
line2offset: Map<number,number>; //{[line:number]:number};
2018-07-08 14:07:19 +00:00
2019-12-27 22:31:24 +00:00
constructor(lines:SourceLine[], text:string) {
2018-07-08 14:07:19 +00:00
lines = lines || [];
this.lines = lines;
this.text = text;
this.offset2loc = new Map();
2019-06-02 01:14:52 +00:00
this.line2offset = new Map();
2018-07-08 14:07:19 +00:00
for (var info of lines) {
if (info.offset >= 0) {
this.offset2loc[info.offset] = info;
2018-07-08 14:07:19 +00:00
this.line2offset[info.line] = info.offset;
}
}
}
// TODO: smarter about looking for source lines between two addresses
findLineForOffset(PC:number, lookbehind:number) {
if (this.offset2loc) {
for (var i=0; i<=lookbehind; i++) {
var loc = this.offset2loc[PC];
if (loc) {
return loc;
2018-07-08 14:07:19 +00:00
}
PC--;
}
}
return null;
}
lineCount():number { return this.lines.length; }
}
export interface Dependency {
path:string,
filename:string,
link:boolean,
2018-07-08 14:07:19 +00:00
data:FileData // TODO: or binary?
}
export interface WorkerFileUpdate {
path:string,
data:FileData
};
export interface WorkerBuildStep {
path?:string
platform:string
tool:string
mainfile?:boolean
};
2018-07-08 14:07:19 +00:00
2018-12-05 13:33:40 +00:00
export interface WorkerMessage extends WorkerBuildStep {
preload:string,
reset:boolean,
code:string,
2018-07-08 14:07:19 +00:00
updates:WorkerFileUpdate[],
buildsteps:WorkerBuildStep[]
}
export interface WorkerError extends SourceLocation {
2018-07-08 14:07:19 +00:00
msg:string,
}
export interface CodeListing {
lines:SourceLine[],
2019-12-27 22:31:24 +00:00
asmlines?:SourceLine[],
text?:string,
sourcefile?:SourceFile, // not returned by worker
assemblyfile?:SourceFile // not returned by worker
2018-07-08 14:07:19 +00:00
}
export type CodeListingMap = {[path:string]:CodeListing};
// TODO
export type VerilogOutput =
{program_rom_variable:string, program_rom:Uint8Array, code:string, name:string, ports:any[], signals:any[]};
export type WorkerOutput = Uint8Array | VerilogOutput;
2018-07-08 14:07:19 +00:00
2019-02-21 21:47:25 +00:00
export type Segment = {name:string, start:number, size:number, last?:number, type?:string};
2018-07-08 14:07:19 +00:00
export interface WorkerResult {
output:WorkerOutput
errors:WorkerError[]
listings:CodeListingMap
symbolmap:{[sym:string]:number}
params:{}
segments?:Segment[]
unchanged?:boolean
debuginfo?:{} // optional info
2018-07-08 14:07:19 +00:00
}
2018-12-01 11:48:33 +00:00