mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 09:31:41 -05:00

This commit makes the compiler pass use different classes in order to represent the metadata. This enables adding per-class toString/convert functions. This enables easy type checking and conversion in the `:set` excmd.
28 lines
683 B
TypeScript
28 lines
683 B
TypeScript
import { FileMetadata } from "./FileMetadata"
|
|
|
|
export class ProgramMetadata {
|
|
constructor(
|
|
public files: Map<string, FileMetadata> = new Map<
|
|
string,
|
|
FileMetadata
|
|
>(),
|
|
) {}
|
|
|
|
setFile(name: string, file: FileMetadata) {
|
|
this.files.set(name, file)
|
|
}
|
|
|
|
getFile(name: string) {
|
|
return this.files.get(name)
|
|
}
|
|
|
|
toConstructor() {
|
|
return (
|
|
`new ProgramMetadata(new Map<string, FileMetadata>([` +
|
|
Array.from(this.files.entries())
|
|
.map(([n, f]) => `[${JSON.stringify(n)}, ${f.toConstructor()}]`)
|
|
.join(",\n") +
|
|
`]))`
|
|
)
|
|
}
|
|
}
|