fun List < ChangeInfo > . getChangedAndImpactedSymbols ( caches : Iterable < IncrementalCacheCommon > , reporter : ICReporter ) : DirtyData

{ <EOL> val dirtyLookupSymbols = HashSet < LookupSymbol > ( ) <EOL> val dirtyClassesFqNames = HashSet < FqName > ( ) <EOL> val sealedParents = HashSet < FqName > ( ) <EOL> for ( change in this ) { <EOL> reporter . debug { "<STR_LIT>" } <EOL> if ( change is ChangeInfo . SignatureChanged ) { <EOL> val fqNames = if ( ! change . areSubclassesAffected ) listOf ( change . fqName ) else withSubtypes ( change . fqName , caches ) <EOL> dirtyClassesFqNames . addAll ( fqNames ) <EOL> for ( classFqName in fqNames ) { <EOL> assert ( ! classFqName . isRoot ) { "<STR_LIT>" } <EOL> val scope = classFqName . parent ( ) . asString ( ) <EOL> val name = classFqName . shortName ( ) . identifier <EOL> dirtyLookupSymbols . add ( LookupSymbol ( name , scope ) ) <EOL> } <EOL> } else if ( change is ChangeInfo . MembersChanged ) { <EOL> val fqNames = withSubtypes ( change . fqName , caches ) <EOL> dirtyClassesFqNames . addAll ( fqNames ) <EOL> for ( name in change . names ) { <EOL> fqNames . mapTo ( dirtyLookupSymbols ) { LookupSymbol ( name , it . asString ( ) ) } <EOL> } <EOL> fqNames . mapTo ( dirtyLookupSymbols ) { LookupSymbol ( SAM_LOOKUP_NAME . asString ( ) , it . asString ( ) ) } <EOL> } else if ( change is ChangeInfo . ParentsChanged ) { <EOL> change . parentsChanged . forEach { parent -> <EOL> sealedParents . addAll ( findSealedSupertypes ( parent , caches ) ) <EOL> } <EOL> } <EOL> } <EOL> return DirtyData ( dirtyLookupSymbols , dirtyClassesFqNames , sealedParents ) <EOL> }

/**
 * Returns changed and impacted symbols from this list of changes.
 *
 * For example, if `Subclass` extends `Superclass` and `Superclass` has changed, `Subclass` will be impacted.
 */


fun findSealedSupertypes ( fqName : FqName , caches : Iterable < IncrementalCacheCommon > ) : Collection < FqName >

{ <EOL> if ( isSealed ( fqName , caches ) ) { <EOL> return listOf ( fqName ) <EOL> } <EOL> return caches . flatMap { cache -> cache . getSupertypesOf ( fqName ) . filter { cache . isSealed ( it ) ? : false } } <EOL> }

/**
 * Finds sealed supertypes of class in same module.
 * This method should be used for processing freedomOsSealedClasses feature, because
 * mutually declared list of sealed subclasses could be declared only in the same module.
 */


public abstract fun createPackagePartProvider ( scope : GlobalSearchScope ) : PackagePartProvider

/**
 * Create a [PackagePartProvider] for a given scope. [PackagePartProvider] is responsible for searching sub packages in a library.
 */


public fun Project . createPackagePartProvider ( scope : GlobalSearchScope ) : PackagePartProvider

= <EOL> getService ( PackagePartProviderFactory :: class . java ) . createPackagePartProvider ( scope )


@ HtmlTagMarker <EOL> inline fun FIELDSET . legend ( classes : String ? = null , crossinline block : LEGEND . ( ) -> Unit = { } ) : Unit

= LEGEND ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FIGURE . legend ( classes : String ? = null , crossinline block : LEGEND . ( ) -> Unit = { } ) : Unit


@ HtmlTagMarker <EOL> inline fun FIGURE . figcaption ( classes : String ? = null , crossinline block : FIGCAPTION . ( ) -> Unit = { } ) : Unit

= FIGCAPTION ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


private fun runConsumerTest ( dependencyProject : Project , withKotlinVersion : String ? <EOL> )

{ <EOL> if ( producerGradleVersion != consumerGradleVersion && ! isPublishedLibrary ) { <EOL> println ( "<STR_LIT>" ) <EOL> return <EOL> } <EOL> val repositoryLinesIfNeeded = if ( isPublishedLibrary ) """<STR_LIT>""" . trimIndent ( ) else "<STR_LIT>" <EOL> val dependencyNotation = <EOL> if ( isPublishedLibrary ) <EOL> """<STR_LIT>""" <EOL> else "<STR_LIT>" <EOL> val usedConsumerGradleVersion : String <EOL> val consumerProject = Project ( "<STR_LIT>" , consumerGradleVersion , minLogLevel = LogLevel . INFO ) . apply { <EOL> usedConsumerGradleVersion = chooseWrapperVersionOrFinishTest ( ) <EOL> projectDir . deleteRecursively ( ) <EOL> if ( ! isPublishedLibrary ) { <EOL> embedProject ( dependencyProject ) <EOL> gradleSettingsScript ( ) . appendText ( "<STR_LIT>" ) <EOL> } <EOL> setupWorkingDir ( applyLanguageVersion = withKotlinVersion != oldKotlinVersion ) <EOL> gradleBuildScript ( "<STR_LIT>" ) . apply { <EOL> writeText ( readText ( ) . let { <EOL> if ( withKotlinVersion != null ) it else it . checkedReplace ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> } . let { text -> <EOL> if ( useFlavors ) text else text . lines ( ) . filter { ! it . trim ( ) . startsWith ( "<STR_LIT>" ) } . joinToString ( "<STR_LIT:\n>" ) <EOL> } + "<STR_LIT:\n>" + """<STR_LIT>""" . trimIndent ( ) ) <EOL> } <EOL> } <EOL> val variantNamePublishedSuffix = if ( isPublishedLibrary ) "<STR_LIT>" else "<STR_LIT>" <EOL> val variantForReleaseAndStaging = if ( isAndroidPublishDebugOnly && isPublishedLibrary ) <EOL> "<STR_LIT>" <EOL> else "<STR_LIT>" <EOL> fun nameWithFlavorIfNeeded ( name : String ) = if ( useFlavors ) "<STR_LIT>" else name <EOL> val configurationToExpectedVariant = listOf ( nameWithFlavorIfNeeded ( "<STR_LIT>" ) to nameWithFlavorIfNeeded ( "<STR_LIT>" ) , nameWithFlavorIfNeeded ( "<STR_LIT>" ) to nameWithFlavorIfNeeded ( variantForReleaseAndStaging ) , nameWithFlavorIfNeeded ( "<STR_LIT>" ) to if ( isPublishedLibrary ) nameWithFlavorIfNeeded ( variantForReleaseAndStaging ) else "<STR_LIT>" ) <EOL> val dependencyInsightModuleName = <EOL> if ( isPublishedLibrary ) <EOL> "<STR_LIT>" <EOL> else "<STR_LIT>" <EOL> val consumerBuildOptions = defaultBuildOptions ( ) . copy ( javaHome = File ( System . getProperty ( "<STR_LIT>" ) ) , androidHome = KtTestUtil . findAndroidSdk ( ) , androidGradlePluginVersion = consumerAgpVersion , kotlinVersion = withKotlinVersion ? : defaultBuildOptions ( ) . kotlinVersion ) . suppressDeprecationWarningsOn ( "<STR_LIT>" ) { options -> <EOL> ( ! isPublishedLibrary && ( withKotlinVersion != null || options . safeAndroidGradlePluginVersion >= AGPVersion . v7_1_0 ) || isPublishedLibrary && withKotlinVersion == oldKotlinVersion ) && <EOL> GradleVersion . version ( usedConsumerGradleVersion ) >= GradleVersion . version ( TestVersions . Gradle . G_7_5 ) && <EOL> options . safeAndroidGradlePluginVersion < AGPVersion . v7_3_0 <EOL> } <EOL> val variantCheckRequests = mutableMapOf < ResolvedVariantRequest , String > ( ) <EOL> configurationToExpectedVariant . forEach { ( configuration , expected ) -> <EOL> val expectedVariant = if ( withKotlinVersion == null && ! isPublishedLibrary ) { <EOL> "<STR_LIT>" <EOL> } else expected <EOL> val resolvedVariantRequest = ResolvedVariantRequest ( "<STR_LIT>" , configuration , dependencyInsightModuleName ) <EOL> variantCheckRequests [ resolvedVariantRequest ] = expectedVariant <EOL> } <EOL> consumerProject . apply { <EOL> gradleSettingsScript ( ) . appendText ( "<STR_LIT>" ) <EOL> projectDir . resolve ( "<STR_LIT>" ) . also { it . parentFile . mkdirs ( ) } . writeText ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> val resolvedVariantRequest = ResolvedVariantRequest ( "<STR_LIT>" , "<STR_LIT>" , dependencyInsightModuleName ) <EOL> variantCheckRequests [ resolvedVariantRequest ] = "<STR_LIT>" <EOL> } <EOL> try { <EOL> ResolvedVariantChecker ( ) . assertResolvedSingleVariantsBatch ( consumerProject , variantCheckRequests , consumerBuildOptions ) <EOL> } catch ( e : AssertionError ) { <EOL> collector . addError ( AssertionError ( "<STR_LIT>" , e ) ) <EOL> } <EOL> }

/** Use [withKotlinVersion] = null for testing without Kotlin Gradle plugin */


public fun dropLast ( size : Int = <NUM_LIT:1> ) : ColumnPath

= ColumnPath ( path . dropLast ( size ) )

/**
 * Returns a shortened [ColumnPath] without the last [size] elements.
 *
 * NOTE: If called from the [ColumnsSelectionDsl], you might be looking for [ColumnsSelectionDsl.dropLastChildren]
 * instead.
 */


public fun dropFirst ( size : Int = <NUM_LIT:1> ) : ColumnPath

= ColumnPath ( path . drop ( size ) )

/**
 * Returns a shortened [ColumnPath] without the first [size] elements.
 *
 * NOTE: If called from the [ColumnsSelectionDsl], you might be looking for [ColumnsSelectionDsl.dropChildren]
 * instead.
 */


public fun take ( first : Int ) : ColumnPath

= ColumnPath ( path . take ( first ) )

/**
 * Returns a shortened [ColumnPath] containing just the first [first] elements.
 *
 * NOTE: If called from the [ColumnsSelectionDsl], you might be looking for [ColumnsSelectionDsl.takeCols]
 * instead.
 */


public fun takeLast ( last : Int ) : ColumnPath

= ColumnPath ( path . takeLast ( last ) )

/**
 * Returns a shortened [ColumnPath] containing just the last [last] elements.
 *
 * NOTE: If called from the [ColumnsSelectionDsl], you might be looking for [ColumnsSelectionDsl.takeLast]
 * instead.
 */


internal fun ColumnPath . dropStartWrt ( otherPath : ColumnPath ) : ColumnPath

{ <EOL> val first = dropOverlappingStartOfChild ( parent = otherPath , child = this ) <EOL> return ColumnPath ( first ) <EOL> }

/**
 * Drops the overlapping start of the child path with respect to the parent path, and returns the resulting ColumnPath.
 *
 * For example:
 * ```kt
 * val parentPath = pathOf("a", "b", "c")
 * val childPath = pathOf("a", "b", "c", "d", "e")
 *
 * childPath.dropStartWrt(parentPath) // returns pathOf("d", "e")
 * ```
 *
 * @param otherPath The parent path to compare against.
 * @return The resulting ColumnPath after dropping the overlapping start.
 */


public fun GraphTrainableModel . loadWeights ( hdfFile : HdfFile ) : Unit

= loadWeights ( hdfFile , layers )

/**
 * Loads weights from hdf5 file created in Keras TensorFlow framework.
 *
 * @param [hdfFile] File in hdf5 file format containing weights of the model.
 */


public fun GraphTrainableModel . loadWeightsForFrozenLayers ( hdfFile : HdfFile )

{ <EOL> loadWeights ( hdfFile , layers . filterNot ( Layer :: isTrainable ) ) <EOL> }

/**
 * Loads weights from hdf5 file created in Keras TensorFlow framework for non-trainable (or frozen) layers only.
 *
 * NOTE: Weights for trainable layers will not be loaded and will be initialized via default initializers.
 *
 * @param [hdfFile] File in hdf5 file format containing weights of Sequential model.
 */


public fun GraphTrainableModel . loadWeights ( hdfFile : HdfFile , layerList : List < Layer > )

