2018-09-22 12:34:26 +02:00
|
|
|
import { Type } from "./Type"
|
|
|
|
|
|
|
|
export class TypeReferenceType implements Type {
|
2019-03-26 06:34:40 +01:00
|
|
|
public constructor(public kind: string, public args: Type[]) {}
|
2018-09-22 12:34:26 +02:00
|
|
|
|
2019-03-26 06:34:40 +01:00
|
|
|
public toConstructor() {
|
2018-09-22 12:34:26 +02:00
|
|
|
return (
|
|
|
|
`new TypeReferenceType(${JSON.stringify(this.kind)}, [` +
|
|
|
|
// Turn every type argument into its constructor representation
|
|
|
|
this.args.map(cur => cur.toConstructor()).join(",\n") +
|
|
|
|
`])`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-03-26 06:34:40 +01:00
|
|
|
public toString() {
|
2018-09-22 12:34:26 +02:00
|
|
|
return `${this.kind}<${this.args.map(a => a.toString()).join(", ")}>`
|
|
|
|
}
|
|
|
|
|
2019-03-26 06:34:40 +01:00
|
|
|
public convert(argument) {
|
2018-09-22 12:34:26 +02:00
|
|
|
throw new Error("Conversion of simple type references not implemented.")
|
|
|
|
}
|
|
|
|
}
|