multiType.ts 633 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 () {
  7. return null;
  8. }
  9. get ord () {
  10. return null;
  11. }
  12. stringInfo () {
  13. let list: any[] = [];
  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) {
  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. }