@jackctaylor/roblox-ts 3.0.0-projectrefs.0
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 +716 -0
- package/LICENSE +21 -0
- package/README.md +55 -0
- package/include/Promise.lua +2068 -0
- package/include/RuntimeLib.lua +258 -0
- package/out/CLI/cli.d.ts +2 -0
- package/out/CLI/cli.js +41 -0
- package/out/CLI/commands/build.d.ts +7 -0
- package/out/CLI/commands/build.js +438 -0
- package/out/CLI/errors/CLIError.d.ts +4 -0
- package/out/CLI/errors/CLIError.js +12 -0
- package/out/CLI/index.d.ts +3 -0
- package/out/CLI/index.js +22 -0
- package/out/CLI/test.d.ts +1 -0
- package/out/CLI/test.js +82 -0
- package/out/CLI/util/patchFs.d.ts +1 -0
- package/out/CLI/util/patchFs.js +26 -0
- package/out/Project/classes/VirtualFileSystem.d.ts +14 -0
- package/out/Project/classes/VirtualFileSystem.js +102 -0
- package/out/Project/classes/VirtualProject.d.ts +15 -0
- package/out/Project/classes/VirtualProject.js +121 -0
- package/out/Project/functions/buildProject.d.ts +18 -0
- package/out/Project/functions/buildProject.js +48 -0
- package/out/Project/functions/buildProjectReferences.d.ts +3 -0
- package/out/Project/functions/buildProjectReferences.js +78 -0
- package/out/Project/functions/buildSolution.d.ts +10 -0
- package/out/Project/functions/buildSolution.js +97 -0
- package/out/Project/functions/checkFileName.d.ts +1 -0
- package/out/Project/functions/checkFileName.js +18 -0
- package/out/Project/functions/checkRojoConfig.d.ts +4 -0
- package/out/Project/functions/checkRojoConfig.js +26 -0
- package/out/Project/functions/cleanup.d.ts +2 -0
- package/out/Project/functions/cleanup.js +30 -0
- package/out/Project/functions/compileFiles.d.ts +4 -0
- package/out/Project/functions/compileFiles.js +160 -0
- package/out/Project/functions/compileProject.d.ts +14 -0
- package/out/Project/functions/compileProject.js +71 -0
- package/out/Project/functions/copyFiles.d.ts +3 -0
- package/out/Project/functions/copyFiles.js +13 -0
- package/out/Project/functions/copyInclude.d.ts +2 -0
- package/out/Project/functions/copyInclude.js +17 -0
- package/out/Project/functions/copyItem.d.ts +3 -0
- package/out/Project/functions/copyItem.js +27 -0
- package/out/Project/functions/createNodeModulesPathMapping.d.ts +1 -0
- package/out/Project/functions/createNodeModulesPathMapping.js +31 -0
- package/out/Project/functions/createPathTranslator.d.ts +4 -0
- package/out/Project/functions/createPathTranslator.js +22 -0
- package/out/Project/functions/createProgramFactory.d.ts +3 -0
- package/out/Project/functions/createProgramFactory.js +31 -0
- package/out/Project/functions/createProjectData.d.ts +2 -0
- package/out/Project/functions/createProjectData.js +102 -0
- package/out/Project/functions/createProjectProgram.d.ts +3 -0
- package/out/Project/functions/createProjectProgram.js +11 -0
- package/out/Project/functions/getChangedFilePaths.d.ts +2 -0
- package/out/Project/functions/getChangedFilePaths.js +47 -0
- package/out/Project/functions/getChangedSourceFiles.d.ts +2 -0
- package/out/Project/functions/getChangedSourceFiles.js +19 -0
- package/out/Project/functions/getParsedCommandLine.d.ts +3 -0
- package/out/Project/functions/getParsedCommandLine.js +41 -0
- package/out/Project/functions/getProjectReferences.d.ts +2 -0
- package/out/Project/functions/getProjectReferences.js +65 -0
- package/out/Project/functions/getResolvedProjectReferences.d.ts +3 -0
- package/out/Project/functions/getResolvedProjectReferences.js +43 -0
- package/out/Project/functions/setupProjectWatchProgram.d.ts +2 -0
- package/out/Project/functions/setupProjectWatchProgram.js +352 -0
- package/out/Project/functions/setupSolutionWatchProgram.d.ts +2 -0
- package/out/Project/functions/setupSolutionWatchProgram.js +355 -0
- package/out/Project/functions/tryRemoveOutput.d.ts +2 -0
- package/out/Project/functions/tryRemoveOutput.js +30 -0
- package/out/Project/functions/validateCompilerOptions.d.ts +2 -0
- package/out/Project/functions/validateCompilerOptions.js +87 -0
- package/out/Project/index.d.ts +4 -0
- package/out/Project/index.js +20 -0
- package/out/Project/preEmitDiagnostics/fileUsesCommentDirectives.d.ts +3 -0
- package/out/Project/preEmitDiagnostics/fileUsesCommentDirectives.js +28 -0
- package/out/Project/transformers/builtin/transformPaths.d.ts +5 -0
- package/out/Project/transformers/builtin/transformPaths.js +129 -0
- package/out/Project/transformers/builtin/transformTypeReferenceDirectives.d.ts +2 -0
- package/out/Project/transformers/builtin/transformTypeReferenceDirectives.js +23 -0
- package/out/Project/transformers/createTransformerList.d.ts +4 -0
- package/out/Project/transformers/createTransformerList.js +87 -0
- package/out/Project/transformers/createTransformerWatcher.d.ts +3 -0
- package/out/Project/transformers/createTransformerWatcher.js +59 -0
- package/out/Project/transformers/getPluginConfigs.d.ts +2 -0
- package/out/Project/transformers/getPluginConfigs.js +34 -0
- package/out/Project/util/createReadBuildProgramHost.d.ts +5 -0
- package/out/Project/util/createReadBuildProgramHost.js +15 -0
- package/out/Project/util/getCustomPreEmitDiagnostics.d.ts +4 -0
- package/out/Project/util/getCustomPreEmitDiagnostics.js +13 -0
- package/out/Project/util/isCompilableFile.d.ts +1 -0
- package/out/Project/util/isCompilableFile.js +18 -0
- package/out/Project/util/walkDirectorySync.d.ts +1 -0
- package/out/Project/util/walkDirectorySync.js +22 -0
- package/out/Shared/classes/Lazy.d.ts +8 -0
- package/out/Shared/classes/Lazy.js +22 -0
- package/out/Shared/classes/LogService.d.ts +9 -0
- package/out/Shared/classes/LogService.js +37 -0
- package/out/Shared/constants.d.ts +23 -0
- package/out/Shared/constants.js +50 -0
- package/out/Shared/diagnostics.d.ts +79 -0
- package/out/Shared/diagnostics.js +140 -0
- package/out/Shared/errors/DiagnosticError.d.ts +7 -0
- package/out/Shared/errors/DiagnosticError.js +16 -0
- package/out/Shared/errors/LoggableError.d.ts +5 -0
- package/out/Shared/errors/LoggableError.js +14 -0
- package/out/Shared/errors/ProjectError.d.ts +4 -0
- package/out/Shared/errors/ProjectError.js +12 -0
- package/out/Shared/index.d.ts +0 -0
- package/out/Shared/index.js +2 -0
- package/out/Shared/types.d.ts +50 -0
- package/out/Shared/types.js +3 -0
- package/out/Shared/util/assert.d.ts +1 -0
- package/out/Shared/util/assert.js +12 -0
- package/out/Shared/util/benchmark.d.ts +3 -0
- package/out/Shared/util/benchmark.js +32 -0
- package/out/Shared/util/createDiagnosticWithLocation.d.ts +3 -0
- package/out/Shared/util/createDiagnosticWithLocation.js +29 -0
- package/out/Shared/util/createGithubLink.d.ts +1 -0
- package/out/Shared/util/createGithubLink.js +12 -0
- package/out/Shared/util/createTextDiagnostic.d.ts +2 -0
- package/out/Shared/util/createTextDiagnostic.js +18 -0
- package/out/Shared/util/findAncestorDir.d.ts +1 -0
- package/out/Shared/util/findAncestorDir.js +16 -0
- package/out/Shared/util/findLastIndex.d.ts +1 -0
- package/out/Shared/util/findLastIndex.js +12 -0
- package/out/Shared/util/formatDiagnostics.d.ts +2 -0
- package/out/Shared/util/formatDiagnostics.js +19 -0
- package/out/Shared/util/getCanonicalFileName.d.ts +2 -0
- package/out/Shared/util/getCanonicalFileName.js +10 -0
- package/out/Shared/util/getOrSetDefault.d.ts +1 -0
- package/out/Shared/util/getOrSetDefault.js +12 -0
- package/out/Shared/util/getRootDirs.d.ts +2 -0
- package/out/Shared/util/getRootDirs.js +10 -0
- package/out/Shared/util/hasErrors.d.ts +2 -0
- package/out/Shared/util/hasErrors.js +11 -0
- package/out/Shared/util/isPathDescendantOf.d.ts +1 -0
- package/out/Shared/util/isPathDescendantOf.js +11 -0
- package/out/Shared/util/realPathExistsSync.d.ts +1 -0
- package/out/Shared/util/realPathExistsSync.js +13 -0
- package/out/Shared/warn.d.ts +1 -0
- package/out/Shared/warn.js +12 -0
- package/out/TSTransformer/classes/DiagnosticService.d.ts +11 -0
- package/out/TSTransformer/classes/DiagnosticService.js +37 -0
- package/out/TSTransformer/classes/MacroManager.d.ts +46 -0
- package/out/TSTransformer/classes/MacroManager.js +178 -0
- package/out/TSTransformer/classes/MultiTransformState.d.ts +9 -0
- package/out/TSTransformer/classes/MultiTransformState.js +15 -0
- package/out/TSTransformer/classes/TransformState.d.ts +73 -0
- package/out/TSTransformer/classes/TransformState.js +307 -0
- package/out/TSTransformer/index.d.ts +4 -0
- package/out/TSTransformer/index.js +23 -0
- package/out/TSTransformer/macros/callMacros.d.ts +2 -0
- package/out/TSTransformer/macros/callMacros.js +56 -0
- package/out/TSTransformer/macros/constructorMacros.d.ts +2 -0
- package/out/TSTransformer/macros/constructorMacros.js +97 -0
- package/out/TSTransformer/macros/identifierMacros.d.ts +2 -0
- package/out/TSTransformer/macros/identifierMacros.js +7 -0
- package/out/TSTransformer/macros/propertyCallMacros.d.ts +4 -0
- package/out/TSTransformer/macros/propertyCallMacros.js +726 -0
- package/out/TSTransformer/macros/types.d.ts +12 -0
- package/out/TSTransformer/macros/types.js +3 -0
- package/out/TSTransformer/nodes/binding/transformArrayAssignmentPattern.d.ts +4 -0
- package/out/TSTransformer/nodes/binding/transformArrayAssignmentPattern.js +78 -0
- package/out/TSTransformer/nodes/binding/transformArrayBindingPattern.d.ts +4 -0
- package/out/TSTransformer/nodes/binding/transformArrayBindingPattern.js +52 -0
- package/out/TSTransformer/nodes/binding/transformBindingName.d.ts +4 -0
- package/out/TSTransformer/nodes/binding/transformBindingName.js +30 -0
- package/out/TSTransformer/nodes/binding/transformObjectAssignmentPattern.d.ts +4 -0
- package/out/TSTransformer/nodes/binding/transformObjectAssignmentPattern.js +97 -0
- package/out/TSTransformer/nodes/binding/transformObjectBindingPattern.d.ts +4 -0
- package/out/TSTransformer/nodes/binding/transformObjectBindingPattern.js +57 -0
- package/out/TSTransformer/nodes/class/transformClassConstructor.d.ts +7 -0
- package/out/TSTransformer/nodes/class/transformClassConstructor.js +96 -0
- package/out/TSTransformer/nodes/class/transformClassLikeDeclaration.d.ts +7 -0
- package/out/TSTransformer/nodes/class/transformClassLikeDeclaration.js +262 -0
- package/out/TSTransformer/nodes/class/transformDecorators.d.ts +4 -0
- package/out/TSTransformer/nodes/class/transformDecorators.js +179 -0
- package/out/TSTransformer/nodes/class/transformPropertyDeclaration.d.ts +4 -0
- package/out/TSTransformer/nodes/class/transformPropertyDeclaration.js +33 -0
- package/out/TSTransformer/nodes/expressions/transformArrayLiteralExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformArrayLiteralExpression.js +79 -0
- package/out/TSTransformer/nodes/expressions/transformAwaitExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformAwaitExpression.js +13 -0
- package/out/TSTransformer/nodes/expressions/transformBinaryExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformBinaryExpression.js +199 -0
- package/out/TSTransformer/nodes/expressions/transformBooleanLiteral.d.ts +3 -0
- package/out/TSTransformer/nodes/expressions/transformBooleanLiteral.js +15 -0
- package/out/TSTransformer/nodes/expressions/transformCallExpression.d.ts +7 -0
- package/out/TSTransformer/nodes/expressions/transformCallExpression.js +191 -0
- package/out/TSTransformer/nodes/expressions/transformClassExpression.d.ts +3 -0
- package/out/TSTransformer/nodes/expressions/transformClassExpression.js +10 -0
- package/out/TSTransformer/nodes/expressions/transformConditionalExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformConditionalExpression.js +55 -0
- package/out/TSTransformer/nodes/expressions/transformDeleteExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformDeleteExpression.js +14 -0
- package/out/TSTransformer/nodes/expressions/transformElementAccessExpression.d.ts +5 -0
- package/out/TSTransformer/nodes/expressions/transformElementAccessExpression.js +62 -0
- package/out/TSTransformer/nodes/expressions/transformExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformExpression.js +107 -0
- package/out/TSTransformer/nodes/expressions/transformFunctionExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformFunctionExpression.js +46 -0
- package/out/TSTransformer/nodes/expressions/transformIdentifier.d.ts +5 -0
- package/out/TSTransformer/nodes/expressions/transformIdentifier.js +147 -0
- package/out/TSTransformer/nodes/expressions/transformImportExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformImportExpression.js +30 -0
- package/out/TSTransformer/nodes/expressions/transformJsxElement.d.ts +3 -0
- package/out/TSTransformer/nodes/expressions/transformJsxElement.js +8 -0
- package/out/TSTransformer/nodes/expressions/transformJsxExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformJsxExpression.js +19 -0
- package/out/TSTransformer/nodes/expressions/transformJsxFragment.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformJsxFragment.js +28 -0
- package/out/TSTransformer/nodes/expressions/transformJsxSelfClosingElement.d.ts +3 -0
- package/out/TSTransformer/nodes/expressions/transformJsxSelfClosingElement.js +8 -0
- package/out/TSTransformer/nodes/expressions/transformNewExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformNewExpression.js +26 -0
- package/out/TSTransformer/nodes/expressions/transformNoSubstitutionTemplateLiteral.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformNoSubstitutionTemplateLiteral.js +14 -0
- package/out/TSTransformer/nodes/expressions/transformNumericLiteral.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformNumericLiteral.js +13 -0
- package/out/TSTransformer/nodes/expressions/transformObjectLiteralExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformObjectLiteralExpression.js +98 -0
- package/out/TSTransformer/nodes/expressions/transformOmittedExpression.d.ts +2 -0
- package/out/TSTransformer/nodes/expressions/transformOmittedExpression.js +11 -0
- package/out/TSTransformer/nodes/expressions/transformParenthesizedExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformParenthesizedExpression.js +19 -0
- package/out/TSTransformer/nodes/expressions/transformPropertyAccessExpression.d.ts +5 -0
- package/out/TSTransformer/nodes/expressions/transformPropertyAccessExpression.js +36 -0
- package/out/TSTransformer/nodes/expressions/transformSpreadElement.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformSpreadElement.js +35 -0
- package/out/TSTransformer/nodes/expressions/transformStringLiteral.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformStringLiteral.js +12 -0
- package/out/TSTransformer/nodes/expressions/transformSuperKeyword.d.ts +2 -0
- package/out/TSTransformer/nodes/expressions/transformSuperKeyword.js +11 -0
- package/out/TSTransformer/nodes/expressions/transformTaggedTemplateExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformTaggedTemplateExpression.js +27 -0
- package/out/TSTransformer/nodes/expressions/transformTemplateExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformTemplateExpression.js +25 -0
- package/out/TSTransformer/nodes/expressions/transformThisExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformThisExpression.js +29 -0
- package/out/TSTransformer/nodes/expressions/transformTypeExpression.d.ts +3 -0
- package/out/TSTransformer/nodes/expressions/transformTypeExpression.js +8 -0
- package/out/TSTransformer/nodes/expressions/transformUnaryExpression.d.ts +5 -0
- package/out/TSTransformer/nodes/expressions/transformUnaryExpression.js +68 -0
- package/out/TSTransformer/nodes/expressions/transformVoidExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformVoidExpression.js +14 -0
- package/out/TSTransformer/nodes/expressions/transformYieldExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformYieldExpression.js +46 -0
- package/out/TSTransformer/nodes/jsx/transformJsx.d.ts +4 -0
- package/out/TSTransformer/nodes/jsx/transformJsx.js +36 -0
- package/out/TSTransformer/nodes/jsx/transformJsxAttributes.d.ts +4 -0
- package/out/TSTransformer/nodes/jsx/transformJsxAttributes.js +83 -0
- package/out/TSTransformer/nodes/jsx/transformJsxChildren.d.ts +4 -0
- package/out/TSTransformer/nodes/jsx/transformJsxChildren.js +34 -0
- package/out/TSTransformer/nodes/jsx/transformJsxTagName.d.ts +4 -0
- package/out/TSTransformer/nodes/jsx/transformJsxTagName.js +42 -0
- package/out/TSTransformer/nodes/statements/transformBlock.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformBlock.js +14 -0
- package/out/TSTransformer/nodes/statements/transformBreakStatement.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformBreakStatement.js +24 -0
- package/out/TSTransformer/nodes/statements/transformClassDeclaration.d.ts +3 -0
- package/out/TSTransformer/nodes/statements/transformClassDeclaration.js +8 -0
- package/out/TSTransformer/nodes/statements/transformContinueStatement.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformContinueStatement.js +24 -0
- package/out/TSTransformer/nodes/statements/transformDoStatement.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformDoStatement.js +31 -0
- package/out/TSTransformer/nodes/statements/transformEnumDeclaration.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformEnumDeclaration.js +97 -0
- package/out/TSTransformer/nodes/statements/transformExportAssignment.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformExportAssignment.js +53 -0
- package/out/TSTransformer/nodes/statements/transformExportDeclaration.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformExportDeclaration.js +109 -0
- package/out/TSTransformer/nodes/statements/transformExpressionStatement.d.ts +5 -0
- package/out/TSTransformer/nodes/statements/transformExpressionStatement.js +62 -0
- package/out/TSTransformer/nodes/statements/transformForOfStatement.d.ts +5 -0
- package/out/TSTransformer/nodes/statements/transformForOfStatement.js +375 -0
- package/out/TSTransformer/nodes/statements/transformForStatement.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformForStatement.js +371 -0
- package/out/TSTransformer/nodes/statements/transformFunctionDeclaration.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformFunctionDeclaration.js +68 -0
- package/out/TSTransformer/nodes/statements/transformIfStatement.d.ts +5 -0
- package/out/TSTransformer/nodes/statements/transformIfStatement.js +46 -0
- package/out/TSTransformer/nodes/statements/transformImportDeclaration.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformImportDeclaration.js +98 -0
- package/out/TSTransformer/nodes/statements/transformImportEqualsDeclaration.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformImportEqualsDeclaration.js +36 -0
- package/out/TSTransformer/nodes/statements/transformModuleDeclaration.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformModuleDeclaration.js +122 -0
- package/out/TSTransformer/nodes/statements/transformReturnStatement.d.ts +5 -0
- package/out/TSTransformer/nodes/statements/transformReturnStatement.js +74 -0
- package/out/TSTransformer/nodes/statements/transformStatement.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformStatement.js +83 -0
- package/out/TSTransformer/nodes/statements/transformSwitchStatement.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformSwitchStatement.js +105 -0
- package/out/TSTransformer/nodes/statements/transformThrowStatement.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformThrowStatement.js +18 -0
- package/out/TSTransformer/nodes/statements/transformTryStatement.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformTryStatement.js +148 -0
- package/out/TSTransformer/nodes/statements/transformVariableStatement.d.ts +8 -0
- package/out/TSTransformer/nodes/statements/transformVariableStatement.js +155 -0
- package/out/TSTransformer/nodes/statements/transformWhileStatement.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformWhileStatement.js +30 -0
- package/out/TSTransformer/nodes/transformEntityName.d.ts +4 -0
- package/out/TSTransformer/nodes/transformEntityName.js +24 -0
- package/out/TSTransformer/nodes/transformInitializer.d.ts +4 -0
- package/out/TSTransformer/nodes/transformInitializer.js +22 -0
- package/out/TSTransformer/nodes/transformInterpolatedStringPart.d.ts +3 -0
- package/out/TSTransformer/nodes/transformInterpolatedStringPart.js +12 -0
- package/out/TSTransformer/nodes/transformLogical.d.ts +4 -0
- package/out/TSTransformer/nodes/transformLogical.js +103 -0
- package/out/TSTransformer/nodes/transformLogicalOrCoalescingAssignmentExpression.d.ts +5 -0
- package/out/TSTransformer/nodes/transformLogicalOrCoalescingAssignmentExpression.js +91 -0
- package/out/TSTransformer/nodes/transformMethodDeclaration.d.ts +5 -0
- package/out/TSTransformer/nodes/transformMethodDeclaration.js +82 -0
- package/out/TSTransformer/nodes/transformOptionalChain.d.ts +46 -0
- package/out/TSTransformer/nodes/transformOptionalChain.js +257 -0
- package/out/TSTransformer/nodes/transformParameters.d.ts +8 -0
- package/out/TSTransformer/nodes/transformParameters.js +104 -0
- package/out/TSTransformer/nodes/transformPropertyName.d.ts +4 -0
- package/out/TSTransformer/nodes/transformPropertyName.js +18 -0
- package/out/TSTransformer/nodes/transformSourceFile.d.ts +4 -0
- package/out/TSTransformer/nodes/transformSourceFile.js +171 -0
- package/out/TSTransformer/nodes/transformStatementList.d.ts +7 -0
- package/out/TSTransformer/nodes/transformStatementList.js +63 -0
- package/out/TSTransformer/nodes/transformWritable.d.ts +9 -0
- package/out/TSTransformer/nodes/transformWritable.js +49 -0
- package/out/TSTransformer/typeGuards.d.ts +5 -0
- package/out/TSTransformer/typeGuards.js +27 -0
- package/out/TSTransformer/types.d.ts +9 -0
- package/out/TSTransformer/types.js +3 -0
- package/out/TSTransformer/util/addIndexDiagnostics.d.ts +3 -0
- package/out/TSTransformer/util/addIndexDiagnostics.js +24 -0
- package/out/TSTransformer/util/addOneIfArrayType.d.ts +4 -0
- package/out/TSTransformer/util/addOneIfArrayType.js +14 -0
- package/out/TSTransformer/util/arrayBindingPatternContainsHoists.d.ts +3 -0
- package/out/TSTransformer/util/arrayBindingPatternContainsHoists.js +23 -0
- package/out/TSTransformer/util/arrayLikeExpressionContainsSpread.d.ts +2 -0
- package/out/TSTransformer/util/arrayLikeExpressionContainsSpread.js +17 -0
- package/out/TSTransformer/util/assertNever.d.ts +1 -0
- package/out/TSTransformer/util/assertNever.js +36 -0
- package/out/TSTransformer/util/assignment.d.ts +7 -0
- package/out/TSTransformer/util/assignment.js +48 -0
- package/out/TSTransformer/util/binding/getAccessorForBindingType.d.ts +6 -0
- package/out/TSTransformer/util/binding/getAccessorForBindingType.js +141 -0
- package/out/TSTransformer/util/binding/getTargetIdForBindingPattern.d.ts +4 -0
- package/out/TSTransformer/util/binding/getTargetIdForBindingPattern.js +15 -0
- package/out/TSTransformer/util/binding/objectAccessor.d.ts +4 -0
- package/out/TSTransformer/util/binding/objectAccessor.js +39 -0
- package/out/TSTransformer/util/bitwise.d.ts +6 -0
- package/out/TSTransformer/util/bitwise.js +67 -0
- package/out/TSTransformer/util/checkVariableHoist.d.ts +3 -0
- package/out/TSTransformer/util/checkVariableHoist.js +33 -0
- package/out/TSTransformer/util/cleanModuleName.d.ts +1 -0
- package/out/TSTransformer/util/cleanModuleName.js +7 -0
- package/out/TSTransformer/util/convertToIndexableExpression.d.ts +3 -0
- package/out/TSTransformer/util/convertToIndexableExpression.js +14 -0
- package/out/TSTransformer/util/createBinaryFromOperator.d.ts +4 -0
- package/out/TSTransformer/util/createBinaryFromOperator.js +54 -0
- package/out/TSTransformer/util/createGetService.d.ts +2 -0
- package/out/TSTransformer/util/createGetService.js +15 -0
- package/out/TSTransformer/util/createHoistDeclaration.d.ts +4 -0
- package/out/TSTransformer/util/createHoistDeclaration.js +20 -0
- package/out/TSTransformer/util/createImportExpression.d.ts +5 -0
- package/out/TSTransformer/util/createImportExpression.js +181 -0
- package/out/TSTransformer/util/createStringFromLiteral.d.ts +2 -0
- package/out/TSTransformer/util/createStringFromLiteral.js +27 -0
- package/out/TSTransformer/util/createTransformServices.d.ts +3 -0
- package/out/TSTransformer/util/createTransformServices.js +9 -0
- package/out/TSTransformer/util/createTruthinessChecks.d.ts +5 -0
- package/out/TSTransformer/util/createTruthinessChecks.js +50 -0
- package/out/TSTransformer/util/createTypeCheck.d.ts +2 -0
- package/out/TSTransformer/util/createTypeCheck.js +11 -0
- package/out/TSTransformer/util/ensureTransformOrder.d.ts +5 -0
- package/out/TSTransformer/util/ensureTransformOrder.js +39 -0
- package/out/TSTransformer/util/expressionChain.d.ts +3 -0
- package/out/TSTransformer/util/expressionChain.js +16 -0
- package/out/TSTransformer/util/expressionMightMutate.d.ts +4 -0
- package/out/TSTransformer/util/expressionMightMutate.js +57 -0
- package/out/TSTransformer/util/findConstructor.d.ts +4 -0
- package/out/TSTransformer/util/findConstructor.js +11 -0
- package/out/TSTransformer/util/fixupWhitespaceAndDecodeEntities.d.ts +1 -0
- package/out/TSTransformer/util/fixupWhitespaceAndDecodeEntities.js +306 -0
- package/out/TSTransformer/util/getAddIterableToArrayBuilder.d.ts +6 -0
- package/out/TSTransformer/util/getAddIterableToArrayBuilder.js +253 -0
- package/out/TSTransformer/util/getAssignableValue.d.ts +3 -0
- package/out/TSTransformer/util/getAssignableValue.js +15 -0
- package/out/TSTransformer/util/getConstantValueLiteral.d.ts +4 -0
- package/out/TSTransformer/util/getConstantValueLiteral.js +19 -0
- package/out/TSTransformer/util/getDeclaredVariables.d.ts +2 -0
- package/out/TSTransformer/util/getDeclaredVariables.js +37 -0
- package/out/TSTransformer/util/getExtendsNode.d.ts +2 -0
- package/out/TSTransformer/util/getExtendsNode.js +16 -0
- package/out/TSTransformer/util/getFlags.d.ts +1 -0
- package/out/TSTransformer/util/getFlags.js +13 -0
- package/out/TSTransformer/util/getKindName.d.ts +2 -0
- package/out/TSTransformer/util/getKindName.js +61 -0
- package/out/TSTransformer/util/getOriginalSymbolOfNode.d.ts +2 -0
- package/out/TSTransformer/util/getOriginalSymbolOfNode.js +15 -0
- package/out/TSTransformer/util/getSourceFileFromModuleSpecifier.d.ts +3 -0
- package/out/TSTransformer/util/getSourceFileFromModuleSpecifier.js +33 -0
- package/out/TSTransformer/util/getStatements.d.ts +2 -0
- package/out/TSTransformer/util/getStatements.js +11 -0
- package/out/TSTransformer/util/hasMultipleDefinitions.d.ts +2 -0
- package/out/TSTransformer/util/hasMultipleDefinitions.js +17 -0
- package/out/TSTransformer/util/isBlockedByTryStatement.d.ts +3 -0
- package/out/TSTransformer/util/isBlockedByTryStatement.js +17 -0
- package/out/TSTransformer/util/isMethod.d.ts +4 -0
- package/out/TSTransformer/util/isMethod.js +90 -0
- package/out/TSTransformer/util/isSymbolMutable.d.ts +3 -0
- package/out/TSTransformer/util/isSymbolMutable.js +24 -0
- package/out/TSTransformer/util/isSymbolOfValue.d.ts +2 -0
- package/out/TSTransformer/util/isSymbolOfValue.js +11 -0
- package/out/TSTransformer/util/isUsedAsStatement.d.ts +2 -0
- package/out/TSTransformer/util/isUsedAsStatement.js +23 -0
- package/out/TSTransformer/util/isValidMethodIndexWithoutCall.d.ts +3 -0
- package/out/TSTransformer/util/isValidMethodIndexWithoutCall.js +31 -0
- package/out/TSTransformer/util/offset.d.ts +2 -0
- package/out/TSTransformer/util/offset.js +44 -0
- package/out/TSTransformer/util/pointer.d.ts +13 -0
- package/out/TSTransformer/util/pointer.js +46 -0
- package/out/TSTransformer/util/spreadDestructuring/index.d.ts +9 -0
- package/out/TSTransformer/util/spreadDestructuring/index.js +45 -0
- package/out/TSTransformer/util/spreadDestructuring/spreadDestructureArray.d.ts +3 -0
- package/out/TSTransformer/util/spreadDestructuring/spreadDestructureArray.js +17 -0
- package/out/TSTransformer/util/spreadDestructuring/spreadDestructureGenerator.d.ts +3 -0
- package/out/TSTransformer/util/spreadDestructuring/spreadDestructureGenerator.js +33 -0
- package/out/TSTransformer/util/spreadDestructuring/spreadDestructureMap.d.ts +3 -0
- package/out/TSTransformer/util/spreadDestructuring/spreadDestructureMap.js +34 -0
- package/out/TSTransformer/util/spreadDestructuring/spreadDestructureObject.d.ts +3 -0
- package/out/TSTransformer/util/spreadDestructuring/spreadDestructureObject.js +41 -0
- package/out/TSTransformer/util/spreadDestructuring/spreadDestructureSet.d.ts +3 -0
- package/out/TSTransformer/util/spreadDestructuring/spreadDestructureSet.js +28 -0
- package/out/TSTransformer/util/traversal.d.ts +7 -0
- package/out/TSTransformer/util/traversal.js +57 -0
- package/out/TSTransformer/util/types.d.ts +31 -0
- package/out/TSTransformer/util/types.js +259 -0
- package/out/TSTransformer/util/validateIdentifier.d.ts +3 -0
- package/out/TSTransformer/util/validateIdentifier.js +18 -0
- package/out/TSTransformer/util/validateMethodAssignment.d.ts +3 -0
- package/out/TSTransformer/util/validateMethodAssignment.js +81 -0
- package/out/TSTransformer/util/validateNotAny.d.ts +3 -0
- package/out/TSTransformer/util/validateNotAny.js +37 -0
- package/out/TSTransformer/util/valueToIdStr.d.ts +2 -0
- package/out/TSTransformer/util/valueToIdStr.js +29 -0
- package/out/TSTransformer/util/wrapExpressionStatement.d.ts +2 -0
- package/out/TSTransformer/util/wrapExpressionStatement.js +22 -0
- package/out/TSTransformer/util/wrapReturnIfLuaTuple.d.ts +4 -0
- package/out/TSTransformer/util/wrapReturnIfLuaTuple.js +56 -0
- package/out/TSTransformer/util/wrapStatementsAsGenerator.d.ts +4 -0
- package/out/TSTransformer/util/wrapStatementsAsGenerator.js +19 -0
- package/package.json +72 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.transformModuleDeclaration = transformModuleDeclaration;
|
|
7
|
+
const luau_ast_1 = __importDefault(require("@roblox-ts/luau-ast"));
|
|
8
|
+
const diagnostics_1 = require("../../../Shared/diagnostics");
|
|
9
|
+
const assert_1 = require("../../../Shared/util/assert");
|
|
10
|
+
const getOrSetDefault_1 = require("../../../Shared/util/getOrSetDefault");
|
|
11
|
+
const DiagnosticService_1 = require("../../classes/DiagnosticService");
|
|
12
|
+
const transformIdentifier_1 = require("../expressions/transformIdentifier");
|
|
13
|
+
const transformStatementList_1 = require("../transformStatementList");
|
|
14
|
+
const hasMultipleDefinitions_1 = require("../../util/hasMultipleDefinitions");
|
|
15
|
+
const isSymbolMutable_1 = require("../../util/isSymbolMutable");
|
|
16
|
+
const isSymbolOfValue_1 = require("../../util/isSymbolOfValue");
|
|
17
|
+
const traversal_1 = require("../../util/traversal");
|
|
18
|
+
const validateIdentifier_1 = require("../../util/validateIdentifier");
|
|
19
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
20
|
+
function isDeclarationOfNamespace(declaration) {
|
|
21
|
+
const modifiers = typescript_1.default.canHaveModifiers(declaration) ? typescript_1.default.getModifiers(declaration) : undefined;
|
|
22
|
+
if (modifiers === null || modifiers === void 0 ? void 0 : modifiers.some(v => v.kind === typescript_1.default.SyntaxKind.DeclareKeyword)) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if (typescript_1.default.isModuleDeclaration(declaration) && typescript_1.default.isInstantiatedModule(declaration, false)) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
else if (typescript_1.default.isFunctionDeclaration(declaration) && declaration.body) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
else if (typescript_1.default.isClassDeclaration(declaration)) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
function getValueDeclarationStatement(symbol) {
|
|
37
|
+
var _a;
|
|
38
|
+
for (const declaration of (_a = symbol.getDeclarations()) !== null && _a !== void 0 ? _a : []) {
|
|
39
|
+
const statement = (0, traversal_1.getAncestor)(declaration, typescript_1.default.isStatement);
|
|
40
|
+
if (statement) {
|
|
41
|
+
const modifiers = typescript_1.default.canHaveModifiers(statement) ? typescript_1.default.getModifiers(statement) : undefined;
|
|
42
|
+
if (typescript_1.default.isFunctionDeclaration(statement) && !statement.body)
|
|
43
|
+
continue;
|
|
44
|
+
if (typescript_1.default.isTypeAliasDeclaration(statement))
|
|
45
|
+
continue;
|
|
46
|
+
if (typescript_1.default.isInterfaceDeclaration(statement))
|
|
47
|
+
continue;
|
|
48
|
+
if (modifiers === null || modifiers === void 0 ? void 0 : modifiers.some(v => v.kind === typescript_1.default.SyntaxKind.DeclareKeyword))
|
|
49
|
+
continue;
|
|
50
|
+
return statement;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function transformNamespace(state, name, body) {
|
|
55
|
+
const symbol = state.typeChecker.getSymbolAtLocation(name);
|
|
56
|
+
(0, assert_1.assert)(symbol);
|
|
57
|
+
(0, validateIdentifier_1.validateIdentifier)(state, name);
|
|
58
|
+
const nameExp = (0, transformIdentifier_1.transformIdentifierDefined)(state, name);
|
|
59
|
+
const statements = luau_ast_1.default.list.make();
|
|
60
|
+
const doStatements = luau_ast_1.default.list.make();
|
|
61
|
+
const containerId = luau_ast_1.default.tempId("container");
|
|
62
|
+
state.setModuleIdBySymbol(symbol, containerId);
|
|
63
|
+
if (state.isHoisted.get(symbol)) {
|
|
64
|
+
luau_ast_1.default.list.push(statements, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.Assignment, {
|
|
65
|
+
left: nameExp,
|
|
66
|
+
operator: "=",
|
|
67
|
+
right: luau_ast_1.default.map(),
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
luau_ast_1.default.list.push(statements, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.VariableDeclaration, {
|
|
72
|
+
left: nameExp,
|
|
73
|
+
right: luau_ast_1.default.map(),
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
const moduleExports = state.getModuleExports(symbol);
|
|
77
|
+
if (moduleExports.length > 0) {
|
|
78
|
+
luau_ast_1.default.list.push(doStatements, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.VariableDeclaration, { left: containerId, right: nameExp }));
|
|
79
|
+
}
|
|
80
|
+
if (typescript_1.default.isModuleBlock(body)) {
|
|
81
|
+
const exportsMap = new Map();
|
|
82
|
+
if (moduleExports.length > 0) {
|
|
83
|
+
for (const exportSymbol of moduleExports) {
|
|
84
|
+
const originalSymbol = typescript_1.default.skipAlias(exportSymbol, state.typeChecker);
|
|
85
|
+
if ((0, isSymbolOfValue_1.isSymbolOfValue)(originalSymbol) && !(0, isSymbolMutable_1.isSymbolMutable)(state, originalSymbol)) {
|
|
86
|
+
const valueDeclarationStatement = getValueDeclarationStatement(exportSymbol);
|
|
87
|
+
if (valueDeclarationStatement) {
|
|
88
|
+
(0, getOrSetDefault_1.getOrSetDefault)(exportsMap, valueDeclarationStatement, () => []).push(exportSymbol.name);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
luau_ast_1.default.list.pushList(doStatements, (0, transformStatementList_1.transformStatementList)(state, body, body.statements, {
|
|
94
|
+
id: containerId,
|
|
95
|
+
mapping: exportsMap,
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
luau_ast_1.default.list.pushList(doStatements, transformNamespace(state, body.name, body.body));
|
|
100
|
+
luau_ast_1.default.list.push(doStatements, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.Assignment, {
|
|
101
|
+
left: luau_ast_1.default.property(containerId, body.name.text),
|
|
102
|
+
operator: "=",
|
|
103
|
+
right: (0, transformIdentifier_1.transformIdentifierDefined)(state, body.name),
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
luau_ast_1.default.list.push(statements, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.DoStatement, { statements: doStatements }));
|
|
107
|
+
return statements;
|
|
108
|
+
}
|
|
109
|
+
function transformModuleDeclaration(state, node) {
|
|
110
|
+
if (!typescript_1.default.isInstantiatedModule(node, false)) {
|
|
111
|
+
return luau_ast_1.default.list.make();
|
|
112
|
+
}
|
|
113
|
+
const symbol = state.typeChecker.getSymbolAtLocation(node.name);
|
|
114
|
+
if (symbol && (0, hasMultipleDefinitions_1.hasMultipleDefinitions)(symbol, declaration => isDeclarationOfNamespace(declaration))) {
|
|
115
|
+
DiagnosticService_1.DiagnosticService.addDiagnosticWithCache(symbol, diagnostics_1.errors.noNamespaceMerging(node), state.multiTransformState.isReportedByMultipleDefinitionsCache);
|
|
116
|
+
return luau_ast_1.default.list.make();
|
|
117
|
+
}
|
|
118
|
+
(0, assert_1.assert)(!typescript_1.default.isStringLiteral(node.name));
|
|
119
|
+
(0, assert_1.assert)(node.body && !typescript_1.default.isIdentifier(node.body));
|
|
120
|
+
return transformNamespace(state, node.name, node.body);
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=transformModuleDeclaration.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import luau from "@roblox-ts/luau-ast";
|
|
2
|
+
import { TransformState } from "../..";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
export declare function transformReturnStatementInner(state: TransformState, returnExp: ts.Expression): luau.List<luau.Statement>;
|
|
5
|
+
export declare function transformReturnStatement(state: TransformState, node: ts.ReturnStatement): luau.List<luau.Statement<luau.SyntaxKind>>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.transformReturnStatementInner = transformReturnStatementInner;
|
|
7
|
+
exports.transformReturnStatement = transformReturnStatement;
|
|
8
|
+
const luau_ast_1 = __importDefault(require("@roblox-ts/luau-ast"));
|
|
9
|
+
const TSTransformer_1 = require("../..");
|
|
10
|
+
const transformExpression_1 = require("../expressions/transformExpression");
|
|
11
|
+
const ensureTransformOrder_1 = require("../../util/ensureTransformOrder");
|
|
12
|
+
const isBlockedByTryStatement_1 = require("../../util/isBlockedByTryStatement");
|
|
13
|
+
const traversal_1 = require("../../util/traversal");
|
|
14
|
+
const types_1 = require("../../util/types");
|
|
15
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
16
|
+
function isTupleReturningCall(state, tsExpression, luaExpression) {
|
|
17
|
+
return (luau_ast_1.default.isCall(luaExpression) &&
|
|
18
|
+
(0, types_1.isLuaTupleType)(state)(state.typeChecker.getTypeAtLocation((0, traversal_1.skipDownwards)(tsExpression))));
|
|
19
|
+
}
|
|
20
|
+
function isTupleMacro(state, expression) {
|
|
21
|
+
if (typescript_1.default.isCallExpression(expression)) {
|
|
22
|
+
const symbol = (0, types_1.getFirstDefinedSymbol)(state, state.getType(expression.expression));
|
|
23
|
+
if (symbol && symbol === state.services.macroManager.getSymbolOrThrow(TSTransformer_1.SYMBOL_NAMES.$tuple)) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
function transformReturnStatementInner(state, returnExp) {
|
|
30
|
+
const result = luau_ast_1.default.list.make();
|
|
31
|
+
let expression;
|
|
32
|
+
const innerReturnExp = (0, traversal_1.skipDownwards)(returnExp);
|
|
33
|
+
if (typescript_1.default.isCallExpression(innerReturnExp) && isTupleMacro(state, innerReturnExp)) {
|
|
34
|
+
const [args, prereqs] = state.capture(() => (0, ensureTransformOrder_1.ensureTransformOrder)(state, innerReturnExp.arguments));
|
|
35
|
+
luau_ast_1.default.list.pushList(result, prereqs);
|
|
36
|
+
expression = luau_ast_1.default.list.make(...args);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
expression = (0, transformExpression_1.transformExpression)(state, innerReturnExp);
|
|
40
|
+
if ((0, types_1.isLuaTupleType)(state)(state.getType(returnExp)) && !isTupleReturningCall(state, returnExp, expression)) {
|
|
41
|
+
if (luau_ast_1.default.isArray(expression)) {
|
|
42
|
+
expression = expression.members;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
expression = luau_ast_1.default.call(luau_ast_1.default.globals.unpack, [expression]);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if ((0, isBlockedByTryStatement_1.isReturnBlockedByTryStatement)(returnExp)) {
|
|
50
|
+
state.markTryUses("usesReturn");
|
|
51
|
+
luau_ast_1.default.list.push(result, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.ReturnStatement, {
|
|
52
|
+
expression: luau_ast_1.default.list.make(state.TS(returnExp, "TRY_RETURN"), luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.Array, {
|
|
53
|
+
members: luau_ast_1.default.list.isList(expression) ? expression : luau_ast_1.default.list.make(expression),
|
|
54
|
+
})),
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
luau_ast_1.default.list.push(result, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.ReturnStatement, { expression }));
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
function transformReturnStatement(state, node) {
|
|
63
|
+
if (!node.expression) {
|
|
64
|
+
if ((0, isBlockedByTryStatement_1.isReturnBlockedByTryStatement)(node)) {
|
|
65
|
+
state.markTryUses("usesReturn");
|
|
66
|
+
return luau_ast_1.default.list.make(luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.ReturnStatement, {
|
|
67
|
+
expression: luau_ast_1.default.list.make(state.TS(node, "TRY_RETURN"), luau_ast_1.default.array()),
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
return luau_ast_1.default.list.make(luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.ReturnStatement, { expression: luau_ast_1.default.nil() }));
|
|
71
|
+
}
|
|
72
|
+
return transformReturnStatementInner(state, node.expression);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=transformReturnStatement.js.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.transformStatement = transformStatement;
|
|
7
|
+
const luau_ast_1 = __importDefault(require("@roblox-ts/luau-ast"));
|
|
8
|
+
const diagnostics_1 = require("../../../Shared/diagnostics");
|
|
9
|
+
const assert_1 = require("../../../Shared/util/assert");
|
|
10
|
+
const DiagnosticService_1 = require("../../classes/DiagnosticService");
|
|
11
|
+
const transformBlock_1 = require("./transformBlock");
|
|
12
|
+
const transformBreakStatement_1 = require("./transformBreakStatement");
|
|
13
|
+
const transformClassDeclaration_1 = require("./transformClassDeclaration");
|
|
14
|
+
const transformContinueStatement_1 = require("./transformContinueStatement");
|
|
15
|
+
const transformDoStatement_1 = require("./transformDoStatement");
|
|
16
|
+
const transformEnumDeclaration_1 = require("./transformEnumDeclaration");
|
|
17
|
+
const transformExportAssignment_1 = require("./transformExportAssignment");
|
|
18
|
+
const transformExportDeclaration_1 = require("./transformExportDeclaration");
|
|
19
|
+
const transformExpressionStatement_1 = require("./transformExpressionStatement");
|
|
20
|
+
const transformForOfStatement_1 = require("./transformForOfStatement");
|
|
21
|
+
const transformForStatement_1 = require("./transformForStatement");
|
|
22
|
+
const transformFunctionDeclaration_1 = require("./transformFunctionDeclaration");
|
|
23
|
+
const transformIfStatement_1 = require("./transformIfStatement");
|
|
24
|
+
const transformImportDeclaration_1 = require("./transformImportDeclaration");
|
|
25
|
+
const transformImportEqualsDeclaration_1 = require("./transformImportEqualsDeclaration");
|
|
26
|
+
const transformModuleDeclaration_1 = require("./transformModuleDeclaration");
|
|
27
|
+
const transformReturnStatement_1 = require("./transformReturnStatement");
|
|
28
|
+
const transformSwitchStatement_1 = require("./transformSwitchStatement");
|
|
29
|
+
const transformThrowStatement_1 = require("./transformThrowStatement");
|
|
30
|
+
const transformTryStatement_1 = require("./transformTryStatement");
|
|
31
|
+
const transformVariableStatement_1 = require("./transformVariableStatement");
|
|
32
|
+
const transformWhileStatement_1 = require("./transformWhileStatement");
|
|
33
|
+
const getKindName_1 = require("../../util/getKindName");
|
|
34
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
35
|
+
const NO_EMIT = () => luau_ast_1.default.list.make();
|
|
36
|
+
const DIAGNOSTIC = (factory) => (state, node) => {
|
|
37
|
+
DiagnosticService_1.DiagnosticService.addDiagnostic(factory(node));
|
|
38
|
+
return NO_EMIT();
|
|
39
|
+
};
|
|
40
|
+
function createTransformerMap(values) {
|
|
41
|
+
return new Map(values);
|
|
42
|
+
}
|
|
43
|
+
const TRANSFORMER_BY_KIND = createTransformerMap([
|
|
44
|
+
[typescript_1.default.SyntaxKind.InterfaceDeclaration, NO_EMIT],
|
|
45
|
+
[typescript_1.default.SyntaxKind.TypeAliasDeclaration, NO_EMIT],
|
|
46
|
+
[typescript_1.default.SyntaxKind.EmptyStatement, NO_EMIT],
|
|
47
|
+
[typescript_1.default.SyntaxKind.ForInStatement, DIAGNOSTIC(diagnostics_1.errors.noForInStatement)],
|
|
48
|
+
[typescript_1.default.SyntaxKind.LabeledStatement, DIAGNOSTIC(diagnostics_1.errors.noLabeledStatement)],
|
|
49
|
+
[typescript_1.default.SyntaxKind.DebuggerStatement, DIAGNOSTIC(diagnostics_1.errors.noDebuggerStatement)],
|
|
50
|
+
[typescript_1.default.SyntaxKind.Block, transformBlock_1.transformBlock],
|
|
51
|
+
[typescript_1.default.SyntaxKind.BreakStatement, transformBreakStatement_1.transformBreakStatement],
|
|
52
|
+
[typescript_1.default.SyntaxKind.ClassDeclaration, transformClassDeclaration_1.transformClassDeclaration],
|
|
53
|
+
[typescript_1.default.SyntaxKind.ContinueStatement, transformContinueStatement_1.transformContinueStatement],
|
|
54
|
+
[typescript_1.default.SyntaxKind.DoStatement, transformDoStatement_1.transformDoStatement],
|
|
55
|
+
[typescript_1.default.SyntaxKind.EnumDeclaration, transformEnumDeclaration_1.transformEnumDeclaration],
|
|
56
|
+
[typescript_1.default.SyntaxKind.ExportAssignment, transformExportAssignment_1.transformExportAssignment],
|
|
57
|
+
[typescript_1.default.SyntaxKind.ExportDeclaration, transformExportDeclaration_1.transformExportDeclaration],
|
|
58
|
+
[typescript_1.default.SyntaxKind.ExpressionStatement, transformExpressionStatement_1.transformExpressionStatement],
|
|
59
|
+
[typescript_1.default.SyntaxKind.ForOfStatement, transformForOfStatement_1.transformForOfStatement],
|
|
60
|
+
[typescript_1.default.SyntaxKind.ForStatement, transformForStatement_1.transformForStatement],
|
|
61
|
+
[typescript_1.default.SyntaxKind.FunctionDeclaration, transformFunctionDeclaration_1.transformFunctionDeclaration],
|
|
62
|
+
[typescript_1.default.SyntaxKind.IfStatement, transformIfStatement_1.transformIfStatement],
|
|
63
|
+
[typescript_1.default.SyntaxKind.ImportDeclaration, transformImportDeclaration_1.transformImportDeclaration],
|
|
64
|
+
[typescript_1.default.SyntaxKind.ImportEqualsDeclaration, transformImportEqualsDeclaration_1.transformImportEqualsDeclaration],
|
|
65
|
+
[typescript_1.default.SyntaxKind.ModuleDeclaration, transformModuleDeclaration_1.transformModuleDeclaration],
|
|
66
|
+
[typescript_1.default.SyntaxKind.ReturnStatement, transformReturnStatement_1.transformReturnStatement],
|
|
67
|
+
[typescript_1.default.SyntaxKind.SwitchStatement, transformSwitchStatement_1.transformSwitchStatement],
|
|
68
|
+
[typescript_1.default.SyntaxKind.ThrowStatement, transformThrowStatement_1.transformThrowStatement],
|
|
69
|
+
[typescript_1.default.SyntaxKind.TryStatement, transformTryStatement_1.transformTryStatement],
|
|
70
|
+
[typescript_1.default.SyntaxKind.VariableStatement, transformVariableStatement_1.transformVariableStatement],
|
|
71
|
+
[typescript_1.default.SyntaxKind.WhileStatement, transformWhileStatement_1.transformWhileStatement],
|
|
72
|
+
]);
|
|
73
|
+
function transformStatement(state, node) {
|
|
74
|
+
const modifiers = typescript_1.default.canHaveModifiers(node) ? typescript_1.default.getModifiers(node) : undefined;
|
|
75
|
+
if (modifiers === null || modifiers === void 0 ? void 0 : modifiers.some(v => v.kind === typescript_1.default.SyntaxKind.DeclareKeyword))
|
|
76
|
+
return NO_EMIT();
|
|
77
|
+
const transformer = TRANSFORMER_BY_KIND.get(node.kind);
|
|
78
|
+
if (transformer) {
|
|
79
|
+
return transformer(state, node);
|
|
80
|
+
}
|
|
81
|
+
(0, assert_1.assert)(false, `Unknown statement: ${(0, getKindName_1.getKindName)(node.kind)}`);
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=transformStatement.js.map
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.transformSwitchStatement = transformSwitchStatement;
|
|
7
|
+
const luau_ast_1 = __importDefault(require("@roblox-ts/luau-ast"));
|
|
8
|
+
const transformExpression_1 = require("../expressions/transformExpression");
|
|
9
|
+
const transformStatementList_1 = require("../transformStatementList");
|
|
10
|
+
const createHoistDeclaration_1 = require("../../util/createHoistDeclaration");
|
|
11
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
12
|
+
function transformCaseClauseExpression(state, caseClauseExpression, switchExpression, fallThroughFlagId, canFallThroughTo) {
|
|
13
|
+
let [expression, prereqStatements] = state.capture(() => (0, transformExpression_1.transformExpression)(state, caseClauseExpression));
|
|
14
|
+
expression = luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.ParenthesizedExpression, { expression });
|
|
15
|
+
let condition = luau_ast_1.default.binary(switchExpression, "==", expression);
|
|
16
|
+
if (canFallThroughTo) {
|
|
17
|
+
if (!luau_ast_1.default.list.isEmpty(prereqStatements)) {
|
|
18
|
+
const noFallThroughCondition = luau_ast_1.default.unary("not", fallThroughFlagId);
|
|
19
|
+
luau_ast_1.default.list.push(prereqStatements, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.Assignment, {
|
|
20
|
+
left: fallThroughFlagId,
|
|
21
|
+
operator: "=",
|
|
22
|
+
right: condition,
|
|
23
|
+
}));
|
|
24
|
+
prereqStatements = luau_ast_1.default.list.make(luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.IfStatement, {
|
|
25
|
+
condition: noFallThroughCondition,
|
|
26
|
+
statements: prereqStatements,
|
|
27
|
+
elseBody: luau_ast_1.default.list.make(),
|
|
28
|
+
}));
|
|
29
|
+
condition = fallThroughFlagId;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
condition = luau_ast_1.default.binary(fallThroughFlagId, "or", condition);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
condition,
|
|
37
|
+
prereqStatements,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function transformCaseClause(state, node, switchExpression, fallThroughFlagId, canFallThroughTo, shouldUpdateFallThroughFlag) {
|
|
41
|
+
const { condition, prereqStatements } = transformCaseClauseExpression(state, node.expression, switchExpression, fallThroughFlagId, canFallThroughTo);
|
|
42
|
+
const nonEmptyStatements = node.statements.filter(v => !typescript_1.default.isEmptyStatement(v));
|
|
43
|
+
const firstStatement = nonEmptyStatements[0];
|
|
44
|
+
const statements = nonEmptyStatements.length === 1 && typescript_1.default.isBlock(firstStatement)
|
|
45
|
+
? (0, transformStatementList_1.transformStatementList)(state, firstStatement, firstStatement.statements)
|
|
46
|
+
: (0, transformStatementList_1.transformStatementList)(state, node, node.statements);
|
|
47
|
+
const canFallThroughFrom = statements.tail === undefined || !luau_ast_1.default.isFinalStatement(statements.tail.value);
|
|
48
|
+
if (canFallThroughFrom && shouldUpdateFallThroughFlag) {
|
|
49
|
+
luau_ast_1.default.list.push(statements, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.Assignment, {
|
|
50
|
+
left: fallThroughFlagId,
|
|
51
|
+
operator: "=",
|
|
52
|
+
right: luau_ast_1.default.bool(true),
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
const clauseStatements = luau_ast_1.default.list.make();
|
|
56
|
+
const hoistDeclaration = (0, createHoistDeclaration_1.createHoistDeclaration)(state, node);
|
|
57
|
+
if (hoistDeclaration) {
|
|
58
|
+
luau_ast_1.default.list.push(clauseStatements, hoistDeclaration);
|
|
59
|
+
}
|
|
60
|
+
luau_ast_1.default.list.push(clauseStatements, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.IfStatement, {
|
|
61
|
+
condition,
|
|
62
|
+
statements,
|
|
63
|
+
elseBody: luau_ast_1.default.list.make(),
|
|
64
|
+
}));
|
|
65
|
+
return {
|
|
66
|
+
canFallThroughFrom,
|
|
67
|
+
prereqs: prereqStatements,
|
|
68
|
+
clauseStatements,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function transformSwitchStatement(state, node) {
|
|
72
|
+
const expression = state.pushToVarIfComplex((0, transformExpression_1.transformExpression)(state, node.expression), "exp");
|
|
73
|
+
const fallThroughFlagId = luau_ast_1.default.tempId("fallthrough");
|
|
74
|
+
let isFallThroughFlagNeeded = false;
|
|
75
|
+
const statements = luau_ast_1.default.list.make();
|
|
76
|
+
let canFallThroughTo = false;
|
|
77
|
+
for (let i = 0; i < node.caseBlock.clauses.length; i++) {
|
|
78
|
+
const caseClauseNode = node.caseBlock.clauses[i];
|
|
79
|
+
if (typescript_1.default.isCaseClause(caseClauseNode)) {
|
|
80
|
+
const shouldUpdateFallThroughFlag = i < node.caseBlock.clauses.length - 1 && typescript_1.default.isCaseClause(node.caseBlock.clauses[i + 1]);
|
|
81
|
+
const { canFallThroughFrom, prereqs, clauseStatements } = transformCaseClause(state, caseClauseNode, expression, fallThroughFlagId, canFallThroughTo, shouldUpdateFallThroughFlag);
|
|
82
|
+
luau_ast_1.default.list.pushList(statements, prereqs);
|
|
83
|
+
luau_ast_1.default.list.pushList(statements, clauseStatements);
|
|
84
|
+
canFallThroughTo = canFallThroughFrom;
|
|
85
|
+
if (canFallThroughFrom) {
|
|
86
|
+
isFallThroughFlagNeeded = true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
luau_ast_1.default.list.pushList(statements, (0, transformStatementList_1.transformStatementList)(state, caseClauseNode, caseClauseNode.statements));
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (isFallThroughFlagNeeded) {
|
|
95
|
+
luau_ast_1.default.list.unshift(statements, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.VariableDeclaration, {
|
|
96
|
+
left: fallThroughFlagId,
|
|
97
|
+
right: luau_ast_1.default.bool(false),
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
return luau_ast_1.default.list.make(luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.RepeatStatement, {
|
|
101
|
+
condition: luau_ast_1.default.bool(true),
|
|
102
|
+
statements,
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=transformSwitchStatement.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.transformThrowStatement = transformThrowStatement;
|
|
7
|
+
const luau_ast_1 = __importDefault(require("@roblox-ts/luau-ast"));
|
|
8
|
+
const transformExpression_1 = require("../expressions/transformExpression");
|
|
9
|
+
function transformThrowStatement(state, node) {
|
|
10
|
+
const args = new Array();
|
|
11
|
+
if (node.expression !== undefined) {
|
|
12
|
+
args.push((0, transformExpression_1.transformExpression)(state, node.expression));
|
|
13
|
+
}
|
|
14
|
+
return luau_ast_1.default.list.make(luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.CallStatement, {
|
|
15
|
+
expression: luau_ast_1.default.call(luau_ast_1.default.globals.error, args),
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=transformThrowStatement.js.map
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.transformTryStatement = transformTryStatement;
|
|
7
|
+
const luau_ast_1 = __importDefault(require("@roblox-ts/luau-ast"));
|
|
8
|
+
const assert_1 = require("../../../Shared/util/assert");
|
|
9
|
+
const transformBindingName_1 = require("../binding/transformBindingName");
|
|
10
|
+
const transformStatementList_1 = require("../transformStatementList");
|
|
11
|
+
const isBlockedByTryStatement_1 = require("../../util/isBlockedByTryStatement");
|
|
12
|
+
function transformCatchClause(state, node) {
|
|
13
|
+
const parameters = luau_ast_1.default.list.make();
|
|
14
|
+
const statements = luau_ast_1.default.list.make();
|
|
15
|
+
if (node.variableDeclaration) {
|
|
16
|
+
luau_ast_1.default.list.push(parameters, (0, transformBindingName_1.transformBindingName)(state, node.variableDeclaration.name, statements));
|
|
17
|
+
}
|
|
18
|
+
luau_ast_1.default.list.pushList(statements, (0, transformStatementList_1.transformStatementList)(state, node.block, node.block.statements));
|
|
19
|
+
const catchFunction = luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.FunctionExpression, {
|
|
20
|
+
parameters,
|
|
21
|
+
hasDotDotDot: false,
|
|
22
|
+
statements,
|
|
23
|
+
});
|
|
24
|
+
return catchFunction;
|
|
25
|
+
}
|
|
26
|
+
function transformIntoTryCall(state, node, exitTypeId, returnsId, tryUses) {
|
|
27
|
+
const tryCallArgs = new Array();
|
|
28
|
+
tryCallArgs.push(luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.FunctionExpression, {
|
|
29
|
+
parameters: luau_ast_1.default.list.make(),
|
|
30
|
+
hasDotDotDot: false,
|
|
31
|
+
statements: (0, transformStatementList_1.transformStatementList)(state, node.tryBlock, node.tryBlock.statements),
|
|
32
|
+
}));
|
|
33
|
+
if (node.catchClause) {
|
|
34
|
+
tryCallArgs.push(transformCatchClause(state, node.catchClause));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
(0, assert_1.assert)(node.finallyBlock);
|
|
38
|
+
tryCallArgs.push(luau_ast_1.default.nil());
|
|
39
|
+
}
|
|
40
|
+
if (node.finallyBlock) {
|
|
41
|
+
tryCallArgs.push(luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.FunctionExpression, {
|
|
42
|
+
parameters: luau_ast_1.default.list.make(),
|
|
43
|
+
hasDotDotDot: false,
|
|
44
|
+
statements: (0, transformStatementList_1.transformStatementList)(state, node.finallyBlock, node.finallyBlock.statements),
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
if (!tryUses.usesReturn && !tryUses.usesBreak && !tryUses.usesContinue) {
|
|
48
|
+
return luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.CallStatement, {
|
|
49
|
+
expression: luau_ast_1.default.call(state.TS(node, "try"), tryCallArgs),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.VariableDeclaration, {
|
|
53
|
+
left: luau_ast_1.default.list.make(exitTypeId, returnsId),
|
|
54
|
+
right: luau_ast_1.default.call(state.TS(node, "try"), tryCallArgs),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function createFlowControlCondition(state, node, exitTypeId, flowControlConstant) {
|
|
58
|
+
return luau_ast_1.default.binary(exitTypeId, "==", state.TS(node, flowControlConstant));
|
|
59
|
+
}
|
|
60
|
+
function collapseFlowControlCases(exitTypeId, cases) {
|
|
61
|
+
(0, assert_1.assert)(cases.length > 0);
|
|
62
|
+
let nextStatements = luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.IfStatement, {
|
|
63
|
+
condition: exitTypeId,
|
|
64
|
+
statements: cases[cases.length - 1].statements,
|
|
65
|
+
elseBody: luau_ast_1.default.list.make(),
|
|
66
|
+
});
|
|
67
|
+
for (let i = cases.length - 2; i >= 0; i--) {
|
|
68
|
+
nextStatements = luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.IfStatement, {
|
|
69
|
+
condition: cases[i].condition || exitTypeId,
|
|
70
|
+
statements: cases[i].statements,
|
|
71
|
+
elseBody: nextStatements,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return luau_ast_1.default.list.make(nextStatements);
|
|
75
|
+
}
|
|
76
|
+
function transformFlowControl(state, node, exitTypeId, returnsId, tryUses) {
|
|
77
|
+
const flowControlCases = new Array();
|
|
78
|
+
if (!tryUses.usesReturn && !tryUses.usesBreak && !tryUses.usesContinue) {
|
|
79
|
+
return luau_ast_1.default.list.make();
|
|
80
|
+
}
|
|
81
|
+
const returnBlocked = (0, isBlockedByTryStatement_1.isReturnBlockedByTryStatement)(node.parent);
|
|
82
|
+
const breakBlocked = (0, isBlockedByTryStatement_1.isBreakBlockedByTryStatement)(node.parent);
|
|
83
|
+
if (tryUses.usesReturn && returnBlocked) {
|
|
84
|
+
state.markTryUses("usesReturn");
|
|
85
|
+
}
|
|
86
|
+
if (tryUses.usesBreak && breakBlocked) {
|
|
87
|
+
state.markTryUses("usesBreak");
|
|
88
|
+
}
|
|
89
|
+
if (tryUses.usesContinue && breakBlocked) {
|
|
90
|
+
state.markTryUses("usesContinue");
|
|
91
|
+
}
|
|
92
|
+
if (tryUses.usesReturn) {
|
|
93
|
+
if (returnBlocked) {
|
|
94
|
+
flowControlCases.push({
|
|
95
|
+
condition: createFlowControlCondition(state, node, exitTypeId, "TRY_RETURN"),
|
|
96
|
+
statements: luau_ast_1.default.list.make(luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.ReturnStatement, {
|
|
97
|
+
expression: luau_ast_1.default.list.make(exitTypeId, returnsId),
|
|
98
|
+
})),
|
|
99
|
+
});
|
|
100
|
+
if (breakBlocked) {
|
|
101
|
+
return collapseFlowControlCases(exitTypeId, flowControlCases);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
flowControlCases.push({
|
|
106
|
+
condition: createFlowControlCondition(state, node, exitTypeId, "TRY_RETURN"),
|
|
107
|
+
statements: luau_ast_1.default.list.make(luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.ReturnStatement, {
|
|
108
|
+
expression: luau_ast_1.default.call(luau_ast_1.default.globals.unpack, [returnsId]),
|
|
109
|
+
})),
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (tryUses.usesBreak || tryUses.usesContinue) {
|
|
114
|
+
if (breakBlocked) {
|
|
115
|
+
flowControlCases.push({
|
|
116
|
+
statements: luau_ast_1.default.list.make(luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.ReturnStatement, {
|
|
117
|
+
expression: exitTypeId,
|
|
118
|
+
})),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
if (tryUses.usesBreak) {
|
|
123
|
+
flowControlCases.push({
|
|
124
|
+
condition: createFlowControlCondition(state, node, exitTypeId, "TRY_BREAK"),
|
|
125
|
+
statements: luau_ast_1.default.list.make(luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.BreakStatement, {})),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
if (tryUses.usesContinue) {
|
|
129
|
+
flowControlCases.push({
|
|
130
|
+
condition: createFlowControlCondition(state, node, exitTypeId, "TRY_CONTINUE"),
|
|
131
|
+
statements: luau_ast_1.default.list.make(luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.ContinueStatement, {})),
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return collapseFlowControlCases(exitTypeId, flowControlCases);
|
|
137
|
+
}
|
|
138
|
+
function transformTryStatement(state, node) {
|
|
139
|
+
const statements = luau_ast_1.default.list.make();
|
|
140
|
+
const exitTypeId = luau_ast_1.default.tempId("exitType");
|
|
141
|
+
const returnsId = luau_ast_1.default.tempId("returns");
|
|
142
|
+
const tryUses = state.pushTryUsesStack();
|
|
143
|
+
luau_ast_1.default.list.push(statements, transformIntoTryCall(state, node, exitTypeId, returnsId, tryUses));
|
|
144
|
+
state.popTryUsesStack();
|
|
145
|
+
luau_ast_1.default.list.pushList(statements, transformFlowControl(state, node, exitTypeId, returnsId, tryUses));
|
|
146
|
+
return statements;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=transformTryStatement.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import luau from "@roblox-ts/luau-ast";
|
|
2
|
+
import { TransformState } from "../..";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
export declare function transformVariable(state: TransformState, identifier: ts.Identifier, right?: luau.Expression): luau.AnyIdentifier | luau.PropertyAccessExpression;
|
|
5
|
+
export declare function transformVariableDeclaration(state: TransformState, node: ts.VariableDeclaration): luau.List<luau.Statement>;
|
|
6
|
+
export declare function isVarDeclaration(node: ts.VariableDeclarationList): boolean;
|
|
7
|
+
export declare function transformVariableDeclarationList(state: TransformState, node: ts.VariableDeclarationList): luau.List<luau.Statement>;
|
|
8
|
+
export declare function transformVariableStatement(state: TransformState, node: ts.VariableStatement): luau.List<luau.Statement>;
|