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.
22 lines
644 B
TypeScript
22 lines
644 B
TypeScript
import { Type } from "./Type"
|
|
|
|
export class TypeReferenceType implements Type {
|
|
constructor(public kind: string, public args: Type[]) {}
|
|
|
|
toConstructor() {
|
|
return (
|
|
`new TypeReferenceType(${JSON.stringify(this.kind)}, [` +
|
|
// Turn every type argument into its constructor representation
|
|
this.args.map(cur => cur.toConstructor()).join(",\n") +
|
|
`])`
|
|
)
|
|
}
|
|
|
|
toString() {
|
|
return `${this.kind}<${this.args.map(a => a.toString()).join(", ")}>`
|
|
}
|
|
|
|
convert(argument) {
|
|
throw new Error("Conversion of simple type references not implemented.")
|
|
}
|
|
}
|