brighterscript 1.0.0-alpha.25 → 1.0.0-alpha.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/bsconfig.schema.json +5 -0
  3. package/dist/AstValidationSegmenter.js +4 -4
  4. package/dist/AstValidationSegmenter.js.map +1 -1
  5. package/dist/BsConfig.d.ts +1 -0
  6. package/dist/Program.d.ts +1 -1
  7. package/dist/Program.js +18 -19
  8. package/dist/Program.js.map +1 -1
  9. package/dist/Scope.d.ts +0 -5
  10. package/dist/Scope.js +8 -14
  11. package/dist/Scope.js.map +1 -1
  12. package/dist/XmlScope.d.ts +0 -5
  13. package/dist/XmlScope.js +3 -21
  14. package/dist/XmlScope.js.map +1 -1
  15. package/dist/astUtils/CachedLookups.js +3 -3
  16. package/dist/astUtils/CachedLookups.js.map +1 -1
  17. package/dist/astUtils/Editor.spec.js +1 -1
  18. package/dist/astUtils/Editor.spec.js.map +1 -1
  19. package/dist/astUtils/creators.js +32 -12
  20. package/dist/astUtils/creators.js.map +1 -1
  21. package/dist/astUtils/creators.spec.js +4 -4
  22. package/dist/astUtils/creators.spec.js.map +1 -1
  23. package/dist/astUtils/reflection.d.ts +1 -1
  24. package/dist/astUtils/reflection.js +1 -1
  25. package/dist/astUtils/reflection.js.map +1 -1
  26. package/dist/astUtils/reflection.spec.js +59 -42
  27. package/dist/astUtils/reflection.spec.js.map +1 -1
  28. package/dist/astUtils/visitors.spec.js +30 -19
  29. package/dist/astUtils/visitors.spec.js.map +1 -1
  30. package/dist/bscPlugin/BscPlugin.d.ts +2 -1
  31. package/dist/bscPlugin/BscPlugin.js +7 -3
  32. package/dist/bscPlugin/BscPlugin.js.map +1 -1
  33. package/dist/bscPlugin/CallExpressionInfo.js +7 -7
  34. package/dist/bscPlugin/CallExpressionInfo.js.map +1 -1
  35. package/dist/bscPlugin/SignatureHelpUtil.js +5 -4
  36. package/dist/bscPlugin/SignatureHelpUtil.js.map +1 -1
  37. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +2 -2
  38. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
  39. package/dist/bscPlugin/completions/CompletionsProcessor.js +3 -3
  40. package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
  41. package/dist/bscPlugin/definition/DefinitionProvider.d.ts +13 -0
  42. package/dist/bscPlugin/definition/DefinitionProvider.js +210 -0
  43. package/dist/bscPlugin/definition/DefinitionProvider.js.map +1 -0
  44. package/dist/bscPlugin/definition/DefinitionProvider.spec.d.ts +1 -0
  45. package/dist/bscPlugin/definition/DefinitionProvider.spec.js +88 -0
  46. package/dist/bscPlugin/definition/DefinitionProvider.spec.js.map +1 -0
  47. package/dist/bscPlugin/hover/HoverProcessor.js +2 -2
  48. package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
  49. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +0 -2
  50. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
  51. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js +8 -6
  52. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -1
  53. package/dist/bscPlugin/validation/BrsFileValidator.js +28 -28
  54. package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
  55. package/dist/bscPlugin/validation/ScopeValidator.d.ts +4 -0
  56. package/dist/bscPlugin/validation/ScopeValidator.js +51 -20
  57. package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
  58. package/dist/bscPlugin/validation/ScopeValidator.spec.js +73 -0
  59. package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -1
  60. package/dist/files/BrsFile.Class.spec.js +3 -3
  61. package/dist/files/BrsFile.Class.spec.js.map +1 -1
  62. package/dist/files/BrsFile.d.ts +4 -11
  63. package/dist/files/BrsFile.js +39 -206
  64. package/dist/files/BrsFile.js.map +1 -1
  65. package/dist/files/BrsFile.spec.js +56 -2
  66. package/dist/files/BrsFile.spec.js.map +1 -1
  67. package/dist/interfaces.d.ts +32 -1
  68. package/dist/interfaces.js.map +1 -1
  69. package/dist/parser/AstNode.spec.js +6 -6
  70. package/dist/parser/AstNode.spec.js.map +1 -1
  71. package/dist/parser/Expression.d.ts +288 -145
  72. package/dist/parser/Expression.js +310 -271
  73. package/dist/parser/Expression.js.map +1 -1
  74. package/dist/parser/Parser.Class.spec.js +11 -11
  75. package/dist/parser/Parser.Class.spec.js.map +1 -1
  76. package/dist/parser/Parser.d.ts +5 -0
  77. package/dist/parser/Parser.js +315 -120
  78. package/dist/parser/Parser.js.map +1 -1
  79. package/dist/parser/Parser.spec.js +42 -185
  80. package/dist/parser/Parser.spec.js.map +1 -1
  81. package/dist/parser/Statement.d.ts +332 -188
  82. package/dist/parser/Statement.js +475 -364
  83. package/dist/parser/Statement.js.map +1 -1
  84. package/dist/parser/Statement.spec.js +2 -2
  85. package/dist/parser/Statement.spec.js.map +1 -1
  86. package/dist/parser/tests/controlFlow/For.spec.js +1 -1
  87. package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
  88. package/dist/parser/tests/controlFlow/ForEach.spec.js +2 -2
  89. package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
  90. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +1 -1
  91. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +1 -1
  92. package/dist/parser/tests/expression/Call.spec.js +11 -11
  93. package/dist/parser/tests/expression/Call.spec.js.map +1 -1
  94. package/dist/parser/tests/expression/Indexing.spec.js +30 -5
  95. package/dist/parser/tests/expression/Indexing.spec.js.map +1 -1
  96. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +2 -2
  97. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
  98. package/dist/parser/tests/expression/TernaryExpression.spec.js +2 -2
  99. package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
  100. package/dist/parser/tests/statement/ConstStatement.spec.js +1 -1
  101. package/dist/parser/tests/statement/ConstStatement.spec.js.map +1 -1
  102. package/dist/parser/tests/statement/Dim.spec.js +8 -8
  103. package/dist/parser/tests/statement/Dim.spec.js.map +1 -1
  104. package/dist/parser/tests/statement/Enum.spec.js +2 -2
  105. package/dist/parser/tests/statement/Enum.spec.js.map +1 -1
  106. package/dist/parser/tests/statement/LibraryStatement.spec.js +2 -2
  107. package/dist/parser/tests/statement/LibraryStatement.spec.js.map +1 -1
  108. package/dist/parser/tests/statement/Misc.spec.js +2 -2
  109. package/dist/parser/tests/statement/Misc.spec.js.map +1 -1
  110. package/dist/parser/tests/statement/PrintStatement.spec.js +1 -1
  111. package/dist/parser/tests/statement/TryCatch.spec.js +1 -1
  112. package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
  113. package/dist/types/BuiltInInterfaceAdder.js +11 -4
  114. package/dist/types/BuiltInInterfaceAdder.js.map +1 -1
  115. package/dist/util.d.ts +17 -8
  116. package/dist/util.js +96 -51
  117. package/dist/util.js.map +1 -1
  118. package/dist/validators/ClassValidator.js +6 -6
  119. package/dist/validators/ClassValidator.js.map +1 -1
  120. package/package.json +1 -1
@@ -9,33 +9,35 @@ const visitors_1 = require("../astUtils/visitors");
9
9
  const visitors_2 = require("../astUtils/visitors");
10
10
  const reflection_1 = require("../astUtils/reflection");
11
11
  const interfaces_1 = require("../interfaces");
12
+ const VoidType_1 = require("../types/VoidType");
13
+ const DynamicType_1 = require("../types/DynamicType");
12
14
  const SymbolTable_1 = require("../SymbolTable");
13
15
  const TypedFunctionType_1 = require("../types/TypedFunctionType");
14
16
  const AstNode_1 = require("./AstNode");
15
17
  const SymbolTable_2 = require("../SymbolTable");
16
18
  const source_map_1 = require("source-map");
17
19
  const StringType_1 = require("../types/StringType");
18
- const DynamicType_1 = require("../types/DynamicType");
19
- const VoidType_1 = require("../types/VoidType");
20
20
  const ReferenceType_1 = require("../types/ReferenceType");
21
21
  const UnionType_1 = require("../types/UnionType");
22
22
  const types_1 = require("../types");
23
23
  const AssociativeArrayType_1 = require("../types/AssociativeArrayType");
24
24
  const creators_1 = require("../astUtils/creators");
