mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-01-26 17:33:36 +00:00
ecs: debug info
This commit is contained in:
parent
3f241bfcc2
commit
9b6f797451
@ -183,7 +183,13 @@ export class ECSCompiler extends Tokenizer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parseCode(): string {
|
parseCode(): string {
|
||||||
return this.expectTokenTypes([TokenType.CodeFragment]).str;
|
let tok = this.expectTokenTypes([TokenType.CodeFragment]);
|
||||||
|
let code = tok.str;
|
||||||
|
let lines = code.split('\n');
|
||||||
|
for (let i=0; i<lines.length; i++) {
|
||||||
|
lines[i] = ` .dbg line, "${this.path}", ${tok.$loc.line+i}\n` + lines[i];
|
||||||
|
}
|
||||||
|
return lines.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
parseScope() : EntityScope {
|
parseScope() : EntityScope {
|
||||||
@ -263,6 +269,7 @@ export class ECSCompiler extends Tokenizer {
|
|||||||
|
|
||||||
export() {
|
export() {
|
||||||
let src = new SourceFileExport();
|
let src = new SourceFileExport();
|
||||||
|
src.debug_file(this.path);
|
||||||
this.exportToFile(src);
|
this.exportToFile(src);
|
||||||
return src.toString();
|
return src.toString();
|
||||||
}
|
}
|
||||||
|
@ -220,6 +220,12 @@ export class SourceFileExport {
|
|||||||
for (let l of s.split('\n'))
|
for (let l of s.split('\n'))
|
||||||
this.lines.push(l);
|
this.lines.push(l);
|
||||||
}
|
}
|
||||||
|
debug_file(path: string) {
|
||||||
|
this.lines.push(` .dbg file, "${path}", 0, 0`);
|
||||||
|
}
|
||||||
|
debug_line(path: string, line: number) {
|
||||||
|
this.lines.push(` .dbg line, "${path}", ${line}`);
|
||||||
|
}
|
||||||
toString() {
|
toString() {
|
||||||
return this.lines.join('\n');
|
return this.lines.join('\n');
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,7 @@ export class Tokenizer {
|
|||||||
includeEOL = false;
|
includeEOL = false;
|
||||||
errorOnCatchAll = false;
|
errorOnCatchAll = false;
|
||||||
codeFragment : string | null = null;
|
codeFragment : string | null = null;
|
||||||
|
codeFragmentStart : SourceLocation | null = null;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.lineno = 0;
|
this.lineno = 0;
|
||||||
@ -110,9 +111,13 @@ export class Tokenizer {
|
|||||||
switch (rule.type) {
|
switch (rule.type) {
|
||||||
case TokenType.CodeFragment:
|
case TokenType.CodeFragment:
|
||||||
if (this.codeFragment) {
|
if (this.codeFragment) {
|
||||||
this._pushToken({ str: this.codeFragment, type: rule.type, $loc: loc }); //TODO: merge start/end
|
let codeLoc = mergeLocs(this.codeFragmentStart, loc);
|
||||||
|
this._pushToken({ str: this.codeFragment, type: rule.type, $loc: codeLoc }); //TODO: merge start/end
|
||||||
|
this.codeFragmentStart = null;
|
||||||
this.codeFragment = null;
|
this.codeFragment = null;
|
||||||
} else {
|
} else {
|
||||||
|
loc.line++;
|
||||||
|
this.codeFragmentStart = loc;
|
||||||
this.codeFragment = '';
|
this.codeFragment = '';
|
||||||
return; // don't add any more tokens (TODO: check for trash?)
|
return; // don't add any more tokens (TODO: check for trash?)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user