brighterscript 1.0.0-alpha.1 → 1.0.0-alpha.13
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 +362 -248
- package/README.md +2 -2
- package/bsconfig.schema.json +1 -1
- package/dist/CodeActionUtil.d.ts +11 -2
- package/dist/CodeActionUtil.js +17 -3
- package/dist/CodeActionUtil.js.map +1 -1
- package/dist/CommentFlagProcessor.d.ts +4 -4
- package/dist/CommentFlagProcessor.js +5 -3
- package/dist/CommentFlagProcessor.js.map +1 -1
- package/dist/DependencyGraph.js.map +1 -1
- package/dist/DiagnosticCollection.js +2 -2
- package/dist/DiagnosticCollection.js.map +1 -1
- package/dist/DiagnosticFilterer.js +3 -3
- package/dist/DiagnosticFilterer.js.map +1 -1
- package/dist/DiagnosticMessages.d.ts +15 -5
- package/dist/DiagnosticMessages.js +19 -9
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/LanguageServer.d.ts +11 -10
- package/dist/LanguageServer.js +87 -58
- package/dist/LanguageServer.js.map +1 -1
- package/dist/Logger.d.ts +2 -0
- package/dist/Logger.js +5 -3
- package/dist/Logger.js.map +1 -1
- package/dist/Program.d.ts +76 -46
- package/dist/Program.js +254 -180
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.d.ts +7 -7
- package/dist/ProgramBuilder.js +37 -43
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/Scope.d.ts +33 -23
- package/dist/Scope.js +222 -147
- package/dist/Scope.js.map +1 -1
- package/dist/SemanticTokenUtils.d.ts +14 -0
- package/dist/SemanticTokenUtils.js +81 -0
- package/dist/SemanticTokenUtils.js.map +1 -0
- package/dist/SymbolTable.d.ts +9 -3
- package/dist/SymbolTable.js +40 -13
- package/dist/SymbolTable.js.map +1 -1
- package/dist/XmlScope.d.ts +7 -2
- package/dist/XmlScope.js +67 -29
- package/dist/XmlScope.js.map +1 -1
- package/dist/astUtils/AstEditor.d.ts +27 -0
- package/dist/astUtils/AstEditor.js +97 -0
- package/dist/astUtils/AstEditor.js.map +1 -0
- package/dist/astUtils/AstEditor.spec.d.ts +1 -0
- package/dist/astUtils/AstEditor.spec.js +133 -0
- package/dist/astUtils/AstEditor.spec.js.map +1 -0
- package/dist/astUtils/creators.d.ts +15 -1
- package/dist/astUtils/creators.js +39 -9
- package/dist/astUtils/creators.js.map +1 -1
- package/dist/astUtils/creators.spec.js +4 -4
- package/dist/astUtils/creators.spec.js.map +1 -1
- package/dist/astUtils/index.js +1 -1
- package/dist/astUtils/reflection.d.ts +20 -8
- package/dist/astUtils/reflection.js +42 -1
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/reflection.spec.js +115 -115
- package/dist/astUtils/reflection.spec.js.map +1 -1
- package/dist/astUtils/stackedVisitor.js.map +1 -1
- package/dist/astUtils/stackedVisitor.spec.js +13 -13
- package/dist/astUtils/stackedVisitor.spec.js.map +1 -1
- package/dist/astUtils/visitors.js +1 -1
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/astUtils/visitors.spec.js +28 -28
- package/dist/astUtils/visitors.spec.js.map +1 -1
- package/dist/astUtils/xml.d.ts +4 -3
- package/dist/astUtils/xml.js +8 -3
- package/dist/astUtils/xml.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.d.ts +2 -1
- package/dist/bscPlugin/BscPlugin.js +4 -0
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +5 -6
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +30 -30
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.d.ts +7 -0
- package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.js +63 -0
- package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.js.map +1 -0
- package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.spec.d.ts +1 -0
- package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.spec.js +45 -0
- package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.spec.js.map +1 -0
- package/dist/diagnosticUtils.d.ts +1 -0
- package/dist/diagnosticUtils.js +14 -7
- package/dist/diagnosticUtils.js.map +1 -1
- package/dist/examples/plugins/removePrint.js +2 -2
- package/dist/examples/plugins/removePrint.js.map +1 -1
- package/dist/files/BrsFile.Class.spec.js +486 -71
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +48 -23
- package/dist/files/BrsFile.js +403 -233
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +367 -316
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/XmlFile.d.ts +13 -6
- package/dist/files/XmlFile.js +27 -21
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/files/XmlFile.spec.js +274 -228
- package/dist/files/XmlFile.spec.js.map +1 -1
- package/dist/files/tests/imports.spec.js +49 -49
- package/dist/files/tests/imports.spec.js.map +1 -1
- package/dist/globalCallables.d.ts +3 -1
- package/dist/globalCallables.js +359 -87
- package/dist/globalCallables.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +51 -14
- package/dist/lexer/Lexer.d.ts +14 -1
- package/dist/lexer/Lexer.js +91 -21
- package/dist/lexer/Lexer.js.map +1 -1
- package/dist/lexer/Lexer.spec.js +187 -132
- package/dist/lexer/Lexer.spec.js.map +1 -1
- package/dist/lexer/Token.d.ts +2 -2
- package/dist/lexer/TokenKind.d.ts +7 -1
- package/dist/lexer/TokenKind.js +51 -3
- package/dist/lexer/TokenKind.js.map +1 -1
- package/dist/lexer/index.js +2 -1
- package/dist/lexer/index.js.map +1 -1
- package/dist/parser/BrsTranspileState.d.ts +7 -0
- package/dist/parser/BrsTranspileState.js +10 -1
- package/dist/parser/BrsTranspileState.js.map +1 -1
- package/dist/parser/Expression.d.ts +23 -5
- package/dist/parser/Expression.js +124 -75
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.Class.spec.js +159 -60
- package/dist/parser/Parser.Class.spec.js.map +1 -1
- package/dist/parser/Parser.d.ts +114 -26
- package/dist/parser/Parser.js +471 -126
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.js +396 -235
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/SGParser.d.ts +41 -4
- package/dist/parser/SGParser.js +186 -175
- package/dist/parser/SGParser.js.map +1 -1
- package/dist/parser/SGParser.spec.js +35 -22
- package/dist/parser/SGParser.spec.js.map +1 -1
- package/dist/parser/SGTypes.d.ts +206 -38
- package/dist/parser/SGTypes.js +470 -161
- package/dist/parser/SGTypes.js.map +1 -1
- package/dist/parser/SGTypes.spec.d.ts +1 -0
- package/dist/parser/SGTypes.spec.js +351 -0
- package/dist/parser/SGTypes.spec.js.map +1 -0
- package/dist/parser/Statement.d.ts +92 -18
- package/dist/parser/Statement.js +287 -58
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/Statement.spec.js +11 -11
- package/dist/parser/Statement.spec.js.map +1 -1
- package/dist/parser/TranspileState.d.ts +1 -1
- package/dist/parser/TranspileState.js +15 -7
- package/dist/parser/TranspileState.js.map +1 -1
- package/dist/parser/index.js +1 -1
- package/dist/parser/tests/Parser.spec.d.ts +8 -7
- package/dist/parser/tests/Parser.spec.js +12 -8
- package/dist/parser/tests/Parser.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/For.spec.js +50 -50
- package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/ForEach.spec.js +31 -31
- package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/If.spec.js +174 -156
- package/dist/parser/tests/controlFlow/If.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/While.spec.js +32 -32
- package/dist/parser/tests/controlFlow/While.spec.js.map +1 -1
- package/dist/parser/tests/expression/Additive.spec.js +21 -21
- package/dist/parser/tests/expression/Additive.spec.js.map +1 -1
- package/dist/parser/tests/expression/ArrayLiterals.spec.js +105 -105
- package/dist/parser/tests/expression/ArrayLiterals.spec.js.map +1 -1
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +148 -124
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +1 -1
- package/dist/parser/tests/expression/Boolean.spec.js +17 -17
- package/dist/parser/tests/expression/Boolean.spec.js.map +1 -1
- package/dist/parser/tests/expression/Call.spec.js +30 -30
- package/dist/parser/tests/expression/Call.spec.js.map +1 -1
- package/dist/parser/tests/expression/Exponential.spec.js +16 -16
- package/dist/parser/tests/expression/Exponential.spec.js.map +1 -1
- package/dist/parser/tests/expression/Function.spec.js +247 -247
- package/dist/parser/tests/expression/Function.spec.js.map +1 -1
- package/dist/parser/tests/expression/Indexing.spec.js +73 -73
- package/dist/parser/tests/expression/Indexing.spec.js.map +1 -1
- package/dist/parser/tests/expression/Multiplicative.spec.js +36 -36
- package/dist/parser/tests/expression/Multiplicative.spec.js.map +1 -1
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +59 -47
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/PrefixUnary.spec.js +35 -35
- package/dist/parser/tests/expression/PrefixUnary.spec.js.map +1 -1
- package/dist/parser/tests/expression/Primary.spec.js +26 -26
- package/dist/parser/tests/expression/Primary.spec.js.map +1 -1
- package/dist/parser/tests/expression/RegexLiteralExpression.spec.d.ts +1 -0
- package/dist/parser/tests/expression/RegexLiteralExpression.spec.js +170 -0
- package/dist/parser/tests/expression/RegexLiteralExpression.spec.js.map +1 -0
- package/dist/parser/tests/expression/Relational.spec.js +42 -42
- package/dist/parser/tests/expression/Relational.spec.js.map +1 -1
- package/dist/parser/tests/expression/SourceLiteralExpression.spec.js +8 -8
- package/dist/parser/tests/expression/SourceLiteralExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js +12 -12
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TernaryExpression.spec.js +100 -100
- package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
- package/dist/parser/tests/statement/AssignmentOperators.spec.js +35 -35
- package/dist/parser/tests/statement/AssignmentOperators.spec.js.map +1 -1
- package/dist/parser/tests/statement/Declaration.spec.js +39 -39
- package/dist/parser/tests/statement/Declaration.spec.js.map +1 -1
- package/dist/parser/tests/statement/Dim.spec.js +21 -21
- package/dist/parser/tests/statement/Dim.spec.js.map +1 -1
- package/dist/parser/tests/statement/Function.spec.js +192 -192
- package/dist/parser/tests/statement/Function.spec.js.map +1 -1
- package/dist/parser/tests/statement/Goto.spec.js +11 -11
- package/dist/parser/tests/statement/Goto.spec.js.map +1 -1
- package/dist/parser/tests/statement/Increment.spec.js +46 -46
- package/dist/parser/tests/statement/Increment.spec.js.map +1 -1
- package/dist/parser/tests/statement/InterfaceStatement.spec.d.ts +1 -0
- package/dist/parser/tests/statement/InterfaceStatement.spec.js +61 -0
- package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -0
- package/dist/parser/tests/statement/LibraryStatement.spec.js +10 -10
- package/dist/parser/tests/statement/LibraryStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Misc.spec.js +37 -36
- package/dist/parser/tests/statement/Misc.spec.js.map +1 -1
- package/dist/parser/tests/statement/PrintStatement.spec.js +30 -30
- package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/ReturnStatement.spec.js +43 -43
- package/dist/parser/tests/statement/ReturnStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Set.spec.js +69 -69
- package/dist/parser/tests/statement/Set.spec.js.map +1 -1
- package/dist/parser/tests/statement/Stop.spec.js +9 -9
- package/dist/parser/tests/statement/Stop.spec.js.map +1 -1
- package/dist/parser/tests/statement/Throw.spec.js +5 -5
- package/dist/parser/tests/statement/Throw.spec.js.map +1 -1
- package/dist/parser/tests/statement/TryCatch.spec.js +13 -13
- package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
- package/dist/preprocessor/Chunk.js.map +1 -1
- package/dist/preprocessor/Manifest.d.ts +1 -1
- package/dist/preprocessor/Preprocessor.js +1 -1
- package/dist/preprocessor/Preprocessor.js.map +1 -1
- package/dist/preprocessor/Preprocessor.spec.js +49 -49
- package/dist/preprocessor/Preprocessor.spec.js.map +1 -1
- package/dist/preprocessor/PreprocessorParser.spec.js +72 -72
- package/dist/preprocessor/PreprocessorParser.spec.js.map +1 -1
- package/dist/preprocessor/index.js +1 -1
- package/dist/types/ArrayType.js +5 -4
- 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.js +3 -3
- package/dist/types/BooleanType.js.map +1 -1
- package/dist/types/BooleanType.spec.js +2 -2
- package/dist/types/BooleanType.spec.js.map +1 -1
- package/dist/types/BscType.d.ts +19 -5
- package/dist/types/BscType.js +9 -0
- package/dist/types/BscType.js.map +1 -1
- package/dist/types/CustomType.d.ts +8 -5
- package/dist/types/CustomType.js +17 -6
- package/dist/types/CustomType.js.map +1 -1
- package/dist/types/DoubleType.js +8 -8
- package/dist/types/DoubleType.js.map +1 -1
- package/dist/types/DoubleType.spec.js +2 -2
- package/dist/types/DoubleType.spec.js.map +1 -1
- package/dist/types/DynamicType.js +1 -1
- package/dist/types/DynamicType.js.map +1 -1
- package/dist/types/DynamicType.spec.js +2 -2
- package/dist/types/DynamicType.spec.js.map +1 -1
- package/dist/types/FloatType.d.ts +1 -1
- package/dist/types/FloatType.js +8 -8
- package/dist/types/FloatType.js.map +1 -1
- package/dist/types/FloatType.spec.js +2 -2
- package/dist/types/FloatType.spec.js.map +1 -1
- package/dist/types/FunctionType.d.ts +5 -11
- package/dist/types/FunctionType.js +24 -13
- package/dist/types/FunctionType.js.map +1 -1
- package/dist/types/FunctionType.spec.js +11 -5
- package/dist/types/FunctionType.spec.js.map +1 -1
- package/dist/types/IntegerType.d.ts +1 -1
- package/dist/types/IntegerType.js +8 -8
- package/dist/types/IntegerType.js.map +1 -1
- package/dist/types/IntegerType.spec.js +2 -2
- package/dist/types/IntegerType.spec.js.map +1 -1
- package/dist/types/InterfaceType.d.ts +8 -2
- package/dist/types/InterfaceType.js +42 -6
- package/dist/types/InterfaceType.js.map +1 -1
- package/dist/types/InterfaceType.spec.d.ts +1 -0
- package/dist/types/InterfaceType.spec.js +174 -0
- package/dist/types/InterfaceType.spec.js.map +1 -0
- package/dist/types/InvalidType.js +4 -4
- package/dist/types/InvalidType.js.map +1 -1
- package/dist/types/InvalidType.spec.js +2 -2
- package/dist/types/InvalidType.spec.js.map +1 -1
- package/dist/types/LazyType.d.ts +9 -7
- package/dist/types/LazyType.js +22 -10
- package/dist/types/LazyType.js.map +1 -1
- package/dist/types/LongIntegerType.d.ts +1 -1
- package/dist/types/LongIntegerType.js +8 -8
- package/dist/types/LongIntegerType.js.map +1 -1
- package/dist/types/LongIntegerType.spec.js +2 -2
- package/dist/types/LongIntegerType.spec.js.map +1 -1
- package/dist/types/ObjectType.d.ts +7 -4
- package/dist/types/ObjectType.js +6 -3
- 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/StringType.js +3 -3
- 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.js +3 -3
- package/dist/types/UninitializedType.js.map +1 -1
- package/dist/types/VoidType.js +3 -3
- 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/helpers.d.ts +42 -0
- package/dist/types/helpers.js +113 -0
- package/dist/types/helpers.js.map +1 -0
- package/dist/util.d.ts +77 -17
- package/dist/util.js +247 -59
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.d.ts +5 -1
- package/dist/validators/ClassValidator.js +59 -24
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +13 -13
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NullCoalescingExpression = exports.TernaryExpression = exports.AnnotationExpression = exports.TaggedTemplateStringExpression = exports.TemplateStringExpression = exports.TemplateStringQuasiExpression = exports.CallfuncExpression = exports.NewExpression = exports.SourceLiteralExpression = exports.VariableExpression = exports.UnaryExpression = exports.AALiteralExpression = exports.AAMemberExpression = exports.ArrayLiteralExpression = exports.EscapedCharCodeLiteralExpression = exports.LiteralExpression = exports.GroupingExpression = exports.IndexedGetExpression = exports.XmlAttributeGetExpression = exports.DottedGetExpression = exports.NamespacedVariableNameExpression = exports.FunctionParameterExpression = exports.FunctionExpression = exports.CallExpression = exports.BinaryExpression = exports.Expression = void 0;
|
|
3
|
+
exports.RegexLiteralExpression = exports.NullCoalescingExpression = exports.TernaryExpression = exports.AnnotationExpression = exports.TaggedTemplateStringExpression = exports.TemplateStringExpression = exports.TemplateStringQuasiExpression = exports.CallfuncExpression = exports.NewExpression = exports.SourceLiteralExpression = exports.VariableExpression = exports.UnaryExpression = exports.AALiteralExpression = exports.AAMemberExpression = exports.ArrayLiteralExpression = exports.EscapedCharCodeLiteralExpression = exports.LiteralExpression = exports.GroupingExpression = exports.IndexedGetExpression = exports.XmlAttributeGetExpression = exports.DottedGetExpression = exports.NamespacedVariableNameExpression = exports.FunctionParameterExpression = exports.FunctionExpression = exports.CallExpression = exports.BinaryExpression = exports.Expression = void 0;
|
|
4
4
|
const lexer_1 = require("../lexer");
|
|
5
5
|
const util_1 = require("../util");
|
|
6
6
|
const Parser_1 = require("./Parser");
|
|
@@ -11,6 +11,7 @@ const VoidType_1 = require("../types/VoidType");
|
|
|
11
11
|
const DynamicType_1 = require("../types/DynamicType");
|
|
12
12
|
const SymbolTable_1 = require("../SymbolTable");
|
|
13
13
|
const FunctionType_1 = require("../types/FunctionType");
|
|
14
|
+
const ObjectType_1 = require("../types/ObjectType");
|
|
14
15
|
/** A BrightScript expression */
|
|
15
16
|
class Expression {
|
|
16
17
|
constructor() {
|
|
@@ -40,8 +41,8 @@ class BinaryExpression extends Expression {
|
|
|
40
41
|
}
|
|
41
42
|
walk(visitor, options) {
|
|
42
43
|
if (options.walkMode & visitors_1.InternalWalkMode.walkExpressions) {
|
|
43
|
-
visitors_1.walk(this, 'left', visitor, options);
|
|
44
|
-
visitors_1.walk(this, 'right', visitor, options);
|
|
44
|
+
(0, visitors_1.walk)(this, 'left', visitor, options);
|
|
45
|
+
(0, visitors_1.walk)(this, 'right', visitor, options);
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
}
|
|
@@ -83,15 +84,15 @@ class CallExpression extends Expression {
|
|
|
83
84
|
}
|
|
84
85
|
walk(visitor, options) {
|
|
85
86
|
if (options.walkMode & visitors_1.InternalWalkMode.walkExpressions) {
|
|
86
|
-
visitors_1.walk(this, 'callee', visitor, options);
|
|
87
|
+
(0, visitors_1.walk)(this, 'callee', visitor, options);
|
|
87
88
|
for (let i = 0; i < this.args.length; i++) {
|
|
88
|
-
visitors_1.walk(this.args, i, visitor, options, this);
|
|
89
|
+
(0, visitors_1.walk)(this.args, i, visitor, options, this);
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
94
|
exports.CallExpression = CallExpression;
|
|
94
|
-
CallExpression.MaximumArguments =
|
|
95
|
+
CallExpression.MaximumArguments = util_1.MAX_PARAM_COUNT;
|
|
95
96
|
class FunctionExpression extends Expression {
|
|
96
97
|
constructor(parameters, body, functionType, end, leftParen, rightParen, asToken, returnTypeToken,
|
|
97
98
|
/**
|
|
@@ -121,7 +122,7 @@ class FunctionExpression extends Expression {
|
|
|
121
122
|
*/
|
|
122
123
|
this.childFunctionExpressions = [];
|
|
123
124
|
if (this.returnTypeToken) {
|
|
124
|
-
this.returnType = util_1.default.tokenToBscType(this.returnTypeToken);
|
|
125
|
+
this.returnType = util_1.default.tokenToBscType(this.returnTypeToken, true, namespaceName);
|
|
125
126
|
}
|
|
126
127
|
else if (this.functionType.text.toLowerCase() === 'sub') {
|
|
127
128
|
this.returnType = new VoidType_1.VoidType();
|
|
@@ -170,7 +171,7 @@ class FunctionExpression extends Expression {
|
|
|
170
171
|
//as
|
|
171
172
|
state.transpileToken(this.asToken), ' ',
|
|
172
173
|
//return type
|
|
173
|
-
state.sourceNode(this.returnTypeToken, this.returnType.toTypeString()));
|
|
174
|
+
state.sourceNode(this.returnTypeToken, this.returnType.toTypeString(state.typeContext)));
|
|
174
175
|
}
|
|
175
176
|
if (includeBody) {
|
|
176
177
|
state.lineage.unshift(this);
|
|
@@ -189,11 +190,11 @@ class FunctionExpression extends Expression {
|
|
|
189
190
|
walk(visitor, options) {
|
|
190
191
|
if (options.walkMode & visitors_1.InternalWalkMode.walkExpressions) {
|
|
191
192
|
for (let i = 0; i < this.parameters.length; i++) {
|
|
192
|
-
visitors_1.walk(this.parameters, i, visitor, options, this);
|
|
193
|
+
(0, visitors_1.walk)(this.parameters, i, visitor, options, this);
|
|
193
194
|
}
|
|
194
195
|
//This is the core of full-program walking...it allows us to step into sub functions
|
|
195
196
|
if (options.walkMode & visitors_1.InternalWalkMode.recurseChildFunctions) {
|
|
196
|
-
visitors_1.walk(this, 'body', visitor, options);
|
|
197
|
+
(0, visitors_1.walk)(this, 'body', visitor, options);
|
|
197
198
|
}
|
|
198
199
|
}
|
|
199
200
|
}
|
|
@@ -201,9 +202,7 @@ class FunctionExpression extends Expression {
|
|
|
201
202
|
let functionType = new FunctionType_1.FunctionType(this.returnType);
|
|
202
203
|
functionType.isSub = this.functionType.text === 'sub';
|
|
203
204
|
for (let param of this.parameters) {
|
|
204
|
-
|
|
205
|
-
//TODO compute optional parameters
|
|
206
|
-
functionType.addParameter(param.name.text, param.type, isRequired);
|
|
205
|
+
functionType.addParameter(param.name.text, param.type, param.isOptional);
|
|
207
206
|
}
|
|
208
207
|
return functionType;
|
|
209
208
|
}
|
|
@@ -241,16 +240,19 @@ class FunctionParameterExpression extends Expression {
|
|
|
241
240
|
result.push(' ');
|
|
242
241
|
result.push(state.transpileToken(this.asToken));
|
|
243
242
|
result.push(' ');
|
|
244
|
-
result.push(state.sourceNode(this.typeToken, this.type.toTypeString()));
|
|
243
|
+
result.push(state.sourceNode(this.typeToken, this.type.toTypeString(state.typeContext)));
|
|
245
244
|
}
|
|
246
245
|
return result;
|
|
247
246
|
}
|
|
248
247
|
walk(visitor, options) {
|
|
249
248
|
// eslint-disable-next-line no-bitwise
|
|
250
249
|
if (this.defaultValue && options.walkMode & visitors_1.InternalWalkMode.walkExpressions) {
|
|
251
|
-
visitors_1.walk(this, 'defaultValue', visitor, options);
|
|
250
|
+
(0, visitors_1.walk)(this, 'defaultValue', visitor, options);
|
|
252
251
|
}
|
|
253
252
|
}
|
|
253
|
+
get isOptional() {
|
|
254
|
+
return !!this.defaultValue;
|
|
255
|
+
}
|
|
254
256
|
}
|
|
255
257
|
exports.FunctionParameterExpression = FunctionParameterExpression;
|
|
256
258
|
class NamespacedVariableNameExpression extends Expression {
|
|
@@ -268,20 +270,20 @@ class NamespacedVariableNameExpression extends Expression {
|
|
|
268
270
|
}
|
|
269
271
|
getNameParts() {
|
|
270
272
|
let parts = [];
|
|
271
|
-
if (reflection_1.isVariableExpression(this.expression)) {
|
|
273
|
+
if ((0, reflection_1.isVariableExpression)(this.expression)) {
|
|
272
274
|
parts.push(this.expression.name.text);
|
|
273
275
|
}
|
|
274
276
|
else {
|
|
275
277
|
let expr = this.expression;
|
|
276
278
|
parts.push(expr.name.text);
|
|
277
|
-
while (reflection_1.isVariableExpression(expr) === false) {
|
|
279
|
+
while ((0, reflection_1.isVariableExpression)(expr) === false) {
|
|
278
280
|
expr = expr.obj;
|
|
279
281
|
parts.unshift(expr.name.text);
|
|
280
282
|
}
|
|
281
283
|
}
|
|
282
284
|
return parts;
|
|
283
285
|
}
|
|
284
|
-
getName(parseMode) {
|
|
286
|
+
getName(parseMode = Parser_1.ParseMode.BrighterScript) {
|
|
285
287
|
if (parseMode === Parser_1.ParseMode.BrighterScript) {
|
|
286
288
|
return this.getNameParts().join('.');
|
|
287
289
|
}
|
|
@@ -291,7 +293,7 @@ class NamespacedVariableNameExpression extends Expression {
|
|
|
291
293
|
}
|
|
292
294
|
walk(visitor, options) {
|
|
293
295
|
if (options.walkMode & visitors_1.InternalWalkMode.walkExpressions) {
|
|
294
|
-
visitors_1.walk(this, 'expression', visitor, options);
|
|
296
|
+
(0, visitors_1.walk)(this, 'expression', visitor, options);
|
|
295
297
|
}
|
|
296
298
|
}
|
|
297
299
|
}
|
|
@@ -319,7 +321,7 @@ class DottedGetExpression extends Expression {
|
|
|
319
321
|
}
|
|
320
322
|
walk(visitor, options) {
|
|
321
323
|
if (options.walkMode & visitors_1.InternalWalkMode.walkExpressions) {
|
|
322
|
-
visitors_1.walk(this, 'obj', visitor, options);
|
|
324
|
+
(0, visitors_1.walk)(this, 'obj', visitor, options);
|
|
323
325
|
}
|
|
324
326
|
}
|
|
325
327
|
}
|
|
@@ -341,7 +343,7 @@ class XmlAttributeGetExpression extends Expression {
|
|
|
341
343
|
}
|
|
342
344
|
walk(visitor, options) {
|
|
343
345
|
if (options.walkMode & visitors_1.InternalWalkMode.walkExpressions) {
|
|
344
|
-
visitors_1.walk(this, 'obj', visitor, options);
|
|
346
|
+
(0, visitors_1.walk)(this, 'obj', visitor, options);
|
|
345
347
|
}
|
|
346
348
|
}
|
|
347
349
|
}
|
|
@@ -365,8 +367,8 @@ class IndexedGetExpression extends Expression {
|
|
|
365
367
|
}
|
|
366
368
|
walk(visitor, options) {
|
|
367
369
|
if (options.walkMode & visitors_1.InternalWalkMode.walkExpressions) {
|
|
368
|
-
visitors_1.walk(this, 'obj', visitor, options);
|
|
369
|
-
visitors_1.walk(this, 'index', visitor, options);
|
|
370
|
+
(0, visitors_1.walk)(this, 'obj', visitor, options);
|
|
371
|
+
(0, visitors_1.walk)(this, 'index', visitor, options);
|
|
370
372
|
}
|
|
371
373
|
}
|
|
372
374
|
}
|
|
@@ -387,7 +389,7 @@ class GroupingExpression extends Expression {
|
|
|
387
389
|
}
|
|
388
390
|
walk(visitor, options) {
|
|
389
391
|
if (options.walkMode & visitors_1.InternalWalkMode.walkExpressions) {
|
|
390
|
-
visitors_1.walk(this, 'expression', visitor, options);
|
|
392
|
+
(0, visitors_1.walk)(this, 'expression', visitor, options);
|
|
391
393
|
}
|
|
392
394
|
}
|
|
393
395
|
}
|
|
@@ -407,7 +409,7 @@ class LiteralExpression extends Expression {
|
|
|
407
409
|
//wrap quasis with quotes (and escape inner quotemarks)
|
|
408
410
|
text = `"${this.token.text.replace(/"/g, '""')}"`;
|
|
409
411
|
}
|
|
410
|
-
else if (reflection_1.isStringType(this.type)) {
|
|
412
|
+
else if ((0, reflection_1.isStringType)(this.type)) {
|
|
411
413
|
text = this.token.text;
|
|
412
414
|
//add trailing quotemark if it's missing. We will have already generated a diagnostic for this.
|
|
413
415
|
if (text.endsWith('"') === false) {
|
|
@@ -463,7 +465,7 @@ class ArrayLiteralExpression extends Expression {
|
|
|
463
465
|
for (let i = 0; i < this.elements.length; i++) {
|
|
464
466
|
let previousElement = this.elements[i - 1];
|
|
465
467
|
let element = this.elements[i];
|
|
466
|
-
if (reflection_1.isCommentStatement(element)) {
|
|
468
|
+
if ((0, reflection_1.isCommentStatement)(element)) {
|
|
467
469
|
//if the comment is on the same line as opening square or previous statement, don't add newline
|
|
468
470
|
if (util_1.default.linesTouch(this.open, element) || util_1.default.linesTouch(previousElement, element)) {
|
|
469
471
|
result.push(' ');
|
|
@@ -482,7 +484,7 @@ class ArrayLiteralExpression extends Expression {
|
|
|
482
484
|
for (let j = i + 1; j < this.elements.length; j++) {
|
|
483
485
|
let el = this.elements[j];
|
|
484
486
|
//add a comma if there will be another element after this
|
|
485
|
-
if (reflection_1.isCommentStatement(el) === false) {
|
|
487
|
+
if ((0, reflection_1.isCommentStatement)(el) === false) {
|
|
486
488
|
result.push(',');
|
|
487
489
|
break;
|
|
488
490
|
}
|
|
@@ -501,7 +503,7 @@ class ArrayLiteralExpression extends Expression {
|
|
|
501
503
|
walk(visitor, options) {
|
|
502
504
|
if (options.walkMode & visitors_1.InternalWalkMode.walkExpressions) {
|
|
503
505
|
for (let i = 0; i < this.elements.length; i++) {
|
|
504
|
-
visitors_1.walk(this.elements, i, visitor, options, this);
|
|
506
|
+
(0, visitors_1.walk)(this.elements, i, visitor, options, this);
|
|
505
507
|
}
|
|
506
508
|
}
|
|
507
509
|
}
|
|
@@ -510,11 +512,12 @@ exports.ArrayLiteralExpression = ArrayLiteralExpression;
|
|
|
510
512
|
class AAMemberExpression extends Expression {
|
|
511
513
|
constructor(keyToken, colonToken,
|
|
512
514
|
/** The expression evaluated to determine the member's initial value. */
|
|
513
|
-
value) {
|
|
515
|
+
value, type) {
|
|
514
516
|
super();
|
|
515
517
|
this.keyToken = keyToken;
|
|
516
518
|
this.colonToken = colonToken;
|
|
517
519
|
this.value = value;
|
|
520
|
+
this.type = type;
|
|
518
521
|
this.range = util_1.default.createRangeFromPositions(keyToken.range.start, this.value.range.end);
|
|
519
522
|
}
|
|
520
523
|
transpile(state) {
|
|
@@ -522,17 +525,30 @@ class AAMemberExpression extends Expression {
|
|
|
522
525
|
return [];
|
|
523
526
|
}
|
|
524
527
|
walk(visitor, options) {
|
|
525
|
-
visitors_1.walk(this, 'value', visitor, options);
|
|
528
|
+
(0, visitors_1.walk)(this, 'value', visitor, options);
|
|
526
529
|
}
|
|
527
530
|
}
|
|
528
531
|
exports.AAMemberExpression = AAMemberExpression;
|
|
529
532
|
class AALiteralExpression extends Expression {
|
|
530
|
-
constructor(elements, open, close) {
|
|
533
|
+
constructor(elements, open, close, functionExpression) {
|
|
531
534
|
super();
|
|
532
535
|
this.elements = elements;
|
|
533
536
|
this.open = open;
|
|
534
537
|
this.close = close;
|
|
538
|
+
this.functionExpression = functionExpression;
|
|
539
|
+
this.symbolTable = new SymbolTable_1.SymbolTable();
|
|
540
|
+
this.memberTable = new SymbolTable_1.SymbolTable();
|
|
535
541
|
this.range = util_1.default.createRangeFromPositions(this.open.range.start, this.close.range.end);
|
|
542
|
+
this.buildSymbolTable();
|
|
543
|
+
}
|
|
544
|
+
buildSymbolTable() {
|
|
545
|
+
this.symbolTable.clear();
|
|
546
|
+
this.symbolTable.addSymbol('m', { start: this.open.range.start, end: this.close.range.end }, new ObjectType_1.ObjectType(this.memberTable));
|
|
547
|
+
for (const element of this.elements) {
|
|
548
|
+
if ((0, reflection_1.isAAMemberExpression)(element)) {
|
|
549
|
+
this.memberTable.addSymbol(element.keyToken.text, element.keyToken.range, (0, Parser_1.getBscTypeFromExpression)(element.value, this.functionExpression));
|
|
550
|
+
}
|
|
551
|
+
}
|
|
536
552
|
}
|
|
537
553
|
transpile(state) {
|
|
538
554
|
let result = [];
|
|
@@ -540,7 +556,7 @@ class AALiteralExpression extends Expression {
|
|
|
540
556
|
result.push(state.transpileToken(this.open));
|
|
541
557
|
let hasChildren = this.elements.length > 0;
|
|
542
558
|
//add newline if the object has children and the first child isn't a comment starting on the same line as opening curly
|
|
543
|
-
if (hasChildren && (reflection_1.isCommentStatement(this.elements[0]) === false || !util_1.default.linesTouch(this.elements[0], this.open))) {
|
|
559
|
+
if (hasChildren && ((0, reflection_1.isCommentStatement)(this.elements[0]) === false || !util_1.default.linesTouch(this.elements[0], this.open))) {
|
|
544
560
|
result.push('\n');
|
|
545
561
|
}
|
|
546
562
|
state.blockDepth++;
|
|
@@ -549,7 +565,7 @@ class AALiteralExpression extends Expression {
|
|
|
549
565
|
let previousElement = this.elements[i - 1];
|
|
550
566
|
let nextElement = this.elements[i + 1];
|
|
551
567
|
//don't indent if comment is same-line
|
|
552
|
-
if (reflection_1.isCommentStatement(element) &&
|
|
568
|
+
if ((0, reflection_1.isCommentStatement)(element) &&
|
|
553
569
|
(util_1.default.linesTouch(this.open, element) || util_1.default.linesTouch(previousElement, element))) {
|
|
554
570
|
result.push(' ');
|
|
555
571
|
//indent line
|
|
@@ -558,7 +574,7 @@ class AALiteralExpression extends Expression {
|
|
|
558
574
|
result.push(state.indent());
|
|
559
575
|
}
|
|
560
576
|
//render comments
|
|
561
|
-
if (reflection_1.isCommentStatement(element)) {
|
|
577
|
+
if ((0, reflection_1.isCommentStatement)(element)) {
|
|
562
578
|
result.push(...element.transpile(state));
|
|
563
579
|
}
|
|
564
580
|
else {
|
|
@@ -569,7 +585,7 @@ class AALiteralExpression extends Expression {
|
|
|
569
585
|
//determine if comments are the only members left in the array
|
|
570
586
|
let onlyCommentsRemaining = true;
|
|
571
587
|
for (let j = i + 1; j < this.elements.length; j++) {
|
|
572
|
-
if (reflection_1.isCommentStatement(this.elements[j]) === false) {
|
|
588
|
+
if ((0, reflection_1.isCommentStatement)(this.elements[j]) === false) {
|
|
573
589
|
onlyCommentsRemaining = false;
|
|
574
590
|
break;
|
|
575
591
|
}
|
|
@@ -582,7 +598,7 @@ class AALiteralExpression extends Expression {
|
|
|
582
598
|
}
|
|
583
599
|
}
|
|
584
600
|
//if next element is a same-line comment, skip the newline
|
|
585
|
-
if (nextElement && reflection_1.isCommentStatement(nextElement) && nextElement.range.start.line === element.range.start.line) {
|
|
601
|
+
if (nextElement && (0, reflection_1.isCommentStatement)(nextElement) && nextElement.range.start.line === element.range.start.line) {
|
|
586
602
|
//add a newline between statements
|
|
587
603
|
}
|
|
588
604
|
else {
|
|
@@ -601,11 +617,11 @@ class AALiteralExpression extends Expression {
|
|
|
601
617
|
walk(visitor, options) {
|
|
602
618
|
if (options.walkMode & visitors_1.InternalWalkMode.walkExpressions) {
|
|
603
619
|
for (let i = 0; i < this.elements.length; i++) {
|
|
604
|
-
if (reflection_1.isCommentStatement(this.elements[i])) {
|
|
605
|
-
visitors_1.walk(this.elements, i, visitor, options, this);
|
|
620
|
+
if ((0, reflection_1.isCommentStatement)(this.elements[i])) {
|
|
621
|
+
(0, visitors_1.walk)(this.elements, i, visitor, options, this);
|
|
606
622
|
}
|
|
607
623
|
else {
|
|
608
|
-
visitors_1.walk(this.elements, i, visitor, options, this);
|
|
624
|
+
(0, visitors_1.walk)(this.elements, i, visitor, options, this);
|
|
609
625
|
}
|
|
610
626
|
}
|
|
611
627
|
}
|
|
@@ -628,7 +644,7 @@ class UnaryExpression extends Expression {
|
|
|
628
644
|
}
|
|
629
645
|
walk(visitor, options) {
|
|
630
646
|
if (options.walkMode & visitors_1.InternalWalkMode.walkExpressions) {
|
|
631
|
-
visitors_1.walk(this, 'right', visitor, options);
|
|
647
|
+
(0, visitors_1.walk)(this, 'right', visitor, options);
|
|
632
648
|
}
|
|
633
649
|
}
|
|
634
650
|
}
|
|
@@ -687,7 +703,8 @@ class SourceLiteralExpression extends Expression {
|
|
|
687
703
|
let text;
|
|
688
704
|
switch (this.token.kind) {
|
|
689
705
|
case lexer_1.TokenKind.SourceFilePathLiteral:
|
|
690
|
-
|
|
706
|
+
const pathUrl = fileUrl(state.srcPath);
|
|
707
|
+
text = `"${pathUrl.substring(0, 4)}" + "${pathUrl.substring(4)}"`;
|
|
691
708
|
break;
|
|
692
709
|
case lexer_1.TokenKind.SourceLineNumLiteral:
|
|
693
710
|
text = `${this.token.range.start.line + 1}`;
|
|
@@ -699,19 +716,14 @@ class SourceLiteralExpression extends Expression {
|
|
|
699
716
|
text = `"${this.getFunctionName(state, Parser_1.ParseMode.BrighterScript)}"`;
|
|
700
717
|
break;
|
|
701
718
|
case lexer_1.TokenKind.SourceLocationLiteral:
|
|
702
|
-
|
|
719
|
+
const locationUrl = fileUrl(state.srcPath);
|
|
720
|
+
text = `"${locationUrl.substring(0, 4)}" + "${locationUrl.substring(4)}:${this.token.range.start.line + 1}"`;
|
|
703
721
|
break;
|
|
704
722
|
case lexer_1.TokenKind.PkgPathLiteral:
|
|
705
|
-
|
|
706
|
-
.replace(/\\/g, '/')
|
|
707
|
-
.replace(/\.bs$/i, '.brs');
|
|
708
|
-
text = `"${pkgPath1}"`;
|
|
723
|
+
text = `"${state.file.pkgPath.replace(/\.bs$/i, '.brs')}"`;
|
|
709
724
|
break;
|
|
710
725
|
case lexer_1.TokenKind.PkgLocationLiteral:
|
|
711
|
-
|
|
712
|
-
.replace(/\\/g, '/')
|
|
713
|
-
.replace(/\.bs$/i, '.brs');
|
|
714
|
-
text = `"${pkgPath2}:" + str(LINE_NUM)`;
|
|
726
|
+
text = `"${state.file.pkgPath.replace(/\.bs$/i, '.brs')}:" + str(LINE_NUM)`;
|
|
715
727
|
break;
|
|
716
728
|
case lexer_1.TokenKind.LineNumLiteral:
|
|
717
729
|
default:
|
|
@@ -760,7 +772,7 @@ class NewExpression extends Expression {
|
|
|
760
772
|
}
|
|
761
773
|
walk(visitor, options) {
|
|
762
774
|
if (options.walkMode & visitors_1.InternalWalkMode.walkExpressions) {
|
|
763
|
-
visitors_1.walk(this, 'call', visitor, options);
|
|
775
|
+
(0, visitors_1.walk)(this, 'call', visitor, options);
|
|
764
776
|
}
|
|
765
777
|
}
|
|
766
778
|
}
|
|
@@ -802,9 +814,9 @@ class CallfuncExpression extends Expression {
|
|
|
802
814
|
}
|
|
803
815
|
walk(visitor, options) {
|
|
804
816
|
if (options.walkMode & visitors_1.InternalWalkMode.walkExpressions) {
|
|
805
|
-
visitors_1.walk(this, 'callee', visitor, options);
|
|
817
|
+
(0, visitors_1.walk)(this, 'callee', visitor, options);
|
|
806
818
|
for (let i = 0; i < this.args.length; i++) {
|
|
807
|
-
visitors_1.walk(this.args, i, visitor, options, this);
|
|
819
|
+
(0, visitors_1.walk)(this.args, i, visitor, options, this);
|
|
808
820
|
}
|
|
809
821
|
}
|
|
810
822
|
}
|
|
@@ -837,7 +849,7 @@ class TemplateStringQuasiExpression extends Expression {
|
|
|
837
849
|
walk(visitor, options) {
|
|
838
850
|
if (options.walkMode & visitors_1.InternalWalkMode.walkExpressions) {
|
|
839
851
|
for (let i = 0; i < this.expressions.length; i++) {
|
|
840
|
-
visitors_1.walk(this.expressions, i, visitor, options, this);
|
|
852
|
+
(0, visitors_1.walk)(this.expressions, i, visitor, options, this);
|
|
841
853
|
}
|
|
842
854
|
}
|
|
843
855
|
}
|
|
@@ -874,8 +886,8 @@ class TemplateStringExpression extends Expression {
|
|
|
874
886
|
add(...quasi.transpile(state));
|
|
875
887
|
if (expression) {
|
|
876
888
|
//skip the toString wrapper around certain expressions
|
|
877
|
-
if (reflection_1.isEscapedCharCodeLiteralExpression(expression) ||
|
|
878
|
-
(reflection_1.isLiteralExpression(expression) && reflection_1.isStringType(expression.type))) {
|
|
889
|
+
if ((0, reflection_1.isEscapedCharCodeLiteralExpression)(expression) ||
|
|
890
|
+
((0, reflection_1.isLiteralExpression)(expression) && (0, reflection_1.isStringType)(expression.type))) {
|
|
879
891
|
add(...expression.transpile(state));
|
|
880
892
|
//wrap all other expressions with a bslib_toString call to prevent runtime type mismatch errors
|
|
881
893
|
}
|
|
@@ -890,10 +902,10 @@ class TemplateStringExpression extends Expression {
|
|
|
890
902
|
if (options.walkMode & visitors_1.InternalWalkMode.walkExpressions) {
|
|
891
903
|
//walk the quasis and expressions in left-to-right order
|
|
892
904
|
for (let i = 0; i < this.quasis.length; i++) {
|
|
893
|
-
visitors_1.walk(this.quasis, i, visitor, options, this);
|
|
905
|
+
(0, visitors_1.walk)(this.quasis, i, visitor, options, this);
|
|
894
906
|
//this skips the final loop iteration since we'll always have one more quasi than expression
|
|
895
907
|
if (this.expressions[i]) {
|
|
896
|
-
visitors_1.walk(this.expressions, i, visitor, options, this);
|
|
908
|
+
(0, visitors_1.walk)(this.expressions, i, visitor, options, this);
|
|
897
909
|
}
|
|
898
910
|
}
|
|
899
911
|
}
|
|
@@ -938,10 +950,10 @@ class TaggedTemplateStringExpression extends Expression {
|
|
|
938
950
|
if (options.walkMode & visitors_1.InternalWalkMode.walkExpressions) {
|
|
939
951
|
//walk the quasis and expressions in left-to-right order
|
|
940
952
|
for (let i = 0; i < this.quasis.length; i++) {
|
|
941
|
-
visitors_1.walk(this.quasis, i, visitor, options, this);
|
|
953
|
+
(0, visitors_1.walk)(this.quasis, i, visitor, options, this);
|
|
942
954
|
//this skips the final loop iteration since we'll always have one more quasi than expression
|
|
943
955
|
if (this.expressions[i]) {
|
|
944
|
-
visitors_1.walk(this.expressions, i, visitor, options, this);
|
|
956
|
+
(0, visitors_1.walk)(this.expressions, i, visitor, options, this);
|
|
945
957
|
}
|
|
946
958
|
}
|
|
947
959
|
}
|
|
@@ -1020,9 +1032,9 @@ class TernaryExpression extends Expression {
|
|
|
1020
1032
|
}
|
|
1021
1033
|
walk(visitor, options) {
|
|
1022
1034
|
if (options.walkMode & visitors_1.InternalWalkMode.walkExpressions) {
|
|
1023
|
-
visitors_1.walk(this, 'test', visitor, options);
|
|
1024
|
-
visitors_1.walk(this, 'consequent', visitor, options);
|
|
1025
|
-
visitors_1.walk(this, 'alternate', visitor, options);
|
|
1035
|
+
(0, visitors_1.walk)(this, 'test', visitor, options);
|
|
1036
|
+
(0, visitors_1.walk)(this, 'consequent', visitor, options);
|
|
1037
|
+
(0, visitors_1.walk)(this, 'alternate', visitor, options);
|
|
1026
1038
|
}
|
|
1027
1039
|
}
|
|
1028
1040
|
}
|
|
@@ -1045,7 +1057,7 @@ class NullCoalescingExpression extends Expression {
|
|
|
1045
1057
|
let hasMutatingExpression = [
|
|
1046
1058
|
...consequentInfo.expressions,
|
|
1047
1059
|
...alternateInfo.expressions
|
|
1048
|
-
].find(e => reflection_1.isCallExpression(e) || reflection_1.isCallfuncExpression(e) || reflection_1.isDottedGetExpression(e));
|
|
1060
|
+
].find(e => (0, reflection_1.isCallExpression)(e) || (0, reflection_1.isCallfuncExpression)(e) || (0, reflection_1.isDottedGetExpression)(e));
|
|
1049
1061
|
if (hasMutatingExpression) {
|
|
1050
1062
|
result.push(`(function(`,
|
|
1051
1063
|
//write all the scope variables as parameters.
|
|
@@ -1064,37 +1076,74 @@ class NullCoalescingExpression extends Expression {
|
|
|
1064
1076
|
}
|
|
1065
1077
|
walk(visitor, options) {
|
|
1066
1078
|
if (options.walkMode & visitors_1.InternalWalkMode.walkExpressions) {
|
|
1067
|
-
visitors_1.walk(this, 'consequent', visitor, options);
|
|
1068
|
-
visitors_1.walk(this, 'alternate', visitor, options);
|
|
1079
|
+
(0, visitors_1.walk)(this, 'consequent', visitor, options);
|
|
1080
|
+
(0, visitors_1.walk)(this, 'alternate', visitor, options);
|
|
1069
1081
|
}
|
|
1070
1082
|
}
|
|
1071
1083
|
}
|
|
1072
1084
|
exports.NullCoalescingExpression = NullCoalescingExpression;
|
|
1085
|
+
class RegexLiteralExpression extends Expression {
|
|
1086
|
+
constructor(tokens) {
|
|
1087
|
+
super();
|
|
1088
|
+
this.tokens = tokens;
|
|
1089
|
+
}
|
|
1090
|
+
get range() {
|
|
1091
|
+
return this.tokens.regexLiteral.range;
|
|
1092
|
+
}
|
|
1093
|
+
transpile(state) {
|
|
1094
|
+
var _a, _b;
|
|
1095
|
+
let text = (_b = (_a = this.tokens.regexLiteral) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : '';
|
|
1096
|
+
let flags = '';
|
|
1097
|
+
//get any flags from the end
|
|
1098
|
+
const flagMatch = /\/([a-z]+)$/i.exec(text);
|
|
1099
|
+
if (flagMatch) {
|
|
1100
|
+
text = text.substring(0, flagMatch.index + 1);
|
|
1101
|
+
flags = flagMatch[1];
|
|
1102
|
+
}
|
|
1103
|
+
let pattern = text
|
|
1104
|
+
//remove leading and trailing slashes
|
|
1105
|
+
.substring(1, text.length - 1)
|
|
1106
|
+
//escape quotemarks
|
|
1107
|
+
.split('"').join('" + chr(34) + "');
|
|
1108
|
+
return [
|
|
1109
|
+
state.sourceNode(this.tokens.regexLiteral, [
|
|
1110
|
+
'CreateObject("roRegex", ',
|
|
1111
|
+
`"${pattern}", `,
|
|
1112
|
+
`"${flags}"`,
|
|
1113
|
+
')'
|
|
1114
|
+
])
|
|
1115
|
+
];
|
|
1116
|
+
}
|
|
1117
|
+
walk(visitor, options) {
|
|
1118
|
+
//nothing to walk
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
exports.RegexLiteralExpression = RegexLiteralExpression;
|
|
1073
1122
|
function expressionToValue(expr, strict) {
|
|
1074
1123
|
if (!expr) {
|
|
1075
1124
|
return null;
|
|
1076
1125
|
}
|
|
1077
|
-
if (reflection_1.isUnaryExpression(expr) && reflection_1.isLiteralNumber(expr.right)) {
|
|
1126
|
+
if ((0, reflection_1.isUnaryExpression)(expr) && (0, reflection_1.isLiteralNumber)(expr.right)) {
|
|
1078
1127
|
return numberExpressionToValue(expr.right, expr.operator.text);
|
|
1079
1128
|
}
|
|
1080
|
-
if (reflection_1.isLiteralString(expr)) {
|
|
1129
|
+
if ((0, reflection_1.isLiteralString)(expr)) {
|
|
1081
1130
|
//remove leading and trailing quotes
|
|
1082
1131
|
return expr.token.text.replace(/^"/, '').replace(/"$/, '');
|
|
1083
1132
|
}
|
|
1084
|
-
if (reflection_1.isLiteralNumber(expr)) {
|
|
1133
|
+
if ((0, reflection_1.isLiteralNumber)(expr)) {
|
|
1085
1134
|
return numberExpressionToValue(expr);
|
|
1086
1135
|
}
|
|
1087
|
-
if (reflection_1.isLiteralBoolean(expr)) {
|
|
1136
|
+
if ((0, reflection_1.isLiteralBoolean)(expr)) {
|
|
1088
1137
|
return expr.token.text.toLowerCase() === 'true';
|
|
1089
1138
|
}
|
|
1090
|
-
if (reflection_1.isArrayLiteralExpression(expr)) {
|
|
1139
|
+
if ((0, reflection_1.isArrayLiteralExpression)(expr)) {
|
|
1091
1140
|
return expr.elements
|
|
1092
|
-
.filter(e => !reflection_1.isCommentStatement(e))
|
|
1141
|
+
.filter(e => !(0, reflection_1.isCommentStatement)(e))
|
|
1093
1142
|
.map(e => expressionToValue(e, strict));
|
|
1094
1143
|
}
|
|
1095
|
-
if (reflection_1.isAALiteralExpression(expr)) {
|
|
1144
|
+
if ((0, reflection_1.isAALiteralExpression)(expr)) {
|
|
1096
1145
|
return expr.elements.reduce((acc, e) => {
|
|
1097
|
-
if (!reflection_1.isCommentStatement(e)) {
|
|
1146
|
+
if (!(0, reflection_1.isCommentStatement)(e)) {
|
|
1098
1147
|
acc[e.keyToken.text] = expressionToValue(e.value, strict);
|
|
1099
1148
|
}
|
|
1100
1149
|
return acc;
|
|
@@ -1103,7 +1152,7 @@ function expressionToValue(expr, strict) {
|
|
|
1103
1152
|
return strict ? null : expr;
|
|
1104
1153
|
}
|
|
1105
1154
|
function numberExpressionToValue(expr, operator = '') {
|
|
1106
|
-
if (reflection_1.isIntegerType(expr.type) || reflection_1.isLongIntegerType(expr.type)) {
|
|
1155
|
+
if ((0, reflection_1.isIntegerType)(expr.type) || (0, reflection_1.isLongIntegerType)(expr.type)) {
|
|
1107
1156
|
return parseInt(operator + expr.token.text);
|
|
1108
1157
|
}
|
|
1109
1158
|
else {
|