brighterscript 0.41.2 → 1.0.0-alpha.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/README.md +2 -2
  3. package/dist/DiagnosticCollection.js +2 -2
  4. package/dist/DiagnosticCollection.js.map +1 -1
  5. package/dist/DiagnosticFilterer.js +2 -2
  6. package/dist/DiagnosticFilterer.js.map +1 -1
  7. package/dist/DiagnosticMessages.d.ts +6 -1
  8. package/dist/DiagnosticMessages.js +5 -0
  9. package/dist/DiagnosticMessages.js.map +1 -1
  10. package/dist/LanguageServer.d.ts +8 -2
  11. package/dist/LanguageServer.js +50 -44
  12. package/dist/LanguageServer.js.map +1 -1
  13. package/dist/Program.d.ts +61 -45
  14. package/dist/Program.js +305 -188
  15. package/dist/Program.js.map +1 -1
  16. package/dist/ProgramBuilder.d.ts +7 -7
  17. package/dist/ProgramBuilder.js +60 -51
  18. package/dist/ProgramBuilder.js.map +1 -1
  19. package/dist/Scope.d.ts +42 -19
  20. package/dist/Scope.js +261 -129
  21. package/dist/Scope.js.map +1 -1
  22. package/dist/SymbolTable.d.ts +73 -0
  23. package/dist/SymbolTable.js +157 -0
  24. package/dist/SymbolTable.js.map +1 -0
  25. package/dist/XmlScope.d.ts +5 -0
  26. package/dist/XmlScope.js +66 -28
  27. package/dist/XmlScope.js.map +1 -1
  28. package/dist/astUtils/creators.d.ts +15 -1
  29. package/dist/astUtils/creators.js +39 -9
  30. package/dist/astUtils/creators.js.map +1 -1
  31. package/dist/astUtils/reflection.d.ts +28 -16
  32. package/dist/astUtils/reflection.js +52 -30
  33. package/dist/astUtils/reflection.js.map +1 -1
  34. package/dist/astUtils/reflection.spec.js +3 -3
  35. package/dist/astUtils/reflection.spec.js.map +1 -1
  36. package/dist/astUtils/visitors.spec.js +12 -13
  37. package/dist/astUtils/visitors.spec.js.map +1 -1
  38. package/dist/astUtils/xml.d.ts +3 -3
  39. package/dist/astUtils/xml.js +2 -2
  40. package/dist/astUtils/xml.js.map +1 -1
  41. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +5 -6
  42. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
  43. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +24 -22
  44. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
  45. package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.spec.js +2 -2
  46. package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.spec.js.map +1 -1
  47. package/dist/examples/plugins/removePrint.js +1 -1
  48. package/dist/examples/plugins/removePrint.js.map +1 -1
  49. package/dist/files/BrsFile.Class.spec.js +356 -41
  50. package/dist/files/BrsFile.Class.spec.js.map +1 -1
  51. package/dist/files/BrsFile.d.ts +55 -37
  52. package/dist/files/BrsFile.js +430 -399
  53. package/dist/files/BrsFile.js.map +1 -1
  54. package/dist/files/BrsFile.spec.js +199 -158
  55. package/dist/files/BrsFile.spec.js.map +1 -1
  56. package/dist/files/XmlFile.d.ts +20 -9
  57. package/dist/files/XmlFile.js +36 -31
  58. package/dist/files/XmlFile.js.map +1 -1
  59. package/dist/files/XmlFile.spec.js +113 -113
  60. package/dist/files/XmlFile.spec.js.map +1 -1
  61. package/dist/files/tests/imports.spec.js +32 -32
  62. package/dist/files/tests/imports.spec.js.map +1 -1
  63. package/dist/globalCallables.js +17 -6
  64. package/dist/globalCallables.js.map +1 -1
  65. package/dist/interfaces.d.ts +155 -39
  66. package/dist/parser/BrsTranspileState.d.ts +7 -0
  67. package/dist/parser/BrsTranspileState.js +10 -1
  68. package/dist/parser/BrsTranspileState.js.map +1 -1
  69. package/dist/parser/Expression.d.ts +23 -12
  70. package/dist/parser/Expression.js +45 -30
  71. package/dist/parser/Expression.js.map +1 -1
  72. package/dist/parser/Parser.Class.spec.js +100 -1
  73. package/dist/parser/Parser.Class.spec.js.map +1 -1
  74. package/dist/parser/Parser.d.ts +118 -5
  75. package/dist/parser/Parser.js +398 -37
  76. package/dist/parser/Parser.js.map +1 -1
  77. package/dist/parser/Parser.spec.js +404 -7
  78. package/dist/parser/Parser.spec.js.map +1 -1
  79. package/dist/parser/SGParser.d.ts +41 -4
  80. package/dist/parser/SGParser.js +185 -174
  81. package/dist/parser/SGParser.js.map +1 -1
  82. package/dist/parser/SGParser.spec.js +17 -4
  83. package/dist/parser/SGParser.spec.js.map +1 -1
  84. package/dist/parser/SGTypes.d.ts +203 -38
  85. package/dist/parser/SGTypes.js +464 -160
  86. package/dist/parser/SGTypes.js.map +1 -1
  87. package/dist/parser/SGTypes.spec.d.ts +1 -0
  88. package/dist/parser/SGTypes.spec.js +351 -0
  89. package/dist/parser/SGTypes.spec.js.map +1 -0
  90. package/dist/parser/Statement.d.ts +37 -26
  91. package/dist/parser/Statement.js +81 -20
  92. package/dist/parser/Statement.js.map +1 -1
  93. package/dist/parser/Statement.spec.js +5 -5
  94. package/dist/parser/Statement.spec.js.map +1 -1
  95. package/dist/parser/TranspileState.d.ts +1 -1
  96. package/dist/parser/TranspileState.js +15 -7
  97. package/dist/parser/TranspileState.js.map +1 -1
  98. package/dist/parser/tests/controlFlow/ForEach.spec.js +5 -4
  99. package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
  100. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +1 -1
  101. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
  102. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js +1 -1
  103. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js.map +1 -1
  104. package/dist/parser/tests/expression/TemplateStringExpression.spec.js +1 -1
  105. package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
  106. package/dist/parser/tests/expression/TernaryExpression.spec.js +1 -1
  107. package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
  108. package/dist/types/ArrayType.d.ts +1 -0
  109. package/dist/types/ArrayType.js +23 -19
  110. package/dist/types/ArrayType.js.map +1 -1
  111. package/dist/types/BooleanType.d.ts +3 -2
  112. package/dist/types/BooleanType.js +6 -3
  113. package/dist/types/BooleanType.js.map +1 -1
  114. package/dist/types/BscType.d.ts +19 -4
  115. package/dist/types/BscType.js +9 -0
  116. package/dist/types/BscType.js.map +1 -1
  117. package/dist/types/CustomType.d.ts +8 -5
  118. package/dist/types/CustomType.js +12 -12
  119. package/dist/types/CustomType.js.map +1 -1
  120. package/dist/types/DoubleType.d.ts +1 -0
  121. package/dist/types/DoubleType.js +11 -11
  122. package/dist/types/DoubleType.js.map +1 -1
  123. package/dist/types/DynamicType.d.ts +1 -0
  124. package/dist/types/DynamicType.js +4 -0
  125. package/dist/types/DynamicType.js.map +1 -1
  126. package/dist/types/FloatType.d.ts +2 -1
  127. package/dist/types/FloatType.js +11 -11
  128. package/dist/types/FloatType.js.map +1 -1
  129. package/dist/types/FunctionType.d.ts +13 -10
  130. package/dist/types/FunctionType.js +34 -18
  131. package/dist/types/FunctionType.js.map +1 -1
  132. package/dist/types/FunctionType.spec.js +8 -2
  133. package/dist/types/FunctionType.spec.js.map +1 -1
  134. package/dist/types/IntegerType.d.ts +2 -1
  135. package/dist/types/IntegerType.js +11 -11
  136. package/dist/types/IntegerType.js.map +1 -1
  137. package/dist/types/InvalidType.d.ts +3 -2
  138. package/dist/types/InvalidType.js +7 -4
  139. package/dist/types/InvalidType.js.map +1 -1
  140. package/dist/types/LazyType.d.ts +17 -0
  141. package/dist/types/LazyType.js +44 -0
  142. package/dist/types/LazyType.js.map +1 -0
  143. package/dist/types/LongIntegerType.d.ts +2 -1
  144. package/dist/types/LongIntegerType.js +11 -11
  145. package/dist/types/LongIntegerType.js.map +1 -1
  146. package/dist/types/ObjectType.d.ts +6 -2
  147. package/dist/types/ObjectType.js +9 -3
  148. package/dist/types/ObjectType.js.map +1 -1
  149. package/dist/types/StringType.d.ts +3 -2
  150. package/dist/types/StringType.js +6 -3
  151. package/dist/types/StringType.js.map +1 -1
  152. package/dist/types/UninitializedType.d.ts +4 -2
  153. package/dist/types/UninitializedType.js +8 -3
  154. package/dist/types/UninitializedType.js.map +1 -1
  155. package/dist/types/VoidType.d.ts +3 -2
  156. package/dist/types/VoidType.js +6 -3
  157. package/dist/types/VoidType.js.map +1 -1
  158. package/dist/types/helpers.d.ts +42 -0
  159. package/dist/types/helpers.js +113 -0
  160. package/dist/types/helpers.js.map +1 -0
  161. package/dist/util.d.ts +68 -15
  162. package/dist/util.js +193 -45
  163. package/dist/util.js.map +1 -1
  164. package/dist/validators/ClassValidator.d.ts +5 -1
  165. package/dist/validators/ClassValidator.js +31 -17
  166. package/dist/validators/ClassValidator.js.map +1 -1
  167. package/package.json +1 -1
  168. package/dist/FunctionScope.d.ts +0 -27
  169. package/dist/FunctionScope.js +0 -49
  170. package/dist/FunctionScope.js.map +0 -1
