brighterscript 1.0.0-alpha.16 → 1.0.0-alpha.19
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 +72 -1
- package/README.md +30 -9
- package/dist/BsConfig.d.ts +4 -0
- package/dist/DiagnosticMessages.d.ts +16 -1
- package/dist/DiagnosticMessages.js +15 -0
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/Logger.js +5 -5
- package/dist/Logger.js.map +1 -1
- package/dist/Program.d.ts +2 -2
- package/dist/Program.js +3 -3
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.d.ts +4 -0
- package/dist/ProgramBuilder.js +14 -4
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/Scope.d.ts +58 -8
- package/dist/Scope.js +141 -25
- package/dist/Scope.js.map +1 -1
- package/dist/XmlScope.js +1 -1
- package/dist/XmlScope.js.map +1 -1
- package/dist/astUtils/creators.d.ts +3 -3
- package/dist/astUtils/creators.js +8 -8
- package/dist/astUtils/creators.js.map +1 -1
- package/dist/astUtils/creators.spec.js +10 -0
- package/dist/astUtils/creators.spec.js.map +1 -1
- package/dist/astUtils/reflection.d.ts +8 -5
- package/dist/astUtils/reflection.js +18 -6
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/reflection.spec.js +10 -0
- package/dist/astUtils/reflection.spec.js.map +1 -1
- package/dist/astUtils/visitors.d.ts +4 -1
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/astUtils/visitors.spec.js +2 -0
- package/dist/astUtils/visitors.spec.js.map +1 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +2 -2
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js +7 -3
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js.map +1 -1
- package/dist/{types/FunctionType.spec.d.ts → bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.d.ts} +0 -0
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js +32 -0
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js.map +1 -0
- package/dist/cli.js +9 -2
- package/dist/cli.js.map +1 -1
- package/dist/examples/plugins/removePrint.js +12 -14
- package/dist/examples/plugins/removePrint.js.map +1 -1
- package/dist/files/BrsFile.Class.spec.js +3 -3
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +2 -2
- package/dist/files/BrsFile.js +89 -59
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +187 -67
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/globalCallables.js +79 -79
- package/dist/globalCallables.js.map +1 -1
- package/dist/interfaces.d.ts +43 -4
- package/dist/parser/Expression.d.ts +75 -8
- package/dist/parser/Expression.js +147 -22
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.Class.spec.js +6 -6
- package/dist/parser/Parser.Class.spec.js.map +1 -1
- package/dist/parser/Parser.d.ts +3 -6
- package/dist/parser/Parser.js +145 -142
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.js +61 -6
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/SGTypes.d.ts +2 -2
- package/dist/parser/SGTypes.js +2 -2
- package/dist/parser/SGTypes.js.map +1 -1
- package/dist/parser/Statement.d.ts +63 -43
- package/dist/parser/Statement.js +135 -92
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/tests/statement/InterfaceStatement.spec.js +181 -0
- package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/TryCatch.spec.js +7 -5
- package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
- package/dist/types/ArrayType.js +4 -1
- package/dist/types/ArrayType.js.map +1 -1
- package/dist/types/ArrayType.spec.js +3 -1
- package/dist/types/ArrayType.spec.js.map +1 -1
- package/dist/types/BooleanType.d.ts +4 -2
- package/dist/types/BooleanType.js +7 -2
- package/dist/types/BooleanType.js.map +1 -1
- package/dist/types/BooleanType.spec.js +3 -1
- package/dist/types/BooleanType.spec.js.map +1 -1
- package/dist/types/BscType.d.ts +1 -0
- package/dist/types/BscType.js +16 -1
- package/dist/types/BscType.js.map +1 -1
- package/dist/types/CustomType.js +10 -0
- package/dist/types/CustomType.js.map +1 -1
- package/dist/types/DoubleType.d.ts +2 -0
- package/dist/types/DoubleType.js +7 -2
- package/dist/types/DoubleType.js.map +1 -1
- package/dist/types/DoubleType.spec.js +3 -1
- package/dist/types/DoubleType.spec.js.map +1 -1
- package/dist/types/DynamicType.d.ts +2 -0
- package/dist/types/DynamicType.js +5 -1
- package/dist/types/DynamicType.js.map +1 -1
- package/dist/types/FloatType.d.ts +3 -1
- package/dist/types/FloatType.js +7 -2
- package/dist/types/FloatType.js.map +1 -1
- package/dist/types/FloatType.spec.js +2 -0
- package/dist/types/FloatType.spec.js.map +1 -1
- package/dist/types/FunctionType.d.ts +3 -22
- package/dist/types/FunctionType.js +8 -68
- package/dist/types/FunctionType.js.map +1 -1
- package/dist/types/IntegerType.d.ts +3 -1
- package/dist/types/IntegerType.js +7 -2
- package/dist/types/IntegerType.js.map +1 -1
- package/dist/types/IntegerType.spec.js +3 -1
- package/dist/types/IntegerType.spec.js.map +1 -1
- package/dist/types/InterfaceType.d.ts +13 -10
- package/dist/types/InterfaceType.js +33 -29
- package/dist/types/InterfaceType.js.map +1 -1
- package/dist/types/InterfaceType.spec.js +36 -16
- package/dist/types/InterfaceType.spec.js.map +1 -1
- package/dist/types/InvalidType.d.ts +4 -2
- package/dist/types/InvalidType.js +7 -2
- package/dist/types/InvalidType.js.map +1 -1
- package/dist/types/InvalidType.spec.js +2 -0
- package/dist/types/InvalidType.spec.js.map +1 -1
- package/dist/types/LazyType.js +4 -0
- package/dist/types/LazyType.js.map +1 -1
- package/dist/types/LongIntegerType.d.ts +3 -1
- package/dist/types/LongIntegerType.js +7 -2
- package/dist/types/LongIntegerType.js.map +1 -1
- package/dist/types/LongIntegerType.spec.js +2 -0
- package/dist/types/LongIntegerType.spec.js.map +1 -1
- package/dist/types/ObjectType.d.ts +2 -1
- package/dist/types/ObjectType.js +4 -2
- package/dist/types/ObjectType.js.map +1 -1
- package/dist/types/StringType.d.ts +4 -2
- package/dist/types/StringType.js +7 -2
- package/dist/types/StringType.js.map +1 -1
- package/dist/types/StringType.spec.js +2 -0
- package/dist/types/StringType.spec.js.map +1 -1
- package/dist/types/TypedFunctionType.d.ts +28 -0
- package/dist/types/TypedFunctionType.js +88 -0
- package/dist/types/TypedFunctionType.js.map +1 -0
- package/dist/types/TypedFunctionType.spec.d.ts +1 -0
- package/dist/types/TypedFunctionType.spec.js +37 -0
- package/dist/types/TypedFunctionType.spec.js.map +1 -0
- package/dist/types/UninitializedType.js.map +1 -1
- package/dist/types/VoidType.d.ts +4 -2
- package/dist/types/VoidType.js +5 -1
- package/dist/types/VoidType.js.map +1 -1
- package/dist/types/helpers.js +7 -2
- package/dist/types/helpers.js.map +1 -1
- package/dist/util.d.ts +6 -7
- package/dist/util.js +43 -55
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.d.ts +14 -1
- package/dist/validators/ClassValidator.js +129 -82
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +3 -2
- package/dist/types/FunctionType.spec.js +0 -35
- package/dist/types/FunctionType.spec.js.map +0 -1
- package/dist/types/UniversalFunctionType.d.ts +0 -9
- package/dist/types/UniversalFunctionType.js +0 -25
- package/dist/types/UniversalFunctionType.js.map +0 -1
|
@@ -3,15 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BooleanType = void 0;
|
|
4
4
|
const reflection_1 = require("../astUtils/reflection");
|
|
5
5
|
class BooleanType {
|
|
6
|
+
constructor(typeText) {
|
|
7
|
+
this.typeText = typeText;
|
|
8
|
+
}
|
|
6
9
|
isAssignableTo(targetType) {
|
|
7
10
|
return ((0, reflection_1.isBooleanType)(targetType) ||
|
|
8
|
-
(0, reflection_1.isDynamicType)(targetType)
|
|
11
|
+
(0, reflection_1.isDynamicType)(targetType) ||
|
|
12
|
+
(0, reflection_1.isObjectType)(targetType));
|
|
9
13
|
}
|
|
10
14
|
isConvertibleTo(targetType) {
|
|
11
15
|
return this.isAssignableTo(targetType);
|
|
12
16
|
}
|
|
13
17
|
toString() {
|
|
14
|
-
|
|
18
|
+
var _a;
|
|
19
|
+
return (_a = this.typeText) !== null && _a !== void 0 ? _a : 'boolean';
|
|
15
20
|
}
|
|
16
21
|
toTypeString() {
|
|
17
22
|
return this.toString();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BooleanType.js","sourceRoot":"","sources":["../../src/types/BooleanType.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"BooleanType.js","sourceRoot":"","sources":["../../src/types/BooleanType.ts"],"names":[],"mappings":";;;AAAA,uDAAoF;AAGpF,MAAa,WAAW;IACpB,YACW,QAAiB;QAAjB,aAAQ,GAAR,QAAQ,CAAS;IACxB,CAAC;IAEE,cAAc,CAAC,UAAmB;QACrC,OAAO,CACH,IAAA,0BAAa,EAAC,UAAU,CAAC;YACzB,IAAA,0BAAa,EAAC,UAAU,CAAC;YACzB,IAAA,yBAAY,EAAC,UAAU,CAAC,CAC3B,CAAC;IACN,CAAC;IAEM,eAAe,CAAC,UAAmB;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3C,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;IAEM,MAAM,CAAC,UAAmB;QAC7B,OAAO,IAAA,0BAAa,EAAC,UAAU,CAAC,CAAC;IACrC,CAAC;CACJ;AA5BD,kCA4BC"}
|
|
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const chai_1 = require("chai");
|
|
4
4
|
const BooleanType_1 = require("./BooleanType");
|
|
5
5
|
const DynamicType_1 = require("./DynamicType");
|
|
6
|
+
const ObjectType_1 = require("./ObjectType");
|
|
6
7
|
describe('BooleanType', () => {
|
|
7
|
-
it('is
|
|
8
|
+
it('is assignable to various types', () => {
|
|
8
9
|
(0, chai_1.expect)(new BooleanType_1.BooleanType().isAssignableTo(new BooleanType_1.BooleanType())).to.be.true;
|
|
9
10
|
(0, chai_1.expect)(new BooleanType_1.BooleanType().isAssignableTo(new DynamicType_1.DynamicType())).to.be.true;
|
|
11
|
+
(0, chai_1.expect)(new BooleanType_1.BooleanType().isAssignableTo(new ObjectType_1.ObjectType())).to.be.true;
|
|
10
12
|
});
|
|
11
13
|
});
|
|
12
14
|
//# sourceMappingURL=BooleanType.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BooleanType.spec.js","sourceRoot":"","sources":["../../src/types/BooleanType.spec.ts"],"names":[],"mappings":";;AAAA,+BAA8B;
|
|
1
|
+
{"version":3,"file":"BooleanType.spec.js","sourceRoot":"","sources":["../../src/types/BooleanType.spec.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAC9B,+CAA4C;AAC5C,+CAA4C;AAC5C,6CAA0C;AAE1C,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACtC,IAAA,aAAM,EAAC,IAAI,yBAAW,EAAE,CAAC,cAAc,CAAC,IAAI,yBAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QACvE,IAAA,aAAM,EAAC,IAAI,yBAAW,EAAE,CAAC,cAAc,CAAC,IAAI,yBAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QACvE,IAAA,aAAM,EAAC,IAAI,yBAAW,EAAE,CAAC,cAAc,CAAC,IAAI,uBAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IAC1E,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
package/dist/types/BscType.d.ts
CHANGED
|
@@ -19,3 +19,4 @@ export interface TypeContext {
|
|
|
19
19
|
position?: Position;
|
|
20
20
|
}
|
|
21
21
|
export declare function getTypeFromContext(type: BscType, context?: TypeContext): BscType;
|
|
22
|
+
export declare function checkAssignabilityToInterface(sourceType: BscType, targetType: BscType, context?: TypeContext): any;
|
package/dist/types/BscType.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTypeFromContext = void 0;
|
|
3
|
+
exports.checkAssignabilityToInterface = exports.getTypeFromContext = void 0;
|
|
4
4
|
const reflection_1 = require("../astUtils/reflection");
|
|
5
5
|
function getTypeFromContext(type, context) {
|
|
6
6
|
if ((0, reflection_1.isLazyType)(type)) {
|
|
@@ -9,4 +9,19 @@ function getTypeFromContext(type, context) {
|
|
|
9
9
|
return type;
|
|
10
10
|
}
|
|
11
11
|
exports.getTypeFromContext = getTypeFromContext;
|
|
12
|
+
function checkAssignabilityToInterface(sourceType, targetType, context) {
|
|
13
|
+
var _a;
|
|
14
|
+
if (!sourceType.memberTable || !targetType.memberTable || !(0, reflection_1.isInterfaceType)(targetType)) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
let isSuperSet = true;
|
|
18
|
+
const targetSymbols = (_a = targetType.memberTable) === null || _a === void 0 ? void 0 : _a.getAllSymbols();
|
|
19
|
+
for (const targetSymbol of targetSymbols) {
|
|
20
|
+
// TODO TYPES: this ignores union types
|
|
21
|
+
const mySymbolsWithName = sourceType.memberTable.getSymbol(targetSymbol.name);
|
|
22
|
+
isSuperSet = isSuperSet && mySymbolsWithName && mySymbolsWithName.length > 0 && mySymbolsWithName[0].type.isAssignableTo(targetSymbol.type, context);
|
|
23
|
+
}
|
|
24
|
+
return isSuperSet;
|
|
25
|
+
}
|
|
26
|
+
exports.checkAssignabilityToInterface = checkAssignabilityToInterface;
|
|
12
27
|
//# sourceMappingURL=BscType.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BscType.js","sourceRoot":"","sources":["../../src/types/BscType.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"BscType.js","sourceRoot":"","sources":["../../src/types/BscType.ts"],"names":[],"mappings":";;;AACA,uDAAqE;AAyBrE,SAAgB,kBAAkB,CAAC,IAAa,EAAE,OAAqB;IACnE,IAAI,IAAA,uBAAU,EAAC,IAAI,CAAC,EAAE;QAClB,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;KAC3C;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AALD,gDAKC;AAED,SAAgB,6BAA6B,CAAC,UAAmB,EAAE,UAAmB,EAAE,OAAqB;;IACzG,IAAI,CAAC,UAAU,CAAC,WAAW,IAAI,CAAC,UAAU,CAAC,WAAW,IAAI,CAAC,IAAA,4BAAe,EAAC,UAAU,CAAC,EAAE;QACpF,OAAO,KAAK,CAAC;KAChB;IACD,IAAI,UAAU,GAAG,IAAI,CAAC;IACtB,MAAM,aAAa,GAAG,MAAA,UAAU,CAAC,WAAW,0CAAE,aAAa,EAAE,CAAC;IAC9D,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE;QACtC,uCAAuC;QAEvC,MAAM,iBAAiB,GAAG,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAC9E,UAAU,GAAG,UAAU,IAAI,iBAAiB,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;KACxJ;IACD,OAAO,UAAU,CAAC;AACtB,CAAC;AAbD,sEAaC"}
|
package/dist/types/CustomType.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CustomType = void 0;
|
|
4
4
|
const reflection_1 = require("../astUtils/reflection");
|
|
5
|
+
const BscType_1 = require("./BscType");
|
|
5
6
|
class CustomType {
|
|
6
7
|
constructor(name, memberTable = null) {
|
|
7
8
|
this.name = name;
|
|
@@ -15,10 +16,19 @@ class CustomType {
|
|
|
15
16
|
}
|
|
16
17
|
isAssignableTo(targetType, context) {
|
|
17
18
|
var _a;
|
|
19
|
+
if ((0, reflection_1.isObjectType)(targetType)) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
18
22
|
const ancestorTypes = (_a = context === null || context === void 0 ? void 0 : context.scope) === null || _a === void 0 ? void 0 : _a.getAncestorTypeListByContext(this, context);
|
|
19
23
|
if (ancestorTypes === null || ancestorTypes === void 0 ? void 0 : ancestorTypes.find(ancestorType => targetType.equals(ancestorType, context))) {
|
|
20
24
|
return true;
|
|
21
25
|
}
|
|
26
|
+
if (this.memberTable && targetType.memberTable) {
|
|
27
|
+
// both have symbol tables, so check if the target is an interface and has all the members of the target
|
|
28
|
+
if ((0, BscType_1.checkAssignabilityToInterface)(this, targetType, context)) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
22
32
|
return (this.equals(targetType, context) ||
|
|
23
33
|
(0, reflection_1.isObjectType)(targetType) ||
|
|
24
34
|
(0, reflection_1.isDynamicType)(targetType));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomType.js","sourceRoot":"","sources":["../../src/types/CustomType.ts"],"names":[],"mappings":";;;AAAA,uDAAmF;
|
|
1
|
+
{"version":3,"file":"CustomType.js","sourceRoot":"","sources":["../../src/types/CustomType.ts"],"names":[],"mappings":";;;AAAA,uDAAmF;AAGnF,uCAA0D;AAE1D,MAAa,UAAU;IAEnB,YAAmB,IAAY,EAAS,cAA2B,IAAI;QAApD,SAAI,GAAJ,IAAI,CAAQ;QAAS,gBAAW,GAAX,WAAW,CAAoB;IACvE,CAAC;IAEM,QAAQ;QACX,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAEM,YAAY;QACf,OAAO,QAAQ,CAAC;IACpB,CAAC;IAEM,cAAc,CAAC,UAAmB,EAAE,OAAqB;;QAC5D,IAAI,IAAA,yBAAY,EAAC,UAAU,CAAC,EAAE;YAC1B,OAAO,IAAI,CAAC;SACf;QACD,MAAM,aAAa,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,0CAAE,4BAA4B,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAClF,IAAI,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,EAAE;YAC/E,OAAO,IAAI,CAAC;SACf;QACD,IAAI,IAAI,CAAC,WAAW,IAAI,UAAU,CAAC,WAAW,EAAE;YAC5C,wGAAwG;YACxG,IAAI,IAAA,uCAA6B,EAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE;gBAC1D,OAAO,IAAI,CAAC;aACf;SACJ;QACD,OAAO,CACH,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC;YAChC,IAAA,yBAAY,EAAC,UAAU,CAAC;YACxB,IAAA,0BAAa,EAAC,UAAU,CAAC,CAC5B,CAAC;IACN,CAAC;IAEM,eAAe,CAAC,UAAmB,EAAE,OAAqB;QAC7D,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;IAEM,MAAM,CAAC,UAAmB,EAAE,OAAqB;QACpD,OAAO,IAAA,yBAAY,EAAC,UAAU,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,MAAK,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,EAAE,CAAA,CAAC;IAClF,CAAC;CACJ;AAzCD,gCAyCC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { BscType } from './BscType';
|
|
2
2
|
export declare class DoubleType implements BscType {
|
|
3
|
+
typeText?: string;
|
|
4
|
+
constructor(typeText?: string);
|
|
3
5
|
isAssignableTo(targetType: BscType): boolean;
|
|
4
6
|
isConvertibleTo(targetType: BscType): boolean;
|
|
5
7
|
toString(): string;
|
package/dist/types/DoubleType.js
CHANGED
|
@@ -3,9 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DoubleType = void 0;
|
|
4
4
|
const reflection_1 = require("../astUtils/reflection");
|
|
5
5
|
class DoubleType {
|
|
6
|
+
constructor(typeText) {
|
|
7
|
+
this.typeText = typeText;
|
|
8
|
+
}
|
|
6
9
|
isAssignableTo(targetType) {
|
|
7
10
|
return ((0, reflection_1.isDoubleType)(targetType) ||
|
|
8
|
-
(0, reflection_1.isDynamicType)(targetType)
|
|
11
|
+
(0, reflection_1.isDynamicType)(targetType) ||
|
|
12
|
+
(0, reflection_1.isObjectType)(targetType));
|
|
9
13
|
}
|
|
10
14
|
isConvertibleTo(targetType) {
|
|
11
15
|
if ((0, reflection_1.isDynamicType)(targetType) ||
|
|
@@ -20,7 +24,8 @@ class DoubleType {
|
|
|
20
24
|
}
|
|
21
25
|
}
|
|
22
26
|
toString() {
|
|
23
|
-
|
|
27
|
+
var _a;
|
|
28
|
+
return (_a = this.typeText) !== null && _a !== void 0 ? _a : 'double';
|
|
24
29
|
}
|
|
25
30
|
toTypeString() {
|
|
26
31
|
return this.toString();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DoubleType.js","sourceRoot":"","sources":["../../src/types/DoubleType.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"DoubleType.js","sourceRoot":"","sources":["../../src/types/DoubleType.ts"],"names":[],"mappings":";;;AAAA,uDAAkI;AAGlI,MAAa,UAAU;IACnB,YACW,QAAiB;QAAjB,aAAQ,GAAR,QAAQ,CAAS;IACxB,CAAC;IAEE,cAAc,CAAC,UAAmB;QACrC,OAAO,CACH,IAAA,yBAAY,EAAC,UAAU,CAAC;YACxB,IAAA,0BAAa,EAAC,UAAU,CAAC;YACzB,IAAA,yBAAY,EAAC,UAAU,CAAC,CAC3B,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;IACM,QAAQ;;QACX,OAAO,MAAA,IAAI,CAAC,QAAQ,mCAAI,QAAQ,CAAC;IACrC,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;AArCD,gCAqCC"}
|
|
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const chai_1 = require("chai");
|
|
4
4
|
const DoubleType_1 = require("./DoubleType");
|
|
5
5
|
const DynamicType_1 = require("./DynamicType");
|
|
6
|
+
const ObjectType_1 = require("./ObjectType");
|
|
6
7
|
describe('DoubleType', () => {
|
|
7
|
-
it('is
|
|
8
|
+
it('is assignable to correct types', () => {
|
|
8
9
|
(0, chai_1.expect)(new DoubleType_1.DoubleType().isAssignableTo(new DoubleType_1.DoubleType())).to.be.true;
|
|
9
10
|
(0, chai_1.expect)(new DoubleType_1.DoubleType().isAssignableTo(new DynamicType_1.DynamicType())).to.be.true;
|
|
11
|
+
(0, chai_1.expect)(new DoubleType_1.DoubleType().isAssignableTo(new ObjectType_1.ObjectType())).to.be.true;
|
|
10
12
|
});
|
|
11
13
|
});
|
|
12
14
|
//# sourceMappingURL=DoubleType.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DoubleType.spec.js","sourceRoot":"","sources":["../../src/types/DoubleType.spec.ts"],"names":[],"mappings":";;AAAA,+BAA8B;
|
|
1
|
+
{"version":3,"file":"DoubleType.spec.js","sourceRoot":"","sources":["../../src/types/DoubleType.spec.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAC9B,6CAA0C;AAC1C,+CAA4C;AAC5C,6CAA0C;AAE1C,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IACxB,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACtC,IAAA,aAAM,EAAC,IAAI,uBAAU,EAAE,CAAC,cAAc,CAAC,IAAI,uBAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QACrE,IAAA,aAAM,EAAC,IAAI,uBAAU,EAAE,CAAC,cAAc,CAAC,IAAI,yBAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QACtE,IAAA,aAAM,EAAC,IAAI,uBAAU,EAAE,CAAC,cAAc,CAAC,IAAI,uBAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IACzE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DynamicType = void 0;
|
|
4
4
|
const reflection_1 = require("../astUtils/reflection");
|
|
5
5
|
class DynamicType {
|
|
6
|
+
constructor(typeText) {
|
|
7
|
+
this.typeText = typeText;
|
|
8
|
+
}
|
|
6
9
|
isAssignableTo(targetType) {
|
|
7
10
|
//everything can be dynamic, so as long as a type is provided, this is true
|
|
8
11
|
return !!targetType;
|
|
@@ -16,7 +19,8 @@ class DynamicType {
|
|
|
16
19
|
return !!targetType;
|
|
17
20
|
}
|
|
18
21
|
toString() {
|
|
19
|
-
|
|
22
|
+
var _a;
|
|
23
|
+
return (_a = this.typeText) !== null && _a !== void 0 ? _a : 'dynamic';
|
|
20
24
|
}
|
|
21
25
|
toTypeString() {
|
|
22
26
|
return this.toString();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicType.js","sourceRoot":"","sources":["../../src/types/DynamicType.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AAGvD,MAAa,WAAW;
|
|
1
|
+
{"version":3,"file":"DynamicType.js","sourceRoot":"","sources":["../../src/types/DynamicType.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AAGvD,MAAa,WAAW;IACpB,YACW,QAAiB;QAAjB,aAAQ,GAAR,QAAQ,CAAS;IACxB,CAAC;IAEE,cAAc,CAAC,UAAmB;QACrC,2EAA2E;QAC3E,OAAO,CAAC,CAAC,UAAU,CAAC;IACxB,CAAC;IAED;;;OAGG;IACI,eAAe,CAAC,UAAmB;QACtC,2EAA2E;QAC3E,OAAO,CAAC,CAAC,UAAU,CAAC;IACxB,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;IAEM,MAAM,CAAC,UAAmB;QAC7B,OAAO,IAAA,0BAAa,EAAC,UAAU,CAAC,CAAC;IACrC,CAAC;CACJ;AA9BD,kCA8BC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { BscType } from './BscType';
|
|
2
2
|
export declare class FloatType implements BscType {
|
|
3
|
-
|
|
3
|
+
typeText?: string;
|
|
4
|
+
constructor(typeText?: string);
|
|
5
|
+
isAssignableTo(targetType: BscType): boolean;
|
|
4
6
|
isConvertibleTo(targetType: BscType): boolean;
|
|
5
7
|
toString(): string;
|
|
6
8
|
toTypeString(): string;
|
package/dist/types/FloatType.js
CHANGED
|
@@ -3,9 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FloatType = void 0;
|
|
4
4
|
const reflection_1 = require("../astUtils/reflection");
|
|
5
5
|
class FloatType {
|
|
6
|
+
constructor(typeText) {
|
|
7
|
+
this.typeText = typeText;
|
|
8
|
+
}
|
|
6
9
|
isAssignableTo(targetType) {
|
|
7
10
|
return ((0, reflection_1.isFloatType)(targetType) ||
|
|
8
|
-
(0, reflection_1.isDynamicType)(targetType)
|
|
11
|
+
(0, reflection_1.isDynamicType)(targetType) ||
|
|
12
|
+
(0, reflection_1.isObjectType)(targetType));
|
|
9
13
|
}
|
|
10
14
|
isConvertibleTo(targetType) {
|
|
11
15
|
if ((0, reflection_1.isDynamicType)(targetType) ||
|
|
@@ -20,7 +24,8 @@ class FloatType {
|
|
|
20
24
|
}
|
|
21
25
|
}
|
|
22
26
|
toString() {
|
|
23
|
-
|
|
27
|
+
var _a;
|
|
28
|
+
return (_a = this.typeText) !== null && _a !== void 0 ? _a : 'float';
|
|
24
29
|
}
|
|
25
30
|
toTypeString() {
|
|
26
31
|
return this.toString();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloatType.js","sourceRoot":"","sources":["../../src/types/FloatType.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"FloatType.js","sourceRoot":"","sources":["../../src/types/FloatType.ts"],"names":[],"mappings":";;;AAAA,uDAAkI;AAGlI,MAAa,SAAS;IAClB,YACW,QAAiB;QAAjB,aAAQ,GAAR,QAAQ,CAAS;IACxB,CAAC;IAEE,cAAc,CAAC,UAAmB;QACrC,OAAO,CACH,IAAA,wBAAW,EAAC,UAAU,CAAC;YACvB,IAAA,0BAAa,EAAC,UAAU,CAAC;YACzB,IAAA,yBAAY,EAAC,UAAU,CAAC,CAC3B,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,MAAA,IAAI,CAAC,QAAQ,mCAAI,OAAO,CAAC;IACpC,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;AAtCD,8BAsCC"}
|
|
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const chai_1 = require("chai");
|
|
4
4
|
const DynamicType_1 = require("./DynamicType");
|
|
5
5
|
const FloatType_1 = require("./FloatType");
|
|
6
|
+
const ObjectType_1 = require("./ObjectType");
|
|
6
7
|
describe('FloatType', () => {
|
|
7
8
|
it('is equivalent to double types', () => {
|
|
8
9
|
(0, chai_1.expect)(new FloatType_1.FloatType().isAssignableTo(new FloatType_1.FloatType())).to.be.true;
|
|
9
10
|
(0, chai_1.expect)(new FloatType_1.FloatType().isAssignableTo(new DynamicType_1.DynamicType())).to.be.true;
|
|
11
|
+
(0, chai_1.expect)(new FloatType_1.FloatType().isAssignableTo(new ObjectType_1.ObjectType())).to.be.true;
|
|
10
12
|
});
|
|
11
13
|
});
|
|
12
14
|
//# sourceMappingURL=FloatType.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloatType.spec.js","sourceRoot":"","sources":["../../src/types/FloatType.spec.ts"],"names":[],"mappings":";;AAAA,+BAA8B;
|
|
1
|
+
{"version":3,"file":"FloatType.spec.js","sourceRoot":"","sources":["../../src/types/FloatType.spec.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAC9B,+CAA4C;AAC5C,2CAAwC;AACxC,6CAA0C;AAE1C,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACrC,IAAA,aAAM,EAAC,IAAI,qBAAS,EAAE,CAAC,cAAc,CAAC,IAAI,qBAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QACnE,IAAA,aAAM,EAAC,IAAI,qBAAS,EAAE,CAAC,cAAc,CAAC,IAAI,yBAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QACrE,IAAA,aAAM,EAAC,IAAI,qBAAS,EAAE,CAAC,cAAc,CAAC,IAAI,uBAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IACxE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -1,28 +1,9 @@
|
|
|
1
1
|
import type { CallableParam } from '../interfaces';
|
|
2
2
|
import type { BscType, TypeContext } from './BscType';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* Determines if this is a sub or not
|
|
7
|
-
*/
|
|
8
|
-
isSub: boolean;
|
|
9
|
-
params: CallableParam[];
|
|
10
|
-
isNew: boolean;
|
|
11
|
-
isVariadic: boolean;
|
|
12
|
-
constructor(returnType: BscType,
|
|
13
|
-
/**
|
|
14
|
-
* Determines if this is a sub or not
|
|
15
|
-
*/
|
|
16
|
-
isSub?: boolean, params?: CallableParam[], isNew?: boolean, isVariadic?: boolean);
|
|
17
|
-
/**
|
|
18
|
-
* The name of the function for this type. Can be null
|
|
19
|
-
*/
|
|
20
|
-
name: string;
|
|
3
|
+
import { TypedFunctionType } from './TypedFunctionType';
|
|
4
|
+
export declare class FunctionType extends TypedFunctionType implements BscType {
|
|
5
|
+
constructor();
|
|
21
6
|
setName(name: string): this;
|
|
22
7
|
addParameter(paramOrName: CallableParam | string, type?: BscType, isOptional?: boolean): this;
|
|
23
|
-
isAssignableTo(targetType: BscType, context?: TypeContext): boolean;
|
|
24
|
-
isConvertibleTo(targetType: BscType, context?: TypeContext): boolean;
|
|
25
|
-
toString(context?: TypeContext): string;
|
|
26
|
-
toTypeString(): string;
|
|
27
8
|
equals(targetType: BscType, context?: TypeContext): boolean;
|
|
28
9
|
}
|
|
@@ -3,82 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FunctionType = void 0;
|
|
4
4
|
const reflection_1 = require("../astUtils/reflection");
|
|
5
5
|
const DynamicType_1 = require("./DynamicType");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
isSub = false, params = [], isNew = false, isVariadic = false) {
|
|
12
|
-
this.returnType = returnType;
|
|
13
|
-
this.isSub = isSub;
|
|
14
|
-
this.params = params;
|
|
15
|
-
this.isNew = isNew;
|
|
16
|
-
this.isVariadic = isVariadic;
|
|
6
|
+
const TypedFunctionType_1 = require("./TypedFunctionType");
|
|
7
|
+
class FunctionType extends TypedFunctionType_1.TypedFunctionType {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(new DynamicType_1.DynamicType());
|
|
10
|
+
this.isVariadic = true;
|
|
17
11
|
}
|
|
18
12
|
setName(name) {
|
|
19
|
-
|
|
13
|
+
// noop
|
|
20
14
|
return this;
|
|
21
15
|
}
|
|
22
16
|
addParameter(paramOrName, type, isOptional) {
|
|
23
|
-
|
|
24
|
-
this.params.push({
|
|
25
|
-
name: paramOrName,
|
|
26
|
-
type: type !== null && type !== void 0 ? type : new DynamicType_1.DynamicType(),
|
|
27
|
-
isOptional: isOptional === true ? true : false,
|
|
28
|
-
isRestArgument: false
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
this.params.push(paramOrName);
|
|
33
|
-
}
|
|
17
|
+
// noop
|
|
34
18
|
return this;
|
|
35
19
|
}
|
|
36
|
-
isAssignableTo(targetType, context) {
|
|
37
|
-
if ((0, reflection_1.isFunctionType)(targetType)) {
|
|
38
|
-
if (!targetType.isVariadic) {
|
|
39
|
-
//compare all parameters
|
|
40
|
-
let len = Math.max(this.params.length, targetType.params.length);
|
|
41
|
-
for (let i = 0; i < len; i++) {
|
|
42
|
-
let myParam = this.params[i];
|
|
43
|
-
let targetParam = targetType.params[i];
|
|
44
|
-
if (!myParam || !targetParam || !myParam.type.isAssignableTo(targetParam.type, context)) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
//compare return type
|
|
50
|
-
if (!this.returnType || !targetType.returnType || !this.returnType.isAssignableTo(targetType.returnType, context)) {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
//made it here, all params and return type are equivalent
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
else if ((0, reflection_1.isDynamicType)(targetType)) {
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
isConvertibleTo(targetType, context) {
|
|
64
|
-
return this.isAssignableTo(targetType, context);
|
|
65
|
-
}
|
|
66
|
-
toString(context) {
|
|
67
|
-
var _a, _b;
|
|
68
|
-
let paramTexts = [];
|
|
69
|
-
for (let param of this.params) {
|
|
70
|
-
paramTexts.push(`${param.name}${param.isOptional ? '?' : ''} as ${param.type.toString(context)}`);
|
|
71
|
-
}
|
|
72
|
-
if (this.isNew) {
|
|
73
|
-
return `new ${(_a = this.name) !== null && _a !== void 0 ? _a : ''}(${paramTexts.join(', ')})`;
|
|
74
|
-
}
|
|
75
|
-
return `${this.isSub ? 'sub' : 'function'} ${(_b = this.name) !== null && _b !== void 0 ? _b : ''}(${paramTexts.join(', ')}) as ${this.returnType.toString(context)}`;
|
|
76
|
-
}
|
|
77
|
-
toTypeString() {
|
|
78
|
-
return 'Function';
|
|
79
|
-
}
|
|
80
20
|
equals(targetType, context) {
|
|
81
|
-
return ((0, reflection_1.isFunctionType)(targetType))
|
|
21
|
+
return ((0, reflection_1.isFunctionType)(targetType));
|
|
82
22
|
}
|
|
83
23
|
}
|
|
84
24
|
exports.FunctionType = FunctionType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionType.js","sourceRoot":"","sources":["../../src/types/FunctionType.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"FunctionType.js","sourceRoot":"","sources":["../../src/types/FunctionType.ts"],"names":[],"mappings":";;;AAAA,uDAAwD;AAGxD,+CAA4C;AAC5C,2DAAwD;AAExD,MAAa,YAAa,SAAQ,qCAAiB;IAE/C;QAEI,KAAK,CAAC,IAAI,yBAAW,EAAE,CAAC,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IAC3B,CAAC;IAEM,OAAO,CAAC,IAAY;QACvB,OAAO;QACP,OAAO,IAAI,CAAC;IAChB,CAAC;IACM,YAAY,CAAC,WAAmC,EAAE,IAAc,EAAE,UAAoB;QACzF,OAAO;QACP,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,MAAM,CAAC,UAAmB,EAAE,OAAqB;QACpD,OAAO,CAAC,IAAA,2BAAc,EAAC,UAAU,CAAC,CAAC,CAAC;IACxC,CAAC;CACJ;AApBD,oCAoBC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { BscType } from './BscType';
|
|
2
2
|
export declare class IntegerType implements BscType {
|
|
3
|
-
|
|
3
|
+
typeText?: string;
|
|
4
|
+
constructor(typeText?: string);
|
|
5
|
+
isAssignableTo(targetType: BscType): boolean;
|
|
4
6
|
isConvertibleTo(targetType: BscType): boolean;
|
|
5
7
|
toString(): string;
|
|
6
8
|
toTypeString(): string;
|
|
@@ -3,9 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.IntegerType = void 0;
|
|
4
4
|
const reflection_1 = require("../astUtils/reflection");
|
|
5
5
|
class IntegerType {
|
|
6
|
+
constructor(typeText) {
|
|
7
|
+
this.typeText = typeText;
|
|
8
|
+
}
|
|
6
9
|
isAssignableTo(targetType) {
|
|
7
10
|
return ((0, reflection_1.isIntegerType)(targetType) ||
|
|
8
|
-
(0, reflection_1.isDynamicType)(targetType)
|
|
11
|
+
(0, reflection_1.isDynamicType)(targetType) ||
|
|
12
|
+
(0, reflection_1.isObjectType)(targetType));
|
|
9
13
|
}
|
|
10
14
|
isConvertibleTo(targetType) {
|
|
11
15
|
if ((0, reflection_1.isDynamicType)(targetType) ||
|
|
@@ -20,7 +24,8 @@ class IntegerType {
|
|
|
20
24
|
}
|
|
21
25
|
}
|
|
22
26
|
toString() {
|
|
23
|
-
|
|
27
|
+
var _a;
|
|
28
|
+
return (_a = this.typeText) !== null && _a !== void 0 ? _a : 'integer';
|
|
24
29
|
}
|
|
25
30
|
toTypeString() {
|
|
26
31
|
return this.toString();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntegerType.js","sourceRoot":"","sources":["../../src/types/IntegerType.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"IntegerType.js","sourceRoot":"","sources":["../../src/types/IntegerType.ts"],"names":[],"mappings":";;;AAAA,uDAAkI;AAIlI,MAAa,WAAW;IACpB,YACW,QAAiB;QAAjB,aAAQ,GAAR,QAAQ,CAAS;IACxB,CAAC;IAEE,cAAc,CAAC,UAAmB;QACrC,OAAO,CACH,IAAA,0BAAa,EAAC,UAAU,CAAC;YACzB,IAAA,0BAAa,EAAC,UAAU,CAAC;YACzB,IAAA,yBAAY,EAAC,UAAU,CAAC,CAC3B,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,MAAA,IAAI,CAAC,QAAQ,mCAAI,SAAS,CAAC;IACtC,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;AAtCD,kCAsCC"}
|
|
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const chai_1 = require("chai");
|
|
4
4
|
const DynamicType_1 = require("./DynamicType");
|
|
5
5
|
const IntegerType_1 = require("./IntegerType");
|
|
6
|
+
const ObjectType_1 = require("./ObjectType");
|
|
6
7
|
describe('IntegerType', () => {
|
|
7
|
-
it('is
|
|
8
|
+
it('is assignable to other proper types', () => {
|
|
8
9
|
(0, chai_1.expect)(new IntegerType_1.IntegerType().isAssignableTo(new IntegerType_1.IntegerType())).to.be.true;
|
|
9
10
|
(0, chai_1.expect)(new IntegerType_1.IntegerType().isAssignableTo(new DynamicType_1.DynamicType())).to.be.true;
|
|
11
|
+
(0, chai_1.expect)(new IntegerType_1.IntegerType().isAssignableTo(new ObjectType_1.ObjectType())).to.be.true;
|
|
10
12
|
});
|
|
11
13
|
});
|
|
12
14
|
//# sourceMappingURL=IntegerType.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntegerType.spec.js","sourceRoot":"","sources":["../../src/types/IntegerType.spec.ts"],"names":[],"mappings":";;AAAA,+BAA8B;
|
|
1
|
+
{"version":3,"file":"IntegerType.spec.js","sourceRoot":"","sources":["../../src/types/IntegerType.spec.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAC9B,+CAA4C;AAC5C,+CAA4C;AAC5C,6CAA0C;AAE1C,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC3C,IAAA,aAAM,EAAC,IAAI,yBAAW,EAAE,CAAC,cAAc,CAAC,IAAI,yBAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QACvE,IAAA,aAAM,EAAC,IAAI,yBAAW,EAAE,CAAC,cAAc,CAAC,IAAI,yBAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QACvE,IAAA,aAAM,EAAC,IAAI,yBAAW,EAAE,CAAC,cAAc,CAAC,IAAI,uBAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IAC1E,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
constructor(members: Map<string, BscType>);
|
|
5
|
-
/**
|
|
6
|
-
* The name of the interface. Can be null.
|
|
7
|
-
*/
|
|
1
|
+
import type { SymbolTable } from '../SymbolTable';
|
|
2
|
+
import type { BscType, SymbolContainer, TypeContext } from './BscType';
|
|
3
|
+
export declare class InterfaceType implements BscType, SymbolContainer {
|
|
8
4
|
name: string;
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
memberTable: SymbolTable;
|
|
6
|
+
constructor(name: string, memberTable?: SymbolTable);
|
|
7
|
+
isAssignableTo(targetType: BscType, context?: TypeContext): any;
|
|
8
|
+
isConvertibleTo(targetType: BscType): any;
|
|
11
9
|
toString(): string;
|
|
10
|
+
/**
|
|
11
|
+
* Gets a string representation of the Interface that looks like javascript
|
|
12
|
+
* @returns {string}
|
|
13
|
+
*/
|
|
14
|
+
toJsString(): string;
|
|
12
15
|
toTypeString(): string;
|
|
13
|
-
equals(targetType: BscType): boolean;
|
|
16
|
+
equals(targetType: BscType, context?: TypeContext): boolean;
|
|
14
17
|
}
|
|
@@ -2,44 +2,51 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InterfaceType = void 0;
|
|
4
4
|
const reflection_1 = require("../astUtils/reflection");
|
|
5
|
+
const BscType_1 = require("./BscType");
|
|
5
6
|
class InterfaceType {
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
7
|
+
constructor(name, memberTable = null) {
|
|
8
|
+
this.name = name;
|
|
9
|
+
this.memberTable = memberTable;
|
|
8
10
|
}
|
|
9
|
-
isAssignableTo(targetType) {
|
|
10
|
-
|
|
11
|
-
if ((0, reflection_1.
|
|
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!
|
|
11
|
+
isAssignableTo(targetType, context) {
|
|
12
|
+
var _a;
|
|
13
|
+
if ((0, reflection_1.isObjectType)(targetType)) {
|
|
23
14
|
return true;
|
|
24
|
-
//we are always assignable to dynamic or object
|
|
25
15
|
}
|
|
26
|
-
|
|
16
|
+
const ancestorTypes = (_a = context === null || context === void 0 ? void 0 : context.scope) === null || _a === void 0 ? void 0 : _a.getAncestorTypeListByContext(this, context);
|
|
17
|
+
if (ancestorTypes === null || ancestorTypes === void 0 ? void 0 : ancestorTypes.find(ancestorType => targetType.equals(ancestorType, context))) {
|
|
27
18
|
return true;
|
|
28
|
-
//not assignable to any other object types
|
|
29
19
|
}
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
if (this.memberTable && targetType.memberTable) {
|
|
21
|
+
// both have symbol tables, so check if this interface has all the members of the target
|
|
22
|
+
return (0, BscType_1.checkAssignabilityToInterface)(this, targetType, context);
|
|
32
23
|
}
|
|
24
|
+
return (this.equals(targetType, context) ||
|
|
25
|
+
(0, reflection_1.isObjectType)(targetType) ||
|
|
26
|
+
(0, reflection_1.isDynamicType)(targetType));
|
|
33
27
|
}
|
|
34
28
|
isConvertibleTo(targetType) {
|
|
35
29
|
return this.isAssignableTo(targetType);
|
|
36
30
|
}
|
|
37
31
|
toString() {
|
|
32
|
+
return this.name;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Gets a string representation of the Interface that looks like javascript
|
|
36
|
+
* @returns {string}
|
|
37
|
+
*/
|
|
38
|
+
toJsString() {
|
|
39
|
+
var _a;
|
|
38
40
|
let result = '{';
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
const memberSymbols = (((_a = this.memberTable) === null || _a === void 0 ? void 0 : _a.getAllSymbols()) || []).sort((a, b) => a.name.localeCompare(b.name));
|
|
42
|
+
for (const symbol of memberSymbols) {
|
|
43
|
+
let symbolTypeString = symbol.type.toString();
|
|
44
|
+
if ((0, reflection_1.isInterfaceType)(symbol.type)) {
|
|
45
|
+
symbolTypeString = symbol.type.toJsString();
|
|
46
|
+
}
|
|
47
|
+
result += ' ' + symbol.name + ': ' + symbolTypeString + ';';
|
|
41
48
|
}
|
|
42
|
-
if (
|
|
49
|
+
if (memberSymbols.length > 0) {
|
|
43
50
|
result += ' ';
|
|
44
51
|
}
|
|
45
52
|
return result + '}';
|
|
@@ -47,12 +54,9 @@ class InterfaceType {
|
|
|
47
54
|
toTypeString() {
|
|
48
55
|
return 'object';
|
|
49
56
|
}
|
|
50
|
-
equals(targetType) {
|
|
57
|
+
equals(targetType, context) {
|
|
51
58
|
if ((0, reflection_1.isInterfaceType)(targetType)) {
|
|
52
|
-
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
return targetType.isAssignableTo(this);
|
|
59
|
+
return this.isAssignableTo(targetType, context) && targetType.isAssignableTo(this, context);
|
|
56
60
|
}
|
|
57
61
|
return false;
|
|
58
62
|
}
|