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
@@ -20,15 +20,13 @@ const NamespaceType_1 = require("../types/NamespaceType");
20
20
  const InterfaceType_1 = require("../types/InterfaceType");
21
21
  const VoidType_1 = require("../types/VoidType");
22
22
  const TypedFunctionType_1 = require("../types/TypedFunctionType");
23
+ const types_1 = require("../types");
23
24
  class EmptyStatement extends AstNode_2.Statement {
24
- constructor(
25
- /**
26
- * Create a negative range to indicate this is an interpolated location
27
- */
28
- range = creators_1.interpolatedRange) {
25
+ constructor(options) {
26
+ var _a;
29
27
  super();
30
- this.range = range;
31
28
  this.kind = AstNode_1.AstNodeKind.EmptyStatement;
29
+ this.range = (_a = options === null || options === void 0 ? void 0 : options.range) !== null && _a !== void 0 ? _a : creators_1.interpolatedRange;
32
30
  }
33
31
  transpile(state) {
34
32
  return [];
@@ -42,11 +40,13 @@ exports.EmptyStatement = EmptyStatement;
42
40
  * This is a top-level statement. Consider this the root of the AST
43
41
  */
44
42
  class Body extends AstNode_2.Statement {
45
- constructor(statements = []) {
43
+ constructor(options) {
44
+ var _a;
46
45
  super();
47
- this.statements = statements;
46
+ this.statements = [];
48
47
  this.kind = AstNode_1.AstNodeKind.Body;
49
48
  this.symbolTable = new SymbolTable_2.SymbolTable('Body', () => { var _a; return (_a = this.parent) === null || _a === void 0 ? void 0 : _a.getSymbolTable(); });
49
+ this.statements = (_a = options === null || options === void 0 ? void 0 : options.statements) !== null && _a !== void 0 ? _a : [];
50
50
  }
51
51
  get range() {
52
52
  var _a;
@@ -100,27 +100,29 @@ class Body extends AstNode_2.Statement {
100
100
  }
101
101
  exports.Body = Body;
102
102
  class AssignmentStatement extends AstNode_2.Statement {
103
- constructor(equals, name, value, asToken, typeExpression) {
103
+ constructor(options) {
104
104
  super();
105
- this.equals = equals;
106
- this.name = name;
107
- this.value = value;
108
- this.asToken = asToken;
109
- this.typeExpression = typeExpression;
110
105
  this.kind = AstNode_1.AstNodeKind.AssignmentStatement;
111
- this.range = util_1.util.createBoundingRange(name, equals, value);
106
+ this.value = options.value;
107
+ this.tokens = {
108
+ equals: options.equals,
109
+ name: options.name,
110
+ as: options.as
111
+ };
112
+ this.typeExpression = options.typeExpression;
113
+ this.range = util_1.util.createBoundingRange(util_1.util.createBoundingRangeFromTokens(this.tokens), this.value);
112
114
  }
113
115
  transpile(state) {
114
- var _a, _b;
116
+ var _a, _b, _c, _d;
115
117
  //if the value is a compound assignment, just transpile the expression itself
116
- if (TokenKind_1.CompoundAssignmentOperators.includes((_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.operator) === null || _b === void 0 ? void 0 : _b.kind)) {
118
+ if (TokenKind_1.CompoundAssignmentOperators.includes((_c = (_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.tokens) === null || _b === void 0 ? void 0 : _b.operator) === null || _c === void 0 ? void 0 : _c.kind)) {
117
119
  return this.value.transpile(state);
118
120
  }
119
121
  else {
120
122
  return [
121
- state.transpileToken(this.name),
123
+ state.transpileToken(this.tokens.name),
122
124
  ' ',
123
- state.transpileToken(this.equals),
125
+ state.transpileToken((_d = this.tokens.equals) !== null && _d !== void 0 ? _d : (0, creators_1.createToken)(TokenKind_1.TokenKind.Equal)),
124
126
  ' ',
125
127
  ...this.value.transpile(state)
126
128
  ];
@@ -133,23 +135,23 @@ class AssignmentStatement extends AstNode_2.Statement {
133
135
  }
134
136
  }
135
137
  getType(options) {
136
- // TODO: Do we still need this.typeExpression?
137
- var _a;
138
+ var _a, _b, _c;
139
+ const variableType = (_b = (_a = this.typeExpression) === null || _a === void 0 ? void 0 : _a.getType(Object.assign(Object.assign({}, options), { typeChain: undefined }))) !== null && _b !== void 0 ? _b : this.value.getType(Object.assign(Object.assign({}, options), { typeChain: undefined }));
138
140
  // Note: compound assignments (eg. +=) are internally dealt with via the RHS being a BinaryExpression
139
141
  // so this.value will be a BinaryExpression, and BinaryExpressions can figure out their own types
140
- const rhs = this.value.getType(Object.assign(Object.assign({}, options), { typeChain: undefined }));
141
- (_a = options.typeChain) === null || _a === void 0 ? void 0 : _a.push(new interfaces_1.TypeChainEntry(this.name.text, rhs, options.data, this.name.range));
142
- return rhs;
142
+ (_c = options.typeChain) === null || _c === void 0 ? void 0 : _c.push(new interfaces_1.TypeChainEntry(this.tokens.name.text, variableType, options.data, this.tokens.name.range));
143
+ return variableType;
143
144
  }
144
145
  }
145
146
  exports.AssignmentStatement = AssignmentStatement;
146
147
  class Block extends AstNode_2.Statement {
147
- constructor(statements, startingRange) {
148
+ constructor(options) {
149
+ var _a;
148
150
  super();
149
- this.statements = statements;
150
- this.startingRange = startingRange;
151
151
  this.kind = AstNode_1.AstNodeKind.Block;
152
- this.range = util_1.util.createBoundingRange({ range: this.startingRange }, ...(statements !== null && statements !== void 0 ? statements : []));
152
+ this.statements = options.statements;
153
+ this.startingRange = options.startingRange;
154
+ this.range = util_1.util.createBoundingRange({ range: this.startingRange }, ...((_a = this.statements) !== null && _a !== void 0 ? _a : []));
153
155
  }
154
156
  transpile(state) {
155
157
  state.blockDepth++;
@@ -183,10 +185,10 @@ class Block extends AstNode_2.Statement {
183
185
  }
184
186
  exports.Block = Block;
185
187
  class ExpressionStatement extends AstNode_2.Statement {
186
- constructor(expression) {
188
+ constructor(options) {
187
189
  super();
188
- this.expression = expression;
189
190
  this.kind = AstNode_1.AstNodeKind.ExpressionStatement;
191
+ this.expression = options.expression;
190
192
  this.range = this.expression.range;
191
193
  }
192
194
  transpile(state) {
@@ -200,29 +202,31 @@ class ExpressionStatement extends AstNode_2.Statement {
200
202
  }
201
203
  exports.ExpressionStatement = ExpressionStatement;
202
204
  class CommentStatement extends AstNode_2.Statement {
203
- constructor(comments) {
205
+ constructor(options) {
204
206
  var _a;
205
207
  super();
206
- this.comments = comments;
207
208
  this.kind = AstNode_1.AstNodeKind.CommentStatement;
208
209
  this.visitMode = visitors_1.InternalWalkMode.visitStatements | visitors_1.InternalWalkMode.visitExpressions;
209
- if (((_a = this.comments) === null || _a === void 0 ? void 0 : _a.length) > 0) {
210
- this.range = util_1.util.createBoundingRange(...this.comments);
210
+ this.tokens = {
211
+ comments: options.comments
212
+ };
213
+ if (((_a = this.tokens.comments) === null || _a === void 0 ? void 0 : _a.length) > 0) {
214
+ this.range = util_1.util.createBoundingRange(...this.tokens.comments);
211
215
  }
212
216
  }
213
217
  get text() {
214
- return this.comments.map(x => x.text).join('\n');
218
+ return this.tokens.comments.map(x => x.text).join('\n');
215
219
  }
216
220
  transpile(state) {
217
221
  let result = [];
218
- for (let i = 0; i < this.comments.length; i++) {
219
- let comment = this.comments[i];
222
+ for (let i = 0; i < this.tokens.comments.length; i++) {
223
+ let comment = this.tokens.comments[i];
220
224
  if (i > 0) {
221
225
  result.push(state.indent());
222
226
  }
223
227
  result.push(state.transpileToken(comment));
224
228
  //add newline for all except final comment
225
- if (i < this.comments.length - 1) {
229
+ if (i < this.tokens.comments.length - 1) {
226
230
  result.push('\n');
227
231
  }
228
232
  }
@@ -237,15 +241,18 @@ class CommentStatement extends AstNode_2.Statement {
237
241
  }
238
242
  exports.CommentStatement = CommentStatement;
239
243
  class ExitForStatement extends AstNode_2.Statement {
240
- constructor(tokens) {
244
+ constructor(options) {
245
+ var _a;
241
246
  super();
242
- this.tokens = tokens;
243
247
  this.kind = AstNode_1.AstNodeKind.ExitForStatement;
244
- this.range = this.tokens.exitFor.range;
248
+ this.tokens = {
249
+ exitFor: options === null || options === void 0 ? void 0 : options.exitFor
250
+ };
251
+ this.range = (_a = this.tokens.exitFor) === null || _a === void 0 ? void 0 : _a.range;
245
252
  }
246
253
  transpile(state) {
247
254
  return [
248
- state.transpileToken(this.tokens.exitFor)
255
+ this.tokens.exitFor ? state.transpileToken(this.tokens.exitFor) : 'exit for'
249
256
  ];
250
257
  }
251
258
  walk(visitor, options) {
@@ -254,15 +261,18 @@ class ExitForStatement extends AstNode_2.Statement {
254
261
  }
255
262
  exports.ExitForStatement = ExitForStatement;
256
263
  class ExitWhileStatement extends AstNode_2.Statement {
257
- constructor(tokens) {
264
+ constructor(options) {
265
+ var _a;
258
266
  super();
259
- this.tokens = tokens;
260
267
  this.kind = AstNode_1.AstNodeKind.ExitWhileStatement;
261
- this.range = this.tokens.exitWhile.range;
268
+ this.tokens = {
269
+ exitWhile: options === null || options === void 0 ? void 0 : options.exitWhile
270
+ };
271
+ this.range = (_a = this.tokens.exitWhile) === null || _a === void 0 ? void 0 : _a.range;
262
272
  }
263
273
  transpile(state) {
264
274
  return [
265
- state.transpileToken(this.tokens.exitWhile)
275
+ this.tokens.exitWhile ? state.transpileToken(this.tokens.exitWhile) : 'exit while'
266
276
  ];
267
277
  }
268
278
  walk(visitor, options) {
@@ -271,11 +281,13 @@ class ExitWhileStatement extends AstNode_2.Statement {
271
281
  }
272
282
  exports.ExitWhileStatement = ExitWhileStatement;
273
283
  class FunctionStatement extends AstNode_2.Statement {
274
- constructor(name, func) {
284
+ constructor(options) {
275
285
  super();
276
- this.name = name;
277
- this.func = func;
278
286
  this.kind = AstNode_1.AstNodeKind.FunctionStatement;
287
+ this.tokens = {
288
+ name: options.name
289
+ };
290
+ this.func = options.func;
279
291
  this.range = this.func.range;
280
292
  }
281
293
  /**
@@ -287,10 +299,10 @@ class FunctionStatement extends AstNode_2.Statement {
287
299
  if (namespace) {
288
300
  let delimiter = parseMode === Parser_1.ParseMode.BrighterScript ? '.' : '_';
289
301
  let namespaceName = namespace.getName(parseMode);
290
- return namespaceName + delimiter + ((_a = this.name) === null || _a === void 0 ? void 0 : _a.text);
302
+ return namespaceName + delimiter + ((_a = this.tokens.name) === null || _a === void 0 ? void 0 : _a.text);
291
303
  }
292
304
  else {
293
- return this.name.text;
305
+ return this.tokens.name.text;
294
306
  }
295
307
  }
296
308
  getLeadingTrivia() {
@@ -298,7 +310,7 @@ class FunctionStatement extends AstNode_2.Statement {
298
310
  }
299
311
  transpile(state) {
300
312
  //create a fake token using the full transpiled name
301
- let nameToken = Object.assign(Object.assign({}, this.name), { text: this.getName(Parser_1.ParseMode.BrightScript) });
313
+ let nameToken = Object.assign(Object.assign({}, this.tokens.name), { text: this.getName(Parser_1.ParseMode.BrightScript) });
302
314
  return this.func.transpile(state, nameToken);
303
315
  }
304
316
  getTypedef(state) {
@@ -318,26 +330,32 @@ class FunctionStatement extends AstNode_2.Statement {
318
330
  getType(options) {
319
331
  var _a;
320
332
  const funcExprType = this.func.getType(options);
321
- funcExprType.setName((_a = this.name) === null || _a === void 0 ? void 0 : _a.text);
333
+ funcExprType.setName((_a = this.tokens.name) === null || _a === void 0 ? void 0 : _a.text);
322
334
  return funcExprType;
323
335
  }
324
336
  }
325
337
  exports.FunctionStatement = FunctionStatement;
326
338
  class IfStatement extends AstNode_2.Statement {
327
- constructor(tokens, condition, thenBranch, elseBranch, isInline) {
339
+ constructor(options) {
328
340
  super();
329
- this.tokens = tokens;
330
- this.condition = condition;
331
- this.thenBranch = thenBranch;
332
- this.elseBranch = elseBranch;
333
- this.isInline = isInline;
334
341
  this.kind = AstNode_1.AstNodeKind.IfStatement;
335
- this.range = util_1.util.createBoundingRange(tokens.if, condition, tokens.then, thenBranch, tokens.else, elseBranch, tokens.endIf);
342
+ this.condition = options.condition;
343
+ this.thenBranch = options.thenBranch;
344
+ this.elseBranch = options.elseBranch;
345
+ this.isInline = options.isInline;
346
+ this.tokens = {
347
+ if: options.if,
348
+ then: options.then,
349
+ else: options.else,
350
+ endIf: options.endIf
351
+ };
352
+ this.range = util_1.util.createBoundingRange(util_1.util.createBoundingRangeFromTokens(this.tokens), this.condition, this.thenBranch, this.elseBranch);
336
353
  }
337
354
  transpile(state) {
355
+ var _a;
338
356
  let results = [];
339
357
  //if (already indented by block)
340
- results.push(state.transpileToken(this.tokens.if));
358
+ results.push(state.transpileToken((_a = this.tokens.if) !== null && _a !== void 0 ? _a : (0, creators_1.createToken)(TokenKind_1.TokenKind.If)));
341
359
  results.push(' ');
342
360
  //conditions
343
361
  results.push(...this.condition.transpile(state));
@@ -411,17 +429,19 @@ class IfStatement extends AstNode_2.Statement {
411
429
  }
412
430
  exports.IfStatement = IfStatement;
413
431
  class IncrementStatement extends AstNode_2.Statement {
414
- constructor(value, operator) {
432
+ constructor(options) {
415
433
  super();
416
- this.value = value;
417
- this.operator = operator;
418
434
  this.kind = AstNode_1.AstNodeKind.IncrementStatement;
419
- this.range = util_1.util.createBoundingRange(value, operator);
435
+ this.value = options.value;
436
+ this.tokens = {
437
+ operator: options.operator
438
+ };
439
+ this.range = util_1.util.createBoundingRange(this.value, this.tokens.operator);
420
440
  }
421
441
  transpile(state) {
422
442
  return [
423
443
  ...this.value.transpile(state),
424
- state.transpileToken(this.operator)
444
+ state.transpileToken(this.tokens.operator)
425
445
  ];
426
446
  }
427
447
  walk(visitor, options) {
@@ -437,16 +457,19 @@ exports.IncrementStatement = IncrementStatement;
437
457
  class PrintStatement extends AstNode_2.Statement {
438
458
  /**
439
459
  * Creates a new internal representation of a BrightScript `print` statement.
440
- * @param tokens the tokens for this statement
441
- * @param tokens.print a print token
442
- * @param expressions an array of expressions or `PrintSeparator`s to be evaluated and printed.
460
+ * @param options the options for this statement
461
+ * @param options.print a print token
462
+ * @param options.expressions an array of expressions or `PrintSeparator`s to be evaluated and printed.
443
463
  */
444
- constructor(tokens, expressions) {
464
+ constructor(options) {
465
+ var _a;
445
466
  super();
446
- this.tokens = tokens;
447
- this.expressions = expressions;
448
467
  this.kind = AstNode_1.AstNodeKind.PrintStatement;
449
- this.range = util_1.util.createBoundingRange(tokens.print, ...(expressions !== null && expressions !== void 0 ? expressions : []));
468
+ this.tokens = {
469
+ print: options.print
470
+ };
471
+ this.expressions = options.expressions;
472
+ this.range = util_1.util.createBoundingRange(this.tokens.print, ...((_a = this.expressions) !== null && _a !== void 0 ? _a : []));
450
473
  }
451
474
  transpile(state) {
452
475
  var _a;
@@ -478,22 +501,25 @@ class PrintStatement extends AstNode_2.Statement {
478
501
  }
479
502
  exports.PrintStatement = PrintStatement;
480
503
  class DimStatement extends AstNode_2.Statement {
481
- constructor(dimToken, identifier, openingSquare, dimensions, closingSquare) {
504
+ constructor(options) {
505
+ var _a;
482
506
  super();
483
- this.dimToken = dimToken;
484
- this.identifier = identifier;
485
- this.openingSquare = openingSquare;
486
- this.dimensions = dimensions;
487
- this.closingSquare = closingSquare;
488
507
  this.kind = AstNode_1.AstNodeKind.DimStatement;
489
- this.range = util_1.util.createBoundingRange(dimToken, identifier, openingSquare, ...(dimensions !== null && dimensions !== void 0 ? dimensions : []), closingSquare);
508
+ this.tokens = {
509
+ dim: options === null || options === void 0 ? void 0 : options.dim,
510
+ name: options.name,
511
+ openingSquare: options.openingSquare,
512
+ closingSquare: options.closingSquare
513
+ };
514
+ this.dimensions = options.dimensions;
515
+ this.range = util_1.util.createBoundingRange(options.dim, options.name, options.openingSquare, ...((_a = this.dimensions) !== null && _a !== void 0 ? _a : []), options.closingSquare);
490
516
  }
491
517
  transpile(state) {
492
518
  let result = [
493
- state.transpileToken(this.dimToken),
519
+ state.transpileToken(this.tokens.dim, 'dim'),
494
520
  ' ',
495
- state.transpileToken(this.identifier),
496
- state.transpileToken(this.openingSquare)
521
+ state.transpileToken(this.tokens.name),
522
+ state.transpileToken(this.tokens.openingSquare, '[')
497
523
  ];
498
524
  for (let i = 0; i < this.dimensions.length; i++) {
499
525
  if (i > 0) {
@@ -501,7 +527,7 @@ class DimStatement extends AstNode_2.Statement {
501
527
  }
502
528
  result.push(...this.dimensions[i].transpile(state));
503
529
  }
504
- result.push(state.transpileToken(this.closingSquare));
530
+ result.push(state.transpileToken(this.tokens.closingSquare, ']'));
505
531
  return result;
506
532
  }
507
533
  walk(visitor, options) {
@@ -510,18 +536,30 @@ class DimStatement extends AstNode_2.Statement {
510
536
  (0, visitors_1.walkArray)(this.dimensions, visitor, options, this);
511
537
  }
512
538
  }
539
+ getType(options) {
540
+ var _a, _b;
541
+ const numDimensions = (_b = (_a = this.dimensions) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 1;
542
+ let type = new types_1.ArrayType();
543
+ for (let i = 0; i < numDimensions - 1; i++) {
544
+ type = new types_1.ArrayType(type);
545
+ }
546
+ return type;
547
+ }
513
548
  }
514
549
  exports.DimStatement = DimStatement;
515
550
  class GotoStatement extends AstNode_2.Statement {
516
- constructor(tokens) {
551
+ constructor(options) {
517
552
  super();
518
- this.tokens = tokens;
519
553
  this.kind = AstNode_1.AstNodeKind.GotoStatement;
520
- this.range = util_1.util.createBoundingRange(tokens.goto, tokens.label);
554
+ this.tokens = {
555
+ goto: options.goto,
556
+ label: options.label
557
+ };
558
+ this.range = util_1.util.createBoundingRange(this.tokens.goto, this.tokens.label);
521
559
  }
522
560
  transpile(state) {
523
561
  return [
524
- state.transpileToken(this.tokens.goto),
562
+ state.transpileToken(this.tokens.goto, 'goto'),
525
563
  ' ',
526
564
  state.transpileToken(this.tokens.label)
527
565
  ];
@@ -532,19 +570,22 @@ class GotoStatement extends AstNode_2.Statement {
532
570
  }
533
571
  exports.GotoStatement = GotoStatement;
534
572
  class LabelStatement extends AstNode_2.Statement {
535
- constructor(tokens) {
573
+ constructor(options) {
536
574
  super();
537
- this.tokens = tokens;
538
575
  this.kind = AstNode_1.AstNodeKind.LabelStatement;
539
- this.range = util_1.util.createBoundingRange(tokens.identifier, tokens.colon);
576
+ this.tokens = {
577
+ name: options.name,
578
+ colon: options.colon
579
+ };
580
+ this.range = util_1.util.createBoundingRange(this.tokens.name, this.tokens.colon);
540
581
  }
541
582
  getLeadingTrivia() {
542
- return util_1.util.concatAnnotationLeadingTrivia(this, this.tokens.identifier.leadingTrivia);
583
+ return util_1.util.concatAnnotationLeadingTrivia(this, this.tokens.name.leadingTrivia);
543
584
  }
544
585
  transpile(state) {
545
586
  return [
546
- state.transpileToken(this.tokens.identifier),
547
- state.transpileToken(this.tokens.colon)
587
+ state.transpileToken(this.tokens.name),
588
+ state.transpileToken(this.tokens.colon, ':')
548
589
  ];
549
590
  }
550
591
  walk(visitor, options) {
@@ -553,16 +594,18 @@ class LabelStatement extends AstNode_2.Statement {
553
594
  }
554
595
  exports.LabelStatement = LabelStatement;
555
596
  class ReturnStatement extends AstNode_2.Statement {
556
- constructor(tokens, value) {
597
+ constructor(options) {
557
598
  super();
558
- this.tokens = tokens;
559
- this.value = value;
560
599
  this.kind = AstNode_1.AstNodeKind.ReturnStatement;
561
- this.range = util_1.util.createBoundingRange(tokens.return, value);
600
+ this.tokens = {
601
+ return: options === null || options === void 0 ? void 0 : options.return
602
+ };
603
+ this.value = options === null || options === void 0 ? void 0 : options.value;
604
+ this.range = util_1.util.createBoundingRange(this.tokens.return, this.value);
562
605
  }
563
606
  transpile(state) {
564
607
  let result = [];
565
- result.push(state.transpileToken(this.tokens.return));
608
+ result.push(state.transpileToken(this.tokens.return, 'return'));
566
609
  if (this.value) {
567
610
  result.push(' ');
568
611
  result.push(...this.value.transpile(state));
@@ -577,15 +620,18 @@ class ReturnStatement extends AstNode_2.Statement {
577
620
  }
578
621
  exports.ReturnStatement = ReturnStatement;
579
622
  class EndStatement extends AstNode_2.Statement {
580
- constructor(tokens) {
623
+ constructor(options) {
624
+ var _a;
581
625
  super();
582
- this.tokens = tokens;
583
626
  this.kind = AstNode_1.AstNodeKind.EndStatement;
584
- this.range = tokens.end.range;
627
+ this.tokens = {
628
+ end: options === null || options === void 0 ? void 0 : options.end
629
+ };
630
+ this.range = (_a = this.tokens.end) === null || _a === void 0 ? void 0 : _a.range;
585
631
  }
586
632
  transpile(state) {
587
633
  return [
588
- state.transpileToken(this.tokens.end)
634
+ state.transpileToken(this.tokens.end, 'end')
589
635
  ];
590
636
  }
591
637
  walk(visitor, options) {
@@ -594,16 +640,16 @@ class EndStatement extends AstNode_2.Statement {
594
640
  }
595
641
  exports.EndStatement = EndStatement;
596
642
  class StopStatement extends AstNode_2.Statement {
597
- constructor(tokens) {
598
- var _a;
643
+ constructor(options) {
644
+ var _a, _b;
599
645
  super();
600
- this.tokens = tokens;
601
646
  this.kind = AstNode_1.AstNodeKind.StopStatement;
602
- this.range = (_a = tokens === null || tokens === void 0 ? void 0 : tokens.stop) === null || _a === void 0 ? void 0 : _a.range;
647
+ this.tokens = { stop: options === null || options === void 0 ? void 0 : options.stop };
648
+ this.range = (_b = (_a = this.tokens) === null || _a === void 0 ? void 0 : _a.stop) === null || _b === void 0 ? void 0 : _b.range;
603
649
  }
604
650
  transpile(state) {
605
651
  return [
606
- state.transpileToken(this.tokens.stop)
652
+ state.transpileToken(this.tokens.stop, 'stop')
607
653
  ];
608
654
  }
609
655
  walk(visitor, options) {
@@ -612,32 +658,34 @@ class StopStatement extends AstNode_2.Statement {
612
658
  }
613
659
  exports.StopStatement = StopStatement;
614
660
  class ForStatement extends AstNode_2.Statement {
615
- constructor(forToken, counterDeclaration, toToken, finalValue, body, endForToken, stepToken, increment) {
661
+ constructor(options) {
616
662
  super();
617
- this.forToken = forToken;
618
- this.counterDeclaration = counterDeclaration;
619
- this.toToken = toToken;
620
- this.finalValue = finalValue;
621
- this.body = body;
622
- this.endForToken = endForToken;
623
- this.stepToken = stepToken;
624
- this.increment = increment;
625
663
  this.kind = AstNode_1.AstNodeKind.ForStatement;
626
- this.range = util_1.util.createBoundingRange(forToken, counterDeclaration, toToken, finalValue, stepToken, increment, body, endForToken);
664
+ this.tokens = {
665
+ for: options.for,
666
+ to: options.to,
667
+ endFor: options.endFor,
668
+ step: options.step
669
+ };
670
+ this.counterDeclaration = options.counterDeclaration;
671
+ this.finalValue = options.finalValue;
672
+ this.body = options.body;
673
+ this.increment = options.increment;
674
+ this.range = util_1.util.createBoundingRange(this.tokens.for, this.counterDeclaration, this.tokens.to, this.finalValue, this.tokens.step, this.increment, this.body, this.tokens.endFor);
627
675
  }
628
676
  transpile(state) {
629
677
  let result = [];
630
678
  //for
631
- result.push(state.transpileToken(this.forToken), ' ');
679
+ result.push(state.transpileToken(this.tokens.for, 'for'), ' ');
632
680
  //i=1
633
681
  result.push(...this.counterDeclaration.transpile(state), ' ');
634
682
  //to
635
- result.push(state.transpileToken(this.toToken), ' ');
683
+ result.push(state.transpileToken(this.tokens.to, 'to'), ' ');
636
684
  //final value
637
685
  result.push(this.finalValue.transpile(state));
638
686
  //step
639
- if (this.stepToken) {
640
- result.push(' ', state.transpileToken(this.stepToken), ' ', this.increment.transpile(state));
687
+ if (this.increment) {
688
+ result.push(' ', state.transpileToken(this.tokens.step, 'step'), ' ', this.increment.transpile(state));
641
689
  }
642
690
  //loop body
643
691
  state.lineage.unshift(this);
@@ -646,7 +694,7 @@ class ForStatement extends AstNode_2.Statement {
646
694
  // add new line before "end for"
647
695
  result.push('\n');
648
696
  //end for
649
- result.push(state.indent(), state.transpileToken(this.endForToken));
697
+ result.push(state.indent(), state.transpileToken(this.tokens.endFor, 'end for'));
650
698
  return result;
651
699
  }
652
700
  walk(visitor, options) {
@@ -664,23 +712,27 @@ class ForStatement extends AstNode_2.Statement {
664
712
  }
665
713
  exports.ForStatement = ForStatement;
666
714
  class ForEachStatement extends AstNode_2.Statement {
667
- constructor(tokens, item, target, body) {
715
+ constructor(options) {
668
716
  super();
669
- this.tokens = tokens;
670
- this.item = item;
671
- this.target = target;
672
- this.body = body;
673
717
  this.kind = AstNode_1.AstNodeKind.ForEachStatement;
674
- this.range = util_1.util.createBoundingRange(tokens.forEach, item, tokens.in, target, body, tokens.endFor);
718
+ this.tokens = {
719
+ forEach: options.forEach,
720
+ item: options.item,
721
+ in: options.in,
722
+ endFor: options.endFor
723
+ };
724
+ this.body = options.body;
725
+ this.target = options.target;
726
+ this.range = util_1.util.createBoundingRange(this.tokens.forEach, this.tokens.item, this.tokens.in, this.target, this.body, this.tokens.endFor);
675
727
  }
676
728
  transpile(state) {
677
729
  let result = [];
678
730
  //for each
679
- result.push(state.transpileToken(this.tokens.forEach), ' ');
731
+ result.push(state.transpileToken(this.tokens.forEach, 'for each'), ' ');
680
732
  //item
681
- result.push(state.transpileToken(this.item), ' ');
733
+ result.push(state.transpileToken(this.tokens.item), ' ');
682
734
  //in
683
- result.push(state.transpileToken(this.tokens.in), ' ');
735
+ result.push(state.transpileToken(this.tokens.in, 'in'), ' ');
684
736
  //target
685
737
  result.push(...this.target.transpile(state));
686
738
  //body
@@ -690,7 +742,7 @@ class ForEachStatement extends AstNode_2.Statement {
690
742
  // add new line before "end for"
691
743
  result.push('\n');
692
744
  //end for
693
- result.push(state.indent(), state.transpileToken(this.tokens.endFor));
745
+ result.push(state.indent(), state.transpileToken(this.tokens.endFor, 'end for'));
694
746
  return result;
695
747
  }
696
748
  walk(visitor, options) {
@@ -704,18 +756,21 @@ class ForEachStatement extends AstNode_2.Statement {
704
756
  }
705
757
  exports.ForEachStatement = ForEachStatement;
706
758
  class WhileStatement extends AstNode_2.Statement {
707
- constructor(tokens, condition, body) {
759
+ constructor(options) {
708
760
  super();
709
- this.tokens = tokens;
710
- this.condition = condition;
711
- this.body = body;
712
761
  this.kind = AstNode_1.AstNodeKind.WhileStatement;
713
- this.range = util_1.util.createBoundingRange(tokens.while, condition, body, tokens.endWhile);
762
+ this.tokens = {
763
+ while: options.while,
764
+ endWhile: options.endWhile
765
+ };
766
+ this.body = options.body;
767
+ this.condition = options.condition;
768
+ this.range = util_1.util.createBoundingRange(this.tokens.while, this.condition, this.body, this.tokens.endWhile);
714
769
  }
715
770
  transpile(state) {
716
771
  let result = [];
717
772
  //while
718
- result.push(state.transpileToken(this.tokens.while), ' ');
773
+ result.push(state.transpileToken(this.tokens.while, 'while'), ' ');
719
774
  //condition
720
775
  result.push(...this.condition.transpile(state));
721
776
  state.lineage.unshift(this);
@@ -725,7 +780,7 @@ class WhileStatement extends AstNode_2.Statement {
725
780
  //trailing newline only if we have body statements
726
781
  result.push('\n');
727
782
  //end while
728
- result.push(state.indent(), state.transpileToken(this.tokens.endWhile));
783
+ result.push(state.indent(), state.transpileToken(this.tokens.endWhile, 'end while'));
729
784
  return result;
730
785
  }
731
786
  walk(visitor, options) {
@@ -739,28 +794,30 @@ class WhileStatement extends AstNode_2.Statement {
739
794
  }
740
795
  exports.WhileStatement = WhileStatement;
741
796
  class DottedSetStatement extends AstNode_2.Statement {
742
- constructor(obj, name, value, dot) {
797
+ constructor(options) {
743
798
  super();
744
- this.obj = obj;
745
- this.name = name;
746
- this.value = value;
747
- this.dot = dot;
748
799
  this.kind = AstNode_1.AstNodeKind.DottedSetStatement;
749
- this.range = util_1.util.createBoundingRange(obj, dot, name, value);
800
+ this.tokens = {
801
+ name: options.name,
802
+ dot: options.dot
803
+ };
804
+ this.obj = options.obj;
805
+ this.value = options.value;
806
+ this.range = util_1.util.createBoundingRange(this.obj, this.tokens.dot, this.tokens.name, this.value);
750
807
  }
751
808
  transpile(state) {
752
- var _a, _b;
809
+ var _a, _b, _c;
753
810
  //if the value is a compound assignment, don't add the obj, dot, name, or operator...the expression will handle that
754
- if (TokenKind_1.CompoundAssignmentOperators.includes((_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.operator) === null || _b === void 0 ? void 0 : _b.kind)) {
811
+ if (TokenKind_1.CompoundAssignmentOperators.includes((_c = (_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.tokens) === null || _b === void 0 ? void 0 : _b.operator) === null || _c === void 0 ? void 0 : _c.kind)) {
755
812
  return this.value.transpile(state);
756
813
  }
757
814
  else {
758
815
  return [
759
816
  //object
760
817
  ...this.obj.transpile(state),
761
- this.dot ? state.tokenToSourceNode(this.dot) : '.',
818
+ this.tokens.dot ? state.tokenToSourceNode(this.tokens.dot) : '.',
762
819
  //name
763
- state.transpileToken(this.name),
820
+ state.transpileToken(this.tokens.name),
764
821
  ' = ',
765
822
  //right-hand-side of assignment
766
823
  ...this.value.transpile(state)
@@ -776,60 +833,67 @@ class DottedSetStatement extends AstNode_2.Statement {
776
833
  getType(options) {
777
834
  var _a, _b, _c, _d, _e, _f;
778
835
  const objType = (_a = this.obj) === null || _a === void 0 ? void 0 : _a.getType(options);
779
- const result = objType === null || objType === void 0 ? void 0 : objType.getMemberType((_b = this.name) === null || _b === void 0 ? void 0 : _b.text, options);
780
- (_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));
836
+ const result = objType === null || objType === void 0 ? void 0 : objType.getMemberType((_b = this.tokens.name) === null || _b === void 0 ? void 0 : _b.text, options);
837
+ (_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));
781
838
  return result;
782
839
  }
783
840
  }
784
841
  exports.DottedSetStatement = DottedSetStatement;
785
842
  class IndexedSetStatement extends AstNode_2.Statement {
786
- constructor(obj, index, value, openingSquare, closingSquare) {
843
+ constructor(options) {
787
844
  super();
788
- this.obj = obj;
789
- this.index = index;
790
- this.value = value;
791
- this.openingSquare = openingSquare;
792
- this.closingSquare = closingSquare;
793
845
  this.kind = AstNode_1.AstNodeKind.IndexedSetStatement;
794
- this.range = util_1.util.createBoundingRange(obj, openingSquare, index, closingSquare, value);
846
+ this.tokens = {
847
+ openingSquare: options.openingSquare,
848
+ closingSquare: options.closingSquare
849
+ };
850
+ this.obj = options.obj;
851
+ this.indexes = options.indexes;
852
+ this.value = options.value;
853
+ this.range = util_1.util.createBoundingRange(this.obj, this.tokens.openingSquare, ...this.indexes, this.tokens.closingSquare, this.value);
795
854
  }
796
855
  transpile(state) {
797
- var _a, _b;
856
+ var _a, _b, _c, _d;
798
857
  //if the value is a component assignment, don't add the obj, index or operator...the expression will handle that
799
- if (TokenKind_1.CompoundAssignmentOperators.includes((_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.operator) === null || _b === void 0 ? void 0 : _b.kind)) {
858
+ if (TokenKind_1.CompoundAssignmentOperators.includes((_c = (_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.tokens) === null || _b === void 0 ? void 0 : _b.operator) === null || _c === void 0 ? void 0 : _c.kind)) {
800
859
  return this.value.transpile(state);
801
860
  }
802
861
  else {
803
- return [
804
- //obj
805
- ...this.obj.transpile(state),
806
- // [
807
- state.transpileToken(this.openingSquare),
808
- // index
809
- ...this.index.transpile(state),
810
- // ]
811
- state.transpileToken(this.closingSquare),
812
- // =
813
- ' = ',
814
- // value
815
- ...this.value.transpile(state)
816
- ];
862
+ const result = [];
863
+ result.push(
864
+ //obj
865
+ ...this.obj.transpile(state),
866
+ // [
867
+ state.transpileToken(this.tokens.openingSquare));
868
+ for (let i = 0; i < this.indexes.length; i++) {
869
+ //add comma between indexes
870
+ if (i > 0) {
871
+ result.push(', ');
872
+ }
873
+ let index = this.indexes[i];
874
+ result.push(...((_d = index === null || index === void 0 ? void 0 : index.transpile(state)) !== null && _d !== void 0 ? _d : []));
875
+ }
876
+ result.push(state.transpileToken(this.tokens.closingSquare), ' = ', ...this.value.transpile(state));
877
+ return result;
817
878
  }
818
879
  }
819
880
  walk(visitor, options) {
820
881
  if (options.walkMode & visitors_1.InternalWalkMode.walkExpressions) {
821
882
  (0, visitors_1.walk)(this, 'obj', visitor, options);
822
- (0, visitors_1.walk)(this, 'index', visitor, options);
883
+ (0, visitors_1.walkArray)(this.indexes, visitor, options, this);
823
884
  (0, visitors_1.walk)(this, 'value', visitor, options);
824
885
  }
825
886
  }
826
887
  }
827
888
  exports.IndexedSetStatement = IndexedSetStatement;
828
889
  class LibraryStatement extends AstNode_2.Statement {
829
- constructor(tokens) {
890
+ constructor(options) {
830
891
  super();
831
- this.tokens = tokens;
832
892
  this.kind = AstNode_1.AstNodeKind.LibraryStatement;
893
+ this.tokens = {
894
+ library: options.library,
895
+ filePath: options.filePath
896
+ };
833
897
  this.range = util_1.util.createBoundingRange(this.tokens.library, this.tokens.filePath);
834
898
  }
835
899
  transpile(state) {
@@ -850,13 +914,15 @@ class LibraryStatement extends AstNode_2.Statement {
850
914
  }
851
915
  exports.LibraryStatement = LibraryStatement;
852
916
  class NamespaceStatement extends AstNode_2.Statement {
853
- constructor(keyword, nameExpression, body, endKeyword) {
917
+ constructor(options) {
854
918
  super();
855
- this.keyword = keyword;
856
- this.nameExpression = nameExpression;
857
- this.body = body;
858
- this.endKeyword = endKeyword;
859
919
  this.kind = AstNode_1.AstNodeKind.NamespaceStatement;
920
+ this.tokens = {
921
+ namespace: options.namespace,
922
+ endNamespace: options.endNamespace
923
+ };
924
+ this.nameExpression = options.nameExpression;
925
+ this.body = options.body;
860
926
  this.name = this.getName(Parser_1.ParseMode.BrighterScript);
861
927
  this.symbolTable = new SymbolTable_2.SymbolTable(`NamespaceStatement: '${this.name}'`, () => { var _a; return (_a = this.parent) === null || _a === void 0 ? void 0 : _a.getSymbolTable(); });
862
928
  }
@@ -866,7 +932,7 @@ class NamespaceStatement extends AstNode_2.Statement {
866
932
  cacheRange() {
867
933
  var _a;
868
934
  if (!this._range) {
869
- this._range = (_a = util_1.util.createBoundingRange(this.keyword, this.nameExpression, this.body, this.endKeyword)) !== null && _a !== void 0 ? _a : creators_1.interpolatedRange;
935
+ this._range = (_a = util_1.util.createBoundingRange(this.tokens.namespace, this.nameExpression, this.body, this.tokens.endNamespace)) !== null && _a !== void 0 ? _a : creators_1.interpolatedRange;
870
936
  }
871
937
  return this._range;
872
938
  }
@@ -880,7 +946,8 @@ class NamespaceStatement extends AstNode_2.Statement {
880
946
  return name;
881
947
  }
882
948
  getLeadingTrivia() {
883
- return util_1.util.concatAnnotationLeadingTrivia(this, this.keyword.leadingTrivia);
949
+ var _a;
950
+ return util_1.util.concatAnnotationLeadingTrivia(this, (_a = this.tokens.namespace) === null || _a === void 0 ? void 0 : _a.leadingTrivia);
884
951
  }
885
952
  getNameParts() {
886
953
  var _a, _b;
@@ -921,17 +988,19 @@ class NamespaceStatement extends AstNode_2.Statement {
921
988
  }
922
989
  exports.NamespaceStatement = NamespaceStatement;
923
990
  class ImportStatement extends AstNode_2.Statement {
924
- constructor(importToken, filePathToken) {
991
+ constructor(options) {
925
992
  super();
926
- this.importToken = importToken;
927
- this.filePathToken = filePathToken;
928
993
  this.kind = AstNode_1.AstNodeKind.ImportStatement;
929
- this.range = util_1.util.createBoundingRange(importToken, filePathToken);
930
- if (this.filePathToken) {
994
+ this.tokens = {
995
+ import: options.import,
996
+ filePath: options.filePath
997
+ };
998
+ this.range = util_1.util.createBoundingRange(this.tokens.import, this.tokens.filePath);
999
+ if (this.tokens.filePath) {
931
1000
  //remove quotes
932
- this.filePath = this.filePathToken.text.replace(/"/g, '');
1001
+ this.filePath = this.tokens.filePath.text.replace(/"/g, '');
933
1002
  //adjust the range to exclude the quotes
934
- this.filePathToken.range = util_1.util.createRange(this.filePathToken.range.start.line, this.filePathToken.range.start.character + 1, this.filePathToken.range.end.line, this.filePathToken.range.end.character - 1);
1003
+ this.tokens.filePath.range = util_1.util.createRange(this.tokens.filePath.range.start.line, this.tokens.filePath.range.start.character + 1, this.tokens.filePath.range.end.line, this.tokens.filePath.range.end.character - 1);
935
1004
  }
936
1005
  }
937
1006
  transpile(state) {
@@ -939,20 +1008,21 @@ class ImportStatement extends AstNode_2.Statement {
939
1008
  //add the import statement as a comment just for debugging purposes
940
1009
  return [
941
1010
  `'`,
942
- state.transpileToken(this.importToken),
1011
+ state.transpileToken(this.tokens.import, 'import'),
943
1012
  ' ',
944
- state.transpileToken(this.filePathToken)
1013
+ state.transpileToken(this.tokens.filePath)
945
1014
  ];
946
1015
  }
947
1016
  /**
948
1017
  * Get the typedef for this statement
949
1018
  */
950
1019
  getTypedef(state) {
1020
+ var _a, _b;
951
1021
  return [
952
- this.importToken.text,
1022
+ (_b = (_a = this.tokens.import) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : 'import',
953
1023
  ' ',
954
1024
  //replace any `.bs` extension with `.brs`
955
- this.filePathToken.text.replace(/\.bs"?$/i, '.brs"')
1025
+ this.tokens.filePath.text.replace(/\.bs"?$/i, '.brs"')
956
1026
  ];
957
1027
  }
958
1028
  walk(visitor, options) {
@@ -961,16 +1031,18 @@ class ImportStatement extends AstNode_2.Statement {
961
1031
  }
962
1032
  exports.ImportStatement = ImportStatement;
963
1033
  class InterfaceStatement extends AstNode_2.Statement {
964
- constructor(interfaceToken, name, extendsToken, parentInterfaceName, body, endInterfaceToken) {
1034
+ constructor(options) {
965
1035
  super();
966
- this.parentInterfaceName = parentInterfaceName;
967
- this.body = body;
968
1036
  this.kind = AstNode_1.AstNodeKind.InterfaceStatement;
969
1037
  this.tokens = {};
970
- this.tokens.interface = interfaceToken;
971
- this.tokens.name = name;
972
- this.tokens.extends = extendsToken;
973
- this.tokens.endInterface = endInterfaceToken;
1038
+ this.tokens = {
1039
+ interface: options.interface,
1040
+ name: options.name,
1041
+ extends: options.extends,
1042
+ endInterface: options.endInterface
1043
+ };
1044
+ this.parentInterfaceName = options.parentInterfaceName;
1045
+ this.body = options.body;
974
1046
  this.range = util_1.util.createBoundingRange(this.tokens.interface, this.tokens.name, this.tokens.extends, this.parentInterfaceName, ...this.body, this.tokens.endInterface);
975
1047
  }
976
1048
  get fields() {
@@ -1087,14 +1159,15 @@ class InterfaceStatement extends AstNode_2.Statement {
1087
1159
  }
1088
1160
  exports.InterfaceStatement = InterfaceStatement;
1089
1161
  class InterfaceFieldStatement extends AstNode_2.Statement {
1090
- constructor(nameToken, asToken, typeExpression, optionalToken) {
1162
+ constructor(options) {
1091
1163
  super();
1092
- this.typeExpression = typeExpression;
1093
1164
  this.kind = AstNode_1.AstNodeKind.InterfaceFieldStatement;
1094
- this.tokens = {};
1095
- this.tokens.optional = optionalToken;
1096
- this.tokens.name = nameToken;
1097
- this.tokens.as = asToken;
1165
+ this.tokens = {
1166
+ optional: options.optional,
1167
+ name: options.name,
1168
+ as: options.as
1169
+ };
1170
+ this.typeExpression = options.typeExpression;
1098
1171
  this.range = util_1.util.createBoundingRange(this.tokens.optional, this.tokens.name, this.tokens.as, this.typeExpression);
1099
1172
  }
1100
1173
  transpile(state) {
@@ -1139,18 +1212,20 @@ exports.InterfaceFieldStatement = InterfaceFieldStatement;
1139
1212
  //TODO: there is much that is similar with this and FunctionExpression.
1140
1213
  //It would be nice to refactor this so there is less duplicated code
1141
1214
  class InterfaceMethodStatement extends AstNode_2.Statement {
1142
- constructor(functionTypeToken, nameToken, leftParen, params, rightParen, asToken, returnTypeExpression, optionalToken) {
1215
+ constructor(options) {
1216
+ var _a;
1143
1217
  super();
1144
- this.params = params;
1145
- this.returnTypeExpression = returnTypeExpression;
1146
1218
  this.kind = AstNode_1.AstNodeKind.InterfaceMethodStatement;
1147
- this.tokens = {};
1148
- this.tokens.optional = optionalToken;
1149
- this.tokens.functionType = functionTypeToken;
1150
- this.tokens.name = nameToken;
1151
- this.tokens.leftParen = leftParen;
1152
- this.tokens.rightParen = rightParen;
1153
- this.tokens.as = asToken;
1219
+ this.tokens = {
1220
+ optional: options.optional,
1221
+ functionType: options.functionType,
1222
+ name: options.name,
1223
+ leftParen: options.leftParen,
1224
+ rightParen: options.rightParen,
1225
+ as: options.as
1226
+ };
1227
+ this.params = (_a = options.params) !== null && _a !== void 0 ? _a : [];
1228
+ this.returnTypeExpression = options.returnTypeExpression;
1154
1229
  }
1155
1230
  transpile(state) {
1156
1231
  throw new Error('Method not implemented.');
@@ -1178,7 +1253,7 @@ class InterfaceMethodStatement extends AstNode_2.Statement {
1178
1253
  }
1179
1254
  }
1180
1255
  getTypedef(state) {
1181
- var _a, _b;
1256
+ var _a, _b, _c, _d;
1182
1257
  const result = [];
1183
1258
  for (let annotation of (_a = this.annotations) !== null && _a !== void 0 ? _a : []) {
1184
1259
  result.push(...annotation.getTypedef(state), state.newline, state.indent());
@@ -1186,14 +1261,14 @@ class InterfaceMethodStatement extends AstNode_2.Statement {
1186
1261
  if (this.isOptional) {
1187
1262
  result.push(this.tokens.optional.text, ' ');
1188
1263
  }
1189
- result.push(this.tokens.functionType.text, ' ', this.tokens.name.text, '(');
1190
- const params = (_b = this.params) !== null && _b !== void 0 ? _b : [];
1264
+ result.push((_c = (_b = this.tokens.functionType) === null || _b === void 0 ? void 0 : _b.text) !== null && _c !== void 0 ? _c : 'function', ' ', this.tokens.name.text, '(');
1265
+ const params = (_d = this.params) !== null && _d !== void 0 ? _d : [];
1191
1266
  for (let i = 0; i < params.length; i++) {
1192
1267
  if (i > 0) {
1193
1268
  result.push(', ');
1194
1269
  }
1195
1270
  const param = params[i];
1196
- result.push(param.name.text);
1271
+ result.push(param.tokens.name.text);
1197
1272
  if (param.typeExpression) {
1198
1273
  result.push(' as ', ...param.typeExpression.getTypedef(state));
1199
1274
  }
@@ -1205,10 +1280,10 @@ class InterfaceMethodStatement extends AstNode_2.Statement {
1205
1280
  return result;
1206
1281
  }
1207
1282
  getType(options) {
1208
- var _a, _b, _c;
1283
+ var _a, _b, _c, _d;
1209
1284
  //if there's a defined return type, use that
1210
1285
  let returnType = (_a = this.returnTypeExpression) === null || _a === void 0 ? void 0 : _a.getType(options);
1211
- const isSub = this.tokens.functionType.kind === TokenKind_1.TokenKind.Sub;
1286
+ const isSub = ((_b = this.tokens.functionType) === null || _b === void 0 ? void 0 : _b.kind) === TokenKind_1.TokenKind.Sub || !returnType;
1212
1287
  //if we don't have a return type and this is a sub, set the return type to `void`. else use `dynamic`
1213
1288
  if (!returnType) {
1214
1289
  returnType = isSub ? VoidType_1.VoidType.instance : DynamicType_1.DynamicType.instance;
@@ -1216,54 +1291,51 @@ class InterfaceMethodStatement extends AstNode_2.Statement {
1216
1291
  const resultType = new TypedFunctionType_1.TypedFunctionType(returnType);
1217
1292
  resultType.isSub = isSub;
1218
1293
  for (let param of this.params) {
1219
- resultType.addParameter(param.name.text, param.getType(options), !!param.defaultValue);
1294
+ resultType.addParameter(param.tokens.name.text, param.getType(options), !!param.defaultValue);
1220
1295
  }
1221
1296
  if (options.typeChain) {
1222
1297
  // need Interface type for type chain
1223
- (_b = this.parent) === null || _b === void 0 ? void 0 : _b.getType(options);
1298
+ (_c = this.parent) === null || _c === void 0 ? void 0 : _c.getType(options);
1224
1299
  }
1225
1300
  let funcName = this.getName(Parser_1.ParseMode.BrighterScript);
1226
1301
  resultType.setName(funcName);
1227
- (_c = options.typeChain) === null || _c === void 0 ? void 0 : _c.push(new interfaces_1.TypeChainEntry(resultType.name, resultType, options.data, this.range));
1302
+ (_d = options.typeChain) === null || _d === void 0 ? void 0 : _d.push(new interfaces_1.TypeChainEntry(resultType.name, resultType, options.data, this.range));
1228
1303
  return resultType;
1229
1304
  }
1230
1305
  }
1231
1306
  exports.InterfaceMethodStatement = InterfaceMethodStatement;
1232
1307
  class ClassStatement extends AstNode_2.Statement {
1233
- constructor(classKeyword,
1234
- /**
1235
- * The name of the class (without namespace prefix)
1236
- */
1237
- name, body, end, extendsKeyword, parentClassName) {
1238
- var _a, _b, _c, _d;
1308
+ constructor(options) {
1309
+ var _a, _b, _c, _d, _e;
1239
1310
  super();
1240
- this.classKeyword = classKeyword;
1241
- this.name = name;
1242
- this.body = body;
1243
- this.end = end;
1244
- this.extendsKeyword = extendsKeyword;
1245
- this.parentClassName = parentClassName;
1246
1311
  this.kind = AstNode_1.AstNodeKind.ClassStatement;
1247
1312
  this.memberMap = {};
1248
1313
  this.methods = [];
1249
1314
  this.fields = [];
1250
- this.body = (_a = this.body) !== null && _a !== void 0 ? _a : [];
1251
- this.symbolTable = new SymbolTable_2.SymbolTable(`ClassStatement: '${(_b = this.name) === null || _b === void 0 ? void 0 : _b.text}'`, () => { var _a; return (_a = this.parent) === null || _a === void 0 ? void 0 : _a.getSymbolTable(); });
1315
+ this.body = (_a = options.body) !== null && _a !== void 0 ? _a : [];
1316
+ this.tokens = {
1317
+ name: options.name,
1318
+ class: options.class,
1319
+ endClass: options.endClass,
1320
+ extends: options.extends
1321
+ };
1322
+ this.parentClassName = options.parentClassName;
1323
+ this.symbolTable = new SymbolTable_2.SymbolTable(`ClassStatement: '${(_b = this.tokens.name) === null || _b === void 0 ? void 0 : _b.text}'`, () => { var _a; return (_a = this.parent) === null || _a === void 0 ? void 0 : _a.getSymbolTable(); });
1252
1324
  for (let statement of this.body) {
1253
1325
  if ((0, reflection_1.isMethodStatement)(statement)) {
1254
1326
  this.methods.push(statement);
1255
- this.memberMap[(_c = statement === null || statement === void 0 ? void 0 : statement.name) === null || _c === void 0 ? void 0 : _c.text.toLowerCase()] = statement;
1327
+ this.memberMap[(_c = statement === null || statement === void 0 ? void 0 : statement.tokens.name) === null || _c === void 0 ? void 0 : _c.text.toLowerCase()] = statement;
1256
1328
  }
1257
1329
  else if ((0, reflection_1.isFieldStatement)(statement)) {
1258
1330
  this.fields.push(statement);
1259
- this.memberMap[(_d = statement === null || statement === void 0 ? void 0 : statement.name) === null || _d === void 0 ? void 0 : _d.text.toLowerCase()] = statement;
1331
+ this.memberMap[(_d = statement === null || statement === void 0 ? void 0 : statement.tokens.name) === null || _d === void 0 ? void 0 : _d.text.toLowerCase()] = statement;
1260
1332
  }
1261
1333
  }
1262
- this.range = util_1.util.createBoundingRange(classKeyword, name, extendsKeyword, parentClassName, ...(body !== null && body !== void 0 ? body : []), end);
1334
+ this.range = util_1.util.createBoundingRange(this.parentClassName, ...((_e = this.body) !== null && _e !== void 0 ? _e : []), util_1.util.createBoundingRangeFromTokens(this.tokens));
1263
1335
  }
1264
1336
  getName(parseMode) {
1265
1337
  var _a;
1266
- const name = (_a = this.name) === null || _a === void 0 ? void 0 : _a.text;
1338
+ const name = (_a = this.tokens.name) === null || _a === void 0 ? void 0 : _a.text;
1267
1339
  if (name) {
1268
1340
  const namespace = this.findAncestor(reflection_1.isNamespaceStatement);
1269
1341
  if (namespace) {
@@ -1281,7 +1353,8 @@ class ClassStatement extends AstNode_2.Statement {
1281
1353
  }
1282
1354
  }
1283
1355
  getLeadingTrivia() {
1284
- return util_1.util.concatAnnotationLeadingTrivia(this, this.classKeyword.leadingTrivia);
1356
+ var _a;
1357
+ return util_1.util.concatAnnotationLeadingTrivia(this, (_a = this.tokens.class) === null || _a === void 0 ? void 0 : _a.leadingTrivia);
1285
1358
  }
1286
1359
  transpile(state) {
1287
1360
  let result = [];
@@ -1298,8 +1371,8 @@ class ClassStatement extends AstNode_2.Statement {
1298
1371
  for (let annotation of (_a = this.annotations) !== null && _a !== void 0 ? _a : []) {
1299
1372
  result.push(...annotation.getTypedef(state), state.newline, state.indent());
1300
1373
  }
1301
- result.push('class ', this.name.text);
1302
- if (this.extendsKeyword && this.parentClassName) {
1374
+ result.push('class ', this.tokens.name.text);
1375
+ if (this.parentClassName) {
1303
1376
  const namespace = this.findAncestor(reflection_1.isNamespaceStatement);
1304
1377
  const fqName = util_1.util.getFullyQualifiedClassName(this.parentClassName.getName(), namespace === null || namespace === void 0 ? void 0 : namespace.getName(Parser_1.ParseMode.BrighterScript));
1305
1378
  result.push(` extends ${fqName}`);
@@ -1396,7 +1469,7 @@ class ClassStatement extends AstNode_2.Statement {
1396
1469
  getConstructorFunction() {
1397
1470
  return this.body.find((stmt) => {
1398
1471
  var _a, _b;
1399
- return ((_b = (_a = stmt === null || stmt === void 0 ? void 0 : stmt.name) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'new';
1472
+ return ((_b = (_a = stmt === null || stmt === void 0 ? void 0 : stmt.tokens.name) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'new';
1400
1473
  });
1401
1474
  }
1402
1475
  /**
@@ -1457,13 +1530,13 @@ class ClassStatement extends AstNode_2.Statement {
1457
1530
  //store overridden parent methods as super{parentIndex}_{methodName}
1458
1531
  if (
1459
1532
  //is override method
1460
- statement.override ||
1533
+ statement.tokens.override ||
1461
1534
  //is constructor function in child class
1462
- (statement.name.text.toLowerCase() === 'new' && ancestors[0])) {
1463
- result.push(`instance.super${parentClassIndex}_${statement.name.text} = instance.${statement.name.text}`, state.newline, state.indent());
1535
+ (statement.tokens.name.text.toLowerCase() === 'new' && ancestors[0])) {
1536
+ result.push(`instance.super${parentClassIndex}_${statement.tokens.name.text} = instance.${statement.tokens.name.text}`, state.newline, state.indent());
1464
1537
  }
1465
1538
  state.classStatement = this;
1466
- result.push('instance.', state.transpileToken(statement.name), ' = ', ...statement.transpile(state), state.newline, state.indent());
1539
+ result.push('instance.', state.transpileToken(statement.tokens.name), ' = ', ...statement.transpile(state), state.newline, state.indent());
1467
1540
  delete state.classStatement;
1468
1541
  }
1469
1542
  else {
@@ -1487,7 +1560,7 @@ class ClassStatement extends AstNode_2.Statement {
1487
1560
  let result = [];
1488
1561
  const constructorFunction = this.getConstructorFunction();
1489
1562
  const constructorParams = constructorFunction ? constructorFunction.func.parameters : [];
1490
- result.push(state.sourceNode(this.classKeyword, 'function'), state.sourceNode(this.classKeyword, ' '), state.sourceNode(this.name, this.getName(Parser_1.ParseMode.BrightScript)), `(`);
1563
+ result.push(state.sourceNode(this, 'function'), state.sourceNode(this, ' '), state.sourceNode(this.tokens.name, this.getName(Parser_1.ParseMode.BrightScript)), `(`);
1491
1564
  let i = 0;
1492
1565
  for (let param of constructorParams) {
1493
1566
  if (i > 0) {
@@ -1508,7 +1581,7 @@ class ClassStatement extends AstNode_2.Statement {
1508
1581
  if (i > 0) {
1509
1582
  result.push(', ');
1510
1583
  }
1511
- result.push(state.transpileToken(param.name));
1584
+ result.push(state.transpileToken(param.tokens.name));
1512
1585
  i++;
1513
1586
  }
1514
1587
  result.push(')', '\n');
@@ -1539,7 +1612,7 @@ class ClassStatement extends AstNode_2.Statement {
1539
1612
  if (((_c = statement.accessModifier) === null || _c === void 0 ? void 0 : _c.kind) === TokenKind_1.TokenKind.Protected) {
1540
1613
  flag |= SymbolTable_1.SymbolTypeFlag.protected;
1541
1614
  }
1542
- resultType.addMember((_d = statement === null || statement === void 0 ? void 0 : statement.name) === null || _d === void 0 ? void 0 : _d.text, { definingNode: statement }, funcType, flag);
1615
+ resultType.addMember((_d = statement === null || statement === void 0 ? void 0 : statement.tokens.name) === null || _d === void 0 ? void 0 : _d.text, { definingNode: statement }, funcType, flag);
1543
1616
  }
1544
1617
  for (const statement of this.fields) {
1545
1618
  const fieldType = statement.getType(Object.assign(Object.assign({}, options), { typeChain: undefined })); //no typechain needed
@@ -1547,13 +1620,13 @@ class ClassStatement extends AstNode_2.Statement {
1547
1620
  if (statement.isOptional) {
1548
1621
  flag |= SymbolTable_1.SymbolTypeFlag.optional;
1549
1622
  }
1550
- if (((_e = statement.accessModifier) === null || _e === void 0 ? void 0 : _e.kind) === TokenKind_1.TokenKind.Private) {
1623
+ if (((_e = statement.tokens.accessModifier) === null || _e === void 0 ? void 0 : _e.kind) === TokenKind_1.TokenKind.Private) {
1551
1624
  flag |= SymbolTable_1.SymbolTypeFlag.private;
1552
1625
  }
1553
- if (((_f = statement.accessModifier) === null || _f === void 0 ? void 0 : _f.kind) === TokenKind_1.TokenKind.Protected) {
1626
+ if (((_f = statement.tokens.accessModifier) === null || _f === void 0 ? void 0 : _f.kind) === TokenKind_1.TokenKind.Protected) {
1554
1627
  flag |= SymbolTable_1.SymbolTypeFlag.protected;
1555
1628
  }
1556
- resultType.addMember((_g = statement === null || statement === void 0 ? void 0 : statement.name) === null || _g === void 0 ? void 0 : _g.text, { definingNode: statement }, fieldType, flag);
1629
+ resultType.addMember((_g = statement === null || statement === void 0 ? void 0 : statement.tokens.name) === null || _g === void 0 ? void 0 : _g.text, { definingNode: statement }, fieldType, flag);
1557
1630
  }
1558
1631
  (_h = options.typeChain) === null || _h === void 0 ? void 0 : _h.push(new interfaces_1.TypeChainEntry(resultType.name, resultType, options.data, this.range));
1559
1632
  return resultType;
@@ -1566,20 +1639,20 @@ const accessModifiers = [
1566
1639
  TokenKind_1.TokenKind.Private
1567
1640
  ];
1568
1641
  class MethodStatement extends FunctionStatement {
1569
- constructor(modifiers, name, func, override) {
1570
- super(name, func);
1571
- this.override = override;
1642
+ constructor(options) {
1643
+ super(options);
1572
1644
  this.kind = AstNode_1.AstNodeKind.MethodStatement;
1573
1645
  this.modifiers = [];
1574
- if (modifiers) {
1575
- if (Array.isArray(modifiers)) {
1576
- this.modifiers.push(...modifiers);
1646
+ if (options.modifiers) {
1647
+ if (Array.isArray(options.modifiers)) {
1648
+ this.modifiers.push(...options.modifiers);
1577
1649
  }
1578
1650
  else {
1579
- this.modifiers.push(modifiers);
1651
+ this.modifiers.push(options.modifiers);
1580
1652
  }
1581
1653
  }
1582
- this.range = util_1.util.createBoundingRange(...(this.modifiers), override, func);
1654
+ this.tokens = Object.assign(Object.assign({}, this.tokens), { override: options.override });
1655
+ this.range = util_1.util.createBoundingRange(...(this.modifiers), util_1.util.createBoundingRangeFromTokens(this.tokens), this.func);
1583
1656
  }
1584
1657
  get accessModifier() {
1585
1658
  return this.modifiers.find(x => accessModifiers.includes(x.kind));
@@ -1588,13 +1661,13 @@ class MethodStatement extends FunctionStatement {
1588
1661
  * Get the name of this method.
1589
1662
  */
1590
1663
  getName(parseMode) {
1591
- return this.name.text;
1664
+ return this.tokens.name.text;
1592
1665
  }
1593
1666
  getLeadingTrivia() {
1594
1667
  return util_1.util.concatAnnotationLeadingTrivia(this, this.func.getLeadingTrivia());
1595
1668
  }
1596
1669
  transpile(state) {
1597
- if (this.name.text.toLowerCase() === 'new') {
1670
+ if (this.tokens.name.text.toLowerCase() === 'new') {
1598
1671
  this.ensureSuperConstructorCall(state);
1599
1672
  //TODO we need to undo this at the bottom of this method
1600
1673
  this.injectFieldInitializersForConstructor(state);
@@ -1604,16 +1677,16 @@ class MethodStatement extends FunctionStatement {
1604
1677
  const parentClassIndex = state.classStatement.getParentClassIndex(state);
1605
1678
  const visitor = (0, visitors_1.createVisitor)({
1606
1679
  VariableExpression: e => {
1607
- if (e.name.text.toLocaleLowerCase() === 'super') {
1608
- state.editor.setProperty(e.name, 'text', `m.super${parentClassIndex}_new`);
1680
+ if (e.tokens.name.text.toLocaleLowerCase() === 'super') {
1681
+ state.editor.setProperty(e.tokens.name, 'text', `m.super${parentClassIndex}_new`);
1609
1682
  }
1610
1683
  },
1611
1684
  DottedGetExpression: e => {
1612
1685
  const beginningVariable = util_1.util.findBeginningVariableExpression(e);
1613
1686
  const lowerName = beginningVariable === null || beginningVariable === void 0 ? void 0 : beginningVariable.getName(Parser_1.ParseMode.BrighterScript).toLowerCase();
1614
1687
  if (lowerName === 'super') {
1615
- state.editor.setProperty(beginningVariable.name, 'text', 'm');
1616
- state.editor.setProperty(e.name, 'text', `super${parentClassIndex}_${e.name.text}`);
1688
+ state.editor.setProperty(beginningVariable.tokens.name, 'text', 'm');
1689
+ state.editor.setProperty(e.tokens.name, 'text', `super${parentClassIndex}_${e.tokens.name.text}`);
1617
1690
  }
1618
1691
  }
1619
1692
  });
@@ -1633,7 +1706,7 @@ class MethodStatement extends FunctionStatement {
1633
1706
  if (this.accessModifier) {
1634
1707
  result.push(this.accessModifier.text, ' ');
1635
1708
  }
1636
- if (this.override) {
1709
+ if (this.tokens.override) {
1637
1710
  result.push('override ');
1638
1711
  }
1639
1712
  result.push(...this.func.getTypedef(state));
@@ -1653,35 +1726,44 @@ class MethodStatement extends FunctionStatement {
1653
1726
  //is a call statement
1654
1727
  return (0, reflection_1.isExpressionStatement)(x) && (0, reflection_1.isCallExpression)(x.expression) &&
1655
1728
  //is a call to super
1656
- util_1.util.findBeginningVariableExpression(x.expression.callee).name.text.toLowerCase() === 'super';
1729
+ util_1.util.findBeginningVariableExpression(x.expression.callee).tokens.name.text.toLowerCase() === 'super';
1657
1730
  }) !== -1;
1658
1731
  //if a call to super exists, quit here
1659
1732
  if (containsSuperCall) {
1660
1733
  return;
1661
1734
  }
1662
1735
  //this is a child class, and the constructor doesn't contain a call to super. Inject one
1663
- const superCall = new ExpressionStatement(new Expression_1.CallExpression(new Expression_1.VariableExpression({
1664
- kind: TokenKind_1.TokenKind.Identifier,
1665
- text: 'super',
1666
- isReserved: false,
1667
- range: state.classStatement.name.range,
1668
- leadingWhitespace: '',
1669
- leadingTrivia: []
1670
- }), {
1671
- kind: TokenKind_1.TokenKind.LeftParen,
1672
- text: '(',
1673
- isReserved: false,
1674
- range: state.classStatement.name.range,
1675
- leadingWhitespace: '',
1676
- leadingTrivia: []
1677
- }, {
1678
- kind: TokenKind_1.TokenKind.RightParen,
1679
- text: ')',
1680
- isReserved: false,
1681
- range: state.classStatement.name.range,
1682
- leadingWhitespace: '',
1683
- leadingTrivia: []
1684
- }, []));
1736
+ const superCall = new ExpressionStatement({
1737
+ expression: new Expression_1.CallExpression({
1738
+ callee: new Expression_1.VariableExpression({
1739
+ name: {
1740
+ kind: TokenKind_1.TokenKind.Identifier,
1741
+ text: 'super',
1742
+ isReserved: false,
1743
+ range: state.classStatement.tokens.name.range,
1744
+ leadingWhitespace: '',
1745
+ leadingTrivia: []
1746
+ }
1747
+ }),
1748
+ openingParen: {
1749
+ kind: TokenKind_1.TokenKind.LeftParen,
1750
+ text: '(',
1751
+ isReserved: false,
1752
+ range: state.classStatement.tokens.name.range,
1753
+ leadingWhitespace: '',
1754
+ leadingTrivia: []
1755
+ },
1756
+ closingParen: {
1757
+ kind: TokenKind_1.TokenKind.RightParen,
1758
+ text: ')',
1759
+ isReserved: false,
1760
+ range: state.classStatement.tokens.name.range,
1761
+ leadingWhitespace: '',
1762
+ leadingTrivia: []
1763
+ },
1764
+ args: []
1765
+ })
1766
+ });
1685
1767
  state.editor.arrayUnshift(this.func.body.statements, superCall);
1686
1768
  }
1687
1769
  /**
@@ -1692,13 +1774,20 @@ class MethodStatement extends FunctionStatement {
1692
1774
  let newStatements = [];
1693
1775
  //insert the field initializers in order
1694
1776
  for (let field of state.classStatement.fields) {
1695
- let thisQualifiedName = Object.assign({}, field.name);
1696
- thisQualifiedName.text = 'm.' + field.name.text;
1777
+ let thisQualifiedName = Object.assign({}, field.tokens.name);
1778
+ thisQualifiedName.text = 'm.' + field.tokens.name.text;
1697
1779
  const fieldAssignment = field.initialValue
1698
- ? new AssignmentStatement(field.equal, thisQualifiedName, field.initialValue)
1699
- : new AssignmentStatement((0, creators_1.createToken)(TokenKind_1.TokenKind.Equal, '=', field.name.range), thisQualifiedName,
1700
- //if there is no initial value, set the initial value to `invalid`
1701
- (0, creators_1.createInvalidLiteral)('invalid', field.name.range));
1780
+ ? new AssignmentStatement({
1781
+ equals: field.tokens.equals,
1782
+ name: thisQualifiedName,
1783
+ value: field.initialValue
1784
+ })
1785
+ : new AssignmentStatement({
1786
+ equals: (0, creators_1.createToken)(TokenKind_1.TokenKind.Equal, '=', field.tokens.name.range),
1787
+ name: thisQualifiedName,
1788
+ //if there is no initial value, set the initial value to `invalid`
1789
+ value: (0, creators_1.createInvalidLiteral)('invalid', field.tokens.name.range)
1790
+ });
1702
1791
  // Add parent so namespace lookups work
1703
1792
  fieldAssignment.parent = state.classStatement;
1704
1793
  newStatements.push(fieldAssignment);
@@ -1713,17 +1802,19 @@ class MethodStatement extends FunctionStatement {
1713
1802
  }
1714
1803
  exports.MethodStatement = MethodStatement;
1715
1804
  class FieldStatement extends AstNode_2.Statement {
1716
- constructor(accessModifier, name, as, typeExpression, equal, initialValue, optional) {
1805
+ constructor(options) {
1717
1806
  super();
1718
- this.accessModifier = accessModifier;
1719
- this.name = name;
1720
- this.as = as;
1721
- this.typeExpression = typeExpression;
1722
- this.equal = equal;
1723
- this.initialValue = initialValue;
1724
- this.optional = optional;
1725
1807
  this.kind = AstNode_1.AstNodeKind.FieldStatement;
1726
- this.range = util_1.util.createBoundingRange(accessModifier, optional, name, as, typeExpression, equal, initialValue);
1808
+ this.tokens = {
1809
+ accessModifier: options.accessModifier,
1810
+ name: options.name,
1811
+ as: options.as,
1812
+ equals: options.equals,
1813
+ optional: options.optional
1814
+ };
1815
+ this.typeExpression = options.typeExpression;
1816
+ this.initialValue = options.initialValue;
1817
+ this.range = util_1.util.createBoundingRange(util_1.util.createBoundingRangeFromTokens(this.tokens), this.typeExpression, this.initialValue);
1727
1818
  }
1728
1819
  /**
1729
1820
  * Derive a ValueKind from the type token, or the initial value.
@@ -1735,10 +1826,10 @@ class FieldStatement extends AstNode_2.Statement {
1735
1826
  }
1736
1827
  getLeadingTrivia() {
1737
1828
  var _a, _b, _c, _d, _e, _f;
1738
- return util_1.util.concatAnnotationLeadingTrivia(this, (_f = (_d = (_b = (_a = this.accessModifier) === null || _a === void 0 ? void 0 : _a.leadingTrivia) !== null && _b !== void 0 ? _b : (_c = this.optional) === null || _c === void 0 ? void 0 : _c.leadingTrivia) !== null && _d !== void 0 ? _d : (_e = this.name) === null || _e === void 0 ? void 0 : _e.leadingTrivia) !== null && _f !== void 0 ? _f : []);
1829
+ return util_1.util.concatAnnotationLeadingTrivia(this, (_f = (_d = (_b = (_a = this.tokens.accessModifier) === null || _a === void 0 ? void 0 : _a.leadingTrivia) !== null && _b !== void 0 ? _b : (_c = this.tokens.optional) === null || _c === void 0 ? void 0 : _c.leadingTrivia) !== null && _d !== void 0 ? _d : (_e = this.tokens.name) === null || _e === void 0 ? void 0 : _e.leadingTrivia) !== null && _f !== void 0 ? _f : []);
1739
1830
  }
1740
1831
  get isOptional() {
1741
- return !!this.optional;
1832
+ return !!this.tokens.optional;
1742
1833
  }
1743
1834
  transpile(state) {
1744
1835
  throw new Error('transpile not implemented for ' + Object.getPrototypeOf(this).constructor.name);
@@ -1746,7 +1837,7 @@ class FieldStatement extends AstNode_2.Statement {
1746
1837
  getTypedef(state) {
1747
1838
  var _a, _b, _c, _d;
1748
1839
  const result = [];
1749
- if (this.name) {
1840
+ if (this.tokens.name) {
1750
1841
  for (let annotation of (_a = this.annotations) !== null && _a !== void 0 ? _a : []) {
1751
1842
  result.push(...annotation.getTypedef(state), state.newline, state.indent());
1752
1843
  }
@@ -1754,11 +1845,11 @@ class FieldStatement extends AstNode_2.Statement {
1754
1845
  if ((0, reflection_1.isInvalidType)(type) || (0, reflection_1.isVoidType)(type)) {
1755
1846
  type = new DynamicType_1.DynamicType();
1756
1847
  }
1757
- result.push((_c = (_b = this.accessModifier) === null || _b === void 0 ? void 0 : _b.text) !== null && _c !== void 0 ? _c : 'public', ' ');
1848
+ result.push((_c = (_b = this.tokens.accessModifier) === null || _b === void 0 ? void 0 : _b.text) !== null && _c !== void 0 ? _c : 'public', ' ');
1758
1849
  if (this.isOptional) {
1759
- result.push(this.optional.text, ' ');
1850
+ result.push(this.tokens.optional.text, ' ');
1760
1851
  }
1761
- result.push((_d = this.name) === null || _d === void 0 ? void 0 : _d.text, ' as ', type.toTypeString());
1852
+ result.push((_d = this.tokens.name) === null || _d === void 0 ? void 0 : _d.text, ' as ', type.toTypeString());
1762
1853
  }
1763
1854
  return result;
1764
1855
  }
@@ -1771,25 +1862,28 @@ class FieldStatement extends AstNode_2.Statement {
1771
1862
  }
1772
1863
  exports.FieldStatement = FieldStatement;
1773
1864
  class TryCatchStatement extends AstNode_2.Statement {
1774
- constructor(tokens, tryBranch, catchStatement) {
1865
+ constructor(options) {
1775
1866
  super();
1776
- this.tokens = tokens;
1777
- this.tryBranch = tryBranch;
1778
- this.catchStatement = catchStatement;
1779
1867
  this.kind = AstNode_1.AstNodeKind.TryCatchStatement;
1780
- this.range = util_1.util.createBoundingRange(tokens.try, tryBranch, catchStatement, tokens.endTry);
1868
+ this.tokens = {
1869
+ try: options.try,
1870
+ endTry: options.endTry
1871
+ };
1872
+ this.tryBranch = options.tryBranch;
1873
+ this.catchStatement = options.catchStatement;
1874
+ this.range = util_1.util.createBoundingRange(this.tokens.try, this.tryBranch, this.catchStatement, this.tokens.endTry);
1781
1875
  }
1782
1876
  transpile(state) {
1783
1877
  var _a, _b;
1784
1878
  return [
1785
- state.transpileToken(this.tokens.try),
1879
+ state.transpileToken(this.tokens.try, 'try'),
1786
1880
  ...this.tryBranch.transpile(state),
1787
1881
  state.newline,
1788
1882
  state.indent(),
1789
1883
  ...((_b = (_a = this.catchStatement) === null || _a === void 0 ? void 0 : _a.transpile(state)) !== null && _b !== void 0 ? _b : ['catch']),
1790
1884
  state.newline,
1791
1885
  state.indent(),
1792
- state.transpileToken(this.tokens.endTry)
1886
+ state.transpileToken(this.tokens.endTry, 'end try')
1793
1887
  ];
1794
1888
  }
1795
1889
  walk(visitor, options) {
@@ -1801,20 +1895,22 @@ class TryCatchStatement extends AstNode_2.Statement {
1801
1895
  }
1802
1896
  exports.TryCatchStatement = TryCatchStatement;
1803
1897
  class CatchStatement extends AstNode_2.Statement {
1804
- constructor(tokens, exceptionVariable, catchBranch) {
1898
+ constructor(options) {
1805
1899
  super();
1806
- this.tokens = tokens;
1807
- this.exceptionVariable = exceptionVariable;
1808
- this.catchBranch = catchBranch;
1809
1900
  this.kind = AstNode_1.AstNodeKind.CatchStatement;
1810
- this.range = util_1.util.createBoundingRange(tokens.catch, exceptionVariable, catchBranch);
1901
+ this.tokens = {
1902
+ catch: options === null || options === void 0 ? void 0 : options.catch,
1903
+ exceptionVariable: options === null || options === void 0 ? void 0 : options.exceptionVariable
1904
+ };
1905
+ this.catchBranch = options === null || options === void 0 ? void 0 : options.catchBranch;
1906
+ this.range = util_1.util.createBoundingRange(this.tokens.catch, this.tokens.exceptionVariable, this.catchBranch);
1811
1907
  }
1812
1908
  transpile(state) {
1813
1909
  var _a, _b, _c, _d;
1814
1910
  return [
1815
- state.transpileToken(this.tokens.catch),
1911
+ state.transpileToken(this.tokens.catch, 'catch'),
1816
1912
  ' ',
1817
- (_b = (_a = this.exceptionVariable) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : 'e',
1913
+ (_b = (_a = this.tokens.exceptionVariable) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : 'e',
1818
1914
  ...((_d = (_c = this.catchBranch) === null || _c === void 0 ? void 0 : _c.transpile(state)) !== null && _d !== void 0 ? _d : [])
1819
1915
  ];
1820
1916
  }
@@ -1826,16 +1922,18 @@ class CatchStatement extends AstNode_2.Statement {
1826
1922
  }
1827
1923
  exports.CatchStatement = CatchStatement;
1828
1924
  class ThrowStatement extends AstNode_2.Statement {
1829
- constructor(throwToken, expression) {
1925
+ constructor(options) {
1830
1926
  super();
1831
- this.throwToken = throwToken;
1832
- this.expression = expression;
1833
1927
  this.kind = AstNode_1.AstNodeKind.ThrowStatement;
1834
- this.range = util_1.util.createBoundingRange(throwToken, expression);
1928
+ this.tokens = {
1929
+ throw: options.throw
1930
+ };
1931
+ this.expression = options.expression;
1932
+ this.range = util_1.util.createBoundingRange(this.tokens.throw, this.expression);
1835
1933
  }
1836
1934
  transpile(state) {
1837
1935
  const result = [
1838
- state.transpileToken(this.throwToken),
1936
+ state.transpileToken(this.tokens.throw, 'throw'),
1839
1937
  ' '
1840
1938
  ];
1841
1939
  //if we have an expression, transpile it
@@ -1856,13 +1954,16 @@ class ThrowStatement extends AstNode_2.Statement {
1856
1954
  }
1857
1955
  exports.ThrowStatement = ThrowStatement;
1858
1956
  class EnumStatement extends AstNode_2.Statement {
1859
- constructor(tokens, body) {
1957
+ constructor(options) {
1860
1958
  var _a;
1861
1959
  super();
1862
- this.tokens = tokens;
1863
- this.body = body;
1864
1960
  this.kind = AstNode_1.AstNodeKind.EnumStatement;
1865
1961
  this.symbolTable = new SymbolTable_2.SymbolTable('Enum');
1962
+ this.tokens = {
1963
+ enum: options.enum,
1964
+ name: options.name,
1965
+ endEnum: options.endEnum
1966
+ };
1866
1967
  this.body = (_a = this.body) !== null && _a !== void 0 ? _a : [];
1867
1968
  }
1868
1969
  get range() {
@@ -1885,7 +1986,7 @@ class EnumStatement extends AstNode_2.Statement {
1885
1986
  * All values are stored as their AST LiteralExpression representation (i.e. string enum values include the wrapping quotes)
1886
1987
  */
1887
1988
  getMemberValueMap() {
1888
- var _a, _b, _c, _d, _e, _f, _g, _h;
1989
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1889
1990
  const result = new Map();
1890
1991
  const members = this.getMembers();
1891
1992
  let currentIntValue = 0;
@@ -1896,22 +1997,22 @@ class EnumStatement extends AstNode_2.Statement {
1896
1997
  currentIntValue++;
1897
1998
  //if explicit integer value, use it and increment the int counter
1898
1999
  }
1899
- else if ((0, reflection_1.isLiteralExpression)(member.value) && member.value.token.kind === TokenKind_1.TokenKind.IntegerLiteral) {
2000
+ else if ((0, reflection_1.isLiteralExpression)(member.value) && member.value.tokens.value.kind === TokenKind_1.TokenKind.IntegerLiteral) {
1900
2001
  //try parsing as integer literal, then as hex integer literal.
1901
- let tokenIntValue = (_b = util_1.util.parseInt(member.value.token.text)) !== null && _b !== void 0 ? _b : util_1.util.parseInt(member.value.token.text.replace(/&h/i, '0x'));
2002
+ let tokenIntValue = (_b = util_1.util.parseInt(member.value.tokens.value.text)) !== null && _b !== void 0 ? _b : util_1.util.parseInt(member.value.tokens.value.text.replace(/&h/i, '0x'));
1902
2003
  if (tokenIntValue !== undefined) {
1903
2004
  currentIntValue = tokenIntValue;
1904
2005
  currentIntValue++;
1905
2006
  }
1906
- result.set((_c = member.name) === null || _c === void 0 ? void 0 : _c.toLowerCase(), member.value.token.text);
2007
+ result.set((_c = member.name) === null || _c === void 0 ? void 0 : _c.toLowerCase(), member.value.tokens.value.text);
1907
2008
  //simple unary expressions (like `-1`)
1908
2009
  }
1909
2010
  else if ((0, reflection_1.isUnaryExpression)(member.value) && (0, reflection_1.isLiteralExpression)(member.value.right)) {
1910
- result.set((_d = member.name) === null || _d === void 0 ? void 0 : _d.toLowerCase(), member.value.operator.text + member.value.right.token.text);
2011
+ result.set((_d = member.name) === null || _d === void 0 ? void 0 : _d.toLowerCase(), member.value.tokens.operator.text + member.value.right.tokens.value.text);
1911
2012
  //all other values
1912
2013
  }
1913
2014
  else {
1914
- result.set((_e = member.name) === null || _e === void 0 ? void 0 : _e.toLowerCase(), (_h = (_g = (_f = member.value) === null || _f === void 0 ? void 0 : _f.token) === null || _g === void 0 ? void 0 : _g.text) !== null && _h !== void 0 ? _h : 'invalid');
2015
+ result.set((_e = member.name) === null || _e === void 0 ? void 0 : _e.toLowerCase(), (_j = (_h = (_g = (_f = member.value) === null || _f === void 0 ? void 0 : _f.tokens) === null || _g === void 0 ? void 0 : _g.value) === null || _h === void 0 ? void 0 : _h.text) !== null && _j !== void 0 ? _j : 'invalid');
1915
2016
  }
1916
2017
  }
1917
2018
  return result;
@@ -1952,12 +2053,12 @@ class EnumStatement extends AstNode_2.Statement {
1952
2053
  return [];
1953
2054
  }
1954
2055
  getTypedef(state) {
1955
- var _a, _b, _c;
2056
+ var _a, _b, _c, _d, _e;
1956
2057
  const result = [];
1957
2058
  for (let annotation of (_a = this.annotations) !== null && _a !== void 0 ? _a : []) {
1958
2059
  result.push(...annotation.getTypedef(state), state.newline, state.indent());
1959
2060
  }
1960
- result.push((_b = this.tokens.enum.text) !== null && _b !== void 0 ? _b : 'enum', ' ', this.tokens.name.text);
2061
+ result.push((_c = (_b = this.tokens.enum) === null || _b === void 0 ? void 0 : _b.text) !== null && _c !== void 0 ? _c : 'enum', ' ', this.tokens.name.text);
1961
2062
  result.push(state.newline);
1962
2063
  state.blockDepth++;
1963
2064
  for (const member of this.body) {
@@ -1966,7 +2067,7 @@ class EnumStatement extends AstNode_2.Statement {
1966
2067
  }
1967
2068
  }
1968
2069
  state.blockDepth--;
1969
- result.push(state.indent(), (_c = this.tokens.endEnum.text) !== null && _c !== void 0 ? _c : 'end enum');
2070
+ result.push(state.indent(), (_e = (_d = this.tokens.endEnum) === null || _d === void 0 ? void 0 : _d.text) !== null && _e !== void 0 ? _e : 'end enum');
1970
2071
  return result;
1971
2072
  }
1972
2073
  walk(visitor, options) {
@@ -1987,14 +2088,17 @@ class EnumStatement extends AstNode_2.Statement {
1987
2088
  }
1988
2089
  exports.EnumStatement = EnumStatement;
1989
2090
  class EnumMemberStatement extends AstNode_2.Statement {
1990
- constructor(tokens, value) {
2091
+ constructor(options) {
1991
2092
  super();
1992
- this.tokens = tokens;
1993
- this.value = value;
1994
2093
  this.kind = AstNode_1.AstNodeKind.EnumMemberStatement;
2094
+ this.tokens = {
2095
+ name: options.name,
2096
+ equals: options.equals
2097
+ };
2098
+ this.value = options.value;
1995
2099
  }
1996
2100
  get range() {
1997
- return util_1.util.createBoundingRange(this.tokens.name, this.tokens.equal, this.value);
2101
+ return util_1.util.createBoundingRange(this.tokens.name, this.tokens.equals, this.value);
1998
2102
  }
1999
2103
  /**
2000
2104
  * The name of the member
@@ -2012,8 +2116,8 @@ class EnumMemberStatement extends AstNode_2.Statement {
2012
2116
  const result = [
2013
2117
  this.tokens.name.text
2014
2118
  ];
2015
- if (this.tokens.equal) {
2016
- result.push(' ', this.tokens.equal.text, ' ');
2119
+ if (this.tokens.equals) {
2120
+ result.push(' ', this.tokens.equals.text, ' ');
2017
2121
  if (this.value) {
2018
2122
  result.push(...this.value.transpile(state));
2019
2123
  }
@@ -2032,11 +2136,15 @@ class EnumMemberStatement extends AstNode_2.Statement {
2032
2136
  }
2033
2137
  exports.EnumMemberStatement = EnumMemberStatement;
2034
2138
  class ConstStatement extends AstNode_2.Statement {
2035
- constructor(tokens, value) {
2139
+ constructor(options) {
2036
2140
  super();
2037
- this.tokens = tokens;
2038
- this.value = value;
2039
2141
  this.kind = AstNode_1.AstNodeKind.ConstStatement;
2142
+ this.tokens = {
2143
+ const: options.const,
2144
+ name: options.name,
2145
+ equals: options.equals
2146
+ };
2147
+ this.value = options.value;
2040
2148
  this.range = util_1.util.createBoundingRange(this.tokens.const, this.tokens.name, this.tokens.equals, this.value);
2041
2149
  }
2042
2150
  get name() {
@@ -2072,11 +2180,11 @@ class ConstStatement extends AstNode_2.Statement {
2072
2180
  }
2073
2181
  getTypedef(state) {
2074
2182
  return [
2075
- state.tokenToSourceNode(this.tokens.const),
2183
+ this.tokens.const ? state.tokenToSourceNode(this.tokens.const) : 'const',
2076
2184
  ' ',
2077
2185
  state.tokenToSourceNode(this.tokens.name),
2078
2186
  ' ',
2079
- state.tokenToSourceNode(this.tokens.equals),
2187
+ this.tokens.equals ? state.tokenToSourceNode(this.tokens.equals) : '=',
2080
2188
  ' ',
2081
2189
  ...this.value.transpile(state)
2082
2190
  ];
@@ -2092,11 +2200,14 @@ class ConstStatement extends AstNode_2.Statement {
2092
2200
  }
2093
2201
  exports.ConstStatement = ConstStatement;
2094
2202
  class ContinueStatement extends AstNode_2.Statement {
2095
- constructor(tokens) {
2203
+ constructor(options) {
2096
2204
  super();
2097
- this.tokens = tokens;
2098
2205
  this.kind = AstNode_1.AstNodeKind.ContinueStatement;
2099
- this.range = util_1.util.createBoundingRange(tokens.continue, tokens.loopType);
2206
+ this.tokens = {
2207
+ continue: options.continue,
2208
+ loopType: options.loopType
2209
+ };
2210
+ this.range = util_1.util.createBoundingRange(this.tokens.continue, this.tokens.loopType);
2100
2211
  }
2101
2212
  transpile(state) {
2102
2213
  var _a, _b, _c, _d, _e;