From be85b36025a07d0beadcd8de41798962eed6d84d Mon Sep 17 00:00:00 2001 From: Vitaly Date: Sat, 9 May 2020 14:09:13 +0300 Subject: [PATCH] [JS BE] add flag `es6mode` --- .../jetbrains/kotlin/ir/backend/js/JsCommonBackendContext.kt | 3 +++ .../org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt | 4 +++- .../src/org/jetbrains/kotlin/ir/backend/js/compiler.kt | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsCommonBackendContext.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsCommonBackendContext.kt index d948afa1bdc..6cd5a693d68 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsCommonBackendContext.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsCommonBackendContext.kt @@ -9,4 +9,7 @@ import org.jetbrains.kotlin.backend.common.CommonBackendContext interface JsCommonBackendContext : CommonBackendContext { override val mapping: JsMapping + + val es6mode: Boolean + get() = false } \ No newline at end of file diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt index 509d42893f3..662fd417bd9 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt @@ -41,7 +41,8 @@ class JsIrBackendContext( irModuleFragment: IrModuleFragment, val additionalExportedDeclarations: Set, override val configuration: CompilerConfiguration, // TODO: remove configuration from backend context - override val scriptMode: Boolean = false + override val scriptMode: Boolean = false, + override val es6mode: Boolean = false ) : JsCommonBackendContext { override val transformedFunction get() = error("Use Mapping.inlineClassMemberToStatic instead") @@ -280,6 +281,7 @@ class JsIrBackendContext( val newThrowableSymbol = symbolTable.referenceSimpleFunction(getJsInternalFunction("newThrowable")) val extendThrowableSymbol = symbolTable.referenceSimpleFunction(getJsInternalFunction("extendThrowable")) + val setPropertiesToThrowableInstanceSymbol = symbolTable.referenceSimpleFunction(getJsInternalFunction("setPropertiesToThrowableInstance")) val throwISEsymbol = symbolTable.referenceSimpleFunction(getFunctions(kotlinPackageFqn.child(Name.identifier("THROW_ISE"))).single()) val throwIAEsymbol = symbolTable.referenceSimpleFunction(getFunctions(kotlinPackageFqn.child(Name.identifier("THROW_IAE"))).single()) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt index 4bdf1a81709..51267fd08a0 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt @@ -45,7 +45,8 @@ fun compile( exportedDeclarations: Set = emptySet(), generateFullJs: Boolean = true, generateDceJs: Boolean = false, - dceDriven: Boolean = false + dceDriven: Boolean = false, + es6mode: Boolean = false ): CompilerResult { stageController = object : StageController {} @@ -56,7 +57,7 @@ fun compile( val mainFunction = JsMainFunctionDetector.getMainFunctionOrNull(moduleFragment) - val context = JsIrBackendContext(moduleDescriptor, irBuiltIns, symbolTable, moduleFragment, exportedDeclarations, configuration) + val context = JsIrBackendContext(moduleDescriptor, irBuiltIns, symbolTable, moduleFragment, exportedDeclarations, configuration, es6mode = es6mode) // Load declarations referenced during `context` initialization val irProviders = listOf(deserializer)