mirror of
https://github.com/Mercantec-GHC/h4-projekt-gruppe-0-sm.git
synced 2025-04-27 16:24:07 +02:00
compiler: stop on errors
This commit is contained in:
parent
21c737d06a
commit
aa35b6f35d
@ -15,6 +15,7 @@ export class Ctx {
|
||||
private _entryFile?: File;
|
||||
|
||||
private reports: Report[] = [];
|
||||
private maxSeverity: number = severityCode.none;
|
||||
|
||||
public fileHasChildWithIdent(file: File, childIdent: string): boolean {
|
||||
return this.files.get(file)!
|
||||
@ -108,9 +109,16 @@ export class Ctx {
|
||||
|
||||
public report(rep: Report) {
|
||||
this.reports.push(rep);
|
||||
if (this.maxSeverity < severityCode[rep.severity]) {
|
||||
this.maxSeverity = severityCode[rep.severity];
|
||||
}
|
||||
this.reportImmediately(rep);
|
||||
}
|
||||
|
||||
public errorOccured(): boolean {
|
||||
return this.maxSeverity >= severityCode.error;
|
||||
}
|
||||
|
||||
public enableReportImmediately = false;
|
||||
public enableStacktrace = false;
|
||||
private reportImmediately(rep: Report) {
|
||||
@ -130,6 +138,14 @@ export class Ctx {
|
||||
}
|
||||
}
|
||||
|
||||
const severityCode = {
|
||||
"none": 0,
|
||||
"info": 1,
|
||||
"warning": 2,
|
||||
"error": 3,
|
||||
"fatal": 4,
|
||||
} as const;
|
||||
|
||||
export type FileInfo = {
|
||||
ident: string;
|
||||
absPath: string;
|
||||
|
@ -49,6 +49,10 @@ export class PackCompiler {
|
||||
new HirStringifyer(this.ctx, checker)
|
||||
.file(entryFileAst),
|
||||
);
|
||||
if (this.ctx.errorOccured()) {
|
||||
console.error("error(s) occurred.");
|
||||
Deno.exit(1);
|
||||
}
|
||||
const astLowerer = new AstLowerer(
|
||||
this.ctx,
|
||||
resols,
|
||||
@ -56,6 +60,10 @@ export class PackCompiler {
|
||||
entryFileAst,
|
||||
);
|
||||
astLowerer.lower();
|
||||
if (this.ctx.errorOccured()) {
|
||||
console.error("error(s) occurred. stopping...");
|
||||
Deno.exit(1);
|
||||
}
|
||||
console.log("=== MIR ===\n" + astLowerer.mirString());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user