multiType.ts 687 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { Type } from "./type";
  2. import { IType } from "./itype";
  3. export class MultiType implements IType {
  4. constructor (public types: Type[]) {
  5. }
  6. get value (): undefined {
  7. return undefined;
  8. }
  9. get ord (): undefined {
  10. return undefined;
  11. }
  12. stringInfo (): object[] {
  13. let list: object[] = [];
  14. for (let i = 0; i < this.types.length; i++) {
  15. const t = this.types[i];
  16. list = list.concat(t.stringInfo());
  17. }
  18. return list;
  19. }
  20. isCompatible (another: Type): boolean {
  21. for (let i = 0; i < this.types.length; i++) {
  22. const t = this.types[i];
  23. if (another.isCompatible(t)) {
  24. return true;
  25. }
  26. }
  27. return false;
  28. }
  29. }