@@ -1,21 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FloatType = void 0;
4
- const DoubleType_1 = require("./DoubleType");
5
- const DynamicType_1 = require("./DynamicType");
6
- const IntegerType_1 = require("./IntegerType");
7
- const LongIntegerType_1 = require("./LongIntegerType");
4
+ const reflection_1 = require("../astUtils/reflection");
8
5
  class FloatType {
9
6
  isAssignableTo(targetType) {
10
- return (targetType instanceof FloatType ||
11
- targetType instanceof DynamicType_1.DynamicType);
7
+ return ((0, reflection_1.isFloatType)(targetType) ||
8
+ (0, reflection_1.isDynamicType)(targetType));
12
9
  }
13
10
  isConvertibleTo(targetType) {
14
- if (targetType instanceof DynamicType_1.DynamicType ||
15
- targetType instanceof IntegerType_1.IntegerType ||
16
- targetType instanceof FloatType ||
17
- targetType instanceof DoubleType_1.DoubleType ||
18
- targetType instanceof LongIntegerType_1.LongIntegerType) {
11
+ if ((0, reflection_1.isDynamicType)(targetType) ||
12
+ (0, reflection_1.isIntegerType)(targetType) ||
13
+ (0, reflection_1.isFloatType)(targetType) ||
14
+ (0, reflection_1.isDoubleType)(targetType) ||
15
+ (0, reflection_1.isLongIntegerType)(targetType)) {
19
16
  return true;
20
17
  }
21
18
  else {
@@ -28,6 +25,9 @@ class FloatType {
28
25
  toTypeString() {
29
26
  return this.toString();
30
27
  }
28
+ equals(targetType) {
29
+ return this.toString() === (targetType === null || targetType === void 0 ? void 0 : targetType.toString());
30
+ }
31
31
  }
32
32
  exports.FloatType = FloatType;
33
33
  //# sourceMappingURL=FloatType.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FloatType.js","sourceRoot":"","sources":["../../src/types/FloatType.ts"],"names":[],"mappings":";;;AACA,6CAA0C;AAC1C,+CAA4C;AAC5C,+CAA4C;AAC5C,uDAAoD;AAEpD,MAAa,SAAS;IACX,cAAc,CAAC,UAAmB;QACrC,OAAO,CACH,UAAU,YAAY,SAAS;YAC/B,UAAU,YAAY,yBAAW,CACpC,CAAC;IACN,CAAC;IAEM,eAAe,CAAC,UAAmB;QACtC,IACI,UAAU,YAAY,yBAAW;YACjC,UAAU,YAAY,yBAAW;YACjC,UAAU,YAAY,SAAS;YAC/B,UAAU,YAAY,uBAAU;YAChC,UAAU,YAAY,iCAAe,EACvC;YACE,OAAO,IAAI,CAAC;SACf;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC;IAEM,QAAQ;QACX,OAAO,OAAO,CAAC;IACnB,CAAC;IAEM,YAAY;QACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;CACJ;AA7BD,8BA6BC"}
1
+ {"version":3,"file":"FloatType.js","sourceRoot":"","sources":["../../src/types/FloatType.ts"],"names":[],"mappings":";;;AAAA,uDAAoH;AAGpH,MAAa,SAAS;IACX,cAAc,CAAC,UAAmB;QACrC,OAAO,CACH,IAAA,wBAAW,EAAC,UAAU,CAAC;YACvB,IAAA,0BAAa,EAAC,UAAU,CAAC,CAE5B,CAAC;IACN,CAAC;IAEM,eAAe,CAAC,UAAmB;QACtC,IACI,IAAA,0BAAa,EAAC,UAAU,CAAC;YACzB,IAAA,0BAAa,EAAC,UAAU,CAAC;YACzB,IAAA,wBAAW,EAAC,UAAU,CAAC;YACvB,IAAA,yBAAY,EAAC,UAAU,CAAC;YACxB,IAAA,8BAAiB,EAAC,UAAU,CAAC,EAC/B;YACE,OAAO,IAAI,CAAC;SACf;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC;IAEM,QAAQ;QACX,OAAO,OAAO,CAAC;IACnB,CAAC;IAEM,YAAY;QACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAEM,MAAM,CAAC,UAAmB;QAC7B,OAAO,IAAI,CAAC,QAAQ,EAAE,MAAK,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,EAAE,CAAA,CAAC;IACtD,CAAC;CACJ;AAlCD,8BAkCC"}
@@ -1,24 +1,27 @@
1
+ import type { CallableParam } from '../interfaces';
1
2
  import type { BscType } from './BscType';
2
3
  export declare class FunctionType implements BscType {
3
4
  returnType: BscType;
4
- constructor(returnType: BscType);
5
5
  /**
6
- * The name of the function for this type. Can be null
6
+ * Determines if this is a sub or not
7
7
  */
8
- name: string;
8
+ isSub: boolean;
9
+ params: CallableParam[];
10
+ isNew: boolean;
11
+ constructor(returnType: BscType,
9
12
  /**
10
13
  * Determines if this is a sub or not
11
14
  */
12
- isSub: boolean;
13
- params: {
14
- name: string;
15
- type: BscType;
16
- isRequired: boolean;
17
- }[];
15
+ isSub?: boolean, params?: CallableParam[], isNew?: boolean);
16
+ /**
17
+ * The name of the function for this type. Can be null
18
+ */
19
+ name: string;
18
20
  setName(name: string): this;
19
- addParameter(name: string, type: BscType, isRequired: boolean): this;
21
+ addParameter(paramOrName: CallableParam | string, type?: BscType, isOptional?: boolean): this;
20
22
  isAssignableTo(targetType: BscType): boolean;
21
23
  isConvertibleTo(targetType: BscType): boolean;
22
24
  toString(): string;
23
25
  toTypeString(): string;
26
+ equals(targetType: BscType): boolean;
24
27
  }
@@ -1,33 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FunctionType = void 0;
4
+ const reflection_1 = require("../astUtils/reflection");
4
5
  const DynamicType_1 = require("./DynamicType");
5
6
  class FunctionType {
6
- constructor(returnType) {
7
+ constructor(returnType,
8
+ /**
9
+ * Determines if this is a sub or not
10
+ */
11
+ isSub = false, params = [], isNew = false) {
7
12
  this.returnType = returnType;
8
- /**
9
- * Determines if this is a sub or not
10
- */
11
- this.isSub = false;
12
- this.params = [];
13
+ this.isSub = isSub;
14
+ this.params = params;
15
+ this.isNew = isNew;
13
16
  }
14
17
  setName(name) {
15
18
  this.name = name;
16
19
  return this;
17
20
  }
18
- addParameter(name, type, isRequired) {
19
- this.params.push({
20
- name: name,
21
- type: type,
22
- isRequired: isRequired === false ? false : true
23
- });
21
+ addParameter(paramOrName, type, isOptional) {
22
+ if (typeof paramOrName === 'string') {
23
+ this.params.push({
24
+ name: paramOrName,
25
+ type: type !== null && type !== void 0 ? type : new DynamicType_1.DynamicType(),
26
+ isOptional: !!isOptional,
27
+ isRestArgument: false
28
+ });
29
+ }
30
+ else {
31
+ this.params.push(paramOrName);
32
+ }
24
33
  return this;
25
34
  }
26
35
  isAssignableTo(targetType) {
27
- if (targetType instanceof DynamicType_1.DynamicType) {
28
- return true;
29
- }
30
- else if (targetType instanceof FunctionType) {
36
+ if ((0, reflection_1.isFunctionType)(targetType)) {
31
37
  //compare all parameters
32
38
  let len = Math.max(this.params.length, targetType.params.length);
33
39
  for (let i = 0; i < len; i++) {
@@ -44,6 +50,9 @@ class FunctionType {
44
50
  //made it here, all params and return type are equivalent
45
51
  return true;
46
52
  }
53
+ else if ((0, reflection_1.isDynamicType)(targetType)) {
54
+ return true;
55
+ }
47
56
  else {
48
57
  return false;
49
58
  }
@@ -52,15 +61,22 @@ class FunctionType {
52
61
  return this.isAssignableTo(targetType);
53
62
  }
54
63
  toString() {
64
+ var _a, _b;
55
65
  let paramTexts = [];
56
66
  for (let param of this.params) {
57
- paramTexts.push(`${param.name}${param.isRequired ? '' : '?'} as ${param.type.toString()}`);
67
+ paramTexts.push(`${param.name}${param.isOptional ? '?' : ''} as ${param.type.toString()}`);
58
68
  }
59
- return `${this.isSub ? 'sub' : 'function'} ${this.name}(${paramTexts.join(', ')}) as ${this.returnType.toString()}`;
69
+ if (this.isNew) {
70
+ return `new ${(_a = this.name) !== null && _a !== void 0 ? _a : ''}(${paramTexts.join(', ')})`;
71
+ }
72
+ return `${this.isSub ? 'sub' : 'function'} ${(_b = this.name) !== null && _b !== void 0 ? _b : ''}(${paramTexts.join(', ')}) as ${this.returnType.toString()}`;
60
73
  }
61
74
  toTypeString() {
62
75
  return 'Function';
63
76
  }
77
+ equals(targetType) {
78
+ return ((0, reflection_1.isFunctionType)(targetType)) && this.isAssignableTo(targetType);
79
+ }
64
80
  }
65
81
  exports.FunctionType = FunctionType;
66
82
  //# sourceMappingURL=FunctionType.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FunctionType.js","sourceRoot":"","sources":["../../src/types/FunctionType.ts"],"names":[],"mappings":";;;AACA,+CAA4C;AAE5C,MAAa,YAAY;IACrB,YACW,UAAmB;QAAnB,eAAU,GAAV,UAAU,CAAS;QAU9B;;WAEG;QACI,UAAK,GAAG,KAAK,CAAC;QAEd,WAAM,GAAG,EAAiE,CAAC;IAZlF,CAAC;IAcM,OAAO,CAAC,IAAY;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,YAAY,CAAC,IAAY,EAAE,IAAa,EAAE,UAAmB;QAChE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YACb,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,IAAI;YACV,UAAU,EAAE,UAAU,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;SAClD,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,cAAc,C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AC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;SAC9F;QACD,IAAI,IAAI,CAAC,KAAK,EAAE;YACZ,OAAO,OAAO,MAAA,IAAI,CAAC,IAAI,mCAAI,EAAE,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;SAC7D;QACD,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,IAAI,MAAA,IAAI,CAAC,IAAI,mCAAI,EAAE,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC;IAE9H,CAAC;IAEM,YAAY;QACf,OAAO,UAAU,CAAC;IACtB,CAAC;IAEM,MAAM,CAAC,UAAmB;QAC7B,OAAO,CAAC,IAAA,2BAAc,EAAC,UAAU,CAAC,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3E,CAAC;CACJ;AApFD,oCAoFC"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const chai_1 = require("chai");
4
4
  const DynamicType_1 = require("./DynamicType");
5
+ const FloatType_1 = require("./FloatType");
5
6
  const FunctionType_1 = require("./FunctionType");
6
7
  const IntegerType_1 = require("./IntegerType");
7
8
  const StringType_1 = require("./StringType");
@@ -13,11 +14,16 @@ describe('FunctionType', () => {
13
14
  it('validates using param and return types', () => {
14
15
  (0, chai_1.expect)(new FunctionType_1.FunctionType(new VoidType_1.VoidType()).isAssignableTo(new FunctionType_1.FunctionType(new VoidType_1.VoidType()))).to.be.true;
15
16
  //different parameter count
16
- (0, chai_1.expect)(new FunctionType_1.FunctionType(new VoidType_1.VoidType()).addParameter('a', new IntegerType_1.IntegerType(), true).isAssignableTo(new FunctionType_1.FunctionType(new VoidType_1.VoidType()))).to.be.false;
17
+ (0, chai_1.expect)(new FunctionType_1.FunctionType(new VoidType_1.VoidType()).addParameter('a', new IntegerType_1.IntegerType(), false).isAssignableTo(new FunctionType_1.FunctionType(new VoidType_1.VoidType()))).to.be.false;
17
18
  //different parameter types
18
- (0, chai_1.expect)(new FunctionType_1.FunctionType(new VoidType_1.VoidType()).addParameter('a', new IntegerType_1.IntegerType(), true).isAssignableTo(new FunctionType_1.FunctionType(new VoidType_1.VoidType()).addParameter('a', new StringType_1.StringType(), true))).to.be.false;
19
+ (0, chai_1.expect)(new FunctionType_1.FunctionType(new VoidType_1.VoidType()).addParameter('a', new IntegerType_1.IntegerType(), false).isAssignableTo(new FunctionType_1.FunctionType(new VoidType_1.VoidType()).addParameter('a', new StringType_1.StringType(), false))).to.be.false;
19
20
  //different return type
20
21
  (0, chai_1.expect)(new FunctionType_1.FunctionType(new VoidType_1.VoidType()).isAssignableTo(new FunctionType_1.FunctionType(new IntegerType_1.IntegerType()))).to.be.false;
21
22
  });
23
+ it('adds a callableParam object as a parameter', () => {
24
+ const myFunc = new FunctionType_1.FunctionType(new IntegerType_1.IntegerType(), false, [{ name: 'a', type: new StringType_1.StringType() }, { name: 'b', type: new DynamicType_1.DynamicType(), isOptional: true }]);
25
+ myFunc.addParameter({ name: 'c', type: new FloatType_1.FloatType(), isOptional: true });
26
+ (0, chai_1.expect)(myFunc.params.length).to.equal(3);
27
+ });
22
28
  });
23
29
  //# sourceMappingURL=FunctionType.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FunctionType.spec.js","sourceRoot":"","sources":["../../src/types/FunctionType.spec.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAE9B,+CAA4C;AAC5C,iDAA8C;AAC9C,+CAA4C;AAC5C,6CAA0C;AAC1C,yCAAsC;AAEtC,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACrC,IAAA,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AAC,GAAG,EAAE,IAAI,uBAAU,EAAE,EAAE,KAAK,CAAC,CAC9E,CACJ,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;QAEd,uBAAuB;QACvB,IAAA,aAAM,EACF,IAAI,2BAAY,CAAC,IAAI,mBAAQ,EAAE,CAAC,CAAC,cAAc,CAC3C,IAAI,2BAAY,CAAC,IAAI,yBAAW,EAAE,CAAC,CACtC,CACJ,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QAClD,MAAM,MAAM,GAAG,IAAI,2BAAY,CAAC,IAAI,yBAAW,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,uBAAU,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,yBAAW,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC7J,MAAM,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,qBAAS,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5E,IAAA,aAAM,EAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,7 +1,8 @@
1
1
  import type { BscType } from './BscType';
2
2
  export declare class IntegerType implements BscType {
3
- isAssignableTo(targetType: BscType): boolean;
3
+ isAssignableTo(targetType: BscType): any;
4
4
  isConvertibleTo(targetType: BscType): boolean;
5
5
  toString(): string;
6
6
  toTypeString(): string;
7
+ equals(targetType: BscType): boolean;
7
8
  }
@@ -1,21 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.IntegerType = void 0;
4
- const DoubleType_1 = require("./DoubleType");
5
- const DynamicType_1 = require("./DynamicType");
6
- const FloatType_1 = require("./FloatType");
7
- const LongIntegerType_1 = require("./LongIntegerType");
4
+ const reflection_1 = require("../astUtils/reflection");
8
5
  class IntegerType {
9
6
  isAssignableTo(targetType) {
10
- return (targetType instanceof IntegerType ||
11
- targetType instanceof DynamicType_1.DynamicType);
7
+ return ((0, reflection_1.isIntegerType)(targetType) ||
8
+ (0, reflection_1.isDynamicType)(targetType));
12
9
  }
13
10
  isConvertibleTo(targetType) {
14
- if (targetType instanceof DynamicType_1.DynamicType ||
15
- targetType instanceof IntegerType ||
16
- targetType instanceof FloatType_1.FloatType ||
17
- targetType instanceof DoubleType_1.DoubleType ||
18
- targetType instanceof LongIntegerType_1.LongIntegerType) {
11
+ if ((0, reflection_1.isDynamicType)(targetType) ||
12
+ (0, reflection_1.isIntegerType)(targetType) ||
13
+ (0, reflection_1.isFloatType)(targetType) ||
14
+ (0, reflection_1.isDoubleType)(targetType) ||
15
+ (0, reflection_1.isLongIntegerType)(targetType)) {
19
16
  return true;
20
17
  }
21
18
  else {
@@ -28,6 +25,9 @@ class IntegerType {
28
25
  toTypeString() {
29
26
  return this.toString();
30
27
  }
28
+ equals(targetType) {
29
+ return this.toString() === (targetType === null || targetType === void 0 ? void 0 : targetType.toString());
30
+ }
31
31
  }
32
32
  exports.IntegerType = IntegerType;
33
33
  //# sourceMappingURL=IntegerType.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IntegerType.js","sourceRoot":"","sources":["../../src/types/IntegerType.ts"],"names":[],"mappings":";;;AACA,6CAA0C;AAC1C,+CAA4C;AAC5C,2CAAwC;AACxC,uDAAoD;AAEpD,MAAa,WAAW;IACb,cAAc,CAAC,UAAmB;QACrC,OAAO,CACH,UAAU,YAAY,WAAW;YACjC,UAAU,YAAY,yBAAW,CACpC,CAAC;IACN,CAAC;IAEM,eAAe,CAAC,UAAmB;QACtC,IACI,UAAU,YAAY,yBAAW;YACjC,UAAU,YAAY,WAAW;YACjC,UAAU,YAAY,qBAAS;YAC/B,UAAU,YAAY,uBAAU;YAChC,UAAU,YAAY,iCAAe,EACvC;YACE,OAAO,IAAI,CAAC;SACf;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC;IAEM,QAAQ;QACX,OAAO,SAAS,CAAC;IACrB,CAAC;IAEM,YAAY;QACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;CACJ;AA7BD,kCA6BC"}
1
+ {"version":3,"file":"IntegerType.js","sourceRoot":"","sources":["../../src/types/IntegerType.ts"],"names":[],"mappings":";;;AAAA,uDAAoH;AAIpH,MAAa,WAAW;IACb,cAAc,CAAC,UAAmB;QACrC,OAAO,CACH,IAAA,0BAAa,EAAC,UAAU,CAAC;YACzB,IAAA,0BAAa,EAAC,UAAU,CAAC,CAC5B,CAAC;IACN,CAAC;IAEM,eAAe,CAAC,UAAmB;QACtC,IACI,IAAA,0BAAa,EAAC,UAAU,CAAC;YACzB,IAAA,0BAAa,EAAC,UAAU,CAAC;YACzB,IAAA,wBAAW,EAAC,UAAU,CAAC;YACvB,IAAA,yBAAY,EAAC,UAAU,CAAC;YACxB,IAAA,8BAAiB,EAAC,UAAU,CAAC,EAC/B;YACE,OAAO,IAAI,CAAC;SACf;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC;IAEM,QAAQ;QACX,OAAO,SAAS,CAAC;IACrB,CAAC;IAEM,YAAY;QACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAEM,MAAM,CAAC,UAAmB;QAC7B,OAAO,IAAI,CAAC,QAAQ,EAAE,MAAK,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,EAAE,CAAA,CAAC;IACtD,CAAC;CACJ;AAjCD,kCAiCC"}
@@ -1,7 +1,8 @@
1
1
  import type { BscType } from './BscType';
2
2
  export declare class InvalidType implements BscType {
3
- isAssignableTo(targetType: BscType): boolean;
4
- isConvertibleTo(targetType: BscType): boolean;
3
+ isAssignableTo(targetType: BscType): any;
4
+ isConvertibleTo(targetType: BscType): any;
5
5
  toString(): string;
6
6
  toTypeString(): string;
7
+ equals(targetType: BscType): boolean;
7
8
  }
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InvalidType = void 0;
4
- const DynamicType_1 = require("./DynamicType");
4
+ const reflection_1 = require("../astUtils/reflection");
5
5
  class InvalidType {
6
6
  isAssignableTo(targetType) {
7
- return (targetType instanceof InvalidType ||
8
- targetType instanceof DynamicType_1.DynamicType);
7
+ return ((0, reflection_1.isInvalidType)(targetType) ||
8
+ (0, reflection_1.isDynamicType)(targetType));
9
9
  }
10
10
  isConvertibleTo(targetType) {
11
- return this.isAssignableTo(targetType);
11
+ return this.isAssignableTo(targetType) || (0, reflection_1.isCustomType)(targetType) || (0, reflection_1.isObjectType)(targetType);
12
12
  }
13
13
  toString() {
14
14
  return 'invalid';
@@ -16,6 +16,9 @@ class InvalidType {
16
16
  toTypeString() {
17
17
  return this.toString();
18
18
  }
19
+ equals(targetType) {
20
+ return (0, reflection_1.isInvalidType)(targetType);
21
+ }
19
22
  }
20
23
  exports.InvalidType = InvalidType;
21
24
  //# sourceMappingURL=InvalidType.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InvalidType.js","sourceRoot":"","sources":["../../src/types/InvalidType.ts"],"names":[],"mappings":";;;AACA,+CAA4C;AAE5C,MAAa,WAAW;IACb,cAAc,CAAC,UAAmB;QACrC,OAAO,CACH,UAAU,YAAY,WAAW;YACjC,UAAU,YAAY,yBAAW,CACpC,CAAC;IACN,CAAC;IAEM,eAAe,CAAC,UAAmB;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAEM,QAAQ;QACX,OAAO,SAAS,CAAC;IACrB,CAAC;IAEM,YAAY;QACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;CACJ;AAnBD,kCAmBC"}
1
+ {"version":3,"file":"InvalidType.js","sourceRoot":"","sources":["../../src/types/InvalidType.ts"],"names":[],"mappings":";;;AAAA,uDAAkG;AAGlG,MAAa,WAAW;IACb,cAAc,CAAC,UAAmB;QACrC,OAAO,CACH,IAAA,0BAAa,EAAC,UAAU,CAAC;YACzB,IAAA,0BAAa,EAAC,UAAU,CAAC,CAC5B,CAAC;IACN,CAAC;IAEM,eAAe,CAAC,UAAmB;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,IAAA,yBAAY,EAAC,UAAU,CAAC,IAAI,IAAA,yBAAY,EAAC,UAAU,CAAC,CAAC;IACnG,CAAC;IAEM,QAAQ;QACX,OAAO,SAAS,CAAC;IACrB,CAAC;IAEM,YAAY;QACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAEM,MAAM,CAAC,UAAmB;QAC7B,OAAO,IAAA,0BAAa,EAAC,UAAU,CAAC,CAAC;IACrC,CAAC;CACJ;AAvBD,kCAuBC"}
@@ -0,0 +1,17 @@
1
+ import type { BscType, TypeContext } from './BscType';
2
+ import type { CustomType } from './CustomType';
3
+ /**
4
+ * A type whose actual type is not computed until requested.
5
+ * This is useful when the parser creates types in the middle of the file that depend on items further down in the file that haven't been parsed yet
6
+ */
7
+ export declare class LazyType implements BscType {
8
+ private factory;
9
+ constructor(factory: (context?: TypeContext) => BscType);
10
+ get type(): BscType;
11
+ getTypeFromContext(context?: TypeContext): BscType;
12
+ isAssignableTo(targetType: BscType, context?: TypeContext, potentialAncestorTypes?: CustomType[]): boolean;
13
+ isConvertibleTo(targetType: BscType, context?: TypeContext): boolean;
14
+ toString(context?: TypeContext): string;
15
+ toTypeString(context?: TypeContext): string;
16
+ equals(targetType: BscType, context?: TypeContext): boolean;
17
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LazyType = void 0;
4
+ const astUtils_1 = require("../astUtils");
5
+ /**
6
+ * A type whose actual type is not computed until requested.
7
+ * This is useful when the parser creates types in the middle of the file that depend on items further down in the file that haven't been parsed yet
8
+ */
9
+ class LazyType {
10
+ constructor(factory) {
11
+ this.factory = factory;
12
+ }
13
+ get type() {
14
+ return this.factory();
15
+ }
16
+ getTypeFromContext(context) {
17
+ return this.factory(context);
18
+ }
19
+ isAssignableTo(targetType, context, potentialAncestorTypes) {
20
+ const foundType = this.getTypeFromContext(context);
21
+ if ((0, astUtils_1.isCustomType)(foundType)) {
22
+ return foundType.isAssignableTo(targetType, context, potentialAncestorTypes);
23
+ }
24
+ return foundType === null || foundType === void 0 ? void 0 : foundType.isAssignableTo(targetType, context);
25
+ }
26
+ isConvertibleTo(targetType, context) {
27
+ var _a;
28
+ return (_a = this.getTypeFromContext(context)) === null || _a === void 0 ? void 0 : _a.isConvertibleTo(targetType, context);
29
+ }
30
+ toString(context) {
31
+ var _a;
32
+ return (_a = this.getTypeFromContext(context)) === null || _a === void 0 ? void 0 : _a.toString(context);
33
+ }
34
+ toTypeString(context) {
35
+ var _a;
36
+ return (_a = this.getTypeFromContext(context)) === null || _a === void 0 ? void 0 : _a.toTypeString(context);
37
+ }
38
+ equals(targetType, context) {
39
+ var _a;
40
+ return (_a = this.getTypeFromContext(context)) === null || _a === void 0 ? void 0 : _a.equals(targetType, context);
41
+ }
42
+ }
43
+ exports.LazyType = LazyType;
44
+ //# sourceMappingURL=LazyType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LazyType.js","sourceRoot":"","sources":["../../src/types/LazyType.ts"],"names":[],"mappings":";;;AAAA,0CAA2C;AAI3C;;;GAGG;AACH,MAAa,QAAQ;IACjB,YACY,OAA2C;QAA3C,YAAO,GAAP,OAAO,CAAoC;IAEvD,CAAC;IAED,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;IACM,kBAAkB,CAAC,OAAqB;QAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAEM,cAAc,CAAC,UAAmB,EAAE,OAAqB,EAAE,sBAAqC;QACnG,MAAM,SAAS,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QACnD,IAAI,IAAA,uBAAY,EAAC,SAAS,CAAC,EAAE;YACzB,OAAO,SAAS,CAAC,cAAc,CAAC,UAAU,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAC;SAChF;QACD,OAAO,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,cAAc,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;IAEM,eAAe,CAAC,UAAmB,EAAE,OAAqB;;QAC7D,OAAO,MAAA,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,0CAAE,eAAe,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAClF,CAAC;IAEM,QAAQ,CAAC,OAAqB;;QACjC,OAAO,MAAA,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,0CAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC/D,CAAC;IAEM,YAAY,CAAC,OAAqB;;QACrC,OAAO,MAAA,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,0CAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IACnE,CAAC;IAEM,MAAM,CAAC,UAAmB,EAAE,OAAqB;;QACpD,OAAO,MAAA,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,0CAAE,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;CACJ;AApCD,4BAoCC"}
@@ -1,7 +1,8 @@
1
1
  import type { BscType } from './BscType';
2
2
  export declare class LongIntegerType implements BscType {
3
- isAssignableTo(targetType: BscType): boolean;
3
+ isAssignableTo(targetType: BscType): any;
4
4
  isConvertibleTo(targetType: BscType): boolean;
5
5
  toString(): string;
6
6
  toTypeString(): string;
7
+ equals(targetType: BscType): boolean;
7
8
  }
@@ -1,21 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LongIntegerType = void 0;
4
- const DoubleType_1 = require("./DoubleType");
5
- const DynamicType_1 = require("./DynamicType");
6
- const FloatType_1 = require("./FloatType");
7
- const IntegerType_1 = require("./IntegerType");
4
+ const reflection_1 = require("../astUtils/reflection");
8
5
  class LongIntegerType {
9
6
  isAssignableTo(targetType) {
10
- return (targetType instanceof LongIntegerType ||
11
- targetType instanceof DynamicType_1.DynamicType);
7
+ return ((0, reflection_1.isLongIntegerType)(targetType) ||
8
+ (0, reflection_1.isDynamicType)(targetType));
12
9
  }
13
10
  isConvertibleTo(targetType) {
14
- if (targetType instanceof DynamicType_1.DynamicType ||
15
- targetType instanceof IntegerType_1.IntegerType ||
16
- targetType instanceof FloatType_1.FloatType ||
17
- targetType instanceof DoubleType_1.DoubleType ||
18
- targetType instanceof LongIntegerType) {
11
+ if ((0, reflection_1.isDynamicType)(targetType) ||
12
+ (0, reflection_1.isIntegerType)(targetType) ||
13
+ (0, reflection_1.isFloatType)(targetType) ||
14
+ (0, reflection_1.isDoubleType)(targetType) ||
15
+ (0, reflection_1.isLongIntegerType)(targetType)) {
19
16
  return true;
20
17
  }
21
18
  else {
@@ -28,6 +25,9 @@ class LongIntegerType {
28
25
  toTypeString() {
29
26
  return this.toString();
30
27
  }
28
+ equals(targetType) {
29
+ return (0, reflection_1.isLongIntegerType)(targetType);
30
+ }
31
31
  }
32
32
  exports.LongIntegerType = LongIntegerType;
33
33
  //# sourceMappingURL=LongIntegerType.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LongIntegerType.js","sourceRoot":"","sources":["../../src/types/LongIntegerType.ts"],"names":[],"mappings":";;;AACA,6CAA0C;AAC1C,+CAA4C;AAC5C,2CAAwC;AACxC,+CAA4C;AAE5C,MAAa,eAAe;IACjB,cAAc,CAAC,UAAmB;Q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C"}
@@ -1,7 +1,11 @@
1
- import type { BscType } from './BscType';
2
- export declare class ObjectType implements BscType {
1
+ import type { SymbolTable } from '../SymbolTable';
2
+ import type { BscType, SymbolContainer } from './BscType';
3
+ export declare class ObjectType implements BscType, SymbolContainer {
4
+ memberTable: SymbolTable;
5
+ constructor(memberTable?: SymbolTable);
3
6
  isAssignableTo(targetType: BscType): boolean;
4
7
  isConvertibleTo(targetType: BscType): boolean;
5
8
  toString(): string;
6
9
  toTypeString(): string;
10
+ equals(targetType: BscType): boolean;
7
11
  }
@@ -1,11 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ObjectType = void 0;
4
- const DynamicType_1 = require("./DynamicType");
4
+ const reflection_1 = require("../astUtils/reflection");
5
5
  class ObjectType {
6
+ constructor(memberTable = null) {
7
+ this.memberTable = memberTable;
8
+ }
6
9
  isAssignableTo(targetType) {
7
- return (targetType instanceof ObjectType ||
8
- targetType instanceof DynamicType_1.DynamicType);
10
+ return ((0, reflection_1.isObjectType)(targetType) ||
11
+ (0, reflection_1.isDynamicType)(targetType));
9
12
  }
10
13
  isConvertibleTo(targetType) {
11
14
  return this.isAssignableTo(targetType);
@@ -16,6 +19,9 @@ class ObjectType {
16
19
  toTypeString() {
17
20
  return this.toString();
18
21
  }
22
+ equals(targetType) {
23
+ return (0, reflection_1.isObjectType)(targetType) && this.isAssignableTo(targetType);
24
+ }
19
25
  }
20
26
  exports.ObjectType = ObjectType;
21
27
  //# sourceMappingURL=ObjectType.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectType.js","sourceRoot":"","sources":["../../src/types/ObjectType.ts"],"names":[],"mappings":";;;AACA,+CAA4C;AAE5C,MAAa,UAAU;IACZ,cAAc,CAAC,UAAmB;QACrC,OAAO,CACH,UAAU,YAAY,UAAU;YAChC,UAAU,YAAY,yBAAW,CACpC,CAAC;IACN,CAAC;IAEM,eAAe,CAAC,UAAmB;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAEM,QAAQ;QACX,OAAO,QAAQ,CAAC;IACpB,CAAC;IAEM,YAAY;QACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;CACJ;AAnBD,gCAmBC"}
1
+ {"version":3,"file":"ObjectType.js","sourceRoot":"","sources":["../../src/types/ObjectType.ts"],"names":[],"mappings":";;;AAAA,uDAAqE;AAIrE,MAAa,UAAU;IAGnB,YAAmB,cAA2B,IAAI;QAA/B,gBAAW,GAAX,WAAW,CAAoB;IAClD,CAAC;IAEM,cAAc,CAAC,UAAmB;QACrC,OAAO,CACH,IAAA,yBAAY,EAAC,UAAU,CAAC;YACxB,IAAA,0BAAa,EAAC,UAAU,CAAC,CAC5B,CAAC;IACN,CAAC;IAEM,eAAe,CAAC,UAAmB;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAEM,QAAQ;QACX,OAAO,QAAQ,CAAC;IACpB,CAAC;IAEM,YAAY;QACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAEM,MAAM,CAAC,UAAmB;QAC7B,OAAO,IAAA,yBAAY,EAAC,UAAU,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IACvE,CAAC;CACJ;AA5BD,gCA4BC"}
@@ -1,7 +1,8 @@
1
1
  import type { BscType } from './BscType';
2
2
  export declare class StringType implements BscType {
3
- isAssignableTo(targetType: BscType): boolean;
4
- isConvertibleTo(targetType: BscType): boolean;
3
+ isAssignableTo(targetType: BscType): any;
4
+ isConvertibleTo(targetType: BscType): any;
5
5
  toString(): string;
6
6
  toTypeString(): string;
7
+ equals(targetType: BscType): boolean;
7
8
  }
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StringType = void 0;
4
- const DynamicType_1 = require("./DynamicType");
4
+ const reflection_1 = require("../astUtils/reflection");
5
5
  class StringType {
6
6
  isAssignableTo(targetType) {
7
- return (targetType instanceof StringType ||
8
- targetType instanceof DynamicType_1.DynamicType);
7
+ return ((0, reflection_1.isStringType)(targetType) ||
8
+ (0, reflection_1.isDynamicType)(targetType));
9
9
  }
10
10
  isConvertibleTo(targetType) {
11
11
  return this.isAssignableTo(targetType);
@@ -16,6 +16,9 @@ class StringType {
16
16
  toTypeString() {
17
17
  return this.toString();
18
18
  }
19
+ equals(targetType) {
20
+ return (0, reflection_1.isStringType)(targetType);
21
+ }
19
22
  }
20
23
  exports.StringType = StringType;
21
24
  //# sourceMappingURL=StringType.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StringType.js","sourceRoot":"","sources":["../../src/types/StringType.ts"],"names":[],"mappings":";;;AACA,+CAA4C;AAE5C,MAAa,UAAU;IACZ,cAAc,CAAC,UAAmB;QACrC,OAAO,CACH,UAAU,YAAY,UAAU;YAChC,UAAU,YAAY,yBAAW,CACpC,CAAC;IACN,CAAC;IAEM,eAAe,CAAC,UAAmB;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAEM,QAAQ;QACX,OAAO,QAAQ,CAAC;IACpB,CAAC;IAEM,YAAY;QACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;CACJ;AAnBD,gCAmBC"}
1
+ {"version":3,"file":"StringType.js","sourceRoot":"","sources":["../../src/types/StringType.ts"],"names":[],"mappings":";;;AAAA,uDAAqE;AAGrE,MAAa,UAAU;IACZ,cAAc,CAAC,UAAmB;QACrC,OAAO,CACH,IAAA,yBAAY,EAAC,UAAU,CAAC;YACxB,IAAA,0BAAa,EAAC,UAAU,CAAC,CAC5B,CAAC;IACN,CAAC;IAEM,eAAe,CAAC,UAAmB;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAEM,QAAQ;QACX,OAAO,QAAQ,CAAC;IACpB,CAAC;IAEM,YAAY;QACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAEM,MAAM,CAAC,UAAmB;QAC7B,OAAO,IAAA,yBAAY,EAAC,UAAU,CAAC,CAAC;IACpC,CAAC;CACJ;AAvBD,gCAuBC"}
@@ -1,7 +1,9 @@
1
1
  import type { BscType } from './BscType';
2
2
  export declare class UninitializedType implements BscType {
3
- isAssignableTo(targetType: BscType): boolean;
4
- isConvertibleTo(targetType: BscType): boolean;
3
+ constructor();
4
+ isAssignableTo(targetType: BscType): any;
5
+ isConvertibleTo(targetType: BscType): any;
5
6
  toString(): string;
6
7
  toTypeString(): string;
8
+ equals(targetType: BscType): boolean;
7
9
  }
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UninitializedType = void 0;
4
- const DynamicType_1 = require("./DynamicType");
4
+ const reflection_1 = require("../astUtils/reflection");
5
5
  class UninitializedType {
6
+ // eslint-disable-next-line @typescript-eslint/no-useless-constructor
7
+ constructor() { }
6
8
  isAssignableTo(targetType) {
7
- return (targetType instanceof UninitializedType ||
8
- targetType instanceof DynamicType_1.DynamicType);
9
+ return ((0, reflection_1.isUninitializedType)(targetType) ||
10
+ (0, reflection_1.isDynamicType)(targetType));
9
11
  }
10
12
  isConvertibleTo(targetType) {
11
13
  return this.isAssignableTo(targetType);
@@ -16,6 +18,9 @@ class UninitializedType {
16
18
  toTypeString() {
17
19
  return this.toString();
18
20
  }
21
+ equals(targetType) {
22
+ return (0, reflection_1.isUninitializedType)(targetType);
23
+ }
19
24
  }
20
25
  exports.UninitializedType = UninitializedType;
21
26
  //# sourceMappingURL=UninitializedType.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UninitializedType.js","sourceRoot":"","sources":["../../src/types/UninitializedType.ts"],"names":[],"mappings":";;;AACA,+CAA4C;AAE5C,MAAa,iBAAiB;IACnB,cAAc,CAAC,UAAmB;QACrC,OAAO,CACH,UAAU,YAAY,iBAAiB;YACvC,UAAU,YAAY,yBAAW,CACpC,CAAC;IACN,CAAC;IAEM,eAAe,CAAC,UAAmB;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAEM,QAAQ;QACX,OAAO,eAAe,CAAC;IAC3B,CAAC;IAGM,YAAY;QACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;CACJ;AApBD,8CAoBC"}
1
+ {"version":3,"file":"UninitializedType.js","sourceRoot":"","sources":["../../src/types/UninitializedType.ts"],"names":[],"mappings":";;;AAAA,uDAA4E;AAG5E,MAAa,iBAAiB;IAE1B,qEAAqE;IACrE,gBAAgB,CAAC;IAEV,cAAc,CAAC,UAAmB;QACrC,OAAO,CACH,IAAA,gCAAmB,EAAC,UAAU,CAAC;YAC/B,IAAA,0BAAa,EAAC,UAAU,CAAC,CAC5B,CAAC;IACN,CAAC;IAEM,eAAe,CAAC,UAAmB;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAEM,QAAQ;QACX,OAAO,eAAe,CAAC;IAC3B,CAAC;IAGM,YAAY;QACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAEM,MAAM,CAAC,UAAmB;QAC7B,OAAO,IAAA,gCAAmB,EAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;CACJ;AA5BD,8CA4BC"}
@@ -1,7 +1,8 @@
1
1
  import type { BscType } from './BscType';
2
2
  export declare class VoidType implements BscType {
3
- isAssignableTo(targetType: BscType): boolean;
4
- isConvertibleTo(targetType: BscType): boolean;
3
+ isAssignableTo(targetType: BscType): any;
4
+ isConvertibleTo(targetType: BscType): any;
5
5
  toString(): string;
6
6
  toTypeString(): string;
7
+ equals(targetType: BscType): boolean;
7
8
  }