@ ExperimentalTopLevelDeclarationsGenerationApi <EOL> public fun FirExtension . createTopLevelFunction ( key : GeneratedDeclarationKey , callableId : CallableId , returnTypeProvider : ( List < FirTypeParameter > ) -> ConeKotlinType , config : SimpleFunctionBuildingContext . ( ) -> Unit = { } ) : FirSimpleFunction

{ <EOL> require ( callableId . classId == null ) <EOL> return SimpleFunctionBuildingContext ( session , key , owner = null , callableId , returnTypeProvider ) . apply ( config ) . build ( ) <EOL> }

/**
 * Creates a top-level function with [callableId] and return type provided by [returnTypeProvider].
 * Use this overload when return type references type parameters of created function.
 *
 * Type and value parameters can be configured with [config] builder.
 */


public fun allocateVectorSchemaRoot ( ) : VectorSchemaRoot

/**
 * Create Arrow [VectorSchemaRoot] with [dataFrame] content cast to [targetSchema] according to the [mode].
 */


public fun writeArrowIPC ( channel : WritableByteChannel )

{ <EOL> allocateVectorSchemaRoot ( ) . use { vectorSchemaRoot -> <EOL> ArrowStreamWriter ( vectorSchemaRoot , null , channel ) . use { writer -> <EOL> writer . writeBatch ( ) <EOL> } <EOL> } <EOL> }

/**
 * Save data to [Arrow interprocess streaming format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-streaming-format), write to opened [channel].
 */


public fun writeArrowIPC ( stream : OutputStream )

{ <EOL> writeArrowIPC ( Channels . newChannel ( stream ) ) <EOL> }

/**
 * Save data to [Arrow interprocess streaming format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-streaming-format), write to opened [stream].
 */


public fun writeArrowIPC ( file : File , append : Boolean = true )

{ <EOL> writeArrowIPC ( FileOutputStream ( file , append ) ) <EOL> }

/**
 * Save data to [Arrow interprocess streaming format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-streaming-format), write to new or existing [file].
 * If file exists, it can be recreated or expanded.
 */


public fun saveArrowIPCToByteArray ( ) : ByteArray

{ <EOL> val stream = ByteArrayOutputStream ( ) <EOL> writeArrowIPC ( stream ) <EOL> return stream . toByteArray ( ) <EOL> }

/**
 * Save data to [Arrow interprocess streaming format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-streaming-format), write to new [ByteArray]
 */


public fun writeArrowFeather ( channel : WritableByteChannel )

{ <EOL> allocateVectorSchemaRoot ( ) . use { vectorSchemaRoot -> <EOL> ArrowFileWriter ( vectorSchemaRoot , null , channel ) . use { writer -> <EOL> writer . writeBatch ( ) <EOL> } <EOL> } <EOL> }

/**
 * Save data to [Arrow random access format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-random-access-files), write to opened [channel].
 */


public fun writeArrowFeather ( stream : OutputStream )

{ <EOL> writeArrowFeather ( Channels . newChannel ( stream ) ) <EOL> }

/**
 * Save data to [Arrow random access format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-random-access-files), write to opened [stream].
 */


public fun writeArrowFeather ( file : File )

{ <EOL> writeArrowFeather ( FileOutputStream ( file ) ) <EOL> }

/**
 * Save data to [Arrow random access format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-random-access-files), write to new or existing [file].
 * If file exists, it would be recreated.
 */


public fun saveArrowFeatherToByteArray ( ) : ByteArray

{ <EOL> val stream = ByteArrayOutputStream ( ) <EOL> writeArrowFeather ( stream ) <EOL> return stream . toByteArray ( ) <EOL> }

/**
 * Save data to [Arrow random access format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-random-access-files), write to new [ByteArray]
 */


{ <EOL> val regex = Regex ( "<STR_LIT>" ) <EOL> var testString = "<STR_LIT>" <EOL> assertTrue ( regex . matches ( testString ) ) <EOL> assertTrue ( regex in testString ) <EOL> assertTrue ( regex . find ( testString ) != null ) <EOL> testString = "<STR_LIT>" <EOL> assertFalse ( regex . matches ( testString ) ) <EOL> assertFalse ( regex in testString ) <EOL> assertFalse ( regex . find ( testString ) != null ) <EOL> assertTrue ( Regex ( "<STR_LIT>" ) . matches ( "<STR_LIT>" ) ) <EOL> assertFalse ( Regex ( "<STR_LIT>" ) . matches ( "<STR_LIT>" ) ) <EOL> assertFalse ( Regex ( "<STR_LIT:bar>" ) . matches ( "<STR_LIT>" ) ) <EOL> assertTrue ( Regex ( "<STR_LIT>" ) . matches ( "<STR_LIT>" ) ) <EOL> }

/**
 * Tests simple pattern compilation and matching methods
 */


public fun toHTML ( configuration : DisplayConfiguration = DisplayConfiguration . DEFAULT ) : DataFrameHtmlData

{ <EOL> return df . toHTML ( getDisplayConfiguration ( configuration ) ) <EOL> }

/**
 * @return DataFrameHtmlData without additional definitions. Can be rendered in Jupyter kernel environments
 */


public fun toStandaloneHTML ( configuration : DisplayConfiguration = DisplayConfiguration . DEFAULT ) : DataFrameHtmlData

{ <EOL> return df . toStandaloneHTML ( getDisplayConfiguration ( configuration ) ) <EOL> }

/**
 * @return DataFrameHtmlData with table script and css definitions. Can be saved as an *.html file and displayed in the browser
 */


@ Test <EOL> fun testFlowsNotSkippingValues ( )