{ <EOL> val group = when { <EOL> hdfFile . attributes . containsKey ( "<STR_LIT>" ) -> hdfFile <EOL> hdfFile . children . containsKey ( "<STR_LIT>" ) -> ( hdfFile as Group ) . getChild ( "<STR_LIT>" ) as Group <EOL> else -> null <EOL> } <EOL> if ( group == null ) { <EOL> logger . error { <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" <EOL> } <EOL> return <EOL> } <EOL> if ( group . getKerasVersion ( ) == <NUM_LIT:1> ) { <EOL> throw UnsupportedOperationException ( "<STR_LIT>" + "<STR_LIT>" ) <EOL> } <EOL> loadWeights ( layerList ) { layer -> fillLayerWeights ( layer , group , this ) } <EOL> }

/**
 * Loads weights from hdf5 file created in Keras TensorFlow framework for pre-defined list of layers.
 *
 * NOTE: Weights for another layers will not be loaded (should be initialized manually).
 *
 * @param [hdfFile] File in hdf5 file format containing weights of Sequential model.
 * @param [layerList] List of layers to load weights. Weights for other layers will be initialized by initializer later.
 */


public fun GraphTrainableModel . loadWeightsByPathTemplates ( hdfFile : HdfFile , kernelDataPathTemplate : String = KERNEL_DATA_PATH_TEMPLATE , biasDataPathTemplate : String = BIAS_DATA_PATH_TEMPLATE ) : Unit

= loadWeightsByPathTemplates ( hdfFile , layers , kernelDataPathTemplate , biasDataPathTemplate )

/**
 * Loads weights from hdf5 file created in Keras TensorFlow framework.
 *
 * @param [hdfFile] File in hdf5 file format containing weights of Sequential model.
 * @param [kernelDataPathTemplate] Template path to kernel weights of the specific layer.
 * @param [biasDataPathTemplate] Template path to bias weights of the specific layer.
 */


public fun GraphTrainableModel . loadWeightsForFrozenLayersByPathTemplates ( hdfFile : HdfFile , kernelDataPathTemplate : String = KERNEL_DATA_PATH_TEMPLATE , biasDataPathTemplate : String = BIAS_DATA_PATH_TEMPLATE )

{ <EOL> loadWeightsByPathTemplates ( hdfFile , layers . filterNot ( Layer :: isTrainable ) , kernelDataPathTemplate , biasDataPathTemplate ) <EOL> }

/**
 * Loads weights from hdf5 file created in Keras TensorFlow framework for non-trainable (or frozen) layers only.
 *
 * NOTE: Weights for trainable layers will not be loaded and will be initialized via default initializers.
 *
 * @param [hdfFile] File in hdf5 file format containing weights of Sequential model.
 * @param [kernelDataPathTemplate] Template path to kernel weights of the specific layer.
 * @param [biasDataPathTemplate] Template path to bias weights of the specific layer.
 */


public fun GraphTrainableModel . loadWeightsByPathTemplates ( hdfFile : HdfFile , layerList : List < Layer > , kernelDataPathTemplate : String = KERNEL_DATA_PATH_TEMPLATE , biasDataPathTemplate : String = BIAS_DATA_PATH_TEMPLATE )

{ <EOL> val layerPaths = LayerConvOrDensePaths ( "<STR_LIT>" , kernelDataPathTemplate , biasDataPathTemplate ) <EOL> loadWeights ( layerList ) { layer -> <EOL> fillLayerWeights ( layer , hdfFile , layerPaths , this ) <EOL> } <EOL> }

/**
 * Loads weights from hdf5 file created in Keras TensorFlow framework for pre-defined list of layers.
 *
 * NOTE: Weights for another layers will not be loaded (should be initialized manually).
 *
 * @param [hdfFile] File in hdf5 file format containing weights of Sequential model.
 * @param [layerList] List of layers to load weights. Weights for other layers will be initialized by initializer later.
 * @param [kernelDataPathTemplate] Template path to kernel weights of the specific layer.
 * @param [biasDataPathTemplate] Template path to bias weights of the specific layer.
 */


public fun GraphTrainableModel . loadWeightsByPaths ( hdfFile : HdfFile , weightPaths : List < LayerPaths > , missedWeights : MissedWeightsStrategy = MissedWeightsStrategy . INITIALIZE , forFrozenLayersOnly : Boolean = false )

{ <EOL> val layersToLoad = if ( forFrozenLayersOnly ) layers . filterNot ( Layer :: isTrainable ) else layers <EOL> val layersToWeightPaths = layersToLoad . mapNotNull { layer -> <EOL> val layerPaths = weightPaths . find { layer . name == it . layerName } <EOL> if ( layerPaths == null && missedWeights == MissedWeightsStrategy . INITIALIZE ) { <EOL> logger . warn { <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" <EOL> } <EOL> return@mapNotNull null <EOL> } <EOL> layer to layerPaths <EOL> } . toMap ( ) <EOL> loadWeights ( layersToWeightPaths . keys ) { layer -> <EOL> fillLayerWeights ( layer , hdfFile , layersToWeightPaths [ layer ] , this ) <EOL> } <EOL> }

/**
 * Loads weights from hdf5 file created in Keras TensorFlow framework.
 *
 * @param [hdfFile] File in hdf5 file format containing weights of Sequential model.
 * @param [weightPaths] Fully-specified paths to kernel and bias weights of each layer.
 *
 * NOTE: Kernel and bias will be initialized by default initializers if they are missed in [weightPaths] object.
 */


public fun GraphTrainableModel . loadWeightsByPaths ( hdfFile : HdfFile , layerList : List < Layer > , kernelDataPathTemplate : String = KERNEL_DATA_PATH_TEMPLATE , biasDataPathTemplate : String = BIAS_DATA_PATH_TEMPLATE )

{ <EOL> val layerConvOrDensePaths = LayerConvOrDensePaths ( "<STR_LIT>" , kernelDataPathTemplate , biasDataPathTemplate ) <EOL> loadWeights ( layerList ) { layer -> <EOL> fillLayerWeights ( layer , hdfFile , layerConvOrDensePaths , this ) <EOL> } <EOL> }


{ <EOL> val modelHub = TFModelHub ( cacheDirectory = File ( "<STR_LIT>" ) ) <EOL> val modelType = TFModels . CV . VGG16 ( ) <EOL> val model = modelHub . loadModel ( modelType ) <EOL> val imageNetClassLabels = modelHub . loadClassLabels ( ) <EOL> model . use { <EOL> it . compile ( optimizer = Adam ( ) , loss = Losses . MAE , metric = Metrics . ACCURACY ) <EOL> it . logSummary ( ) <EOL> val hdfFile = modelHub . loadWeights ( modelType ) <EOL> it . loadWeights ( hdfFile ) <EOL> val fileDataLoader = modelType . createPreprocessing ( it ) . fileLoader ( ) <EOL> for ( i in <NUM_LIT:1> .. <NUM_LIT:8> ) { <EOL> val inputData = fileDataLoader . load ( getFileFromResource ( "<STR_LIT>" ) ) <EOL> val res = it . predict ( inputData , "<STR_LIT>" ) <EOL> println ( "<STR_LIT>" ) <EOL> val top5 = it . predictTop5Labels ( inputData , imageNetClassLabels ) <EOL> println ( top5 . toString ( ) ) <EOL> } <EOL> } <EOL> }

/**
 * This example demonstrates the inference concept on VGG'16 model:
 * - Model configuration, model weights and labels are obtained from [TFModelHub].
 * - Weights are loaded from .h5 file, configuration is loaded from .json file.
 * - Model predicts on a few images located in resources.
 * - Special preprocessing (used in VGG'16 during training on ImageNet dataset) is applied to each image before prediction.
 * - No additional training.
 * - No new layers are added.
 *
 * @see
 * Very Deep Convolutional Networks for Large-Scale Image Recognition (ICLR 2015).
 * @see
 * Detailed description of VGG'16 model and an approach to build it in Keras.
 */


= vgg16prediction ( )


private fun tryToMapLibrarySourceFile ( dependencies : Iterable < ModuleDescriptor > , sourceMapPath : String ) : String ?

{ <EOL> for ( dependency in dependencies ) { <EOL> val libraryFile = try { <EOL> File ( testServices . libraryProvider . getPathByDescriptor ( dependency ) ) <EOL> } catch ( e : NoSuchElementException ) { <EOL> continue <EOL> } <EOL> val sourceRoot : File = libraryFile <EOL> . parentFile <EOL> ? . parentFile <EOL> ? . parentFile <EOL> ? . parentFile <EOL> ? . parentFile <EOL> ? : continue <EOL> val searchPaths = listOf ( sourceRoot , sourceRoot . resolve ( "<STR_LIT:build>" ) ) <EOL> for ( searchPath in searchPaths ) { <EOL> val resolved = searchPath . resolve ( sourceMapPath ) <EOL> if ( resolved . exists ( ) ) { <EOL> return resolved . absolutePath <EOL> } <EOL> } <EOL> } <EOL> return null <EOL> }

/**
 * Some heuristics to find the library source file that this [sourceMapPath] should point to.
 * May not work in 100% of cases, but should be good enough for our tests.
 */


public fun pretrainedModel ( modelHub : ModelHub ) : U

/** Returns the specially prepared pre-trained model of the type U. */


public fun model ( modelHub : ModelHub ) : T

{ <EOL> return modelHub . loadModel ( this ) <EOL> }

/** Loads the model, identified by this name, from the [modelHub]. */


@ Suppress ( "<STR_LIT:FunctionName>" ) <EOL> public actual inline fun Runnable ( crossinline block : ( ) -> Unit ) : Runnable

= <EOL> java . lang . Runnable { block ( ) }

/**
 * Creates [Runnable] task instance.
 */


@ JvmName ( "<STR_LIT>" ) <EOL> @ JvmOverloads <EOL> public fun Handler . asCoroutineDispatcher ( name : String ? = null ) : HandlerDispatcher

= <EOL> HandlerContext ( this , name )

/**
 * Represents an arbitrary [Handler] as an implementation of [CoroutineDispatcher]
 * with an optional [name] for nicer debugging
 *
 * ## Rejected execution
 *
 * If the underlying handler is closed and its message-scheduling methods start to return `false` on
 * an attempt to submit a continuation task to the resulting dispatcher,
 * then the [Job] of the affected task is [cancelled][Job.cancel] and the task is submitted to the
 * [Dispatchers.IO], so that the affected coroutine can cleanup its resources and promptly complete.
 */


public suspend fun awaitFrame ( ) : Long

{ <EOL> val choreographer = choreographer <EOL> return if ( choreographer != null ) { <EOL> suspendCancellableCoroutine { cont -> <EOL> postFrameCallback ( choreographer , cont ) <EOL> } <EOL> } else { <EOL> awaitFrameSlowPath ( ) <EOL> } <EOL> }

/**
 * Awaits the next animation frame and returns frame time in nanoseconds.
 */


public fun < T > xMax ( column : ColumnReference < T > ) : PositionalMapping < T >

{ <EOL> return addPositionalMapping < T > ( X_MAX , column . name ( ) , null ) <EOL> }

/**
 * Maps the `xMax` aesthetic to a data column specified by a [ColumnReference].
 *
 * @param column the data column to be mapped.
 * @return a [PositionalMapping] object representing the mapping.
 */


public fun < T > xMax ( column : KProperty < T > ) : PositionalMapping < T >

{ <EOL> return addPositionalMapping < T > ( X_MAX , column . name , null ) <EOL> }

/**
 * Maps the `xMax` aesthetic to a data column specified by a [KProperty].
 *
 * @param column the data column to be mapped.
 * @return a [PositionalMapping] object representing the mapping.
 */


public fun xMax ( column : String ) : PositionalMapping < Any ? >

{ <EOL> return addPositionalMapping ( X_MAX , column , null ) <EOL> }

/**
 * Maps the `xMax` aesthetic to a data column specified by a [String].
 *
 * @param column the data column to be mapped.
 * @return a [PositionalMapping] object representing the mapping.
 */


public fun < T > xMax ( values : Iterable < T > ) : PositionalMapping < T >

{ <EOL> return addPositionalMapping < T > ( X_MAX , values . toList ( ) , null , null ) <EOL> }

/**
 * Maps the `xMax` aesthetic to iterable of values.
 *
 * @param values the iterable of values to be mapped.
 * @return a [PositionalMapping] object representing the mapping.
 */


public fun < T > xMax ( values : DataColumn < T > ) : PositionalMapping < T >

{ <EOL> return addPositionalMapping < T > ( X_MAX , values , null ) <EOL> }

/**
 * Maps the `xMax` aesthetic to a data column.
 *
 * @param values the data column to be mapped.
 * @return a [PositionalMapping] object representing the mapping.
 */


internal fun KonanTarget . enabledOnCurrentHostForKlibCompilation ( provider : PropertiesProvider )

= <EOL> HostManager ( ) . isEnabled ( this ) || provider . enableKlibsCrossCompilation

/**
 * Returns whether klib compilation is allowed for [this]-target on the current host.
 * [enabledOnCurrentHostForBinariesCompilation] returns 'true' only if [enabledOnCurrentHostForKlibCompilation]
 * returns 'true'
 *
 * [enabledOnCurrentHostForKlibCompilation] might return 'true' in some cases where [enabledOnCurrentHostForBinariesCompilation]
 * returns 'false' (e.g.: compile a klib for iOS target on Linux when the code depends only on Kotlin Stdlib)
 *
 * Ideally, these APIs should be in [HostManager] instead of KGP-side wrappers. Refer to KT-64512 for that
 */


protected fun isCompatibleTo ( ourVersion : BinaryVersion ) : Boolean

{ <EOL> return if ( major == <NUM_LIT:0> ) ourVersion . major == <NUM_LIT:0> && minor == ourVersion . minor <EOL> else major == ourVersion . major && minor <= ourVersion . minor <EOL> }

/**
 * Returns true if this version of some format loaded from some binaries is compatible
 * to the expected version of that format in the current compiler.
 *
 * @param ourVersion the version of this format in the current compiler
 */


fun lerp ( start : Int , stop : Int , fraction : Float ) : Int

{ <EOL> return start + ( ( stop - start ) * fraction . toDouble ( ) ) . roundToInt ( ) <EOL> }

/**
 * Linearly interpolate between [start] and [stop] with [fraction] fraction between them.
 */


fun lerp ( start : Long , stop : Long , fraction : Float ) : Long

{ <EOL> return start + ( ( stop - start ) * fraction . toDouble ( ) ) . roundToLong ( ) <EOL> }


fun libraryDefinition ( buildAction : ( LibraryDefinitionImpl ) -> Unit ) : LibraryDefinition

{ <EOL> return LibraryDefinitionImpl . build ( buildAction ) <EOL> }

/**
 * Builds an instance of [LibraryDefinition].
 * Build action receives [LibraryDefinitionImpl] as an explicit argument
 * because of problems with names clashing that may arise.
 */


{ <EOL> return "<STR_LIT:test>" <EOL> }

/**
 * JVM actual implementation for `getCurrentDate`
 */


override fun beforeEach ( extensionContext : ExtensionContext ) : Unit

= with ( extensionContext ) { <EOL> val settings = createTestRunSettings ( ) <EOL> with ( settings . get < BlackBoxTestInstances > ( ) . enclosingTestInstance ) { <EOL> testRunSettings = settings <EOL> testRunProvider = getOrCreateTestRunProvider ( ) <EOL> } <EOL> }

/**
 * Note: [BeforeEachCallback.beforeEach] allows accessing test instances while [BeforeAllCallback.beforeAll] which may look
 * more preferable here does not allow it because it is called at the time when test instances are not created yet.
 * Also, [TestInstancePostProcessor.postProcessTestInstance] allows accessing only the currently created test instance and does
 * not allow accessing its parent test instance in case there are inner test classes in the generated test suite.
 */


= with ( extensionContext ) { <EOL> val settings = createSimpleTestRunSettings ( ) <EOL> with ( settings . get < SimpleTestInstances > ( ) . enclosingTestInstance ) { <EOL> testRunSettings = settings <EOL> testRunProvider = getOrCreateSimpleTestRunProvider ( ) <EOL> } <EOL> }


fun ExtensionContext . getOrCreateTestProcessSettings ( ) : TestProcessSettings

= <EOL> root . getStore ( NAMESPACE ) . getOrComputeIfAbsent ( TestProcessSettings :: class . java . name ) { <EOL> val nativeHome = computeNativeHome ( ) <EOL> System . setProperty ( "<STR_LIT>" , nativeHome . dir . path ) <EOL> setUpMemoryTracking ( ) <EOL> TestProcessSettings ( nativeHome , computeNativeClassLoader ( ) , computeBaseDirs ( ) , LLDB ( nativeHome ) ) <EOL> } as TestProcessSettings


fun computeNativeClassLoader ( parent : ClassLoader ? = null ) : KotlinNativeClassLoader

= KotlinNativeClassLoader ( lazy { <EOL> val nativeClassPath = ProcessLevelProperty . COMPILER_CLASSPATH . readValue ( ) <EOL> . split ( File . pathSeparatorChar ) <EOL> . map { File ( it ) . toURI ( ) . toURL ( ) } <EOL> . toTypedArray ( ) <EOL> URLClassLoader ( nativeClassPath , parent ) . apply { setDefaultAssertionStatus ( true ) } <EOL> } )

/**
 * - For Codegen native tests, no parent classloader should be provided,
 * since compiler `class K2Native: CLICompiler` is invoked via reflection with kotlinNativeClassLoader,
 * so both classes K2Native and CLICompiler need to be loaded with same nativeclassloader.
 * This way, `K2Native.doExecute()` method would define abstract method `CLICompiler.doExecute()`.
 * With parent classloader, these two classes would be loaded by different classloaders and AbstractMethodError is thrown
 * - For irText tests, classloaded mangler instance is passed to generate mangles to IR dumps files.
 * For this, a cast of mangler object(within K/N classloader) to mangler interface(within app classloader) is needed,
 * which is possible when app classloader is provided as parent.
 */


private fun ExtensionContext . addCommonTestClassSettingsTo ( enclosingTestClass : Class < * > , output : MutableCollection < Any > ) : KotlinNativeTargets

{ <EOL> val enforcedProperties = EnforcedProperties ( enclosingTestClass ) <EOL> val optimizationMode = computeOptimizationMode ( enforcedProperties ) <EOL> val threadStateChecker = computeThreadStateChecker ( enforcedProperties ) <EOL> if ( threadStateChecker == ThreadStateChecker . ENABLED ) { <EOL> assertEquals ( OptimizationMode . DEBUG , optimizationMode ) { <EOL> "<STR_LIT>" <EOL> } <EOL> } <EOL> val sanitizer = computeSanitizer ( enforcedProperties ) <EOL> val gcType = computeGCType ( enforcedProperties ) <EOL> val gcScheduler = computeGCScheduler ( enforcedProperties ) <EOL> val allocator = computeAllocator ( enforcedProperties ) <EOL> val nativeHome = getOrCreateTestProcessSettings ( ) . get < KotlinNativeHome > ( ) <EOL> val distribution = Distribution ( nativeHome . dir . path ) <EOL> val hostManager = HostManager ( ) <EOL> val nativeTargets = computeNativeTargets ( enforcedProperties , hostManager ) <EOL> val cacheMode = computeCacheMode ( enforcedProperties , distribution , nativeTargets , optimizationMode ) <EOL> if ( cacheMode != CacheMode . WithoutCache ) { <EOL> assertEquals ( ThreadStateChecker . DISABLED , threadStateChecker ) { <EOL> "<STR_LIT>" <EOL> } <EOL> assertEquals ( Sanitizer . NONE , sanitizer ) { <EOL> "<STR_LIT>" <EOL> } <EOL> } <EOL> output += optimizationMode <EOL> output += threadStateChecker <EOL> output += gcType <EOL> output += gcScheduler <EOL> output += allocator <EOL> output += nativeTargets <EOL> output += sanitizer <EOL> output += CacheMode :: class to cacheMode <EOL> output += computeTestMode ( enforcedProperties ) <EOL> output += computeCompilerPlugins ( enforcedProperties ) <EOL> output += computeCustomKlibs ( enforcedProperties ) <EOL> output += computeTestKind ( enforcedProperties ) <EOL> output += computeForcedNoopTestRunner ( enforcedProperties ) <EOL> output += computeSharedExecutionTestRunner ( enforcedProperties ) <EOL> output += computeTimeouts ( enforcedProperties ) <EOL> output += computePipelineType ( enforcedProperties , testClass . get ( ) ) <EOL> output += computeUsedPartialLinkageConfig ( enclosingTestClass ) <EOL> output += computeCompilerOutputInterceptor ( enforcedProperties ) <EOL> output += computeBinaryLibraryKind ( enforcedProperties ) <EOL> output += computeCInterfaceMode ( enforcedProperties ) <EOL> return nativeTargets <EOL> }


private fun ExtensionContext . getOrCreateTestClassSettings ( ) : TestClassSettings

= <EOL> root . getStore ( NAMESPACE ) . getOrComputeIfAbsent ( testClassKeyFor < TestClassSettings > ( ) ) { <EOL> val enclosingTestClass = enclosingTestClass <EOL> val testProcessSettings = getOrCreateTestProcessSettings ( ) <EOL> val computedTestConfiguration = computeTestConfiguration ( enclosingTestClass ) . run { <EOL> if ( TestGroupCreation . getFromProperty ( ) == TestGroupCreation . EAGER && configuration . providerClass == ExtTestCaseGroupProvider :: class ) { <EOL> val annotation = UseEagerExtTestCaseGroupProvider ( ) <EOL> val testConfiguration = annotation . annotationClass . findAnnotation < TestConfiguration > ( ) <EOL> ? : error ( "<STR_LIT>" ) <EOL> ComputedTestConfiguration ( testConfiguration , annotation ) <EOL> } else { <EOL> this <EOL> } <EOL> } <EOL> val settings = buildList { <EOL> val nativeTargets = addCommonTestClassSettingsTo ( enclosingTestClass , this ) <EOL> this += computedTestConfiguration <EOL> this += computeBinariesForBlackBoxTests ( testProcessSettings . get ( ) , nativeTargets , enclosingTestClass ) <EOL> computedTestConfiguration . configuration . requiredSettings . forEach { clazz -> <EOL> this += when ( clazz ) { <EOL> TestRoots :: class -> computeTestRoots ( enclosingTestClass ) <EOL> GeneratedSources :: class -> computeGeneratedSourceDirs ( testProcessSettings . get ( ) , nativeTargets , enclosingTestClass ) <EOL> DisabledTestDataFiles :: class -> computeDisabledTestDataFiles ( enclosingTestClass ) <EOL> else -> fail { "<STR_LIT>" } <EOL> } <EOL> } <EOL> } <EOL> TestClassSettings ( parent = testProcessSettings , settings ) <EOL> } as TestClassSettings

/*************** Test class settings (for black box tests only) ***************/


private fun computeBinariesForBlackBoxTests ( baseDirs : BaseDirs , targets : KotlinNativeTargets , enclosingTestClass : Class < * > ) : Binaries

{ <EOL> val testBinariesDir = baseDirs . testBuildDir <EOL> . resolve ( "<STR_LIT>" ) <EOL> . resolve ( "<STR_LIT>" ) <EOL> . ensureExistsAndIsEmptyDirectory ( ) <EOL> return Binaries ( testBinariesDir = testBinariesDir , lazySharedBinariesDir = { testBinariesDir . resolve ( SHARED_MODULES_DIR_NAME ) . ensureExistsAndIsEmptyDirectory ( ) } , lazyGivenBinariesDir = { testBinariesDir . resolve ( GIVEN_MODULES_DIR_NAME ) . ensureExistsAndIsEmptyDirectory ( ) } ) <EOL> }

/** See also [computeBinariesForSimpleTests] */


private fun ExtensionContext . getOrCreateSimpleTestClassSettings ( ) : SimpleTestClassSettings

= <EOL> root . getStore ( NAMESPACE ) . getOrComputeIfAbsent ( testClassKeyFor < SimpleTestClassSettings > ( ) ) { <EOL> SimpleTestClassSettings ( parent = getOrCreateTestProcessSettings ( ) , buildList { addCommonTestClassSettingsTo ( enclosingTestClass , this ) } ) <EOL> } as SimpleTestClassSettings


fun ExtensionContext . createTestRunSettings ( ) : TestRunSettings

{ <EOL> val testInstances = computeBlackBoxTestInstances ( ) <EOL> return TestRunSettings ( parent = getOrCreateTestClassSettings ( ) , listOfNotNull ( testInstances , ( testInstances . enclosingTestInstance as? ExternalSourceTransformersProvider ) ? . let { ExternalSourceTransformersProvider :: class to it } ) ) <EOL> }

/*************** Test run settings (for black box tests only) ***************/


fun ExtensionContext . createSimpleTestRunSettings ( ) : SimpleTestRunSettings

{ <EOL> val testClassSettings = getOrCreateSimpleTestClassSettings ( ) <EOL> return SimpleTestRunSettings ( parent = testClassSettings , listOf ( computeSimpleTestInstances ( ) , computeBinariesForSimpleTests ( testClassSettings . get ( ) , testClassSettings . get ( ) ) ) ) <EOL> }


private fun ExtensionContext . computeBinariesForSimpleTests ( baseDirs : BaseDirs , targets : KotlinNativeTargets ) : Binaries

{ <EOL> val compressedClassNames = testClasses . map ( Class < * > :: compressedSimpleName ) . joinToString ( separator = "<STR_LIT:_>" ) <EOL> val testBinariesDir = baseDirs . testBuildDir <EOL> . resolve ( "<STR_LIT:s>" ) <EOL> . resolve ( "<STR_LIT>" ) <EOL> . resolve ( requiredTestMethod . name ) <EOL> . ensureExistsAndIsEmptyDirectory ( ) <EOL> return Binaries ( testBinariesDir = testBinariesDir , lazySharedBinariesDir = { testBinariesDir . resolve ( SHARED_MODULES_DIR_NAME ) . ensureExistsAndIsEmptyDirectory ( ) } , lazyGivenBinariesDir = { testBinariesDir . resolve ( GIVEN_MODULES_DIR_NAME ) . ensureExistsAndIsEmptyDirectory ( ) } ) <EOL> }

/** See also [computeBinariesForBlackBoxTests] */


fun ExtensionContext . getOrCreateTestRunProvider ( ) : TestRunProvider

= <EOL> root . getStore ( NAMESPACE ) . getOrComputeIfAbsent ( testClassKeyFor < TestRunProvider > ( ) ) { <EOL> val testCaseGroupProvider = createTestCaseGroupProvider ( getOrCreateTestClassSettings ( ) . get ( ) ) <EOL> TestRunProvider ( testCaseGroupProvider ) <EOL> } as TestRunProvider

/*************** Test run provider (for black box tests only) ***************/


fun getOrCreateSimpleTestRunProvider ( ) : SimpleTestRunProvider

= SimpleTestRunProvider


fun compile ( allModules : Collection < IrModuleFragment > , dirtyFiles : Collection < IrFile > ) : List < ( ) -> JsIrProgramFragments >

/**
 * It is expected that the method implementation runs a lowering pipeline
 * and produces a list of generators capable of generating JS AST fragments.
 */


fun createCompilerForIC ( mainModule : IrModuleFragment , configuration : CompilerConfiguration ) : JsIrCompilerICInterface

/**
 * It is expected that the method implementation creates a backend context and initializes all builtins and intrinsics.
 */


fun actualizeCaches ( ) : List < ModuleArtifact >

{ <EOL> stopwatch . clear ( ) <EOL> dirtyFileStats . clear ( ) <EOL> val ( incrementalCachesArtifacts , moduleNames , generators ) = loadIrAndMakeIrFragmentGenerators ( ) <EOL> val rebuiltFragments = generateIrFragments ( generators ) <EOL> return commitCacheAndBuildModuleArtifacts ( incrementalCachesArtifacts , moduleNames , rebuiltFragments ) <EOL> }

/**
 * This method performs the following routine:
 * - Estimates dirty files that must be relowered;
 * - Creates a compiler instance by calling [compilerInterfaceFactory];
 * - Runs the compiler (lowering pipeline) for the dirty files (see [JsIrCompilerICInterface]);
 * - Transforms lowered IR to JS AST fragments [JsIrProgramFragments];
 * - Saves the cache data on the disk.
 *
 * @return A module artifact list, where [ModuleArtifact] represents a compiled klib.
 * It contains either paths to files with serialized JS AST or the deserialized [JsIrProgramFragments] objects themselves
 * for every file in the generating JS module. The list should be used for building the final JS module in [JsExecutableProducer]
 */


fun KtModule . getFirResolveSession ( project : Project ) : LLFirResolveSession

= <EOL> LLFirResolveSessionService . getInstance ( project ) . getFirResolveSession ( this )

/**
 * Returns [LLFirResolveSession] which corresponds to containing module
 */


fun KtDeclaration . resolveToFirSymbol ( firResolveSession : LLFirResolveSession , phase : FirResolvePhase = FirResolvePhase . RAW_FIR , ) : FirBasedSymbol < * >

{ <EOL> return firResolveSession . resolveToFirSymbol ( this , phase ) <EOL> }

/**
 * Creates [FirBasedSymbol] by [KtDeclaration] .
 * returned [FirDeclaration] will be resolved at least to [phase]
 *
 */


@ Suppress ( "<STR_LIT:INVISIBLE_REFERENCE>" , "<STR_LIT:INVISIBLE_MEMBER>" ) <EOL> inline fun < reified S : FirBasedSymbol < * > > KtDeclaration . resolveToFirSymbolOfType ( firResolveSession : LLFirResolveSession , phase : FirResolvePhase = FirResolvePhase . RAW_FIR , ) : @ kotlin . internal . NoInfer S

{ <EOL> val symbol = resolveToFirSymbol ( firResolveSession , phase ) <EOL> if ( symbol !is S ) { <EOL> throwUnexpectedFirElementError ( symbol , this , S :: class ) <EOL> } <EOL> return symbol <EOL> }

/**
 * Creates [FirBasedSymbol] by [KtDeclaration] .
 * returned [FirDeclaration] will be resolved at least to [phase]
 *
 * If resulted [FirBasedSymbol] is not subtype of [S], throws [InvalidFirElementTypeException]
 */


@ Suppress ( "<STR_LIT:INVISIBLE_REFERENCE>" , "<STR_LIT:INVISIBLE_MEMBER>" ) <EOL> inline fun < reified S : FirBasedSymbol < * > > KtDeclaration . resolveToFirSymbolOfTypeSafe ( firResolveSession : LLFirResolveSession , phase : FirResolvePhase = FirResolvePhase . RAW_FIR , ) : @ kotlin . internal . NoInfer S ?

{ <EOL> return resolveToFirSymbol ( firResolveSession , phase ) as? S <EOL> }

/**
 * Creates [FirBasedSymbol] by [KtDeclaration] .
 * returned [FirDeclaration] will be resolved at least to [phase]
 *
 * If resulted [FirBasedSymbol] is not subtype of [S], returns `null`
 */


fun KtElement . getDiagnostics ( firResolveSession : LLFirResolveSession , filter : DiagnosticCheckerFilter ) : Collection < KtPsiDiagnostic >

= <EOL> firResolveSession . getDiagnostics ( this , filter )

/**
 * Returns a list of Diagnostics compiler finds for given [KtElement]
 * This operation could be performance affective because it create FIleStructureElement and resolve non-local declaration into BODY phase
 */


fun KtFile . collectDiagnosticsForFile ( firResolveSession : LLFirResolveSession , filter : DiagnosticCheckerFilter ) : Collection < KtPsiDiagnostic >

= <EOL> firResolveSession . collectDiagnosticsForFile ( this , filter )

/**
 * Returns a list of Diagnostics compiler finds for given [KtFile]
 * This operation could be performance affective because it create FIleStructureElement and resolve non-local declaration into BODY phase
 */


fun KtElement . getOrBuildFir ( firResolveSession : LLFirResolveSession , ) : FirElement ?

= firResolveSession . getOrBuildFirFor ( this )

/**
 * Build [FirElement] node in its final resolved state for a requested element.
 *
 * Note: that it isn't always [BODY_RESOLVE][FirResolvePhase.BODY_RESOLVE]
 * as not all declarations have types/bodies/etc. to resolve.
 *
 * This operation could be time-consuming because it creates
 * [FileStructureElement][org.jetbrains.kotlin.analysis.low.level.api.fir.file.structure.FileStructureElement]
 * and may resolve non-local declarations into [BODY_RESOLVE][FirResolvePhase.BODY_RESOLVE] phase.
 *
 * Please use [getOrBuildFirFile] to get [FirFile] in undefined phase.
 *
 * @return associated [FirElement] in final resolved state if it exists.
 *
 * @see getOrBuildFirFile
 * @see LLFirResolveSession.getOrBuildFirFor
 */


inline fun < reified E : FirElement > KtElement . getOrBuildFirSafe ( firResolveSession : LLFirResolveSession , )

= getOrBuildFir ( firResolveSession ) as? E

/**
 * Get a [FirElement] which was created by [KtElement], but only if it is subtype of [E], `null` otherwise
 * Returned [FirElement] is guaranteed to be resolved to [FirResolvePhase.BODY_RESOLVE] phase
 * This operation could be performance affective because it create FIleStructureElement and resolve non-local declaration into BODY phase
 */


inline fun < reified E : FirElement > KtElement . getOrBuildFirOfType ( firResolveSession : LLFirResolveSession , ) : E

{ <EOL> val fir = getOrBuildFir ( firResolveSession ) <EOL> if ( fir is E ) return fir <EOL> throwUnexpectedFirElementError ( fir , this , E :: class ) <EOL> }

/**
 * Get a [FirElement] which was created by [KtElement], but only if it is subtype of [E], throws [InvalidFirElementTypeException] otherwise
 * Returned [FirElement] is guaranteed to be resolved to [FirResolvePhase.BODY_RESOLVE] phase
 * This operation could be performance affective because it create FIleStructureElement and resolve non-local declaration into BODY phase
 */


fun KtFile . getOrBuildFirFile ( firResolveSession : LLFirResolveSession ) : FirFile

= <EOL> firResolveSession . getOrBuildFirFile ( this )

/**
 * Get a [FirFile] which was created by [KtElement]
 * Returned [FirFile] can be resolved to any phase from [FirResolvePhase.RAW_FIR] to [FirResolvePhase.BODY_RESOLVE]
 */


public actual fun CharSequence . elementAt ( index : Int ) : Char

{ <EOL> return elementAtOrElse ( index ) { throw IndexOutOfBoundsException ( "<STR_LIT>" ) } <EOL> }

/**
 * Returns a character at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this char sequence.
 *
 * @sample samples.collections.Collections.Elements.elementAt
 */


override fun visitFunctionExpression ( expression : IrFunctionExpression )

{ <EOL> if ( expression . type . isSyntheticComposableFunction ( ) ) { <EOL> expression . function . mark ( ) <EOL> } <EOL> super . visitFunctionExpression ( expression ) <EOL> }

/**
 * This function propagates the special function type kind for composable to function expressions like lambda expression.
 */


override fun visitFunctionReference ( expression : IrFunctionReference )

{ <EOL> if ( expression . type . isSyntheticComposableFunction ( ) ) { <EOL> expression . symbol . owner . mark ( ) <EOL> } <EOL> super . visitFunctionReference ( expression ) <EOL> }

/**
 * This function propagates the special function type kind for composable to function references.
 */


public inline fun < P : KotlinComposableProvider , reified T : P > List < P > . mergeSpecificProviders ( factory : KotlinCompositeProviderFactory < P > , crossinline mergeTargets : ( List < T > ) -> P , ) : P

{ <EOL> return factory . createFlattened ( factory . flatten ( this ) . mergeOnly < _ , T > { mergeTargets ( it ) } ) <EOL> }

/**
 * Uses the given [factory] to merge all providers of type [T] with the given [mergeTargets] strategy. Other providers (not of type [T]) are
 * added to the resulting composite provider unmerged.
 */


fun KotlinLibraryLayoutImpl . extract ( file : File ) : File

= extract ( this . klib , file )

/**
 * This class and its children automatically extracts pieces of the library on first access. Use it if you need
 * to pass extracted files to an external tool. Otherwise, stick to [FromZipBaseLibraryImpl].
 */


fun multiPoseDetectionMoveNetLightAPI ( )

{ <EOL> val modelHub = ONNXModelHub ( cacheDirectory = File ( "<STR_LIT>" ) ) <EOL> val model = ONNXModels . PoseDetection . MoveNetMultiPoseLighting . pretrainedModel ( modelHub ) <EOL> model . printSummary ( ) <EOL> model . use { poseDetectionModel -> <EOL> val result = mutableMapOf < BufferedImage , MultiPoseDetectionResult > ( ) <EOL> for ( i in <NUM_LIT:1> .. <NUM_LIT:3> ) { <EOL> val image = ImageConverter . toBufferedImage ( getFileFromResource ( "<STR_LIT>" ) ) <EOL> val detectedPoses = poseDetectionModel . detectPoses ( image = image , confidence = <NUM_LIT> ) <EOL> detectedPoses . poses . forEach { ( bbox , pose ) -> <EOL> println ( "<STR_LIT>" ) <EOL> pose . landmarks . forEach { <EOL> println ( "<STR_LIT>" ) <EOL> } <EOL> pose . edges . forEach { <EOL> println ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> result [ image ] = detectedPoses <EOL> } <EOL> val panel = JPanel ( ) <EOL> panel . layout = BoxLayout ( panel , BoxLayout . PAGE_AXIS ) <EOL> val width = <NUM_LIT> <EOL> for ( ( image , detectedPoses ) in result ) { <EOL> val displayedImage = pipeline < BufferedImage > ( ) <EOL> . resize { outputWidth = width ; outputHeight = width * image . height / image . width } <EOL> . apply ( image ) <EOL> panel . add ( createMultipleDetectedPosesPanel ( displayedImage , detectedPoses ) ) <EOL> } <EOL> showFrame ( "<STR_LIT>" , panel ) <EOL> } <EOL> }

/**
 * This examples demonstrates the inference concept on MoveNetSinglePoseLighting model:
 * - Model is obtained from [ONNXModelHub].
 * - Model predicts on a few images located in resources.
 * - Special preprocessing is applied to each image before prediction.
 */


= multiPoseDetectionMoveNetLightAPI ( )


@ JvmStatic <EOL> fun ScriptHandler . configureBuildScript ( rootProject : Project )

{ <EOL> rootProject . checkRedirect ( repositories , "<STR_LIT>" ) <EOL> }

/**
 * Substitutes repositories in buildScript { } block.
 */


@ JvmStatic <EOL> fun configureJsPackageManagers ( project : Project )

{ <EOL> project . configureYarnAndNodeRedirects ( ) <EOL> }

/**
 * Configures JS-specific extensions to use
 */


@ JvmStatic <EOL> fun configureWasmNodeRepositories ( project : Project )

{ <EOL> val extension = project . extensions . findByType < NodeJsRootExtension > ( ) <EOL> if ( extension != null ) { <EOL> extension . nodeVersion = "<STR_LIT>" <EOL> extension . nodeDownloadBaseUrl = "<STR_LIT>" <EOL> } <EOL> project . tasks . withType < KotlinNpmInstallTask > ( ) . configureEach { <EOL> args . add ( "<STR_LIT>" ) <EOL> } <EOL> }

/**
 * Temporary repositories to depend on until GC milestone 4 in KGP
 * and stable Node release. Safe to remove when its removal does not break WASM tests.
 */


fun FunctionSymbolMarker . allOverriddenDeclarationsRecursive ( ) : Sequence < CallableSymbolMarker >

/**
 * Returns all symbols that are overridden by [this] symbol
 */


fun skipCheckingAnnotationsOfActualClassMember ( actualMember : DeclarationSymbolMarker ) : Boolean

/**
 * Determines whether it is needed to skip checking annotations on class member in [AbstractExpectActualAnnotationMatchChecker].
 *
 * This is needed to prevent checking member twice if it is real `actual` member (not fake override or member of
 * class being typealiased).
 * Example:
 * ```
 * actual class A {
 * actual fun foo() {} // 1: checked itself, 2: checked as member of A
 * }
 * ```
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> fun KCallable < * > . findParameterByName ( name : String ) : KParameter ?

{ <EOL> return parameters . singleOrNull { it . name == name } <EOL> }

/**
 * Returns the parameter of this callable with the given name, or `null` if there's no such parameter.
 */


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> suspend fun < R > KCallable < R > . callSuspend ( vararg args : Any ? ) : R

{ <EOL> if ( ! this . isSuspend ) return call ( * args ) <EOL> if ( this !is KFunction < * > ) throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> val result = suspendCoroutineUninterceptedOrReturn < R > { call ( * args , it ) } <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> if ( returnType . classifier == Unit :: class && ! returnType . isMarkedNullable ) return ( Unit as R ) <EOL> return result <EOL> }

/**
 * Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.call].
 * Otherwise, calls the suspend function with current continuation.
 */


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> suspend fun < R > KCallable < R > . callSuspendBy ( args : Map < KParameter , Any ? > ) : R

{ <EOL> if ( ! this . isSuspend ) return callBy ( args ) <EOL> if ( this !is KFunction < * > ) throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> val kCallable = asKCallableImpl ( ) ? : throw KotlinReflectionInternalError ( "<STR_LIT>" ) <EOL> val result = suspendCoroutineUninterceptedOrReturn < R > { kCallable . callDefaultMethod ( args , it ) } <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> if ( returnType . classifier == Unit :: class && ! returnType . isMarkedNullable ) return ( Unit as R ) <EOL> return result <EOL> }

/**
 * Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.callBy].
 * Otherwise, calls the suspend function with current continuation.
 */


@ Test <EOL> fun testSchedulerDisposed ( ) : Unit

= runTest { <EOL> val dispatcher = currentDispatcher ( ) as CoroutineDispatcher <EOL> val scheduler = dispatcher . asScheduler ( ) <EOL> testRunnableDisposed ( scheduler :: scheduleDirect ) <EOL> }

/**
 * Test that we don't get an OOM if we schedule many jobs at once.
 * It's expected that if you don't dispose you'd see an OOM error.
 */


{ <EOL> Thread . sleep ( a . size / ( a . size + <NUM_LIT:1> ) + <NUM_LIT> ) <EOL> }

/**
 * Test function that holds a reference. Used for testing OOM situations
 */


@ Test <EOL> fun testSchedulerDisposedDuringDelay ( ) : Unit

= runTest { <EOL> val dispatcher = currentDispatcher ( ) as CoroutineDispatcher <EOL> val scheduler = dispatcher . asScheduler ( ) <EOL> testRunnableDisposedDuringDelay ( scheduler :: scheduleDirect ) <EOL> }

/**
 * Test that we don't get an OOM if we schedule many delayed jobs at once. It's expected that if you don't dispose that you'd
 * see a OOM error.
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public fun < T : Number , D : Dimension > Math . cos ( a : MultiArray < T , D > ) : NDArray < Double , D >

= this . mathEx . cos ( a )

/**
 * Returns a ndarray of Double from the given ndarray to each element of which a cos function has been applied.
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public fun < D : Dimension > Math . cos ( a : MultiArray < Float , D > ) : NDArray < Float , D >

= this . mathEx . cosF ( a )

/**
 * Returns a ndarray of Float from the given ndarray to each element of which a cos function has been applied.
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public fun < D : Dimension > Math . cos ( a : MultiArray < ComplexFloat , D > ) : NDArray < ComplexFloat , D >

= this . mathEx . cosCF ( a )

/**
 * Returns a ndarray of [ComplexFloat] from the given ndarray to each element of which a cos function has been applied.
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public fun < D : Dimension > Math . cos ( a : MultiArray < ComplexDouble , D > ) : NDArray < ComplexDouble , D >

= this . mathEx . cosCD ( a )

/**
 * Returns a ndarray of [ComplexDouble] from the given ndarray to each element of which a cos function has been applied.
 */


/**
 * [test.<caret_1>function]
 * [<caret_2>function]
 *
 * [Base.<caret_3>function]
 * [test.Base.<caret_4>function]
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun < T > java . util . Enumeration < T > . asSequence ( ) : Sequence < T >

= this . iterator ( ) . asSequence ( )

/**
 * Creates a sequence that returns all values from this enumeration. The sequence is constrained to be iterated only once.
 * @sample samples.collections.Sequences.Building.sequenceFromEnumeration
 */


@ SinceKotlin ( "<STR_LIT:1.6>" ) <EOL> @ WasExperimental ( ExperimentalTime :: class ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun Duration . toJavaDuration ( ) : java . time . Duration

= <EOL> toComponents { seconds , nanoseconds -> java . time . Duration . ofSeconds ( seconds , nanoseconds . toLong ( ) ) }

/**
 * Converts [kotlin.time.Duration][Duration] value to [java.time.Duration][java.time.Duration] value.
 *
 * An infinite duration is converted to either [Long.MAX_VALUE], or [Long.MIN_VALUE] seconds, depending on its sign.
 */


= runTest { <EOL> val sh = emptyFlow < Int > ( ) . shareIn ( this , SharingStarted . Eagerly ) <EOL> assertTrue ( sh !is MutableSharedFlow < * > ) <EOL> assertSame ( sh , ( sh as Flow < * > ) . cancellable ( ) ) <EOL> assertSame ( sh , ( sh as Flow < * > ) . flowOn ( Dispatchers . Default ) ) <EOL> assertSame ( sh , sh . buffer ( Channel . RENDEZVOUS ) ) <EOL> coroutineContext . cancelChildren ( ) <EOL> }

/**
 * Test perfect fusion for operators **after** [shareIn].
 */


@ Test <EOL> fun testChannelFlowBufferShareIn ( )

= runTest { <EOL> expect ( <NUM_LIT:1> ) <EOL> val flow = channelFlow { <EOL> for ( i in <NUM_LIT:1> .. <NUM_LIT:10> ) { <EOL> assertTrue ( trySend ( i ) . isSuccess ) <EOL> } <EOL> send ( <NUM_LIT:0> ) <EOL> } . buffer ( <NUM_LIT:10> ) <EOL> val shared = flow . shareIn ( this , SharingStarted . Eagerly ) <EOL> shared <EOL> . takeWhile { it > <NUM_LIT:0> } <EOL> . collect { i -> expect ( i + <NUM_LIT:1> ) } <EOL> finish ( <NUM_LIT:12> ) <EOL> }

/**
 * Tests that `channelFlow { ... }.buffer(x)` works according to the [channelFlow] docs, and subsequent
 * application of [shareIn] does not leak upstream.
 */


private fun < T > T . annotationsForTransformationTo ( map : MutableMap < FirElementWithResolveState , List < FirAnnotation > > , ) where T : FirAnnotationContainer , T : FirElementWithResolveState

{ <EOL> when ( this ) { <EOL> is FirFunction -> { <EOL> valueParameters . forEach { <EOL> it . annotationsForTransformationTo ( map ) <EOL> } <EOL> } <EOL> is FirProperty -> { <EOL> getter ? . annotationsForTransformationTo ( map ) <EOL> setter ? . annotationsForTransformationTo ( map ) <EOL> backingField ? . annotationsForTransformationTo ( map ) <EOL> } <EOL> } <EOL> if ( annotations . isEmpty ( ) ) return <EOL> var hasApplicableAnnotation = false <EOL> val containerForAnnotations = ArrayList < FirAnnotation > ( annotations . size ) <EOL> for ( annotation in annotations ) { <EOL> val userTypeRef = ( annotation as? FirAnnotationCall ) ? . annotationTypeRef as? FirUserTypeRef <EOL> containerForAnnotations += if ( userTypeRef != null && transformer . annotationTransformer . shouldRunAnnotationResolve ( userTypeRef ) ) { <EOL> hasApplicableAnnotation = true <EOL> buildAnnotationCallCopy ( annotation ) { <EOL> annotationTypeRef = transformer . annotationTransformer . createDeepCopyOfTypeRef ( userTypeRef ) <EOL> if ( FirLazyBodiesCalculator . needCalculatingAnnotationCall ( annotation ) ) { <EOL> argumentList = FirLazyBodiesCalculator . calculateLazyArgumentsForAnnotation ( annotation , llFirSession ) <EOL> } <EOL> } <EOL> } else { <EOL> annotation <EOL> } <EOL> } <EOL> if ( hasApplicableAnnotation ) { <EOL> map [ this ] = containerForAnnotations <EOL> } <EOL> }

/**
 * @return true if at least one applicable annotation is present
 */


public abstract fun KtAnalysisSession . getNavigationTargets ( element : KtElement ) : Collection < PsiElement >

/**
 * Provides a [PsiElement] which will be opened on a navigation request for [element].
 *
 * Usually returns a single result. Might return an empty collection if there is no navigation target.
 * Also, might multiple targets in a case of ambiguity or multiple targets for a [symbol]
 *
 * Returned [PsiElement] will be used as a navigation target inside the IDE.
 */


internal fun IrModuleFragment . stubOrphanedExpectSymbols ( stubGenerator : DeclarationStubGenerator )

{ <EOL> val transformer = StubOrphanedExpectSymbolTransformer ( stubGenerator ) <EOL> files . forEach ( transformer :: visitFile ) <EOL> }

/**
 * Replaces `expect` symbols for which no `actual` counterpart exists with an `actual` stub in all files of the [IrModuleFragment]. The
 * implementation keeps track of generated stubs and only generates a single stub for each unique `expect` symbol.
 *
 * [stubOrphanedExpectSymbols] is used by the IDE bytecode tool window to allow compiling source files with `expect` declarations for which
 * the compiled module has no `actual` declaration. (The `actual` declaration would be defined in a module dependent on the compiled
 * module, but choosing this module is non-trivial due to possibly multiple implementations of the same `expect` symbol. In addition, when
 * generating bytecode for a single source file, the number of source files to compile should be kept low. Stubbing helps with that.)
 */


override fun isTargetDeclaration ( declaration : IrDeclaration ) : Boolean

= <EOL> super . isTargetDeclaration ( declaration ) || <EOL> declaration is IrSimpleFunction && declaration . correspondingPropertySymbol ? . owner ? . isExpect == true

/**
 * Property getters and setters are not marked as `isExpect` even if the corresponding property is. However, we still need to stub such
 * getters and setters, so [isTargetDeclaration] allows it.
 */


private fun MemberDescriptor . isOrphanedExpect ( ) : Boolean

= findCompatibleActualsForExpected ( module ) . isEmpty ( )

/**
 * If an `actual` symbol exists, we shouldn't stub the `expect` symbol. This will be performed by
 * [org.jetbrains.kotlin.backend.common.lower.ExpectDeclarationsRemoveLowering] during lowering.
 */


private fun IrDeclaration . ensureClassParent ( descriptor : MemberDescriptor )

{ <EOL> if ( parent !is IrClass ) { <EOL> parent = stubGenerator . generateOrGetFacadeClass ( descriptor ) ? : return <EOL> } <EOL> }

/**
 * [descriptor] should be the original descriptor, because the copied `actual` descriptor has no source.
 */


= first > last

/**
 * Checks if the range is empty.

 * The range is empty if its start value is greater than the end value.
 */


= if ( step > <NUM_LIT:0> ) first > last else first < last

/**
 * Checks if the progression is empty.

 * Progression with a positive step is empty if its first element is greater than the last element.
 * Progression with a negative step is empty if its first element is less than the last element.
 */


public fun fromClosedRange ( rangeStart : UInt , rangeEnd : UInt , step : Int ) : UIntProgression

= UIntProgression ( rangeStart , rangeEnd , step )

/**
 * Creates UIntProgression within the specified bounds of a closed range.

 * The progression starts with the [rangeStart] value and goes toward the [rangeEnd] value not excluding it, with the specified [step].
 * In order to go backwards the [step] must be negative.
 *
 * [step] must be greater than `Int.MIN_VALUE` and not equal to zero.
 */


internal fun addBuildEventsListenerRegistryMock ( project : Project )

{ <EOL> val executedExtensionKey = "<STR_LIT>" <EOL> try { <EOL> if ( project . findExtension < Boolean > ( executedExtensionKey ) == true ) return <EOL> val projectScopeServices = ( project as DefaultProject ) . services as ProjectScopeServices <EOL> val state : Field = ProjectScopeServices :: class . java . superclass . getDeclaredField ( "<STR_LIT>" ) <EOL> state . isAccessible = true <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> val stateValue : AtomicReference < Any > = state . get ( projectScopeServices ) as AtomicReference < Any > <EOL> val enumClass = Class . forName ( DefaultServiceRegistry :: class . java . name + "<STR_LIT>" ) <EOL> stateValue . set ( enumClass . enumConstants [ <NUM_LIT:0> ] ) <EOL> projectScopeServices . add ( BuildEventsListenerRegistry :: class . java , BuildEventsListenerRegistryMock ) <EOL> stateValue . set ( enumClass . enumConstants [ <NUM_LIT:1> ] ) <EOL> project . addExtension ( executedExtensionKey , true ) <EOL> } catch ( e : Throwable ) { <EOL> throw RuntimeException ( e ) <EOL> } <EOL> }

/**
 * In Gradle 6.7-rc-1 BuildEventsListenerRegistry service is not created in we need it in order
 * to instantiate AGP. This creates a fake one and injects it - http://b/168630734.
 * https://github.com/gradle/gradle/issues/16774 (Waiting for Gradle 7.5)
 */


internal expect fun < K , V > createMapForCache ( initialCapacity : Int ) : MutableMap < K , V >

/**
 * Creates a ConcurrentHashMap on JVM and regular HashMap on other platforms.
 * To make actual use of cache in Kotlin/Native, mark a top-level object with this map
 * as a @[ThreadLocal].
 */


public fun ColumnSet < * > . colsAtAnyDepth ( predicate : ColumnFilter < * > = { true } ) : ColumnSet < * >

= <EOL> colsAtAnyDepthInternal ( predicate )

/**
 * @include [CommonAtAnyDepthDocs]
 * @set [CommonAtAnyDepthDocs.Examples]
 *
 * `df.`[select][DataFrame.select]` { `[colGroups][ColumnsSelectionDsl.colGroups]`().`[colsAtAnyDepth][ColumnsSelectionDsl.colsAtAnyDepth]` { "Alice" `[in][Iterable.contains]` it.`[values][DataColumn.values]`() } }`
 */


public fun ColumnsSelectionDsl < * > . colsAtAnyDepth ( predicate : ColumnFilter < * > = { true } ) : ColumnSet < * >

= <EOL> asSingleColumn ( ) . colsAtAnyDepthInternal ( predicate )

/**
 * @include [CommonAtAnyDepthDocs]
 * @set [CommonAtAnyDepthDocs.Examples]
 *
 * `df.`[select][DataFrame.select]` { `[colsAtAnyDepth][ColumnsSelectionDsl.colsAtAnyDepth]` { "Alice" `[in][Iterable.contains]` it.`[values][DataColumn.values]`() }.`[first][ColumnsSelectionDsl.first]`() }`
 *
 * `df.`[select][DataFrame.select]` { `[colsAtAnyDepth][ColumnsSelectionDsl.colsAtAnyDepth]` { !it.`[isColumnGroup][DataColumn.isColumnGroup]` } }`
 */


public fun SingleColumn < DataRow < * > > . colsAtAnyDepth ( predicate : ColumnFilter < * > = { true } ) : ColumnSet < * >

= <EOL> ensureIsColumnGroup ( ) . colsAtAnyDepthInternal ( predicate )

/**
 * @include [CommonAtAnyDepthDocs]
 * @set [CommonAtAnyDepthDocs.Examples]
 *
 * `df.`[select][DataFrame.select]` { myColGroup.`[colsAtAnyDepth][SingleColumn.colsAtAnyDepth]` { "Alice" `[in][Iterable.contains]` it.`[values][DataColumn.values]`() } }`
 */


public fun String . colsAtAnyDepth ( predicate : ColumnFilter < * > = { true } ) : ColumnSet < * >

= <EOL> columnGroup ( this ) . colsAtAnyDepth ( predicate )

/**
 * @include [CommonAtAnyDepthDocs]
 * @set [CommonAtAnyDepthDocs.Examples]
 *
 * `df.`[select][DataFrame.select]` { "myColumnGroup".`[colsAtAnyDepth][String.colsAtAnyDepth]` { "Alice" `[in][Iterable.contains]` it.`[values][DataColumn.values]`() } }`
 */


public fun KProperty < * > . colsAtAnyDepth ( predicate : ColumnFilter < * > = { true } ) : ColumnSet < * >

/**
 * @include [CommonAtAnyDepthDocs]
 * @set [CommonAtAnyDepthDocs.Examples]
 *
 * `df.`[select][DataFrame.select]` { Type::myColumnGroup.`[colsAtAnyDepth][KProperty.colsAtAnyDepth]` { "Alice" `[in][Iterable.contains]` it.`[values][DataColumn.values]`() } }`
 */


public fun ColumnPath . colsAtAnyDepth ( predicate : ColumnFilter < * > = { true } ) : ColumnSet < * >

/**
 * @include [CommonAtAnyDepthDocs]
 * @set [CommonAtAnyDepthDocs.Examples]
 *
 * `df.`[select][DataFrame.select]` { "pathTo"["myGroupCol"].`[colsAtAnyDepth][ColumnsSelectionDsl.colsAtAnyDepth]` { "Alice" `[in][Iterable.contains]` it.`[values][DataColumn.values]`() } }`
 */


internal fun ColumnsResolver < * > . colsAtAnyDepthInternal ( predicate : ColumnFilter < * > ) : ColumnSet < * >

= <EOL> colsInternal ( predicate ) <EOL> . atAnyDepthImpl ( includeTopLevel = true , includeGroups = true )

/**
 * Returns all columns inside this [ColumnsResolver] at any depth if they satisfy the
 * given predicate.
 */


fun kotlinxImmutable ( name : String ? = null ) : String

{ <EOL> return listOfNotNull ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , name ) . joinToString ( "<STR_LIT:.>" ) <EOL> }

/**
 * Required because :kotlin-compiler-embeddable performs package relocation
 * If there's a "kotlinx.collections.immutable" string literal in bytecode
 * it becomes "org.jetbrains.kotlin.kotlinx.collections.immutable" thus
 * breaking target project class name matching
 */


internal fun collectGeneralConfigurationTimeMetrics ( project : Project , gradle : Gradle , buildReportOutputs : List < BuildReportType > , useClasspathSnapshot : Boolean , pluginVersion : String , isProjectIsolationEnabled : Boolean , isProjectIsolationRequested : Boolean , isConfigurationCacheRequested : Boolean ) : MetricContainer

{ <EOL> val configurationTimeMetrics = MetricContainer ( ) <EOL> val statisticOverhead = measureTimeMillis { <EOL> configurationTimeMetrics . put ( StringMetrics . KOTLIN_COMPILER_VERSION , pluginVersion ) <EOL> configurationTimeMetrics . put ( StringMetrics . USE_CLASSPATH_SNAPSHOT , useClasspathSnapshot . toString ( ) ) <EOL> buildReportOutputs . forEach { <EOL> when ( it ) { <EOL> BuildReportType . BUILD_SCAN -> configurationTimeMetrics . put ( BooleanMetrics . BUILD_SCAN_BUILD_REPORT , true ) <EOL> BuildReportType . FILE -> configurationTimeMetrics . put ( BooleanMetrics . FILE_BUILD_REPORT , true ) <EOL> BuildReportType . HTTP -> configurationTimeMetrics . put ( BooleanMetrics . HTTP_BUILD_REPORT , true ) <EOL> BuildReportType . SINGLE_FILE -> configurationTimeMetrics . put ( BooleanMetrics . SINGLE_FILE_BUILD_REPORT , true ) <EOL> BuildReportType . TRY_NEXT_CONSOLE -> { } <EOL> BuildReportType . JSON -> configurationTimeMetrics . put ( BooleanMetrics . JSON_BUILD_REPORT , true ) <EOL> } <EOL> } <EOL> configurationTimeMetrics . put ( StringMetrics . PROJECT_PATH , project . rootDir . absolutePath ) <EOL> configurationTimeMetrics . put ( StringMetrics . GRADLE_VERSION , gradle . gradleVersion ) <EOL> if ( ! isProjectIsolationEnabled ) { <EOL> gradle . taskGraph . whenReady { taskExecutionGraph -> <EOL> val executedTaskNames = taskExecutionGraph . allTasks . map { it . name } . distinct ( ) <EOL> configurationTimeMetrics . put ( BooleanMetrics . MAVEN_PUBLISH_EXECUTED , executedTaskNames . contains ( "<STR_LIT>" ) ) <EOL> } <EOL> } <EOL> configurationTimeMetrics . put ( BooleanMetrics . GRADLE_CONFIGURATION_CACHE_ENABLED , isConfigurationCacheRequested ) <EOL> configurationTimeMetrics . put ( BooleanMetrics . GRADLE_PROJECT_ISOLATION_ENABLED , isProjectIsolationRequested ) <EOL> } <EOL> configurationTimeMetrics . put ( NumericalMetrics . STATISTICS_VISIT_ALL_PROJECTS_OVERHEAD , statisticOverhead ) <EOL> return configurationTimeMetrics <EOL> }

/**
 * Collect general configuration metrics
 **/


internal fun collectProjectConfigurationTimeMetrics ( project : Project , ) : MetricContainer

{ <EOL> val configurationTimeMetrics = MetricContainer ( ) <EOL> val statisticOverhead = measureTimeMillis { <EOL> collectAppliedPluginsStatistics ( project , configurationTimeMetrics ) <EOL> val configurations = project . configurations . asMap . values <EOL> for ( configuration in configurations ) { <EOL> try { <EOL> val configurationName = configuration . name <EOL> val dependencies = configuration . dependencies <EOL> when ( configurationName ) { <EOL> "<STR_LIT>" -> { <EOL> configurationTimeMetrics . put ( BooleanMetrics . ENABLED_KOVER , true ) <EOL> } <EOL> "<STR_LIT>" -> { <EOL> configurationTimeMetrics . put ( BooleanMetrics . ENABLED_KAPT , true ) <EOL> for ( dependency in dependencies ) { <EOL> when ( dependency . group ) { <EOL> "<STR_LIT>" -> configurationTimeMetrics . put ( BooleanMetrics . ENABLED_DAGGER , true ) <EOL> "<STR_LIT>" -> configurationTimeMetrics . put ( BooleanMetrics . ENABLED_DATABINDING , true ) <EOL> } <EOL> } <EOL> } <EOL> API -> { <EOL> configurationTimeMetrics . put ( NumericalMetrics . CONFIGURATION_API_COUNT , <NUM_LIT:1> ) <EOL> reportLibrariesVersions ( configurationTimeMetrics , dependencies ) <EOL> } <EOL> IMPLEMENTATION -> { <EOL> configurationTimeMetrics . put ( NumericalMetrics . CONFIGURATION_IMPLEMENTATION_COUNT , <NUM_LIT:1> ) <EOL> reportLibrariesVersions ( configurationTimeMetrics , dependencies ) <EOL> } <EOL> COMPILE -> { <EOL> configurationTimeMetrics . put ( NumericalMetrics . CONFIGURATION_COMPILE_COUNT , <NUM_LIT:1> ) <EOL> reportLibrariesVersions ( configurationTimeMetrics , dependencies ) <EOL> } <EOL> COMPILE_ONLY -> { <EOL> configurationTimeMetrics . put ( NumericalMetrics . CONFIGURATION_COMPILE_ONLY_COUNT , <NUM_LIT:1> ) <EOL> reportLibrariesVersions ( configurationTimeMetrics , dependencies ) <EOL> } <EOL> RUNTIME -> { <EOL> configurationTimeMetrics . put ( NumericalMetrics . CONFIGURATION_RUNTIME_COUNT , <NUM_LIT:1> ) <EOL> reportLibrariesVersions ( configurationTimeMetrics , dependencies ) <EOL> } <EOL> RUNTIME_ONLY -> { <EOL> configurationTimeMetrics . put ( NumericalMetrics . CONFIGURATION_RUNTIME_ONLY_COUNT , <NUM_LIT:1> ) <EOL> reportLibrariesVersions ( configurationTimeMetrics , dependencies ) <EOL> } <EOL> } <EOL> } catch ( e : Throwable ) { <EOL> } <EOL> } <EOL> configurationTimeMetrics . put ( NumericalMetrics . NUMBER_OF_SUBPROJECTS , <NUM_LIT:1> ) <EOL> configurationTimeMetrics . put ( BooleanMetrics . KOTLIN_KTS_USED , project . buildscript . sourceFile ? . name ? . endsWith ( "<STR_LIT>" ) ? : false ) <EOL> addTaskMetrics ( project , configurationTimeMetrics ) <EOL> if ( project . name == "<STR_LIT>" ) { <EOL> configurationTimeMetrics . put ( NumericalMetrics . BUILD_SRC_COUNT , <NUM_LIT:1> ) <EOL> configurationTimeMetrics . put ( BooleanMetrics . BUILD_SRC_EXISTS , true ) <EOL> } <EOL> } <EOL> configurationTimeMetrics . put ( NumericalMetrics . STATISTICS_VISIT_ALL_PROJECTS_OVERHEAD , statisticOverhead ) <EOL> return configurationTimeMetrics <EOL> }

/**
 * Collect project's configuration metrics including applied plugins. It should be called inside afterEvaluate block.
 */


@ KtAllowAnalysisOnEdt <EOL> public inline fun < T > allowAnalysisOnEdt ( action : ( ) -> T ) : T

{ <EOL> if ( KtReadActionConfinementLifetimeToken . allowOnEdt . get ( ) ) return action ( ) <EOL> KtReadActionConfinementLifetimeToken . allowOnEdt . set ( true ) <EOL> try { <EOL> return action ( ) <EOL> } finally { <EOL> KtReadActionConfinementLifetimeToken . allowOnEdt . set ( false ) <EOL> } <EOL> }

/**
 * @see KtAnalysisSession
 * @see KtReadActionConfinementLifetimeToken
 */


@ KtAllowAnalysisFromWriteAction <EOL> @ KtAllowProhibitedAnalyzeFromWriteAction <EOL> public inline fun < T > allowAnalysisFromWriteAction ( action : ( ) -> T ) : T

{ <EOL> if ( KtReadActionConfinementLifetimeToken . allowFromWriteAction . get ( ) ) return action ( ) <EOL> KtReadActionConfinementLifetimeToken . allowFromWriteAction . set ( true ) <EOL> try { <EOL> return action ( ) <EOL> } finally { <EOL> KtReadActionConfinementLifetimeToken . allowFromWriteAction . set ( false ) <EOL> } <EOL> }

/**
 * Analysis is not supposed to be called from write action.
 * Such actions can lead to IDE freezes and incorrect behavior in some cases.
 *
 * There is no guarantee that PSI changes will be reflected in an Analysis API world inside
 * one [analyze] session.
 * Example:
 * ```
 * // code to be analyzed
 * fun foo(): Int = 0
 *
 * // use case code
 * fun useCase() {
 * analyse(function) {
 * // 'getConstantFromExpressionBody' is an imaginary function
 * val valueBefore = function.getConstantFromExpressionBody() // valueBefore is 0
 *
 * changeExpressionBodyTo(1) // now function will looks like `fun foo(): Int = 1`
 * val valueAfter = function.getConstantFromExpressionBody() // Wrong way: valueAfter is not guarantied to be '1'
 * }
 *
 * analyse(function) {
 * val valueAfter = function.getConstantFromExpressionBody() // OK: valueAfter is guarantied to be '1'
 * }
 * }
 * ```
 *
 * @see KtAnalysisSession
 * @see KtReadActionConfinementLifetimeToken
 */


fun runJvmCompilerAsync ( args : K2JVMCompilerArguments , environment : GradleCompilerEnvironment , jdkHome : File , taskOutputsBackup : TaskOutputsBackup ? , ) : WorkQueue ?

{ <EOL> if ( args . jdkHome == null && ! args . noJdk ) args . jdkHome = jdkHome . absolutePath <EOL> loggerProvider . kotlinInfo ( "<STR_LIT>" ) <EOL> return runCompilerAsync ( KotlinCompilerClass . JVM , args , environment , taskOutputsBackup ) <EOL> }

/**
 * Compiler might be executed asynchronously. Do not do anything requiring end of compilation after this function is called.
 * @see [GradleKotlinCompilerWork]
 */


fun runJsCompilerAsync ( args : K2JSCompilerArguments , environment : GradleCompilerEnvironment , taskOutputsBackup : TaskOutputsBackup ? , ) : WorkQueue ?

{ <EOL> return runCompilerAsync ( KotlinCompilerClass . JS , args , environment , taskOutputsBackup ) <EOL> }


fun runMetadataCompilerAsync ( args : K2MetadataCompilerArguments , environment : GradleCompilerEnvironment , ) : WorkQueue ?

{ <EOL> return runCompilerAsync ( KotlinCompilerClass . METADATA , args , environment ) <EOL> }


internal fun setupAttributesMatchingStrategy ( attributesSchema : AttributesSchema )

{ <EOL> attributesSchema . attribute ( attribute ) <EOL> }

/**
 * Sets up the attributes matching strategy for the given attributes schema.
 *
 * @param attributesSchema The attributes schema to set up the matching strategy for.
 */


internal fun setupTransform ( project : Project )

{ <EOL> project . dependencies . artifactTypes . maybeCreate ( "<STR_LIT>" ) . also { artifactType -> <EOL> artifactType . attributes . setAttribute ( attribute , KotlinNativeBundleArtifactsTypes . ARCHIVE ) <EOL> } <EOL> project . dependencies . artifactTypes . maybeCreate ( "<STR_LIT>" ) . also { artifactType -> <EOL> artifactType . attributes . setAttribute ( attribute , KotlinNativeBundleArtifactsTypes . ARCHIVE ) <EOL> } <EOL> project . dependencies . registerTransform ( UnzipTransformationAction :: class . java ) { transform -> <EOL> transform . from . setAttribute ( attribute , KotlinNativeBundleArtifactsTypes . ARCHIVE ) <EOL> transform . to . setAttribute ( attribute , KotlinNativeBundleArtifactsTypes . DIRECTORY ) <EOL> } <EOL> }

/**
 * Sets up the necessary transformations for handling artifact types "tar.gz" and "zip" in the given project.
 *
 * @param project The project in which to set up the transformations.
 */


@ Test <EOL> fun shouldAssertEnumDocumentationHasNotChanged ( )

{ <EOL> val sourcesLink = "<STR_LIT>" <EOL> val sources = URL ( sourcesLink ) . readText ( ) <EOL> val expectedValuesDoc = <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" <EOL> check ( sources . contains ( expectedValuesDoc ) ) <EOL> val expectedValueOfDoc = <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" <EOL> check ( sources . contains ( expectedValueOfDoc ) ) <EOL> }

/**
 * Documentation for Enum's synthetic values() and valueOf() functions is only present in source code,
 * but not present in the descriptors. However, Dokka needs to generate documentation for these functions,
 * so it ships with hardcoded kdoc templates.
 *
 * This test exists to make sure documentation for these hardcoded synthetic functions does not change,
 * and fails if it does, indicating that it needs to be updated.
 */


fun bind ( owner : Owner )

/**
 * Sets this symbol's owner.
 *
 * Throws [IllegalStateException] if this symbol has already been bound.
 */


public fun sourceIterator ( ) : Iterator < T >

/** Returns an [Iterator] over the elements of the source of this grouping. */


public fun keyOf ( element : T ) : K

/** Extracts the key of an [element]. */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> public inline fun < T , K , R > Grouping < T , K > . aggregate ( operation : ( key : K , accumulator : R ? , element : T , first : Boolean ) -> R ) : Map < K , R >

{ <EOL> return aggregateTo ( mutableMapOf < K , R > ( ) , operation ) <EOL> }

/**
 * Groups elements from the [Grouping] source by key and applies [operation] to the elements of each group sequentially,
 * passing the previously accumulated value and the current element as arguments, and stores the results in a new map.
 *
 * The key for each element is provided by the [Grouping.keyOf] function.
 *
 * @param operation function is invoked on each element with the following parameters:
 * - `key`: the key of the group this element belongs to;
 * - `accumulator`: the current value of the accumulator of the group, can be `null` if it's the first `element` encountered in the group;
 * - `element`: the element from the source being aggregated;
 * - `first`: indicates whether it's the first `element` encountered in the group.
 *
 * @return a [Map] associating the key of each group with the result of aggregation of the group elements.
 * @sample samples.collections.Grouping.aggregateByRadix
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> public inline fun < T , K , R , M : MutableMap < in K , R > > Grouping < T , K > . aggregateTo ( destination : M , operation : ( key : K , accumulator : R ? , element : T , first : Boolean ) -> R ) : M

{ <EOL> for ( e in this . sourceIterator ( ) ) { <EOL> val key = keyOf ( e ) <EOL> val accumulator = destination [ key ] <EOL> destination [ key ] = operation ( key , accumulator , e , accumulator == null && ! destination . containsKey ( key ) ) <EOL> } <EOL> return destination <EOL> }

/**
 * Groups elements from the [Grouping] source by key and applies [operation] to the elements of each group sequentially,
 * passing the previously accumulated value and the current element as arguments,
 * and stores the results in the given [destination] map.
 *
 * The key for each element is provided by the [Grouping.keyOf] function.
 *
 * @param operation a function that is invoked on each element with the following parameters:
 * - `key`: the key of the group this element belongs to;
 * - `accumulator`: the current value of the accumulator of the group, can be `null` if it's the first `element` encountered in the group;
 * - `element`: the element from the source being aggregated;
 * - `first`: indicates whether it's the first `element` encountered in the group.
 *
 * If the [destination] map already has a value corresponding to some key,
 * then the elements being aggregated for that key are never considered as `first`.
 *
 * @return the [destination] map associating the key of each group with the result of aggregation of the group elements.
 * @sample samples.collections.Grouping.aggregateByRadixTo
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> public inline fun < T , K , R > Grouping < T , K > . fold ( initialValueSelector : ( key : K , element : T ) -> R , operation : ( key : K , accumulator : R , element : T ) -> R ) : Map < K , R >

= <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> aggregate { key , acc , e , first -> operation ( key , if ( first ) initialValueSelector ( key , e ) else acc as R , e ) }

/**
 * Groups elements from the [Grouping] source by key and applies [operation] to the elements of each group sequentially,
 * passing the previously accumulated value and the current element as arguments, and stores the results in a new map.
 * An initial value of accumulator is provided by [initialValueSelector] function.
 *
 * @param initialValueSelector a function that provides an initial value of accumulator for each group.
 * It's invoked with parameters:
 * - `key`: the key of the group;
 * - `element`: the first element being encountered in that group.
 *
 * @param operation a function that is invoked on each element with the following parameters:
 * - `key`: the key of the group this element belongs to;
 * - `accumulator`: the current value of the accumulator of the group;
 * - `element`: the element from the source being accumulated.
 *
 * @return a [Map] associating the key of each group with the result of accumulating the group elements.
 * @sample samples.collections.Grouping.foldByEvenLengthWithComputedInitialValue
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> public inline fun < T , K , R , M : MutableMap < in K , R > > Grouping < T , K > . foldTo ( destination : M , initialValueSelector : ( key : K , element : T ) -> R , operation : ( key : K , accumulator : R , element : T ) -> R ) : M

= <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> aggregateTo ( destination ) { key , acc , e , first -> operation ( key , if ( first ) initialValueSelector ( key , e ) else acc as R , e ) }

/**
 * Groups elements from the [Grouping] source by key and applies [operation] to the elements of each group sequentially,
 * passing the previously accumulated value and the current element as arguments,
 * and stores the results in the given [destination] map.
 * An initial value of accumulator is provided by [initialValueSelector] function.
 *
 * @param initialValueSelector a function that provides an initial value of accumulator for each group.
 * It's invoked with parameters:
 * - `key`: the key of the group;
 * - `element`: the first element being encountered in that group.
 *
 * If the [destination] map already has a value corresponding to some key, that value is used as an initial value of
 * the accumulator for that group and the [initialValueSelector] function is not called for that group.
 *
 * @param operation a function that is invoked on each element with the following parameters:
 * - `key`: the key of the group this element belongs to;
 * - `accumulator`: the current value of the accumulator of the group;
 * - `element`: the element from the source being accumulated.
 *
 * @return the [destination] map associating the key of each group with the result of accumulating the group elements.
 * @sample samples.collections.Grouping.foldByEvenLengthWithComputedInitialValueTo
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> public inline fun < T , K , R > Grouping < T , K > . fold ( initialValue : R , operation : ( accumulator : R , element : T ) -> R ) : Map < K , R >

= <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> aggregate { _ , acc , e , first -> operation ( if ( first ) initialValue else acc as R , e ) }

/**
 * Groups elements from the [Grouping] source by key and applies [operation] to the elements of each group sequentially,
 * passing the previously accumulated value and the current element as arguments, and stores the results in a new map.
 * An initial value of accumulator is the same [initialValue] for each group.
 *
 * @param operation a function that is invoked on each element with the following parameters:
 * - `accumulator`: the current value of the accumulator of the group;
 * - `element`: the element from the source being accumulated.
 *
 * @return a [Map] associating the key of each group with the result of accumulating the group elements.
 * @sample samples.collections.Grouping.foldByEvenLengthWithConstantInitialValue
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> public inline fun < T , K , R , M : MutableMap < in K , R > > Grouping < T , K > . foldTo ( destination : M , initialValue : R , operation : ( accumulator : R , element : T ) -> R ) : M

= <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> aggregateTo ( destination ) { _ , acc , e , first -> operation ( if ( first ) initialValue else acc as R , e ) }

/**
 * Groups elements from the [Grouping] source by key and applies [operation] to the elements of each group sequentially,
 * passing the previously accumulated value and the current element as arguments,
 * and stores the results in the given [destination] map.
 * An initial value of accumulator is the same [initialValue] for each group.
 *
 * If the [destination] map already has a value corresponding to the key of some group,
 * that value is used as an initial value of the accumulator for that group.
 *
 * @param operation a function that is invoked on each element with the following parameters:
 * - `accumulator`: the current value of the accumulator of the group;
 * - `element`: the element from the source being accumulated.
 *
 * @return the [destination] map associating the key of each group with the result of accumulating the group elements.
 * @sample samples.collections.Grouping.foldByEvenLengthWithConstantInitialValueTo
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> public inline fun < S , T : S , K > Grouping < T , K > . reduce ( operation : ( key : K , accumulator : S , element : T ) -> S ) : Map < K , S >

= <EOL> aggregate { key , acc , e , first -> <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> if ( first ) e else operation ( key , acc as S , e ) <EOL> }

/**
 * Groups elements from the [Grouping] source by key and applies the reducing [operation] to the elements of each group
 * sequentially starting from the second element of the group,
 * passing the previously accumulated value and the current element as arguments,
 * and stores the results in a new map.
 * An initial value of accumulator is the first element of the group.
 *
 * @param operation a function that is invoked on each subsequent element of the group with the following parameters:
 * - `key`: the key of the group this element belongs to;
 * - `accumulator`: the current value of the accumulator of the group;
 * - `element`: the element from the source being accumulated.
 *
 * @return a [Map] associating the key of each group with the result of accumulating the group elements.
 * @sample samples.collections.Grouping.reduceByMaxVowels
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> public inline fun < S , T : S , K , M : MutableMap < in K , S > > Grouping < T , K > . reduceTo ( destination : M , operation : ( key : K , accumulator : S , element : T ) -> S ) : M

= <EOL> aggregateTo ( destination ) { key , acc , e , first -> <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> if ( first ) e else operation ( key , acc as S , e ) <EOL> }

/**
 * Groups elements from the [Grouping] source by key and applies the reducing [operation] to the elements of each group
 * sequentially starting from the second element of the group,
 * passing the previously accumulated value and the current element as arguments,
 * and stores the results in the given [destination] map.
 * An initial value of accumulator is the first element of the group.
 *
 * If the [destination] map already has a value corresponding to the key of some group,
 * that value is used as an initial value of the accumulator for that group and the first element of that group is also
 * subjected to the [operation].

 * @param operation a function that is invoked on each subsequent element of the group with the following parameters:
 * - `accumulator`: the current value of the accumulator of the group;
 * - `element`: the element from the source being folded;
 *
 * @return the [destination] map associating the key of each group with the result of accumulating the group elements.
 * @sample samples.collections.Grouping.reduceByMaxVowelsTo
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> public fun < T , K , M : MutableMap < in K , Int > > Grouping < T , K > . eachCountTo ( destination : M ) : M

= <EOL> foldTo ( destination , <NUM_LIT:0> ) { acc , _ -> acc + <NUM_LIT:1> }

/**
 * Groups elements from the [Grouping] source by key and counts elements in each group to the given [destination] map.
 *
 * If the [destination] map already has a value corresponding to the key of some group,
 * that value is used as an initial value of the counter for that group.
 *
 * @return the [destination] map associating the key of each group with the count of elements in the group.
 *
 * @sample samples.collections.Grouping.groupingByEachCount
 */


@ kotlin . internal . InlineOnly <EOL> public inline operator fun BigDecimal . plus ( other : BigDecimal ) : BigDecimal

= this . add ( other )

/**
 * Enables the use of the `+` operator for [BigDecimal] instances.
 */


@ kotlin . internal . InlineOnly <EOL> public inline operator fun BigDecimal . minus ( other : BigDecimal ) : BigDecimal

= this . subtract ( other )

/**
 * Enables the use of the `-` operator for [BigDecimal] instances.
 */


@ kotlin . internal . InlineOnly <EOL> public inline operator fun BigDecimal . times ( other : BigDecimal ) : BigDecimal

= this . multiply ( other )

/**
 * Enables the use of the `*` operator for [BigDecimal] instances.
 */


@ kotlin . internal . InlineOnly <EOL> public inline operator fun BigDecimal . div ( other : BigDecimal ) : BigDecimal

= this . divide ( other , RoundingMode . HALF_EVEN )

/**
 * Enables the use of the `/` operator for [BigDecimal] instances.
 *
 * The scale of the result is the same as the scale of `this` (divident), and for rounding the [RoundingMode.HALF_EVEN]
 * rounding mode is used.
 */


@ kotlin . internal . InlineOnly <EOL> public inline operator fun BigDecimal . rem ( other : BigDecimal ) : BigDecimal

= this . remainder ( other )

/**
 * Enables the use of the `%` operator for [BigDecimal] instances.
 */


@ kotlin . internal . InlineOnly <EOL> public inline operator fun BigDecimal . unaryMinus ( ) : BigDecimal

= this . negate ( )

/**
 * Enables the use of the unary `-` operator for [BigDecimal] instances.
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline operator fun BigDecimal . inc ( ) : BigDecimal

= this . add ( BigDecimal . ONE )

/**
 * Enables the use of the unary `++` operator for [BigDecimal] instances.
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline operator fun BigDecimal . dec ( ) : BigDecimal

= this . subtract ( BigDecimal . ONE )

/**
 * Enables the use of the unary `--` operator for [BigDecimal] instances.
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun Int . toBigDecimal ( ) : BigDecimal

= BigDecimal . valueOf ( this . toLong ( ) )

/**
 * Returns the value of this [Int] number as a [BigDecimal].
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun Int . toBigDecimal ( mathContext : MathContext ) : BigDecimal

= BigDecimal ( this , mathContext )

/**
 * Returns the value of this [Int] number as a [BigDecimal].
 * @param mathContext specifies the precision and the rounding mode.
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun Long . toBigDecimal ( ) : BigDecimal

= BigDecimal . valueOf ( this )

/**
 * Returns the value of this [Long] number as a [BigDecimal].
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun Long . toBigDecimal ( mathContext : MathContext ) : BigDecimal

= BigDecimal ( this , mathContext )

/**
 * Returns the value of this [Long] number as a [BigDecimal].
 * @param mathContext specifies the precision and the rounding mode.
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun Float . toBigDecimal ( ) : BigDecimal

= BigDecimal ( this . toString ( ) )

/**
 * Returns the value of this [Float] number as a [BigDecimal].
 *
 * The number is converted to a string and then the string is converted to a [BigDecimal].
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun Float . toBigDecimal ( mathContext : MathContext ) : BigDecimal

= BigDecimal ( this . toString ( ) , mathContext )

/**
 * Returns the value of this [Float] number as a [BigDecimal].
 *
 * The number is converted to a string and then the string is converted to a [BigDecimal].
 *
 * @param mathContext specifies the precision and the rounding mode.
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun Double . toBigDecimal ( ) : BigDecimal

= BigDecimal ( this . toString ( ) )

/**
 * Returns the value of this [Double] number as a [BigDecimal].
 *
 * The number is converted to a string and then the string is converted to a [BigDecimal].
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun Double . toBigDecimal ( mathContext : MathContext ) : BigDecimal

/**
 * Returns the value of this [Double] number as a [BigDecimal].
 *
 * The number is converted to a string and then the string is converted to a [BigDecimal].
 *
 * @param mathContext specifies the precision and the rounding mode.
 */


fun loadTypeAlias ( proto : ProtoBuf . TypeAlias , preComputedSymbol : FirTypeAliasSymbol ? = null ) : FirTypeAlias

{ <EOL> val flags = proto . flags <EOL> val name = c . nameResolver . getName ( proto . name ) <EOL> val classId = ClassId ( c . packageFqName , name ) <EOL> val symbol = preComputedSymbol ? : FirTypeAliasSymbol ( classId ) <EOL> val local = c . childContext ( proto . typeParameterList , containingDeclarationSymbol = symbol ) <EOL> val versionRequirements = VersionRequirement . create ( proto , c ) <EOL> return buildTypeAlias { <EOL> moduleData = c . moduleData <EOL> origin = FirDeclarationOrigin . Library <EOL> this . name = name <EOL> val visibility = ProtoEnumFlags . visibility ( Flags . VISIBILITY . get ( flags ) ) <EOL> status = FirResolvedDeclarationStatusImpl ( visibility , Modality . FINAL , visibility . toEffectiveVisibility ( owner = null ) ) . apply { <EOL> isExpect = Flags . IS_EXPECT_CLASS . get ( flags ) <EOL> isActual = false <EOL> } <EOL> annotations += c . annotationDeserializer . loadTypeAliasAnnotations ( proto , local . nameResolver ) <EOL> this . symbol = symbol <EOL> expandedTypeRef = proto . underlyingType ( c . typeTable ) . toTypeRef ( local ) <EOL> resolvePhase = FirResolvePhase . ANALYZED_DEPENDENCIES <EOL> typeParameters += local . typeDeserializer . ownTypeParameters . map { it . fir } <EOL> deprecationsProvider = annotations . getDeprecationsProviderFromAnnotations ( c . session , fromJava = false , versionRequirements ) <EOL> } . apply { <EOL> this . versionRequirements = versionRequirements <EOL> sourceElement = c . containerSource <EOL> } <EOL> }

/**
 * If loading happens in post-compute, then symbol for type alias is already computed and should be provided in [preComputedSymbol]
 * @See AbstractFirDeserializedSymbolProvider.findAndDeserializeTypeAlias
 */


private fun isStatic ( function : Function < * > ) : Boolean

{ <EOL> try { <EOL> with ( function . javaClass . getDeclaredField ( "<STR_LIT>" ) ) { <EOL> if ( ! java . lang . reflect . Modifier . isStatic ( modifiers ) || ! java . lang . reflect . Modifier . isFinal ( modifiers ) ) { <EOL> return false <EOL> } <EOL> isAccessible = true <EOL> return get ( null ) == function <EOL> } <EOL> } catch ( e : NoSuchFieldException ) { <EOL> return false <EOL> } <EOL> }

/**
 * Returns `true` if given function is *static* as defined in [staticCFunction].
 */


private fun ffiTypeStruct ( elementTypes : List < ffi_type > ) : ffi_type

{ <EOL> val elements = nativeHeap . allocArrayOfPointersTo ( * elementTypes . toTypedArray ( ) , null ) <EOL> val res = ffiTypeStruct0 ( elements . rawValue ) <EOL> if ( res == <NUM_LIT:0L> ) { <EOL> throw OutOfMemoryError ( ) <EOL> } <EOL> caches . addTypeStruct ( res ) <EOL> return interpretPointed ( res ) <EOL> }

/**
 * Allocates and initializes `ffi_type` describing the struct.
 *
 * @param elements types of the struct elements
 */


private fun ffiCreateCif ( returnType : ffi_type , paramTypes : List < ffi_type > ) : ffi_cif

{ <EOL> val nArgs = paramTypes . size <EOL> val argTypes = nativeHeap . allocArrayOfPointersTo ( * paramTypes . toTypedArray ( ) , null ) <EOL> val res = ffiCreateCif0 ( nArgs , returnType . rawPtr , argTypes . rawValue ) <EOL> when ( res ) { <EOL> <NUM_LIT:0L> -> throw OutOfMemoryError ( ) <EOL> - <NUM_LIT:1L> -> throw Error ( "<STR_LIT>" ) <EOL> - <NUM_LIT> -> throw Error ( "<STR_LIT>" ) <EOL> - <NUM_LIT:3L> -> throw Error ( "<STR_LIT>" ) <EOL> } <EOL> caches . addCif ( res ) <EOL> return interpretPointed ( res ) <EOL> }

/**
 * Creates and prepares an `ffi_cif`.
 *
 * @param returnType native function return value type
 * @param paramTypes native function parameter types
 *
 * @return the initialized `ffi_cif`
 */


private fun ffiCreateClosure ( ffiCif : ffi_cif , impl : FfiClosureImpl ) : NativePtr

{ <EOL> val ffiClosure = nativeHeap . alloc ( Long . SIZE_BYTES , <NUM_LIT:8> ) <EOL> try { <EOL> val res = ffiCreateClosure0 ( ffiCif . rawPtr , ffiClosure . rawPtr , userData = impl ) <EOL> when ( res ) { <EOL> <NUM_LIT:0L> -> throw OutOfMemoryError ( ) <EOL> - <NUM_LIT:1L> -> throw Error ( "<STR_LIT>" ) <EOL> } <EOL> caches . addClosure ( unsafe . getLong ( ffiClosure . rawPtr ) ) <EOL> return res <EOL> } finally { <EOL> nativeHeap . free ( ffiClosure ) <EOL> } <EOL> }

/**
 * Uses libffi to allocate a native function which will call [impl] when invoked.
 *
 * @param ffiCif describes the type of the function to create
 */


override fun get ( fir : FirElement , unwrapAlias : ( RealVariable , FirElement ) -> RealVariable ? ) : DataFlowVariable ?

{ <EOL> return get ( fir . unwrapElement ( ) , createReal = false , createSynthetic = false , unwrapAlias ) <EOL> }

/**
 * Get an existing [DataFlowVariable] for the specified [fir] [FirElement].
 *
 * @param unwrapAlias lambda used to transform a [RealVariable] if it represents an alias for another [RealVariable], or return the same
 * variable. If the alias is unstable, `null` can be returned. This will cause the function to also return `null`.
 */


fun getOrCreateIfReal ( fir : FirElement , unwrapAlias : ( RealVariable , FirElement ) -> RealVariable ? ) : DataFlowVariable ?

{ <EOL> return get ( fir . unwrapElement ( ) , createReal = true , createSynthetic = false , unwrapAlias ) <EOL> }

/**
 * Get an existing [DataFlowVariable], or create a [RealVariable] for the specified [fir] [FirElement] if possible.
 * If the variable does not already exist and cannot be represented by a [RealVariable], the function will return `null`.
 *
 * @param unwrapAlias lambda used to transform a [RealVariable] if it represents an alias for another [RealVariable], or return the same
 * variable. If the alias is unstable, `null` can be returned. This will cause the function to also return `null`.
 */


fun getOrCreate ( fir : FirElement , unwrapAlias : ( RealVariable , FirElement ) -> RealVariable ? ) : DataFlowVariable ?

{ <EOL> return get ( fir . unwrapElement ( ) , createReal = true , createSynthetic = true , unwrapAlias ) <EOL> }

/**
 * Get an existing [DataFlowVariable], or create a [DataFlowVariable] for the specified [fir] [FirElement].
 *
 * @param unwrapAlias lambda used to transform a [RealVariable] if it represents an alias for another [RealVariable], or return the same
 * variable. If the alias is unstable, `null` can be returned. This will cause the function to also return `null`.
 */


public fun createCopy ( ) : T ?

/**
 * Creates a copy of the current instance.
 *
 * For better debuggability, it is recommended to use original exception as [cause][Throwable.cause] of the resulting one.
 * Stacktrace of copied exception will be overwritten by stacktrace recovery machinery by [Throwable.setStackTrace] call.
 * An exception can opt-out of copying by returning `null` from this function.
 * Suppressed exceptions of the original exception should not be copied in order to avoid circular exceptions.
 *
 * This function is allowed to create a copy with a modified [message][Throwable.message], but it should be noted
 * that the copy can be later recovered as well and message modification code should handle this situation correctly
 * (e.g. by also storing the original message and checking it) to produce a human-readable result.
 */


public fun < T > flow ( @ BuilderInference block : suspend FlowCollector < T > . ( ) -> Unit ) : Flow < T >

= SafeFlow ( block )

/**
 * Creates a _cold_ flow from the given suspendable [block].
 * The flow being _cold_ means that the [block] is called every time a terminal operator is applied to the resulting flow.
 *
 * Example of usage:
 *
 * ```
 * fun fibonacci(): Flow<BigInteger> = flow {
 * var x = BigInteger.ZERO
 * var y = BigInteger.ONE
 * while (true) {
 * emit(x)
 * x = y.also {
 * y += x
 * }
 * }
 * }
 *
 * fibonacci().take(100).collect { println(it) }
 * ```
 *
 * Emissions from [flow] builder are [cancellable] by default — each call to [emit][FlowCollector.emit]
 * also calls [ensureActive][CoroutineContext.ensureActive].
 *
 * `emit` should happen strictly in the dispatchers of the [block] in order to preserve the flow context.
 * For example, the following code will result in an [IllegalStateException]:
 *
 * ```
 * flow {
 * emit(1) // Ok
 * withContext(Dispatcher.IO) {
 * emit(2) // Will fail with ISE
 * }
 * }
 * ```
 *
 * If you want to switch the context of execution of a flow, use the [flowOn] operator.
 */


public fun < T > ( ( ) -> T ) . asFlow ( ) : Flow < T >

= flow { <EOL> emit ( invoke ( ) ) <EOL> }

/**
 * Creates a _cold_ flow that produces a single value from the given functional type.
 */