brighterscript 1.0.0-alpha.48 → 1.0.0-alpha.49
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/README.md +7 -10
- package/bsconfig.schema.json +34 -7
- package/dist/AstValidationSegmenter.js +12 -0
- package/dist/AstValidationSegmenter.js.map +1 -1
- package/dist/BsConfig.d.ts +6 -35
- package/dist/CrossScopeValidator.d.ts +1 -0
- package/dist/CrossScopeValidator.js +28 -4
- package/dist/CrossScopeValidator.js.map +1 -1
- package/dist/DiagnosticMessages.d.ts +1 -1
- package/dist/DiagnosticMessages.js +20 -6
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/LanguageServer.d.ts +3 -1
- package/dist/LanguageServer.js +32 -19
- package/dist/LanguageServer.js.map +1 -1
- package/dist/Program.d.ts +9 -3
- package/dist/Program.js +111 -74
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.d.ts +0 -2
- package/dist/ProgramBuilder.js +10 -28
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/SymbolTable.js +3 -2
- package/dist/SymbolTable.js.map +1 -1
- package/dist/astUtils/reflection.d.ts +14 -2
- package/dist/astUtils/reflection.js +70 -18
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/visitors.d.ts +2 -1
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/bscPlugin/CallExpressionInfo.js +9 -3
- package/dist/bscPlugin/CallExpressionInfo.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.js +3 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +34 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/hover/HoverProcessor.spec.js +31 -0
- package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +3 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.d.ts +5 -0
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js +71 -3
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -1
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js +7 -7
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.js +10 -2
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js +99 -0
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +1 -0
- package/dist/bscPlugin/validation/ScopeValidator.js +19 -4
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.spec.js +334 -0
- package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -1
- package/dist/cli.js +11 -18
- package/dist/cli.js.map +1 -1
- package/dist/files/BrsFile.Class.spec.js +336 -200
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.spec.js +61 -10
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/XmlFile.d.ts +7 -0
- package/dist/files/XmlFile.js +36 -0
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/files/XmlFile.spec.js +7 -9
- package/dist/files/XmlFile.spec.js.map +1 -1
- package/dist/files/tests/imports.spec.js +3 -3
- package/dist/files/tests/imports.spec.js.map +1 -1
- package/dist/files/tests/optionalChaning.spec.js +1 -1
- package/dist/files/tests/optionalChaning.spec.js.map +1 -1
- package/dist/interfaces.d.ts +12 -4
- package/dist/interfaces.js.map +1 -1
- package/dist/lexer/Lexer.spec.js +12 -2
- package/dist/lexer/Lexer.spec.js.map +1 -1
- package/dist/lexer/TokenKind.js +6 -3
- package/dist/lexer/TokenKind.js.map +1 -1
- package/dist/lsp/Project.js +1 -3
- package/dist/lsp/Project.js.map +1 -1
- package/dist/lsp/Project.spec.js +1 -1
- package/dist/lsp/Project.spec.js.map +1 -1
- package/dist/lsp/ProjectManager.d.ts +8 -0
- package/dist/lsp/ProjectManager.js +7 -5
- package/dist/lsp/ProjectManager.js.map +1 -1
- package/dist/lsp/ProjectManager.spec.js +128 -0
- package/dist/lsp/ProjectManager.spec.js.map +1 -1
- package/dist/lsp/worker/WorkerThreadProject.js +21 -16
- package/dist/lsp/worker/WorkerThreadProject.js.map +1 -1
- package/dist/lsp/worker/run.d.ts +1 -0
- package/dist/lsp/worker/run.js +14 -0
- package/dist/lsp/worker/run.js.map +1 -0
- package/dist/parser/AstNode.d.ts +8 -1
- package/dist/parser/AstNode.js +9 -0
- package/dist/parser/AstNode.js.map +1 -1
- package/dist/parser/AstNode.spec.js +1 -1
- package/dist/parser/AstNode.spec.js.map +1 -1
- package/dist/parser/Expression.d.ts +43 -0
- package/dist/parser/Expression.js +120 -7
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.Class.spec.js +25 -0
- package/dist/parser/Parser.Class.spec.js.map +1 -1
- package/dist/parser/Parser.d.ts +4 -0
- package/dist/parser/Parser.js +117 -7
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.js +200 -1
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/Statement.d.ts +32 -1
- package/dist/parser/Statement.js +126 -62
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/tests/statement/ConstStatement.spec.js +238 -0
- package/dist/parser/tests/statement/ConstStatement.spec.js.map +1 -1
- package/dist/roku-types/data.json +422 -64
- package/dist/roku-types/index.d.ts +50 -0
- package/dist/types/ArrayType.js +3 -0
- package/dist/types/ArrayType.js.map +1 -1
- package/dist/types/BscType.d.ts +4 -3
- package/dist/types/BscType.js +2 -4
- package/dist/types/BscType.js.map +1 -1
- package/dist/types/BscTypeKind.d.ts +2 -0
- package/dist/types/BscTypeKind.js +2 -0
- package/dist/types/BscTypeKind.js.map +1 -1
- package/dist/types/CallFuncableType.d.ts +24 -0
- package/dist/types/CallFuncableType.js +91 -0
- package/dist/types/CallFuncableType.js.map +1 -0
- package/dist/types/ComponentType.d.ts +3 -15
- package/dist/types/ComponentType.js +2 -56
- package/dist/types/ComponentType.js.map +1 -1
- package/dist/types/DoubleType.js +1 -1
- package/dist/types/DoubleType.js.map +1 -1
- package/dist/types/FloatType.js +1 -1
- package/dist/types/FloatType.js.map +1 -1
- package/dist/types/InlineInterfaceType.d.ts +5 -0
- package/dist/types/InlineInterfaceType.js +17 -0
- package/dist/types/InlineInterfaceType.js.map +1 -0
- package/dist/types/IntegerType.js +1 -1
- package/dist/types/IntegerType.js.map +1 -1
- package/dist/types/InterfaceType.d.ts +2 -2
- package/dist/types/InterfaceType.js +5 -4
- package/dist/types/InterfaceType.js.map +1 -1
- package/dist/types/LongIntegerType.js +1 -1
- package/dist/types/LongIntegerType.js.map +1 -1
- package/dist/types/ObjectType.d.ts +1 -0
- package/dist/types/ObjectType.js +3 -0
- package/dist/types/ObjectType.js.map +1 -1
- package/dist/types/ReferenceType.d.ts +3 -1
- package/dist/types/ReferenceType.js +41 -2
- package/dist/types/ReferenceType.js.map +1 -1
- package/dist/types/TypeStatementType.d.ts +18 -0
- package/dist/types/TypeStatementType.js +45 -0
- package/dist/types/TypeStatementType.js.map +1 -0
- package/dist/types/roFunctionType.d.ts +11 -0
- package/dist/types/roFunctionType.js +37 -0
- package/dist/types/roFunctionType.js.map +1 -0
- package/dist/types/roFunctionType.spec.d.ts +1 -0
- package/dist/types/roFunctionType.spec.js +20 -0
- package/dist/types/roFunctionType.spec.js.map +1 -0
- package/dist/util.d.ts +3 -94
- package/dist/util.js +53 -303
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.js +1 -1
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +3 -3
package/dist/parser/Statement.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConditionalCompileConstStatement = exports.ConditionalCompileStatement = exports.AliasStatement = exports.ConditionalCompileErrorStatement = exports.TypecastStatement = exports.ContinueStatement = exports.ConstStatement = exports.EnumMemberStatement = exports.EnumStatement = exports.ThrowStatement = exports.CatchStatement = exports.TryCatchStatement = exports.FieldStatement = exports.MethodStatement = exports.ClassStatement = exports.InterfaceMethodStatement = exports.InterfaceFieldStatement = exports.InterfaceStatement = exports.ImportStatement = exports.NamespaceStatement = exports.LibraryStatement = exports.IndexedSetStatement = exports.DottedSetStatement = exports.WhileStatement = exports.ForEachStatement = exports.ForStatement = exports.StopStatement = exports.EndStatement = exports.ReturnStatement = exports.LabelStatement = exports.GotoStatement = exports.DimStatement = exports.PrintStatement = exports.IncrementStatement = exports.IfStatement = exports.FunctionStatement = exports.ExitStatement = exports.ExpressionStatement = exports.Block = exports.AugmentedAssignmentStatement = exports.AssignmentStatement = exports.Body = exports.EmptyStatement = void 0;
|
|
3
|
+
exports.TypeStatement = exports.ConditionalCompileConstStatement = exports.ConditionalCompileStatement = exports.AliasStatement = exports.ConditionalCompileErrorStatement = exports.TypecastStatement = exports.ContinueStatement = exports.ConstStatement = exports.EnumMemberStatement = exports.EnumStatement = exports.ThrowStatement = exports.CatchStatement = exports.TryCatchStatement = exports.FieldStatement = exports.MethodStatement = exports.ClassStatement = exports.InterfaceMethodStatement = exports.InterfaceFieldStatement = exports.InterfaceStatement = exports.ImportStatement = exports.NamespaceStatement = exports.LibraryStatement = exports.IndexedSetStatement = exports.DottedSetStatement = exports.WhileStatement = exports.ForEachStatement = exports.ForStatement = exports.StopStatement = exports.EndStatement = exports.ReturnStatement = exports.LabelStatement = exports.GotoStatement = exports.DimStatement = exports.PrintStatement = exports.IncrementStatement = exports.IfStatement = exports.FunctionStatement = exports.ExitStatement = exports.ExpressionStatement = exports.Block = exports.AugmentedAssignmentStatement = exports.AssignmentStatement = exports.Body = exports.EmptyStatement = void 0;
|
|
4
4
|
const TokenKind_1 = require("../lexer/TokenKind");
|
|
5
5
|
const Expression_1 = require("./Expression");
|
|
6
6
|
const Expression_2 = require("./Expression");
|
|
@@ -1780,11 +1780,16 @@ class ClassStatement extends AstNode_1.Statement {
|
|
|
1780
1780
|
}
|
|
1781
1781
|
transpile(state) {
|
|
1782
1782
|
let result = [];
|
|
1783
|
+
const className = this.getName(Parser_1.ParseMode.BrightScript).replace(/\./g, '_');
|
|
1784
|
+
const ancestors = this.getAncestors(state);
|
|
1785
|
+
const body = this.getTranspiledClassBody(ancestors);
|
|
1786
|
+
//make the methods
|
|
1787
|
+
result.push(...this.getTranspiledMethods(state, className, body));
|
|
1783
1788
|
//make the builder
|
|
1784
|
-
result.push(...this.getTranspiledBuilder(state));
|
|
1789
|
+
result.push(...this.getTranspiledBuilder(state, className, ancestors, body));
|
|
1785
1790
|
result.push('\n', state.indent());
|
|
1786
1791
|
//make the class assembler (i.e. the public-facing class creator method)
|
|
1787
|
-
result.push(...this.getTranspiledClassFunction(state));
|
|
1792
|
+
result.push(...this.getTranspiledClassFunction(state, className));
|
|
1788
1793
|
return result;
|
|
1789
1794
|
}
|
|
1790
1795
|
getTypedef(state) {
|
|
@@ -1876,11 +1881,11 @@ class ClassStatement extends AstNode_1.Statement {
|
|
|
1876
1881
|
}
|
|
1877
1882
|
return ancestors;
|
|
1878
1883
|
}
|
|
1879
|
-
getBuilderName(
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
return `__${name}
|
|
1884
|
+
getBuilderName(transpiledClassName) {
|
|
1885
|
+
return `__${transpiledClassName}_builder`;
|
|
1886
|
+
}
|
|
1887
|
+
getMethodIdentifier(transpiledClassName, statement) {
|
|
1888
|
+
return Object.assign(Object.assign({}, statement.tokens.name), { text: `__${transpiledClassName}_method_${statement.tokens.name.text}` });
|
|
1884
1889
|
}
|
|
1885
1890
|
getConstructorType() {
|
|
1886
1891
|
var _a, _b;
|
|
@@ -1928,21 +1933,17 @@ class ClassStatement extends AstNode_1.Statement {
|
|
|
1928
1933
|
* This needs to be a separate function so that child classes can call the builder from their parent
|
|
1929
1934
|
* without instantiating the parent constructor at that point in time.
|
|
1930
1935
|
*/
|
|
1931
|
-
getTranspiledBuilder(state) {
|
|
1936
|
+
getTranspiledBuilder(state, transpiledClassName, ancestors, body) {
|
|
1932
1937
|
let result = [];
|
|
1933
|
-
result.push(`function ${this.getBuilderName(
|
|
1938
|
+
result.push(`function ${this.getBuilderName(transpiledClassName)}()\n`);
|
|
1934
1939
|
state.blockDepth++;
|
|
1935
1940
|
//indent
|
|
1936
1941
|
result.push(state.indent());
|
|
1937
|
-
/**
|
|
1938
|
-
* The lineage of this class. index 0 is a direct parent, index 1 is index 0's parent, etc...
|
|
1939
|
-
*/
|
|
1940
|
-
let ancestors = this.getAncestors(state);
|
|
1941
1942
|
//construct parent class or empty object
|
|
1942
1943
|
if (ancestors[0]) {
|
|
1943
1944
|
const ancestorNamespace = ancestors[0].findAncestor(reflection_1.isNamespaceStatement);
|
|
1944
1945
|
let fullyQualifiedClassName = util_1.util.getFullyQualifiedClassName(ancestors[0].getName(Parser_1.ParseMode.BrighterScript), ancestorNamespace === null || ancestorNamespace === void 0 ? void 0 : ancestorNamespace.getName(Parser_1.ParseMode.BrighterScript));
|
|
1945
|
-
result.push(
|
|
1946
|
+
result.push(`instance = ${this.getBuilderName(fullyQualifiedClassName.replace(/\./g, '_'))}()`);
|
|
1946
1947
|
}
|
|
1947
1948
|
else {
|
|
1948
1949
|
//use an empty object.
|
|
@@ -1950,47 +1951,6 @@ class ClassStatement extends AstNode_1.Statement {
|
|
|
1950
1951
|
}
|
|
1951
1952
|
result.push(state.newline, state.indent());
|
|
1952
1953
|
let parentClassIndex = this.getParentClassIndex(state);
|
|
1953
|
-
let body = this.body;
|
|
1954
|
-
//inject an empty "new" method if missing
|
|
1955
|
-
if (!this.getConstructorFunction()) {
|
|
1956
|
-
if (ancestors.length === 0) {
|
|
1957
|
-
body = [
|
|
1958
|
-
(0, creators_1.createMethodStatement)('new', TokenKind_1.TokenKind.Sub),
|
|
1959
|
-
...this.body
|
|
1960
|
-
];
|
|
1961
|
-
}
|
|
1962
|
-
else {
|
|
1963
|
-
const params = this.getConstructorParams(ancestors);
|
|
1964
|
-
const call = new ExpressionStatement({
|
|
1965
|
-
expression: new Expression_2.CallExpression({
|
|
1966
|
-
callee: new Expression_2.VariableExpression({
|
|
1967
|
-
name: (0, creators_1.createToken)(TokenKind_1.TokenKind.Identifier, 'super')
|
|
1968
|
-
}),
|
|
1969
|
-
openingParen: (0, creators_1.createToken)(TokenKind_1.TokenKind.LeftParen),
|
|
1970
|
-
args: params.map(x => new Expression_2.VariableExpression({
|
|
1971
|
-
name: util_1.util.cloneToken(x.tokens.name)
|
|
1972
|
-
})),
|
|
1973
|
-
closingParen: (0, creators_1.createToken)(TokenKind_1.TokenKind.RightParen)
|
|
1974
|
-
})
|
|
1975
|
-
});
|
|
1976
|
-
body = [
|
|
1977
|
-
new MethodStatement({
|
|
1978
|
-
name: (0, creators_1.createIdentifier)('new'),
|
|
1979
|
-
func: new Expression_1.FunctionExpression({
|
|
1980
|
-
parameters: params.map(x => x.clone()),
|
|
1981
|
-
body: new Block({
|
|
1982
|
-
statements: [call]
|
|
1983
|
-
}),
|
|
1984
|
-
functionType: (0, creators_1.createToken)(TokenKind_1.TokenKind.Sub),
|
|
1985
|
-
endFunctionType: (0, creators_1.createToken)(TokenKind_1.TokenKind.EndSub),
|
|
1986
|
-
leftParen: (0, creators_1.createToken)(TokenKind_1.TokenKind.LeftParen),
|
|
1987
|
-
rightParen: (0, creators_1.createToken)(TokenKind_1.TokenKind.RightParen)
|
|
1988
|
-
})
|
|
1989
|
-
}),
|
|
1990
|
-
...this.body
|
|
1991
|
-
];
|
|
1992
|
-
}
|
|
1993
|
-
}
|
|
1994
1954
|
for (let statement of body) {
|
|
1995
1955
|
//is field statement
|
|
1996
1956
|
if ((0, reflection_1.isFieldStatement)(statement)) {
|
|
@@ -2013,7 +1973,7 @@ class ClassStatement extends AstNode_1.Statement {
|
|
|
2013
1973
|
if (statement.leadingTrivia.filter(token => token.kind === TokenKind_1.TokenKind.Comment).length > 0) {
|
|
2014
1974
|
result.push(...state.transpileComments(statement.leadingTrivia), state.indent());
|
|
2015
1975
|
}
|
|
2016
|
-
result.push('instance.', state.transpileToken(statement.tokens.name), ' = ',
|
|
1976
|
+
result.push('instance.', state.transpileToken(statement.tokens.name), ' = ', state.transpileToken(this.getMethodIdentifier(transpiledClassName, statement)), state.newline, state.indent());
|
|
2017
1977
|
state.skipLeadingComments = false;
|
|
2018
1978
|
delete state.classStatement;
|
|
2019
1979
|
}
|
|
@@ -2029,12 +1989,69 @@ class ClassStatement extends AstNode_1.Statement {
|
|
|
2029
1989
|
result.push(`end function`);
|
|
2030
1990
|
return result;
|
|
2031
1991
|
}
|
|
1992
|
+
/**
|
|
1993
|
+
* Returns a copy of the class' body, with the constructor function added if it doesn't exist.
|
|
1994
|
+
*/
|
|
1995
|
+
getTranspiledClassBody(ancestors) {
|
|
1996
|
+
const body = [];
|
|
1997
|
+
body.push(...this.body);
|
|
1998
|
+
//inject an empty "new" method if missing
|
|
1999
|
+
if (!this.getConstructorFunction()) {
|
|
2000
|
+
if (ancestors.length === 0) {
|
|
2001
|
+
body.unshift((0, creators_1.createMethodStatement)('new', TokenKind_1.TokenKind.Sub));
|
|
2002
|
+
}
|
|
2003
|
+
else {
|
|
2004
|
+
const params = this.getConstructorParams(ancestors);
|
|
2005
|
+
const call = new ExpressionStatement({
|
|
2006
|
+
expression: new Expression_2.CallExpression({
|
|
2007
|
+
callee: new Expression_2.VariableExpression({
|
|
2008
|
+
name: (0, creators_1.createToken)(TokenKind_1.TokenKind.Identifier, 'super')
|
|
2009
|
+
}),
|
|
2010
|
+
openingParen: (0, creators_1.createToken)(TokenKind_1.TokenKind.LeftParen),
|
|
2011
|
+
args: params.map(x => new Expression_2.VariableExpression({
|
|
2012
|
+
name: x.tokens.name
|
|
2013
|
+
})),
|
|
2014
|
+
closingParen: (0, creators_1.createToken)(TokenKind_1.TokenKind.RightParen)
|
|
2015
|
+
})
|
|
2016
|
+
});
|
|
2017
|
+
body.unshift(new MethodStatement({
|
|
2018
|
+
modifiers: [],
|
|
2019
|
+
name: (0, creators_1.createIdentifier)('new'),
|
|
2020
|
+
func: new Expression_1.FunctionExpression({
|
|
2021
|
+
parameters: params.map(x => x.clone()),
|
|
2022
|
+
body: new Block({ statements: [call] }),
|
|
2023
|
+
functionType: (0, creators_1.createToken)(TokenKind_1.TokenKind.Sub),
|
|
2024
|
+
endFunctionType: (0, creators_1.createToken)(TokenKind_1.TokenKind.EndSub),
|
|
2025
|
+
leftParen: (0, creators_1.createToken)(TokenKind_1.TokenKind.LeftParen),
|
|
2026
|
+
rightParen: (0, creators_1.createToken)(TokenKind_1.TokenKind.RightParen)
|
|
2027
|
+
}),
|
|
2028
|
+
override: null
|
|
2029
|
+
}));
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
return body;
|
|
2033
|
+
}
|
|
2034
|
+
/**
|
|
2035
|
+
* These are the methods that are defined in this class. They are transpiled outside of the class body
|
|
2036
|
+
* to ensure they don't appear as "$anon_#" in stack traces and crash logs.
|
|
2037
|
+
*/
|
|
2038
|
+
getTranspiledMethods(state, transpiledClassName, body) {
|
|
2039
|
+
let result = [];
|
|
2040
|
+
for (let statement of body) {
|
|
2041
|
+
if ((0, reflection_1.isMethodStatement)(statement)) {
|
|
2042
|
+
state.classStatement = this;
|
|
2043
|
+
result.push(...statement.transpile(state, this.getMethodIdentifier(transpiledClassName, statement)), state.newline, state.indent());
|
|
2044
|
+
delete state.classStatement;
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
return result;
|
|
2048
|
+
}
|
|
2032
2049
|
/**
|
|
2033
2050
|
* The class function is the function with the same name as the class. This is the function that
|
|
2034
2051
|
* consumers should call to create a new instance of that class.
|
|
2035
2052
|
* This invokes the builder, gets an instance of the class, then invokes the "new" function on that class.
|
|
2036
2053
|
*/
|
|
2037
|
-
getTranspiledClassFunction(state) {
|
|
2054
|
+
getTranspiledClassFunction(state, transpiledClassName) {
|
|
2038
2055
|
let result = state.transpileAnnotations(this);
|
|
2039
2056
|
const constructorFunction = this.getConstructorFunction();
|
|
2040
2057
|
let constructorParams = [];
|
|
@@ -2056,7 +2073,7 @@ class ClassStatement extends AstNode_1.Statement {
|
|
|
2056
2073
|
result.push(')', '\n');
|
|
2057
2074
|
state.blockDepth++;
|
|
2058
2075
|
result.push(state.indent());
|
|
2059
|
-
result.push(`instance = ${this.getBuilderName(
|
|
2076
|
+
result.push(`instance = ${this.getBuilderName(transpiledClassName)}()\n`);
|
|
2060
2077
|
result.push(state.indent());
|
|
2061
2078
|
result.push(`instance.new(`);
|
|
2062
2079
|
//append constructor arguments
|
|
@@ -2161,7 +2178,7 @@ class MethodStatement extends FunctionStatement {
|
|
|
2161
2178
|
get leadingTrivia() {
|
|
2162
2179
|
return this.func.leadingTrivia;
|
|
2163
2180
|
}
|
|
2164
|
-
transpile(state) {
|
|
2181
|
+
transpile(state, name) {
|
|
2165
2182
|
if (this.tokens.name.text.toLowerCase() === 'new') {
|
|
2166
2183
|
this.ensureSuperConstructorCall(state);
|
|
2167
2184
|
//TODO we need to undo this at the bottom of this method
|
|
@@ -2190,7 +2207,7 @@ class MethodStatement extends FunctionStatement {
|
|
|
2190
2207
|
visitor(statement, undefined);
|
|
2191
2208
|
statement.walk(visitor, walkOptions);
|
|
2192
2209
|
}
|
|
2193
|
-
return this.func.transpile(state);
|
|
2210
|
+
return this.func.transpile(state, name);
|
|
2194
2211
|
}
|
|
2195
2212
|
getTypedef(state) {
|
|
2196
2213
|
var _a, _b;
|
|
@@ -2937,7 +2954,7 @@ class AliasStatement extends AstNode_1.Statement {
|
|
|
2937
2954
|
this.location = util_1.util.createBoundingLocation(this.tokens.alias, this.tokens.name, this.tokens.equals, this.value);
|
|
2938
2955
|
}
|
|
2939
2956
|
transpile(state) {
|
|
2940
|
-
//
|
|
2957
|
+
//transpile to a comment just for debugging purposes
|
|
2941
2958
|
return [
|
|
2942
2959
|
state.transpileToken(this.tokens.alias, 'alias', true),
|
|
2943
2960
|
' ',
|
|
@@ -3129,4 +3146,51 @@ class ConditionalCompileConstStatement extends AstNode_1.Statement {
|
|
|
3129
3146
|
}
|
|
3130
3147
|
}
|
|
3131
3148
|
exports.ConditionalCompileConstStatement = ConditionalCompileConstStatement;
|
|
3149
|
+
class TypeStatement extends AstNode_1.Statement {
|
|
3150
|
+
constructor(options) {
|
|
3151
|
+
super();
|
|
3152
|
+
this.kind = AstNode_1.AstNodeKind.TypeStatement;
|
|
3153
|
+
this.tokens = {
|
|
3154
|
+
type: options.type,
|
|
3155
|
+
name: options.name,
|
|
3156
|
+
equals: options.equals
|
|
3157
|
+
};
|
|
3158
|
+
this.value = options.value;
|
|
3159
|
+
this.location = util_1.util.createBoundingLocation(this.tokens.type, this.tokens.name, this.tokens.equals, this.value);
|
|
3160
|
+
}
|
|
3161
|
+
transpile(state) {
|
|
3162
|
+
//transpile to a comment just for debugging purposes
|
|
3163
|
+
return [
|
|
3164
|
+
state.transpileToken(this.tokens.type, 'type', true),
|
|
3165
|
+
' ',
|
|
3166
|
+
state.transpileToken(this.tokens.name),
|
|
3167
|
+
' ',
|
|
3168
|
+
state.transpileToken(this.tokens.equals, '='),
|
|
3169
|
+
' ',
|
|
3170
|
+
this.value.transpile(state)
|
|
3171
|
+
];
|
|
3172
|
+
}
|
|
3173
|
+
walk(visitor, options) {
|
|
3174
|
+
if (options.walkMode & visitors_1.InternalWalkMode.walkExpressions) {
|
|
3175
|
+
(0, visitors_1.walk)(this, 'value', visitor, options);
|
|
3176
|
+
}
|
|
3177
|
+
}
|
|
3178
|
+
get leadingTrivia() {
|
|
3179
|
+
var _a, _b;
|
|
3180
|
+
return (_b = (_a = this.tokens.type) === null || _a === void 0 ? void 0 : _a.leadingTrivia) !== null && _b !== void 0 ? _b : [];
|
|
3181
|
+
}
|
|
3182
|
+
getType(options) {
|
|
3183
|
+
return this.value.getType(options);
|
|
3184
|
+
}
|
|
3185
|
+
clone() {
|
|
3186
|
+
var _a;
|
|
3187
|
+
return this.finalizeClone(new TypeStatement({
|
|
3188
|
+
type: util_1.util.cloneToken(this.tokens.type),
|
|
3189
|
+
name: util_1.util.cloneToken(this.tokens.name),
|
|
3190
|
+
equals: util_1.util.cloneToken(this.tokens.equals),
|
|
3191
|
+
value: (_a = this.value) === null || _a === void 0 ? void 0 : _a.clone()
|
|
3192
|
+
}), ['value']);
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
exports.TypeStatement = TypeStatement;
|
|
3132
3196
|
//# sourceMappingURL=Statement.js.map
|