= scope . launch { <EOL> val list = flowOf ( <NUM_LIT:1> ) . onStart { emit ( <NUM_LIT:0> ) } <EOL> . combine ( flowOf ( "<STR_LIT:A>" ) ) { int , str -> "<STR_LIT>" } <EOL> . toList ( ) <EOL> assertEquals ( list , listOf ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> } . void ( )

/** Tests that the [StandardTestDispatcher] follows an execution order similar to `runBlocking`. */


@ Test <EOL> fun testLaunchDispatched ( )

= scope . launch { <EOL> expect ( <NUM_LIT:1> ) <EOL> launch { <EOL> expect ( <NUM_LIT:3> ) <EOL> } <EOL> finish ( <NUM_LIT:2> ) <EOL> } . void ( )

/** Tests that each [launch] gets dispatched. */


= scope . launch { <EOL> expect ( <NUM_LIT:1> ) <EOL> scope . launch { <EOL> expect ( <NUM_LIT:3> ) <EOL> yield ( ) <EOL> expect ( <NUM_LIT:6> ) <EOL> } <EOL> scope . launch { <EOL> expect ( <NUM_LIT:4> ) <EOL> yield ( ) <EOL> finish ( <NUM_LIT:7> ) <EOL> } <EOL> expect ( <NUM_LIT:2> ) <EOL> yield ( ) <EOL> expect ( <NUM_LIT:5> ) <EOL> } . void ( )

/** Tests that dispatching is done in a predictable order and [yield] puts this task at the end of the queue. */


{ <EOL> val dispatcher1 = StandardTestDispatcher ( ) <EOL> Dispatchers . setMain ( dispatcher1 ) <EOL> try { <EOL> val dispatcher2 = StandardTestDispatcher ( ) <EOL> assertSame ( dispatcher1 . scheduler , dispatcher2 . scheduler ) <EOL> } finally { <EOL> Dispatchers . resetMain ( ) <EOL> } <EOL> }

/** Tests that the [TestCoroutineScheduler] used for [Dispatchers.Main] gets used by default. */


@ Test <EOL> fun testClassVersionsInJavaLangOfJdk11 ( )

{ <EOL> val configuration = CompilerConfiguration ( ) <EOL> val jdkHome = JvmEnvironmentConfigurator . getJdkHome ( TestJdkKind . FULL_JDK_11 ) <EOL> requireNotNull ( jdkHome ) <EOL> configuration . put ( JVMConfigurationKeys . JDK_HOME , jdkHome ) <EOL> val environment = <EOL> KotlinCoreEnvironment . getOrCreateApplicationEnvironmentForTests ( this . testRootDisposable , configuration ) <EOL> val jrt = environment . jrtFileSystem ? : error ( "<STR_LIT>" ) <EOL> val root = jrt . findFileByPath ( "<STR_LIT>" ) <EOL> requireNotNull ( root ) <EOL> val children = root . children . filter { it . extension == "<STR_LIT:class>" } <EOL> assert ( children . isNotEmpty ( ) ) <EOL> children . forEach { file -> <EOL> checkClassVersion ( Opcodes . V11 , file ) <EOL> } <EOL> }

/**
 * The test ensures that Thread class always contains version from JDK_11, when such javaHome is used
 * Regardless of compiler runtime JDK
 */


@ SlicedGeneratedTest ( allTools = true ) <EOL> fun BuildConfigurator . testPackageInTheMiddle ( )

{ <EOL> addProjectWithKover { <EOL> sourcesFrom ( "<STR_LIT>" ) <EOL> kover { <EOL> reports { <EOL> filters { <EOL> excludes { <EOL> packages ( "<STR_LIT:foo>" ) <EOL> } <EOL> } <EOL> } <EOL> } <EOL> } <EOL> run ( "<STR_LIT>" ) { <EOL> xmlReport { <EOL> classCounter ( "<STR_LIT>" ) . assertAbsent ( ) <EOL> classCounter ( "<STR_LIT>" ) . assertCovered ( ) <EOL> } <EOL> } <EOL> }

/**
 * Check that when excluding packages, the excluding occurs starting from the root package,
 * and there is no search for any middle occurrence of the specified string.
 *
 * See https://github.com/Kotlin/kotlinx-kover/issues/543
 */


{ <EOL> val modelHub = <EOL> ONNXModelHub ( cacheDirectory = File ( "<STR_LIT>" ) ) <EOL> val model = ONNXModels . ObjectDetection . SSD . pretrainedModel ( modelHub ) <EOL> model . printSummary ( ) <EOL> model . use { detectionModel -> <EOL> println ( detectionModel ) <EOL> val file = getFileFromResource ( "<STR_LIT>" ) <EOL> val image = ImageConverter . toBufferedImage ( file ) <EOL> val detectedObjects = detectionModel . detectObjects ( image , topK = <NUM_LIT:20> ) <EOL> detectedObjects . forEach { <EOL> println ( "<STR_LIT>" ) <EOL> } <EOL> val displayedImage = pipeline < BufferedImage > ( ) <EOL> . resize { outputWidth = <NUM_LIT> ; outputHeight = ( ( <NUM_LIT> / image . width ) * image . height ) . toInt ( ) } <EOL> . apply ( image ) <EOL> showFrame ( "<STR_LIT>" , createDetectedObjectsPanel ( displayedImage , detectedObjects ) ) <EOL> } <EOL> }

/**
 * This examples demonstrates the light-weight inference API with [SSDObjectDetectionModel] on SSD model:
 * - Model is obtained from [ONNXModelHub].
 * - Model predicts rectangles for the detected objects on a few images located in resources.
 * - The detected rectangles related to the objects are drawn on the images used for prediction.
 */


protected open fun loadVariables ( variableNames : Collection < String > , getData : ( String , Shape ) -> Any )

{ <EOL> for ( variableName in variableNames ) { <EOL> val variableOperation = tfGraph . operation ( variableName ) <EOL> check ( variableOperation != null ) { "<STR_LIT>" } <EOL> val variableShape = variableOperation . output < Float > ( <NUM_LIT:0> ) . shape ( ) <EOL> val data = getData ( variableName , variableShape ) <EOL> assignVariable ( variableName , variableShape , data ) <EOL> } <EOL> }

/**
 * Loads variable data for variable names in the provided collection using a provided function.
 * @param [variableNames] Variable names to load.
 * @param [getData] Function that returns variable data by variable name and shape.
 */


protected fun isOptimizerVariable ( variableName : String ) : Boolean

= variableName . startsWith ( "<STR_LIT>" )

/** Check that the variable with the name [variableName] is an optimizer variable**/


protected fun loadVariablesFromTxt ( pathToModelDirectory : String , loadOptimizerState : Boolean )

{ <EOL> loadVariablesFromTxt ( pathToModelDirectory ) { variableName -> <EOL> loadOptimizerState || ! isOptimizerVariable ( variableName ) <EOL> } <EOL> }

/**
 * Loads variable data from .txt files.
 *
 * @param [pathToModelDirectory] Path to directory with TensorFlow graph and variable data.
 * @param [loadOptimizerState] Loads optimizer internal variables data, if true.
 */


protected fun loadVariablesFromTxt ( pathToModelDirectory : String , predicate : ( String ) -> Boolean )

{ <EOL> val variableNamesFile = File ( "<STR_LIT>" ) <EOL> if ( ! variableNamesFile . exists ( ) ) throw FileNotFoundException ( "<STR_LIT>" + "<STR_LIT>" ) <EOL> val variableNamesToLoad = variableNamesFile . readLines ( ) . filter ( predicate ) <EOL> loadVariables ( variableNamesToLoad ) { variableName , variableShape -> <EOL> val file = File ( "<STR_LIT>" ) <EOL> if ( ! file . exists ( ) ) throw FileNotFoundException ( "<STR_LIT>" + "<STR_LIT>" ) <EOL> Scanner ( file . inputStream ( ) ) . use { scanner -> <EOL> scanner . useLocale ( Locale . US ) <EOL> scanner . createFloatArray ( variableShape ) <EOL> } <EOL> } <EOL> }

/**
 * Loads variable data from .txt files for variables matching the provided predicate.
 *
 * @param [pathToModelDirectory] Path to directory with TensorFlow graph and variable data.
 * @param [predicate] Predicate for matching variable names for loading.
 */


protected fun assignVariable ( variableName : String , variableShape : Shape , data : Any )

{ <EOL> val initializerName = defaultInitializerOpName ( variableName ) <EOL> val assignOpName = defaultAssignOpName ( variableName ) <EOL> val initOp = tfGraph . operation ( initializerName ) <EOL> check ( initOp != null ) { <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" <EOL> } <EOL> val assignOp = tfGraph . operation ( assignOpName ) <EOL> check ( assignOp != null ) { "<STR_LIT>" } <EOL> populateVariable ( assignOpName , initializerName , data ) <EOL> logger . debug { "<STR_LIT>" } <EOL> logger . debug { "<STR_LIT>" } <EOL> logger . debug { "<STR_LIT>" } <EOL> }

/**
 * Assigns variable data from multidimensional array.
 *
 * @param [variableName] Name of variable to load state for.
 * @param [variableShape] Shape of the variable.
 * @param [data] Variable data.
 */


{ <EOL> session . close ( ) <EOL> tfGraph . close ( ) <EOL> }

/** Closes internal resources: session and tfGraph. */


{ <EOL> tensors . forEach { <EOL> try { <EOL> it . close ( ) <EOL> } finally { <EOL> } <EOL> } <EOL> }


operator fun get ( project : Project ) : List < T >

/**
 * @return all currently registered extension points.
 * The returned list is *not* live and just represents the current snapshot.
 */


fun register ( project : Project , extension : T )

/**
 * @param project The current [project] to register an extension. The extension will only be visible to this particular [project]
 * @param extension The implementation of the extension to register. If registered twice, it will be returned twice when
 * the extensions are queried (no de-duplication)
 */


public fun OrtSession . Result . getFloatArrayWithShape ( index : Int ) : Pair < FloatArray , LongArray >

{ <EOL> return get ( index ) . getFloatArrayWithShape ( ) <EOL> }

/**
 * Returns the output at [index] as a [FloatArray] with its shape.
 */


public fun OrtSession . Result . getFloatArray ( index : Int ) : FloatArray

{ <EOL> return getFloatArrayWithShape ( index ) . first <EOL> }

/**
 * Returns the output at [index] as a [FloatArray].
 */


public fun OrtSession . Result . getFloatArrayWithShape ( name : String ) : Pair < FloatArray , LongArray >

{ <EOL> return get ( name ) . get ( ) . getFloatArrayWithShape ( ) <EOL> }

/**
 * Returns the output by [name] as a [FloatArray] with its shape.
 */


public fun OrtSession . Result . getFloatArray ( name : String ) : FloatArray

{ <EOL> return getFloatArrayWithShape ( name ) . first <EOL> }

/**
 * Returns the output by [name] as a [FloatArray].
 */


public fun OrtSession . Result . getDoubleArrayWithShape ( index : Int ) : Pair < DoubleArray , LongArray >

{ <EOL> return get ( index ) . getDoubleArrayWithShape ( ) <EOL> }

/**
 * Returns the output at [index] as a [DoubleArray] with its shape.
 */


public fun OrtSession . Result . getDoubleArray ( index : Int ) : DoubleArray

{ <EOL> return getDoubleArrayWithShape ( index ) . first <EOL> }

/**
 * Returns the output at [index] as a [DoubleArray].
 */


public fun OrtSession . Result . getDoubleArrayWithShape ( name : String ) : Pair < DoubleArray , LongArray >

{ <EOL> return get ( name ) . get ( ) . getDoubleArrayWithShape ( ) <EOL> }

/**
 * Returns the output by [name] as a [DoubleArray] with its shape.
 */


public fun OrtSession . Result . getDoubleArray ( name : String ) : DoubleArray

{ <EOL> return getDoubleArrayWithShape ( name ) . first <EOL> }

/**
 * Returns the output by [name] as a [DoubleArray].
 */


public fun OrtSession . Result . getLongArrayWithShape ( index : Int ) : Pair < LongArray , LongArray >

{ <EOL> return get ( index ) . getLongArrayWithShape ( ) <EOL> }

/**
 * Returns the output at [index] as a [LongArray] with its shape.
 */


public fun OrtSession . Result . getLongArray ( index : Int ) : LongArray

{ <EOL> return getLongArrayWithShape ( index ) . first <EOL> }

/**
 * Returns the output at [index] as a [LongArray].
 */


public fun OrtSession . Result . getLongArrayWithShape ( name : String ) : Pair < LongArray , LongArray >

{ <EOL> return get ( name ) . get ( ) . getLongArrayWithShape ( ) <EOL> }

/**
 * Returns the output by [name] as a [LongArray] with its shape.
 */


public fun OrtSession . Result . getLongArray ( name : String ) : LongArray

{ <EOL> return getLongArrayWithShape ( name ) . first <EOL> }


public fun OrtSession . Result . getIntArrayWithShape ( index : Int ) : Pair < IntArray , LongArray >

{ <EOL> return get ( index ) . getIntArrayWithShape ( ) <EOL> }

/**
 * Returns the output at [index] as an [IntArray] with its shape.
 */


public fun OrtSession . Result . getIntArray ( index : Int ) : IntArray

{ <EOL> return getIntArrayWithShape ( index ) . first <EOL> }

/**
 * Returns the output at [index] as an [IntArray].
 */


public fun OrtSession . Result . getIntArrayWithShape ( name : String ) : Pair < IntArray , LongArray >

{ <EOL> return get ( name ) . get ( ) . getIntArrayWithShape ( ) <EOL> }

/**
 * Returns the output by [name] as an [IntArray] with its shape.
 */


public fun OrtSession . Result . getIntArray ( name : String ) : IntArray

{ <EOL> return getIntArrayWithShape ( name ) . first <EOL> }

/**
 * Returns the output by [name] as an [IntArray].
 */


public fun OrtSession . Result . getShortArrayWithShape ( index : Int ) : Pair < ShortArray , LongArray >

{ <EOL> return get ( index ) . getShortArrayWithShape ( ) <EOL> }

/**
 * Returns the output at [index] as a [ShortArray] with its shape.
 */


public fun OrtSession . Result . getShortArray ( index : Int ) : ShortArray

{ <EOL> return getShortArrayWithShape ( index ) . first <EOL> }

/**
 * Returns the output at [index] as a [ShortArray].
 */


public fun OrtSession . Result . getShortArrayWithShape ( name : String ) : Pair < ShortArray , LongArray >

{ <EOL> return get ( name ) . get ( ) . getShortArrayWithShape ( ) <EOL> }

/**
 * Returns the output by [name] as a [ShortArray] with its shape.
 */


public fun OrtSession . Result . getShortArray ( name : String ) : ShortArray

{ <EOL> return getShortArrayWithShape ( name ) . first <EOL> }

/**
 * Returns the output by [name] as a [ShortArray].
 */


public fun OrtSession . Result . getByteArrayWithShape ( index : Int ) : Pair < ByteArray , LongArray >

{ <EOL> return get ( index ) . getByteArrayWithShape ( ) <EOL> }

/**
 * Returns the output at [index] as a [ByteArray] with its shape.
 */


public fun OrtSession . Result . getByteArray ( index : Int ) : ByteArray

{ <EOL> return getByteArrayWithShape ( index ) . first <EOL> }

/**
 * Returns the output at [index] as a [ByteArray].
 */


public fun OrtSession . Result . getByteArrayWithShape ( name : String ) : Pair < ByteArray , LongArray >

{ <EOL> return get ( name ) . get ( ) . getByteArrayWithShape ( ) <EOL> }

/**
 * Returns the output by [name] as a [ByteArray] with its shape.
 */


public fun OrtSession . Result . getByteArray ( name : String ) : ByteArray

{ <EOL> return getByteArrayWithShape ( name ) . first <EOL> }

/**
 * Returns the output by [name] as a [ByteArray].
 */


public fun OrtSession . Result . get2DFloatArray ( name : String ) : Array < FloatArray >

{ <EOL> return get ( name ) . get ( ) . get2DFloatArray ( ) <EOL> }

/**
 * Returns the output by [name] as an Array<FloatArray>. This operation could be slow for high dimensional tensors,
 * in which case [getFloatArray] should be used.
 */


public fun OrtSession . Result . get2DFloatArray ( index : Int ) : Array < FloatArray >

{ <EOL> return get ( index ) . get2DFloatArray ( ) <EOL> }

/**
 * Returns the output at [index] as an Array<FloatArray>. This operation could be slow for high dimensional tensors,
 * in which case [getFloatArray] should be used.
 */


public fun OrtSession . Result . getValues ( ) : Map < String , Any >

= associate { it . key to it . value . value }

/**
 * Returns all values from this [OrtSession.Result]. This operation could be slow for high dimensional tensors,
 * in which case functions that return one dimensional array such as [getFloatArray] or [getLongArray] should be used.
 * @see OnnxValue.getValue
 */


internal fun throwIfOutputNotSupported ( valueInfo : ValueInfo , valueName : String , method : String , type : OnnxJavaType ? = null )

{ <EOL> val typeString = type ? . toString ( ) ? . let { "<STR_LIT>" } ? : "<STR_LIT>" <EOL> require ( valueInfo !is MapInfo ) { "<STR_LIT>" } <EOL> require ( valueInfo !is SequenceInfo ) { "<STR_LIT>" } <EOL> if ( type != null ) { <EOL> require ( valueInfo is TensorInfo && valueInfo . type == type ) { "<STR_LIT>" } <EOL> } <EOL> }

/**
 * Checks if [valueInfo] corresponds to a Tensor of the specified [type].
 * If it does not satisfy the requirements, exception with a message containing [valueName] and calling [method] name is thrown.
 */


fun JsNode . any ( predicate : ( JsNode ) -> Boolean ) : Boolean

{ <EOL> val visitor = object : RecursiveJsVisitor ( ) { <EOL> var matched : Boolean = false <EOL> override fun visitElement ( node : JsNode ) { <EOL> matched = matched || predicate ( node ) <EOL> if ( ! matched ) { <EOL> super . visitElement ( node ) <EOL> } <EOL> } <EOL> } <EOL> visitor . accept ( this ) <EOL> return visitor . matched <EOL> }

/**
 * Tests, if any node containing in receiver's AST matches, [predicate].
 */


{ <EOL> logger . info ( "<STR_LIT>" ) <EOL> if ( executionInProgress . get ( ) ) { <EOL> val execution = executorThread <EOL> val executionName = execution . name <EOL> logger . info ( "<STR_LIT>" ) <EOL> execution . interrupt ( ) <EOL> logger . info ( "<STR_LIT>" ) <EOL> Thread . sleep ( <NUM_LIT:100> ) <EOL> if ( execution . name == executionName ) { <EOL> try { <EOL> @ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> execution . stop ( ) <EOL> logger . info ( "<STR_LIT>" ) <EOL> } catch ( e : UnsupportedOperationException ) { <EOL> logger . warn ( "<STR_LIT>" , e , ) <EOL> } <EOL> } <EOL> } <EOL> }

/**
 * We cannot use [Thread.interrupt] here because we have no way
 * to control the code user executes. [Thread.interrupt] will do nothing for
 * the simple calculation (like `while (true) 1`). Consider replacing with
 * something smarter in the future.
 */


public fun build ( tf : Ops ) : Placeholder < Float >

{ <EOL> input = tf . withName ( DATA_PLACEHOLDER ) . placeholder ( getDType ( ) , Placeholder . shape ( Shape . make ( - <NUM_LIT:1L> , * packedDims ) ) ) <EOL> return input <EOL> }

/**
 * Extend this function to define placeholder in layer.
 *
 * NOTE: Called instead of [Layer.build].
 *
 * @param [tf] TensorFlow graph API for building operations.
 */


@ JvmStatic <EOL> fun mapClass ( classId : String ) : String

{ <EOL> return map [ classId ] ? : "<STR_LIT>" <EOL> }

/**
 * @param classId the name of the class in the format: "org/foo/bar/Test.Inner"
 */


private fun collectDesignationPath ( firFile : FirFile , containerClassId : ClassId ? , expectedDeclarationAcceptor : ( FirDeclaration ) -> Boolean , ) : FirDesignation ?

{ <EOL> if ( containerClassId != null ) { <EOL> requireWithAttachment ( ! containerClassId . isLocal , { "<STR_LIT>" } ) { <EOL> withEntry ( "<STR_LIT>" , containerClassId ) { it . asString ( ) } <EOL> } <EOL> requireWithAttachment ( firFile . packageFqName == containerClassId . packageFqName , { "<STR_LIT>" } ) { <EOL> withEntry ( "<STR_LIT>" , firFile . packageFqName ) { it . asString ( ) } <EOL> withEntry ( "<STR_LIT>" , containerClassId . packageFqName ) { it . asString ( ) } <EOL> } <EOL> } <EOL> val classIdPathSegment = containerClassId ? . relativeClassName ? . pathSegments ( ) . orEmpty ( ) <EOL> val path = ArrayList < FirDeclaration > ( classIdPathSegment . size + <NUM_LIT:2> ) <EOL> var result : FirDeclaration ? = null <EOL> fun find ( declarations : Iterable < FirDeclaration > , classIdPathIndex : Int ) : Boolean { <EOL> val currentClassSegment = classIdPathSegment . getOrNull ( classIdPathIndex ) <EOL> for ( subDeclaration in declarations ) { <EOL> when { <EOL> currentClassSegment == null && expectedDeclarationAcceptor ( subDeclaration ) -> { <EOL> result = subDeclaration <EOL> return true <EOL> } <EOL> subDeclaration is FirScript -> { <EOL> path += subDeclaration <EOL> val scriptParameters = subDeclaration . parameters <EOL> if ( find ( scriptParameters , classIdPathIndex ) ) { <EOL> return true <EOL> } <EOL> val scriptDeclarations = subDeclaration . declarations <EOL> if ( find ( scriptDeclarations , classIdPathIndex ) ) { <EOL> return true <EOL> } <EOL> path . removeLast ( ) <EOL> continue <EOL> } <EOL> subDeclaration is FirCodeFragment -> { <EOL> val codeFragmentDeclarations = subDeclaration . block . statements . asSequence ( ) . filterIsInstance < FirDeclaration > ( ) <EOL> if ( find ( codeFragmentDeclarations . asIterable ( ) , classIdPathIndex ) ) { <EOL> return true <EOL> } <EOL> continue <EOL> } <EOL> subDeclaration is FirRegularClass && currentClassSegment == subDeclaration . symbol . name -> { <EOL> path += subDeclaration <EOL> if ( find ( subDeclaration . declarations , classIdPathIndex + <NUM_LIT:1> ) ) { <EOL> return true <EOL> } <EOL> path . removeLast ( ) <EOL> } <EOL> } <EOL> } <EOL> return false <EOL> } <EOL> path += firFile <EOL> find ( firFile . declarations , classIdPathIndex = <NUM_LIT:0> ) <EOL> if ( result == null ) { <EOL> return null <EOL> } <EOL> @ Suppress ( "<STR_LIT>" ) <EOL> return FirDesignation ( path = patchDesignationPathIfNeeded ( result ! ! , path ) . ifEmpty { emptyList ( ) } , target = result ! ! , ) <EOL> }

/**
 * @return [FirDesignation] where [FirDesignation.target] is [FirDeclaration]
 *
 * @see declarationTarget
 */


private fun Project . findPropertySafe ( propertyName : String ) : Any ?

= <EOL> try { <EOL> findProperty ( propertyName ) <EOL> } catch ( ex : Exception ) { <EOL> logger . warn ( "<STR_LIT>" , ex ) <EOL> null <EOL> }

/**
 * In case [Project.findProperty] can throw exception, this version catch it and return null
 */


infix fun Tuple1 < * > . zip ( other : EmptyTuple ) : EmptyTuple

= EmptyTuple

/**
 * This file provides zip-functions to all Tuple variants.
 * Given two tuples, `t(a1, ..., an) zip t(a1, ..., an)`, returns a tuple
 * `t(t(a1, b1), ..., t(an, bn))`. If the two tuples have different sizes,
 * the extra elements of the larger tuple will be disregarded.
 * The result is typed as `TupleX<Tuple2<TA1, TB1>, ..., Tuple2<TAn, TBn>>`.
 */


public fun < T > type ( column : ColumnReference < T > , parameters : LetsPlotNonPositionalMappingParametersCategorical < T , LineType > . ( ) -> Unit = { } ) : NonPositionalMapping < T , LineType >

{ <EOL> return addNonPositionalMapping < T , LineType > ( LINE_TYPE , column . name ( ) , LetsPlotNonPositionalMappingParametersCategorical < T , LineType > ( ) . apply ( parameters ) ) <EOL> }

/**
 * Maps the `type` aesthetic to a data column by [ColumnReference].
 *
 * @param column the data column to map to the type.
 * @param parameters optional lambda to configure additional scale parameters.
 * @return a [NonPositionalMapping] object representing the mapping.
 */


public fun < T > type ( column : KProperty < T > , parameters : LetsPlotNonPositionalMappingParametersCategorical < T , LineType > . ( ) -> Unit = { } ) : NonPositionalMapping < T , LineType >

{ <EOL> return addNonPositionalMapping < T , LineType > ( LINE_TYPE , column . name , LetsPlotNonPositionalMappingParametersCategorical < T , LineType > ( ) . apply ( parameters ) ) <EOL> }

/**
 * Maps the `type` aesthetic to a data column by [KProperty].
 *
 * @param column the data column to map to the type.
 * @param parameters optional lambda to configure additional scale parameters.
 * @return a [NonPositionalMapping] object representing the mapping.
 */


public fun type ( column : String , parameters : LetsPlotNonPositionalMappingParametersCategorical < Any ? , LineType > . ( ) -> Unit = { } ) : NonPositionalMapping < Any ? , LineType >

{ <EOL> return addNonPositionalMapping ( LINE_TYPE , column , LetsPlotNonPositionalMappingParametersCategorical < Any ? , LineType > ( ) . apply ( parameters ) ) <EOL> }

/**
 * Maps the `type` aesthetic to a data column by [String].
 *
 * @param column the data column to map to the type.
 * @param parameters optional lambda to configure additional scale parameters.
 * @return a [NonPositionalMapping] object representing the mapping.
 */


public fun < T > type ( values : Iterable < T > , name : String ? = null , parameters : LetsPlotNonPositionalMappingParametersCategorical < T , LineType > . ( ) -> Unit = { } ) : NonPositionalMapping < T , LineType >

{ <EOL> return addNonPositionalMapping ( LINE_TYPE , values . toList ( ) , name , LetsPlotNonPositionalMappingParametersCategorical < T , LineType > ( ) . apply ( parameters ) ) <EOL> }

/**
 * Maps the `type` aesthetic to iterable of values.
 *
 * @param values the iterable containing the categorical values.
 * @param name optional name for this aesthetic mapping.
 * @param parameters optional lambda to configure additional scale parameters.
 * @return a [NonPositionalMapping] object representing the mapping.
 */


public fun < T > type ( values : DataColumn < T > , parameters : LetsPlotNonPositionalMappingParametersCategorical < T , LineType > . ( ) -> Unit = { } ) : NonPositionalMapping < T , LineType >

{ <EOL> return addNonPositionalMapping ( LINE_TYPE , values , LetsPlotNonPositionalMappingParametersCategorical < T , LineType > ( ) . apply ( parameters ) ) <EOL> }

/**
 * Maps the `type` aesthetic to a data column.
 *
 * @param values the data column to map to the type.
 * @param parameters optional lambda to configure additional scale parameters.
 * @return a [NonPositionalMapping] object representing the mapping.
 */


@ Test <EOL> fun `test - launching after Lifecycle finished - will execute code right away` ( )

{ <EOL> project . evaluate ( ) <EOL> val actionAInvocations = AtomicInteger ( <NUM_LIT:0> ) <EOL> val actionBInvocations = AtomicInteger ( <NUM_LIT:0> ) <EOL> project . launch actionB @ { <EOL> project . launch actionA @ { <EOL> assertEquals ( <NUM_LIT:0> , actionBInvocations . get ( ) ) <EOL> assertEquals ( <NUM_LIT:1> , actionAInvocations . incrementAndGet ( ) ) <EOL> } <EOL> assertEquals ( <NUM_LIT:1> , actionAInvocations . get ( ) ) <EOL> assertEquals ( <NUM_LIT:1> , actionBInvocations . incrementAndGet ( ) ) <EOL> } <EOL> assertEquals ( <NUM_LIT:1> , actionAInvocations . get ( ) ) <EOL> assertEquals ( <NUM_LIT:1> , actionBInvocations . get ( ) ) <EOL> }

/**
 * This requirement is important to safely support project.future { }.getOrThrow() patterns (when the lifecycle is finished),
 */


@ Test <EOL> fun `Java primitive annotations work` ( )

{ <EOL> testInline ( """<STR_LIT>""" . trimMargin ( ) , javaConfiguration ) { <EOL> documentablesMergingStage = { module -> <EOL> val type = module . packages . single ( ) . functions . single ( ) . type as GenericTypeConstructor <EOL> assertEquals ( Annotations . Annotation ( DRI ( "<STR_LIT:sample>" , "<STR_LIT:Hello>" ) , emptyMap ( ) ) , type . extra [ Annotations ] ? . directAnnotations ? . values ? . single ( ) ? . single ( ) ) <EOL> assertEquals ( "<STR_LIT>" , type . dri . toString ( ) ) <EOL> } <EOL> } <EOL> }

/**
 * Kotlin Int becomes java int. Java int cannot be annotated in source, but Kotlin Int can be.
 * This is paired with KotlinAsJavaPluginTest.`Java primitive annotations work`()
 */


@ Deprecated ( "<STR_LIT>" ) <EOL> fun source ( sourceSet : KotlinSourceSet )

/**
 * Will add a [KotlinSourceSet] directly into this compilation.
 * This method is deprecated and targets Kotlin 2.1 for its removal.
 * After Kotlin 2.1 there will be exactly one SourceSet associated with a given Kotlin Compilation.
 *
 * In order to include other sources into the compilation, please build a hierarchy of Source Sets instead.
 * See: [KotlinSourceSet.dependsOn] or [KotlinTargetHierarchyDsl].
 * This approach is most applicable if
 * - The sources can be shared for multiple compilations
 * - The sources shall be analyzed in a different context than [defaultSourceSet]
 * - The project uses multiplatform and sources shall provide expects
 *
 *
 * Alternatively, when just including source files from another directory,
 * the [SourceDirectorySet] from the [defaultSourceSet] can be used.
 * This approach is most applicable if
 * - sources are not intended to be shared across multiple compilations
 * - sources shall be analyzed in the same context as other sources in the [defaultSourceSet]
 *
 * #### Example 1: Create a new 'utils' source set and make it available to the 'main' compilation:
 * ```kotlin
 * kotlin {
 * val compilation = target.compilations.getByName("main")
 * val utilsSourceSet = sourceSets.create("utils")
 * compilation.defaultSourceSet.dependsOn(utilsSourceSet)
 * }
 * ```
 *
 * #### Example 2: Add 'src/utils/kotlin' to the main SourceSet
 * ```kotlin
 * kotlin {
 * val compilation = target.compilations.getByName("main")
 * compilation.defaultSourceSet.kotlin.srcDir("src/utils/kotlin")
 * }
 * ```
 * Further details:
 * https://kotl.in/compilation-source-deprecation
 */


protected abstract fun configure ( model : Model < Element > )

/**
 * A customization point to fine-tune existing implementation classes or add new ones.
 *
 * Override this method and use [noImpl] or [impl] in it to configure implementations of tree nodes.
 */


protected abstract fun configureAllImplementations ( model : Model < Element > )

/**
 * A customization point for batch-applying rules to existing implementations.
 *
 * Override this method and use [configureFieldInAllImplementations] to configure fields that are common to multiple implementation
 * classes.
 */


protected fun noImpl ( element : Element )

{ <EOL> element . doesNotNeedImplementation = true <EOL> }

/**
 * Disables generating any implementation classes for [element].
 */


protected fun impl ( element : Element , name : String ? = null , config : ImplementationContext . ( ) -> Unit = { } ) : Implementation

{ <EOL> val implementation = element . implementations . firstOrNull { it . name == name } <EOL> ? : createImplementation ( element , name ) <EOL> val context = ImplementationContext ( implementation ) <EOL> context . apply ( config ) <EOL> elementsWithImpl += element <EOL> return implementation <EOL> }

/**
 * Provides a way to fine-tune a single implementation class for [element].
 *
 * @param element The element whose implementation you want to configure.
 * @param name The name of the implementation class, or `null` if you want to configure the default implementation class for this
 * element. If an implementation with this name already exists, it will be used, otherwise a new implementation will be created.
 * @param config The configuration block. See [ImplementationContext]'s documentation for description of its DSL methods.
 * @return The configured implementation.
 */


protected fun allImplOf ( element : Element , config : ElementContext . ( ) -> Unit )

{ <EOL> val context = ElementContext ( element ) <EOL> context . apply ( config ) <EOL> }

/**
 * Provides a way to fine-tune all implementations of classes deriving from [element].
 */


private fun inheritImplementationFieldSpecifications ( elements : List < Element > )

{ <EOL> for ( element in elements ) { <EOL> for ( implementation in element . implementations ) { <EOL> for ( field in implementation . allFields ) { <EOL> if ( field . implementationDefaultStrategy == null ) { <EOL> for ( ancestor in element . elementAncestorsAndSelfBreadthFirst ( ) ) { <EOL> val inheritedDefaults = ancestor . elementParents <EOL> . mapNotNull { it . element . getOrNull ( field . name ) } <EOL> . mapNotNull { it . implementationDefaultStrategy } <EOL> if ( inheritedDefaults . isNotEmpty ( ) ) { <EOL> field . implementationDefaultStrategy = inheritedDefaults . singleOrNull ( ) <EOL> ? : error ( "<STR_LIT>" ) <EOL> break <EOL> } <EOL> } <EOL> if ( field . implementationDefaultStrategy == null ) { <EOL> field . implementationDefaultStrategy = AbstractField . ImplementationDefaultStrategy . Required <EOL> } <EOL> } <EOL> } <EOL> } <EOL> } <EOL> }

/**
 * Apply the configuration done in [allImplOf] to all actual implementation classes, choosing the
 * most specific configuration for a given implementation, or applies default value if no
 * customized configuration is found.
 */


protected fun configureFieldInAllImplementations ( fieldName : String ? , implementationPredicate : ( Implementation ) -> Boolean = { true } , fieldPredicate : ( ImplementationField ) -> Boolean = { true } , config : ImplementationContext . ( field : String ) -> Unit , )

{ <EOL> for ( element in elementsWithImpl ) { <EOL> for ( implementation in element . implementations ) { <EOL> if ( ! implementationPredicate ( implementation ) ) continue <EOL> if ( fieldName != null && ! implementation . allFields . any { it . name == fieldName } ) continue <EOL> val fields = if ( fieldName != null ) { <EOL> listOf ( implementation [ fieldName ] ) <EOL> } else { <EOL> implementation . allFields <EOL> } <EOL> for ( field in fields . filter ( fieldPredicate ) ) { <EOL> ImplementationContext ( implementation ) . config ( field . name ) <EOL> } <EOL> } <EOL> } <EOL> }

/**
 * Allows to batch-apply [config] to certain fields in _all_ the implementations that satisfy the given
 * [implementationPredicate].
 *
 * @param fieldName The name of the field to configure across all `Impl` classes, or `null` if [config] should be applied to all fields.
 * @param implementationPredicate Only implementations satisfying this predicate will be used in this configuration.
 * @param fieldPredicate Only fields satisfying this predicate will be configured
 * @param config The configuration block. Accepts the field name as an argument.
 * See [ImplementationContext]'s documentation for description of its DSL methods.
 */


protected fun configureAllImplementations ( implementationPredicate : ( Implementation ) -> Boolean = { true } , config : ImplementationContext . ( ) -> Unit , )

{ <EOL> for ( element in elementsWithImpl ) { <EOL> for ( implementation in element . implementations ) { <EOL> if ( ! implementationPredicate ( implementation ) ) continue <EOL> ImplementationContext ( implementation ) . config ( ) <EOL> } <EOL> } <EOL> }

/**
 * Allows to batch-apply [config] to _all_ the implementations that satisfy the given
 * [implementationPredicate].
 *
 * @param implementationPredicate Only implementations satisfying this predicate will be used in this configuration.
 * @param config The configuration block. Accepts the field name as an argument.
 * See [ImplementationContext]'s documentation for description of its DSL methods.
 */


fun isMutable ( vararg fields : String )

{ <EOL> fields . forEach { <EOL> val field = fieldContainer [ it ] <EOL> field . isMutable = true <EOL> } <EOL> }

/**
 * Makes the specified fields in the implementation class mutable
 * (even if they were not configured as mutable in the element configurator).
 */


fun isLateinit ( vararg fields : String )

{ <EOL> fields . forEach { <EOL> val field = fieldContainer [ it ] <EOL> field . implementationDefaultStrategy = AbstractField . ImplementationDefaultStrategy . Lateinit <EOL> } <EOL> }

/**
 * Makes the specified fields in the implementation class `lateinit`
 * (even if they were not configured as `lateinit` in the element configurator).
 */


fun default ( field : String , value : String , withGetter : Boolean = false )

{ <EOL> default ( field ) { <EOL> this . value = value <EOL> this . withGetter = withGetter <EOL> } <EOL> }

/**
 * Specifies the default value of [field] in this implementation class. The default value can be arbitrary code.
 *
 * Use [additionalImports] if the default value uses types/functions that are not otherwise imported.
 */


fun defaultTrue ( vararg fields : String , withGetter : Boolean = false )

{ <EOL> for ( field in fields ) { <EOL> default ( field ) { <EOL> value = "<STR_LIT:true>" <EOL> this . withGetter = withGetter <EOL> } <EOL> } <EOL> }

/**
 * Specifies that the default value of each field of [fields] in this implementation class should be `true`.
 *
 * If [withGetter] is `true`, the fields will be generated as getter-only computed properties with their getter returning `true`,
 * otherwise, as stored properties initialized to `true`.
 */


fun defaultFalse ( vararg fields : String , withGetter : Boolean = false )

{ <EOL> for ( field in fields ) { <EOL> default ( field ) { <EOL> value = "<STR_LIT:false>" <EOL> this . withGetter = withGetter <EOL> } <EOL> } <EOL> }

/**
 * Specifies that the default value of each field of [fields] in this implementation class should be `false`.
 *
 * If [withGetter] is `true`, the fields will be generated as getter-only computed properties with their getter returning `false`,
 * otherwise, as stored properties initialized to `false`.
 */


fun defaultNull ( vararg fields : String , withGetter : Boolean = false )

{ <EOL> for ( field in fields ) { <EOL> default ( field ) { <EOL> value = "<STR_LIT:null>" <EOL> this . withGetter = withGetter <EOL> } <EOL> require ( fieldContainer [ field ] . nullable ) { <EOL> "<STR_LIT>" <EOL> } <EOL> } <EOL> }

/**
 * Specifies that the default value of each field of [fields] in this implementation class should be `null`.
 *
 * If [withGetter] is `true`, the fields will be generated as getter-only computed properties with their getter returning `null`,
 * otherwise, as stored properties initialized to `null`.
 */


fun defaultEmptyList ( vararg fields : String , withGetter : Boolean = false )

{ <EOL> for ( field in fields ) { <EOL> require ( fieldContainer [ field ] . origin is ListField ) { <EOL> "<STR_LIT>" <EOL> } <EOL> default ( field ) { <EOL> value = "<STR_LIT>" <EOL> this . withGetter = withGetter <EOL> } <EOL> } <EOL> }

/**
 * Specifies that the default value of each field of [fields] in this implementation class should be [emptyList].
 *
 * @param withGetter If `true`, the field will be generated as a computed property instead of stored one.
 */


fun default ( field : String , init : DefaultValueContext . ( ) -> Unit )

{ <EOL> DefaultValueContext ( fieldContainer [ field ] ) . apply ( init ) . applyConfiguration ( ) <EOL> }

/**
 * Allows to configure the default value of [field] in this implementation class.
 *
 * See the [DefaultValueContext] documentation for description of its DSL methods.
 */


fun delegateFields ( fields : List < String > , delegate : String )

{ <EOL> for ( field in fields ) { <EOL> default ( field ) { <EOL> this . delegate = delegate <EOL> } <EOL> } <EOL> }

/**
 * Specifies that for each field in the [fields] list its getter should be delegated to the [delegate]'s property of the same name.
 *
 * For example, `delegateFields(listOf("foo", "bar"), "myDelegate")` will result in generating the following properties in
 * the implementation class (provided that there are fields with names "foo" and "bar" in this implementation):
 * ```kotlin
 * val foo: Foo
 * get() = myDelegate.foo
 *
 * val bar: Bar
 * get() = myDelegate.bar
 * ```
 */


{ <EOL> implementation . requiresOptIn = true <EOL> }

/**
 * Call this function if you want this implementation class to be marked with an [OptIn] annotation.
 *
 * This is necessary if some code inside the implementation class requires that [OptIn] annotation.
 */


{ <EOL> implementation . isPublic = true <EOL> }

/**
 * By default, all implementation classes are generated with `internal` visibility.
 *
 * This method allows to forcibly make this implementation `public`.
 */


fun additionalImports ( vararg importables : Importable )

{ <EOL> implementation . additionalImports . addAll ( importables ) <EOL> }

/**
 * Types/functions that you want to additionally import in the file with the implementation class.
 *
 * This is useful if, for example, default values of fields reference classes or functions from other packages.
 *
 * Note that classes referenced in field types will be imported automatically.
 */


public fun KtCallableSymbol . getAllOverriddenSymbols ( ) : List < KtCallableSymbol >

= <EOL> withValidityAssertion { analysisSession . symbolDeclarationOverridesProvider . getAllOverriddenSymbols ( this ) }

/**
 * Return a list of **all** explicitly declared symbols that are overridden by symbol
 *
 * E.g., if we have `A.foo` overrides `B.foo` overrides `C.foo`, all two super declarations `B.foo`, `C.foo` will be returned
 *
 * Unwraps substituted overridden symbols
 * (see [INTERSECTION_OVERRIDE][org.jetbrains.kotlin.analysis.api.symbols.KtSymbolOrigin.INTERSECTION_OVERRIDE] and [SUBSTITUTION_OVERRIDE][org.jetbrains.kotlin.analysis.api.symbols.KtSymbolOrigin.SUBSTITUTION_OVERRIDE]),
 * so such fake declaration won't be returned.
 *
 * @see getDirectlyOverriddenSymbols
 */


public fun KtCallableSymbol . getDirectlyOverriddenSymbols ( ) : List < KtCallableSymbol >

= <EOL> withValidityAssertion { analysisSession . symbolDeclarationOverridesProvider . getDirectlyOverriddenSymbols ( this ) }

/**
 * Return a list of explicitly declared symbols which are **directly** overridden by symbol
 **
 * E.g., if we have `A.foo` overrides `B.foo` overrides `C.foo`, only declarations directly overridden `B.foo` will be returned
 *
 * Unwraps substituted overridden symbols
 * (see [INTERSECTION_OVERRIDE][org.jetbrains.kotlin.analysis.api.symbols.KtSymbolOrigin.INTERSECTION_OVERRIDE] and [SUBSTITUTION_OVERRIDE][org.jetbrains.kotlin.analysis.api.symbols.KtSymbolOrigin.SUBSTITUTION_OVERRIDE]),
 * so such fake declaration won't be returned.
 *
 * @see getAllOverriddenSymbols
 */


public fun KtClassOrObjectSymbol . isSubClassOf ( superClass : KtClassOrObjectSymbol ) : Boolean

= <EOL> withValidityAssertion { analysisSession . symbolDeclarationOverridesProvider . isSubClassOf ( this , superClass ) }

/**
 * Checks if [this] class has [superClass] as its superclass somewhere in the inheritance hierarchy.
 *
 * N.B. The class is not considered to be a subclass of itself, so `myClass.isSubClassOf(myClass)` is always `false`.
 */


public fun KtClassOrObjectSymbol . isDirectSubClassOf ( superClass : KtClassOrObjectSymbol ) : Boolean

= <EOL> withValidityAssertion { analysisSession . symbolDeclarationOverridesProvider . isDirectSubClassOf ( this , superClass ) }

/**
 * Checks if [this] class has [superClass] listed as its direct superclass.
 *
 * N.B. The class is not considered to be a direct subclass of itself, so `myClass.isDirectSubClassOf(myClass)` is always `false`.
 */


internal fun Project . transformMetadataLibrariesForIde ( resolution : MetadataDependencyResolution . ChooseVisibleSourceSets ) : Map < String , Iterable < File > >

{ <EOL> return when ( val metadataProvider = resolution . metadataProvider ) { <EOL> is ProjectMetadataProvider -> resolution . visibleSourceSetNamesExcludingDependsOn . associateWith { visibleSourceSetName -> <EOL> metadataProvider . getSourceSetCompiledMetadata ( visibleSourceSetName ) ? : emptyList ( ) <EOL> } <EOL> is ArtifactMetadataProvider -> transformMetadataLibrariesForIde ( kotlinTransformedMetadataLibraryDirectoryForIde , resolution , metadataProvider ) <EOL> } <EOL> }

/**
 * Returns a map from 'visibleSourceSetName' to the transformed metadata libraries.
 * The map is necessary to support [MetadataDependencyTransformation]'s shape, which
 * is used in import and therefore hard to change.
 *
 * This function will also support project to project dependencies and just returns the compiled output FileCollections to the metadata.
 */


internal fun ObjectFactory . transformMetadataLibrariesForBuild ( resolution : MetadataDependencyResolution . ChooseVisibleSourceSets , outputDirectory : File , materializeFiles : Boolean ) : Iterable < File >

{ <EOL> return when ( resolution . metadataProvider ) { <EOL> is ProjectMetadataProvider -> fileCollection ( ) . from ( resolution . visibleSourceSetNamesExcludingDependsOn . map { visibleSourceSetName -> <EOL> resolution . metadataProvider . getSourceSetCompiledMetadata ( visibleSourceSetName ) <EOL> } ) <EOL> is ArtifactMetadataProvider -> transformMetadataLibrariesForBuild ( resolution , outputDirectory , materializeFiles , resolution . metadataProvider ) <EOL> } <EOL> }

/**
 * Will transform the [CompositeMetadataArtifact] extracting the visible source sets specified in the [resolution]
 * @param materializeFiles: If true, the klib files will actually be created and extracted
 *
 * In case the [resolution] points to a project dependency, then the output file collections will be returned.
 */


public fun < C > valueCol ( valueCol : ColumnAccessor < C > ) : ColumnAccessor < C >

= valueCol . ensureIsValueColumn ( )

/**
 * @include [ValueColReferenceDocs] {@set [CommonValueColDocs.ReceiverArg]}
 */


public fun < C > SingleColumn < DataRow < * > > . valueCol ( valueCol : ColumnAccessor < C > ) : SingleColumn < C >

= <EOL> this . ensureIsColumnGroup ( ) . transformSingle { <EOL> val child = it . getCol ( valueCol ) <EOL> ? : throw IllegalStateException ( "<STR_LIT>" ) <EOL> child . data . ensureIsValueColumn ( ) <EOL> listOf ( child ) <EOL> } . singleImpl ( )

/**
 * @include [ValueColReferenceDocs] {@set [CommonValueColDocs.ReceiverArg] myColumnGroup.}
 */


public fun < C > AnyColumnGroupAccessor . valueCol ( valueCol : ColumnAccessor < C > ) : ColumnAccessor < C >

= <EOL> this . ensureIsColumnGroup ( ) . valueColumn < C > ( valueCol . path ( ) ) . ensureIsValueColumn ( )


public fun < C > String . valueCol ( valueCol : ColumnAccessor < C > ) : ColumnAccessor < C >

= <EOL> columnGroup ( this ) . ensureIsColumnGroup ( ) . valueColumn < C > ( valueCol . path ( ) ) . ensureIsValueColumn ( )

/**
 * @include [ValueColReferenceDocs] {@set [CommonValueColDocs.ReceiverArg] "myColumnGroup".}
 */


public fun < C > KProperty < * > . valueCol ( valueCol : ColumnAccessor < C > ) : ColumnAccessor < C >

/**
 * @include [ValueColReferenceDocs] {@set [CommonValueColDocs.ReceiverArg] Type::myColumnGroup.}
 */


public fun < C > ColumnPath . valueCol ( valueCol : ColumnAccessor < C > ) : ColumnAccessor < C >

/**
 * @include [ValueColReferenceDocs] {@set [CommonValueColDocs.ReceiverArg] "pathTo"["myColumnGroup"].}
 */


@ Suppress ( "<STR_LIT:INAPPLICABLE_JVM_NAME>" ) <EOL> @ JvmName ( "<STR_LIT>" ) <EOL> public fun valueCol ( name : String ) : ColumnAccessor < * >

= valueColumn < Any ? > ( name ) . ensureIsValueColumn ( )

/**
 * @include [ValueColNameDocs] {@set [CommonValueColDocs.ReceiverArg]}
 */


public fun < C > valueCol ( name : String ) : ColumnAccessor < C >

= valueColumn < C > ( name ) . ensureIsValueColumn ( )

/**
 * @include [ValueColNameDocs] {@set [CommonValueColDocs.ReceiverArg]}
 * @include [CommonValueColDocs.ValueColumnTypeParam]
 */


@ Suppress ( "<STR_LIT:INAPPLICABLE_JVM_NAME>" ) <EOL> @ JvmName ( "<STR_LIT>" ) <EOL> public fun SingleColumn < DataRow < * > > . valueCol ( name : String ) : SingleColumn < * >

= <EOL> valueCol < Any ? > ( name )

/**
 * @include [ValueColNameDocs] {@set [CommonValueColDocs.ReceiverArg] myColumnGroup.}
 */


public fun < C > SingleColumn < DataRow < * > > . valueCol ( name : String ) : SingleColumn < C >

= <EOL> this . ensureIsColumnGroup ( ) . transformSingle { <EOL> val child = it . getCol ( name ) ? . cast < C > ( ) <EOL> ? : throw IllegalStateException ( "<STR_LIT>" ) <EOL> child . data . ensureIsValueColumn ( ) <EOL> listOf ( child ) <EOL> } . singleImpl ( )

/**
 * @include [ValueColNameDocs] {@set [CommonValueColDocs.ReceiverArg] myColumnGroup.}
 * @include [CommonValueColDocs.ValueColumnTypeParam]
 */


@ Suppress ( "<STR_LIT:INAPPLICABLE_JVM_NAME>" ) <EOL> @ JvmName ( "<STR_LIT>" ) <EOL> public fun AnyColumnGroupAccessor . valueCol ( name : String ) : ColumnAccessor < * >

= <EOL> valueCol < Any ? > ( name )


public fun < C > AnyColumnGroupAccessor . valueCol ( name : String ) : ColumnAccessor < C >

= <EOL> this . ensureIsColumnGroup ( ) . valueColumn < C > ( name ) . ensureIsValueColumn ( )


@ Suppress ( "<STR_LIT:INAPPLICABLE_JVM_NAME>" ) <EOL> @ JvmName ( "<STR_LIT>" ) <EOL> public fun String . valueCol ( name : String ) : ColumnAccessor < * >

= <EOL> valueCol < Any ? > ( name )

/**
 * @include [ValueColNameDocs] {@set [CommonValueColDocs.ReceiverArg] "myColumnGroup".}
 */


public fun < C > String . valueCol ( name : String ) : ColumnAccessor < C >

= <EOL> columnGroup ( this ) . ensureIsColumnGroup ( ) . valueColumn < C > ( name ) . ensureIsValueColumn ( )

/**
 * @include [ValueColNameDocs] {@set [CommonValueColDocs.ReceiverArg] "myColumnGroup".}
 * @include [CommonValueColDocs.ValueColumnTypeParam]
 */


@ Suppress ( "<STR_LIT:INAPPLICABLE_JVM_NAME>" ) <EOL> @ JvmName ( "<STR_LIT>" ) <EOL> public fun KProperty < * > . valueCol ( name : String ) : ColumnAccessor < * >

= <EOL> valueCol < Any ? > ( name )

/**
 * @include [ValueColNameDocs] {@set [CommonValueColDocs.ReceiverArg] Type::myColumnGroup.}
 */


public fun < C > KProperty < * > . valueCol ( name : String ) : ColumnAccessor < C >

/**
 * @include [ValueColNameDocs] {@set [CommonValueColDocs.ReceiverArg] Type::myColumnGroup.}
 * @include [CommonValueColDocs.ValueColumnTypeParam]
 */


@ Suppress ( "<STR_LIT:INAPPLICABLE_JVM_NAME>" ) <EOL> @ JvmName ( "<STR_LIT>" ) <EOL> public fun ColumnPath . valueCol ( name : String ) : ColumnAccessor < * >

= <EOL> valueCol < Any ? > ( name )

/**
 * @include [ValueColNameDocs] {@set [CommonValueColDocs.ReceiverArg] "pathTo"["myColumnGroup"].}
 */


public fun < C > ColumnPath . valueCol ( name : String ) : ColumnAccessor < C >

/**
 * @include [ValueColNameDocs] {@set [CommonValueColDocs.ReceiverArg] "pathTo"["myColumnGroup"].}
 * @include [CommonValueColDocs.ValueColumnTypeParam]
 */


@ Suppress ( "<STR_LIT:INAPPLICABLE_JVM_NAME>" ) <EOL> @ JvmName ( "<STR_LIT>" ) <EOL> public fun valueCol ( path : ColumnPath ) : ColumnAccessor < * >

= valueColumn < Any ? > ( path ) . ensureIsValueColumn ( )

/**
 * @include [ValueColPathDocs] {@set [CommonValueColDocs.ReceiverArg]}
 */


public fun < C > valueCol ( path : ColumnPath ) : ColumnAccessor < C >

= valueColumn < C > ( path ) . ensureIsValueColumn ( )

/**
 * @include [ValueColPathDocs] {@set [CommonValueColDocs.ReceiverArg]}
 * @include [CommonValueColDocs.ValueColumnTypeParam]
 */


@ Suppress ( "<STR_LIT:INAPPLICABLE_JVM_NAME>" ) <EOL> @ JvmName ( "<STR_LIT>" ) <EOL> public fun SingleColumn < DataRow < * > > . valueCol ( path : ColumnPath ) : SingleColumn < * >

= <EOL> valueCol < Any ? > ( path )

/**
 * @include [ValueColPathDocs] {@set [CommonValueColDocs.ReceiverArg] myColumnGroup.}
 */


public fun < C > SingleColumn < DataRow < * > > . valueCol ( path : ColumnPath ) : SingleColumn < C >

= <EOL> this . ensureIsColumnGroup ( ) . transformSingle { <EOL> val child = it . getCol ( path ) ? . cast < C > ( ) <EOL> ? : throw IllegalStateException ( "<STR_LIT>" ) <EOL> child . data . ensureIsValueColumn ( ) <EOL> listOf ( child ) <EOL> } . singleImpl ( )

/**
 * @include [ValueColPathDocs] {@set [CommonValueColDocs.ReceiverArg] myColumnGroup.}
 * @include [CommonValueColDocs.ValueColumnTypeParam]
 */


@ Suppress ( "<STR_LIT:INAPPLICABLE_JVM_NAME>" ) <EOL> @ JvmName ( "<STR_LIT>" ) <EOL> public fun AnyColumnGroupAccessor . valueCol ( path : ColumnPath ) : ColumnAccessor < * >

= <EOL> valueCol < Any ? > ( path )


public fun < C > AnyColumnGroupAccessor . valueCol ( path : ColumnPath ) : ColumnAccessor < C >

= <EOL> this . ensureIsColumnGroup ( ) . valueColumn < C > ( path ) . ensureIsValueColumn ( )


@ Suppress ( "<STR_LIT:INAPPLICABLE_JVM_NAME>" ) <EOL> @ JvmName ( "<STR_LIT>" ) <EOL> public fun String . valueCol ( path : ColumnPath ) : ColumnAccessor < * >

= <EOL> valueCol < Any ? > ( path )

/**
 * @include [ValueColPathDocs] {@set [CommonValueColDocs.ReceiverArg] "myColumnGroup".}
 */


public fun < C > String . valueCol ( path : ColumnPath ) : ColumnAccessor < C >

= <EOL> columnGroup ( this ) . ensureIsColumnGroup ( ) . valueColumn < C > ( path ) . ensureIsValueColumn ( )

/**
 * @include [ValueColPathDocs] {@set [CommonValueColDocs.ReceiverArg] "myColumnGroup".}
 * @include [CommonValueColDocs.ValueColumnTypeParam]
 */


@ Suppress ( "<STR_LIT:INAPPLICABLE_JVM_NAME>" ) <EOL> @ JvmName ( "<STR_LIT>" ) <EOL> public fun KProperty < * > . valueCol ( path : ColumnPath ) : ColumnAccessor < * >

= <EOL> valueCol < Any ? > ( path )

/**
 * @include [ValueColPathDocs] {@set [CommonValueColDocs.ReceiverArg] Type::myColumnGroup.}
 */


public fun < C > KProperty < * > . valueCol ( path : ColumnPath ) : ColumnAccessor < C >

/**
 * @include [ValueColPathDocs] {@set [CommonValueColDocs.ReceiverArg] Type::myColumnGroup.}
 * @include [CommonValueColDocs.ValueColumnTypeParam]
 */


@ Suppress ( "<STR_LIT:INAPPLICABLE_JVM_NAME>" ) <EOL> @ JvmName ( "<STR_LIT>" ) <EOL> public fun ColumnPath . valueCol ( path : ColumnPath ) : ColumnAccessor < * >

= <EOL> valueCol < Any ? > ( path )

/**
 * @include [ValueColPathDocs] {@set [CommonValueColDocs.ReceiverArg] "pathTo"["myColumnGroup"].}
 */


public fun < C > ColumnPath . valueCol ( path : ColumnPath ) : ColumnAccessor < C >

/**
 * @include [ValueColPathDocs] {@set [CommonValueColDocs.ReceiverArg] "pathTo"["myColumnGroup"].}
 * @include [CommonValueColDocs.ValueColumnTypeParam]
 */


public fun < C > valueCol ( property : KProperty < C > ) : SingleColumn < C >

= valueColumn ( property ) . ensureIsValueColumn ( )

/**
 * @include [ValueColKPropertyDocs] {@set [CommonValueColDocs.ReceiverArg]}
 */


public fun < C > SingleColumn < DataRow < * > > . valueCol ( property : KProperty < C > ) : SingleColumn < C >

= <EOL> valueCol < C > ( property . name )

/**
 * @include [ValueColKPropertyDocs] {@set [CommonValueColDocs.ReceiverArg] myColumnGroup.}
 */


public fun < C > AnyColumnGroupAccessor . valueCol ( property : KProperty < C > ) : ColumnAccessor < C >

= <EOL> this . ensureIsColumnGroup ( ) . valueColumn ( property ) . ensureIsValueColumn ( )


public fun < C > String . valueCol ( property : KProperty < C > ) : ColumnAccessor < C >

= <EOL> columnGroup ( this ) . ensureIsColumnGroup ( ) . valueColumn ( property ) . ensureIsValueColumn ( )

/**
 * @include [ValueColKPropertyDocs] {@set [CommonValueColDocs.ReceiverArg] "myColumnGroup".}
 */


public fun < C > KProperty < * > . valueCol ( property : KProperty < C > ) : ColumnAccessor < C >

/**
 * @include [ValueColKPropertyDocs] {@set [CommonValueColDocs.ReceiverArg] Type::myColumnGroup.}
 */


public fun < C > ColumnPath . valueCol ( property : KProperty < C > ) : ColumnAccessor < C >

/**
 * @include [ValueColKPropertyDocs] {@set [CommonValueColDocs.ReceiverArg] "pathTo"["myColumnGroup"].}
 */


public fun < C > ColumnSet < C > . valueCol ( index : Int ) : SingleColumn < C >

= getAt ( index ) . ensureIsValueColumn ( )

/**
 * @include [ValueColIndexDocs] {@set [CommonValueColDocs.ReceiverArg] `[colsOf][ColumnsSelectionDsl.colsOf]`<`[Int][Int]`>().}
 * @include [CommonValueColDocs.ValueColumnTypeParam]
 * {@set [CommonValueColDocs.ExampleArg] {@include [CommonValueColDocs.SingleExample]}}
 */


@ Suppress ( "<STR_LIT:INAPPLICABLE_JVM_NAME>" ) <EOL> @ JvmName ( "<STR_LIT>" ) <EOL> public fun ColumnsSelectionDsl < * > . valueCol ( index : Int ) : SingleColumn < * >

= <EOL> valueCol < Any ? > ( index )

/**
 * @include [ValueColIndexDocs] {@set [CommonValueColDocs.ReceiverArg]}
 */


public fun < C > ColumnsSelectionDsl < * > . valueCol ( index : Int ) : SingleColumn < C >

= <EOL> asSingleColumn ( ) . valueCol < C > ( index )

/**
 * @include [ValueColIndexDocs] {@set [CommonValueColDocs.ReceiverArg]}
 * @include [CommonValueColDocs.ValueColumnTypeParam]
 */


@ Suppress ( "<STR_LIT:INAPPLICABLE_JVM_NAME>" ) <EOL> @ JvmName ( "<STR_LIT>" ) <EOL> public fun SingleColumn < DataRow < * > > . valueCol ( index : Int ) : SingleColumn < * >

= <EOL> valueCol < Any ? > ( index )

/**
 * @include [ValueColIndexDocs] {@set [CommonValueColDocs.ReceiverArg] myColumnGroup.}
 */


public fun < C > SingleColumn < DataRow < * > > . valueCol ( index : Int ) : SingleColumn < C >

= <EOL> this . ensureIsColumnGroup ( ) <EOL> . allColumnsInternal ( ) <EOL> . getAt ( index ) <EOL> . ensureIsValueColumn ( ) <EOL> . cast ( )

/**
 * @include [ValueColIndexDocs] {@set [CommonValueColDocs.ReceiverArg] myColumnGroup.}
 * @include [CommonValueColDocs.ValueColumnTypeParam]
 */


@ Suppress ( "<STR_LIT:INAPPLICABLE_JVM_NAME>" ) <EOL> @ JvmName ( "<STR_LIT>" ) <EOL> public fun String . valueCol ( index : Int ) : SingleColumn < * >

= <EOL> valueCol < Any ? > ( index )

/**
 * @include [ValueColIndexDocs] {@set [CommonValueColDocs.ReceiverArg] "myColumnGroup".}
 */


public fun < C > String . valueCol ( index : Int ) : SingleColumn < C >

= <EOL> columnGroup ( this ) . valueCol < C > ( index )

/**
 * @include [ValueColIndexDocs] {@set [CommonValueColDocs.ReceiverArg] "myColumnGroup".}
 * @include [CommonValueColDocs.ValueColumnTypeParam]
 */


@ Suppress ( "<STR_LIT:INAPPLICABLE_JVM_NAME>" ) <EOL> @ JvmName ( "<STR_LIT>" ) <EOL> public fun KProperty < * > . valueCol ( index : Int ) : SingleColumn < * >

= <EOL> valueCol < Any ? > ( index )

/**
 * @include [ValueColIndexDocs] {@set [CommonValueColDocs.ReceiverArg] Type::myColumnGroup.}
 */


public fun < C > KProperty < * > . valueCol ( index : Int ) : SingleColumn < C >

/**
 * @include [ValueColIndexDocs] {@set [CommonValueColDocs.ReceiverArg] Type::myColumnGroup.}
 * @include [CommonValueColDocs.ValueColumnTypeParam]
 */


@ Suppress ( "<STR_LIT:INAPPLICABLE_JVM_NAME>" ) <EOL> @ JvmName ( "<STR_LIT>" ) <EOL> public fun ColumnPath . valueCol ( index : Int ) : SingleColumn < * >

= <EOL> valueCol < Any ? > ( index )

/**
 * @include [ValueColIndexDocs] {@set [CommonValueColDocs.ReceiverArg] "pathTo"["myColumnGroup"].}
 */


public fun < C > ColumnPath . valueCol ( index : Int ) : SingleColumn < C >

/**
 * @include [ValueColIndexDocs] {@set [CommonValueColDocs.ReceiverArg] "pathTo"["myColumnGroup"].}
 * @include [CommonValueColDocs.ValueColumnTypeParam]
 */


internal fun < C > SingleColumn < C > . ensureIsValueColumn ( ) : SingleColumn < C >

= <EOL> onResolve { col : ColumnWithPath < * > ? -> <EOL> require ( col ? . isValueColumn ( ) != false ) { <EOL> "<STR_LIT>" <EOL> } <EOL> }

/**
 * Checks the validity of this [SingleColumn],
 * by adding a check to see it's a [ValueColumn] (so, a [SingleColumn]<*>)
 * and throwing an [IllegalArgumentException] if it's not.
 */


internal fun < C > ColumnAccessor < C > . ensureIsValueColumn ( ) : ColumnAccessor < C >

/** @include [SingleColumn.ensureIsValueColumn] */


inline fun TypeSystemInferenceExtensionContext . isProperTypeForFixation ( type : KotlinTypeMarker , notFixedTypeVariables : Set < TypeConstructorMarker > , isProper : ( KotlinTypeMarker ) -> Boolean ) : Boolean

{ <EOL> if ( type . typeConstructor ( ) in notFixedTypeVariables ) return false <EOL> return isProper ( type ) && extractProjectionsForAllCapturedTypes ( type ) . all ( isProper ) <EOL> }

/**
 * Returns `false` for fixed type variables types even if `isProper(type) == true`
 * Thus allowing only non-TVs types to be used for fixation on top level.
 * While this limitation is important, it doesn't really limit final results because when we have a constraint like T <: E or E <: T
 * and we're going to fix T into E, we assume that if E has some other constraints, they are being incorporated to T, so we would choose
 * them instead of E itself.
 */


fun sortClassMembers ( classNode : ClassNode )

{ <EOL> classNode . fields . sortWith ( compareBy ( { it . name } , { it . desc } ) ) <EOL> classNode . methods . sortWith ( compareBy ( { it . name } , { it . desc } ) ) <EOL> }

/**
 * Sorts fields and methods in the given class.
 *
 * This is useful when we want to ensure a change in the order of the fields and methods doesn't impact the snapshot (i.e., if their
 * order has changed in the `.class` file, it shouldn't require recompilation of the other source files).
 */


fun PsiElement . isOptInAllowed ( annotationFqName : FqName , languageVersionSettings : LanguageVersionSettings , bindingContext : BindingContext ) : Boolean

= isOptInAllowed ( annotationFqName , languageVersionSettings , bindingContext , subclassesOnly = false )

/**
 * Checks whether there's an element lexically above in the tree, annotated with `@OptIn(X::class)`, or a declaration
 * annotated with `@X` where [annotationFqName] is the FQ name of X.
 *
 * This implementation also was rewritten for K2 use in intellij repository.
 * See `org.jetbrains.kotlin.idea.base.fir.codeInsight.FirOptInUsageCheckerKt#isOptInAllowed`.
 */


@ ExperimentalCoroutinesApi <EOL> public suspend inline fun whileSelect ( crossinline builder : SelectBuilder < Boolean > . ( ) -> Unit )

{ <EOL> while ( select ( builder ) ) { } <EOL> }

/**
 * Loops while [select] expression returns `true`.
 *
 * The statement of the form:
 *
 * ```
 * whileSelect {
 * /*body*/
 * }
 * ```
 *
 * is a shortcut for:
 *
 * ```
 * while(select<Boolean> {
 * /*body*/
 * }) {}
 *
 * **Note: This is an experimental api.** It may be replaced with a higher-performance DSL for selection from loops.
 */


{ klibFiles . add ( project . files ( file ) ) }


= klibInternal ( lib , false )


fun artifact ( libraryProject : Project , name : String , friend : Boolean )

{ <EOL> project . evaluationDependsOn ( libraryProject ) <EOL> klibInternal ( libraryProject . konanArtifactsContainer . getByName ( name ) , friend ) <EOL> }

/** Artifact in the specified project by name */


fun artifact ( name : String , friend : Boolean )

= artifact ( project , name , friend )

/** Artifact in the current project by name */


fun artifact ( artifact : KonanLibrary )

= klib ( artifact )


fun artifact ( artifact : KonanInteropLibrary )

= klib ( artifact )


fun allLibrariesFrom ( vararg libraryProjects : Project )

= allArtifactsFromInternal ( libraryProjects ) { <EOL> it is KonanLibrary || it is KonanInteropLibrary <EOL> }

/** All libraries (both interop and non-interop ones) from the projects by direct references */


fun allInteropLibrariesFrom ( vararg libraryProjects : Project )

= allArtifactsFromInternal ( libraryProjects ) { <EOL> it is KonanInteropLibrary <EOL> }

/** All interop libraries from the projects by direct references */


protected open fun makeIncrementalCompilationFeatures ( ) : IncrementalCompilationFeatures

{ <EOL> return IncrementalCompilationFeatures ( preciseCompilationResultsBackup = preciseCompilationResultsBackup . get ( ) , keepIncrementalCompilationCachesInMemory = keepIncrementalCompilationCachesInMemory . get ( ) , enableUnsafeIncrementalCompilationForMultiplatform = enableUnsafeIncrementalCompilationForMultiplatform . get ( ) , ) <EOL> }

/**
 * Entry point for getting IC feature toggles in Gradle. Child classes should override it
 * if they have a platform-specific Input.
 */


internal abstract fun callCompilerAsync ( args : T , inputChanges : InputChanges , taskOutputsBackup : TaskOutputsBackup ? <EOL> )

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


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public fun Node . clear ( )

{ <EOL> while ( hasChildNodes ( ) ) { <EOL> removeChild ( firstChild ! ! ) <EOL> } <EOL> }

/** Removes all the children from this node. */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public fun Element . appendText ( text : String ) : Element

{ <EOL> appendChild ( ownerDocument ! ! . createTextNode ( text ) ) <EOL> return this <EOL> }

/**
 * Creates text node and append it to the element.
 *
 * @return this element
 */


internal fun Project . dokkaBuild ( configure : DokkaBuildProperties . ( ) -> Unit )

= <EOL> extensions . configure ( configure )

/**
 * Configures the [dokkaBuild][dokkabuild.DokkaBuildProperties] extension.
 */


internal fun collectKotlinSupertypesWithKind ( documentable : Iterable < Documentable > , sourceSet : DokkaConfiguration . DokkaSourceSet ) : Map < DRI , SuperclassesWithKind >

{ <EOL> val typeTranslator = TypeTranslator ( sourceSet , AnnotationTranslator ( ) ) <EOL> val hierarchy = mutableMapOf < DRI , SuperclassesWithKind > ( ) <EOL> analyze ( kotlinAnalysis . getModule ( sourceSet ) ) { <EOL> documentable . filterIsInstance < DClasslike > ( ) . forEach { <EOL> val source = it . sources [ sourceSet ] <EOL> if ( source is KtPsiDocumentableSource ) { <EOL> ( source . psi as? KtClassOrObject ) ? . let { psi -> <EOL> val type = psi . getNamedClassOrObjectSymbol ( ) ? . buildSelfClassType ( ) ? : return@analyze <EOL> collectSupertypesWithKindFromKtType ( typeTranslator , with ( typeTranslator ) { <EOL> toTypeConstructorWithKindFrom ( type ) <EOL> } to type , hierarchy ) <EOL> } <EOL> } <EOL> } <EOL> } <EOL> return hierarchy <EOL> }

/**
 * Currently, it works only for Symbols
 */


private fun String . cleanContentPreservingLinesLayout ( start : Int = <NUM_LIT:0> , end : Int = this . length )

= subSequence ( start , end ) <EOL> . map { if ( it == '<CHAR_LIT:\r>' || it == '<CHAR_LIT:\n>' ) it else '<CHAR_LIT:U+0020>' }

/**
 * Replaces every character with ' ' except end of line
 */


fun File . toScriptSource ( ) : SourceCode

= FileScriptSource ( this )

/**
 * Converts the file into the SourceCode
 */


fun String . toScriptSource ( name : String ? = null ) : SourceCode

= StringScriptSource ( this , name )

/**
 * Converts the String into the SourceCode
 */


public fun < I > Operation < I , FloatData > . normalize ( block : Normalizing . ( ) -> Unit ) : Operation < I , FloatData >

{ <EOL> return PreprocessingPipeline ( this , Normalizing ( ) . apply ( block ) ) <EOL> }

/** Applies [Normalizing] preprocessor to the tensor to normalize it with given mean and std values. */


public fun < I > Operation < I , FloatData > . rescale ( block : Rescaling . ( ) -> Unit ) : Operation < I , FloatData >

{ <EOL> return PreprocessingPipeline ( this , Rescaling ( ) . apply ( block ) ) <EOL> }

/** Applies [Rescaling] preprocessor to the tensor to scale each value by a given coefficient. */


@ PublishedApi <EOL> internal actual fun < T : Throwable > checkResultIsFailure ( exceptionClass : KClass < T > , message : String ? , blockResult : Result < Unit > ) : T

{ <EOL> blockResult . fold ( onSuccess = { <EOL> val msg = messagePrefix ( message ) <EOL> asserter . fail ( msg + "<STR_LIT>" ) <EOL> } , onFailure = { e -> <EOL> if ( exceptionClass . java . isInstance ( e ) ) { <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> return e as T <EOL> } <EOL> asserter . fail ( messagePrefix ( message ) + "<STR_LIT>" , e ) <EOL> } ) <EOL> }

/** Asserts that a [blockResult] is a failure with the specific exception type being thrown. */


@ Deprecated ( "<STR_LIT>" , level = DeprecationLevel . HIDDEN ) <EOL> @ JvmName ( "<STR_LIT>" ) <EOL> public fun assertFailsNoInline ( block : ( ) -> Unit ) : Throwable

= assertFails ( block )


@ Deprecated ( "<STR_LIT>" , level = DeprecationLevel . HIDDEN ) <EOL> @ JvmName ( "<STR_LIT>" ) <EOL> public fun assertFailsNoInline ( message : String ? , block : ( ) -> Unit ) : Throwable

= assertFails ( message , block )


@ Deprecated ( "<STR_LIT>" , level = DeprecationLevel . HIDDEN ) <EOL> @ JvmName ( "<STR_LIT>" ) <EOL> public fun < T : Throwable > assertFailsWithNoInline ( exceptionClass : KClass < T > , block : ( ) -> Unit ) : T

= assertFailsWith ( exceptionClass , block )


@ Deprecated ( "<STR_LIT>" , level = DeprecationLevel . HIDDEN ) <EOL> @ JvmName ( "<STR_LIT>" ) <EOL> public fun < T : Throwable > assertFailsWithNoInline ( exceptionClass : KClass < T > , message : String ? , block : ( ) -> Unit ) : T

= <EOL> assertFailsWith ( exceptionClass , message , block )


@ Suppress ( "<STR_LIT:INVISIBLE_REFERENCE>" , "<STR_LIT:INVISIBLE_MEMBER>" ) <EOL> @ InlineOnly <EOL> public actual inline fun todo ( @ Suppress ( "<STR_LIT:UNUSED_PARAMETER>" ) block : ( ) -> Unit )

{ <EOL> println ( "<STR_LIT>" + currentStackTrace ( ) [ <NUM_LIT:0> ] ) <EOL> }

/**
 * Takes the given [block] of test code and _doesn't_ execute it.
 *
 * This keeps the code under test referenced, but doesn't actually test it until it is implemented.
 */


@ Suppress ( "<STR_LIT:INVISIBLE_REFERENCE>" , "<STR_LIT:INVISIBLE_MEMBER>" ) <EOL> @ InlineOnly <EOL> public inline fun currentStackTrace ( ) : Array < StackTraceElement >

= @ Suppress ( "<STR_LIT>" ) ( java . lang . Exception ( ) as java . lang . Throwable ) . stackTrace

/**
 * Returns an array of stack trace elements, each representing one stack frame.
 * The first element of the array (assuming the array is not empty) represents the top of the
 * stack, which is the place where [currentStackTrace] function was called from.
 */


internal actual fun AssertionErrorWithCause ( message : String ? , cause : Throwable ? ) : AssertionError

{ <EOL> val assertionError = if ( message == null ) AssertionError ( ) else AssertionError ( message ) <EOL> assertionError . initCause ( cause ) <EOL> return assertionError <EOL> }

/** Platform-specific construction of AssertionError with cause */


fun registerReplacement ( original : IrValueDeclaration , replacement : IrValueDeclaration )

{ <EOL> oldValueSymbol2NewValueSymbol [ original . symbol ] = replacement . symbol <EOL> }

/**
 * Registers one-to-one replacement
 */


fun registerReplacement ( original : IrValueDeclaration , replacement : ValueDeclarationMfvcNodeInstance )

{ <EOL> oldSymbol2MfvcNodeInstance [ original . symbol ] = replacement <EOL> }

/**
 * Registers replacement of a simple expression with flattened MFVC instance
 */


private fun IrBlockBuilder . makeFlattenedExpressionsWithGivenSafety ( node : MfvcNode , safe : Boolean , expression : IrExpression )

= if ( safe ) { <EOL> val ( forVariables , rest ) = splitExpressions ( flattenExpression ( expression ) ) <EOL> val variables = when ( node ) { <EOL> is LeafMfvcNode -> forVariables . map { expr -> irTemporary ( expr ) } <EOL> is MfvcNodeWithSubnodes -> forVariables . zip ( node . leaves ) { expr , leaf -> <EOL> irTemporary ( expr , nameHint = leaf . fullFieldName . asString ( ) ) <EOL> } <EOL> } <EOL> variables . map { irGet ( it ) } + rest <EOL> } else { <EOL> flattenExpression ( expression ) <EOL> }

/**
 * @param safe whether protect from partial (because of a potential exception) initialization or not
 */


private fun IrBuilderWithScope . removeExtraSetVariablesFromExpressionList ( block : IrContainerExpression , variables : List < IrVariable > ) : List < IrExpression >

{ <EOL> val forbiddenVariables = mutableSetOf < IrVariable > ( ) <EOL> val variablesSet = variables . toSet ( ) <EOL> val standaloneExpressions = mutableListOf < IrExpression > ( ) <EOL> val resultVariables = variables . toMutableList ( ) <EOL> fun recur ( block : IrContainerExpression ) : Boolean { <EOL> while ( block . statements . isNotEmpty ( ) && resultVariables . isNotEmpty ( ) ) { <EOL> val statement = block . statements . last ( ) <EOL> when { <EOL> statement is IrContainerExpression -> if ( recur ( statement ) ) { <EOL> if ( statement . statements . isEmpty ( ) ) { <EOL> block . statements . removeLast ( ) <EOL> } <EOL> return true <EOL> } else { <EOL> require ( statement . statements . isEmpty ( ) || resultVariables . isEmpty ( ) ) { "<STR_LIT>" } <EOL> if ( statement . statements . isEmpty ( ) ) { <EOL> block . statements . removeLast ( ) <EOL> } <EOL> } <EOL> statement !is IrSetValue -> return true <EOL> statement . symbol . owner != resultVariables . last ( ) -> return true <EOL> statement . symbol . owner in forbiddenVariables -> return true <EOL> else -> { <EOL> standaloneExpressions . add ( statement . value ) <EOL> resultVariables . removeLast ( ) <EOL> block . statements . removeLast ( ) <EOL> statement . value . acceptVoid ( object : IrElementVisitorVoid { <EOL> override fun visitElement ( element : IrElement ) { <EOL> element . acceptChildrenVoid ( this ) <EOL> } <EOL> override fun visitValueAccess ( expression : IrValueAccessExpression ) { <EOL> val valueDeclaration = expression . symbol . owner <EOL> if ( valueDeclaration is IrVariable && valueDeclaration in variablesSet ) { <EOL> forbiddenVariables . add ( valueDeclaration ) <EOL> } <EOL> super . visitValueAccess ( expression ) <EOL> } <EOL> } ) <EOL> } <EOL> } <EOL> } <EOL> return false <EOL> } <EOL> recur ( block ) <EOL> return resultVariables . map { irGet ( it ) } + standaloneExpressions . asReversed ( ) <EOL> }

/**
 * Inlines initialization of variables when possible and returns their values
 *
 * Example:
 * Before:
 * val a = 2
 * val b = 3
 * val c = b + 1
 * [a, b, c]
 *
 * After:
 * val a = 2
 * val b = 3
 * [a, b, b + 1]
 */


fun IrBlockBuilder . flattenExpression ( expression : IrExpression ) : List < IrExpression >

{ <EOL> if ( ! expression . type . needsMfvcFlattening ( ) ) { <EOL> return listOf ( expression . transform ( this @ JvmMultiFieldValueClassLowering , null ) ) <EOL> } <EOL> val rootMfvcNode = replacements . getRootMfvcNode ( expression . type . erasedUpperBound ) <EOL> val typeArguments = makeTypeArgumentsFromType ( expression . type as IrSimpleType ) <EOL> val variables = rootMfvcNode . leaves . map { <EOL> savableStandaloneVariable ( type = it . type . substitute ( typeArguments ) , origin = IrDeclarationOrigin . IR_TEMPORARY_VARIABLE , saveVariable = :: variablesSaver , isVar = false , ) <EOL> } <EOL> val instance = ValueDeclarationMfvcNodeInstance ( rootMfvcNode , typeArguments , variables ) <EOL> val block = irBlock { <EOL> flattenExpressionTo ( expression , instance ) <EOL> } <EOL> val expressions = removeExtraSetVariablesFromExpressionList ( block , variables ) <EOL> if ( block . statements . isNotEmpty ( ) ) { <EOL> + block . unwrapBlock ( ) <EOL> } <EOL> return expressions <EOL> }

/**
 * Takes not transformed expression and returns its flattened transformed representation (expressions)
 */


private fun IrBlockBuilder . flattenExpressionTo ( expression : IrExpression , instance : MfvcNodeInstance )

{ <EOL> val rootNode = replacements . getRootMfvcNodeOrNull ( if ( expression is IrConstructorCall ) expression . symbol . owner . constructedClass else expression . type . erasedUpperBound ) <EOL> val type = if ( expression is IrConstructorCall ) expression . symbol . owner . constructedClass . defaultType else expression . type <EOL> if ( type == context . irBuiltIns . nothingType ) { <EOL> return flattenExpressionTo ( irImplicitCast ( expression , instance . type ) , instance ) <EOL> } <EOL> val lowering = this@JvmMultiFieldValueClassLowering <EOL> if ( rootNode == null || ! type . needsMfvcFlattening ( ) || instance . size == <NUM_LIT:1> ) { <EOL> require ( instance . size == <NUM_LIT:1> ) { "<STR_LIT>" } <EOL> instance . addSetterStatements ( this , listOf ( expression . transform ( lowering , null ) ) ) <EOL> return <EOL> } <EOL> require ( rootNode . leavesCount == instance . size ) { <EOL> "<STR_LIT>" <EOL> } <EOL> if ( expression is IrWhen ) { <EOL> for ( branch in expression . branches ) { <EOL> branch . condition = branch . condition . transform ( lowering , null ) <EOL> branch . result = irBlock { <EOL> flattenExpressionTo ( branch . result , instance ) <EOL> } . unwrapBlock ( ) <EOL> } <EOL> + expression <EOL> return <EOL> } <EOL> if ( expression is IrTry ) { <EOL> expression . tryResult = irBlock { flattenExpressionTo ( expression . tryResult , instance ) } . unwrapBlock ( ) <EOL> expression . catches . replaceAll { irCatch ( it . catchParameter , irBlock { flattenExpressionTo ( it . result , instance ) } . unwrapBlock ( ) ) } <EOL> expression . finallyExpression = expression . finallyExpression ? . transform ( lowering , null ) <EOL> + expression <EOL> return <EOL> } <EOL> if ( expression is IrConstructorCall ) { <EOL> val constructor = expression . symbol . owner <EOL> if ( constructor . isPrimary && constructor . constructedClass . isMultiFieldValueClass && constructor . origin != JvmLoweredDeclarationOrigin . STATIC_MULTI_FIELD_VALUE_CLASS_CONSTRUCTOR ) { <EOL> val oldArguments = List ( expression . valueArgumentsCount ) { <EOL> expression . getValueArgument ( it ) <EOL> ? : error ( "<STR_LIT>" ) <EOL> } <EOL> require ( rootNode . subnodes . size == oldArguments . size ) { <EOL> "<STR_LIT>" <EOL> } <EOL> for ( ( subnode , argument ) in rootNode . subnodes zip oldArguments ) { <EOL> flattenExpressionTo ( argument , instance [ subnode . name ] ! ! ) <EOL> } <EOL> + irCall ( rootNode . primaryConstructorImpl . let { rootNode . throwWhenNotExternalIsNull ( it ) ; it } ) . apply { <EOL> copyTypeArgumentsFrom ( expression ) <EOL> val flattenedGetterExpressions = <EOL> instance . makeFlattenedGetterExpressions ( this @ flattenExpressionTo , irCurrentClass , :: registerPossibleExtraBoxUsage ) <EOL> for ( ( index , leafExpression ) in flattenedGetterExpressions . withIndex ( ) ) { <EOL> putValueArgument ( index , leafExpression ) <EOL> } <EOL> } <EOL> return <EOL> } <EOL> } <EOL> val nullableTransformedExpression = expression . transform ( this @ JvmMultiFieldValueClassLowering , null ) <EOL> val transformedExpression = castExpressionToNotNullTypeIfNeeded ( nullableTransformedExpression , instance . type ) <EOL> val addedSettersToFlattened = valueDeclarationsRemapper . handleFlattenedGetterExpressions ( this , transformedExpression ) { <EOL> require ( it . size == instance . size ) { "<STR_LIT>" } <EOL> instance . makeSetterExpressions ( this , it ) <EOL> } <EOL> if ( addedSettersToFlattened != null ) { <EOL> + addedSettersToFlattened <EOL> return <EOL> } <EOL> val expressionInstance = rootNode . createInstanceFromBox ( this , transformedExpression , AccessType . ChooseEffective , :: variablesSaver , ) <EOL> require ( expressionInstance . size == instance . size ) { "<STR_LIT>" } <EOL> instance . addSetterStatements ( this , expressionInstance . makeFlattenedGetterExpressions ( this , irCurrentClass , :: registerPossibleExtraBoxUsage ) ) <EOL> }

/**
 * Takes not transformed expression and initialized given MfvcNodeInstance with transformed version of it
 */


private fun IrBody . removeAllExtraBoxes ( )

{ <EOL> accept ( object : IrElementVisitor < Unit , Boolean > { <EOL> override fun visitElement ( element : IrElement , data : Boolean ) { <EOL> element . acceptChildren ( this , true ) <EOL> } <EOL> override fun visitTypeOperator ( expression : IrTypeOperatorCall , data : Boolean ) { <EOL> expression . acceptChildren ( this , data ) <EOL> } <EOL> private tailrec fun getFunctionCallOrNull ( statement : IrStatement ) : IrCall ? = when ( statement ) { <EOL> is IrTypeOperatorCall -> getFunctionCallOrNull ( statement . argument ) <EOL> is IrCall -> statement <EOL> else -> null <EOL> } <EOL> override fun visitFunction ( declaration : IrFunction , data : Boolean ) = Unit <EOL> override fun visitClass ( declaration : IrClass , data : Boolean ) = Unit <EOL> override fun visitContainerExpression ( expression : IrContainerExpression , data : Boolean ) { <EOL> handleStatementContainer ( expression , data ) <EOL> } <EOL> override fun visitWhen ( expression : IrWhen , data : Boolean ) { <EOL> expression . acceptChildren ( this , data ) <EOL> } <EOL> override fun visitCatch ( aCatch : IrCatch , data : Boolean ) { <EOL> aCatch . acceptChildren ( this , data ) <EOL> } <EOL> override fun visitTry ( aTry : IrTry , data : Boolean ) { <EOL> aTry . tryResult . accept ( this , data ) <EOL> aTry . catches . forEach { it . accept ( this , data ) } <EOL> aTry . finallyExpression ? . accept ( this , false ) <EOL> } <EOL> override fun visitBranch ( branch : IrBranch , data : Boolean ) { <EOL> branch . condition . accept ( this , true ) <EOL> branch . result . accept ( this , data ) <EOL> } <EOL> override fun visitBlockBody ( body : IrBlockBody , data : Boolean ) { <EOL> handleStatementContainer ( body , data ) <EOL> } <EOL> private fun handleStatementContainer ( expression : IrStatementContainer , resultIsUsed : Boolean ) { <EOL> for ( statement in expression . statements . subListWithoutLast ( <NUM_LIT:1> ) ) { <EOL> statement . accept ( this , false ) <EOL> } <EOL> expression . statements . lastOrNull ( ) ? . accept ( this , resultIsUsed ) <EOL> val statementsToRemove = mutableSetOf < IrStatement > ( ) <EOL> for ( statement in expression . statements . subListWithoutLast ( if ( resultIsUsed ) <NUM_LIT:1> else <NUM_LIT:0> ) ) { <EOL> val call = getFunctionCallOrNull ( statement ) ? : continue <EOL> val node = replacements . getRootMfvcNodeOrNull ( call . type . erasedUpperBound ) ? : continue <EOL> if ( node . boxMethod == call . symbol . owner && List ( call . valueArgumentsCount ) { call . getValueArgument ( it ) } . all { it . isRepeatableGetter ( ) } ) { <EOL> statementsToRemove . add ( statement ) <EOL> } <EOL> } <EOL> expression . statements . removeIf { it in statementsToRemove } <EOL> } <EOL> } , false ) <EOL> }

/**
 * Removes boxing when the result is not used
 */


private fun findNearestBlocksForVariables ( variables : Set < IrVariable > , body : BlockOrBody ) : Map < IrVariable , BlockOrBody ? >

{ <EOL> if ( variables . isEmpty ( ) ) return mapOf ( ) <EOL> val variableUsages = mutableMapOf < BlockOrBody , MutableSet < IrVariable > > ( ) <EOL> val childrenBlocks = mutableMapOf < BlockOrBody , MutableList < BlockOrBody > > ( ) <EOL> body . element . acceptVoid ( object : IrElementVisitorVoid { <EOL> private val stack = mutableListOf < BlockOrBody > ( ) <EOL> override fun visitElement ( element : IrElement ) { <EOL> element . acceptChildren ( this , null ) <EOL> } <EOL> override fun visitBody ( body : IrBody ) { <EOL> currentStackElement ( ) ? . let { childrenBlocks . getOrPut ( it ) { mutableListOf ( ) } . add ( BlockOrBody . Body ( body ) ) } <EOL> stack . add ( BlockOrBody . Body ( body ) ) <EOL> super . visitBody ( body ) <EOL> require ( stack . removeLast ( ) == BlockOrBody . Body ( body ) ) { "<STR_LIT>" } <EOL> } <EOL> override fun visitBlock ( expression : IrBlock ) { <EOL> if ( expression is IrInlinedFunctionBlock ) { <EOL> return super . visitBlock ( expression ) <EOL> } <EOL> currentStackElement ( ) ? . let { childrenBlocks . getOrPut ( it ) { mutableListOf ( ) } . add ( Block ( expression ) ) } <EOL> stack . add ( Block ( expression ) ) <EOL> super . visitBlock ( expression ) <EOL> require ( stack . removeLast ( ) == Block ( expression ) ) { "<STR_LIT>" } <EOL> } <EOL> private fun currentStackElement ( ) = stack . lastOrNull ( ) <EOL> override fun visitValueAccess ( expression : IrValueAccessExpression ) { <EOL> val valueDeclaration = expression . symbol . owner <EOL> if ( valueDeclaration is IrVariable && valueDeclaration in variables ) { <EOL> variableUsages . getOrPut ( currentStackElement ( ) ! ! ) { mutableSetOf ( ) } . add ( valueDeclaration ) <EOL> } <EOL> super . visitValueAccess ( expression ) <EOL> } <EOL> } ) <EOL> fun dfs ( currentBlock : BlockOrBody , variable : IrVariable ) : BlockOrBody ? { <EOL> if ( variable in ( variableUsages [ currentBlock ] ? : listOf ( ) ) ) return currentBlock <EOL> val childrenResult = childrenBlocks [ currentBlock ] ? . mapNotNull { dfs ( it , variable ) } ? : listOf ( ) <EOL> return when ( childrenResult . size ) { <EOL> <NUM_LIT:0> -> return null <EOL> <NUM_LIT:1> -> return childrenResult . single ( ) <EOL> else -> currentBlock <EOL> } <EOL> } <EOL> return variables . associateWith { dfs ( body , it ) } <EOL> }

/**
 * Finds the most narrow block or body which contains all usages of each of the given variables
 */


private fun BlockOrBody . makeBodyWithAddedVariables ( context : JvmBackendContext , variables : Set < IrVariable > , symbol : IrSymbol ) : IrElement

{ <EOL> if ( variables . isEmpty ( ) ) return element <EOL> extractVariablesSettersToOuterPossibleBlock ( variables ) <EOL> val nearestBlocks = findNearestBlocksForVariables ( variables , this ) <EOL> val containingVariables : Map < BlockOrBody , List < IrVariable > > = nearestBlocks . entries <EOL> . mapNotNull { ( k , v ) -> if ( v != null ) k to v else null } <EOL> . groupBy ( { ( _ , v ) -> v } , { ( k , _ ) -> k } ) <EOL> return element . transform ( object : IrElementTransformerVoid ( ) { <EOL> private fun getFirstInnerStatement ( statement : IrStatement ) : IrStatement ? = <EOL> if ( statement is IrStatementContainer ) statement . statements . first ( ) . let ( :: getFirstInnerStatement ) else statement <EOL> private fun removeFirstInnerStatement ( statement : IrStatement ) : IrStatement ? { <EOL> if ( statement !is IrStatementContainer ) return null <EOL> val innerResult = removeFirstInnerStatement ( statement . statements [ <NUM_LIT:0> ] ) <EOL> return when { <EOL> innerResult != null -> statement . also { statement . statements [ <NUM_LIT:0> ] = innerResult } <EOL> statement . statements . size > <NUM_LIT:1> -> statement . also { statement . statements . removeAt ( <NUM_LIT:0> ) } <EOL> else -> null <EOL> } <EOL> } <EOL> private fun IrStatement . removeInnerEmptyBlocks ( ) { <EOL> if ( this !is IrContainerExpression || statements . isEmpty ( ) ) return <EOL> val emptyBlocks = statements . mapNotNull { <EOL> it . removeInnerEmptyBlocks ( ) <EOL> if ( it is IrContainerExpression && it . statements . isEmpty ( ) ) it else null <EOL> } <EOL> statements . removeAll ( emptyBlocks ) <EOL> } <EOL> private fun replaceSetVariableWithInitialization ( variables : List < IrVariable > , container : IrStatementContainer ) { <EOL> require ( variables . all { it . initializer == null } ) { "<STR_LIT>" } <EOL> val variableFirstUsage = variables . associateWith { v -> container . statements . firstOrNull { it . containsUsagesOf ( setOf ( v ) ) } } <EOL> val variableDeclarationPerStatement = variableFirstUsage . entries <EOL> . mapNotNull { ( variable , firstUsage ) -> if ( firstUsage == null ) null else firstUsage to variable } <EOL> . groupBy ( { ( k , _ ) -> k } , { ( _ , v ) -> v } ) <EOL> if ( variableDeclarationPerStatement . isEmpty ( ) ) return <EOL> val newStatements = buildList { <EOL> for ( statement in container . statements ) { <EOL> statement . removeInnerEmptyBlocks ( ) <EOL> if ( statement is IrContainerExpression && statement . statements . isEmpty ( ) ) continue <EOL> val varsBefore = variableDeclarationPerStatement [ statement ] <EOL> if ( varsBefore != null ) { <EOL> addAll ( varsBefore ) <EOL> val innerStatement = getFirstInnerStatement ( statement ) <EOL> if ( innerStatement is IrSetValue ) { <EOL> val assignedVariable = innerStatement . symbol . owner <EOL> if ( assignedVariable is IrVariable && assignedVariable in varsBefore && assignedVariable . initializer == null ) { <EOL> assignedVariable . initializer = innerStatement . value <EOL> addIfNotNull ( removeFirstInnerStatement ( statement ) ) <EOL> continue <EOL> } <EOL> } <EOL> } <EOL> add ( statement ) <EOL> } <EOL> } <EOL> container . statements . replaceAll ( newStatements ) <EOL> } <EOL> override fun visitBlock ( expression : IrBlock ) : IrExpression { <EOL> containingVariables [ Block ( expression ) ] ? . let { <EOL> expression . transformChildrenVoid ( ) <EOL> replaceSetVariableWithInitialization ( it , expression ) <EOL> return expression <EOL> } <EOL> return super . visitBlock ( expression ) <EOL> } <EOL> override fun visitBlockBody ( body : IrBlockBody ) : IrBody { <EOL> containingVariables [ BlockOrBody . Body ( body ) ] ? . let { <EOL> body . transformChildrenVoid ( ) <EOL> replaceSetVariableWithInitialization ( it , body ) <EOL> return body <EOL> } <EOL> return super . visitBlockBody ( body ) <EOL> } <EOL> override fun visitExpressionBody ( body : IrExpressionBody ) : IrBody { <EOL> val lowering = this <EOL> containingVariables [ BlockOrBody . Body ( body ) ] ? . takeIf { it . isNotEmpty ( ) } ? . let { bodyVars -> <EOL> return with ( context . createJvmIrBuilder ( symbol ) ) { <EOL> val blockBody = irBlock { + body . expression . transform ( lowering , null ) } <EOL> replaceSetVariableWithInitialization ( bodyVars , blockBody ) <EOL> irExprBody ( blockBody ) <EOL> } <EOL> } <EOL> return super . visitExpressionBody ( body ) <EOL> } <EOL> } , null ) <EOL> }

/**
 * Adds declarations of the variables to the most narrow possible block or body.
 * It adds them before the first usage within the block and inlines initialization of them when possible.
 */


public fun < I > Operation < I , FloatData > . transpose ( sharpBlock : Transpose . ( ) -> Unit ) : Operation < I , FloatData >

{ <EOL> return PreprocessingPipeline ( this , Transpose ( ) . apply ( sharpBlock ) ) <EOL> }

/**
 * The DSL extension function for [Transpose] operation.
 */


internal expect fun < T > commonThreadLocal ( name : Symbol ) : CommonThreadLocal < T >

/**
 * Create a thread-local storage for an object of type [T].
 *
 * If two different thread-local objects share the same [name], they will not necessarily share the same value,
 * but they may.
 * Therefore, use a unique [name] for each thread-local object.
 */


override fun matches ( startIndex : Int , testString : CharSequence , matchResult : MatchResultImpl ) : Int

{ <EOL> val start = matchResult . getConsumed ( groupIndex ) <EOL> matchResult . setConsumed ( groupIndex , startIndex ) <EOL> children . forEach { <EOL> val shift = it . matches ( startIndex , testString , matchResult ) <EOL> if ( shift >= <NUM_LIT:0> ) { <EOL> return next . matches ( ( fSet as AtomicFSet ) . index , testString , matchResult ) <EOL> } <EOL> } <EOL> matchResult . setConsumed ( groupIndex , start ) <EOL> return - <NUM_LIT:1> <EOL> }

/** Returns startIndex+shift, the next position to match */


fun HTMLTag . unsafe ( block : Unsafe . ( ) -> Unit ) : Unit

= consumer . onTagContentUnsafe ( block )

/***
 * unsafe allows writing strings directly into the HTML DOM without any escaping.
 * In general, setting HTML without escaping is risky because it is easy to expose your users to a cross-site scripting (XSS) attack.
 * Consider using the builder DSL instead, or ensure that you are escaping the HTML properly.
 */


inline fun KtSourceElement . forEachChildOfType ( types : Set < IElementType > , depth : Int = - <NUM_LIT:1> , reverse : Boolean = false , processChild : ( KtSourceElement ) -> Unit , )

= when ( this ) { <EOL> is KtPsiSourceElement -> psi . forEachChildOfType ( types , depth , reverse ) { <EOL> processChild ( it . toKtPsiSourceElement ( ) ) <EOL> } <EOL> is KtLightSourceElement -> lighterASTNode . forEachChildOfType ( types , depth , reverse , treeStructure ) { <EOL> processChild ( it . toKtLightSourceElement ( treeStructure ) ) <EOL> } <EOL> }

/**
 * Iterates recursively over all children up to the given depth.
 * `processChild` is invoked for each child having a type in the `types` set.
 */


inline fun PsiElement . forEachChildOfType ( types : Set < IElementType > , depth : Int = - <NUM_LIT:1> , reverse : Boolean = false , processChild : ( PsiElement ) -> Unit , )

= forEachChildOfType ( this , types , depth , reverse , getElementType = { it . node . elementType } , getChildren = { it . allChildren . toList ( ) } , processChild , )

/**
 * See [KtSourceElement.forEachChildOfType]
 */


inline fun LighterASTNode . forEachChildOfType ( types : Set < IElementType > , depth : Int = - <NUM_LIT:1> , reverse : Boolean = false , treeStructure : FlyweightCapableTreeStructure < LighterASTNode > , processChild : ( LighterASTNode ) -> Unit , )

= forEachChildOfType ( this , types , depth , reverse , getElementType = { it . tokenType } , getChildren = { it . getChildren ( treeStructure ) } , processChild , )


internal fun KtLightSourceElement . buildChildSourceElement ( childNode : LighterASTNode ) : KtLightSourceElement

{ <EOL> val offsetDelta = startOffset - lighterASTNode . startOffset <EOL> return childNode . toKtLightSourceElement ( treeStructure , startOffset = childNode . startOffset + offsetDelta , endOffset = childNode . endOffset + offsetDelta ) <EOL> }

/**
 * Keeps 'padding' of parent node in child node
 */


fun FirImport . getSourceForImportSegment ( indexFromLast : Int ) : KtSourceElement ?

{ <EOL> var segmentSource : KtSourceElement = source ? : return null <EOL> repeat ( indexFromLast + <NUM_LIT:1> ) { <EOL> segmentSource = segmentSource . getChild ( IMPORT_PARENT_TOKEN_TYPES , depth = <NUM_LIT:1> ) ? : return null <EOL> } <EOL> return segmentSource . takeIf { it . elementType == KtNodeTypes . REFERENCE_EXPRESSION } <EOL> ? : segmentSource . getChild ( KtNodeTypes . REFERENCE_EXPRESSION , depth = <NUM_LIT:1> , reverse = true ) <EOL> }

/**
 * Returns a source element for the import segment that is [indexFromLast]th from last.
 */


fun FirImport . getLastImportedFqNameSegmentSource ( ) : KtSourceElement ?

= <EOL> source ? . getChild ( KtNodeTypes . REFERENCE_EXPRESSION , reverse = true )

/**
 * Looks for the source element of the last segment
 * of `importedFqName`.
 */


{ <EOL> runImageRecognitionPrediction ( modelType = TFModels . CV . Xception ( ) ) <EOL> }

/**
 * This example demonstrates the inference concept on Xception 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 Xception during training on ImageNet dataset) is applied to each image before prediction.
 *
 * NOTE: Input resolution is 299*299
 */


= xceptionPrediction ( )


fun cleanUp ( value : V ? )

/**
 * Cleans up after [value] has been removed from the cache or garbage-collected.
 *
 * [value] is non-null if it was removed from the cache and is still referable, or `null` if it has already been garbage-collected.
 */


= backingMap [ key ] ? . get ( )

/**
 * Returns a value for the given [key] if it exists in the map. **Must be called in a read action.**
 */


fun computeIfAbsent ( key : K , computeValue : ( K ) -> V ) : V

{ <EOL> get ( key ) ? . let { return it } <EOL> return compute ( key ) { _ , currentValue -> currentValue ? : computeValue ( key ) } <EOL> ? : error ( "<STR_LIT>" ) <EOL> }

/**
 * If [key] is currently absent, attempts to add a value computed by [computeValue] to the cache. [computeValue] is invoked exactly once
 * if [key] is present, and otherwise never. **Must be called in a read action.**
 *
 * [computeValue] should not modify the cache during computation.
 *
 * @return The already present or newly computed value associated with [key].
 */


fun compute ( key : K , computeValue : ( K , V ? ) -> V ? ) : V ?

{ <EOL> var newValue : V ? = null <EOL> var removedRef : SoftReferenceWithCleanup < K , V > ? = null <EOL> val newRef = backingMap . compute ( key ) { _ , currentRef -> <EOL> val currentValue = currentRef ? . get ( ) <EOL> newValue = computeValue ( key , currentValue ) <EOL> when { <EOL> newValue == null -> { <EOL> removedRef = currentRef <EOL> null <EOL> } <EOL> newValue === currentValue -> currentRef <EOL> else -> { <EOL> removedRef = currentRef <EOL> createSoftReference ( key , newValue ! ! ) <EOL> } <EOL> } <EOL> } <EOL> removedRef ? . performCleanup ( ) <EOL> processQueue ( ) <EOL> require ( newRef ? . get ( ) === newValue ) { <EOL> "<STR_LIT>" <EOL> } <EOL> return newValue <EOL> }

/**
 * Replaces the current value at [key] with a new value computed by [computeValue]. [computeValue] is invoked exactly once. **Must be
 * called in a read action.**
 *
 * If the cache already contains a value `v` at [key], cleanup will be performed on it, *unless* the result of the computation is
 * referentially equal to `v`. This behavior enables computation functions to decide to retain an existing value, without triggering
 * cleanup.
 *
 * [computeValue] should not modify the cache during computation.
 *
 * @return The computed value now associated with [key].
 */