[JS IR] Add flag with writing base class to metadata
This commit is contained in:
committed by
TeamCityServer
parent
228c6879f5
commit
18cb8a1b9b
+3
@@ -154,6 +154,9 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
|||||||
@Argument(value = "-Xir-legacy-property-access", description = "Force property access via JS properties (requires -Xir-export-all)")
|
@Argument(value = "-Xir-legacy-property-access", description = "Force property access via JS properties (requires -Xir-export-all)")
|
||||||
var irLegacyPropertyAccess: Boolean by FreezableVar(false)
|
var irLegacyPropertyAccess: Boolean by FreezableVar(false)
|
||||||
|
|
||||||
|
@Argument(value = "-Xir-base-class-in-metadata", description = "Write base class into metadata")
|
||||||
|
var irBaseClassInMetadata: Boolean by FreezableVar(false)
|
||||||
|
|
||||||
@Argument(value = "-Xir-per-module", description = "Splits generated .js per-module")
|
@Argument(value = "-Xir-per-module", description = "Splits generated .js per-module")
|
||||||
var irPerModule: Boolean by FreezableVar(false)
|
var irPerModule: Boolean by FreezableVar(false)
|
||||||
|
|
||||||
|
|||||||
@@ -276,6 +276,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
|||||||
relativeRequirePath = true,
|
relativeRequirePath = true,
|
||||||
propertyLazyInitialization = arguments.irPropertyLazyInitialization,
|
propertyLazyInitialization = arguments.irPropertyLazyInitialization,
|
||||||
legacyPropertyAccess = arguments.irLegacyPropertyAccess,
|
legacyPropertyAccess = arguments.irLegacyPropertyAccess,
|
||||||
|
baseClassIntoMetadata = arguments.irBaseClassInMetadata,
|
||||||
)
|
)
|
||||||
|
|
||||||
val jsCode = if (arguments.irDce && !arguments.irDceDriven) compiledModule.dceJsCode!! else compiledModule.jsCode!!
|
val jsCode = if (arguments.irDce && !arguments.irDceDriven) compiledModule.dceJsCode!! else compiledModule.jsCode!!
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ class JsIrBackendContext(
|
|||||||
val dceRuntimeDiagnostic: DceRuntimeDiagnostic? = null,
|
val dceRuntimeDiagnostic: DceRuntimeDiagnostic? = null,
|
||||||
val propertyLazyInitialization: Boolean = false,
|
val propertyLazyInitialization: Boolean = false,
|
||||||
val legacyPropertyAccess: Boolean = false,
|
val legacyPropertyAccess: Boolean = false,
|
||||||
|
val baseClassIntoMetadata: Boolean = false,
|
||||||
) : JsCommonBackendContext {
|
) : JsCommonBackendContext {
|
||||||
val fileToInitializationFuns: MutableMap<IrFile, IrSimpleFunction?> = mutableMapOf()
|
val fileToInitializationFuns: MutableMap<IrFile, IrSimpleFunction?> = mutableMapOf()
|
||||||
val fileToInitializerPureness: MutableMap<IrFile, Boolean> = mutableMapOf()
|
val fileToInitializerPureness: MutableMap<IrFile, Boolean> = mutableMapOf()
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ fun compile(
|
|||||||
relativeRequirePath: Boolean = false,
|
relativeRequirePath: Boolean = false,
|
||||||
propertyLazyInitialization: Boolean,
|
propertyLazyInitialization: Boolean,
|
||||||
legacyPropertyAccess: Boolean = false,
|
legacyPropertyAccess: Boolean = false,
|
||||||
|
baseClassIntoMetadata: Boolean = false,
|
||||||
): CompilerResult {
|
): CompilerResult {
|
||||||
val (moduleFragment: IrModuleFragment, dependencyModules, irBuiltIns, symbolTable, deserializer, moduleToName) =
|
val (moduleFragment: IrModuleFragment, dependencyModules, irBuiltIns, symbolTable, deserializer, moduleToName) =
|
||||||
loadIr(project, mainModule, analyzer, configuration, allDependencies, friendDependencies, irFactory, forceAllJs)
|
loadIr(project, mainModule, analyzer, configuration, allDependencies, friendDependencies, irFactory, forceAllJs)
|
||||||
@@ -74,7 +75,8 @@ fun compile(
|
|||||||
es6mode = es6mode,
|
es6mode = es6mode,
|
||||||
dceRuntimeDiagnostic = dceRuntimeDiagnostic,
|
dceRuntimeDiagnostic = dceRuntimeDiagnostic,
|
||||||
propertyLazyInitialization = propertyLazyInitialization,
|
propertyLazyInitialization = propertyLazyInitialization,
|
||||||
legacyPropertyAccess = legacyPropertyAccess
|
legacyPropertyAccess = legacyPropertyAccess,
|
||||||
|
baseClassIntoMetadata = baseClassIntoMetadata
|
||||||
)
|
)
|
||||||
|
|
||||||
// Load declarations referenced during `context` initialization
|
// Load declarations referenced during `context` initialization
|
||||||
|
|||||||
+6
-1
@@ -247,7 +247,12 @@ class JsClassGenerator(private val irClass: IrClass, val context: JsGenerationCo
|
|||||||
val symbol = it.classifierOrFail as IrClassSymbol
|
val symbol = it.classifierOrFail as IrClassSymbol
|
||||||
val isFunctionType = it.run { isFunctionOrKFunction() || isSuspendFunctionOrKFunction() }
|
val isFunctionType = it.run { isFunctionOrKFunction() || isSuspendFunctionOrKFunction() }
|
||||||
// TODO: make sure that there is a test which breaks when isExternal is used here instead of isEffectivelyExternal
|
// TODO: make sure that there is a test which breaks when isExternal is used here instead of isEffectivelyExternal
|
||||||
if (/*symbol.isInterface && */!it.isAny() && !isFunctionType && !symbol.isEffectivelyExternal) {
|
val requireInMetadata = if (context.staticContext.backendContext.baseClassIntoMetadata)
|
||||||
|
!it.isAny()
|
||||||
|
else
|
||||||
|
symbol.isInterface
|
||||||
|
|
||||||
|
if (requireInMetadata && !isFunctionType && !symbol.isEffectivelyExternal) {
|
||||||
JsNameRef(context.getNameForClass(symbol.owner))
|
JsNameRef(context.getNameForClass(symbol.owner))
|
||||||
} else null
|
} else null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user