25
25
  class BinaryExpression extends AstNode_1.Expression {
26
- constructor(left, operator, right) {
26
+ constructor(options) {
27
27
  super();
28
- this.left = left;
29
- this.operator = operator;
30
- this.right = right;
31
28
  this.kind = AstNode_1.AstNodeKind.BinaryExpression;
32
- this.range = util_1.default.createRangeFromPositions(this.left.range.start, this.right.range.end);
29
+ this.tokens = {
30
+ operator: options.operator
31
+ };
32
+ this.left = options.left;
33
+ this.right = options.right;
34
+ this.range = util_1.default.createBoundingRange(this.left, this.tokens.operator, this.right);
33
35
  }
34
36
  transpile(state) {
35
37
  return [
36
38
  state.sourceNode(this.left, this.left.transpile(state)),
37
39
  ' ',
38
- state.transpileToken(this.operator),
40
+ state.transpileToken(this.tokens.operator),
39
41
  ' ',
40
42
  state.sourceNode(this.right, this.right.transpile(state))
41
43
  ];
@@ -47,7 +49,7 @@ class BinaryExpression extends AstNode_1.Expression {
47
49
  }
48
50
  }
49
51
  getType(options) {
50
- const operatorKind = this.operator.kind;
52
+ const operatorKind = this.tokens.operator.kind;
51
53
  if (options.flags & SymbolTable_1.SymbolTypeFlag.typetime) {
52
54
  // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
53
55
  switch (operatorKind) {
@@ -57,25 +59,24 @@ class BinaryExpression extends AstNode_1.Expression {
57
59
  }
58
60
  }
59
61
  else if (options.flags & SymbolTable_1.SymbolTypeFlag.runtime) {
60
- return util_1.default.binaryOperatorResultType(this.left.getType(options), this.operator, this.right.getType(options));
62
+ return util_1.default.binaryOperatorResultType(this.left.getType(options), this.tokens.operator, this.right.getType(options));
61
63
  }
62
64
  return DynamicType_1.DynamicType.instance;
63
65
  }
64
66
  }
65
67
  exports.BinaryExpression = BinaryExpression;
66
68
  class CallExpression extends AstNode_1.Expression {
67
- constructor(callee,
68
- /**
69
- * Can either be `(`, or `?(` for optional chaining
70
- */
71
- openingParen, closingParen, args, unused) {
69
+ constructor(options) {
70
+ var _a;
72
71
  super();
73
- this.callee = callee;
74
- this.openingParen = openingParen;
75
- this.closingParen = closingParen;
76
- this.args = args;
77
72
  this.kind = AstNode_1.AstNodeKind.CallExpression;
78
- this.range = util_1.default.createBoundingRange(this.callee, this.openingParen, ...args, this.closingParen);
73
+ this.tokens = {
74
+ openingParen: options.openingParen,
75
+ closingParen: options.closingParen
76
+ };
77
+ this.callee = options.callee;
78
+ this.args = (_a = options.args) !== null && _a !== void 0 ? _a : [];
79
+ this.range = util_1.default.createBoundingRange(this.callee, this.tokens.openingParen, ...this.args, this.tokens.closingParen);
79
80
  }
80
81
  transpile(state, nameOverride) {
81
82
  let result = [];
@@ -86,7 +87,7 @@ class CallExpression extends AstNode_1.Expression {
86
87
  else {
87
88
  result.push(...this.callee.transpile(state));
88
89
  }
89
- result.push(state.transpileToken(this.openingParen));
90
+ result.push(state.transpileToken(this.tokens.openingParen, '('));
90
91
  for (let i = 0; i < this.args.length; i++) {
91
92
  //add comma between args
92
93
  if (i > 0) {
@@ -95,8 +96,8 @@ class CallExpression extends AstNode_1.Expression {
95
96
  let arg = this.args[i];
96
97
  result.push(...arg.transpile(state));
97
98
  }
98
- if (this.closingParen) {
99
- result.push(state.transpileToken(this.closingParen));
99
+ if (this.tokens.closingParen) {
100
+ result.push(state.transpileToken(this.tokens.closingParen));
100
101
  }
101
102
  return result;
102
103
  }
@@ -127,22 +128,25 @@ class CallExpression extends AstNode_1.Expression {
127
128
  exports.CallExpression = CallExpression;
128
129
  CallExpression.MaximumArguments = 32;
129
130
  class FunctionExpression extends AstNode_1.Expression {
130
- constructor(parameters, body, functionType, end, leftParen, rightParen, asToken, returnTypeExpression) {
131
+ constructor(options) {
132
+ var _a;
131
133
  super();
132
- this.parameters = parameters;
133
- this.body = body;
134
- this.functionType = functionType;
135
- this.end = end;
136
- this.leftParen = leftParen;
137
- this.rightParen = rightParen;
138
- this.asToken = asToken;
139
- this.returnTypeExpression = returnTypeExpression;
140
134
  this.kind = AstNode_1.AstNodeKind.FunctionExpression;
141
135
  /**
142
136
  * The list of function calls that are declared within this function scope. This excludes CallExpressions
143
137
  * declared in child functions
144
138
  */
145
139
  this.callExpressions = [];
140
+ this.tokens = {
141
+ functionType: options.functionType,
142
+ leftParen: options.leftParen,
143
+ rightParen: options.rightParen,
144
+ as: options.as,
145
+ endFunctionType: options.endFunctionType
146
+ };
147
+ this.parameters = (_a = options.parameters) !== null && _a !== void 0 ? _a : [];
148
+ this.body = options.body;
149
+ this.returnTypeExpression = options.returnTypeExpression;
146
150
  //if there's a body, and it doesn't have a SymbolTable, assign one
147
151
  if (this.body && !this.body.symbolTable) {
148
152
  this.body.symbolTable = new SymbolTable_2.SymbolTable(`Function Body`);
@@ -151,25 +155,26 @@ class FunctionExpression extends AstNode_1.Expression {
151
155
  }
152
156
  getLeadingTrivia() {
153
157
  var _a, _b;
154
- return (_b = (_a = this.functionType) === null || _a === void 0 ? void 0 : _a.leadingTrivia) !== null && _b !== void 0 ? _b : [];
158
+ return (_b = (_a = this.tokens.functionType) === null || _a === void 0 ? void 0 : _a.leadingTrivia) !== null && _b !== void 0 ? _b : [];
155
159
  }
156
160
  /**
157
161
  * The range of the function, starting at the 'f' in function or 's' in sub (or the open paren if the keyword is missing),
158
162
  * and ending with the last n' in 'end function' or 'b' in 'end sub'
159
163
  */
160
164
  get range() {
161
- return util_1.default.createBoundingRange(this.functionType, this.leftParen, ...this.parameters, this.rightParen, this.asToken, this.returnTypeExpression, this.end);
165
+ return util_1.default.createBoundingRange(this.tokens.functionType, this.tokens.leftParen, ...this.parameters, this.tokens.rightParen, this.tokens.as, this.returnTypeExpression, this.tokens.endFunctionType);
162
166
  }
163
167
  transpile(state, name, includeBody = true) {
168
+ var _a;
164
169
  let results = [];
165
170
  //'function'|'sub'
166
- results.push(state.transpileToken(this.functionType));
171
+ results.push(state.transpileToken(this.tokens.functionType, 'function'));
167
172
  //functionName?
168
173
  if (name) {
169
174
  results.push(' ', state.transpileToken(name));
170
175
  }
171
176
  //leftParen
172
- results.push(state.transpileToken(this.leftParen));
177
+ results.push(state.transpileToken(this.tokens.leftParen));
173
178
  //parameters
174
179
  for (let i = 0; i < this.parameters.length; i++) {
175
180
  let param = this.parameters[i];
@@ -181,12 +186,12 @@ class FunctionExpression extends AstNode_1.Expression {
181
186
  results.push(param.transpile(state));
182
187
  }
183
188
  //right paren
184
- results.push(state.transpileToken(this.rightParen));
189
+ results.push(state.transpileToken(this.tokens.rightParen));
185
190
  //as [Type]
186
- if (this.asToken && !state.options.removeParameterTypes && this.returnTypeExpression) {
191
+ if (!state.options.removeParameterTypes && this.returnTypeExpression) {
187
192
  results.push(' ',
188
193
  //as
189
- state.transpileToken(this.asToken), ' ',
194
+ state.transpileToken(this.tokens.as, 'as'), ' ',
190
195
  //return type
191
196
  ...this.returnTypeExpression.transpile(state));
192
197
  }
@@ -198,36 +203,38 @@ class FunctionExpression extends AstNode_1.Expression {
198
203
  }
199
204
  results.push('\n');
200
205
  //'end sub'|'end function'
201
- results.push(state.indent(), state.transpileToken(this.end));
206
+ results.push(state.indent(), state.transpileToken(this.tokens.endFunctionType, `end ${(_a = this.tokens.functionType) !== null && _a !== void 0 ? _a : 'function'}`));
202
207
  return results;
203
208
  }
204
209
  getTypedef(state) {
205
- var _a, _b, _c, _d, _e;
210
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
206
211
  let results = [
207
212
  new source_map_1.SourceNode(1, 0, null, [
208
213
  //'function'|'sub'
209
- (_a = this.functionType) === null || _a === void 0 ? void 0 : _a.text,
214
+ (_b = (_a = this.tokens.functionType) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : 'function',
210
215
  //functionName?
211
- ...((0, reflection_1.isFunctionStatement)(this.parent) || (0, reflection_1.isMethodStatement)(this.parent) ? [' ', (_c = (_b = this.parent.name) === null || _b === void 0 ? void 0 : _b.text) !== null && _c !== void 0 ? _c : ''] : []),
216
+ ...((0, reflection_1.isFunctionStatement)(this.parent) || (0, reflection_1.isMethodStatement)(this.parent) ? [' ', (_d = (_c = this.parent.tokens.name) === null || _c === void 0 ? void 0 : _c.text) !== null && _d !== void 0 ? _d : ''] : []),
212
217
  //leftParen
213
218
  '(',
214
219
  //parameters
215
- ...((_e = (_d = this.parameters) === null || _d === void 0 ? void 0 : _d.map((param, i) => ([
220
+ ...((_f = (_e = this.parameters) === null || _e === void 0 ? void 0 : _e.map((param, i) => ([
216
221
  //separating comma
217
222
  i > 0 ? ', ' : '',
218
223
  ...param.getTypedef(state)
219
- ]))) !== null && _e !== void 0 ? _e : []),
224
+ ]))) !== null && _f !== void 0 ? _f : []),
220
225
  //right paren
221
226
  ')',
222
227
  //as <ReturnType>
223
- ...(this.asToken ? [
224
- ' as ',
228
+ ...(this.returnTypeExpression ? [
229
+ ' ',
230
+ (_h = (_g = this.tokens.as) === null || _g === void 0 ? void 0 : _g.text) !== null && _h !== void 0 ? _h : 'as',
231
+ ' ',
225
232
  ...this.returnTypeExpression.getTypedef(state)
226
233
  ] : []),
227
234
  '\n',
228
235
  state.indent(),
229
236
  //'end sub'|'end function'
230
- this.end.text
237
+ (_k = (_j = this.tokens.endFunctionType) === null || _j === void 0 ? void 0 : _j.text) !== null && _k !== void 0 ? _k : `end ${(_l = this.tokens.functionType) !== null && _l !== void 0 ? _l : 'function'}`
231
238
  ])
232
239
  ];
233
240
  return results;
@@ -243,10 +250,10 @@ class FunctionExpression extends AstNode_1.Expression {
243
250
  }
244
251
  }
245
252
  getType(options) {
246
- var _a, _b, _c;
253
+ var _a, _b, _c, _d;
247
254
  //if there's a defined return type, use that
248
255
  let returnType = (_a = this.returnTypeExpression) === null || _a === void 0 ? void 0 : _a.getType(Object.assign(Object.assign({}, options), { typeChain: undefined }));
249
- const isSub = this.functionType.kind === TokenKind_1.TokenKind.Sub;
256
+ const isSub = ((_b = this.tokens.functionType) === null || _b === void 0 ? void 0 : _b.kind) === TokenKind_1.TokenKind.Sub;
250
257
  //if we don't have a return type and this is a sub, set the return type to `void`. else use `dynamic`
251
258
  if (!returnType) {
252
259
  returnType = isSub ? VoidType_1.VoidType.instance : DynamicType_1.DynamicType.instance;
@@ -254,7 +261,7 @@ class FunctionExpression extends AstNode_1.Expression {
254
261
  const resultType = new TypedFunctionType_1.TypedFunctionType(returnType);
255
262
  resultType.isSub = isSub;
256
263
  for (let param of this.parameters) {
257
- resultType.addParameter(param.name.text, param.getType(Object.assign(Object.assign({}, options), { typeChain: undefined })), !!param.defaultValue);
264
+ resultType.addParameter(param.tokens.name.text, param.getType(Object.assign(Object.assign({}, options), { typeChain: undefined })), !!param.defaultValue);
258
265
  }
259
266
  // Figure out this function's name if we can
260
267
  let funcName = '';
@@ -262,7 +269,7 @@ class FunctionExpression extends AstNode_1.Expression {
262
269
  funcName = this.parent.getName(Parser_1.ParseMode.BrighterScript);
263
270
  if (options.typeChain) {
264
271
  // Get the typechain info from the parent class
265
- (_b = this.parent.parent) === null || _b === void 0 ? void 0 : _b.getType(options);
272
+ (_c = this.parent.parent) === null || _c === void 0 ? void 0 : _c.getType(options);
266
273
  }
267
274
  }
268
275
  else if ((0, reflection_1.isFunctionStatement)(this.parent)) {
@@ -271,35 +278,37 @@ class FunctionExpression extends AstNode_1.Expression {
271
278
  if (funcName) {
272
279
  resultType.setName(funcName);
273
280
  }
274
- (_c = options.typeChain) === null || _c === void 0 ? void 0 : _c.push(new interfaces_1.TypeChainEntry(funcName, resultType, options.data, this.range));
281
+ (_d = options.typeChain) === null || _d === void 0 ? void 0 : _d.push(new interfaces_1.TypeChainEntry(funcName, resultType, options.data, this.range));
275
282
  return resultType;
276
283
  }
277
284
  }
278
285
  exports.FunctionExpression = FunctionExpression;
279
286
  class FunctionParameterExpression extends AstNode_1.Expression {
280
- constructor(name, equalToken, defaultValue, asToken, typeExpression) {
287
+ constructor(options) {
281
288
  super();
282
- this.name = name;
283
- this.equalToken = equalToken;
284
- this.defaultValue = defaultValue;
285
- this.asToken = asToken;
286
- this.typeExpression = typeExpression;
287
289
  this.kind = AstNode_1.AstNodeKind.FunctionParameterExpression;
290
+ this.tokens = {
291
+ name: options.name,
292
+ equals: options.equals,
293
+ as: options.as
294
+ };
295
+ this.defaultValue = options.defaultValue;
296
+ this.typeExpression = options.typeExpression;
288
297
  }
289
298
  getType(options) {
290
299
  var _a, _b, _c, _d, _e;
291
300
  const paramType = (_d = (_b = (_a = this.typeExpression) === null || _a === void 0 ? void 0 : _a.getType(Object.assign(Object.assign({}, options), { flags: SymbolTable_1.SymbolTypeFlag.typetime, typeChain: undefined }))) !== null && _b !== void 0 ? _b : (_c = this.defaultValue) === null || _c === void 0 ? void 0 : _c.getType(Object.assign(Object.assign({}, options), { flags: SymbolTable_1.SymbolTypeFlag.runtime, typeChain: undefined }))) !== null && _d !== void 0 ? _d : DynamicType_1.DynamicType.instance;
292
- (_e = options.typeChain) === null || _e === void 0 ? void 0 : _e.push(new interfaces_1.TypeChainEntry(this.name.text, paramType, options.data, this.range));
301
+ (_e = options.typeChain) === null || _e === void 0 ? void 0 : _e.push(new interfaces_1.TypeChainEntry(this.tokens.name.text, paramType, options.data, this.range));
293
302
  return paramType;
294
303
  }
295
304
  get range() {
296
- return util_1.default.createBoundingRange(this.name, this.asToken, this.typeExpression, this.defaultValue);
305
+ return util_1.default.createBoundingRange(this.tokens.name, this.tokens.as, this.typeExpression, this.tokens.equals, this.defaultValue);
297
306
  }
298
307
  transpile(state) {
299
308
  var _a, _b;
300
309
  let result = [
301
310
  //name
302
- state.transpileToken(this.name)
311
+ state.transpileToken(this.tokens.name)
303
312
  ];
304
313
  //default value
305
314
  if (this.defaultValue) {
@@ -307,9 +316,9 @@ class FunctionParameterExpression extends AstNode_1.Expression {
307
316
  result.push(this.defaultValue.transpile(state));
308
317
  }
309
318
  //type declaration
310
- if (this.asToken && !state.options.removeParameterTypes) {
319
+ if (this.typeExpression && !state.options.removeParameterTypes) {
311
320
  result.push(' ');
312
- result.push(state.transpileToken(this.asToken));
321
+ result.push(state.transpileToken(this.tokens.as, 'as'));
313
322
  result.push(' ');
314
323
  result.push(...((_b = (_a = this.typeExpression) === null || _a === void 0 ? void 0 : _a.transpile(state)) !== null && _b !== void 0 ? _b : []));
315
324
  }
@@ -319,14 +328,14 @@ class FunctionParameterExpression extends AstNode_1.Expression {
319
328
  var _a, _b;
320
329
  return [
321
330
  //name
322
- this.name.text,
331
+ this.tokens.name.text,
323
332
  //default value
324
333
  ...(this.defaultValue ? [
325
334
  ' = ',
326
335
  ...this.defaultValue.transpile(state)
327
336
  ] : []),
328
337
  //type declaration
329
- ...(this.asToken ? [
338
+ ...(this.typeExpression ? [
330
339
  ' as ',
331
340
  ...((_b = (_a = this.typeExpression) === null || _a === void 0 ? void 0 : _a.getTypedef(state)) !== null && _b !== void 0 ? _b : [''])
332
341
  ] : [])
@@ -342,17 +351,15 @@ class FunctionParameterExpression extends AstNode_1.Expression {
342
351
  }
343
352
  exports.FunctionParameterExpression = FunctionParameterExpression;
344
353
  class DottedGetExpression extends AstNode_1.Expression {
345
- constructor(obj, name,
346
- /**
347
- * Can either be `.`, or `?.` for optional chaining
348
- */
349
- dot) {
354
+ constructor(options) {
350
355
  super();
351
- this.obj = obj;
352
- this.name = name;
353
- this.dot = dot;
354
356
  this.kind = AstNode_1.AstNodeKind.DottedGetExpression;
355
- this.range = util_1.default.createBoundingRange(this.obj, this.dot, this.name);
357
+ this.tokens = {
358
+ name: options.name,
359
+ dot: options.dot
360
+ };
361
+ this.obj = options.obj;
362
+ this.range = util_1.default.createBoundingRange(this.obj, this.tokens.dot, this.tokens.name);
356
363
  }
357
364
  transpile(state) {
358
365
  //if the callee starts with a namespace name, transpile the name
@@ -364,8 +371,8 @@ class DottedGetExpression extends AstNode_1.Expression {
364
371
  else {
365
372
  return [
366
373
  ...this.obj.transpile(state),
367
- state.transpileToken(this.dot),
368
- state.transpileToken(this.name)
374
+ state.transpileToken(this.tokens.dot, '.'),
375
+ state.transpileToken(this.tokens.name)
369
376
  ];
370
377
  }
371
378
  }
@@ -377,8 +384,8 @@ class DottedGetExpression extends AstNode_1.Expression {
377
384
  getType(options) {
378
385
  var _a, _b, _c, _d, _e, _f;
379
386
  const objType = (_a = this.obj) === null || _a === void 0 ? void 0 : _a.getType(options);
380
- const result = objType === null || objType === void 0 ? void 0 : objType.getMemberType((_b = this.name) === null || _b === void 0 ? void 0 : _b.text, options);
381
- (_c = options.typeChain) === null || _c === void 0 ? void 0 : _c.push(new interfaces_1.TypeChainEntry((_d = this.name) === null || _d === void 0 ? void 0 : _d.text, result, options.data, (_f = (_e = this.name) === null || _e === void 0 ? void 0 : _e.range) !== null && _f !== void 0 ? _f : this.range));
387
+ const result = objType === null || objType === void 0 ? void 0 : objType.getMemberType((_b = this.tokens.name) === null || _b === void 0 ? void 0 : _b.text, options);
388
+ (_c = options.typeChain) === null || _c === void 0 ? void 0 : _c.push(new interfaces_1.TypeChainEntry((_d = this.tokens.name) === null || _d === void 0 ? void 0 : _d.text, result, options.data, (_f = (_e = this.tokens.name) === null || _e === void 0 ? void 0 : _e.range) !== null && _f !== void 0 ? _f : this.range));
382
389
  if (result || options.flags & SymbolTable_1.SymbolTypeFlag.typetime) {
383
390
  // All types should be known at typetime
384
391
  return result;
@@ -393,23 +400,18 @@ class DottedGetExpression extends AstNode_1.Expression {
393
400
  }
394
401
  exports.DottedGetExpression = DottedGetExpression;
395
402
  class XmlAttributeGetExpression extends AstNode_1.Expression {
396
- constructor(obj, name,
397
- /**
398
- * Can either be `@`, or `?@` for optional chaining
399
- */
400
- at) {
403
+ constructor(options) {
401
404
  super();
402
- this.obj = obj;
403
- this.name = name;
404
- this.at = at;
405
405
  this.kind = AstNode_1.AstNodeKind.XmlAttributeGetExpression;
406
- this.range = util_1.default.createBoundingRange(this.obj, this.at, this.name);
406
+ this.obj = options.obj;
407
+ this.tokens = { at: options.at, name: options.name };
408
+ this.range = util_1.default.createBoundingRange(this.obj, this.tokens.at, this.tokens.name);
407
409
  }
408
410
  transpile(state) {
409
411
  return [
410
412
  ...this.obj.transpile(state),
411
- state.transpileToken(this.at),
412
- state.transpileToken(this.name)
413
+ state.transpileToken(this.tokens.at, '@'),
414
+ state.transpileToken(this.tokens.name)
413
415
  ];
414
416
  }
415
417
  walk(visitor, options) {
@@ -420,35 +422,37 @@ class XmlAttributeGetExpression extends AstNode_1.Expression {
420
422
  }
421
423
  exports.XmlAttributeGetExpression = XmlAttributeGetExpression;
422
424
  class IndexedGetExpression extends AstNode_1.Expression {
423
- constructor(obj, index,
424
- /**
425
- * Can either be `[` or `?[`. If `?.[` is used, this will be `[` and `optionalChainingToken` will be `?.`
426
- */
427
- openingSquare, closingSquare, questionDotToken // ? or ?.
428
- ) {
425
+ constructor(options) {
429
426
  super();
430
- this.obj = obj;
431
- this.index = index;
432
- this.openingSquare = openingSquare;
433
- this.closingSquare = closingSquare;
434
- this.questionDotToken = questionDotToken;
435
427
  this.kind = AstNode_1.AstNodeKind.IndexedGetExpression;
436
- this.range = util_1.default.createBoundingRange(this.obj, this.openingSquare, this.questionDotToken, this.openingSquare, this.index, this.closingSquare);
428
+ this.tokens = {
429
+ openingSquare: options.openingSquare,
430
+ closingSquare: options.closingSquare,
431
+ questionDot: options.questionDot
432
+ };
433
+ this.obj = options.obj;
434
+ this.indexes = options.indexes;
435
+ this.range = util_1.default.createBoundingRange(this.obj, this.tokens.openingSquare, this.tokens.questionDot, this.tokens.openingSquare, ...this.indexes, this.tokens.closingSquare);
437
436
  }
438
437
  transpile(state) {
439
- var _a, _b;
440
- return [
441
- ...this.obj.transpile(state),
442
- this.questionDotToken ? state.transpileToken(this.questionDotToken) : '',
443
- state.transpileToken(this.openingSquare),
444
- ...((_b = (_a = this.index) === null || _a === void 0 ? void 0 : _a.transpile(state)) !== null && _b !== void 0 ? _b : []),
445
- this.closingSquare ? state.transpileToken(this.closingSquare) : ''
446
- ];
438
+ var _a;
439
+ const result = [];
440
+ result.push(...this.obj.transpile(state), this.tokens.questionDot ? state.transpileToken(this.tokens.questionDot) : '', state.transpileToken(this.tokens.openingSquare, '['));
441
+ for (let i = 0; i < this.indexes.length; i++) {
442
+ //add comma between indexes
443
+ if (i > 0) {
444
+ result.push(', ');
445
+ }
446
+ let index = this.indexes[i];
447
+ result.push(...((_a = index === null || index === void 0 ? void 0 : index.transpile(state)) !== null && _a !== void 0 ? _a : []));
448
+ }
449
+ result.push(state.transpileToken(this.tokens.closingSquare, ']'));
450
+ return result;
447
451
  }
448
452
  walk(visitor, options) {
449
453
  if (options.walkMode & visitors_2.InternalWalkMode.walkExpressions) {
450
454
  (0, visitors_2.walk)(this, 'obj', visitor, options);
451
- (0, visitors_2.walk)(this, 'index', visitor, options);
455
+ (0, visitors_2.walkArray)(this.indexes, visitor, options, this);
452
456
  }
453
457
  }
454
458
  getType(options) {
@@ -462,21 +466,24 @@ class IndexedGetExpression extends AstNode_1.Expression {
462
466
  }
463
467
  exports.IndexedGetExpression = IndexedGetExpression;
464
468
  class GroupingExpression extends AstNode_1.Expression {
465
- constructor(tokens, expression) {
469
+ constructor(options) {
466
470
  super();
467
- this.tokens = tokens;
468
- this.expression = expression;
469
471
  this.kind = AstNode_1.AstNodeKind.GroupingExpression;
470
- this.range = util_1.default.createBoundingRange(this.tokens.left, this.expression, this.tokens.right);
472
+ this.tokens = {
473
+ rightParen: options.rightParen,
474
+ leftParen: options.leftParen
475
+ };
476
+ this.expression = options.expression;
477
+ this.range = util_1.default.createBoundingRange(this.tokens.leftParen, this.expression, this.tokens.rightParen);
471
478
  }
472
479
  transpile(state) {
473
480
  if ((0, reflection_1.isTypeCastExpression)(this.expression)) {
474
481
  return this.expression.transpile(state);
475
482
  }
476
483
  return [
477
- state.transpileToken(this.tokens.left),
484
+ state.transpileToken(this.tokens.leftParen),
478
485
  ...this.expression.transpile(state),
479
- state.transpileToken(this.tokens.right)
486
+ state.transpileToken(this.tokens.rightParen)
480
487
  ];
481
488
  }
482
489
  walk(visitor, options) {
@@ -490,32 +497,34 @@ class GroupingExpression extends AstNode_1.Expression {
490
497
  }
491
498
  exports.GroupingExpression = GroupingExpression;
492
499
  class LiteralExpression extends AstNode_1.Expression {
493
- constructor(token) {
500
+ constructor(options) {
494
501
  super();
495
- this.token = token;
496
502
  this.kind = AstNode_1.AstNodeKind.LiteralExpression;
503
+ this.tokens = {
504
+ value: options.value
505
+ };
497
506
  }
498
507
  get range() {
499
- return this.token.range;
508
+ return this.tokens.value.range;
500
509
  }
501
510
  getType(options) {
502
- return util_1.default.tokenToBscType(this.token);
511
+ return util_1.default.tokenToBscType(this.tokens.value);
503
512
  }
504
513
  transpile(state) {
505
514
  let text;
506
- if (this.token.kind === TokenKind_1.TokenKind.TemplateStringQuasi) {
515
+ if (this.tokens.value.kind === TokenKind_1.TokenKind.TemplateStringQuasi) {
507
516
  //wrap quasis with quotes (and escape inner quotemarks)
508
- text = `"${this.token.text.replace(/"/g, '""')}"`;
517
+ text = `"${this.tokens.value.text.replace(/"/g, '""')}"`;
509
518
  }
510
- else if (this.token.kind === TokenKind_1.TokenKind.StringLiteral) {
511
- text = this.token.text;
519
+ else if (this.tokens.value.kind === TokenKind_1.TokenKind.StringLiteral) {
520
+ text = this.tokens.value.text;
512
521
  //add trailing quotemark if it's missing. We will have already generated a diagnostic for this.
513
522
  if (text.endsWith('"') === false) {
514
523
  text += '"';
515
524
  }
516
525
  }
517
526
  else {
518
- text = this.token.text;
527
+ text = this.tokens.value.text;
519
528
  }
520
529
  return [
521
530
  state.sourceNode(this, text)
@@ -531,15 +540,15 @@ exports.LiteralExpression = LiteralExpression;
531
540
  * during template string transpile by identifying these expressions explicitly and skipping the bslib_toString around them
532
541
  */
533
542
  class EscapedCharCodeLiteralExpression extends AstNode_1.Expression {
534
- constructor(token) {
543
+ constructor(options) {
535
544
  super();
536
- this.token = token;
537
545
  this.kind = AstNode_1.AstNodeKind.EscapedCharCodeLiteralExpression;
538
- this.range = token.range;
546
+ this.tokens = { value: options.value };
547
+ this.range = this.tokens.value.range;
539
548
  }
540
549
  transpile(state) {
541
550
  return [
542
- state.sourceNode(this, `chr(${this.token.charCode})`)
551
+ state.sourceNode(this, `chr(${this.tokens.value.charCode})`)
543
552
  ];
544
553
  }
545
554
  walk(visitor, options) {
@@ -548,18 +557,19 @@ class EscapedCharCodeLiteralExpression extends AstNode_1.Expression {
548
557
  }
549
558
  exports.EscapedCharCodeLiteralExpression = EscapedCharCodeLiteralExpression;
550
559
  class ArrayLiteralExpression extends AstNode_1.Expression {
551
- constructor(elements, open, close, hasSpread = false) {
560
+ constructor(options) {
552
561
  super();
553
- this.elements = elements;
554
- this.open = open;
555
- this.close = close;
556
- this.hasSpread = hasSpread;
557
562
  this.kind = AstNode_1.AstNodeKind.ArrayLiteralExpression;
558
- this.range = util_1.default.createBoundingRange(this.open, ...this.elements, this.close);
563
+ this.tokens = {
564
+ open: options.open,
565
+ close: options.close
566
+ };
567
+ this.elements = options.elements;
568
+ this.range = util_1.default.createBoundingRange(this.tokens.open, ...this.elements, this.tokens.close);
559
569
  }
560
570
  transpile(state) {
561
571
  let result = [];
562
- result.push(state.transpileToken(this.open));
572
+ result.push(state.transpileToken(this.tokens.open, '['));
563
573
  let hasChildren = this.elements.length > 0;
564
574
  state.blockDepth++;
565
575
  for (let i = 0; i < this.elements.length; i++) {
@@ -567,7 +577,7 @@ class ArrayLiteralExpression extends AstNode_1.Expression {
567
577
  let element = this.elements[i];
568
578
  if ((0, reflection_1.isCommentStatement)(element)) {
569
579
  //if the comment is on the same line as opening square or previous statement, don't add newline
570
- if (util_1.default.linesTouch(this.open, element) || util_1.default.linesTouch(previousElement, element)) {
580
+ if (util_1.default.linesTouch(this.tokens.open, element) || util_1.default.linesTouch(previousElement, element)) {
571
581
  result.push(' ');
572
582
  }
573
583
  else {
@@ -588,8 +598,8 @@ class ArrayLiteralExpression extends AstNode_1.Expression {
588
598
  result.push('\n');
589
599
  result.push(state.indent());
590
600
  }
591
- if (this.close) {
592
- result.push(state.transpileToken(this.close));
601
+ if (this.tokens.close) {
602
+ result.push(state.transpileToken(this.tokens.close));
593
603
  }
594
604
  return result;
595
605
  }
@@ -605,15 +615,16 @@ class ArrayLiteralExpression extends AstNode_1.Expression {
605
615
  }
606
616
  exports.ArrayLiteralExpression = ArrayLiteralExpression;
607
617
  class AAMemberExpression extends AstNode_1.Expression {
608
- constructor(keyToken, colonToken,
609
- /** The expression evaluated to determine the member's initial value. */
610
- value) {
618
+ constructor(options) {
611
619
  super();
612
- this.keyToken = keyToken;
613
- this.colonToken = colonToken;
614
- this.value = value;
615
620
  this.kind = AstNode_1.AstNodeKind.AAMemberExpression;
616
- this.range = util_1.default.createBoundingRange(this.keyToken, this.colonToken, this.value);
621
+ this.tokens = {
622
+ key: options.key,
623
+ colon: options.colon,
624
+ comma: options.comma
625
+ };
626
+ this.value = options.value;
627
+ this.range = util_1.default.createBoundingRange(this.tokens.key, this.tokens.colon, this.value);
617
628
  }
618
629
  transpile(state) {
619
630
  //TODO move the logic from AALiteralExpression loop into this function
@@ -628,21 +639,23 @@ class AAMemberExpression extends AstNode_1.Expression {
628
639
  }
629
640
  exports.AAMemberExpression = AAMemberExpression;
630
641
  class AALiteralExpression extends AstNode_1.Expression {
631
- constructor(elements, open, close) {
642
+ constructor(options) {
632
643
  super();
633
- this.elements = elements;
634
- this.open = open;
635
- this.close = close;
636
644
  this.kind = AstNode_1.AstNodeKind.AALiteralExpression;
637
- this.range = util_1.default.createBoundingRange(this.open, ...this.elements, this.close);
645
+ this.tokens = {
646
+ open: options.open,
647
+ close: options.close
648
+ };
649
+ this.elements = options.elements;
650
+ this.range = util_1.default.createBoundingRange(this.tokens.open, ...this.elements, this.tokens.close);
638
651
  }
639
652
  transpile(state) {
640
653
  let result = [];
641
654
  //open curly
642
- result.push(state.transpileToken(this.open));
655
+ result.push(state.transpileToken(this.tokens.open, '{'));
643
656
  let hasChildren = this.elements.length > 0;
644
657
  //add newline if the object has children and the first child isn't a comment starting on the same line as opening curly
645
- if (hasChildren && ((0, reflection_1.isCommentStatement)(this.elements[0]) === false || !util_1.default.linesTouch(this.elements[0], this.open))) {
658
+ if (hasChildren && ((0, reflection_1.isCommentStatement)(this.elements[0]) === false || !util_1.default.linesTouch(this.elements[0], this.tokens.open))) {
646
659
  result.push('\n');
647
660
  }
648
661
  state.blockDepth++;
@@ -652,7 +665,7 @@ class AALiteralExpression extends AstNode_1.Expression {
652
665
  let nextElement = this.elements[i + 1];
653
666
  //don't indent if comment is same-line
654
667
  if ((0, reflection_1.isCommentStatement)(element) &&
655
- (util_1.default.linesTouch(this.open, element) || util_1.default.linesTouch(previousElement, element))) {
668
+ (util_1.default.linesTouch(this.tokens.open, element) || util_1.default.linesTouch(previousElement, element))) {
656
669
  result.push(' ');
657
670
  //indent line
658
671
  }
@@ -665,9 +678,9 @@ class AALiteralExpression extends AstNode_1.Expression {
665
678
  }
666
679
  else {
667
680
  //key
668
- result.push(state.transpileToken(element.keyToken));
681
+ result.push(state.transpileToken(element.tokens.key));
669
682
  //colon
670
- result.push(state.transpileToken(element.colonToken), ' ');
683
+ result.push(state.transpileToken(element.tokens.colon, ':'), ' ');
671
684
  //value
672
685
  result.push(...element.value.transpile(state));
673
686
  }
@@ -685,9 +698,7 @@ class AALiteralExpression extends AstNode_1.Expression {
685
698
  result.push(state.indent());
686
699
  }
687
700
  //close curly
688
- if (this.close) {
689
- result.push(state.transpileToken(this.close));
690
- }
701
+ result.push(state.transpileToken(this.tokens.close, '}'));
691
702
  return result;
692
703
  }
693
704
  walk(visitor, options) {
@@ -699,7 +710,7 @@ class AALiteralExpression extends AstNode_1.Expression {
699
710
  const resultType = new AssociativeArrayType_1.AssociativeArrayType();
700
711
  for (const element of this.elements) {
701
712
  if ((0, reflection_1.isAAMemberExpression)(element)) {
702
- resultType.addMember(element.keyToken.text, { definingNode: element }, element.getType(options), SymbolTable_1.SymbolTypeFlag.runtime);
713
+ resultType.addMember(element.tokens.key.text, { definingNode: element }, element.getType(options), SymbolTable_1.SymbolTypeFlag.runtime);
703
714
  }
704
715
  }
705
716
  return resultType;
@@ -707,26 +718,28 @@ class AALiteralExpression extends AstNode_1.Expression {
707
718
  }
708
719
  exports.AALiteralExpression = AALiteralExpression;
709
720
  class UnaryExpression extends AstNode_1.Expression {
710
- constructor(operator, right) {
721
+ constructor(options) {
711
722
  super();
712
- this.operator = operator;
713
- this.right = right;
714
723
  this.kind = AstNode_1.AstNodeKind.UnaryExpression;
715
- this.range = util_1.default.createBoundingRange(this.operator, this.right);
724
+ this.tokens = {
725
+ operator: options.operator
726
+ };
727
+ this.right = options.right;
728
+ this.range = util_1.default.createBoundingRange(this.tokens.operator, this.right);
716
729
  }
717
730
  transpile(state) {
718
731
  let separatingWhitespace;
719
732
  if ((0, reflection_1.isVariableExpression)(this.right)) {
720
- separatingWhitespace = this.right.name.leadingWhitespace;
733
+ separatingWhitespace = this.right.tokens.name.leadingWhitespace;
721
734
  }
722
735
  else if ((0, reflection_1.isLiteralExpression)(this.right)) {
723
- separatingWhitespace = this.right.token.leadingWhitespace;
736
+ separatingWhitespace = this.right.tokens.value.leadingWhitespace;
724
737
  }
725
738
  else {
726
739
  separatingWhitespace = ' ';
727
740
  }
728
741
  return [
729
- state.transpileToken(this.operator),
742
+ state.transpileToken(this.tokens.operator),
730
743
  separatingWhitespace,
731
744
  ...this.right.transpile(state)
732
745
  ];
@@ -737,20 +750,22 @@ class UnaryExpression extends AstNode_1.Expression {
737
750
  }
738
751
  }
739
752
  getType(options) {
740
- return util_1.default.unaryOperatorResultType(this.operator, this.right.getType(options));
753
+ return util_1.default.unaryOperatorResultType(this.tokens.operator, this.right.getType(options));
741
754
  }
742
755
  }
743
756
  exports.UnaryExpression = UnaryExpression;
744
757
  class VariableExpression extends AstNode_1.Expression {
745
- constructor(name) {
758
+ constructor(options) {
746
759
  var _a;
747
760
  super();
748
- this.name = name;
749
761
  this.kind = AstNode_1.AstNodeKind.VariableExpression;
750
- this.range = (_a = this.name) === null || _a === void 0 ? void 0 : _a.range;
762
+ this.tokens = {
763
+ name: options.name
764
+ };
765
+ this.range = (_a = this.tokens.name) === null || _a === void 0 ? void 0 : _a.range;
751
766
  }
752
767
  getName(parseMode) {
753
- return this.name.text;
768
+ return this.tokens.name.text;
754
769
  }
755
770
  transpile(state) {
756
771
  let result = [];
@@ -765,7 +780,7 @@ class VariableExpression extends AstNode_1.Expression {
765
780
  //transpile normally
766
781
  }
767
782
  else {
768
- result.push(state.transpileToken(this.name));
783
+ result.push(state.transpileToken(this.tokens.name));
769
784
  }
770
785
  return result;
771
786
  }
@@ -774,8 +789,8 @@ class VariableExpression extends AstNode_1.Expression {
774
789
  }
775
790
  getType(options) {
776
791
  var _a;
777
- let resultType = util_1.default.tokenToBscType(this.name);
778
- const nameKey = this.name.text;
792
+ let resultType = util_1.default.tokenToBscType(this.tokens.name);
793
+ const nameKey = this.getName();
779
794
  if (!resultType) {
780
795
  const symbolTable = this.getSymbolTable();
781
796
  resultType = symbolTable === null || symbolTable === void 0 ? void 0 : symbolTable.getSymbolType(nameKey, Object.assign(Object.assign({}, options), { fullName: nameKey, tableProvider: () => this.getSymbolTable() }));
@@ -786,11 +801,14 @@ class VariableExpression extends AstNode_1.Expression {
786
801
  }
787
802
  exports.VariableExpression = VariableExpression;
788
803
  class SourceLiteralExpression extends AstNode_1.Expression {
789
- constructor(token) {
804
+ constructor(options) {
805
+ var _a;
790
806
  super();
791
- this.token = token;
792
807
  this.kind = AstNode_1.AstNodeKind.SourceLiteralExpression;
793
- this.range = token === null || token === void 0 ? void 0 : token.range;
808
+ this.tokens = {
809
+ value: options.value
810
+ };
811
+ this.range = (_a = this.tokens.value) === null || _a === void 0 ? void 0 : _a.range;
794
812
  }
795
813
  /**
796
814
  * Find the index of the function in its parent
@@ -810,7 +828,7 @@ class SourceLiteralExpression extends AstNode_1.Expression {
810
828
  return index;
811
829
  }
812
830
  getFunctionName(state, parseMode) {
813
- let func = state.file.getFunctionScopeAtPosition(this.token.range.start).func;
831
+ let func = state.file.getFunctionScopeAtPosition(this.tokens.value.range.start).func;
814
832
  let nameParts = [];
815
833
  let parentFunction;
816
834
  while ((parentFunction = func.findAncestor(reflection_1.isFunctionExpression))) {
@@ -824,13 +842,13 @@ class SourceLiteralExpression extends AstNode_1.Expression {
824
842
  }
825
843
  transpile(state) {
826
844
  let text;
827
- switch (this.token.kind) {
845
+ switch (this.tokens.value.kind) {
828
846
  case TokenKind_1.TokenKind.SourceFilePathLiteral:
829
847
  const pathUrl = fileUrl(state.srcPath);
830
848
  text = `"${pathUrl.substring(0, 4)}" + "${pathUrl.substring(4)}"`;
831
849
  break;
832
850
  case TokenKind_1.TokenKind.SourceLineNumLiteral:
833
- text = `${this.token.range.start.line + 1}`;
851
+ text = `${this.tokens.value.range.start.line + 1}`;
834
852
  break;
835
853
  case TokenKind_1.TokenKind.FunctionNameLiteral:
836
854
  text = `"${this.getFunctionName(state, Parser_1.ParseMode.BrightScript)}"`;
@@ -840,7 +858,7 @@ class SourceLiteralExpression extends AstNode_1.Expression {
840
858
  break;
841
859
  case TokenKind_1.TokenKind.SourceLocationLiteral:
842
860
  const locationUrl = fileUrl(state.srcPath);
843
- text = `"${locationUrl.substring(0, 4)}" + "${locationUrl.substring(4)}:${this.token.range.start.line + 1}"`;
861
+ text = `"${locationUrl.substring(0, 4)}" + "${locationUrl.substring(4)}:${this.tokens.value.range.start.line + 1}"`;
844
862
  break;
845
863
  case TokenKind_1.TokenKind.PkgPathLiteral:
846
864
  text = `"${util_1.default.sanitizePkgPath(state.file.pkgPath)}"`;
@@ -851,7 +869,7 @@ class SourceLiteralExpression extends AstNode_1.Expression {
851
869
  case TokenKind_1.TokenKind.LineNumLiteral:
852
870
  default:
853
871
  //use the original text (because it looks like a variable)
854
- text = this.token.text;
872
+ text = this.tokens.value.text;
855
873
  break;
856
874
  }
857
875
  return [
@@ -869,12 +887,14 @@ exports.SourceLiteralExpression = SourceLiteralExpression;
869
887
  * do more type checking.
870
888
  */
871
889
  class NewExpression extends AstNode_1.Expression {
872
- constructor(newKeyword, call) {
890
+ constructor(options) {
873
891
  super();
874
- this.newKeyword = newKeyword;
875
- this.call = call;
876
892
  this.kind = AstNode_1.AstNodeKind.NewExpression;
877
- this.range = util_1.default.createBoundingRange(this.newKeyword, this.call);
893
+ this.tokens = {
894
+ new: options.new
895
+ };
896
+ this.call = options.call;
897
+ this.range = util_1.default.createBoundingRange(this.tokens.new, this.call);
878
898
  }
879
899
  /**
880
900
  * The name of the class to initialize (with optional namespace prefixed)
@@ -903,28 +923,29 @@ class NewExpression extends AstNode_1.Expression {
903
923
  }
904
924
  exports.NewExpression = NewExpression;
905
925
  class CallfuncExpression extends AstNode_1.Expression {
906
- constructor(callee, operator, methodName, openingParen, args, closingParen) {
926
+ constructor(options) {
927
+ var _a;
907
928
  super();
908
- this.callee = callee;
909
- this.operator = operator;
910
- this.methodName = methodName;
911
- this.openingParen = openingParen;
912
- this.args = args;
913
- this.closingParen = closingParen;
914
929
  this.kind = AstNode_1.AstNodeKind.CallfuncExpression;
915
- this.range = util_1.default.createBoundingRange(callee, operator, methodName, openingParen, ...args, closingParen);
930
+ this.tokens = {
931
+ operator: options.operator,
932
+ methodName: options.methodName,
933
+ openingParen: options.openingParen,
934
+ closingParen: options.closingParen
935
+ };
936
+ this.callee = options.callee;
937
+ this.args = (_a = options.args) !== null && _a !== void 0 ? _a : [];
938
+ this.range = util_1.default.createBoundingRange(this.callee, this.tokens.operator, this.tokens.methodName, this.tokens.openingParen, ...this.args, this.tokens.closingParen);
916
939
  }
917
940
  transpile(state) {
941
+ var _a;
918
942
  let result = [];
919
- result.push(...this.callee.transpile(state), state.sourceNode(this.operator, '.callfunc'), state.transpileToken(this.openingParen),
943
+ result.push(...this.callee.transpile(state), state.sourceNode(this.tokens.operator, '.callfunc'), state.transpileToken(this.tokens.openingParen, '('),
920
944
  //the name of the function
921
- state.sourceNode(this.methodName, ['"', this.methodName.text, '"']), ', ');
922
- //transpile args
923
- //callfunc with zero args never gets called, so pass invalid as the first parameter if there are no args
924
- if (this.args.length === 0) {
925
- result.push('invalid');
926
- }
927
- else {
945
+ state.sourceNode(this.tokens.methodName, ['"', this.tokens.methodName.text, '"']));
946
+ if (((_a = this.args) === null || _a === void 0 ? void 0 : _a.length) > 0) {
947
+ result.push(', ');
948
+ //transpile args
928
949
  for (let i = 0; i < this.args.length; i++) {
929
950
  //add comma between args
930
951
  if (i > 0) {
@@ -934,7 +955,10 @@ class CallfuncExpression extends AstNode_1.Expression {
934
955
  result.push(...arg.transpile(state));
935
956
  }
936
957
  }
937
- result.push(state.transpileToken(this.closingParen));
958
+ else if (state.options.legacyCallfuncHandling) {
959
+ result.push(', ', 'invalid');
960
+ }
961
+ result.push(state.transpileToken(this.tokens.closingParen, ')'));
938
962
  return result;
939
963
  }
940
964
  walk(visitor, options) {
@@ -950,9 +974,9 @@ class CallfuncExpression extends AstNode_1.Expression {
950
974
  // It's nicer for CallExpression, because it's a call on any expression.
951
975
  const calleeType = this.callee.getType(Object.assign(Object.assign({}, options), { flags: SymbolTable_1.SymbolTypeFlag.runtime }));
952
976
  if ((0, reflection_1.isComponentType)(calleeType) || (0, reflection_1.isReferenceType)(calleeType)) {
953
- const funcType = (_b = (_a = calleeType).getCallFuncType) === null || _b === void 0 ? void 0 : _b.call(_a, this.methodName.text, options);
977
+ const funcType = (_b = (_a = calleeType).getCallFuncType) === null || _b === void 0 ? void 0 : _b.call(_a, this.tokens.methodName.text, options);
954
978
  if (funcType) {
955
- (_c = options.typeChain) === null || _c === void 0 ? void 0 : _c.push(new interfaces_1.TypeChainEntry(this.methodName.text, funcType, options.data, this.methodName.range, (0, creators_1.createToken)(TokenKind_1.TokenKind.Callfunc)));
979
+ (_c = options.typeChain) === null || _c === void 0 ? void 0 : _c.push(new interfaces_1.TypeChainEntry(this.tokens.methodName.text, funcType, options.data, this.tokens.methodName.range, (0, creators_1.createToken)(TokenKind_1.TokenKind.Callfunc)));
956
980
  if (options.ignoreCall) {
957
981
  result = funcType;
958
982
  }
@@ -977,11 +1001,11 @@ exports.CallfuncExpression = CallfuncExpression;
977
1001
  * This is a single expression that represents the string contatenation of all parts of a single quasi.
978
1002
  */
979
1003
  class TemplateStringQuasiExpression extends AstNode_1.Expression {
980
- constructor(expressions) {
1004
+ constructor(options) {
981
1005
  super();
982
- this.expressions = expressions;
983
1006
  this.kind = AstNode_1.AstNodeKind.TemplateStringQuasiExpression;
984
- this.range = util_1.default.createBoundingRange(...expressions);
1007
+ this.expressions = options.expressions;
1008
+ this.range = util_1.default.createBoundingRange(...this.expressions);
985
1009
  }
986
1010
  transpile(state, skipEmptyStrings = true) {
987
1011
  let result = [];
@@ -989,7 +1013,7 @@ class TemplateStringQuasiExpression extends AstNode_1.Expression {
989
1013
  for (let expression of this.expressions) {
990
1014
  //skip empty strings
991
1015
  //TODO what does an empty string literal expression look like?
992
- if (expression.token.text === '' && skipEmptyStrings === true) {
1016
+ if (expression.tokens.value.text === '' && skipEmptyStrings === true) {
993
1017
  continue;
994
1018
  }
995
1019
  result.push(plus, ...expression.transpile(state));
@@ -1005,14 +1029,16 @@ class TemplateStringQuasiExpression extends AstNode_1.Expression {
1005
1029
  }
1006
1030
  exports.TemplateStringQuasiExpression = TemplateStringQuasiExpression;
1007
1031
  class TemplateStringExpression extends AstNode_1.Expression {
1008
- constructor(openingBacktick, quasis, expressions, closingBacktick) {
1032
+ constructor(options) {
1009
1033
  super();
1010
- this.openingBacktick = openingBacktick;
1011
- this.quasis = quasis;
1012
- this.expressions = expressions;
1013
- this.closingBacktick = closingBacktick;
1014
1034
  this.kind = AstNode_1.AstNodeKind.TemplateStringExpression;
1015
- this.range = util_1.default.createBoundingRange(openingBacktick, quasis[0], quasis[quasis.length - 1], closingBacktick);
1035
+ this.tokens = {
1036
+ openingBacktick: options.openingBacktick,
1037
+ closingBacktick: options.closingBacktick
1038
+ };
1039
+ this.quasis = options.quasis;
1040
+ this.expressions = options.expressions;
1041
+ this.range = util_1.default.createBoundingRange(this.tokens.openingBacktick, this.quasis[0], this.quasis[this.quasis.length - 1], this.tokens.closingBacktick);
1016
1042
  }
1017
1043
  getType(options) {
1018
1044
  return StringType_1.StringType.instance;
@@ -1068,19 +1094,21 @@ class TemplateStringExpression extends AstNode_1.Expression {
1068
1094
  }
1069
1095
  exports.TemplateStringExpression = TemplateStringExpression;
1070
1096
  class TaggedTemplateStringExpression extends AstNode_1.Expression {
1071
- constructor(tagName, openingBacktick, quasis, expressions, closingBacktick) {
1097
+ constructor(options) {
1072
1098
  super();
1073
- this.tagName = tagName;
1074
- this.openingBacktick = openingBacktick;
1075
- this.quasis = quasis;
1076
- this.expressions = expressions;
1077
- this.closingBacktick = closingBacktick;
1078
1099
  this.kind = AstNode_1.AstNodeKind.TaggedTemplateStringExpression;
1079
- this.range = util_1.default.createBoundingRange(tagName, openingBacktick, quasis[0], quasis[quasis.length - 1], closingBacktick);
1100
+ this.tokens = {
1101
+ tagName: options.tagName,
1102
+ openingBacktick: options.openingBacktick,
1103
+ closingBacktick: options.closingBacktick
1104
+ };
1105
+ this.quasis = options.quasis;
1106
+ this.expressions = options.expressions;
1107
+ this.range = util_1.default.createBoundingRange(this.tokens.tagName, this.tokens.openingBacktick, this.quasis[0], this.quasis[this.quasis.length - 1], this.tokens.closingBacktick);
1080
1108
  }
1081
1109
  transpile(state) {
1082
1110
  let result = [];
1083
- result.push(state.transpileToken(this.tagName), '([');
1111
+ result.push(state.transpileToken(this.tokens.tagName), '([');
1084
1112
  //add quasis as the first array
1085
1113
  for (let i = 0; i < this.quasis.length; i++) {
1086
1114
  let quasi = this.quasis[i];
@@ -1099,7 +1127,7 @@ class TaggedTemplateStringExpression extends AstNode_1.Expression {
1099
1127
  }
1100
1128
  result.push(...expression.transpile(state));
1101
1129
  }
1102
- result.push(state.sourceNode(this.closingBacktick, '])'));
1130
+ result.push(state.sourceNode(this.tokens.closingBacktick, '])'));
1103
1131
  return result;
1104
1132
  }
1105
1133
  walk(visitor, options) {
@@ -1117,15 +1145,18 @@ class TaggedTemplateStringExpression extends AstNode_1.Expression {
1117
1145
  }
1118
1146
  exports.TaggedTemplateStringExpression = TaggedTemplateStringExpression;
1119
1147
  class AnnotationExpression extends AstNode_1.Expression {
1120
- constructor(atToken, nameToken) {
1148
+ constructor(options) {
1121
1149
  super();
1122
- this.atToken = atToken;
1123
- this.nameToken = nameToken;
1124
1150
  this.kind = AstNode_1.AstNodeKind.AnnotationExpression;
1125
- this.name = nameToken.text;
1151
+ this.tokens = {
1152
+ at: options.at,
1153
+ name: options.name
1154
+ };
1155
+ this.call = options.call;
1156
+ this.name = this.tokens.name.text;
1126
1157
  }
1127
1158
  get range() {
1128
- return util_1.default.createBoundingRange(this.atToken, this.nameToken, this.call);
1159
+ return util_1.default.createBoundingRange(this.tokens.at, this.tokens.name, this.call);
1129
1160
  }
1130
1161
  /**
1131
1162
  * Convert annotation arguments to JavaScript types
@@ -1138,7 +1169,8 @@ class AnnotationExpression extends AstNode_1.Expression {
1138
1169
  return this.call.args.map(e => expressionToValue(e, strict));
1139
1170
  }
1140
1171
  getLeadingTrivia() {
1141
- return this.atToken.leadingTrivia;
1172
+ var _a;
1173
+ return (_a = this.tokens.at) === null || _a === void 0 ? void 0 : _a.leadingTrivia;
1142
1174
  }
1143
1175
  transpile(state) {
1144
1176
  return [];
@@ -1157,15 +1189,17 @@ class AnnotationExpression extends AstNode_1.Expression {
1157
1189
  }
1158
1190
  exports.AnnotationExpression = AnnotationExpression;
1159
1191
  class TernaryExpression extends AstNode_1.Expression {
1160
- constructor(test, questionMarkToken, consequent, colonToken, alternate) {
1192
+ constructor(options) {
1161
1193
  super();
1162
- this.test = test;
1163
- this.questionMarkToken = questionMarkToken;
1164
- this.consequent = consequent;
1165
- this.colonToken = colonToken;
1166
- this.alternate = alternate;
1167
1194
  this.kind = AstNode_1.AstNodeKind.TernaryExpression;
1168
- this.range = util_1.default.createBoundingRange(test, questionMarkToken, consequent, colonToken, alternate);
1195
+ this.tokens = {
1196
+ questionMark: options.questionMark,
1197
+ colon: options.colon
1198
+ };
1199
+ this.test = options.test;
1200
+ this.consequent = options.consequent;
1201
+ this.alternate = options.alternate;
1202
+ this.range = util_1.default.createBoundingRange(this.test, this.tokens.questionMark, this.consequent, this.tokens.colon, this.alternate);
1169
1203
  }
1170
1204
  transpile(state) {
1171
1205
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
@@ -1179,12 +1213,12 @@ class TernaryExpression extends AstNode_1.Expression {
1179
1213
  ...alternateInfo.expressions
1180
1214
  ].filter(e => e instanceof CallExpression || e instanceof CallfuncExpression || e instanceof DottedGetExpression);
1181
1215
  if (mutatingExpressions.length > 0) {
1182
- result.push(state.sourceNode(this.questionMarkToken,
1216
+ result.push(state.sourceNode(this.tokens.questionMark,
1183
1217
  //write all the scope variables as parameters.
1184
1218
  //TODO handle when there are more than 31 parameters
1185
1219
  `(function(__bsCondition, ${allUniqueVarNames.join(', ')})`), state.newline,
1186
1220
  //double indent so our `end function` line is still indented one at the end
1187
- state.indent(2), state.sourceNode(this.test, `if __bsCondition then`), state.newline, state.indent(1), state.sourceNode((_a = this.consequent) !== null && _a !== void 0 ? _a : this.questionMarkToken, 'return '), ...(_c = (_b = this.consequent) === null || _b === void 0 ? void 0 : _b.transpile(state)) !== null && _c !== void 0 ? _c : [state.sourceNode(this.questionMarkToken, 'invalid')], state.newline, state.indent(-1), state.sourceNode((_d = this.consequent) !== null && _d !== void 0 ? _d : this.questionMarkToken, 'else'), state.newline, state.indent(1), state.sourceNode((_e = this.consequent) !== null && _e !== void 0 ? _e : this.questionMarkToken, 'return '), ...(_g = (_f = this.alternate) === null || _f === void 0 ? void 0 : _f.transpile(state)) !== null && _g !== void 0 ? _g : [state.sourceNode((_h = this.consequent) !== null && _h !== void 0 ? _h : this.questionMarkToken, 'invalid')], state.newline, state.indent(-1), state.sourceNode(this.questionMarkToken, 'end if'), state.newline, state.indent(-1), state.sourceNode(this.questionMarkToken, 'end function)('), ...this.test.transpile(state), state.sourceNode(this.questionMarkToken, `, ${allUniqueVarNames.join(', ')})`));
1221
+ state.indent(2), state.sourceNode(this.test, `if __bsCondition then`), state.newline, state.indent(1), state.sourceNode((_a = this.consequent) !== null && _a !== void 0 ? _a : this.tokens.questionMark, 'return '), ...(_c = (_b = this.consequent) === null || _b === void 0 ? void 0 : _b.transpile(state)) !== null && _c !== void 0 ? _c : [state.sourceNode(this.tokens.questionMark, 'invalid')], state.newline, state.indent(-1), state.sourceNode((_d = this.consequent) !== null && _d !== void 0 ? _d : this.tokens.questionMark, 'else'), state.newline, state.indent(1), state.sourceNode((_e = this.consequent) !== null && _e !== void 0 ? _e : this.tokens.questionMark, 'return '), ...(_g = (_f = this.alternate) === null || _f === void 0 ? void 0 : _f.transpile(state)) !== null && _g !== void 0 ? _g : [state.sourceNode((_h = this.consequent) !== null && _h !== void 0 ? _h : this.tokens.questionMark, 'invalid')], state.newline, state.indent(-1), state.sourceNode(this.tokens.questionMark, 'end if'), state.newline, state.indent(-1), state.sourceNode(this.tokens.questionMark, 'end function)('), ...this.test.transpile(state), state.sourceNode(this.tokens.questionMark, `, ${allUniqueVarNames.join(', ')})`));
1188
1222
  state.blockDepth--;
1189
1223
  }
1190
1224
  else {
@@ -1202,13 +1236,15 @@ class TernaryExpression extends AstNode_1.Expression {
1202
1236
  }
1203
1237
  exports.TernaryExpression = TernaryExpression;
1204
1238
  class NullCoalescingExpression extends AstNode_1.Expression {
1205
- constructor(consequent, questionQuestionToken, alternate) {
1239
+ constructor(options) {
1206
1240
  super();
1207
- this.consequent = consequent;
1208
- this.questionQuestionToken = questionQuestionToken;
1209
- this.alternate = alternate;
1210
1241
  this.kind = AstNode_1.AstNodeKind.NullCoalescingExpression;
1211
- this.range = util_1.default.createBoundingRange(consequent, questionQuestionToken, alternate);
1242
+ this.tokens = {
1243
+ questionQuestion: options.questionQuestion
1244
+ };
1245
+ this.consequent = options.consequent;
1246
+ this.alternate = options.alternate;
1247
+ this.range = util_1.default.createBoundingRange(this.consequent, this.tokens.questionQuestion, this.alternate);
1212
1248
  }
1213
1249
  transpile(state) {
1214
1250
  let result = [];
@@ -1245,10 +1281,12 @@ class NullCoalescingExpression extends AstNode_1.Expression {
1245
1281
  }
1246
1282
  exports.NullCoalescingExpression = NullCoalescingExpression;
1247
1283
  class RegexLiteralExpression extends AstNode_1.Expression {
1248
- constructor(tokens) {
1284
+ constructor(options) {
1249
1285
  super();
1250
- this.tokens = tokens;
1251
1286
  this.kind = AstNode_1.AstNodeKind.RegexLiteralExpression;
1287
+ this.tokens = {
1288
+ regexLiteral: options.regexLiteral
1289
+ };
1252
1290
  }
1253
1291
  get range() {
1254
1292
  var _a, _b;
@@ -1288,17 +1326,17 @@ function expressionToValue(expr, strict) {
1288
1326
  return null;
1289
1327
  }
1290
1328
  if ((0, reflection_1.isUnaryExpression)(expr) && (0, reflection_1.isLiteralNumber)(expr.right)) {
1291
- return numberExpressionToValue(expr.right, expr.operator.text);
1329
+ return numberExpressionToValue(expr.right, expr.tokens.operator.text);
1292
1330
  }
1293
1331
  if ((0, reflection_1.isLiteralString)(expr)) {
1294
1332
  //remove leading and trailing quotes
1295
- return expr.token.text.replace(/^"/, '').replace(/"$/, '');
1333
+ return expr.tokens.value.text.replace(/^"/, '').replace(/"$/, '');
1296
1334
  }
1297
1335
  if ((0, reflection_1.isLiteralNumber)(expr)) {
1298
1336
  return numberExpressionToValue(expr);
1299
1337
  }
1300
1338
  if ((0, reflection_1.isLiteralBoolean)(expr)) {
1301
- return expr.token.text.toLowerCase() === 'true';
1339
+ return expr.tokens.value.text.toLowerCase() === 'true';
1302
1340
  }
1303
1341
  if ((0, reflection_1.isArrayLiteralExpression)(expr)) {
1304
1342
  return expr.elements
@@ -1308,7 +1346,7 @@ function expressionToValue(expr, strict) {
1308
1346
  if ((0, reflection_1.isAALiteralExpression)(expr)) {
1309
1347
  return expr.elements.reduce((acc, e) => {
1310
1348
  if (!(0, reflection_1.isCommentStatement)(e)) {
1311
- acc[e.keyToken.text] = expressionToValue(e.value, strict);
1349
+ acc[e.tokens.key.text] = expressionToValue(e.value, strict);
1312
1350
  }
1313
1351
  return acc;
1314
1352
  }, {});
@@ -1317,22 +1355,19 @@ function expressionToValue(expr, strict) {
1317
1355
  }
1318
1356
  function numberExpressionToValue(expr, operator = '') {
1319
1357
  if ((0, reflection_1.isIntegerType)(expr.getType()) || (0, reflection_1.isLongIntegerType)(expr.getType())) {
1320
- return parseInt(operator + expr.token.text);
1358
+ return parseInt(operator + expr.tokens.value.text);
1321
1359
  }
1322
1360
  else {
1323
- return parseFloat(operator + expr.token.text);
1361
+ return parseFloat(operator + expr.tokens.value.text);
1324
1362
  }
1325
1363
  }
1326
1364
  class TypeExpression extends AstNode_1.Expression {
1327
- constructor(
1328
- /**
1329
- * The standard AST expression that represents the type for this TypeExpression.
1330
- */
1331
- expression) {
1365
+ constructor(options) {
1366
+ var _a;
1332
1367
  super();
1333
- this.expression = expression;
1334
1368
  this.kind = AstNode_1.AstNodeKind.TypeExpression;
1335
- this.range = expression === null || expression === void 0 ? void 0 : expression.range;
1369
+ this.expression = options.expression;
1370
+ this.range = (_a = this.expression) === null || _a === void 0 ? void 0 : _a.range;
1336
1371
  }
1337
1372
  transpile(state) {
1338
1373
  return [this.getType({ flags: SymbolTable_1.SymbolTypeFlag.typetime }).toTypeString()];
@@ -1360,13 +1395,15 @@ class TypeExpression extends AstNode_1.Expression {
1360
1395
  }
1361
1396
  exports.TypeExpression = TypeExpression;
1362
1397
  class TypeCastExpression extends AstNode_1.Expression {
1363
- constructor(obj, asToken, typeExpression) {
1398
+ constructor(options) {
1364
1399
  super();
1365
- this.obj = obj;
1366
- this.asToken = asToken;
1367
- this.typeExpression = typeExpression;
1368
1400
  this.kind = AstNode_1.AstNodeKind.TypeCastExpression;
1369
- this.range = util_1.default.createBoundingRange(this.obj, this.asToken, this.typeExpression);
1401
+ this.tokens = {
1402
+ as: options.as
1403
+ };
1404
+ this.obj = options.obj;
1405
+ this.typeExpression = options.typeExpression;
1406
+ this.range = util_1.default.createBoundingRange(this.obj, this.tokens.as, this.typeExpression);
1370
1407
  }
1371
1408
  transpile(state) {
1372
1409
  return this.obj.transpile(state);
@@ -1383,13 +1420,15 @@ class TypeCastExpression extends AstNode_1.Expression {
1383
1420
  }
1384
1421
  exports.TypeCastExpression = TypeCastExpression;
1385
1422
  class TypedArrayExpression extends AstNode_1.Expression {
1386
- constructor(innerType, leftBracket, rightBracket) {
1423
+ constructor(options) {
1387
1424
  super();
1388
- this.innerType = innerType;
1389
- this.leftBracket = leftBracket;
1390
- this.rightBracket = rightBracket;
1391
1425
  this.kind = AstNode_1.AstNodeKind.TypedArrayExpression;
1392
- this.range = util_1.default.createBoundingRange(this.innerType, this.leftBracket, this.rightBracket);
1426
+ this.tokens = {
1427
+ leftBracket: options.leftBracket,
1428
+ rightBracket: options.rightBracket
1429
+ };
1430
+ this.innerType = options.innerType;
1431
+ this.range = util_1.default.createBoundingRange(this.innerType, this.tokens.leftBracket, this.tokens.rightBracket);
1393
1432
  }
1394
1433
  transpile(state) {
1395
1434
  return [this.getType({ flags: SymbolTable_1.SymbolTypeFlag.typetime }).toTypeString()];