brighterscript 1.0.0-alpha.14 → 1.0.0-alpha.17
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 +83 -1
- package/README.md +28 -9
- package/dist/Cache.d.ts +2 -7
- package/dist/Cache.js +4 -13
- package/dist/Cache.js.map +1 -1
- package/dist/DependencyGraph.js +5 -4
- package/dist/DependencyGraph.js.map +1 -1
- package/dist/DiagnosticMessages.d.ts +21 -1
- package/dist/DiagnosticMessages.js +21 -1
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/Logger.js +5 -5
- package/dist/Logger.js.map +1 -1
- package/dist/Program.d.ts +3 -3
- package/dist/Program.js +9 -7
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.js +1 -1
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/Scope.d.ts +16 -11
- package/dist/Scope.js +42 -12
- package/dist/Scope.js.map +1 -1
- package/dist/XmlScope.d.ts +3 -3
- package/dist/XmlScope.js +1 -1
- package/dist/XmlScope.js.map +1 -1
- package/dist/astUtils/AstEditor.d.ts +6 -0
- package/dist/astUtils/AstEditor.js +10 -0
- package/dist/astUtils/AstEditor.js.map +1 -1
- package/dist/astUtils/AstEditor.spec.js +37 -0
- package/dist/astUtils/AstEditor.spec.js.map +1 -1
- package/dist/astUtils/creators.d.ts +10 -6
- package/dist/astUtils/creators.js +93 -12
- package/dist/astUtils/creators.js.map +1 -1
- package/dist/astUtils/creators.spec.js +10 -0
- package/dist/astUtils/creators.spec.js.map +1 -1
- package/dist/astUtils/reflection.d.ts +7 -2
- package/dist/astUtils/reflection.js +19 -3
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/reflection.spec.js +5 -4
- package/dist/astUtils/reflection.spec.js.map +1 -1
- package/dist/astUtils/visitors.d.ts +3 -1
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/astUtils/visitors.spec.js +2 -0
- package/dist/astUtils/visitors.spec.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.d.ts +4 -1
- package/dist/bscPlugin/BscPlugin.js +16 -0
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.d.ts +1 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +38 -2
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +28 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.d.ts +8 -0
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js +40 -0
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js.map +1 -0
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.d.ts +1 -0
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js +32 -0
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js.map +1 -0
- package/dist/bscPlugin/validation/BrsFileValidator.d.ts +9 -0
- package/dist/bscPlugin/validation/BrsFileValidator.js +66 -0
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -0
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +11 -0
- package/dist/bscPlugin/validation/ScopeValidator.js +94 -0
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -0
- package/dist/diagnosticUtils.js +3 -3
- package/dist/diagnosticUtils.js.map +1 -1
- package/dist/examples/plugins/removePrint.js +12 -14
- package/dist/examples/plugins/removePrint.js.map +1 -1
- package/dist/files/BrsFile.Class.spec.js +22 -23
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +10 -3
- package/dist/files/BrsFile.js +133 -49
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +299 -123
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/XmlFile.d.ts +5 -5
- package/dist/files/XmlFile.js +3 -3
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/files/XmlFile.spec.js +9 -9
- package/dist/files/XmlFile.spec.js.map +1 -1
- package/dist/interfaces.d.ts +29 -37
- package/dist/lexer/Lexer.spec.js +8 -0
- package/dist/lexer/Lexer.spec.js.map +1 -1
- package/dist/lexer/TokenKind.d.ts +2 -0
- package/dist/lexer/TokenKind.js +5 -0
- package/dist/lexer/TokenKind.js.map +1 -1
- package/dist/parser/Expression.d.ts +85 -21
- package/dist/parser/Expression.js +177 -53
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.Class.spec.js +1 -1
- package/dist/parser/Parser.Class.spec.js.map +1 -1
- package/dist/parser/Parser.d.ts +12 -3
- package/dist/parser/Parser.js +156 -56
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.js +57 -2
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/Statement.d.ts +94 -30
- package/dist/parser/Statement.js +281 -106
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/tests/statement/Enum.spec.d.ts +1 -0
- package/dist/parser/tests/statement/Enum.spec.js +774 -0
- package/dist/parser/tests/statement/Enum.spec.js.map +1 -0
- package/dist/parser/tests/statement/For.spec.d.ts +1 -0
- package/dist/parser/tests/statement/For.spec.js +46 -0
- package/dist/parser/tests/statement/For.spec.js.map +1 -0
- package/dist/parser/tests/statement/ForEach.spec.d.ts +1 -0
- package/dist/parser/tests/statement/ForEach.spec.js +37 -0
- package/dist/parser/tests/statement/ForEach.spec.js.map +1 -0
- package/dist/types/BooleanType.d.ts +4 -2
- package/dist/types/BooleanType.js +5 -1
- package/dist/types/BooleanType.js.map +1 -1
- package/dist/types/DoubleType.d.ts +2 -0
- package/dist/types/DoubleType.js +5 -1
- package/dist/types/DoubleType.js.map +1 -1
- package/dist/types/DynamicType.d.ts +2 -0
- package/dist/types/DynamicType.js +5 -1
- package/dist/types/DynamicType.js.map +1 -1
- package/dist/types/FloatType.d.ts +3 -1
- package/dist/types/FloatType.js +5 -1
- package/dist/types/FloatType.js.map +1 -1
- package/dist/types/FunctionType.d.ts +2 -1
- package/dist/types/FunctionType.js +11 -8
- package/dist/types/FunctionType.js.map +1 -1
- package/dist/types/FunctionType.spec.js +6 -0
- package/dist/types/FunctionType.spec.js.map +1 -1
- package/dist/types/IntegerType.d.ts +3 -1
- package/dist/types/IntegerType.js +5 -1
- package/dist/types/IntegerType.js.map +1 -1
- package/dist/types/InvalidType.d.ts +4 -2
- package/dist/types/InvalidType.js +5 -1
- package/dist/types/InvalidType.js.map +1 -1
- package/dist/types/LongIntegerType.d.ts +3 -1
- package/dist/types/LongIntegerType.js +5 -1
- package/dist/types/LongIntegerType.js.map +1 -1
- package/dist/types/ObjectType.d.ts +2 -1
- package/dist/types/ObjectType.js +4 -2
- package/dist/types/ObjectType.js.map +1 -1
- package/dist/types/StringType.d.ts +4 -2
- package/dist/types/StringType.js +5 -1
- package/dist/types/StringType.js.map +1 -1
- package/dist/types/UninitializedType.js.map +1 -1
- package/dist/types/UniversalFunctionType.d.ts +9 -0
- package/dist/types/UniversalFunctionType.js +25 -0
- package/dist/types/UniversalFunctionType.js.map +1 -0
- package/dist/types/VoidType.d.ts +4 -2
- package/dist/types/VoidType.js +5 -1
- package/dist/types/VoidType.js.map +1 -1
- package/dist/util.d.ts +12 -2
- package/dist/util.js +74 -44
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.js +3 -3
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +2 -3
|
@@ -6,9 +6,12 @@ import { ParseMode } from './Parser';
|
|
|
6
6
|
import type { WalkOptions, WalkVisitor } from '../astUtils/visitors';
|
|
7
7
|
import { InternalWalkMode } from '../astUtils/visitors';
|
|
8
8
|
import type { TranspileResult, TypedefProvider } from '../interfaces';
|
|
9
|
+
import { VoidType } from '../types/VoidType';
|
|
10
|
+
import { DynamicType } from '../types/DynamicType';
|
|
9
11
|
import type { BscType, SymbolContainer } from '../types/BscType';
|
|
10
12
|
import { SymbolTable } from '../SymbolTable';
|
|
11
13
|
import { FunctionType } from '../types/FunctionType';
|
|
14
|
+
import { ArrayType } from '../types/ArrayType';
|
|
12
15
|
export declare type ExpressionVisitor = (expression: Expression, parent: Expression) => void;
|
|
13
16
|
/** A BrightScript expression */
|
|
14
17
|
export declare abstract class Expression {
|
|
@@ -59,24 +62,31 @@ export declare class FunctionExpression extends Expression implements TypedefPro
|
|
|
59
62
|
readonly leftParen: Token;
|
|
60
63
|
readonly rightParen: Token;
|
|
61
64
|
readonly asToken?: Token;
|
|
62
|
-
readonly
|
|
65
|
+
readonly returnType?: TypeExpression;
|
|
63
66
|
/**
|
|
64
67
|
* If this function is enclosed within another function, this will reference that parent function
|
|
65
68
|
*/
|
|
66
69
|
readonly parentFunction?: FunctionExpression;
|
|
67
70
|
readonly namespaceName?: NamespacedVariableNameExpression;
|
|
68
71
|
readonly parentSymbolTable?: SymbolTable;
|
|
69
|
-
constructor(parameters: FunctionParameterExpression[], body: Block, functionType: Token | null, end: Token, leftParen: Token, rightParen: Token, asToken?: Token,
|
|
72
|
+
constructor(parameters: FunctionParameterExpression[], body: Block, functionType: Token | null, end: Token, leftParen: Token, rightParen: Token, asToken?: Token, returnType?: TypeExpression,
|
|
70
73
|
/**
|
|
71
74
|
* If this function is enclosed within another function, this will reference that parent function
|
|
72
75
|
*/
|
|
73
76
|
parentFunction?: FunctionExpression, namespaceName?: NamespacedVariableNameExpression, parentSymbolTable?: SymbolTable);
|
|
77
|
+
get range(): Range;
|
|
78
|
+
/**
|
|
79
|
+
* The range of the function
|
|
80
|
+
*/
|
|
81
|
+
cacheRange(): Range;
|
|
82
|
+
private _range;
|
|
74
83
|
readonly symbolTable: SymbolTable;
|
|
75
84
|
labelStatements: LabelStatement[];
|
|
85
|
+
private _returnType;
|
|
76
86
|
/**
|
|
77
87
|
* The type this function returns
|
|
78
88
|
*/
|
|
79
|
-
|
|
89
|
+
getReturnType(): BscType;
|
|
80
90
|
/**
|
|
81
91
|
* The list of function calls that are declared within this function scope. This excludes CallExpressions
|
|
82
92
|
* declared in child functions
|
|
@@ -90,11 +100,6 @@ export declare class FunctionExpression extends Expression implements TypedefPro
|
|
|
90
100
|
* A list of all child functions declared directly within this function
|
|
91
101
|
*/
|
|
92
102
|
childFunctionExpressions: FunctionExpression[];
|
|
93
|
-
/**
|
|
94
|
-
* The range of the function, starting at the 'f' in function or 's' in sub (or the open paren if the keyword is missing),
|
|
95
|
-
* and ending with the last n' in 'end function' or 'b' in 'end sub'
|
|
96
|
-
*/
|
|
97
|
-
get range(): Range;
|
|
98
103
|
transpile(state: BrsTranspileState, name?: Identifier, includeBody?: boolean): any[];
|
|
99
104
|
getTypedef(state: BrsTranspileState, name?: Identifier): any[];
|
|
100
105
|
walk(visitor: WalkVisitor, options: WalkOptions): void;
|
|
@@ -102,14 +107,15 @@ export declare class FunctionExpression extends Expression implements TypedefPro
|
|
|
102
107
|
}
|
|
103
108
|
export declare class FunctionParameterExpression extends Expression {
|
|
104
109
|
name: Identifier;
|
|
105
|
-
|
|
110
|
+
private typeInContext;
|
|
106
111
|
equalsToken?: Token;
|
|
107
112
|
defaultValue?: Expression;
|
|
108
113
|
asToken?: Token;
|
|
109
|
-
|
|
114
|
+
type?: TypeExpression;
|
|
110
115
|
readonly namespaceName?: NamespacedVariableNameExpression;
|
|
111
|
-
constructor(name: Identifier,
|
|
112
|
-
|
|
116
|
+
constructor(name: Identifier, typeInContext: BscType, equalsToken?: Token, defaultValue?: Expression, asToken?: Token, type?: TypeExpression, namespaceName?: NamespacedVariableNameExpression);
|
|
117
|
+
readonly range: Range;
|
|
118
|
+
getType(): BscType;
|
|
113
119
|
transpile(state: BrsTranspileState): any[];
|
|
114
120
|
walk(visitor: WalkVisitor, options: WalkOptions): void;
|
|
115
121
|
get isOptional(): boolean;
|
|
@@ -117,7 +123,7 @@ export declare class FunctionParameterExpression extends Expression {
|
|
|
117
123
|
export declare class NamespacedVariableNameExpression extends Expression {
|
|
118
124
|
readonly expression: DottedGetExpression | VariableExpression;
|
|
119
125
|
constructor(expression: DottedGetExpression | VariableExpression);
|
|
120
|
-
range: Range;
|
|
126
|
+
readonly range: Range;
|
|
121
127
|
transpile(state: BrsTranspileState): import("source-map").SourceNode[];
|
|
122
128
|
getNameParts(): string[];
|
|
123
129
|
getName(parseMode?: ParseMode): string;
|
|
@@ -168,7 +174,7 @@ export declare class GroupingExpression extends Expression {
|
|
|
168
174
|
export declare class LiteralExpression extends Expression {
|
|
169
175
|
token: Token;
|
|
170
176
|
constructor(token: Token);
|
|
171
|
-
|
|
177
|
+
readonly range: Range;
|
|
172
178
|
/**
|
|
173
179
|
* The (data) type of this expression
|
|
174
180
|
*/
|
|
@@ -210,7 +216,7 @@ export declare class AAMemberExpression extends Expression {
|
|
|
210
216
|
constructor(keyToken: Token, colonToken: Token,
|
|
211
217
|
/** The expression evaluated to determine the member's initial value. */
|
|
212
218
|
value: Expression, type: BscType);
|
|
213
|
-
range: Range;
|
|
219
|
+
readonly range: Range;
|
|
214
220
|
commaToken?: Token;
|
|
215
221
|
transpile(state: BrsTranspileState): any[];
|
|
216
222
|
walk(visitor: WalkVisitor, options: WalkOptions): void;
|
|
@@ -221,9 +227,9 @@ export declare class AALiteralExpression extends Expression implements SymbolCon
|
|
|
221
227
|
readonly close: Token;
|
|
222
228
|
readonly functionExpression: FunctionExpression;
|
|
223
229
|
constructor(elements: Array<AAMemberExpression | CommentStatement>, open: Token, close: Token, functionExpression: FunctionExpression);
|
|
230
|
+
readonly range: Range;
|
|
224
231
|
readonly symbolTable: SymbolTable;
|
|
225
232
|
readonly memberTable: SymbolTable;
|
|
226
|
-
readonly range: Range;
|
|
227
233
|
buildSymbolTable(): void;
|
|
228
234
|
transpile(state: BrsTranspileState): any[];
|
|
229
235
|
walk(visitor: WalkVisitor, options: WalkOptions): void;
|
|
@@ -241,7 +247,6 @@ export declare class VariableExpression extends Expression {
|
|
|
241
247
|
namespaceName: NamespacedVariableNameExpression;
|
|
242
248
|
constructor(name: Identifier, namespaceName: NamespacedVariableNameExpression);
|
|
243
249
|
readonly range: Range;
|
|
244
|
-
isCalled: boolean;
|
|
245
250
|
getName(parseMode: ParseMode): string;
|
|
246
251
|
transpile(state: BrsTranspileState): any[];
|
|
247
252
|
walk(visitor: WalkVisitor, options: WalkOptions): void;
|
|
@@ -263,12 +268,12 @@ export declare class NewExpression extends Expression {
|
|
|
263
268
|
readonly newKeyword: Token;
|
|
264
269
|
readonly call: CallExpression;
|
|
265
270
|
constructor(newKeyword: Token, call: CallExpression);
|
|
271
|
+
readonly range: Range;
|
|
266
272
|
/**
|
|
267
273
|
* The name of the class to initialize (with optional namespace prefixed)
|
|
268
274
|
*/
|
|
269
275
|
get className(): NamespacedVariableNameExpression;
|
|
270
276
|
get namespaceName(): NamespacedVariableNameExpression;
|
|
271
|
-
readonly range: Range;
|
|
272
277
|
transpile(state: BrsTranspileState): any[];
|
|
273
278
|
walk(visitor: WalkVisitor, options: WalkOptions): void;
|
|
274
279
|
}
|
|
@@ -320,8 +325,10 @@ export declare class AnnotationExpression extends Expression {
|
|
|
320
325
|
readonly atToken: Token;
|
|
321
326
|
readonly nameToken: Token;
|
|
322
327
|
constructor(atToken: Token, nameToken: Token);
|
|
328
|
+
get range(): Range;
|
|
329
|
+
cacheRange(): Range;
|
|
330
|
+
private _range;
|
|
323
331
|
name: string;
|
|
324
|
-
range: Range;
|
|
325
332
|
call: CallExpression;
|
|
326
333
|
/**
|
|
327
334
|
* Convert annotation arguments to JavaScript types
|
|
@@ -339,7 +346,7 @@ export declare class TernaryExpression extends Expression {
|
|
|
339
346
|
readonly colonToken?: Token;
|
|
340
347
|
readonly alternate?: Expression;
|
|
341
348
|
constructor(test: Expression, questionMarkToken: Token, consequent?: Expression, colonToken?: Token, alternate?: Expression);
|
|
342
|
-
range: Range;
|
|
349
|
+
readonly range: Range;
|
|
343
350
|
transpile(state: BrsTranspileState): any[];
|
|
344
351
|
walk(visitor: WalkVisitor, options: WalkOptions): void;
|
|
345
352
|
}
|
|
@@ -359,10 +366,67 @@ export declare class RegexLiteralExpression extends Expression {
|
|
|
359
366
|
constructor(tokens: {
|
|
360
367
|
regexLiteral: Token;
|
|
361
368
|
});
|
|
362
|
-
|
|
369
|
+
readonly range: Range;
|
|
363
370
|
transpile(state: BrsTranspileState): TranspileResult;
|
|
364
371
|
walk(visitor: WalkVisitor, options: WalkOptions): void;
|
|
365
372
|
}
|
|
373
|
+
export declare class TypeExpression extends Expression {
|
|
374
|
+
private tokens;
|
|
375
|
+
namespaceName?: NamespacedVariableNameExpression;
|
|
376
|
+
constructor(tokens: {
|
|
377
|
+
type?: Token;
|
|
378
|
+
}, namespaceName?: NamespacedVariableNameExpression);
|
|
379
|
+
readonly range: Range;
|
|
380
|
+
private _type;
|
|
381
|
+
/**
|
|
382
|
+
* The this TypeExpression refers to
|
|
383
|
+
*/
|
|
384
|
+
get type(): BscType;
|
|
385
|
+
/**
|
|
386
|
+
* Derive a BscType from the type token
|
|
387
|
+
* Can deal with multiple brackets to make multidimensional arrays, eg. float[][]
|
|
388
|
+
* Defaults to `DynamicType`
|
|
389
|
+
*/
|
|
390
|
+
getType(parseMode?: ParseMode): DynamicType | BscType | import("../types/FloatType").FloatType | import("../types/IntegerType").IntegerType | import("../types/DoubleType").DoubleType | import("../types/LongIntegerType").LongIntegerType | import("../types/StringType").StringType | import("../types/BooleanType").BooleanType | import("../types/UniversalFunctionType").UniversalFunctionType | import("../types/InvalidType").InvalidType | VoidType;
|
|
391
|
+
/**
|
|
392
|
+
* Is this a valid, (eg. known) type?
|
|
393
|
+
*/
|
|
394
|
+
isValidType(parseMode?: ParseMode): boolean;
|
|
395
|
+
/**
|
|
396
|
+
* Gives a human readable string that says the type
|
|
397
|
+
* @returns text to display to show the type
|
|
398
|
+
*/
|
|
399
|
+
getText(): string;
|
|
400
|
+
transpile(state: BrsTranspileState): TranspileResult;
|
|
401
|
+
walk(visitor: WalkVisitor, options: WalkOptions): void;
|
|
402
|
+
}
|
|
403
|
+
export declare class ArrayTypeExpression extends TypeExpression {
|
|
404
|
+
innerTypes: TypeExpression[];
|
|
405
|
+
private bracketTokens;
|
|
406
|
+
namespaceName?: NamespacedVariableNameExpression;
|
|
407
|
+
constructor(innerTypes: TypeExpression[], // this is an array so that in the future when we support union types
|
|
408
|
+
bracketTokens: {
|
|
409
|
+
leftBracket?: Token;
|
|
410
|
+
rightBracket?: Token;
|
|
411
|
+
}, namespaceName?: NamespacedVariableNameExpression);
|
|
412
|
+
readonly range: Range;
|
|
413
|
+
private get defaultTypeExpression();
|
|
414
|
+
/**
|
|
415
|
+
* Derive a BscType from the type token
|
|
416
|
+
* Returns an array type with the inner types based on the inner type expressions
|
|
417
|
+
*/
|
|
418
|
+
getType(parseMode?: ParseMode): ArrayType;
|
|
419
|
+
/**
|
|
420
|
+
* Is this a valid, (eg. known) type?
|
|
421
|
+
*/
|
|
422
|
+
isValidType(parseMode?: ParseMode): boolean;
|
|
423
|
+
/**
|
|
424
|
+
* Gives a human readable string that says the type
|
|
425
|
+
* @returns text to display to show the type
|
|
426
|
+
*/
|
|
427
|
+
getText(): string;
|
|
428
|
+
walk(visitor: WalkVisitor, options: WalkOptions): void;
|
|
429
|
+
}
|
|
366
430
|
declare type ExpressionValue = string | number | boolean | Expression | ExpressionValue[] | {
|
|
367
431
|
[key: string]: ExpressionValue;
|
|
368
432
|
};
|