brighterscript 0.65.1 → 0.66.0-alpha.1
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.
- package/CHANGELOG.md +14 -0
- package/README.md +8 -0
- package/dist/BsConfig.d.ts +5 -11
- package/dist/CacheVerifier.d.ts +8 -0
- package/dist/CacheVerifier.js +20 -0
- package/dist/CacheVerifier.js.map +1 -0
- package/dist/DiagnosticMessages.d.ts +9 -4
- package/dist/DiagnosticMessages.js +8 -3
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/FunctionScope.d.ts +1 -0
- package/dist/FunctionScope.js +3 -0
- package/dist/FunctionScope.js.map +1 -1
- package/dist/PluginInterface.d.ts +0 -4
- package/dist/PluginInterface.js.map +1 -1
- package/dist/Program.d.ts +6 -39
- package/dist/Program.js +94 -68
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.d.ts +4 -0
- package/dist/ProgramBuilder.js +33 -13
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/Scope.d.ts +1 -5
- package/dist/Scope.js +53 -37
- package/dist/Scope.js.map +1 -1
- package/dist/SymbolTable.d.ts +44 -6
- package/dist/SymbolTable.js +154 -26
- package/dist/SymbolTable.js.map +1 -1
- package/dist/XmlScope.js +11 -12
- package/dist/XmlScope.js.map +1 -1
- package/dist/astUtils/creators.d.ts +16 -6
- package/dist/astUtils/creators.js +39 -16
- package/dist/astUtils/creators.js.map +1 -1
- package/dist/astUtils/reflection.d.ts +46 -37
- package/dist/astUtils/reflection.js +145 -147
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/reflection.spec.js +1 -6
- package/dist/astUtils/reflection.spec.js.map +1 -1
- package/dist/astUtils/visitors.d.ts +4 -11
- package/dist/astUtils/visitors.js +0 -7
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/astUtils/visitors.spec.js +8 -6
- package/dist/astUtils/visitors.spec.js.map +1 -1
- package/dist/astUtils/xml.d.ts +9 -9
- package/dist/astUtils/xml.js +6 -6
- package/dist/astUtils/xml.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.d.ts +2 -3
- package/dist/bscPlugin/BscPlugin.js +6 -2
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/CallExpressionInfo.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +2 -2
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
- package/dist/bscPlugin/hover/HoverProcessor.js +71 -59
- package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
- package/dist/bscPlugin/hover/HoverProcessor.spec.js +110 -10
- package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +6 -5
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js +1 -1
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js.map +1 -1
- package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.d.ts +11 -0
- package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js +53 -0
- package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js.map +1 -0
- package/dist/bscPlugin/validation/BrsFileValidator.d.ts +4 -0
- package/dist/bscPlugin/validation/BrsFileValidator.js +37 -16
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -1
- package/dist/bscPlugin/validation/ProgramValidator.d.ts +3 -3
- package/dist/bscPlugin/validation/ProgramValidator.js +6 -6
- package/dist/bscPlugin/validation/ProgramValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +1 -0
- package/dist/bscPlugin/validation/ScopeValidator.js +72 -18
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
- package/dist/bscPlugin/validation/XmlFileValidator.js +9 -9
- package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -1
- package/dist/files/BrsFile.Class.spec.js +9 -10
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +8 -10
- package/dist/files/BrsFile.js +72 -52
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +57 -15
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/XmlFile.d.ts +19 -19
- package/dist/files/XmlFile.js +24 -42
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/files/XmlFile.spec.js +70 -17
- package/dist/files/XmlFile.spec.js.map +1 -1
- package/dist/files/tests/imports.spec.js +8 -11
- package/dist/files/tests/imports.spec.js.map +1 -1
- package/dist/globalCallables.js +2 -1
- package/dist/globalCallables.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +107 -28
- package/dist/interfaces.js +13 -0
- package/dist/interfaces.js.map +1 -1
- package/dist/lexer/TokenKind.d.ts +2 -0
- package/dist/lexer/TokenKind.js +5 -1
- package/dist/lexer/TokenKind.js.map +1 -1
- package/dist/parser/AstNode.d.ts +78 -1
- package/dist/parser/AstNode.js +80 -1
- package/dist/parser/AstNode.js.map +1 -1
- package/dist/parser/Expression.d.ts +87 -53
- package/dist/parser/Expression.js +243 -139
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.Class.spec.js +10 -7
- package/dist/parser/Parser.Class.spec.js.map +1 -1
- package/dist/parser/Parser.d.ts +9 -5
- package/dist/parser/Parser.js +125 -78
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.d.ts +2 -0
- package/dist/parser/Parser.spec.js +117 -5
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/SGParser.d.ts +42 -4
- package/dist/parser/SGParser.js +191 -195
- package/dist/parser/SGParser.js.map +1 -1
- package/dist/parser/SGParser.spec.js +13 -10
- package/dist/parser/SGParser.spec.js.map +1 -1
- package/dist/parser/SGTypes.d.ts +279 -51
- package/dist/parser/SGTypes.js +562 -185
- package/dist/parser/SGTypes.js.map +1 -1
- package/dist/parser/Statement.d.ts +88 -70
- package/dist/parser/Statement.js +212 -136
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/TranspileState.d.ts +1 -1
- package/dist/parser/TranspileState.js +5 -2
- package/dist/parser/TranspileState.js.map +1 -1
- package/dist/parser/tests/expression/TypeExpression.spec.d.ts +1 -0
- package/dist/parser/tests/expression/TypeExpression.spec.js +127 -0
- package/dist/parser/tests/expression/TypeExpression.spec.js.map +1 -0
- package/dist/types/ArrayType.d.ts +6 -4
- package/dist/types/ArrayType.js +30 -22
- package/dist/types/ArrayType.js.map +1 -1
- package/dist/types/ArrayType.spec.js +8 -8
- package/dist/types/ArrayType.spec.js.map +1 -1
- package/dist/types/BooleanType.d.ts +7 -4
- package/dist/types/BooleanType.js +13 -8
- package/dist/types/BooleanType.js.map +1 -1
- package/dist/types/BooleanType.spec.js +9 -3
- package/dist/types/BooleanType.spec.js.map +1 -1
- package/dist/types/BscType.d.ts +25 -2
- package/dist/types/BscType.js +64 -0
- package/dist/types/BscType.js.map +1 -1
- package/dist/types/BscTypeKind.d.ts +22 -0
- package/dist/types/BscTypeKind.js +27 -0
- package/dist/types/BscTypeKind.js.map +1 -0
- package/dist/types/ClassType.d.ts +11 -0
- package/dist/types/ClassType.js +31 -0
- package/dist/types/ClassType.js.map +1 -0
- package/dist/types/ClassType.spec.d.ts +1 -0
- package/dist/types/ClassType.spec.js +75 -0
- package/dist/types/ClassType.spec.js.map +1 -0
- package/dist/types/DoubleType.d.ts +7 -4
- package/dist/types/DoubleType.js +16 -20
- package/dist/types/DoubleType.js.map +1 -1
- package/dist/types/DoubleType.spec.js +11 -3
- package/dist/types/DoubleType.spec.js.map +1 -1
- package/dist/types/DynamicType.d.ts +9 -3
- package/dist/types/DynamicType.js +16 -2
- package/dist/types/DynamicType.js.map +1 -1
- package/dist/types/DynamicType.spec.js +15 -4
- package/dist/types/DynamicType.spec.js.map +1 -1
- package/dist/types/EnumType.d.ts +22 -0
- package/dist/types/EnumType.js +59 -0
- package/dist/types/EnumType.js.map +1 -0
- package/dist/types/EnumType.spec.d.ts +1 -0
- package/dist/types/EnumType.spec.js +33 -0
- package/dist/types/EnumType.spec.js.map +1 -0
- package/dist/types/FloatType.d.ts +7 -4
- package/dist/types/FloatType.js +16 -20
- package/dist/types/FloatType.js.map +1 -1
- package/dist/types/FloatType.spec.js +3 -3
- package/dist/types/FloatType.spec.js.map +1 -1
- package/dist/types/FunctionType.d.ts +6 -4
- package/dist/types/FunctionType.js +22 -19
- package/dist/types/FunctionType.js.map +1 -1
- package/dist/types/FunctionType.spec.js +5 -5
- package/dist/types/FunctionType.spec.js.map +1 -1
- package/dist/types/InheritableType.d.ts +25 -0
- package/dist/types/InheritableType.js +88 -0
- package/dist/types/InheritableType.js.map +1 -0
- package/dist/types/IntegerType.d.ts +7 -4
- package/dist/types/IntegerType.js +16 -20
- package/dist/types/IntegerType.js.map +1 -1
- package/dist/types/IntegerType.spec.js +7 -3
- package/dist/types/IntegerType.spec.js.map +1 -1
- package/dist/types/InterfaceType.d.ts +10 -10
- package/dist/types/InterfaceType.js +24 -45
- package/dist/types/InterfaceType.js.map +1 -1
- package/dist/types/InterfaceType.spec.js +59 -45
- package/dist/types/InterfaceType.spec.js.map +1 -1
- package/dist/types/InvalidType.d.ts +6 -4
- package/dist/types/InvalidType.js +12 -8
- package/dist/types/InvalidType.js.map +1 -1
- package/dist/types/InvalidType.spec.js +7 -3
- package/dist/types/InvalidType.spec.js.map +1 -1
- package/dist/types/LongIntegerType.d.ts +7 -4
- package/dist/types/LongIntegerType.js +16 -20
- package/dist/types/LongIntegerType.js.map +1 -1
- package/dist/types/LongIntegerType.spec.js +9 -3
- package/dist/types/LongIntegerType.spec.js.map +1 -1
- package/dist/types/NamespaceType.d.ts +11 -0
- package/dist/types/NamespaceType.js +25 -0
- package/dist/types/NamespaceType.js.map +1 -0
- package/dist/types/ObjectType.d.ts +8 -4
- package/dist/types/ObjectType.js +26 -7
- package/dist/types/ObjectType.js.map +1 -1
- package/dist/types/ObjectType.spec.js +2 -2
- package/dist/types/ObjectType.spec.js.map +1 -1
- package/dist/types/ReferenceType.d.ts +51 -0
- package/dist/types/ReferenceType.js +274 -0
- package/dist/types/ReferenceType.js.map +1 -0
- package/dist/types/ReferenceType.spec.d.ts +1 -0
- package/dist/types/ReferenceType.spec.js +122 -0
- package/dist/types/ReferenceType.spec.js.map +1 -0
- package/dist/types/StringType.d.ts +10 -4
- package/dist/types/StringType.js +16 -8
- package/dist/types/StringType.js.map +1 -1
- package/dist/types/StringType.spec.js +2 -2
- package/dist/types/StringType.spec.js.map +1 -1
- package/dist/types/UninitializedType.d.ts +6 -3
- package/dist/types/UninitializedType.js +14 -3
- package/dist/types/UninitializedType.js.map +1 -1
- package/dist/types/UnionType.d.ts +18 -0
- package/dist/types/UnionType.js +91 -0
- package/dist/types/UnionType.js.map +1 -0
- package/dist/types/UnionType.spec.d.ts +1 -0
- package/dist/types/UnionType.spec.js +103 -0
- package/dist/types/UnionType.spec.js.map +1 -0
- package/dist/types/VoidType.d.ts +7 -4
- package/dist/types/VoidType.js +13 -8
- package/dist/types/VoidType.js.map +1 -1
- package/dist/types/VoidType.spec.js +2 -2
- package/dist/types/VoidType.spec.js.map +1 -1
- package/dist/types/helper.spec.d.ts +1 -0
- package/dist/types/helper.spec.js +130 -0
- package/dist/types/helper.spec.js.map +1 -0
- package/dist/types/helpers.d.ts +19 -0
- package/dist/types/helpers.js +131 -0
- package/dist/types/helpers.js.map +1 -0
- package/dist/types/index.d.ts +22 -0
- package/dist/types/index.js +39 -0
- package/dist/types/index.js.map +1 -0
- package/dist/util.d.ts +9 -8
- package/dist/util.js +78 -32
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.d.ts +0 -4
- package/dist/validators/ClassValidator.js +6 -30
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +2 -1
- package/dist/types/CustomType.d.ts +0 -9
- package/dist/types/CustomType.js +0 -32
- package/dist/types/CustomType.js.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { BscType } from './BscType';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { BscTypeKind } from './BscTypeKind';
|
|
3
|
+
import { InheritableType } from './InheritableType';
|
|
4
|
+
export declare class InterfaceType extends InheritableType {
|
|
5
|
+
name: string;
|
|
6
|
+
readonly superInterface?: BscType;
|
|
7
|
+
constructor(name: string, superInterface?: BscType);
|
|
8
|
+
readonly kind = BscTypeKind.InterfaceType;
|
|
9
|
+
isTypeCompatible(targetType: BscType): boolean;
|
|
5
10
|
/**
|
|
6
|
-
*
|
|
11
|
+
* Is this the exact same interface as the target?
|
|
7
12
|
*/
|
|
8
|
-
|
|
9
|
-
isAssignableTo(targetType: BscType): boolean;
|
|
10
|
-
isConvertibleTo(targetType: BscType): boolean;
|
|
11
|
-
toString(): string;
|
|
12
|
-
toTypeString(): string;
|
|
13
|
-
equals(targetType: BscType): boolean;
|
|
13
|
+
isEqual(targetType: BscType): boolean;
|
|
14
14
|
}
|
|
@@ -1,61 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InterfaceType = void 0;
|
|
4
|
+
const SymbolTable_1 = require("../SymbolTable");
|
|
4
5
|
const reflection_1 = require("../astUtils/reflection");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const BscTypeKind_1 = require("./BscTypeKind");
|
|
7
|
+
const InheritableType_1 = require("./InheritableType");
|
|
8
|
+
class InterfaceType extends InheritableType_1.InheritableType {
|
|
9
|
+
constructor(name, superInterface) {
|
|
10
|
+
super(name, superInterface);
|
|
11
|
+
this.name = name;
|
|
12
|
+
this.superInterface = superInterface;
|
|
13
|
+
this.kind = BscTypeKind_1.BscTypeKind.InterfaceType;
|
|
8
14
|
}
|
|
9
|
-
|
|
10
|
-
//
|
|
11
|
-
if (
|
|
12
|
-
for (const [targetMemberName, targetMemberType] of targetType.members) {
|
|
13
|
-
//we don't have the target member
|
|
14
|
-
if (!this.members.has(targetMemberName)) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
//our member's type is not assignable to the target member type
|
|
18
|
-
if (!this.members.get(targetMemberName).isAssignableTo(targetMemberType)) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
//we have all of the target member's types. we are assignable!
|
|
15
|
+
isTypeCompatible(targetType) {
|
|
16
|
+
//TODO: We need to make sure that things don't get assigned to built-in types
|
|
17
|
+
if (this.isEqual(targetType)) {
|
|
23
18
|
return true;
|
|
24
|
-
//we are always assignable to dynamic or object
|
|
25
19
|
}
|
|
26
|
-
|
|
20
|
+
if ((0, reflection_1.isDynamicType)(targetType)) {
|
|
27
21
|
return true;
|
|
28
|
-
//not assignable to any other object types
|
|
29
22
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
isConvertibleTo(targetType) {
|
|
35
|
-
return this.isAssignableTo(targetType);
|
|
36
|
-
}
|
|
37
|
-
toString() {
|
|
38
|
-
let result = '{';
|
|
39
|
-
for (const [key, type] of this.members.entries()) {
|
|
40
|
-
result += ' ' + key + ': ' + type.toString() + ';';
|
|
41
|
-
}
|
|
42
|
-
if (this.members.size > 0) {
|
|
43
|
-
result += ' ';
|
|
23
|
+
const ancestorTypes = this.getAncestorTypeList();
|
|
24
|
+
if (ancestorTypes === null || ancestorTypes === void 0 ? void 0 : ancestorTypes.find(ancestorType => ancestorType.isEqual(targetType))) {
|
|
25
|
+
return true;
|
|
44
26
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
toTypeString() {
|
|
48
|
-
return 'object';
|
|
49
|
-
}
|
|
50
|
-
equals(targetType) {
|
|
51
|
-
if ((0, reflection_1.isInterfaceType)(targetType)) {
|
|
52
|
-
if (targetType.members.size !== this.members.size) {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
return targetType.isAssignableTo(this);
|
|
27
|
+
if ((0, reflection_1.isInheritableType)(targetType) || (0, reflection_1.isUnionType)(targetType)) {
|
|
28
|
+
return this.checkCompatibilityBasedOnMembers(targetType, SymbolTable_1.SymbolTypeFlag.runtime);
|
|
56
29
|
}
|
|
57
30
|
return false;
|
|
58
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Is this the exact same interface as the target?
|
|
34
|
+
*/
|
|
35
|
+
isEqual(targetType) {
|
|
36
|
+
return (0, reflection_1.isInterfaceType)(targetType) && this.name.toLowerCase() === targetType.name.toLowerCase();
|
|
37
|
+
}
|
|
59
38
|
}
|
|
60
39
|
exports.InterfaceType = InterfaceType;
|
|
61
40
|
//# sourceMappingURL=InterfaceType.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InterfaceType.js","sourceRoot":"","sources":["../../src/types/InterfaceType.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"InterfaceType.js","sourceRoot":"","sources":["../../src/types/InterfaceType.ts"],"names":[],"mappings":";;;AAAA,gDAAgD;AAChD,uDAAwG;AAExG,+CAA4C;AAC5C,uDAAoD;AAEpD,MAAa,aAAc,SAAQ,iCAAe;IAC9C,YACW,IAAY,EACH,cAAwB;QAExC,KAAK,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAHrB,SAAI,GAAJ,IAAI,CAAQ;QACH,mBAAc,GAAd,cAAc,CAAU;QAK5B,SAAI,GAAG,yBAAW,CAAC,aAAa,CAAC;IAFjD,CAAC;IAIM,gBAAgB,CAAC,UAAmB;QACvC,6EAA6E;QAC7E,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAC1B,OAAO,IAAI,CAAC;SACf;QACD,IAAI,IAAA,0BAAa,EAAC,UAAU,CAAC,EAAE;YAC3B,OAAO,IAAI,CAAC;SACf;QACD,MAAM,aAAa,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACjD,IAAI,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,EAAE;YACvE,OAAO,IAAI,CAAC;SACf;QACD,IAAI,IAAA,8BAAiB,EAAC,UAAU,CAAC,IAAI,IAAA,wBAAW,EAAC,UAAU,CAAC,EAAE;YAC1D,OAAO,IAAI,CAAC,gCAAgC,CAAC,UAAU,EAAE,4BAAc,CAAC,OAAO,CAAC,CAAC;SACpF;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,UAAmB;QACvB,OAAO,IAAA,4BAAe,EAAC,UAAU,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;IACpG,CAAC;CACJ;AAlCD,sCAkCC"}
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const chai_config_spec_1 = require("../chai-config.spec");
|
|
4
4
|
const sinon_1 = require("sinon");
|
|
5
|
-
const testHelpers_spec_1 = require("../testHelpers.spec");
|
|
6
5
|
const DynamicType_1 = require("./DynamicType");
|
|
7
6
|
const IntegerType_1 = require("./IntegerType");
|
|
8
7
|
const InterfaceType_1 = require("./InterfaceType");
|
|
9
8
|
const ObjectType_1 = require("./ObjectType");
|
|
10
9
|
const StringType_1 = require("./StringType");
|
|
10
|
+
const SymbolTable_1 = require("../SymbolTable");
|
|
11
11
|
describe('InterfaceType', () => {
|
|
12
|
-
describe('
|
|
12
|
+
describe('toJSString', () => {
|
|
13
13
|
it('returns empty curly braces when no members', () => {
|
|
14
|
-
(0, chai_config_spec_1.expect)(iface({}).
|
|
14
|
+
(0, chai_config_spec_1.expect)(iface({}).toJSString()).to.eql('{}');
|
|
15
15
|
});
|
|
16
16
|
it('includes member types', () => {
|
|
17
|
-
(0, chai_config_spec_1.expect)(iface({ name: new StringType_1.StringType() }).
|
|
17
|
+
(0, chai_config_spec_1.expect)(iface({ name: new StringType_1.StringType() }).toJSString()).to.eql('{ name: string; }');
|
|
18
18
|
});
|
|
19
19
|
it('includes nested object types', () => {
|
|
20
20
|
(0, chai_config_spec_1.expect)(iface({
|
|
@@ -22,12 +22,12 @@ describe('InterfaceType', () => {
|
|
|
22
22
|
parent: iface({
|
|
23
23
|
age: new IntegerType_1.IntegerType()
|
|
24
24
|
})
|
|
25
|
-
}).
|
|
25
|
+
}).toJSString()).to.eql('{ name: string; parent: { age: integer; }; }');
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
|
-
describe('
|
|
28
|
+
describe('isTypeCompatible', () => {
|
|
29
29
|
it('works', () => {
|
|
30
|
-
|
|
30
|
+
expectCompatible({
|
|
31
31
|
name: new StringType_1.StringType()
|
|
32
32
|
}, {
|
|
33
33
|
name: new StringType_1.StringType()
|
|
@@ -35,28 +35,32 @@ describe('InterfaceType', () => {
|
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
37
|
describe('equals', () => {
|
|
38
|
-
it('matches
|
|
39
|
-
|
|
38
|
+
it('matches same objects', () => {
|
|
39
|
+
const ifaceObj = iface({ name: new StringType_1.StringType() });
|
|
40
|
+
(0, chai_config_spec_1.expect)(ifaceObj.isEqual(ifaceObj)).to.be.true;
|
|
41
|
+
});
|
|
42
|
+
it('does not match interfaces with same members', () => {
|
|
43
|
+
(0, chai_config_spec_1.expect)(iface({ name: new StringType_1.StringType() }).isEqual(iface({ name: new StringType_1.StringType() }))).to.be.false;
|
|
40
44
|
});
|
|
41
45
|
it('does not match inequal objects', () => {
|
|
42
|
-
(0, chai_config_spec_1.expect)(iface({ name: new StringType_1.StringType() }).
|
|
46
|
+
(0, chai_config_spec_1.expect)(iface({ name: new StringType_1.StringType() }).isEqual(iface({ name: new IntegerType_1.IntegerType() }))).to.be.false;
|
|
43
47
|
});
|
|
44
48
|
});
|
|
45
|
-
describe('
|
|
46
|
-
it('rejects being
|
|
49
|
+
describe('isTypeCompatible', () => {
|
|
50
|
+
it('rejects being able to assign other types to this', () => {
|
|
47
51
|
(0, chai_config_spec_1.expect)(iface({
|
|
48
52
|
name: new StringType_1.StringType()
|
|
49
|
-
}).
|
|
53
|
+
}).isTypeCompatible(new IntegerType_1.IntegerType())).to.be.false;
|
|
50
54
|
});
|
|
51
55
|
it('matches exact properties', () => {
|
|
52
|
-
|
|
56
|
+
expectCompatible({
|
|
53
57
|
name: new StringType_1.StringType()
|
|
54
58
|
}, {
|
|
55
59
|
name: new StringType_1.StringType()
|
|
56
60
|
});
|
|
57
61
|
});
|
|
58
62
|
it('matches an object with more properties being assigned to an object with less', () => {
|
|
59
|
-
|
|
63
|
+
expectCompatible({
|
|
60
64
|
name: new StringType_1.StringType()
|
|
61
65
|
}, {
|
|
62
66
|
name: new StringType_1.StringType(),
|
|
@@ -64,7 +68,7 @@ describe('InterfaceType', () => {
|
|
|
64
68
|
});
|
|
65
69
|
});
|
|
66
70
|
it('rejects assigning an object with less properties to one with more', () => {
|
|
67
|
-
|
|
71
|
+
expectNotCompatible({
|
|
68
72
|
name: new StringType_1.StringType(),
|
|
69
73
|
age: new IntegerType_1.IntegerType()
|
|
70
74
|
}, {
|
|
@@ -72,23 +76,26 @@ describe('InterfaceType', () => {
|
|
|
72
76
|
});
|
|
73
77
|
});
|
|
74
78
|
it('matches properties in mismatched order', () => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
const ifaceOne = iface({
|
|
80
|
+
name: new StringType_1.StringType(),
|
|
81
|
+
age: new IntegerType_1.IntegerType()
|
|
82
|
+
});
|
|
83
|
+
const ifaceTwo = iface({
|
|
84
|
+
age: new IntegerType_1.IntegerType(),
|
|
85
|
+
name: new StringType_1.StringType()
|
|
86
|
+
});
|
|
87
|
+
(0, chai_config_spec_1.expect)(ifaceOne.isTypeCompatible(ifaceTwo)).to.be.true;
|
|
88
|
+
(0, chai_config_spec_1.expect)(ifaceTwo.isTypeCompatible(ifaceOne)).to.be.true;
|
|
82
89
|
});
|
|
83
90
|
it('rejects with member having mismatched type', () => {
|
|
84
|
-
|
|
91
|
+
expectNotCompatible({
|
|
85
92
|
name: new StringType_1.StringType()
|
|
86
93
|
}, {
|
|
87
94
|
name: new IntegerType_1.IntegerType()
|
|
88
95
|
});
|
|
89
96
|
});
|
|
90
97
|
it('rejects with object member having mismatched type', () => {
|
|
91
|
-
|
|
98
|
+
expectNotCompatible({
|
|
92
99
|
parent: iface({
|
|
93
100
|
name: new StringType_1.StringType()
|
|
94
101
|
})
|
|
@@ -99,7 +106,7 @@ describe('InterfaceType', () => {
|
|
|
99
106
|
});
|
|
100
107
|
});
|
|
101
108
|
it('rejects with object member having missing prop type', () => {
|
|
102
|
-
|
|
109
|
+
expectNotCompatible({
|
|
103
110
|
parent: iface({
|
|
104
111
|
name: new StringType_1.StringType(),
|
|
105
112
|
age: new IntegerType_1.IntegerType()
|
|
@@ -111,7 +118,7 @@ describe('InterfaceType', () => {
|
|
|
111
118
|
});
|
|
112
119
|
});
|
|
113
120
|
it('accepts with object member having same prop types', () => {
|
|
114
|
-
|
|
121
|
+
expectCompatible({
|
|
115
122
|
parent: iface({
|
|
116
123
|
name: new StringType_1.StringType(),
|
|
117
124
|
age: new IntegerType_1.IntegerType()
|
|
@@ -124,52 +131,59 @@ describe('InterfaceType', () => {
|
|
|
124
131
|
});
|
|
125
132
|
});
|
|
126
133
|
it('accepts with source member having dyanmic prop type', () => {
|
|
127
|
-
|
|
134
|
+
expectCompatible({
|
|
135
|
+
parent: new DynamicType_1.DynamicType()
|
|
136
|
+
}, {
|
|
128
137
|
parent: iface({
|
|
129
138
|
name: new StringType_1.StringType(),
|
|
130
139
|
age: new IntegerType_1.IntegerType()
|
|
131
140
|
})
|
|
132
|
-
}, {
|
|
133
|
-
parent: new DynamicType_1.DynamicType()
|
|
134
141
|
});
|
|
135
142
|
});
|
|
136
|
-
it('accepts with target member having
|
|
137
|
-
|
|
138
|
-
parent: new DynamicType_1.DynamicType()
|
|
139
|
-
}, {
|
|
143
|
+
it('accepts with target member having dynamic prop type', () => {
|
|
144
|
+
expectCompatible({
|
|
140
145
|
parent: iface({
|
|
141
146
|
name: new StringType_1.StringType(),
|
|
142
147
|
age: new IntegerType_1.IntegerType()
|
|
143
148
|
})
|
|
149
|
+
}, {
|
|
150
|
+
parent: new DynamicType_1.DynamicType()
|
|
144
151
|
});
|
|
145
152
|
});
|
|
146
153
|
it('accepts with target member having "object" prop type', () => {
|
|
147
|
-
|
|
148
|
-
parent: new ObjectType_1.ObjectType()
|
|
149
|
-
}, {
|
|
154
|
+
expectCompatible({
|
|
150
155
|
parent: iface({
|
|
151
156
|
name: new StringType_1.StringType(),
|
|
152
157
|
age: new IntegerType_1.IntegerType()
|
|
153
158
|
})
|
|
159
|
+
}, {
|
|
160
|
+
parent: new ObjectType_1.ObjectType()
|
|
154
161
|
});
|
|
155
162
|
});
|
|
156
163
|
});
|
|
157
164
|
});
|
|
158
|
-
|
|
159
|
-
|
|
165
|
+
let ifaceCount = 0;
|
|
166
|
+
function iface(members, name, parentType) {
|
|
167
|
+
name = name !== null && name !== void 0 ? name : 'SomeIFace' + ifaceCount;
|
|
168
|
+
ifaceCount++;
|
|
169
|
+
const ifaceType = new InterfaceType_1.InterfaceType(name, parentType);
|
|
170
|
+
for (const key in members) {
|
|
171
|
+
ifaceType.addMember(key, null, members[key], SymbolTable_1.SymbolTypeFlag.runtime);
|
|
172
|
+
}
|
|
173
|
+
return ifaceType;
|
|
160
174
|
}
|
|
161
|
-
function
|
|
175
|
+
function expectCompatible(targetMembers, sourceMembers) {
|
|
162
176
|
const targetIface = iface(targetMembers);
|
|
163
177
|
const sourceIface = iface(sourceMembers);
|
|
164
|
-
if (!sourceIface.
|
|
165
|
-
sinon_1.assert.fail(`expected type ${targetIface.
|
|
178
|
+
if (!sourceIface.isTypeCompatible(targetIface)) {
|
|
179
|
+
sinon_1.assert.fail(`expected type ${targetIface.toJSString()} to be assignable to type ${sourceIface.toJSString()}`);
|
|
166
180
|
}
|
|
167
181
|
}
|
|
168
|
-
function
|
|
182
|
+
function expectNotCompatible(targetMembers, sourceMembers) {
|
|
169
183
|
const targetIface = iface(targetMembers);
|
|
170
184
|
const sourceIface = iface(sourceMembers);
|
|
171
|
-
if (sourceIface.
|
|
172
|
-
sinon_1.assert.fail(`expected type ${targetIface.
|
|
185
|
+
if (sourceIface.isTypeCompatible(targetIface)) {
|
|
186
|
+
sinon_1.assert.fail(`expected type ${targetIface.toJSString()} to not be assignable to type ${sourceIface.toJSString()}`);
|
|
173
187
|
}
|
|
174
188
|
}
|
|
175
189
|
//# sourceMappingURL=InterfaceType.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InterfaceType.spec.js","sourceRoot":"","sources":["../../src/types/InterfaceType.spec.ts"],"names":[],"mappings":";;AAAA,0DAA6C;AAC7C,iCAA+B;
|
|
1
|
+
{"version":3,"file":"InterfaceType.spec.js","sourceRoot":"","sources":["../../src/types/InterfaceType.spec.ts"],"names":[],"mappings":";;AAAA,0DAA6C;AAC7C,iCAA+B;AAE/B,+CAA4C;AAC5C,+CAA4C;AAC5C,mDAAgD;AAChD,6CAA0C;AAC1C,6CAA0C;AAE1C,gDAAgD;AAEhD,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC3B,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QACxB,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;YAClD,IAAA,yBAAM,EAAE,KAAK,CAAC,EAAE,CAAS,CAAC,U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AC;KACnI;AACL,CAAC;AAED,SAAS,mBAAmB,CAAC,aAAsC,EAAE,aAAsC;IACvG,MAAM,WAAW,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC;IACzC,MAAM,WAAW,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC;IACzC,IAAI,WAAW,CAAC,gBAAgB,CAAC,WAAW,CAAC,EAAE;QAC3C,cAAM,CAAC,IAAI,CAAC,iBAAkB,WAAmB,CAAC,UAAU,EAAE,iCAAkC,WAAmB,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;KACvI;AACL,CAAC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { BscType } from './BscType';
|
|
2
|
+
import { BscTypeKind } from './BscTypeKind';
|
|
3
|
+
export declare class InvalidType extends BscType {
|
|
3
4
|
typeText?: string;
|
|
4
5
|
constructor(typeText?: string);
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
readonly kind = BscTypeKind.InvalidType;
|
|
7
|
+
isTypeCompatible(targetType: BscType): boolean;
|
|
7
8
|
toString(): string;
|
|
8
9
|
toTypeString(): string;
|
|
10
|
+
isEqual(targetType: BscType): boolean;
|
|
9
11
|
}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InvalidType = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const reflection_1 = require("../astUtils/reflection");
|
|
5
|
+
const BscType_1 = require("./BscType");
|
|
6
|
+
const BscTypeKind_1 = require("./BscTypeKind");
|
|
7
|
+
class InvalidType extends BscType_1.BscType {
|
|
6
8
|
constructor(typeText) {
|
|
9
|
+
super();
|
|
7
10
|
this.typeText = typeText;
|
|
11
|
+
this.kind = BscTypeKind_1.BscTypeKind.InvalidType;
|
|
8
12
|
}
|
|
9
|
-
|
|
10
|
-
return (targetType
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
isConvertibleTo(targetType) {
|
|
14
|
-
return this.isAssignableTo(targetType);
|
|
13
|
+
isTypeCompatible(targetType) {
|
|
14
|
+
return ((0, reflection_1.isInvalidType)(targetType) ||
|
|
15
|
+
(0, reflection_1.isDynamicType)(targetType));
|
|
15
16
|
}
|
|
16
17
|
toString() {
|
|
17
18
|
var _a;
|
|
@@ -20,6 +21,9 @@ class InvalidType {
|
|
|
20
21
|
toTypeString() {
|
|
21
22
|
return this.toString();
|
|
22
23
|
}
|
|
24
|
+
isEqual(targetType) {
|
|
25
|
+
return (0, reflection_1.isInvalidType)(targetType);
|
|
26
|
+
}
|
|
23
27
|
}
|
|
24
28
|
exports.InvalidType = InvalidType;
|
|
25
29
|
//# sourceMappingURL=InvalidType.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvalidType.js","sourceRoot":"","sources":["../../src/types/InvalidType.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"InvalidType.js","sourceRoot":"","sources":["../../src/types/InvalidType.ts"],"names":[],"mappings":";;;AAAA,uDAAsE;AACtE,uCAAoC;AACpC,+CAA4C;AAE5C,MAAa,WAAY,SAAQ,iBAAO;IACpC,YACW,QAAiB;QAExB,KAAK,EAAE,CAAC;QAFD,aAAQ,GAAR,QAAQ,CAAS;QAKZ,SAAI,GAAG,yBAAW,CAAC,WAAW,CAAC;IAF/C,CAAC;IAIM,gBAAgB,CAAC,UAAmB;QACvC,OAAO,CACH,IAAA,0BAAa,EAAC,UAAU,CAAC;YACzB,IAAA,0BAAa,EAAC,UAAU,CAAC,CAC5B,CAAC;IACN,CAAC;IAEM,QAAQ;;QACX,OAAO,MAAA,IAAI,CAAC,QAAQ,mCAAI,SAAS,CAAC;IACtC,CAAC;IAEM,YAAY;QACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAED,OAAO,CAAC,UAAmB;QACvB,OAAO,IAAA,0BAAa,EAAC,UAAU,CAAC,CAAC;IACrC,CAAC;CACJ;AA3BD,kCA2BC"}
|
|
@@ -4,9 +4,13 @@ const chai_config_spec_1 = require("../chai-config.spec");
|
|
|
4
4
|
const DynamicType_1 = require("./DynamicType");
|
|
5
5
|
const InvalidType_1 = require("./InvalidType");
|
|
6
6
|
describe('InvalidType', () => {
|
|
7
|
-
it('is
|
|
8
|
-
(0, chai_config_spec_1.expect)(new InvalidType_1.InvalidType().
|
|
9
|
-
(0, chai_config_spec_1.expect)(new InvalidType_1.InvalidType().
|
|
7
|
+
it('is compatible to invalid types', () => {
|
|
8
|
+
(0, chai_config_spec_1.expect)(new InvalidType_1.InvalidType().isTypeCompatible(new InvalidType_1.InvalidType())).to.be.true;
|
|
9
|
+
(0, chai_config_spec_1.expect)(new InvalidType_1.InvalidType().isTypeCompatible(new DynamicType_1.DynamicType())).to.be.true;
|
|
10
|
+
});
|
|
11
|
+
it('is equal to invalid types', () => {
|
|
12
|
+
(0, chai_config_spec_1.expect)(new InvalidType_1.InvalidType().isEqual(new InvalidType_1.InvalidType())).to.be.true;
|
|
13
|
+
(0, chai_config_spec_1.expect)(new InvalidType_1.InvalidType().isEqual(new DynamicType_1.DynamicType())).to.be.false;
|
|
10
14
|
});
|
|
11
15
|
});
|
|
12
16
|
//# sourceMappingURL=InvalidType.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvalidType.spec.js","sourceRoot":"","sources":["../../src/types/InvalidType.spec.ts"],"names":[],"mappings":";;AAAA,0DAA6C;AAE7C,+CAA4C;AAC5C,+CAA4C;AAE5C,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACtC,IAAA,yBAAM,EAAC,IAAI,yBAAW,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"InvalidType.spec.js","sourceRoot":"","sources":["../../src/types/InvalidType.spec.ts"],"names":[],"mappings":";;AAAA,0DAA6C;AAE7C,+CAA4C;AAC5C,+CAA4C;AAE5C,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACtC,IAAA,yBAAM,EAAC,IAAI,yBAAW,EAAE,CAAC,gBAAgB,CAAC,IAAI,yBAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QACzE,IAAA,yBAAM,EAAC,IAAI,yBAAW,EAAE,CAAC,gBAAgB,CAAC,IAAI,yBAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2BAA2B,EAAE,GAAG,EAAE;QACjC,IAAA,yBAAM,EAAC,IAAI,yBAAW,EAAE,CAAC,OAAO,CAAC,IAAI,yBAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QAChE,IAAA,yBAAM,EAAC,IAAI,yBAAW,EAAE,CAAC,OAAO,CAAC,IAAI,yBAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;IACrE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { BscType } from './BscType';
|
|
2
|
+
import { BscTypeKind } from './BscTypeKind';
|
|
3
|
+
export declare class LongIntegerType extends BscType {
|
|
3
4
|
typeText?: string;
|
|
4
5
|
constructor(typeText?: string);
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
readonly kind = BscTypeKind.LongIntegerType;
|
|
7
|
+
static instance: LongIntegerType;
|
|
8
|
+
isTypeCompatible(targetType: BscType): boolean;
|
|
7
9
|
toString(): string;
|
|
8
10
|
toTypeString(): string;
|
|
11
|
+
isEqual(targetType: BscType): boolean;
|
|
9
12
|
}
|
|
@@ -1,29 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LongIntegerType = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
class LongIntegerType {
|
|
4
|
+
const reflection_1 = require("../astUtils/reflection");
|
|
5
|
+
const BscType_1 = require("./BscType");
|
|
6
|
+
const BscTypeKind_1 = require("./BscTypeKind");
|
|
7
|
+
class LongIntegerType extends BscType_1.BscType {
|
|
9
8
|
constructor(typeText) {
|
|
9
|
+
super();
|
|
10
10
|
this.typeText = typeText;
|
|
11
|
+
this.kind = BscTypeKind_1.BscTypeKind.LongIntegerType;
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
-
return (targetType
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
targetType instanceof IntegerType_1.IntegerType ||
|
|
19
|
-
targetType instanceof FloatType_1.FloatType ||
|
|
20
|
-
targetType instanceof DoubleType_1.DoubleType ||
|
|
21
|
-
targetType instanceof LongIntegerType) {
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
13
|
+
isTypeCompatible(targetType) {
|
|
14
|
+
return ((0, reflection_1.isDynamicType)(targetType) ||
|
|
15
|
+
(0, reflection_1.isIntegerType)(targetType) ||
|
|
16
|
+
(0, reflection_1.isFloatType)(targetType) ||
|
|
17
|
+
(0, reflection_1.isDoubleType)(targetType) ||
|
|
18
|
+
(0, reflection_1.isLongIntegerType)(targetType));
|
|
27
19
|
}
|
|
28
20
|
toString() {
|
|
29
21
|
var _a;
|
|
@@ -32,6 +24,10 @@ class LongIntegerType {
|
|
|
32
24
|
toTypeString() {
|
|
33
25
|
return this.toString();
|
|
34
26
|
}
|
|
27
|
+
isEqual(targetType) {
|
|
28
|
+
return (0, reflection_1.isLongIntegerType)(targetType);
|
|
29
|
+
}
|
|
35
30
|
}
|
|
36
31
|
exports.LongIntegerType = LongIntegerType;
|
|
32
|
+
LongIntegerType.instance = new LongIntegerType('longinteger');
|
|
37
33
|
//# sourceMappingURL=LongIntegerType.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LongIntegerType.js","sourceRoot":"","sources":["../../src/types/LongIntegerType.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"LongIntegerType.js","sourceRoot":"","sources":["../../src/types/LongIntegerType.ts"],"names":[],"mappings":";;;AAAA,uDAAoH;AACpH,uCAAoC;AACpC,+CAA4C;AAE5C,MAAa,eAAgB,SAAQ,iBAAO;IACxC,YACW,QAAiB;QAExB,KAAK,EAAE,CAAC;QAFD,aAAQ,GAAR,QAAQ,CAAS;QAKZ,SAAI,GAAG,yBAAW,CAAC,eAAe,CAAC;IAFnD,CAAC;IAMM,gBAAgB,CAAC,UAAmB;QACvC,OAAO,CACH,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,CAChC,CAAC;IACN,CAAC;IAEM,QAAQ;;QACX,OAAO,MAAA,IAAI,CAAC,QAAQ,mCAAI,aAAa,CAAC;IAC1C,CAAC;IAEM,YAAY;QACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAED,OAAO,CAAC,UAAmB;QACvB,OAAO,IAAA,8BAAiB,EAAC,UAAU,CAAC,CAAC;IACzC,CAAC;;AA/BL,0CAgCC;AAvBiB,wBAAQ,GAAG,IAAI,eAAe,CAAC,aAAa,CAAC,CAAC"}
|
|
@@ -2,11 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const chai_config_spec_1 = require("../chai-config.spec");
|
|
4
4
|
const DynamicType_1 = require("./DynamicType");
|
|
5
|
+
const FloatType_1 = require("./FloatType");
|
|
5
6
|
const LongIntegerType_1 = require("./LongIntegerType");
|
|
6
7
|
describe('LongIntegerType', () => {
|
|
7
|
-
it('is
|
|
8
|
-
(0, chai_config_spec_1.expect)(new LongIntegerType_1.LongIntegerType().
|
|
9
|
-
(0, chai_config_spec_1.expect)(new LongIntegerType_1.LongIntegerType().
|
|
8
|
+
it('is equal to other longinteger types', () => {
|
|
9
|
+
(0, chai_config_spec_1.expect)(new LongIntegerType_1.LongIntegerType().isEqual(new LongIntegerType_1.LongIntegerType())).to.be.true;
|
|
10
|
+
(0, chai_config_spec_1.expect)(new LongIntegerType_1.LongIntegerType().isEqual(new DynamicType_1.DynamicType())).to.be.false;
|
|
11
|
+
});
|
|
12
|
+
it('is compatible with to other integer types', () => {
|
|
13
|
+
(0, chai_config_spec_1.expect)(new LongIntegerType_1.LongIntegerType().isTypeCompatible(new LongIntegerType_1.LongIntegerType())).to.be.true;
|
|
14
|
+
(0, chai_config_spec_1.expect)(new LongIntegerType_1.LongIntegerType().isTypeCompatible(new FloatType_1.FloatType())).to.be.true;
|
|
15
|
+
(0, chai_config_spec_1.expect)(new LongIntegerType_1.LongIntegerType().isTypeCompatible(new DynamicType_1.DynamicType())).to.be.true;
|
|
10
16
|
});
|
|
11
17
|
});
|
|
12
18
|
//# sourceMappingURL=LongIntegerType.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LongIntegerType.spec.js","sourceRoot":"","sources":["../../src/types/LongIntegerType.spec.ts"],"names":[],"mappings":";;AAAA,0DAA6C;AAE7C,+CAA4C;AAC5C,uDAAoD;AAEpD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACjD,IAAA,yBAAM,EAAC,IAAI,iCAAe,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"LongIntegerType.spec.js","sourceRoot":"","sources":["../../src/types/LongIntegerType.spec.ts"],"names":[],"mappings":";;AAAA,0DAA6C;AAE7C,+CAA4C;AAC5C,2CAAwC;AACxC,uDAAoD;AAEpD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC3C,IAAA,yBAAM,EAAC,IAAI,iCAAe,EAAE,CAAC,OAAO,CAAC,IAAI,iCAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QACxE,IAAA,yBAAM,EAAC,IAAI,iCAAe,EAAE,CAAC,OAAO,CAAC,IAAI,yBAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;IACzE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACjD,IAAA,yBAAM,EAAC,IAAI,iCAAe,EAAE,CAAC,gBAAgB,CAAC,IAAI,iCAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QACjF,IAAA,yBAAM,EAAC,IAAI,iCAAe,EAAE,CAAC,gBAAgB,CAAC,IAAI,qBAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QAC3E,IAAA,yBAAM,EAAC,IAAI,iCAAe,EAAE,CAAC,gBAAgB,CAAC,IAAI,yBAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IACjF,CAAC,CAAC,CAAC;AAEP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { GetTypeOptions } from '../interfaces';
|
|
2
|
+
import { BscType } from './BscType';
|
|
3
|
+
import { BscTypeKind } from './BscTypeKind';
|
|
4
|
+
export declare class NamespaceType extends BscType {
|
|
5
|
+
name: string;
|
|
6
|
+
constructor(name: string);
|
|
7
|
+
readonly kind = BscTypeKind.NamespaceType;
|
|
8
|
+
toString(): string;
|
|
9
|
+
getMemberType(name: string, options: GetTypeOptions): BscType;
|
|
10
|
+
isEqual(targetType: BscType): boolean;
|
|
11
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NamespaceType = void 0;
|
|
4
|
+
const reflection_1 = require("../astUtils/reflection");
|
|
5
|
+
const BscType_1 = require("./BscType");
|
|
6
|
+
const BscTypeKind_1 = require("./BscTypeKind");
|
|
7
|
+
class NamespaceType extends BscType_1.BscType {
|
|
8
|
+
constructor(name) {
|
|
9
|
+
super(name);
|
|
10
|
+
this.name = name;
|
|
11
|
+
this.kind = BscTypeKind_1.BscTypeKind.NamespaceType;
|
|
12
|
+
}
|
|
13
|
+
toString() {
|
|
14
|
+
return this.name;
|
|
15
|
+
}
|
|
16
|
+
getMemberType(name, options) {
|
|
17
|
+
const fullName = this.toString() + '.' + name;
|
|
18
|
+
return super.getMemberType(name, Object.assign(Object.assign({}, options), { fullName: fullName, tableProvider: () => this.memberTable }));
|
|
19
|
+
}
|
|
20
|
+
isEqual(targetType) {
|
|
21
|
+
return (0, reflection_1.isNamespaceType)(targetType) && targetType.name === this.name;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.NamespaceType = NamespaceType;
|
|
25
|
+
//# sourceMappingURL=NamespaceType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NamespaceType.js","sourceRoot":"","sources":["../../src/types/NamespaceType.ts"],"names":[],"mappings":";;;AAAA,uDAAyD;AAEzD,uCAAoC;AACpC,+CAA4C;AAE5C,MAAa,aAAc,SAAQ,iBAAO;IAEtC,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QADG,SAAI,GAAJ,IAAI,CAAQ;QAIf,SAAI,GAAG,yBAAW,CAAC,aAAa,CAAC;IAFjD,CAAC;IAIM,QAAQ;QACX,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,aAAa,CAAC,IAAY,EAAE,OAAuB;QAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG,IAAI,CAAC;QAC9C,OAAO,KAAK,CAAC,aAAa,CAAC,IAAI,kCAAO,OAAO,KAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,IAAG,CAAC;IAChH,CAAC;IAED,OAAO,CAAC,UAAmB;QACvB,OAAO,IAAA,4BAAe,EAAC,UAAU,CAAC,IAAI,UAAU,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC;IACxE,CAAC;CAEJ;AArBD,sCAqBC"}
|