singularci
Version:
SingularCI is a DSL transpiler used to generate CI/CD configuration files for existing CI platforms
43 lines (32 loc) • 915 B
text/typescript
import IStage from "../SemanticModel/interfaces/IStage";
export default class StageSymbolTable {
private static instance: StageSymbolTable | undefined;
private stages: Record<string, IStage>;
private constructor() {
this.stages = {};
}
static getInstance(): StageSymbolTable {
if (!this.instance) {
this.instance = new StageSymbolTable();
}
return this.instance;
}
addStage(stage: IStage): void {
if (this.stages[stage.getName()]) {
throw new Error(`Stage ${stage.getName()} already exists`);
}
this.stages[stage.getName()] = stage;
}
getStage(name: string): IStage {
if (this.stages[name]) {
return this.stages[name];
}
throw new Error(`Stage ${name} not found`);
}
getStages(): Record<string, IStage> {
return this.stages;
}
reset(): void {
this.stages = {};
}
}