[JS BE] add flag es6mode

This commit is contained in:
Vitaly
2020-05-09 14:09:13 +03:00
committed by romanart
parent 9ede8445e7
commit be85b36025
3 changed files with 9 additions and 3 deletions
@@ -9,4 +9,7 @@ import org.jetbrains.kotlin.backend.common.CommonBackendContext
interface JsCommonBackendContext : CommonBackendContext {
override val mapping: JsMapping
val es6mode: Boolean
get() = false
}
@@ -41,7 +41,8 @@ class JsIrBackendContext(
irModuleFragment: IrModuleFragment,
val additionalExportedDeclarations: Set<FqName>,
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())
@@ -45,7 +45,8 @@ fun compile(
exportedDeclarations: Set<FqName> = 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)