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;
|
2020-08-09 21:32:52 +00:00
|
|
|
label?: string;
|
|
|
|
path?: string; // TODO: make mandatory?
|
2020-08-05 04:48:29 +00:00
|
|
|
start?: number;
|
|
|
|
end?: number;
|
|
|
|
}
|
|
|
|
|
2020-08-11 02:35:25 +00:00
|
|
|
// actually it's a kind of SourceSnippet .. can have multiple per line
|
2020-08-09 21:32:52 +00:00
|
|
|
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;
|
2020-08-11 02:35:25 +00:00
|
|
|
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;
|
2020-08-11 02:35:25 +00:00
|
|
|
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) {
|
2020-08-11 02:35:25 +00:00
|
|
|
this.offset2loc[info.offset] = info;
|
2018-07-08 14:07:19 +00:00
|
|
|
this.line2offset[info.line] = info.offset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-12-27 23:03:09 +00:00
|
|
|
// TODO: smarter about looking for source lines between two addresses
|
|
|
|
findLineForOffset(PC:number, lookbehind:number) {
|
2020-08-11 02:35:25 +00:00
|
|
|
if (this.offset2loc) {
|
2018-08-18 14:21:18 +00:00
|
|
|
for (var i=0; i<=lookbehind; i++) {
|
2020-08-11 02:35:25 +00:00
|
|
|
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,
|
2018-08-03 18:06:08 +00:00
|
|
|
link:boolean,
|
2018-07-08 14:07:19 +00:00
|
|
|
data:FileData // TODO: or binary?
|
|
|
|
}
|
|
|
|
|
2018-10-05 13:47:15 +00:00
|
|
|
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[]
|
|
|
|
}
|
|
|
|
|
2020-08-10 01:40:17 +00:00
|
|
|
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
|
2018-11-22 17:28:50 +00:00
|
|
|
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 {
|
2020-07-08 01:56:44 +00:00
|
|
|
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
|
|
|
|