brighterscript 1.0.0-alpha.26 → 1.0.0-alpha.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -5
- package/dist/AstValidationSegmenter.d.ts +1 -1
- package/dist/AstValidationSegmenter.js +2 -3
- package/dist/AstValidationSegmenter.js.map +1 -1
- package/dist/DiagnosticMessages.d.ts +1 -3
- package/dist/DiagnosticMessages.js +5 -8
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/Program.js +24 -25
- package/dist/Program.js.map +1 -1
- package/dist/Scope.d.ts +2 -8
- package/dist/Scope.js +20 -22
- package/dist/Scope.js.map +1 -1
- package/dist/SymbolTable.d.ts +1 -8
- package/dist/SymbolTable.js +1 -10
- package/dist/SymbolTable.js.map +1 -1
- package/dist/SymbolTableFlag.d.ts +8 -0
- package/dist/SymbolTableFlag.js +13 -0
- package/dist/SymbolTableFlag.js.map +1 -0
- package/dist/XmlScope.d.ts +1 -1
- package/dist/XmlScope.js +6 -7
- package/dist/XmlScope.js.map +1 -1
- package/dist/astUtils/CachedLookups.d.ts +1 -2
- package/dist/astUtils/CachedLookups.js +0 -11
- package/dist/astUtils/CachedLookups.js.map +1 -1
- package/dist/astUtils/creators.js +45 -6
- package/dist/astUtils/creators.js.map +1 -1
- package/dist/astUtils/reflection.d.ts +2 -0
- package/dist/astUtils/reflection.js +11 -3
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/reflection.spec.js +1 -1
- package/dist/astUtils/reflection.spec.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.js +20 -20
- package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
- package/dist/bscPlugin/hover/HoverProcessor.d.ts +1 -0
- package/dist/bscPlugin/hover/HoverProcessor.js +26 -6
- package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
- package/dist/bscPlugin/hover/HoverProcessor.spec.js +74 -2
- package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +2 -3
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.js +25 -26
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +6 -0
- package/dist/bscPlugin/validation/ScopeValidator.js +70 -20
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.spec.js +92 -10
- package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -1
- package/dist/diagnosticUtils.d.ts +1 -1
- package/dist/files/BrsFile.Class.spec.js +4 -3
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +3 -4
- package/dist/files/BrsFile.js +19 -112
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +56 -156
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/XmlFile.d.ts +2 -3
- package/dist/files/XmlFile.js +0 -2
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/interfaces.d.ts +77 -83
- package/dist/interfaces.js +9 -9
- package/dist/interfaces.js.map +1 -1
- package/dist/parser/Expression.d.ts +85 -91
- package/dist/parser/Expression.js +50 -28
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.Class.spec.js +15 -16
- package/dist/parser/Parser.Class.spec.js.map +1 -1
- package/dist/parser/Parser.d.ts +1 -2
- package/dist/parser/Parser.js +68 -62
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.js +27 -28
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/SGParser.js +49 -35
- package/dist/parser/SGParser.js.map +1 -1
- package/dist/parser/SGTypes.d.ts +36 -24
- package/dist/parser/SGTypes.js +26 -55
- package/dist/parser/SGTypes.js.map +1 -1
- package/dist/parser/Statement.d.ts +138 -139
- package/dist/parser/Statement.js +50 -37
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/tests/expression/TypeExpression.spec.js +8 -9
- package/dist/parser/tests/expression/TypeExpression.spec.js.map +1 -1
- package/dist/parser/tests/statement/TryCatch.spec.js +9 -2
- package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
- package/dist/roku-types/data.json +70 -52
- package/dist/roku-types/index.d.ts +43 -21
- package/dist/types/ArrayType.js +1 -2
- package/dist/types/ArrayType.js.map +1 -1
- package/dist/types/ArrayType.spec.js +7 -8
- package/dist/types/ArrayType.spec.js.map +1 -1
- package/dist/types/AssociativeArrayType.js +2 -3
- package/dist/types/AssociativeArrayType.js.map +1 -1
- package/dist/types/BscType.d.ts +1 -1
- package/dist/types/BscType.js +2 -3
- package/dist/types/BscType.js.map +1 -1
- package/dist/types/BuiltInInterfaceAdder.js +7 -8
- package/dist/types/BuiltInInterfaceAdder.js.map +1 -1
- package/dist/types/BuiltInInterfaceAdder.spec.js +31 -32
- package/dist/types/BuiltInInterfaceAdder.spec.js.map +1 -1
- package/dist/types/ClassType.spec.js +10 -11
- package/dist/types/ClassType.spec.js.map +1 -1
- package/dist/types/ComponentType.d.ts +2 -1
- package/dist/types/ComponentType.js.map +1 -1
- package/dist/types/EnumType.js +2 -3
- package/dist/types/EnumType.js.map +1 -1
- package/dist/types/InheritableType.js +3 -4
- package/dist/types/InheritableType.js.map +1 -1
- package/dist/types/InterfaceType.js +2 -3
- package/dist/types/InterfaceType.js.map +1 -1
- package/dist/types/InterfaceType.spec.js +3 -4
- package/dist/types/InterfaceType.spec.js.map +1 -1
- package/dist/types/ObjectType.js +1 -2
- package/dist/types/ObjectType.js.map +1 -1
- package/dist/types/ReferenceType.d.ts +1 -1
- package/dist/types/ReferenceType.spec.js +21 -22
- package/dist/types/ReferenceType.spec.js.map +1 -1
- package/dist/types/UnionType.js +3 -3
- package/dist/types/UnionType.js.map +1 -1
- package/dist/types/UnionType.spec.js +37 -38
- package/dist/types/UnionType.spec.js.map +1 -1
- package/dist/types/helper.spec.js +4 -5
- package/dist/types/helper.spec.js.map +1 -1
- package/dist/util.d.ts +3 -3
- package/dist/util.js +20 -19
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.d.ts +0 -9
- package/dist/validators/ClassValidator.js +3 -46
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,8 +4,7 @@ import type { Range } from 'vscode-languageserver';
|
|
|
4
4
|
import type { BrsTranspileState } from './BrsTranspileState';
|
|
5
5
|
import { ParseMode } from './Parser';
|
|
6
6
|
import type { WalkOptions, WalkVisitor } from '../astUtils/visitors';
|
|
7
|
-
import type { GetTypeOptions } from '../interfaces';
|
|
8
|
-
import { type TranspileResult, type TypedefProvider } from '../interfaces';
|
|
7
|
+
import type { GetTypeOptions, TranspileResult, TypedefProvider } from '../interfaces';
|
|
9
8
|
import { VoidType } from '../types/VoidType';
|
|
10
9
|
import { DynamicType } from '../types/DynamicType';
|
|
11
10
|
import type { BscType } from '../types/BscType';
|
|
@@ -21,11 +20,11 @@ export declare class BinaryExpression extends Expression {
|
|
|
21
20
|
operator: Token;
|
|
22
21
|
right: Expression;
|
|
23
22
|
});
|
|
24
|
-
tokens: {
|
|
25
|
-
operator: Token;
|
|
23
|
+
readonly tokens: {
|
|
24
|
+
readonly operator: Token;
|
|
26
25
|
};
|
|
27
|
-
left: Expression;
|
|
28
|
-
right: Expression;
|
|
26
|
+
readonly left: Expression;
|
|
27
|
+
readonly right: Expression;
|
|
29
28
|
readonly kind = AstNodeKind.BinaryExpression;
|
|
30
29
|
readonly range: Range;
|
|
31
30
|
transpile(state: BrsTranspileState): (string | SourceNode)[];
|
|
@@ -42,7 +41,7 @@ export declare class CallExpression extends Expression {
|
|
|
42
41
|
});
|
|
43
42
|
readonly callee: Expression;
|
|
44
43
|
readonly args: Expression[];
|
|
45
|
-
tokens: {
|
|
44
|
+
readonly tokens: {
|
|
46
45
|
/**
|
|
47
46
|
* Can either be `(`, or `?(` for optional chaining - defaults to '('
|
|
48
47
|
*/
|
|
@@ -68,20 +67,15 @@ export declare class FunctionExpression extends Expression implements TypedefPro
|
|
|
68
67
|
});
|
|
69
68
|
readonly kind = AstNodeKind.FunctionExpression;
|
|
70
69
|
readonly parameters: FunctionParameterExpression[];
|
|
71
|
-
body: Block;
|
|
72
|
-
returnTypeExpression?: TypeExpression;
|
|
70
|
+
readonly body: Block;
|
|
71
|
+
readonly returnTypeExpression?: TypeExpression;
|
|
73
72
|
readonly tokens: {
|
|
74
|
-
functionType?: Token;
|
|
75
|
-
endFunctionType?: Token;
|
|
76
|
-
leftParen?: Token;
|
|
77
|
-
rightParen?: Token;
|
|
78
|
-
as?: Token;
|
|
73
|
+
readonly functionType?: Token;
|
|
74
|
+
readonly endFunctionType?: Token;
|
|
75
|
+
readonly leftParen?: Token;
|
|
76
|
+
readonly rightParen?: Token;
|
|
77
|
+
readonly as?: Token;
|
|
79
78
|
};
|
|
80
|
-
/**
|
|
81
|
-
* The list of function calls that are declared within this function scope. This excludes CallExpressions
|
|
82
|
-
* declared in child functions
|
|
83
|
-
*/
|
|
84
|
-
callExpressions: CallExpression[];
|
|
85
79
|
/**
|
|
86
80
|
* If this function is part of a FunctionStatement, this will be set. Otherwise this will be undefined
|
|
87
81
|
*/
|
|
@@ -106,13 +100,13 @@ export declare class FunctionParameterExpression extends Expression {
|
|
|
106
100
|
typeExpression?: TypeExpression;
|
|
107
101
|
});
|
|
108
102
|
readonly kind = AstNodeKind.FunctionParameterExpression;
|
|
109
|
-
tokens: {
|
|
110
|
-
name: Identifier;
|
|
111
|
-
equals?: Token;
|
|
112
|
-
as?: Token;
|
|
103
|
+
readonly tokens: {
|
|
104
|
+
readonly name: Identifier;
|
|
105
|
+
readonly equals?: Token;
|
|
106
|
+
readonly as?: Token;
|
|
113
107
|
};
|
|
114
|
-
defaultValue?: Expression;
|
|
115
|
-
typeExpression?: TypeExpression;
|
|
108
|
+
readonly defaultValue?: Expression;
|
|
109
|
+
readonly typeExpression?: TypeExpression;
|
|
116
110
|
getType(options: GetTypeOptions): BscType;
|
|
117
111
|
get range(): Range;
|
|
118
112
|
transpile(state: BrsTranspileState): any[];
|
|
@@ -129,8 +123,8 @@ export declare class DottedGetExpression extends Expression {
|
|
|
129
123
|
dot?: Token;
|
|
130
124
|
});
|
|
131
125
|
readonly tokens: {
|
|
132
|
-
name: Identifier;
|
|
133
|
-
dot?: Token;
|
|
126
|
+
readonly name: Identifier;
|
|
127
|
+
readonly dot?: Token;
|
|
134
128
|
};
|
|
135
129
|
readonly obj: Expression;
|
|
136
130
|
readonly kind = AstNodeKind.DottedGetExpression;
|
|
@@ -150,7 +144,7 @@ export declare class XmlAttributeGetExpression extends Expression {
|
|
|
150
144
|
name: Identifier;
|
|
151
145
|
});
|
|
152
146
|
readonly kind = AstNodeKind.XmlAttributeGetExpression;
|
|
153
|
-
tokens: {
|
|
147
|
+
readonly tokens: {
|
|
154
148
|
name: Identifier;
|
|
155
149
|
at?: Token;
|
|
156
150
|
};
|
|
@@ -171,15 +165,15 @@ export declare class IndexedGetExpression extends Expression {
|
|
|
171
165
|
questionDot?: Token;
|
|
172
166
|
});
|
|
173
167
|
readonly kind = AstNodeKind.IndexedGetExpression;
|
|
174
|
-
obj: Expression;
|
|
175
|
-
indexes: Expression[];
|
|
176
|
-
tokens: {
|
|
168
|
+
readonly obj: Expression;
|
|
169
|
+
readonly indexes: Expression[];
|
|
170
|
+
readonly tokens: {
|
|
177
171
|
/**
|
|
178
172
|
* Can either be `[` or `?[`. If `?.[` is used, this will be `[` and `optionalChainingToken` will be `?.` - defaults to '[' in transpile
|
|
179
173
|
*/
|
|
180
|
-
openingSquare?: Token;
|
|
181
|
-
closingSquare?: Token;
|
|
182
|
-
questionDot?: Token;
|
|
174
|
+
readonly openingSquare?: Token;
|
|
175
|
+
readonly closingSquare?: Token;
|
|
176
|
+
readonly questionDot?: Token;
|
|
183
177
|
};
|
|
184
178
|
readonly range: Range;
|
|
185
179
|
transpile(state: BrsTranspileState): any[];
|
|
@@ -193,10 +187,10 @@ export declare class GroupingExpression extends Expression {
|
|
|
193
187
|
expression: Expression;
|
|
194
188
|
});
|
|
195
189
|
readonly tokens: {
|
|
196
|
-
leftParen?: Token;
|
|
197
|
-
rightParen?: Token;
|
|
190
|
+
readonly leftParen?: Token;
|
|
191
|
+
readonly rightParen?: Token;
|
|
198
192
|
};
|
|
199
|
-
expression: Expression;
|
|
193
|
+
readonly expression: Expression;
|
|
200
194
|
readonly kind = AstNodeKind.GroupingExpression;
|
|
201
195
|
readonly range: Range;
|
|
202
196
|
transpile(state: BrsTranspileState): TranspileResult;
|
|
@@ -207,12 +201,12 @@ export declare class LiteralExpression extends Expression {
|
|
|
207
201
|
constructor(options: {
|
|
208
202
|
value: Token;
|
|
209
203
|
});
|
|
210
|
-
tokens: {
|
|
211
|
-
value: Token;
|
|
204
|
+
readonly tokens: {
|
|
205
|
+
readonly value: Token;
|
|
212
206
|
};
|
|
213
207
|
readonly kind = AstNodeKind.LiteralExpression;
|
|
214
208
|
get range(): Range;
|
|
215
|
-
getType(options?: GetTypeOptions): DynamicType | import("
|
|
209
|
+
getType(options?: GetTypeOptions): DynamicType | import("..").ObjectType | StringType | import("..").IntegerType | import("..").BooleanType | import("..").FloatType | import("..").DoubleType | import("..").LongIntegerType | VoidType | import("../types/FunctionType").FunctionType;
|
|
216
210
|
transpile(state: BrsTranspileState): SourceNode[];
|
|
217
211
|
walk(visitor: WalkVisitor, options: WalkOptions): void;
|
|
218
212
|
}
|
|
@@ -227,8 +221,8 @@ export declare class EscapedCharCodeLiteralExpression extends Expression {
|
|
|
227
221
|
};
|
|
228
222
|
});
|
|
229
223
|
readonly kind = AstNodeKind.EscapedCharCodeLiteralExpression;
|
|
230
|
-
tokens: {
|
|
231
|
-
value: Token & {
|
|
224
|
+
readonly tokens: {
|
|
225
|
+
readonly value: Token & {
|
|
232
226
|
charCode: number;
|
|
233
227
|
};
|
|
234
228
|
};
|
|
@@ -244,8 +238,8 @@ export declare class ArrayLiteralExpression extends Expression {
|
|
|
244
238
|
});
|
|
245
239
|
readonly elements: Array<Expression | CommentStatement>;
|
|
246
240
|
readonly tokens: {
|
|
247
|
-
open?: Token;
|
|
248
|
-
close?: Token;
|
|
241
|
+
readonly open?: Token;
|
|
242
|
+
readonly close?: Token;
|
|
249
243
|
};
|
|
250
244
|
readonly kind = AstNodeKind.ArrayLiteralExpression;
|
|
251
245
|
readonly range: Range;
|
|
@@ -262,14 +256,14 @@ export declare class AAMemberExpression extends Expression {
|
|
|
262
256
|
comma?: Token;
|
|
263
257
|
});
|
|
264
258
|
readonly kind = AstNodeKind.AAMemberExpression;
|
|
265
|
-
range: Range;
|
|
266
|
-
tokens: {
|
|
267
|
-
key: Token;
|
|
268
|
-
colon?: Token;
|
|
269
|
-
comma?: Token;
|
|
259
|
+
readonly range: Range;
|
|
260
|
+
readonly tokens: {
|
|
261
|
+
readonly key: Token;
|
|
262
|
+
readonly colon?: Token;
|
|
263
|
+
readonly comma?: Token;
|
|
270
264
|
};
|
|
271
265
|
/** The expression evaluated to determine the member's initial value. */
|
|
272
|
-
value: Expression;
|
|
266
|
+
readonly value: Expression;
|
|
273
267
|
transpile(state: BrsTranspileState): any[];
|
|
274
268
|
walk(visitor: WalkVisitor, options: WalkOptions): void;
|
|
275
269
|
getType(options: GetTypeOptions): BscType;
|
|
@@ -282,8 +276,8 @@ export declare class AALiteralExpression extends Expression {
|
|
|
282
276
|
});
|
|
283
277
|
readonly elements: Array<AAMemberExpression | CommentStatement>;
|
|
284
278
|
readonly tokens: {
|
|
285
|
-
open?: Token;
|
|
286
|
-
close?: Token;
|
|
279
|
+
readonly open?: Token;
|
|
280
|
+
readonly close?: Token;
|
|
287
281
|
};
|
|
288
282
|
readonly kind = AstNodeKind.AALiteralExpression;
|
|
289
283
|
readonly range: Range;
|
|
@@ -298,10 +292,10 @@ export declare class UnaryExpression extends Expression {
|
|
|
298
292
|
});
|
|
299
293
|
readonly kind = AstNodeKind.UnaryExpression;
|
|
300
294
|
readonly range: Range;
|
|
301
|
-
tokens: {
|
|
302
|
-
operator: Token;
|
|
295
|
+
readonly tokens: {
|
|
296
|
+
readonly operator: Token;
|
|
303
297
|
};
|
|
304
|
-
right: Expression;
|
|
298
|
+
readonly right: Expression;
|
|
305
299
|
transpile(state: BrsTranspileState): (string | SourceNode)[];
|
|
306
300
|
walk(visitor: WalkVisitor, options: WalkOptions): void;
|
|
307
301
|
getType(options: GetTypeOptions): BscType;
|
|
@@ -311,7 +305,7 @@ export declare class VariableExpression extends Expression {
|
|
|
311
305
|
name: Identifier;
|
|
312
306
|
});
|
|
313
307
|
readonly tokens: {
|
|
314
|
-
name: Identifier;
|
|
308
|
+
readonly name: Identifier;
|
|
315
309
|
};
|
|
316
310
|
readonly kind = AstNodeKind.VariableExpression;
|
|
317
311
|
readonly range: Range;
|
|
@@ -327,7 +321,7 @@ export declare class SourceLiteralExpression extends Expression {
|
|
|
327
321
|
readonly range: Range;
|
|
328
322
|
readonly kind = AstNodeKind.SourceLiteralExpression;
|
|
329
323
|
readonly tokens: {
|
|
330
|
-
value: Token;
|
|
324
|
+
readonly value: Token;
|
|
331
325
|
};
|
|
332
326
|
/**
|
|
333
327
|
* Find the index of the function in its parent
|
|
@@ -350,7 +344,7 @@ export declare class NewExpression extends Expression {
|
|
|
350
344
|
readonly kind = AstNodeKind.NewExpression;
|
|
351
345
|
readonly range: Range;
|
|
352
346
|
readonly tokens: {
|
|
353
|
-
new?: Token;
|
|
347
|
+
readonly new?: Token;
|
|
354
348
|
};
|
|
355
349
|
readonly call: CallExpression;
|
|
356
350
|
/**
|
|
@@ -373,10 +367,10 @@ export declare class CallfuncExpression extends Expression {
|
|
|
373
367
|
readonly callee: Expression;
|
|
374
368
|
readonly args: Expression[];
|
|
375
369
|
readonly tokens: {
|
|
376
|
-
operator: Token;
|
|
377
|
-
methodName: Identifier;
|
|
378
|
-
openingParen?: Token;
|
|
379
|
-
closingParen?: Token;
|
|
370
|
+
readonly operator: Token;
|
|
371
|
+
readonly methodName: Identifier;
|
|
372
|
+
readonly openingParen?: Token;
|
|
373
|
+
readonly closingParen?: Token;
|
|
380
374
|
};
|
|
381
375
|
readonly kind = AstNodeKind.CallfuncExpression;
|
|
382
376
|
readonly range: Range;
|
|
@@ -407,8 +401,8 @@ export declare class TemplateStringExpression extends Expression {
|
|
|
407
401
|
});
|
|
408
402
|
readonly kind = AstNodeKind.TemplateStringExpression;
|
|
409
403
|
readonly tokens: {
|
|
410
|
-
openingBacktick?: Token;
|
|
411
|
-
closingBacktick?: Token;
|
|
404
|
+
readonly openingBacktick?: Token;
|
|
405
|
+
readonly closingBacktick?: Token;
|
|
412
406
|
};
|
|
413
407
|
readonly quasis: TemplateStringQuasiExpression[];
|
|
414
408
|
readonly expressions: Expression[];
|
|
@@ -426,10 +420,10 @@ export declare class TaggedTemplateStringExpression extends Expression {
|
|
|
426
420
|
closingBacktick?: Token;
|
|
427
421
|
});
|
|
428
422
|
readonly kind = AstNodeKind.TaggedTemplateStringExpression;
|
|
429
|
-
tokens: {
|
|
430
|
-
tagName: Identifier;
|
|
431
|
-
openingBacktick?: Token;
|
|
432
|
-
closingBacktick?: Token;
|
|
423
|
+
readonly tokens: {
|
|
424
|
+
readonly tagName: Identifier;
|
|
425
|
+
readonly openingBacktick?: Token;
|
|
426
|
+
readonly closingBacktick?: Token;
|
|
433
427
|
};
|
|
434
428
|
readonly quasis: TemplateStringQuasiExpression[];
|
|
435
429
|
readonly expressions: Expression[];
|
|
@@ -445,11 +439,11 @@ export declare class AnnotationExpression extends Expression {
|
|
|
445
439
|
});
|
|
446
440
|
readonly kind = AstNodeKind.AnnotationExpression;
|
|
447
441
|
readonly tokens: {
|
|
448
|
-
at: Token;
|
|
449
|
-
name: Token;
|
|
442
|
+
readonly at: Token;
|
|
443
|
+
readonly name: Token;
|
|
450
444
|
};
|
|
451
445
|
get range(): Range;
|
|
452
|
-
name: string;
|
|
446
|
+
readonly name: string;
|
|
453
447
|
call: CallExpression;
|
|
454
448
|
/**
|
|
455
449
|
* Convert annotation arguments to JavaScript types
|
|
@@ -470,10 +464,10 @@ export declare class TernaryExpression extends Expression {
|
|
|
470
464
|
alternate?: Expression;
|
|
471
465
|
});
|
|
472
466
|
readonly kind = AstNodeKind.TernaryExpression;
|
|
473
|
-
range: Range;
|
|
467
|
+
readonly range: Range;
|
|
474
468
|
readonly tokens: {
|
|
475
|
-
questionMark?: Token;
|
|
476
|
-
colon?: Token;
|
|
469
|
+
readonly questionMark?: Token;
|
|
470
|
+
readonly colon?: Token;
|
|
477
471
|
};
|
|
478
472
|
readonly test: Expression;
|
|
479
473
|
readonly consequent?: Expression;
|
|
@@ -489,11 +483,11 @@ export declare class NullCoalescingExpression extends Expression {
|
|
|
489
483
|
});
|
|
490
484
|
readonly kind = AstNodeKind.NullCoalescingExpression;
|
|
491
485
|
readonly range: Range;
|
|
492
|
-
tokens: {
|
|
493
|
-
questionQuestion?: Token;
|
|
486
|
+
readonly tokens: {
|
|
487
|
+
readonly questionQuestion?: Token;
|
|
494
488
|
};
|
|
495
|
-
consequent: Expression;
|
|
496
|
-
alternate: Expression;
|
|
489
|
+
readonly consequent: Expression;
|
|
490
|
+
readonly alternate: Expression;
|
|
497
491
|
transpile(state: BrsTranspileState): any[];
|
|
498
492
|
walk(visitor: WalkVisitor, options: WalkOptions): void;
|
|
499
493
|
}
|
|
@@ -502,8 +496,8 @@ export declare class RegexLiteralExpression extends Expression {
|
|
|
502
496
|
regexLiteral: Token;
|
|
503
497
|
});
|
|
504
498
|
readonly kind = AstNodeKind.RegexLiteralExpression;
|
|
505
|
-
tokens: {
|
|
506
|
-
regexLiteral: Token;
|
|
499
|
+
readonly tokens: {
|
|
500
|
+
readonly regexLiteral: Token;
|
|
507
501
|
};
|
|
508
502
|
get range(): Range;
|
|
509
503
|
transpile(state: BrsTranspileState): TranspileResult;
|
|
@@ -523,8 +517,8 @@ export declare class TypeExpression extends Expression implements TypedefProvide
|
|
|
523
517
|
/**
|
|
524
518
|
* The standard AST expression that represents the type for this TypeExpression.
|
|
525
519
|
*/
|
|
526
|
-
expression: Expression;
|
|
527
|
-
range: Range;
|
|
520
|
+
readonly expression: Expression;
|
|
521
|
+
readonly range: Range;
|
|
528
522
|
transpile(state: BrsTranspileState): TranspileResult;
|
|
529
523
|
walk(visitor: WalkVisitor, options: WalkOptions): void;
|
|
530
524
|
getType(options: GetTypeOptions): BscType;
|
|
@@ -539,12 +533,12 @@ export declare class TypeCastExpression extends Expression {
|
|
|
539
533
|
typeExpression?: TypeExpression;
|
|
540
534
|
});
|
|
541
535
|
readonly kind = AstNodeKind.TypeCastExpression;
|
|
542
|
-
obj: Expression;
|
|
543
|
-
tokens: {
|
|
544
|
-
as?: Token;
|
|
536
|
+
readonly obj: Expression;
|
|
537
|
+
readonly tokens: {
|
|
538
|
+
readonly as?: Token;
|
|
545
539
|
};
|
|
546
540
|
typeExpression?: TypeExpression;
|
|
547
|
-
range: Range;
|
|
541
|
+
readonly range: Range;
|
|
548
542
|
transpile(state: BrsTranspileState): TranspileResult;
|
|
549
543
|
walk(visitor: WalkVisitor, options: WalkOptions): void;
|
|
550
544
|
getType(options: GetTypeOptions): BscType;
|
|
@@ -555,13 +549,13 @@ export declare class TypedArrayExpression extends Expression {
|
|
|
555
549
|
leftBracket?: Token;
|
|
556
550
|
rightBracket?: Token;
|
|
557
551
|
});
|
|
558
|
-
tokens: {
|
|
559
|
-
leftBracket?: Token;
|
|
560
|
-
rightBracket?: Token;
|
|
552
|
+
readonly tokens: {
|
|
553
|
+
readonly leftBracket?: Token;
|
|
554
|
+
readonly rightBracket?: Token;
|
|
561
555
|
};
|
|
562
|
-
innerType: Expression;
|
|
556
|
+
readonly innerType: Expression;
|
|
563
557
|
readonly kind = AstNodeKind.TypedArrayExpression;
|
|
564
|
-
range: Range;
|
|
558
|
+
readonly range: Range;
|
|
565
559
|
transpile(state: BrsTranspileState): TranspileResult;
|
|
566
560
|
walk(visitor: WalkVisitor, options: WalkOptions): void;
|
|
567
561
|
getType(options: GetTypeOptions): BscType;
|
|
@@ -11,15 +11,14 @@ const reflection_1 = require("../astUtils/reflection");
|
|
|
11
11
|
const interfaces_1 = require("../interfaces");
|
|
12
12
|
const VoidType_1 = require("../types/VoidType");
|
|
13
13
|
const DynamicType_1 = require("../types/DynamicType");
|
|
14
|
-
const SymbolTable_1 = require("../SymbolTable");
|
|
15
14
|
const TypedFunctionType_1 = require("../types/TypedFunctionType");
|
|
16
15
|
const AstNode_1 = require("./AstNode");
|
|
17
|
-
const
|
|
16
|
+
const SymbolTable_1 = require("../SymbolTable");
|
|
18
17
|
const source_map_1 = require("source-map");
|
|
19
18
|
const StringType_1 = require("../types/StringType");
|
|
20
19
|
const ReferenceType_1 = require("../types/ReferenceType");
|
|
21
20
|
const UnionType_1 = require("../types/UnionType");
|
|
22
|
-
const
|
|
21
|
+
const ArrayType_1 = require("../types/ArrayType");
|
|
23
22
|
const AssociativeArrayType_1 = require("../types/AssociativeArrayType");
|
|
24
23
|
const creators_1 = require("../astUtils/creators");
|
|
25
24
|
class BinaryExpression extends AstNode_1.Expression {
|
|
@@ -50,7 +49,7 @@ class BinaryExpression extends AstNode_1.Expression {
|
|
|
50
49
|
}
|
|
51
50
|
getType(options) {
|
|
52
51
|
const operatorKind = this.tokens.operator.kind;
|
|
53
|
-
if (options.flags &
|
|
52
|
+
if (options.flags & 2 /* SymbolTypeFlag.typetime */) {
|
|
54
53
|
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
|
|
55
54
|
switch (operatorKind) {
|
|
56
55
|
case TokenKind_1.TokenKind.Or:
|
|
@@ -58,7 +57,7 @@ class BinaryExpression extends AstNode_1.Expression {
|
|
|
58
57
|
//TODO: Intersection Types?, eg. case TokenKind.And:
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
|
-
else if (options.flags &
|
|
60
|
+
else if (options.flags & 1 /* SymbolTypeFlag.runtime */) {
|
|
62
61
|
return util_1.default.binaryOperatorResultType(this.left.getType(options), this.tokens.operator, this.right.getType(options));
|
|
63
62
|
}
|
|
64
63
|
return DynamicType_1.DynamicType.instance;
|
|
@@ -132,11 +131,6 @@ class FunctionExpression extends AstNode_1.Expression {
|
|
|
132
131
|
var _a;
|
|
133
132
|
super();
|
|
134
133
|
this.kind = AstNode_1.AstNodeKind.FunctionExpression;
|
|
135
|
-
/**
|
|
136
|
-
* The list of function calls that are declared within this function scope. This excludes CallExpressions
|
|
137
|
-
* declared in child functions
|
|
138
|
-
*/
|
|
139
|
-
this.callExpressions = [];
|
|
140
134
|
this.tokens = {
|
|
141
135
|
functionType: options.functionType,
|
|
142
136
|
leftParen: options.leftParen,
|
|
@@ -149,9 +143,9 @@ class FunctionExpression extends AstNode_1.Expression {
|
|
|
149
143
|
this.returnTypeExpression = options.returnTypeExpression;
|
|
150
144
|
//if there's a body, and it doesn't have a SymbolTable, assign one
|
|
151
145
|
if (this.body && !this.body.symbolTable) {
|
|
152
|
-
this.body.symbolTable = new
|
|
146
|
+
this.body.symbolTable = new SymbolTable_1.SymbolTable(`Block`, () => this.getSymbolTable());
|
|
153
147
|
}
|
|
154
|
-
this.symbolTable = new
|
|
148
|
+
this.symbolTable = new SymbolTable_1.SymbolTable('FunctionExpression', () => { var _a; return (_a = this.parent) === null || _a === void 0 ? void 0 : _a.getSymbolTable(); });
|
|
155
149
|
}
|
|
156
150
|
getLeadingTrivia() {
|
|
157
151
|
var _a, _b;
|
|
@@ -278,7 +272,7 @@ class FunctionExpression extends AstNode_1.Expression {
|
|
|
278
272
|
if (funcName) {
|
|
279
273
|
resultType.setName(funcName);
|
|
280
274
|
}
|
|
281
|
-
(_d = options.typeChain) === null || _d === void 0 ? void 0 : _d.push(new interfaces_1.TypeChainEntry(funcName, resultType, options.data, this.range));
|
|
275
|
+
(_d = options.typeChain) === null || _d === void 0 ? void 0 : _d.push(new interfaces_1.TypeChainEntry({ name: funcName, type: resultType, data: options.data, range: this.range, kind: this.kind }));
|
|
282
276
|
return resultType;
|
|
283
277
|
}
|
|
284
278
|
}
|
|
@@ -297,8 +291,8 @@ class FunctionParameterExpression extends AstNode_1.Expression {
|
|
|
297
291
|
}
|
|
298
292
|
getType(options) {
|
|
299
293
|
var _a, _b, _c, _d, _e;
|
|
300
|
-
const paramType = (_d = (_b = (_a = this.typeExpression) === null || _a === void 0 ? void 0 : _a.getType(Object.assign(Object.assign({}, options), { flags:
|
|
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));
|
|
294
|
+
const paramType = (_d = (_b = (_a = this.typeExpression) === null || _a === void 0 ? void 0 : _a.getType(Object.assign(Object.assign({}, options), { flags: 2 /* 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: 1 /* SymbolTypeFlag.runtime */, typeChain: undefined }))) !== null && _d !== void 0 ? _d : DynamicType_1.DynamicType.instance;
|
|
295
|
+
(_e = options.typeChain) === null || _e === void 0 ? void 0 : _e.push(new interfaces_1.TypeChainEntry({ name: this.tokens.name.text, type: paramType, data: options.data, range: this.range, kind: this.kind }));
|
|
302
296
|
return paramType;
|
|
303
297
|
}
|
|
304
298
|
get range() {
|
|
@@ -385,8 +379,14 @@ class DottedGetExpression extends AstNode_1.Expression {
|
|
|
385
379
|
var _a, _b, _c, _d, _e, _f;
|
|
386
380
|
const objType = (_a = this.obj) === null || _a === void 0 ? void 0 : _a.getType(options);
|
|
387
381
|
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(
|
|
389
|
-
|
|
382
|
+
(_c = options.typeChain) === null || _c === void 0 ? void 0 : _c.push(new interfaces_1.TypeChainEntry({
|
|
383
|
+
name: (_d = this.tokens.name) === null || _d === void 0 ? void 0 : _d.text,
|
|
384
|
+
type: result,
|
|
385
|
+
data: options.data,
|
|
386
|
+
range: (_f = (_e = this.tokens.name) === null || _e === void 0 ? void 0 : _e.range) !== null && _f !== void 0 ? _f : this.range,
|
|
387
|
+
kind: this.kind
|
|
388
|
+
}));
|
|
389
|
+
if (result || options.flags & 2 /* SymbolTypeFlag.typetime */) {
|
|
390
390
|
// All types should be known at typetime
|
|
391
391
|
return result;
|
|
392
392
|
}
|
|
@@ -610,7 +610,7 @@ class ArrayLiteralExpression extends AstNode_1.Expression {
|
|
|
610
610
|
}
|
|
611
611
|
getType(options) {
|
|
612
612
|
const innerTypes = this.elements.filter(x => !(0, reflection_1.isCommentStatement)(x)).map(expr => expr.getType(options));
|
|
613
|
-
return new
|
|
613
|
+
return new ArrayType_1.ArrayType(...innerTypes);
|
|
614
614
|
}
|
|
615
615
|
}
|
|
616
616
|
exports.ArrayLiteralExpression = ArrayLiteralExpression;
|
|
@@ -710,7 +710,7 @@ class AALiteralExpression extends AstNode_1.Expression {
|
|
|
710
710
|
const resultType = new AssociativeArrayType_1.AssociativeArrayType();
|
|
711
711
|
for (const element of this.elements) {
|
|
712
712
|
if ((0, reflection_1.isAAMemberExpression)(element)) {
|
|
713
|
-
resultType.addMember(element.tokens.key.text, { definingNode: element }, element.getType(options),
|
|
713
|
+
resultType.addMember(element.tokens.key.text, { definingNode: element }, element.getType(options), 1 /* SymbolTypeFlag.runtime */);
|
|
714
714
|
}
|
|
715
715
|
}
|
|
716
716
|
return resultType;
|
|
@@ -795,7 +795,7 @@ class VariableExpression extends AstNode_1.Expression {
|
|
|
795
795
|
const symbolTable = this.getSymbolTable();
|
|
796
796
|
resultType = symbolTable === null || symbolTable === void 0 ? void 0 : symbolTable.getSymbolType(nameKey, Object.assign(Object.assign({}, options), { fullName: nameKey, tableProvider: () => this.getSymbolTable() }));
|
|
797
797
|
}
|
|
798
|
-
(_a = options.typeChain) === null || _a === void 0 ? void 0 : _a.push(new interfaces_1.TypeChainEntry(nameKey, resultType, options.data, this.range));
|
|
798
|
+
(_a = options.typeChain) === null || _a === void 0 ? void 0 : _a.push(new interfaces_1.TypeChainEntry({ name: nameKey, type: resultType, data: options.data, range: this.range, kind: this.kind }));
|
|
799
799
|
return resultType;
|
|
800
800
|
}
|
|
801
801
|
}
|
|
@@ -918,7 +918,15 @@ class NewExpression extends AstNode_1.Expression {
|
|
|
918
918
|
}
|
|
919
919
|
}
|
|
920
920
|
getType(options) {
|
|
921
|
-
|
|
921
|
+
const result = this.call.getType(options);
|
|
922
|
+
if (options.typeChain) {
|
|
923
|
+
// modify last typechain entry to show it is a new ...()
|
|
924
|
+
const lastEntry = options.typeChain[options.typeChain.length - 1];
|
|
925
|
+
if (lastEntry) {
|
|
926
|
+
lastEntry.kind = this.kind;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
return result;
|
|
922
930
|
}
|
|
923
931
|
}
|
|
924
932
|
exports.NewExpression = NewExpression;
|
|
@@ -972,11 +980,17 @@ class CallfuncExpression extends AstNode_1.Expression {
|
|
|
972
980
|
let result = DynamicType_1.DynamicType.instance;
|
|
973
981
|
// a little hacky here with checking options.ignoreCall because callFuncExpression has the method name
|
|
974
982
|
// It's nicer for CallExpression, because it's a call on any expression.
|
|
975
|
-
const calleeType = this.callee.getType(Object.assign(Object.assign({}, options), { flags:
|
|
983
|
+
const calleeType = this.callee.getType(Object.assign(Object.assign({}, options), { flags: 1 /* SymbolTypeFlag.runtime */ }));
|
|
976
984
|
if ((0, reflection_1.isComponentType)(calleeType) || (0, reflection_1.isReferenceType)(calleeType)) {
|
|
977
985
|
const funcType = (_b = (_a = calleeType).getCallFuncType) === null || _b === void 0 ? void 0 : _b.call(_a, this.tokens.methodName.text, options);
|
|
978
986
|
if (funcType) {
|
|
979
|
-
(_c = options.typeChain) === null || _c === void 0 ? void 0 : _c.push(new interfaces_1.TypeChainEntry(
|
|
987
|
+
(_c = options.typeChain) === null || _c === void 0 ? void 0 : _c.push(new interfaces_1.TypeChainEntry({
|
|
988
|
+
name: this.tokens.methodName.text,
|
|
989
|
+
type: funcType,
|
|
990
|
+
data: options.data, range: this.tokens.methodName.range,
|
|
991
|
+
separatorToken: (0, creators_1.createToken)(TokenKind_1.TokenKind.Callfunc),
|
|
992
|
+
kind: this.kind
|
|
993
|
+
}));
|
|
980
994
|
if (options.ignoreCall) {
|
|
981
995
|
result = funcType;
|
|
982
996
|
}
|
|
@@ -1370,7 +1384,7 @@ class TypeExpression extends AstNode_1.Expression {
|
|
|
1370
1384
|
this.range = (_a = this.expression) === null || _a === void 0 ? void 0 : _a.range;
|
|
1371
1385
|
}
|
|
1372
1386
|
transpile(state) {
|
|
1373
|
-
return [this.getType({ flags:
|
|
1387
|
+
return [this.getType({ flags: 2 /* SymbolTypeFlag.typetime */ }).toTypeString()];
|
|
1374
1388
|
}
|
|
1375
1389
|
walk(visitor, options) {
|
|
1376
1390
|
if (options.walkMode & visitors_2.InternalWalkMode.walkExpressions) {
|
|
@@ -1378,7 +1392,7 @@ class TypeExpression extends AstNode_1.Expression {
|
|
|
1378
1392
|
}
|
|
1379
1393
|
}
|
|
1380
1394
|
getType(options) {
|
|
1381
|
-
return this.expression.getType(Object.assign(Object.assign({}, options), { flags:
|
|
1395
|
+
return this.expression.getType(Object.assign(Object.assign({}, options), { flags: 2 /* SymbolTypeFlag.typetime */ }));
|
|
1382
1396
|
}
|
|
1383
1397
|
getTypedef(state) {
|
|
1384
1398
|
// TypeDefs should pass through any valid type names
|
|
@@ -1415,7 +1429,15 @@ class TypeCastExpression extends AstNode_1.Expression {
|
|
|
1415
1429
|
}
|
|
1416
1430
|
}
|
|
1417
1431
|
getType(options) {
|
|
1418
|
-
|
|
1432
|
+
const result = this.typeExpression.getType(options);
|
|
1433
|
+
if (options.typeChain) {
|
|
1434
|
+
// modify last typechain entry to show it is a typecast
|
|
1435
|
+
const lastEntry = options.typeChain[options.typeChain.length - 1];
|
|
1436
|
+
if (lastEntry) {
|
|
1437
|
+
lastEntry.kind = this.kind;
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
return result;
|
|
1419
1441
|
}
|
|
1420
1442
|
}
|
|
1421
1443
|
exports.TypeCastExpression = TypeCastExpression;
|
|
@@ -1431,7 +1453,7 @@ class TypedArrayExpression extends AstNode_1.Expression {
|
|
|
1431
1453
|
this.range = util_1.default.createBoundingRange(this.innerType, this.tokens.leftBracket, this.tokens.rightBracket);
|
|
1432
1454
|
}
|
|
1433
1455
|
transpile(state) {
|
|
1434
|
-
return [this.getType({ flags:
|
|
1456
|
+
return [this.getType({ flags: 2 /* SymbolTypeFlag.typetime */ }).toTypeString()];
|
|
1435
1457
|
}
|
|
1436
1458
|
walk(visitor, options) {
|
|
1437
1459
|
if (options.walkMode & visitors_2.InternalWalkMode.walkExpressions) {
|
|
@@ -1439,7 +1461,7 @@ class TypedArrayExpression extends AstNode_1.Expression {
|
|
|
1439
1461
|
}
|
|
1440
1462
|
}
|
|
1441
1463
|
getType(options) {
|
|
1442
|
-
return new
|
|
1464
|
+
return new ArrayType_1.ArrayType(this.innerType.getType(options));
|
|
1443
1465
|
}
|
|
1444
1466
|
}
|
|
1445
1467
|
exports.TypedArrayExpression = TypedArrayExpression;
|