baseTypes.js 619 B

123456789101112131415161718192021222324252627
  1. class BaseType {
  2. constructor(name, ord) {
  3. this.name = name;
  4. this.ord = ord;
  5. }
  6. get value () {
  7. return this.name;
  8. }
  9. isCompatible (another) {
  10. if(another instanceof BaseType) {
  11. return this.name === another.name && this.ord === another.ord;
  12. }
  13. return false;
  14. }
  15. }
  16. // Base types names are the same as i18n ui type keys
  17. export const BaseTypes = Object.freeze({
  18. INTEGER: new BaseType("integer", 0),
  19. REAL: new BaseType("real", 1),
  20. STRING: new BaseType("text", 2),
  21. BOOLEAN: new BaseType("boolean", 3),
  22. VOID: new BaseType("void", 4),
  23. UNDEFINED: new BaseType("undefined", 5)
  24. })